import type { Euler } from "three/src/Three"; import { Matrix4, Object3D, Quaternion, Vector3 } from "three/src/Three"; import type { ReadonlyVector3 } from "../math/ReadonlyVector3"; import type { GameObject } from "./GameObject"; /** * transform that delegates Object3D * do not drive this class */ export declare class Transform { private static readonly _transformObject3D; private readonly _object3D; private readonly _gameObject; private readonly _engineGlobalObject; private readonly _onParentChanged; private readonly _worldPosition; private readonly _worldRotationEuler; private readonly _worldRotation; private readonly _worldScale; private _hasChanged; private _localMatrixNeedUpdate; private _worldMatrixNeedUpdate; private _worldPositionRotationScaleNeedUpdate; private _localPositionRotationScaleNeedUpdate; private readonly _onBeforeGetLocalBind; private readonly _onBeforeLocalChangeBind; private readonly _onLocalEulerRotationChangedBind; private readonly _onLocalRotationChangedBind; private readonly _onBeforeGetWorldBind; private readonly _onBeforeWorldChangeBind; private readonly _onWorldEulerRotationChangedBind; private readonly _onWorldRotationChangedBind; private _ignoreObservableEvent; private onBeforeGetLocal; private onBeforeLocalChange; private onLocalEulerRotationChanged; private onLocalRotationChanged; private onBeforeGetWorld; private onBeforeWorldChange; private onWorldEulerRotationChanged; private onWorldRotationChanged; private setWorldPositionRotationScaleNeedUpdateRecursively; private setChildrenWorldPositionRotationScaleNeedUpdateRecursively; private setWorldMatrixNeedUpdateRecursively; private setWorldMatrixNeedUpdateRecursivelyInternal; private setHasChangedRecursively; private static readonly _matrix4Buffer; private updateLocalPositionRotationScaleFromOthers; private updateWorldPositionRotationScaleFromOthers; private updateWorldMatrixFromLocalMatrixAndParentWorldMatrix; private updateLocalMatrixFromOthers; private updateLocalPositionRotationScaleFromOthersRecursively; private updateChildrenLocalPositionRotationScaleFromOthersRecursively; private tryUpdateWorldMatrixRecursivelyFromThisToChildrenInternal; /** * foreach children transform * * you must not change length of children array while iterating * @param callback */ foreachChild(callback: (transform: Transform) => void): void; /** * iterate children transfrom * * you must not change length of children array while iterating * @param callback if return false, stop iteration */ iterateChild(callback: (transform: Transform) => boolean): void; /** * get parent. if parent is scene, returns null */ get parent(): Transform | null; /** * set parent, if value is null, set to scene * * you can't set parent that in another engine instance */ set parent(value: Transform | null); setParent(parent: Transform | null, worldPositionStays?: boolean): void; /** * get children. it returns new instance of Array, so you can change it */ get children(): Transform[]; /** * get gameObject of this transform */ get gameObject(): GameObject; private static readonly _vector3Buffer; /** * Returns a normalized vector representing the blue axis of the transform in world space. * @param target optional, target vector */ getForward(target?: Vector3): Vector3; /** * set vector representing the blue axis of the transform in world space. */ setForward(value: ReadonlyVector3): void; /** * The red axis of the transform in world space. * @param target optional, target vector */ getRight(target?: Vector3): Vector3; /** * set vector representing the red axis of the transform in world space. */ setRight(value: ReadonlyVector3): void; /** * The green axis of the transform in world space. * @param target optional, target vector */ getUp(target?: Vector3): Vector3; /** * set vector representing the green axis of the transform in world space. */ setUp(value: ReadonlyVector3): void; /** * Object's local position. * @default new THREE.Vector3() */ get localPosition(): Vector3; /** * Object's local rotation (Euler angles), in radians. * @default new THREE.Euler() */ get localEulerAngles(): Euler; /** * Object's local rotation as a Quaternion. * @default new THREE.Quaternion() */ get localRotation(): Quaternion; /** * Object's local scale. * @default new THREE.Vector3() */ get localScale(): Vector3; /** * Object's world position. */ get position(): Vector3; /** * Object's world rotation (Euler angles), in radians. */ get eulerAngles(): Euler; /** * Object's world rotation as a Quaternion. */ get rotation(): Quaternion; /** * Object's world scale. */ get lossyScale(): ReadonlyVector3; /** * Has the transform changed since the last time the flag was set to 'false'? */ get hasChanged(): boolean; /** * Has the transform changed since the last time the flag was set to 'false'? * @param value */ set hasChanged(value: boolean); /** * world to local matrix * @param target optional, target matrix */ getWorldToLocalMatrix(target?: Matrix4): Matrix4; /** * local to world matrix * @param target optional, target matrix */ getLocalToWorldMatrix(target?: Matrix4): Matrix4; /** * Transforms position from local space to world space. * @param position A local position. */ transformPoint(position: Vector3): Vector3; /** * Transforms position from world space to local space. * @param position A world position. */ inverseTransformPoint(position: Vector3): Vector3; /** * Transforms direction from local space to world space. * This operation is not affected by scale or position of the transform. The returned vector has the same length as direction. * @param direction A local direction. */ transformDirection(direction: Vector3): Vector3; /** * Transforms direction from world space to local space. * This operation is unaffected by scale. * @param direction A world direction. */ inverseTransformDirection(direction: Vector3): Vector3; /** * Transforms vector from local space to world space. * This operation is not affected by position of the transform, but it is affected by scale. The returned vector may have a different length than vector. * @param vector A local vector. */ transformVector(vector: Vector3): Vector3; /** * Transforms a vector from world space to local space. The opposite of Transform.TransformVector. * This operation is affected by scale. */ inverseTransformVector(vector: Vector3): Vector3; /** * Is this transform a child of parent? * @returns a boolean value that indicates whether the transform is a child of a given transform. true if this transform is a child, deep child (child of a child) or identical to this transform, otherwise false. */ isChildOf(parent: Transform): boolean; private static readonly _quaternionBuffer; /** * Rotates object to face point in space. * @param vector A world vector to look at. */ lookAt(vector: Vector3): void; setRotationFromAxisAngle(axis: Vector3, angle: number): void; setRotationFromEuler(euler: Euler): void; setRotationFromMatrix(m: Matrix4): void; setRotationFromQuaternion(q: Quaternion): void; /** * Rotate an object along an axis in object space. The axis is assumed to be normalized. * @param axis A normalized vector in object space. * @param angle The angle in radians. */ rotateOnAxis(axis: Vector3, angle: number): this; /** * Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent. * @param axis A normalized vector in object space. * @param angle The angle in radians. */ rotateOnWorldAxis(axis: Vector3, angle: number): this; /** * * @param angle */ rotateX(angle: number): this; /** * * @param angle */ rotateY(angle: number): this; /** * * @param angle */ rotateZ(angle: number): this; /** * @param axis A normalized vector in object space. * @param distance The distance to translate. */ translateOnAxis(axis: Vector3, distance: number): this; /** * Translates object along x axis by distance. * @param distance Distance. */ translateX(distance: number): this; /** * Translates object along y axis by distance. * @param distance Distance. */ translateY(distance: number): this; /** * Translates object along z axis by distance. * @param distance Distance. */ translateZ(distance: number): this; /** * get Object3D of the GameObject. you can use this to add three.js Object3D to the scene * if you want to add a custom Object3D to the scene, you must manage the lifecycle of the Object3D yourself * * see also: * "Object3D.visible" property has same value as "GameObject.activeInHierarchy" * you must not change "Object3D.visible" directly, use "GameObject.activeInHierarchy" instead * "Object3D.add" method is not available for GameObject Transform it for other Object3D classes */ unsafeGetObject3D(): Object3D; enqueueRenderAttachedObject3D(rerenderObject: Object3D): void; dequeueRenderAttachedObject3D(rerenderObject: Object3D): void; static updateRawObject3DWorldMatrixRecursively(object3D: Object3D): void; private static updateRawObject3DWorldMatrixRecursivelyInternal; }