layer-space-transforms
Layer Space Transforms
Section titled “Layer Space Transforms”thisLayer
Use layer space transform methods to transform values from one space to another, such as from layer space to world space.
Composition (comp) and world space are the same for 2D layers. For 3D layers, however, composition space is relative to the active camera, and world space is independent of the camera.
On this page, we’re going to use thisLayer
as a sample on how to call these items, however note that any method that returns a Layer will work.
”From” & “To” Methods
Section titled “”From” & “To” Methods”The from
methods transform values from the named space (composition or world) to the layer space.
The to
methods transform values from the layer space to the named space (composition or world). Each transform method takes an optional argument to determine the time at which the transform is computed; however, you can almost always use the current (default) time.
”Vec” Methods
Section titled “”Vec” Methods”Use Vec
transform methods when transforming a direction vector, such as the difference between two position values.
Use the plain (non-Vec
) transform methods when transforming a point, such as position.
Methods
Section titled “Methods”toComp()
Section titled “toComp()”thisLayer.toComp(point[, t=time])
Description
Section titled “Description”Transforms a point from layer space to composition space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
point | Array (2- or 3-dimensional) | The point to convert |
t | Number | Optional. The time at which to sample the point at. Defaults to time . |
Array (2- or 3-dimensional)
fromComp()
Section titled “fromComp()”thisLayer.fromComp(point[, t=time])
Description
Section titled “Description”Transforms a point from composition space to layer space. The resulting point in a 3D layer may have a nonzero value even though it is in layer space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
point | Array (2- or 3-dimensional) | The point to convert |
t | Number | Optional. The time at which to sample the point at. Defaults to time . |
Array (2- or 3-dimensional)
Example
Section titled “Example”fromComp(thisComp.layer(2).position)
toWorld()
Section titled “toWorld()”thisLayer.toWorld(point[, t=time])
Description
Section titled “Description”Transforms a point from layer space to view-independent world space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
point | Array (2- or 3-dimensional) | The point to convert |
t | Number | Optional. The time at which to sample the point at. Defaults to time . |
Array (2- or 3-dimensional)
Example
Section titled “Example”toWorld.effect("Bulge")("Bulge Center")
fromWorld()
Section titled “fromWorld()”thisLayer.fromWorld(point[, t=time])
Description
Section titled “Description”Transforms a point from world space to layer space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
point | Array (2- or 3-dimensional) | The point to convert |
t | Number | Optional. The time at which to sample the point at. Defaults to time . |
Array (2- or 3-dimensional)
Example
Section titled “Example”fromWorld(thisComp.layer(2).position)
toCompVec()
Section titled “toCompVec()”thisLayer.toCompVec(vec[, t=time])
Description
Section titled “Description”Transforms a vector from layer space to composition space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
vec | Array (2- or 3-dimensional) | |
t | Number |
Array (2- or 3-dimensional)
Example
Section titled “Example”toCompVec([1, 0])
fromCompVec()
Section titled “fromCompVec()”thisLayer.fromCompVec(vec[, t=time])
Description
Section titled “Description”Transforms a vector from composition space to layer space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
vec | Array (2- or 3-dimensional) | |
t | Number |
Array (2- or 3-dimensional)
Example:
Section titled “Example:”For a 2D layer:
const dir = sub(position, thisComp.layer(2).position);fromCompVec(dir)
toWorldVec()
Section titled “toWorldVec()”thisLayer.toWorldVec(vec[, t=time])
Description
Section titled “Description”Transforms a vector from layer space to world space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
vec | Array (2- or 3-dimensional) | |
t | Number |
Array (2- or 3-dimensional)
Example
Section titled “Example”Transform two different “Bulge Center” properties from the layer space of the layer the effect is applied to, to the world space of the comp the layers live in:
const p1 = effect("Eye Bulge 1")("Bulge Center");const p2 = effect("Eye Bulge 2")("Bulge Center");
toWorld(sub(p1, p2))
fromWorldVec()
Section titled “fromWorldVec()”thisLayer.fromWorldVec(vec[, t=time])
Description
Section titled “Description”Transforms a vector from world space to layer space.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
vec | Array (2- or 3-dimensional) | |
t | Number |
Array (2- or 3-dimensional)
Example
Section titled “Example”Convert layer #2’s position from world space to this layer’s space:
fromWorld(thisComp.layer(2).position)
fromCompToSurface()
Section titled “fromCompToSurface()”thisLayer.fromCompToSurface(point[, t=time])
Description
Section titled “Description”Projects a point located in composition space to a point on the surface of the layer (zero z-value) at the location where it appears when viewed from the active camera. This method is useful for setting effect control points.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
point | Array (2- or 3-dimensional) | The point to convert |
t | Number | Optional. The time at which to sample the point at. Defaults to time . |
Array (2-dimensional)