@babylonjs/core 8.46.0 → 8.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { WebXRAbstractFeature } from "./WebXRAbstractFeature.js";
2
2
  import type { WebXRSessionManager } from "../webXRSessionManager.js";
3
3
  import type { AbstractMesh } from "../../Meshes/abstractMesh.js";
4
- import type { Mesh } from "../../Meshes/mesh.js";
4
+ import { Mesh } from "../../Meshes/mesh.js";
5
5
  import type { WebXRInput } from "../webXRInput.js";
6
6
  import type { WebXRInputSource } from "../webXRInputSource.js";
7
7
  import type { Nullable } from "../../types.js";
@@ -225,6 +225,7 @@ export declare class WebXRHand implements IDisposable {
225
225
  * The float array that will directly receive the transform matrix data from WebXR.
226
226
  */
227
227
  private _jointTransformMatrices;
228
+ private _jointSpaces;
228
229
  private _tempJointMatrix;
229
230
  /**
230
231
  * The float array that will directly receive the joint radii from WebXR.
@@ -1,5 +1,6 @@
1
1
  import { WebXRAbstractFeature } from "./WebXRAbstractFeature.js";
2
2
  import { WebXRFeatureName, WebXRFeaturesManager } from "../webXRFeaturesManager.js";
3
+ import { Mesh } from "../../Meshes/mesh.js";
3
4
  import { Matrix, Quaternion } from "../../Maths/math.vector.js";
4
5
  import { PhysicsImpostor } from "../../Physics/v1/physicsImpostor.js";
5
6
  import { PhysicsAggregate } from "../../Physics/v2/physicsAggregate.js";
@@ -225,6 +226,7 @@ export class WebXRHand {
225
226
  * The float array that will directly receive the transform matrix data from WebXR.
226
227
  */
227
228
  this._jointTransformMatrices = new Float32Array(HandJointReferenceArray.length * 16);
229
+ this._jointSpaces = new Array(HandJointReferenceArray.length);
228
230
  this._tempJointMatrix = new Matrix();
229
231
  /**
230
232
  * The float array that will directly receive the joint radii from WebXR.
@@ -305,16 +307,18 @@ export class WebXRHand {
305
307
  }
306
308
  // TODO: Modify webxr.d.ts to better match WebXR IDL so we don't need this any cast.
307
309
  const anyHand = hand;
308
- const jointSpaces = HandJointReferenceArray.map((jointName) => anyHand[jointName] || hand.get(jointName));
310
+ for (let i = 0; i < HandJointReferenceArray.length; ++i) {
311
+ this._jointSpaces[i] = anyHand[HandJointReferenceArray[i]] || hand.get(HandJointReferenceArray[i]);
312
+ }
309
313
  let trackingSuccessful = false;
310
314
  if (xrFrame.fillPoses && xrFrame.fillJointRadii) {
311
- trackingSuccessful = xrFrame.fillPoses(jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(jointSpaces, this._jointRadii);
315
+ trackingSuccessful = xrFrame.fillPoses(this._jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(this._jointSpaces, this._jointRadii);
312
316
  }
313
317
  else if (xrFrame.getJointPose) {
314
318
  trackingSuccessful = true;
315
319
  // Warning: This codepath is slow by comparison, only here for compat.
316
- for (let jointIdx = 0; jointIdx < jointSpaces.length; jointIdx++) {
317
- const jointPose = xrFrame.getJointPose(jointSpaces[jointIdx], referenceSpace);
320
+ for (let jointIdx = 0; jointIdx < this._jointSpaces.length; jointIdx++) {
321
+ const jointPose = xrFrame.getJointPose(this._jointSpaces[jointIdx], referenceSpace);
318
322
  if (jointPose) {
319
323
  this._jointTransformMatrices.set(jointPose.transform.matrix, jointIdx * 16);
320
324
  this._jointRadii[jointIdx] = jointPose.radius || 0.008;
@@ -328,6 +332,18 @@ export class WebXRHand {
328
332
  if (!trackingSuccessful) {
329
333
  return;
330
334
  }
335
+ // L1 Cache Optimization: Invert to LHS in valid Babylon systems IN PLACE
336
+ // This linear loop is much faster than doing it per-object and avoids cache thrashing
337
+ if (!this._scene.useRightHandedSystem) {
338
+ for (let i = 0; i < HandJointReferenceArray.length; ++i) {
339
+ const offset = i * 16;
340
+ this._jointTransformMatrices[offset + 2] *= -1;
341
+ this._jointTransformMatrices[offset + 6] *= -1;
342
+ this._jointTransformMatrices[offset + 8] *= -1;
343
+ this._jointTransformMatrices[offset + 9] *= -1;
344
+ this._jointTransformMatrices[offset + 14] *= -1;
345
+ }
346
+ }
331
347
  for (let jointIdx = 0; jointIdx < HandJointReferenceArray.length; jointIdx++) {
332
348
  const jointTransform = this._jointTransforms[jointIdx];
333
349
  Matrix.FromArrayToRef(this._jointTransformMatrices, jointIdx * 16, this._tempJointMatrix);
@@ -340,16 +356,12 @@ export class WebXRHand {
340
356
  jointMesh.rotationQuaternion.copyFrom(jointTransform.rotationQuaternion);
341
357
  jointMesh.scaling.setAll(scaledJointRadius);
342
358
  jointMesh.parent = xrCamera.parent;
343
- // The WebXR data comes as right-handed, so we might need to do some conversions.
344
- if (!this._scene.useRightHandedSystem) {
345
- jointMesh.position.z *= -1;
346
- jointMesh.rotationQuaternion.z *= -1;
347
- jointMesh.rotationQuaternion.w *= -1;
348
- if (this._leftHandedMeshes && this._handMesh) {
349
- jointTransform.position.z *= -1;
350
- jointTransform.rotationQuaternion.z *= -1;
351
- jointTransform.rotationQuaternion.w *= -1;
352
- }
359
+ // Restore correct transform for meshes that are NOT left-handed (e.g. default GLTF)
360
+ // The buffer is now LHS, so if the mesh expects RHS, we must un-flip.
361
+ if (!this._leftHandedMeshes && !this._scene.useRightHandedSystem && this._handMesh) {
362
+ jointTransform.position.z *= -1;
363
+ jointTransform.rotationQuaternion.z *= -1;
364
+ jointTransform.rotationQuaternion.w *= -1;
353
365
  }
354
366
  }
355
367
  if (this._handMesh) {
@@ -385,15 +397,21 @@ export class WebXRHand {
385
397
  * WebXR Hand Joint tracking feature, available for selected browsers and devices
386
398
  */
387
399
  export class WebXRHandTracking extends WebXRAbstractFeature {
388
- static _GenerateTrackedJointMeshes(featureOptions, originalMesh = CreateIcoSphere("jointParent", WebXRHandTracking._ICOSPHERE_PARAMS)) {
389
- const meshes = {};
390
- ["left", "right"].map((handedness) => {
400
+ static _GenerateTrackedJointMeshes(options, originalMesh) {
401
+ const meshes = { left: [], right: [] };
402
+ for (const handedness of ["left", "right"]) {
403
+ const h = handedness;
391
404
  const trackedMeshes = [];
392
- originalMesh.isVisible = !!featureOptions.jointMeshes?.keepOriginalVisible;
393
- for (let i = 0; i < HandJointReferenceArray.length; ++i) {
394
- let newInstance = originalMesh.createInstance(`${handedness}-handJoint-${i}`);
395
- if (featureOptions.jointMeshes?.onHandJointMeshGenerated) {
396
- const returnedMesh = featureOptions.jointMeshes.onHandJointMeshGenerated(newInstance, i, handedness);
405
+ for (let i = 0; i < HandJointReferenceArray.length; i++) {
406
+ let newInstance;
407
+ if (originalMesh instanceof Mesh) {
408
+ newInstance = originalMesh.createInstance(`${handedness}-handJoint-${i}`);
409
+ }
410
+ else {
411
+ newInstance = originalMesh.clone(`${handedness}-handJoint-${i}`, null);
412
+ }
413
+ if (options.jointMeshes?.onHandJointMeshGenerated) {
414
+ const returnedMesh = options.jointMeshes.onHandJointMeshGenerated(newInstance, i, h);
397
415
  if (returnedMesh) {
398
416
  if (returnedMesh !== newInstance) {
399
417
  newInstance.dispose();
@@ -402,8 +420,8 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
402
420
  }
403
421
  }
404
422
  newInstance.isPickable = false;
405
- if (featureOptions.jointMeshes?.enablePhysics) {
406
- const props = featureOptions.jointMeshes?.physicsProps || {};
423
+ if (options.jointMeshes?.enablePhysics) {
424
+ const props = options.jointMeshes?.physicsProps;
407
425
  // downscale the instances so that physics will be initialized correctly
408
426
  newInstance.scaling.setAll(0.02);
409
427
  // Detect physics version
@@ -412,7 +430,7 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
412
430
  const physicsVersion = physicsEngine?.getPluginVersion() || 1;
413
431
  if (physicsVersion === 2) {
414
432
  // V2 physics
415
- const impostorType = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;
433
+ const impostorType = props?.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;
416
434
  let shapeType = 0 /* PhysicsShapeType.SPHERE */;
417
435
  // Map v1 impostor types to v2 shape types
418
436
  switch (impostorType) {
@@ -430,28 +448,30 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
430
448
  }
431
449
  const aggregate = new PhysicsAggregate(newInstance, shapeType, {
432
450
  mass: 0,
433
- friction: props.friction ?? 0.2,
434
- restitution: props.restitution ?? 0.2,
451
+ friction: props?.friction ?? 0.2,
452
+ restitution: props?.restitution ?? 0.2,
435
453
  }, scene);
436
454
  aggregate.body.setMotionType(1 /* PhysicsMotionType.ANIMATED */);
437
455
  aggregate.body.disableSync = true;
438
456
  }
439
457
  else {
440
458
  // V1 physics
441
- const type = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;
442
- newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, { mass: 0, ...props });
459
+ const type = props?.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;
460
+ newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, props ? { mass: 0, ...props } : { mass: 0 });
443
461
  }
444
462
  }
463
+ if (options.jointMeshes?.invisible) {
464
+ newInstance.isVisible = false;
465
+ }
445
466
  newInstance.rotationQuaternion = new Quaternion();
446
- newInstance.isVisible = false;
447
467
  trackedMeshes.push(newInstance);
448
468
  }
449
- meshes[handedness] = trackedMeshes;
450
- });
451
- return { left: meshes.left, right: meshes.right };
469
+ meshes[h] = trackedMeshes;
470
+ }
471
+ return meshes;
452
472
  }
453
473
  static async _GenerateDefaultHandMeshesAsync(scene, xrSessionManager, options) {
454
- // eslint-disable-next-line no-async-promise-executor, @typescript-eslint/no-misused-promises
474
+ // eslint-disable-next-line no-async-promise-executor
455
475
  return await new Promise(async (resolve) => {
456
476
  const riggedMeshes = {};
457
477
  // check the cache, defensive
@@ -508,9 +528,13 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
508
528
  }
509
529
  const handMesh = handGLB.meshes[1];
510
530
  handMesh._internalAbstractMeshDataInfo._computeBonesUsingShaders = true;
531
+ if (handMesh.skeleton) {
532
+ handMesh.skeleton.useTextureToStoreBoneMatrices = false;
533
+ }
511
534
  // if in multiview do not use the material
512
535
  if (!isMultiview && !options?.handMeshes?.disableHandShader) {
513
536
  handMesh.material = handShader.clone(`${handedness}HandShaderClone`, true);
537
+ handMesh.material.freeze();
514
538
  }
515
539
  handMesh.isVisible = false;
516
540
  riggedMeshes[handedness] = handMesh;
@@ -612,7 +636,7 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
612
636
  return;
613
637
  }
614
638
  const handedness = xrController.inputSource.handedness;
615
- const webxrHand = new WebXRHand(xrController, this._handResources.jointMeshes[handedness], this._handResources.handMeshes && this._handResources.handMeshes[handedness], this._handResources.rigMappings && this._handResources.rigMappings[handedness], this.options.handMeshes?.meshesUseLeftHandedCoordinates, this.options.jointMeshes?.invisible, this.options.jointMeshes?.scaleFactor);
639
+ const webxrHand = new WebXRHand(xrController, this._handResources.jointMeshes && this._handResources.jointMeshes[handedness], this._handResources.handMeshes && this._handResources.handMeshes[handedness], this._handResources.rigMappings && this._handResources.rigMappings[handedness], this.options.handMeshes?.meshesUseLeftHandedCoordinates, this.options.jointMeshes?.invisible, this.options.jointMeshes?.scaleFactor);
616
640
  this._attachedHands[xrController.uniqueId] = webxrHand;
617
641
  this._trackingHands[handedness] = webxrHand;
618
642
  this.onHandAddedObservable.notifyObservers(webxrHand);
@@ -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;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAKrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM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,WAAW,CAAC,KAAK,EAAE,CAAC;gBAC9D,WAAW,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC;QACL,CAAC;IACL,CAAC;;AAhhBD;;GAEG;AACoB,sBAAI,GAAG,gBAAgB,CAAC,aAAa,AAAjC,CAAkC;AAC7D;;;;GAIG;AACoB,yBAAO,GAAG,CAAC,AAAJ,CAAK;AAEnC,+CAA+C;AACjC,6CAA2B,GAAG,+CAA+C,AAAlD,CAAmD;AAC5F,4DAA4D;AAC9C,mDAAiC,GAAG,gBAAgB,AAAnB,CAAoB;AACnE,2DAA2D;AAC7C,kDAAgC,GAAG,gBAAgB,AAAnB,CAAoB;AAClE,sEAAsE;AACxD,+CAA6B,GAAG,+DAA+D,AAAlE,CAAmE;AAE9G,gHAAgH;AACxF,mCAAiB,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;AA2f1E,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\nimport { PhysicsAggregate } from \"../../Physics/v2/physicsAggregate\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"../../Physics/v2/IPhysicsEnginePlugin\";\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\r\n // Detect physics version\r\n const scene = newInstance.getScene();\r\n const physicsEngine = scene.getPhysicsEngine();\r\n const physicsVersion = physicsEngine?.getPluginVersion() || 1;\r\n\r\n if (physicsVersion === 2) {\r\n // V2 physics\r\n const impostorType = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n let shapeType = PhysicsShapeType.SPHERE;\r\n\r\n // Map v1 impostor types to v2 shape types\r\n switch (impostorType) {\r\n case PhysicsImpostor.SphereImpostor:\r\n shapeType = PhysicsShapeType.SPHERE;\r\n break;\r\n case PhysicsImpostor.BoxImpostor:\r\n shapeType = PhysicsShapeType.BOX;\r\n break;\r\n case PhysicsImpostor.CapsuleImpostor:\r\n shapeType = PhysicsShapeType.CAPSULE;\r\n break;\r\n default:\r\n shapeType = PhysicsShapeType.SPHERE;\r\n }\r\n\r\n const aggregate = new PhysicsAggregate(\r\n newInstance,\r\n shapeType,\r\n {\r\n mass: 0,\r\n friction: props.friction ?? 0.2,\r\n restitution: props.restitution ?? 0.2,\r\n },\r\n scene\r\n );\r\n aggregate.body.setMotionType(PhysicsMotionType.ANIMATED);\r\n aggregate.body.disableSync = true;\r\n } else {\r\n // V1 physics\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 }\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"]}
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;AAEjF,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAKrE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,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nB,CAAoB;AACnE,2DAA2D;AAC7C,kDAAgC,GAAG,gBAAgB,AAAnB,CAAoB;AAClE,sEAAsE;AACxD,+CAA6B,GAAG,+DAA+D,AAAlE,CAAmE;AAE9G,gHAAgH;AACxF,mCAAiB,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;AAogB1E,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 { 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\nimport { PhysicsAggregate } from \"../../Physics/v2/physicsAggregate\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"../../Physics/v2/IPhysicsEnginePlugin\";\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 private _jointSpaces: XRJointSpace[] = new Array(HandJointReferenceArray.length);\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 for (let i = 0; i < HandJointReferenceArray.length; ++i) {\r\n this._jointSpaces[i] = anyHand[HandJointReferenceArray[i]] || hand.get(HandJointReferenceArray[i]);\r\n }\r\n let trackingSuccessful = false;\r\n\r\n if (xrFrame.fillPoses && xrFrame.fillJointRadii) {\r\n trackingSuccessful = xrFrame.fillPoses(this._jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(this._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 < this._jointSpaces.length; jointIdx++) {\r\n const jointPose = xrFrame.getJointPose(this._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 // L1 Cache Optimization: Invert to LHS in valid Babylon systems IN PLACE\r\n // This linear loop is much faster than doing it per-object and avoids cache thrashing\r\n if (!this._scene.useRightHandedSystem) {\r\n for (let i = 0; i < HandJointReferenceArray.length; ++i) {\r\n const offset = i * 16;\r\n this._jointTransformMatrices[offset + 2] *= -1;\r\n this._jointTransformMatrices[offset + 6] *= -1;\r\n this._jointTransformMatrices[offset + 8] *= -1;\r\n this._jointTransformMatrices[offset + 9] *= -1;\r\n this._jointTransformMatrices[offset + 14] *= -1;\r\n }\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 // Restore correct transform for meshes that are NOT left-handed (e.g. default GLTF)\r\n // The buffer is now LHS, so if the mesh expects RHS, we must un-flip.\r\n if (!this._leftHandedMeshes && !this._scene.useRightHandedSystem && 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 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\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(options: IWebXRHandTrackingOptions, originalMesh: AbstractMesh): { left: AbstractMesh[]; right: AbstractMesh[] } {\r\n const meshes: { left: AbstractMesh[]; right: AbstractMesh[] } = { left: [], right: [] };\r\n\r\n for (const handedness of [\"left\", \"right\"] as const) {\r\n const h = handedness as \"left\" | \"right\";\r\n const trackedMeshes: AbstractMesh[] = [];\r\n for (let i = 0; i < HandJointReferenceArray.length; i++) {\r\n let newInstance: AbstractMesh;\r\n if (originalMesh instanceof Mesh) {\r\n newInstance = originalMesh.createInstance(`${handedness}-handJoint-${i}`);\r\n } else {\r\n newInstance = originalMesh.clone(`${handedness}-handJoint-${i}`, null) as AbstractMesh;\r\n }\r\n if (options.jointMeshes?.onHandJointMeshGenerated) {\r\n const returnedMesh = options.jointMeshes.onHandJointMeshGenerated(newInstance as InstancedMesh, i, h);\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 (options.jointMeshes?.enablePhysics) {\r\n const props = options.jointMeshes?.physicsProps;\r\n // downscale the instances so that physics will be initialized correctly\r\n newInstance.scaling.setAll(0.02);\r\n // Detect physics version\r\n const scene = newInstance.getScene();\r\n const physicsEngine = scene.getPhysicsEngine();\r\n const physicsVersion = physicsEngine?.getPluginVersion() || 1;\r\n\r\n if (physicsVersion === 2) {\r\n // V2 physics\r\n const impostorType = props?.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n let shapeType = PhysicsShapeType.SPHERE;\r\n\r\n // Map v1 impostor types to v2 shape types\r\n switch (impostorType) {\r\n case PhysicsImpostor.SphereImpostor:\r\n shapeType = PhysicsShapeType.SPHERE;\r\n break;\r\n case PhysicsImpostor.BoxImpostor:\r\n shapeType = PhysicsShapeType.BOX;\r\n break;\r\n case PhysicsImpostor.CapsuleImpostor:\r\n shapeType = PhysicsShapeType.CAPSULE;\r\n break;\r\n default:\r\n shapeType = PhysicsShapeType.SPHERE;\r\n }\r\n\r\n const aggregate = new PhysicsAggregate(\r\n newInstance,\r\n shapeType,\r\n {\r\n mass: 0,\r\n friction: props?.friction ?? 0.2,\r\n restitution: props?.restitution ?? 0.2,\r\n },\r\n scene\r\n );\r\n aggregate.body.setMotionType(PhysicsMotionType.ANIMATED);\r\n aggregate.body.disableSync = true;\r\n } else {\r\n // V1 physics\r\n const type = props?.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, props ? { mass: 0, ...props } : { mass: 0 });\r\n }\r\n }\r\n if (options.jointMeshes?.invisible) {\r\n newInstance.isVisible = false;\r\n }\r\n newInstance.rotationQuaternion = new Quaternion();\r\n trackedMeshes.push(newInstance);\r\n }\r\n\r\n meshes[h] = trackedMeshes;\r\n }\r\n return meshes;\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\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 (handMesh.skeleton) {\r\n handMesh.skeleton.useTextureToStoreBoneMatrices = false;\r\n }\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 handMesh.material.freeze();\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 && 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\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/core",
3
- "version": "8.46.0",
3
+ "version": "8.46.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",