Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Controlling 3D Layer Y rotation with Ramp

  • Controlling 3D Layer Y rotation with Ramp

    Posted by Scott Smith on April 22, 2015 at 1:50 pm

    I lifted this code from ECAbrams on Youtube:

    sourceLayer = thisComp.layer("Transition Control 2");
    sampleSize = [1,1];
    samplePoint = transform.position;
    colour = sourceLayer.sampleImage(samplePoint,samp­leSize);
    x=colour[0]*100;
    [x,x]

    What it does is use the source layer Transition Control 2’s color, evaluates the color, and picks a scale size to match that color. Here’s the video: https://www.youtube.com/watch?v=4OQN2mHQuD0

    So I modified it a bit but I’ve run into a problem. Here’s the code first:

    sourceLayer = thisComp.layer("control");
    sampleSize = [1,1];

    colour = sourceLayer.sampleImage(sampleSize);
    x=colour[0]*360;
    [x]

    This had to be modified otherwise I run into errors. I’m applying it to a 3D layer to control Y rotation so I can do a card flip animation with a gradient ramp.

    The Y does rotate but I can’t use the variable samplePoint = transform.position because I run into an error at colour = sourceLayer.sampleImage(sampleSize,samplePoint)

    Now I imagine this is because I’m using a 3D layer and sampling a 2D image and that’s the reason I can’t sample the transform.position.

    Anyone see a good way around this? Right now all I can think is to duplicate each layer, hide them, and then pick whip the Y rotation of the visible objects to the duplicates’ scale, and use the above code so that the ramp controls the scale which in turn will control the visible Y rotation. But I was hoping just a few lines of code would be easier :).

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    Joshua Russell replied 11 years ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 22, 2015 at 3:40 pm

    What is it that you’re trying to do exactly?

    Dan

  • Joshua Russell

    April 27, 2015 at 9:52 pm

    I needed to replicate this in a project I was working on today. The issue is that you are pulling your 3d layer’s position, which is an array containing 3 numbers, and putting it into a function that can only accept 2 numbers. Check out the attached expression code for a workaround.

    Notice we are filling “samplePoint” with the x and y position values. This may not be the best way to do it but it works.

    sourceLayer = thisComp.layer("control")
    sampleSize = [1,1];
    samplePoint = [transform.position[0], transform.position[1]];
    colour= sourceLayer.sampleImage(samplePoint, sampleSize);
    x=colour[0]*360;
    [x]

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