Search code examples
javascriptadobeextendscriptafter-effects

After Effects Extendscript - changing the centerpoint for addlight


Using this example code:

app.project.item(index).layers.addLight(name, centerPoint)

I created the following test code where I add a light to my second scene (composition) in my project to create a shadow:

var s2light1 = scene2.layers.addLight("s2light1", [1143,121]);

This works perfectly. But I now also want to set the 3rd (Z) value for the centerPoint in Extendscript (as is possible in After Effects).

However according to the After Effects CS6 scripting guide it seems you can only set the X and Y values: "The center of the new camera, a floating-point array [x, y]. This is used to set the initial x and y values of the new camera’s Point of Interest property. The z value is set to 0."

Is there another approach or work around to set the Z-value for the center point in Extendscript which I can try?


Solution

  • newLight = app.project.item(1).layers.addLight("foo", [22, 33]);
    //now set the point of interest ('center point') value:
    newLight.property("Point of Interest").setValue([22, 33, 11]);
    

    and to make a light not auto-orient (one-node):

    newLight.autoOrient = AutoOrientType.NO_AUTO_ORIENT;
    

    In which case you would control the Position and Rotation properties -- no point of interest.