Setting a node's orientation so that it faces camera - without using Billboarding?

An object’s pose in 3D is represented by position and orientation. I would like to set a plane’s orientation so that it faces the camera - however, I don’t wish to use Billboarding.

The reasoning for this is simple - once a button is clicked, I would like the planes in my scene to face the camera and then I perform some operations on them. Once the operations are done, I would like the planes to maintain the orientation when the button was pushed. Namely, I don’t wish the planes to reorient themselves once I pan around the scene, hence no billboarding.

If the user clicks again on the same button - the planes reorient themselves and face the camera.

I am having difficulties achieving this and don’t even know where to start in Babylon JS - rotation, absoluteRotationQuaternion do not give me the orientation as expressed in world coordinates.

counteract rotation
https://playground.babylonjs.com/#YQP1LC
(press ‘space’ to make pl faces to cam)

4 Likes

You can also use quaternions to do the same thing:

plane.rotationQuaternion = scene.activeCamera.absoluteRotation;

https://playground.babylonjs.com/#YQP1LC#2

5 Likes

I unfortunately cannot vote for 2 solutions.

1 Like

Quaternions always win ! :slight_smile:

1 Like

Actually there are 3. TransformNode.lookAt()

2 Likes