Created
November 14, 2017 15:57
-
-
Save aescripts/258020cc91926a914149993b0ccbc492 to your computer and use it in GitHub Desktop.
#AfterEffects #Script #KBar #MotionScript #Camera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (app.project.activeItem instanceof CompItem) { | |
var myCam; | |
if (app.project.activeItem.activeCamera instanceof CameraLayer) | |
myCam = app.project.activeItem.activeCamera; | |
else | |
myCam = app.project.activeItem.layers.addCamera("Target Camera", [app.project.activeItem.width/2,app.project.activeItem.height/2]); | |
var myNull = app.project.activeItem.layers.addNull(); | |
myNull.name = "Target"; | |
myCam.cameraOption.focusDistance.expression = "target = thisComp.layer(\"Target\");\nv1 = target.toWorld(target.anchorPoint) - toWorld([0,0,0]);\nv2 = toWorldVec([0,0,1]);\ndot(v1,v2);"; | |
} else { | |
alert("Please select a comp"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added the "3D layer" to NULL(Target), that it would be possible to animate DOF in the plane Z.