@babylonjs/core 5.0.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/Engines/Extensions/engine.readTexture.d.ts +2 -2
  2. package/Engines/Extensions/engine.readTexture.js +8 -4
  3. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  4. package/Engines/WebGPU/Extensions/engine.readTexture.js +4 -2
  5. package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
  6. package/Engines/engine.d.ts +7 -1
  7. package/Engines/engine.js +14 -0
  8. package/Engines/engine.js.map +1 -1
  9. package/Engines/nativeEngine.d.ts +24 -0
  10. package/Engines/nativeEngine.js +39 -0
  11. package/Engines/nativeEngine.js.map +1 -1
  12. package/Engines/thinEngine.d.ts +2 -1
  13. package/Engines/thinEngine.js +16 -6
  14. package/Engines/thinEngine.js.map +1 -1
  15. package/Engines/webgpuEngine.d.ts +13 -1
  16. package/Engines/webgpuEngine.js +25 -1
  17. package/Engines/webgpuEngine.js.map +1 -1
  18. package/Materials/PBR/pbrBaseMaterial.js +3 -0
  19. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  20. package/Materials/Textures/MultiviewRenderTarget.js +1 -0
  21. package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
  22. package/Materials/Textures/baseTexture.d.ts +5 -1
  23. package/Materials/Textures/baseTexture.js +21 -11
  24. package/Materials/Textures/baseTexture.js.map +1 -1
  25. package/Materials/Textures/texture.d.ts +3 -0
  26. package/Materials/Textures/texture.js +4 -2
  27. package/Materials/Textures/texture.js.map +1 -1
  28. package/Maths/math.color.d.ts +11 -2
  29. package/Maths/math.color.js +12 -7
  30. package/Maths/math.color.js.map +1 -1
  31. package/Meshes/abstractMesh.js +1 -1
  32. package/Meshes/abstractMesh.js.map +1 -1
  33. package/Meshes/mesh.js +0 -1
  34. package/Meshes/mesh.js.map +1 -1
  35. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +6 -1
  36. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +13 -2
  37. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  38. package/XR/features/WebXRHandTracking.js +1 -1
  39. package/XR/features/WebXRHandTracking.js.map +1 -1
  40. package/assetContainer.d.ts +13 -1
  41. package/assetContainer.js +130 -17
  42. package/assetContainer.js.map +1 -1
  43. package/package.json +1 -1
@@ -59,7 +59,6 @@ export declare class SSAORenderingPipeline extends PostProcessRenderPipeline {
59
59
  */
60
60
  base: number;
61
61
  private _scene;
62
- private _depthTexture;
63
62
  private _randomTexture;
64
63
  private _originalColorPostProcess;
65
64
  private _ssaoPostProcess;
@@ -79,6 +78,12 @@ export declare class SSAORenderingPipeline extends PostProcessRenderPipeline {
79
78
  * @param cameras - The array of cameras that the rendering pipeline will be attached to
80
79
  */
81
80
  constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
81
+ /**
82
+ * @param cameras
83
+ * @param unique
84
+ * @hidden
85
+ */
86
+ _attachCameras(cameras: any, unique: boolean): void;
82
87
  /**
83
88
  * Get the class name
84
89
  * @returns "SSAORenderingPipeline"
@@ -82,7 +82,6 @@ var SSAORenderingPipeline = /** @class */ (function (_super) {
82
82
  _this._scene = scene;
83
83
  // Set up assets
84
84
  _this._createRandomTexture();
85
- _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
86
85
  var ssaoRatio = ratio.ssaoRatio || ratio;
87
86
  var combineRatio = ratio.combineRatio || ratio;
88
87
  _this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
@@ -122,6 +121,18 @@ var SSAORenderingPipeline = /** @class */ (function (_super) {
122
121
  enumerable: false,
123
122
  configurable: true
124
123
  });
124
+ /**
125
+ * @param cameras
126
+ * @param unique
127
+ * @hidden
128
+ */
129
+ SSAORenderingPipeline.prototype._attachCameras = function (cameras, unique) {
130
+ _super.prototype._attachCameras.call(this, cameras, unique);
131
+ for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
132
+ var camera = _a[_i];
133
+ this._scene.enableDepthRenderer(camera).getDepthMap(); // Force depth renderer "on"
134
+ }
135
+ };
125
136
  // Public Methods
126
137
  /**
127
138
  * Get the class name
@@ -193,7 +204,7 @@ var SSAORenderingPipeline = /** @class */ (function (_super) {
193
204
  effect.setFloat("area", _this.area);
194
205
  effect.setFloat("fallOff", _this.fallOff);
195
206
  effect.setFloat("base", _this.base);
196
- effect.setTexture("textureSampler", _this._depthTexture);
207
+ effect.setTexture("textureSampler", _this._scene.enableDepthRenderer(_this._scene.activeCamera).getDepthMap());
197
208
  effect.setTexture("randomSampler", _this._randomTexture);
198
209
  };
199
210
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ssaoRenderingPipeline.js","sourceRoot":"","sources":["../../../../../../../lts/core/generated/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iEAAiE,CAAC;AAC5G,OAAO,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,OAAO,sFAAsF,CA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K,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;gBACjD,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;gBAEjD,OAAO,CAAC,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,GAAG,CAAC;gBAC5F,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;aAChC;SACJ;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IA7SD;QADC,SAAS,EAAE;gEACuB;IAMnC;QADC,SAAS,EAAE;yDACmB;IAQ/B;QADC,SAAS,EAAE;uDACiB;IAQ7B;QADC,SAAS,EAAE;0DACsB;IAOlC;QADC,SAAS,EAAE;uDACc;IAiR9B,4BAAC;CAAA,AA/UD,CAA2C,yBAAyB,GA+UnE;SA/UY,qBAAqB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector2, Vector3, TmpVectors } from \"../../../Maths/math.vector\";\r\nimport type { Camera } from \"../../../Cameras/camera\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport { DynamicTexture } from \"../../../Materials/Textures/dynamicTexture\";\r\nimport type { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { PostProcess } from \"../../../PostProcesses/postProcess\";\r\nimport { PostProcessRenderPipeline } from \"../../../PostProcesses/RenderPipeline/postProcessRenderPipeline\";\r\nimport { PostProcessRenderEffect } from \"../../../PostProcesses/RenderPipeline/postProcessRenderEffect\";\r\nimport { PassPostProcess } from \"../../../PostProcesses/passPostProcess\";\r\nimport { BlurPostProcess } from \"../../../PostProcesses/blurPostProcess\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { serialize } from \"../../../Misc/decorators\";\r\nimport type { Scene } from \"../../../scene\";\r\n\r\nimport \"../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent\";\r\n\r\nimport \"../../../Shaders/ssao.fragment\";\r\nimport \"../../../Shaders/ssaoCombine.fragment\";\r\n\r\n/**\r\n * Render pipeline to produce ssao effect\r\n */\r\nexport class SSAORenderingPipeline extends PostProcessRenderPipeline {\r\n // Members\r\n\r\n /**\r\n * @ignore\r\n * The PassPostProcess id in the pipeline that contains the original scene color\r\n */\r\n public SSAOOriginalSceneColorEffect: string = \"SSAOOriginalSceneColorEffect\";\r\n /**\r\n * @ignore\r\n * The SSAO PostProcess id in the pipeline\r\n */\r\n public SSAORenderEffect: string = \"SSAORenderEffect\";\r\n /**\r\n * @ignore\r\n * The horizontal blur PostProcess id in the pipeline\r\n */\r\n public SSAOBlurHRenderEffect: string = \"SSAOBlurHRenderEffect\";\r\n /**\r\n * @ignore\r\n * The vertical blur PostProcess id in the pipeline\r\n */\r\n public SSAOBlurVRenderEffect: string = \"SSAOBlurVRenderEffect\";\r\n /**\r\n * @ignore\r\n * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)\r\n */\r\n public SSAOCombineRenderEffect: string = \"SSAOCombineRenderEffect\";\r\n\r\n /**\r\n * The output strength of the SSAO post-process. Default value is 1.0.\r\n */\r\n @serialize()\r\n public totalStrength: number = 1.0;\r\n\r\n /**\r\n * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006\r\n */\r\n @serialize()\r\n public radius: number = 0.0001;\r\n\r\n /**\r\n * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to fallOff and superior to fallOff.\r\n * Default value is 0.0075\r\n */\r\n @serialize()\r\n public area: number = 0.0075;\r\n\r\n /**\r\n * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to area and inferior to area.\r\n * Default value is 0.000001\r\n */\r\n @serialize()\r\n public fallOff: number = 0.000001;\r\n\r\n /**\r\n * The base color of the SSAO post-process\r\n * The final result is \"base + ssao\" between [0, 1]\r\n */\r\n @serialize()\r\n public base: number = 0.5;\r\n\r\n private _scene: Scene;\r\n private _depthTexture: RenderTargetTexture;\r\n private _randomTexture: DynamicTexture;\r\n\r\n private _originalColorPostProcess: PassPostProcess;\r\n private _ssaoPostProcess: PostProcess;\r\n private _blurHPostProcess: BlurPostProcess;\r\n private _blurVPostProcess: BlurPostProcess;\r\n private _ssaoCombinePostProcess: PostProcess;\r\n\r\n private _firstUpdate: boolean = true;\r\n\r\n /**\r\n * Gets active scene\r\n */\r\n public get scene(): Scene {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * @constructor\r\n * @param name - The rendering pipeline name\r\n * @param scene - The scene linked to this pipeline\r\n * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }\r\n * @param cameras - The array of cameras that the rendering pipeline will be attached to\r\n */\r\n constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]) {\r\n super(scene.getEngine(), name);\r\n\r\n this._scene = scene;\r\n\r\n // Set up assets\r\n this._createRandomTexture();\r\n this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer \"on\"\r\n\r\n const ssaoRatio = ratio.ssaoRatio || ratio;\r\n const combineRatio = ratio.combineRatio || ratio;\r\n\r\n this._originalColorPostProcess = new PassPostProcess(\"SSAOOriginalSceneColor\", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);\r\n this._createSSAOPostProcess(ssaoRatio);\r\n this._createBlurPostProcess(ssaoRatio);\r\n this._createSSAOCombinePostProcess(combineRatio);\r\n\r\n // Set up pipeline\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOOriginalSceneColorEffect,\r\n () => {\r\n return this._originalColorPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAORenderEffect,\r\n () => {\r\n return this._ssaoPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOBlurHRenderEffect,\r\n () => {\r\n return this._blurHPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOBlurVRenderEffect,\r\n () => {\r\n return this._blurVPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOCombineRenderEffect,\r\n () => {\r\n return this._ssaoCombinePostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n // Finish\r\n scene.postProcessRenderPipelineManager.addPipeline(this);\r\n if (cameras) {\r\n scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);\r\n }\r\n }\r\n\r\n // Public Methods\r\n\r\n /**\r\n * Get the class name\r\n * @returns \"SSAORenderingPipeline\"\r\n */\r\n public getClassName(): string {\r\n return \"SSAORenderingPipeline\";\r\n }\r\n\r\n /**\r\n * Removes the internal pipeline assets and detaches the pipeline from the scene cameras\r\n * @param disableDepthRender\r\n */\r\n public dispose(disableDepthRender: boolean = false): void {\r\n for (let i = 0; i < this._scene.cameras.length; i++) {\r\n const camera = this._scene.cameras[i];\r\n\r\n this._originalColorPostProcess.dispose(camera);\r\n this._ssaoPostProcess.dispose(camera);\r\n this._blurHPostProcess.dispose(camera);\r\n this._blurVPostProcess.dispose(camera);\r\n this._ssaoCombinePostProcess.dispose(camera);\r\n }\r\n\r\n this._randomTexture.dispose();\r\n\r\n if (disableDepthRender) {\r\n this._scene.disableDepthRenderer();\r\n }\r\n\r\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);\r\n\r\n super.dispose();\r\n }\r\n\r\n // Private Methods\r\n private _createBlurPostProcess(ratio: number): void {\r\n const size = 16;\r\n\r\n this._blurHPostProcess = new BlurPostProcess(\r\n \"BlurH\",\r\n new Vector2(1, 0),\r\n size,\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n this._blurVPostProcess = new BlurPostProcess(\r\n \"BlurV\",\r\n new Vector2(0, 1),\r\n size,\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n\r\n this._blurHPostProcess.onActivateObservable.add(() => {\r\n const dw = this._blurHPostProcess.width / this._scene.getEngine().getRenderWidth();\r\n this._blurHPostProcess.kernel = size * dw;\r\n });\r\n\r\n this._blurVPostProcess.onActivateObservable.add(() => {\r\n const dw = this._blurVPostProcess.height / this._scene.getEngine().getRenderHeight();\r\n this._blurVPostProcess.kernel = size * dw;\r\n });\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild() {\r\n this._firstUpdate = true;\r\n super._rebuild();\r\n }\r\n\r\n private _createSSAOPostProcess(ratio: number): void {\r\n const numSamples = 16;\r\n const sampleSphere = [\r\n 0.5381, 0.1856, -0.4319, 0.1379, 0.2486, 0.443, 0.3371, 0.5679, -0.0057, -0.6999, -0.0451, -0.0019, 0.0689, -0.1598, -0.8547, 0.056, 0.0069, -0.1843, -0.0146, 0.1402,\r\n 0.0762, 0.01, -0.1924, -0.0344, -0.3577, -0.5301, -0.4358, -0.3169, 0.1063, 0.0158, 0.0103, -0.5869, 0.0046, -0.0897, -0.494, 0.3287, 0.7119, -0.0154, -0.0918, -0.0533,\r\n 0.0596, -0.5411, 0.0352, -0.0631, 0.546, -0.4776, 0.2847, -0.0271,\r\n ];\r\n const samplesFactor = 1.0 / numSamples;\r\n\r\n this._ssaoPostProcess = new PostProcess(\r\n \"ssao\",\r\n \"ssao\",\r\n [\"sampleSphere\", \"samplesFactor\", \"randTextureTiles\", \"totalStrength\", \"radius\", \"area\", \"fallOff\", \"base\", \"range\", \"viewport\"],\r\n [\"randomSampler\"],\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n \"#define SAMPLES \" + numSamples + \"\\n#define SSAO\"\r\n );\r\n\r\n this._ssaoPostProcess.externalTextureSamplerBinding = true;\r\n this._ssaoPostProcess.onApply = (effect: Effect) => {\r\n if (this._firstUpdate) {\r\n effect.setArray3(\"sampleSphere\", sampleSphere);\r\n effect.setFloat(\"samplesFactor\", samplesFactor);\r\n effect.setFloat(\"randTextureTiles\", 4.0);\r\n }\r\n\r\n effect.setFloat(\"totalStrength\", this.totalStrength);\r\n effect.setFloat(\"radius\", this.radius);\r\n effect.setFloat(\"area\", this.area);\r\n effect.setFloat(\"fallOff\", this.fallOff);\r\n effect.setFloat(\"base\", this.base);\r\n\r\n effect.setTexture(\"textureSampler\", this._depthTexture);\r\n effect.setTexture(\"randomSampler\", this._randomTexture);\r\n };\r\n }\r\n\r\n private _createSSAOCombinePostProcess(ratio: number): void {\r\n this._ssaoCombinePostProcess = new PostProcess(\r\n \"ssaoCombine\",\r\n \"ssaoCombine\",\r\n [],\r\n [\"originalColor\", \"viewport\"],\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false\r\n );\r\n\r\n this._ssaoCombinePostProcess.onApply = (effect: Effect) => {\r\n effect.setVector4(\"viewport\", TmpVectors.Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));\r\n effect.setTextureFromPostProcess(\"originalColor\", this._originalColorPostProcess);\r\n };\r\n }\r\n\r\n private _createRandomTexture(): void {\r\n const size = 512;\r\n\r\n this._randomTexture = new DynamicTexture(\"SSAORandomTexture\", size, this._scene, false, Texture.TRILINEAR_SAMPLINGMODE);\r\n this._randomTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n this._randomTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n\r\n const context = this._randomTexture.getContext();\r\n\r\n const rand = (min: number, max: number) => {\r\n return Math.random() * (max - min) + min;\r\n };\r\n\r\n const randVector = Vector3.Zero();\r\n\r\n for (let x = 0; x < size; x++) {\r\n for (let y = 0; y < size; y++) {\r\n randVector.x = Math.floor(rand(-1.0, 1.0) * 255);\r\n randVector.y = Math.floor(rand(-1.0, 1.0) * 255);\r\n randVector.z = Math.floor(rand(-1.0, 1.0) * 255);\r\n\r\n context.fillStyle = \"rgb(\" + randVector.x + \", \" + randVector.y + \", \" + randVector.z + \")\";\r\n context.fillRect(x, y, 1, 1);\r\n }\r\n }\r\n\r\n this._randomTexture.update(false);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ssaoRenderingPipeline.js","sourceRoot":"","sources":["../../../../../../../lts/core/generated/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iEAAiE,CAAC;AAC5G,OAAO,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAA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,IAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;gBAC3B,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;gBACjD,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;gBACjD,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;gBAEjD,OAAO,CAAC,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,GAAG,CAAC;gBAC5F,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;aAChC;SACJ;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAxTD;QADC,SAAS,EAAE;gEACuB;IAMnC;QADC,SAAS,EAAE;yDACmB;IAQ/B;QADC,SAAS,EAAE;uDACiB;IAQ7B;QADC,SAAS,EAAE;0DACsB;IAOlC;QADC,SAAS,EAAE;uDACc;IA4R9B,4BAAC;CAAA,AA1VD,CAA2C,yBAAyB,GA0VnE;SA1VY,qBAAqB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Vector2, Vector3, TmpVectors } from \"../../../Maths/math.vector\";\r\nimport type { Camera } from \"../../../Cameras/camera\";\r\nimport type { Effect } from \"../../../Materials/effect\";\r\nimport { Texture } from \"../../../Materials/Textures/texture\";\r\nimport { DynamicTexture } from \"../../../Materials/Textures/dynamicTexture\";\r\nimport { PostProcess } from \"../../../PostProcesses/postProcess\";\r\nimport { PostProcessRenderPipeline } from \"../../../PostProcesses/RenderPipeline/postProcessRenderPipeline\";\r\nimport { PostProcessRenderEffect } from \"../../../PostProcesses/RenderPipeline/postProcessRenderEffect\";\r\nimport { PassPostProcess } from \"../../../PostProcesses/passPostProcess\";\r\nimport { BlurPostProcess } from \"../../../PostProcesses/blurPostProcess\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { serialize } from \"../../../Misc/decorators\";\r\nimport type { Scene } from \"../../../scene\";\r\n\r\nimport \"../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent\";\r\n\r\nimport \"../../../Shaders/ssao.fragment\";\r\nimport \"../../../Shaders/ssaoCombine.fragment\";\r\n\r\n/**\r\n * Render pipeline to produce ssao effect\r\n */\r\nexport class SSAORenderingPipeline extends PostProcessRenderPipeline {\r\n // Members\r\n\r\n /**\r\n * @ignore\r\n * The PassPostProcess id in the pipeline that contains the original scene color\r\n */\r\n public SSAOOriginalSceneColorEffect: string = \"SSAOOriginalSceneColorEffect\";\r\n /**\r\n * @ignore\r\n * The SSAO PostProcess id in the pipeline\r\n */\r\n public SSAORenderEffect: string = \"SSAORenderEffect\";\r\n /**\r\n * @ignore\r\n * The horizontal blur PostProcess id in the pipeline\r\n */\r\n public SSAOBlurHRenderEffect: string = \"SSAOBlurHRenderEffect\";\r\n /**\r\n * @ignore\r\n * The vertical blur PostProcess id in the pipeline\r\n */\r\n public SSAOBlurVRenderEffect: string = \"SSAOBlurVRenderEffect\";\r\n /**\r\n * @ignore\r\n * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)\r\n */\r\n public SSAOCombineRenderEffect: string = \"SSAOCombineRenderEffect\";\r\n\r\n /**\r\n * The output strength of the SSAO post-process. Default value is 1.0.\r\n */\r\n @serialize()\r\n public totalStrength: number = 1.0;\r\n\r\n /**\r\n * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006\r\n */\r\n @serialize()\r\n public radius: number = 0.0001;\r\n\r\n /**\r\n * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to fallOff and superior to fallOff.\r\n * Default value is 0.0075\r\n */\r\n @serialize()\r\n public area: number = 0.0075;\r\n\r\n /**\r\n * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to area and inferior to area.\r\n * Default value is 0.000001\r\n */\r\n @serialize()\r\n public fallOff: number = 0.000001;\r\n\r\n /**\r\n * The base color of the SSAO post-process\r\n * The final result is \"base + ssao\" between [0, 1]\r\n */\r\n @serialize()\r\n public base: number = 0.5;\r\n\r\n private _scene: Scene;\r\n private _randomTexture: DynamicTexture;\r\n\r\n private _originalColorPostProcess: PassPostProcess;\r\n private _ssaoPostProcess: PostProcess;\r\n private _blurHPostProcess: BlurPostProcess;\r\n private _blurVPostProcess: BlurPostProcess;\r\n private _ssaoCombinePostProcess: PostProcess;\r\n\r\n private _firstUpdate: boolean = true;\r\n\r\n /**\r\n * Gets active scene\r\n */\r\n public get scene(): Scene {\r\n return this._scene;\r\n }\r\n\r\n /**\r\n * @constructor\r\n * @param name - The rendering pipeline name\r\n * @param scene - The scene linked to this pipeline\r\n * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }\r\n * @param cameras - The array of cameras that the rendering pipeline will be attached to\r\n */\r\n constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]) {\r\n super(scene.getEngine(), name);\r\n\r\n this._scene = scene;\r\n\r\n // Set up assets\r\n this._createRandomTexture();\r\n\r\n const ssaoRatio = ratio.ssaoRatio || ratio;\r\n const combineRatio = ratio.combineRatio || ratio;\r\n\r\n this._originalColorPostProcess = new PassPostProcess(\"SSAOOriginalSceneColor\", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);\r\n this._createSSAOPostProcess(ssaoRatio);\r\n this._createBlurPostProcess(ssaoRatio);\r\n this._createSSAOCombinePostProcess(combineRatio);\r\n\r\n // Set up pipeline\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOOriginalSceneColorEffect,\r\n () => {\r\n return this._originalColorPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAORenderEffect,\r\n () => {\r\n return this._ssaoPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOBlurHRenderEffect,\r\n () => {\r\n return this._blurHPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOBlurVRenderEffect,\r\n () => {\r\n return this._blurVPostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n this.addEffect(\r\n new PostProcessRenderEffect(\r\n scene.getEngine(),\r\n this.SSAOCombineRenderEffect,\r\n () => {\r\n return this._ssaoCombinePostProcess;\r\n },\r\n true\r\n )\r\n );\r\n\r\n // Finish\r\n scene.postProcessRenderPipelineManager.addPipeline(this);\r\n if (cameras) {\r\n scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);\r\n }\r\n }\r\n\r\n /**\r\n * @param cameras\r\n * @param unique\r\n * @hidden\r\n */\r\n public _attachCameras(cameras: any, unique: boolean): void {\r\n super._attachCameras(cameras, unique);\r\n\r\n for (const camera of this._cameras) {\r\n this._scene.enableDepthRenderer(camera).getDepthMap(); // Force depth renderer \"on\"\r\n }\r\n }\r\n\r\n // Public Methods\r\n\r\n /**\r\n * Get the class name\r\n * @returns \"SSAORenderingPipeline\"\r\n */\r\n public getClassName(): string {\r\n return \"SSAORenderingPipeline\";\r\n }\r\n\r\n /**\r\n * Removes the internal pipeline assets and detaches the pipeline from the scene cameras\r\n * @param disableDepthRender\r\n */\r\n public dispose(disableDepthRender: boolean = false): void {\r\n for (let i = 0; i < this._scene.cameras.length; i++) {\r\n const camera = this._scene.cameras[i];\r\n\r\n this._originalColorPostProcess.dispose(camera);\r\n this._ssaoPostProcess.dispose(camera);\r\n this._blurHPostProcess.dispose(camera);\r\n this._blurVPostProcess.dispose(camera);\r\n this._ssaoCombinePostProcess.dispose(camera);\r\n }\r\n\r\n this._randomTexture.dispose();\r\n\r\n if (disableDepthRender) {\r\n this._scene.disableDepthRenderer();\r\n }\r\n\r\n this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);\r\n\r\n super.dispose();\r\n }\r\n\r\n // Private Methods\r\n private _createBlurPostProcess(ratio: number): void {\r\n const size = 16;\r\n\r\n this._blurHPostProcess = new BlurPostProcess(\r\n \"BlurH\",\r\n new Vector2(1, 0),\r\n size,\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n this._blurVPostProcess = new BlurPostProcess(\r\n \"BlurV\",\r\n new Vector2(0, 1),\r\n size,\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n\r\n this._blurHPostProcess.onActivateObservable.add(() => {\r\n const dw = this._blurHPostProcess.width / this._scene.getEngine().getRenderWidth();\r\n this._blurHPostProcess.kernel = size * dw;\r\n });\r\n\r\n this._blurVPostProcess.onActivateObservable.add(() => {\r\n const dw = this._blurVPostProcess.height / this._scene.getEngine().getRenderHeight();\r\n this._blurVPostProcess.kernel = size * dw;\r\n });\r\n }\r\n\r\n /** @hidden */\r\n public _rebuild() {\r\n this._firstUpdate = true;\r\n super._rebuild();\r\n }\r\n\r\n private _createSSAOPostProcess(ratio: number): void {\r\n const numSamples = 16;\r\n const sampleSphere = [\r\n 0.5381, 0.1856, -0.4319, 0.1379, 0.2486, 0.443, 0.3371, 0.5679, -0.0057, -0.6999, -0.0451, -0.0019, 0.0689, -0.1598, -0.8547, 0.056, 0.0069, -0.1843, -0.0146, 0.1402,\r\n 0.0762, 0.01, -0.1924, -0.0344, -0.3577, -0.5301, -0.4358, -0.3169, 0.1063, 0.0158, 0.0103, -0.5869, 0.0046, -0.0897, -0.494, 0.3287, 0.7119, -0.0154, -0.0918, -0.0533,\r\n 0.0596, -0.5411, 0.0352, -0.0631, 0.546, -0.4776, 0.2847, -0.0271,\r\n ];\r\n const samplesFactor = 1.0 / numSamples;\r\n\r\n this._ssaoPostProcess = new PostProcess(\r\n \"ssao\",\r\n \"ssao\",\r\n [\"sampleSphere\", \"samplesFactor\", \"randTextureTiles\", \"totalStrength\", \"radius\", \"area\", \"fallOff\", \"base\", \"range\", \"viewport\"],\r\n [\"randomSampler\"],\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false,\r\n \"#define SAMPLES \" + numSamples + \"\\n#define SSAO\"\r\n );\r\n\r\n this._ssaoPostProcess.externalTextureSamplerBinding = true;\r\n this._ssaoPostProcess.onApply = (effect: Effect) => {\r\n if (this._firstUpdate) {\r\n effect.setArray3(\"sampleSphere\", sampleSphere);\r\n effect.setFloat(\"samplesFactor\", samplesFactor);\r\n effect.setFloat(\"randTextureTiles\", 4.0);\r\n }\r\n\r\n effect.setFloat(\"totalStrength\", this.totalStrength);\r\n effect.setFloat(\"radius\", this.radius);\r\n effect.setFloat(\"area\", this.area);\r\n effect.setFloat(\"fallOff\", this.fallOff);\r\n effect.setFloat(\"base\", this.base);\r\n\r\n effect.setTexture(\"textureSampler\", this._scene.enableDepthRenderer(this._scene.activeCamera).getDepthMap());\r\n effect.setTexture(\"randomSampler\", this._randomTexture);\r\n };\r\n }\r\n\r\n private _createSSAOCombinePostProcess(ratio: number): void {\r\n this._ssaoCombinePostProcess = new PostProcess(\r\n \"ssaoCombine\",\r\n \"ssaoCombine\",\r\n [],\r\n [\"originalColor\", \"viewport\"],\r\n ratio,\r\n null,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n this._scene.getEngine(),\r\n false\r\n );\r\n\r\n this._ssaoCombinePostProcess.onApply = (effect: Effect) => {\r\n effect.setVector4(\"viewport\", TmpVectors.Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));\r\n effect.setTextureFromPostProcess(\"originalColor\", this._originalColorPostProcess);\r\n };\r\n }\r\n\r\n private _createRandomTexture(): void {\r\n const size = 512;\r\n\r\n this._randomTexture = new DynamicTexture(\"SSAORandomTexture\", size, this._scene, false, Texture.TRILINEAR_SAMPLINGMODE);\r\n this._randomTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n this._randomTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n\r\n const context = this._randomTexture.getContext();\r\n\r\n const rand = (min: number, max: number) => {\r\n return Math.random() * (max - min) + min;\r\n };\r\n\r\n const randVector = Vector3.Zero();\r\n\r\n for (let x = 0; x < size; x++) {\r\n for (let y = 0; y < size; y++) {\r\n randVector.x = Math.floor(rand(-1.0, 1.0) * 255);\r\n randVector.y = Math.floor(rand(-1.0, 1.0) * 255);\r\n randVector.z = Math.floor(rand(-1.0, 1.0) * 255);\r\n\r\n context.fillStyle = \"rgb(\" + randVector.x + \", \" + randVector.y + \", \" + randVector.z + \")\";\r\n context.fillRect(x, y, 1, 1);\r\n }\r\n }\r\n\r\n this._randomTexture.update(false);\r\n }\r\n}\r\n"]}
@@ -453,7 +453,7 @@ var WebXRHandTracking = /** @class */ (function (_super) {
453
453
  riggedMeshes[handedness] = handMesh;
454
454
  // single change for left handed systems
455
455
  if (!handsDefined && !scene.useRightHandedSystem) {
456
- handGLB.transformNodes[0].rotate(Axis.Y, Math.PI);
456
+ handGLB.meshes[1].rotate(Axis.Y, Math.PI);
457
457
  }
458
458
  });
459
459
  handShader.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"WebXRHandTracking.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/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,+BAA+B,CAAC;AAGhE,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,wCAAwC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AA4LpD,IAAM,uBAAuB,GAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B9C,CAAC;AAEF,IAAM,mBAAmB;IACrB,0BAAkB,qBAAmB;IACrC,0BAAkB,kLAA2H;IAC7I,0BAAkB;;;;;;KAMjB;IACD,4BAAmB;;;;;;KAMlB;IACD,wBAAiB;;;;;;KAMhB;IACD,4BAAmB;;;;;;KAMlB;OACJ,CAAC;AAEF;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rB,oBAAoB,CAAC,eAAe,CAChC,iBAAiB,CAAC,IAAI,EACtB,UAAC,gBAAgB,EAAE,OAAO;IACtB,OAAO,cAAM,OAAA,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAhD,CAAgD,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/physicsImpostor\";\r\n\r\nimport type { IDisposable, Scene } from \"../../scene\";\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\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\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 XRHandJoint {\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 XRHandJoint]: string };\r\n\r\nconst handJointReferenceArray: XRHandJoint[] = [\r\n XRHandJoint.WRIST,\r\n XRHandJoint.THUMB_METACARPAL,\r\n XRHandJoint.THUMB_PHALANX_PROXIMAL,\r\n XRHandJoint.THUMB_PHALANX_DISTAL,\r\n XRHandJoint.THUMB_TIP,\r\n XRHandJoint.INDEX_FINGER_METACARPAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.INDEX_FINGER_TIP,\r\n XRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.MIDDLE_FINGER_TIP,\r\n XRHandJoint.RING_FINGER_METACARPAL,\r\n XRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.RING_FINGER_TIP,\r\n XRHandJoint.PINKY_FINGER_METACARPAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.PINKY_FINGER_TIP,\r\n];\r\n\r\nconst handPartsDefinition: { [key in HandPart]: XRHandJoint[] } = {\r\n [HandPart.WRIST]: [XRHandJoint.WRIST],\r\n [HandPart.THUMB]: [XRHandJoint.THUMB_METACARPAL, XRHandJoint.THUMB_PHALANX_PROXIMAL, XRHandJoint.THUMB_PHALANX_DISTAL, XRHandJoint.THUMB_TIP],\r\n [HandPart.INDEX]: [\r\n XRHandJoint.INDEX_FINGER_METACARPAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.INDEX_FINGER_TIP,\r\n ],\r\n [HandPart.MIDDLE]: [\r\n XRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.MIDDLE_FINGER_TIP,\r\n ],\r\n [HandPart.RING]: [\r\n XRHandJoint.RING_FINGER_METACARPAL,\r\n XRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.RING_FINGER_TIP,\r\n ],\r\n [HandPart.LITTLE]: [\r\n XRHandJoint.PINKY_FINGER_METACARPAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.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 private _scene: Scene;\r\n\r\n /**\r\n * Transform nodes that will directly receive the transforms from the WebXR matrix data.\r\n */\r\n private _jointTransforms = new Array<TransformNode>(handJointReferenceArray.length);\r\n\r\n /**\r\n * The float array that will directly receive the transform matrix data from WebXR.\r\n */\r\n private _jointTransformMatrices = new Float32Array(handJointReferenceArray.length * 16);\r\n\r\n private _tempJointMatrix = new Matrix();\r\n\r\n /**\r\n * The float array that will directly receive the joint radii from WebXR.\r\n */\r\n private _jointRadii = new Float32Array(handJointReferenceArray.length);\r\n\r\n /**\r\n * Get the hand mesh.\r\n */\r\n public get handMesh(): Nullable<AbstractMesh> {\r\n return this._handMesh;\r\n }\r\n\r\n /**\r\n * Get meshes of part of the hand.\r\n * @param part The part of hand to get.\r\n * @returns An array of meshes that correlate to the hand part requested.\r\n */\r\n public getHandPartMeshes(part: HandPart): AbstractMesh[] {\r\n return handPartsDefinition[part].map((name) => this._jointMeshes[handJointReferenceArray.indexOf(name)]!);\r\n }\r\n\r\n /**\r\n * Retrieves a mesh linked to a named joint in the hand.\r\n * @param jointName The name of the joint.\r\n * @returns An AbstractMesh whose position corresponds with the joint position.\r\n */\r\n public getJointMesh(jointName: XRHandJoint): 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 const jointTransform = (this._jointTransforms[jointIdx] = new TransformNode(handJointReferenceArray[jointIdx], this._scene));\r\n jointTransform.rotationQuaternion = new Quaternion();\r\n\r\n // Set the rotation quaternion so we can use it later for tracking.\r\n _jointMeshes[jointIdx].rotationQuaternion = new Quaternion();\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.setEnabled(false);\r\n } else {\r\n this.xrController.motionController.onModelLoadedObservable.add((controller) => {\r\n if (controller.rootMesh) {\r\n controller.rootMesh.setEnabled(false);\r\n }\r\n });\r\n }\r\n }\r\n\r\n this.xrController.onMotionControllerInitObservable.add((motionController) => {\r\n motionController.onModelLoadedObservable.add((controller) => {\r\n if (controller.rootMesh) {\r\n controller.rootMesh.setEnabled(false);\r\n }\r\n });\r\n if (motionController.rootMesh) {\r\n motionController.rootMesh.setEnabled(false);\r\n }\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 */\r\n public setHandMesh(handMesh: AbstractMesh, rigMapping: Nullable<XRHandMeshRigMapping>) {\r\n this._handMesh = handMesh;\r\n\r\n // Avoid any strange frustum culling. We will manually control visibility via attach and detach.\r\n handMesh.alwaysSelectAsActiveMesh = true;\r\n handMesh.getChildMeshes().forEach((mesh) => (mesh.alwaysSelectAsActiveMesh = true));\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 handJointReferenceArray.forEach((jointName, 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\r\n /**\r\n * Update this hand from the latest xr frame.\r\n * @param xrFrame The latest frame received from WebXR.\r\n * @param referenceSpace The current viewer reference space.\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace) {\r\n const hand = this.xrController.inputSource.hand;\r\n if (!hand) {\r\n return;\r\n }\r\n\r\n // TODO: Modify webxr.d.ts to better match WebXR IDL so we don't need this any cast.\r\n const anyHand: any = hand;\r\n const jointSpaces: XRJointSpace[] = handJointReferenceArray.map((jointName) => anyHand[jointName] || hand.get(jointName));\r\n let trackingSuccessful = false;\r\n\r\n if (xrFrame.fillPoses && xrFrame.fillJointRadii) {\r\n trackingSuccessful = xrFrame.fillPoses(jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(jointSpaces, this._jointRadii);\r\n } else if (xrFrame.getJointPose) {\r\n trackingSuccessful = true;\r\n // Warning: This codepath is slow by comparison, only here for compat.\r\n for (let jointIdx = 0; jointIdx < jointSpaces.length; jointIdx++) {\r\n const jointPose = xrFrame.getJointPose(jointSpaces[jointIdx], referenceSpace);\r\n if (jointPose) {\r\n this._jointTransformMatrices.set(jointPose.transform.matrix, jointIdx * 16);\r\n this._jointRadii[jointIdx] = jointPose.radius || 0.008;\r\n } else {\r\n trackingSuccessful = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!trackingSuccessful) {\r\n return;\r\n }\r\n\r\n handJointReferenceArray.forEach((_jointName, jointIdx) => {\r\n const jointTransform = this._jointTransforms[jointIdx];\r\n Matrix.FromArrayToRef(this._jointTransformMatrices, jointIdx * 16, this._tempJointMatrix);\r\n this._tempJointMatrix.decompose(undefined, jointTransform.rotationQuaternion!, jointTransform.position);\r\n\r\n // The radius we need to make the joint in order for it to roughly cover the joints of the user's real hand.\r\n const scaledJointRadius = this._jointRadii[jointIdx] * this._jointScaleFactor;\r\n\r\n const jointMesh = this._jointMeshes[jointIdx];\r\n jointMesh.isVisible = !this._handMesh && !this._jointsInvisible;\r\n jointMesh.position.copyFrom(jointTransform.position);\r\n jointMesh.rotationQuaternion!.copyFrom(jointTransform.rotationQuaternion!);\r\n jointMesh.scaling.setAll(scaledJointRadius);\r\n\r\n // The WebXR data comes as right-handed, so we might need to do some conversions.\r\n if (!this._scene.useRightHandedSystem) {\r\n jointMesh.position.z *= -1;\r\n jointMesh.rotationQuaternion!.z *= -1;\r\n jointMesh.rotationQuaternion!.w *= -1;\r\n\r\n if (this._leftHandedMeshes && this._handMesh) {\r\n jointTransform.position.z *= -1;\r\n jointTransform.rotationQuaternion!.z *= -1;\r\n jointTransform.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n });\r\n\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = true;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose this Hand object\r\n */\r\n public dispose() {\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = false;\r\n }\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/meshes/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/meshes/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(featureOptions: IWebXRHandTrackingOptions): { 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 const originalMesh = featureOptions.jointMeshes?.sourceMesh || CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS);\r\n originalMesh.isVisible = !!featureOptions.jointMeshes?.keepOriginalVisible;\r\n for (let i = 0; i < handJointReferenceArray.length; ++i) {\r\n let newInstance: AbstractMesh = originalMesh.createInstance(`${handedness}-handJoint-${i}`);\r\n if (featureOptions.jointMeshes?.onHandJointMeshGenerated) {\r\n const returnedMesh = featureOptions.jointMeshes.onHandJointMeshGenerated(newInstance as InstancedMesh, i, handedness);\r\n if (returnedMesh) {\r\n if (returnedMesh !== newInstance) {\r\n newInstance.dispose();\r\n newInstance = returnedMesh;\r\n }\r\n }\r\n }\r\n newInstance.isPickable = false;\r\n if (featureOptions.jointMeshes?.enablePhysics) {\r\n const props = featureOptions.jointMeshes?.physicsProps || {};\r\n // downscale the instances so that physics will be initialized correctly\r\n newInstance.scaling.setAll(0.02);\r\n const type = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, { mass: 0, ...props });\r\n }\r\n newInstance.rotationQuaternion = new Quaternion();\r\n newInstance.isVisible = false;\r\n trackedMeshes.push(newInstance);\r\n }\r\n\r\n meshes[handedness] = trackedMeshes;\r\n });\r\n return { left: meshes.left, right: meshes.right };\r\n }\r\n\r\n private static _GenerateDefaultHandMeshesAsync(scene: Scene, options?: IWebXRHandTrackingOptions): Promise<{ left: AbstractMesh; right: AbstractMesh }> {\r\n // eslint-disable-next-line no-async-promise-executor\r\n return 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 handGLBs = await Promise.all([\r\n WebXRHandTracking._RightHandGLB ||\r\n SceneLoader.ImportMeshAsync(\"\", WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL, WebXRHandTracking.DEFAULT_HAND_MODEL_RIGHT_FILENAME, scene),\r\n WebXRHandTracking._LeftHandGLB ||\r\n SceneLoader.ImportMeshAsync(\"\", WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL, WebXRHandTracking.DEFAULT_HAND_MODEL_LEFT_FILENAME, scene),\r\n ]);\r\n WebXRHandTracking._RightHandGLB = handGLBs[0];\r\n WebXRHandTracking._LeftHandGLB = handGLBs[1];\r\n\r\n const handShader = new NodeMaterial(\"handShader\", scene, { emitComments: false });\r\n await handShader.loadAsync(WebXRHandTracking.DEFAULT_HAND_MODEL_SHADER_URL);\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\r\n [\"left\", \"right\"].forEach((handedness) => {\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 handMesh.material = handShader.clone(`${handedness}HandShaderClone`, true);\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.transformNodes[0].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 */\r\n private static _GenerateDefaultHandMeshRigMapping(handedness: XRHandedness): XRHandMeshRigMapping {\r\n const H = handedness == \"right\" ? \"R\" : \"L\";\r\n return {\r\n [XRHandJoint.WRIST]: `wrist_${H}`,\r\n [XRHandJoint.THUMB_METACARPAL]: `thumb_metacarpal_${H}`,\r\n [XRHandJoint.THUMB_PHALANX_PROXIMAL]: `thumb_proxPhalanx_${H}`,\r\n [XRHandJoint.THUMB_PHALANX_DISTAL]: `thumb_distPhalanx_${H}`,\r\n [XRHandJoint.THUMB_TIP]: `thumb_tip_${H}`,\r\n [XRHandJoint.INDEX_FINGER_METACARPAL]: `index_metacarpal_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL]: `index_proxPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE]: `index_intPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_DISTAL]: `index_distPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_TIP]: `index_tip_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_METACARPAL]: `middle_metacarpal_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL]: `middle_proxPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE]: `middle_intPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL]: `middle_distPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_TIP]: `middle_tip_${H}`,\r\n [XRHandJoint.RING_FINGER_METACARPAL]: `ring_metacarpal_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_PROXIMAL]: `ring_proxPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE]: `ring_intPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_DISTAL]: `ring_distPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_TIP]: `ring_tip_${H}`,\r\n [XRHandJoint.PINKY_FINGER_METACARPAL]: `little_metacarpal_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL]: `little_proxPhalanx_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE]: `little_intPhalanx_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_DISTAL]: `little_distPhalanx_${H}`,\r\n [XRHandJoint.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 /**\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 /**\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 */\r\n public 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 [\r\n [anyJointMeshOptions.rigMapping.left, leftRigMapping],\r\n [anyJointMeshOptions.rigMapping.right, rightRigMapping],\r\n ].forEach((rigMappingTuple) => {\r\n const legacyRigMapping = rigMappingTuple[0] as string[];\r\n const rigMapping = rigMappingTuple[1] as XRHandMeshRigMapping;\r\n legacyRigMapping.forEach((modelJointName, 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 attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n this._handResources = {\r\n jointMeshes: WebXRHandTracking._GenerateTrackedJointMeshes(this.options),\r\n handMeshes: this.options.handMeshes?.customMeshes || null,\r\n rigMappings: this.options.handMeshes?.customRigMappings || null,\r\n };\r\n\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 WebXRHandTracking._GenerateDefaultHandMeshesAsync(EngineStore.LastCreatedScene!, 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);\r\n this._trackingHands.right?.setHandMesh(this._handResources.handMeshes.right, this._handResources.rigMappings.right);\r\n });\r\n }\r\n\r\n this.options.xrInput.controllers.forEach(this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand);\r\n\r\n return true;\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n }\r\n\r\n private _attachHand = (xrController: WebXRInputSource) => {\r\n if (!xrController.inputSource.hand || xrController.inputSource.handedness == \"none\" || !this._handResources.jointMeshes) {\r\n return;\r\n }\r\n\r\n const handedness = xrController.inputSource.handedness;\r\n const webxrHand = new WebXRHand(\r\n xrController,\r\n this._handResources.jointMeshes[handedness],\r\n this._handResources.handMeshes && this._handResources.handMeshes[handedness],\r\n this._handResources.rigMappings && this._handResources.rigMappings[handedness],\r\n this.options.handMeshes?.meshesUseLeftHandedCoordinates,\r\n this.options.jointMeshes?.invisible,\r\n this.options.jointMeshes?.scaleFactor\r\n );\r\n\r\n this._attachedHands[xrController.uniqueId] = webxrHand;\r\n this._trackingHands[handedness] = webxrHand;\r\n\r\n this.onHandAddedObservable.notifyObservers(webxrHand);\r\n };\r\n\r\n private _detachHandById(controllerId: string) {\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();\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 detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n Object.keys(this._attachedHands).forEach((uniqueId) => this._detachHandById(uniqueId));\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 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 WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n if (this._handResources.jointMeshes) {\r\n this._handResources.jointMeshes.left.forEach((trackedMesh) => trackedMesh.dispose());\r\n this._handResources.jointMeshes.right.forEach((trackedMesh) => trackedMesh.dispose());\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":["../../../../../../lts/core/generated/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,+BAA+B,CAAC;AAGhE,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,wCAAwC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AA4LpD,IAAM,uBAAuB,GAAkB;;;;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MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAE3E,+BAAa,GAAsC,IAAI,CAAC;IACxD,8BAAY,GAAsC,IAAI,CAAC;IAwX1E,wBAAC;CAAA,AAjZD,CAAuC,oBAAoB,GAiZ1D;SAjZY,iBAAiB;AAmZ9B,qBAAqB;AACrB,oBAAoB,CAAC,eAAe,CAChC,iBAAiB,CAAC,IAAI,EACtB,UAAC,gBAAgB,EAAE,OAAO;IACtB,OAAO,cAAM,OAAA,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAhD,CAAgD,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/physicsImpostor\";\r\n\r\nimport type { IDisposable, Scene } from \"../../scene\";\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\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\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 XRHandJoint {\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 XRHandJoint]: string };\r\n\r\nconst handJointReferenceArray: XRHandJoint[] = [\r\n XRHandJoint.WRIST,\r\n XRHandJoint.THUMB_METACARPAL,\r\n XRHandJoint.THUMB_PHALANX_PROXIMAL,\r\n XRHandJoint.THUMB_PHALANX_DISTAL,\r\n XRHandJoint.THUMB_TIP,\r\n XRHandJoint.INDEX_FINGER_METACARPAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.INDEX_FINGER_TIP,\r\n XRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.MIDDLE_FINGER_TIP,\r\n XRHandJoint.RING_FINGER_METACARPAL,\r\n XRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.RING_FINGER_TIP,\r\n XRHandJoint.PINKY_FINGER_METACARPAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.PINKY_FINGER_TIP,\r\n];\r\n\r\nconst handPartsDefinition: { [key in HandPart]: XRHandJoint[] } = {\r\n [HandPart.WRIST]: [XRHandJoint.WRIST],\r\n [HandPart.THUMB]: [XRHandJoint.THUMB_METACARPAL, XRHandJoint.THUMB_PHALANX_PROXIMAL, XRHandJoint.THUMB_PHALANX_DISTAL, XRHandJoint.THUMB_TIP],\r\n [HandPart.INDEX]: [\r\n XRHandJoint.INDEX_FINGER_METACARPAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.INDEX_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.INDEX_FINGER_TIP,\r\n ],\r\n [HandPart.MIDDLE]: [\r\n XRHandJoint.MIDDLE_FINGER_METACARPAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.MIDDLE_FINGER_TIP,\r\n ],\r\n [HandPart.RING]: [\r\n XRHandJoint.RING_FINGER_METACARPAL,\r\n XRHandJoint.RING_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.RING_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.RING_FINGER_TIP,\r\n ],\r\n [HandPart.LITTLE]: [\r\n XRHandJoint.PINKY_FINGER_METACARPAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL,\r\n XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE,\r\n XRHandJoint.PINKY_FINGER_PHALANX_DISTAL,\r\n XRHandJoint.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 private _scene: Scene;\r\n\r\n /**\r\n * Transform nodes that will directly receive the transforms from the WebXR matrix data.\r\n */\r\n private _jointTransforms = new Array<TransformNode>(handJointReferenceArray.length);\r\n\r\n /**\r\n * The float array that will directly receive the transform matrix data from WebXR.\r\n */\r\n private _jointTransformMatrices = new Float32Array(handJointReferenceArray.length * 16);\r\n\r\n private _tempJointMatrix = new Matrix();\r\n\r\n /**\r\n * The float array that will directly receive the joint radii from WebXR.\r\n */\r\n private _jointRadii = new Float32Array(handJointReferenceArray.length);\r\n\r\n /**\r\n * Get the hand mesh.\r\n */\r\n public get handMesh(): Nullable<AbstractMesh> {\r\n return this._handMesh;\r\n }\r\n\r\n /**\r\n * Get meshes of part of the hand.\r\n * @param part The part of hand to get.\r\n * @returns An array of meshes that correlate to the hand part requested.\r\n */\r\n public getHandPartMeshes(part: HandPart): AbstractMesh[] {\r\n return handPartsDefinition[part].map((name) => this._jointMeshes[handJointReferenceArray.indexOf(name)]!);\r\n }\r\n\r\n /**\r\n * Retrieves a mesh linked to a named joint in the hand.\r\n * @param jointName The name of the joint.\r\n * @returns An AbstractMesh whose position corresponds with the joint position.\r\n */\r\n public getJointMesh(jointName: XRHandJoint): 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 const jointTransform = (this._jointTransforms[jointIdx] = new TransformNode(handJointReferenceArray[jointIdx], this._scene));\r\n jointTransform.rotationQuaternion = new Quaternion();\r\n\r\n // Set the rotation quaternion so we can use it later for tracking.\r\n _jointMeshes[jointIdx].rotationQuaternion = new Quaternion();\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.setEnabled(false);\r\n } else {\r\n this.xrController.motionController.onModelLoadedObservable.add((controller) => {\r\n if (controller.rootMesh) {\r\n controller.rootMesh.setEnabled(false);\r\n }\r\n });\r\n }\r\n }\r\n\r\n this.xrController.onMotionControllerInitObservable.add((motionController) => {\r\n motionController.onModelLoadedObservable.add((controller) => {\r\n if (controller.rootMesh) {\r\n controller.rootMesh.setEnabled(false);\r\n }\r\n });\r\n if (motionController.rootMesh) {\r\n motionController.rootMesh.setEnabled(false);\r\n }\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 */\r\n public setHandMesh(handMesh: AbstractMesh, rigMapping: Nullable<XRHandMeshRigMapping>) {\r\n this._handMesh = handMesh;\r\n\r\n // Avoid any strange frustum culling. We will manually control visibility via attach and detach.\r\n handMesh.alwaysSelectAsActiveMesh = true;\r\n handMesh.getChildMeshes().forEach((mesh) => (mesh.alwaysSelectAsActiveMesh = true));\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 handJointReferenceArray.forEach((jointName, 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\r\n /**\r\n * Update this hand from the latest xr frame.\r\n * @param xrFrame The latest frame received from WebXR.\r\n * @param referenceSpace The current viewer reference space.\r\n */\r\n public updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace) {\r\n const hand = this.xrController.inputSource.hand;\r\n if (!hand) {\r\n return;\r\n }\r\n\r\n // TODO: Modify webxr.d.ts to better match WebXR IDL so we don't need this any cast.\r\n const anyHand: any = hand;\r\n const jointSpaces: XRJointSpace[] = handJointReferenceArray.map((jointName) => anyHand[jointName] || hand.get(jointName));\r\n let trackingSuccessful = false;\r\n\r\n if (xrFrame.fillPoses && xrFrame.fillJointRadii) {\r\n trackingSuccessful = xrFrame.fillPoses(jointSpaces, referenceSpace, this._jointTransformMatrices) && xrFrame.fillJointRadii(jointSpaces, this._jointRadii);\r\n } else if (xrFrame.getJointPose) {\r\n trackingSuccessful = true;\r\n // Warning: This codepath is slow by comparison, only here for compat.\r\n for (let jointIdx = 0; jointIdx < jointSpaces.length; jointIdx++) {\r\n const jointPose = xrFrame.getJointPose(jointSpaces[jointIdx], referenceSpace);\r\n if (jointPose) {\r\n this._jointTransformMatrices.set(jointPose.transform.matrix, jointIdx * 16);\r\n this._jointRadii[jointIdx] = jointPose.radius || 0.008;\r\n } else {\r\n trackingSuccessful = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (!trackingSuccessful) {\r\n return;\r\n }\r\n\r\n handJointReferenceArray.forEach((_jointName, jointIdx) => {\r\n const jointTransform = this._jointTransforms[jointIdx];\r\n Matrix.FromArrayToRef(this._jointTransformMatrices, jointIdx * 16, this._tempJointMatrix);\r\n this._tempJointMatrix.decompose(undefined, jointTransform.rotationQuaternion!, jointTransform.position);\r\n\r\n // The radius we need to make the joint in order for it to roughly cover the joints of the user's real hand.\r\n const scaledJointRadius = this._jointRadii[jointIdx] * this._jointScaleFactor;\r\n\r\n const jointMesh = this._jointMeshes[jointIdx];\r\n jointMesh.isVisible = !this._handMesh && !this._jointsInvisible;\r\n jointMesh.position.copyFrom(jointTransform.position);\r\n jointMesh.rotationQuaternion!.copyFrom(jointTransform.rotationQuaternion!);\r\n jointMesh.scaling.setAll(scaledJointRadius);\r\n\r\n // The WebXR data comes as right-handed, so we might need to do some conversions.\r\n if (!this._scene.useRightHandedSystem) {\r\n jointMesh.position.z *= -1;\r\n jointMesh.rotationQuaternion!.z *= -1;\r\n jointMesh.rotationQuaternion!.w *= -1;\r\n\r\n if (this._leftHandedMeshes && this._handMesh) {\r\n jointTransform.position.z *= -1;\r\n jointTransform.rotationQuaternion!.z *= -1;\r\n jointTransform.rotationQuaternion!.w *= -1;\r\n }\r\n }\r\n });\r\n\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = true;\r\n }\r\n }\r\n\r\n /**\r\n * Dispose this Hand object\r\n */\r\n public dispose() {\r\n if (this._handMesh) {\r\n this._handMesh.isVisible = false;\r\n }\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/meshes/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/meshes/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(featureOptions: IWebXRHandTrackingOptions): { 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 const originalMesh = featureOptions.jointMeshes?.sourceMesh || CreateIcoSphere(\"jointParent\", WebXRHandTracking._ICOSPHERE_PARAMS);\r\n originalMesh.isVisible = !!featureOptions.jointMeshes?.keepOriginalVisible;\r\n for (let i = 0; i < handJointReferenceArray.length; ++i) {\r\n let newInstance: AbstractMesh = originalMesh.createInstance(`${handedness}-handJoint-${i}`);\r\n if (featureOptions.jointMeshes?.onHandJointMeshGenerated) {\r\n const returnedMesh = featureOptions.jointMeshes.onHandJointMeshGenerated(newInstance as InstancedMesh, i, handedness);\r\n if (returnedMesh) {\r\n if (returnedMesh !== newInstance) {\r\n newInstance.dispose();\r\n newInstance = returnedMesh;\r\n }\r\n }\r\n }\r\n newInstance.isPickable = false;\r\n if (featureOptions.jointMeshes?.enablePhysics) {\r\n const props = featureOptions.jointMeshes?.physicsProps || {};\r\n // downscale the instances so that physics will be initialized correctly\r\n newInstance.scaling.setAll(0.02);\r\n const type = props.impostorType !== undefined ? props.impostorType : PhysicsImpostor.SphereImpostor;\r\n newInstance.physicsImpostor = new PhysicsImpostor(newInstance, type, { mass: 0, ...props });\r\n }\r\n newInstance.rotationQuaternion = new Quaternion();\r\n newInstance.isVisible = false;\r\n trackedMeshes.push(newInstance);\r\n }\r\n\r\n meshes[handedness] = trackedMeshes;\r\n });\r\n return { left: meshes.left, right: meshes.right };\r\n }\r\n\r\n private static _GenerateDefaultHandMeshesAsync(scene: Scene, options?: IWebXRHandTrackingOptions): Promise<{ left: AbstractMesh; right: AbstractMesh }> {\r\n // eslint-disable-next-line no-async-promise-executor\r\n return 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 handGLBs = await Promise.all([\r\n WebXRHandTracking._RightHandGLB ||\r\n SceneLoader.ImportMeshAsync(\"\", WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL, WebXRHandTracking.DEFAULT_HAND_MODEL_RIGHT_FILENAME, scene),\r\n WebXRHandTracking._LeftHandGLB ||\r\n SceneLoader.ImportMeshAsync(\"\", WebXRHandTracking.DEFAULT_HAND_MODEL_BASE_URL, WebXRHandTracking.DEFAULT_HAND_MODEL_LEFT_FILENAME, scene),\r\n ]);\r\n WebXRHandTracking._RightHandGLB = handGLBs[0];\r\n WebXRHandTracking._LeftHandGLB = handGLBs[1];\r\n\r\n const handShader = new NodeMaterial(\"handShader\", scene, { emitComments: false });\r\n await handShader.loadAsync(WebXRHandTracking.DEFAULT_HAND_MODEL_SHADER_URL);\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\r\n [\"left\", \"right\"].forEach((handedness) => {\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 handMesh.material = handShader.clone(`${handedness}HandShaderClone`, true);\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 */\r\n private static _GenerateDefaultHandMeshRigMapping(handedness: XRHandedness): XRHandMeshRigMapping {\r\n const H = handedness == \"right\" ? \"R\" : \"L\";\r\n return {\r\n [XRHandJoint.WRIST]: `wrist_${H}`,\r\n [XRHandJoint.THUMB_METACARPAL]: `thumb_metacarpal_${H}`,\r\n [XRHandJoint.THUMB_PHALANX_PROXIMAL]: `thumb_proxPhalanx_${H}`,\r\n [XRHandJoint.THUMB_PHALANX_DISTAL]: `thumb_distPhalanx_${H}`,\r\n [XRHandJoint.THUMB_TIP]: `thumb_tip_${H}`,\r\n [XRHandJoint.INDEX_FINGER_METACARPAL]: `index_metacarpal_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_PROXIMAL]: `index_proxPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_INTERMEDIATE]: `index_intPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_PHALANX_DISTAL]: `index_distPhalanx_${H}`,\r\n [XRHandJoint.INDEX_FINGER_TIP]: `index_tip_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_METACARPAL]: `middle_metacarpal_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_PROXIMAL]: `middle_proxPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_INTERMEDIATE]: `middle_intPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_PHALANX_DISTAL]: `middle_distPhalanx_${H}`,\r\n [XRHandJoint.MIDDLE_FINGER_TIP]: `middle_tip_${H}`,\r\n [XRHandJoint.RING_FINGER_METACARPAL]: `ring_metacarpal_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_PROXIMAL]: `ring_proxPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_INTERMEDIATE]: `ring_intPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_PHALANX_DISTAL]: `ring_distPhalanx_${H}`,\r\n [XRHandJoint.RING_FINGER_TIP]: `ring_tip_${H}`,\r\n [XRHandJoint.PINKY_FINGER_METACARPAL]: `little_metacarpal_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_PROXIMAL]: `little_proxPhalanx_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_INTERMEDIATE]: `little_intPhalanx_${H}`,\r\n [XRHandJoint.PINKY_FINGER_PHALANX_DISTAL]: `little_distPhalanx_${H}`,\r\n [XRHandJoint.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 /**\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 /**\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 */\r\n public 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 [\r\n [anyJointMeshOptions.rigMapping.left, leftRigMapping],\r\n [anyJointMeshOptions.rigMapping.right, rightRigMapping],\r\n ].forEach((rigMappingTuple) => {\r\n const legacyRigMapping = rigMappingTuple[0] as string[];\r\n const rigMapping = rigMappingTuple[1] as XRHandMeshRigMapping;\r\n legacyRigMapping.forEach((modelJointName, 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 attach(): boolean {\r\n if (!super.attach()) {\r\n return false;\r\n }\r\n\r\n this._handResources = {\r\n jointMeshes: WebXRHandTracking._GenerateTrackedJointMeshes(this.options),\r\n handMeshes: this.options.handMeshes?.customMeshes || null,\r\n rigMappings: this.options.handMeshes?.customRigMappings || null,\r\n };\r\n\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 WebXRHandTracking._GenerateDefaultHandMeshesAsync(EngineStore.LastCreatedScene!, 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);\r\n this._trackingHands.right?.setHandMesh(this._handResources.handMeshes.right, this._handResources.rigMappings.right);\r\n });\r\n }\r\n\r\n this.options.xrInput.controllers.forEach(this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand);\r\n this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand);\r\n\r\n return true;\r\n }\r\n\r\n protected _onXRFrame(_xrFrame: XRFrame): void {\r\n this._trackingHands.left?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n this._trackingHands.right?.updateFromXRFrame(_xrFrame, this._xrSessionManager.referenceSpace);\r\n }\r\n\r\n private _attachHand = (xrController: WebXRInputSource) => {\r\n if (!xrController.inputSource.hand || xrController.inputSource.handedness == \"none\" || !this._handResources.jointMeshes) {\r\n return;\r\n }\r\n\r\n const handedness = xrController.inputSource.handedness;\r\n const webxrHand = new WebXRHand(\r\n xrController,\r\n this._handResources.jointMeshes[handedness],\r\n this._handResources.handMeshes && this._handResources.handMeshes[handedness],\r\n this._handResources.rigMappings && this._handResources.rigMappings[handedness],\r\n this.options.handMeshes?.meshesUseLeftHandedCoordinates,\r\n this.options.jointMeshes?.invisible,\r\n this.options.jointMeshes?.scaleFactor\r\n );\r\n\r\n this._attachedHands[xrController.uniqueId] = webxrHand;\r\n this._trackingHands[handedness] = webxrHand;\r\n\r\n this.onHandAddedObservable.notifyObservers(webxrHand);\r\n };\r\n\r\n private _detachHandById(controllerId: string) {\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();\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 detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n Object.keys(this._attachedHands).forEach((uniqueId) => this._detachHandById(uniqueId));\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 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 WebXRHandTracking._RightHandGLB = null;\r\n WebXRHandTracking._LeftHandGLB = null;\r\n }\r\n\r\n if (this._handResources.jointMeshes) {\r\n this._handResources.jointMeshes.left.forEach((trackedMesh) => trackedMesh.dispose());\r\n this._handResources.jointMeshes.right.forEach((trackedMesh) => trackedMesh.dispose());\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"]}
@@ -50,20 +50,32 @@ export declare class AssetContainer extends AbstractScene {
50
50
  * @param nameFunction defines an optional function used to get new names for clones
51
51
  * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
52
52
  * @param options defines an optional list of options to control how to instantiate / clone models
53
- * @param options.doNotInstantiate
53
+ * @param options.doNotInstantiate defines if the model must be instantiated or just cloned
54
+ * @param options.predicate defines a predicate used to filter whih mesh to instantiate/clone
54
55
  * @returns a list of rootNodes, skeletons and animation groups that were duplicated
55
56
  */
56
57
  instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean, options?: {
57
58
  doNotInstantiate: boolean;
59
+ predicate?: (entity: any) => boolean;
58
60
  }): InstantiatedEntries;
59
61
  /**
60
62
  * Adds all the assets from the container to the scene.
61
63
  */
62
64
  addAllToScene(): void;
65
+ /**
66
+ * Adds assets from the container to the scene.
67
+ * @param predicate defines a predicate used to select which entity will be added (can be null)
68
+ */
69
+ addToScene(predicate?: Nullable<(entity: any) => boolean>): void;
63
70
  /**
64
71
  * Removes all the assets in the container from the scene
65
72
  */
66
73
  removeAllFromScene(): void;
74
+ /**
75
+ * Removes assets in the container from the scene
76
+ * @param predicate defines a predicate used to select which entity will be added (can be null)
77
+ */
78
+ removeFromScene(predicate?: Nullable<(entity: any) => boolean>): void;
67
79
  /**
68
80
  * Disposes all the assets in the container
69
81
  */