look at components rotates the offset towards the targets rotation
parent
8ddba38561
commit
cf57556a0b
|
@ -23,10 +23,11 @@ GameLib.D3.ComponentLookAt = function(
|
|||
};
|
||||
|
||||
|
||||
ComponentLookAt_rotatedTargetOffset = new THREE.Vector3();
|
||||
ComponentLookAt_currentPos = new THREE.Vector3();
|
||||
ComponentLookAt_targetPos = new THREE.Vector3();
|
||||
ComponentLookAt_upVector = new THREE.Vector3(0, 1, 0);
|
||||
ComponentLookAt_parentQuaternion = new THREE.Quaternion(0, 0, 0, 1);
|
||||
ComponentLookAt_targetQuaternion = new THREE.Quaternion(0, 0, 0, 1);
|
||||
ComponentLookAt_tmpQuaternion = new THREE.Quaternion(0, 0, 0, 1);
|
||||
ComponentLookAt_newRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1);
|
||||
ComponentLookAt_lastRotationQuaternion = new THREE.Quaternion(0, 0, 0, 1);
|
||||
|
@ -53,10 +54,28 @@ GameLib.D3.ComponentLookAt.prototype.onUpdate = function(
|
|||
this.lastTargetQuaternion.w
|
||||
);
|
||||
|
||||
ComponentLookAt_rotatedTargetOffset.set(
|
||||
this.targetOffset.x,
|
||||
this.targetOffset.y,
|
||||
this.targetOffset.z
|
||||
);
|
||||
|
||||
ComponentLookAt_targetQuaternion.set(
|
||||
this.targetEntity.quaternion.x,
|
||||
this.targetEntity.quaternion.y,
|
||||
this.targetEntity.quaternion.z,
|
||||
this.targetEntity.quaternion.w
|
||||
);
|
||||
|
||||
ComponentLookAt_rotatedTargetOffset =
|
||||
ComponentLookAt_rotatedTargetOffset.applyQuaternion(
|
||||
ComponentLookAt_targetQuaternion
|
||||
);
|
||||
|
||||
ComponentLookAt_targetPos.set(
|
||||
target.x + this.targetOffset.x,
|
||||
target.y + this.targetOffset.y,
|
||||
target.z + this.targetOffset.z
|
||||
target.x + ComponentLookAt_rotatedTargetOffset.x,
|
||||
target.y + ComponentLookAt_rotatedTargetOffset.y,
|
||||
target.z + ComponentLookAt_rotatedTargetOffset.z
|
||||
);
|
||||
|
||||
ComponentLookAt_lookAtMatrix.lookAt(
|
||||
|
|
Loading…
Reference in New Issue