I've got a component to animate to a position in front of the camera, but when it's a child of another object this is animating in the wrong direction (away from the camera) because it's using the world position in an entity.
I know it's because of world coordinates.. can anyone help tell me how to convert this world position into local coordinates?
pLocal= new THREE.Vector3(0, 0, -distX)
this._targetPosition = pLocal.applyMatrix4(this._threeCamera.matrixWorld)
I this example the box is a child of the sphere and animates away from the camera. https://jsfiddle.net/jpvsrnq1/2/
If the box is not a child it animates towards camera. https://jsfiddle.net/jpvsrnq1/3/
How do I make it animate to camera when it's a child of another object?