three-stdlib 2.11.1 → 2.12.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.
- 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/VRButton.cjs.js +1 -1
- package/webxr/VRButton.d.ts +6 -4
- package/webxr/VRButton.js +14 -15
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);
|
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) {
|