Just like how spot/direction light looks at it’s target and sprites look at camera , how can i make Mesh/Object3d/Group A look at Mesh/Object3d/Group B without adding any extra code in the animation loop as this object’s existence in the scene is optional and will controlled by the user
one method i found which works is to override the eye object’s updateMatrixWorld and call the eyeObject.lookAt(targetObject.position) there .
eg:
class EyeObject extends Object3d{
constructor() {
super()
this.target = new Object3d()
}
updateMatrixWorld(force) {
this.lookAt(this.target.position)
super.updateWorldMatrix(force)
}
}
Function lookAt resets rotation around local z axis, so it will only work if your eye is vertical, as in if it’s a snake eye, the pupil is vertical in the world space.
You can use Object.defineProperty to overwrite quaternion, I wouldn’t call it a better way, a better way is to use the animation loop
yesss , that seems easy and efficient to setup !
the doc says it only works for render-able mesh , need to confirm if it’ll work with Groups also
thanks!