lookAt method
Directly rotates the entity so it faces the given target position.
Implementation
GameEntity lookAt(Vector3 target ) {
final parent = this.parent;
if ( parent != null ) {
getWorldPosition( positionWorld );
targetDirection.subVectors( target, positionWorld ).normalize();
rotation.lookAt( forward, targetDirection, up );
quaternionWorld.extractRotationFromMatrix( parent.worldMatrix() ).inverse();
rotation.premultiply( quaternionWorld );
}
else {
targetDirection.subVectors( target, position ).normalize();
rotation.lookAt( forward, targetDirection, up );
}
return this;
}