Initially, I envisioned my small 'ship' with turrets that could track a target. This is the jfiddle I created to showcase it. You can view it here. However, when the turrets track, they behave strangely. I noticed that the turret seems to believe it is slightly off from its intended location (at the origin), as indicated by this piece of code:
turret_a.position.y = .25;
turret_a.position.z = 2;
The reason I set these values was to establish a relative position when adding the turret to the 'base ship', as shown in the following code snippet:
ship = new THREE.Object3D();
ship.add( ship_base );
ship.add( turret_a ) ;
Surprisingly, when I adjusted the position of turret_a after it was already added to the ship and the ship was included in the scene, the turret started to track in a way that aligned more closely with my vision.
My question pertains to why the lookAt() function appears to be using the previous location of the turret rather than its current position relative to its parent object when determining the necessary rotation angles. Why does this happen?