three-stdlib 2.35.4 → 2.35.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"VRButton.cjs","sources":["../../src/webxr/VRButton.ts"],"sourcesContent":["import { WebGLRenderer } from 'three'\n\nconst VRButton = /* @__PURE__ */ (() => {\n class VRButton {\n static createButton(\n renderer: WebGLRenderer,\n sessionInit: XRSessionInit = {},\n ): HTMLButtonElement | HTMLAnchorElement {\n const button = document.createElement('button')\n\n function showEnterVR(/*device*/): void {\n let currentSession: XRSession | null = null\n\n async function onSessionStarted(session: XRSession): Promise<void> {\n session.addEventListener('end', onSessionEnded)\n\n await renderer.xr.setSession(session as any)\n button.textContent = 'EXIT VR'\n\n currentSession = session\n }\n\n function onSessionEnded(/*event*/): void {\n currentSession!.removeEventListener('end', onSessionEnded)\n\n button.textContent = 'ENTER VR'\n\n currentSession = null\n }\n\n //\n\n button.style.display = ''\n\n button.style.cursor = 'pointer'\n button.style.left = 'calc(50% - 50px)'\n button.style.width = '100px'\n\n button.textContent = 'ENTER VR'\n\n button.onmouseenter = (): void => {\n button.style.opacity = '1.0'\n }\n\n button.onmouseleave = (): void => {\n button.style.opacity = '0.5'\n }\n\n button.onclick = (): void => {\n if (currentSession === null) {\n // WebXR's requestReferenceSpace only works if the corresponding feature\n // was requested at session creation time. For simplicity, just ask for\n // the interesting ones as optional features, but be aware that the\n // requestReferenceSpace call will fail if it turns out to be unavailable.\n // ('local' is always available for immersive sessions and doesn't need to\n // be requested separately.)\n\n const optionalFeatures = [sessionInit.optionalFeatures, 'local-floor', 'bounded-floor', 'hand-tracking']\n .flat()\n .filter(Boolean) as string[]\n\n ;(navigator as Navigator).xr\n ?.requestSession('immersive-vr', { ...sessionInit, optionalFeatures })\n .then(onSessionStarted)\n } else {\n currentSession.end()\n }\n }\n }\n\n function disableButton(): void {\n button.style.display = ''\n\n button.style.cursor = 'auto'\n button.style.left = 'calc(50% - 75px)'\n button.style.width = '150px'\n\n button.onmouseenter = null\n button.onmouseleave = null\n\n button.onclick = null\n }\n\n function showWebXRNotFound(): void {\n disableButton()\n\n button.textContent = 'VR NOT SUPPORTED'\n }\n\n function stylizeElement(element: HTMLElement): void {\n element.style.position = 'absolute'\n element.style.bottom = '20px'\n element.style.padding = '12px 6px'\n element.style.border = '1px solid #fff'\n element.style.borderRadius = '4px'\n element.style.background = 'rgba(0,0,0,0.1)'\n element.style.color = '#fff'\n element.style.font = 'normal 13px sans-serif'\n element.style.textAlign = 'center'\n element.style.opacity = '0.5'\n element.style.outline = 'none'\n element.style.zIndex = '999'\n }\n\n if ('xr' in navigator) {\n stylizeElement(button)\n button.id = 'VRButton'\n button.style.display = 'none'\n\n // Query for session mode\n navigator.xr!.isSessionSupported('immersive-vr').then((supported) => {\n supported ? showEnterVR() : showWebXRNotFound()\n\n if (supported && VRButton.xrSessionIsGranted) {\n button.click()\n }\n })\n\n return button\n } else {\n const message = document.createElement('a')\n\n if (window.isSecureContext === false) {\n message.href = document.location.href.replace(/^http:/, 'https:')\n message.innerHTML = 'WEBXR NEEDS HTTPS' // TODO Improve message\n } else {\n message.href = 'https://immersiveweb.dev/'\n message.innerHTML = 'WEBXR NOT AVAILABLE'\n }\n\n message.style.left = 'calc(50% - 90px)'\n message.style.width = '180px'\n message.style.textDecoration = 'none'\n\n stylizeElement(message)\n\n return message\n }\n }\n\n static xrSessionIsGranted = false\n\n static registerSessionGrantedListener(): void {\n if (typeof navigator !== 'undefined' && 'xr' in navigator) {\n ;(navigator as Navigator).xr!.addEventListener('sessiongranted', () => {\n VRButton.xrSessionIsGranted = true\n })\n }\n }\n }\n\n VRButton.registerSessionGrantedListener()\n\n return VRButton\n})()\n\nexport { VRButton }\n"],"names":["VRButton"],"mappings":";;;;;;;;AAEA,MAAM,WAAkC,uBAAA;AACtC,QAAMA,aAAN,MAAe;AAAA,IACb,OAAO,aACL,UACA,cAA6B,IACU;AACjC,YAAA,SAAS,SAAS,cAAc,QAAQ;AAE9C,eAAS,cAA8B;AACrC,YAAI,iBAA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,MAAM,QAAQ;AACtB,gBAAQ,MAAM,OAAO;AACrB,gBAAQ,MAAM,YAAY;AAC1B,gBAAQ,MAAM,UAAU;AACxB,gBAAQ,MAAM,UAAU;AACxB,gBAAQ,MAAM,SAAS;AAAA,MACzB;AAEA,UAAI,QAAQ,WAAW;AACrB,uBAAe,MAAM;AACrB,eAAO,KAAK;AACZ,eAAO,MAAM,UAAU;AAGvB,kBAAU,GAAI,mBAAmB,cAAc,EAAE,KAAK,CAAC,cAAc;AACvD,sBAAA,gBAAgB;AAExB,cAAA,aAAaA,WAAS,oBAAoB;AAC5C,mBAAO,MAAM;AAAA,UACf;AAAA,QAAA,CACD;AAEM,eAAA;AAAA,MAAA,OACF;AACC,cAAA,UAAU,SAAS,cAAc,GAAG;AAEtC,YAAA,OAAO,oBAAoB,OAAO;AACpC,kBAAQ,OAAO,SAAS,SAAS,KAAK,QAAQ,UAAU,QAAQ;AAChE,kBAAQ,YAAY;AAAA,QAAA,OACf;AACL,kBAAQ,OAAO;AACf,kBAAQ,YAAY;AAAA,QACtB;AAEA,gBAAQ,MAAM,OAAO;AACrB,gBAAQ,MAAM,QAAQ;AACtB,gBAAQ,MAAM,iBAAiB;AAE/B,uBAAe,OAAO;AAEf,eAAA;AAAA,MACT;AAAA,IACF;AAAA,IAIA,OAAO,iCAAuC;AAC5C,UAAI,OAAO,cAAc,eAAe,QAAQ,WAAW;AACvD,kBAAwB,GAAI,iBAAiB,kBAAkB,MAAM;AACrEA,qBAAS,qBAAqB;AAAA,QAAA,CAC/B;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAlJA,MAAMA,YAAN;AAyIE,gBAzIIA,WAyIG,sBAAqB;AAW9BA,YAAS,+BAA+B;AAEjCA,SAAAA;AACT,GAAG;;"}
1
+ {"version":3,"file":"VRButton.cjs","sources":["../../src/webxr/VRButton.js"],"sourcesContent":["const VRButton = /* @__PURE__ */ (() => {\n class VRButton {\n static createButton(renderer, sessionInit = {}) {\n const button = document.createElement('button')\n\n function showEnterVR(/*device*/) {\n let currentSession = null\n\n async function onSessionStarted(session) {\n session.addEventListener('end', onSessionEnded)\n\n await renderer.xr.setSession(session)\n button.textContent = 'EXIT VR'\n\n currentSession = session\n }\n\n function onSessionEnded(/*event*/) {\n currentSession.removeEventListener('end', onSessionEnded)\n\n button.textContent = 'ENTER VR'\n\n currentSession = null\n }\n\n //\n\n button.style.display = ''\n\n button.style.cursor = 'pointer'\n button.style.left = 'calc(50% - 50px)'\n button.style.width = '100px'\n\n button.textContent = 'ENTER VR'\n\n button.onmouseenter = () => {\n button.style.opacity = '1.0'\n }\n\n button.onmouseleave = () => {\n button.style.opacity = '0.5'\n }\n\n button.onclick = () => {\n if (currentSession === null) {\n // WebXR's requestReferenceSpace only works if the corresponding feature\n // was requested at session creation time. For simplicity, just ask for\n // the interesting ones as optional features, but be aware that the\n // requestReferenceSpace call will fail if it turns out to be unavailable.\n // ('local' is always available for immersive sessions and doesn't need to\n // be requested separately.)\n\n const optionalFeatures = [sessionInit.optionalFeatures, 'local-floor', 'bounded-floor', 'hand-tracking']\n .flat()\n .filter(Boolean)\n\n navigator.xr?.requestSession('immersive-vr', { ...sessionInit, optionalFeatures }).then(onSessionStarted)\n } else {\n currentSession.end()\n }\n }\n }\n\n function disableButton() {\n button.style.display = ''\n\n button.style.cursor = 'auto'\n button.style.left = 'calc(50% - 75px)'\n button.style.width = '150px'\n\n button.onmouseenter = null\n button.onmouseleave = null\n\n button.onclick = null\n }\n\n function showWebXRNotFound() {\n disableButton()\n\n button.textContent = 'VR NOT SUPPORTED'\n }\n\n function stylizeElement(element) {\n element.style.position = 'absolute'\n element.style.bottom = '20px'\n element.style.padding = '12px 6px'\n element.style.border = '1px solid #fff'\n element.style.borderRadius = '4px'\n element.style.background = 'rgba(0,0,0,0.1)'\n element.style.color = '#fff'\n element.style.font = 'normal 13px sans-serif'\n element.style.textAlign = 'center'\n element.style.opacity = '0.5'\n element.style.outline = 'none'\n element.style.zIndex = '999'\n }\n\n if ('xr' in navigator) {\n stylizeElement(button)\n button.id = 'VRButton'\n button.style.display = 'none'\n\n // Query for session mode\n navigator.xr.isSessionSupported('immersive-vr').then((supported) => {\n supported ? showEnterVR() : showWebXRNotFound()\n\n if (supported && VRButton.xrSessionIsGranted) {\n button.click()\n }\n })\n\n return button\n } else {\n const message = document.createElement('a')\n\n if (window.isSecureContext === false) {\n message.href = document.location.href.replace(/^http:/, 'https:')\n message.innerHTML = 'WEBXR NEEDS HTTPS' // TODO Improve message\n } else {\n message.href = 'https://immersiveweb.dev/'\n message.innerHTML = 'WEBXR NOT AVAILABLE'\n }\n\n message.style.left = 'calc(50% - 90px)'\n message.style.width = '180px'\n message.style.textDecoration = 'none'\n\n stylizeElement(message)\n\n return message\n }\n }\n\n static xrSessionIsGranted = false\n\n static registerSessionGrantedListener() {\n if (typeof navigator !== 'undefined' && 'xr' in navigator) {\n navigator.xr.addEventListener('sessiongranted', () => {\n VRButton.xrSessionIsGranted = true\n })\n }\n }\n }\n\n VRButton.registerSessionGrantedListener()\n\n return VRButton\n})()\n\nexport { VRButton }\n"],"names":["VRButton"],"mappings":";;;;;;;;AAAK,MAAC,WAA4B,uBAAM;AACtC,QAAM,YAAN,MAAe;AAAA,IACb,OAAO,aAAa,UAAU,cAAc,IAAI;AAC9C,YAAM,SAAS,SAAS,cAAc,QAAQ;AAE9C,eAAS,cAAwB;AAC/B,YAAI,iBAAiB;AAErB,uBAAe,iBAAiB,SAAS;AACvC,kBAAQ,iBAAiB,OAAO,cAAc;AAE9C,gBAAM,SAAS,GAAG,WAAW,OAAO;AACpC,iBAAO,cAAc;AAErB,2BAAiB;AAAA,QAClB;AAED,iBAAS,iBAA0B;AACjC,yBAAe,oBAAoB,OAAO,cAAc;AAExD,iBAAO,cAAc;AAErB,2BAAiB;AAAA,QAClB;AAID,eAAO,MAAM,UAAU;AAEvB,eAAO,MAAM,SAAS;AACtB,eAAO,MAAM,OAAO;AACpB,eAAO,MAAM,QAAQ;AAErB,eAAO,cAAc;AAErB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B;AAC5C,mBAAO,MAAO;AAAA,UACf;AAAA,QACX,CAAS;AAED,eAAO;AAAA,MACf,OAAa;AACL,cAAM,UAAU,SAAS,cAAc,GAAG;AAE1C,YAAI,OAAO,oBAAoB,OAAO;AACpC,kBAAQ,OAAO,SAAS,SAAS,KAAK,QAAQ,UAAU,QAAQ;AAChE,kBAAQ,YAAY;AAAA,QAC9B,OAAe;AACL,kBAAQ,OAAO;AACf,kBAAQ,YAAY;AAAA,QACrB;AAED,gBAAQ,MAAM,OAAO;AACrB,gBAAQ,MAAM,QAAQ;AACtB,gBAAQ,MAAM,iBAAiB;AAE/B,uBAAe,OAAO;AAEtB,eAAO;AAAA,MACR;AAAA,IACF;AAAA,IAID,OAAO,iCAAiC;AACtC,UAAI,OAAO,cAAc,eAAe,QAAQ,WAAW;AACzD,kBAAU,GAAG,iBAAiB,kBAAkB,MAAM;AACpD,oBAAS,qBAAqB;AAAA,QACxC,CAAS;AAAA,MACF;AAAA,IACF;AAAA,EACF;AA7ID,MAAMA,YAAN;AAoIE,gBApIIA,WAoIG,sBAAqB;AAW9B,EAAAA,UAAS,+BAAgC;AAEzC,SAAOA;AACT,GAAC;;"}
@@ -1,9 +1,11 @@
1
- /// <reference types="webxr" />
2
- import { WebGLRenderer } from 'three';
3
- declare const VRButton: {
4
- new (): {};
5
- createButton(renderer: WebGLRenderer, sessionInit?: XRSessionInit): HTMLButtonElement | HTMLAnchorElement;
6
- xrSessionIsGranted: boolean;
7
- registerSessionGrantedListener(): void;
8
- };
9
- export { VRButton };
1
+ import { WebGLRenderer } from 'three'
2
+
3
+ declare class VRButton {
4
+ static createButton(renderer: WebGLRenderer, sessionInit?: XRSessionInit): HTMLButtonElement | HTMLAnchorElement
5
+
6
+ static xrSessionIsGranted: boolean
7
+
8
+ static registerSessionGrantedListener(): void
9
+ }
10
+
11
+ export { VRButton }
package/webxr/VRButton.js CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  const VRButton = /* @__PURE__ */ (() => {
8
- const _VRButton2 = class {
8
+ const _VRButton = class {
9
9
  static createButton(renderer, sessionInit = {}) {
10
10
  const button = document.createElement("button");
11
11
  function showEnterVR() {
@@ -75,7 +75,7 @@ const VRButton = /* @__PURE__ */ (() => {
75
75
  button.style.display = "none";
76
76
  navigator.xr.isSessionSupported("immersive-vr").then((supported) => {
77
77
  supported ? showEnterVR() : showWebXRNotFound();
78
- if (supported && _VRButton2.xrSessionIsGranted) {
78
+ if (supported && _VRButton.xrSessionIsGranted) {
79
79
  button.click();
80
80
  }
81
81
  });
@@ -99,12 +99,12 @@ const VRButton = /* @__PURE__ */ (() => {
99
99
  static registerSessionGrantedListener() {
100
100
  if (typeof navigator !== "undefined" && "xr" in navigator) {
101
101
  navigator.xr.addEventListener("sessiongranted", () => {
102
- _VRButton2.xrSessionIsGranted = true;
102
+ _VRButton.xrSessionIsGranted = true;
103
103
  });
104
104
  }
105
105
  }
106
106
  };
107
- let VRButton2 = _VRButton2;
107
+ let VRButton2 = _VRButton;
108
108
  __publicField(VRButton2, "xrSessionIsGranted", false);
109
109
  VRButton2.registerSessionGrantedListener();
110
110
  return VRButton2;
@@ -1 +1 @@
1
- {"version":3,"file":"VRButton.js","sources":["../../src/webxr/VRButton.ts"],"sourcesContent":["import { WebGLRenderer } from 'three'\n\nconst VRButton = /* @__PURE__ */ (() => {\n class VRButton {\n static createButton(\n renderer: WebGLRenderer,\n sessionInit: XRSessionInit = {},\n ): HTMLButtonElement | HTMLAnchorElement {\n const button = document.createElement('button')\n\n function showEnterVR(/*device*/): void {\n let currentSession: XRSession | null = null\n\n async function onSessionStarted(session: XRSession): Promise<void> {\n session.addEventListener('end', onSessionEnded)\n\n await renderer.xr.setSession(session as any)\n button.textContent = 'EXIT VR'\n\n currentSession = session\n }\n\n function onSessionEnded(/*event*/): void {\n currentSession!.removeEventListener('end', onSessionEnded)\n\n button.textContent = 'ENTER VR'\n\n currentSession = null\n }\n\n //\n\n button.style.display = ''\n\n button.style.cursor = 'pointer'\n button.style.left = 'calc(50% - 50px)'\n button.style.width = '100px'\n\n button.textContent = 'ENTER VR'\n\n button.onmouseenter = (): void => {\n button.style.opacity = '1.0'\n }\n\n button.onmouseleave = (): void => {\n button.style.opacity = '0.5'\n }\n\n button.onclick = (): void => {\n if (currentSession === null) {\n // WebXR's requestReferenceSpace only works if the corresponding feature\n // was requested at session creation time. For simplicity, just ask for\n // the interesting ones as optional features, but be aware that the\n // requestReferenceSpace call will fail if it turns out to be unavailable.\n // ('local' is always available for immersive sessions and doesn't need to\n // be requested separately.)\n\n const optionalFeatures = [sessionInit.optionalFeatures, 'local-floor', 'bounded-floor', 'hand-tracking']\n .flat()\n .filter(Boolean) as string[]\n\n ;(navigator as Navigator).xr\n ?.requestSession('immersive-vr', { ...sessionInit, optionalFeatures })\n .then(onSessionStarted)\n } else {\n currentSession.end()\n }\n }\n }\n\n function disableButton(): void {\n button.style.display = ''\n\n button.style.cursor = 'auto'\n button.style.left = 'calc(50% - 75px)'\n button.style.width = '150px'\n\n button.onmouseenter = null\n button.onmouseleave = null\n\n button.onclick = null\n }\n\n function showWebXRNotFound(): void {\n disableButton()\n\n button.textContent = 'VR NOT SUPPORTED'\n }\n\n function stylizeElement(element: HTMLElement): void {\n element.style.position = 'absolute'\n element.style.bottom = '20px'\n element.style.padding = '12px 6px'\n element.style.border = '1px solid #fff'\n element.style.borderRadius = '4px'\n element.style.background = 'rgba(0,0,0,0.1)'\n element.style.color = '#fff'\n element.style.font = 'normal 13px sans-serif'\n element.style.textAlign = 'center'\n element.style.opacity = '0.5'\n element.style.outline = 'none'\n element.style.zIndex = '999'\n }\n\n if ('xr' in navigator) {\n stylizeElement(button)\n button.id = 'VRButton'\n button.style.display = 'none'\n\n // Query for session mode\n navigator.xr!.isSessionSupported('immersive-vr').then((supported) => {\n supported ? showEnterVR() : showWebXRNotFound()\n\n if (supported && VRButton.xrSessionIsGranted) {\n button.click()\n }\n })\n\n return button\n } else {\n const message = document.createElement('a')\n\n if (window.isSecureContext === false) {\n message.href = document.location.href.replace(/^http:/, 'https:')\n message.innerHTML = 'WEBXR NEEDS HTTPS' // TODO Improve message\n } else {\n message.href = 'https://immersiveweb.dev/'\n message.innerHTML = 'WEBXR NOT AVAILABLE'\n }\n\n message.style.left = 'calc(50% - 90px)'\n message.style.width = '180px'\n message.style.textDecoration = 'none'\n\n stylizeElement(message)\n\n return message\n }\n }\n\n static xrSessionIsGranted = false\n\n static registerSessionGrantedListener(): void {\n if (typeof navigator !== 'undefined' && 'xr' in navigator) {\n ;(navigator as Navigator).xr!.addEventListener('sessiongranted', () => {\n VRButton.xrSessionIsGranted = true\n })\n }\n }\n }\n\n VRButton.registerSessionGrantedListener()\n\n return VRButton\n})()\n\nexport { VRButton }\n"],"names":["VRButton"],"mappings":";;;;;;AAEA,MAAM,WAAkC,uBAAA;AACtC,QAAMA,aAAN,MAAe;AAAA,IACb,OAAO,aACL,UACA,cAA6B,IACU;AACjC,YAAA,SAAS,SAAS,cAAc,QAAQ;AAE9C,eAAS,cAA8B;AACrC,YAAI,iBAAmC;AAEvC,uBAAe,iBAAiB,SAAmC;AACzD,kBAAA,iBAAiB,OAAO,cAAc;AAExC,gBAAA,SAAS,GAAG,WAAW,OAAc;AAC3C,iBAAO,cAAc;AAEJ,2BAAA;AAAA,QACnB;AAEA,iBAAS,iBAAgC;AACvB,yBAAA,oBAAoB,OAAO,cAAc;AAEzD,iBAAO,cAAc;AAEJ,2BAAA;AAAA,QACnB;AAIA,eAAO,MAAM,UAAU;AAEvB,eAAO,MAAM,SAAS;AACtB,eAAO,MAAM,OAAO;AACpB,eAAO,MAAM,QAAQ;AAErB,eAAO,cAAc;AAErB,eAAO,eAAe,MAAY;AAChC,iBAAO,MAAM,UAAU;AAAA,QAAA;AAGzB,eAAO,eAAe,MAAY;AAChC,iBAAO,MAAM,UAAU;AAAA,QAAA;AAGzB,eAAO,UAAU,MAAY;AA9CrC;AA+CU,cAAI,mBAAmB,MAAM;AA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,UAAU,QAAQ;AAChE,kBAAQ,YAAY;AAAA,QAAA,OACf;AACL,kBAAQ,OAAO;AACf,kBAAQ,YAAY;AAAA,QACtB;AAEA,gBAAQ,MAAM,OAAO;AACrB,gBAAQ,MAAM,QAAQ;AACtB,gBAAQ,MAAM,iBAAiB;AAE/B,uBAAe,OAAO;AAEf,eAAA;AAAA,MACT;AAAA,IACF;AAAA,IAIA,OAAO,iCAAuC;AAC5C,UAAI,OAAO,cAAc,eAAe,QAAQ,WAAW;AACvD,kBAAwB,GAAI,iBAAiB,kBAAkB,MAAM;AACrEA,qBAAS,qBAAqB;AAAA,QAAA,CAC/B;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAlJA,MAAMA,YAAN;AAyIE,gBAzIIA,WAyIG,sBAAqB;AAW9BA,YAAS,+BAA+B;AAEjCA,SAAAA;AACT,GAAG;"}
1
+ {"version":3,"file":"VRButton.js","sources":["../../src/webxr/VRButton.js"],"sourcesContent":["const VRButton = /* @__PURE__ */ (() => {\n class VRButton {\n static createButton(renderer, sessionInit = {}) {\n const button = document.createElement('button')\n\n function showEnterVR(/*device*/) {\n let currentSession = null\n\n async function onSessionStarted(session) {\n session.addEventListener('end', onSessionEnded)\n\n await renderer.xr.setSession(session)\n button.textContent = 'EXIT VR'\n\n currentSession = session\n }\n\n function onSessionEnded(/*event*/) {\n currentSession.removeEventListener('end', onSessionEnded)\n\n button.textContent = 'ENTER VR'\n\n currentSession = null\n }\n\n //\n\n button.style.display = ''\n\n button.style.cursor = 'pointer'\n button.style.left = 'calc(50% - 50px)'\n button.style.width = '100px'\n\n button.textContent = 'ENTER VR'\n\n button.onmouseenter = () => {\n button.style.opacity = '1.0'\n }\n\n button.onmouseleave = () => {\n button.style.opacity = '0.5'\n }\n\n button.onclick = () => {\n if (currentSession === null) {\n // WebXR's requestReferenceSpace only works if the corresponding feature\n // was requested at session creation time. For simplicity, just ask for\n // the interesting ones as optional features, but be aware that the\n // requestReferenceSpace call will fail if it turns out to be unavailable.\n // ('local' is always available for immersive sessions and doesn't need to\n // be requested separately.)\n\n const optionalFeatures = [sessionInit.optionalFeatures, 'local-floor', 'bounded-floor', 'hand-tracking']\n .flat()\n .filter(Boolean)\n\n navigator.xr?.requestSession('immersive-vr', { ...sessionInit, optionalFeatures }).then(onSessionStarted)\n } else {\n currentSession.end()\n }\n }\n }\n\n function disableButton() {\n button.style.display = ''\n\n button.style.cursor = 'auto'\n button.style.left = 'calc(50% - 75px)'\n button.style.width = '150px'\n\n button.onmouseenter = null\n button.onmouseleave = null\n\n button.onclick = null\n }\n\n function showWebXRNotFound() {\n disableButton()\n\n button.textContent = 'VR NOT SUPPORTED'\n }\n\n function stylizeElement(element) {\n element.style.position = 'absolute'\n element.style.bottom = '20px'\n element.style.padding = '12px 6px'\n element.style.border = '1px solid #fff'\n element.style.borderRadius = '4px'\n element.style.background = 'rgba(0,0,0,0.1)'\n element.style.color = '#fff'\n element.style.font = 'normal 13px sans-serif'\n element.style.textAlign = 'center'\n element.style.opacity = '0.5'\n element.style.outline = 'none'\n element.style.zIndex = '999'\n }\n\n if ('xr' in navigator) {\n stylizeElement(button)\n button.id = 'VRButton'\n button.style.display = 'none'\n\n // Query for session mode\n navigator.xr.isSessionSupported('immersive-vr').then((supported) => {\n supported ? showEnterVR() : showWebXRNotFound()\n\n if (supported && VRButton.xrSessionIsGranted) {\n button.click()\n }\n })\n\n return button\n } else {\n const message = document.createElement('a')\n\n if (window.isSecureContext === false) {\n message.href = document.location.href.replace(/^http:/, 'https:')\n message.innerHTML = 'WEBXR NEEDS HTTPS' // TODO Improve message\n } else {\n message.href = 'https://immersiveweb.dev/'\n message.innerHTML = 'WEBXR NOT AVAILABLE'\n }\n\n message.style.left = 'calc(50% - 90px)'\n message.style.width = '180px'\n message.style.textDecoration = 'none'\n\n stylizeElement(message)\n\n return message\n }\n }\n\n static xrSessionIsGranted = false\n\n static registerSessionGrantedListener() {\n if (typeof navigator !== 'undefined' && 'xr' in navigator) {\n navigator.xr.addEventListener('sessiongranted', () => {\n VRButton.xrSessionIsGranted = true\n })\n }\n }\n }\n\n VRButton.registerSessionGrantedListener()\n\n return VRButton\n})()\n\nexport { VRButton }\n"],"names":["VRButton"],"mappings":";;;;;;AAAK,MAAC,WAA4B,uBAAM;AACtC,QAAM,YAAN,MAAe;AAAA,IACb,OAAO,aAAa,UAAU,cAAc,IAAI;AAC9C,YAAM,SAAS,SAAS,cAAc,QAAQ;AAE9C,eAAS,cAAwB;AAC/B,YAAI,iBAAiB;AAErB,uBAAe,iBAAiB,SAAS;AACvC,kBAAQ,iBAAiB,OAAO,cAAc;AAE9C,gBAAM,SAAS,GAAG,WAAW,OAAO;AACpC,iBAAO,cAAc;AAErB,2BAAiB;AAAA,QAClB;AAED,iBAAS,iBAA0B;AACjC,yBAAe,oBAAoB,OAAO,cAAc;AAExD,iBAAO,cAAc;AAErB,2BAAiB;AAAA,QAClB;AAID,eAAO,MAAM,UAAU;AAEvB,eAAO,MAAM,SAAS;AACtB,eAAO,MAAM,OAAO;AACpB,eAAO,MAAM,QAAQ;AAErB,eAAO,cAAc;AAErB,eAAO,eAAe,MAAM;AAC1B,iBAAO,MAAM,UAAU;AAAA,QACxB;AAED,eAAO,eAAe,MAAM;AAC1B,iBAAO,MAAM,UAAU;AAAA,QACxB;AAED,eAAO,UAAU,MAAM;AA3C1B;AA4CK,cAAI,mBAAmB,MAAM;AAQ3B,kBAAM,mBAAmB,CAAC,YAAY,kBAAkB,eAAe,iBAAiB,eAAe,EACpG,KAAM,EACN,OAAO,OAAO;AAEjB,4BAAU,OAAV,mBAAc,eAAe,gBAAgB,EAAE,GAAG,aAAa,iBAAkB,GAAE,KAAK;AAAA,UACpG,OAAiB;AACL,2BAAe,IAAK;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAED,eAAS,gBAAgB;AACvB,eAAO,MAAM,UAAU;AAEvB,eAAO,MAAM,SAAS;AACtB,eAAO,MAAM,OAAO;AACpB,eAAO,MAAM,QAAQ;AAErB,eAAO,eAA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