reusing vars inside mesh permutation component
parent
32afbd1abb
commit
de5961456f
|
@ -15,6 +15,15 @@ GameLib.D3.ComponentMeshPermutation = function(
|
||||||
GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
GameLib.D3.Utils.Extend(GameLib.D3.ComponentMeshPermutation, GameLib.D3.ComponentInterface);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ComponentMeshPermutation_quaternion = new THREE.Quaternion();
|
||||||
|
ComponentMeshPermutation_quaternionCopy = new THREE.Quaternion();
|
||||||
|
ComponentMeshPermutation_position = new THREE.Vector3();
|
||||||
|
ComponentMeshPermutation_scale = new THREE.Vector3();
|
||||||
|
|
||||||
|
ComponentMeshPermutation_offsetQuaternion = new THREE.Quaternion();
|
||||||
|
ComponentMeshPermutation_offsetPosition = new THREE.Vector3();
|
||||||
|
ComponentMeshPermutation_offsetScale = new THREE.Vector3();
|
||||||
|
|
||||||
///////////////////////// Methods to override //////////////////////////
|
///////////////////////// Methods to override //////////////////////////
|
||||||
GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function(
|
GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function(
|
||||||
deltaTime,
|
deltaTime,
|
||||||
|
@ -22,31 +31,23 @@ GameLib.D3.ComponentMeshPermutation.prototype.onLateUpdate = function(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if(parentEntity && parentEntity.mesh) {
|
if(parentEntity && parentEntity.mesh) {
|
||||||
var quaternion = new THREE.Quaternion();
|
ComponentMeshPermutation_quaternion.copy(parentEntity.mesh.quaternion);
|
||||||
quaternion.copy(parentEntity.mesh.quaternion);
|
ComponentMeshPermutation_quaternionCopy.copy(ComponentMeshPermutation_quaternion);
|
||||||
|
ComponentMeshPermutation_position.copy(parentEntity.mesh.position);
|
||||||
|
|
||||||
var quaternionCopy = quaternion.clone();
|
ComponentMeshPermutation_offsetQuaternion.copy(this.quaternionOffset);
|
||||||
|
ComponentMeshPermutation_quaternion = ComponentMeshPermutation_quaternion.multiply(ComponentMeshPermutation_offsetQuaternion).normalize();
|
||||||
|
|
||||||
var position = new THREE.Vector3();
|
ComponentMeshPermutation_offsetPosition.copy(this.positionOffset);
|
||||||
position.copy(parentEntity.mesh.position);
|
ComponentMeshPermutation_position = ComponentMeshPermutation_position.add(ComponentMeshPermutation_offsetPosition.applyQuaternion(ComponentMeshPermutation_quaternionCopy));
|
||||||
|
|
||||||
var offsetQuaternion = new THREE.Quaternion();
|
ComponentMeshPermutation_scale.copy(parentEntity.mesh.scale);
|
||||||
offsetQuaternion.copy(this.quaternionOffset);
|
|
||||||
quaternion = quaternion.multiply(offsetQuaternion).normalize();
|
|
||||||
|
|
||||||
var offsetPosition = new THREE.Vector3();
|
ComponentMeshPermutation_offsetScale.copy(this.scaleOffset);
|
||||||
offsetPosition.copy(this.positionOffset);
|
ComponentMeshPermutation_scale = ComponentMeshPermutation_scale.add(ComponentMeshPermutation_offsetScale);
|
||||||
position = position.add(offsetPosition.applyQuaternion(quaternionCopy));
|
|
||||||
|
|
||||||
var scale = new THREE.Vector3();
|
parentEntity.mesh.position.copy(ComponentMeshPermutation_position);
|
||||||
scale.copy(parentEntity.mesh.scale);
|
parentEntity.mesh.quaternion.copy(ComponentMeshPermutation_quaternion);
|
||||||
|
parentEntity.mesh.scale.copy(ComponentMeshPermutation_scale);
|
||||||
var scaleOffset = new THREE.Vector3();
|
|
||||||
scaleOffset.copy(this.scaleOffset);
|
|
||||||
scale = scale.add(scaleOffset);
|
|
||||||
|
|
||||||
parentEntity.mesh.position.copy(position);
|
|
||||||
parentEntity.mesh.quaternion.copy(quaternion);
|
|
||||||
parentEntity.mesh.scale.copy(scale);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue