@babylonjs/core 5.43.0 → 5.43.1
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/thinEngine.js +2 -2
- package/Engines/thinEngine.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/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/package.json +1 -1
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { ShapeType } from "./IPhysicsEnginePlugin.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* PhysicsShape class.
|
|
4
|
+
* This class is useful for creating a physics shape that can be used in a physics engine.
|
|
5
|
+
* A Physic Shape determine how collision are computed. It must be attached to a body.
|
|
4
6
|
*/
|
|
5
|
-
/** @internal */
|
|
6
7
|
export class PhysicsShape {
|
|
7
8
|
/**
|
|
9
|
+
* Constructs a new physics shape.
|
|
10
|
+
* @param type The type of the shape.
|
|
11
|
+
* @param options The options of the shape.
|
|
12
|
+
* @param scene The scene the shape belongs to.
|
|
8
13
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @returns
|
|
14
|
+
* This code is useful for creating a new physics shape with the given type, options, and scene.
|
|
15
|
+
* It also checks that the physics engine and plugin version are correct.
|
|
16
|
+
* If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
|
|
13
17
|
*/
|
|
14
18
|
constructor(type, options = {}, scene) {
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* V2 Physics plugin private data for single shape
|
|
21
|
+
*/
|
|
16
22
|
this._pluginData = undefined;
|
|
17
23
|
this._type = type;
|
|
18
24
|
if (!scene) {
|
|
@@ -168,7 +174,7 @@ export class PhysicsShapeCylinder extends PhysicsShape {
|
|
|
168
174
|
*
|
|
169
175
|
*/
|
|
170
176
|
/** @internal */
|
|
171
|
-
export class
|
|
177
|
+
export class PhysicsShapeBox extends PhysicsShape {
|
|
172
178
|
/** @internal */
|
|
173
179
|
/**
|
|
174
180
|
*
|
|
@@ -185,7 +191,7 @@ export class PhysicsShapeShapeBox extends PhysicsShape {
|
|
|
185
191
|
*
|
|
186
192
|
*/
|
|
187
193
|
/** @internal */
|
|
188
|
-
export class
|
|
194
|
+
export class PhysicsShapeConvexHull extends PhysicsShape {
|
|
189
195
|
/** @internal */
|
|
190
196
|
/**
|
|
191
197
|
*
|
|
@@ -200,7 +206,7 @@ export class PhysicsShapeShapeConvexHull extends PhysicsShape {
|
|
|
200
206
|
*
|
|
201
207
|
*/
|
|
202
208
|
/** @internal */
|
|
203
|
-
export class
|
|
209
|
+
export class PhysicsShapeMesh extends PhysicsShape {
|
|
204
210
|
/** @internal */
|
|
205
211
|
/**
|
|
206
212
|
*
|
|
@@ -215,7 +221,7 @@ export class PhysicsShapeShapeMesh extends PhysicsShape {
|
|
|
215
221
|
*
|
|
216
222
|
*/
|
|
217
223
|
/** @internal */
|
|
218
|
-
export class
|
|
224
|
+
export class PhysicsShapeContainer extends PhysicsShape {
|
|
219
225
|
/** @internal */
|
|
220
226
|
/**
|
|
221
227
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAQrB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAkC,EAAE,EAAE,KAAY;QAd5E,gBAAgB;QACT,gBAAW,GAAQ,SAAS,CAAC;QAchC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QAED,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,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ClD,gBAAgB;IAChB;;;;;;OAMG;IACH,YAAY,MAAe,EAAE,QAAoB,EAAE,OAAgB,EAAE,KAAY;QAC7E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1F,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,2BAA4B,SAAQ,YAAY;IACzD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,YAAY;IACxD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAkB,EAAE,KAAY;QACxC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShape {\r\n /** @internal */\r\n public _pluginData: any = undefined;\r\n\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: ShapeType;\r\n\r\n /**\r\n *\r\n * @param type\r\n * @param options\r\n * @param scene\r\n * @returns\r\n */\r\n constructor(type: number, options: PhysicsShapeParameters = {}, scene: Scene) {\r\n this._type = type;\r\n if (!scene) {\r\n return;\r\n }\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.initShape(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get type(): ShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n *\r\n * @param layer\r\n */\r\n public setFilterLayer(layer: number): void {\r\n this._physicsPlugin.setFilterLayer(this, layer);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterLayer(): number {\r\n return this._physicsPlugin.getFilterLayer(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param materialId\r\n */\r\n public setMaterial(material: PhysicsMaterial): void {\r\n this._physicsPlugin.setMaterial(this, material);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMaterial(): PhysicsMaterial | undefined {\r\n return this._physicsPlugin.getMaterial(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public setDensity(density: number): void {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getDensity(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param newChild\r\n * @param childTransform\r\n */\r\n public addChild(newChild: PhysicsShape, childTransform: TransformNode): void {\r\n this._physicsPlugin.addChild(this, newChild, childTransform);\r\n }\r\n\r\n /**\r\n *\r\n * @param childIndex\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.SPHERE, { center: center, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/***\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CAPSULE, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CYLINDER, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeBox extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param rotation\r\n * @param extents\r\n * @param scene\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super(ShapeType.BOX, { center: center, rotation: rotation, extents: extents }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeConvexHull extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONVEX_HULL, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeMesh extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.MESH, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeShapeContainer extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: AbstractMesh, scene: Scene) {\r\n super(ShapeType.CONTAINER, {}, scene);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAYrB;;;;;;;;;OASG;IACH,YAAY,IAAY,EAAE,UAAkC,EAAE,EAAE,KAAY;QArB5E;;WAEG;QACI,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AgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD,gBAAgB;IAChB;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * PhysicsShape class.\r\n * This class is useful for creating a physics shape that can be used in a physics engine.\r\n * A Physic Shape determine how collision are computed. It must be attached to a body.\r\n */\r\nexport class PhysicsShape {\r\n /**\r\n * V2 Physics plugin private data for single shape\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 private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: ShapeType;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param type The type of the shape.\r\n * @param options The options of the shape.\r\n * @param scene The scene the shape belongs to.\r\n *\r\n * This code is useful for creating a new physics shape with the given type, options, and scene.\r\n * It also checks that the physics engine and plugin version are correct.\r\n * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.\r\n */\r\n constructor(type: number, options: PhysicsShapeParameters = {}, scene: Scene) {\r\n this._type = type;\r\n if (!scene) {\r\n return;\r\n }\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.initShape(this, type, options);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get type(): ShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n *\r\n * @param layer\r\n */\r\n public setFilterLayer(layer: number): void {\r\n this._physicsPlugin.setFilterLayer(this, layer);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFilterLayer(): number {\r\n return this._physicsPlugin.getFilterLayer(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param materialId\r\n */\r\n public setMaterial(material: PhysicsMaterial): void {\r\n this._physicsPlugin.setMaterial(this, material);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMaterial(): PhysicsMaterial | undefined {\r\n return this._physicsPlugin.getMaterial(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public setDensity(density: number): void {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getDensity(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param newChild\r\n * @param childTransform\r\n */\r\n public addChild(newChild: PhysicsShape, childTransform: TransformNode): void {\r\n this._physicsPlugin.addChild(this, newChild, childTransform);\r\n }\r\n\r\n /**\r\n *\r\n * @param childIndex\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose() {\r\n this._physicsPlugin.disposeShape(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.SPHERE, { center: center, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/***\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CAPSULE, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param pointA\r\n * @param pointB\r\n * @param radius\r\n * @param scene\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super(ShapeType.CYLINDER, { pointA: pointA, pointB: pointB, radius: radius }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param center\r\n * @param rotation\r\n * @param extents\r\n * @param scene\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super(ShapeType.BOX, { center: center, rotation: rotation, extents: extents }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super(ShapeType.CONVEX_HULL, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super(ShapeType.MESH, { mesh: mesh }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n *\r\n * @param mesh\r\n * @param scene\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super(ShapeType.CONTAINER, {}, scene);\r\n }\r\n}\r\n"]}
|