@babylonjs/core 5.52.0 → 5.53.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.
- package/Animations/animatable.js +1 -1
- package/Animations/animatable.js.map +1 -1
- package/Collisions/pickingInfo.d.ts +2 -1
- package/Collisions/pickingInfo.js +4 -3
- package/Collisions/pickingInfo.js.map +1 -1
- package/DeviceInput/eventFactory.js +4 -0
- package/DeviceInput/eventFactory.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +17 -9
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/engine.d.ts +2 -0
- package/Engines/engine.js +5 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +3 -3
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.js +5 -12
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +3 -2
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginManager.js +13 -3
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +2 -0
- package/Materials/uniformBuffer.js +4 -0
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.frustum.d.ts +8 -1
- package/Maths/math.frustum.js +14 -0
- package/Maths/math.frustum.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +2 -1
- package/Meshes/instancedMesh.js +3 -2
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +10 -5
- package/Meshes/mesh.js +40 -16
- package/Meshes/mesh.js.map +1 -1
- package/Misc/filesInput.d.ts +5 -2
- package/Misc/filesInput.js +39 -20
- package/Misc/filesInput.js.map +1 -1
- package/Misc/sceneOptimizer.js +3 -0
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Physics/v2/physicsAggregate.js +3 -3
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +27 -16
- package/Physics/v2/physicsBody.js +31 -16
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +6 -6
- package/Physics/v2/physicsConstraint.js +6 -6
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +7 -7
- package/Physics/v2/physicsShape.js +7 -7
- package/Physics/v2/physicsShape.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
- package/XR/features/WebXRControllerTeleportation.js +28 -4
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/package.json +1 -1
|
@@ -62,31 +62,31 @@ export declare class PhysicsShape {
|
|
|
62
62
|
*
|
|
63
63
|
* @param layer
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
set filterLayer(layer: number);
|
|
66
66
|
/**
|
|
67
67
|
*
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
get filterLayer(): number;
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
|
-
* @param
|
|
73
|
+
* @param material
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
set material(material: PhysicsMaterial);
|
|
76
76
|
/**
|
|
77
77
|
*
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
get material(): PhysicsMaterial;
|
|
81
81
|
/**
|
|
82
82
|
*
|
|
83
83
|
* @param density
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
set density(density: number);
|
|
86
86
|
/**
|
|
87
87
|
*
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
get density(): number;
|
|
90
90
|
/**
|
|
91
91
|
*
|
|
92
92
|
* @param newChild
|
|
@@ -60,21 +60,21 @@ export class PhysicsShape {
|
|
|
60
60
|
*
|
|
61
61
|
* @param layer
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
set filterLayer(layer) {
|
|
64
64
|
this._physicsPlugin.setFilterLayer(this, layer);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
*
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
get filterLayer() {
|
|
71
71
|
return this._physicsPlugin.getFilterLayer(this);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
*
|
|
75
|
-
* @param
|
|
75
|
+
* @param material
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
set material(material) {
|
|
78
78
|
this._physicsPlugin.setMaterial(this, material);
|
|
79
79
|
this._material = material;
|
|
80
80
|
}
|
|
@@ -82,20 +82,20 @@ export class PhysicsShape {
|
|
|
82
82
|
*
|
|
83
83
|
* @returns
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
get material() {
|
|
86
86
|
return this._material;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
*
|
|
90
90
|
* @param density
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
set density(density) {
|
|
93
93
|
this._physicsPlugin.setDensity(this, density);
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
*
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
get density() {
|
|
99
99
|
return this._physicsPlugin.getDensity(this);
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
@@ -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;IAcrB;;;;;;;;;;;;OAYG;IACH,YAAY,OAA2B,EAAE,KAAY;;QA1BrD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAwBhC,IAAI,CAAC,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D;;;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 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 this._material = material;\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getMaterial(): PhysicsMaterial | undefined {\r\n return this._material;\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 * 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,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAuB9D;;;;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,UAAU,KAAK,IAAI,EAAE;YACjE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;YACtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC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,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,SAAS,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAC9C;;;;OAIG;IACH,YAAY,IAAU,EAAE,KAAY;QAChC,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,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"]}
|
|
@@ -8,6 +8,7 @@ import { Vector3 } from "../../Maths/math.vector";
|
|
|
8
8
|
import type { Material } from "../../Materials/material";
|
|
9
9
|
import type { PickingInfo } from "../../Collisions/pickingInfo";
|
|
10
10
|
import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
|
|
11
|
+
import { Color4 } from "../../Maths/math.color";
|
|
11
12
|
import type { Scene } from "../../scene";
|
|
12
13
|
/**
|
|
13
14
|
* The options container for the teleportation module
|
|
@@ -99,6 +100,11 @@ export interface IWebXRTeleportationOptions {
|
|
|
99
100
|
* Meshes that the teleportation ray cannot go through
|
|
100
101
|
*/
|
|
101
102
|
pickBlockerMeshes?: AbstractMesh[];
|
|
103
|
+
/**
|
|
104
|
+
* Color of the teleportation ray when it is blocked by a mesh in the pickBlockerMeshes array
|
|
105
|
+
* Defaults to red.
|
|
106
|
+
*/
|
|
107
|
+
blockedRayColor?: Color4;
|
|
102
108
|
/**
|
|
103
109
|
* Should teleport work only on a specific hand?
|
|
104
110
|
*/
|
|
@@ -123,6 +129,8 @@ export declare class WebXRMotionControllerTeleportation extends WebXRAbstractFea
|
|
|
123
129
|
private _snapToPositions;
|
|
124
130
|
private _snappedToPoint;
|
|
125
131
|
private _teleportationRingMaterial?;
|
|
132
|
+
private _blockedRayColor;
|
|
133
|
+
private _cachedColor4White;
|
|
126
134
|
private _tmpRay;
|
|
127
135
|
private _tmpVector;
|
|
128
136
|
private _tmpQuaternion;
|
|
@@ -262,6 +270,7 @@ export declare class WebXRMotionControllerTeleportation extends WebXRAbstractFea
|
|
|
262
270
|
private _findClosestSnapPointWithRadius;
|
|
263
271
|
private _setTargetMeshPosition;
|
|
264
272
|
private _setTargetMeshVisibility;
|
|
273
|
+
private _disposeBezierCurve;
|
|
265
274
|
private _showParabolicPath;
|
|
266
275
|
private _teleportForward;
|
|
267
276
|
}
|
|
@@ -14,7 +14,7 @@ import { CreateTorus } from "../../Meshes/Builders/torusBuilder.js";
|
|
|
14
14
|
import { Curve3 } from "../../Maths/math.path.js";
|
|
15
15
|
import { CreateLines } from "../../Meshes/Builders/linesBuilder.js";
|
|
16
16
|
import { WebXRAbstractFeature } from "./WebXRAbstractFeature.js";
|
|
17
|
-
import { Color3 } from "../../Maths/math.color.js";
|
|
17
|
+
import { Color3, Color4 } from "../../Maths/math.color.js";
|
|
18
18
|
import { UtilityLayerRenderer } from "../../Rendering/utilityLayerRenderer.js";
|
|
19
19
|
import { PointerEventTypes } from "../../Events/pointerEvents.js";
|
|
20
20
|
import { setAndStartTimer } from "../../Misc/timer.js";
|
|
@@ -60,6 +60,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
60
60
|
this._options = _options;
|
|
61
61
|
this._controllers = {};
|
|
62
62
|
this._snappedToPoint = false;
|
|
63
|
+
this._cachedColor4White = new Color4(1, 1, 1, 1);
|
|
63
64
|
this._tmpRay = new Ray(new Vector3(), new Vector3());
|
|
64
65
|
this._tmpVector = new Vector3();
|
|
65
66
|
this._tmpQuaternion = new Quaternion();
|
|
@@ -120,6 +121,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
120
121
|
rotating: false,
|
|
121
122
|
currentRotation: 0,
|
|
122
123
|
baseRotation: 0,
|
|
124
|
+
blocked: false,
|
|
123
125
|
},
|
|
124
126
|
};
|
|
125
127
|
const controllerData = this._controllers[xrController.uniqueId];
|
|
@@ -241,6 +243,10 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
241
243
|
controllerData.teleportationState.rotating = false;
|
|
242
244
|
}
|
|
243
245
|
if (axesData.x === 0 && axesData.y === 0) {
|
|
246
|
+
if (controllerData.teleportationState.blocked) {
|
|
247
|
+
controllerData.teleportationState.blocked = false;
|
|
248
|
+
this._setTargetMeshVisibility(false);
|
|
249
|
+
}
|
|
244
250
|
if (controllerData.teleportationState.forward) {
|
|
245
251
|
this._teleportForward(xrController.uniqueId);
|
|
246
252
|
}
|
|
@@ -289,6 +295,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
289
295
|
}
|
|
290
296
|
this._floorMeshes = this._options.floorMeshes || [];
|
|
291
297
|
this._snapToPositions = this._options.snapPositions || [];
|
|
298
|
+
this._blockedRayColor = this._options.blockedRayColor || new Color4(1, 0, 0, 0.75);
|
|
292
299
|
this._setTargetMeshVisibility(false);
|
|
293
300
|
}
|
|
294
301
|
/**
|
|
@@ -456,9 +463,13 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
456
463
|
return this._floorMeshes[index].absolutePosition.y < this._options.xrInput.xrCamera.globalPosition.y;
|
|
457
464
|
});
|
|
458
465
|
if (pick && pick.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(pick.pickedMesh) !== -1) {
|
|
466
|
+
controllerData.teleportationState.blocked = true;
|
|
467
|
+
this._setTargetMeshVisibility(false);
|
|
468
|
+
this._showParabolicPath(pick);
|
|
459
469
|
return;
|
|
460
470
|
}
|
|
461
471
|
else if (pick && pick.pickedPoint) {
|
|
472
|
+
controllerData.teleportationState.blocked = false;
|
|
462
473
|
hitPossible = true;
|
|
463
474
|
this._setTargetMeshPosition(pick);
|
|
464
475
|
this._setTargetMeshVisibility(true);
|
|
@@ -485,9 +496,13 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
485
496
|
return this._floorMeshes.indexOf(o) !== -1;
|
|
486
497
|
});
|
|
487
498
|
if (pick && pick.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(pick.pickedMesh) !== -1) {
|
|
499
|
+
controllerData.teleportationState.blocked = true;
|
|
500
|
+
this._setTargetMeshVisibility(false);
|
|
501
|
+
this._showParabolicPath(pick);
|
|
488
502
|
return;
|
|
489
503
|
}
|
|
490
504
|
else if (pick && pick.pickedPoint) {
|
|
505
|
+
controllerData.teleportationState.blocked = false;
|
|
491
506
|
hitPossible = true;
|
|
492
507
|
this._setTargetMeshPosition(pick);
|
|
493
508
|
this._setTargetMeshVisibility(true);
|
|
@@ -502,6 +517,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
519
|
else {
|
|
520
|
+
this._disposeBezierCurve();
|
|
505
521
|
this._setTargetMeshVisibility(false);
|
|
506
522
|
}
|
|
507
523
|
}
|
|
@@ -648,11 +664,11 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
648
664
|
this._options.teleportationTargetMesh.position.y += 0.01;
|
|
649
665
|
this.onTargetMeshPositionUpdatedObservable.notifyObservers(pickInfo);
|
|
650
666
|
}
|
|
651
|
-
_setTargetMeshVisibility(visible) {
|
|
667
|
+
_setTargetMeshVisibility(visible, force) {
|
|
652
668
|
if (!this._options.teleportationTargetMesh) {
|
|
653
669
|
return;
|
|
654
670
|
}
|
|
655
|
-
if (this._options.teleportationTargetMesh.isVisible === visible) {
|
|
671
|
+
if (this._options.teleportationTargetMesh.isVisible === visible && !force) {
|
|
656
672
|
return;
|
|
657
673
|
}
|
|
658
674
|
this._options.teleportationTargetMesh.isVisible = visible;
|
|
@@ -674,6 +690,12 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
674
690
|
}
|
|
675
691
|
}
|
|
676
692
|
}
|
|
693
|
+
_disposeBezierCurve() {
|
|
694
|
+
if (this._quadraticBezierCurve) {
|
|
695
|
+
this._quadraticBezierCurve.dispose();
|
|
696
|
+
this._quadraticBezierCurve = null;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
677
699
|
_showParabolicPath(pickInfo) {
|
|
678
700
|
if (!pickInfo.pickedPoint || !this._currentTeleportationControllerId) {
|
|
679
701
|
return;
|
|
@@ -683,8 +705,10 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
|
|
|
683
705
|
: this._xrSessionManager.scene;
|
|
684
706
|
const controllerData = this._controllers[this._currentTeleportationControllerId];
|
|
685
707
|
const quadraticBezierVectors = Curve3.CreateQuadraticBezier(controllerData.xrController.pointer.absolutePosition, pickInfo.ray.origin, pickInfo.pickedPoint, 25);
|
|
708
|
+
const color = controllerData.teleportationState.blocked ? this._blockedRayColor : undefined;
|
|
709
|
+
const colorsArray = new Array(26).fill(color || this._cachedColor4White);
|
|
686
710
|
if (!this._options.generateRayPathMesh) {
|
|
687
|
-
this._quadraticBezierCurve = CreateLines("teleportation path line", { points: quadraticBezierVectors.getPoints(), instance: this._quadraticBezierCurve, updatable: true }, sceneToRenderTo);
|
|
711
|
+
this._quadraticBezierCurve = CreateLines("teleportation path line", { points: quadraticBezierVectors.getPoints(), instance: this._quadraticBezierCurve, updatable: true, colors: colorsArray }, sceneToRenderTo);
|
|
688
712
|
}
|
|
689
713
|
else {
|
|
690
714
|
this._quadraticBezierCurve = this._options.generateRayPathMesh(quadraticBezierVectors.getPoints(), pickInfo);
|