Camera Paths from Plugins
Lua plugins can create, inspect and edit the same camera paths that are available in the Open Brush UI. This is useful for procedural camera moves, drawing along paths and automated rendering.
This page introduces the main objects and workflows. The generated Plugin API Scripting Reference is the source for every property, method and parameter.
Get the active camera path
Camera paths are available through Sketch.cameraPaths:
local cameraPath = Sketch.cameraPaths.active
if cameraPath == nil and Sketch.cameraPaths.count > 0 then
cameraPath = Sketch.cameraPaths.last
endA camera path exposes positionKnots, rotationKnots, speedKnots, fovKnots and a combined knots list.
Sample a path
Sample returns the camera transform at a time along the path. SampleFull also returns the interpolated speed, field of view and position along the path:
local sample = cameraPath:SampleFull(2.5, true, false)
local position = sample.position
local rotation = sample.rotation
local speed = sample.speed
local fieldOfView = sample.fov
local pathRatio = sample.pathRatioThe second argument controls looping. The third enables ping-pong playback, which reverses direction on alternating loops.
Create a camera path from a Path
If a plugin has already created a Path, convert it to a camera path:
Use CameraPath:FromPathWithRotations(path, false) to create rotation knots from the rotations stored on the path points. The Boolean argument controls whether the result loops.
You can convert a camera path back to a regularly sampled Path:
Edit knots
Camera-path methods can extend or loop the path and insert position, rotation, speed or FOV knots. You can also edit knot properties directly:
Speed values use world-space units and FOV values use degrees. Changing a non-position knot's pathT moves it along the path and automatically restores the correct knot order.
Draw or render a path
Draw along a camera path with the current brush:
Or supply explicit brush settings:
Use CameraPath:PreviewActivePath(true) to preview the active path and CameraPath:RenderActivePath() to render it using the current video settings.
Last updated