@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
|
@@ -8,36 +8,55 @@ import type { PhysicsBody } from "./physicsBody";
|
|
|
8
8
|
* It holds a set of functions to control the underlying constraint
|
|
9
9
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
10
10
|
*/
|
|
11
|
-
/** @internal */
|
|
12
11
|
export declare class PhysicsConstraint {
|
|
13
|
-
/** @internal */
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* V2 Physics plugin private data for a physics material
|
|
16
14
|
*/
|
|
17
15
|
_pluginData: any;
|
|
16
|
+
/**
|
|
17
|
+
* The V2 plugin used to create and manage this Physics Body
|
|
18
|
+
*/
|
|
18
19
|
protected _physicsPlugin: IPhysicsEnginePluginV2;
|
|
19
20
|
/**
|
|
21
|
+
* Constructs a new constraint for the physics constraint.
|
|
22
|
+
* @param type The type of constraint to create.
|
|
23
|
+
* @param options The options for the constraint.
|
|
24
|
+
* @param scene The scene the constraint belongs to.
|
|
20
25
|
*
|
|
26
|
+
* This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.
|
|
27
|
+
* If all checks pass, it initializes the constraint with the given type and options.
|
|
21
28
|
*/
|
|
22
29
|
constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene);
|
|
23
30
|
/**
|
|
31
|
+
* Sets the parent body of this body.
|
|
32
|
+
* @param body - The parent body to set.
|
|
24
33
|
*
|
|
25
|
-
*
|
|
34
|
+
* This method is useful for setting the parent body of a physics body in a physics engine.
|
|
35
|
+
* This allows the engine to accurately simulate the motion of the body in relation to its parent body.
|
|
36
|
+
* For example, if the parent body is a planet, the engine can accurately simulate the motion of the body in relation to the planet's gravity.
|
|
26
37
|
*/
|
|
27
38
|
setParentBody(body: PhysicsBody): void;
|
|
28
39
|
/**
|
|
40
|
+
* Retrieves the parent body of the current physics constraint.
|
|
29
41
|
*
|
|
30
|
-
* @returns
|
|
42
|
+
* @returns The parent body of the current physics constraint, or `undefined` if the
|
|
43
|
+
* current constraint does not have a parent body.
|
|
31
44
|
*/
|
|
32
45
|
getParentBody(): PhysicsBody | undefined;
|
|
33
46
|
/**
|
|
47
|
+
* Sets the child body of the current body.
|
|
34
48
|
*
|
|
35
|
-
* @param body
|
|
49
|
+
* @param body - The child body to set.
|
|
50
|
+
*
|
|
51
|
+
* This method is useful for setting the child body of the current body in a physics engine.
|
|
52
|
+
* This allows for the creation of complex structures of bodies that interact with each other in a realistic way.
|
|
36
53
|
*/
|
|
37
54
|
setChildBody(body: PhysicsBody): void;
|
|
38
55
|
/**
|
|
56
|
+
* Retrieves the child body of the current physics constraint.
|
|
39
57
|
*
|
|
40
|
-
* @returns
|
|
58
|
+
* @returns The child body of the current physics constraint, or `undefined` if no
|
|
59
|
+
* child body is present.
|
|
41
60
|
*/
|
|
42
61
|
getChildBody(): PhysicsBody | undefined;
|
|
43
62
|
/**
|
|
@@ -4,15 +4,19 @@ import { ConstraintType } from "./IPhysicsEnginePlugin.js";
|
|
|
4
4
|
* It holds a set of functions to control the underlying constraint
|
|
5
5
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
6
6
|
*/
|
|
7
|
-
/** @internal */
|
|
8
7
|
export class PhysicsConstraint {
|
|
9
8
|
/**
|
|
9
|
+
* Constructs a new constraint for the physics constraint.
|
|
10
|
+
* @param type The type of constraint to create.
|
|
11
|
+
* @param options The options for the constraint.
|
|
12
|
+
* @param scene The scene the constraint belongs to.
|
|
10
13
|
*
|
|
14
|
+
* This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.
|
|
15
|
+
* If all checks pass, it initializes the constraint with the given type and options.
|
|
11
16
|
*/
|
|
12
17
|
constructor(type, options, scene) {
|
|
13
|
-
/** @internal */
|
|
14
18
|
/**
|
|
15
|
-
*
|
|
19
|
+
* V2 Physics plugin private data for a physics material
|
|
16
20
|
*/
|
|
17
21
|
this._pluginData = undefined;
|
|
18
22
|
if (!scene) {
|
|
@@ -33,29 +37,41 @@ export class PhysicsConstraint {
|
|
|
33
37
|
this._physicsPlugin.initConstraint(this, type, options);
|
|
34
38
|
}
|
|
35
39
|
/**
|
|
40
|
+
* Sets the parent body of this body.
|
|
41
|
+
* @param body - The parent body to set.
|
|
36
42
|
*
|
|
37
|
-
*
|
|
43
|
+
* This method is useful for setting the parent body of a physics body in a physics engine.
|
|
44
|
+
* This allows the engine to accurately simulate the motion of the body in relation to its parent body.
|
|
45
|
+
* For example, if the parent body is a planet, the engine can accurately simulate the motion of the body in relation to the planet's gravity.
|
|
38
46
|
*/
|
|
39
47
|
setParentBody(body) {
|
|
40
48
|
this._physicsPlugin.setParentBody(this, body);
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
51
|
+
* Retrieves the parent body of the current physics constraint.
|
|
43
52
|
*
|
|
44
|
-
* @returns
|
|
53
|
+
* @returns The parent body of the current physics constraint, or `undefined` if the
|
|
54
|
+
* current constraint does not have a parent body.
|
|
45
55
|
*/
|
|
46
56
|
getParentBody() {
|
|
47
57
|
return this._physicsPlugin.getParentBody(this);
|
|
48
58
|
}
|
|
49
59
|
/**
|
|
60
|
+
* Sets the child body of the current body.
|
|
50
61
|
*
|
|
51
|
-
* @param body
|
|
62
|
+
* @param body - The child body to set.
|
|
63
|
+
*
|
|
64
|
+
* This method is useful for setting the child body of the current body in a physics engine.
|
|
65
|
+
* This allows for the creation of complex structures of bodies that interact with each other in a realistic way.
|
|
52
66
|
*/
|
|
53
67
|
setChildBody(body) {
|
|
54
68
|
this._physicsPlugin.setChildBody(this, body);
|
|
55
69
|
}
|
|
56
70
|
/**
|
|
71
|
+
* Retrieves the child body of the current physics constraint.
|
|
57
72
|
*
|
|
58
|
-
* @returns
|
|
73
|
+
* @returns The child body of the current physics constraint, or `undefined` if no
|
|
74
|
+
* child body is present.
|
|
59
75
|
*/
|
|
60
76
|
getChildBody() {
|
|
61
77
|
return this._physicsPlugin.getChildBody(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;;;GAIG;AACH,gBAAgB;AAChB,MAAM,OAAO,iBAAiB;IAQ1B;;OAEG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QAVpF,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAOhC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,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,KA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AY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraint {\r\n /** @internal */\r\n /**\r\n *\r\n */\r\n public _pluginData: any = undefined;\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n *\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\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 this._physicsPlugin.initConstraint(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setParentBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setParentBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getParentBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getParentBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public setChildBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setChildBody(this, body);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getChildBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getChildBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot +\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInParent(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInChild(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param friction\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @returns\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param limitMode\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n /**\r\n *\r\n * @param axis\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintBallAndSocket extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintDistance extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintHinge extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintSlider extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintLock extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAU1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QAlBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAgBhC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,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,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;OAOG;IACI,aAAa,CAAC,IAAiB;QAClC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,IAA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from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\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 this._physicsPlugin.initConstraint(this, type, options);\r\n }\r\n\r\n /**\r\n * Sets the parent body of this body.\r\n * @param body - The parent body to set.\r\n *\r\n * This method is useful for setting the parent body of a physics body in a physics engine.\r\n * This allows the engine to accurately simulate the motion of the body in relation to its parent body.\r\n * For example, if the parent body is a planet, the engine can accurately simulate the motion of the body in relation to the planet's gravity.\r\n */\r\n public setParentBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setParentBody(this, body);\r\n }\r\n\r\n /**\r\n * Retrieves the parent body of the current physics constraint.\r\n *\r\n * @returns The parent body of the current physics constraint, or `undefined` if the\r\n * current constraint does not have a parent body.\r\n */\r\n public getParentBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getParentBody(this);\r\n }\r\n\r\n /**\r\n * Sets the child body of the current body.\r\n *\r\n * @param body - The child body to set.\r\n *\r\n * This method is useful for setting the child body of the current body in a physics engine.\r\n * This allows for the creation of complex structures of bodies that interact with each other in a realistic way.\r\n */\r\n public setChildBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setChildBody(this, body);\r\n }\r\n\r\n /**\r\n * Retrieves the child body of the current physics constraint.\r\n *\r\n * @returns The child body of the current physics constraint, or `undefined` if no\r\n * child body is present.\r\n */\r\n public getChildBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getChildBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot +\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInParent(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInChild(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param friction\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @returns\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param limitMode\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n /**\r\n *\r\n * @param axis\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintBallAndSocket extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintDistance extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintHinge extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintSlider extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintLock extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
|
|
@@ -99,13 +99,6 @@ export class PhysicsEngine {
|
|
|
99
99
|
* @param delta defines the timespan between frames
|
|
100
100
|
*/
|
|
101
101
|
_step(delta) {
|
|
102
|
-
//check if any mesh has no body / requires an update
|
|
103
|
-
/*this._impostors.forEach((impostor) => {
|
|
104
|
-
if (impostor.isBodyInitRequired()) {
|
|
105
|
-
this._physicsPlugin.generatePhysicsBody(impostor);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
*/
|
|
109
102
|
if (delta > 0.1) {
|
|
110
103
|
delta = 0.1;
|
|
111
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,C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CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,oBAAoB;QACvB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;OAIG;IAEH;;;OAGG;IACI,KAAK,CAAC,KAAa;QACtB,
|
|
1
|
+
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IA0BtB;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAyC,aAAa,CAAC,oBAAoB,EAAE;QAA7E,mBAAc,GAAd,cAAc,CAA+D;QA9B7H,gBAAgB;QACR,mBAAc,GAAuB,EAAE,CAAC;QACxC,iBAAY,GAAW,CAAC,CAAC;QA6B7B,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IAxBD;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAaD;;;OAGG;IACI,UAAU,CAAC,OAAgB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CA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C;SAC5D;IACL,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n //private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n *\r\n * @param body\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n *\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._physicsPlugin.raycast(from, to, result);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result);\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -3,12 +3,13 @@ import type { Observer } from "../../Misc/observable";
|
|
|
3
3
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
4
4
|
import type { Node } from "../../node";
|
|
5
5
|
import type { PhysicsBody } from "./physicsBody";
|
|
6
|
-
|
|
6
|
+
import "../joinedPhysicsEngineComponent";
|
|
7
|
+
declare module "../../Meshes/transformNode" {
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
9
10
|
*/
|
|
10
11
|
/** @internal */
|
|
11
|
-
interface
|
|
12
|
+
interface TransformNode {
|
|
12
13
|
/** @internal */
|
|
13
14
|
_physicsBody: Nullable<PhysicsBody>;
|
|
14
15
|
/**
|
|
@@ -24,7 +25,7 @@ declare module "../../Meshes/abstractMesh" {
|
|
|
24
25
|
* @param contactPoint defines where to apply the force
|
|
25
26
|
* @returns the current mesh
|
|
26
27
|
*/
|
|
27
|
-
applyImpulse(force: Vector3, contactPoint: Vector3):
|
|
28
|
+
applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;
|
|
28
29
|
/** @internal */
|
|
29
30
|
_disposePhysicsObserver: Nullable<Observer<Node>>;
|
|
30
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TransformNode } from "../../Meshes/transformNode.js";
|
|
2
|
+
import "../joinedPhysicsEngineComponent.js";
|
|
3
|
+
Object.defineProperty(TransformNode.prototype, "physicsBody", {
|
|
3
4
|
get: function () {
|
|
4
5
|
return this._physicsBody;
|
|
5
6
|
},
|
|
@@ -29,7 +30,7 @@ Object.defineProperty(AbstractMesh.prototype, "physicsBody", {
|
|
|
29
30
|
* @returns a physics body or null
|
|
30
31
|
*/
|
|
31
32
|
/** @internal */
|
|
32
|
-
|
|
33
|
+
TransformNode.prototype.getPhysicsBody = function () {
|
|
33
34
|
return this.physicsBody;
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
@@ -40,9 +41,9 @@ AbstractMesh.prototype.getPhysicsBody = function () {
|
|
|
40
41
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
41
42
|
*/
|
|
42
43
|
/** @internal */
|
|
43
|
-
|
|
44
|
+
TransformNode.prototype.applyImpulse = function (force, contactPoint) {
|
|
44
45
|
if (!this.physicsBody) {
|
|
45
|
-
throw new Error("No Physics Body for
|
|
46
|
+
throw new Error("No Physics Body for TransformNode");
|
|
46
47
|
}
|
|
47
48
|
this.physicsBody.applyImpulse(force, contactPoint);
|
|
48
49
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,iCAAiC,CAAC;AAiCzC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE;IAC1D,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,UAA+B,KAA4B;QAC5D,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC7D,UAAU;gBACV,IAAI,IAAI,CAAC,WAAW,EAAE;oBAClB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAC,iBAAiB,CAAC,CAAC;oBAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC3B;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,gBAAgB;AAChB,aAAa,CAAC,SAAS,CAAC,cAAc,GAAG;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,gBAAgB;AAChB,aAAa,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IAClF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\nimport \"../joinedPhysicsEngineComponent\";\r\n\r\ndeclare module \"../../Meshes/transformNode\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface TransformNode {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsBody\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics body\r\n * @returns a physics body or null\r\n */\r\n/** @internal */\r\nTransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nTransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n"]}
|
|
@@ -1,45 +1,72 @@
|
|
|
1
1
|
import type { Scene } from "../../scene";
|
|
2
2
|
import type { IPhysicsEnginePluginV2 } from "./IPhysicsEnginePlugin";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Physics material class
|
|
5
|
+
* Helps setting friction and restitution that are used to compute responding forces in collision response
|
|
5
6
|
*/
|
|
6
|
-
/** @internal */
|
|
7
7
|
export declare class PhysicsMaterial {
|
|
8
|
-
/** @internal */
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* V2 Physics plugin private data for a physics material
|
|
11
10
|
*/
|
|
12
11
|
_pluginData: any;
|
|
12
|
+
/**
|
|
13
|
+
* The V2 plugin used to create and manage this Physics Body
|
|
14
|
+
*/
|
|
13
15
|
protected _physicsPlugin: IPhysicsEnginePluginV2;
|
|
14
16
|
/**
|
|
17
|
+
* Constructor of the physics material.
|
|
18
|
+
* @param friction - The friction of the material.
|
|
19
|
+
* @param restitution - The restitution of the material.
|
|
20
|
+
* @param scene - The scene to which the physics engine belongs.
|
|
15
21
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
22
|
+
* This code is useful for initializing the physics material with the
|
|
23
|
+
* given friction, restitution and scene. It also checks if the
|
|
24
|
+
* physics engine and plugin are available and if the plugin version
|
|
25
|
+
* is correct. If all conditions are met, it initializes the material
|
|
26
|
+
* with the physics plugin.
|
|
19
27
|
*/
|
|
20
28
|
constructor(friction: number, restitution: number, scene: Scene);
|
|
21
29
|
/**
|
|
30
|
+
* Sets the friction of the physics engine.
|
|
31
|
+
* @param friction - The friction to set.
|
|
22
32
|
*
|
|
23
|
-
*
|
|
33
|
+
* This method is useful for setting the friction of the physics engine, which is important for simulating realistic physics.
|
|
34
|
+
* The friction determines how much an object will slow down when it is in contact with another object.
|
|
35
|
+
* This is important for simulating realistic physics, such as when an object slides across a surface.
|
|
24
36
|
*/
|
|
25
37
|
setFriction(friction: number): void;
|
|
26
38
|
/**
|
|
39
|
+
* Gets the friction of the physics engine.
|
|
40
|
+
*
|
|
41
|
+
* @returns The friction of the physics engine.
|
|
27
42
|
*
|
|
28
|
-
*
|
|
43
|
+
* This method is useful for getting the friction of the physics engine, which is used to calculate the force of friction between two objects.
|
|
44
|
+
* Knowing the friction of the engine can help to accurately simulate the physical behavior of objects in the engine.
|
|
29
45
|
*/
|
|
30
46
|
getFriction(): number;
|
|
31
47
|
/**
|
|
48
|
+
* Sets the restitution of the physics body.
|
|
49
|
+
* @param restitution A number between 0 and 1 that represents the restitution of the body.
|
|
32
50
|
*
|
|
33
|
-
*
|
|
51
|
+
* This method is useful for setting the restitution of a physics body, which is the amount of energy that is retained after a collision.
|
|
52
|
+
* A restitution of 0 means that no energy is retained, while a restitution of 1 means that all energy is retained.
|
|
53
|
+
* Setting the restitution of a body can help to create realistic physics simulations.
|
|
34
54
|
*/
|
|
35
55
|
setRestitution(restitution: number): void;
|
|
36
56
|
/**
|
|
57
|
+
* Gets the restitution of the physics engine.
|
|
58
|
+
* @returns The restitution of the physics engine.
|
|
37
59
|
*
|
|
38
|
-
*
|
|
60
|
+
* This method is useful for retrieving the restitution of the physics engine, which is the amount of energy that is preserved after two objects collide.
|
|
61
|
+
* Knowing the restitution of the physics engine can help to accurately simulate the behavior of objects in the physics engine.
|
|
39
62
|
*/
|
|
40
63
|
getRestitution(): number;
|
|
41
64
|
/**
|
|
65
|
+
* Disposes the material.
|
|
42
66
|
*
|
|
67
|
+
* This method is useful for cleaning up the material when it is no longer needed.
|
|
68
|
+
* It calls the disposeMaterial method of the physics plugin, which is responsible for disposing the material and freeing up any resources associated with it.
|
|
69
|
+
* This ensures that the material is properly disposed of and does not cause any memory leaks.
|
|
43
70
|
*/
|
|
44
71
|
dispose(): void;
|
|
45
72
|
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Physics material class
|
|
3
|
+
* Helps setting friction and restitution that are used to compute responding forces in collision response
|
|
3
4
|
*/
|
|
4
|
-
/** @internal */
|
|
5
5
|
export class PhysicsMaterial {
|
|
6
6
|
/**
|
|
7
|
+
* Constructor of the physics material.
|
|
8
|
+
* @param friction - The friction of the material.
|
|
9
|
+
* @param restitution - The restitution of the material.
|
|
10
|
+
* @param scene - The scene to which the physics engine belongs.
|
|
7
11
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
12
|
+
* This code is useful for initializing the physics material with the
|
|
13
|
+
* given friction, restitution and scene. It also checks if the
|
|
14
|
+
* physics engine and plugin are available and if the plugin version
|
|
15
|
+
* is correct. If all conditions are met, it initializes the material
|
|
16
|
+
* with the physics plugin.
|
|
11
17
|
*/
|
|
12
18
|
constructor(friction, restitution, scene) {
|
|
13
|
-
/** @internal */
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
20
|
+
* V2 Physics plugin private data for a physics material
|
|
16
21
|
*/
|
|
17
22
|
this._pluginData = undefined;
|
|
18
23
|
const physicsEngine = scene.getPhysicsEngine();
|
|
@@ -30,35 +35,54 @@ export class PhysicsMaterial {
|
|
|
30
35
|
this._physicsPlugin.initMaterial(this);
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
38
|
+
* Sets the friction of the physics engine.
|
|
39
|
+
* @param friction - The friction to set.
|
|
33
40
|
*
|
|
34
|
-
*
|
|
41
|
+
* This method is useful for setting the friction of the physics engine, which is important for simulating realistic physics.
|
|
42
|
+
* The friction determines how much an object will slow down when it is in contact with another object.
|
|
43
|
+
* This is important for simulating realistic physics, such as when an object slides across a surface.
|
|
35
44
|
*/
|
|
36
45
|
setFriction(friction) {
|
|
37
46
|
this._physicsPlugin.setFriction(this, friction);
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
49
|
+
* Gets the friction of the physics engine.
|
|
40
50
|
*
|
|
41
|
-
* @returns
|
|
51
|
+
* @returns The friction of the physics engine.
|
|
52
|
+
*
|
|
53
|
+
* This method is useful for getting the friction of the physics engine, which is used to calculate the force of friction between two objects.
|
|
54
|
+
* Knowing the friction of the engine can help to accurately simulate the physical behavior of objects in the engine.
|
|
42
55
|
*/
|
|
43
56
|
getFriction() {
|
|
44
57
|
return this._physicsPlugin.getFriction(this);
|
|
45
58
|
}
|
|
46
59
|
/**
|
|
60
|
+
* Sets the restitution of the physics body.
|
|
61
|
+
* @param restitution A number between 0 and 1 that represents the restitution of the body.
|
|
47
62
|
*
|
|
48
|
-
*
|
|
63
|
+
* This method is useful for setting the restitution of a physics body, which is the amount of energy that is retained after a collision.
|
|
64
|
+
* A restitution of 0 means that no energy is retained, while a restitution of 1 means that all energy is retained.
|
|
65
|
+
* Setting the restitution of a body can help to create realistic physics simulations.
|
|
49
66
|
*/
|
|
50
67
|
setRestitution(restitution) {
|
|
51
68
|
this._physicsPlugin.setRestitution(this, restitution);
|
|
52
69
|
}
|
|
53
70
|
/**
|
|
71
|
+
* Gets the restitution of the physics engine.
|
|
72
|
+
* @returns The restitution of the physics engine.
|
|
54
73
|
*
|
|
55
|
-
*
|
|
74
|
+
* This method is useful for retrieving the restitution of the physics engine, which is the amount of energy that is preserved after two objects collide.
|
|
75
|
+
* Knowing the restitution of the physics engine can help to accurately simulate the behavior of objects in the physics engine.
|
|
56
76
|
*/
|
|
57
77
|
getRestitution() {
|
|
58
78
|
return this._physicsPlugin.getRestitution(this);
|
|
59
79
|
}
|
|
60
80
|
/**
|
|
81
|
+
* Disposes the material.
|
|
61
82
|
*
|
|
83
|
+
* This method is useful for cleaning up the material when it is no longer needed.
|
|
84
|
+
* It calls the disposeMaterial method of the physics plugin, which is responsible for disposing the material and freeing up any resources associated with it.
|
|
85
|
+
* This ensures that the material is properly disposed of and does not cause any memory leaks.
|
|
62
86
|
*/
|
|
63
87
|
dispose() {
|
|
64
88
|
this._physicsPlugin.disposeMaterial(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,eAAe;IAUxB;;;;;;;;;;;OAWG;IACH,YAAY,QAAgB,EAAE,WAAmB,EAAE,KAAY;QArB/D;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAmBhC,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,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,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACI,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;OAOG;IACI,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;OAMG;IACI,cAAc;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * Physics material class\r\n * Helps setting friction and restitution that are used to compute responding forces in collision response\r\n */\r\nexport class PhysicsMaterial {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n * Constructor of the physics material.\r\n * @param friction - The friction of the material.\r\n * @param restitution - The restitution of the material.\r\n * @param scene - The scene to which the physics engine belongs.\r\n *\r\n * This code is useful for initializing the physics material with the\r\n * given friction, restitution and scene. It also checks if the\r\n * physics engine and plugin are available and if the plugin version\r\n * is correct. If all conditions are met, it initializes the material\r\n * with the physics plugin.\r\n */\r\n constructor(friction: number, restitution: number, scene: Scene) {\r\n const physicsEngine = scene.getPhysicsEngine();\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 this._physicsPlugin.initMaterial(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the physics engine.\r\n * @param friction - The friction to set.\r\n *\r\n * This method is useful for setting the friction of the physics engine, which is important for simulating realistic physics.\r\n * The friction determines how much an object will slow down when it is in contact with another object.\r\n * This is important for simulating realistic physics, such as when an object slides across a surface.\r\n */\r\n public setFriction(friction: number): void {\r\n this._physicsPlugin.setFriction(this, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the physics engine.\r\n *\r\n * @returns The friction of the physics engine.\r\n *\r\n * This method is useful for getting the friction of the physics engine, which is used to calculate the force of friction between two objects.\r\n * Knowing the friction of the engine can help to accurately simulate the physical behavior of objects in the engine.\r\n */\r\n public getFriction(): number {\r\n return this._physicsPlugin.getFriction(this);\r\n }\r\n\r\n /**\r\n * Sets the restitution of the physics body.\r\n * @param restitution A number between 0 and 1 that represents the restitution of the body.\r\n *\r\n * This method is useful for setting the restitution of a physics body, which is the amount of energy that is retained after a collision.\r\n * A restitution of 0 means that no energy is retained, while a restitution of 1 means that all energy is retained.\r\n * Setting the restitution of a body can help to create realistic physics simulations.\r\n */\r\n public setRestitution(restitution: number): void {\r\n this._physicsPlugin.setRestitution(this, restitution);\r\n }\r\n\r\n /**\r\n * Gets the restitution of the physics engine.\r\n * @returns The restitution of the physics engine.\r\n *\r\n * This method is useful for retrieving the restitution of the physics engine, which is the amount of energy that is preserved after two objects collide.\r\n * Knowing the restitution of the physics engine can help to accurately simulate the behavior of objects in the physics engine.\r\n */\r\n public getRestitution(): number {\r\n return this._physicsPlugin.getRestitution(this);\r\n }\r\n\r\n /**\r\n * Disposes the material.\r\n *\r\n * This method is useful for cleaning up the material when it is no longer needed.\r\n * It calls the disposeMaterial method of the physics plugin, which is responsible for disposing the material and freeing up any resources associated with it.\r\n * This ensures that the material is properly disposed of and does not cause any memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeMaterial(this);\r\n }\r\n}\r\n"]}
|
|
@@ -5,23 +5,32 @@ import type { PhysicsShapeParameters } from "./IPhysicsEnginePlugin";
|
|
|
5
5
|
import type { PhysicsMaterial } from "./physicsMaterial";
|
|
6
6
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
7
7
|
import type { Quaternion } from "../../Maths/math.vector";
|
|
8
|
-
import type {
|
|
8
|
+
import type { Mesh } from "../../Meshes/mesh";
|
|
9
9
|
import type { Scene } from "../../scene";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* PhysicsShape class.
|
|
12
|
+
* This class is useful for creating a physics shape that can be used in a physics engine.
|
|
13
|
+
* A Physic Shape determine how collision are computed. It must be attached to a body.
|
|
12
14
|
*/
|
|
13
|
-
/** @internal */
|
|
14
15
|
export declare class PhysicsShape {
|
|
15
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* V2 Physics plugin private data for single shape
|
|
18
|
+
*/
|
|
16
19
|
_pluginData: any;
|
|
20
|
+
/**
|
|
21
|
+
* The V2 plugin used to create and manage this Physics Body
|
|
22
|
+
*/
|
|
17
23
|
private _physicsPlugin;
|
|
18
24
|
private _type;
|
|
19
25
|
/**
|
|
26
|
+
* Constructs a new physics shape.
|
|
27
|
+
* @param type The type of the shape.
|
|
28
|
+
* @param options The options of the shape.
|
|
29
|
+
* @param scene The scene the shape belongs to.
|
|
20
30
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @returns
|
|
31
|
+
* This code is useful for creating a new physics shape with the given type, options, and scene.
|
|
32
|
+
* It also checks that the physics engine and plugin version are correct.
|
|
33
|
+
* If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
|
|
25
34
|
*/
|
|
26
35
|
constructor(type: number, options: PhysicsShapeParameters | undefined, scene: Scene);
|
|
27
36
|
/**
|
|
@@ -130,7 +139,7 @@ export declare class PhysicsShapeCylinder extends PhysicsShape {
|
|
|
130
139
|
*
|
|
131
140
|
*/
|
|
132
141
|
/** @internal */
|
|
133
|
-
export declare class
|
|
142
|
+
export declare class PhysicsShapeBox extends PhysicsShape {
|
|
134
143
|
/** @internal */
|
|
135
144
|
/**
|
|
136
145
|
*
|
|
@@ -145,38 +154,38 @@ export declare class PhysicsShapeShapeBox extends PhysicsShape {
|
|
|
145
154
|
*
|
|
146
155
|
*/
|
|
147
156
|
/** @internal */
|
|
148
|
-
export declare class
|
|
157
|
+
export declare class PhysicsShapeConvexHull extends PhysicsShape {
|
|
149
158
|
/** @internal */
|
|
150
159
|
/**
|
|
151
160
|
*
|
|
152
161
|
* @param mesh
|
|
153
162
|
* @param scene
|
|
154
163
|
*/
|
|
155
|
-
constructor(mesh:
|
|
164
|
+
constructor(mesh: Mesh, scene: Scene);
|
|
156
165
|
}
|
|
157
166
|
/**
|
|
158
167
|
*
|
|
159
168
|
*/
|
|
160
169
|
/** @internal */
|
|
161
|
-
export declare class
|
|
170
|
+
export declare class PhysicsShapeMesh extends PhysicsShape {
|
|
162
171
|
/** @internal */
|
|
163
172
|
/**
|
|
164
173
|
*
|
|
165
174
|
* @param mesh
|
|
166
175
|
* @param scene
|
|
167
176
|
*/
|
|
168
|
-
constructor(mesh:
|
|
177
|
+
constructor(mesh: Mesh, scene: Scene);
|
|
169
178
|
}
|
|
170
179
|
/**
|
|
171
180
|
*
|
|
172
181
|
*/
|
|
173
182
|
/** @internal */
|
|
174
|
-
export declare class
|
|
183
|
+
export declare class PhysicsShapeContainer extends PhysicsShape {
|
|
175
184
|
/** @internal */
|
|
176
185
|
/**
|
|
177
186
|
*
|
|
178
187
|
* @param mesh
|
|
179
188
|
* @param scene
|
|
180
189
|
*/
|
|
181
|
-
constructor(mesh:
|
|
190
|
+
constructor(mesh: Mesh, scene: Scene);
|
|
182
191
|
}
|