-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmycompgenerator.jsx
120 lines (84 loc) · 3.75 KB
/
mycompgenerator.jsx
1
// adds bike comps + their lights to a comp// set numberOfLayers to control # of bikes generated.// change columnObjects to control number of bikes in a column.numberOfLayers = 256; // # total bikes to generate.var columnObjects = 16; // # objects per columnArray.range= function(a, len, step){ var A= []; if(typeof a== 'number'){ A[0]= a; step= step || 1; while(A.length<= len){ A[A.length]= a+= step; } } return A;}app.beginUndoGroup("Add new shape layer"); var currComp = app.project.activeItem; var xp = 1782.0; var yp = 1000; var zp = 0.0;for (var i = 0, length = numberOfLayers; i < length; i++) { if(currComp){ var nullposition = [xp,yp,zp]; bikeNull = currComp.layers.addNull(); bikeNull.threeDLayer = true; bikeNull.transform.position.setValue(nullposition); bikeNull.name = 'null '+i; bp = bikeNull.transform.position; bikeLayer = currComp.layers.add(app.project.item(4)); bikeLayer.threeDLayer = true; bikeLayer.collapseTransformation = true; bikeLayer.scale.setValue([25.0,25.0,35.0]); bikeLayer.transform.position.setValue(bp.value); bikeLayer.name = 'bike '+i; bpxy = [bp.value[0],bp.value[1]]; spot1 = currComp.layers.addLight('spot1', bpxy); spot1.transform.pointOfInterest.setValue(bp.value); spot1.transform.position.setValue([bp.value[0]+3.6,bp.value[1]-135.3,bp.value[2]-5.9]); spot1.lightType = LightType.SPOT; spot1.lightOption.coneAngle.setValue(54); spot1.lightOption.coneFeather.setValue(16); spot1.lightOption.castsShadows.setValue(true); spot1.lightOption.shadowDarkness.setValue(82); spot1.lightOption.shadowDiffusion.setValue(11); spot1.name = 'bike '+i+' spot 1'; spot2 = currComp.layers.addLight('spot2', bpxy); spot2.transform.pointOfInterest.setValue(bp.value); spot2.transform.position.setValue([bp.value[0]+149.6,bp.value[1]-51.6,bp.value[2]-21.5]); spot2.lightType = LightType.SPOT; spot2.lightOption.coneAngle.setValue(58); spot2.lightOption.coneFeather.setValue(16); spot2.lightOption.castsShadows.setValue(true); spot2.lightOption.shadowDarkness.setValue(82); spot2.lightOption.shadowDiffusion.setValue(11); spot2.name = 'bike '+i+' spot 2'; } } //parent bikes and lights to nullsvar nullLayerPosition = Array.range(4,10,4);app.project.item(3).layer(1).parent = app.project.item(3).layer(4);app.project.item(3).layer(2).parent = app.project.item(3).layer(4);app.project.item(3).layer(3).parent = app.project.item(3).layer(4);b = Array.range(4,numberOfLayers,4);var itm = 3; // the number of the comp (within the project) that we are adding objects to. var zSpacing = 192;var xSpacing = 0;for(var i = 0; i < numberOfLayers-1; i++){ var nl = Array.range(b[i]+1,3,1); app.project.item(itm).layer(nl[0]).parent = app.project.item(itm).layer(nl[3]); app.project.item(itm).layer(nl[1]).parent = app.project.item(itm).layer(nl[3]); app.project.item(itm).layer(nl[2]).parent = app.project.item(itm).layer(nl[3]); app.project.item(itm).layer(nl[3]).parent = app.project.item(itm).layer(b[i]); // grid layout if ( (i+1) % columnObjects == 0){ zSpacing = -zSpacing*(columnObjects-1); // reset zSpacing, increment xSpacing; xSpacing = 489; } else { zSpacing = 192; xSpacing = 0; } app.project.item(itm).layer(nl[3]).transform.position.setValue([xSpacing,0,zSpacing]); } app.endUndoGroup();