
Transformations helper class to store 2d position, rotation and scale. Can also perform transformations inheritance, where we combine local with parent transformations.
NumberCombine child scalar value with parent using a transformation mode.
Vector2Combine child vector value with parent using a transformation mode.
Vector2Combine child vector value with parent using a transformation mode and multiplication.
Transformations helper class to store 2d position, rotation and scale. Can also perform transformations inheritance, where we combine local with parent transformations.
Kind: global class
functionVector2TransformModesTransformationTransformationTransformationTransformationTransformationVector2TransformModesTransformationTransformationTransformationTransformationTransformationNumberNumberNumberTransformModesTransformationTransformationTransformationTransformationTransformationBooleanTransformationMatrixCreate the transformations.
| Param | Type | Description |
|---|---|---|
| position | Vector2 |
Optional position value. |
| rotation | Number |
Optional rotation value. |
| scale | Vector2 |
Optional sscale value. |
Example
// create local and world transformations
const transform = new Shaku.utils.Transformation();
const worldTransform = new Shaku.utils.Transformation();
// set offset to world transofm and rotation to local transform
worldTransform.setPosition({x: 100, y:50});
transform.setRotation(5);
// combine transformations and convert to a matrix
const combined = Shaku.utils.Transformation.combine(transform, worldTransform);
const matrix = combined.asMatrix();
functionMethod to call when this transformation change. Function params: transformation instance (this), properties changed (boolean), transform modes changed (boolean).
Kind: instance property of Transformation
Vector2Get position.
Kind: instance method of Transformation
Returns: Vector2 - Position.
TransformModesGet position transformations mode.
Kind: instance method of Transformation
Returns: TransformModes - Position transformation mode.
TransformationSet position.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Vector2 |
New position. |
TransformationSet position X value.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New position.x value. |
TransformationSet position Y value.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New position.y value. |
TransformationMove position by a given vector.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Vector2 |
Vector to move position by. |
TransformationSet position transformations mode.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | TransformModes |
Position transformation mode. |
Vector2Get scale.
Kind: instance method of Transformation
Returns: Vector2 - Scale.
TransformModesGet scale transformations mode.
Kind: instance method of Transformation
Returns: TransformModes - Scale transformation mode.
TransformationSet scale.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Vector2 |
New scale. |
TransformationSet scale X value.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New scale.x value. |
TransformationSet scale Y value.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New scale.y value. |
TransformationScale by a given vector.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Vector2 |
Vector to scale by. |
TransformationSet scale transformations mode.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | TransformModes |
Scale transformation mode. |
NumberGet rotation.
Kind: instance method of Transformation
Returns: Number - rotation.
NumberGet rotation as degrees.
Kind: instance method of Transformation
Returns: Number - rotation.
NumberGet rotation as degrees, wrapped between 0 to 360.
Kind: instance method of Transformation
Returns: Number - rotation.
TransformModesGet rotation transformations mode.
Kind: instance method of Transformation
Returns: TransformModes - Rotation transformations mode.
TransformationSet rotation.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New rotation. |
| wrap | Boolean |
If true, will wrap value if out of possible range. |
TransformationRotate transformation by given radians.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
Rotate value in radians. |
| wrap | Boolean |
If true, will wrap value if out of possible range. |
TransformationSet rotation as degrees.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
New rotation. |
| wrap | Boolean |
If true, will wrap value if out of possible range. |
TransformationRotate transformation by given degrees.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | Number |
Rotate value in degrees. |
TransformationSet rotation transformations mode.
Kind: instance method of Transformation
Returns: Transformation - this.
| Param | Type | Description |
|---|---|---|
| value | TransformModes |
Rotation transformation mode. |
BooleanCheck if this transformation equals another.
Kind: instance method of Transformation
Returns: Boolean - True if equal, false otherwise.
| Param | Type | Description |
|---|---|---|
| other | Transformation |
Other transform to compare to. |
TransformationReturn a clone of this transformations.
Kind: instance method of Transformation
Returns: Transformation - Cloned transformations.
Serialize this transformation into a dictionary.
Kind: instance method of Transformation
Deserialize this transformation from a dictionary.
Kind: instance method of Transformation
| Param | Type | Description |
|---|---|---|
| data | \* |
Data to set. |
MatrixCreate and return a transformation matrix.
Kind: instance method of Transformation
Returns: Matrix - New transformation matrix.
TransformationCombine child transformations with parent transformations.
Kind: static method of Transformation
Returns: Transformation - Combined transformations.
| Param | Type | Description |
|---|---|---|
| child | Transformation |
Child transformations. |
| parent | Transformation |
Parent transformations. |
NumberCombine child scalar value with parent using a transformation mode.
Kind: global function
Returns: Number - Combined value.
| Param | Type | Description |
|---|---|---|
| childValue | Number |
Child value. |
| parentValue | Number |
Parent value. |
| parent | Transformation |
Parent transformations. |
| mode | TransformModes |
Transformation mode. |
Vector2Combine child vector value with parent using a transformation mode.
Kind: global function
Returns: Vector2 - Combined value.
| Param | Type | Description |
|---|---|---|
| childValue | Vector2 |
Child value. |
| parentValue | Vector2 |
Parent value. |
| parent | Transformation |
Parent transformations. |
| mode | TransformModes |
Transformation mode. |
Vector2Combine child vector value with parent using a transformation mode and multiplication.
Kind: global function
Returns: Vector2 - Combined value.
| Param | Type | Description |
|---|---|---|
| childValue | Vector2 |
Child value. |
| parentValue | Vector2 |
Parent value. |
| parent | Transformation |
Parent transformations. |
| mode | TransformModes |
Transformation mode. |