Skip to content

editor › Globals › PhysicalObject

Class: PhysicalObject

A Physical object represents everything that is physically existing, e.g. a Plate or a Bend

Hierarchy

  • any

↳ PhysicalObject

↳ ExternalObject

↳ IkeaShelf

↳ DummyMesh

↳ Plate

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new PhysicalObject(uid: string): PhysicalObject

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:67

Parameters:

Name Type Default
uid string PseudoRandomString.generate(10)

Returns: PhysicalObject

Properties

Private assembly

• assembly: Assembly | null = null

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:54

Assembly this physical object is part of


Private compositeModel

• compositeModel: CompositeModel | null = null

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:49

reference to the composite model it belongs to


Private hints

• hints: object

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:60

Generic object that stores hints. Hints are small flags/settings that indicate how this object should be rendered, should be handled in the physics engine etc..

Type declaration:


Private joints

• joints: Joint[] = []

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:44

Physical connections to other physical objects


Private physicsShapeDirty

• physicsShapeDirty: boolean = true

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:31

Dirty flags for PhysicsFactory


Private physicsTransformsDirty

• physicsTransformsDirty: boolean = true

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:32


Private realizer

• realizer: IModelElementRealizer‹IModelElement› = null

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:65

Realizer which created this physical object


Private transforms

• transforms: Transforms = new Transforms()

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:26


Private Readonly uid

• uid: string

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:69


Private visible

• visible: boolean = true

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:67


Private visualizationShapeDirty

• visualizationShapeDirty: boolean = true

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:38

Flags for PhysicsFactory / VisualizationFactory that the visualization for this object needs to be changed or recreated


Private visualizationTransformsDirty

• visualizationTransformsDirty: boolean = true

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:39

Methods

Private _getAllConnectedPhysicalObjects

▸ _getAllConnectedPhysicalObjects(allObjs: Set‹PhysicalObject›, onlySameAssembly: boolean): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:673

Finds and puts all connected physical objects into the given set

Parameters:

Name Type Default Description
allObjs Set‹PhysicalObject› - The set to insert the new connected physical objects into
onlySameAssembly boolean true @see PhysicalObject#getAllConnectedPhysicalObjects

Returns: void


Private _getAllowedEvents

▸ _getAllowedEvents(): string[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:663

Possible events are - 'jointAdd' (physicalObject, joint, ownJointPossibility) - 'jointRemove' (physicalObject, joint) - 'transformsChange' (physicalObject)

Returns: string[]


addJoint

▸ addJoint(joint: Joint, ownJointPossibility: JointPossibility): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:289

Add a joint to the physical object. Only to be called from Joint constructor.

Parameters:

Name Type
joint Joint
ownJointPossibility JointPossibility

Returns: void


clearAssembly

▸ clearAssembly(): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:491

Clears the assembly. Only to be called by the composite model upon removal

Returns: void


clearCompositeModel

▸ clearCompositeModel(): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:325

Returns: void


getAllConnectedPhysicalObjects

▸ getAllConnectedPhysicalObjects(onlySameAssembly: boolean): PhysicalObject[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:280

Finds and returns all connected physical objects

Parameters:

Name Type Default Description
onlySameAssembly boolean true If set to true, joints that span over multiple assemblies (and the associated physical object) will be ignored

Returns: PhysicalObject[]

All connected physical objects


getAssembly

▸ getAssembly(): Assembly

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:495

Returns: Assembly


getAssemblyAABB

▸ getAssemblyAABB(): AABB

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:593

Returns: AABB


getAssemblyLocalPoints

▸ getAssemblyLocalPoints(exact: boolean): Vector3[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:589

Get points in assembly space roughly representing the shape of this object. This may not be an accurate rendering of all the points.

Parameters:

Name Type Default
exact boolean true

Returns: Vector3[]

The points in assembly space


getCompositeModel

▸ getCompositeModel(): CompositeModel

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:321

Returns: CompositeModel

The composite model this object belongs to


getHint

▸ getHint(key: string, defaultValue: any): any

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:535

Retrieve a hint for this object

Parameters:

Name Type Default Description
key string - The name of the hint
defaultValue any null Default value if hint is not defined Used hints: - (plate) passThroughPlate if true, the plate will not be attempted to be merged or joined with other plates upon export - (plate) importedJoints (An array of finger joints for use by the AssembleTool. Only set temporarily during the SVG import.) - (plate) physicsEngineThickness [Float] (Temporary thickness of the physical representation of the plate during push pull (collisionhandling).) - (externalObject) physicsEngineBodyType (One of: Body.DYNAMIC, Body.STATIC and Body.KINEMATIC see http://schteppe.github.io/cannon.js/docs/classes/Body.html) - (externalObject) ignoreWindSimulation [Boolean] (if true this object will be ignored in the wind simulation) - (externalObject) shading ('smooth' or 'flat' which equals with THREE.FlatShading or THREE.SmoothShading see https://threejs.org/docs/#Reference/Materials/MeshPhongMaterial.shading) - (externalObject) backgroundPartSpec the specs of the background part. Used for resetting background parts. - (any) lowQuality A hint for the renderer to render this physical object in lower quality. How this is achieved depends on the implementation of the renderer. - (externalObject) isSizeReferenceObject is used by the SizeReferenceTool. It flags Objects created by it to remove them, when a new SizeReferenceObject is created. - (physicalObject) notInteractable [Boolean] if true, tools cannot interact with this object

Returns: any


getJointPossibilities

▸ getJointPossibilities(interactionPoint: Vector3): Array‹object›

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:129

This is ancient code. There was a tool, that would assemble individual plates. It would ask each object for its joint possibilities and then match them up - nowadays, this is no longer needed, so subclasses don't have to implement this or can just return [].

Parameters:

Name Type Description
interactionPoint Vector3 Point of the interaction, in assembly coordinates

Returns: Array‹object›

An array of joint possibilities and their distance to the interaction point. Joint possibilities should not be returned if they are already joined and are unable to acccept new joints.


getJoints

▸ getJoints(): Joint[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:270

Returns: Joint[]

Array of all joints to other objects


getLocalAABB

▸ getLocalAABB(): AABB

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:621

This may not take into account all points, but only yields a rough representation.

Returns: AABB

This object's AABB in local space


getLowQualityRendering

▸ getLowQualityRendering(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:570

Returns: boolean


getNormal

▸ getNormal(space: "assembly" | "world", target: Vector3‹›): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:452

Parameters:

Name Type Default Description
space "assembly" | "world" "assembly" Defines the result coordinate system
target Vector3‹› new Vector3() (optional) Vector that will receive the calculation result

Returns: Vector3

The vector (0, 0, 1) transformed to assembly or world space


getObjectLocalPoints

▸ getObjectLocalPoints(exact: boolean): Vector3[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:580

Get points in local space roughly representing the shape of this object. This may not be an accurate rendering of all the points.

Parameters:

Name Type Default Description
exact boolean true If true, this method tries to be more exact in determining the points.

Returns: Vector3[]

The points in local space


getParent

▸ getParent(): ITransformable

Implementation of ITransformable

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:90

Returns: ITransformable


getPhysEngineBody

▸ getPhysEngineBody(): any

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:179

Returns: any

The physics simulation body associated with this physical object


getPhysicsShapeDirty

▸ getPhysicsShapeDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:250

Returns: boolean

Whether this object's shape should be considered dirty regarding its physics representation


getPhysicsTransformsDirty

▸ getPhysicsTransformsDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:257

Returns: boolean

Whether this object's transforms should be considered dirty regarding its physics representation


getPosition

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

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:137

Parameters:

Name Type Default
target Vector3‹› new Vector3()

Returns: Vector3‹›

Position of the object, in assembly space. If the object does not have an assembly assigned the position is in world space.


getRealizer

▸ getRealizer(): IModelElementRealizer‹IModelElement› | IModelElementRealizer‹Mesh›

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:82

Returns: IModelElementRealizer‹IModelElement› | IModelElementRealizer‹Mesh›


getRotation

▸ getRotation(target: Quaternion): Quaternion

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:158

Parameters:

Name Type Default
target Quaternion new Quaternion()

Returns: Quaternion

Rotation of the object, in assembly-local space


getTransforms

▸ getTransforms(): IReadOnlyTransforms

Implementation of ITransformable

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:86

Returns: IReadOnlyTransforms


getUid

▸ getUid(): string

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:74

Returns: string


getVisualizationShapeDirty

▸ getVisualizationShapeDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:236

Returns: boolean

Whether this object's shape should be considered dirty regarding its visualization


getVisualizationTransformsDirty

▸ getVisualizationTransformsDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:243

Returns: boolean

Whether this object's transforms should be considered dirty regarding its visualization


getWorldAABB

▸ getWorldAABB(): AABB

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:630

This may not take into account all points, but only yields a rough representation.

Returns: AABB

This object's AABB in world space


getWorldPoints

▸ getWorldPoints(exact: boolean): Vector3[]

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:607

Get points in world space roughly representing the shape of this object. This may not be an accurate rendering of all the points. Note: This is currently used by: - WaterSimulationAddOn to determine the submerged volume - PositionHintFilterStrategy to determine overlap of hints with objects in the scene - CameraMotion to detect view frustum fitting

Parameters:

Name Type Default
exact boolean true

Returns: Vector3[]

The points in world space


getWorldPosition

▸ getWorldPosition(): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:502

Maps the value of #getPosition through the assembly back to world, if an assembly is present.

Returns: Vector3


isConnectedToPhysicalObject

▸ isConnectedToPhysicalObject(physicalObject: PhysicalObject): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:461

Parameters:

Name Type
physicalObject PhysicalObject

Returns: boolean


isVisible

▸ isVisible(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:639

Returns: boolean


isolate

▸ isolate(onlyDestroyJointsTo: any[], keepJointsTo: any[]): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:105

Isolates the object within its assembly. Destroys all joints, further logic has to be implemented in subclasses

Parameters:

Name Type Default Description
onlyDestroyJointsTo any[] [] (optional) [Array] If set, only joints that connect this physical object to objects of the specified classes are getting destroyed
keepJointsTo any[] [] (optional) [Array] If set, joints that connect this physical object to objects of the specified classes are not deleted

Returns: void


mapAssemblyAxisToLocal

▸ mapAssemblyAxisToLocal(assemblyAxis: ReadonlyVector3, target?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:422

Deprecated: Use getTransforms().mapGlobalDirectionToLocal instead

deprecated

Parameters:

Name Type
assemblyAxis ReadonlyVector3
target? Vector3

Returns: Vector3


mapAssemblyToLocal

▸ mapAssemblyToLocal(assemblyPointOrQuaternion: Quaternion, targetPointOrQuaternion?: Quaternion): Quaternion

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:344

Deprecated: Use getTransforms().mapGlobalPositionToLocal or getTransforms().mapGlobalRotationToLocal instead

Maps a point/quaternion from the assembly coordinate system into the object local coordinate system (undo rotation and translation)

deprecated

Parameters:

Name Type
assemblyPointOrQuaternion Quaternion
targetPointOrQuaternion? Quaternion

Returns: Quaternion

▸ mapAssemblyToLocal(assemblyPointOrQuaternion: Vector3, targetPointOrQuaternion?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:346

deprecated

Parameters:

Name Type
assemblyPointOrQuaternion Vector3
targetPointOrQuaternion? Vector3

Returns: Vector3


mapLocalAxisToAssembly

▸ mapLocalAxisToAssembly(localAxis: Vector3, target?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:430

Deprecated: Use getTransforms().mapLocalDirectionToGlobal instead

deprecated

Parameters:

Name Type
localAxis Vector3
target? Vector3

Returns: Vector3


mapLocalAxisToWorld

▸ mapLocalAxisToWorld(localAxis: Vector3, target?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:434

Parameters:

Name Type
localAxis Vector3
target? Vector3

Returns: Vector3


mapLocalToAssembly

▸ mapLocalToAssembly(localPointOrQuaternion: Quaternion, targetPointOrQuaternion?: Quaternion): Quaternion

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:366

Deprecated: Use getTransforms().mapLocalPositionToGlobal or getTransforms().mapLocalRotationToGlobal instead

Maps a point/quaternion from the local coordinate system into the assembly system (applies rotation and translation)

deprecated

Parameters:

Name Type Description
localPointOrQuaternion Quaternion -
targetPointOrQuaternion? Quaternion -

Returns: Quaternion

▸ mapLocalToAssembly(localPointOrQuaternion: Vector3, targetPointOrQuaternion?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:368

deprecated

Parameters:

Name Type
localPointOrQuaternion Vector3
targetPointOrQuaternion? Vector3

Returns: Vector3


mapLocalToWorld

▸ mapLocalToWorld(localPointOrQuaternion: Quaternion, targetPointOrQuaternion?: Quaternion): Quaternion

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:397

Maps a point/quaternion from the object local coordinate system into the world system (using the assembly if set)

Parameters:

Name Type
localPointOrQuaternion Quaternion
targetPointOrQuaternion? Quaternion

Returns: Quaternion

▸ mapLocalToWorld(localPointOrQuaternion: Vector3, targetPointOrQuaternion?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:398

Parameters:

Name Type
localPointOrQuaternion Vector3
targetPointOrQuaternion? Vector3

Returns: Vector3


mapWorldAxisToLocal

▸ mapWorldAxisToLocal(worldAxis: ReadonlyVector3, target?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:412

Parameters:

Name Type
worldAxis ReadonlyVector3
target? Vector3

Returns: Vector3


mapWorldToLocal

▸ mapWorldToLocal(worldPointOrQuaternion: ReadonlyQuaternion, targetPointOrQuaternion?: Quaternion): Quaternion

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:381

Maps a point/quaternion from the world coordinate system into the object local system (using the assembly if set)

Parameters:

Name Type
worldPointOrQuaternion ReadonlyQuaternion
targetPointOrQuaternion? Quaternion

Returns: Quaternion

▸ mapWorldToLocal(worldPointOrQuaternion: ReadonlyVector3, targetPointOrQuaternion?: Vector3): Vector3

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:382

Parameters:

Name Type
worldPointOrQuaternion ReadonlyVector3
targetPointOrQuaternion? Vector3

Returns: Vector3


markPhysicsTransformsDirty

▸ markPhysicsTransformsDirty(): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:189

Returns: void


markShapeHasChanged

▸ markShapeHasChanged(): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:261

Returns: void


markTransformsHaveChanged

▸ markTransformsHaveChanged(): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:183

Returns: void


prepareForTransforms

▸ prepareForTransforms(): any

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:644

Returns: any


removeJoint

▸ removeJoint(joint: Joint): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:302

Removes a joint from the physical object. Only to be called from Joint.destroy()

Parameters:

Name Type
joint Joint

Returns: void


resetPhysicsShapeDirty

▸ resetPhysicsShapeDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:227

Resets the physicsTransformsDirty flag.

Returns: boolean

The state of the flag before reset


resetPhysicsTransformsDirty

▸ resetPhysicsTransformsDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:217

Resets the physicsShapeDirty flag.

Returns: boolean

The state of the flag before reset


resetVisualizationShapeDirty

▸ resetVisualizationShapeDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:207

Resets the visualizationTransformsDirty flag.

Returns: boolean

The state of the flag before reset


resetVisualizationTransformsDirty

▸ resetVisualizationTransformsDirty(): boolean

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:197

Resets the visualizationShapeDirty flag.

Returns: boolean

The state of the flag before reset


rotate

▸ rotate(rotation: Quaternion): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:172

Rotates this object around the local origin.

Parameters:

Name Type
rotation Quaternion

Returns: void


setAssembly

▸ setAssembly(newAssembly: Assembly, dueToMerge: boolean): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:475

Sets the assembly the object belongs to

Parameters:

Name Type Default Description
newAssembly Assembly - _ the new assembly the object belongs to
dueToMerge boolean false Indicates if this object is being re-assigned due to merging two assemblies

Returns: void


setCompositeModel

▸ setCompositeModel(compositeModel: CompositeModel): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:332

Parameters:

Name Type Description
compositeModel CompositeModel The composite model this object belongs to

Returns: void


setHint

▸ setHint(key: string, value: any): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:547

Sets a hint for this object

Parameters:

Name Type Description
key string The name of the hint
value any The value for this hint

Returns: void


setLowQualityRendering

▸ setLowQualityRendering(newValue: boolean): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:556

Sets a hint for low res rendering. If this value differs from the previous value, markShapeHasChanged will be called automatically for you.

Parameters:

Name Type Description
newValue boolean The value to set for the lowQuality hint

Returns: void


setPosition

▸ setPosition(position: Vector3): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:144

Parameters:

Name Type Description
position Vector3 New assembly-local position of the object

Returns: void


setRealizer

▸ setRealizer(realizer: IModelElementRealizer‹IModelElement›): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:78

Parameters:

Name Type
realizer IModelElementRealizer‹IModelElement›

Returns: void


setRotation

▸ setRotation(rotation: Quaternion): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:165

Parameters:

Name Type Description
rotation Quaternion New rotation quaternion in assembly-local space

Returns: void


setVisible

▸ setVisible(visibility: boolean): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:635

Parameters:

Name Type
visibility boolean

Returns: void


toString

▸ toString(): string

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:652

Returns: string


translate

▸ translate(translation: Vector3): void

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:151

Parameters:

Name Type Description
translation Vector3 Translates the object's position by translation

Returns: void


unprepareFromTransforms

▸ unprepareFromTransforms(params: any): any

Defined in src/model/data/PhysicalObject/PhysicalObject.ts:648

Parameters:

Name Type
params any

Returns: any