@awayjs/core
Version:
AwayJS core classes
323 lines • 11.2 kB
TypeScript
import { EventDispatcher } from '../events/EventDispatcher';
import { Matrix } from '../geom/Matrix';
import { Matrix3D } from '../geom/Matrix3D';
import { Rectangle } from '../geom/Rectangle';
import { Vector3D } from '../geom/Vector3D';
import { ColorTransform } from './ColorTransform';
/**
* The Transform class provides access to color adjustment properties and two-
* or three-dimensional transformation objects that can be applied to a display
* object. During the transformation, the color or the orientation and position
* of a display object is adjusted(offset) from the current values or
* coordinates to new values or coordinates. The Transform class also collects
* data about color and two-dimensional matrix transformations that are applied
* to a display object and all of its parent objects. You can access these
* combined transformations through the `concatenatedColorTransform` and
* `concatenatedMatrix` properties.
*
* To apply color transformations: create a ColorTransform object, set the color
* adjustments using the object's methods and properties, and then assign the
* `colorTransformation` property of the `transform` property of the display
* object to the new ColorTransformation object.
*
* To apply two-dimensional transformations: create a Matrix object, set the
* matrix's two-dimensional transformation, and then assign the
* `transform.matrix` property of the display object to the new Matrix object.
*
* To apply three-dimensional transformations: start with a three-dimensional
* display object. A three-dimensional display object has a `z` property value
* other than zero. You do not need to create the Matrix3D object. For all
* three-dimensional objects, a Matrix3D object is created automatically when
* you assign a `z` value to a display object. You can access the display
* object's Matrix3D object through the display object's `transform` property.
* Using the methods of the Matrix3D class, you can add to or modify the
* existing transformation settings. Also, you can create a custom Matrix3D
* object, set the custom Matrix3D object's transformation elements, and then
* assign the new Matrix3D object to the display object using the
* `transform.matrix` property.
*
* To modify a perspective projection of the stage or root object: use the
* `transform.matrix` property of the root display object to gain access to the
* PerspectiveProjection object. Or, apply different perspective projection
* properties to a display object by setting the perspective projection
* properties of the display object's parent. The child display object inherits
* the new properties. Specifically, create a PerspectiveProjection object and
* set its properties, then assign the PerspectiveProjection object to the
* `perspectiveProjection` property of the parent display object's `transform`
* property. The specified projection transformation then applies to all the
* display object's three-dimensional children.
*
* Since both PerspectiveProjection and Matrix3D objects perform perspective
* transformations, do not assign both to a display object at the same time. Use
* the PerspectiveProjection object for focal length and projection center
* changes. For more control over the perspective transformation, create a
* perspective projection Matrix3D object.
*/
export declare class Transform extends EventDispatcher {
private static _tempVector;
private _backVector;
private _colorTransform;
private _components;
private _componentsDirty;
private _downVector;
private _forwardVector;
private _invalidateColorTransform;
private _invalidateMatrix3D;
private _inverseMatrix3D;
private _inverseMatrix3DDirty;
private _leftVector;
private _matrix;
private _matrix3D;
private _matrix3DDirty;
private _pixelBounds;
private _rawData;
private _rawDataComponents;
private _rightVector;
private _rotation;
private _scale;
private _skew;
private _upVector;
/**
*
*/
get backVector(): Vector3D;
/**
* A ColorTransform object containing values that universally adjust the
* colors in the display object.
*
* @throws TypeError The colorTransform is null when being set
*/
get colorTransform(): ColorTransform;
set colorTransform(val: ColorTransform);
/**
*
*/
get inverseMatrix3D(): Matrix3D;
/**
*
*/
get downVector(): Vector3D;
/**
*
*/
get forwardVector(): Vector3D;
/**
*
*/
get leftVector(): Vector3D;
/**
* A Matrix object containing values that alter the scaling, rotation, and
* translation of the display object. If the `matrix` property is set to a
* value (not `null`), the `matrix3D` property is `null`. And if the
* `matrix3D` property is set to a value(not `null`), the `matrix` property
* is `null`.
*
* @throws TypeError The matrix is null when being set
*/
get matrix(): Matrix;
set matrix(value: Matrix);
/**
* Provides access to the Matrix3D object of a three-dimensional display
* object. The Matrix3D object represents a transformation matrix that
* determines the display object's position and orientation. A Matrix3D
* object can also perform perspective projection.
*
* If the `matrix` property is set to a value(not `null`), the `matrix3D`
* property is `null`. And if the `matrix3D` property is set to a value(not
* `null`), the `matrix` property is `null`.
*/
get matrix3D(): Matrix3D;
set matrix3D(val: Matrix3D);
/**
* A Rectangle object that defines the bounding rectangle of the display
* object on the stage.
*/
get pixelBounds(): Rectangle;
/**
* Defines the position of the 3d object, relative to the local coordinates
* of the parent `ObjectContainer3D`.
*/
get position(): Vector3D;
/**
*
*/
get rightVector(): Vector3D;
/**
* Defines the rotation of the 3d object, relative to the local coordinates
* of the parent `ObjectContainer3D` .
*/
get rotation(): Vector3D;
/**
* Defines the scale of the 3d object, relative to the local coordinates of
* the parent `ObjectContainer3D` .
*/
get scale(): Vector3D;
/**
* Defines the scale of the 3d object, relative to the local coordinates of
* the parent `ObjectContainer3D` .
*/
get skew(): Vector3D;
/**
*
*/
get upVector(): Vector3D;
constructor(rawData?: Float32Array);
/**
*
* @param value
*/
append(value: Matrix3D): void;
/**
*
*/
clearColorTransform(): void;
/**
*
*/
clearMatrix3D(): void;
/**
*
*/
clone(): Transform;
/**
*
* @param transform
*/
copyRawDataTo(transform: Transform): void;
/**
*
*/
dispose(): void;
invalidateColorTransform(): void;
invalidateComponents(): void;
/**
* Invalidates the 3D transformation matrix, causing it to be updated upon the next request
*
* @private
*/
invalidateMatrix3D(): void;
/**
*
*/
invalidatePosition(): void;
/**
* Rotates the 3d object around to face a point defined relative to the
* local coordinates of the parent `ObjectContainer3D` .
*
* @param target The vector defining the point to be looked at.
* @param upAxis An optional vector used to define the desired up
* orientation of the 3d object after rotation has occurred.
*/
lookAt(position: Vector3D, upAxis?: Vector3D): void;
/**
* Moves the 3d object backwards along it's local z axis
*
* @param distance The length of the movement
*/
moveBackward(distance: number): void;
/**
* Moves the 3d object backwards along it's local y axis
*
* @param distance The length of the movement
*/
moveDown(distance: number): void;
/**
* Moves the 3d object forwards along it's local z axis
*
* @param distance The length of the movement
*/
moveForward(distance: number): void;
/**
* Moves the 3d object backwards along it's local x axis
*
* @param distance The length of the movement
*/
moveLeft(distance: number): void;
/**
* Moves the 3d object forwards along it's local x axis
*
* @param distance The length of the movement
*/
moveRight(distance: number): void;
/**
* Moves the 3d object directly to a point in space
*
* @param dx The amount of movement along the local x axis.
* @param dy The amount of movement along the local y axis.
* @param dz The amount of movement along the local z axis.
*/
moveTo(dx: number, dy: number, dz: number): void;
/**
* Moves the 3d object forwards along it's local y axis
*
* @param distance The length of the movement
*/
moveUp(distance: number): void;
/**
* Rotates the 3d object around it's local x-axis
*
* @param angle The amount of rotation in degrees
*/
pitch(angle: number): void;
/**
* Rotates the 3d object around it's local z-axis
*
* @param angle The amount of rotation in degrees
*/
roll(angle: number): void;
/**
* Rotates the 3d object around an axis by a defined angle
*
* @param axis The vector defining the axis of rotation
* @param angle The amount of rotation in degrees
*/
rotate(axis: Vector3D, angle: number): void;
/**
* Rotates the 3d object directly to a euler angle
*
* @param ax The angle in degrees of the rotation around the x axis.
* @param ay The angle in degrees of the rotation around the y axis.
* @param az The angle in degrees of the rotation around the z axis.
*/
rotateTo(ax: number, ay: number, az: number): void;
/**
*
* @param sx
* @param sy
* @param sz
*/
scaleTo(sx: number, sy: number, sz: number): void;
/**
*
* @param sx
* @param sy
* @param sz
*/
skewTo(sx: number, sy: number, sz: number): void;
/**
* Moves the 3d object along a vector by a defined length.
*
* @param axis The vector defining the axis of movement.
* @param distance The length of the movement.
*/
translate(axis: Vector3D, distance: number): void;
/**
* Moves the 3d object along a vector by a defined length.
*
* @param axis The vector defining the axis of movement.
* @param distance The length of the movement.
*/
translateLocal(axis: Vector3D, distance: number): void;
/**
*
*/
updateMatrix3D(): void;
/**
* Rotates the 3d object around it's local y-axis
*
* @param angle The amount of rotation in degrees
*/
yaw(angle: number): void;
private _updateComponents;
}
//# sourceMappingURL=Transform.d.ts.map