Orientate line curve to face the camera, with Geometry Nodes

Hi there!

I got stuck at the following problem, which I believe shall be easy. I need a Curve Line to have its normal to point to the camera (so that when I use the Curve Line as a profile to curve to mesh, the geometry will be facing the camera as if it was flat). And I have not found a way to actually do this!

I also tested creating a line, that connects the camera with the center of a bounding box of the curve object, which will turn into a mesh, using the Curve Line as a profile, but also there I got stuck, unable to copy its vector to adjust the Curve Line’s rotation.

I want to use this to generate flat geometry (animation trails) that will have its faces oriented to the camera at any time.

Thank you for your help!

Use Set Curve Tilt and resample the curve if it’s not a line to not have wild twists:

Arctan2 - you give it rise and run and it gives back the angle in range -π to π… preferable to Arcsine and Arccosine since those only work in the range -π/2 to π/2.

Good luck!

3 Likes

You are a hero!

Many thanks. And also, this is a great look into the Cross and Dot Product maths used in the example.

Yeah, just remember that crossing the tangent with the normal gives the local “up” vector and those 3 vectors (normal, tangent and up) are all orthogonal and define the basis coordinate frame for any given point on a curve… and a lot of things should make more sense.

Good luck!

I copied your example and it’s not working yet, but I will take it slowly step by step and try to visualise the calculations to see where it’s going wrong. Right now, it’s actually breaking the profile line as if it had three vertices, while it still has just two…

But that might be some of the other parts of the node tree, causing this, so I have to go through it properly haha

Looks like your profile line cuve has a Z component.

Should only have an X component… (Profile X is along Normal and Y along local “up”). My math sets the X component to face the camera.

Here the camera has been animated… Viewport has camera focus. Press space to see curve aligning to camera.
curve tilt to direction.blend (88.5 KB)

2 Likes

Thank you for sharing the source.

nd yes, I had the curve aligned with the Z axis. Good eye!