Skip to content

editorGlobalsTransforms

Class: Transforms

In addition to the coordinate system of IReadOnlyTransforms, this class also provides methods to modify the coordinate system and bind to change events.

Consider only exposing the IReadOnlyTransforms interface if you do not need to give "outsiders" modification access.

Hierarchy

  • Transforms

Implements

Index

Properties

Methods

Properties

Private Readonly changeEventEmitter

changeEventEmitter: EventEmitter‹void› = new EventEmitter()

Defined in src/util/Transforms.ts:199


Private globalToLocalMatrix

globalToLocalMatrix: Matrix4 = new Matrix4()

Defined in src/util/Transforms.ts:197


Private localToGlobalMatrix

localToGlobalMatrix: Matrix4 = new Matrix4()

Defined in src/util/Transforms.ts:196


Private matricesDirty

matricesDirty: boolean = true

Defined in src/util/Transforms.ts:198


Private position

position: Vector3 = new Vector3()

Defined in src/util/Transforms.ts:194


Private rotation

rotation: Quaternion = new Quaternion()

Defined in src/util/Transforms.ts:195


Static Private targetTransforms1

targetTransforms1: Transforms‹› = new Transforms()

Defined in src/util/Transforms.ts:69


Static Private targetTransforms2

targetTransforms2: Transforms‹› = new Transforms()

Defined in src/util/Transforms.ts:70

Methods

Private _transformsChanged

_transformsChanged(): void

Defined in src/util/Transforms.ts:394

Returns: void


Private _updateMatrices

_updateMatrices(): void

Defined in src/util/Transforms.ts:386

Returns: void


clone

clone(): Transforms

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:354

Returns: Transforms


concat

concat(otherTransforms: IReadOnlyTransforms, target: Transforms‹›): Transforms

Defined in src/util/Transforms.ts:230

Assuming this transforms map A -> B and otherTransforms map B -> C, return A -> C

Parameters:

Name Type Default Description
otherTransforms IReadOnlyTransforms - -
target Transforms‹› new Transforms() The target to write the result into

Returns: Transforms


copy

copy(transforms: IReadOnlyTransforms): this

Defined in src/util/Transforms.ts:372

Copies the transforms from the passed IReadOnlyTransforms into this.

Parameters:

Name Type Description
transforms IReadOnlyTransforms -

Returns: this


getChangeEventEmitter

getChangeEventEmitter(): IPublicEventEmitterInterface‹void›

Defined in src/util/Transforms.ts:346

Returns: IPublicEventEmitterInterface‹void›


getGlobalToLocalMatrix

getGlobalToLocalMatrix(): Matrix4

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:350

Returns: Matrix4


getPosition

getPosition(target: Vector3‹›): Vector3‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:244

Parameters:

Name Type Default
target Vector3‹› new Vector3()

Returns: Vector3‹›


getRotation

getRotation(target: Quaternion‹›): Quaternion‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:260

Parameters:

Name Type Default
target Quaternion‹› new Quaternion()

Returns: Quaternion‹›


invert

invert(): this

Defined in src/util/Transforms.ts:361

Returns: this


isIdentityTransform

isIdentityTransform(): boolean

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:382

Returns whether this Transforms is at position (0,0,0) and has no rotation.

Returns: boolean


mapGlobalDirectionToLocal

mapGlobalDirectionToLocal(globalDirection: ReadonlyVector3, target?: Vector3): Vector3‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:333

Parameters:

Name Type
globalDirection ReadonlyVector3
target? Vector3

Returns: Vector3‹›


mapGlobalPlaneToLocal

mapGlobalPlaneToLocal(plane: Plane, target?: Plane): Plane

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:213

Parameters:

Name Type
plane Plane
target? Plane

Returns: Plane


mapGlobalPositionToLocal

mapGlobalPositionToLocal(globalPosition: ReadonlyVector3, target?: Vector3): Vector3‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:314

Parameters:

Name Type
globalPosition ReadonlyVector3
target? Vector3

Returns: Vector3‹›


mapGlobalRotationToLocal

mapGlobalRotationToLocal(globalRotation: Quaternion, target: Quaternion‹›): Quaternion‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:326

Parameters:

Name Type Default
globalRotation Quaternion -
target Quaternion‹› new Quaternion()

Returns: Quaternion‹›


mapLocalDirectionToGlobal

mapLocalDirectionToGlobal(localDirection: Vector3, target?: Vector3): Vector3

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:301

Parameters:

Name Type
localDirection Vector3
target? Vector3

Returns: Vector3


mapLocalPlaneToGlobal

mapLocalPlaneToGlobal(plane: Plane, target?: Plane): Plane

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:201

Parameters:

Name Type
plane Plane
target? Plane

Returns: Plane


mapLocalPosition2DToGlobal

mapLocalPosition2DToGlobal(localPosition: ReadonlyVector2, target: Vector3): Vector3‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:279

Parameters:

Name Type Default
localPosition ReadonlyVector2 -
target Vector3 new Vector3()

Returns: Vector3‹›


mapLocalPositionToGlobal

mapLocalPositionToGlobal(localPosition: ReadonlyVector3, target: Vector3): Vector3

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:287

Parameters:

Name Type Default
localPosition ReadonlyVector3 -
target Vector3 new Vector3()

Returns: Vector3


mapLocalRotationToGlobal

mapLocalRotationToGlobal(localRotation: ReadonlyQuaternion, target: Quaternion‹›): Quaternion‹›

Implementation of IReadOnlyTransforms

Defined in src/util/Transforms.ts:295

Parameters:

Name Type Default
localRotation ReadonlyQuaternion -
target Quaternion‹› new Quaternion()

Returns: Quaternion‹›


rotate

rotate(rotation: Quaternion): void

Defined in src/util/Transforms.ts:264

Parameters:

Name Type
rotation Quaternion

Returns: void


rotateAround

rotateAround(rotation: Quaternion, rotationCenter: ReadonlyVector3): void

Defined in src/util/Transforms.ts:270

Parameters:

Name Type
rotation Quaternion
rotationCenter ReadonlyVector3

Returns: void


setPosition

setPosition(position: ReadonlyVector3): this

Defined in src/util/Transforms.ts:238

Parameters:

Name Type
position ReadonlyVector3

Returns: this


setRotation

setRotation(rotation: Quaternion): this

Defined in src/util/Transforms.ts:254

Parameters:

Name Type
rotation Quaternion

Returns: this


translate

translate(translation: Vector3): this

Defined in src/util/Transforms.ts:248

Parameters:

Name Type
translation Vector3

Returns: this


Static Private _mapToTransforms

_mapToTransforms(elementsOrTransforms: Array‹IReadOnlyTransforms | ITransformable›): IReadOnlyTransforms[]

Defined in src/util/Transforms.ts:181

Each element which is a IPositionableElement will be mapped to a IReadOnlyTransforms

Parameters:

Name Type
elementsOrTransforms Array‹IReadOnlyTransforms | ITransformable

Returns: IReadOnlyTransforms[]


Static chain

chain(...elements: Array‹IReadOnlyTransforms | ITransformable›): Transforms

Defined in src/util/Transforms.ts:78

Chains Transforms together to one Transforms. If the first Transforms maps A -> B and second maps B -> C, the returned Transforms maps A -> C

Parameters:

Name Type Description
...elements Array‹IReadOnlyTransforms | ITransformable The objects to chain (different types can be mixed)

Returns: Transforms

an IReadOnlyTransforms which is created by concatenating all given Transforms


Static chainIntoTarget

chainIntoTarget(target: Transforms, ...elements: Array‹IReadOnlyTransforms | ITransformable›): Transforms

Defined in src/util/Transforms.ts:89

Chains Transforms together to one Transforms stored in target. If the first Transforms maps A -> B and second maps B -> C, the returned Transforms maps A -> C

Parameters:

Name Type Description
target Transforms result will be stored here
...elements Array‹IReadOnlyTransforms | ITransformable The objects to chain (different types can be mixed)

Returns: Transforms

an IReadOnlyTransforms which is created by concatenating all given Transforms


Static getMappingBetween

getMappingBetween(from: ITransformable | null, to: ITransformable | null): Transforms

Defined in src/util/Transforms.ts:147

Returns the Transforms between both coordinate systems. In the returned transforms from is global and to local. To map to or from the world coordinate system, pass null as from or to (Example 3 below).

For readability the first parameter should be in a higher space than the second.

Example 1:

const meshPoint = Transforms.getMappingBetween(mesh, plate).mapLocalPositionToGlobal(platePoint);

Example 2:

const plateRotation = Transforms.getMappingBetween(assembly, plate).mapGlobalRotationToLocal(assemblyRotation);

Example 3:

const meshPoint = Transforms.getMappingBetween(null, mesh).mapGlobalPositionToLocal(worldPoint);

Parameters:

Name Type Description
from ITransformable | null the coordinate system which will be global (null for world)
to ITransformable | null the coordinate system which will be local (null for world)

Returns: Transforms

a transforms where from is global and to is local


Static makeTransformable

makeTransformable(transforms: IReadOnlyTransforms, parent: ITransformable | null): ITransformable

Defined in src/util/Transforms.ts:115

Can be used to use getMappingBetween without an object implementing ITransformable

Example:

Transforms.getMappingBetween(
    Transforms.makeTransformable(anchor.getTransforms(), assembly),
    mesh,
)

Parameters:

Name Type
transforms IReadOnlyTransforms
parent ITransformable | null

Returns: ITransformable