ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Movement from a Parented layer to 3d stroke

FAQ   •   VIEW ALL
 Movement from a Parented layer to 3d stroke by Mac Ladon Apr 9, 2018 at 7:44:53 pm

Hi Guys,
I have a 3d layer which is parented to a 3d null which is animated along position and rotation. Basically, 3d Layer is a Mobile Comp. I also have a layer which has a 3d stroke effect on it. I have already added toWorld expression to the position of xy and z in the effect which traces back the world position of the mobile. When I add below expression to the rotation it works fine but gets crazy when I add a value to it at the end.
For rotation in x
L = thisComp.layer("Child Layer");
s = L.scale/100;
u = L.toWorldVec([s[0],0,0]);
v = L.toWorldVec([0,s[1],0]);
w = L.toWorldVec([0,0,s[2]]);
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb/thisComp.pixelAspect);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = Math.atan2(u[1],v[1]);
c = 0;
}

For rotation in y
L = thisComp.layer("Child Layer");
s = L.scale/100;
u = L.toWorldVec([s[0],0,0]);
v = L.toWorldVec([0,s[1],0]);
w = L.toWorldVec([0,0,s[2]]);
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb/thisComp.pixelAspect);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = Math.atan2(u[1],v[1]);
c = 0;
}

For rotation in z
L = thisComp.layer("Child Layer");
s = L.scale/100;
u = L.toWorldVec([s[0],0,0]);
v = L.toWorldVec([0,s[1],0]);
w = L.toWorldVec([0,0,s[2]]);
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb/thisComp.pixelAspect);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = Math.atan2(u[1],v[1]);
c = 0;
}

So by adding these expressions, I get my 3d stroke parallel to the mobile so to work it as a speed line rotating around I need to add 90 to the end value of x rotation or in y..here it becomes crazy and that's where I need some expression help
Is there any other way to solve this problem...?