three-stdlib 2.8.2 → 2.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/{BufferGeometryUtils-582025b8.js → BufferGeometryUtils-1a7a235c.js} +2 -1
  2. package/{BufferGeometryUtils-9eb5c2e7.js → BufferGeometryUtils-971dfde3.js} +0 -0
  3. package/animation/MMDAnimationHelper.d.ts +17 -17
  4. package/animation/MMDPhysics.d.ts +3 -3
  5. package/csm/CSM.d.ts +47 -22
  6. package/csm/CSMHelper.d.ts +20 -7
  7. package/effects/OutlineEffect.d.ts +4 -4
  8. package/effects/OutlineEffect.js +8 -2
  9. package/exporters/GLTFExporter.js +5 -10
  10. package/geometries/ConvexGeometry.d.ts +1 -1
  11. package/geometries/ParametricGeometries.d.ts +4 -2
  12. package/helpers/RectAreaLightHelper.d.ts +3 -3
  13. package/index.cjs.js +1 -1
  14. package/index.d.ts +9 -4
  15. package/index.js +9 -4
  16. package/libs/MotionControllers.cjs.js +1 -0
  17. package/libs/MotionControllers.js +403 -0
  18. package/loaders/AssimpLoader.js +39 -10
  19. package/loaders/ColladaLoader.js +22 -5
  20. package/loaders/EXRLoader.js +5 -1
  21. package/loaders/FBXLoader.js +10 -2
  22. package/loaders/GLTFLoader.cjs.js +1 -1
  23. package/loaders/GLTFLoader.d.ts +44 -20
  24. package/loaders/GLTFLoader.js +0 -1
  25. package/loaders/LDrawLoader.d.ts +6 -0
  26. package/loaders/MTLLoader.d.ts +18 -18
  27. package/loaders/RGBMLoader.d.ts +10 -10
  28. package/loaders/RGBMLoader.js +253 -178
  29. package/loaders/SVGLoader.d.ts +5 -3
  30. package/loaders/SVGLoader.js +10 -5
  31. package/loaders/lwo/IFFParser.js +4 -1
  32. package/math/OBB.d.ts +1 -1
  33. package/misc/GPUComputationRenderer.d.ts +8 -6
  34. package/misc/MD2CharacterComplex.js +9 -2
  35. package/misc/Volume.d.ts +2 -0
  36. package/modifiers/CurveModifier.cjs.js +1 -1
  37. package/modifiers/CurveModifier.js +1 -1
  38. package/modifiers/EdgeSplitModifier.cjs.js +1 -1
  39. package/modifiers/SimplifyModifier.cjs.js +1 -1
  40. package/nodes/inputs/ColorNode.d.ts +2 -2
  41. package/nodes/inputs/TextureNode.d.ts +3 -2
  42. package/nodes/materials/StandardNodeMaterial.d.ts +1 -1
  43. package/nodes/materials/nodes/StandardNode.d.ts +1 -0
  44. package/nodes/utils/ColorSpaceNode.d.ts +1 -1
  45. package/nodes/utils/JoinNode.d.ts +1 -0
  46. package/objects/MarchingCubes.d.ts +12 -4
  47. package/objects/Reflector.d.ts +4 -2
  48. package/objects/ReflectorForSSRPass.d.ts +6 -6
  49. package/objects/Refractor.d.ts +4 -2
  50. package/objects/Water.d.ts +4 -3
  51. package/objects/Water2.d.ts +12 -3
  52. package/package.json +2 -3
  53. package/postprocessing/ClearPass.d.ts +3 -3
  54. package/postprocessing/SAOPass.d.ts +3 -2
  55. package/postprocessing/SSAARenderPass.d.ts +3 -3
  56. package/postprocessing/SSAOPass.d.ts +3 -2
  57. package/postprocessing/SSRPass.d.ts +14 -17
  58. package/postprocessing/TAARenderPass.d.ts +2 -2
  59. package/renderers/CSS2DRenderer.d.ts +5 -1
  60. package/renderers/CSS3DRenderer.d.ts +5 -1
  61. package/renderers/webgpu/WebGPUTextures.js +62 -41
  62. package/shaders/SSRShader.d.ts +1 -2
  63. package/utils/BufferGeometryUtils.cjs.js +1 -1
  64. package/utils/BufferGeometryUtils.js +2 -1
  65. package/utils/LDrawUtils.cjs.js +1 -1
  66. package/utils/LDrawUtils.d.ts +5 -0
  67. package/utils/LDrawUtils.js +1 -1
  68. package/utils/RoughnessMipmapper.js +5 -1
  69. package/utils/SceneUtils.d.ts +10 -12
  70. package/utils/ShadowMapViewer.js +4 -1
  71. package/webxr/OculusHandModel.cjs.js +1 -0
  72. package/webxr/OculusHandModel.d.ts +19 -0
  73. package/webxr/OculusHandModel.js +72 -0
  74. package/webxr/OculusHandPointerModel.cjs.js +1 -0
  75. package/webxr/OculusHandPointerModel.d.ts +63 -0
  76. package/webxr/OculusHandPointerModel.js +248 -0
  77. package/webxr/Text2D.cjs.js +1 -0
  78. package/webxr/Text2D.d.ts +3 -0
  79. package/webxr/Text2D.js +32 -0
  80. package/webxr/VRButton.cjs.js +1 -1
  81. package/webxr/VRButton.js +17 -1
  82. package/webxr/XRControllerModelFactory.cjs.js +1 -1
  83. package/webxr/XRControllerModelFactory.js +65 -66
  84. package/webxr/XREstimatedLight.cjs.js +1 -1
  85. package/webxr/XREstimatedLight.js +1 -0
  86. package/webxr/XRHandMeshModel.cjs.js +1 -0
  87. package/webxr/XRHandMeshModel.d.ts +11 -0
  88. package/webxr/XRHandMeshModel.js +55 -0
  89. package/webxr/XRHandModelFactory.cjs.js +1 -1
  90. package/webxr/XRHandModelFactory.d.ts +3 -3
  91. package/webxr/XRHandModelFactory.js +47 -50
  92. package/webxr/XRHandPrimitiveModel.cjs.js +1 -1
  93. package/webxr/XRHandPrimitiveModel.d.ts +1 -1
  94. package/webxr/XRHandPrimitiveModel.js +31 -41
  95. package/csm/Frustum.d.ts +0 -16
  96. package/csm/Shader.d.ts +0 -6
  97. package/loaders/XLoader.d.ts +0 -19
  98. package/shaders/FresnelShader.d.ts +0 -13
  99. package/shaders/ParallaxShader.d.ts +0 -20
  100. package/utils/RoughnessMipmapper.d.ts +0 -7
  101. package/webxr/XRHandOculusMeshModel.cjs.js +0 -1
  102. package/webxr/XRHandOculusMeshModel.d.ts +0 -23
  103. package/webxr/XRHandOculusMeshModel.js +0 -89
@@ -0,0 +1,32 @@
1
+ import * as THREE from 'three';
2
+
3
+ function createText(message, height) {
4
+ const canvas = document.createElement('canvas');
5
+ const context = canvas.getContext('2d');
6
+ let metrics = null;
7
+ const textHeight = 100;
8
+ context.font = 'normal ' + textHeight + 'px Arial';
9
+ metrics = context.measureText(message);
10
+ const textWidth = metrics.width;
11
+ canvas.width = textWidth;
12
+ canvas.height = textHeight;
13
+ context.font = 'normal ' + textHeight + 'px Arial';
14
+ context.textAlign = 'center';
15
+ context.textBaseline = 'middle';
16
+ context.fillStyle = '#ffffff';
17
+ context.fillText(message, textWidth / 2, textHeight / 2);
18
+ const texture = new THREE.Texture(canvas);
19
+ texture.needsUpdate = true; //var spriteAlignment = new THREE.Vector2(0,0) ;
20
+
21
+ const material = new THREE.MeshBasicMaterial({
22
+ color: 0xffffff,
23
+ side: THREE.DoubleSide,
24
+ map: texture,
25
+ transparent: true
26
+ });
27
+ const geometry = new THREE.PlaneGeometry(height * textWidth / textHeight, height);
28
+ const plane = new THREE.Mesh(geometry, material);
29
+ return plane;
30
+ }
31
+
32
+ export { createText };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.VRButton=class{static createButton(e,t){t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const n=document.createElement("button");function o(){n.style.display="",n.style.cursor="auto",n.style.left="calc(50% - 75px)",n.style.width="150px",n.onmouseenter=null,n.onmouseleave=null,n.onclick=null,n.textContent="VR NOT SUPPORTED"}function s(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return n.id="VRButton",n.style.display="none",s(n),navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function o(o){o.addEventListener("end",s),await e.xr.setSession(o),n.textContent="EXIT VR",t=o}function s(){t.removeEventListener("end",s),n.textContent="ENTER VR",t=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(50% - 50px)",n.style.width="100px",n.textContent="ENTER VR",n.onmouseenter=function(){n.style.opacity="1.0"},n.onmouseleave=function(){n.style.opacity="0.5"},n.onclick=function(){if(null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking"]};navigator.xr.requestSession("immersive-vr",e).then(o)}else t.end()}}():o()})),n;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",s(e),e}}};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@babel/runtime/helpers/defineProperty"));class n{static createButton(e,t){t&&console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');const o=document.createElement("button");function s(){o.style.display="",o.style.cursor="auto",o.style.left="calc(50% - 75px)",o.style.width="150px",o.onmouseenter=null,o.onmouseleave=null,o.onclick=null,o.textContent="VR NOT SUPPORTED"}function r(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if("xr"in navigator)return o.id="VRButton",o.style.display="none",r(o),navigator.xr.isSessionSupported("immersive-vr").then((function(t){t?function(){let t=null;async function n(n){n.addEventListener("end",s),await e.xr.setSession(n),o.textContent="EXIT VR",t=n}function s(){t.removeEventListener("end",s),o.textContent="ENTER VR",t=null}o.style.display="",o.style.cursor="pointer",o.style.left="calc(50% - 50px)",o.style.width="100px",o.textContent="ENTER VR",o.onmouseenter=function(){o.style.opacity="1.0"},o.onmouseleave=function(){o.style.opacity="0.5"},o.onclick=function(){if(null===t){const e={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};navigator.xr.requestSession("immersive-vr",e).then(n)}else t.end()}}():s(),t&&n.xrSessionIsGranted&&o.click()})),o;{const e=document.createElement("a");return!1===window.isSecureContext?(e.href=document.location.href.replace(/^http:/,"https:"),e.innerHTML="WEBXR NEEDS HTTPS"):(e.href="https://immersiveweb.dev/",e.innerHTML="WEBXR NOT AVAILABLE"),e.style.left="calc(50% - 90px)",e.style.width="180px",e.style.textDecoration="none",r(e),e}}static registerSessionGrantedListener(){"xr"in navigator&&navigator.xr.addEventListener("sessiongranted",(()=>{n.xrSessionIsGranted=!0}))}}t.default(n,"xrSessionIsGranted",!1),exports.VRButton=n;
package/webxr/VRButton.js CHANGED
@@ -1,3 +1,5 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+
1
3
  class VRButton {
2
4
  static createButton(renderer, options) {
3
5
  if (options) {
@@ -50,7 +52,7 @@ class VRButton {
50
52
  // ('local' is always available for immersive sessions and doesn't need to
51
53
  // be requested separately.)
52
54
  const sessionInit = {
53
- optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking']
55
+ optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking', 'layers']
54
56
  };
55
57
  navigator.xr.requestSession('immersive-vr', sessionInit).then(onSessionStarted);
56
58
  } else {
@@ -95,6 +97,10 @@ class VRButton {
95
97
  stylizeElement(button);
96
98
  navigator.xr.isSessionSupported('immersive-vr').then(function (supported) {
97
99
  supported ? showEnterVR() : showWebXRNotFound();
100
+
101
+ if (supported && VRButton.xrSessionIsGranted) {
102
+ button.click();
103
+ }
98
104
  });
99
105
  return button;
100
106
  } else {
@@ -116,6 +122,16 @@ class VRButton {
116
122
  }
117
123
  }
118
124
 
125
+ static registerSessionGrantedListener() {
126
+ if ('xr' in navigator) {
127
+ navigator.xr.addEventListener('sessiongranted', () => {
128
+ VRButton.xrSessionIsGranted = true;
129
+ });
130
+ }
131
+ }
132
+
119
133
  }
120
134
 
135
+ _defineProperty(VRButton, "xrSessionIsGranted", false);
136
+
121
137
  export { VRButton };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../loaders/GLTFLoader.cjs.js"),o=require("@webxr-input-profiles/motion-controllers");function n(){e.Object3D.call(this),this.motionController=null,this.envMap=null}function r(t,n){!function(t,n){Object.values(t.components).forEach((t=>{const{type:r,touchPointNodeName:s,visualResponses:a}=t;if(r===o.Constants.ComponentType.TOUCHPAD)if(t.touchPointNode=n.getObjectByName(s),t.touchPointNode){const o=new e.SphereGeometry(.001),n=new e.MeshBasicMaterial({color:255}),r=new e.Mesh(o,n);t.touchPointNode.add(r)}else console.warn(`Could not find touch dot, ${t.touchPointNodeName}, in touchpad component ${t.id}`);Object.values(a).forEach((e=>{const{valueNodeName:t,minNodeName:r,maxNodeName:s,valueNodeProperty:a}=e;if(a===o.Constants.VisualResponseProperty.TRANSFORM){if(e.minNode=n.getObjectByName(r),e.maxNode=n.getObjectByName(s),!e.minNode)return void console.warn(`Could not find ${r} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${s} in the model`)}e.valueNode=n.getObjectByName(t),e.valueNode||console.warn(`Could not find ${t} in the model`)}))}))}(t.motionController,n),t.envMap&&n.traverse((e=>{e.isMesh&&(e.material.envMap=t.envMap,e.material.needsUpdate=!0)})),t.add(n)}n.prototype=Object.assign(Object.create(e.Object3D.prototype),{constructor:n,setEnvironmentMap:function(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this},updateMatrixWorld:function(t){e.Object3D.prototype.updateMatrixWorld.call(this,t),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((t=>{Object.values(t.visualResponses).forEach((t=>{const{valueNode:n,minNode:r,maxNode:s,value:a,valueNodeProperty:i}=t;n&&(i===o.Constants.VisualResponseProperty.VISIBILITY?n.visible=a:i===o.Constants.VisualResponseProperty.TRANSFORM&&(e.Quaternion.slerp(r.quaternion,s.quaternion,n.quaternion,a),n.position.lerpVectors(r.position,s.position,a)))}))})))}});var s=function(){function e(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new t.GLTFLoader)}return e.prototype={constructor:e,createControllerModel:function(e){const t=new n;let s=null;return e.addEventListener("connected",(e=>{const n=e.data;"tracked-pointer"===n.targetRayMode&&n.gamepad&&o.fetchProfile(n,this.path,"generic-trigger").then((({profile:e,assetPath:a})=>{t.motionController=new o.MotionController(n,e,a);const i=this._assetCache[t.motionController.assetUrl];if(i)s=i.scene.clone(),r(t,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,(e=>{this._assetCache[t.motionController.assetUrl]=e,s=e.scene.clone(),r(t,s)}),null,(()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{t.motionController=null,t.remove(s),s=null})),t}},e}();exports.XRControllerModelFactory=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),o=require("../loaders/GLTFLoader.cjs.js"),t=require("../libs/MotionControllers.cjs.js");class n extends e.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e||(this.envMap=e,this.traverse((e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}))),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach((e=>{Object.values(e.visualResponses).forEach((e=>{const{valueNode:o,minNode:n,maxNode:r,value:s,valueNodeProperty:a}=e;o&&(a===t.MotionControllerConstants.VisualResponseProperty.VISIBILITY?o.visible=s:a===t.MotionControllerConstants.VisualResponseProperty.TRANSFORM&&(o.quaternion.slerpQuaternions(n.quaternion,r.quaternion,s),o.position.lerpVectors(n.position,r.position,s)))}))})))}}function r(o,n){!function(o,n){Object.values(o.components).forEach((o=>{const{type:r,touchPointNodeName:s,visualResponses:a}=o;if(r===t.MotionControllerConstants.ComponentType.TOUCHPAD)if(o.touchPointNode=n.getObjectByName(s),o.touchPointNode){const t=new e.SphereGeometry(.001),n=new e.MeshBasicMaterial({color:255}),r=new e.Mesh(t,n);o.touchPointNode.add(r)}else console.warn(`Could not find touch dot, ${o.touchPointNodeName}, in touchpad component ${o.id}`);Object.values(a).forEach((e=>{const{valueNodeName:o,minNodeName:r,maxNodeName:s,valueNodeProperty:a}=e;if(a===t.MotionControllerConstants.VisualResponseProperty.TRANSFORM){if(e.minNode=n.getObjectByName(r),e.maxNode=n.getObjectByName(s),!e.minNode)return void console.warn(`Could not find ${r} in the model`);if(!e.maxNode)return void console.warn(`Could not find ${s} in the model`)}e.valueNode=n.getObjectByName(o),e.valueNode||console.warn(`Could not find ${o} in the model`)}))}))}(o.motionController,n),o.envMap&&n.traverse((e=>{e.isMesh&&(e.material.envMap=o.envMap,e.material.needsUpdate=!0)})),o.add(n)}exports.XRControllerModelFactory=class{constructor(e=null){this.gltfLoader=e,this.path="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",this._assetCache={},this.gltfLoader||(this.gltfLoader=new o.GLTFLoader)}createControllerModel(e){const o=new n;let s=null;return e.addEventListener("connected",(e=>{const n=e.data;"tracked-pointer"===n.targetRayMode&&n.gamepad&&t.fetchProfile(n,this.path,"generic-trigger").then((({profile:e,assetPath:a})=>{o.motionController=new t.MotionController(n,e,a);const l=this._assetCache[o.motionController.assetUrl];if(l)s=l.scene.clone(),r(o,s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(o.motionController.assetUrl,(e=>{this._assetCache[o.motionController.assetUrl]=e,s=e.scene.clone(),r(o,s)}),null,(()=>{throw new Error(`Asset ${o.motionController.assetUrl} missing or malformed.`)}))}})).catch((e=>{console.warn(e)}))})),e.addEventListener("disconnected",(()=>{o.motionController=null,o.remove(s),s=null})),o}};
@@ -1,19 +1,18 @@
1
- import { Object3D, Quaternion, SphereGeometry, MeshBasicMaterial, Mesh } from 'three';
1
+ import { Object3D, SphereGeometry, MeshBasicMaterial, Mesh } from 'three';
2
2
  import { GLTFLoader } from '../loaders/GLTFLoader.js';
3
- import { Constants, fetchProfile, MotionController } from '@webxr-input-profiles/motion-controllers';
3
+ import { fetchProfile, MotionController, MotionControllerConstants } from '../libs/MotionControllers.js';
4
4
 
5
5
  const DEFAULT_PROFILES_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles';
6
6
  const DEFAULT_PROFILE = 'generic-trigger';
7
7
 
8
- function XRControllerModel() {
9
- Object3D.call(this);
10
- this.motionController = null;
11
- this.envMap = null;
12
- }
8
+ class XRControllerModel extends Object3D {
9
+ constructor() {
10
+ super();
11
+ this.motionController = null;
12
+ this.envMap = null;
13
+ }
13
14
 
14
- XRControllerModel.prototype = Object.assign(Object.create(Object3D.prototype), {
15
- constructor: XRControllerModel,
16
- setEnvironmentMap: function (envMap) {
15
+ setEnvironmentMap(envMap) {
17
16
  if (this.envMap == envMap) {
18
17
  return this;
19
18
  }
@@ -26,14 +25,15 @@ XRControllerModel.prototype = Object.assign(Object.create(Object3D.prototype), {
26
25
  }
27
26
  });
28
27
  return this;
29
- },
30
-
28
+ }
31
29
  /**
32
30
  * Polls data from the XRInputSource and updates the model's components to match
33
31
  * the real world data
34
32
  */
35
- updateMatrixWorld: function (force) {
36
- Object3D.prototype.updateMatrixWorld.call(this, force);
33
+
34
+
35
+ updateMatrixWorld(force) {
36
+ super.updateMatrixWorld(force);
37
37
  if (!this.motionController) return; // Cause the MotionController to poll the Gamepad for data
38
38
 
39
39
  this.motionController.updateFromGamepad(); // Update the 3D model to reflect the button, thumbstick, and touchpad state
@@ -52,22 +52,24 @@ XRControllerModel.prototype = Object.assign(Object.create(Object3D.prototype), {
52
52
 
53
53
  if (!valueNode) return; // Calculate the new properties based on the weight supplied
54
54
 
55
- if (valueNodeProperty === Constants.VisualResponseProperty.VISIBILITY) {
55
+ if (valueNodeProperty === MotionControllerConstants.VisualResponseProperty.VISIBILITY) {
56
56
  valueNode.visible = value;
57
- } else if (valueNodeProperty === Constants.VisualResponseProperty.TRANSFORM) {
58
- Quaternion.slerp(minNode.quaternion, maxNode.quaternion, valueNode.quaternion, value);
57
+ } else if (valueNodeProperty === MotionControllerConstants.VisualResponseProperty.TRANSFORM) {
58
+ valueNode.quaternion.slerpQuaternions(minNode.quaternion, maxNode.quaternion, value);
59
59
  valueNode.position.lerpVectors(minNode.position, maxNode.position, value);
60
60
  }
61
61
  });
62
62
  });
63
63
  }
64
- });
64
+
65
+ }
65
66
  /**
66
67
  * Walks the model's tree to find the nodes needed to animate the components and
67
68
  * saves them to the motionContoller components for use in the frame loop. When
68
69
  * touchpads are found, attaches a touch dot to them.
69
70
  */
70
71
 
72
+
71
73
  function findNodes(motionController, scene) {
72
74
  // Loop through the components and find the nodes needed for each components' visual responses
73
75
  Object.values(motionController.components).forEach(component => {
@@ -77,7 +79,7 @@ function findNodes(motionController, scene) {
77
79
  visualResponses
78
80
  } = component;
79
81
 
80
- if (type === Constants.ComponentType.TOUCHPAD) {
82
+ if (type === MotionControllerConstants.ComponentType.TOUCHPAD) {
81
83
  component.touchPointNode = scene.getObjectByName(touchPointNodeName);
82
84
 
83
85
  if (component.touchPointNode) {
@@ -102,7 +104,7 @@ function findNodes(motionController, scene) {
102
104
  valueNodeProperty
103
105
  } = visualResponse; // If animating a transform, find the two nodes to be interpolated between.
104
106
 
105
- if (valueNodeProperty === Constants.VisualResponseProperty.TRANSFORM) {
107
+ if (valueNodeProperty === MotionControllerConstants.VisualResponseProperty.TRANSFORM) {
106
108
  visualResponse.minNode = scene.getObjectByName(minNodeName);
107
109
  visualResponse.maxNode = scene.getObjectByName(maxNodeName); // If the extents cannot be found, skip this animation
108
110
 
@@ -144,8 +146,8 @@ function addAssetSceneToControllerModel(controllerModel, scene) {
144
146
  controllerModel.add(scene);
145
147
  }
146
148
 
147
- var XRControllerModelFactory = function () {
148
- function XRControllerModelFactory(gltfLoader = null) {
149
+ class XRControllerModelFactory {
150
+ constructor(gltfLoader = null) {
149
151
  this.gltfLoader = gltfLoader;
150
152
  this.path = DEFAULT_PROFILES_PATH;
151
153
  this._assetCache = {}; // If a GLTFLoader wasn't supplied to the constructor create a new one.
@@ -155,51 +157,48 @@ var XRControllerModelFactory = function () {
155
157
  }
156
158
  }
157
159
 
158
- XRControllerModelFactory.prototype = {
159
- constructor: XRControllerModelFactory,
160
- createControllerModel: function (controller) {
161
- const controllerModel = new XRControllerModel();
162
- let scene = null;
163
- controller.addEventListener('connected', event => {
164
- const xrInputSource = event.data;
165
- if (xrInputSource.targetRayMode !== 'tracked-pointer' || !xrInputSource.gamepad) return;
166
- fetchProfile(xrInputSource, this.path, DEFAULT_PROFILE).then(({
167
- profile,
168
- assetPath
169
- }) => {
170
- controllerModel.motionController = new MotionController(xrInputSource, profile, assetPath);
171
- const cachedAsset = this._assetCache[controllerModel.motionController.assetUrl];
172
-
173
- if (cachedAsset) {
174
- scene = cachedAsset.scene.clone();
175
- addAssetSceneToControllerModel(controllerModel, scene);
176
- } else {
177
- if (!this.gltfLoader) {
178
- throw new Error('GLTFLoader not set.');
179
- }
180
-
181
- this.gltfLoader.setPath('');
182
- this.gltfLoader.load(controllerModel.motionController.assetUrl, asset => {
183
- this._assetCache[controllerModel.motionController.assetUrl] = asset;
184
- scene = asset.scene.clone();
185
- addAssetSceneToControllerModel(controllerModel, scene);
186
- }, null, () => {
187
- throw new Error(`Asset ${controllerModel.motionController.assetUrl} missing or malformed.`);
188
- });
160
+ createControllerModel(controller) {
161
+ const controllerModel = new XRControllerModel();
162
+ let scene = null;
163
+ controller.addEventListener('connected', event => {
164
+ const xrInputSource = event.data;
165
+ if (xrInputSource.targetRayMode !== 'tracked-pointer' || !xrInputSource.gamepad) return;
166
+ fetchProfile(xrInputSource, this.path, DEFAULT_PROFILE).then(({
167
+ profile,
168
+ assetPath
169
+ }) => {
170
+ controllerModel.motionController = new MotionController(xrInputSource, profile, assetPath);
171
+ const cachedAsset = this._assetCache[controllerModel.motionController.assetUrl];
172
+
173
+ if (cachedAsset) {
174
+ scene = cachedAsset.scene.clone();
175
+ addAssetSceneToControllerModel(controllerModel, scene);
176
+ } else {
177
+ if (!this.gltfLoader) {
178
+ throw new Error('GLTFLoader not set.');
189
179
  }
190
- }).catch(err => {
191
- console.warn(err);
192
- });
193
- });
194
- controller.addEventListener('disconnected', () => {
195
- controllerModel.motionController = null;
196
- controllerModel.remove(scene);
197
- scene = null;
180
+
181
+ this.gltfLoader.setPath('');
182
+ this.gltfLoader.load(controllerModel.motionController.assetUrl, asset => {
183
+ this._assetCache[controllerModel.motionController.assetUrl] = asset;
184
+ scene = asset.scene.clone();
185
+ addAssetSceneToControllerModel(controllerModel, scene);
186
+ }, null, () => {
187
+ throw new Error(`Asset ${controllerModel.motionController.assetUrl} missing or malformed.`);
188
+ });
189
+ }
190
+ }).catch(err => {
191
+ console.warn(err);
198
192
  });
199
- return controllerModel;
200
- }
201
- };
202
- return XRControllerModelFactory;
203
- }();
193
+ });
194
+ controller.addEventListener('disconnected', () => {
195
+ controllerModel.motionController = null;
196
+ controllerModel.remove(scene);
197
+ scene = null;
198
+ });
199
+ return controllerModel;
200
+ }
201
+
202
+ }
204
203
 
205
204
  export { XRControllerModelFactory };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class i{constructor(i,e,n,s,r){this.xrLight=i,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const h=e.xr.getSession();if(s&&"XRWebGLBinding"in window){const n=new t.WebGLCubeRenderTarget(16);i.environment=n.texture;const s=e.getContext();switch(h.preferredReflectionFormat){case"srgba8":s.getExtension("EXT_sRGB");break;case"rgba16f":s.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(h,s),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}h.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const i=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);i&&(t.__webglTexture=i)}}onXRFrame(t,i){if(!this.xrLight)return;i.session.requestAnimationFrame(this.frameCallback);const e=i.getLightEstimate(this.lightProbe);if(e){this.xrLight.lightProbe.sh.fromArray(e.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(e.primaryLightIntensity.x,Math.max(e.primaryLightIntensity.y,e.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(e.primaryLightIntensity.x/t,e.primaryLightIntensity.y/t,e.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(e.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class e extends t.Group{constructor(e,n=!0){super(),this.lightProbe=new t.LightProbe,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new t.DirectionalLight,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let s=null,r=!1;e.xr.addEventListener("sessionstart",(()=>{const t=e.xr.getSession();"requestLightProbe"in t&&t.requestLightProbe({reflectionFormat:t.preferredReflectionFormat}).then((t=>{s=new i(this,e,t,n,(()=>{r=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),e.xr.addEventListener("sessionend",(()=>{s&&(s.dispose(),s=null),r&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{s&&(s.dispose(),s=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}exports.XREstimatedLight=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class i{constructor(i,e,n,s,r){this.xrLight=i,this.renderer=e,this.lightProbe=n,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const h=e.xr.getSession();if(s&&"XRWebGLBinding"in window){const n=new t.WebGLCubeRenderTarget(16);i.environment=n.texture;const s=e.getContext();switch(h.preferredReflectionFormat){case"srgba8":s.getExtension("EXT_sRGB");break;case"rgba16f":s.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(h,s),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}h.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const i=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);i&&(t.__webglTexture=i,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,i){if(!this.xrLight)return;i.session.requestAnimationFrame(this.frameCallback);const e=i.getLightEstimate(this.lightProbe);if(e){this.xrLight.lightProbe.sh.fromArray(e.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(e.primaryLightIntensity.x,Math.max(e.primaryLightIntensity.y,e.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(e.primaryLightIntensity.x/t,e.primaryLightIntensity.y/t,e.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(e.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class e extends t.Group{constructor(e,n=!0){super(),this.lightProbe=new t.LightProbe,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new t.DirectionalLight,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let s=null,r=!1;e.xr.addEventListener("sessionstart",(()=>{const t=e.xr.getSession();"requestLightProbe"in t&&t.requestLightProbe({reflectionFormat:t.preferredReflectionFormat}).then((t=>{s=new i(this,e,t,n,(()=>{r=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),e.xr.addEventListener("sessionend",(()=>{s&&(s.dispose(),s=null),r&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{s&&(s.dispose(),s=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}exports.XREstimatedLight=e;
@@ -46,6 +46,7 @@ class SessionLightProbe {
46
46
 
47
47
  if (cubeMap) {
48
48
  textureProperties.__webglTexture = cubeMap;
49
+ this.xrLight.environment.needsPMREMUpdate = true;
49
50
  }
50
51
  }
51
52
  }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../loaders/GLTFLoader.cjs.js");require("three");exports.XRHandMeshModel=class{constructor(i,n,a,t){this.controller=n,this.handModel=i,this.bones=[];const r=new e.GLTFLoader;r.setPath(a||"https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/"),r.load(`${t}.glb`,(e=>{const i=e.scene.children[0];this.handModel.add(i);const n=i.getObjectByProperty("type","SkinnedMesh");n.frustumCulled=!1,n.castShadow=!0,n.receiveShadow=!0;["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"].forEach((e=>{const n=i.getObjectByName(e);void 0!==n?n.jointName=e:console.warn(`Couldn't find ${e} in ${t} hand mesh`),this.bones.push(n)}))}))}updateMesh(){const e=this.controller.joints;for(let i=0;i<this.bones.length;i++){const n=this.bones[i];if(n){const i=e[n.jointName];if(i.visible){const e=i.position;n.position.copy(e),n.quaternion.copy(i.quaternion)}}}}};
@@ -0,0 +1,11 @@
1
+ import { Object3D } from 'three';
2
+
3
+ export class XRHandMeshModel {
4
+ controller: Object3D;
5
+ handModel: Object3D;
6
+ bones: Object3D[];
7
+
8
+ constructor(handModel: Object3D, controller: Object3D, path: string, handedness: string);
9
+
10
+ updateMesh(): void;
11
+ }
@@ -0,0 +1,55 @@
1
+ import { GLTFLoader } from '../loaders/GLTFLoader.js';
2
+
3
+ const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/';
4
+
5
+ class XRHandMeshModel {
6
+ constructor(handModel, controller, path, handedness) {
7
+ this.controller = controller;
8
+ this.handModel = handModel;
9
+ this.bones = [];
10
+ const loader = new GLTFLoader();
11
+ loader.setPath(path || DEFAULT_HAND_PROFILE_PATH);
12
+ loader.load(`${handedness}.glb`, gltf => {
13
+ const object = gltf.scene.children[0];
14
+ this.handModel.add(object);
15
+ const mesh = object.getObjectByProperty('type', 'SkinnedMesh');
16
+ mesh.frustumCulled = false;
17
+ mesh.castShadow = true;
18
+ mesh.receiveShadow = true;
19
+ const joints = ['wrist', 'thumb-metacarpal', 'thumb-phalanx-proximal', 'thumb-phalanx-distal', 'thumb-tip', 'index-finger-metacarpal', 'index-finger-phalanx-proximal', 'index-finger-phalanx-intermediate', 'index-finger-phalanx-distal', 'index-finger-tip', 'middle-finger-metacarpal', 'middle-finger-phalanx-proximal', 'middle-finger-phalanx-intermediate', 'middle-finger-phalanx-distal', 'middle-finger-tip', 'ring-finger-metacarpal', 'ring-finger-phalanx-proximal', 'ring-finger-phalanx-intermediate', 'ring-finger-phalanx-distal', 'ring-finger-tip', 'pinky-finger-metacarpal', 'pinky-finger-phalanx-proximal', 'pinky-finger-phalanx-intermediate', 'pinky-finger-phalanx-distal', 'pinky-finger-tip'];
20
+ joints.forEach(jointName => {
21
+ const bone = object.getObjectByName(jointName);
22
+
23
+ if (bone !== undefined) {
24
+ bone.jointName = jointName;
25
+ } else {
26
+ console.warn(`Couldn't find ${jointName} in ${handedness} hand mesh`);
27
+ }
28
+
29
+ this.bones.push(bone);
30
+ });
31
+ });
32
+ }
33
+
34
+ updateMesh() {
35
+ // XR Joints
36
+ const XRJoints = this.controller.joints;
37
+
38
+ for (let i = 0; i < this.bones.length; i++) {
39
+ const bone = this.bones[i];
40
+
41
+ if (bone) {
42
+ const XRJoint = XRJoints[bone.jointName];
43
+
44
+ if (XRJoint.visible) {
45
+ const position = XRJoint.position;
46
+ bone.position.copy(position);
47
+ bone.quaternion.copy(XRJoint.quaternion); // bone.scale.setScalar( XRJoint.jointRadius || defaultRadius );
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ }
54
+
55
+ export { XRHandMeshModel };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./XRHandPrimitiveModel.cjs.js"),o=require("./XRHandOculusMeshModel.cjs.js");function r(t){e.Object3D.call(this),this.controller=t,this.motionController=null,this.envMap=null,this.mesh=null}require("../loaders/FBXLoader.cjs.js"),require("fflate"),require("../curves/NURBSCurve.cjs.js"),require("../curves/NURBSUtils.cjs.js"),r.prototype=Object.assign(Object.create(e.Object3D.prototype),{constructor:r,updateMatrixWorld:function(t){e.Object3D.prototype.updateMatrixWorld.call(this,t),this.motionController&&this.motionController.updateMesh()}});const n=function(){function e(){this.path=""}return e.prototype={constructor:e,setPath:function(e){return this.path=e,this},createHandModel:function(e,n,s){const i=new r(e);return e.addEventListener("connected",(r=>{const l=r.data;l.hand&&!i.motionController&&(i.visible=!0,i.xrInputSource=l,void 0===n||"spheres"===n?i.motionController=new t.XRHandPrimitiveModel(i,e,this.path,l.handedness,{primitive:"sphere"}):"boxes"===n?i.motionController=new t.XRHandPrimitiveModel(i,e,this.path,l.handedness,{primitive:"box"}):"oculus"===n&&(i.motionController=new o.XRHandOculusMeshModel(i,e,this.path,l.handedness,s)))})),e.addEventListener("disconnected",(()=>{})),i}},e}();exports.XRHandModelFactory=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./XRHandPrimitiveModel.cjs.js"),r=require("./XRHandMeshModel.cjs.js");require("../loaders/GLTFLoader.cjs.js");class o extends e.Object3D{constructor(e){super(),this.controller=e,this.motionController=null,this.envMap=null,this.mesh=null}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&this.motionController.updateMesh()}}exports.XRHandModelFactory=class{constructor(){this.path=null}setPath(e){return this.path=e,this}createHandModel(e,n){const s=new o(e);return e.addEventListener("connected",(o=>{const i=o.data;i.hand&&!s.motionController&&(s.xrInputSource=i,void 0===n||"spheres"===n?s.motionController=new t.XRHandPrimitiveModel(s,e,this.path,i.handedness,{primitive:"sphere"}):"boxes"===n?s.motionController=new t.XRHandPrimitiveModel(s,e,this.path,i.handedness,{primitive:"box"}):"mesh"===n&&(s.motionController=new r.XRHandMeshModel(s,e,this.path,i.handedness)))})),e.addEventListener("disconnected",(()=>{})),s}};
@@ -1,14 +1,14 @@
1
1
  import { Group, Object3D } from 'three';
2
2
 
3
3
  import { XRHandPrimitiveModel, XRHandPrimitiveModelOptions } from './XRHandPrimitiveModel';
4
- import { XRHandOculusMeshModel, XRHandOculusMeshModelOptions } from './XRHandOculusMeshModel';
4
+ import { XRHandMeshModel } from './XRHandMeshModel';
5
5
 
6
6
  export type XRHandModelHandedness = 'left' | 'right';
7
7
 
8
8
  export class XRHandModel extends Object3D {
9
9
  constructor();
10
10
 
11
- motionController: XRHandPrimitiveModel | XRHandOculusMeshModel;
11
+ motionController: XRHandPrimitiveModel | XRHandMeshModel;
12
12
  }
13
13
 
14
14
  export class XRHandModelFactory {
@@ -20,6 +20,6 @@ export class XRHandModelFactory {
20
20
  createHandModel(
21
21
  controller: Group,
22
22
  profile?: 'spheres' | 'boxes' | 'oculus',
23
- options?: XRHandPrimitiveModelOptions | XRHandOculusMeshModelOptions,
23
+ options?: XRHandPrimitiveModelOptions,
24
24
  ): XRHandModel;
25
25
  }
@@ -1,67 +1,64 @@
1
1
  import { Object3D } from 'three';
2
2
  import { XRHandPrimitiveModel } from './XRHandPrimitiveModel.js';
3
- import { XRHandOculusMeshModel } from './XRHandOculusMeshModel.js';
3
+ import { XRHandMeshModel } from './XRHandMeshModel.js';
4
4
 
5
- function XRHandModel(controller) {
6
- Object3D.call(this);
7
- this.controller = controller;
8
- this.motionController = null;
9
- this.envMap = null;
10
- this.mesh = null;
11
- }
5
+ class XRHandModel extends Object3D {
6
+ constructor(controller) {
7
+ super();
8
+ this.controller = controller;
9
+ this.motionController = null;
10
+ this.envMap = null;
11
+ this.mesh = null;
12
+ }
12
13
 
13
- XRHandModel.prototype = Object.assign(Object.create(Object3D.prototype), {
14
- constructor: XRHandModel,
15
- updateMatrixWorld: function (force) {
16
- Object3D.prototype.updateMatrixWorld.call(this, force);
14
+ updateMatrixWorld(force) {
15
+ super.updateMatrixWorld(force);
17
16
 
18
17
  if (this.motionController) {
19
18
  this.motionController.updateMesh();
20
19
  }
21
20
  }
22
- });
23
21
 
24
- const XRHandModelFactory = function () {
25
- function XRHandModelFactory() {
26
- this.path = '';
22
+ }
23
+
24
+ class XRHandModelFactory {
25
+ constructor() {
26
+ this.path = null;
27
+ }
28
+
29
+ setPath(path) {
30
+ this.path = path;
31
+ return this;
27
32
  }
28
33
 
29
- XRHandModelFactory.prototype = {
30
- constructor: XRHandModelFactory,
31
- setPath: function (path) {
32
- this.path = path;
33
- return this;
34
- },
35
- createHandModel: function (controller, profile, options) {
36
- const handModel = new XRHandModel(controller);
37
- controller.addEventListener('connected', event => {
38
- const xrInputSource = event.data;
34
+ createHandModel(controller, profile) {
35
+ const handModel = new XRHandModel(controller);
36
+ controller.addEventListener('connected', event => {
37
+ const xrInputSource = event.data;
39
38
 
40
- if (xrInputSource.hand && !handModel.motionController) {
41
- handModel.visible = true;
42
- handModel.xrInputSource = xrInputSource; // @todo Detect profile if not provided
39
+ if (xrInputSource.hand && !handModel.motionController) {
40
+ handModel.xrInputSource = xrInputSource; // @todo Detect profile if not provided
43
41
 
44
- if (profile === undefined || profile === 'spheres') {
45
- handModel.motionController = new XRHandPrimitiveModel(handModel, controller, this.path, xrInputSource.handedness, {
46
- primitive: 'sphere'
47
- });
48
- } else if (profile === 'boxes') {
49
- handModel.motionController = new XRHandPrimitiveModel(handModel, controller, this.path, xrInputSource.handedness, {
50
- primitive: 'box'
51
- });
52
- } else if (profile === 'oculus') {
53
- handModel.motionController = new XRHandOculusMeshModel(handModel, controller, this.path, xrInputSource.handedness, options);
54
- }
42
+ if (profile === undefined || profile === 'spheres') {
43
+ handModel.motionController = new XRHandPrimitiveModel(handModel, controller, this.path, xrInputSource.handedness, {
44
+ primitive: 'sphere'
45
+ });
46
+ } else if (profile === 'boxes') {
47
+ handModel.motionController = new XRHandPrimitiveModel(handModel, controller, this.path, xrInputSource.handedness, {
48
+ primitive: 'box'
49
+ });
50
+ } else if (profile === 'mesh') {
51
+ handModel.motionController = new XRHandMeshModel(handModel, controller, this.path, xrInputSource.handedness);
55
52
  }
56
- });
57
- controller.addEventListener('disconnected', () => {// handModel.motionController = null;
58
- // handModel.remove( scene );
59
- // scene = null;
60
- });
61
- return handModel;
62
- }
63
- };
64
- return XRHandModelFactory;
65
- }();
53
+ }
54
+ });
55
+ controller.addEventListener('disconnected', () => {// handModel.motionController = null;
56
+ // handModel.remove( scene );
57
+ // scene = null;
58
+ });
59
+ return handModel;
60
+ }
61
+
62
+ }
66
63
 
67
64
  export { XRHandModelFactory };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");exports.XRHandPrimitiveModel=class{constructor(i,n,a,r,t){if(this.controller=n,this.handModel=i,this.envMap=null,this.handMesh=new e.Group,this.handModel.add(this.handMesh),window.XRHand){let i;t&&t.primitive&&"sphere"!==t.primitive?"box"===t.primitive&&(i=new e.BoxGeometry(1,1,1)):i=new e.SphereGeometry(1,10,10);const n=new e.MeshStandardMaterial({color:16777215,roughness:1,metalness:0}),a=new e.MeshStandardMaterial({color:10066329,roughness:1,metalness:0}),r=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"];for(let t of r){var l=new e.Mesh(i,-1!==t.indexOf("tip")?a:n);l.castShadow=!0,l.receiveShadow=!0,l.jointName=t,this.handMesh.add(l)}}}updateMesh(){const e=this.handMesh.children,i=this.controller.joints;for(let n=0;n<e.length;n++){const a=e[n],r=i[a.jointName];r.visible&&(a.position.copy(r.position),a.quaternion.copy(r.quaternion),a.scale.setScalar(r.jointRadius||.008)),a.visible=r.visible}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const i=new e.Matrix4,n=new e.Vector3;exports.XRHandPrimitiveModel=class{constructor(i,n,a,t,r){let s;this.controller=n,this.handModel=i,this.envMap=null,r&&r.primitive&&"sphere"!==r.primitive?"box"===r.primitive&&(s=new e.BoxGeometry(1,1,1)):s=new e.SphereGeometry(1,10,10);const h=new e.MeshStandardMaterial;this.handMesh=new e.InstancedMesh(s,h,30),this.handMesh.instanceMatrix.setUsage(e.DynamicDrawUsage),this.handMesh.castShadow=!0,this.handMesh.receiveShadow=!0,this.handModel.add(this.handMesh),this.joints=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"]}updateMesh(){const e=this.controller.joints;let a=0;for(let t=0;t<this.joints.length;t++){const r=e[this.joints[t]];r.visible&&(n.setScalar(r.jointRadius||.008),i.compose(r.position,r.quaternion,n),this.handMesh.setMatrixAt(t,i),a++)}this.handMesh.count=a,this.handMesh.instanceMatrix.needsUpdate=!0}};
@@ -3,7 +3,7 @@ import { Group, Texture } from 'three';
3
3
  import { XRHandModel, XRHandModelHandedness } from './XRHandModelFactory';
4
4
 
5
5
  export interface XRHandPrimitiveModelOptions {
6
- primitive?: 'sphere' | 'box';
6
+ primitive?: 'sphere' | 'box' | undefined;
7
7
  }
8
8
 
9
9
  export class XRHandPrimitiveModel {