ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Controlling z axis in layer to bring image to front of the rest

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mark Mitchell
Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 4:23:21 pm

I have 8 layers and I currently have them scaling up as they are passed across like Apple Doc. The issue is as they scale because of the layer order parts of the graphics are hidden beneath the layer objects on either side. So, I need to be able to bring the layers Z axis forward each time it is passed across. I have tried Dan Ebberts script attached but this only works with 1 layer, I am guessing I am missing a parameter in the script to adjust for each layer it's applied to? Any Help would be great - Dan, if you see this please respond. I've attached an example image demonstrating the problem.



below = 0;
for (i = 1; i &lt;= thisComp.numLayers; i++){
if (i == index) continue;
if (thisComp.layer(i).position[1] &lt; value[1]) below--;
}
[value[0],value[1],below]


Regards

Mark


Return to posts index

Dan Ebberts
Re: Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 6:46:48 pm

What does your scale expression look like?


Dan



Return to posts index

Mark Mitchell
Re: Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 6:49:11 pm

Hi Dan,
Here is the expression -

// Scale with control layer
// Applied to scale parameter

// Point1 is current layer, point2 is control layer
point1=thisLayer.position;
point2=thisComp.layer("Drag Me").position;

// Find the vector between the 2 points
delta=sub(point1, point2);

// Now find the length
distance=length(delta);

//Remap distance to large scale when near, small when far
linear(distance, 0, 100, [250,250], [75,75]);



Regards

Mark


Return to posts index


Dan Ebberts
Re: Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 7:06:27 pm

Something like this should work:


L = thisComp.layer("Drag Me");
point2= L.position;
myMin = 999999;
minIdx = 0;

for (var i = 1; i <= thisComp.numLayers; i++){
if (i == L.index) continue;
point1=thisComp.layer(i).position;
delta=sub(point1, point2);
distance=length(delta);
if (distance < myMin){
myMin = distance;
minIdx = i;
}
}
z = (minIdx == index) ? 1 : 0;
[value[0],value[1],z]



Dan



Return to posts index

Mark Mitchell
Re: Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 7:28:37 pm

Hi Dan,
Kind of works, apart it sends the focus page to the back. Looks like there it just needs reversing to go to the front.

Regards

Mark


Return to posts index

Dan Ebberts
Re: Controlling z axis in layer to bring image to front of the rest
on Feb 26, 2019 at 7:43:27 pm

Yeah, sorry. Change this line:

z = (minIdx == index) ? 1 : 0;

to this:

z = (minIdx == index) ? -1 : 0;


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]