@babylonjs/core 5.57.0 → 6.0.0

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.
Files changed (65) hide show
  1. package/Engines/WebGPU/Extensions/engine.multiRender.js +51 -8
  2. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  3. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
  4. package/Engines/WebGPU/webgpuHardwareTexture.js +23 -10
  5. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  6. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -1
  7. package/Engines/WebGPU/webgpuTextureHelper.js +6 -14
  8. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  9. package/Engines/engine.d.ts +5 -6
  10. package/Engines/thinEngine.js +2 -2
  11. package/Engines/thinEngine.js.map +1 -1
  12. package/Engines/webgpuEngine.js +16 -8
  13. package/Engines/webgpuEngine.js.map +1 -1
  14. package/Lights/Shadows/shadowGenerator.d.ts +2 -0
  15. package/Lights/Shadows/shadowGenerator.js +11 -22
  16. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  17. package/Maths/math.vector.js +4 -2
  18. package/Maths/math.vector.js.map +1 -1
  19. package/Meshes/abstractMesh.d.ts +13 -0
  20. package/Meshes/abstractMesh.js +20 -0
  21. package/Meshes/abstractMesh.js.map +1 -1
  22. package/Meshes/thinInstanceMesh.js +4 -1
  23. package/Meshes/thinInstanceMesh.js.map +1 -1
  24. package/Particles/solidParticleSystem.d.ts +1 -1
  25. package/Particles/solidParticleSystem.js +1 -1
  26. package/Particles/solidParticleSystem.js.map +1 -1
  27. package/Physics/physicsEngineComponent.d.ts +1 -0
  28. package/Physics/physicsEngineComponent.js +1 -0
  29. package/Physics/physicsEngineComponent.js.map +1 -1
  30. package/Physics/physicsHelper.d.ts +12 -5
  31. package/Physics/physicsHelper.js +160 -90
  32. package/Physics/physicsHelper.js.map +1 -1
  33. package/Physics/physicsRaycastResult.d.ts +9 -0
  34. package/Physics/physicsRaycastResult.js.map +1 -1
  35. package/Physics/v2/IPhysicsEnginePlugin.d.ts +120 -77
  36. package/Physics/v2/IPhysicsEnginePlugin.js +119 -48
  37. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  38. package/Physics/v2/Plugins/havokPlugin.d.ts +687 -0
  39. package/Physics/v2/Plugins/havokPlugin.js +1592 -0
  40. package/Physics/v2/Plugins/havokPlugin.js.map +1 -0
  41. package/Physics/v2/Plugins/index.d.ts +1 -0
  42. package/Physics/v2/Plugins/index.js +1 -1
  43. package/Physics/v2/Plugins/index.js.map +1 -1
  44. package/Physics/v2/index.d.ts +1 -0
  45. package/Physics/v2/index.js +2 -0
  46. package/Physics/v2/index.js.map +1 -1
  47. package/Physics/v2/physicsAggregate.d.ts +9 -2
  48. package/Physics/v2/physicsAggregate.js +66 -31
  49. package/Physics/v2/physicsAggregate.js.map +1 -1
  50. package/Physics/v2/physicsBody.d.ts +51 -62
  51. package/Physics/v2/physicsBody.js +101 -128
  52. package/Physics/v2/physicsBody.js.map +1 -1
  53. package/Physics/v2/physicsConstraint.d.ts +57 -25
  54. package/Physics/v2/physicsConstraint.js +32 -15
  55. package/Physics/v2/physicsConstraint.js.map +1 -1
  56. package/Physics/v2/physicsEngine.d.ts +0 -1
  57. package/Physics/v2/physicsEngine.js +0 -1
  58. package/Physics/v2/physicsEngine.js.map +1 -1
  59. package/Physics/v2/physicsEngineComponent.d.ts +0 -10
  60. package/Physics/v2/physicsEngineComponent.js +0 -29
  61. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  62. package/Physics/v2/physicsShape.d.ts +52 -11
  63. package/Physics/v2/physicsShape.js +80 -23
  64. package/Physics/v2/physicsShape.js.map +1 -1
  65. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import type { TransformNode } from "../../Meshes/transformNode";
2
2
  import type { AbstractMesh } from "../../Meshes/abstractMesh";
3
3
  import type { BoundingBox } from "../../Culling/boundingBox";
4
- import { ShapeType } from "./IPhysicsEnginePlugin";
4
+ import { PhysicsShapeType } from "./IPhysicsEnginePlugin";
5
5
  import type { PhysicsShapeParameters } from "./IPhysicsEnginePlugin";
6
6
  import type { PhysicsMaterial } from "./physicsMaterial";
7
7
  import { Vector3, Quaternion } from "../../Maths/math.vector";
@@ -14,7 +14,7 @@ export interface PhysicShapeOptions {
14
14
  /**
15
15
  * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER
16
16
  */
17
- type?: ShapeType;
17
+ type?: PhysicsShapeType;
18
18
  /**
19
19
  * The parameters of the shape. Varies depending of the shape type.
20
20
  */
@@ -54,20 +54,50 @@ export declare class PhysicsShape {
54
54
  * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
55
55
  */
56
56
  constructor(options: PhysicShapeOptions, scene: Scene);
57
+ /**
58
+ * Returns the string "PhysicsShape".
59
+ * @returns "PhysicsShape"
60
+ */
61
+ getClassName(): string;
57
62
  /**
58
63
  *
59
64
  */
60
- get type(): ShapeType;
65
+ get type(): PhysicsShapeType;
61
66
  /**
67
+ * Set the membership mask of a shape. This is a bitfield of arbitrary
68
+ * "categories" to which the shape is a member. This is used in combination
69
+ * with the collide mask to determine if this shape should collide with
70
+ * another.
62
71
  *
63
- * @param layer
72
+ * @param membershipMask Bitfield of categories of this shape.
73
+ */
74
+ set filterMembershipMask(membershipMask: number);
75
+ /**
76
+ * Get the membership mask of a shape.
77
+ * @returns Bitmask of categories which this shape is a member of.
64
78
  */
65
- set filterLayer(layer: number);
79
+ get filterMembershipMask(): number;
66
80
  /**
81
+ * Sets the collide mask of a shape. This is a bitfield of arbitrary
82
+ * "categories" to which this shape collides with. Given two shapes,
83
+ * the engine will check if the collide mask and membership overlap:
84
+ * shapeA.filterMembershipMask & shapeB.filterCollideMask
67
85
  *
68
- * @returns
86
+ * If this value is zero (i.e. shapeB only collides with categories
87
+ * which shapeA is _not_ a member of) then the shapes will not collide.
88
+ *
89
+ * Note, the engine will also perform the same test with shapeA and
90
+ * shapeB swapped; the shapes will not collide if either shape has
91
+ * a collideMask which prevents collision with the other shape.
92
+ *
93
+ * @param collideMask Bitmask of categories this shape should collide with
94
+ */
95
+ set filterCollideMask(collideMask: number);
96
+ /**
97
+ *
98
+ * @returns Bitmask of categories that this shape should collide with
69
99
  */
70
- get filterLayer(): number;
100
+ get filterCollideMask(): number;
71
101
  /**
72
102
  *
73
103
  * @param material
@@ -88,11 +118,23 @@ export declare class PhysicsShape {
88
118
  */
89
119
  get density(): number;
90
120
  /**
121
+ * Utility to add a child shape to this container,
122
+ * automatically computing the relative transform between
123
+ * the container shape and the child instance.
91
124
  *
92
- * @param newChild
93
- * @param childTransform
125
+ * @param parentTransform The transform node associated with this shape
126
+ * @param newChild The new PhysicsShape to add
127
+ * @param childTransform The transform node associated with the child shape
128
+ */
129
+ addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void;
130
+ /**
131
+ * Adds a child shape to a container with an optional transform
132
+ * @param newChild The new PhysicsShape to add
133
+ * @param translation Optional position of the child shape relative to this shape
134
+ * @param rotation Optional rotation of the child shape relative to this shape
135
+ * @param scale Optional scale of the child shape relative to this shape
94
136
  */
95
- addChild(newChild: PhysicsShape, childTransform: TransformNode): void;
137
+ addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;
96
138
  /**
97
139
  *
98
140
  * @param childIndex
@@ -116,7 +158,6 @@ export declare class PhysicsShape {
116
158
  * Helper object to create a sphere shape
117
159
  */
118
160
  export declare class PhysicsShapeSphere extends PhysicsShape {
119
- /** @internal */
120
161
  /**
121
162
  * Constructor for the Sphere Shape
122
163
  * @param center local center of the sphere
@@ -1,5 +1,5 @@
1
- import { ShapeType } from "./IPhysicsEnginePlugin.js";
2
- import { Vector3, Quaternion } from "../../Maths/math.vector.js";
1
+ import { PhysicsShapeType } from "./IPhysicsEnginePlugin.js";
2
+ import { Matrix, Vector3, Quaternion, TmpVectors } from "../../Maths/math.vector.js";
3
3
  /**
4
4
  * PhysicsShape class.
5
5
  * This class is useful for creating a physics shape that can be used in a physics engine.
@@ -50,6 +50,13 @@ export class PhysicsShape {
50
50
  this._physicsPlugin.initShape(this, options.type, parameters);
51
51
  }
52
52
  }
53
+ /**
54
+ * Returns the string "PhysicsShape".
55
+ * @returns "PhysicsShape"
56
+ */
57
+ getClassName() {
58
+ return "PhysicsShape";
59
+ }
53
60
  /**
54
61
  *
55
62
  */
@@ -57,18 +64,47 @@ export class PhysicsShape {
57
64
  return this._type;
58
65
  }
59
66
  /**
67
+ * Set the membership mask of a shape. This is a bitfield of arbitrary
68
+ * "categories" to which the shape is a member. This is used in combination
69
+ * with the collide mask to determine if this shape should collide with
70
+ * another.
60
71
  *
61
- * @param layer
72
+ * @param membershipMask Bitfield of categories of this shape.
62
73
  */
63
- set filterLayer(layer) {
64
- this._physicsPlugin.setFilterLayer(this, layer);
74
+ set filterMembershipMask(membershipMask) {
75
+ this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);
65
76
  }
66
77
  /**
78
+ * Get the membership mask of a shape.
79
+ * @returns Bitmask of categories which this shape is a member of.
80
+ */
81
+ get filterMembershipMask() {
82
+ return this._physicsPlugin.getShapeFilterMembershipMask(this);
83
+ }
84
+ /**
85
+ * Sets the collide mask of a shape. This is a bitfield of arbitrary
86
+ * "categories" to which this shape collides with. Given two shapes,
87
+ * the engine will check if the collide mask and membership overlap:
88
+ * shapeA.filterMembershipMask & shapeB.filterCollideMask
67
89
  *
68
- * @returns
90
+ * If this value is zero (i.e. shapeB only collides with categories
91
+ * which shapeA is _not_ a member of) then the shapes will not collide.
92
+ *
93
+ * Note, the engine will also perform the same test with shapeA and
94
+ * shapeB swapped; the shapes will not collide if either shape has
95
+ * a collideMask which prevents collision with the other shape.
96
+ *
97
+ * @param collideMask Bitmask of categories this shape should collide with
69
98
  */
70
- get filterLayer() {
71
- return this._physicsPlugin.getFilterLayer(this);
99
+ set filterCollideMask(collideMask) {
100
+ this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);
101
+ }
102
+ /**
103
+ *
104
+ * @returns Bitmask of categories that this shape should collide with
105
+ */
106
+ get filterCollideMask() {
107
+ return this._physicsPlugin.getShapeFilterCollideMask(this);
72
108
  }
73
109
  /**
74
110
  *
@@ -99,12 +135,34 @@ export class PhysicsShape {
99
135
  return this._physicsPlugin.getDensity(this);
100
136
  }
101
137
  /**
138
+ * Utility to add a child shape to this container,
139
+ * automatically computing the relative transform between
140
+ * the container shape and the child instance.
102
141
  *
103
- * @param newChild
104
- * @param childTransform
142
+ * @param parentTransform The transform node associated with this shape
143
+ * @param newChild The new PhysicsShape to add
144
+ * @param childTransform The transform node associated with the child shape
105
145
  */
106
- addChild(newChild, childTransform) {
107
- this._physicsPlugin.addChild(this, newChild, childTransform);
146
+ addChildFromParent(parentTransform, newChild, childTransform) {
147
+ const childToWorld = childTransform.computeWorldMatrix(true);
148
+ const parentToWorld = parentTransform.computeWorldMatrix(true);
149
+ const childToParent = TmpVectors.Matrix[0];
150
+ childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);
151
+ const translation = TmpVectors.Vector3[0];
152
+ const rotation = TmpVectors.Quaternion[0];
153
+ const scale = TmpVectors.Vector3[1];
154
+ childToParent.decompose(scale, rotation, translation);
155
+ this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);
156
+ }
157
+ /**
158
+ * Adds a child shape to a container with an optional transform
159
+ * @param newChild The new PhysicsShape to add
160
+ * @param translation Optional position of the child shape relative to this shape
161
+ * @param rotation Optional rotation of the child shape relative to this shape
162
+ * @param scale Optional scale of the child shape relative to this shape
163
+ */
164
+ addChild(newChild, translation, rotation, scale) {
165
+ this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);
108
166
  }
109
167
  /**
110
168
  *
@@ -137,7 +195,6 @@ export class PhysicsShape {
137
195
  * Helper object to create a sphere shape
138
196
  */
139
197
  export class PhysicsShapeSphere extends PhysicsShape {
140
- /** @internal */
141
198
  /**
142
199
  * Constructor for the Sphere Shape
143
200
  * @param center local center of the sphere
@@ -145,7 +202,7 @@ export class PhysicsShapeSphere extends PhysicsShape {
145
202
  * @param scene scene to attach to
146
203
  */
147
204
  constructor(center, radius, scene) {
148
- super({ type: ShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);
205
+ super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);
149
206
  }
150
207
  /**
151
208
  *
@@ -154,9 +211,9 @@ export class PhysicsShapeSphere extends PhysicsShape {
154
211
  */
155
212
  static FromMesh(mesh) {
156
213
  const bounds = mesh.getBoundingInfo();
157
- //<todo.eoin We don't use bounding sphere because the results seem to be wrong
158
- const centerLocal = bounds.boundingBox.center;
159
- const radius = bounds.boundingBox.extendSize.x;
214
+ const centerLocal = bounds.boundingSphere.center;
215
+ const he = bounds.boundingBox.extendSize;
216
+ const radius = Math.max(he.x, he.y, he.z);
160
217
  return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());
161
218
  }
162
219
  }
@@ -172,7 +229,7 @@ export class PhysicsShapeCapsule extends PhysicsShape {
172
229
  * @param scene scene to attach to
173
230
  */
174
231
  constructor(pointA, pointB, radius, scene) {
175
- super({ type: ShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);
232
+ super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);
176
233
  }
177
234
  /**
178
235
  * Derive an approximate capsule from the transform node. Note, this is
@@ -200,7 +257,7 @@ export class PhysicsShapeCylinder extends PhysicsShape {
200
257
  * @param scene scene to attach to
201
258
  */
202
259
  constructor(pointA, pointB, radius, scene) {
203
- super({ type: ShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);
260
+ super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);
204
261
  }
205
262
  /**
206
263
  * Derive an approximate cylinder from the transform node. Note, this is
@@ -228,7 +285,7 @@ export class PhysicsShapeBox extends PhysicsShape {
228
285
  * @param scene scene to attach to
229
286
  */
230
287
  constructor(center, rotation, extents, scene) {
231
- super({ type: ShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);
288
+ super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);
232
289
  }
233
290
  /**
234
291
  *
@@ -252,7 +309,7 @@ export class PhysicsShapeConvexHull extends PhysicsShape {
252
309
  * @param scene scene to attach to
253
310
  */
254
311
  constructor(mesh, scene) {
255
- super({ type: ShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);
312
+ super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);
256
313
  }
257
314
  }
258
315
  /**
@@ -265,7 +322,7 @@ export class PhysicsShapeMesh extends PhysicsShape {
265
322
  * @param scene scene to attach to
266
323
  */
267
324
  constructor(mesh, scene) {
268
- super({ type: ShapeType.MESH, parameters: { mesh: mesh } }, scene);
325
+ super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);
269
326
  }
270
327
  }
271
328
  /**
@@ -277,7 +334,7 @@ export class PhysicsShapeContainer extends PhysicsShape {
277
334
  * @param scene scene to attach to
278
335
  */
279
336
  constructor(scene) {
280
- super({ type: ShapeType.CONTAINER, parameters: {} }, scene);
337
+ super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);
281
338
  }
282
339
  }
283
340
  //# sourceMappingURL=physicsShape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAuB9D;;;;GAIG;AACH,MAAM,OAAO,YAAY;I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AAC,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD;;;OAGG;IACH,YAAY,KAAY;QACpB,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\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 { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: ShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\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 private _material: PhysicsMaterial;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\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(options: PhysicShapeOptions, 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 this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\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 set filterLayer(layer: number) {\r\n this._physicsPlugin.setFilterLayer(this, layer);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public get filterLayer(): number {\r\n return this._physicsPlugin.getFilterLayer(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public get material(): PhysicsMaterial {\r\n return this._material;\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get density(): 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 * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /** @internal */\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: ShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n //<todo.eoin We don't use bounding sphere because the results seem to be wrong\r\n const centerLocal = bounds.boundingBox.center;\r\n const radius = bounds.boundingBox.extendSize.x;\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: ShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the transform node. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param TransformNode node Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: ShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the transform node. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param TransformNode node Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the sphere\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: ShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: ShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: ShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: ShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAuBlF;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAcrB;;;;;;;;;;;;OAYG;IACH,YAAY,OAA2B,EAAE,KAAY;;QA1BrD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAwBhC,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;QACD,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAE9D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,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AAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,wDAAwD;QAClH,OAAO,IAAI,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7F,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IACpD;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACrF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD;;;OAGG;IACH,YAAY,KAAY;QACpB,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { Matrix, Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: PhysicsShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\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: PhysicsShapeType;\r\n\r\n private _material: PhysicsMaterial;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\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(options: PhysicShapeOptions, 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 this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsShape\".\r\n * @returns \"PhysicsShape\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsShape\";\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get type(): PhysicsShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Set the membership mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which the shape is a member. This is used in combination\r\n * with the collide mask to determine if this shape should collide with\r\n * another.\r\n *\r\n * @param membershipMask Bitfield of categories of this shape.\r\n */\r\n public set filterMembershipMask(membershipMask: number) {\r\n this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);\r\n }\r\n\r\n /**\r\n * Get the membership mask of a shape.\r\n * @returns Bitmask of categories which this shape is a member of.\r\n */\r\n public get filterMembershipMask(): number {\r\n return this._physicsPlugin.getShapeFilterMembershipMask(this);\r\n }\r\n\r\n /**\r\n * Sets the collide mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which this shape collides with. Given two shapes,\r\n * the engine will check if the collide mask and membership overlap:\r\n * shapeA.filterMembershipMask & shapeB.filterCollideMask\r\n *\r\n * If this value is zero (i.e. shapeB only collides with categories\r\n * which shapeA is _not_ a member of) then the shapes will not collide.\r\n *\r\n * Note, the engine will also perform the same test with shapeA and\r\n * shapeB swapped; the shapes will not collide if either shape has\r\n * a collideMask which prevents collision with the other shape.\r\n *\r\n * @param collideMask Bitmask of categories this shape should collide with\r\n */\r\n public set filterCollideMask(collideMask: number) {\r\n this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Bitmask of categories that this shape should collide with\r\n */\r\n public get filterCollideMask(): number {\r\n return this._physicsPlugin.getShapeFilterCollideMask(this);\r\n }\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public get material(): PhysicsMaterial {\r\n return this._material;\r\n }\r\n\r\n /**\r\n *\r\n * @param density\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public get density(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n * Utility to add a child shape to this container,\r\n * automatically computing the relative transform between\r\n * the container shape and the child instance.\r\n *\r\n * @param parentTransform The transform node associated with this shape\r\n * @param newChild The new PhysicsShape to add\r\n * @param childTransform The transform node associated with the child shape\r\n */\r\n public addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void {\r\n const childToWorld = childTransform.computeWorldMatrix(true);\r\n const parentToWorld = parentTransform.computeWorldMatrix(true);\r\n const childToParent = TmpVectors.Matrix[0];\r\n childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);\r\n const translation = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scale = TmpVectors.Vector3[1];\r\n childToParent.decompose(scale, rotation, translation);\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Adds a child shape to a container with an optional transform\r\n * @param newChild The new PhysicsShape to add\r\n * @param translation Optional position of the child shape relative to this shape\r\n * @param rotation Optional rotation of the child shape relative to this shape\r\n * @param scale Optional scale of the child shape relative to this shape\r\n */\r\n public addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\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 * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingSphere.center;\r\n const he = bounds.boundingBox.extendSize;\r\n const radius = Math.max(he.x, he.y, he.z);\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the transform node. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param TransformNode node Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the transform node. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param TransformNode node Node from which to derive a cylinder shape\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the sphere\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/core",
3
- "version": "5.57.0",
3
+ "version": "6.0.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",