- core
- Context
- ElementAllocator
- ElementOutput
- Engine
- Entity
- EventEmitter
- EventHandler
- Group
- Modifier
- OptionsManager
- RenderNode
- Scene
- SpecParser
- Transform
- View
- ViewSequence
- events
- EventArbiter
- EventFilter
- EventMapper
- inputs
- Accumulator
- GenericSync
- MouseSync
- PinchSync
- RotateSync
- ScaleSync
- ScrollSync
- TouchSync
- TouchTracker
- TwoFingerSync
- math
- Matrix
- Quaternion
- Random
- Utilities
- Vector
- modifiers
- Draggable
- Fader
- ModifierChain
- StateModifier
- physics
- PhysicsEngine
- physics/bodies
- Body
- Circle
- Particle
- Rectangle
- physics/constraints
- Surface
- Collision
- Constraint
- Curve
- Distance
- Snap
- Wall
- Walls
- physics/forces
- Drag
- Force
- Repulsion
- RotationalDrag
- RotationalSpring
- Spring
- VectorField
- physics/integrators
- SymplecticEuler
- surfaces
- CanvasSurface
- ContainerSurface
- ImageSurface
- InputSurface
- TextareaSurface
- VideoSurface
- transitions
- CachedMap
- Easing
- MultipleTransition
- SnapTransition
- SpringTransition
- Transitionable
- TransitionableTransform
- TweenTransition
- WallTransition
- utilities
- KeyCodes
- Timer
- Utility
- views
- ContextualView
- Deck
- DrawerLayout
- EdgeSwapper
- FlexibleLayout
- Flipper
- GridLayout
- HeaderFooterLayout
- Lightbox
- RenderController
- ScrollContainer
- Scroller
- Scrollview
- SequentialLayout
- widgets
- NavigationBar
- TabBar
Transform
A high-performance static matrix math library used to calculate affine transforms on surfaces and other renderables. Famo.us uses 4x4 matrices corresponding directly to WebKit matrices (column-major order). The internal "type" of a Matrix is a 16-long float array in row-major order, with: elements [0],[1],[2],[4],[5],[6],[8],[9],[10] forming the 3x3 transformation matrix; elements [12], [13], [14] corresponding to the t_x, t_y, t_z translation; elements [3], [7], [11] set to 0; element [15] set to 1. All methods are static.
Overview
Methods
Methods
multiply4x4(a, b)Static
Multiply two or more Transform matrix types to return a Transform matrix.
Parameters
Returns
multiply(a, b)Static
Fast-multiply two Transform matrix types to return a Matrix, assuming bottom row on each is [0 0 0 1].
Parameters
Returns
thenMove(m, t)Static
Return a Transform translated by additional amounts in each dimension. This is equivalent to the result of Transform.multiply(Matrix.translate(t[0], t[1], t[2]), m).
Parameters
Returns
moveThen(v, m)Static
Return a Transform matrix which represents the result of a transform matrix applied after a move. This is faster than the equivalent multiply. This is equivalent to the result of: Transform.multiply(m, Transform.translate(t[0], t[1], t[2])).
Parameters
Returns
translate(x, y, z)Static
Return a Transform which represents a translation by specified amounts in each dimension.
Parameters
Returns
thenScale(m, s)Static
Return a Transform scaled by a vector in each dimension. This is a more performant equivalent to the result of Transform.multiply(Transform.scale(s[0], s[1], s[2]), m).
Parameters
Returns
scale(x, y, z)Static
Return a Transform which represents a scale by specified amounts in each dimension.
Parameters
Returns
rotateX(theta)Static
Return a Transform which represents a clockwise rotation around the x axis.
Parameters
Returns
rotateY(theta)Static
Return a Transform which represents a clockwise rotation around the y axis.
Parameters
Returns
rotateZ(theta)Static
Return a Transform which represents a clockwise rotation around the z axis.
Parameters
Returns
rotate(phi, theta, psi)Static
Return a Transform which represents composed clockwise rotations along each of the axes. Equivalent to the result of Matrix.multiply(rotateX(phi), rotateY(theta), rotateZ(psi)).
Parameters
Returns
rotateAxis(v, theta)Static
Return a Transform which represents an axis-angle rotation
Parameters
Returns
aboutOrigin(v, m)Static
Return a Transform which represents a transform matrix applied about a separate origin point.
Parameters
Returns
skew(phi, theta, psi)Static
Return a Transform representation of a skew transformation
Parameters
Returns
skewX(angle)Static
Return a Transform representation of a skew in the x-direction
Parameters
Returns
skewY(angle)Static
Return a Transform representation of a skew in the y-direction
Parameters
Returns
perspective(focusZ)Static
Returns a perspective Transform matrix
Parameters
Returns
getTranslate(m)Static
Return translation vector component of given Transform
Parameters
Returns
inverse(m)Static
Return inverse affine transform for given Transform. Note: This assumes m[3] = m[7] = m[11] = 0, and m[15] = 1. Will provide incorrect results if not invertible or preconditions not met.
Parameters
Returns
transpose(m)Static
Returns the transpose of a 4x4 matrix
Parameters
Returns
interpret(M)Static
Decompose Transform into separate .translate, .rotate, .scale, and .skew components.
Parameters
Returns
average(M1, M2, t)Static
Weighted average between two matrices by averaging their translation, rotation, scale, skew components. f(M1,M2,t) = (1 - t) * M1 + t * M2
Parameters
Returns
build(spec)Static
Compose .translate, .rotate, .scale, .skew components into Transform matrix
Parameters
Returns
equals(a, b)Static
Determine if two Transforms are component-wise equal Warning: breaks on perspective Transforms
Parameters
Returns
notEquals(a, b)Static
Determine if two Transforms are component-wise unequal Warning: breaks on perspective Transforms
Parameters
Returns
normalizeRotation(rotation)Static
Constrain angle-trio components to range of [-pi, pi).
Parameters
Returns
inFront()Static
(Property) Array defining a translation forward in z by 1
behind()Static
(Property) Array defining a translation backwards in z by 1