Forum Replies Created

  • Felipe Griebel

    June 4, 2012 at 1:15 pm in reply to: Track the rotation of a child layer.

    Well, actually i found a solution walking to work(and thinking) this morning, and it was quite simple.

    I’ve added an Angle Control Effect to the target which i want to get the real rotation, and added the code below.

    If you want to put it on a 3D space, just make 3 copies of the Angle Control Effect and change “.rotation” to “.orientation[0]”, “.orientation[1]”, “.orientation[2]”.

    Basically it checks for every parent and sums up its rotations.

    result = effect("Angle Control")("Angle") + transform.rotation;
    parentStack = [];
    inheritance = true;

    if(thisLayer.hasParent)
    {
    parentStack.push(thisLayer.parent);
    while(inheritance)
    {
    if(parentStack[parentStack.length-1].hasParent)
    {
    parentStack.push(parentStack[parentStack.length-1].parent);
    }else{
    inheritance = false;
    }
    }
    for(var i = 0, l = parentStack.length ; i<l;i++)
    {
    result += parentStack[i].rotation;
    }
    }
    result

  • Felipe Griebel

    June 1, 2012 at 9:43 pm in reply to: Track the rotation of a child layer.

    I’m looking for that answer too. Let me add a few details about this issue:
    if there is just one level of parenting, like A parented to B, you could just take A’s coordinates by toWorld() or toComp() and B’s rotation.

    but the real problem starts when there are more levels, like A parented to B, parented to C… parented to N. Cause then we would have to get every layer rotation.

    I’m looking instead of doing this massive process, just get the A’s rotation by doing something like toWorld() that returns the relative value of that property.

    Thanks

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