Show:

A library for creating and composing CSS3 matrix transforms. A Transform is a 16 element float array t = [t0, ..., t15] that corresponds to a 4x4 transformation matrix (in row-major order)

  ┌               ┐
  │ t0  t1  t2  0 │
  │ t4  t5  t6  0 │
  │ t8  t9  t10 0 │
  │ t12 t13 t14 1 │
  └               ┘

This matrix is a data structure encoding a combination of translation, scale, skew and rotation components.

Note: these matrices are transposes from their mathematical counterparts.

Item Index

Methods

Properties

Methods

aboutOrigin

(
  • v
  • t
)
Array static

Return a Transform which represents a Transform applied about an origin point. Useful for rotating and scaling relative to an origin.

Parameters:

  • v Number[]

    Origin point [x,y,z]

  • t Transform

    Transform

Returns:

average

(
  • M1
  • M2
  • [t=1/2]
)
Array static

Weighted average between two matrices by averaging their translation, rotation, scale, skew components. f(M1,M2,t) = (1 - t) * M1 + t * M2

Parameters:

  • M1 Transform

    M1 = f(M1,M2,0) Transform

  • M2 Transform

    M2 = f(M1,M2,1) Transform

  • [t=1/2] Number optional

Returns:

build

(
  • spec
)
Array private static

Compose .translate, .rotate, .scale and .skew components into a Transform matrix. The "inverse" of .interpret.

Parameters:

  • spec Object

    Object with keys "translate, rotate, scale, skew" and their vector values

Returns:

compose

(
  • t1
  • t2
)
Array static

Compose Transform arrays via matrix multiplication.

Parameters:

  • t1 Transform

    Left Transform

  • t2 Transform

    Right Transform

Returns:

composeMany

(
  • Transform
)
Array static

Convenience method to Compose several Transform arrays.

Parameters:

  • Transform ...Transform

    arrays

Returns:

equals

(
  • a
  • b
)
Boolean static

Determine if two Transforms are component-wise equal.

Parameters:

  • a Transform

    Transform

  • b Transform

    Transform

Returns:

getTranslate

(
  • t
)
Number[] static

Return translation vector component of the given Transform.

Parameters:

  • t Transform

    Transform

Returns:

interpret

(
  • t
)
Object private static

Decompose Transform into separate translate, rotate, scale and skew components.

Parameters:

  • t Transform

    Transform

Returns:

inverse

(
  • t
)
Array static

Return inverse Transform for given Transform. Note: will provide incorrect results if Transform is not invertible.

Parameters:

  • t Transform

    Transform

Returns:

moveThen

(
  • v
  • t
)
Array static

Translate a Transform before the Transform is applied.

Parameters:

  • v Number[]

    Array of [x,y,z] translation components

  • t Transform

    Transform

Returns:

notEquals

(
  • a
  • b
)
Boolean static

Determine if two Transforms are component-wise unequal

Parameters:

  • a Transform

    Transform

  • b Transform

    Transform

Returns:

perspective

(
  • focusZ
)
Array static

Returns a perspective Transform.

Parameters:

  • focusZ Number

    z-depth of focal point

Returns:

rotateAxis

(
  • v
  • angle
)
Array static

Return a Transform which represents an axis-angle rotation.

Parameters:

  • v Number[]

    Unit vector representing the axis to rotate about

  • angle Number

    Radians to rotate clockwise about the axis

Returns:

rotateX

(
  • angle
)
Array static

Return a Transform representing a clockwise rotation around the x-axis.

Parameters:

  • angle Number

    Angle in radians

Returns:

rotateX

(
  • angle
)
Array static

Return a Transform representing a clockwise rotation around the z-axis.

Parameters:

  • angle Number

    Angle in radians

Returns:

rotateY

(
  • angle
)
Array static

Return a Transform representing a clockwise rotation around the y-axis.

Parameters:

  • angle Number

    Angle in radians

Returns:

scale

(
  • v
)
Array static

Return a Transform which represents a scaling by specified amounts in each dimension.

Parameters:

Returns:

scaleX

(
  • x
)
static

Return a Transform which represents scaling in the x-direction.

Parameters:

scaleY

(
  • y
)
static

Return a Transform which represents scaling in the y-direction.

Parameters:

scaleZ

(
  • z
)
static

Return a Transform which represents scaling in the z-direction.

Parameters:

skewX

(
  • angle
)
Array static

Return a Transform representation of a skew in the x-direction

Parameters:

  • angle Number

    The angle between the top and left sides

Returns:

skewY

(
  • angle
)
Array static

Return a Transform representation of a skew in the y-direction

Parameters:

  • angle Number

    The angle between the bottom and right sides

Returns:

thenMove

(
  • t
  • v
)
Array static

Translate a Transform after the Transform is applied.

Parameters:

  • t Transform

    Transform

  • v Number[]

    Array of [x,y,z] translation components

Returns:

thenScale

(
  • t
  • v
)
Array static

Scale a Transform after the Transform is applied.

Parameters:

  • t Transform

    Transform

  • v Number[]

    Array of [x,y,z] scale components

Returns:

translate

(
  • v
)
Array static

Return a Transform which represents translation by a translation vector.

Parameters:

Returns:

translateX

(
  • x
)
static

Return a Transform which represents translation in the x-direction.

Parameters:

translateY

(
  • y
)
static

Return a Transform which represents translation in the y-direction.

Parameters:

translateZ

(
  • z
)
static

Return a Transform which represents translation in the z-direction.

Parameters:

transpose

(
  • t
)
Array static

Returns the transpose of a Transform.

Parameters:

  • t Transform

    Transform

Returns:

Properties

behind

Array final static

Transform for moving a renderable behind another renderable in the z-direction.

identity

Array final static

Identity transform.

inFront

Array final static

Transform for moving a renderable in front of another renderable in the z-direction.