@babylonjs/core 8.20.0 → 8.21.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/Animations/animationGroup.d.ts +5 -0
- package/Animations/animationGroup.js +7 -0
- package/Animations/animationGroup.js.map +1 -1
- package/Cameras/Inputs/flyCameraMouseInput.js +2 -3
- package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseInput.js +3 -5
- package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraTouchInput.js +2 -2
- package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +4 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +4 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +2 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/material.js +3 -0
- package/Materials/material.js.map +1 -1
- package/Misc/decorators.serialization.js +6 -1
- package/Misc/decorators.serialization.js.map +1 -1
- package/Misc/dumpTools.d.ts +2 -13
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/textureTools.d.ts +6 -6
- package/Misc/textureTools.js +81 -19
- package/Misc/textureTools.js.map +1 -1
- package/Particles/flowMap.js +3 -24
- package/Particles/flowMap.js.map +1 -1
- package/XR/features/WebXRHandTracking.d.ts +7 -1
- package/XR/features/WebXRHandTracking.js +17 -3
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/webXRCamera.d.ts +0 -1
- package/XR/webXRCamera.js +1 -8
- package/XR/webXRCamera.js.map +1 -1
- package/package.json +1 -1
package/Particles/flowMap.js.map
CHANGED
|
@@ -1 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","sourcesContent":["import { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Particle } from \"../Particles/particle\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\n\r\nconst FlowVector = new Vector3(0, 0, 0);\r\nconst ScaledFlowVector = new Vector3(0, 0, 0);\r\nconst ScreenPos = new Vector3(0, 0, 0);\r\n\r\n/**\r\n * Represents an object that can move or be influenced by FlowMap\r\n */\r\nexport interface IFlowable {\r\n /**\r\n * The direction vector indicating the flow or movement direction of the object.\r\n */\r\n direction: Vector3;\r\n\r\n /**\r\n * The current position of the object in 3D space.\r\n */\r\n position: Vector3;\r\n}\r\n\r\n/**\r\n * Class used to represent a particle flow map.\r\n * #5DM02T#7\r\n * GPUParts: #5DM02T#12 (webgl2)\r\n * GPUParts: #5DM02T#13 (webgpu)\r\n */\r\nexport class FlowMap {\r\n /**\r\n * Create a new flow map.\r\n * @param width defines the width of the flow map\r\n * @param height defines the height of the flow map\r\n * @param data defines the data of the flow map\r\n */\r\n constructor(\r\n public readonly width: number,\r\n public readonly height: number,\r\n public readonly data: Uint8ClampedArray\r\n ) {}\r\n\r\n public processFlowable(flowable: IFlowable, strength = 1, flowMapSamplePosOrTransformationMatrix?: IVector3Like | Matrix) {\r\n if (!flowMapSamplePosOrTransformationMatrix) {\r\n return;\r\n }\r\n\r\n // Convert world pos to screen pos\r\n if (flowMapSamplePosOrTransformationMatrix instanceof Matrix) {\r\n Vector3.TransformCoordinatesToRef(flowable.position, flowMapSamplePosOrTransformationMatrix, ScreenPos);\r\n } else {\r\n ScreenPos.x = flowMapSamplePosOrTransformationMatrix.x;\r\n ScreenPos.y = flowMapSamplePosOrTransformationMatrix.y;\r\n ScreenPos.z = flowMapSamplePosOrTransformationMatrix.z;\r\n }\r\n\r\n const u = ScreenPos.x * 0.5 + 0.5;\r\n const v = 1.0 - (ScreenPos.y * 0.5 + 0.5);\r\n\r\n const x = Math.floor(u * this.width);\r\n const y = Math.floor(v * this.height);\r\n\r\n // Clamp\r\n if (x < 0 || x >= this.width || y < 0 || y >= this.height) {\r\n return;\r\n }\r\n\r\n const index = (y * this.width + x) * 4;\r\n const r = this.data[index];\r\n const g = this.data[index + 1];\r\n const b = this.data[index + 2];\r\n const a = this.data[index + 3];\r\n\r\n const fx = (r / 255.0) * 2.0 - 1.0;\r\n const fy = (g / 255.0) * 2.0 - 1.0;\r\n const fz = (b / 255.0) * 2.0 - 1.0;\r\n const localStrength = a / 255.0;\r\n\r\n FlowVector.set(fx, fy, fz);\r\n FlowVector.scaleToRef(strength * localStrength, ScaledFlowVector);\r\n\r\n flowable.direction.addInPlace(ScaledFlowVector); // Update IFlowable velocity\r\n }\r\n\r\n /** @internal */\r\n public _processParticle(particle: Particle, strength = 1, matrix?: Matrix) {\r\n this.processFlowable(particle, strength, matrix);\r\n }\r\n\r\n /**\r\n * Creates a FlowMap from a url.\r\n * @param url The url of the image to load\r\n * @returns a promise that resolves to a FlowMap object\r\n */\r\n public static async FromUrlAsync(url: string): Promise<FlowMap> {\r\n return await new Promise((resolve, reject) => {\r\n const flowCanvas = document.createElement(\"canvas\");\r\n const flowCtx = flowCanvas.getContext(\"2d\")!;\r\n let flowImageData = null;\r\n\r\n const flowMapImage = new Image();\r\n flowMapImage.crossOrigin = \"anonymous\"; // If loading from another domain\r\n flowMapImage.src = url;\r\n\r\n flowMapImage.onerror = (e) => {\r\n reject(new Error(`Failed to load image: ${url} : ${e}`));\r\n };\r\n\r\n flowMapImage.onload = () => {\r\n flowCanvas.width = flowMapImage.width;\r\n flowCanvas.height = flowMapImage.height;\r\n flowCtx.drawImage(flowMapImage, 0, 0);\r\n flowImageData = flowCtx.getImageData(0, 0, flowCanvas.width, flowCanvas.height);\r\n\r\n resolve(new FlowMap(flowCanvas.width, flowCanvas.height, flowImageData.data));\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Load from a texture\r\n * @param texture defines the source texture\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public static async ExtractFromTextureAsync(texture: Texture) {\r\n return await new Promise<FlowMap>((resolve, reject) => {\r\n if (!texture.isReady()) {\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n texture.onLoadObservable.addOnce(async () => {\r\n try {\r\n const result = await this.ExtractFromTextureAsync(texture);\r\n resolve(result);\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(e);\r\n }\r\n });\r\n return;\r\n }\r\n const size = texture.getSize();\r\n TextureTools.GetTextureDataAsync(texture, size.width, size.height)\r\n // eslint-disable-next-line github/no-then\r\n .then((data) => {\r\n resolve(new FlowMap(size.width, size.height, new Uint8ClampedArray(data)));\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowMap.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/flowMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,YAAY,EAAE,gCAA+B;AAEtD,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAiBvC;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IAChB;;;;;OAKG;IACH,YACoB,KAAa,EACb,MAAc,EACd,IAAuB;QAFvB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAmB;IACxC,CAAC;IAEG,eAAe,CAAC,QAAmB,EAAE,QAAQ,G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W,CAAC,CAAC,iCAAiC;YACzE,YAAY,CAAC,GAAG,GAAG,GAAG,CAAC;YAEvB,YAAY,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;gBACzB,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7D,CAAC,CAAC;YAEF,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE;gBACvB,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;gBACtC,UAAU,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;gBACxC,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;gBAEhF,OAAO,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,OAAgB;QACxD,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5C,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,CAAC;CACJ","sourcesContent":["import { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Particle } from \"../Particles/particle\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\n\r\nconst FlowVector = new Vector3(0, 0, 0);\r\nconst ScaledFlowVector = new Vector3(0, 0, 0);\r\nconst ScreenPos = new Vector3(0, 0, 0);\r\n\r\n/**\r\n * Represents an object that can move or be influenced by FlowMap\r\n */\r\nexport interface IFlowable {\r\n /**\r\n * The direction vector indicating the flow or movement direction of the object.\r\n */\r\n direction: Vector3;\r\n\r\n /**\r\n * The current position of the object in 3D space.\r\n */\r\n position: Vector3;\r\n}\r\n\r\n/**\r\n * Class used to represent a particle flow map.\r\n * #5DM02T#7\r\n * GPUParts: #5DM02T#12 (webgl2)\r\n * GPUParts: #5DM02T#13 (webgpu)\r\n */\r\nexport class FlowMap {\r\n /**\r\n * Create a new flow map.\r\n * @param width defines the width of the flow map\r\n * @param height defines the height of the flow map\r\n * @param data defines the data of the flow map\r\n */\r\n constructor(\r\n public readonly width: number,\r\n public readonly height: number,\r\n public readonly data: Uint8ClampedArray\r\n ) {}\r\n\r\n public processFlowable(flowable: IFlowable, strength = 1, flowMapSamplePosOrTransformationMatrix?: IVector3Like | Matrix) {\r\n if (!flowMapSamplePosOrTransformationMatrix) {\r\n return;\r\n }\r\n\r\n // Convert world pos to screen pos\r\n if (flowMapSamplePosOrTransformationMatrix instanceof Matrix) {\r\n Vector3.TransformCoordinatesToRef(flowable.position, flowMapSamplePosOrTransformationMatrix, ScreenPos);\r\n } else {\r\n ScreenPos.x = flowMapSamplePosOrTransformationMatrix.x;\r\n ScreenPos.y = flowMapSamplePosOrTransformationMatrix.y;\r\n ScreenPos.z = flowMapSamplePosOrTransformationMatrix.z;\r\n }\r\n\r\n const u = ScreenPos.x * 0.5 + 0.5;\r\n const v = 1.0 - (ScreenPos.y * 0.5 + 0.5);\r\n\r\n const x = Math.floor(u * this.width);\r\n const y = Math.floor(v * this.height);\r\n\r\n // Clamp\r\n if (x < 0 || x >= this.width || y < 0 || y >= this.height) {\r\n return;\r\n }\r\n\r\n const index = (y * this.width + x) * 4;\r\n const r = this.data[index];\r\n const g = this.data[index + 1];\r\n const b = this.data[index + 2];\r\n const a = this.data[index + 3];\r\n\r\n const fx = (r / 255.0) * 2.0 - 1.0;\r\n const fy = (g / 255.0) * 2.0 - 1.0;\r\n const fz = (b / 255.0) * 2.0 - 1.0;\r\n const localStrength = a / 255.0;\r\n\r\n FlowVector.set(fx, fy, fz);\r\n FlowVector.scaleToRef(strength * localStrength, ScaledFlowVector);\r\n\r\n flowable.direction.addInPlace(ScaledFlowVector); // Update IFlowable velocity\r\n }\r\n\r\n /** @internal */\r\n public _processParticle(particle: Particle, strength = 1, matrix?: Matrix) {\r\n this.processFlowable(particle, strength, matrix);\r\n }\r\n\r\n /**\r\n * Creates a FlowMap from a url.\r\n * @param url The url of the image to load\r\n * @returns a promise that resolves to a FlowMap object\r\n */\r\n public static async FromUrlAsync(url: string): Promise<FlowMap> {\r\n return await new Promise((resolve, reject) => {\r\n const flowCanvas = document.createElement(\"canvas\");\r\n const flowCtx = flowCanvas.getContext(\"2d\")!;\r\n let flowImageData = null;\r\n\r\n const flowMapImage = new Image();\r\n flowMapImage.crossOrigin = \"anonymous\"; // If loading from another domain\r\n flowMapImage.src = url;\r\n\r\n flowMapImage.onerror = (e) => {\r\n reject(new Error(`Failed to load image: ${url} : ${e}`));\r\n };\r\n\r\n flowMapImage.onload = () => {\r\n flowCanvas.width = flowMapImage.width;\r\n flowCanvas.height = flowMapImage.height;\r\n flowCtx.drawImage(flowMapImage, 0, 0);\r\n flowImageData = flowCtx.getImageData(0, 0, flowCanvas.width, flowCanvas.height);\r\n\r\n resolve(new FlowMap(flowCanvas.width, flowCanvas.height, flowImageData.data));\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Load from a texture\r\n * @param texture defines the source texture\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public static async ExtractFromTextureAsync(texture: Texture) {\r\n const data = await TextureTools.GetTextureDataAsync(texture);\r\n const { width, height } = texture.getSize();\r\n return new FlowMap(width, height, new Uint8ClampedArray(data));\r\n }\r\n}\r\n"]}
|
|
@@ -9,6 +9,7 @@ import type { IDisposable } from "../../scene.js";
|
|
|
9
9
|
import { Observable } from "../../Misc/observable.js";
|
|
10
10
|
import type { InstancedMesh } from "../../Meshes/instancedMesh.js";
|
|
11
11
|
import { Color3 } from "../../Maths/math.color.js";
|
|
12
|
+
import type { WebXRCamera } from "../webXRCamera.js";
|
|
12
13
|
/**
|
|
13
14
|
* Configuration interface for the hand tracking feature
|
|
14
15
|
*/
|
|
@@ -229,6 +230,10 @@ export declare class WebXRHand implements IDisposable {
|
|
|
229
230
|
* The float array that will directly receive the joint radii from WebXR.
|
|
230
231
|
*/
|
|
231
232
|
private _jointRadii;
|
|
233
|
+
/**
|
|
234
|
+
* The hand mesh's top-most parent, if any.
|
|
235
|
+
*/
|
|
236
|
+
private _handMeshRoot;
|
|
232
237
|
/**
|
|
233
238
|
* Get the hand mesh.
|
|
234
239
|
*/
|
|
@@ -275,8 +280,9 @@ export declare class WebXRHand implements IDisposable {
|
|
|
275
280
|
* Update this hand from the latest xr frame.
|
|
276
281
|
* @param xrFrame The latest frame received from WebXR.
|
|
277
282
|
* @param referenceSpace The current viewer reference space.
|
|
283
|
+
* @param xrCamera the xr camera, used for parenting
|
|
278
284
|
*/
|
|
279
|
-
updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
|
|
285
|
+
updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, xrCamera: WebXRCamera): void;
|
|
280
286
|
/**
|
|
281
287
|
* Dispose this Hand object
|
|
282
288
|
* @param disposeMeshes Should the meshes be disposed as well
|
|
@@ -229,6 +229,10 @@ export class WebXRHand {
|
|
|
229
229
|
* The float array that will directly receive the joint radii from WebXR.
|
|
230
230
|
*/
|
|
231
231
|
this._jointRadii = new Float32Array(HandJointReferenceArray.length);
|
|
232
|
+
/**
|
|
233
|
+
* The hand mesh's top-most parent, if any.
|
|
234
|
+
*/
|
|
235
|
+
this._handMeshRoot = null;
|
|
232
236
|
this._scene = _jointMeshes[0].getScene();
|
|
233
237
|
// Initialize the joint transform quaternions and link the transforms to the bones.
|
|
234
238
|
for (let jointIdx = 0; jointIdx < this._jointTransforms.length; jointIdx++) {
|
|
@@ -264,6 +268,10 @@ export class WebXRHand {
|
|
|
264
268
|
*/
|
|
265
269
|
setHandMesh(handMesh, rigMapping, _xrSessionManager) {
|
|
266
270
|
this._handMesh = handMesh;
|
|
271
|
+
this._handMeshRoot = this._handMesh;
|
|
272
|
+
while (this._handMeshRoot.parent) {
|
|
273
|
+
this._handMeshRoot = this._handMeshRoot.parent;
|
|
274
|
+
}
|
|
267
275
|
// Avoid any strange frustum culling. We will manually control visibility via attach and detach.
|
|
268
276
|
handMesh.alwaysSelectAsActiveMesh = true;
|
|
269
277
|
const children = handMesh.getChildMeshes();
|
|
@@ -287,8 +295,9 @@ export class WebXRHand {
|
|
|
287
295
|
* Update this hand from the latest xr frame.
|
|
288
296
|
* @param xrFrame The latest frame received from WebXR.
|
|
289
297
|
* @param referenceSpace The current viewer reference space.
|
|
298
|
+
* @param xrCamera the xr camera, used for parenting
|
|
290
299
|
*/
|
|
291
|
-
updateFromXRFrame(xrFrame, referenceSpace) {
|
|
300
|
+
updateFromXRFrame(xrFrame, referenceSpace, xrCamera) {
|
|
292
301
|
const hand = this.xrController.inputSource.hand;
|
|
293
302
|
if (!hand) {
|
|
294
303
|
return;
|
|
@@ -329,6 +338,7 @@ export class WebXRHand {
|
|
|
329
338
|
jointMesh.position.copyFrom(jointTransform.position);
|
|
330
339
|
jointMesh.rotationQuaternion.copyFrom(jointTransform.rotationQuaternion);
|
|
331
340
|
jointMesh.scaling.setAll(scaledJointRadius);
|
|
341
|
+
jointMesh.parent = xrCamera.parent;
|
|
332
342
|
// The WebXR data comes as right-handed, so we might need to do some conversions.
|
|
333
343
|
if (!this._scene.useRightHandedSystem) {
|
|
334
344
|
jointMesh.position.z *= -1;
|
|
@@ -343,7 +353,11 @@ export class WebXRHand {
|
|
|
343
353
|
}
|
|
344
354
|
if (this._handMesh) {
|
|
345
355
|
this._handMesh.isVisible = true;
|
|
356
|
+
if (this._handMeshRoot) {
|
|
357
|
+
this._handMeshRoot.parent = xrCamera.parent;
|
|
358
|
+
}
|
|
346
359
|
}
|
|
360
|
+
this.xrController.pointer.parent = xrCamera.parent;
|
|
347
361
|
}
|
|
348
362
|
/**
|
|
349
363
|
* Dispose this Hand object
|
|
@@ -659,8 +673,8 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
|
|
|
659
673
|
return true;
|
|
660
674
|
}
|
|
661
675
|
_onXRFrame(_xrFrame) {
|
|
662
|
-
this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);
|
|
663
|
-
this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);
|
|
676
|
+
this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace, this.options.xrInput.xrCamera);
|
|
677
|
+
this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace, this.options.xrInput.xrCamera);
|
|
664
678
|
}
|
|
665
679
|
_detachHandById(controllerId, disposeMesh) {
|
|
666
680
|
const hand = this.getHandByControllerId(controllerId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebXRHandTracking.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRHandTracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAKjF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM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iB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,AAAhD,CAAiD;AAE3E,+BAAa,GAAsC,IAAI,AAA1C,CAA2C;AACxD,8BAAY,GAAsC,IAAI,AAA1C,CAA2C;AAkd1E,qBAAqB;AACrB,oBAAoB,CAAC,eAAe,CAChC,iBAAiB,CAAC,IAAI,EACtB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC,EACD,iBAAiB,CAAC,OAAO,EACzB,KAAK,CACR,CAAC","sourcesContent":["import { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { WebXRFeatureName, WebXRFeaturesManager } from \"../webXRFeaturesManager\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { WebXRInput } from \"../webXRInput\";\r\nimport type { WebXRInputSource } from \"../webXRInputSource\";\r\nimport { Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { PhysicsImpostor } from \"../../Physics/v1/physicsImpostor\";\r\n\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { InstancedMesh } from \"../../Meshes/instancedMesh\";\r\nimport type { ISceneLoaderAsyncResult } from \"../../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { NodeMaterial } from \"../../Materials/Node/nodeMaterial\";\r\nimport type { InputBlock } from \"../../Materials/Node/Blocks/Input/inputBlock\";\r\nimport { Material } from \"../../Materials/material\";\r\nimport { CreateIcoSphere } from \"../../Meshes/Builders/icoSphereBuilder\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Axis } from \"../../Maths/math.axis\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { WebXRCompositionLayerWrapper } from \"./Layers/WebXRCompositionLayer\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\ndeclare const XRHand: XRHand;\r\n\r\n/**\r\n * Configuration interface for the hand tracking feature\r\n */\r\nexport interface IWebXRHandTrackingOptions {\r\n /**\r\n * The xrInput that will be used as source for new hands\r\n */\r\n xrInput: WebXRInput;\r\n\r\n /**\r\n * Configuration object for the joint meshes.\r\n */\r\n jointMeshes?: {\r\n /**\r\n * Should the meshes created be invisible (defaults to false).\r\n */\r\n invisible?: boolean;\r\n /**\r\n * A source mesh to be used to create instances. Defaults to an icosphere with two subdivisions and smooth lighting.\r\n * This mesh will be the source for all other (25) meshes.\r\n * It should have the general size of a single unit, as the instances will be scaled according to the provided radius.\r\n */\r\n sourceMesh?: Mesh;\r\n /**\r\n * This function will be called after a mesh was created for a specific joint.\r\n * Using this function you can either manipulate the instance or return a new mesh.\r\n * When returning a new mesh the instance created before will be disposed.\r\n * @param meshInstance An instance of the original joint mesh being used for the joint.\r\n * @param jointId The joint's index, see https://immersive-web.github.io/webxr-hand-input/#skeleton-joints-section for more info.\r\n * @param hand Which hand (\"left\", \"right\") the joint will be on.\r\n */\r\n onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, hand: XRHandedness) => AbstractMesh | undefined;\r\n /**\r\n * Should the source mesh stay visible (defaults to false).\r\n */\r\n keepOriginalVisible?: boolean;\r\n /**\r\n * Should each instance have its own physics impostor\r\n */\r\n enablePhysics?: boolean;\r\n /**\r\n * If enabled, override default physics properties\r\n */\r\n physicsProps?: { friction?: number; restitution?: number; impostorType?: number };\r\n /**\r\n * Scale factor for all joint meshes (defaults to 1)\r\n */\r\n scaleFactor?: number;\r\n };\r\n\r\n /**\r\n * Configuration object for the hand meshes.\r\n */\r\n handMeshes?: {\r\n /**\r\n * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).\r\n */\r\n disableDefaultMeshes?: boolean;\r\n /**\r\n * Rigged hand meshes that will be tracked to the user's hands. This will override the default hand mesh.\r\n */\r\n customMeshes?: {\r\n right: AbstractMesh;\r\n left: AbstractMesh;\r\n };\r\n /**\r\n * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.\r\n */\r\n meshesUseLeftHandedCoordinates?: boolean;\r\n /**\r\n * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh\r\n */\r\n customRigMappings?: {\r\n right: XRHandMeshRigMapping;\r\n left: XRHandMeshRigMapping;\r\n };\r\n\r\n /**\r\n * Override the colors of the hand meshes.\r\n */\r\n customColors?: {\r\n base?: Color3;\r\n fresnel?: Color3;\r\n fingerColor?: Color3;\r\n tipFresnel?: Color3;\r\n };\r\n\r\n /**\r\n * Define whether or not the hand meshes should be disposed on just invisible when the session ends.\r\n * Not setting, or setting to false, will maintain the hand meshes in the scene after the session ends, which will allow q quicker re-entry into XR.\r\n */\r\n disposeOnSessionEnd?: boolean;\r\n\r\n /**\r\n * Setting this will allow the developer to avoid loading the NME material and use the standard material instead.\r\n */\r\n disableHandShader?: boolean;\r\n };\r\n}\r\n\r\n/**\r\n * Parts of the hands divided to writs and finger names\r\n */\r\nexport const enum HandPart {\r\n /**\r\n * HandPart - Wrist\r\n */\r\n WRIST = \"wrist\",\r\n /**\r\n * HandPart - The thumb\r\n */\r\n THUMB = \"thumb\",\r\n /**\r\n * HandPart - Index finger\r\n */\r\n INDEX = \"index\",\r\n /**\r\n * HandPart - Middle finger\r\n */\r\n MIDDLE = \"middle\",\r\n /**\r\n * HandPart - Ring finger\r\n */\r\n RING = \"ring\",\r\n /**\r\n * HandPart - Little finger\r\n */\r\n LITTLE = \"little\",\r\n}\r\n\r\n/**\r\n * Joints of the hand as defined by the WebXR specification.\r\n * https://immersive-web.github.io/webxr-hand-input/#skeleton-joints-section\r\n */\r\nexport const enum WebXRHandJoint {\r\n /** Wrist */\r\n WRIST = \"wrist\",\r\n\r\n /** Thumb near wrist */\r\n THUMB_METACARPAL = \"thumb-metacarpal\",\r\n /** Thumb first knuckle */\r\n THUMB_PHALANX_PROXIMAL = \"thumb-phalanx-proximal\",\r\n /** Thumb second knuckle */\r\n THUMB_PHALANX_DISTAL = \"thumb-phalanx-distal\",\r\n /** Thumb tip */\r\n THUMB_TIP = \"thumb-tip\",\r\n\r\n /** Index finger near wrist */\r\n INDEX_FINGER_METACARPAL = \"index-finger-metacarpal\",\r\n /** Index finger first knuckle */\r\n INDEX_FINGER_PHALANX_PROXIMAL = \"index-finger-phalanx-proximal\",\r\n /** Index finger second knuckle */\r\n INDEX_FINGER_PHALANX_INTERMEDIATE = \"index-finger-phalanx-intermediate\",\r\n /** Index finger third knuckle */\r\n INDEX_FINGER_PHALANX_DISTAL = \"index-finger-phalanx-distal\",\r\n /** Index finger tip */\r\n INDEX_FINGER_TIP = \"index-finger-tip\",\r\n\r\n /** Middle finger near wrist */\r\n MIDDLE_FINGER_METACARPAL = \"middle-finger-metacarpal\",\r\n /** Middle finger first knuckle */\r\n MIDDLE_FINGER_PHALANX_PROXIMAL = \"middle-finger-phalanx-proximal\",\r\n /** Middle finger second knuckle */\r\n MIDDLE_FINGER_PHALANX_INTERMEDIATE = \"middle-finger-phalanx-intermediate\",\r\n /** Middle finger third knuckle */\r\n MIDDLE_FINGER_PHALANX_DISTAL = \"middle-finger-phalanx-distal\",\r\n /** Middle finger tip */\r\n MIDDLE_FINGER_TIP = \"middle-finger-tip\",\r\n\r\n /** Ring finger near wrist */\r\n RING_FINGER_METACARPAL = \"ring-finger-metacarpal\",\r\n /** Ring finger first knuckle */\r\n RING_FINGER_PHALANX_PROXIMAL = \"ring-finger-phalanx-proximal\",\r\n /** Ring finger second knuckle */\r\n RING_FINGER_PHALANX_INTERMEDIATE = \"ring-finger-phalanx-intermediate\",\r\n /** Ring finger third knuckle */\r\n RING_FINGER_PHALANX_DISTAL = \"ring-finger-phalanx-distal\",\r\n /** Ring finger tip */\r\n RING_FINGER_TIP = \"ring-finger-tip\",\r\n\r\n /** Pinky finger near wrist */\r\n PINKY_FINGER_METACARPAL = \"pinky-finger-metacarpal\",\r\n /** Pinky finger first knuckle */\r\n PINKY_FINGER_PHALANX_PROXIMAL = \"pinky-finger-phalanx-proximal\",\r\n /** Pinky finger second knuckle */\r\n PINKY_FINGER_PHALANX_INTERMEDIATE = \"pinky-finger-phalanx-intermediate\",\r\n /** Pinky finger third knuckle */\r\n PINKY_FINGER_PHALANX_DISTAL = \"pinky-finger-phalanx-distal\",\r\n /** Pinky finger tip */\r\n PINKY_FINGER_TIP = \"pinky-finger-tip\",\r\n}\r\n\r\n/** A type encapsulating a dictionary mapping WebXR joints to bone names in a rigged hand mesh. */\r\nexport type XRHandMeshRigMapping = { [webXRJointName in WebXRHandJoint]: string };\r\n\r\nconst HandJointReferenceArray: WebXRHandJoint[] = [\r\n WebXRHandJoint.WRIST,\r\n WebXRHandJoint.THUMB_METACARPAL,\r\n WebXRHandJoint.THUMB_PHALANX_PROXIMAL,\r\n WebXRHandJoint.THUMB_PHALANX_DISTAL,\r\n WebXRHandJoint.THUMB_TIP,\r\n WebXRHandJoint.INDEX_FINGER_METACARPAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.INDEX_FINGER_TIP,\r\n WebXRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.MIDDLE_FINGER_TIP,\r\n WebXRHandJoint.RING_FINGER_METACARPAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.RING_FINGER_TIP,\r\n WebXRHandJoint.PINKY_FINGER_METACARPAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.PINKY_FINGER_TIP,\r\n];\r\n\r\nconst HandPartsDefinition: { [key in HandPart]: WebXRHandJoint[] } = {\r\n [HandPart.WRIST]: [WebXRHandJoint.WRIST],\r\n [HandPart.THUMB]: [WebXRHandJoint.THUMB_METACARPAL, WebXRHandJoint.THUMB_PHALANX_PROXIMAL, WebXRHandJoint.THUMB_PHALANX_DISTAL, WebXRHandJoint.THUMB_TIP],\r\n [HandPart.INDEX]: [\r\n WebXRHandJoint.INDEX_FINGER_METACARPAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.INDEX_FINGER_TIP,\r\n ],\r\n [HandPart.MIDDLE]: [\r\n WebXRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.MIDDLE_FINGER_TIP,\r\n ],\r\n [HandPart.RING]: [\r\n WebXRHandJoint.RING_FINGER_METACARPAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.RING_FINGER_TIP,\r\n ],\r\n [HandPart.LITTLE]: [\r\n WebXRHandJoint.PINKY_FINGER_METACARPAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.PINKY_FINGER_TIP,\r\n ],\r\n};\r\n\r\n/**\r\n * Representing a single hand (with its corresponding native XRHand object)\r\n */\r\nexport class WebXRHand implements IDisposable {\r\n /**\r\n * This observable will notify registered observers when the hand object has been set with a new mesh.\r\n * you can get the hand mesh using `webxrHand.handMesh`\r\n */\r\n public onHandMeshSetObservable = new Observable<WebXRHand>();\r\n\r\n private _scene: Scene;\r\n\r\n /**\r\n * Transform nodes that will directly receive the transforms from the WebXR matrix data.\r\n */\r\n private _jointTransforms = new Array<TransformNode>(HandJointReferenceArray.length);\r\n\r\n /**\r\n * The float array that will directly receive the transform matrix data from WebXR.\r\n */\r\n private _jointTransformMatrices = new Float32Array(HandJointReferenceArray.length * 16);\r\n\r\n private _tempJointMatrix = new Matrix();\r\n\r\n /**\r\n * The float array that will directly receive the joint radii from WebXR.\r\n */\r\n private _jointRadii = new Float32Array(HandJointReferenceArray.length);\r\n\r\n /**\r\n * Get the hand mesh.\r\n */\r\n public get handMesh(): Nullable<AbstractMesh> {\r\n return this._handMesh;\r\n }\r\n\r\n /**\r\n * Get meshes of part of the hand.\r\n * @param part The part of hand to get.\r\n * @returns An array of meshes that correlate to the hand part requested.\r\n */\r\n public getHandPartMeshes(part: HandPart): AbstractMesh[] {\r\n return HandPartsDefinition[part].map((name) => this._jointMeshes[HandJointReferenceArray.indexOf(name)]);\r\n }\r\n\r\n /**\r\n * Retrieves a mesh linked to a named joint in the hand.\r\n * @param jointName The name of the joint.\r\n * @returns An AbstractMesh whose position corresponds with the joint position.\r\n */\r\n public getJointMesh(jointName: WebXRHandJoint): AbstractMesh {\r\n return this._jointMeshes[HandJointReferenceArray.indexOf(jointName)];\r\n }\r\n\r\n /**\r\n * Construct a new hand object\r\n * @param xrController The controller to which the hand correlates.\r\n * @param _jointMeshes The meshes to be used to track the hand joints.\r\n * @param _handMesh An optional hand mesh.\r\n * @param rigMapping An optional rig mapping for the hand mesh.\r\n * If not provided (but a hand mesh is provided),\r\n * it will be assumed that the hand mesh's bones are named\r\n * directly after the WebXR bone names.\r\n * @param _leftHandedMeshes Are the hand meshes left-handed-system meshes\r\n * @param _jointsInvisible Are the tracked joint meshes visible\r\n * @param _jointScaleFactor Scale factor for all joint meshes\r\n */\r\n constructor(\r\n /** The controller to which the hand correlates. */\r\n public readonly xrController: WebXRInputSource,\r\n private readonly _jointMeshes: AbstractMesh[],\r\n private _handMesh: Nullable<AbstractMesh>,\r\n /** An optional rig mapping for the hand mesh. If not provided (but a hand mesh is provided),\r\n * it will be assumed that the hand mesh's bones are named directly after the WebXR bone names. */\r\n readonly rigMapping: Nullable<XRHandMeshRigMapping>,\r\n private readonly _leftHandedMeshes: boolean = false,\r\n private readonly _jointsInvisible: boolean = false,\r\n private readonly _jointScaleFactor: number = 1\r\n ) {\r\n this._scene = _jointMeshes[0].getScene();\r\n\r\n // Initialize the joint transform quaternions and link the transforms to the bones.\r\n for (let jointIdx = 0; jointIdx < this._jointTransforms.length; jointIdx++) {\r\n this._jointTransforms[jointIdx] = new TransformNode(HandJointReferenceArray[jointIdx], this._scene);\r\n this._jointTransforms[jointIdx].rotationQuaternion = new Quaternion();\r\n\r\n // Set the rotation quaternion so we can use it later for tracking.\r\n if (_jointMeshes[jointIdx].rotationQuaternion) {\r\n _jointMeshes[jointIdx].rotationQuaternion = new Quaternion();\r\n } else {\r\n _jointMeshes[jointIdx].rotationQuaternion?.set(0, 0, 0, 1);\r\n }\r\n }\r\n\r\n if (_handMesh) {\r\n // Note that this logic needs to happen after we initialize the joint tracking transform nodes.\r\n this.setHandMesh(_handMesh, rigMapping);\r\n }\r\n\r\n // hide the motion controller, if available/loaded\r\n if (this.xrController.motionController) {\r\n if (this.xrController.motionController.rootMesh) {\r\n this.xrController.motionController.rootMesh.dispose(false, true);\r\n }\r\n }\r\n\r\n this.xrController.onMotionControllerInitObservable.add((motionController) => {\r\n motionController._doNotLoadControllerMesh = true;\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current hand mesh to render for the WebXRHand.\r\n * @param handMesh The rigged hand mesh that will be tracked to the user's hand.\r\n * @param rigMapping The mapping from XRHandJoint to bone names to use with the mesh.\r\n * @param _xrSessionManager The XRSessionManager used to initialize the hand mesh.\r\n */\r\n public setHandMesh(handMesh: AbstractMesh, rigMapping: Nullable<XRHandMeshRigMapping>, _xrSessionManager?: WebXRSessionManager) {\r\n this._handMesh = handMesh;\r\n\r\n // Avoid any strange frustum culling. We will manually control visibility via attach and detach.\r\n handMesh.alwaysSelectAsActiveMesh = true;\r\n const children = handMesh.getChildMeshes();\r\n for (const mesh of children) {\r\n mesh.alwaysSelectAsActiveMesh = true;\r\n }\r\n\r\n // Link the bones in the hand mesh to the transform nodes that will be bound to the WebXR tracked joints.\r\n if (this._handMesh.skeleton) {\r\n const handMeshSkeleton = this._handMesh.skeleton;\r\n for (let jointIdx = 0; jointIdx < HandJointReferenceArray.length; jointIdx++) {\r\n const jointName = HandJointReferenceArray[jointIdx];\r\n const jointBoneIdx = handMeshSkeleton.getBoneIndexByName(rigMapping ? rigMapping[jointName] : jointName);\r\n if (jointBoneIdx !== -1) {\r\n handMeshSkeleton.bones[jointBoneIdx].linkTransformNode(this._jointTransforms[jointIdx]);\r\n }\r\n }\r\n }\r\n\r\n this.onHandMeshSetObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Update this hand from the latest xr frame.\r\n * @param xrFrame The latest frame received from WebXR.\r\n * @param referenceSpace The current viewer reference space.\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace) {\r\n const hand = this.xrController.inputSource.hand;\r\n if (!hand) {\r\n return;\r\n }\r\n\r\n // TODO: Modify webxr.d.ts to better match WebXR IDL so we don't need this any cast.\r\n const anyHand: any = hand;\r\n const jointSpaces: XRJointSpace[] = HandJointReferenceArray.map((jointName) => anyHand[jointName] || hand.get(jointName));\r\n let trackingSuccessful = false;\r\n\r\n if (xrFrame.fillPoses && xrFrame.fillJointRadii) {\r\n trackingSuccessful = xrFrame.fillPoses(jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(jointSpaces, this._jointRadii);\r\n } else if (xrFrame.getJointPose) {\r\n trackingSuccessful = true;\r\n // Warning: This codepath is slow by comparison, only here for compat.\r\n for (let jointIdx = 0; jointIdx < jointSpaces.length; jointIdx++) {\r\n const jointPose = xrFrame.getJointPose(jointSpaces[jointIdx], referenceSpace);\r\n if (jointPose) {\r\n this._jointTransformMatrices.set(jointPose.transform.matrix, jointIdx * 16);\r\n this._jointRadii[jointIdx] = jointPose.radius || 0.008;\r\n } else {\r\n trackingSuccessful = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!trackingSuccessful) {\r\n return;\r\n }\r\n\r\n for (let jointIdx = 0; jointIdx < HandJointReferenceArray.length; jointIdx++) {\r\n const jointTransform = this._jointTransforms[jointIdx];\r\n Matrix.FromArrayToRef(this._jointTransformMatrices, jointIdx * 16, this._tempJointMatrix);\r\n this._tempJointMatrix.decompose(undefined, jointTransform.rotationQuaternion!, jointTransform.position);\r\n\r\n // The radius we need to make the joint in order for it to roughly cover the joints of the user's real hand.\r\n const scaledJointRadius = this._jointRadii[jointIdx] * this._jointScaleFactor;\r\n\r\n const jointMesh = this._jointMeshes[jointIdx];\r\n jointMesh.isVisible = !this._handMesh && !this._jointsInvisible;\r\n jointMesh.position.copyFrom(jointTransform.position);\r\n jointMesh.rotationQuaternion!.copyFrom(jointTransform.rotationQuaternion!);\r\n jointMesh.scaling.setAll(scaledJointRadius);\r\n\r\n // The WebXR data comes as right-handed, so we might need to do some conversions.\r\n if (!this._scene.useRightHandedSystem) {\r\n jointMesh.position.z *= -1;\r\n jointMesh.rotationQuaternion!.z *= -1;\r\n jointMesh.rotationQuaternion!.w *= -1;\r\n\r\n if (this._leftHandedMeshes && this._handMesh) {\r\n jointTransform.position.z *= -1;\r\n jointTransform.rotationQuaternion!.z *= -1;\r\n jointTransform.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n }\r\n\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = true;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose this Hand object\r\n * @param disposeMeshes Should the meshes be disposed as well\r\n */\r\n public dispose(disposeMeshes = false) {\r\n if (this._handMesh) {\r\n if (disposeMeshes) {\r\n this._handMesh.skeleton?.dispose();\r\n this._handMesh.dispose(false, true);\r\n } else {\r\n this._handMesh.isVisible = false;\r\n }\r\n }\r\n for (const transform of this._jointTransforms) {\r\n transform.dispose();\r\n }\r\n this._jointTransforms.length = 0;\r\n this.onHandMeshSetObservable.clear();\r\n }\r\n}\r\n\r\n/**\r\n * WebXR Hand Joint tracking feature, available for selected browsers and devices\r\n */\r\nexport class WebXRHandTracking extends WebXRAbstractFeature {\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.HAND_TRACKING;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /** The base URL for the default hand model. */\r\n public static DEFAULT_HAND_MODEL_BASE_URL = \"https://assets.babylonjs.com/core/HandMeshes/\";\r\n /** The filename to use for the default right hand model. */\r\n public static DEFAULT_HAND_MODEL_RIGHT_FILENAME = \"r_hand_rhs.glb\";\r\n /** The filename to use for the default left hand model. */\r\n public static DEFAULT_HAND_MODEL_LEFT_FILENAME = \"l_hand_rhs.glb\";\r\n /** The URL pointing to the default hand model NodeMaterial shader. */\r\n public static DEFAULT_HAND_MODEL_SHADER_URL = \"https://assets.babylonjs.com/core/HandMeshes/handsShader.json\";\r\n\r\n // We want to use lightweight models, diameter will initially be 1 but scaled to the values returned from WebXR.\r\n private static readonly _ICOSPHERE_PARAMS = { radius: 0.5, flat: false, subdivisions: 2 };\r\n\r\n private static _RightHandGLB: Nullable<ISceneLoaderAsyncResult> = null;\r\n private static _LeftHandGLB: Nullable<ISceneLoaderAsyncResult> = null;\r\n\r\n private static _GenerateTrackedJointMeshes(\r\n featureOptions: IWebXRHandTrackingOptions,\r\n originalMesh: Mesh = CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS)\r\n ): { left: AbstractMesh[]; right: AbstractMesh[] } {\r\n const meshes: { [handedness: string]: AbstractMesh[] } = {};\r\n [\"left\" as XRHandedness, \"right\" as XRHandedness].map((handedness) => {\r\n const trackedMeshes = [];\r\n originalMesh.isVisible = !!featureOptions.jointMeshes?.keepOriginalVisible;\r\n for (let i = 0; i < HandJointReferenceArray.length; ++i) {\r\n let newInstance: AbstractMesh = originalMesh.createInstance(`${handedness}-handJoint-${i}`);\r\n if (featureOptions.jointMeshes?.onHandJointMeshGenerated) {\r\n const returnedMesh = featureOptions.jointMeshes.onHandJointMeshGenerated(newInstance as InstancedMesh, i, handedness);\r\n if (returnedMesh) {\r\n if (returnedMesh !== newInstance) {\r\n newInstance.dispose();\r\n newInstance = returnedMesh;\r\n }\r\n }\r\n }\r\n newInstance.isPickable = false;\r\n if (featureOptions.jointMeshes?.enablePhysics) {\r\n const props = featureOptions.jointMeshes?.physicsProps || {};\r\n // downscale the instances so that physics will be initialized correctly\r\n newInstance.scaling.setAll(0.02);\r\n const type = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, { mass: 0, ...props });\r\n }\r\n newInstance.rotationQuaternion = new Quaternion();\r\n newInstance.isVisible = false;\r\n trackedMeshes.push(newInstance);\r\n }\r\n\r\n meshes[handedness] = trackedMeshes;\r\n });\r\n return { left: meshes.left, right: meshes.right };\r\n }\r\n\r\n private static async _GenerateDefaultHandMeshesAsync(\r\n scene: Scene,\r\n xrSessionManager: WebXRSessionManager,\r\n options?: IWebXRHandTrackingOptions\r\n ): Promise<{ left: AbstractMesh; right: AbstractMesh }> {\r\n // eslint-disable-next-line no-async-promise-executor, @typescript-eslint/no-misused-promises\r\n return await new Promise(async (resolve) => {\r\n const riggedMeshes: { [handedness: string]: AbstractMesh } = {};\r\n // check the cache, defensive\r\n if (WebXRHandTracking._RightHandGLB?.meshes[1]?.isDisposed()) {\r\n WebXRHandTracking._RightHandGLB = null;\r\n }\r\n if (WebXRHandTracking._LeftHandGLB?.meshes[1]?.isDisposed()) {\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n const handsDefined = !!(WebXRHandTracking._RightHandGLB && WebXRHandTracking._LeftHandGLB);\r\n // load them in parallel\r\n const defaulrHandGLBUrl = Tools.GetAssetUrl(WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL);\r\n const handGLBs = await Promise.all([\r\n WebXRHandTracking._RightHandGLB || SceneLoader.ImportMeshAsync(\"\", defaulrHandGLBUrl, WebXRHandTracking.DEFAULT_HAND_MODEL_RIGHT_FILENAME, scene),\r\n WebXRHandTracking._LeftHandGLB || SceneLoader.ImportMeshAsync(\"\", defaulrHandGLBUrl, WebXRHandTracking.DEFAULT_HAND_MODEL_LEFT_FILENAME, scene),\r\n ]);\r\n // eslint-disable-next-line require-atomic-updates\r\n WebXRHandTracking._RightHandGLB = handGLBs[0];\r\n // eslint-disable-next-line require-atomic-updates\r\n WebXRHandTracking._LeftHandGLB = handGLBs[1];\r\n const shaderUrl = Tools.GetAssetUrl(WebXRHandTracking.DEFAULT_HAND_MODEL_SHADER_URL);\r\n const handShader = await NodeMaterial.ParseFromFileAsync(\"handShader\", shaderUrl, scene, undefined, true);\r\n\r\n // depth prepass and alpha mode\r\n handShader.needDepthPrePass = true;\r\n handShader.transparencyMode = Material.MATERIAL_ALPHABLEND;\r\n handShader.alphaMode = Constants.ALPHA_COMBINE;\r\n\r\n // build node materials\r\n handShader.build(false);\r\n\r\n // shader\r\n const handColors = {\r\n base: Color3.FromInts(116, 63, 203),\r\n fresnel: Color3.FromInts(149, 102, 229),\r\n fingerColor: Color3.FromInts(177, 130, 255),\r\n tipFresnel: Color3.FromInts(220, 200, 255),\r\n ...options?.handMeshes?.customColors,\r\n };\r\n\r\n const handNodes = {\r\n base: handShader.getBlockByName(\"baseColor\") as InputBlock,\r\n fresnel: handShader.getBlockByName(\"fresnelColor\") as InputBlock,\r\n fingerColor: handShader.getBlockByName(\"fingerColor\") as InputBlock,\r\n tipFresnel: handShader.getBlockByName(\"tipFresnelColor\") as InputBlock,\r\n };\r\n\r\n handNodes.base.value = handColors.base;\r\n handNodes.fresnel.value = handColors.fresnel;\r\n handNodes.fingerColor.value = handColors.fingerColor;\r\n handNodes.tipFresnel.value = handColors.tipFresnel;\r\n const isMultiview = (xrSessionManager._getBaseLayerWrapper() as WebXRCompositionLayerWrapper)?.isMultiview;\r\n const hd = [\"left\", \"right\"];\r\n for (const handedness of hd) {\r\n const handGLB = handedness == \"left\" ? WebXRHandTracking._LeftHandGLB : WebXRHandTracking._RightHandGLB;\r\n if (!handGLB) {\r\n // this should never happen!\r\n throw new Error(\"Could not load hand model\");\r\n }\r\n const handMesh = handGLB.meshes[1];\r\n handMesh._internalAbstractMeshDataInfo._computeBonesUsingShaders = true;\r\n // if in multiview do not use the material\r\n if (!isMultiview && !options?.handMeshes?.disableHandShader) {\r\n handMesh.material = handShader.clone(`${handedness}HandShaderClone`, true);\r\n }\r\n handMesh.isVisible = false;\r\n\r\n riggedMeshes[handedness] = handMesh;\r\n\r\n // single change for left handed systems\r\n if (!handsDefined && !scene.useRightHandedSystem) {\r\n handGLB.meshes[1].rotate(Axis.Y, Math.PI);\r\n }\r\n }\r\n\r\n handShader.dispose();\r\n resolve({ left: riggedMeshes.left, right: riggedMeshes.right });\r\n });\r\n }\r\n\r\n /**\r\n * Generates a mapping from XRHandJoint to bone name for the default hand mesh.\r\n * @param handedness The handedness being mapped for.\r\n * @returns A mapping from XRHandJoint to bone name.\r\n */\r\n private static _GenerateDefaultHandMeshRigMapping(handedness: XRHandedness): XRHandMeshRigMapping {\r\n const h = handedness == \"right\" ? \"R\" : \"L\";\r\n return {\r\n [WebXRHandJoint.WRIST]: `wrist_${h}`,\r\n [WebXRHandJoint.THUMB_METACARPAL]: `thumb_metacarpal_${h}`,\r\n [WebXRHandJoint.THUMB_PHALANX_PROXIMAL]: `thumb_proxPhalanx_${h}`,\r\n [WebXRHandJoint.THUMB_PHALANX_DISTAL]: `thumb_distPhalanx_${h}`,\r\n [WebXRHandJoint.THUMB_TIP]: `thumb_tip_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_METACARPAL]: `index_metacarpal_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL]: `index_proxPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE]: `index_intPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL]: `index_distPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_TIP]: `index_tip_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_METACARPAL]: `middle_metacarpal_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL]: `middle_proxPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE]: `middle_intPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL]: `middle_distPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_TIP]: `middle_tip_${h}`,\r\n [WebXRHandJoint.RING_FINGER_METACARPAL]: `ring_metacarpal_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL]: `ring_proxPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE]: `ring_intPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_DISTAL]: `ring_distPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_TIP]: `ring_tip_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_METACARPAL]: `little_metacarpal_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL]: `little_proxPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE]: `little_intPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL]: `little_distPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_TIP]: `little_tip_${h}`,\r\n };\r\n }\r\n\r\n private _attachedHands: {\r\n [uniqueId: string]: WebXRHand;\r\n } = {};\r\n\r\n private _trackingHands: {\r\n left: Nullable<WebXRHand>;\r\n right: Nullable<WebXRHand>;\r\n } = { left: null, right: null };\r\n\r\n private _handResources: {\r\n jointMeshes: Nullable<{ left: AbstractMesh[]; right: AbstractMesh[] }>;\r\n handMeshes: Nullable<{ left: AbstractMesh; right: AbstractMesh }>;\r\n rigMappings: Nullable<{ left: XRHandMeshRigMapping; right: XRHandMeshRigMapping }>;\r\n } = { jointMeshes: null, handMeshes: null, rigMappings: null };\r\n\r\n private _worldScaleObserver?: Nullable<Observer<{ previousScaleFactor: number; newScaleFactor: number }>> = null;\r\n\r\n /**\r\n * This observable will notify registered observers when a new hand object was added and initialized\r\n */\r\n public onHandAddedObservable: Observable<WebXRHand> = new Observable();\r\n /**\r\n * This observable will notify its observers right before the hand object is disposed\r\n */\r\n public onHandRemovedObservable: Observable<WebXRHand> = new Observable();\r\n\r\n private _originalMesh?: Mesh;\r\n\r\n /**\r\n * Check if the needed objects are defined.\r\n * This does not mean that the feature is enabled, but that the objects needed are well defined.\r\n * @returns true if the needed objects for this feature are defined\r\n */\r\n public override isCompatible(): boolean {\r\n return typeof XRHand !== \"undefined\";\r\n }\r\n\r\n /**\r\n * Get the hand object according to the controller id\r\n * @param controllerId the controller id to which we want to get the hand\r\n * @returns null if not found or the WebXRHand object if found\r\n */\r\n public getHandByControllerId(controllerId: string): Nullable<WebXRHand> {\r\n return this._attachedHands[controllerId];\r\n }\r\n\r\n /**\r\n * Get a hand object according to the requested handedness\r\n * @param handedness the handedness to request\r\n * @returns null if not found or the WebXRHand object if found\r\n */\r\n public getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand> {\r\n if (handedness == \"none\") {\r\n return null;\r\n }\r\n return this._trackingHands[handedness];\r\n }\r\n\r\n /**\r\n * Creates a new instance of the XR hand tracking feature.\r\n * @param _xrSessionManager An instance of WebXRSessionManager.\r\n * @param options Options to use when constructing this feature.\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /** Options to use when constructing this feature. */\r\n public readonly options: IWebXRHandTrackingOptions\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"hand-tracking\";\r\n\r\n // Support legacy versions of the options object by copying over joint mesh properties\r\n const anyOptions = options as any;\r\n const anyJointMeshOptions = anyOptions.jointMeshes;\r\n if (anyJointMeshOptions) {\r\n if (typeof anyJointMeshOptions.disableDefaultHandMesh !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.disableDefaultMeshes = anyJointMeshOptions.disableDefaultHandMesh;\r\n }\r\n if (typeof anyJointMeshOptions.handMeshes !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.customMeshes = anyJointMeshOptions.handMeshes;\r\n }\r\n if (typeof anyJointMeshOptions.leftHandedSystemMeshes !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.meshesUseLeftHandedCoordinates = anyJointMeshOptions.leftHandedSystemMeshes;\r\n }\r\n if (typeof anyJointMeshOptions.rigMapping !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n const leftRigMapping = {};\r\n const rightRigMapping = {};\r\n const rigMappingTuples = [\r\n [anyJointMeshOptions.rigMapping.left, leftRigMapping],\r\n [anyJointMeshOptions.rigMapping.right, rightRigMapping],\r\n ];\r\n\r\n for (const rigMappingTuple of rigMappingTuples) {\r\n const legacyRigMapping = rigMappingTuple[0] as string[];\r\n const rigMapping = rigMappingTuple[1] as XRHandMeshRigMapping;\r\n for (let index = 0; index < legacyRigMapping.length; index++) {\r\n const modelJointName = legacyRigMapping[index];\r\n rigMapping[HandJointReferenceArray[index]] = modelJointName;\r\n }\r\n }\r\n options.handMeshes.customRigMappings = {\r\n left: leftRigMapping as XRHandMeshRigMapping,\r\n right: rightRigMapping as XRHandMeshRigMapping,\r\n };\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Attach this feature.\r\n * Will usually be called by the features manager.\r\n *\r\n * @returns true if successful.\r\n */\r\n public override attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n if (!this._handResources.jointMeshes) {\r\n this._originalMesh = this._originalMesh || this.options.jointMeshes?.sourceMesh || CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS);\r\n this._originalMesh.isVisible = false;\r\n\r\n this._handResources.jointMeshes = WebXRHandTracking._GenerateTrackedJointMeshes(this.options, this._originalMesh);\r\n }\r\n this._handResources.handMeshes = this.options.handMeshes?.customMeshes || null;\r\n this._handResources.rigMappings = this.options.handMeshes?.customRigMappings || null;\r\n // If they didn't supply custom meshes and are not disabling the default meshes...\r\n if (!this.options.handMeshes?.customMeshes && !this.options.handMeshes?.disableDefaultMeshes) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n WebXRHandTracking._GenerateDefaultHandMeshesAsync(EngineStore.LastCreatedScene!, this._xrSessionManager, this.options).then((defaultHandMeshes) => {\r\n this._handResources.handMeshes = defaultHandMeshes;\r\n this._handResources.rigMappings = {\r\n left: WebXRHandTracking._GenerateDefaultHandMeshRigMapping(\"left\"),\r\n right: WebXRHandTracking._GenerateDefaultHandMeshRigMapping(\"right\"),\r\n };\r\n\r\n // Apply meshes to existing hands if already tracking.\r\n this._trackingHands.left?.setHandMesh(this._handResources.handMeshes.left, this._handResources.rigMappings.left, this._xrSessionManager);\r\n this._trackingHands.right?.setHandMesh(this._handResources.handMeshes.right, this._handResources.rigMappings.right, this._xrSessionManager);\r\n this._handResources.handMeshes.left.scaling.setAll(this._xrSessionManager.worldScalingFactor);\r\n this._handResources.handMeshes.right.scaling.setAll(this._xrSessionManager.worldScalingFactor);\r\n });\r\n this._worldScaleObserver = this._xrSessionManager.onWorldScaleFactorChangedObservable.add((scalingFactors) => {\r\n if (this._handResources.handMeshes) {\r\n this._handResources.handMeshes.left.scaling.scaleInPlace(scalingFactors.newScaleFactor / scalingFactors.previousScaleFactor);\r\n this._handResources.handMeshes.right.scaling.scaleInPlace(scalingFactors.newScaleFactor / scalingFactors.previousScaleFactor);\r\n }\r\n });\r\n }\r\n\r\n for (const controller of this.options.xrInput.controllers) {\r\n this._attachHand(controller);\r\n }\r\n\r\n this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand);\r\n\r\n return true;\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n }\r\n\r\n private _attachHand = (xrController: WebXRInputSource) => {\r\n if (!xrController.inputSource.hand || xrController.inputSource.handedness == \"none\" || !this._handResources.jointMeshes) {\r\n return;\r\n }\r\n\r\n const handedness = xrController.inputSource.handedness;\r\n const webxrHand = new WebXRHand(\r\n xrController,\r\n this._handResources.jointMeshes[handedness],\r\n this._handResources.handMeshes && this._handResources.handMeshes[handedness],\r\n this._handResources.rigMappings && this._handResources.rigMappings[handedness],\r\n this.options.handMeshes?.meshesUseLeftHandedCoordinates,\r\n this.options.jointMeshes?.invisible,\r\n this.options.jointMeshes?.scaleFactor\r\n );\r\n\r\n this._attachedHands[xrController.uniqueId] = webxrHand;\r\n this._trackingHands[handedness] = webxrHand;\r\n\r\n this.onHandAddedObservable.notifyObservers(webxrHand);\r\n };\r\n\r\n private _detachHandById(controllerId: string, disposeMesh?: boolean) {\r\n const hand = this.getHandByControllerId(controllerId);\r\n if (hand) {\r\n const handedness = hand.xrController.inputSource.handedness == \"left\" ? \"left\" : \"right\";\r\n if (this._trackingHands[handedness]?.xrController.uniqueId === controllerId) {\r\n this._trackingHands[handedness] = null;\r\n }\r\n this.onHandRemovedObservable.notifyObservers(hand);\r\n hand.dispose(disposeMesh);\r\n delete this._attachedHands[controllerId];\r\n }\r\n }\r\n\r\n private _detachHand = (xrController: WebXRInputSource) => {\r\n this._detachHandById(xrController.uniqueId);\r\n };\r\n\r\n /**\r\n * Detach this feature.\r\n * Will usually be called by the features manager.\r\n *\r\n * @returns true if successful.\r\n */\r\n public override detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n const keys = Object.keys(this._attachedHands);\r\n for (const uniqueId of keys) {\r\n this._detachHandById(uniqueId, this.options.handMeshes?.disposeOnSessionEnd);\r\n }\r\n\r\n if (this.options.handMeshes?.disposeOnSessionEnd) {\r\n if (this._handResources.jointMeshes) {\r\n for (const trackedMesh of this._handResources.jointMeshes.left) {\r\n trackedMesh.dispose();\r\n }\r\n for (const trackedMesh of this._handResources.jointMeshes.right) {\r\n trackedMesh.dispose();\r\n }\r\n this._handResources.jointMeshes = null;\r\n }\r\n if (this._handResources.handMeshes) {\r\n this._handResources.handMeshes.left.dispose();\r\n this._handResources.handMeshes.right.dispose();\r\n this._handResources.handMeshes = null;\r\n }\r\n\r\n if (WebXRHandTracking._RightHandGLB) {\r\n for (const mesh of WebXRHandTracking._RightHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n if (WebXRHandTracking._LeftHandGLB) {\r\n for (const mesh of WebXRHandTracking._LeftHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n this._originalMesh?.dispose();\r\n this._originalMesh = undefined;\r\n }\r\n\r\n // remove world scale observer\r\n if (this._worldScaleObserver) {\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n this.onHandAddedObservable.clear();\r\n this.onHandRemovedObservable.clear();\r\n\r\n if (this._handResources.handMeshes && !this.options.handMeshes?.customMeshes) {\r\n // this will dispose the cached meshes\r\n this._handResources.handMeshes.left.dispose();\r\n this._handResources.handMeshes.right.dispose();\r\n // remove the cached meshes\r\n\r\n if (WebXRHandTracking._RightHandGLB) {\r\n for (const mesh of WebXRHandTracking._RightHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n if (WebXRHandTracking._LeftHandGLB) {\r\n for (const mesh of WebXRHandTracking._LeftHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n if (this._handResources.jointMeshes) {\r\n for (const trackedMesh of this._handResources.jointMeshes.left) {\r\n trackedMesh.dispose();\r\n }\r\n for (const trackedMesh of this._handResources.jointMeshes.right) {\r\n trackedMesh.dispose();\r\n }\r\n }\r\n }\r\n}\r\n\r\n//register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRHandTracking.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRHandTracking(xrSessionManager, options);\r\n },\r\n WebXRHandTracking.Version,\r\n false\r\n);\r\n"]}
|
|
1
|
+
{"version":3,"file":"WebXRHandTracking.js","sourceRoot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CAAC,IAAI,EACtB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC,EACD,iBAAiB,CAAC,OAAO,EACzB,KAAK,CACR,CAAC","sourcesContent":["import { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { WebXRFeatureName, WebXRFeaturesManager } from \"../webXRFeaturesManager\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { WebXRInput } from \"../webXRInput\";\r\nimport type { WebXRInputSource } from \"../webXRInputSource\";\r\nimport { Matrix, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { PhysicsImpostor } from \"../../Physics/v1/physicsImpostor\";\r\n\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { InstancedMesh } from \"../../Meshes/instancedMesh\";\r\nimport type { ISceneLoaderAsyncResult } from \"../../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../../Loading/sceneLoader\";\r\nimport { Color3 } from \"../../Maths/math.color\";\r\nimport { NodeMaterial } from \"../../Materials/Node/nodeMaterial\";\r\nimport type { InputBlock } from \"../../Materials/Node/Blocks/Input/inputBlock\";\r\nimport { Material } from \"../../Materials/material\";\r\nimport { CreateIcoSphere } from \"../../Meshes/Builders/icoSphereBuilder\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Axis } from \"../../Maths/math.axis\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { WebXRCompositionLayerWrapper } from \"./Layers/WebXRCompositionLayer\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { WebXRCamera } from \"../webXRCamera\";\r\nimport type { Node } from \"../../node\";\r\n\r\ndeclare const XRHand: XRHand;\r\n\r\n/**\r\n * Configuration interface for the hand tracking feature\r\n */\r\nexport interface IWebXRHandTrackingOptions {\r\n /**\r\n * The xrInput that will be used as source for new hands\r\n */\r\n xrInput: WebXRInput;\r\n\r\n /**\r\n * Configuration object for the joint meshes.\r\n */\r\n jointMeshes?: {\r\n /**\r\n * Should the meshes created be invisible (defaults to false).\r\n */\r\n invisible?: boolean;\r\n /**\r\n * A source mesh to be used to create instances. Defaults to an icosphere with two subdivisions and smooth lighting.\r\n * This mesh will be the source for all other (25) meshes.\r\n * It should have the general size of a single unit, as the instances will be scaled according to the provided radius.\r\n */\r\n sourceMesh?: Mesh;\r\n /**\r\n * This function will be called after a mesh was created for a specific joint.\r\n * Using this function you can either manipulate the instance or return a new mesh.\r\n * When returning a new mesh the instance created before will be disposed.\r\n * @param meshInstance An instance of the original joint mesh being used for the joint.\r\n * @param jointId The joint's index, see https://immersive-web.github.io/webxr-hand-input/#skeleton-joints-section for more info.\r\n * @param hand Which hand (\"left\", \"right\") the joint will be on.\r\n */\r\n onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, hand: XRHandedness) => AbstractMesh | undefined;\r\n /**\r\n * Should the source mesh stay visible (defaults to false).\r\n */\r\n keepOriginalVisible?: boolean;\r\n /**\r\n * Should each instance have its own physics impostor\r\n */\r\n enablePhysics?: boolean;\r\n /**\r\n * If enabled, override default physics properties\r\n */\r\n physicsProps?: { friction?: number; restitution?: number; impostorType?: number };\r\n /**\r\n * Scale factor for all joint meshes (defaults to 1)\r\n */\r\n scaleFactor?: number;\r\n };\r\n\r\n /**\r\n * Configuration object for the hand meshes.\r\n */\r\n handMeshes?: {\r\n /**\r\n * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).\r\n */\r\n disableDefaultMeshes?: boolean;\r\n /**\r\n * Rigged hand meshes that will be tracked to the user's hands. This will override the default hand mesh.\r\n */\r\n customMeshes?: {\r\n right: AbstractMesh;\r\n left: AbstractMesh;\r\n };\r\n /**\r\n * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.\r\n */\r\n meshesUseLeftHandedCoordinates?: boolean;\r\n /**\r\n * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh\r\n */\r\n customRigMappings?: {\r\n right: XRHandMeshRigMapping;\r\n left: XRHandMeshRigMapping;\r\n };\r\n\r\n /**\r\n * Override the colors of the hand meshes.\r\n */\r\n customColors?: {\r\n base?: Color3;\r\n fresnel?: Color3;\r\n fingerColor?: Color3;\r\n tipFresnel?: Color3;\r\n };\r\n\r\n /**\r\n * Define whether or not the hand meshes should be disposed on just invisible when the session ends.\r\n * Not setting, or setting to false, will maintain the hand meshes in the scene after the session ends, which will allow q quicker re-entry into XR.\r\n */\r\n disposeOnSessionEnd?: boolean;\r\n\r\n /**\r\n * Setting this will allow the developer to avoid loading the NME material and use the standard material instead.\r\n */\r\n disableHandShader?: boolean;\r\n };\r\n}\r\n\r\n/**\r\n * Parts of the hands divided to writs and finger names\r\n */\r\nexport const enum HandPart {\r\n /**\r\n * HandPart - Wrist\r\n */\r\n WRIST = \"wrist\",\r\n /**\r\n * HandPart - The thumb\r\n */\r\n THUMB = \"thumb\",\r\n /**\r\n * HandPart - Index finger\r\n */\r\n INDEX = \"index\",\r\n /**\r\n * HandPart - Middle finger\r\n */\r\n MIDDLE = \"middle\",\r\n /**\r\n * HandPart - Ring finger\r\n */\r\n RING = \"ring\",\r\n /**\r\n * HandPart - Little finger\r\n */\r\n LITTLE = \"little\",\r\n}\r\n\r\n/**\r\n * Joints of the hand as defined by the WebXR specification.\r\n * https://immersive-web.github.io/webxr-hand-input/#skeleton-joints-section\r\n */\r\nexport const enum WebXRHandJoint {\r\n /** Wrist */\r\n WRIST = \"wrist\",\r\n\r\n /** Thumb near wrist */\r\n THUMB_METACARPAL = \"thumb-metacarpal\",\r\n /** Thumb first knuckle */\r\n THUMB_PHALANX_PROXIMAL = \"thumb-phalanx-proximal\",\r\n /** Thumb second knuckle */\r\n THUMB_PHALANX_DISTAL = \"thumb-phalanx-distal\",\r\n /** Thumb tip */\r\n THUMB_TIP = \"thumb-tip\",\r\n\r\n /** Index finger near wrist */\r\n INDEX_FINGER_METACARPAL = \"index-finger-metacarpal\",\r\n /** Index finger first knuckle */\r\n INDEX_FINGER_PHALANX_PROXIMAL = \"index-finger-phalanx-proximal\",\r\n /** Index finger second knuckle */\r\n INDEX_FINGER_PHALANX_INTERMEDIATE = \"index-finger-phalanx-intermediate\",\r\n /** Index finger third knuckle */\r\n INDEX_FINGER_PHALANX_DISTAL = \"index-finger-phalanx-distal\",\r\n /** Index finger tip */\r\n INDEX_FINGER_TIP = \"index-finger-tip\",\r\n\r\n /** Middle finger near wrist */\r\n MIDDLE_FINGER_METACARPAL = \"middle-finger-metacarpal\",\r\n /** Middle finger first knuckle */\r\n MIDDLE_FINGER_PHALANX_PROXIMAL = \"middle-finger-phalanx-proximal\",\r\n /** Middle finger second knuckle */\r\n MIDDLE_FINGER_PHALANX_INTERMEDIATE = \"middle-finger-phalanx-intermediate\",\r\n /** Middle finger third knuckle */\r\n MIDDLE_FINGER_PHALANX_DISTAL = \"middle-finger-phalanx-distal\",\r\n /** Middle finger tip */\r\n MIDDLE_FINGER_TIP = \"middle-finger-tip\",\r\n\r\n /** Ring finger near wrist */\r\n RING_FINGER_METACARPAL = \"ring-finger-metacarpal\",\r\n /** Ring finger first knuckle */\r\n RING_FINGER_PHALANX_PROXIMAL = \"ring-finger-phalanx-proximal\",\r\n /** Ring finger second knuckle */\r\n RING_FINGER_PHALANX_INTERMEDIATE = \"ring-finger-phalanx-intermediate\",\r\n /** Ring finger third knuckle */\r\n RING_FINGER_PHALANX_DISTAL = \"ring-finger-phalanx-distal\",\r\n /** Ring finger tip */\r\n RING_FINGER_TIP = \"ring-finger-tip\",\r\n\r\n /** Pinky finger near wrist */\r\n PINKY_FINGER_METACARPAL = \"pinky-finger-metacarpal\",\r\n /** Pinky finger first knuckle */\r\n PINKY_FINGER_PHALANX_PROXIMAL = \"pinky-finger-phalanx-proximal\",\r\n /** Pinky finger second knuckle */\r\n PINKY_FINGER_PHALANX_INTERMEDIATE = \"pinky-finger-phalanx-intermediate\",\r\n /** Pinky finger third knuckle */\r\n PINKY_FINGER_PHALANX_DISTAL = \"pinky-finger-phalanx-distal\",\r\n /** Pinky finger tip */\r\n PINKY_FINGER_TIP = \"pinky-finger-tip\",\r\n}\r\n\r\n/** A type encapsulating a dictionary mapping WebXR joints to bone names in a rigged hand mesh. */\r\nexport type XRHandMeshRigMapping = { [webXRJointName in WebXRHandJoint]: string };\r\n\r\nconst HandJointReferenceArray: WebXRHandJoint[] = [\r\n WebXRHandJoint.WRIST,\r\n WebXRHandJoint.THUMB_METACARPAL,\r\n WebXRHandJoint.THUMB_PHALANX_PROXIMAL,\r\n WebXRHandJoint.THUMB_PHALANX_DISTAL,\r\n WebXRHandJoint.THUMB_TIP,\r\n WebXRHandJoint.INDEX_FINGER_METACARPAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.INDEX_FINGER_TIP,\r\n WebXRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.MIDDLE_FINGER_TIP,\r\n WebXRHandJoint.RING_FINGER_METACARPAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.RING_FINGER_TIP,\r\n WebXRHandJoint.PINKY_FINGER_METACARPAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.PINKY_FINGER_TIP,\r\n];\r\n\r\nconst HandPartsDefinition: { [key in HandPart]: WebXRHandJoint[] } = {\r\n [HandPart.WRIST]: [WebXRHandJoint.WRIST],\r\n [HandPart.THUMB]: [WebXRHandJoint.THUMB_METACARPAL, WebXRHandJoint.THUMB_PHALANX_PROXIMAL, WebXRHandJoint.THUMB_PHALANX_DISTAL, WebXRHandJoint.THUMB_TIP],\r\n [HandPart.INDEX]: [\r\n WebXRHandJoint.INDEX_FINGER_METACARPAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.INDEX_FINGER_TIP,\r\n ],\r\n [HandPart.MIDDLE]: [\r\n WebXRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.MIDDLE_FINGER_TIP,\r\n ],\r\n [HandPart.RING]: [\r\n WebXRHandJoint.RING_FINGER_METACARPAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.RING_FINGER_TIP,\r\n ],\r\n [HandPart.LITTLE]: [\r\n WebXRHandJoint.PINKY_FINGER_METACARPAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n WebXRHandJoint.PINKY_FINGER_TIP,\r\n ],\r\n};\r\n\r\n/**\r\n * Representing a single hand (with its corresponding native XRHand object)\r\n */\r\nexport class WebXRHand implements IDisposable {\r\n /**\r\n * This observable will notify registered observers when the hand object has been set with a new mesh.\r\n * you can get the hand mesh using `webxrHand.handMesh`\r\n */\r\n public onHandMeshSetObservable = new Observable<WebXRHand>();\r\n\r\n private _scene: Scene;\r\n\r\n /**\r\n * Transform nodes that will directly receive the transforms from the WebXR matrix data.\r\n */\r\n private _jointTransforms = new Array<TransformNode>(HandJointReferenceArray.length);\r\n\r\n /**\r\n * The float array that will directly receive the transform matrix data from WebXR.\r\n */\r\n private _jointTransformMatrices = new Float32Array(HandJointReferenceArray.length * 16);\r\n\r\n private _tempJointMatrix = new Matrix();\r\n\r\n /**\r\n * The float array that will directly receive the joint radii from WebXR.\r\n */\r\n private _jointRadii = new Float32Array(HandJointReferenceArray.length);\r\n\r\n /**\r\n * The hand mesh's top-most parent, if any.\r\n */\r\n private _handMeshRoot: Nullable<Node> = null;\r\n\r\n /**\r\n * Get the hand mesh.\r\n */\r\n public get handMesh(): Nullable<AbstractMesh> {\r\n return this._handMesh;\r\n }\r\n\r\n /**\r\n * Get meshes of part of the hand.\r\n * @param part The part of hand to get.\r\n * @returns An array of meshes that correlate to the hand part requested.\r\n */\r\n public getHandPartMeshes(part: HandPart): AbstractMesh[] {\r\n return HandPartsDefinition[part].map((name) => this._jointMeshes[HandJointReferenceArray.indexOf(name)]);\r\n }\r\n\r\n /**\r\n * Retrieves a mesh linked to a named joint in the hand.\r\n * @param jointName The name of the joint.\r\n * @returns An AbstractMesh whose position corresponds with the joint position.\r\n */\r\n public getJointMesh(jointName: WebXRHandJoint): AbstractMesh {\r\n return this._jointMeshes[HandJointReferenceArray.indexOf(jointName)];\r\n }\r\n\r\n /**\r\n * Construct a new hand object\r\n * @param xrController The controller to which the hand correlates.\r\n * @param _jointMeshes The meshes to be used to track the hand joints.\r\n * @param _handMesh An optional hand mesh.\r\n * @param rigMapping An optional rig mapping for the hand mesh.\r\n * If not provided (but a hand mesh is provided),\r\n * it will be assumed that the hand mesh's bones are named\r\n * directly after the WebXR bone names.\r\n * @param _leftHandedMeshes Are the hand meshes left-handed-system meshes\r\n * @param _jointsInvisible Are the tracked joint meshes visible\r\n * @param _jointScaleFactor Scale factor for all joint meshes\r\n */\r\n constructor(\r\n /** The controller to which the hand correlates. */\r\n public readonly xrController: WebXRInputSource,\r\n private readonly _jointMeshes: AbstractMesh[],\r\n private _handMesh: Nullable<AbstractMesh>,\r\n /** An optional rig mapping for the hand mesh. If not provided (but a hand mesh is provided),\r\n * it will be assumed that the hand mesh's bones are named directly after the WebXR bone names. */\r\n readonly rigMapping: Nullable<XRHandMeshRigMapping>,\r\n private readonly _leftHandedMeshes: boolean = false,\r\n private readonly _jointsInvisible: boolean = false,\r\n private readonly _jointScaleFactor: number = 1\r\n ) {\r\n this._scene = _jointMeshes[0].getScene();\r\n\r\n // Initialize the joint transform quaternions and link the transforms to the bones.\r\n for (let jointIdx = 0; jointIdx < this._jointTransforms.length; jointIdx++) {\r\n this._jointTransforms[jointIdx] = new TransformNode(HandJointReferenceArray[jointIdx], this._scene);\r\n this._jointTransforms[jointIdx].rotationQuaternion = new Quaternion();\r\n\r\n // Set the rotation quaternion so we can use it later for tracking.\r\n if (_jointMeshes[jointIdx].rotationQuaternion) {\r\n _jointMeshes[jointIdx].rotationQuaternion = new Quaternion();\r\n } else {\r\n _jointMeshes[jointIdx].rotationQuaternion?.set(0, 0, 0, 1);\r\n }\r\n }\r\n\r\n if (_handMesh) {\r\n // Note that this logic needs to happen after we initialize the joint tracking transform nodes.\r\n this.setHandMesh(_handMesh, rigMapping);\r\n }\r\n\r\n // hide the motion controller, if available/loaded\r\n if (this.xrController.motionController) {\r\n if (this.xrController.motionController.rootMesh) {\r\n this.xrController.motionController.rootMesh.dispose(false, true);\r\n }\r\n }\r\n\r\n this.xrController.onMotionControllerInitObservable.add((motionController) => {\r\n motionController._doNotLoadControllerMesh = true;\r\n });\r\n }\r\n\r\n /**\r\n * Sets the current hand mesh to render for the WebXRHand.\r\n * @param handMesh The rigged hand mesh that will be tracked to the user's hand.\r\n * @param rigMapping The mapping from XRHandJoint to bone names to use with the mesh.\r\n * @param _xrSessionManager The XRSessionManager used to initialize the hand mesh.\r\n */\r\n public setHandMesh(handMesh: AbstractMesh, rigMapping: Nullable<XRHandMeshRigMapping>, _xrSessionManager?: WebXRSessionManager) {\r\n this._handMesh = handMesh;\r\n\r\n this._handMeshRoot = this._handMesh;\r\n while (this._handMeshRoot.parent) {\r\n this._handMeshRoot = this._handMeshRoot.parent;\r\n }\r\n\r\n // Avoid any strange frustum culling. We will manually control visibility via attach and detach.\r\n handMesh.alwaysSelectAsActiveMesh = true;\r\n const children = handMesh.getChildMeshes();\r\n for (const mesh of children) {\r\n mesh.alwaysSelectAsActiveMesh = true;\r\n }\r\n\r\n // Link the bones in the hand mesh to the transform nodes that will be bound to the WebXR tracked joints.\r\n if (this._handMesh.skeleton) {\r\n const handMeshSkeleton = this._handMesh.skeleton;\r\n for (let jointIdx = 0; jointIdx < HandJointReferenceArray.length; jointIdx++) {\r\n const jointName = HandJointReferenceArray[jointIdx];\r\n const jointBoneIdx = handMeshSkeleton.getBoneIndexByName(rigMapping ? rigMapping[jointName] : jointName);\r\n if (jointBoneIdx !== -1) {\r\n handMeshSkeleton.bones[jointBoneIdx].linkTransformNode(this._jointTransforms[jointIdx]);\r\n }\r\n }\r\n }\r\n\r\n this.onHandMeshSetObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Update this hand from the latest xr frame.\r\n * @param xrFrame The latest frame received from WebXR.\r\n * @param referenceSpace The current viewer reference space.\r\n * @param xrCamera the xr camera, used for parenting\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, xrCamera: WebXRCamera) {\r\n const hand = this.xrController.inputSource.hand;\r\n if (!hand) {\r\n return;\r\n }\r\n\r\n // TODO: Modify webxr.d.ts to better match WebXR IDL so we don't need this any cast.\r\n const anyHand: any = hand;\r\n const jointSpaces: XRJointSpace[] = HandJointReferenceArray.map((jointName) => anyHand[jointName] || hand.get(jointName));\r\n let trackingSuccessful = false;\r\n\r\n if (xrFrame.fillPoses && xrFrame.fillJointRadii) {\r\n trackingSuccessful = xrFrame.fillPoses(jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(jointSpaces, this._jointRadii);\r\n } else if (xrFrame.getJointPose) {\r\n trackingSuccessful = true;\r\n // Warning: This codepath is slow by comparison, only here for compat.\r\n for (let jointIdx = 0; jointIdx < jointSpaces.length; jointIdx++) {\r\n const jointPose = xrFrame.getJointPose(jointSpaces[jointIdx], referenceSpace);\r\n if (jointPose) {\r\n this._jointTransformMatrices.set(jointPose.transform.matrix, jointIdx * 16);\r\n this._jointRadii[jointIdx] = jointPose.radius || 0.008;\r\n } else {\r\n trackingSuccessful = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!trackingSuccessful) {\r\n return;\r\n }\r\n\r\n for (let jointIdx = 0; jointIdx < HandJointReferenceArray.length; jointIdx++) {\r\n const jointTransform = this._jointTransforms[jointIdx];\r\n Matrix.FromArrayToRef(this._jointTransformMatrices, jointIdx * 16, this._tempJointMatrix);\r\n this._tempJointMatrix.decompose(undefined, jointTransform.rotationQuaternion!, jointTransform.position);\r\n\r\n // The radius we need to make the joint in order for it to roughly cover the joints of the user's real hand.\r\n const scaledJointRadius = this._jointRadii[jointIdx] * this._jointScaleFactor;\r\n\r\n const jointMesh = this._jointMeshes[jointIdx];\r\n jointMesh.isVisible = !this._handMesh && !this._jointsInvisible;\r\n jointMesh.position.copyFrom(jointTransform.position);\r\n jointMesh.rotationQuaternion!.copyFrom(jointTransform.rotationQuaternion!);\r\n jointMesh.scaling.setAll(scaledJointRadius);\r\n jointMesh.parent = xrCamera.parent;\r\n\r\n // The WebXR data comes as right-handed, so we might need to do some conversions.\r\n if (!this._scene.useRightHandedSystem) {\r\n jointMesh.position.z *= -1;\r\n jointMesh.rotationQuaternion!.z *= -1;\r\n jointMesh.rotationQuaternion!.w *= -1;\r\n\r\n if (this._leftHandedMeshes && this._handMesh) {\r\n jointTransform.position.z *= -1;\r\n jointTransform.rotationQuaternion!.z *= -1;\r\n jointTransform.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n }\r\n\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = true;\r\n\r\n if (this._handMeshRoot) {\r\n this._handMeshRoot.parent = xrCamera.parent;\r\n }\r\n }\r\n\r\n this.xrController.pointer.parent = xrCamera.parent;\r\n }\r\n\r\n /**\r\n * Dispose this Hand object\r\n * @param disposeMeshes Should the meshes be disposed as well\r\n */\r\n public dispose(disposeMeshes = false) {\r\n if (this._handMesh) {\r\n if (disposeMeshes) {\r\n this._handMesh.skeleton?.dispose();\r\n this._handMesh.dispose(false, true);\r\n } else {\r\n this._handMesh.isVisible = false;\r\n }\r\n }\r\n for (const transform of this._jointTransforms) {\r\n transform.dispose();\r\n }\r\n this._jointTransforms.length = 0;\r\n this.onHandMeshSetObservable.clear();\r\n }\r\n}\r\n\r\n/**\r\n * WebXR Hand Joint tracking feature, available for selected browsers and devices\r\n */\r\nexport class WebXRHandTracking extends WebXRAbstractFeature {\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.HAND_TRACKING;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /** The base URL for the default hand model. */\r\n public static DEFAULT_HAND_MODEL_BASE_URL = \"https://assets.babylonjs.com/core/HandMeshes/\";\r\n /** The filename to use for the default right hand model. */\r\n public static DEFAULT_HAND_MODEL_RIGHT_FILENAME = \"r_hand_rhs.glb\";\r\n /** The filename to use for the default left hand model. */\r\n public static DEFAULT_HAND_MODEL_LEFT_FILENAME = \"l_hand_rhs.glb\";\r\n /** The URL pointing to the default hand model NodeMaterial shader. */\r\n public static DEFAULT_HAND_MODEL_SHADER_URL = \"https://assets.babylonjs.com/core/HandMeshes/handsShader.json\";\r\n\r\n // We want to use lightweight models, diameter will initially be 1 but scaled to the values returned from WebXR.\r\n private static readonly _ICOSPHERE_PARAMS = { radius: 0.5, flat: false, subdivisions: 2 };\r\n\r\n private static _RightHandGLB: Nullable<ISceneLoaderAsyncResult> = null;\r\n private static _LeftHandGLB: Nullable<ISceneLoaderAsyncResult> = null;\r\n\r\n private static _GenerateTrackedJointMeshes(\r\n featureOptions: IWebXRHandTrackingOptions,\r\n originalMesh: Mesh = CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS)\r\n ): { left: AbstractMesh[]; right: AbstractMesh[] } {\r\n const meshes: { [handedness: string]: AbstractMesh[] } = {};\r\n [\"left\" as XRHandedness, \"right\" as XRHandedness].map((handedness) => {\r\n const trackedMeshes = [];\r\n originalMesh.isVisible = !!featureOptions.jointMeshes?.keepOriginalVisible;\r\n for (let i = 0; i < HandJointReferenceArray.length; ++i) {\r\n let newInstance: AbstractMesh = originalMesh.createInstance(`${handedness}-handJoint-${i}`);\r\n if (featureOptions.jointMeshes?.onHandJointMeshGenerated) {\r\n const returnedMesh = featureOptions.jointMeshes.onHandJointMeshGenerated(newInstance as InstancedMesh, i, handedness);\r\n if (returnedMesh) {\r\n if (returnedMesh !== newInstance) {\r\n newInstance.dispose();\r\n newInstance = returnedMesh;\r\n }\r\n }\r\n }\r\n newInstance.isPickable = false;\r\n if (featureOptions.jointMeshes?.enablePhysics) {\r\n const props = featureOptions.jointMeshes?.physicsProps || {};\r\n // downscale the instances so that physics will be initialized correctly\r\n newInstance.scaling.setAll(0.02);\r\n const type = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, { mass: 0, ...props });\r\n }\r\n newInstance.rotationQuaternion = new Quaternion();\r\n newInstance.isVisible = false;\r\n trackedMeshes.push(newInstance);\r\n }\r\n\r\n meshes[handedness] = trackedMeshes;\r\n });\r\n return { left: meshes.left, right: meshes.right };\r\n }\r\n\r\n private static async _GenerateDefaultHandMeshesAsync(\r\n scene: Scene,\r\n xrSessionManager: WebXRSessionManager,\r\n options?: IWebXRHandTrackingOptions\r\n ): Promise<{ left: AbstractMesh; right: AbstractMesh }> {\r\n // eslint-disable-next-line no-async-promise-executor, @typescript-eslint/no-misused-promises\r\n return await new Promise(async (resolve) => {\r\n const riggedMeshes: { [handedness: string]: AbstractMesh } = {};\r\n // check the cache, defensive\r\n if (WebXRHandTracking._RightHandGLB?.meshes[1]?.isDisposed()) {\r\n WebXRHandTracking._RightHandGLB = null;\r\n }\r\n if (WebXRHandTracking._LeftHandGLB?.meshes[1]?.isDisposed()) {\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n const handsDefined = !!(WebXRHandTracking._RightHandGLB && WebXRHandTracking._LeftHandGLB);\r\n // load them in parallel\r\n const defaulrHandGLBUrl = Tools.GetAssetUrl(WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL);\r\n const handGLBs = await Promise.all([\r\n WebXRHandTracking._RightHandGLB || SceneLoader.ImportMeshAsync(\"\", defaulrHandGLBUrl, WebXRHandTracking.DEFAULT_HAND_MODEL_RIGHT_FILENAME, scene),\r\n WebXRHandTracking._LeftHandGLB || SceneLoader.ImportMeshAsync(\"\", defaulrHandGLBUrl, WebXRHandTracking.DEFAULT_HAND_MODEL_LEFT_FILENAME, scene),\r\n ]);\r\n // eslint-disable-next-line require-atomic-updates\r\n WebXRHandTracking._RightHandGLB = handGLBs[0];\r\n // eslint-disable-next-line require-atomic-updates\r\n WebXRHandTracking._LeftHandGLB = handGLBs[1];\r\n const shaderUrl = Tools.GetAssetUrl(WebXRHandTracking.DEFAULT_HAND_MODEL_SHADER_URL);\r\n const handShader = await NodeMaterial.ParseFromFileAsync(\"handShader\", shaderUrl, scene, undefined, true);\r\n\r\n // depth prepass and alpha mode\r\n handShader.needDepthPrePass = true;\r\n handShader.transparencyMode = Material.MATERIAL_ALPHABLEND;\r\n handShader.alphaMode = Constants.ALPHA_COMBINE;\r\n\r\n // build node materials\r\n handShader.build(false);\r\n\r\n // shader\r\n const handColors = {\r\n base: Color3.FromInts(116, 63, 203),\r\n fresnel: Color3.FromInts(149, 102, 229),\r\n fingerColor: Color3.FromInts(177, 130, 255),\r\n tipFresnel: Color3.FromInts(220, 200, 255),\r\n ...options?.handMeshes?.customColors,\r\n };\r\n\r\n const handNodes = {\r\n base: handShader.getBlockByName(\"baseColor\") as InputBlock,\r\n fresnel: handShader.getBlockByName(\"fresnelColor\") as InputBlock,\r\n fingerColor: handShader.getBlockByName(\"fingerColor\") as InputBlock,\r\n tipFresnel: handShader.getBlockByName(\"tipFresnelColor\") as InputBlock,\r\n };\r\n\r\n handNodes.base.value = handColors.base;\r\n handNodes.fresnel.value = handColors.fresnel;\r\n handNodes.fingerColor.value = handColors.fingerColor;\r\n handNodes.tipFresnel.value = handColors.tipFresnel;\r\n const isMultiview = (xrSessionManager._getBaseLayerWrapper() as WebXRCompositionLayerWrapper)?.isMultiview;\r\n const hd = [\"left\", \"right\"];\r\n for (const handedness of hd) {\r\n const handGLB = handedness == \"left\" ? WebXRHandTracking._LeftHandGLB : WebXRHandTracking._RightHandGLB;\r\n if (!handGLB) {\r\n // this should never happen!\r\n throw new Error(\"Could not load hand model\");\r\n }\r\n const handMesh = handGLB.meshes[1];\r\n handMesh._internalAbstractMeshDataInfo._computeBonesUsingShaders = true;\r\n // if in multiview do not use the material\r\n if (!isMultiview && !options?.handMeshes?.disableHandShader) {\r\n handMesh.material = handShader.clone(`${handedness}HandShaderClone`, true);\r\n }\r\n handMesh.isVisible = false;\r\n\r\n riggedMeshes[handedness] = handMesh;\r\n\r\n // single change for left handed systems\r\n if (!handsDefined && !scene.useRightHandedSystem) {\r\n handGLB.meshes[1].rotate(Axis.Y, Math.PI);\r\n }\r\n }\r\n\r\n handShader.dispose();\r\n resolve({ left: riggedMeshes.left, right: riggedMeshes.right });\r\n });\r\n }\r\n\r\n /**\r\n * Generates a mapping from XRHandJoint to bone name for the default hand mesh.\r\n * @param handedness The handedness being mapped for.\r\n * @returns A mapping from XRHandJoint to bone name.\r\n */\r\n private static _GenerateDefaultHandMeshRigMapping(handedness: XRHandedness): XRHandMeshRigMapping {\r\n const h = handedness == \"right\" ? \"R\" : \"L\";\r\n return {\r\n [WebXRHandJoint.WRIST]: `wrist_${h}`,\r\n [WebXRHandJoint.THUMB_METACARPAL]: `thumb_metacarpal_${h}`,\r\n [WebXRHandJoint.THUMB_PHALANX_PROXIMAL]: `thumb_proxPhalanx_${h}`,\r\n [WebXRHandJoint.THUMB_PHALANX_DISTAL]: `thumb_distPhalanx_${h}`,\r\n [WebXRHandJoint.THUMB_TIP]: `thumb_tip_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_METACARPAL]: `index_metacarpal_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL]: `index_proxPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE]: `index_intPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_PHALANX_DISTAL]: `index_distPhalanx_${h}`,\r\n [WebXRHandJoint.INDEX_FINGER_TIP]: `index_tip_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_METACARPAL]: `middle_metacarpal_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL]: `middle_proxPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE]: `middle_intPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL]: `middle_distPhalanx_${h}`,\r\n [WebXRHandJoint.MIDDLE_FINGER_TIP]: `middle_tip_${h}`,\r\n [WebXRHandJoint.RING_FINGER_METACARPAL]: `ring_metacarpal_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_PROXIMAL]: `ring_proxPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE]: `ring_intPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_PHALANX_DISTAL]: `ring_distPhalanx_${h}`,\r\n [WebXRHandJoint.RING_FINGER_TIP]: `ring_tip_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_METACARPAL]: `little_metacarpal_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL]: `little_proxPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE]: `little_intPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_PHALANX_DISTAL]: `little_distPhalanx_${h}`,\r\n [WebXRHandJoint.PINKY_FINGER_TIP]: `little_tip_${h}`,\r\n };\r\n }\r\n\r\n private _attachedHands: {\r\n [uniqueId: string]: WebXRHand;\r\n } = {};\r\n\r\n private _trackingHands: {\r\n left: Nullable<WebXRHand>;\r\n right: Nullable<WebXRHand>;\r\n } = { left: null, right: null };\r\n\r\n private _handResources: {\r\n jointMeshes: Nullable<{ left: AbstractMesh[]; right: AbstractMesh[] }>;\r\n handMeshes: Nullable<{ left: AbstractMesh; right: AbstractMesh }>;\r\n rigMappings: Nullable<{ left: XRHandMeshRigMapping; right: XRHandMeshRigMapping }>;\r\n } = { jointMeshes: null, handMeshes: null, rigMappings: null };\r\n\r\n private _worldScaleObserver?: Nullable<Observer<{ previousScaleFactor: number; newScaleFactor: number }>> = null;\r\n\r\n /**\r\n * This observable will notify registered observers when a new hand object was added and initialized\r\n */\r\n public onHandAddedObservable: Observable<WebXRHand> = new Observable();\r\n /**\r\n * This observable will notify its observers right before the hand object is disposed\r\n */\r\n public onHandRemovedObservable: Observable<WebXRHand> = new Observable();\r\n\r\n private _originalMesh?: Mesh;\r\n\r\n /**\r\n * Check if the needed objects are defined.\r\n * This does not mean that the feature is enabled, but that the objects needed are well defined.\r\n * @returns true if the needed objects for this feature are defined\r\n */\r\n public override isCompatible(): boolean {\r\n return typeof XRHand !== \"undefined\";\r\n }\r\n\r\n /**\r\n * Get the hand object according to the controller id\r\n * @param controllerId the controller id to which we want to get the hand\r\n * @returns null if not found or the WebXRHand object if found\r\n */\r\n public getHandByControllerId(controllerId: string): Nullable<WebXRHand> {\r\n return this._attachedHands[controllerId];\r\n }\r\n\r\n /**\r\n * Get a hand object according to the requested handedness\r\n * @param handedness the handedness to request\r\n * @returns null if not found or the WebXRHand object if found\r\n */\r\n public getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand> {\r\n if (handedness == \"none\") {\r\n return null;\r\n }\r\n return this._trackingHands[handedness];\r\n }\r\n\r\n /**\r\n * Creates a new instance of the XR hand tracking feature.\r\n * @param _xrSessionManager An instance of WebXRSessionManager.\r\n * @param options Options to use when constructing this feature.\r\n */\r\n constructor(\r\n _xrSessionManager: WebXRSessionManager,\r\n /** Options to use when constructing this feature. */\r\n public readonly options: IWebXRHandTrackingOptions\r\n ) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"hand-tracking\";\r\n\r\n // Support legacy versions of the options object by copying over joint mesh properties\r\n const anyOptions = options as any;\r\n const anyJointMeshOptions = anyOptions.jointMeshes;\r\n if (anyJointMeshOptions) {\r\n if (typeof anyJointMeshOptions.disableDefaultHandMesh !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.disableDefaultMeshes = anyJointMeshOptions.disableDefaultHandMesh;\r\n }\r\n if (typeof anyJointMeshOptions.handMeshes !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.customMeshes = anyJointMeshOptions.handMeshes;\r\n }\r\n if (typeof anyJointMeshOptions.leftHandedSystemMeshes !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n options.handMeshes.meshesUseLeftHandedCoordinates = anyJointMeshOptions.leftHandedSystemMeshes;\r\n }\r\n if (typeof anyJointMeshOptions.rigMapping !== \"undefined\") {\r\n options.handMeshes = options.handMeshes || {};\r\n const leftRigMapping = {};\r\n const rightRigMapping = {};\r\n const rigMappingTuples = [\r\n [anyJointMeshOptions.rigMapping.left, leftRigMapping],\r\n [anyJointMeshOptions.rigMapping.right, rightRigMapping],\r\n ];\r\n\r\n for (const rigMappingTuple of rigMappingTuples) {\r\n const legacyRigMapping = rigMappingTuple[0] as string[];\r\n const rigMapping = rigMappingTuple[1] as XRHandMeshRigMapping;\r\n for (let index = 0; index < legacyRigMapping.length; index++) {\r\n const modelJointName = legacyRigMapping[index];\r\n rigMapping[HandJointReferenceArray[index]] = modelJointName;\r\n }\r\n }\r\n options.handMeshes.customRigMappings = {\r\n left: leftRigMapping as XRHandMeshRigMapping,\r\n right: rightRigMapping as XRHandMeshRigMapping,\r\n };\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Attach this feature.\r\n * Will usually be called by the features manager.\r\n *\r\n * @returns true if successful.\r\n */\r\n public override attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n if (!this._handResources.jointMeshes) {\r\n this._originalMesh = this._originalMesh || this.options.jointMeshes?.sourceMesh || CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS);\r\n this._originalMesh.isVisible = false;\r\n\r\n this._handResources.jointMeshes = WebXRHandTracking._GenerateTrackedJointMeshes(this.options, this._originalMesh);\r\n }\r\n this._handResources.handMeshes = this.options.handMeshes?.customMeshes || null;\r\n this._handResources.rigMappings = this.options.handMeshes?.customRigMappings || null;\r\n // If they didn't supply custom meshes and are not disabling the default meshes...\r\n if (!this.options.handMeshes?.customMeshes && !this.options.handMeshes?.disableDefaultMeshes) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n WebXRHandTracking._GenerateDefaultHandMeshesAsync(EngineStore.LastCreatedScene!, this._xrSessionManager, this.options).then((defaultHandMeshes) => {\r\n this._handResources.handMeshes = defaultHandMeshes;\r\n this._handResources.rigMappings = {\r\n left: WebXRHandTracking._GenerateDefaultHandMeshRigMapping(\"left\"),\r\n right: WebXRHandTracking._GenerateDefaultHandMeshRigMapping(\"right\"),\r\n };\r\n\r\n // Apply meshes to existing hands if already tracking.\r\n this._trackingHands.left?.setHandMesh(this._handResources.handMeshes.left, this._handResources.rigMappings.left, this._xrSessionManager);\r\n this._trackingHands.right?.setHandMesh(this._handResources.handMeshes.right, this._handResources.rigMappings.right, this._xrSessionManager);\r\n this._handResources.handMeshes.left.scaling.setAll(this._xrSessionManager.worldScalingFactor);\r\n this._handResources.handMeshes.right.scaling.setAll(this._xrSessionManager.worldScalingFactor);\r\n });\r\n this._worldScaleObserver = this._xrSessionManager.onWorldScaleFactorChangedObservable.add((scalingFactors) => {\r\n if (this._handResources.handMeshes) {\r\n this._handResources.handMeshes.left.scaling.scaleInPlace(scalingFactors.newScaleFactor / scalingFactors.previousScaleFactor);\r\n this._handResources.handMeshes.right.scaling.scaleInPlace(scalingFactors.newScaleFactor / scalingFactors.previousScaleFactor);\r\n }\r\n });\r\n }\r\n\r\n for (const controller of this.options.xrInput.controllers) {\r\n this._attachHand(controller);\r\n }\r\n\r\n this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand);\r\n\r\n return true;\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace, this.options.xrInput.xrCamera);\r\n this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace, this.options.xrInput.xrCamera);\r\n }\r\n\r\n private _attachHand = (xrController: WebXRInputSource) => {\r\n if (!xrController.inputSource.hand || xrController.inputSource.handedness == \"none\" || !this._handResources.jointMeshes) {\r\n return;\r\n }\r\n\r\n const handedness = xrController.inputSource.handedness;\r\n const webxrHand = new WebXRHand(\r\n xrController,\r\n this._handResources.jointMeshes[handedness],\r\n this._handResources.handMeshes && this._handResources.handMeshes[handedness],\r\n this._handResources.rigMappings && this._handResources.rigMappings[handedness],\r\n this.options.handMeshes?.meshesUseLeftHandedCoordinates,\r\n this.options.jointMeshes?.invisible,\r\n this.options.jointMeshes?.scaleFactor\r\n );\r\n\r\n this._attachedHands[xrController.uniqueId] = webxrHand;\r\n this._trackingHands[handedness] = webxrHand;\r\n\r\n this.onHandAddedObservable.notifyObservers(webxrHand);\r\n };\r\n\r\n private _detachHandById(controllerId: string, disposeMesh?: boolean) {\r\n const hand = this.getHandByControllerId(controllerId);\r\n if (hand) {\r\n const handedness = hand.xrController.inputSource.handedness == \"left\" ? \"left\" : \"right\";\r\n if (this._trackingHands[handedness]?.xrController.uniqueId === controllerId) {\r\n this._trackingHands[handedness] = null;\r\n }\r\n this.onHandRemovedObservable.notifyObservers(hand);\r\n hand.dispose(disposeMesh);\r\n delete this._attachedHands[controllerId];\r\n }\r\n }\r\n\r\n private _detachHand = (xrController: WebXRInputSource) => {\r\n this._detachHandById(xrController.uniqueId);\r\n };\r\n\r\n /**\r\n * Detach this feature.\r\n * Will usually be called by the features manager.\r\n *\r\n * @returns true if successful.\r\n */\r\n public override detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n const keys = Object.keys(this._attachedHands);\r\n for (const uniqueId of keys) {\r\n this._detachHandById(uniqueId, this.options.handMeshes?.disposeOnSessionEnd);\r\n }\r\n\r\n if (this.options.handMeshes?.disposeOnSessionEnd) {\r\n if (this._handResources.jointMeshes) {\r\n for (const trackedMesh of this._handResources.jointMeshes.left) {\r\n trackedMesh.dispose();\r\n }\r\n for (const trackedMesh of this._handResources.jointMeshes.right) {\r\n trackedMesh.dispose();\r\n }\r\n this._handResources.jointMeshes = null;\r\n }\r\n if (this._handResources.handMeshes) {\r\n this._handResources.handMeshes.left.dispose();\r\n this._handResources.handMeshes.right.dispose();\r\n this._handResources.handMeshes = null;\r\n }\r\n\r\n if (WebXRHandTracking._RightHandGLB) {\r\n for (const mesh of WebXRHandTracking._RightHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n if (WebXRHandTracking._LeftHandGLB) {\r\n for (const mesh of WebXRHandTracking._LeftHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n this._originalMesh?.dispose();\r\n this._originalMesh = undefined;\r\n }\r\n\r\n // remove world scale observer\r\n if (this._worldScaleObserver) {\r\n this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n this.onHandAddedObservable.clear();\r\n this.onHandRemovedObservable.clear();\r\n\r\n if (this._handResources.handMeshes && !this.options.handMeshes?.customMeshes) {\r\n // this will dispose the cached meshes\r\n this._handResources.handMeshes.left.dispose();\r\n this._handResources.handMeshes.right.dispose();\r\n // remove the cached meshes\r\n\r\n if (WebXRHandTracking._RightHandGLB) {\r\n for (const mesh of WebXRHandTracking._RightHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n if (WebXRHandTracking._LeftHandGLB) {\r\n for (const mesh of WebXRHandTracking._LeftHandGLB.meshes) {\r\n mesh.dispose();\r\n }\r\n }\r\n WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n if (this._handResources.jointMeshes) {\r\n for (const trackedMesh of this._handResources.jointMeshes.left) {\r\n trackedMesh.dispose();\r\n }\r\n for (const trackedMesh of this._handResources.jointMeshes.right) {\r\n trackedMesh.dispose();\r\n }\r\n }\r\n }\r\n}\r\n\r\n//register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRHandTracking.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRHandTracking(xrSessionManager, options);\r\n },\r\n WebXRHandTracking.Version,\r\n false\r\n);\r\n"]}
|
package/XR/webXRCamera.d.ts
CHANGED
|
@@ -86,7 +86,6 @@ export declare class WebXRCamera extends FreeCamera {
|
|
|
86
86
|
setTarget(target: Vector3): void;
|
|
87
87
|
dispose(): void;
|
|
88
88
|
private _updateDepthNearFar;
|
|
89
|
-
private _rotate180;
|
|
90
89
|
private _updateFromXRSession;
|
|
91
90
|
private _updateNumberOfRigCameras;
|
|
92
91
|
private _updateReferenceSpace;
|
package/XR/webXRCamera.js
CHANGED
|
@@ -47,7 +47,6 @@ export class WebXRCamera extends FreeCamera {
|
|
|
47
47
|
* This is used when copying the position from a native (non XR) camera
|
|
48
48
|
*/
|
|
49
49
|
this.compensateOnFirstFrame = true;
|
|
50
|
-
this._rotate180 = new Quaternion(0, 1, 0, 0);
|
|
51
50
|
// Initial camera configuration
|
|
52
51
|
this.minZ = 0.1;
|
|
53
52
|
this.rotationQuaternion = new Quaternion();
|
|
@@ -163,7 +162,7 @@ export class WebXRCamera extends FreeCamera {
|
|
|
163
162
|
target.subtractToRef(this.position, tmpVector);
|
|
164
163
|
tmpVector.y = 0;
|
|
165
164
|
tmpVector.normalize();
|
|
166
|
-
const yRotation = Math.atan2(tmpVector.x, tmpVector.z);
|
|
165
|
+
const yRotation = Math.atan2(tmpVector.x, tmpVector.z) + (this._scene.useRightHandedSystem ? Math.PI : 0);
|
|
167
166
|
this.rotationQuaternion.toEulerAnglesToRef(tmpVector);
|
|
168
167
|
Quaternion.FromEulerAnglesToRef(tmpVector.x, yRotation, tmpVector.z, this.rotationQuaternion);
|
|
169
168
|
}
|
|
@@ -212,9 +211,6 @@ export class WebXRCamera extends FreeCamera {
|
|
|
212
211
|
this._referenceQuaternion.z *= -1;
|
|
213
212
|
this._referenceQuaternion.w *= -1;
|
|
214
213
|
}
|
|
215
|
-
else {
|
|
216
|
-
this._referenceQuaternion.multiplyInPlace(this._rotate180);
|
|
217
|
-
}
|
|
218
214
|
if (this._firstFrame) {
|
|
219
215
|
this._firstFrame = false;
|
|
220
216
|
// we have the XR reference, now use this to find the offset to get the camera to be
|
|
@@ -267,9 +263,6 @@ export class WebXRCamera extends FreeCamera {
|
|
|
267
263
|
currentRig.rotationQuaternion.z *= -1;
|
|
268
264
|
currentRig.rotationQuaternion.w *= -1;
|
|
269
265
|
}
|
|
270
|
-
else {
|
|
271
|
-
currentRig.rotationQuaternion.multiplyInPlace(this._rotate180);
|
|
272
|
-
}
|
|
273
266
|
Matrix.FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, currentRig._projectionMatrix);
|
|
274
267
|
if (!this._scene.useRightHandedSystem) {
|
|
275
268
|
currentRig._projectionMatrix.toggleProjectionMatrixHandInPlace();
|