-
Controlling 3D Layer Y rotation with Ramp
I lifted this code from ECAbrams on Youtube:
sourceLayer = thisComp.layer("Transition Control 2");
sampleSize = [1,1];
samplePoint = transform.position;
colour = sourceLayer.sampleImage(samplePoint,sampleSize);
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.positionbecause I run into an error atcolour = 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.