Class: Transform

SQR.Transform(name)

new Transform(name)

A transform is a basic building block for 3D scenes made with squareroot.js

Parameters:
Name Type Description
name string

the name of the transform.

Source:

Members

active :boolean

is set to false, the transform and all it's children will not be rendered.

Type:
  • boolean
Default Value:
  • false
Source:

directMatrixMode :boolean

When set to true matrix value inside @this.matrix can be manipulated directly.

Type:
  • boolean
Default Value:
  • false
Source:

(readonly) forward :SQR.V3

the forward vector

Type:
Source:

(readonly) globalPosition :SQR.V3

the global position of this transform (set automatically)

Type:
Source:

isStatic :boolean

Any object can have two different positioning modes: dynamic or static. If this value is set to false (dynamic) the matrices for this object will be recalculated at each frame.
If this value is set to true (static) the matrices for this object will be recalculated only once.

Type:
  • boolean
Default Value:
  • false
Source:

matrix :SQR.Matrix44

object-to-parent transformation matrix

Type:
Source:

name :string

a unique name of this transform, useful for debugging

Type:
  • string
Default Value:
  • `sqr.transform.` + a counter (ex. `sqr.transform.29)
Source:

position :SQR.V3

the position of this transform relative to it's parent

Type:
Source:

quaternion :SQR.Quaternion

A Quaternion that describes the rotation of the transform, only active if useQuaternion is set to true.

Type:
Source:

rotation :SQR.V3

A 3D vector the describes the rotation of the transform in Euler angles, disabled if useQuaternion is set to true.

Type:
Source:

scale :SQR.V3

the scale of the object on x, y and z axis

Type:
Source:

useQuaternion :SQR.Quaternion

if set to true, will use quaternion for rotation instead of the Euler angles in rotation

Type:
Default Value:
  • false
Source:

Methods

add()

Add a child transform. Accepts multiple arguments but all of them need to be of type {SQR.Transform}. It doesn't do any sort of type checking so if you add non object that are not {SQR.Transform} it will result in errors when the scene is rendered.

Source:

computeInverseMatrix()

Calculate the camera inverse matrix.

Used only if this transform is a camera.

This function is called in the rendering process, do not call directly.

Source:

contains(c)

Checks if transform is child of this transfom

Parameters:
Name Type Description
c SQR.Transform

the transform to look for

Source:

recurse(f, excludeSelf)

Execute this function on all the child transforms.

Parameters:
Name Type Description
f function

the function that will be called on each child. This function will receive the transform as argument.

excludeSelf boolean

if set to true, the function will only be called for all the ancestors of the Transform, not on the transform itself.

Source:

remove()

Removes a child transform. Accepts multiple arguments but all of them need to be of type {SQR.Transform}

Source:

removeAll()

Removes all children transform.

Source:

transformView(inverseCamMatrix)

Calculate the view matrix.

This function is called in the rendering process, do not call directly.

Parameters:
Name Type Description
inverseCamMatrix SQR.Matrix44

the inverse matrix of the camera

Source:

transformWorld()

Sets up the local matrix and multiplies is by the parents globalMatrix. This function is called in the rendering process, do not call directly.

Source:

viewDepth()

Used for sorting objects in the rendering function (not implemented yet)

Source: