-
Notifications
You must be signed in to change notification settings - Fork 425
Closed
Description
I tried updating look-at dynamically with some values I was getting. It didn't work, so I had to jump in a bit.
I found out that removing the current target3D, then calling setAttribute('look-at', ...) worked:
_location_apex_1 = document.getElementById('apex_1').object3D.getWorldPosition();
location_apex_1 = _location_apex_1.x + " " + _location_apex_1.y + " " + _location_apex_1.z
airplane.components['look-at'].target3D = ''
airplane.setAttribute('look-at', location_apex_1);
But something was off, the rotation was not right. I looked at the component, and saw that for object following, there was another manipulation of the coordinates/vector before using, so I tried that as well:
Line 106-108:
if (typeof target === 'object') {
return object3D.lookAt(new THREE.Vector3(target.x, target.y, target.z));
}
were replaced with:
if (typeof target === 'object') {
var vector = new THREE.Vector3(target.x, target.y, target.z);
object3D.parent.worldToLocal(vector);
return object3D.lookAt(vector);
}
This now correctly updates my airplane to look at the correct coordinates.
Does this make sense or did I find a strange special case here?
Metadata
Metadata
Assignees
Labels
No labels