three-stdlib 2.10.3 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs.js +1 -1
- package/package.json +1 -1
- package/webxr/ARButton.cjs.js +1 -1
- package/webxr/ARButton.d.ts +4 -4
- package/webxr/ARButton.js +14 -11
- package/webxr/OculusHandModel.cjs.js +1 -1
- package/webxr/OculusHandModel.d.ts +15 -12
- package/webxr/OculusHandModel.js +22 -4
- package/webxr/VRButton.cjs.js +1 -1
- package/webxr/VRButton.d.ts +6 -4
- package/webxr/VRButton.js +14 -15
- package/webxr/XRHandMeshModel.cjs.js +1 -1
- package/webxr/XRHandMeshModel.d.ts +3 -5
- package/webxr/XRHandMeshModel.js +10 -3
- package/webxr/XRHandModelFactory.cjs.js +1 -1
package/package.json
CHANGED
package/webxr/ARButton.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.ARButton=class{static createButton(e,t={}){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="AR 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="ARButton",n.style.display="none",s(n),navigator.xr.isSessionSupported("immersive-ar").then((function(s){s?function(){if(void 0===t.domOverlay){
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.ARButton=class{static createButton(e,t={}){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="AR 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="ARButton",n.style.display="none",s(n),navigator.xr.isSessionSupported("immersive-ar").then((function(s){s?function(){if(void 0===t.domOverlay){const e=document.createElement("div");e.style.display="none",document.body.appendChild(e);const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","38px"),n.setAttribute("height","38px"),n.style.position="absolute",n.style.right="20px",n.style.top="20px",n.addEventListener("click",(function(){var e;null===(e=o)||void 0===e||e.end()})),e.appendChild(n);const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),s.setAttribute("stroke","#fff"),s.setAttribute("stroke-width","2px"),n.appendChild(s),void 0===t.optionalFeatures&&(t.optionalFeatures=[]),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:e}}let o=null;async function s(s){s.addEventListener("end",l),e.xr.setReferenceSpaceType("local"),await e.xr.setSession(s),n.textContent="STOP AR",t.domOverlay.root.style.display="",o=s}function l(){o.removeEventListener("end",l),n.textContent="START AR",t.domOverlay.root.style.display="none",o=null}n.style.display="",n.style.cursor="pointer",n.style.left="calc(50% - 50px)",n.style.width="100px",n.textContent="START AR",n.onmouseenter=()=>{n.style.opacity="1.0"},n.onmouseleave=()=>{n.style.opacity="0.5"},n.onclick=()=>{null===o?navigator.xr.requestSession("immersive-ar",t).then(s):o.end()}}():o()})).catch(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}}};
|
package/webxr/ARButton.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { WebGLRenderer } from 'three';
|
2
|
-
|
3
|
-
|
4
|
-
function createButton(renderer: WebGLRenderer, sessionInit?: any): HTMLElement;
|
1
|
+
import { WebGLRenderer, XRSessionInit } from 'three';
|
2
|
+
declare class ARButton {
|
3
|
+
static createButton(renderer: WebGLRenderer, sessionInit?: XRSessionInit): HTMLButtonElement | HTMLAnchorElement;
|
5
4
|
}
|
5
|
+
export { ARButton };
|
package/webxr/ARButton.js
CHANGED
@@ -6,23 +6,25 @@ class ARButton {
|
|
6
6
|
/*device*/
|
7
7
|
showStartAR() {
|
8
8
|
if (sessionInit.domOverlay === undefined) {
|
9
|
-
|
9
|
+
const overlay = document.createElement('div');
|
10
10
|
overlay.style.display = 'none';
|
11
11
|
document.body.appendChild(overlay);
|
12
|
-
|
13
|
-
svg.setAttribute('width',
|
14
|
-
svg.setAttribute('height',
|
12
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
13
|
+
svg.setAttribute('width', '38px');
|
14
|
+
svg.setAttribute('height', '38px');
|
15
15
|
svg.style.position = 'absolute';
|
16
16
|
svg.style.right = '20px';
|
17
17
|
svg.style.top = '20px';
|
18
18
|
svg.addEventListener('click', function () {
|
19
|
-
|
19
|
+
var _currentSession;
|
20
|
+
|
21
|
+
(_currentSession = currentSession) === null || _currentSession === void 0 ? void 0 : _currentSession.end();
|
20
22
|
});
|
21
23
|
overlay.appendChild(svg);
|
22
|
-
|
24
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
23
25
|
path.setAttribute('d', 'M 12,12 L 28,28 M 28,12 12,28');
|
24
26
|
path.setAttribute('stroke', '#fff');
|
25
|
-
path.setAttribute('stroke-width',
|
27
|
+
path.setAttribute('stroke-width', '2px');
|
26
28
|
svg.appendChild(path);
|
27
29
|
|
28
30
|
if (sessionInit.optionalFeatures === undefined) {
|
@@ -63,15 +65,15 @@ class ARButton {
|
|
63
65
|
button.style.width = '100px';
|
64
66
|
button.textContent = 'START AR';
|
65
67
|
|
66
|
-
button.onmouseenter =
|
68
|
+
button.onmouseenter = () => {
|
67
69
|
button.style.opacity = '1.0';
|
68
70
|
};
|
69
71
|
|
70
|
-
button.onmouseleave =
|
72
|
+
button.onmouseleave = () => {
|
71
73
|
button.style.opacity = '0.5';
|
72
74
|
};
|
73
75
|
|
74
|
-
button.onclick =
|
76
|
+
button.onclick = () => {
|
75
77
|
if (currentSession === null) {
|
76
78
|
navigator.xr.requestSession('immersive-ar', sessionInit).then(onSessionStarted);
|
77
79
|
} else {
|
@@ -113,7 +115,8 @@ class ARButton {
|
|
113
115
|
if ('xr' in navigator) {
|
114
116
|
button.id = 'ARButton';
|
115
117
|
button.style.display = 'none';
|
116
|
-
stylizeElement(button)
|
118
|
+
stylizeElement(button) // Query for session mode
|
119
|
+
;
|
117
120
|
navigator.xr.isSessionSupported('immersive-ar').then(function (supported) {
|
118
121
|
supported ? showStartAR() : showARNotSupported();
|
119
122
|
}).catch(showARNotSupported);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("three"),o=require("./XRHandMeshModel.cjs.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../loaders/GLTFLoader.cjs.js");var r=n(e);class s extends t.Object3D{constructor(e,t){super(),r.default(this,"controller",void 0),r.default(this,"motionController",void 0),r.default(this,"envMap",void 0),r.default(this,"mesh",void 0),r.default(this,"xrInputSource",void 0),this.controller=e,this.motionController=null,this.envMap=null,this.mesh=null,this.xrInputSource=null,e.addEventListener("connected",(n=>{const r=n.data;r.hand&&!this.motionController&&(this.xrInputSource=r,this.motionController=new o.XRHandMeshModel(this,e,void 0,r.handedness,"left"===r.handedness?null==t?void 0:t[0]:null==t?void 0:t[1]))})),e.addEventListener("disconnected",(()=>{this.dispose()}))}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&this.motionController.updateMesh()}getPointerPosition(){const e=this.controller.joints["index-finger-tip"];return e?e.position:null}intersectBoxObject(e){const o=this.getPointerPosition();if(o){const n=new t.Sphere(o,.01),r=(new t.Box3).setFromObject(e);return n.intersectsBox(r)}return!1}checkButton(e){this.intersectBoxObject(e)?e.onPress():e.onClear(),e.isPressed()&&e.whilePressed()}dispose(){this.clear(),this.motionController=null}}exports.OculusHandModel=s;
|
@@ -1,19 +1,22 @@
|
|
1
|
-
import { Object3D,
|
2
|
-
|
3
|
-
export
|
1
|
+
import { Object3D, Mesh, Texture, XRInputSource, Vector3 } from 'three';
|
2
|
+
import { XRHandMeshModel } from './XRHandMeshModel';
|
3
|
+
export interface XRButton extends Object3D {
|
4
|
+
onPress(): void;
|
5
|
+
onClear(): void;
|
6
|
+
isPressed(): boolean;
|
7
|
+
whilePressed(): void;
|
8
|
+
}
|
9
|
+
declare class OculusHandModel extends Object3D {
|
4
10
|
controller: Object3D;
|
5
|
-
motionController:
|
11
|
+
motionController: XRHandMeshModel | null;
|
6
12
|
envMap: Texture | null;
|
7
|
-
|
8
13
|
mesh: Mesh | null;
|
9
|
-
|
10
|
-
constructor(controller: Object3D);
|
11
|
-
|
14
|
+
xrInputSource: XRInputSource | null;
|
15
|
+
constructor(controller: Object3D, customModels?: string[]);
|
12
16
|
updateMatrixWorld(force?: boolean): void;
|
13
|
-
|
14
17
|
getPointerPosition(): Vector3 | null;
|
15
|
-
|
16
18
|
intersectBoxObject(boxObject: Object3D): boolean;
|
17
|
-
|
18
|
-
|
19
|
+
checkButton(button: XRButton): void;
|
20
|
+
dispose(): void;
|
19
21
|
}
|
22
|
+
export { OculusHandModel };
|
package/webxr/OculusHandModel.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
1
2
|
import { Object3D, Sphere, Box3 } from 'three';
|
2
3
|
import { XRHandMeshModel } from './XRHandMeshModel.js';
|
3
4
|
|
@@ -5,23 +6,34 @@ const TOUCH_RADIUS = 0.01;
|
|
5
6
|
const POINTING_JOINT = 'index-finger-tip';
|
6
7
|
|
7
8
|
class OculusHandModel extends Object3D {
|
8
|
-
constructor(controller) {
|
9
|
+
constructor(controller, customModels) {
|
9
10
|
super();
|
11
|
+
|
12
|
+
_defineProperty(this, "controller", void 0);
|
13
|
+
|
14
|
+
_defineProperty(this, "motionController", void 0);
|
15
|
+
|
16
|
+
_defineProperty(this, "envMap", void 0);
|
17
|
+
|
18
|
+
_defineProperty(this, "mesh", void 0);
|
19
|
+
|
20
|
+
_defineProperty(this, "xrInputSource", void 0);
|
21
|
+
|
10
22
|
this.controller = controller;
|
11
23
|
this.motionController = null;
|
12
24
|
this.envMap = null;
|
13
25
|
this.mesh = null;
|
26
|
+
this.xrInputSource = null;
|
14
27
|
controller.addEventListener('connected', event => {
|
15
28
|
const xrInputSource = event.data;
|
16
29
|
|
17
30
|
if (xrInputSource.hand && !this.motionController) {
|
18
31
|
this.xrInputSource = xrInputSource;
|
19
|
-
this.motionController = new XRHandMeshModel(this, controller,
|
32
|
+
this.motionController = new XRHandMeshModel(this, controller, undefined, xrInputSource.handedness, xrInputSource.handedness === 'left' ? customModels === null || customModels === void 0 ? void 0 : customModels[0] : customModels === null || customModels === void 0 ? void 0 : customModels[1]);
|
20
33
|
}
|
21
34
|
});
|
22
35
|
controller.addEventListener('disconnected', () => {
|
23
|
-
this.
|
24
|
-
this.motionController = null;
|
36
|
+
this.dispose();
|
25
37
|
});
|
26
38
|
}
|
27
39
|
|
@@ -34,6 +46,7 @@ class OculusHandModel extends Object3D {
|
|
34
46
|
}
|
35
47
|
|
36
48
|
getPointerPosition() {
|
49
|
+
// @ts-ignore XRController needs to extend Group
|
37
50
|
const indexFingerTip = this.controller.joints[POINTING_JOINT];
|
38
51
|
|
39
52
|
if (indexFingerTip) {
|
@@ -67,6 +80,11 @@ class OculusHandModel extends Object3D {
|
|
67
80
|
}
|
68
81
|
}
|
69
82
|
|
83
|
+
dispose() {
|
84
|
+
this.clear();
|
85
|
+
this.motionController = null;
|
86
|
+
}
|
87
|
+
|
70
88
|
}
|
71
89
|
|
72
90
|
export { OculusHandModel };
|
package/webxr/VRButton.cjs.js
CHANGED
@@ -1 +1 @@
|
|
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){
|
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={}){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 r(o),o.id="VRButton",o.style.display="none",navigator.xr.isSessionSupported("immersive-vr").then((r=>{r?function(){let n=null;async function s(t){t.addEventListener("end",r),await e.xr.setSession(t),o.textContent="EXIT VR",n=t}function r(){n.removeEventListener("end",r),o.textContent="ENTER VR",n=null}o.style.display="",o.style.cursor="pointer",o.style.left="calc(50% - 50px)",o.style.width="100px",o.textContent="ENTER VR",o.onmouseenter=()=>{o.style.opacity="1.0"},o.onmouseleave=()=>{o.style.opacity="0.5"},o.onclick=()=>{if(null===n){var e;const n=[t.optionalFeatures,"local-floor","bounded-floor","hand-tracking"].flat().filter(Boolean);null===(e=navigator.xr)||void 0===e||e.requestSession("immersive-vr",{...t,optionalFeatures:n}).then(s)}else n.end()}}():s(),r&&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.d.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
import { WebGLRenderer } from 'three';
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { WebGLRenderer, XRSessionInit } from 'three';
|
2
|
+
declare class VRButton {
|
3
|
+
static createButton(renderer: WebGLRenderer, sessionInit?: XRSessionInit): HTMLButtonElement | HTMLAnchorElement;
|
4
|
+
static xrSessionIsGranted: boolean;
|
5
|
+
static registerSessionGrantedListener(): void;
|
5
6
|
}
|
7
|
+
export { VRButton };
|
package/webxr/VRButton.js
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
2
|
|
3
3
|
class VRButton {
|
4
|
-
static createButton(renderer,
|
5
|
-
if (options) {
|
6
|
-
console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.');
|
7
|
-
}
|
8
|
-
|
4
|
+
static createButton(renderer, sessionInit = {}) {
|
9
5
|
const button = document.createElement('button');
|
10
6
|
|
11
7
|
function
|
@@ -35,26 +31,28 @@ class VRButton {
|
|
35
31
|
button.style.width = '100px';
|
36
32
|
button.textContent = 'ENTER VR';
|
37
33
|
|
38
|
-
button.onmouseenter =
|
34
|
+
button.onmouseenter = () => {
|
39
35
|
button.style.opacity = '1.0';
|
40
36
|
};
|
41
37
|
|
42
|
-
button.onmouseleave =
|
38
|
+
button.onmouseleave = () => {
|
43
39
|
button.style.opacity = '0.5';
|
44
40
|
};
|
45
41
|
|
46
|
-
button.onclick =
|
42
|
+
button.onclick = () => {
|
47
43
|
if (currentSession === null) {
|
44
|
+
var _xr;
|
45
|
+
|
48
46
|
// WebXR's requestReferenceSpace only works if the corresponding feature
|
49
47
|
// was requested at session creation time. For simplicity, just ask for
|
50
48
|
// the interesting ones as optional features, but be aware that the
|
51
49
|
// requestReferenceSpace call will fail if it turns out to be unavailable.
|
52
50
|
// ('local' is always available for immersive sessions and doesn't need to
|
53
51
|
// be requested separately.)
|
54
|
-
const
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
const optionalFeatures = [sessionInit.optionalFeatures, 'local-floor', 'bounded-floor', 'hand-tracking'].flat().filter(Boolean);
|
53
|
+
(_xr = navigator.xr) === null || _xr === void 0 ? void 0 : _xr.requestSession('immersive-vr', { ...sessionInit,
|
54
|
+
optionalFeatures
|
55
|
+
}).then(onSessionStarted);
|
58
56
|
} else {
|
59
57
|
currentSession.end();
|
60
58
|
}
|
@@ -92,10 +90,11 @@ class VRButton {
|
|
92
90
|
}
|
93
91
|
|
94
92
|
if ('xr' in navigator) {
|
95
|
-
button.id = 'VRButton';
|
96
|
-
button.style.display = 'none';
|
97
93
|
stylizeElement(button);
|
98
|
-
|
94
|
+
button.id = 'VRButton';
|
95
|
+
button.style.display = 'none' // Query for session mode
|
96
|
+
;
|
97
|
+
navigator.xr.isSessionSupported('immersive-vr').then(supported => {
|
99
98
|
supported ? showEnterVR() : showWebXRNotFound();
|
100
99
|
|
101
100
|
if (supported && VRButton.xrSessionIsGranted) {
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../loaders/GLTFLoader.cjs.js");require("three");exports.XRHandMeshModel=class{constructor(
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),i=require("../loaders/GLTFLoader.cjs.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("three");var t=n(e);exports.XRHandMeshModel=class{constructor(e,n,a="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/",r,l){t.default(this,"controller",void 0),t.default(this,"handModel",void 0),t.default(this,"bones",void 0),this.controller=n,this.handModel=e,this.bones=[];const o=new i.GLTFLoader;l||o.setPath(a),o.load(null!=l?l:`${r}.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 ${r} 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)}}}}};
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import { Object3D } from 'three';
|
2
|
-
|
3
|
-
export class XRHandMeshModel {
|
2
|
+
declare class XRHandMeshModel {
|
4
3
|
controller: Object3D;
|
5
4
|
handModel: Object3D;
|
6
5
|
bones: Object3D[];
|
7
|
-
|
8
|
-
constructor(handModel: Object3D, controller: Object3D, path: string, handedness: string);
|
9
|
-
|
6
|
+
constructor(handModel: Object3D, controller: Object3D, path: string | undefined, handedness: string, customModel?: string);
|
10
7
|
updateMesh(): void;
|
11
8
|
}
|
9
|
+
export { XRHandMeshModel };
|
package/webxr/XRHandMeshModel.js
CHANGED
@@ -1,15 +1,22 @@
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
1
2
|
import { GLTFLoader } from '../loaders/GLTFLoader.js';
|
2
3
|
|
3
4
|
const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/';
|
4
5
|
|
5
6
|
class XRHandMeshModel {
|
6
|
-
constructor(handModel, controller, path, handedness) {
|
7
|
+
constructor(handModel, controller, path = DEFAULT_HAND_PROFILE_PATH, handedness, customModel) {
|
8
|
+
_defineProperty(this, "controller", void 0);
|
9
|
+
|
10
|
+
_defineProperty(this, "handModel", void 0);
|
11
|
+
|
12
|
+
_defineProperty(this, "bones", void 0);
|
13
|
+
|
7
14
|
this.controller = controller;
|
8
15
|
this.handModel = handModel;
|
9
16
|
this.bones = [];
|
10
17
|
const loader = new GLTFLoader();
|
11
|
-
loader.setPath(path
|
12
|
-
loader.load(`${handedness}.glb`, gltf => {
|
18
|
+
if (!customModel) loader.setPath(path);
|
19
|
+
loader.load(customModel != null ? customModel : `${handedness}.glb`, gltf => {
|
13
20
|
const object = gltf.scene.children[0];
|
14
21
|
this.handModel.add(object);
|
15
22
|
const mesh = object.getObjectByProperty('type', 'SkinnedMesh');
|
@@ -1 +1 @@
|
|
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
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./XRHandPrimitiveModel.cjs.js"),r=require("./XRHandMeshModel.cjs.js");require("@babel/runtime/helpers/defineProperty"),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}};
|