normalize camera quat, entity parent uses a static tmpvector for it's calculations.
todo: we have a huge memory issue. 700mb on the heap.beta.r3js.org
parent
563f18fc99
commit
bc27db190d
|
@ -1 +1,2 @@
|
||||||
//#define EDITOR__
|
//#define EDITOR__
|
||||||
|
//#define DEBUG__
|
|
@ -1 +1,2 @@
|
||||||
//#define RUNTIME__
|
//#define RUNTIME__
|
||||||
|
//#define DEBUG__
|
|
@ -37,6 +37,11 @@ GameLib.D3.ComponentCamera.prototype.onLateUpdate = function(
|
||||||
deltaTime,
|
deltaTime,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
this.camera.quaternion.copy(parentEntity.quaternion);
|
this.camera.quaternion.copy(parentEntity.quaternion).normalize();
|
||||||
this.camera.position.copy(parentEntity.position);
|
this.camera.position.copy(parentEntity.position);
|
||||||
|
|
||||||
|
parentEntity.quaternion.x = this.camera.quaternion.x;
|
||||||
|
parentEntity.quaternion.y = this.camera.quaternion.y;
|
||||||
|
parentEntity.quaternion.z = this.camera.quaternion.z;
|
||||||
|
parentEntity.quaternion.w = this.camera.quaternion.w;
|
||||||
};
|
};
|
|
@ -27,6 +27,12 @@ GameLib.D3.ComponentEntityParent = function ComponentEntityParent(
|
||||||
};
|
};
|
||||||
|
|
||||||
//#ifdef RUNTIME__
|
//#ifdef RUNTIME__
|
||||||
|
|
||||||
|
if(typeof THREE != "undefined") {
|
||||||
|
ComponentEntityParent_TmpVector = new THREE.Vector3();
|
||||||
|
ComponentEntityParent_TmpQuaternion = new THREE.Vector3();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////// Methods to override //////////////////////////
|
///////////////////////// Methods to override //////////////////////////
|
||||||
GameLib.D3.ComponentEntityParent.prototype.onLateUpdate = function(
|
GameLib.D3.ComponentEntityParent.prototype.onLateUpdate = function(
|
||||||
deltaTime,
|
deltaTime,
|
||||||
|
@ -43,22 +49,25 @@ GameLib.D3.ComponentEntityParent.prototype.onLateUpdate = function(
|
||||||
// apply quaternion
|
// apply quaternion
|
||||||
//
|
//
|
||||||
|
|
||||||
var tmpVector = new THREE.Vector3(
|
ComponentEntityParent_TmpQuaternion.set(
|
||||||
|
this.parent.quaternion.x,
|
||||||
|
this.parent.quaternion.y,
|
||||||
|
this.parent.quaternion.z,
|
||||||
|
this.parent.quaternion.w
|
||||||
|
);
|
||||||
|
|
||||||
|
ComponentEntityParent_TmpVector =
|
||||||
|
ComponentEntityParent_TmpVector.set(
|
||||||
this.parentEntity.position.x,
|
this.parentEntity.position.x,
|
||||||
this.parentEntity.position.y,
|
this.parentEntity.position.y,
|
||||||
this.parentEntity.position.z
|
this.parentEntity.position.z
|
||||||
).applyQuaternion(
|
).applyQuaternion(
|
||||||
new THREE.Quaternion(
|
ComponentEntityParent_TmpQuaternion
|
||||||
this.parent.quaternion.x,
|
|
||||||
this.parent.quaternion.y,
|
|
||||||
this.parent.quaternion.z,
|
|
||||||
this.parent.quaternion.w
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.parentEntity.position.x = tmpVector.x + this.parent.position.x;
|
this.parentEntity.position.x = ComponentEntityParent_TmpVector.x + this.parent.position.x;
|
||||||
this.parentEntity.position.y = tmpVector.y + this.parent.position.y;
|
this.parentEntity.position.y = ComponentEntityParent_TmpVector.y + this.parent.position.y;
|
||||||
this.parentEntity.position.z = tmpVector.z + this.parent.position.z;
|
this.parentEntity.position.z = ComponentEntityParent_TmpVector.z + this.parent.position.z;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.parentEntity.position.x = this.parent.position.x;
|
this.parentEntity.position.x = this.parent.position.x;
|
||||||
|
@ -76,21 +85,6 @@ GameLib.D3.ComponentEntityParent.prototype.onLateUpdate = function(
|
||||||
this.parentEntity.scale.z = this.parent.scale.z;
|
this.parentEntity.scale.z = this.parent.scale.z;
|
||||||
|
|
||||||
this.parentEntity.mesh.updateMatrix();
|
this.parentEntity.mesh.updateMatrix();
|
||||||
|
|
||||||
/*//
|
|
||||||
this.parentEntity.mesh.position.x = this.parentEntity.position.x;
|
|
||||||
this.parentEntity.mesh.position.y = this.parentEntity.position.y;
|
|
||||||
this.parentEntity.mesh.position.z = this.parentEntity.position.z;
|
|
||||||
|
|
||||||
this.parentEntity.mesh.quaternion.x = this.parentEntity.quaternion.x;
|
|
||||||
this.parentEntity.mesh.quaternion.y = this.parentEntity.quaternion.y;
|
|
||||||
this.parentEntity.mesh.quaternion.z = this.parentEntity.quaternion.z;
|
|
||||||
this.parentEntity.mesh.quaternion.w = this.parentEntity.quaternion.w;
|
|
||||||
|
|
||||||
this.parentEntity.mesh.scale.x = this.parentEntity.scale.x;
|
|
||||||
this.parentEntity.mesh.scale.y = this.parentEntity.scale.y;
|
|
||||||
this.parentEntity.mesh.scale.z = this.parentEntity.scale.z;*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ GameLib.D3.ComponentPathAI.prototype.onUpdate = function(
|
||||||
// - - -- - - - - -- - - - - - - - - - - - - - -
|
// - - -- - - - - -- - - - - - - - - - - - - - -
|
||||||
// D E B U G G I N G
|
// D E B U G G I N G
|
||||||
// - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - -
|
||||||
|
//#ifdef DEBUG__
|
||||||
if(this.sensorVisualizer) {
|
if(this.sensorVisualizer) {
|
||||||
|
|
||||||
for(var i = 0, l = this.sensors.length; i < l; ++i) {
|
for(var i = 0, l = this.sensors.length; i < l; ++i) {
|
||||||
|
@ -141,6 +142,7 @@ GameLib.D3.ComponentPathAI.prototype.onUpdate = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue