Russell Strauss
Russell Strauss

Reputation: 1200

Make mesh parallel to xy-plane in Three.js

I have some serious refreshing to do with my CG fundamentals. How can I make a mesh (flat geometry), let's just say a circle, parallel to the xy-plane?

For example, similar to

circleMesh.lookAt(camera.position);

where camera is at position (0, 0, 50), but instead of having a circle tilt toward the camera when it is off to the left or right, I want it to be normal to the direction the camera is facing, perfectly parallel to xy-plane.

Upvotes: 0

Views: 887

Answers (1)

WestLangley
WestLangley

Reputation: 104823

Setting

mesh.quaternion.copy( camera.quaternion );

will orient the mesh so its local z-axis is parallel to the local z-axis of the camera.

This assumes neither the mesh, nor the camera, have a rotated parent.

three.js r.84

Upvotes: 1

Related Questions