Transformation
A 4x4 matrix describing a position, rotation, and scale in 3D space.
Transformations are how you move, rotate, and scale geometry in SketchUp. Every group and component instance carries a transformation that positions it in the model.
You usually don’t construct these directly — instead, call the
static factory methods translation(), rotation(), or
scaling(), then pass the result to operation methods like
drawingElementsApplyTransformation.
Transformations are immutable. Methods like applyTo() and
inverse return new instances.
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let { Transformation } = SketchUpApi;
await model.performOperation(async op => { const groupRef = op.createGroup(model); op.createEdge(groupRef, [[0,0,0], [50,0,0]]);
// Move the group 20" along the green axis op.drawingElementsApplyTransformation( groupRef, Transformation.translation([0, 20, 0]) );}, 'Create and move group');
// Compose transformations with applyTolet move = Transformation.translation([10, 0, 0]);let spin = Transformation.rotation( [0, 0, 0], [0, 0, 1], Math.PI / 4);let combined = move.applyTo(spin);console.log(combined.origin.toArray());// => [10, 0, 0]Constructor
Section titled “Constructor”Constructor
Section titled “Constructor”new Transformation(
_m?):Transformation
Creates a Transformation directly from a raw 16-element
column-major matrix array — equivalent to fromArray(). Most
code should prefer the static factory methods or fromArray()
for clarity; this is here for advanced cases where you already
have a raw matrix on hand.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
readonly [ |
|
16 numbers in column-major order. Defaults to the identity matrix. |
Returns
Section titled “Returns”Transformation
Properties
Section titled “Properties”identity
Section titled “identity”
readonlystaticidentity:Transformation
The identity transformation (no translation, rotation, or scale). Use this as a starting point or default value.
Example
Section titled “Example”let { Transformation } = SketchUpApi;
// This is the static property — it returns// the identity Transformation instance.let t = Transformation.identity;console.log(t.origin.toArray());// => [0, 0, 0]Accessors
Section titled “Accessors”identity
Section titled “identity”Get Signature
Section titled “Get Signature”get identity():
boolean
True if this transformation has no effect (no translation,
rotation, or scale). Not to be confused with the static
Transformation.identity property which returns the identity
instance itself.
Example
Section titled “Example”let { Transformation } = SketchUpApi;
// This is the getter — it returns a boolean// telling you if a transform is a no-op.let move = Transformation.translation([10, 0, 0]);console.log(move.identity);// => false (it moves things!)console.log(Transformation.identity.identity);// => true (yes, identity is identity)Returns
Section titled “Returns”boolean
inverse
Section titled “inverse”Get Signature
Section titled “Get Signature”get inverse():
Transformation
A new transformation that undoes this one. Applying a transformation followed by its inverse returns to the original position.
Returns
Section titled “Returns”Transformation
origin
Section titled “origin”Get Signature
Section titled “Get Signature”get origin():
Point3d
The translation component of this transformation — where the local origin ends up in world space.
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get xaxis():
Vector3d
The local X axis direction after this transformation is applied (the “red axis” of the transformed space).
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get yaxis():
Vector3d
The local Y axis direction after this transformation is applied (the “green axis” of the transformed space).
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get zaxis():
Vector3d
The local Z axis direction after this transformation is applied (the “blue axis” of the transformed space).
Returns
Section titled “Returns”Methods
Section titled “Methods”applyTo()
Section titled “applyTo()”Call Signature
Section titled “Call Signature”applyTo(
point):Point3d
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”applyTo(
vector):Vector3d
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”applyTo(
transformation):Transformation
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Transformation
Call Signature
Section titled “Call Signature”applyTo(
point):Point3d
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
[ |
‐ |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”applyTo(
plane):Plane
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
[ |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”applyTo(
plane):Plane
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”applyTo(
plane):Plane
Applies this transformation to a point, vector, plane, or another transformation. Returns a new transformed instance — the original is unchanged. When applied to another transformation, the result is their composition (matrix multiplication).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”toArray()
Section titled “toArray()”toArray():
SketchupTransform
Returns the 16-element column-major matrix as an array.
Returns
Section titled “Returns”SketchupTransform
SDK 2.35.0
toString()
Section titled “toString()”toString():
string
Returns
Section titled “Returns”string
axes()
Section titled “axes()”
staticaxes(origin,xaxis,yaxis,zaxis?):Transformation
Creates a transformation that maps world coordinates into a local coordinate system defined by an origin and axis vectors.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
‐ |
|
|
|
|
‐ |
|
|
|
|
‐ |
|
|
|
|
|
optional — computed from x cross y if omitted |
Returns
Section titled “Returns”Transformation
create()
Section titled “create()”
staticcreate(transform):Transformation
Utility that constructs a transform from anything shaped like a transformation
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”Transformation
Example
Section titled “Example”let translations = SketchUpApi.Transformation.create([100, 200, 300]);SDK 2.37.0
fromArray()
Section titled “fromArray()”
staticfromArray(array):Transformation
Creates a Transformation from a 16-element column-major
matrix array — the inverse of to_a.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
readonly |
16 numbers in column-major order |
Returns
Section titled “Returns”Transformation
interpolate()
Section titled “interpolate()”
staticinterpolate(transform1,transform2,weight):Transformation
Blends between two transformations. A weight of 0 returns
transform1, 1 returns transform2, and values in between
produce a smooth interpolation (slerp for rotation, lerp for
translation).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
‐ |
|
|
|
0–1 blend factor |
Returns
Section titled “Returns”Transformation
originAndDirection()
Section titled “originAndDirection()”
staticoriginAndDirection(origin,direction):Transformation
Creates a transformation whose Z axis points along
direction, with an arbitrary but consistent X and Y axis
computed perpendicular to it. Useful when you only care
about orientation along one axis — like aligning geometry
to a face normal — and don’t need to specify all three axes
yourself. See Transformation.axes if you do.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
the transformation’s origin |
|
|
|
becomes the new Z axis |
Returns
Section titled “Returns”Transformation
Example
Section titled “Example”let { Transformation } = SketchUpApi;
// Orient a transform along an arbitrary directionlet t = Transformation.originAndDirection( [0, 0, 0], [0, 0, 1]);console.log(t.zaxis.toArray());// => [0, 0, 1]rotation()
Section titled “rotation()”
staticrotation(point,vector,angle):Transformation
Creates a rotation transformation around an axis passing
through a point. The angle is in radians — multiply degrees
by Math.PI / 180 to convert.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
center of rotation |
|
|
|
axis direction |
|
|
|
|
rotation amount in radians |
Returns
Section titled “Returns”Transformation
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let { Transformation } = SketchUpApi;
await model.performOperation(async op => { const groupRef = op.createGroup(model); op.createFace(groupRef, [ [0, 0, 0], [50, 0, 0], [50, 50, 0], [0, 50, 0] ]);
// Rotate 45° about the Z axis at the origin const degrees = 45; const radians = degrees * Math.PI / 180; op.drawingElementsApplyTransformation( groupRef, Transformation.rotation( [0, 0, 0], [0, 0, 1], radians ) );}, 'Rotated square');scaling()
Section titled “scaling()”Call Signature
Section titled “Call Signature”
staticscaling(scale):Transformation
Creates a scaling transformation. Pass a single number for uniform scale, three numbers for per-axis scale, or include a point to scale around a specific origin.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
Returns
Section titled “Returns”Transformation
Call Signature
Section titled “Call Signature”
staticscaling(xscale,yscale,zscale):Transformation
Creates a scaling transformation. Pass a single number for uniform scale, three numbers for per-axis scale, or include a point to scale around a specific origin.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”Transformation
Call Signature
Section titled “Call Signature”
staticscaling(point,scale):Transformation
Creates a scaling transformation. Pass a single number for uniform scale, three numbers for per-axis scale, or include a point to scale around a specific origin.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
‐ |
|
|
|
|
‐ |
Returns
Section titled “Returns”Transformation
Call Signature
Section titled “Call Signature”
staticscaling(point,xscale,yscale,zscale):Transformation
Creates a scaling transformation. Pass a single number for uniform scale, three numbers for per-axis scale, or include a point to scale around a specific origin.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Section titled “Returns”Transformation
translation()
Section titled “translation()”
statictranslation(arg):Transformation
Creates a translation (move) transformation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
offset as a Vector3d, Point3d, or |
Returns
Section titled “Returns”Transformation
Example
Section titled “Example”let model = await SketchUpApi.getActiveModel();let { Transformation } = SketchUpApi;
await model.performOperation(async op => { const groupRef = op.createGroup(model); op.createFace(groupRef, [ [0, 0, 0], [30, 0, 0], [30, 30, 0], [0, 30, 0] ]);
// Move the group 50" along the red axis op.drawingElementsApplyTransformation( groupRef, Transformation.translation([50, 0, 0]) );}, 'Translated square');Deprecated
Section titled “Deprecated”Get Signature
Section titled “Get Signature”get to_a():
SketchupTransform
Returns
Section titled “Returns”SketchupTransform