ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# After Effects 3D Position only rotate

FAQ   •   VIEW ALL
 After Effects 3D Position only rotate on Jan 28, 2017 at 3:29:10 pm

Hi all,
trying to figure out a way to rotate layers around an axis in 3d without the actual layer itself rotating, but only taking in positional data from a null. Is there a way to do this? I guess I need to bake the positional data of the 3d null out from the rotation attribute so I can use it to parent the layer.

Imagine a solar system and I need to rotate flat planets around a sun in 3D so the faces of the planets are always facing the camera.

Any hints will be appreciated.

Thanks!

 Re: After Effects 3D Position only rotateon Jan 28, 2017 at 4:21:17 pm

apply this expression to the rotation property of your layer:
`-parent.rotation`

now the layer will not take into account the parented rotation information.

Roei Tzoref
After Effects Artist & Instructor
♫ Ae Blues Tutorials

 Re: After Effects 3D Position only rotateon Jan 28, 2017 at 4:38:25 pm

Thanks very simple, just invert the parameter!

I used:
-parent.transform.xRotation

Cheers

~~~~~~~~~~~~~~~~~~~~~~
△ As Above | So Below ▽

 Re: After Effects 3D Position only rotateon Jan 28, 2017 at 7:29:26 pm

Ok, when I try rotating more than one axis, this technique falls apart. Just inverting the rotation against the null doesn't seem to work.. I guess the math isnt right!

Any ideas?

Cheers

 Re: After Effects 3D Position only rotateon Jan 28, 2017 at 9:53:35 pm

Fantastic, found this incredible post here

`https://forums.creativecow.net/thread/227/24188#27547`

Apply this expression to your orientation and it will nullify any 3D rotation inherited from the parent.

Not entirely sure how it works though!

```u = fromWorldVec([1,0,0]); v = fromWorldVec([0,1,0]); w = fromWorldVec([0,0,1]); sinb = clamp(w[0],-1,1); b = Math.asin(sinb); cosb = Math.cos(b); if (Math.abs(cosb) > .0005){ c = -Math.atan2(v[0],u[0]); a = -Math.atan2(w[1],w[2]); }else{ a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]); c = 0; } [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]```

credit to Dan Ebberts

Cheers