Skip to content

Commit

Permalink
Realize fix and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tparisi committed Oct 16, 2014
1 parent 17f8f6c commit f4173e3
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 39 deletions.
31 changes: 15 additions & 16 deletions js/cloners/cloner.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
G.Cloner = function(params){
var obj = new Vizi.Object;

obj.addComponent(new G.ClonerScript(params, obj));
obj.addComponent(new G.ClonerScript(params));

return obj;
}

G.ClonerScript = function(params, obj){
G.ClonerScript = function(params){
Vizi.Script.call(this)
this.params = params;
obj.transform.position.copy(this.params.position)
}


goog.inherits(G.ClonerScript, Vizi.Script);

G.ClonerScript.prototype.realize = function(){

Vizi.Script.prototype.realize.call(this);

this._object.transform.position.copy(this.params.position)
this.params.posRange = this.params.posRange || {x: {start: 0, end: 0}, y: {start: 0, end: 0}, z:{start: 0, end: 0 }}
this.params.scaleRange = this.params.scaleRange || {x: {start: 1, end: 1}, y: {start: 1, end: 1}, z:{start: 1, end: 1 }}
this.params.rotRange = this.params.rotRange || {start: 0, end: 0}
Expand All @@ -18,30 +27,20 @@ G.ClonerScript = function(params, obj){
//we only want to wait to spawn the primitives and show them if we've specified a visibility effector, otherwise show them right away
if(!this.params.visibilityEffector){

this.spawnPrimitives(obj);
this.spawnPrimitives();
}

this.spawnPrimitives(obj);
}

goog.inherits(G.ClonerScript, Vizi.Script)

G.ClonerScript.prototype.realize = function(){

Vizi.Script.prototype.realize.call(this);

}

G.ClonerScript.prototype.update = function(){
}

G.ClonerScript.prototype.spawnPrimitives = function(obj){
G.ClonerScript.prototype.spawnPrimitives = function(){
for(var i = 0; i < this.params.num; i++){
var primitive = this.params.primitive(this.params);
primitive.transform.position.set(G.rf(this.params.posRange.x.start, this.params.posRange.x.end), G.rf(this.params.posRange.y.start, this.params.posRange.y.end), G.rf(this.params.posRange.z.start, this.params.posRange.z.end));
primitive.transform.scale.set(G.rf(this.params.scaleRange.x.start, this.params.scaleRange.x.end), G.rf(this.params.scaleRange.y.start, this.params.scaleRange.y.end),G.rf(this.params.scaleRange.z.start, this.params.scaleRange.z.end));
primitive.transform.rotation.set(0, G.rf(this.params.rotRange.start, this.params.rotRange.end), 0)
obj.addChild(primitive);
this._object.addChild(primitive);
_.each(this.params.primitiveEffectors, function(effector){
if(effector === G.visibilityEffector){
this.primitiveVis = true;
Expand Down
20 changes: 12 additions & 8 deletions js/cloners/curvedotprimitive.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
G.CurveDotPrimitive = function(params) {
var obj = new Vizi.Object;

var script = new G.CurveDotPrimitiveScript(params, obj);
var script = new G.CurveDotPrimitiveScript(params);
obj.addComponent(script);

return obj;
}

G.CurveDotPrimitiveScript = function(params, obj) {
G.CurveDotPrimitiveScript = function(params) {
Vizi.Script.call(this);

this.visible = false;
this.shown = false;
}


goog.inherits(G.CurveDotPrimitiveScript, Vizi.Script);

G.CurveDotPrimitiveScript.prototype.realize = function() {

this.subdivisions = 100
this.dotScale = 0.01;
this.percentFullScale = .1 // dot will be full scale by 10% of curve
Expand Down Expand Up @@ -52,7 +61,7 @@ G.CurveDotPrimitiveScript = function(params, obj) {
var visual = new Vizi.Visual({
object: this.strand
});
obj.addComponent(visual);
this._object.addComponent(visual);

this.dot = new Vizi.Object();
visual = new Vizi.Visual({
Expand All @@ -64,13 +73,8 @@ G.CurveDotPrimitiveScript = function(params, obj) {


this.strand.material.attributes.opacity.needsUpdate = true

this.visible = false;
this.shown = false;
}

goog.inherits(G.CurveDotPrimitiveScript, Vizi.Script);

G.CurveDotPrimitiveScript.prototype.update = function() {
if (this.visible && !this.shown) {
this.growStrand(0);
Expand Down
9 changes: 7 additions & 2 deletions js/cloners/fresnalprimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ G.FresnalPrimitive = function(params) {
G.FresnalPrimitiveScript = function(params, obj) {
Vizi.Script.call(this, params);
this.params = params;
}

goog.inherits(G.FresnalPrimitiveScript, Vizi.Script);

G.FresnalPrimitiveScript.prototype.realize = function() {

this._dTheta = 0.01;
this._material = new THREE.PointCloudMaterial({
Expand Down Expand Up @@ -55,11 +60,11 @@ G.FresnalPrimitiveScript = function(params, obj) {
object: pCloud
})

obj.addComponent(visual);
this._object.addComponent(visual);

}

goog.inherits(G.FresnalPrimitiveScript, Vizi.Script)


G.FresnalPrimitiveScript.prototype.update = function() {
}
Expand Down
15 changes: 9 additions & 6 deletions js/cloners/tracerprimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ G.TracerPrimitiveScript = function(params, obj) {
Vizi.Script.call(this, params);
this.params = params;

this.visible = false;
this.shown = false;
}

goog.inherits(G.TracerPrimitiveScript, Vizi.Script);

G.TracerPrimitiveScript.prototype.realize = function() {

this._numSteps = 100;
this._step = 1 / this._numSteps;
this.strandMat = new THREE.ShaderMaterial({
Expand Down Expand Up @@ -61,15 +69,10 @@ G.TracerPrimitiveScript = function(params, obj) {
var visual = new Vizi.Visual({
object: strand
});
obj.addComponent(visual);
this._object.addComponent(visual);
strand.material.attributes.opacity.needsUpdate = true;

this.visible = false;
this.shown = false;
}

goog.inherits(G.TracerPrimitiveScript, Vizi.Script);

G.TracerPrimitiveScript.prototype.update = function() {
if (this.visible && !this.shown) {
this.growStrand(0);
Expand Down
5 changes: 3 additions & 2 deletions js/infoworld.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ InfoWorld.prototype.init = function(param) {
cam.active = true;
G.dolly.addChild(camera);

var effect = new Vizi.Effect(new THREE.BloomPass(2));
Vizi.Graphics.instance.addEffect(effect);
var effect = new Vizi.Effect(new THREE.BloomPass(1));
// Vizi.Graphics.instance.addEffect(effect);


this.controller = Vizi.Prefabs.ModelController({
Expand All @@ -110,6 +110,7 @@ InfoWorld.prototype.init = function(param) {

if (parameters.mode === 'cardboard') {
// effect = new THREE.StereoEffect(G.renderer);
alert("Cardboard");

} else {

Expand Down
Loading

0 comments on commit f4173e3

Please sign in to comment.