Skip to content

Commit

Permalink
super hack in vizi to get around object not being in corrct world spa…
Browse files Browse the repository at this point in the history
…ce first time render loop is run
  • Loading branch information
ericrius1 committed Oct 13, 2014
1 parent 1da74a9 commit 9e5db9e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions js/cloners/cloner.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ G.Cloner.prototype.spawnPrimitives = function(){




primitive.addEventListener('distancethreshold', function(){
this.appear()
}.bind(primitive));
Expand Down
9 changes: 3 additions & 6 deletions js/effectors/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ G.ScaleEffector = function(params) {
this.params.farScale = this.params.farScale || 1 //The scale of the object when it is at the far distance from the target object
this.params.nearScale = this.params.nearScale || 10 //The scale of the object when it's at the nearest distance to the target object
}


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



G.ScaleEffector.prototype.update = function() {

//Tony: For some reason I need to put updateMatrixWorld here for the first run through for object position to be correct... I should be able to put it at end of init
//Is it being reset somewhere within vizi before rendering?
// G.scene.updateMatrixWorld()


//bug with when matrix world is updated

var pos = new THREE.Vector3()
pos.setFromMatrixPosition(this._object.transform.object.matrixWorld);
var distance = pos.distanceTo(this.params.targetObject.transform.position);
console.log(distance)

if(distance < this.params.farDistance && distance > this.params.nearDistance){
console.log('scale')
Expand Down
2 changes: 0 additions & 2 deletions js/infoworld.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ InfoWorld.prototype.init = function(param) {

this._services[4].scene.fog = new THREE.Fog(0x00000, -4000, 80000)


var cloners = new G.ClonerManager();
// // G.scene.updateMatrixWorld()
//Should be able to just update matrix world oncee before we start rendering, because then threejs renderer automatically calls this every frame... something with vizi?

}
2 changes: 2 additions & 0 deletions lib/vizi.js
Original file line number Diff line number Diff line change
Expand Up @@ -53772,6 +53772,8 @@ Vizi.Application.prototype.focus = function() {
Vizi.Application.prototype.run = function() {
// core game loop here
this.realizeObjects();
//TONY: What is a better way to do this so the objects world pos it updated before I start running logic?
G.scene.updateMatrixWorld()
this.lastFrameTime = Date.now();
this.running = true;
this.runloop();
Expand Down

0 comments on commit 9e5db9e

Please sign in to comment.