@babylonjs/core 5.43.0 → 5.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/sound.d.ts +2 -1
- package/Audio/sound.js +27 -26
- package/Audio/sound.js.map +1 -1
- package/Debug/physicsViewer.d.ts +59 -4
- package/Debug/physicsViewer.js +115 -7
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/ICanvas.d.ts +1 -1
- package/Engines/ICanvas.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +10 -9
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/effect.js +1 -1
- package/Materials/effect.js.map +1 -1
- package/Meshes/linesMesh.d.ts +2 -1
- package/Meshes/linesMesh.js +1 -2
- package/Meshes/linesMesh.js.map +1 -1
- package/Misc/observable.js +7 -4
- package/Misc/observable.js.map +1 -1
- package/Physics/joinedPhysicsEngineComponent.d.ts +84 -0
- package/Physics/joinedPhysicsEngineComponent.js +144 -0
- package/Physics/joinedPhysicsEngineComponent.js.map +1 -0
- package/Physics/physicsEngineComponent.d.ts +2 -84
- package/Physics/physicsEngineComponent.js +3 -143
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +4 -2
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +126 -28
- package/Physics/v2/physicsBody.js +127 -31
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +26 -7
- package/Physics/v2/physicsConstraint.js +23 -7
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngine.js +0 -7
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +4 -3
- package/Physics/v2/physicsEngineComponent.js +6 -5
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/physicsMaterial.d.ts +38 -11
- package/Physics/v2/physicsMaterial.js +35 -11
- package/Physics/v2/physicsMaterial.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +24 -15
- package/Physics/v2/physicsShape.js +17 -11
- package/Physics/v2/physicsShape.js.map +1 -1
- package/Shaders/fluidRenderingBilateralBlur.fragment.js +1 -1
- package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -1
- package/Shaders/fluidRenderingRender.fragment.js +2 -2
- package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
- package/Shaders/fluidRenderingStandardBlur.fragment.js +1 -1
- package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -1
- package/assetContainer.d.ts +4 -0
- package/assetContainer.js +17 -0
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAUA,gBAAgB;AAChB,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IAC/B,qEAAI,CAAA;IACJ,2EAAO,CAAA;IACP,yEAAM,CAAA;IACN,qEAAI,CAAA;AACR,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,cAQX;AARD,WAAY,cAAc;IACtB,2DAAQ,CAAA;IACR,2DAAQ,CAAA;IACR,2DAAQ,CAAA;IACR,6DAAS,CAAA;IACT,6DAAS,CAAA;IACT,6DAAS,CAAA;IACT,yEAAe,CAAA;AACnB,CAAC,EARW,cAAc,KAAd,cAAc,QAQzB;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACtB,yEAAe,CAAA;IACf,2DAAQ,CAAA;IACR,qDAAK,CAAA;IACL,uDAAM,CAAA;IACN,mDAAI,CAAA;AACR,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACjB,6CAAM,CAAA;IACN,+CAAO,CAAA;IACP,iDAAQ,CAAA;IACR,uCAAG,CAAA;IACH,uDAAW,CAAA;IACX,mDAAS,CAAA;IACT,yCAAI,CAAA;IACJ,uDAAW,CAAA;AACf,CAAC,EATW,SAAS,KAAT,SAAS,QASpB;AAED,gBAAgB;AAChB,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC3B,6DAAI,CAAA;IACJ,qEAAQ,CAAA;IACR,qEAAQ,CAAA;AACZ,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\n\r\n/** @internal */\r\nexport enum ConstraintAxisLimitMode {\r\n FREE,\r\n LIMITED,\r\n LOCKED,\r\n NONE,\r\n}\r\n\r\n/** @internal */\r\nexport enum ConstraintAxis {\r\n LINEAR_X,\r\n LINEAR_Y,\r\n LINEAR_Z,\r\n ANGULAR_X,\r\n ANGULAR_Y,\r\n ANGULAR_Z,\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** @internal */\r\nexport enum ConstraintType {\r\n BALL_AND_SOCKET,\r\n DISTANCE,\r\n HINGE,\r\n SLIDER,\r\n LOCK,\r\n}\r\n\r\n/** @internal */\r\nexport enum ShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** @internal */\r\nexport enum ConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\n/** @internal */\r\nexport interface PhysicsShapeParameters {\r\n center?: Vector3;\r\n radius?: number;\r\n pointA?: Vector3;\r\n pointB?: Vector3;\r\n rotation?: Quaternion;\r\n extents?: Vector3;\r\n mesh?: Mesh;\r\n includeChildMeshes?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport interface PhysicsConstraintParameters {\r\n pivotA?: Vector3;\r\n pivotB?: Vector3;\r\n axisA?: Vector3;\r\n axisB?: Vector3;\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport interface MassProperties {\r\n /**\r\n *\r\n */\r\n centerOfMass: Vector3;\r\n /**\r\n *\r\n */\r\n mass: number;\r\n /**\r\n *\r\n */\r\n intertia: Vector3;\r\n /**\r\n *\r\n */\r\n inertiaOrientation: Quaternion;\r\n}\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n *\r\n */\r\n world: any;\r\n /**\r\n *\r\n */\r\n name: string;\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: PhysicsShape): void;\r\n getShape(body: PhysicsBody): PhysicsShape;\r\n setFilterGroup(body: PhysicsBody, group: number): void;\r\n getFilterGroup(body: PhysicsBody): number;\r\n setEventMask(body: PhysicsBody, eventMask: number): void;\r\n getEventMask(body: PhysicsBody): number;\r\n setMassProperties(body: PhysicsBody, massProps: MassProperties): void;\r\n getMassProperties(body: PhysicsBody): MassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number): void;\r\n getLinearDamping(body: PhysicsBody): number;\r\n setAngularDamping(body: PhysicsBody, damping: number): void;\r\n getAngularDamping(body: PhysicsBody): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3): void;\r\n applyImpulse(body: PhysicsBody, location: Vector3, impulse: Vector3): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: ShapeType, options: PhysicsShapeParameters): void;\r\n setFilterLayer(shape: PhysicsShape, layer: number): void;\r\n getFilterLayer(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n getMaterial(shape: PhysicsShape): PhysicsMaterial;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, childTransform: TransformNode): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n\r\n // material\r\n initMaterial(material: PhysicsMaterial): void;\r\n setFriction(material: PhysicsMaterial, friction: number): void;\r\n getFriction(material: PhysicsMaterial): number;\r\n setRestitution(material: PhysicsMaterial, restitution: number): void;\r\n getRestitution(material: PhysicsMaterial): number;\r\n disposeMaterial(material: PhysicsMaterial): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, type: ConstraintType, options: PhysicsConstraintParameters): void;\r\n setParentBody(constraint: PhysicsConstraint, body: PhysicsBody): void;\r\n getParentBody(constraint: PhysicsConstraint): PhysicsBody;\r\n setChildBody(constraint: PhysicsConstraint, body: PhysicsBody): void;\r\n getChildBody(constraint: PhysicsConstraint): PhysicsBody;\r\n setAnchorInParent(constraint: PhysicsConstraint, pivot: Vector3, axisX: Vector3, axisY: Vector3): void;\r\n setAnchorInChild(constraint: PhysicsConstraint, pivot: Vector3, axisX: Vector3, axisY: Vector3): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: ConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: ConstraintAxis): number;\r\n setAxisMode(constraint: PhysicsConstraint, axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: ConstraintAxis): ConstraintAxisLimitMode;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: ConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: ConstraintAxis): number;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: ConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: ConstraintAxis): number;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: ConstraintAxis, motorType: ConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: ConstraintAxis): ConstraintMotorType;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: ConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: ConstraintAxis): number;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: ConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: ConstraintAxis): number;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
|
|
@@ -4,116 +4,214 @@ import type { Vector3 } from "../../Maths/math.vector";
|
|
|
4
4
|
import type { Scene } from "../../scene";
|
|
5
5
|
import type { TransformNode } from "../../Meshes";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows
|
|
8
|
+
* the user to set the mass and velocity of the body, which can then be used to calculate the
|
|
9
|
+
* motion of the body in the physics engine.
|
|
8
10
|
*/
|
|
9
|
-
/** @internal */
|
|
10
11
|
export declare class PhysicsBody {
|
|
11
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* V2 Physics plugin private data for single Transform
|
|
14
|
+
*/
|
|
12
15
|
_pluginData: any;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* V2 Physics plugin private data for instances
|
|
15
18
|
*/
|
|
16
19
|
_pluginDataInstances: Array<any>;
|
|
20
|
+
/**
|
|
21
|
+
* The V2 plugin used to create and manage this Physics Body
|
|
22
|
+
*/
|
|
17
23
|
private _physicsPlugin;
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
25
|
+
* The transform node associated with this Physics Body
|
|
20
26
|
*/
|
|
21
|
-
|
|
27
|
+
transformNode: TransformNode;
|
|
22
28
|
/**
|
|
29
|
+
* Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.
|
|
30
|
+
* True by default for maximum performance.
|
|
31
|
+
*/
|
|
32
|
+
disablePreStep: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Constructs a new physics body for the given node.
|
|
35
|
+
* @param transformNode - The Transform Node to construct the physics body for.
|
|
36
|
+
* @param scene - The scene containing the physics engine.
|
|
23
37
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
38
|
+
* This code is useful for creating a physics body for a given Transform Node in a scene.
|
|
39
|
+
* It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.
|
|
40
|
+
* It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.
|
|
26
41
|
*/
|
|
27
|
-
constructor(
|
|
42
|
+
constructor(transformNode: TransformNode, scene: Scene);
|
|
28
43
|
/**
|
|
44
|
+
* Sets the shape of the physics body.
|
|
45
|
+
* @param shape - The shape of the physics body.
|
|
29
46
|
*
|
|
30
|
-
*
|
|
47
|
+
* This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.
|
|
48
|
+
* The shape is used to calculate the body's mass, inertia, and other properties.
|
|
31
49
|
*/
|
|
32
50
|
setShape(shape: PhysicsShape): void;
|
|
33
51
|
/**
|
|
52
|
+
* Retrieves the physics shape associated with this object.
|
|
53
|
+
*
|
|
54
|
+
* @returns The physics shape associated with this object, or `undefined` if no
|
|
55
|
+
* shape is associated.
|
|
34
56
|
*
|
|
35
|
-
*
|
|
57
|
+
* This method is useful for retrieving the physics shape associated with this object,
|
|
58
|
+
* which can be used to apply physical forces to the object or to detect collisions.
|
|
36
59
|
*/
|
|
37
60
|
getShape(): PhysicsShape | undefined;
|
|
38
61
|
/**
|
|
62
|
+
* Sets the filter group of the physics body.
|
|
63
|
+
* @param group - The filter group of the physics body.
|
|
39
64
|
*
|
|
40
|
-
*
|
|
65
|
+
* This method is useful for setting the filter group of the physics body.
|
|
66
|
+
* The filter group is used to determine which bodies should collide with each other.
|
|
67
|
+
* This allows for more control over the physics engine and can be used to create more realistic simulations.
|
|
41
68
|
*/
|
|
42
69
|
setFilterGroup(group: number): void;
|
|
43
70
|
/**
|
|
71
|
+
* Gets the filter group of the physics engine.
|
|
44
72
|
*
|
|
45
|
-
* @returns
|
|
73
|
+
* @returns The filter group of the physics engine.
|
|
74
|
+
*
|
|
75
|
+
* This method is useful for getting the filter group of the physics engine,
|
|
76
|
+
* which is used to determine which objects will interact with each other.
|
|
77
|
+
* This is important for creating realistic physics simulations.
|
|
46
78
|
*/
|
|
47
79
|
getFilterGroup(): number;
|
|
48
80
|
/**
|
|
81
|
+
* Sets the event mask for the physics engine.
|
|
82
|
+
*
|
|
83
|
+
* @param eventMask - A bitmask that determines which events will be sent to the physics engine.
|
|
49
84
|
*
|
|
50
|
-
*
|
|
85
|
+
* This method is useful for setting the event mask for the physics engine, which determines which events
|
|
86
|
+
* will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.
|
|
51
87
|
*/
|
|
52
88
|
setEventMask(eventMask: number): void;
|
|
53
89
|
/**
|
|
90
|
+
* Gets the event mask of the physics engine.
|
|
54
91
|
*
|
|
55
|
-
* @returns
|
|
92
|
+
* @returns The event mask of the physics engine.
|
|
93
|
+
*
|
|
94
|
+
* This method is useful for getting the event mask of the physics engine,
|
|
95
|
+
* which is used to determine which events the engine will respond to.
|
|
96
|
+
* This is important for ensuring that the engine is responding to the correct events and not
|
|
97
|
+
* wasting resources on unnecessary events.
|
|
56
98
|
*/
|
|
57
99
|
getEventMask(): number;
|
|
58
100
|
/**
|
|
101
|
+
* Sets the mass properties of the physics object.
|
|
102
|
+
*
|
|
103
|
+
* @param massProps - The mass properties to set.
|
|
59
104
|
*
|
|
60
|
-
*
|
|
105
|
+
* This method is useful for setting the mass properties of a physics object, such as its mass,
|
|
106
|
+
* inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.
|
|
61
107
|
*/
|
|
62
108
|
setMassProperties(massProps: MassProperties): void;
|
|
63
109
|
/**
|
|
110
|
+
* Retrieves the mass properties of the object.
|
|
111
|
+
*
|
|
112
|
+
* @returns The mass properties of the object, or `undefined` if the physics
|
|
113
|
+
* plugin does not support mass properties.
|
|
64
114
|
*
|
|
65
|
-
*
|
|
115
|
+
* This method is useful for physics simulations, as it allows the user to
|
|
116
|
+
* retrieve the mass properties of the object, such as its mass, center of mass,
|
|
117
|
+
* and moment of inertia. This information is necessary for accurate physics
|
|
118
|
+
* simulations.
|
|
66
119
|
*/
|
|
67
120
|
getMassProperties(): MassProperties | undefined;
|
|
68
121
|
/**
|
|
122
|
+
* Sets the linear damping of the physics body.
|
|
69
123
|
*
|
|
70
|
-
* @param damping
|
|
124
|
+
* @param damping - The linear damping value.
|
|
125
|
+
*
|
|
126
|
+
* This method is useful for controlling the linear damping of the physics body,
|
|
127
|
+
* which is the rate at which the body's velocity decreases over time. This is useful for simulating
|
|
128
|
+
* the effects of air resistance or other forms of friction.
|
|
71
129
|
*/
|
|
72
130
|
setLinearDamping(damping: number): void;
|
|
73
131
|
/**
|
|
132
|
+
* Gets the linear damping of the physics body.
|
|
133
|
+
* @returns The linear damping of the physics body.
|
|
74
134
|
*
|
|
75
|
-
*
|
|
135
|
+
* This method is useful for retrieving the linear damping of the physics body, which is the amount of
|
|
136
|
+
* resistance the body has to linear motion. This is useful for simulating realistic physics behavior
|
|
137
|
+
* in a game.
|
|
76
138
|
*/
|
|
77
139
|
getLinearDamping(): number;
|
|
78
140
|
/**
|
|
141
|
+
* Sets the angular damping of the physics body.
|
|
142
|
+
* @param damping The angular damping of the body.
|
|
79
143
|
*
|
|
80
|
-
*
|
|
144
|
+
* This method is useful for controlling the angular velocity of a physics body.
|
|
145
|
+
* By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.
|
|
146
|
+
* This can be used to create realistic physical behavior in a physics engine.
|
|
81
147
|
*/
|
|
82
148
|
setAngularDamping(damping: number): void;
|
|
83
149
|
/**
|
|
150
|
+
* Gets the angular damping of the physics body.
|
|
151
|
+
*
|
|
152
|
+
* @returns The angular damping of the physics body.
|
|
84
153
|
*
|
|
85
|
-
*
|
|
154
|
+
* This method is useful for getting the angular damping of the physics body,
|
|
155
|
+
* which is the rate of reduction of the angular velocity over time.
|
|
156
|
+
* This is important for simulating realistic physics behavior in a game.
|
|
86
157
|
*/
|
|
87
158
|
getAngularDamping(): number;
|
|
88
159
|
/**
|
|
160
|
+
* Sets the linear velocity of the physics object.
|
|
161
|
+
* @param linVel - The linear velocity to set.
|
|
89
162
|
*
|
|
90
|
-
*
|
|
163
|
+
* This method is useful for setting the linear velocity of a physics object,
|
|
164
|
+
* which is necessary for simulating realistic physics in a game engine.
|
|
165
|
+
* By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.
|
|
166
|
+
* This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.
|
|
91
167
|
*/
|
|
92
168
|
setLinearVelocity(linVel: Vector3): void;
|
|
93
169
|
/**
|
|
170
|
+
* Gets the linear velocity of the physics body and stores it in the given vector3.
|
|
171
|
+
* @param linVel - The vector3 to store the linear velocity in.
|
|
94
172
|
*
|
|
95
|
-
*
|
|
96
|
-
|
|
173
|
+
* This method is useful for getting the linear velocity of a physics body in a physics engine.
|
|
174
|
+
* This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/
|
|
97
175
|
getLinearVelocityToRef(linVel: Vector3): void;
|
|
98
176
|
/**
|
|
177
|
+
* Sets the angular velocity of the physics object.
|
|
178
|
+
* @param angVel - The angular velocity to set.
|
|
99
179
|
*
|
|
100
|
-
*
|
|
180
|
+
* This method is useful for setting the angular velocity of a physics object, which is necessary for
|
|
181
|
+
* simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,
|
|
182
|
+
* which is important for simulating realistic motion.
|
|
101
183
|
*/
|
|
102
184
|
setAngularVelocity(angVel: Vector3): void;
|
|
103
185
|
/**
|
|
186
|
+
* Gets the angular velocity of the physics body and stores it in the given vector3.
|
|
187
|
+
* @param angVel - The vector3 to store the angular velocity in.
|
|
104
188
|
*
|
|
105
|
-
*
|
|
189
|
+
* This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's
|
|
190
|
+
* rotational speed. This information can be used to create realistic physics simulations.
|
|
106
191
|
*/
|
|
107
192
|
getAngularVelocityToRef(angVel: Vector3): void;
|
|
108
193
|
/**
|
|
194
|
+
* Applies an impulse to the physics object.
|
|
109
195
|
*
|
|
110
|
-
* @param location
|
|
111
|
-
* @param impulse
|
|
196
|
+
* @param location The location of the impulse.
|
|
197
|
+
* @param impulse The impulse vector.
|
|
198
|
+
*
|
|
199
|
+
* This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,
|
|
200
|
+
* collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.
|
|
112
201
|
*/
|
|
113
202
|
applyImpulse(location: Vector3, impulse: Vector3): void;
|
|
203
|
+
/**
|
|
204
|
+
* Retrieves the geometry of the body from the physics plugin.
|
|
205
|
+
*
|
|
206
|
+
* @returns The geometry of the body.
|
|
207
|
+
*
|
|
208
|
+
* This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.
|
|
209
|
+
*/
|
|
114
210
|
getGeometry(): {};
|
|
115
211
|
/**
|
|
212
|
+
* Disposes the body from the physics engine.
|
|
116
213
|
*
|
|
214
|
+
* This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.
|
|
117
215
|
*/
|
|
118
216
|
dispose(): void;
|
|
119
217
|
}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import { Quaternion } from "../../Maths/math.vector.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows
|
|
4
|
+
* the user to set the mass and velocity of the body, which can then be used to calculate the
|
|
5
|
+
* motion of the body in the physics engine.
|
|
4
6
|
*/
|
|
5
|
-
/** @internal */
|
|
6
7
|
export class PhysicsBody {
|
|
7
8
|
/**
|
|
9
|
+
* Constructs a new physics body for the given node.
|
|
10
|
+
* @param transformNode - The Transform Node to construct the physics body for.
|
|
11
|
+
* @param scene - The scene containing the physics engine.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
13
|
+
* This code is useful for creating a physics body for a given Transform Node in a scene.
|
|
14
|
+
* It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.
|
|
15
|
+
* It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.
|
|
11
16
|
*/
|
|
12
|
-
constructor(
|
|
13
|
-
/**
|
|
17
|
+
constructor(transformNode, scene) {
|
|
18
|
+
/**
|
|
19
|
+
* V2 Physics plugin private data for single Transform
|
|
20
|
+
*/
|
|
14
21
|
this._pluginData = undefined;
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
23
|
+
* V2 Physics plugin private data for instances
|
|
17
24
|
*/
|
|
18
25
|
this._pluginDataInstances = [];
|
|
26
|
+
/**
|
|
27
|
+
* Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.
|
|
28
|
+
* True by default for maximum performance.
|
|
29
|
+
*/
|
|
30
|
+
this.disablePreStep = true;
|
|
19
31
|
if (!scene) {
|
|
20
32
|
return;
|
|
21
33
|
}
|
|
@@ -31,146 +43,230 @@ export class PhysicsBody {
|
|
|
31
43
|
throw new Error("No Physics Plugin available.");
|
|
32
44
|
}
|
|
33
45
|
this._physicsPlugin = physicsPlugin;
|
|
34
|
-
if (!
|
|
35
|
-
|
|
46
|
+
if (!transformNode.rotationQuaternion) {
|
|
47
|
+
transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);
|
|
36
48
|
}
|
|
37
49
|
// instances?
|
|
38
|
-
const m =
|
|
50
|
+
const m = transformNode;
|
|
39
51
|
if (m.hasThinInstances) {
|
|
40
52
|
this._physicsPlugin.initBodyInstances(this, m);
|
|
41
53
|
}
|
|
42
54
|
else {
|
|
43
55
|
// single instance
|
|
44
|
-
this._physicsPlugin.initBody(this,
|
|
56
|
+
this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);
|
|
45
57
|
}
|
|
46
|
-
this.
|
|
58
|
+
this.transformNode = transformNode;
|
|
59
|
+
transformNode.physicsBody = this;
|
|
47
60
|
physicsEngine.addBody(this);
|
|
48
61
|
}
|
|
49
62
|
/**
|
|
63
|
+
* Sets the shape of the physics body.
|
|
64
|
+
* @param shape - The shape of the physics body.
|
|
50
65
|
*
|
|
51
|
-
*
|
|
66
|
+
* This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.
|
|
67
|
+
* The shape is used to calculate the body's mass, inertia, and other properties.
|
|
52
68
|
*/
|
|
53
69
|
setShape(shape) {
|
|
54
70
|
this._physicsPlugin.setShape(this, shape);
|
|
55
71
|
}
|
|
56
72
|
/**
|
|
73
|
+
* Retrieves the physics shape associated with this object.
|
|
74
|
+
*
|
|
75
|
+
* @returns The physics shape associated with this object, or `undefined` if no
|
|
76
|
+
* shape is associated.
|
|
57
77
|
*
|
|
58
|
-
*
|
|
78
|
+
* This method is useful for retrieving the physics shape associated with this object,
|
|
79
|
+
* which can be used to apply physical forces to the object or to detect collisions.
|
|
59
80
|
*/
|
|
60
81
|
getShape() {
|
|
61
82
|
return this._physicsPlugin.getShape(this);
|
|
62
83
|
}
|
|
63
84
|
/**
|
|
85
|
+
* Sets the filter group of the physics body.
|
|
86
|
+
* @param group - The filter group of the physics body.
|
|
64
87
|
*
|
|
65
|
-
*
|
|
88
|
+
* This method is useful for setting the filter group of the physics body.
|
|
89
|
+
* The filter group is used to determine which bodies should collide with each other.
|
|
90
|
+
* This allows for more control over the physics engine and can be used to create more realistic simulations.
|
|
66
91
|
*/
|
|
67
92
|
setFilterGroup(group) {
|
|
68
93
|
this._physicsPlugin.setFilterGroup(this, group);
|
|
69
94
|
}
|
|
70
95
|
/**
|
|
96
|
+
* Gets the filter group of the physics engine.
|
|
71
97
|
*
|
|
72
|
-
* @returns
|
|
98
|
+
* @returns The filter group of the physics engine.
|
|
99
|
+
*
|
|
100
|
+
* This method is useful for getting the filter group of the physics engine,
|
|
101
|
+
* which is used to determine which objects will interact with each other.
|
|
102
|
+
* This is important for creating realistic physics simulations.
|
|
73
103
|
*/
|
|
74
104
|
getFilterGroup() {
|
|
75
105
|
return this._physicsPlugin.getFilterGroup(this);
|
|
76
106
|
}
|
|
77
107
|
/**
|
|
108
|
+
* Sets the event mask for the physics engine.
|
|
109
|
+
*
|
|
110
|
+
* @param eventMask - A bitmask that determines which events will be sent to the physics engine.
|
|
78
111
|
*
|
|
79
|
-
*
|
|
112
|
+
* This method is useful for setting the event mask for the physics engine, which determines which events
|
|
113
|
+
* will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.
|
|
80
114
|
*/
|
|
81
115
|
setEventMask(eventMask) {
|
|
82
116
|
this._physicsPlugin.setEventMask(this, eventMask);
|
|
83
117
|
}
|
|
84
118
|
/**
|
|
119
|
+
* Gets the event mask of the physics engine.
|
|
85
120
|
*
|
|
86
|
-
* @returns
|
|
121
|
+
* @returns The event mask of the physics engine.
|
|
122
|
+
*
|
|
123
|
+
* This method is useful for getting the event mask of the physics engine,
|
|
124
|
+
* which is used to determine which events the engine will respond to.
|
|
125
|
+
* This is important for ensuring that the engine is responding to the correct events and not
|
|
126
|
+
* wasting resources on unnecessary events.
|
|
87
127
|
*/
|
|
88
128
|
getEventMask() {
|
|
89
129
|
return this._physicsPlugin.getEventMask(this);
|
|
90
130
|
}
|
|
91
131
|
/**
|
|
132
|
+
* Sets the mass properties of the physics object.
|
|
133
|
+
*
|
|
134
|
+
* @param massProps - The mass properties to set.
|
|
92
135
|
*
|
|
93
|
-
*
|
|
136
|
+
* This method is useful for setting the mass properties of a physics object, such as its mass,
|
|
137
|
+
* inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.
|
|
94
138
|
*/
|
|
95
139
|
setMassProperties(massProps) {
|
|
96
140
|
this._physicsPlugin.setMassProperties(this, massProps);
|
|
97
141
|
}
|
|
98
142
|
/**
|
|
143
|
+
* Retrieves the mass properties of the object.
|
|
99
144
|
*
|
|
100
|
-
* @returns
|
|
145
|
+
* @returns The mass properties of the object, or `undefined` if the physics
|
|
146
|
+
* plugin does not support mass properties.
|
|
147
|
+
*
|
|
148
|
+
* This method is useful for physics simulations, as it allows the user to
|
|
149
|
+
* retrieve the mass properties of the object, such as its mass, center of mass,
|
|
150
|
+
* and moment of inertia. This information is necessary for accurate physics
|
|
151
|
+
* simulations.
|
|
101
152
|
*/
|
|
102
153
|
getMassProperties() {
|
|
103
154
|
return this._physicsPlugin.getMassProperties(this);
|
|
104
155
|
}
|
|
105
156
|
/**
|
|
157
|
+
* Sets the linear damping of the physics body.
|
|
158
|
+
*
|
|
159
|
+
* @param damping - The linear damping value.
|
|
106
160
|
*
|
|
107
|
-
*
|
|
161
|
+
* This method is useful for controlling the linear damping of the physics body,
|
|
162
|
+
* which is the rate at which the body's velocity decreases over time. This is useful for simulating
|
|
163
|
+
* the effects of air resistance or other forms of friction.
|
|
108
164
|
*/
|
|
109
165
|
setLinearDamping(damping) {
|
|
110
166
|
this._physicsPlugin.setLinearDamping(this, damping);
|
|
111
167
|
}
|
|
112
168
|
/**
|
|
169
|
+
* Gets the linear damping of the physics body.
|
|
170
|
+
* @returns The linear damping of the physics body.
|
|
113
171
|
*
|
|
114
|
-
*
|
|
172
|
+
* This method is useful for retrieving the linear damping of the physics body, which is the amount of
|
|
173
|
+
* resistance the body has to linear motion. This is useful for simulating realistic physics behavior
|
|
174
|
+
* in a game.
|
|
115
175
|
*/
|
|
116
176
|
getLinearDamping() {
|
|
117
177
|
return this._physicsPlugin.getLinearDamping(this);
|
|
118
178
|
}
|
|
119
179
|
/**
|
|
180
|
+
* Sets the angular damping of the physics body.
|
|
181
|
+
* @param damping The angular damping of the body.
|
|
120
182
|
*
|
|
121
|
-
*
|
|
183
|
+
* This method is useful for controlling the angular velocity of a physics body.
|
|
184
|
+
* By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.
|
|
185
|
+
* This can be used to create realistic physical behavior in a physics engine.
|
|
122
186
|
*/
|
|
123
187
|
setAngularDamping(damping) {
|
|
124
188
|
this._physicsPlugin.setAngularDamping(this, damping);
|
|
125
189
|
}
|
|
126
190
|
/**
|
|
191
|
+
* Gets the angular damping of the physics body.
|
|
192
|
+
*
|
|
193
|
+
* @returns The angular damping of the physics body.
|
|
127
194
|
*
|
|
128
|
-
*
|
|
195
|
+
* This method is useful for getting the angular damping of the physics body,
|
|
196
|
+
* which is the rate of reduction of the angular velocity over time.
|
|
197
|
+
* This is important for simulating realistic physics behavior in a game.
|
|
129
198
|
*/
|
|
130
199
|
getAngularDamping() {
|
|
131
200
|
return this._physicsPlugin.getAngularDamping(this);
|
|
132
201
|
}
|
|
133
202
|
/**
|
|
203
|
+
* Sets the linear velocity of the physics object.
|
|
204
|
+
* @param linVel - The linear velocity to set.
|
|
134
205
|
*
|
|
135
|
-
*
|
|
206
|
+
* This method is useful for setting the linear velocity of a physics object,
|
|
207
|
+
* which is necessary for simulating realistic physics in a game engine.
|
|
208
|
+
* By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.
|
|
209
|
+
* This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.
|
|
136
210
|
*/
|
|
137
211
|
setLinearVelocity(linVel) {
|
|
138
212
|
this._physicsPlugin.setLinearVelocity(this, linVel);
|
|
139
213
|
}
|
|
140
214
|
/**
|
|
215
|
+
* Gets the linear velocity of the physics body and stores it in the given vector3.
|
|
216
|
+
* @param linVel - The vector3 to store the linear velocity in.
|
|
141
217
|
*
|
|
142
|
-
*
|
|
143
|
-
|
|
218
|
+
* This method is useful for getting the linear velocity of a physics body in a physics engine.
|
|
219
|
+
* This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/
|
|
144
220
|
getLinearVelocityToRef(linVel) {
|
|
145
221
|
return this._physicsPlugin.getLinearVelocityToRef(this, linVel);
|
|
146
222
|
}
|
|
147
223
|
/**
|
|
224
|
+
* Sets the angular velocity of the physics object.
|
|
225
|
+
* @param angVel - The angular velocity to set.
|
|
148
226
|
*
|
|
149
|
-
*
|
|
227
|
+
* This method is useful for setting the angular velocity of a physics object, which is necessary for
|
|
228
|
+
* simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,
|
|
229
|
+
* which is important for simulating realistic motion.
|
|
150
230
|
*/
|
|
151
231
|
setAngularVelocity(angVel) {
|
|
152
232
|
this._physicsPlugin.setAngularVelocity(this, angVel);
|
|
153
233
|
}
|
|
154
234
|
/**
|
|
235
|
+
* Gets the angular velocity of the physics body and stores it in the given vector3.
|
|
236
|
+
* @param angVel - The vector3 to store the angular velocity in.
|
|
155
237
|
*
|
|
156
|
-
*
|
|
238
|
+
* This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's
|
|
239
|
+
* rotational speed. This information can be used to create realistic physics simulations.
|
|
157
240
|
*/
|
|
158
241
|
getAngularVelocityToRef(angVel) {
|
|
159
242
|
return this._physicsPlugin.getAngularVelocityToRef(this, angVel);
|
|
160
243
|
}
|
|
161
244
|
/**
|
|
245
|
+
* Applies an impulse to the physics object.
|
|
246
|
+
*
|
|
247
|
+
* @param location The location of the impulse.
|
|
248
|
+
* @param impulse The impulse vector.
|
|
162
249
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
250
|
+
* This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,
|
|
251
|
+
* collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.
|
|
165
252
|
*/
|
|
166
253
|
applyImpulse(location, impulse) {
|
|
167
254
|
this._physicsPlugin.applyImpulse(this, location, impulse);
|
|
168
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves the geometry of the body from the physics plugin.
|
|
258
|
+
*
|
|
259
|
+
* @returns The geometry of the body.
|
|
260
|
+
*
|
|
261
|
+
* This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.
|
|
262
|
+
*/
|
|
169
263
|
getGeometry() {
|
|
170
264
|
return this._physicsPlugin.getBodyGeometry(this);
|
|
171
265
|
}
|
|
172
266
|
/**
|
|
267
|
+
* Disposes the body from the physics engine.
|
|
173
268
|
*
|
|
269
|
+
* This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.
|
|
174
270
|
*/
|
|
175
271
|
dispose() {
|
|
176
272
|
this._physicsPlugin.disposeBody(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,WAAW;IAYpB;;;;OAIG;IACH,YAAY,IAAmB,EAAE,KAAY;QAhB7C,gBAAgB;QACT,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAYzC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1B,IAAI,CAAC,kBAAkB,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC3G;QACD,aAAa;QACb,MAAM,CAAC,GAAG,IAAY,CAAC;QACvB,IAAI,CAAC,CAAC,gBAAgB,EAAE;YACpB,IA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O;QACV,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode } from \"../../Meshes\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsBody {\r\n /** @internal */\r\n public _pluginData: any = undefined;\r\n /**\r\n *\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n *\r\n */\r\n node: TransformNode;\r\n /**\r\n *\r\n * @param scene\r\n * @returns\r\n */\r\n constructor(node: TransformNode, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!node.rotationQuaternion) {\r\n node.rotationQuaternion = Quaternion.FromEulerAngles(node.rotation.x, node.rotation.y, node.rotation.z);\r\n }\r\n // instances?\r\n const m = node as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, node.position, node.rotationQuaternion);\r\n }\r\n this.node = node;\r\n physicsEngine.addBody(this);\r\n }\r\n /**\r\n *\r\n * @param shape\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param group\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param eventMask\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param massProps\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param damping\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param damping\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param linVel\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n *\r\n * @param angVel\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n *\r\n * @param location\r\n * @param impulse\r\n */\r\n public applyImpulse(location: Vector3, impulse: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, location, impulse);\r\n }\r\n\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeBody(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAuBpB;;;;;;;;OAQG;IACH,YAAY,aAA4B,EAAE,KAAY;QA/BtD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAY3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,K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,CAAC;IAED;;;;;kIAK8H;IACvH,sBAAsB,CAAC,MAAe;QACzC,OAAO,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACI,kBAAkB,CAAC,MAAe;QACrC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,uBAAuB,CAAC,MAAe;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;;;OAQG;IACI,YAAY,CAAC,QAAiB,EAAE,OAAgB;QACnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;OAMG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode } from \"../../Meshes\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param location The location of the impulse.\r\n * @param impulse The impulse vector.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(location: Vector3, impulse: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, location, impulse);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeBody(this);\r\n }\r\n}\r\n"]}
|