Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Error when using toWorldVec when scale is 0

  • Error when using toWorldVec when scale is 0

    Posted by Simon Bjork on October 7, 2022 at 1:39 pm

    I’m using toWorldVec to extract the rotation/scale matrix from a 3d layer, but it seems like this expression breaks when scale is 0. Is there a way around this without changing the actual value of the layer?

    Example:

    thisComp.layer(2).toWorldVec([1,0,0])
    // returns an error if the scale is 0 on any axis.
    Simon Bjork replied 3 years, 11 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    October 7, 2022 at 2:25 pm

    Possibly, depending on what you want to happen. You could encase the toWorldVec() in a try/catch clause, but then you have to decide what you want the result to be in that case:

    try{
    thisComp.layer(2).toWorldVec([1,0,0])
    }catch(e){
    [1,0,0]
    }

    Or maybe you could have an invisible layer that isn’t scaled parented to the layer that is scaled and get the x vector from the one that isn’t scaled. It depends on what your situation is.

  • Simon Bjork

    October 7, 2022 at 3:16 pm

    Thanks for the reply Dan.

    Yes, that would work. But as the toWorlVec is both rotation and scale, I guess rotation is lost as well in that case?

    I’m exporting objects to other applications and therefore I need to extract the world matrix of objects.

  • Dan Ebberts

    October 7, 2022 at 4:11 pm

    I’m guessing the math behind toWorldVec just doesn’t work if scale is zero. So at that point maybe rotation has no meaning? I’m not sure.

  • Simon Bjork

    October 7, 2022 at 6:13 pm

    Yes, I think so too. It would have been nice if it internally changed 0 to 0.0001 or something. I guess the only way around this is to build the matrices from scratch manually.

    Or just alert the user if the scale is 0.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy