I got to ask : does it REALLY help to see the full expression? because this thing is not only fairly big as expressions go, it's part of a system. I suspect you'd need the whole darned thing, and then we're talking about an entire project. I'm working through it. it looks like (and I cannot 'know' because the debugger is buggered to heck) a function called : layersRelevantToTime is returning gibberish. so I've duplicated it's behavior in the main Logic (at the bottom) and I'm trying to see what's what. I had trouble getting AE to return arrays of layers in the past. You might even see a comment to that effect somewhere in that mish mash. I'm wondering if that's what's going on here. commenting out anything that tries to get layersRelevantToTime seems to evaluate. // ----------------------------------------------------------------------------- // // functions: // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // function orderedLayers(theArray){ // the one with the earliest inPoint. var earliest = theArray[0] var second = theArray[1] var andex = 0; for(andex = 0; andex < theArray.length; andex ++){ if(theArray[andex].inPoint < earliest.inPoint){ second = earliest; earliest = theArray[andex]; } } return [earliest,second] } // ----------------------------------------------------------------------------- // // does the bulk of the work to transition from 1 layer to the next. // assumes the layers have certain features: handles for instance. function doTransition(startLayer, stopLayer){ // now get the points. in WorldCoords. var startPT = startLayer.toWorld(startLayer.anchorPoint); var stopPT = stopLayer.toWorld(stopLayer.anchorPoint); var startHPt = startLayer.effect("outgoingHandle")("3D Point"); var stopHPt = stopLayer.effect("incomingHandle")("3D Point"); // thats the 4 spline points. // now get our position along the spline. var duration = stopLayer.inPoint - startLayer.outPoint ; // now we used to just average accorss the ease. looked like this: renderVal = ease((time - M.inPoint) / dur, outVal, inVal); but now we want to get the progress 0 - 1 eased. var uneasedProg = (time - startLayer.outPoint)/duration; var progress = easeInOutQuad((time - startLayer.outPoint)/duration); // eased. //had to reverse the order of points, bc that makes it go forward. return (pointOnSpline(stopPT, stopHPt, startHPt, startPT, progress)) } // ----------------------------------------------------------------------------- // // returns position data for 3d Position along a spline, given 4 points and a position. // getting seriously anomolous results from the Z channel. looking for bad coding, and hoping it's not math. function pointOnSpline(cpZero, cpOne, cpTwo, cpThree, t){ var retArray = []; var cx = 3.0* (cpOne[0] - cpZero[0]); var bx = 3.0 * (cpTwo[0] - cpOne[0]) - cx; var ax = cpThree[0] - cpZero[0]- cx - bx; // ok to here. var cy = 3.0* (cpOne[1] - cpZero[1]); var by = 3.0 * (cpTwo[1] - cpOne[1]) - cy; var ay = cpThree[1] - cpZero[1]- cy - by; // ok to here. var cz = 3.0* (cpOne[2] - cpZero[2]); var bz = 3.0 * (cpTwo[2] - cpOne[2]) - cz; var az = cpThree[2] - cpZero[2]- cz - bz; var tSquare = t * t; var tCube = tSquare * t; // now create the result. var theX = (ax * tCube) + (bx * tSquare) + (cx * t) + cpZero[0]; var theY = (ay * tCube) + (by * tSquare) + (cy * t) + cpZero[1]; var theZ = (az * tCube) + (bz * tSquare) + (cz *t) + cpZero[2]; retArray = [theX, theY, theZ]; return retArray; } // ----------------------------------------------------------------------------- // // homebrew ease function. function easeInOutQuad(t) { return t<.5 ? 2*t*t : -1+(4-2*t)*t } // ----------------------------------------------------------------------------- // // compares layers in the list to time. returns in timed order, relevant layers (layers with inpoints/outpoints that overlap current time. function layersRelevantToTime(theLayers){ var retArray = [] var dex = 1; for (dex = 0; dex < theLayers.length; dex ++){ if(theLayers[dex].inPoint <= time && theLayers[dex].outPoint >= time){ retArray.push(theLayers[dex]); } } return retArray.reverse(); //return retArray; } // ----------------------------------------------------------------------------- // function idLayers(ralId){ // get all layers in comp. var count = thisComp.numLayers; var i = 1; var anArray = []; for(i = 1; i <= count; i ++){ try{ //var constantVal = ralId; var iValue = thisComp.layer(i).effect("railID")("Slider").value; if(iValue == ralId){ // then we have a match. put it on the list. anArray.push(thisComp.layer(i)); } } catch(err){ // ignore errors } } return anArray.reverse(); } // ----------------------------------------------------------------------------- // // main logic // ----------------------------------------------------------------------------- // var someIdLayers = idLayers(effect("theRailID")("Slider").value); // get all the layers with the correct rail id // now we must test if we got anything. var theCount = someIdLayers.length; //var theCount = 1; if(theCount > 0){ // then we know we have layers out there. at least 1. //var myArray = layersRelevantToTime(someIdLayers); // now just get the layers that are alive at this time. /////var retArray = [] var myArray = []; var dex = 1; for (dex = 0; dex < someIdLayers.length; dex ++){ if(someIdLayers[dex].inPoint <= time && someIdLayers[dex].outPoint >= time){ myArray.push(someIdLayers[dex]); } } // now test my array. var aNewCount = myArray.length; //var aNewCount = 1; if(aNewCount > 1){ // if we get at least 2 layers <- good thing. var someLayers = orderedLayers(myArray); // we might get more than 2 active layers so filter out all but the first 2. var theVal = doTransition(someLayers[0], someLayers[1]); // run the main function. theVal; // set the value. }else{ // with just 1 or less layers. if(aNewCount == 1){ myArray[0].toWorld(myArray[0].anchorPoint); } if(aNewCount == 0){ // unlikely but we COULD get no relevant layers. transform.position } } }else{ // with no layers, we can't do anything. transform.position }
... View more