Copy link to clipboard
Copied
So to start with, I've got this from way back when:
L = thisComp.layer("Layer 2/Mouse Cursor.ai");
p = L.transform.position;
sampleImage(p,[.5,.5],true)[3] > 0 ? 100 : 0
It's from an old project, which emulated the Windows GUI and governed the mouse-hover effects (when the mouse cursor was over something it would become visible just like in Windows).
I'm looking to do something similar now but I can't figure out how to do it. Basically, I've got a path that draws a line through a scene courtesy a Trim Paths property, with dots marking vertices in the path (so anytime the path turns, there's a dot to mark it). What I'm looking to do is for the dots to sample the path layer, and when the path becomes visible beneath them, for the dots themselves to become visible.
I know SampleImage is the key to making it work, but I can't figure out how to go about it.
I feel like this is close (applied to the Opacity property of one of the "dot" layers):
target = thisComp.layer("Shape Layer 1");
target.sampleImage([transform.xPosition,transform.yPosition], [5,5], true) > 100 ? 0 : 0
As best I understand it, it's telling AE to sample Shape Layer 1, and when it becomes visible at the coordinates of the dot itself, plus or minus 5 pixels, then it becomes visible...but it's not working.
Can anybody help me straighten this out?
EDIT: it's a 3D scene using the Classic 3D renderer if that makes a difference
I haven't been able to crack this. I can get a vanilla 3D setup to work with this expression:
target = thisComp.layer("Shape Layer 1");
p = toComp(anchorPoint);
target.sampleImage([p[0],p[1]], [5,5], true)[3] > 0 ? 100 : 0
But things get wonky when you introduce z separation and camera angles. I'm confident that it all makes sense if you spend the time to work it out, but I don't have a ready answer for you.
Copy link to clipboard
Copied
Try it this way. It might work, depending on how you have the anchor points set up:
target = thisComp.layer("Shape Layer 1");
target.sampleImage([transform.xPosition,transform.yPosition], [5,5], true)[3] > 0 ? 100 : 0
Copy link to clipboard
Copied
Unfortunately no luck...I'm thinking the 3D piece of this may be the reason; even though it's just the Classic 3D renderer, looks like they don't play well together. I tried giving it a third coordinate for the Z axis but it doesn't look like SampleImage will accept the third coordinate.
Copy link to clipboard
Copied
Any chance you could post a trimmed-down version of the project file?
Copy link to clipboard
Copied
Any chance you could post a trimmed-down version of the project file?
By @Dan Ebberts
Here you are sir. This is just the one graphic that I'm developing, but if we can solve the problem here then I can apply it elsewhere. This version doesn't include the expression on the opacity properties, I just settled for making them visible by hand; the layers I'm trying to configure to appear automatically are the "Timeline Dot" layers.
Copy link to clipboard
Copied
I haven't been able to crack this. I can get a vanilla 3D setup to work with this expression:
target = thisComp.layer("Shape Layer 1");
p = toComp(anchorPoint);
target.sampleImage([p[0],p[1]], [5,5], true)[3] > 0 ? 100 : 0
But things get wonky when you introduce z separation and camera angles. I'm confident that it all makes sense if you spend the time to work it out, but I don't have a ready answer for you.
Copy link to clipboard
Copied
No worries, we tried and that's what counts! I can live with doing it the manual way. Thanks for trying though!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now