Camera Rig 1
// Create a new camera
var comp = app.project.activeItem;
if (comp && comp instanceof CompItem) {
var camera = comp.layers.addCamera("Camera 1", [comp.width / 2, comp.height / 2]);
if (camera) {
// Set the camera's zoom level to 10000
var zoomLevel = 10000;
camera.property("ADBE Camera Options Group").property("ADBE Camera Zoom").setValue(zoomLevel);
// Adjust the camera's Z position to offset the increased zoom level
var zPosition = -5333.3 * (10000 / 5333.3);
camera.property("ADBE Transform Group").property("ADBE Position").setValue([1920, 1080, zPosition]);
// Enable depth of field
camera.property("ADBE Camera Options Group").property("ADBE Camera Depth of Field").setValue(true);
// Set aperture to 100 pixels
camera.property("ADBE Camera Options Group").property("ADBE Camera Aperture").setValue(100);
// Set the camera layer color to pink
camera.label = 9; // Pink color label
// Create a new null object for focus
var focusNull = comp.layers.addNull();
if (focusNull) {
focusNull.threeDLayer = true;
focusNull.name = "FocusNull1";
focusNull.source.name = "FocusNull1"; // Change the source name
// Set the focus null layer color to pink
focusNull.label = 9; // Pink color label
// Link the camera's focus distance to the 'FocusNull1'
var focusDistance = camera.property("ADBE Camera Options Group").property("ADBE Camera Focus Distance");
if (focusDistance) {
var focusDistanceExpression =
"var targetLayer = thisComp.layer('FocusNull1');\n" +
"var targetPos = targetLayer.toWorld(targetLayer.anchorPoint);\n" +
"var cameraPos = thisComp.activeCamera.toWorld([0,0,0]);\n" +
"length(targetPos - cameraPos);";
focusDistance.expression = focusDistanceExpression;
}
// Apply expression to restrict Z transformation of the focus null's position
var position = focusNull.property("ADBE Transform Group").property("ADBE Position");
if (position) {
var positionExpression =
"var original = position;\n" +
"[original[0], original[1], 0];";
position.expression = positionExpression;
}
}
// Create a new null object for the camera rig
var cameraRig = comp.layers.addNull();
if (cameraRig) {
cameraRig.name = "CameraRig1";
cameraRig.source.name = "CameraRig1"; // Change the source name
cameraRig.property("ADBE Transform Group").property("ADBE Position").setValue([0, 0, 0]); // Position to top-left corner
// Set the camera rig layer color to pink
cameraRig.label = 9; // Pink color label
// Add a slider control to the camera rig and name it "Zoom"
var zoomSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
zoomSlider.name = "Zoom";
zoomSlider.property("ADBE Slider Control-0001").setValue(10000);
zoomSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 2000, 20000);";
// Add a second slider control to the camera rig and name it "Aperture"
var apertureSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
apertureSlider.name = "Aperture";
apertureSlider.property("ADBE Slider Control-0001").setValue(100);
apertureSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 0, 20000);";
// Add a third slider control to the camera rig and name it "Blur Level"
var blurSlider = cameraRig.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
blurSlider.name = "Blur Level";
blurSlider.property("ADBE Slider Control-0001").setValue(100);
blurSlider.property("ADBE Slider Control-0001").expression = "clamp(value, 0, 1000);";
// Add expression to the camera's zoom property
var zoom = camera.property("ADBE Camera Options Group").property("ADBE Camera Zoom");
if (zoom) {
zoom.expression = 'thisComp.layer("CameraRig1").effect("Zoom")("Slider")';
}
// Add expression to the camera's aperture property
var aperture = camera.property("ADBE Camera Options Group").property("ADBE Camera Aperture");
if (aperture) {
aperture.expression = 'thisComp.layer("CameraRig1").effect("Aperture")("Slider")';
}
// Add expression to the camera's blur property
var blur = camera.property("ADBE Camera Options Group").property("ADBE Camera Blur Level");
if (blur) {
blur.expression = 'thisComp.layer("CameraRig1").effect("Blur Level")("Slider")';
}
}
// Add keyframes at the current time for the camera's point of interest and position properties
var currentTime = comp.time;
var pointOfInterest = camera.property("ADBE Transform Group").property("ADBE Point of Interest");
var position = camera.property("ADBE Transform Group").property("ADBE Position");
if (pointOfInterest && position) {
pointOfInterest.setValueAtTime(currentTime, pointOfInterest.value);
position.setValueAtTime(currentTime, position.value);
}
}
}
How to use the script
Always check code before running it on your computer. Even basic scripts like this one. If you’re not a developer, ask an LLM like ChatGPT, Claude, or Gemini to verify it for you.
Option 1: Install to your AE Folder
Download and install the below .jsx file in your After Effects Script folder. You can then run it using the scripts menu, or by using a launcher like Quick Menu 3.
Option 2: Adapt the script yourself
Alternatively copy the code below and develop your own version. If you’re not a developer you can do this easily with an LLM like ChatGPT.
More about my Stack
Sorry, we haven't filled this category yet!