//****************************** SUBROUTINES function Bake(theComp, propBeingCopied, propBeingWritten) { StartBake=theComp.workAreaStart; EndBake=StartBake+theComp.workAreaDuration; NextFrame=1/theComp.frameRate; for (var i=StartBake; i180) value = value-360; if(value<-180) value = value+360; propBeingWritten.setValueAtTime(i,value); }; }; //****************************** MAIN PROGRAM theComp = app.project.activeItem; theCamera = theComp.selectedLayers; CameraName = theCamera[0].name; theComp.layers.addCamera("CameraCopy 1",[0,0]).startTime=0; CamCopy01=theComp.layer(1); CamCopy01.position.expression="L=thisComp.layer("+"\'"+CameraName+"\'"+");L.toWorld([0,0,0])"; CamCopy01.pointOfInterest.expression="position"; CamCopy01.orientation.expression="C = this_comp.layer("+"\'"+CameraName+"\'"+");u = C.to_world_vec([1,0,0]);v = C.to_world_vec([0,1,0]);w = C.to_world_vec([0,0,1]);sinb = clamp(w[0],-1,1);b = Math.asin(sinb/this_comp.pixel_aspect);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;}[radians_to_degrees(a),radians_to_degrees(b),radians_to_degrees(c)]"; theComp.layers.addCamera("CameraCopy 2",[0,0]).startTime=0; CamCopy02=theComp.layer(1); CamCopy02.position.expression="thisComp.layer('CameraCopy 1').position"; CamCopy02.pointOfInterest.expression="position"; CamCopy02.rotationX.expression="thisComp.layer('CameraCopy 1').orientation[0]"; CamCopy02.rotationY.expression="thisComp.layer('CameraCopy 1').orientation[1]"; CamCopy02.rotation.expression="thisComp.layer('CameraCopy 1').orientation[2]"; CamCopy02.zoom.expression="this_comp.layer("+"\'"+CameraName+"\'"+").zoom"; theComp.layers.addCamera("Baked Camera",[0,0]).startTime=0; CamCopy03=theComp.layer(1); Bake(theComp, theComp.layer(2).position, CamCopy03.position); CamCopy03.pointOfInterest.expression="position"; BakeRot(theComp, theComp.layer(2).rotationX, CamCopy03.rotationX); BakeRot(theComp, theComp.layer(2).rotationY, CamCopy03.rotationY); BakeRot(theComp, theComp.layer(2).rotation, CamCopy03.rotation); Bake(theComp, theComp.layer(2).zoom, CamCopy03.zoom); theComp.layer(3).remove(); theComp.layer(2).remove(); alert("Turn off the auto-orientation on the baked camera"); //****************************** END