Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(model-viewer): move every viewer to 4.4.0 so pages stop printing model-viewer's debug logs
nirholasa2b0688d3aa7
diff --git a/api/_lib/asset-snippets.js b/api/_lib/asset-snippets.jsindex 556df5169..37d067fe0 100644--- a/api/_lib/asset-snippets.js+++ b/api/_lib/asset-snippets.js@@ -52,9 +52,9 @@ export function resetReleaseCache() {// load. Kept identical to pages/objects.html on purpose: a reader who copies// this snippet gets exactly the renderer they saw on the site.const MODEL_VIEWER_SRC =- 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';const MODEL_VIEWER_SRI =- 'sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW';+ 'sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p';export const MODEL_FRAMEWORKS = ['agent-3d', 'model-viewer', 'three', 'react'];export const CLIP_FRAMEWORKS = ['three', 'react', 'agent-3d'];diff --git a/api/_lib/model-viewer-cdn.js b/api/_lib/model-viewer-cdn.jsindex 03ef122f9..0929ae4b0 100644--- a/api/_lib/model-viewer-cdn.js+++ b/api/_lib/model-viewer-cdn.js@@ -21,9 +21,10 @@// public/ar-forge.html, public/spatial-mcp/, pages/daily.html). A// template-interpolated embed cannot carry an integrity hash as cheaply as// a hand-authored document can, which is the only reason this rung has none.-// 2. public/viewer.html and the static first-party pages, Google's CDN with-// an SRI hash: top-level documents that own their whole page and can-// afford the stricter integrity check.+// 2. public/viewer.html and the static first-party pages, jsdelivr with an+// SRI hash: top-level documents that own their whole page and can afford+// the stricter integrity check. (Google's ajax.googleapis.com mirror+// stopped at 4.3.1, the build that logged debug noise on every load.)// 3. src/shared/model-viewer-loader.js, three CDNs in a failover chain: the// Vite-bundled first-party pages (/forge and the pickers), where a blocked// CDN must fall through to the next host instead of leaving an inert box.@@ -35,7 +36,7 @@// pages/ibm/vendor/ stops matching the pinned build./** The pinned model-viewer version. One build platform-wide; see above. */-export const MODEL_VIEWER_VERSION = '4.3.1';+export const MODEL_VIEWER_VERSION = '4.4.0';/** CDN origin the embed surfaces load model-viewer from (must be CSP-allowlisted). */export const MODEL_VIEWER_CDN_ORIGIN = 'https://cdn.jsdelivr.net';diff --git a/api/_mcp/render.js b/api/_mcp/render.jsindex 95d190269..045eef6ac 100644--- a/api/_mcp/render.js+++ b/api/_mcp/render.js@@ -81,7 +81,7 @@ export function renderModelViewerHtml({ src, name, poster, background, height, wreturn ['<!doctype html>','<html><head><meta charset="utf-8"><title>' + esc(name || 'Avatar') + '</title>',- '<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>',+ '<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>','<style>html,body{margin:0;height:100%;background:' + attr(bg) + '}','model-viewer{width:' + attr(w) + ';height:' + attr(h) + ';--progress-bar-color:#6a5cff}','a.ar{position:absolute;left:50%;transform:translateX(-50%);bottom:14px;font-family:ui-sans-serif,system-ui,sans-serif;' +diff --git a/data/tour-atlas.json b/data/tour-atlas.jsonindex e8b190330..7b9cf5844 100644--- a/data/tour-atlas.json+++ b/data/tour-atlas.json@@ -1319,7 +1319,7 @@},"consoleErrors": 1,"consoleSamples": [- "TypeError: Failed to fetch\n at Zl.load (https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js:17:506510)\n at Ru.load (https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js:528:4494)\n at https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/mo"+ "TypeError: Failed to fetch\n at Zl.load (https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:506510)\n at Ru.load (https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:528:4494)\n at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/mo"],"notes": ["anchored by the director's generic fallback, not a curated selector for this page"diff --git a/docs/ALL.md b/docs/ALL.mdindex 530ce9639..69376a460 100644--- a/docs/ALL.md+++ b/docs/ALL.md@@ -35263,10 +35263,10 @@ Call log:### `/spatial-mcp` (labs)- **desktop**- console: $l: fetch for "https://three.ws/cdn/forge/anon/eddcea57-a278-474a-a632-99ca99861755.glb" responded with 502:- at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206+ at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206- **mobile**- console: $l: fetch for "https://three.ws/cdn/forge/anon/eddcea57-a278-474a-a632-99ca99861755.glb" responded with 502:- at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206+ at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206### `/ibm/hello` (crypto)- **desktop**@@ -112869,7 +112869,7 @@ The live demo at [`/spatial-mcp`](https://three.ws/spatial-mcp) renders exactlyThe reference renderer is framework-free and reusable independent of three.ws:```html-<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><div id="mount" style="height:360px"></div><script type="module">import { renderSpatialArtifact } from 'https://three.ws/spatial-mcp/spatial-renderer.js';diff --git a/docs/audit/console-sweep-2026-09-07.md b/docs/audit/console-sweep-2026-09-07.mdindex 236373381..a5685f9c4 100644--- a/docs/audit/console-sweep-2026-09-07.md+++ b/docs/audit/console-sweep-2026-09-07.md@@ -844,10 +844,10 @@ Call log:### `/spatial-mcp` (labs)- **desktop**- console: $l: fetch for "https://three.ws/cdn/forge/anon/eddcea57-a278-474a-a632-99ca99861755.glb" responded with 502:- at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206+ at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206- **mobile**- console: $l: fetch for "https://three.ws/cdn/forge/anon/eddcea57-a278-474a-a632-99ca99861755.glb" responded with 502:- at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206+ at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:507206### `/ibm/hello` (crypto)- **desktop**diff --git a/docs/mcp-studio.md b/docs/mcp-studio.mdindex 8dd088a05..886e64bc7 100644--- a/docs/mcp-studio.md+++ b/docs/mcp-studio.md@@ -239,7 +239,7 @@ Generated a 3D model (GLB).Viewer: https://three.ws/viewer?src=https%3A%2F%2Fthree.ws%2Fcdn%2Fcreations%2F…%2Fmodel.glb&title=a%20red%20ceramic%20teapotGLB: https://three.ws/cdn/creations/…/model.glbPoster PNG: https://three.ws/api/render/glb?glbUrl=https%3A%2F%2Fthree.ws%2Fcdn%2Fcreations%2F…%2Fmodel.glb&width=1024&height=1024-Embed HTML: <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-…" crossorigin="anonymous" ></script> <model-viewer src="https://three.ws/cdn/creations/…/model.glb" alt="a red ceramic teapot" camera-controls auto-rotate ar shadow-intensity="1" style="width:100%;height:420px" ></model-viewer>+Embed HTML: <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-…" crossorigin="anonymous" ></script> <model-viewer src="https://three.ws/cdn/creations/…/model.glb" alt="a red ceramic teapot" camera-controls auto-rotate ar shadow-intensity="1" style="width:100%;height:420px" ></model-viewer>Place it in your room (AR, open on a phone): https://three.ws/api/ar?src=…```diff --git a/docs/mcp.md b/docs/mcp.mdindex 67763b366..93ebe3a5e 100644--- a/docs/mcp.md+++ b/docs/mcp.md@@ -427,7 +427,7 @@ free studio's generation and persona tools ([docs/mcp-studio.md](./mcp-studio.md"viewer_url": "https://three.ws/viewer?src=https%3A%2F%2F...%2Fpainted_wooden_chair_01.glb&title=Painted%20Wooden%20Chair%2001","glb_url": "https://.../objects/polyhaven/glb/painted_wooden_chair_01.glb","poster_png_url": "https://three.ws/api/render/glb?glbUrl=https%3A%2F%2F...%2Fpainted_wooden_chair_01.glb&width=1024&height=1024",- "embed_html": "<script type=\"module\" src=\"https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js\" ...></script>\n\n<model-viewer src=\"...\" ...></model-viewer>"+ "embed_html": "<script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\" ...></script>\n\n<model-viewer src=\"...\" ...></model-viewer>"}],"facets": { "kinds": { "object": 10 }, "categories": [{ "value": "furniture", "count": 8 }] },diff --git a/docs/spatial-mcp.md b/docs/spatial-mcp.mdindex b30daf097..2ebef65cb 100644--- a/docs/spatial-mcp.md+++ b/docs/spatial-mcp.md@@ -83,7 +83,7 @@ The live demo at [`/spatial-mcp`](https://three.ws/spatial-mcp) renders exactlyThe reference renderer is framework-free and reusable independent of three.ws:```html-<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><div id="mount" style="height:360px"></div><script type="module">import { renderSpatialArtifact } from 'https://three.ws/spatial-mcp/spatial-renderer.js';diff --git a/infra/lambda/forge/page.mjs b/infra/lambda/forge/page.mjsindex 1783db1a6..58c9d65de 100644--- a/infra/lambda/forge/page.mjs+++ b/infra/lambda/forge/page.mjs@@ -41,7 +41,7 @@ export function buildPage({ seed, traits, origin }) {<meta name="twitter:description" content="${esc(desc)}" /><meta name="twitter:image" content="${esc(ogUrl)}" /><link rel="canonical" href="${esc(pageUrl)}" />-<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>:root { --bg:#05060a; --panel:#0c0e16; --panel-2:#10131e; --line:#1d2231; --line-2:#2a3146;--text:#eaeef7; --muted:#868da1; --accent:#7c5cff; --accent-2:#19d6a8; --radius:16px;diff --git a/packages/assets-cli/README.md b/packages/assets-cli/README.mdindex c489f45e4..92bb01aec 100644--- a/packages/assets-cli/README.md+++ b/packages/assets-cli/README.md@@ -18,8 +18,8 @@ The second command downloads the GLB into `public/three-ws/` and prints this, re```html<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/packages/threews-avatar-mcp/app/build.mjs b/packages/threews-avatar-mcp/app/build.mjsindex f9aee9892..ccd1b91cb 100644--- a/packages/threews-avatar-mcp/app/build.mjs+++ b/packages/threews-avatar-mcp/app/build.mjs@@ -16,7 +16,7 @@ import { dirname, join } from 'node:path';const here = dirname(fileURLToPath(import.meta.url));const pkgRoot = join(here, '..');-const MODEL_VIEWER_SRC = 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+const MODEL_VIEWER_SRC = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';const result = await build({entryPoints: [join(here, 'avatar-app.js')],diff --git a/packages/threews-avatar-mcp/src/avatar-app.html b/packages/threews-avatar-mcp/src/avatar-app.htmlindex 56152eee7..bdbeda1ea 100644--- a/packages/threews-avatar-mcp/src/avatar-app.html+++ b/packages/threews-avatar-mcp/src/avatar-app.html@@ -4,7 +4,7 @@<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>three.ws avatar</title>-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>html, body { margin: 0; height: 100%; background: transparent; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }#stage { position: relative; width: 100%; height: 100vh; min-height: 360px; }diff --git a/packages/threews-avatar-mcp/src/threews.js b/packages/threews-avatar-mcp/src/threews.jsindex ac868e06e..161b7a690 100644--- a/packages/threews-avatar-mcp/src/threews.js+++ b/packages/threews-avatar-mcp/src/threews.js@@ -198,7 +198,7 @@ export function modelViewerHtml({ model_url, name = 'Avatar', background = 'tran<html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>${escapeHtml(name)}</title>-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>html,body { margin:0; height:100%; background:${bg}; }model-viewer { width:100%; height:${Number(height)}px; --progress-bar-color:#6a5cff; }diff --git a/packages/threews-avatar-mcp/src/ui.js b/packages/threews-avatar-mcp/src/ui.jsindex 053ecde5c..9be58b03b 100644--- a/packages/threews-avatar-mcp/src/ui.js+++ b/packages/threews-avatar-mcp/src/ui.js@@ -22,13 +22,13 @@ export const UI_MIME_TYPE = 'text/html;profile=mcp-app';// supported by the spec.export const UI_CSP = {connectDomains: [- 'https://ajax.googleapis.com',+ 'https://cdn.jsdelivr.net','https://*.r2.dev','https://three.ws','https://*.three.ws',],resourceDomains: [- 'https://ajax.googleapis.com',+ 'https://cdn.jsdelivr.net','https://*.r2.dev','https://three.ws','https://*.three.ws',diff --git a/pages/a-edit.html b/pages/a-edit.htmlindex 34cf9f203..afded69f3 100644--- a/pages/a-edit.html+++ b/pages/a-edit.html@@ -18,8 +18,8 @@<link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/ar-view.html b/pages/ar-view.htmlindex 83a0afb2a..58345995b 100644--- a/pages/ar-view.html+++ b/pages/ar-view.html@@ -19,8 +19,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script type="module" src="/src/ar-view.js"></script>diff --git a/pages/ar.html b/pages/ar.htmlindex d52be53c3..cc7e415bf 100644--- a/pages/ar.html+++ b/pages/ar.html@@ -34,8 +34,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script type="module" src="/src/ar-page.js"></script>diff --git a/pages/avatar-page.html b/pages/avatar-page.htmlindex ca16ba54a..66e600100 100644--- a/pages/avatar-page.html+++ b/pages/avatar-page.html@@ -20,8 +20,8 @@<link rel="stylesheet" href="/mobile.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/certificate.html b/pages/certificate.htmlindex 3e5cf0a0f..fc24d86e6 100644--- a/pages/certificate.html+++ b/pages/certificate.html@@ -30,7 +30,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><link rel="canonical" href="https://three.ws/cert"><meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">diff --git a/pages/character-library.html b/pages/character-library.htmlindex dcb3b5f6d..03e905b48 100644--- a/pages/character-library.html+++ b/pages/character-library.html@@ -28,7 +28,7 @@<meta property="og:locale" content="en_US" /><link rel="shortcut icon" href="/favicon.ico" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/model-viewer-meshopt.js"></script><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" />diff --git a/pages/cosmos.html b/pages/cosmos.htmlindex 6db088469..813380dba 100644--- a/pages/cosmos.html+++ b/pages/cosmos.html@@ -34,7 +34,7 @@<script src="/model-viewer-meshopt.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>diff --git a/pages/create-agent.html b/pages/create-agent.htmlindex 5d92304ab..de3f499ea 100644--- a/pages/create-agent.html+++ b/pages/create-agent.html@@ -1487,8 +1487,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><link rel="canonical" href="https://three.ws/create-agent" />diff --git a/pages/create-prompt.html b/pages/create-prompt.htmlindex 36e57e703..82cf6520a 100644--- a/pages/create-prompt.html+++ b/pages/create-prompt.html@@ -660,8 +660,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script type="application/ld+json">diff --git a/pages/create-selfie.html b/pages/create-selfie.htmlindex 633311dfc..57235fac1 100644--- a/pages/create-selfie.html+++ b/pages/create-selfie.html@@ -1365,8 +1365,8 @@<link rel="stylesheet" href="/mobile.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/create/video.html b/pages/create/video.htmlindex 52be33628..1b08fad18 100644--- a/pages/create/video.html+++ b/pages/create/video.html@@ -1080,8 +1080,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script type="module" src="/src/create-video.js"></script>diff --git a/pages/creations.html b/pages/creations.htmlindex 287f5441c..d584d76e5 100644--- a/pages/creations.html+++ b/pages/creations.html@@ -46,7 +46,7 @@<meta property="og:locale" content="en_US" /><meta property="og:image:alt" content="Creator Gallery — three.ws" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/daily.html b/pages/daily.htmlindex c79c66b75..833ef5167 100644--- a/pages/daily.html+++ b/pages/daily.html@@ -273,7 +273,7 @@return new Promise((resolve, reject) => {const el = document.createElement('script');el.type = 'module';- el.src = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';+ el.src = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';el.onload = () => resolve();el.onerror = () => reject(new Error('model-viewer failed to load'));document.head.appendChild(el);diff --git a/pages/diorama.html b/pages/diorama.htmlindex d16c95e76..a0a15443e 100644--- a/pages/diorama.html+++ b/pages/diorama.html@@ -45,8 +45,8 @@<!-- model-viewer powers the optional "view in your room" (AR) handoff, mirroring /forge. --><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/drop-collection.html b/pages/drop-collection.htmlindex 05bfb587a..b3bae3d54 100644--- a/pages/drop-collection.html+++ b/pages/drop-collection.html@@ -35,7 +35,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/features.html b/pages/features.htmlindex 39b1712a9..b9a5d8101 100644--- a/pages/features.html+++ b/pages/features.html@@ -48,8 +48,8 @@<link rel="stylesheet" href="/mobile.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script defer src="/footer-newsletter.js"></script>diff --git a/pages/features/ar.html b/pages/features/ar.htmlindex 755c93766..e1efe0e86 100644--- a/pages/features/ar.html+++ b/pages/features/ar.html@@ -39,8 +39,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/features/forge.html b/pages/features/forge.htmlindex 9318ebc65..a5ab1a1fb 100644--- a/pages/features/forge.html+++ b/pages/features/forge.html@@ -45,8 +45,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/features/scan.html b/pages/features/scan.htmlindex 79b7037c8..5ba3566ad 100644--- a/pages/features/scan.html+++ b/pages/features/scan.html@@ -51,8 +51,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/features/walk.html b/pages/features/walk.htmlindex a5cee2f5e..cc5287e02 100644--- a/pages/features/walk.html+++ b/pages/features/walk.html@@ -45,8 +45,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/forge-embed.html b/pages/forge-embed.htmlindex 9466a74bc..2b8ca84dd 100644--- a/pages/forge-embed.html+++ b/pages/forge-embed.html@@ -10,8 +10,8 @@<link rel="icon" href="/favicon.ico" sizes="any" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/forge-nim.html b/pages/forge-nim.htmlindex 72d22e1b4..f41f1d3fe 100644--- a/pages/forge-nim.html+++ b/pages/forge-nim.html@@ -38,8 +38,8 @@<script src="/model-viewer-meshopt.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/forge-spark.html b/pages/forge-spark.htmlindex 9113e8788..fa62ca7bf 100644--- a/pages/forge-spark.html+++ b/pages/forge-spark.html@@ -37,8 +37,8 @@<link rel="stylesheet" href="/style.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/forge-studio.html b/pages/forge-studio.htmlindex d7c81884a..24f484633 100644--- a/pages/forge-studio.html+++ b/pages/forge-studio.html@@ -36,11 +36,11 @@<link rel="apple-touch-icon" href="/apple-touch-icon.png" /><link rel="manifest" href="/manifest.webmanifest" /><link rel="stylesheet" href="/style.css" />- <link rel="preconnect" href="https://ajax.googleapis.com" />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/forge-workflows.html b/pages/forge-workflows.htmlindex 0784c86fc..9caadb4cb 100644--- a/pages/forge-workflows.html+++ b/pages/forge-workflows.html@@ -36,7 +36,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/forge.html b/pages/forge.htmlindex e8265b6f2..657e1a584 100644--- a/pages/forge.html+++ b/pages/forge.html@@ -40,7 +40,7 @@<link rel="preload" href="/fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin /><link rel="preload" href="/fonts/space-grotesk-latin.woff2" as="font" type="font/woff2" crossorigin /><link rel="stylesheet" href="/style.css" />- <link rel="preconnect" href="https://ajax.googleapis.com" />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" /><!-- The meshopt decoder shim has to register before any model-viewerstarts loading, so it stays a plain deferred script here. model-vieweritself is NOT loaded on arrival: this page's landing state has no 3D ondiff --git a/pages/forged.html b/pages/forged.htmlindex 623486e39..1fd9bf6e3 100644--- a/pages/forged.html+++ b/pages/forged.html@@ -29,7 +29,7 @@<meta property="og:image:alt" content="Agent-Forged Gallery, three.ws" /><link rel="shortcut icon" href="/favicon.ico" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/model-viewer-meshopt.js"></script><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" />diff --git a/pages/gallery-picker.html b/pages/gallery-picker.htmlindex 3747b0379..13d84122c 100644--- a/pages/gallery-picker.html+++ b/pages/gallery-picker.html@@ -32,8 +32,8 @@<link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/grok.html b/pages/grok.htmlindex 89c6b148e..c84552fdf 100644--- a/pages/grok.html+++ b/pages/grok.html@@ -462,7 +462,7 @@ print(chat.sample().content)</pre><script src="/brand.js" defer></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><script type="module" src="/src/grok-page.js"></script><script type="module" src="/i18n.js"></script></body>diff --git a/pages/home.html b/pages/home.htmlindex 24cac12c9..c6c8adaaa 100644--- a/pages/home.html+++ b/pages/home.html@@ -42,7 +42,7 @@<!-- The hero/showcase 3D viewers lazy-load model-viewer (4.0.0) from this CDNon first interaction; warm the connection so the TLS/DNS handshake is paidbefore the element bundle is requested. -->- <link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin /><link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/tokens.css" /><link rel="stylesheet" href="/buttons.css" />@@ -1386,7 +1386,7 @@ import { attendRotation } from '/src/shared/attended-rotation.js';var viewersLive = false;var pendingViewerCards = [];- const MV_SRC = 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ const MV_SRC = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';function ensureModelViewer() {if (customElements.get('model-viewer')) return;// Reuse the library if the hero/mini-forge already injected it, but match@@ -2353,8 +2353,8 @@ import { attendRotation } from '/src/shared/attended-rotation.js';await new Promise((resolve, reject) => {const s = document.createElement('script');s.type = 'module';- s.src = 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';- s.integrity = 'sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW';+ s.src = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';+ s.integrity = 'sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p';s.crossOrigin = 'anonymous';s.onload = resolve;s.onerror = reject;diff --git a/pages/ibm/vendor/model-viewer.min.js b/pages/ibm/vendor/model-viewer.min.jsindex ee8c68547..0564a617c 100644--- a/pages/ibm/vendor/model-viewer.min.js+++ b/pages/ibm/vendor/model-viewer.min.js@@ -193,7 +193,7 @@ canvas {pointer-events: initial;}-.annotation-wrapper.hide ::slotted(*) {+.annotation-wrapper.hide:not(:focus-within) ::slotted(*) {opacity: var(--min-hotspot-opacity, 0.25);}@@ -606,7 +606,7 @@ canvas {* See the License for the specific language governing permissions and* limitations under the License.*/-const Gm=t=>void 0!==t.material&&t.userData&&t.userData.variantMaterials&&!!Array.from(t.userData.variantMaterials.values()).filter(t=>zm(t.material)),zm=t=>t&&t.isMaterial&&!Array.isArray(t);class Hm{constructor(t){this.writer=t,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(t){const e=new Set,i=t=>{if(!Gm(t))return;const i=t.userData.variantMaterials,n=t.userData.variantData;for(const[t,r]of n){const n=i.get(r.index);n&&zm(n.material)&&e.add(t)}};if(Array.isArray(t))for(const e of t)e.traverse(i);else t.traverse(i);e.forEach(t=>this.variantNames.push(t))}async writeMesh(t,e){if(!Gm(t))return;const i=t.userData,n=i.variantMaterials,r=i.variantData,s=new Map,a=new Map,o=Array.from(r.values()).sort((t,e)=>t.index-e.index);for(const[t,e]of o.entries())a.set(e.index,t);for(const t of r.values()){const e=n.get(t.index);if(!e||!zm(e.material))continue;const i=await this.writer.processMaterialAsync(e.material);s.has(i)||s.set(i,{material:i,variants:[]}),s.get(i).variants.push(a.get(t.index))}const l=Array.from(s.values()).map(t=>t.variants.sort((t,e)=>t-e)&&t).sort((t,e)=>t.material-e.material);if(0===l.length)return;const c=zm(i.originalMaterial)?await this.writer.processMaterialAsync(i.originalMaterial):-1;for(const t of e.primitives)c>=0&&(t.material=c),t.extensions=t.extensions||{},t.extensions[this.name]={mappings:l}}afterParse(){if(0===this.variantNames.length)return;const t=this.writer.json;t.extensions=t.extensions||{};const e=this.variantNames.map(t=>({name:t}));t.extensions[this.name]={variants:e},this.writer.extensionsUsed[this.name]=!0}}class Vm{constructor(t,e,i,n,r){this.xrLight=t,this.renderer=e,this.lightProbe=i,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(n&&"XRWebGLBinding"in window){const i=new hh(16);t.environment=i.texture;const n=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":n.getExtension("EXT_sRGB");break;case"rgba16f":n.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,n),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const i=e.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/t,i.primaryLightIntensity.y/t,i.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(i.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class qm extends fr{constructor(t,e=!0){super(),this.lightProbe=new dc,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new hc,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let i=null,n=!1;t.xr.addEventListener("sessionstart",()=>{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then(r=>{i=new Vm(this,t,r,e,()=>{n=!0,this.dispatchEvent({type:"estimationstart"})})})}),t.xr.addEventListener("sessionend",()=>{i&&(i.dispose(),i=null),n&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{i&&(i.dispose(),i=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}+const Gm=t=>void 0!==t.material&&t.userData&&t.userData.variantMaterials&&!!Array.from(t.userData.variantMaterials.values()).filter(t=>zm(t.material)),zm=t=>!(!t||!t.isMaterial||Array.isArray(t));class Hm{constructor(t){this.writer=t,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(t){const e=new Set,i=t=>{if(!Gm(t))return;const i=t.userData.variantMaterials,n=t.userData.variantData;for(const[t,r]of n){const n=i.get(r.index);n&&zm(n.material)&&e.add(t)}};if(Array.isArray(t))for(const e of t)e.traverse(i);else t.traverse(i);e.forEach(t=>this.variantNames.push(t))}async writeMesh(t,e){if(!Gm(t))return;const i=t.userData,n=i.variantMaterials,r=i.variantData,s=new Map,a=new Map,o=Array.from(r.values()).sort((t,e)=>t.index-e.index);for(const[t,e]of o.entries())a.set(e.index,t);for(const t of r.values()){const e=n.get(t.index);if(!e||!zm(e.material))continue;const i=await this.writer.processMaterialAsync(e.material);s.has(i)||s.set(i,{material:i,variants:[]}),s.get(i).variants.push(a.get(t.index))}const l=Array.from(s.values()).map(t=>t.variants.sort((t,e)=>t-e)&&t).sort((t,e)=>t.material-e.material);if(0===l.length)return;const c=zm(i.originalMaterial)?await this.writer.processMaterialAsync(i.originalMaterial):-1;for(const t of e.primitives)c>=0&&(t.material=c),t.extensions=t.extensions||{},t.extensions[this.name]={mappings:l}}afterParse(){if(0===this.variantNames.length)return;const t=this.writer.json;t.extensions=t.extensions||{};const e=this.variantNames.map(t=>({name:t}));t.extensions[this.name]={variants:e},this.writer.extensionsUsed[this.name]=!0}}class Vm{constructor(t,e,i,n,r){this.xrLight=t,this.renderer=e,this.lightProbe=i,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(n&&"XRWebGLBinding"in window){const i=new hh(16);t.environment=i.texture;const n=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":n.getExtension("EXT_sRGB");break;case"rgba16f":n.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,n),this.lightProbe.addEventListener("reflectionchange",()=>{this.updateReflection()})}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const i=e.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/t,i.primaryLightIntensity.y/t,i.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(i.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class qm extends fr{constructor(t,e=!0){super(),this.lightProbe=new dc,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new hc,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let i=null,n=!1;t.xr.addEventListener("sessionstart",()=>{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then(r=>{i=new Vm(this,t,r,e,()=>{n=!0,this.dispatchEvent({type:"estimationstart"})})})}),t.xr.addEventListener("sessionend",()=>{i&&(i.dispose(),i=null),n&&this.dispatchEvent({type:"estimationend"})}),this.dispose=()=>{i&&(i.dispose(),i=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}}/* @license* Copyright 2020 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -648,7 +648,7 @@ const Gm=t=>void 0!==t.material&&t.userData&&t.userData.variantMaterials&&!!Arra* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.- */const Ym=(t,e)=>({type:"number",number:t,unit:e}),$m=(()=>{const t={};return e=>{const i=e;if(i in t)return t[i];const n=[];let r=0;for(;e;){if(++r>1e3){e="";break}const t=Zm(e),i=t.nodes[0];if(null==i||0===i.terms.length)break;n.push(i),e=t.remainingInput}return t[i]=n}})(),Zm=(()=>{const t=/^(\-\-|[a-z\u0240-\uffff])/i,e=/^([\*\+\/]|[\-]\s)/i,i=/^[\),]/;return n=>{const r=[];for(;n.length&&(n=n.trim(),!i.test(n));)if("("===n[0]){const{nodes:t,remainingInput:e}=rf(n);n=e,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:t})}else if(t.test(n)){const t=tf(n),e=t.nodes[0];if("("===(n=t.remainingInput)[0]){const{nodes:t,remainingInput:i}=rf(n);r.push({type:"function",name:e,arguments:t}),n=i}else r.push(e)}else if(e.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:t,remainingInput:e}="#"===n[0]?nf(n):ef(n);if(0===t.length)break;r.push(t[0]),n=e}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),tf=(()=>{const t=/[^a-z0-9_\-\u0240-\uffff]/i;return e=>{const i=e.match(t);return{nodes:[{type:"ident",value:null==i?e:e.substr(0,i.index)}],remainingInput:null==i?"":e.substr(i.index)}}})(),ef=(()=>{const t=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,e=/^[a-z%]+/i,i=/^(m|mm|cm|rad|deg|[%])$/;return n=>{const r=n.match(t),s=null==r?"0":r[0],a=(n=null==s?n:n.slice(s.length)).match(e);let o=null!=a&&""!==a[0]?a[0]:null;const l=null==a?n:n.slice(o.length);return null==o||i.test(o)||(o=null),{nodes:[{type:"number",number:parseFloat(s)||0,unit:o}],remainingInput:l}}})(),nf=(()=>{const t=/^[a-f0-9]*/i;return e=>{const i=(e=e.slice(1).trim()).match(t);return{nodes:null==i?[]:[{type:"hex",value:i[0]}],remainingInput:null==i?e:e.slice(i[0].length)}}})(),rf=t=>{const e=[];for(t=t.slice(1).trim();t.length;){const i=Zm(t);if(e.push(i.nodes[0]),","===(t=i.remainingInput.trim())[0])t=t.slice(1).trim();else if(")"===t[0]){t=t.slice(1);break}}return{nodes:e,remainingInput:t}},sf=Symbol("visitedTypes");class af{constructor(t){this[sf]=t}walk(t,e){const i=t.slice();for(;i.length;){const t=i.shift();switch(this[sf].indexOf(t.type)>-1&&e(t),t.type){case"expression":i.unshift(...t.terms);break;case"function":i.unshift(t.name,...t.arguments)}}}}const of=Object.freeze({type:"number",number:0,unit:null}),lf=(t,e=0)=>{let{number:i,unit:n}=t;if(isFinite(i)){if("rad"===t.unit||null==t.unit)return t}else i=e,n="rad";return{type:"number",number:("deg"===n&&null!=i?i:0)*Math.PI/180,unit:"rad"}},cf=(t,e=0)=>{let i,{number:n,unit:r}=t;if(isFinite(n)){if("m"===t.unit)return t}else n=e,r="m";switch(r){default:i=1;break;case"cm":i=.01;break;case"mm":i=.001}return{type:"number",number:i*n,unit:"m"}},hf=(()=>{const t=t=>t,e={rad:t,deg:lf,m:t,mm:cf,cm:cf};return(t,i=of)=>{isFinite(t.number)||(t.number=i.number,t.unit=i.unit);const{unit:n}=t;if(null==n)return t;const r=e[n];return null==r?i:r(t)}})();+ */const Ym=(t,e)=>({type:"number",number:t,unit:e}),$m=(()=>{const t={};return e=>{const i=e;if(i in t)return t[i];const n=[];let r=0;for(;e;){if(++r>1e3){e="";break}const t=Zm(e),i=t.nodes[0];if(null==i||0===i.terms.length)break;n.push(i),e=t.remainingInput}return t[i]=n}})(),Zm=(()=>{const t=/^(\-\-|[a-z\u0240-\uffff])/i,e=/^([\*\+\/]|[\-]\s)/i,i=/^[\),]/;return n=>{const r=[];for(;n.length&&(n=n.trim(),!i.test(n));)if("("===n[0]){const{nodes:t,remainingInput:e}=rf(n);n=e,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:t})}else if(t.test(n)){const t=tf(n),e=t.nodes[0];if("("===(n=t.remainingInput)[0]){const{nodes:t,remainingInput:i}=rf(n);r.push({type:"function",name:e,arguments:t}),n=i}else r.push(e)}else if(e.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:t,remainingInput:e}="#"===n[0]?nf(n):ef(n);if(0===t.length)break;r.push(t[0]),n=e}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),tf=(()=>{const t=/[^a-z0-9_\-\u0240-\uffff]/i;return e=>{const i=e.match(t);return{nodes:[{type:"ident",value:null==i?e:e.substr(0,i.index)}],remainingInput:null==i?"":e.substr(i.index)}}})(),ef=(()=>{const t=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,e=/^[a-z%]+/i,i=/^(m|mm|cm|rad|deg|[%])$/;return n=>{const r=n.match(t),s=null==r?"0":r[0],a=(n=null==s?n:n.slice(s.length)).match(e);let o=null!=a&&""!==a[0]?a[0]:null;const l=null==a?n:n.slice(o.length);return null==o||i.test(o)||(o=null),{nodes:[{type:"number",number:parseFloat(s)||0,unit:o}],remainingInput:l}}})(),nf=(()=>{const t=/^([a-f0-9]{8}|[a-f0-9]{6}|[a-f0-9]{4}|[a-f0-9]{3})(?![a-f0-9])/i;return e=>{const i=(e=e.slice(1).trim()).match(t);return{nodes:null==i?[]:[{type:"hex",value:i[0]}],remainingInput:null==i?e:e.slice(i[0].length)}}})(),rf=t=>{const e=[];for(t=t.slice(1).trim();t.length;){const i=Zm(t);if(e.push(i.nodes[0]),","===(t=i.remainingInput.trim())[0])t=t.slice(1).trim();else if(")"===t[0]){t=t.slice(1);break}}return{nodes:e,remainingInput:t}},sf=Symbol("visitedTypes");class af{constructor(t){this[sf]=t}walk(t,e){const i=t.slice();for(;i.length;){const t=i.shift();switch(this[sf].indexOf(t.type)>-1&&e(t),t.type){case"expression":i.unshift(...t.terms);break;case"function":i.unshift(t.name,...t.arguments)}}}}const of=Object.freeze({type:"number",number:0,unit:null}),lf=(t,e=0)=>{const{number:i,unit:n}=t;if(!isFinite(i))return{type:"number",number:e,unit:"rad"};if("rad"===t.unit||null==t.unit)return t;return{type:"number",number:("deg"===n&&null!=i?i:0)*Math.PI/180,unit:"rad"}},cf=(t,e=0)=>{let i,{number:n,unit:r}=t;if(isFinite(n)){if("m"===t.unit)return t}else n=e,r="m";switch(r){default:i=1;break;case"cm":i=.01;break;case"mm":i=.001}return{type:"number",number:i*n,unit:"m"}},hf=(()=>{const t=t=>t,e={rad:t,deg:lf,m:t,mm:cf,cm:cf};return(t,i=of)=>{isFinite(t.number)||(t.number=i.number,t.unit=i.unit);const{unit:n}=t;if(null==n)return t;const r=e[n];return null==r?i:r(t)}})();/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -750,7 +750,7 @@ var $f=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.* See the License for the specific language governing permissions and* limitations under the License.*/-const hv=.8,uv=150,dv=new vn(0,1,0),pv=.01,Av=.001,gv="not-presenting",mv="session-started",fv="object-placed",bv="failed",vv="tracking",yv="not-tracking",xv=new vn,_v=new bn,Ev=new Hn,Sv=new vn,Cv=new nc(45,1,.1,100),wv=(new Es).setFromPoints([new vn(0,0,0),new vn(0,0,-1)]),Mv="screen-space",Iv="world-space";class Tv extends sn{isWorldSpaceReady(){return this.xrMode===Iv&&this.worldSpaceInitialPlacementDone}constructor(t){super(),this.renderer=t,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.menuPanel=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.xrMode=null,this.xrController1=null,this.xrController2=null,this.selectedXRController=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new vn,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.lastDragPosition=new vn,this.deltaRotation=new bn,this.scaleLine=new Na(wv),this.firstRatio=0,this.lastAngle=0,this.goalPosition=new vn,this.goalYaw=0,this.goalScale=1,this.xDamper=new jm,this.yDamper=new jm,this.zDamper=new jm,this.yawDamper=new jm,this.pitchDamper=new jm,this.rollDamper=new jm,this.scaleDamper=new jm,this.wasTwoFingering=!1,this.worldSpaceInitialPlacementDone=!1,this.initialModelScale=1,this.minScale=1,this.maxScale=1,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onControllerSelectStart=t=>{var e,i,n;const r=this.presentedScene,s=t.target,a=this.menuPanel;if(null!=this.menuPanel.exitButtonControllerIntersection(r,s))return null===(e=this.menuPanel)||void 0===e||e.dispose(),void this.stopPresenting();if(null!=this.menuPanel.scaleModeButtonControllerIntersection(r,s)){const t=this.menuPanel.handleScaleToggle(this.worldSpaceInitialPlacementDone,this.initialModelScale,this.minScale,this.maxScale);return void(null!==t&&(this.goalScale=t))}a&&(a.show=!1);const o=this.placementBox.controllerIntersection(r,s);if(null!=o){const t=(new Gr).setFromObject(r.scenePivot).min.y+.2;if(o.point.y<=t)null!=this.selectedXRController?(this.selectedXRController.userData.line.visible=!1,r.canScale&&this.isWorldSpaceReady()&&(this.isTwoHandInteraction=!0,this.firstRatio=this.controllerSeparation()/r.scenePivot.scale.x,this.scaleLine.visible=!0)):s.attach(r.scenePivot),this.selectedXRController=s,r.setShadowIntensity(.01);else if(s==this.xrController1?this.xrController1.userData.isSelected=!0:s==this.xrController2&&(this.xrController2.userData.isSelected=!0),(null===(i=this.xrController1)||void 0===i?void 0:i.userData.isSelected)&&(null===(n=this.xrController2)||void 0===n?void 0:n.userData.isSelected))r.canScale&&this.isWorldSpaceReady()&&(this.isTwoHandInteraction=!0,this.firstRatio=this.controllerSeparation()/r.scenePivot.scale.x,this.scaleLine.visible=!0);else{const t=s===this.xrController1?this.xrController2:this.xrController1;s.userData.initialX=s.position.x,t.userData.turning=!1,s.userData.turning=!0,s.userData.line.visible=!1}}},this.onControllerSelectEnd=t=>{const e=t.target;if(e.userData.turning=!1,e.userData.line.visible=!0,this.isTwoHandInteraction=!1,this.scaleLine.visible=!1,e==this.xrController1?this.xrController1.userData.isSelected=!1:e==this.xrController2&&(this.xrController2.userData.isSelected=!1),null!=this.selectedXRController&&this.selectedXRController!=e)return;const i=this.presentedScene;i.attach(i.scenePivot),this.selectedXRController=null,this.goalYaw=Math.atan2(i.scenePivot.matrix.elements[8],i.scenePivot.matrix.elements[10]),this.goalPosition.x=i.scenePivot.position.x,this.goalPosition.z=i.scenePivot.position.z,this.isWorldSpaceReady()&&(this.goalPosition.y=i.scenePivot.position.y);this.menuPanel.show=!0},this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.updateFromModelChanges(),this.placementBox.setScreenSpaceMode(this.xrMode===Mv)),this.xrMode!==Mv&&(this.menuPanel&&(this.menuPanel.dispose(),this.menuPanel=null),this.menuPanel=new cv,this.presentedScene.add(this.menuPanel),this.menuPanel.updatePosition(this.presentedScene.getCamera(),this.placementBox))},this.onSelectStart=t=>{const e=this.transientHitTestSource;if(null==e)return;const i=this.frame.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=this.placementBox;if(1===i.length){this.inputSource=t.inputSource;const{axes:e}=this.inputSource.gamepad,i=r.getHit(this.presentedScene,e[0],e[1]);r.show=!0,null!=i?(this.isTranslating=!0,this.lastDragPosition.copy(i)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*e[0])}else if(2===i.length){r.show=!0,this.isTwoHandInteraction=!0;const{separation:t,angle:e}=this.fingerPolar(i);return this.lastAngle=e,0===this.firstRatio&&(this.firstRatio=t/n.scenePivot.scale.x),void(n.canScale&&this.setScale(t))}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.onBeforeXRSelect=t=>{const e=t.composedPath();for(const i of e)if(i instanceof HTMLElement){const e=i.tagName.toLowerCase();if("input"===e||"button"===e||"select"===e||"textarea"===e||"a"===e||i.hasAttribute("data-pointer-coalesce")||i.classList.contains("interactive")){t.preventDefault();break}}},this.threeRenderer=t.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){Hd();const t=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:[],optionalFeatures:["hit-test","dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(t),this.threeRenderer.xr.cameraAutoUpdate=!1,t}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return Hd(),await navigator.xr.isSessionSupported("immersive-ar")}catch(t){return console.warn("Request to present in WebXR denied:"),console.warn(t),console.warn("Falling back to next ar-mode"),!1}}async present(t,e=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let i=new Promise((t,e)=>{requestAnimationFrame(()=>t())});t.setHotspotsVisibility(!1),t.queueRender(),await i,this._presentedScene=t,this.overlay=t.element.shadowRoot.querySelector("div.default"),null!=this.overlay&&this.overlay.addEventListener("beforexrselect",this.onBeforeXRSelect),!0===e&&(this.xrLight=new qm(this.threeRenderer),this.xrLight.addEventListener("estimationstart",()=>{if(!this.isPresenting||null==this.xrLight)return;const t=this.presentedScene;t.add(this.xrLight),t.environment=this.xrLight.environment}));const n=await this.resolveARSession();n.addEventListener("end",()=>{this.postSessionCleanup()},{once:!0});const r=t.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");r.classList.add("enabled"),r.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=r;const s=await n.requestReferenceSpace("viewer");this.xrMode=n.interactionMode,this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=t.yaw,this.goalYaw=t.yaw,this.goalScale=1,t.setBackground(null),this.oldShadowIntensity=t.shadowIntensity,t.setShadowIntensity(.01),this.oldTarget.copy(t.getTarget()),t.element.addEventListener("load",this.onUpdateScene);const a=20*Math.PI/180,o=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(a),z:-Math.cos(a)});n.requestHitTestSource({space:s,offsetRay:o}).then(t=>{this.initialHitSource=t}),this.xrMode!==Mv&&(this.setupXRControllers(),this.xDamper.setDecayTime(uv),this.yDamper.setDecayTime(uv),this.zDamper.setDecayTime(uv),this.yawDamper.setDecayTime(uv),this.pitchDamper.setDecayTime(uv),this.rollDamper.setDecayTime(uv),this.scaleDamper.setDecayTime(uv)),this.currentSession=n,this.placementBox=new Jm(t,this.placeOnWall?"back":"bottom"),this.placementBox&&this.placementBox.setScreenSpaceMode(this.xrMode===Mv),this.placementComplete=!1,this.xrMode!==Mv&&(this.menuPanel=new cv,t.add(this.menuPanel),this.menuPanel.updatePosition(t.getCamera(),this.placementBox)),this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:mv})}setupXRControllerLine(t){if(!t.userData.line){const e=new Na(wv);e.name="line",e.scale.z=5,t.userData.turning=!1,t.userData.line=e,t.add(e)}}setupController(t){this.setupXRControllerLine(t),t.addEventListener("selectstart",this.onControllerSelectStart),t.addEventListener("selectend",this.onControllerSelectEnd)}setupXRControllers(){this.xrController1=this.threeRenderer.xr.getController(0),this.xrController2=this.threeRenderer.xr.getController(1),this.setupController(this.xrController1),this.setupController(this.xrController2),this.scaleLine.name="scale line",this.scaleLine.visible=!1,this.xrController1.add(this.scaleLine);const t=this.presentedScene;t.add(this.xrController1),t.add(this.xrController2)}hover(t){if(this.xrMode===Mv||this.selectedXRController==t)return!1;const e=this.presentedScene,i=this.placementBox.controllerIntersection(e,t);return t.userData.line.scale.z=null==i?5:i.distance,null!=i}controllerSeparation(){return this.xrController1.position.distanceTo(this.xrController2.position)}async stopPresenting(){if(!this.isPresenting)return;const t=new Promise(t=>{this.resolveCleanup=t});try{await this.currentSession.end(),await t}catch(t){console.warn("Error while trying to end WebXR AR session"),console.warn(t),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const t=this.presentedScene;if(null!=t){const e=t.getTarget();this.oldTarget.copy(e),this.placeOnWall?e.z=t.boundingBox.min.z:e.y=t.boundingBox.min.y,t.setTarget(e.x,e.y,e.z)}}cleanupXRController(t){t.userData.turning=!1,t.userData.line.visible=!0,t.removeEventListener("selectstart",this.onControllerSelectStart),t.removeEventListener("selectend",this.onControllerSelectEnd),t.removeFromParent()}postSessionCleanup(){const t=this.currentSession;null!=t&&(t.removeEventListener("selectstart",this.onSelectStart),t.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const e=this.presentedScene;if(this._presentedScene=null,null!=e){const{element:t}=e;null!=this.xrLight&&(e.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),null!=this.menuPanel&&(this.menuPanel.dispose(),this.menuPanel=null),e.add(e.scenePivot),e.scenePivot.quaternion.set(0,0,0,1),e.scenePivot.position.set(0,0,0),e.scenePivot.scale.set(1,1,1),e.setShadowOffset(0);const i=this.turntableRotation;null!=i&&(e.yaw=i);const n=this.oldShadowIntensity;null!=n&&e.setShadowIntensity(n),e.setEnvironmentAndSkybox(t[Kd],t[Jd]);const r=this.oldTarget;e.setTarget(r.x,r.y,r.z),e.xrCamera=null,e.element.removeEventListener("load",this.onUpdateScene),e.orientHotspots(0);const{width:s,height:a}=t.getBoundingClientRect();e.setSize(s,a),requestAnimationFrame(()=>{e.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:$b.NONE}}))})}this.renderer.height=0;const i=this.exitWebXRButtonContainer;null!=i&&(i.classList.remove("enabled"),i.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const n=this.transientHitTestSource;null!=n&&(n.cancel(),this.transientHitTestSource=null);const r=this.initialHitSource;null!=r&&(r.cancel(),this.initialHitSource=null),null!=this.placementBox&&(this.placementBox.dispose(),this.placementBox=null),this.xrMode!==Mv&&(null!=this.xrController1&&(this.cleanupXRController(this.xrController1),this.xrController1=null),null!=this.xrController2&&(this.cleanupXRController(this.xrController2),this.xrController2=null),this.selectedXRController=null,this.scaleLine.visible=!1),this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,null!=this.overlay&&(this.overlay.removeEventListener("beforexrselect",this.onBeforeXRSelect),this.overlay=null),this.worldSpaceInitialPlacementDone=!1,null!=this.resolveCleanup&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:gv})}updateView(t){const e=this.presentedScene,i=this.threeRenderer.xr;i.updateCamera(Cv),e.xrCamera=i.getCamera();const{elements:n}=e.getCamera().matrixWorld;if(e.orientHotspots(Math.atan2(n[1],n[5])),this.initialized||(this.placeInitially(),this.initialized=!0),t.requestViewportScale&&t.recommendedViewportScale){const e=t.recommendedViewportScale;t.requestViewportScale(Math.max(e,.25))}const r=i.getBaseLayer();if(null!=r){const e=r instanceof XRWebGLLayer?r.getViewport(t):i.getBinding().getViewSubImage(r,t).viewport;this.threeRenderer.setViewport(e.x,e.y,e.width,e.height)}}placeInitially(){const t=this.presentedScene,{scenePivot:e,element:i}=t,{position:n}=e,r=t.getCamera(),{width:s,height:a}=this.overlay.getBoundingClientRect();t.setSize(s,a),r.projectionMatrixInverse.copy(r.projectionMatrix).invert();const{theta:o}=i.getCameraOrbit(),l=r.getWorldDirection(xv);if(t.yaw=Math.atan2(-l.x,-l.z)-o,this.goalYaw=t.yaw,this.xrMode!==Iv||this.worldSpaceInitialPlacementDone){if(this.xrMode===Mv){const e=Math.max(1,2*t.boundingSphere.radius);n.copy(r.position).add(l.multiplyScalar(e)),this.updateTarget();const i=t.getTarget();n.add(i).sub(this.oldTarget),this.goalPosition.copy(n)}}else{const{position:i,scale:s}=this.calculateWorldSpaceOptimalPlacement(t,r);this.goalPosition.copy(i),this.goalScale=s,this.initialModelScale=s,n.copy(i),e.scale.set(s,s,s),this.worldSpaceInitialPlacementDone=!0,this.calculateWorldSpaceScaleLimits(t),this.enableWorldSpaceUserInteraction()}if(t.setHotspotsVisibility(!0),this.xrMode===Mv){const{session:t}=this.frame;t.addEventListener("selectstart",this.onSelectStart),t.addEventListener("selectend",this.onSelectEnd),t.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then(t=>{this.transientHitTestSource=t})}}getTouchLocation(){const{axes:t}=this.inputSource.gamepad;let e=this.placementBox.getExpandedHit(this.presentedScene,t[0],t[1]);return null!=e&&(xv.copy(e).sub(this.presentedScene.getCamera().position),xv.length()>10)?null:e}getHitPoint(t){const e=this.threeRenderer.xr.getReferenceSpace(),i=t.getPose(e);if(null==i)return null;const n=Ev.fromArray(i.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(n.elements[4],n.elements[6])),n.elements[5]>.75!==this.placeOnWall?Sv.setFromMatrixPosition(n):null}moveToFloor(t){if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone)return this.placementBox.show=!1,void this.dispatchEvent({type:"status",status:fv});const e=this.initialHitSource;if(null==e)return;const i=t.getHitTestResults(e);if(0==i.length)return;const n=i[0],r=this.getHitPoint(n);null!=r&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(r):this.goalPosition.y=r.y),e.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:fv}))}fingerPolar(t){const e=t[0].inputSource.gamepad.axes,i=t[1].inputSource.gamepad.axes,n=i[0]-e[0],r=i[1]-e[1],s=Math.atan2(r,n);let a=this.lastAngle-s;return a>Math.PI?a-=2*Math.PI:a<-Math.PI&&(a+=2*Math.PI),{separation:Math.sqrt(n*n+r*r),deltaYaw:a,angle:s}}setScale(t){let e=t/this.firstRatio;e=Math.abs(e-1)<.2?1:e,this.isWorldSpaceReady()&&(e=Math.max(this.minScale,Math.min(this.maxScale,e))),this.goalScale=e}processInput(t){const e=this.transientHitTestSource;if(null==e)return;const i=t.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=n.scenePivot.scale.x;if(2===i.length){if(!this.wasTwoFingering){const{separation:t,angle:e}=this.fingerPolar(i);return this.firstRatio=t/r,this.lastAngle=e,this.wasTwoFingering=!0,void(this.isTwoHandInteraction=!0)}const{separation:t,deltaYaw:e,angle:s}=this.fingerPolar(i);return this.goalYaw+=e,this.lastAngle=s,n.canScale&&this.setScale(t),void(this.isTwoHandInteraction=!0)}if(this.wasTwoFingering&&(this.wasTwoFingering=!1,this.isTwoHandInteraction=!1,this.firstRatio=0),this.isTranslating||this.isTwoHandInteraction||this.isRotating)if(this.isRotating){const t=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=t-this.lastAngle,this.lastAngle=t}else this.isTranslating&&i.forEach(t=>{if(t.inputSource!==this.inputSource)return;let e=null;if(t.results.length>0&&(e=this.getHitPoint(t.results[0])),null==e&&(e=this.getTouchLocation()),null!=e){if(this.goalPosition.sub(this.lastDragPosition),this.isWorldSpaceReady())console.log("[processInput] Setting goalPosition.y to hit.y:",e.y),this.goalPosition.add(e);else if(!1===this.placeOnWall){const t=e.y-this.lastDragPosition.y;if(t<0){this.placementBox.offsetHeight=t/r,this.presentedScene.setShadowOffset(t);const i=xv.copy(n.getCamera().position),s=-t/(i.y-e.y);i.multiplyScalar(s),e.multiplyScalar(1-s).add(i)}this.goalPosition.add(e)}else this.goalPosition.add(e);this.lastDragPosition.copy(e)}})}applyXRControllerRotation(t,e){if(!t.userData.turning)return;const i=.3*(t.position.x-t.userData.initialX);this.deltaRotation.setFromAxisAngle(dv,i),e.quaternion.multiplyQuaternions(this.deltaRotation,e.quaternion)}handleScalingInXR(t,e){if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone)return;if(this.xrController1&&this.xrController2&&this.isTwoHandInteraction){const t=this.controllerSeparation();this.setScale(t),this.scaleLine.scale.z=-t,this.scaleLine.lookAt(this.xrController2.position)}const i=t.scenePivot.scale.x;if(this.goalScale!==i){const n=this.scaleDamper.update(i,this.goalScale,e,1);t.scenePivot.scale.set(n,n,n)}}updatePivotPosition(t,e){const{scenePivot:i}=t,n=this.placementBox,r=t.boundingSphere.radius,s=this.goalPosition,a=i.position;let o=$b.NONE;if(!s.equals(a)){o=$b.USER_INTERACTION;let{x:i,y:l,z:c}=a;if(i=this.xDamper.update(i,s.x,e,r),l=this.yDamper.update(l,s.y,e,r),c=this.zDamper.update(c,s.z,e,r),a.set(i,l,c),this.xrMode===Mv&&!this.isTranslating){const e=s.y-l;this.placementComplete&&!1===this.placeOnWall?(n.offsetHeight=e/t.scenePivot.scale.x,t.setShadowOffset(e)):0===e&&(this.placementComplete=!0,n.show=!1,t.setShadowIntensity(hv))}this.xrMode!==Mv&&s.equals(a)&&t.setShadowIntensity(hv),this.isWorldSpaceReady()&&t.setShadowIntensity(hv)}if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone&&this.goalScale!==i.scale.x){const t=this.scaleDamper.update(i.scale.x,this.goalScale,e,1);i.scale.set(t,t,t)}return t.updateTarget(e),o}updateYaw(t,e){_v.setFromAxisAngle(xv.set(0,1,0),this.goalYaw);const i=t.scenePivot.quaternion.angleTo(_v),n=i-this.yawDamper.update(i,0,e,Math.PI);t.scenePivot.quaternion.rotateTowards(_v,n)}updateMenuPanel(t,e,i){this.menuPanel&&(this.menuPanel.updateOpacity(i),this.menuPanel.updatePosition(t.getCamera(),e))}applyXRInputToScene(t){const e=this.presentedScene,i=e.scenePivot,n=this.placementBox;if(this.updatePlacementBoxOpacity(n,t),this.updateTwoHandInteractionState(),this.applyXRControllerRotations(i),this.handleScalingInXR(e,t),i.parent!==e)return void this.updateMenuPanel(e,n,t);const r=this.updatePivotPosition(e,t);this.updateYaw(e,t),this.dispatchCameraChangeEvent(e,r),this.updateMenuPanel(e,n,t)}updatePlacementBoxOpacity(t,e){const i=this.presentedScene.getCamera();t.update(e,i.position);const n=this.hover(this.xrController1),r=this.hover(this.xrController2),s=(n||r)&&!this.isTwoHandInteraction;t.setInteractionState(this.isTranslating||this.isRotating,s)}updateTwoHandInteractionState(){var t,e;const i=(null===(t=this.xrController1)||void 0===t?void 0:t.userData.isSelected)&&(null===(e=this.xrController2)||void 0===e?void 0:e.userData.isSelected);this.isTwoHandInteraction=!!i}applyXRControllerRotations(t){this.isTwoHandInteraction||(this.xrController1&&this.applyXRControllerRotation(this.xrController1,t),this.xrController2&&this.applyXRControllerRotation(this.xrController2,t))}dispatchCameraChangeEvent(t,e){t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:e}}))}updateXRControllerHover(){const t=this.hover(this.xrController1),e=this.hover(this.xrController2),i=(t||e)&&!this.isTwoHandInteraction;this.placementBox&&(this.placementBox.setInteractionState(this.isTranslating||this.isRotating,i),this.placementBox.show=i)}enableWorldSpaceUserInteraction(){this.placementBox&&(this.placementBox.show=!0),this.presentedScene&&this.presentedScene.setShadowIntensity(hv)}handleFirstView(t,e){this.xrMode===Iv&&this.worldSpaceInitialPlacementDone||this.moveToFloor(t),this.processInput(t);const i=e-this.lastTick;this.applyXRInputToScene(i),this.renderer.preRender(this.presentedScene,e,i),this.lastTick=e,this.presentedScene.renderShadow(this.threeRenderer)}onWebXRFrame(t,e){this.xrMode!==Mv&&this.updateXRControllerHover(),this.frame=e,++this.frames;const i=this.threeRenderer.xr.getReferenceSpace(),n=e.getViewerPose(i);null==n&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:yv}));const r=this.presentedScene;if(null==n||null==r||!r.element.loaded)return void this.threeRenderer.clear();!1===this.tracking&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:vv}));let s=!0;for(const i of n.views)this.updateView(i),s&&(this.handleFirstView(e,t),s=!1),this.threeRenderer.render(r,r.getCamera())}calculateWorldSpaceOptimalPlacement(t,e){const i=t.boundingBox,n={x:(i.max.x-i.min.x)/2,y:(i.max.y-i.min.y)/2,z:(i.max.z-i.min.z)/2},r=.15,s=Math.max(1.65,2*Math.max(n.x,n.z)+r),a=15*Math.PI/180,o=new vn(0,-s*Math.sin(a),-s*Math.cos(a)),l=e.matrixWorld,c=o.clone().applyMatrix4(l),h=Math.max(n.x,n.z)+r,u=n.y,d=.3*s,p=.3*s/Math.max(u,pv),A=d/Math.max(h,pv),g=Math.min(p,A);return{position:c.clone().sub(new vn(0,g*n.y,0)),scale:g}}calculateWorldSpaceScaleLimits(t){const e=t.size,i=Math.max(e.x,e.y,e.z),n=Math.max(Math.min(e.x,e.y,e.z),Av),r=pv/Math.max(i,Av),s=70/Math.max(n,Av);this.minScale=Math.min(r,s,this.goalScale),this.maxScale=Math.max(r,s,this.goalScale)}}+const hv=.8,uv=150,dv=new vn(0,1,0),pv=.01,Av=.001,gv="not-presenting",mv="session-started",fv="object-placed",bv="failed",vv="tracking",yv="not-tracking",xv=new vn,_v=new bn,Ev=new Hn,Sv=new vn,Cv=new nc(45,1,.1,100),wv=(new Es).setFromPoints([new vn(0,0,0),new vn(0,0,-1)]),Mv="screen-space",Iv="world-space";class Tv extends sn{isWorldSpaceReady(){return this.xrMode===Iv&&this.worldSpaceInitialPlacementDone}constructor(t){super(),this.renderer=t,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.menuPanel=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.xrMode=null,this.xrController1=null,this.xrController2=null,this.selectedXRController=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new vn,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.lastDragPosition=new vn,this.deltaRotation=new bn,this.scaleLine=new Na(wv),this.firstRatio=0,this.lastAngle=0,this.goalPosition=new vn,this.goalYaw=0,this.goalScale=1,this.xDamper=new jm,this.yDamper=new jm,this.zDamper=new jm,this.yawDamper=new jm,this.pitchDamper=new jm,this.rollDamper=new jm,this.scaleDamper=new jm,this.wasTwoFingering=!1,this.worldSpaceInitialPlacementDone=!1,this.initialModelScale=1,this.minScale=1,this.maxScale=1,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onControllerSelectStart=t=>{var e,i,n;const r=this.presentedScene,s=t.target,a=this.menuPanel;if(null!=this.menuPanel.exitButtonControllerIntersection(r,s))return null===(e=this.menuPanel)||void 0===e||e.dispose(),void this.stopPresenting();if(null!=this.menuPanel.scaleModeButtonControllerIntersection(r,s)){const t=this.menuPanel.handleScaleToggle(this.worldSpaceInitialPlacementDone,this.initialModelScale,this.minScale,this.maxScale);return void(null!==t&&(this.goalScale=t))}a&&(a.show=!1);const o=this.placementBox.controllerIntersection(r,s);if(null!=o){const t=(new Gr).setFromObject(r.scenePivot).min.y+.2;if(o.point.y<=t)null!=this.selectedXRController?(this.selectedXRController.userData.line.visible=!1,r.canScale&&this.isWorldSpaceReady()&&(this.isTwoHandInteraction=!0,this.firstRatio=this.controllerSeparation()/r.scenePivot.scale.x,this.scaleLine.visible=!0)):s.attach(r.scenePivot),this.selectedXRController=s,r.setShadowIntensity(.01);else if(s==this.xrController1?this.xrController1.userData.isSelected=!0:s==this.xrController2&&(this.xrController2.userData.isSelected=!0),(null===(i=this.xrController1)||void 0===i?void 0:i.userData.isSelected)&&(null===(n=this.xrController2)||void 0===n?void 0:n.userData.isSelected))r.canScale&&this.isWorldSpaceReady()&&(this.isTwoHandInteraction=!0,this.firstRatio=this.controllerSeparation()/r.scenePivot.scale.x,this.scaleLine.visible=!0);else{const t=s===this.xrController1?this.xrController2:this.xrController1;s.userData.initialX=s.position.x,t.userData.turning=!1,s.userData.turning=!0,s.userData.line.visible=!1}}},this.onControllerSelectEnd=t=>{const e=t.target;if(e.userData.turning=!1,e.userData.line.visible=!0,this.isTwoHandInteraction=!1,this.scaleLine.visible=!1,e==this.xrController1?this.xrController1.userData.isSelected=!1:e==this.xrController2&&(this.xrController2.userData.isSelected=!1),null!=this.selectedXRController&&this.selectedXRController!=e)return;const i=this.presentedScene;i.attach(i.scenePivot),this.selectedXRController=null,this.goalYaw=Math.atan2(i.scenePivot.matrix.elements[8],i.scenePivot.matrix.elements[10]),this.goalPosition.x=i.scenePivot.position.x,this.goalPosition.z=i.scenePivot.position.z,this.isWorldSpaceReady()&&(this.goalPosition.y=i.scenePivot.position.y);this.menuPanel.show=!0},this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.updateFromModelChanges(),this.placementBox.setScreenSpaceMode(this.xrMode===Mv)),this.xrMode!==Mv&&(this.menuPanel&&(this.menuPanel.dispose(),this.menuPanel=null),this.menuPanel=new cv,this.presentedScene.add(this.menuPanel),this.menuPanel.updatePosition(this.presentedScene.getCamera(),this.placementBox))},this.onSelectStart=t=>{const e=this.transientHitTestSource;if(null==e)return;const i=this.frame.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=this.placementBox;if(1===i.length){this.inputSource=t.inputSource;const{axes:e}=this.inputSource.gamepad,i=r.getHit(this.presentedScene,e[0],e[1]);r.show=!0,null!=i?(this.isTranslating=!0,this.lastDragPosition.copy(i)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*e[0])}else if(2===i.length){r.show=!0,this.isTwoHandInteraction=!0;const{separation:t,angle:e}=this.fingerPolar(i);return this.lastAngle=e,0===this.firstRatio&&(this.firstRatio=t/n.scenePivot.scale.x),void(n.canScale&&this.setScale(t))}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.onBeforeXRSelect=t=>{const e=t.composedPath();for(const i of e)if(i instanceof HTMLElement){const e=i.tagName.toLowerCase();if("input"===e||"button"===e||"select"===e||"textarea"===e||"a"===e||i.hasAttribute("data-pointer-coalesce")||i.classList.contains("interactive")){t.preventDefault();break}}},this.threeRenderer=t.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){Hd();const t=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:[],optionalFeatures:["hit-test","dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(t),this.threeRenderer.xr.cameraAutoUpdate=!1,t}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return Hd(),await navigator.xr.isSessionSupported("immersive-ar")}catch(t){return console.warn("Request to present in WebXR denied:"),console.warn(t),console.warn("Falling back to next ar-mode"),!1}}async present(t,e=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let i=new Promise((t,e)=>{requestAnimationFrame(()=>t())});t.setHotspotsVisibility(!1),t.queueRender(),await i,this._presentedScene=t,this.overlay=t.element.shadowRoot.querySelector("div.default"),null!=this.overlay&&this.overlay.addEventListener("beforexrselect",this.onBeforeXRSelect),!0===e&&(this.xrLight=new qm(this.threeRenderer),this.xrLight.addEventListener("estimationstart",()=>{if(!this.isPresenting||null==this.xrLight)return;const t=this.presentedScene;t.add(this.xrLight),t.environment=this.xrLight.environment}));const n=await this.resolveARSession();n.addEventListener("end",()=>{this.postSessionCleanup()},{once:!0});const r=t.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");r.classList.add("enabled"),r.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=r;const s=await n.requestReferenceSpace("viewer");this.xrMode=n.interactionMode,this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=t.yaw,this.goalYaw=t.yaw,this.goalScale=1,t.setBackground(null),this.oldShadowIntensity=t.shadowIntensity,t.setShadowIntensity(.01),this.oldTarget.copy(t.getTarget()),t.element.addEventListener("load",this.onUpdateScene);const a=20*Math.PI/180,o=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(a),z:-Math.cos(a)});n.requestHitTestSource({space:s,offsetRay:o}).then(t=>{this.initialHitSource=t}),this.xrMode!==Mv&&(this.setupXRControllers(),this.xDamper.setDecayTime(uv),this.yDamper.setDecayTime(uv),this.zDamper.setDecayTime(uv),this.yawDamper.setDecayTime(uv),this.pitchDamper.setDecayTime(uv),this.rollDamper.setDecayTime(uv),this.scaleDamper.setDecayTime(uv)),this.currentSession=n,this.placementBox=new Jm(t,this.placeOnWall?"back":"bottom"),this.placementBox&&this.placementBox.setScreenSpaceMode(this.xrMode===Mv),this.placementComplete=!1,this.xrMode!==Mv&&(this.menuPanel=new cv,t.add(this.menuPanel),this.menuPanel.updatePosition(t.getCamera(),this.placementBox)),this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:mv})}setupXRControllerLine(t){if(!t.userData.line){const e=new Na(wv);e.name="line",e.scale.z=5,t.userData.turning=!1,t.userData.line=e,t.add(e)}}setupController(t){this.setupXRControllerLine(t),t.addEventListener("selectstart",this.onControllerSelectStart),t.addEventListener("selectend",this.onControllerSelectEnd)}setupXRControllers(){this.xrController1=this.threeRenderer.xr.getController(0),this.xrController2=this.threeRenderer.xr.getController(1),this.setupController(this.xrController1),this.setupController(this.xrController2),this.scaleLine.name="scale line",this.scaleLine.visible=!1,this.xrController1.add(this.scaleLine);const t=this.presentedScene;t.add(this.xrController1),t.add(this.xrController2)}hover(t){if(this.xrMode===Mv||this.selectedXRController==t)return!1;const e=this.presentedScene,i=this.placementBox.controllerIntersection(e,t);return t.userData.line.scale.z=null==i?5:i.distance,null!=i}controllerSeparation(){return this.xrController1.position.distanceTo(this.xrController2.position)}async stopPresenting(){if(!this.isPresenting)return;const t=new Promise(t=>{this.resolveCleanup=t});try{await this.currentSession.end(),await t}catch(t){console.warn("Error while trying to end WebXR AR session"),console.warn(t),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const t=this.presentedScene;if(null!=t){const e=t.getTarget();this.oldTarget.copy(e),this.placeOnWall?e.z=t.boundingBox.min.z:e.y=t.boundingBox.min.y,t.setTarget(e.x,e.y,e.z)}}cleanupXRController(t){t.userData.turning=!1,t.userData.line.visible=!0,t.removeEventListener("selectstart",this.onControllerSelectStart),t.removeEventListener("selectend",this.onControllerSelectEnd),t.removeFromParent()}postSessionCleanup(){const t=this.currentSession;null!=t&&(t.removeEventListener("selectstart",this.onSelectStart),t.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const e=this.presentedScene;if(this._presentedScene=null,null!=e){const{element:t}=e;null!=this.xrLight&&(e.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),null!=this.menuPanel&&(this.menuPanel.dispose(),this.menuPanel=null),e.add(e.scenePivot),e.scenePivot.quaternion.set(0,0,0,1),e.scenePivot.position.set(0,0,0),e.scenePivot.scale.set(1,1,1),e.setShadowOffset(0);const i=this.turntableRotation;null!=i&&(e.yaw=i);const n=this.oldShadowIntensity;null!=n&&e.setShadowIntensity(n),e.setEnvironmentAndSkybox(t[Kd],t[Jd]);const r=this.oldTarget;e.setTarget(r.x,r.y,r.z),e.xrCamera=null,e.element.removeEventListener("load",this.onUpdateScene),e.orientHotspots(0);const{width:s,height:a}=t.getBoundingClientRect();e.setSize(s,a),requestAnimationFrame(()=>{e.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:$b.NONE}}))})}this.renderer.height=0;const i=this.exitWebXRButtonContainer;null!=i&&(i.classList.remove("enabled"),i.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const n=this.transientHitTestSource;null!=n&&(n.cancel(),this.transientHitTestSource=null);const r=this.initialHitSource;null!=r&&(r.cancel(),this.initialHitSource=null),null!=this.placementBox&&(this.placementBox.dispose(),this.placementBox=null),this.xrMode!==Mv&&(null!=this.xrController1&&(this.cleanupXRController(this.xrController1),this.xrController1=null),null!=this.xrController2&&(this.cleanupXRController(this.xrController2),this.xrController2=null),this.selectedXRController=null,this.scaleLine.visible=!1),this.isTranslating=!1,this.isRotating=!1,this.isTwoHandInteraction=!1,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,null!=this.overlay&&(this.overlay.removeEventListener("beforexrselect",this.onBeforeXRSelect),this.overlay=null),this.worldSpaceInitialPlacementDone=!1,null!=this.resolveCleanup&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:gv})}updateView(t){const e=this.presentedScene,i=this.threeRenderer.xr;i.updateCamera(Cv),e.xrCamera=i.getCamera();const{elements:n}=e.getCamera().matrixWorld;if(e.orientHotspots(Math.atan2(n[1],n[5])),this.initialized||(this.placeInitially(),this.initialized=!0),t.requestViewportScale&&t.recommendedViewportScale){const e=t.recommendedViewportScale;t.requestViewportScale(Math.max(e,.25))}const r=i.getBaseLayer();if(null!=r){const e=r instanceof XRWebGLLayer?r.getViewport(t):i.getBinding().getViewSubImage(r,t).viewport;this.threeRenderer.setViewport(e.x,e.y,e.width,e.height)}}placeInitially(){const t=this.presentedScene,{scenePivot:e,element:i}=t,{position:n}=e,r=t.getCamera(),{width:s,height:a}=this.overlay.getBoundingClientRect();t.setSize(s,a),r.projectionMatrixInverse.copy(r.projectionMatrix).invert();const{theta:o}=i.getCameraOrbit(),l=r.getWorldDirection(xv);if(t.yaw=Math.atan2(-l.x,-l.z)-o,this.goalYaw=t.yaw,this.xrMode!==Iv||this.worldSpaceInitialPlacementDone){if(this.xrMode===Mv){const e=Math.max(1,2*t.boundingSphere.radius);n.copy(r.position).add(l.multiplyScalar(e)),this.updateTarget();const i=t.getTarget();n.add(i).sub(this.oldTarget),this.goalPosition.copy(n)}}else{const{position:i,scale:s}=this.calculateWorldSpaceOptimalPlacement(t,r);this.goalPosition.copy(i),this.goalScale=s,this.initialModelScale=s,n.copy(i),e.scale.set(s,s,s),this.worldSpaceInitialPlacementDone=!0,this.calculateWorldSpaceScaleLimits(t),this.enableWorldSpaceUserInteraction()}if(t.setHotspotsVisibility(!0),this.xrMode===Mv){const{session:t}=this.frame;t.addEventListener("selectstart",this.onSelectStart),t.addEventListener("selectend",this.onSelectEnd),t.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then(t=>{this.transientHitTestSource=t})}}getTouchLocation(){const{axes:t}=this.inputSource.gamepad;let e=this.placementBox.getExpandedHit(this.presentedScene,t[0],t[1]);return null!=e&&(xv.copy(e).sub(this.presentedScene.getCamera().position),xv.length()>10)?null:e}getHitPoint(t){const e=this.threeRenderer.xr.getReferenceSpace(),i=t.getPose(e);if(null==i)return null;const n=Ev.fromArray(i.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(n.elements[4],n.elements[6])),n.elements[5]>.75!==this.placeOnWall?Sv.setFromMatrixPosition(n):null}moveToFloor(t){if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone)return this.placementBox.show=!1,void this.dispatchEvent({type:"status",status:fv});const e=this.initialHitSource;if(null==e)return;const i=t.getHitTestResults(e);if(0==i.length)return;const n=i[0],r=this.getHitPoint(n);null!=r&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(r):this.goalPosition.y=r.y),e.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:fv}))}fingerPolar(t){const e=t[0].inputSource.gamepad.axes,i=t[1].inputSource.gamepad.axes,n=i[0]-e[0],r=i[1]-e[1],s=Math.atan2(r,n);let a=this.lastAngle-s;return a>Math.PI?a-=2*Math.PI:a<-Math.PI&&(a+=2*Math.PI),{separation:Math.sqrt(n*n+r*r),deltaYaw:a,angle:s}}setScale(t){let e=t/this.firstRatio;e=Math.abs(e-1)<.2?1:e,this.isWorldSpaceReady()&&(e=Math.max(this.minScale,Math.min(this.maxScale,e))),this.goalScale=e}processInput(t){const e=this.transientHitTestSource;if(null==e)return;const i=t.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=n.scenePivot.scale.x;if(2===i.length){if(!this.wasTwoFingering){const{separation:t,angle:e}=this.fingerPolar(i);return this.firstRatio=t/r,this.lastAngle=e,this.wasTwoFingering=!0,void(this.isTwoHandInteraction=!0)}const{separation:t,deltaYaw:e,angle:s}=this.fingerPolar(i);return this.goalYaw+=e,this.lastAngle=s,n.canScale&&this.setScale(t),void(this.isTwoHandInteraction=!0)}if(this.wasTwoFingering&&(this.wasTwoFingering=!1,this.isTwoHandInteraction=!1,this.firstRatio=0),this.isTranslating||this.isTwoHandInteraction||this.isRotating)if(this.isRotating){const t=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=t-this.lastAngle,this.lastAngle=t}else this.isTranslating&&i.forEach(t=>{if(t.inputSource!==this.inputSource)return;let e=null;if(t.results.length>0&&(e=this.getHitPoint(t.results[0])),null==e&&(e=this.getTouchLocation()),null!=e){if(this.goalPosition.sub(this.lastDragPosition),this.isWorldSpaceReady())this.goalPosition.add(e);else if(!1===this.placeOnWall){const t=e.y-this.lastDragPosition.y;if(t<0){this.placementBox.offsetHeight=t/r,this.presentedScene.setShadowOffset(t);const i=xv.copy(n.getCamera().position),s=-t/(i.y-e.y);i.multiplyScalar(s),e.multiplyScalar(1-s).add(i)}this.goalPosition.add(e)}else this.goalPosition.add(e);this.lastDragPosition.copy(e)}})}applyXRControllerRotation(t,e){if(!t.userData.turning)return;const i=.3*(t.position.x-t.userData.initialX);this.deltaRotation.setFromAxisAngle(dv,i),e.quaternion.multiplyQuaternions(this.deltaRotation,e.quaternion)}handleScalingInXR(t,e){if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone)return;if(this.xrController1&&this.xrController2&&this.isTwoHandInteraction){const t=this.controllerSeparation();this.setScale(t),this.scaleLine.scale.z=-t,this.scaleLine.lookAt(this.xrController2.position)}const i=t.scenePivot.scale.x;if(this.goalScale!==i){const n=this.scaleDamper.update(i,this.goalScale,e,1);t.scenePivot.scale.set(n,n,n)}}updatePivotPosition(t,e){const{scenePivot:i}=t,n=this.placementBox,r=t.boundingSphere.radius,s=this.goalPosition,a=i.position;let o=$b.NONE;if(!s.equals(a)){o=$b.USER_INTERACTION;let{x:i,y:l,z:c}=a;if(i=this.xDamper.update(i,s.x,e,r),l=this.yDamper.update(l,s.y,e,r),c=this.zDamper.update(c,s.z,e,r),a.set(i,l,c),this.xrMode===Mv&&!this.isTranslating){const e=s.y-l;this.placementComplete&&!1===this.placeOnWall?(n.offsetHeight=e/t.scenePivot.scale.x,t.setShadowOffset(e)):0===e&&(this.placementComplete=!0,n.show=!1,t.setShadowIntensity(hv))}this.xrMode!==Mv&&s.equals(a)&&t.setShadowIntensity(hv),this.isWorldSpaceReady()&&t.setShadowIntensity(hv)}if(this.xrMode===Iv&&!this.worldSpaceInitialPlacementDone&&this.goalScale!==i.scale.x){const t=this.scaleDamper.update(i.scale.x,this.goalScale,e,1);i.scale.set(t,t,t)}return t.updateTarget(e),o}updateYaw(t,e){_v.setFromAxisAngle(xv.set(0,1,0),this.goalYaw);const i=t.scenePivot.quaternion.angleTo(_v),n=i-this.yawDamper.update(i,0,e,Math.PI);t.scenePivot.quaternion.rotateTowards(_v,n)}updateMenuPanel(t,e,i){this.menuPanel&&(this.menuPanel.updateOpacity(i),this.menuPanel.updatePosition(t.getCamera(),e))}applyXRInputToScene(t){const e=this.presentedScene,i=e.scenePivot,n=this.placementBox;if(this.updatePlacementBoxOpacity(n,t),this.updateTwoHandInteractionState(),this.applyXRControllerRotations(i),this.handleScalingInXR(e,t),i.parent!==e)return void this.updateMenuPanel(e,n,t);const r=this.updatePivotPosition(e,t);this.updateYaw(e,t),this.dispatchCameraChangeEvent(e,r),this.updateMenuPanel(e,n,t)}updatePlacementBoxOpacity(t,e){const i=this.presentedScene.getCamera();t.update(e,i.position);const n=this.hover(this.xrController1),r=this.hover(this.xrController2),s=(n||r)&&!this.isTwoHandInteraction;t.setInteractionState(this.isTranslating||this.isRotating,s)}updateTwoHandInteractionState(){var t,e;const i=(null===(t=this.xrController1)||void 0===t?void 0:t.userData.isSelected)&&(null===(e=this.xrController2)||void 0===e?void 0:e.userData.isSelected);this.isTwoHandInteraction=!!i}applyXRControllerRotations(t){this.isTwoHandInteraction||(this.xrController1&&this.applyXRControllerRotation(this.xrController1,t),this.xrController2&&this.applyXRControllerRotation(this.xrController2,t))}dispatchCameraChangeEvent(t,e){t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:e}}))}updateXRControllerHover(){const t=this.hover(this.xrController1),e=this.hover(this.xrController2),i=(t||e)&&!this.isTwoHandInteraction;this.placementBox&&(this.placementBox.setInteractionState(this.isTranslating||this.isRotating,i),this.placementBox.show=i)}enableWorldSpaceUserInteraction(){this.placementBox&&(this.placementBox.show=!0),this.presentedScene&&this.presentedScene.setShadowIntensity(hv)}handleFirstView(t,e){this.xrMode===Iv&&this.worldSpaceInitialPlacementDone||this.moveToFloor(t),this.processInput(t);const i=e-this.lastTick;this.applyXRInputToScene(i),this.renderer.preRender(this.presentedScene,e,i),this.lastTick=e,this.presentedScene.renderShadow(this.threeRenderer)}onWebXRFrame(t,e){this.xrMode!==Mv&&this.updateXRControllerHover(),this.frame=e,++this.frames;const i=this.threeRenderer.xr.getReferenceSpace(),n=e.getViewerPose(i);null==n&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:yv}));const r=this.presentedScene;if(null==n||null==r||!r.element.loaded)return void this.threeRenderer.clear();!1===this.tracking&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:vv}));let s=!0;for(const i of n.views)this.updateView(i),s&&(this.handleFirstView(e,t),s=!1),this.threeRenderer.render(r,r.getCamera())}calculateWorldSpaceOptimalPlacement(t,e){const i=t.boundingBox,n={x:(i.max.x-i.min.x)/2,y:(i.max.y-i.min.y)/2,z:(i.max.z-i.min.z)/2},r=.15,s=Math.max(1.65,2*Math.max(n.x,n.z)+r),a=15*Math.PI/180,o=new vn(0,-s*Math.sin(a),-s*Math.cos(a)),l=e.matrixWorld,c=o.clone().applyMatrix4(l),h=Math.max(n.x,n.z)+r,u=n.y,d=.3*s,p=.3*s/Math.max(u,pv),A=d/Math.max(h,pv),g=Math.min(p,A);return{position:c.clone().sub(new vn(0,g*n.y,0)),scale:g}}calculateWorldSpaceScaleLimits(t){const e=t.size,i=Math.max(e.x,e.y,e.z),n=Math.max(Math.min(e.x,e.y,e.z),Av),r=pv/Math.max(i,Av),s=70/Math.max(n,Av);this.minScale=Math.min(r,s,this.goalScale),this.maxScale=Math.max(r,s,this.goalScale)}}/* @license* Copyright 2020 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -806,7 +806,7 @@ const hv=.8,uv=150,dv=new vn(0,1,0),pv=.01,Av=.001,gv="not-presenting",mv="sessi* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.- */const uy=20,dy=/\.hdr(\.js)?$/,py=/\.ktx2(\?|#|$)/;class Ay{constructor(t){this.threeRenderer=t,this.lottieLoaderUrl="",this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}ldrLoader(t){return null==this._ldrLoader&&(this._ldrLoader=new Vl),this._ldrLoader.setWithCredentials(t),this._ldrLoader}imageLoader(t){return null==this._imageLoader&&(this._imageLoader=new sy(this.threeRenderer)),this._imageLoader.setWithCredentials(t),this._imageLoader}hdrLoader(t){return null==this._hdrLoader&&(this._hdrLoader=new oy,this._hdrLoader.setDataType(Se)),this._hdrLoader.setWithCredentials(t),this._hdrLoader}async getLottieLoader(t){if(null==this._lottieLoader){const{LottieLoader:t}=await import(this.lottieLoaderUrl);this._lottieLoader=new t}return this._lottieLoader.setWithCredentials(t),this._lottieLoader}async loadImage(t,e,i){if("image/ktx2"===i||py.test(t))return this.loadKTX2(t,e);const n=await new Promise((i,n)=>this.ldrLoader(e).load(t,i,()=>{},n));return n.name=t,n.flipY=!1,n}async loadKTX2(t,e){Ig.setWithCredentials(e);const i=await new Promise((e,i)=>Ig.load(t,e,()=>{},i));return i.name=t,i.flipY=!1,i}async loadLottie(t,e,i){const n=await this.getLottieLoader(i);n.setQuality(e);const r=await new Promise((e,i)=>n.load(t,e,()=>{},i));return r.name=t,r}async loadEquirect(t,e=!1,i=()=>{}){try{const n=dy.test(t),r=n?this.hdrLoader(e):this.imageLoader(e),s=await new Promise((e,n)=>r.load(t,t=>{const{renderTarget:i}=t;if(null!=i){let n;try{const e=t.toDataTexture();e.needsUpdate=!0;const r=e.image.data;let s=!1;const a=r.length;for(let t=0;t<a;t++)if(0!==r[t]){s=!0;break}s?(n=e,t.dispose(!0)):(console.warn("Decoded DataTexture is completely black, falling back to render target texture."),n=i.texture,t.dispose(!1))}catch(e){console.warn("Failed to convert gainmap to DataTexture, falling back to render target texture:",e),n=i.texture,t.dispose(!1)}e(n)}else e(t)},t=>{i(t.loaded/t.total*.9)},n));return i(1),s.name=t,s.mapping=se,n||s.type===Se||(s.colorSpace=Di),s}finally{i&&i(1)}}async generateEnvironmentMapAndSkybox(t=null,e=null,i=()=>{},n=!1){const r="legacy"!==e;"legacy"!==e&&"neutral"!==e||(e=null),e=zd(e);let s,a=Promise.resolve(null);t&&(a=this.loadEquirectFromUrl(t,n,i)),s=e?this.loadEquirectFromUrl(e,n,i):t?this.loadEquirectFromUrl(t,n,i):r?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[o,l]=await Promise.all([s,a]);if(null==o)throw new Error("Failed to load environment map.");return{environmentMap:o,skybox:l}}async loadEquirectFromUrl(t,e,i){if(!this.skyboxCache.has(t)){const n=this.loadEquirect(t,e,i);this.skyboxCache.set(t,n)}return this.skyboxCache.get(t)}async GenerateEnvironmentMap(t,e){await((t=0)=>new Promise(e=>setTimeout(e,t)))();const i=this.threeRenderer,n=new hh(256,{generateMipmaps:!1,type:Se,format:Re,colorSpace:Li,depthBuffer:!0}),r=new fc(.1,100,n),s=r.renderTarget.texture;s.name=e;const a=i.outputColorSpace,o=i.toneMapping;return i.toneMapping=0,i.outputColorSpace=Li,r.update(i,t),this.blurCubemap(n,.04),i.toneMapping=o,i.outputColorSpace=a,s}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new hy("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new hy("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(t,e){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(uy);const t=new so,e=new Ks(t,this.blurMaterial);this.blurScene=new wr,this.blurScene.add(e)}const i=t.clone();this.halfblur(t,i,e,"latitudinal"),this.halfblur(i,t,e,"longitudinal")}halfblur(t,e,i,n){const r=t.width,s=isFinite(i)?Math.PI/(2*r):2*Math.PI/39,a=i/s,o=isFinite(i)?1+Math.floor(3*a):uy;o>uy&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${o} samples when the maximum is set to 20`);const l=[];let c=0;for(let t=0;t<uy;++t){const e=t/a,i=Math.exp(-e*e/2);l.push(i),0==t?c+=i:t<o&&(c+=2*i)}for(let t=0;t<l.length;t++)l[t]=l[t]/c;const h=this.blurMaterial.uniforms;h.envMap.value=t.texture,h.samples.value=o,h.weights.value=l,h.latitudinal.value="latitudinal"===n,h.dTheta.value=s;new fc(.1,100,e).update(this.threeRenderer,this.blurScene)}getBlurShader(t){const e=new Float32Array(t),i=new vn(0,1,0);return new ll({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:i}},vertexShader:"\n \n varying vec3 vOutputDirection;\n \n void main() {\n \n vOutputDirection = vec3( position );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n \n }\n ",fragmentShader:"\n varying vec3 vOutputDirection;\n \n uniform samplerCube envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform vec3 poleAxis;\n \n vec3 getSample( float theta, vec3 axis ) {\n \n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n \n return vec3( textureCube( envMap, sampleDirection ) );\n \n }\n \n void main() {\n \n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n \n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n \n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n \n }\n \n axis = normalize( axis );\n \n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n \n for ( int i = 1; i < n; i++ ) {\n \n if ( i >= samples ) {\n \n break;\n \n }\n \n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n \n }\n }\n ",blending:0,depthTest:!1,depthWrite:!1,side:1})}async dispose(){for(const[,t]of this.skyboxCache){(await t).dispose()}null!=this.generatedEnvironmentMap&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),null!=this.generatedEnvironmentMapAlt&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),null!=this.blurMaterial&&this.blurMaterial.dispose()}}+ */const uy=20,dy=/\.hdr(\.js)?$/,py=/\.ktx2(\?|#|$)/;class Ay{constructor(t){this.threeRenderer=t,this.lottieLoaderUrl="",this._ldrLoader=null,this._imageLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}ldrLoader(t){return null==this._ldrLoader&&(this._ldrLoader=new Vl),this._ldrLoader.setWithCredentials(t),this._ldrLoader}imageLoader(t){return null==this._imageLoader&&(this._imageLoader=new sy(this.threeRenderer)),this._imageLoader.setWithCredentials(t),this._imageLoader}hdrLoader(t){return null==this._hdrLoader&&(this._hdrLoader=new oy,this._hdrLoader.setDataType(Se)),this._hdrLoader.setWithCredentials(t),this._hdrLoader}async getLottieLoader(t){if(null==this._lottieLoader){const{LottieLoader:t}=await import(this.lottieLoaderUrl);this._lottieLoader=new t}return this._lottieLoader.setWithCredentials(t),this._lottieLoader}async loadImage(t,e,i){if("image/ktx2"===i||py.test(t))return this.loadKTX2(t,e);const n=await new Promise((i,n)=>this.ldrLoader(e).load(t,i,()=>{},n));return n.name=t,n.flipY=!1,n}async loadKTX2(t,e){Ig.setWithCredentials(e);const i=await new Promise((e,i)=>Ig.load(t,e,()=>{},i));return i.name=t,i.flipY=!1,i}async loadLottie(t,e,i){const n=await this.getLottieLoader(i);n.setQuality(e);const r=await new Promise((e,i)=>n.load(t,e,()=>{},i));return r.name=t,r}async loadEquirect(t,e=!1,i=()=>{}){try{const n=dy.test(t),r=n?this.hdrLoader(e):this.imageLoader(e),s=await new Promise((e,n)=>r.load(t,t=>{const{renderTarget:i}=t;if(null!=i){let n;try{const e=t.toDataTexture();e.needsUpdate=!0;const r=e.image.data;let s=!1;const a=r.length;for(let t=0;t<a;t++)if(0!==r[t]){s=!0;break}s?(n=e,t.dispose(!0)):(console.warn("Decoded DataTexture is completely black, falling back to render target texture."),n=i.texture,t.dispose(!1))}catch(e){console.warn("Failed to convert gainmap to DataTexture, falling back to render target texture:",e),n=i.texture,t.dispose(!1)}e(n)}else e(t)},t=>{i(t.loaded/t.total*.9)},n));return i(1),s.name=t,s.mapping=se,n||s.type===Se||(s.colorSpace=Di),s}finally{i&&i(1)}}async generateEnvironmentMapAndSkybox(t=null,e=null,i=()=>{},n=!1){const r="legacy"!==e;"legacy"!==e&&"neutral"!==e||(e=null),e=zd(e);let s,a=Promise.resolve(null);t&&(a=this.loadEquirectFromUrl(t,n,i)),s=e?this.loadEquirectFromUrl(e,n,i):t?this.loadEquirectFromUrl(t,n,i):r?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[o,l]=await Promise.all([s,a]);if(null==o)throw new Error("Failed to load environment map.");return{environmentMap:o,skybox:l}}async loadEquirectFromUrl(t,e,i){if(!this.skyboxCache.has(t)){const n=this.loadEquirect(t,e,i);this.skyboxCache.set(t,n),n.catch(()=>{this.skyboxCache.get(t)===n&&this.skyboxCache.delete(t)})}return this.skyboxCache.get(t)}async GenerateEnvironmentMap(t,e){await((t=0)=>new Promise(e=>setTimeout(e,t)))();const i=this.threeRenderer,n=new hh(256,{generateMipmaps:!1,type:Se,format:Re,colorSpace:Li,depthBuffer:!0}),r=new fc(.1,100,n),s=r.renderTarget.texture;s.name=e;const a=i.outputColorSpace,o=i.toneMapping;return i.toneMapping=0,i.outputColorSpace=Li,r.update(i,t),this.blurCubemap(n,.04),i.toneMapping=o,i.outputColorSpace=a,s}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new hy("legacy"),"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new hy("neutral"),"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(t,e){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(uy);const t=new so,e=new Ks(t,this.blurMaterial);this.blurScene=new wr,this.blurScene.add(e)}const i=t.clone();this.halfblur(t,i,e,"latitudinal"),this.halfblur(i,t,e,"longitudinal")}halfblur(t,e,i,n){const r=t.width,s=isFinite(i)?Math.PI/(2*r):2*Math.PI/39,a=i/s,o=isFinite(i)?1+Math.floor(3*a):uy;o>uy&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${o} samples when the maximum is set to 20`);const l=[];let c=0;for(let t=0;t<uy;++t){const e=t/a,i=Math.exp(-e*e/2);l.push(i),0==t?c+=i:t<o&&(c+=2*i)}for(let t=0;t<l.length;t++)l[t]=l[t]/c;const h=this.blurMaterial.uniforms;h.envMap.value=t.texture,h.samples.value=o,h.weights.value=l,h.latitudinal.value="latitudinal"===n,h.dTheta.value=s;new fc(.1,100,e).update(this.threeRenderer,this.blurScene)}getBlurShader(t){const e=new Float32Array(t),i=new vn(0,1,0);return new ll({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:i}},vertexShader:"\n \n varying vec3 vOutputDirection;\n \n void main() {\n \n vOutputDirection = vec3( position );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n \n }\n ",fragmentShader:"\n varying vec3 vOutputDirection;\n \n uniform samplerCube envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform vec3 poleAxis;\n \n vec3 getSample( float theta, vec3 axis ) {\n \n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n \n return vec3( textureCube( envMap, sampleDirection ) );\n \n }\n \n void main() {\n \n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n \n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n \n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n \n }\n \n axis = normalize( axis );\n \n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n \n for ( int i = 1; i < n; i++ ) {\n \n if ( i >= samples ) {\n \n break;\n \n }\n \n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n \n }\n }\n ",blending:0,depthTest:!1,depthWrite:!1,side:1})}async dispose(){for(const[,t]of this.skyboxCache){(await t).dispose()}null!=this.generatedEnvironmentMap&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),null!=this.generatedEnvironmentMapAlt&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),null!=this.blurMaterial&&this.blurMaterial.dispose()}}/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1005,7 +1005,7 @@ class s_ extends Ks{constructor(){super(void 0,new Ns({depthWrite:!1})),this.hei* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.- */const f_=new vn,b_=new vn,v_=new vn,y_=new class{constructor(t,e,i=0,n=1/0){this.ray=new Us(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new tr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):en("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Rc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rc),this}intersectObject(t,e=!0,i=[]){return Lc(t,this,i,e),i.sort(Dc),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;n<r;n++)Lc(t[n],this,i,e);return i.sort(Dc),i}},x_=new vn,__=new fn;class E_ extends wr{constructor({canvas:t,element:e,width:i,height:n}){super(),this.annotationRenderer=new Gg,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.appendedAnimations=[],this.markedAnimations=[],this.camera=new nc(45,1,.1,100),this.xrCamera=null,this.url=null,this.extraUrls=[],this.scenePivot=new mr,this.target=new mr,this.animationNames=[],this.boundingBox=new Gr,this.boundingSphere=new gs,this.size=new vn,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=7,this.canScale=!0,this.isDirty=!1,this.goalTarget=new vn,this.targetDamperX=new jm,this.targetDamperY=new jm,this.targetDamperZ=new jm,this._currentGLTFs=[],this._models=[],this.boundsAndShadowDirty=!1,this.mixers=[],this.mixerPausedStates=[],this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationActions=[],this.groundedSkybox=new s_,this.name="ModelScene",this.element=e,this.canvas=t,this.camera=new nc(45,1,.1,100),this.camera.name="MainCamera",this.add(this.scenePivot),this.scenePivot.name="Pivot",this.scenePivot.add(this.target),this.setSize(i,n),this.target.name="Target",this.mixers=[];const{domElement:r}=this.annotationRenderer,{style:s}=r;s.display="none",s.pointerEvents="none",s.position="absolute",s.top="0",this.element.shadowRoot.querySelector(".default").appendChild(r),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return null!=this.xrCamera?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(t){this.reset(),this._models=[t],this.target.add(t),await this.setupScene()}async setSource(t,e=[],i=()=>{}){if((!t||t===this.url)&&e.join(",")===this.extraUrls.join(","))return void i(1);if(this.reset(),this.url=t,this.extraUrls=e,null!=this.externalRenderer){const t=await this.externalRenderer.load(i);return this.boundingSphere.radius=t.framedRadius,void(this.idealAspect=t.fieldOfViewAspect)}null!=this.cancelPendingSourceChange&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);let n=[];try{const r=[];t&&r.push(t),e&&r.push(...e),r.length>0&&(n=await new Promise((t,e)=>{this.cancelPendingSourceChange=()=>e(),(async()=>{try{const e=await Promise.all(r.map(t=>this.element[bE].loader.load(t,this.element,i)));t(e)}catch(t){e(t)}})()}))}catch(t){if(null==t)return;throw t}this.cancelPendingSourceChange=null,this.reset(),this.url=t,this.extraUrls=e,this._currentGLTFs=n;for(const t of n)null!=t?(this._models.push(t.scene),this.target.add(t.scene),this.mixers.push(new Tc(t.scene)),this.mixerPausedStates.push(!1),this.currentAnimationActions.push(null)):(this.mixers.push(new Tc(this.target)),this.mixerPausedStates.push(!1),this.currentAnimationActions.push(null));const r=new Map,s=[],a=[];for(const t of n)for(const e of t.animations||[])r.set(e.name,e),s.push(e.name),a.push(e);this.animations=a,this.animationsByName=r,this.animationNames=s,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}updateModelTransforms(t,e,i,n){const r=this._models[t];if(r){if(e){const t=e.split(" ").map(t=>t.trim()).filter(t=>t.length>0).map(Number);3!==t.length||t.some(isNaN)||r.position.set(t[0],t[1],t[2])}if(n){const t=n.split(" ").map(t=>t.trim()).filter(t=>t.length>0).map(Number);1!==t.length||isNaN(t[0])?3!==t.length||t.some(isNaN)||r.scale.set(t[0],t[1],t[2]):r.scale.setScalar(t[0])}r.updateMatrixWorld(!0),this.boundsAndShadowDirty=!0,this.queueRender()}}updateBoundingBoxAndShadowIfDirty(){this.boundsAndShadowDirty&&(this.boundsAndShadowDirty=!1,this.updateBoundingBox(),this.updateShadow())}reset(){this.url=null,this.renderCount=0,this.queueRender(),null!=this.shadow&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_models:t}=this;for(const e of t)null!=e&&e.removeFromParent();this._models=[];const e=this._currentGLTFs;for(const t of e)null!=t&&t.dispose();this._currentGLTFs=[];for(const t of this.currentAnimationActions)null!=t&&t.stop();this.currentAnimationActions=[];for(const t of this.mixers)t.stopAllAction(),t.uncacheRoot(this);this.mixers=[],this.mixerPausedStates=[]}dispose(){this.reset(),null!=this.shadow&&(this.shadow.dispose(),this.shadow=null),this.element[Zx]=null,this.element[t_]=null,this.element[e_]=null}get currentGLTF(){return this._currentGLTFs[0]||null}get currentGLTFs(){return this._currentGLTFs}setSize(t,e){if(this.width!==t||this.height!==e){if(this.width=Math.max(t,1),this.height=Math.max(e,1),this.annotationRenderer.setSize(t,e),this.aspect=this.width/this.height,null!=this.externalRenderer){const i=window.devicePixelRatio;this.externalRenderer.resize(t*i,e*i)}this.queueRender()}}markBakedShadow(t){t.userData.noHit=!0,this.bakedShadows.add(t)}unmarkBakedShadow(t){t.userData.noHit=!1,t.visible=!0,this.bakedShadows.delete(t),this.boundingBox.expandByObject(t)}findBakedShadows(t){const e=new Gr;t.traverse(t=>{const i=t;if(!i.material)return;if(!i.material.transparent)return;e.setFromObject(i);const n=e.getSize(x_),r=Math.min(n.x,n.y,n.z);Math.max(n.x,n.y,n.z)<100*r||this.markBakedShadow(i)})}checkBakedShadows(){const{min:t,max:e}=this.boundingBox,i=new Gr;this.boundingBox.getSize(this.size);for(const n of this.bakedShadows)i.setFromObject(n),i.min.y<t.y+this.size.y/100&&i.min.x<=t.x&&i.max.x>=e.x&&i.min.z<=t.z&&i.max.z>=e.z||i.min.z<t.z+this.size.z/100&&i.min.x<=t.x&&i.max.x>=e.x&&i.min.y<=t.y&&i.max.y>=e.y||this.unmarkBakedShadow(n)}applyTransform(){const{models:t}=this;if(0===t.length)return;const e=$m(this.element.orientation)[0].terms,i=hf(e[0]).number,n=hf(e[1]).number,r=hf(e[2]).number,s=$m(this.element.scale)[0].terms;for(const e of t)e.quaternion.setFromEuler(new Zn(n,r,i,"YXZ")),e.scale.set(s[0].number,s[1].number,s[2].number)}updateBoundingBox(){const{models:t}=this;if(0===t.length)return;for(const e of t)this.target.remove(e),this.findBakedShadows(e);const e=(t,e)=>t.expandByPoint(e);this.setBakedShadowVisibility(!1);let i=new Gr;for(const n of t)i=zg(n,e,i);if(this.boundingBox=i,this.boundingBox.isEmpty()){this.setBakedShadowVisibility(!0),this.bakedShadows.forEach(t=>this.unmarkBakedShadow(t)),i=new Gr;for(const n of t)i=zg(n,e,i);this.boundingBox=i}this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size);for(const e of t)this.target.add(e)}async updateFraming(){const{models:t}=this;if(0===t.length)return;for(const e of t)this.target.remove(e);this.setBakedShadowVisibility(!1);const{center:e}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,e.copy(this.getTarget());const i=(t,i)=>Math.max(t,e.distanceToSquared(i));let n=0;for(const e of t)n=Math.max(n,zg(e,i,0));this.boundingSphere.radius=Math.sqrt(n);const r=(t,i)=>{i.sub(e);const n=Math.sqrt(i.x*i.x+i.z*i.z);return Math.max(t,n/(this.idealCameraDistance()-Math.abs(i.y)))};let s=0;for(const e of t)s=Math.max(s,zg(e,r,0));this.idealAspect=s/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility();for(const e of t)this.target.add(e)}setBakedShadowVisibility(t=this.shadowIntensity<=0){for(const e of this.bakedShadows)e.visible=t}idealCameraDistance(){const t=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(t)}adjustedFoV(t){const e=Math.tan(t/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(e)*180/Math.PI}getNDC(t,e){if(null!=this.xrCamera)__.set(t/window.screen.width,e/window.screen.height);else{const i=this.element.getBoundingClientRect();__.set((t-i.x)/this.width,(e-i.y)/this.height)}return __.multiplyScalar(2).subScalar(1),__.y*=-1,__}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(t,e){this.element[bE].arRenderer.presentedScene!==this&&(this.environment=t,this.setBackground(e),this.queueRender())}setBackground(t){this.groundedSkybox.map=t,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=t)}farRadius(){return this.boundingSphere.radius*(null!=this.groundedSkybox.parent?10:1)}setGroundedSkybox(){const t=$m(this.element.skyboxHeight)[0].terms[0],e=hf(t).number,i=10*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(e,i),this.groundedSkybox.position.y=e-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(t,e,i){this.goalTarget.set(-t,-e,-i)}setTargetDamperDecayTime(t){this.targetDamperX.setDecayTime(t),this.targetDamperY.setDecayTime(t),this.targetDamperZ.setDecayTime(t)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}getDynamicTarget(){return this.target.position.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(t){const e=this.goalTarget,i=this.target.position;if(e.equals(i))return!1;{const n=this.boundingSphere.radius/10;let{x:r,y:s,z:a}=i;return r=this.targetDamperX.update(r,e.x,t,n),s=this.targetDamperY.update(s,e.y,t,n),a=this.targetDamperZ.update(a,e.z,t,n),this.groundedSkybox.position.x=-r,this.groundedSkybox.position.z=-a,this.target.position.set(r,s,a),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(t,e){const{x:i,z:n}=this.position;this.yaw=Math.atan2(t-i,e-n)}get model(){return this._models[0]||null}get models(){return this._models}set yaw(t){this.scenePivot.rotation.y=t,this.groundedSkybox.rotation.y=-t,this.queueRender()}get yaw(){return this.scenePivot.rotation.y}set animationTime(t){for(const e of this.mixers)e.setTime(t);this.queueShadowRender()}get animationTime(){let t=0;for(const e of this.currentAnimationActions)if(null!=e){let i=e.time;const n=Math.max(e._loopCount,0);if(e.loop===Ei&&!(1&~n)){i=(e.getClip()?e.getClip().duration:0)-e.time}i>t&&(t=i)}return t}set animationTimeScale(t){for(const e of this.mixers)e.timeScale=t}get animationTimeScale(){return this.mixers.length>0?this.mixers[0].timeScale:1}get duration(){let t=0;for(const e of this.currentAnimationActions)if(null!=e&&e.getClip()){const i=e.getClip().duration;i>t&&(t=i)}return t}get hasActiveAnimation(){return this.currentAnimationActions.some(t=>null!=t)}playAnimation(t=null,e=0,i=2201,n=1/0,r=null){const s=null!=r?r:0,a=null!=r?r+1:this._models.length;for(let r=s;r<a;r++){const s=this._currentGLTFs[r];if(null==s)continue;const a=s.animations||[];if(0===a.length)continue;let o=null;if(null!=t){for(let e=a.length-1;e>=0;e--)if(a[e].name===t){o=a[e];break}if(null==o){const e=parseInt(t);!isNaN(e)&&e>=0&&e<a.length&&(o=a[e])}}null==o&&(o=a[0]);try{const t=this.currentAnimationActions[r],s=this.mixers[r],a=s.clipAction(o,this._models[r]);this.currentAnimationActions[r]=a,this.element.paused?(s.stopAllAction(),this.mixerPausedStates[r]=!0):(a.paused=!1,this.mixerPausedStates[r]=!1,null!=t&&a!==t?a.crossFadeFrom(t,e,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),a.setLoop(i,n),a.enabled=!0,a.clampWhenFinished=!0,a.play()}catch(t){console.error(t)}}}appendAnimation(t="",e=2201,i=1/0,n=1,r=1,s=!1,a=!1,o=!0,l=null,c=!1,h=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:u}=this;if(null==u||0===u.length)return;const d=t?this.animationsByName.get(t):null;if(null==d)return;if("string"==typeof i?isNaN(parseFloat(i))?(i=1/0,console.warn(`Invalid repetitionCount value: ${i}. Using default: Infinity`)):(parseInt(i)<1&&console.warn(`Invalid repetitionCount value: ${i}. Using 1 as minimum.`),i=Math.max(parseInt(i),1)):"number"==typeof i&&i<1?(i=1,console.warn(`Invalid repetitionCount value: ${i}. Using 1 value as minimum.`)):console.warn(`Invalid repetitionCount value: ${i}. Using default: Infinity`),1===i&&e!==xi&&(e=xi),"string"==typeof n){const t=parseFloat(n);isNaN(t)||t<0||t>1?(n=1,console.warn(`Invalid weight value: ${n}. Using default: 1`)):n=t}if("string"==typeof r){const t=parseFloat(r);isNaN(t)||t<0?(r=1,console.warn(`Invalid timeScale value: ${r}. Using default: 1`)):r=t}if("string"==typeof l){const t=parseFloat(l);isNaN(t)?(l=null,console.warn(`Invalid time value: ${l}. Using default: 0 or previous time`)):l=t}const{shouldFade:p,duration:A}=this.parseFadeValue(s,!1,1.25);let g=!1,m=0;"boolean"==typeof a?(g=a,m=a?1.25:0):"number"==typeof a?(g=a>0,m=Math.max(a,0),a<0&&console.warn(`Invalid warp value: ${a}. Using default: false`)):"string"==typeof a&&("true"===a.toLowerCase().trim()?(g=!0,m=1.25):"false"===a.toLowerCase().trim()?g=!1:isNaN(parseFloat(a))?console.warn(`Invalid warp value: ${a}. Using default: false`):(m=Math.max(parseFloat(a),0),g=m>0,m<=0&&console.warn(`Invalid warp value: ${a}. Using default: false`)));try{c&&this.appendedAnimations.includes(t)&&(this.markedAnimations.map(t=>t.name).includes(t)||this.markedAnimations.push({name:t,loopMode:e,repetitionCount:i}));const s=null!=h?h:0,a=null!=h?h+1:this.mixers.length;for(let t=s;t<a;t++){const s=this.mixers[t],a=s.existingAction(d)||s.clipAction(d,this._models[t]||this),c=a.timeScale;"number"==typeof l&&(a.time=Math.min(Math.max(l,0),d.duration)),p?a.fadeIn(A):n>=0&&(a.weight=Math.min(Math.max(n,0),1)),g?a.warp(o?c:0,r,m):a.timeScale=r,a.isRunning()||(a.time==d.duration&&a.stop(),a.setLoop(e,i),a.paused=!1,a.enabled=!0,a.clampWhenFinished=!0,a.play())}this.appendedAnimations.includes(t)||this.element[pE].appendedAnimations.push(t)}catch(t){console.error(t)}}parseFadeValue(t,e=!0,i=1.5){if("boolean"==typeof t)return{shouldFade:t,duration:t?i:0};if("number"==typeof t){const e=Math.max(t,0);return{shouldFade:e>0,duration:e}}if("string"==typeof t){const e=t.toLowerCase().trim();if("true"===e)return{shouldFade:!0,duration:i};if("false"===e)return{shouldFade:!1,duration:0};const n=parseFloat(e);if(!isNaN(n)){const t=Math.max(n,0);return{shouldFade:t>0,duration:t}}}return console.warn(`Invalid fade value: ${t}. Using default: ${e}`),{shouldFade:e,duration:e?i:0}}detachAnimation(t="",e=!0,i=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:n}=this;if(null==n||0===n.length)return;const r=t?this.animationsByName.get(t):null;if(null==r)return;const{shouldFade:s,duration:a}=this.parseFadeValue(e,!0,1.5);try{const e=null!=i?i:0,n=null!=i?i+1:this.mixers.length;for(let t=e;t<n;t++){const e=this.mixers[t],i=e.existingAction(r)||e.clipAction(r,this._models[t]||this);s?i.fadeOut(a):i.stop()}this.element[pE].appendedAnimations=this.element[pE].appendedAnimations.filter(e=>e!==t)}catch(t){console.error(t)}}updateAnimationLoop(t="",e=2201,i=1/0,n=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:r}=this;if(null==r||0===r.length)return;let s=null;if(t&&(s=this.animationsByName.get(t)),null!=s)try{const t=null!=n?n:0,r=null!=n?n+1:this.mixers.length;for(let n=t;n<r;n++){const t=this.mixers[n],r=t.existingAction(s)||t.clipAction(s,this._models[n]||this);r.stop(),r.setLoop(e,i),r.play()}}catch(t){console.error(t)}}stopAnimation(){this.currentAnimationActions.fill(null);for(const t of this.mixers)t.stopAllAction();this.mixerPausedStates.fill(!0)}isAllAnimationsPaused(){return this.mixerPausedStates.every(t=>t)}pauseAnimation(t=null){const e=null!=t?t:0,i=null!=t?t+1:this.mixers.length;for(let t=e;t<i;t++)this.mixerPausedStates[t]=!0}unpauseAnimation(t=null){const e=null!=t?t:0,i=null!=t?t+1:this.mixers.length;for(let t=e;t<i;t++)this.mixerPausedStates[t]=!1}updateAnimation(t){for(let e=0;e<this.mixers.length;e++)this.mixerPausedStates[e]||this.mixers[e].update(t);this.queueShadowRender()}subscribeMixerEvent(t,e){for(const i of this.mixers)i.addEventListener(t,e)}updateShadow(){const t=this.shadow;if(null!=t){const e="wall"===this.element.arPlacement?"back":"bottom";t.setScene(this,this.shadowSoftness,e),t.needsUpdate=!0}}renderShadow(t){this.updateBoundingBoxAndShadowIfDirty();const e=this.shadow;null!=e&&1==e.needsUpdate&&(e.render(t,this),e.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(t){if(this.shadowIntensity=t,null!=this.currentGLTF&&(this.setBakedShadowVisibility(),!(t<=0&&null==this.shadow))){if(null==this.shadow){const t="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new m_(this,this.shadowSoftness,t)}this.shadow.setIntensity(t)}}setShadowSoftness(t){this.shadowSoftness=t;const e=this.shadow;null!=e&&e.setSoftness(t)}setShadowOffset(t){const e=this.shadow;null!=e&&e.setOffset(t)}getHit(t=this){return y_.intersectObject(t,!0).find(t=>t.object.visible&&!t.object.userData.noHit)}hitFromController(t,e=this){return y_.setFromXRController(t),this.getHit(e)}hitFromPoint(t,e=this){return y_.setFromCamera(t,this.getCamera()),this.getHit(e)}getModelIndexFromHit(t){let e=t.object;for(;null!=e;){const t=this.models.indexOf(e);if(-1!==t)return t;e=e.parent}return 0}positionAndNormalFromPoint(t,e=this){var i;const n=this.hitFromPoint(t,e);if(null==n)return null;const r=n.point,s=null!=n.face?n.face.normal.clone().applyNormalMatrix((new _n).getNormalMatrix(n.object.matrixWorld)):y_.ray.direction.clone().multiplyScalar(-1),a=null!==(i=n.uv)&&void 0!==i?i:null,o=this.getModelIndexFromHit(n),l=this.models[o]||this.target;return{position:r,normal:s,uv:a,modelIndex:o,worldToModel:(new Hn).copy(l.matrixWorld).invert()}}surfaceFromPoint(t,e=this){var i;const n=this.hitFromPoint(t,e);if(null==n||null==n.face)return null;const r=this.getModelIndexFromHit(n),s=0===r?this.element.model:null===(i=this.element.extraModels)||void 0===i?void 0:i[r-1];if(null==s)return null;const a=s[Vx](n);if(null==a)return null;const{meshes:o,primitives:l}=a.mesh.userData.associations,c=new vn,h=new vn,u=new vn,{a:d,b:p,c:A}=n.face,g=n.object;g.getVertexPosition(d,c),g.getVertexPosition(p,h),g.getVertexPosition(A,u);const m=new Qr(c,h,u),f=new vn;m.getBarycoord(g.worldToLocal(n.point),f),m.getBarycoord(g.worldToLocal(n.point),f);const b=`${o} ${l} ${d} ${p} ${A} ${f.x.toFixed(3)} ${f.y.toFixed(3)} ${f.z.toFixed(3)}`;return 0===r?b:`${r} ${b}`}updateHotspotAttachment(t){const e=null!=t.modelIndex&&t.modelIndex>0&&this._models[t.modelIndex]?this._models[t.modelIndex]:this.target;t.parent!==e&&(e.add(t),t.updatePosition(t.position.toArray().join(" ")+"m"),t.updateMatrixWorld(!0))}addHotspot(t){this.updateHotspotAttachment(t),this.annotationRenderer.domElement.appendChild(t.element),this.updateSurfaceHotspot(t)}removeHotspot(t){t.parent&&t.parent.remove(t)}forHotspots(t){const e=[...this.target.children];for(let i=0,n=e.length;i<n;i++){const n=e[i];n instanceof d_&&t(n)}for(const e of this._models)if(e&&e!==this.target){const i=[...e.children];for(let e=0,n=i.length;e<n;e++){const n=i[e];n instanceof d_&&t(n)}}}updateSurfaceHotspot(t){var e,i;if(null==t.surface)return;const n=$m(t.surface)[0].terms;if(8!==n.length&&9!==n.length)return void console.warn(t.surface+" does not have exactly 8 or 9 numbers. Did you use an outdated string?");const r=8===n.length,s=r?0:n[0].number,a=r?0:1,o=null!==(e=t.modelIndex)&&void 0!==e?e:s;t.modelIndex=o,this.updateHotspotAttachment(t);const l=0===o?this.element.model:null===(i=this.element.extraModels)||void 0===i?void 0:i[o-1];if(null==l)return;const c=l[qx](n[0+a].number,n[1+a].number);if(null==c)return void console.warn(t.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");const h=c.mesh.geometry.attributes.position.count,u=new vn(n[2+a].number,n[3+a].number,n[4+a].number);if(u.x>=h||u.y>=h||u.z>=h)return void console.warn(t.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const d=new vn(n[5+a].number,n[6+a].number,n[7+a].number);t.mesh=c.mesh,t.tri=u,t.bary=d,t.updateSurface()}animateSurfaceHotspots(){this.element.paused||this.forHotspots(t=>{t.updateSurface()})}updateHotspotsVisibility(t){this.forHotspots(e=>{f_.copy(t),b_.setFromMatrixPosition(e.matrixWorld),f_.sub(b_),v_.copy(e.normal).transformDirection(this.target.matrixWorld),f_.dot(v_)<0?e.hide():e.show()})}orientHotspots(t){this.forHotspots(e=>{e.orient(t)})}setHotspotsVisibility(t){this.forHotspots(e=>{e.visible=t})}updateSchema(t){var e;const{schemaElement:i,element:n}=this,{alt:r,poster:s,iosSrc:a}=n;if(null!=t){const n=[{"@type":"MediaObject",contentUrl:t,encodingFormat:"gltf"===(null===(e=t.split(".").pop())||void 0===e?void 0:e.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];a&&n.push({"@type":"MediaObject",contentUrl:a,encodingFormat:"model/vnd.usdz+zip"});const o={"@context":"http://schema.org/","@type":"3DModel",image:null!=s?s:void 0,name:null!=r?r:void 0,encoding:n};i.textContent=JSON.stringify(o),document.head.appendChild(i)}else null!=i.parentElement&&i.parentElement.removeChild(i)}}+ */const f_=new vn,b_=new vn,v_=new vn,y_=new class{constructor(t,e,i=0,n=1/0){this.ray=new Us(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new tr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):en("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Rc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rc),this}intersectObject(t,e=!0,i=[]){return Lc(t,this,i,e),i.sort(Dc),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;n<r;n++)Lc(t[n],this,i,e);return i.sort(Dc),i}},x_=new vn,__=new fn;class E_ extends wr{constructor({canvas:t,element:e,width:i,height:n}){super(),this.annotationRenderer=new Gg,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.appendedAnimations=[],this.markedAnimations=[],this.camera=new nc(45,1,.1,100),this.xrCamera=null,this.url=null,this.extraUrls=[],this.scenePivot=new mr,this.target=new mr,this.animationNames=[],this.boundingBox=new Gr,this.boundingSphere=new gs,this.size=new vn,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.toneMapping=7,this.canScale=!0,this.isDirty=!1,this.goalTarget=new vn,this.targetDamperX=new jm,this.targetDamperY=new jm,this.targetDamperZ=new jm,this._currentGLTFs=[],this._models=[],this.boundsAndShadowDirty=!1,this.mixers=[],this.mixerPausedStates=[],this.mixerEventSubscriptions=[],this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationActions=[],this.groundedSkybox=new s_,this.name="ModelScene",this.element=e,this.canvas=t,this.camera=new nc(45,1,.1,100),this.camera.name="MainCamera",this.add(this.scenePivot),this.scenePivot.name="Pivot",this.scenePivot.add(this.target),this.setSize(i,n),this.target.name="Target",this.mixers=[];const{domElement:r}=this.annotationRenderer,{style:s}=r;s.display="none",s.pointerEvents="none",s.position="absolute",s.top="0",this.element.shadowRoot.querySelector(".default").appendChild(r),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return null!=this.xrCamera?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(t){this.reset(),this._models=[t],this.target.add(t),await this.setupScene()}async setSource(t,e=[],i=()=>{}){if((!t||t===this.url)&&e.join(",")===this.extraUrls.join(","))return void i(1);if(this.reset(),this.url=t,this.extraUrls=e,null!=this.externalRenderer){const t=await this.externalRenderer.load(i);return this.boundingSphere.radius=t.framedRadius,void(this.idealAspect=t.fieldOfViewAspect)}null!=this.cancelPendingSourceChange&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);let n=[];try{const r=[];t&&r.push(t),e&&r.push(...e),r.length>0&&(n=await new Promise((t,e)=>{this.cancelPendingSourceChange=()=>e(),(async()=>{try{const e=await Promise.all(r.map(t=>this.element[bE].loader.load(t,this.element,i)));t(e)}catch(t){e(t)}})()}))}catch(t){if(null==t)return;throw t}this.cancelPendingSourceChange=null,this.reset(),this.url=t,this.extraUrls=e,this._currentGLTFs=n;for(const t of n)null!=t?(this._models.push(t.scene),this.target.add(t.scene),this.mixers.push(this.createMixer(t.scene)),this.mixerPausedStates.push(!1),this.currentAnimationActions.push(null)):(this.mixers.push(this.createMixer(this.target)),this.mixerPausedStates.push(!1),this.currentAnimationActions.push(null));const r=new Map,s=[],a=[];for(const t of n)for(const e of t.animations||[])r.set(e.name,e),s.push(e.name),a.push(e);this.animations=a,this.animationsByName=r,this.animationNames=s,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity),this.setGroundedSkybox()}updateModelTransforms(t,e,i,n){const r=this._models[t];if(r){if(e){const t=$m(e)[0].terms;if(t.length>=3){const e=hf(t[0]).number,i=hf(t[1]).number,n=hf(t[2]).number;r.position.set(e,i,n)}}if(i){const t=$m(i)[0].terms;if(t.length>=3){const e=hf(t[0]).number,i=hf(t[1]).number,n=hf(t[2]).number;r.quaternion.setFromEuler(new Zn(i,n,e,"YXZ"))}}if(n){const t=n.split(" ").map(t=>t.trim()).filter(t=>t.length>0).map(Number);1!==t.length||isNaN(t[0])?3!==t.length||t.some(isNaN)||r.scale.set(t[0],t[1],t[2]):r.scale.setScalar(t[0])}r.updateMatrixWorld(!0),this.boundsAndShadowDirty=!0,this.queueRender()}}updateBoundingBoxAndShadowIfDirty(){this.boundsAndShadowDirty&&(this.boundsAndShadowDirty=!1,this.updateBoundingBox(),this.updateShadow())}reset(){this.url=null,this.extraUrls=[],this.renderCount=0,this.queueRender(),null!=this.shadow&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_models:t}=this;for(const e of t)null!=e&&e.removeFromParent();this._models=[];const e=this._currentGLTFs;for(const t of e)null!=t&&t.dispose();this._currentGLTFs=[];for(const t of this.currentAnimationActions)null!=t&&t.stop();this.currentAnimationActions=[];for(const t of this.mixers)t.stopAllAction(),t.uncacheRoot(this);this.mixers=[],this.mixerPausedStates=[]}dispose(){this.reset(),null!=this.shadow&&(this.shadow.dispose(),this.shadow=null),this.element[Zx]=null,this.element[t_]=null,this.element[e_]=null}get currentGLTF(){return this._currentGLTFs[0]||null}get currentGLTFs(){return this._currentGLTFs}setSize(t,e){if(this.width!==t||this.height!==e){if(this.width=Math.max(t,1),this.height=Math.max(e,1),this.annotationRenderer.setSize(t,e),this.aspect=this.width/this.height,null!=this.externalRenderer){const i=window.devicePixelRatio;this.externalRenderer.resize(t*i,e*i)}this.queueRender()}}markBakedShadow(t){t.userData.noHit=!0,this.bakedShadows.add(t)}unmarkBakedShadow(t){t.userData.noHit=!1,t.visible=!0,this.bakedShadows.delete(t),this.boundingBox.expandByObject(t)}findBakedShadows(t){const e=new Gr;t.traverse(t=>{const i=t;if(!i.material)return;if(!i.material.transparent)return;e.setFromObject(i);const n=e.getSize(x_),r=Math.min(n.x,n.y,n.z);Math.max(n.x,n.y,n.z)<100*r||this.markBakedShadow(i)})}checkBakedShadows(){const{min:t,max:e}=this.boundingBox,i=new Gr;this.boundingBox.getSize(this.size);for(const n of this.bakedShadows)i.setFromObject(n),i.min.y<t.y+this.size.y/100&&i.min.x<=t.x&&i.max.x>=e.x&&i.min.z<=t.z&&i.max.z>=e.z||i.min.z<t.z+this.size.z/100&&i.min.x<=t.x&&i.max.x>=e.x&&i.min.y<=t.y&&i.max.y>=e.y||this.unmarkBakedShadow(n)}applyTransform(){const{models:t}=this;if(0===t.length)return;const e=$m(this.element.orientation)[0].terms,i=hf(e[0]).number,n=hf(e[1]).number,r=hf(e[2]).number,s=$m(this.element.scale)[0].terms;for(const e of t)e.quaternion.setFromEuler(new Zn(n,r,i,"YXZ")),e.scale.set(s[0].number,s[1].number,s[2].number)}updateBoundingBox(){const{models:t}=this;if(0===t.length)return;for(const e of t)this.target.remove(e),this.findBakedShadows(e);const e=(t,e)=>t.expandByPoint(e);this.setBakedShadowVisibility(!1);let i=new Gr;for(const n of t)i=zg(n,e,i);if(this.boundingBox=i,this.boundingBox.isEmpty()){this.setBakedShadowVisibility(!0),this.bakedShadows.forEach(t=>this.unmarkBakedShadow(t)),i=new Gr;for(const n of t)i=zg(n,e,i);this.boundingBox=i}this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size);for(const e of t)this.target.add(e)}async updateFraming(){const{models:t}=this;if(0===t.length)return;for(const e of t)this.target.remove(e);this.setBakedShadowVisibility(!1);const{center:e}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,e.copy(this.getTarget());const i=(t,i)=>Math.max(t,e.distanceToSquared(i));let n=0;for(const e of t)n=Math.max(n,zg(e,i,0));this.boundingSphere.radius=Math.sqrt(n);const r=(t,i)=>{i.sub(e);const n=Math.sqrt(i.x*i.x+i.z*i.z);return Math.max(t,n/(this.idealCameraDistance()-Math.abs(i.y)))};let s=0;for(const e of t)s=Math.max(s,zg(e,r,0));this.idealAspect=s/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility();for(const e of t)this.target.add(e)}setBakedShadowVisibility(t=this.shadowIntensity<=0){for(const e of this.bakedShadows)e.visible=t}idealCameraDistance(){const t=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(t)}adjustedFoV(t){const e=Math.tan(t/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(e)*180/Math.PI}getNDC(t,e){if(null!=this.xrCamera)__.set(t/window.screen.width,e/window.screen.height);else{const i=this.element.getBoundingClientRect();__.set((t-i.x)/this.width,(e-i.y)/this.height)}return __.multiplyScalar(2).subScalar(1),__.y*=-1,__}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(t,e){this.element[bE].arRenderer.presentedScene!==this&&(this.environment=t,this.setBackground(e),this.queueRender())}setBackground(t){this.groundedSkybox.map=t,this.groundedSkybox.isUsable()?(this.target.add(this.groundedSkybox),this.background=null):(this.target.remove(this.groundedSkybox),this.background=t)}farRadius(){return this.boundingSphere.radius*(null!=this.groundedSkybox.parent?10:1)}setGroundedSkybox(){const t=$m(this.element.skyboxHeight)[0].terms[0],e=hf(t).number,i=10*this.boundingSphere.radius;this.groundedSkybox.updateGeometry(e,i),this.groundedSkybox.position.y=e-(this.shadow?2*this.shadow.gap():0),this.setBackground(this.groundedSkybox.map)}setTarget(t,e,i){this.goalTarget.set(-t,-e,-i)}setTargetDamperDecayTime(t){this.targetDamperX.setDecayTime(t),this.targetDamperY.setDecayTime(t),this.targetDamperZ.setDecayTime(t)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}getDynamicTarget(){return this.target.position.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(t){const e=this.goalTarget,i=this.target.position;if(e.equals(i))return!1;{const n=this.boundingSphere.radius/10;let{x:r,y:s,z:a}=i;return r=this.targetDamperX.update(r,e.x,t,n),s=this.targetDamperY.update(s,e.y,t,n),a=this.targetDamperZ.update(a,e.z,t,n),this.groundedSkybox.position.x=-r,this.groundedSkybox.position.z=-a,this.target.position.set(r,s,a),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(t,e){const{x:i,z:n}=this.position;this.yaw=Math.atan2(t-i,e-n)}get model(){return this._models[0]||null}get models(){return this._models}set yaw(t){this.scenePivot.rotation.y=t,this.groundedSkybox.rotation.y=-t,this.queueRender()}get yaw(){return this.scenePivot.rotation.y}set animationTime(t){for(const e of this.mixers)e.setTime(t);this.queueShadowRender()}get animationTime(){let t=0;for(const e of this.currentAnimationActions)if(null!=e){let i=e.time;const n=Math.max(e._loopCount,0);if(e.loop===Ei&&!(1&~n)){i=(e.getClip()?e.getClip().duration:0)-e.time}i>t&&(t=i)}return t}set animationTimeScale(t){for(const e of this.mixers)e.timeScale=t}get animationTimeScale(){return this.mixers.length>0?this.mixers[0].timeScale:1}get duration(){let t=0;for(const e of this.currentAnimationActions)if(null!=e&&e.getClip()){const i=e.getClip().duration;i>t&&(t=i)}return t}get hasActiveAnimation(){return this.currentAnimationActions.some(t=>null!=t)}playAnimation(t=null,e=0,i=2201,n=1/0,r=null){const s=null!=r?r:0,a=null!=r?r+1:this._models.length;for(let r=s;r<a;r++){const s=this._currentGLTFs[r];if(null==s)continue;const a=s.animations||[];if(0===a.length)continue;let o=null;if(null!=t){for(let e=a.length-1;e>=0;e--)if(a[e].name===t){o=a[e];break}if(null==o){const e=parseInt(t);!isNaN(e)&&e>=0&&e<a.length&&(o=a[e])}}null==o&&(o=a[0]);try{const t=this.currentAnimationActions[r],s=this.mixers[r],a=s.clipAction(o,this._models[r]);this.currentAnimationActions[r]=a,this.element.paused?(s.stopAllAction(),this.mixerPausedStates[r]=!0):(a.paused=!1,this.mixerPausedStates[r]=!1,null!=t&&a!==t?a.crossFadeFrom(t,e,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),a.setLoop(i,n),a.enabled=!0,a.clampWhenFinished=!0,a.play()}catch(t){console.error(t)}}}appendAnimation(t="",e=2201,i=1/0,n=1,r=1,s=!1,a=!1,o=!0,l=null,c=!1,h=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:u}=this;if(null==u||0===u.length)return;const d=t?this.animationsByName.get(t):null;if(null==d)return;if("string"==typeof i?isNaN(parseFloat(i))?(i=1/0,console.warn(`Invalid repetitionCount value: ${i}. Using default: Infinity`)):(parseInt(i)<1&&console.warn(`Invalid repetitionCount value: ${i}. Using 1 as minimum.`),i=Math.max(parseInt(i),1)):"number"!=typeof i||isNaN(i)?(console.warn(`Invalid repetitionCount value: ${i}. Using default: Infinity`),i=1/0):i<1&&(console.warn(`Invalid repetitionCount value: ${i}. Using 1 as minimum.`),i=1),1===i&&e!==xi&&(e=xi),"string"==typeof n){const t=parseFloat(n);isNaN(t)||t<0||t>1?(n=1,console.warn(`Invalid weight value: ${n}. Using default: 1`)):n=t}if("string"==typeof r){const t=parseFloat(r);isNaN(t)||t<0?(r=1,console.warn(`Invalid timeScale value: ${r}. Using default: 1`)):r=t}if("string"==typeof l){const t=parseFloat(l);isNaN(t)?(l=null,console.warn(`Invalid time value: ${l}. Using default: 0 or previous time`)):l=t}const{shouldFade:p,duration:A}=this.parseFadeValue(s,!1,1.25);let g=!1,m=0;"boolean"==typeof a?(g=a,m=a?1.25:0):"number"==typeof a?(g=a>0,m=Math.max(a,0),a<0&&console.warn(`Invalid warp value: ${a}. Using default: false`)):"string"==typeof a&&("true"===a.toLowerCase().trim()?(g=!0,m=1.25):"false"===a.toLowerCase().trim()?g=!1:isNaN(parseFloat(a))?console.warn(`Invalid warp value: ${a}. Using default: false`):(m=Math.max(parseFloat(a),0),g=m>0,m<=0&&console.warn(`Invalid warp value: ${a}. Using default: false`)));try{c&&this.appendedAnimations.includes(t)&&(this.markedAnimations.map(t=>t.name).includes(t)||this.markedAnimations.push({name:t,loopMode:e,repetitionCount:i}));const s=null!=h?h:0,a=null!=h?h+1:this.mixers.length;for(let t=s;t<a;t++){const s=this.mixers[t],a=s.existingAction(d)||s.clipAction(d,this._models[t]||this),c=a.timeScale;"number"==typeof l&&(a.time=Math.min(Math.max(l,0),d.duration)),p?a.fadeIn(A):n>=0&&(a.weight=Math.min(Math.max(n,0),1)),g?a.warp(o?c:0,r,m):a.timeScale=r,a.isRunning()||(a.time==d.duration&&a.stop(),a.setLoop(e,i),a.paused=!1,a.enabled=!0,a.clampWhenFinished=!0,a.play())}this.appendedAnimations.includes(t)||this.element[pE].appendedAnimations.push(t)}catch(t){console.error(t)}}parseFadeValue(t,e=!0,i=1.5){if("boolean"==typeof t)return{shouldFade:t,duration:t?i:0};if("number"==typeof t){const e=Math.max(t,0);return{shouldFade:e>0,duration:e}}if("string"==typeof t){const e=t.toLowerCase().trim();if("true"===e)return{shouldFade:!0,duration:i};if("false"===e)return{shouldFade:!1,duration:0};const n=parseFloat(e);if(!isNaN(n)){const t=Math.max(n,0);return{shouldFade:t>0,duration:t}}}return console.warn(`Invalid fade value: ${t}. Using default: ${e}`),{shouldFade:e,duration:e?i:0}}detachAnimation(t="",e=!0,i=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:n}=this;if(null==n||0===n.length)return;const r=t?this.animationsByName.get(t):null;if(null==r)return;const{shouldFade:s,duration:a}=this.parseFadeValue(e,!0,1.5);try{const e=null!=i?i:0,n=null!=i?i+1:this.mixers.length;for(let t=e;t<n;t++){const e=this.mixers[t],i=e.existingAction(r)||e.clipAction(r,this._models[t]||this);s?i.fadeOut(a):i.stop()}this.element[pE].appendedAnimations=this.element[pE].appendedAnimations.filter(e=>e!==t)}catch(t){console.error(t)}}updateAnimationLoop(t="",e=2201,i=1/0,n=null){if(null==this.currentGLTF||t===this.element.animationName)return;const{animations:r}=this;if(null==r||0===r.length)return;let s=null;if(t&&(s=this.animationsByName.get(t)),null!=s)try{const t=null!=n?n:0,r=null!=n?n+1:this.mixers.length;for(let n=t;n<r;n++){const t=this.mixers[n],r=t.existingAction(s)||t.clipAction(s,this._models[n]||this);r.stop(),r.setLoop(e,i),r.play()}}catch(t){console.error(t)}}stopAnimation(){this.currentAnimationActions.fill(null);for(const t of this.mixers)t.stopAllAction();this.mixerPausedStates.fill(!0)}isAllAnimationsPaused(){return this.mixerPausedStates.every(t=>t)}pauseAnimation(t=null){const e=null!=t?t:0,i=null!=t?t+1:this.mixers.length;for(let t=e;t<i;t++)this.mixerPausedStates[t]=!0}unpauseAnimation(t=null){const e=null!=t?t:0,i=null!=t?t+1:this.mixers.length;for(let t=e;t<i;t++)this.mixerPausedStates[t]=!1}updateAnimation(t){for(let e=0;e<this.mixers.length;e++)this.mixerPausedStates[e]||this.mixers[e].update(t);this.queueShadowRender()}subscribeMixerEvent(t,e){this.mixerEventSubscriptions.push({event:t,callback:e});for(const i of this.mixers)i.addEventListener(t,e)}createMixer(t){const e=new Tc(t);for(const{event:t,callback:i}of this.mixerEventSubscriptions)e.addEventListener(t,i);return e}updateShadow(){const t=this.shadow;if(null!=t){const e="wall"===this.element.arPlacement?"back":"bottom";t.setScene(this,this.shadowSoftness,e),t.needsUpdate=!0}}renderShadow(t){this.updateBoundingBoxAndShadowIfDirty();const e=this.shadow;null!=e&&1==e.needsUpdate&&(e.render(t,this),e.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(t){if(this.shadowIntensity=t,null!=this.currentGLTF&&(this.setBakedShadowVisibility(),!(t<=0&&null==this.shadow))){if(null==this.shadow){const t="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new m_(this,this.shadowSoftness,t)}this.shadow.setIntensity(t)}}setShadowSoftness(t){this.shadowSoftness=t;const e=this.shadow;null!=e&&e.setSoftness(t)}setShadowOffset(t){const e=this.shadow;null!=e&&e.setOffset(t)}getHit(t=this){return y_.intersectObject(t,!0).find(t=>t.object.visible&&!t.object.userData.noHit)}hitFromController(t,e=this){return y_.setFromXRController(t),this.getHit(e)}hitFromPoint(t,e=this){return y_.setFromCamera(t,this.getCamera()),this.getHit(e)}getModelIndexFromHit(t){let e=t.object;for(;null!=e;){const t=this.models.indexOf(e);if(-1!==t)return t;e=e.parent}return 0}positionAndNormalFromPoint(t,e=this){var i;const n=this.hitFromPoint(t,e);if(null==n)return null;const r=n.point,s=null!=n.face?n.face.normal.clone().applyNormalMatrix((new _n).getNormalMatrix(n.object.matrixWorld)):y_.ray.direction.clone().multiplyScalar(-1),a=null!==(i=n.uv)&&void 0!==i?i:null,o=this.getModelIndexFromHit(n),l=this.models[o]||this.target;return{position:r,normal:s,uv:a,modelIndex:o,worldToModel:(new Hn).copy(l.matrixWorld).invert()}}surfaceFromPoint(t,e=this){var i;const n=this.hitFromPoint(t,e);if(null==n||null==n.face)return null;const r=this.getModelIndexFromHit(n),s=0===r?this.element.model:null===(i=this.element.extraModels)||void 0===i?void 0:i[r-1];if(null==s)return null;const a=s[Vx](n);if(null==a)return null;const{meshes:o,primitives:l}=a.mesh.userData.associations,c=new vn,h=new vn,u=new vn,{a:d,b:p,c:A}=n.face,g=n.object;g.getVertexPosition(d,c),g.getVertexPosition(p,h),g.getVertexPosition(A,u);const m=new Qr(c,h,u),f=new vn;m.getBarycoord(g.worldToLocal(n.point),f),m.getBarycoord(g.worldToLocal(n.point),f);const b=`${o} ${l} ${d} ${p} ${A} ${f.x.toFixed(3)} ${f.y.toFixed(3)} ${f.z.toFixed(3)}`;return 0===r?b:`${r} ${b}`}updateHotspotAttachment(t){const e=null!=t.modelIndex&&t.modelIndex>0&&this._models[t.modelIndex]?this._models[t.modelIndex]:this.target;t.parent!==e&&(e.add(t),t.updatePosition(t.position.toArray().join(" ")+"m"),t.updateMatrixWorld(!0))}addHotspot(t){this.updateHotspotAttachment(t),this.annotationRenderer.domElement.appendChild(t.element),this.updateSurfaceHotspot(t)}removeHotspot(t){t.parent&&t.parent.remove(t)}forHotspots(t){const e=[...this.target.children];for(let i=0,n=e.length;i<n;i++){const n=e[i];n instanceof d_&&t(n)}for(const e of this._models)if(e&&e!==this.target){const i=[...e.children];for(let e=0,n=i.length;e<n;e++){const n=i[e];n instanceof d_&&t(n)}}}updateSurfaceHotspot(t){var e,i;if(null==t.surface)return;const n=$m(t.surface)[0].terms;if(8!==n.length&&9!==n.length)return void console.warn(t.surface+" does not have exactly 8 or 9 numbers. Did you use an outdated string?");const r=8===n.length,s=r?0:n[0].number,a=r?0:1,o=null!==(e=t.modelIndex)&&void 0!==e?e:s;t.modelIndex=o,this.updateHotspotAttachment(t);const l=0===o?this.element.model:null===(i=this.element.extraModels)||void 0===i?void 0:i[o-1];if(null==l)return;const c=l[qx](n[0+a].number,n[1+a].number);if(null==c)return void console.warn(t.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");const h=c.mesh.geometry.attributes.position.count,u=new vn(n[2+a].number,n[3+a].number,n[4+a].number);if(u.x>=h||u.y>=h||u.z>=h)return void console.warn(t.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const d=new vn(n[5+a].number,n[6+a].number,n[7+a].number);t.mesh=c.mesh,t.tri=u,t.bary=d,t.updateSurface()}animateSurfaceHotspots(){this.element.paused||this.forHotspots(t=>{t.updateSurface()})}updateHotspotsVisibility(t){this.forHotspots(e=>{f_.copy(t),b_.setFromMatrixPosition(e.matrixWorld),f_.sub(b_),v_.copy(e.normal).transformDirection(this.target.matrixWorld),f_.dot(v_)<0?e.hide():e.show()})}orientHotspots(t){this.forHotspots(e=>{e.orient(t)})}setHotspotsVisibility(t){this.forHotspots(e=>{e.visible=t})}updateSchema(t){var e;const{schemaElement:i,element:n}=this,{alt:r,poster:s,iosSrc:a}=n;if(null!=t){const n=[{"@type":"MediaObject",contentUrl:t,encodingFormat:"gltf"===(null===(e=t.split(".").pop())||void 0===e?void 0:e.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];a&&n.push({"@type":"MediaObject",contentUrl:a,encodingFormat:"model/vnd.usdz+zip"});const o={"@context":"http://schema.org/","@type":"3DModel",image:null!=s?s:void 0,name:null!=r?r:void 0,encoding:n};i.textContent=JSON.stringify(o),document.head.appendChild(i)}else null!=i.parentElement&&i.parentElement.removeChild(i)}}/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1033,7 +1033,7 @@ class s_ extends Ks{constructor(){super(void 0,new Ns({depthWrite:!1})),this.hei* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.- */var C_,w_,M_,I_,T_,B_,R_,D_,L_,P_,F_,U_,N_,O_,k_,Q_=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const G_=document.createElement("canvas"),z_=Symbol("fallbackResizeHandler"),H_=Symbol("defaultAriaLabel"),V_=Symbol("resizeObserver"),q_=Symbol("clearModelTimeout"),j_=Symbol("onContextLost"),W_=Symbol("loaded"),X_=Symbol("status"),K_=Symbol("onFocus"),J_=Symbol("onBlur"),Y_=Symbol("onSlotChange"),$_=Symbol("onExtraModelChanged"),Z_=Symbol("updateSize"),tE=Symbol("intersectionObserver"),eE=Symbol("isElementInViewport"),iE=Symbol("announceModelVisibility"),nE=Symbol("ariaLabel"),rE=Symbol("altDefaulted"),sE=Symbol("statusElement"),aE=Symbol("updateStatus"),oE=Symbol("loadedTime"),lE=Symbol("updateSource"),cE=Symbol("markLoaded"),hE=Symbol("container"),uE=Symbol("input"),dE=Symbol("canvas"),pE=Symbol("scene"),AE=Symbol("needsRender"),gE=Symbol("tick"),mE=Symbol("onModelLoad"),fE=Symbol("onResize"),bE=Symbol("renderer"),vE=Symbol("progressTracker"),yE=Symbol("getLoaded"),xE=Symbol("getModelIsVisible"),_E=Symbol("shouldAttemptPreload"),EE=t=>({x:t.x,y:t.y,z:t.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),SE=t=>({u:t.x,v:t.y,toString(){return`${this.u} ${this.v}`}});class CE extends y{static get is(){return"model-viewer"}static set modelCacheSize(t){Pg[Dg].evictionThreshold=t}static get modelCacheSize(){return Pg[Dg].evictionThreshold}static set minimumRenderScale(t){t>1&&console.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),t<=0&&console.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),fy.singleton.minScale=t}static get minimumRenderScale(){return fy.singleton.minScale}get loaded(){return this[yE]()}get[(C_=eE,w_=W_,M_=oE,I_=X_,T_=q_,B_=Y_,R_=$_,D_=z_,L_=iE,P_=V_,F_=tE,U_=vE,bE)](){return fy.singleton}get modelIsVisible(){return this[xE]()}constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[C_]=!1,this[w_]=!1,this[M_]=0,this[I_]="",this[T_]=null,this[B_]=()=>{if(!this[pE])return;const t=Array.from(this.querySelectorAll("extra-model")),e=t.map(t=>t.src).filter(t=>null!=t),i=this[pE].extraUrls||[];e.join(",")===i.join(",")&&t.length===i.length||this[lE]()},this[R_]=t=>{const e=t,i=e.target,n=Array.from(this.querySelectorAll("extra-model")).indexOf(i);if(console.log(`[onExtraModelChanged] childIndex: ${n} srcChanged: ${e.detail.srcChanged} offset: ${e.detail.offset}`),-1===n)return;const r=this.src?n+1:n;e.detail.srcChanged?(this[W_]=!1,this[lE]()):this[pE]&&this[pE].updateModelTransforms(r,e.detail.offset,e.detail.orientation,e.detail.scale)},this[D_]=qd(()=>{const t=this.getBoundingClientRect();this[Z_](t)},50),this[L_]=qd(t=>{const e=this.modelIsVisible;e!==t&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:e}}))},0),this[P_]=null,this[F_]=null,this[U_]=new S_,this[N_]=()=>{this[sE].textContent=this[X_]},this[O_]=()=>{this[sE].textContent=""},this[k_]=t=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:t.sourceEvent}}))},this.attachShadow({mode:"open"});const t=this.shadowRoot;let e,i;if((t=>{rt(Zd,t)})(t),this[hE]=t.querySelector(".container"),this[uE]=t.querySelector(".userInput"),this[dE]=t.querySelector("canvas"),this[sE]=t.querySelector("#status"),this[H_]=this[uE].getAttribute("aria-label"),this.isConnected){const t=this.getBoundingClientRect();e=t.width,i=t.height}else e=300,i=150;this[pE]=new E_({canvas:this[dE],element:this,width:e,height:i}),Promise.resolve().then(()=>{this[Z_](this.getBoundingClientRect())}),Rd&&(this[V_]=new ResizeObserver(t=>{if(!this[bE].isPresenting)for(let e of t)e.target===this&&this[Z_](e.contentRect)})),Dd?this[tE]=new IntersectionObserver(t=>{for(let e of t)if(e.target===this){const t=this.modelIsVisible;this[eE]=e.isIntersecting,this[iE](t),console.log(`IntersectionObserver fired! isIntersecting: ${e.isIntersecting}`),this[eE]&&!this.loaded&&this[lE]()}},{root:null,rootMargin:"0px",threshold:1e-5}):this[eE]=!0}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Rd?this[V_].observe(this):self.addEventListener("resize",this[z_]),Dd&&this[tE].observe(this),this.addEventListener("focus",this[K_]),this.addEventListener("blur",this[J_]),this.addEventListener("extra-model-changed",this[$_]);const t=this.shadowRoot.querySelector(".slot.default slot");t&&t.addEventListener("slotchange",this[Y_]);const e=this[bE];e.addEventListener("contextlost",this[j_]),e.registerScene(this[pE]),null!=this[q_]&&(self.clearTimeout(this[q_]),this[q_]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Rd?this[V_].unobserve(this):self.removeEventListener("resize",this[z_]),Dd&&this[tE].unobserve(this),this.removeEventListener("focus",this[K_]),this.removeEventListener("blur",this[J_]),this.removeEventListener("extra-model-changed",this[$_]);const t=this.shadowRoot.querySelector(".slot.default slot");t&&t.removeEventListener("slotchange",this[Y_]);const e=this[bE];e.removeEventListener("contextlost",this[j_]),e.unregisterScene(this[pE]),this[q_]=self.setTimeout(()=>{this[pE].dispose(),this[q_]=null},10)}updated(t){if(super.updated(t),t.has("src")){const t=Array.from(this.querySelectorAll("extra-model")),e=t.map(t=>t.src).filter(t=>null!=t),i=e.join(",")===(this[pE].extraUrls||[]).join(",");null==this.src&&0===t.length?(this[W_]=!1,this[oE]=0,this[pE].reset()):this.src===this[pE].url&&i||(this[W_]=!1,this[oE]=0,this[lE]())}if(t.has("alt")&&this[uE].setAttribute("aria-label",this[nE]),t.has("generateSchema"))if(this.generateSchema){const t=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),e=this.src||t[0]||null;this[pE].updateSchema(e)}else this[pE].updateSchema(null)}toDataURL(t,e){return this[bE].displayCanvas(this[pE]).toDataURL(t,e)}async toBlob(t){const e=t?t.mimeType:void 0,i=t?t.qualityArgument:void 0,n=t?t.idealAspect:void 0,{width:r,height:s,idealAspect:a,aspect:o}=this[pE],{dpr:l,scaleFactor:c}=this[bE];let h=r*c*l,u=s*c*l,d=0,p=0;if(!0===n)if(a>o){const t=u;u=Math.round(h/a),p=(t-u)/2}else{const t=h;h=Math.round(u*a),d=(t-h)/2}G_.width=h,G_.height=u;try{return new Promise(async(t,n)=>{G_.getContext("2d").drawImage(this[bE].displayCanvas(this[pE]),d,p,h,u,0,0,h,u),G_.toBlob(e=>{if(!e)return n(new Error("Unable to retrieve canvas blob"));t(e)},e,i)})}finally{this[Z_]({width:r,height:s})}}registerEffectComposer(t){t.setRenderer(this[bE].threeRenderer),t.setMainCamera(this[pE].getCamera()),t.setMainScene(this[pE]),this[pE].effectRenderer=t}unregisterEffectComposer(){this[pE].effectRenderer=null}registerRenderer(t){this[pE].externalRenderer=t}unregisterRenderer(){this[pE].externalRenderer=null}get[nE](){return this[rE]}get[rE](){return null==this.alt||"null"===this.alt?this[H_]:this.alt}[yE](){return this[W_]}[xE](){return this.loaded&&this[eE]}[_E](){const t=Array.from(this.querySelectorAll("extra-model"));return!!(this.src||t.length>0)&&this[eE]}[Z_]({width:t,height:e}){0!==t&&0!==e&&(this[hE].style.width=`${t}px`,this[hE].style.height=`${e}px`,this[fE]({width:t,height:e}))}[gE](t,e){var i;null===(i=this[pE].effectRenderer)||void 0===i||i.beforeRender(t,e)}[cE](){this[W_]||(this[W_]=!0,this[oE]=performance.now())}[AE](){this[pE].queueRender()}[mE](){}[aE](t){this[X_]=t;const e=this.getRootNode();null!=e&&e.activeElement===this&&this[sE].textContent!=t&&(this[sE].textContent=t)}[(N_=K_,O_=J_,fE)](t){this[pE].setSize(t.width,t.height)}async[(k_=j_,lE)](){const t=this[pE],e=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),i=e.join(",")===(t.extraUrls||[]).join(",");if(console.log(`[$updateSource] called! \nsrc: ${this.src}\nextraUrls: ${e.join(",")}\nloaded: ${this.loaded}`),this.loaded||!this[_E]()||this.src===t.url&&i)return void console.log("[$updateSource] BAILING OUT EARLY!");const n=this.src,r=n||e[0]||null;this.generateSchema&&t.updateSchema(r),this[aE]("Loading"),t.stopAnimation();const s=this[vE].beginActivity("model-load");try{const i=t.setSource(n,e,t=>s(.95*jd(t,0,1))),a=this[Yd]();await Promise.all([i,a]);Array.from(this.querySelectorAll("extra-model")).forEach((t,e)=>{const i=this.src?e+1:e;this[pE].updateModelTransforms(i,t.offset,t.orientation,t.scale)}),this[cE](),this[mE](),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("before-render"))}),await new Promise(t=>{const e=setTimeout(()=>{console.warn("rAF timed out in updateSource"),t()},500);requestAnimationFrame(()=>{requestAnimationFrame(()=>{clearTimeout(e),t()})})}),this.dispatchEvent(new CustomEvent("load",{detail:{url:r}}))}catch(t){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:t}}))}finally{s(1)}}}Q_([ht({type:String})],CE.prototype,"alt",void 0),Q_([ht({type:String})],CE.prototype,"src",void 0),Q_([ht({type:Boolean,attribute:"with-credentials"})],CE.prototype,"withCredentials",void 0),Q_([ht({type:Boolean,attribute:"generate-schema"})],CE.prototype,"generateSchema",void 0);+ */var C_,w_,M_,I_,T_,B_,R_,D_,L_,P_,F_,U_,N_,O_,k_,Q_=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const G_=document.createElement("canvas"),z_=Symbol("fallbackResizeHandler"),H_=Symbol("defaultAriaLabel"),V_=Symbol("resizeObserver"),q_=Symbol("clearModelTimeout"),j_=Symbol("onContextLost"),W_=Symbol("loaded"),X_=Symbol("status"),K_=Symbol("onFocus"),J_=Symbol("onBlur"),Y_=Symbol("onSlotChange"),$_=Symbol("onExtraModelChanged"),Z_=Symbol("updateSize"),tE=Symbol("intersectionObserver"),eE=Symbol("isElementInViewport"),iE=Symbol("announceModelVisibility"),nE=Symbol("ariaLabel"),rE=Symbol("altDefaulted"),sE=Symbol("statusElement"),aE=Symbol("updateStatus"),oE=Symbol("loadedTime"),lE=Symbol("updateSource"),cE=Symbol("markLoaded"),hE=Symbol("container"),uE=Symbol("input"),dE=Symbol("canvas"),pE=Symbol("scene"),AE=Symbol("needsRender"),gE=Symbol("tick"),mE=Symbol("onModelLoad"),fE=Symbol("onResize"),bE=Symbol("renderer"),vE=Symbol("progressTracker"),yE=Symbol("getLoaded"),xE=Symbol("getModelIsVisible"),_E=Symbol("shouldAttemptPreload"),EE=t=>({x:t.x,y:t.y,z:t.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),SE=t=>({u:t.x,v:t.y,toString(){return`${this.u} ${this.v}`}});class CE extends y{static get is(){return"model-viewer"}static set modelCacheSize(t){Pg[Dg].evictionThreshold=t}static get modelCacheSize(){return Pg[Dg].evictionThreshold}static set minimumRenderScale(t){t>1&&console.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),t<=0&&console.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),fy.singleton.minScale=t}static get minimumRenderScale(){return fy.singleton.minScale}get loaded(){return this[yE]()}get[(C_=eE,w_=W_,M_=oE,I_=X_,T_=q_,B_=Y_,R_=$_,D_=z_,L_=iE,P_=V_,F_=tE,U_=vE,bE)](){return fy.singleton}get modelIsVisible(){return this[xE]()}constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[C_]=!1,this[w_]=!1,this[M_]=0,this[I_]="",this[T_]=null,this[B_]=()=>{if(!this[pE])return;const t=Array.from(this.querySelectorAll("extra-model")),e=t.map(t=>t.src).filter(t=>null!=t),i=this[pE].extraUrls||[];e.join(",")===i.join(",")&&t.length===i.length||(null==this.src&&0===t.length?(this[W_]=!1,this[oE]=0,this[pE].reset()):(this[W_]=!1,this[oE]=0,this[lE]()))},this[R_]=t=>{const e=t,i=e.target,n=Array.from(this.querySelectorAll("extra-model")).indexOf(i);if(-1===n)return;const r=this.src?n+1:n;e.detail.srcChanged?(this[W_]=!1,this[oE]=0,this[lE]()):this[pE]&&this[pE].updateModelTransforms(r,e.detail.offset,e.detail.orientation,e.detail.scale)},this[D_]=qd(()=>{const t=this.getBoundingClientRect();this[Z_](t)},50),this[L_]=qd(t=>{const e=this.modelIsVisible;e!==t&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:e}}))},0),this[P_]=null,this[F_]=null,this[U_]=new S_,this[N_]=()=>{this[sE].textContent=this[X_]},this[O_]=()=>{this[sE].textContent=""},this[k_]=t=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:t.sourceEvent}}))},this.attachShadow({mode:"open"});const t=this.shadowRoot;let e,i;if((t=>{rt(Zd,t)})(t),this[hE]=t.querySelector(".container"),this[uE]=t.querySelector(".userInput"),this[dE]=t.querySelector("canvas"),this[sE]=t.querySelector("#status"),this[H_]=this[uE].getAttribute("aria-label"),this.isConnected){const t=this.getBoundingClientRect();e=t.width,i=t.height}else e=300,i=150;this[pE]=new E_({canvas:this[dE],element:this,width:e,height:i}),Promise.resolve().then(()=>{this[Z_](this.getBoundingClientRect())}),Rd&&(this[V_]=new ResizeObserver(t=>{if(!this[bE].isPresenting)for(let e of t)e.target===this&&this[Z_](e.contentRect)})),Dd?this[tE]=new IntersectionObserver(t=>{for(let e of t)if(e.target===this){const t=this.modelIsVisible;this[eE]=e.isIntersecting,this[iE](t),this[eE]&&!this.loaded&&this[lE]()}},{root:null,rootMargin:"0px",threshold:1e-5}):this[eE]=!0}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Rd?this[V_].observe(this):self.addEventListener("resize",this[z_]),Dd&&this[tE].observe(this),this.addEventListener("focus",this[K_]),this.addEventListener("blur",this[J_]),this.addEventListener("extra-model-changed",this[$_]);const t=this.shadowRoot.querySelector(".slot.default slot");t&&t.addEventListener("slotchange",this[Y_]);const e=this[bE];e.addEventListener("contextlost",this[j_]),e.registerScene(this[pE]),null!=this[q_]&&(self.clearTimeout(this[q_]),this[q_]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Rd?this[V_].unobserve(this):self.removeEventListener("resize",this[z_]),Dd&&this[tE].unobserve(this),this.removeEventListener("focus",this[K_]),this.removeEventListener("blur",this[J_]),this.removeEventListener("extra-model-changed",this[$_]);const t=this.shadowRoot.querySelector(".slot.default slot");t&&t.removeEventListener("slotchange",this[Y_]);const e=this[bE];e.removeEventListener("contextlost",this[j_]),e.unregisterScene(this[pE]),this[q_]=self.setTimeout(()=>{this[pE].dispose(),this[q_]=null},10)}updated(t){if(super.updated(t),t.has("src")){const t=Array.from(this.querySelectorAll("extra-model")),e=t.map(t=>t.src).filter(t=>null!=t),i=e.join(",")===(this[pE].extraUrls||[]).join(",");null==this.src&&0===t.length?(this[W_]=!1,this[oE]=0,this[pE].reset()):this.src===this[pE].url&&i||(this[W_]=!1,this[oE]=0,this[lE]())}if(t.has("alt")&&this[uE].setAttribute("aria-label",this[nE]),t.has("generateSchema"))if(this.generateSchema){const t=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),e=this.src||t[0]||null;this[pE].updateSchema(e)}else this[pE].updateSchema(null)}toDataURL(t,e){return this[bE].displayCanvas(this[pE]).toDataURL(t,e)}async toBlob(t){const e=t?t.mimeType:void 0,i=t?t.qualityArgument:void 0,n=t?t.idealAspect:void 0,{width:r,height:s,idealAspect:a,aspect:o}=this[pE],{dpr:l,scaleFactor:c}=this[bE];let h=r*c*l,u=s*c*l,d=0,p=0;if(!0===n)if(a>o){const t=u;u=Math.round(h/a),p=(t-u)/2}else{const t=h;h=Math.round(u*a),d=(t-h)/2}G_.width=h,G_.height=u;try{return new Promise(async(t,n)=>{G_.getContext("2d").drawImage(this[bE].displayCanvas(this[pE]),d,p,h,u,0,0,h,u),G_.toBlob(e=>{if(!e)return n(new Error("Unable to retrieve canvas blob"));t(e)},e,i)})}finally{this[Z_]({width:r,height:s})}}registerEffectComposer(t){t.setRenderer(this[bE].threeRenderer),t.setMainCamera(this[pE].getCamera()),t.setMainScene(this[pE]),this[pE].effectRenderer=t}unregisterEffectComposer(){this[pE].effectRenderer=null}registerRenderer(t){this[pE].externalRenderer=t}unregisterRenderer(){this[pE].externalRenderer=null}get[nE](){return this[rE]}get[rE](){return null==this.alt||"null"===this.alt?this[H_]:this.alt}[yE](){return this[W_]}[xE](){return this.loaded&&this[eE]}[_E](){const t=Array.from(this.querySelectorAll("extra-model"));return!!(this.src||t.length>0)&&this[eE]}[Z_]({width:t,height:e}){0!==t&&0!==e&&(this[hE].style.width=`${t}px`,this[hE].style.height=`${e}px`,this[fE]({width:t,height:e}))}[gE](t,e){var i;null===(i=this[pE].effectRenderer)||void 0===i||i.beforeRender(t,e)}[cE](){this[W_]||(this[W_]=!0,this[oE]=performance.now())}[AE](){this[pE].queueRender()}[mE](){}[aE](t){this[X_]=t;const e=this.getRootNode();null!=e&&e.activeElement===this&&this[sE].textContent!=t&&(this[sE].textContent=t)}[(N_=K_,O_=J_,fE)](t){this[pE].setSize(t.width,t.height)}async[(k_=j_,lE)](){const t=this[pE],e=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),i=e.join(",")===(t.extraUrls||[]).join(",");if(this.loaded||!this[_E]()||this.src===t.url&&i)return;const n=this.src,r=n||e[0]||null;this.generateSchema&&t.updateSchema(r),this[aE]("Loading"),t.stopAnimation();const s=this[vE].beginActivity("model-load");try{const i=t.setSource(n,e,t=>s(.95*jd(t,0,1))),a=this[Yd]();await Promise.all([i,a]);Array.from(this.querySelectorAll("extra-model")).forEach((t,e)=>{const i=this.src?e+1:e;this[pE].updateModelTransforms(i,t.offset,t.orientation,t.scale)}),this[cE](),this[mE](),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("before-render"))}),await new Promise(t=>{const e=setTimeout(()=>{console.warn("rAF timed out in updateSource"),t()},500);requestAnimationFrame(()=>{requestAnimationFrame(()=>{clearTimeout(e),t()})})}),this.dispatchEvent(new CustomEvent("load",{detail:{url:r}}))}catch(t){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:t}}))}finally{s(1)}}}Q_([ht({type:String})],CE.prototype,"alt",void 0),Q_([ht({type:String})],CE.prototype,"src",void 0),Q_([ht({type:Boolean,attribute:"with-credentials"})],CE.prototype,"withCredentials",void 0),Q_([ht({type:Boolean,attribute:"generate-schema"})],CE.prototype,"generateSchema",void 0);/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1048,14 +1048,14 @@ class s_ extends Ks{constructor(){super(void 0,new Ns({depthWrite:!1})),this.hei* See the License for the specific language governing permissions and* limitations under the License.*/-var wE=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const ME=Symbol("changeAnimation"),IE=Symbol("appendAnimation"),TE=Symbol("detachAnimation"),BE=Symbol("paused"),RE={repetitions:1/0,pingpong:!1},DE={pingpong:!1,repetitions:null,weight:1,timeScale:1,fade:!1,warp:!1,relativeWarp:!0,time:null},LE={fade:!0},PE=Symbol("hotspotMap"),FE=Symbol("mutationCallback"),UE=Symbol("observer"),NE=Symbol("addHotspot"),OE=Symbol("removeHotspot");+var wE=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const ME=Symbol("changeAnimation"),IE=Symbol("appendAnimation"),TE=Symbol("detachAnimation"),BE=Symbol("paused"),RE=Symbol("currentAnimationOptions"),DE={repetitions:1/0,pingpong:!1},LE={pingpong:!1,repetitions:null,weight:1,timeScale:1,fade:!1,warp:!1,relativeWarp:!0,time:null},PE={fade:!0},FE=Symbol("hotspotMap"),UE=Symbol("mutationCallback"),NE=Symbol("observer"),OE=Symbol("addHotspot"),kE=Symbol("removeHotspot");/*!fflate - fast JavaScript compression/decompression<https://101arrowz.github.io/fflate>Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSEversion 0.8.2*/-var kE=Uint8Array,QE=Uint16Array,GE=Int32Array,zE=new kE([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),HE=new kE([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),VE=new kE([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qE=function(t,e){for(var i=new QE(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];var r=new GE(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},jE=qE(zE,2),WE=jE.b,XE=jE.r;WE[28]=258,XE[258]=28;for(var KE=qE(HE,0).r,JE=new QE(32768),YE=0;YE<32768;++YE){var $E=(43690&YE)>>1|(21845&YE)<<1;$E=(61680&($E=(52428&$E)>>2|(13107&$E)<<2))>>4|(3855&$E)<<4,JE[YE]=((65280&$E)>>8|(255&$E)<<8)>>1}var ZE=function(t,e,i){for(var n=t.length,r=0,s=new QE(e);r<n;++r)t[r]&&++s[t[r]-1];var a,o=new QE(e);for(r=1;r<e;++r)o[r]=o[r-1]+s[r-1]<<1;if(i){a=new QE(1<<e);var l=15-e;for(r=0;r<n;++r)if(t[r])for(var c=r<<4|t[r],h=e-t[r],u=o[t[r]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[JE[u]>>l]=c}else for(a=new QE(n),r=0;r<n;++r)t[r]&&(a[r]=JE[o[t[r]-1]++]>>15-t[r]);return a},tS=new kE(288);for(YE=0;YE<144;++YE)tS[YE]=8;for(YE=144;YE<256;++YE)tS[YE]=9;for(YE=256;YE<280;++YE)tS[YE]=7;for(YE=280;YE<288;++YE)tS[YE]=8;var eS=new kE(32);for(YE=0;YE<32;++YE)eS[YE]=5;var iS=ZE(tS,9,0),nS=ZE(eS,5,0),rS=function(t){return(t+7)/8|0},sS=function(t,e,i){return(null==i||i>t.length)&&(i=t.length),new kE(t.subarray(e,i))},aS=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],oS=function(t,e,i){var n=new Error(e||aS[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,oS),!i)throw n;return n},lS=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8},cS=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8,t[n+2]|=i>>16},hS=function(t,e){for(var i=[],n=0;n<t.length;++n)t[n]&&i.push({s:n,f:t[n]});var r=i.length,s=i.slice();if(!r)return{t:fS,l:0};if(1==r){var a=new kE(i[0].s+1);return a[i[0].s]=1,{t:a,l:1}}i.sort(function(t,e){return t.f-e.f}),i.push({s:-1,f:25001});var o=i[0],l=i[1],c=0,h=1,u=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=r-1;)o=i[i[c].f<i[u].f?c++:u++],l=i[c!=h&&i[c].f<i[u].f?c++:u++],i[h++]={s:-1,f:o.f+l.f,l:o,r:l};var d=s[0].s;for(n=1;n<r;++n)s[n].s>d&&(d=s[n].s);var p=new QE(d+1),A=uS(i[h-1],p,0);if(A>e){n=0;var g=0,m=A-e,f=1<<m;for(s.sort(function(t,e){return p[e.s]-p[t.s]||t.f-e.f});n<r;++n){var b=s[n].s;if(!(p[b]>e))break;g+=f-(1<<A-p[b]),p[b]=e}for(g>>=m;g>0;){var v=s[n].s;p[v]<e?g-=1<<e-p[v]++-1:++n}for(;n>=0&&g;--n){var y=s[n].s;p[y]==e&&(--p[y],++g)}A=e}return{t:new kE(p),l:A}},uS=function(t,e,i){return-1==t.s?Math.max(uS(t.l,e,i+1),uS(t.r,e,i+1)):e[t.s]=i},dS=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new QE(++e),n=0,r=t[0],s=1,a=function(t){i[n++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:i.subarray(0,n),n:e}},pS=function(t,e){for(var i=0,n=0;n<e.length;++n)i+=t[n]*e[n];return i},AS=function(t,e,i){var n=i.length,r=rS(e+2);t[r]=255&n,t[r+1]=n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s<n;++s)t[r+s+4]=i[s];return 8*(r+4+n)},gS=function(t,e,i,n,r,s,a,o,l,c,h){lS(e,h++,i),++r[256];for(var u=hS(r,15),d=u.t,p=u.l,A=hS(s,15),g=A.t,m=A.l,f=dS(d),b=f.c,v=f.n,y=dS(g),x=y.c,_=y.n,E=new QE(19),S=0;S<b.length;++S)++E[31&b[S]];for(S=0;S<x.length;++S)++E[31&x[S]];for(var C=hS(E,7),w=C.t,M=C.l,I=19;I>4&&!w[VE[I-1]];--I);var T,B,R,D,L=c+5<<3,P=pS(r,tS)+pS(s,eS)+a,F=pS(r,d)+pS(s,g)+a+14+3*I+pS(E,w)+2*E[16]+3*E[17]+7*E[18];if(l>=0&&L<=P&&L<=F)return AS(e,h,t.subarray(l,l+c));if(lS(e,h,1+(F<P)),h+=2,F<P){T=ZE(d,p,0),B=d,R=ZE(g,m,0),D=g;var U=ZE(w,M,0);lS(e,h,v-257),lS(e,h+5,_-1),lS(e,h+10,I-4),h+=14;for(S=0;S<I;++S)lS(e,h+3*S,w[VE[S]]);h+=3*I;for(var N=[b,x],O=0;O<2;++O){var k=N[O];for(S=0;S<k.length;++S){var Q=31&k[S];lS(e,h,U[Q]),h+=w[Q],Q>15&&(lS(e,h,k[S]>>5&127),h+=k[S]>>12)}}}else T=iS,B=tS,R=nS,D=eS;for(S=0;S<o;++S){var G=n[S];if(G>255){cS(e,h,T[(Q=G>>18&31)+257]),h+=B[Q+257],Q>7&&(lS(e,h,G>>23&31),h+=zE[Q]);var z=31&G;cS(e,h,R[z]),h+=D[z],z>3&&(cS(e,h,G>>5&8191),h+=HE[z])}else cS(e,h,T[G]),h+=B[G]}return cS(e,h,T[256]),h+B[256]},mS=new GE([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fS=new kE(0),bS=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),vS=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n<e.length;++n)i=bS[255&i^e[n]]^i>>>8;t=i},d:function(){return~t}}},yS=function(t,e,i,n,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new kE(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,i,n,r,s){var a=s.z||t.length,o=new kE(n+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(n,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=mS[e-1],d=u>>13,p=8191&u,A=(1<<i)-1,g=s.p||new QE(32768),m=s.h||new QE(A+1),f=Math.ceil(i/3),b=2*f,v=function(e){return(t[e]^t[e+1]<<f^t[e+2]<<b)&A},y=new GE(25e3),x=new QE(288),_=new QE(32),E=0,S=0,C=s.i||0,w=0,M=s.w||0,I=0;C+2<a;++C){var T=v(C),B=32767&C,R=m[T];if(g[B]=R,m[T]=B,M<=C){var D=a-C;if((E>7e3||w>24576)&&(D>423||!c)){h=gS(t,l,0,y,x,_,S,w,I,C-I,h),w=E=S=0,I=C;for(var L=0;L<286;++L)x[L]=0;for(L=0;L<30;++L)_[L]=0}var P=2,F=0,U=p,N=B-R&32767;if(D>2&&T==v(C-N))for(var O=Math.min(d,D)-1,k=Math.min(32767,C),Q=Math.min(258,D);N<=k&&--U&&B!=R;){if(t[C+P]==t[C+P-N]){for(var G=0;G<Q&&t[C+G]==t[C+G-N];++G);if(G>P){if(P=G,F=N,G>O)break;var z=Math.min(N,G-2),H=0;for(L=0;L<z;++L){var V=C-N+L&32767,q=V-g[V]&32767;q>H&&(H=q,R=V)}}}N+=(B=R)-(R=g[B])&32767}if(F){y[w++]=268435456|XE[P]<<18|KE[F];var j=31&XE[P],W=31&KE[F];S+=zE[j]+HE[W],++x[257+j],++_[W],M=C+P,++E}else y[w++]=t[C],++x[t[C]]}}for(C=Math.max(C,M);C<a;++C)y[w++]=t[C],++x[t[C]];h=gS(t,l,c,y,x,_,S,w,I,C-I,h),c||(s.r=7&h|l[h/8|0]<<3,h-=7,s.h=m,s.p=g,s.i=C,s.w=M)}else{for(C=s.w||0;C<a+c;C+=65535){var X=C+65535;X>=a&&(l[h/8|0]=c,X=a),h=AS(l,h+1,t.subarray(C,X))}s.i=a}return sS(o,0,n+rS(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,i,n,r)},xS=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},_S=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function ES(t,e){return yS(t,e||{},0,0)}var SS=function(t,e,i,n){for(var r in t){var s=t[r],a=e+r,o=n;Array.isArray(s)&&(o=xS(n,s[1]),s=s[0]),s instanceof kE?i[a]=[s,o]:(i[a+="/"]=[new kE(0),o],SS(s,a,i,n))}},CS="undefined"!=typeof TextEncoder&&new TextEncoder,wS="undefined"!=typeof TextDecoder&&new TextDecoder;try{wS.decode(fS,{stream:!0})}catch(S){}function MS(t,e){if(CS)return CS.encode(t);for(var i=t.length,n=new kE(t.length+(t.length>>1)),r=0,s=function(t){n[r++]=t},a=0;a<i;++a){if(r+5>n.length){var o=new kE(r+8+(i-a<<1));o.set(n),n=o}var l=t.charCodeAt(a);l<128||e?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++a))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return sS(n,0,r)}var IS=function(t){var e=0;if(t)for(var i in t){var n=t[i].length;n>65535&&oS(9),e+=n+4}return e},TS=function(t,e,i,n,r,s,a,o){var l=n.length,c=i.extra,h=o&&o.length,u=IS(c);_S(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var d=new Date(null==i.mtime?Date.now():i.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&oS(10),_S(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(_S(t,e,i.crc),_S(t,e+4,s<0?-s-2:s),_S(t,e+8,i.size)),_S(t,e+12,l),_S(t,e+14,u),e+=16,null!=a&&(_S(t,e,h),_S(t,e+6,i.attrs),_S(t,e+10,a),e+=14),t.set(n,e),e+=l,u)for(var A in c){var g=c[A],m=g.length;_S(t,e,+A),_S(t,e+2,m),t.set(g,e+4),e+=4+m}return h&&(t.set(o,e),e+=h),e};function BS(t,e){e||(e={});var i={},n=[];SS(t,"",i,e);var r=0,s=0;for(var a in i){var o=i[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(E=MS(a)).length,d=c.comment,p=d&&MS(d),A=p&&p.length,g=IS(c.extra);u>65535&&oS(11);var m=h?ES(l,c):l,f=m.length,b=vS();b.p(l),n.push(xS(c,{size:l.length,crc:b.d(),c:m,f:E,m:p,u:u!=a.length||p&&d.length!=A,o:r,compression:h})),r+=30+u+g+f,s+=76+2*(u+g)+(A||0)+f}for(var v=new kE(s+22),y=r,x=s-r,_=0;_<n.length;++_){var E=n[_];TS(v,E.o,E,E.f,E.u,E.c.length);var S=30+E.f.length+IS(E.extra);v.set(E.c,E.o+S),TS(v,r,E,E.f,E.u,E.c.length,E.o,E.m),r+=16+S+(E.m?E.m.length:0)}return function(t,e,i,n,r){_S(t,e,101010256),_S(t,e+8,i),_S(t,e+10,i),_S(t,e+12,n),_S(t,e+16,r)}(v,r,n.length,x,y),v}class RS{constructor(t,e="",i=[],n=[]){this.name=t,this.type=e,this.metadata=i,this.properties=n,this.children=[]}addMetadata(t,e){this.metadata.push({key:t,value:e})}addProperty(t,e=[]){this.properties.push({property:t,metadata:e})}addChild(t){this.children.push(t)}toString(t=0){const e="\t".repeat(t),i=this.metadata.map(t=>{const i=t.key,n=t.value;if(Array.isArray(n)){const t=[];return t.push(`${i} = {`),n.forEach(i=>{t.push(`${e}\t\t${i}`)}),t.push(`${e}\t}`),t.join("\n")}return`${i} = ${n}`}),n=i.length?` (\n${i.map(t=>`${e}\t${t}`).join("\n")}\n${e})`:"",r=this.properties.map(t=>{const i=t.property,n=t.metadata.length?` (\n${t.metadata.map(t=>`${e}\t\t${t}`).join("\n")}\n${e}\t)`:"";return`${e}\t${i}${n}`}),s=this.children.map(e=>e.toString(t+1)),a=[];if(r.length>0&&a.push(...r),s.length>0){r.length>0&&a.push("");for(let t=0;t<s.length;t++)a.push(s[t]),t<s.length-1&&a.push("")}const o=a.join("\n"),l=this.type?this.type+" ":"";return`${e}def ${l}"${this.name}"${n}\n${e}{\n${o}\n${e}}`}}class DS{constructor(){this.textureUtils=null}setTextureUtils(t){this.textureUtils=t}parse(t,e,i,n){this.parseAsync(t,n).then(e).catch(i)}async parseAsync(t,e={}){e=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},includeAnchoringProperties:!0,onlyVisible:!0,quickLookCompatible:!1,maxTextureSize:1024},e);const i=new Set,n={},r="model.usda";n[r]=null;const s=new RS("Root","Xform"),a=new RS("Scenes","Scope");a.addMetadata("kind",'"sceneLibrary"'),s.addChild(a);const o="Scene",l=new RS(o,"Xform");let c;l.addMetadata("customData",["bool preliminary_collidesWithEnvironment = 0",`string sceneName = "${o}"`]),l.addMetadata("sceneName",`"${o}"`),e.includeAnchoringProperties&&(l.addProperty(`token preliminary:anchoring:type = "${e.ar.anchoring.type}"`),l.addProperty(`token preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"`)),a.addChild(l);const h={},u={};NS(t,l,h,i,n,e);const d=function(t,e,i=!1){const n=new RS("Materials");for(const r in t){const s=t[r];n.addChild(qS(s,e,i))}return n}(h,u,e.quickLookCompatible);c=US()+"\n"+s.toString()+"\n\n"+d.toString(),n[r]=MS(c),c=null;for(const t in u){let i=u[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=PS(i.image,i.flipY,e.maxTextureSize),s=await new Promise(t=>r.toBlob(t,"image/png",1));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let p=0;for(const t in n){const e=n[t];p+=34+t.length;const i=63&p;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}p=e.length}return BS(n,{level:0})}}function LS(t,e){let i=t.name;return i=i.replace(/[^A-Za-z0-9_]/g,""),/^[0-9]/.test(i)&&(i="_"+i),""===i&&(i=t.isCamera?"Camera":"Object"),e.has(i)&&(i=i+"_"+t.id),e.add(i),i}function PS(t,e,i){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=i/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,n),r.height=t.height*Math.min(1,n);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const FS=7;function US(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n'}function NS(t,e,i,n,r,s){for(let a=0,o=t.children.length;a<o;a++){const o=t.children[a];if(!1===o.visible&&!0===s.onlyVisible)continue;let l;if(o.isMesh){const t=o.geometry,e=o.material;if(e.isMeshStandardMaterial){const s="geometries/Geometry_"+t.id+".usda";if(!(s in r)){const e=zS(t);r[s]=MS(US()+"\n"+e.toString())}e.uuid in i||(i[e.uuid]=e),l=kS(o,t,i[e.uuid],n)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",o)}else l=o.isCamera?XS(o,n):OS(o,n);l&&(e.addChild(l),NS(o,l,i,n,r,s))}}function OS(t,e){const i=LS(t,e);t.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);const n=new RS(i,"Xform");if(null!==t.pivot){const e=t.position,i=t.quaternion,r=t.scale,s=t.pivot;n.addProperty(`float3 xformOp:translate = (${e.x.toPrecision(FS)}, ${e.y.toPrecision(FS)}, ${e.z.toPrecision(FS)})`),n.addProperty(`float3 xformOp:translate:pivot = (${s.x.toPrecision(FS)}, ${s.y.toPrecision(FS)}, ${s.z.toPrecision(FS)})`),n.addProperty(`quatf xformOp:orient = (${i.w.toPrecision(FS)}, ${i.x.toPrecision(FS)}, ${i.y.toPrecision(FS)}, ${i.z.toPrecision(FS)})`),n.addProperty(`float3 xformOp:scale = (${r.x.toPrecision(FS)}, ${r.y.toPrecision(FS)}, ${r.z.toPrecision(FS)})`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]')}else{const e=QS(t.matrix);n.addProperty(`matrix4d xformOp:transform = ${e}`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]')}return n}function kS(t,e,i,n){const r=OS(t,n);return r.addMetadata("prepend references",`@./geometries/Geometry_${e.id}.usda@</Geometry>`),r.addMetadata("prepend apiSchemas",'["MaterialBindingAPI"]'),r.addProperty(`rel material:binding = </Materials/Material_${i.id}>`),r}function QS(t){const e=t.elements;return`( ${GS(e,0)}, ${GS(e,4)}, ${GS(e,8)}, ${GS(e,12)} )`}function GS(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function zS(t){const e=new RS("Geometry"),i=function(t){const e="Geometry",i=t.attributes,n=i.position.count,r=new RS(e,"Mesh");r.addProperty(`int[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]`),r.addProperty(`int[] faceVertexIndices = [${function(t){const e=t.index,i=[];if(null!==e)for(let t=0;t<e.count;t++)i.push(e.getX(t));else{const e=t.attributes.position.count;for(let t=0;t<e;t++)i.push(t)}return i.join(", ")}(t)}]`),r.addProperty(`normal3f[] normals = [${HS(i.normal,n)}]`,['interpolation = "vertex"']),r.addProperty(`point3f[] points = [${HS(i.position,n)}]`);for(let t=0;t<4;t++){const e=t>0?t:"",n=i["uv"+e];void 0!==n&&r.addProperty(`texCoord2f[] primvars:st${e} = [${VS(n)}]`,['interpolation = "vertex"'])}const s=i.color;void 0!==s&&r.addProperty(`color3f[] primvars:displayColor = [${HS(s,n)}]`,['interpolation = "vertex"']);return r.addProperty('uniform token subdivisionScheme = "none"'),r}(t);return e.addChild(i),e}function HS(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const i=[];for(let e=0;e<t.count;e++){const n=t.getX(e),r=t.getY(e),s=t.getZ(e);i.push(`(${n.toPrecision(FS)}, ${r.toPrecision(FS)}, ${s.toPrecision(FS)})`)}return i.join(", ")}function VS(t){const e=[];for(let i=0;i<t.count;i++){const n=t.getX(i),r=t.getY(i);e.push(`(${n.toPrecision(FS)}, ${1-r.toPrecision(FS)})`)}return e.join(", ")}function qS(t,e,i=!1){const n=new RS(`Material_${t.id}`,"Material");function r(n,r,s){const a=n.source.id+"_"+n.flipY;e[a]=n;const o=n.channel>0?"st"+n.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=n.repeat.clone(),h=n.offset.clone(),u=n.rotation,d=Math.sin(u),p=Math.cos(u);h.y=1-h.y-c.y,i?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y);const A=new RS(`PrimvarReader_${r}`,"Shader");A.addProperty('uniform token info:id = "UsdPrimvarReader_float2"'),A.addProperty("float2 inputs:fallback = (0.0, 0.0)"),A.addProperty(`string inputs:varname = "${o}"`),A.addProperty("float2 outputs:result");const g=new RS(`Transform2d_${r}`,"Shader");g.addProperty('uniform token info:id = "UsdTransform2d"'),g.addProperty(`float2 inputs:in.connect = </Materials/Material_${t.id}/PrimvarReader_${r}.outputs:result>`),g.addProperty(`float inputs:rotation = ${(u*(180/Math.PI)).toFixed(FS)}`),g.addProperty(`float2 inputs:scale = ${WS(c)}`),g.addProperty(`float2 inputs:translation = ${WS(h)}`),g.addProperty("float2 outputs:result");const m=new RS(`Texture_${n.id}_${r}`,"Shader");return m.addProperty('uniform token info:id = "UsdUVTexture"'),m.addProperty(`asset inputs:file = @textures/Texture_${a}.png@`),m.addProperty(`float2 inputs:st.connect = </Materials/Material_${t.id}/Transform2d_${r}.outputs:result>`),void 0!==s&&m.addProperty(`float4 inputs:scale = ${function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s)}`),"normal"===r&&(m.addProperty("float4 inputs:scale = (2, 2, 2, 1)"),m.addProperty("float4 inputs:bias = (-1, -1, -1, 0)")),m.addProperty(`token inputs:sourceColorSpace = "${n.colorSpace===Ri?"raw":"sRGB"}"`),m.addProperty(`token inputs:wrapS = "${l[n.wrapS]}"`),m.addProperty(`token inputs:wrapT = "${l[n.wrapT]}"`),m.addProperty("float outputs:r"),m.addProperty("float outputs:g"),m.addProperty("float outputs:b"),m.addProperty("float3 outputs:rgb"),(t.transparent||t.alphaTest>0)&&m.addProperty("float outputs:a"),[A,g,m]}2===t.side&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t);const s=new RS("PreviewSurface","Shader");if(s.addProperty('uniform token info:id = "UsdPreviewSurface"'),null!==t.map){s.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:rgb>`),t.transparent?s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`):t.alphaTest>0&&(s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`),s.addProperty(`float inputs:opacityThreshold = ${t.alphaTest}`));r(t.map,"diffuse",t.color).forEach(t=>n.addChild(t))}else s.addProperty(`color3f inputs:diffuseColor = ${jS(t.color)}`);if(null!==t.emissiveMap){s.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${t.id}/Texture_${t.emissiveMap.id}_emissive.outputs:rgb>`);const e=new Sr(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity);r(t.emissiveMap,"emissive",e).forEach(t=>n.addChild(t))}else t.emissive.getHex()>0&&s.addProperty(`color3f inputs:emissiveColor = ${jS(t.emissive)}`);if(null!==t.normalMap){s.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${t.id}/Texture_${t.normalMap.id}_normal.outputs:rgb>`);r(t.normalMap,"normal").forEach(t=>n.addChild(t))}if(null!==t.aoMap){s.addProperty(`float inputs:occlusion.connect = </Materials/Material_${t.id}/Texture_${t.aoMap.id}_occlusion.outputs:r>`);const e=new Sr(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity);r(t.aoMap,"occlusion",e).forEach(t=>n.addChild(t))}if(null!==t.roughnessMap){s.addProperty(`float inputs:roughness.connect = </Materials/Material_${t.id}/Texture_${t.roughnessMap.id}_roughness.outputs:g>`);const e=new Sr(t.roughness,t.roughness,t.roughness);r(t.roughnessMap,"roughness",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:roughness = ${t.roughness}`);if(null!==t.metalnessMap){s.addProperty(`float inputs:metallic.connect = </Materials/Material_${t.id}/Texture_${t.metalnessMap.id}_metallic.outputs:b>`);const e=new Sr(t.metalness,t.metalness,t.metalness);r(t.metalnessMap,"metallic",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:metallic = ${t.metalness}`);if(null!==t.alphaMap){s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.alphaMap.id}_opacity.outputs:r>`),s.addProperty("float inputs:opacityThreshold = 0.0001");r(t.alphaMap,"opacity").forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:opacity = ${t.opacity}`);if(t.isMeshPhysicalMaterial){if(null!==t.clearcoatMap){s.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatMap.id}_clearcoat.outputs:r>`);const e=new Sr(t.clearcoat,t.clearcoat,t.clearcoat);r(t.clearcoatMap,"clearcoat",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:clearcoat = ${t.clearcoat}`);if(null!==t.clearcoatRoughnessMap){s.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);const e=new Sr(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness);r(t.clearcoatRoughnessMap,"clearcoatRoughness",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`);s.addProperty(`float inputs:ior = ${t.ior}`)}return s.addProperty("int inputs:useSpecularWorkflow = 0"),s.addProperty("token outputs:surface"),n.addChild(s),n.addProperty(`token outputs:surface.connect = </Materials/Material_${t.id}/PreviewSurface.outputs:surface>`),n}function jS(t){return`(${t.r}, ${t.g}, ${t.b})`}function WS(t){return`(${t.x}, ${t.y})`}function XS(t,e){const i=LS(t,e),n=QS(t.matrix);t.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);const r=new RS(i,"Camera");r.addProperty(`matrix4d xformOp:transform = ${n}`),r.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]');const s=t.isOrthographicCamera?"orthographic":"perspective";r.addProperty(`token projection = "${s}"`);const a=`(${t.near.toPrecision(FS)}, ${t.far.toPrecision(FS)})`;let o,l;if(r.addProperty(`float2 clippingRange = ${a}`),o=t.isOrthographicCamera?(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(FS):t.getFilmWidth().toPrecision(FS),r.addProperty(`float horizontalAperture = ${o}`),l=t.isOrthographicCamera?(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(FS):t.getFilmHeight().toPrecision(FS),r.addProperty(`float verticalAperture = ${l}`),t.isPerspectiveCamera){const e=t.getFocalLength().toPrecision(FS);r.addProperty(`float focalLength = ${e}`);const i=t.focus.toPrecision(FS);r.addProperty(`float focusDistance = ${i}`)}return r}+var QE=Uint8Array,GE=Uint16Array,zE=Int32Array,HE=new QE([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),VE=new QE([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),qE=new QE([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jE=function(t,e){for(var i=new GE(31),n=0;n<31;++n)i[n]=e+=1<<t[n-1];var r=new zE(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},WE=jE(HE,2),XE=WE.b,KE=WE.r;XE[28]=258,KE[258]=28;for(var JE=jE(VE,0).r,YE=new GE(32768),$E=0;$E<32768;++$E){var ZE=(43690&$E)>>1|(21845&$E)<<1;ZE=(61680&(ZE=(52428&ZE)>>2|(13107&ZE)<<2))>>4|(3855&ZE)<<4,YE[$E]=((65280&ZE)>>8|(255&ZE)<<8)>>1}var tS=function(t,e,i){for(var n=t.length,r=0,s=new GE(e);r<n;++r)t[r]&&++s[t[r]-1];var a,o=new GE(e);for(r=1;r<e;++r)o[r]=o[r-1]+s[r-1]<<1;if(i){a=new GE(1<<e);var l=15-e;for(r=0;r<n;++r)if(t[r])for(var c=r<<4|t[r],h=e-t[r],u=o[t[r]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[YE[u]>>l]=c}else for(a=new GE(n),r=0;r<n;++r)t[r]&&(a[r]=YE[o[t[r]-1]++]>>15-t[r]);return a},eS=new QE(288);for($E=0;$E<144;++$E)eS[$E]=8;for($E=144;$E<256;++$E)eS[$E]=9;for($E=256;$E<280;++$E)eS[$E]=7;for($E=280;$E<288;++$E)eS[$E]=8;var iS=new QE(32);for($E=0;$E<32;++$E)iS[$E]=5;var nS=tS(eS,9,0),rS=tS(iS,5,0),sS=function(t){return(t+7)/8|0},aS=function(t,e,i){return(null==i||i>t.length)&&(i=t.length),new QE(t.subarray(e,i))},oS=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],lS=function(t,e,i){var n=new Error(e||oS[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,lS),!i)throw n;return n},cS=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8},hS=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8,t[n+2]|=i>>16},uS=function(t,e){for(var i=[],n=0;n<t.length;++n)t[n]&&i.push({s:n,f:t[n]});var r=i.length,s=i.slice();if(!r)return{t:bS,l:0};if(1==r){var a=new QE(i[0].s+1);return a[i[0].s]=1,{t:a,l:1}}i.sort(function(t,e){return t.f-e.f}),i.push({s:-1,f:25001});var o=i[0],l=i[1],c=0,h=1,u=2;for(i[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=r-1;)o=i[i[c].f<i[u].f?c++:u++],l=i[c!=h&&i[c].f<i[u].f?c++:u++],i[h++]={s:-1,f:o.f+l.f,l:o,r:l};var d=s[0].s;for(n=1;n<r;++n)s[n].s>d&&(d=s[n].s);var p=new GE(d+1),A=dS(i[h-1],p,0);if(A>e){n=0;var g=0,m=A-e,f=1<<m;for(s.sort(function(t,e){return p[e.s]-p[t.s]||t.f-e.f});n<r;++n){var b=s[n].s;if(!(p[b]>e))break;g+=f-(1<<A-p[b]),p[b]=e}for(g>>=m;g>0;){var v=s[n].s;p[v]<e?g-=1<<e-p[v]++-1:++n}for(;n>=0&&g;--n){var y=s[n].s;p[y]==e&&(--p[y],++g)}A=e}return{t:new QE(p),l:A}},dS=function(t,e,i){return-1==t.s?Math.max(dS(t.l,e,i+1),dS(t.r,e,i+1)):e[t.s]=i},pS=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new GE(++e),n=0,r=t[0],s=1,a=function(t){i[n++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return{c:i.subarray(0,n),n:e}},AS=function(t,e){for(var i=0,n=0;n<e.length;++n)i+=t[n]*e[n];return i},gS=function(t,e,i){var n=i.length,r=sS(e+2);t[r]=255&n,t[r+1]=n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s<n;++s)t[r+s+4]=i[s];return 8*(r+4+n)},mS=function(t,e,i,n,r,s,a,o,l,c,h){cS(e,h++,i),++r[256];for(var u=uS(r,15),d=u.t,p=u.l,A=uS(s,15),g=A.t,m=A.l,f=pS(d),b=f.c,v=f.n,y=pS(g),x=y.c,_=y.n,E=new GE(19),S=0;S<b.length;++S)++E[31&b[S]];for(S=0;S<x.length;++S)++E[31&x[S]];for(var C=uS(E,7),w=C.t,M=C.l,I=19;I>4&&!w[qE[I-1]];--I);var T,B,R,D,L=c+5<<3,P=AS(r,eS)+AS(s,iS)+a,F=AS(r,d)+AS(s,g)+a+14+3*I+AS(E,w)+2*E[16]+3*E[17]+7*E[18];if(l>=0&&L<=P&&L<=F)return gS(e,h,t.subarray(l,l+c));if(cS(e,h,1+(F<P)),h+=2,F<P){T=tS(d,p,0),B=d,R=tS(g,m,0),D=g;var U=tS(w,M,0);cS(e,h,v-257),cS(e,h+5,_-1),cS(e,h+10,I-4),h+=14;for(S=0;S<I;++S)cS(e,h+3*S,w[qE[S]]);h+=3*I;for(var N=[b,x],O=0;O<2;++O){var k=N[O];for(S=0;S<k.length;++S){var Q=31&k[S];cS(e,h,U[Q]),h+=w[Q],Q>15&&(cS(e,h,k[S]>>5&127),h+=k[S]>>12)}}}else T=nS,B=eS,R=rS,D=iS;for(S=0;S<o;++S){var G=n[S];if(G>255){hS(e,h,T[(Q=G>>18&31)+257]),h+=B[Q+257],Q>7&&(cS(e,h,G>>23&31),h+=HE[Q]);var z=31&G;hS(e,h,R[z]),h+=D[z],z>3&&(hS(e,h,G>>5&8191),h+=VE[z])}else hS(e,h,T[G]),h+=B[G]}return hS(e,h,T[256]),h+B[256]},fS=new zE([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),bS=new QE(0),vS=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),yS=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n<e.length;++n)i=vS[255&i^e[n]]^i>>>8;t=i},d:function(){return~t}}},xS=function(t,e,i,n,r){if(!r&&(r={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new QE(s.length+t.length);a.set(s),a.set(t,s.length),t=a,r.w=s.length}return function(t,e,i,n,r,s){var a=s.z||t.length,o=new QE(n+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(n,o.length-r),c=s.l,h=7&(s.r||0);if(e){h&&(l[0]=s.r>>3);for(var u=fS[e-1],d=u>>13,p=8191&u,A=(1<<i)-1,g=s.p||new GE(32768),m=s.h||new GE(A+1),f=Math.ceil(i/3),b=2*f,v=function(e){return(t[e]^t[e+1]<<f^t[e+2]<<b)&A},y=new zE(25e3),x=new GE(288),_=new GE(32),E=0,S=0,C=s.i||0,w=0,M=s.w||0,I=0;C+2<a;++C){var T=v(C),B=32767&C,R=m[T];if(g[B]=R,m[T]=B,M<=C){var D=a-C;if((E>7e3||w>24576)&&(D>423||!c)){h=mS(t,l,0,y,x,_,S,w,I,C-I,h),w=E=S=0,I=C;for(var L=0;L<286;++L)x[L]=0;for(L=0;L<30;++L)_[L]=0}var P=2,F=0,U=p,N=B-R&32767;if(D>2&&T==v(C-N))for(var O=Math.min(d,D)-1,k=Math.min(32767,C),Q=Math.min(258,D);N<=k&&--U&&B!=R;){if(t[C+P]==t[C+P-N]){for(var G=0;G<Q&&t[C+G]==t[C+G-N];++G);if(G>P){if(P=G,F=N,G>O)break;var z=Math.min(N,G-2),H=0;for(L=0;L<z;++L){var V=C-N+L&32767,q=V-g[V]&32767;q>H&&(H=q,R=V)}}}N+=(B=R)-(R=g[B])&32767}if(F){y[w++]=268435456|KE[P]<<18|JE[F];var j=31&KE[P],W=31&JE[F];S+=HE[j]+VE[W],++x[257+j],++_[W],M=C+P,++E}else y[w++]=t[C],++x[t[C]]}}for(C=Math.max(C,M);C<a;++C)y[w++]=t[C],++x[t[C]];h=mS(t,l,c,y,x,_,S,w,I,C-I,h),c||(s.r=7&h|l[h/8|0]<<3,h-=7,s.h=m,s.p=g,s.i=C,s.w=M)}else{for(C=s.w||0;C<a+c;C+=65535){var X=C+65535;X>=a&&(l[h/8|0]=c,X=a),h=gS(l,h+1,t.subarray(C,X))}s.i=a}return aS(o,0,n+sS(h)+r)}(t,null==e.level?6:e.level,null==e.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,i,n,r)},_S=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},ES=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function SS(t,e){return xS(t,e||{},0,0)}var CS=function(t,e,i,n){for(var r in t){var s=t[r],a=e+r,o=n;Array.isArray(s)&&(o=_S(n,s[1]),s=s[0]),s instanceof QE?i[a]=[s,o]:(i[a+="/"]=[new QE(0),o],CS(s,a,i,n))}},wS="undefined"!=typeof TextEncoder&&new TextEncoder,MS="undefined"!=typeof TextDecoder&&new TextDecoder;try{MS.decode(bS,{stream:!0})}catch(S){}function IS(t,e){if(wS)return wS.encode(t);for(var i=t.length,n=new QE(t.length+(t.length>>1)),r=0,s=function(t){n[r++]=t},a=0;a<i;++a){if(r+5>n.length){var o=new QE(r+8+(i-a<<1));o.set(n),n=o}var l=t.charCodeAt(a);l<128||e?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++a))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return aS(n,0,r)}var TS=function(t){var e=0;if(t)for(var i in t){var n=t[i].length;n>65535&&lS(9),e+=n+4}return e},BS=function(t,e,i,n,r,s,a,o){var l=n.length,c=i.extra,h=o&&o.length,u=TS(c);ES(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(s<0&&8),t[e++]=r&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var d=new Date(null==i.mtime?Date.now():i.mtime),p=d.getFullYear()-1980;if((p<0||p>119)&&lS(10),ES(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=s&&(ES(t,e,i.crc),ES(t,e+4,s<0?-s-2:s),ES(t,e+8,i.size)),ES(t,e+12,l),ES(t,e+14,u),e+=16,null!=a&&(ES(t,e,h),ES(t,e+6,i.attrs),ES(t,e+10,a),e+=14),t.set(n,e),e+=l,u)for(var A in c){var g=c[A],m=g.length;ES(t,e,+A),ES(t,e+2,m),t.set(g,e+4),e+=4+m}return h&&(t.set(o,e),e+=h),e};function RS(t,e){e||(e={});var i={},n=[];CS(t,"",i,e);var r=0,s=0;for(var a in i){var o=i[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(E=IS(a)).length,d=c.comment,p=d&&IS(d),A=p&&p.length,g=TS(c.extra);u>65535&&lS(11);var m=h?SS(l,c):l,f=m.length,b=yS();b.p(l),n.push(_S(c,{size:l.length,crc:b.d(),c:m,f:E,m:p,u:u!=a.length||p&&d.length!=A,o:r,compression:h})),r+=30+u+g+f,s+=76+2*(u+g)+(A||0)+f}for(var v=new QE(s+22),y=r,x=s-r,_=0;_<n.length;++_){var E=n[_];BS(v,E.o,E,E.f,E.u,E.c.length);var S=30+E.f.length+TS(E.extra);v.set(E.c,E.o+S),BS(v,r,E,E.f,E.u,E.c.length,E.o,E.m),r+=16+S+(E.m?E.m.length:0)}return function(t,e,i,n,r){ES(t,e,101010256),ES(t,e+8,i),ES(t,e+10,i),ES(t,e+12,n),ES(t,e+16,r)}(v,r,n.length,x,y),v}class DS{constructor(t,e="",i=[],n=[]){this.name=t,this.type=e,this.metadata=i,this.properties=n,this.children=[]}addMetadata(t,e){this.metadata.push({key:t,value:e})}addProperty(t,e=[]){this.properties.push({property:t,metadata:e})}addChild(t){this.children.push(t)}toString(t=0){const e="\t".repeat(t),i=this.metadata.map(t=>{const i=t.key,n=t.value;if(Array.isArray(n)){const t=[];return t.push(`${i} = {`),n.forEach(i=>{t.push(`${e}\t\t${i}`)}),t.push(`${e}\t}`),t.join("\n")}return`${i} = ${n}`}),n=i.length?` (\n${i.map(t=>`${e}\t${t}`).join("\n")}\n${e})`:"",r=this.properties.map(t=>{const i=t.property,n=t.metadata.length?` (\n${t.metadata.map(t=>`${e}\t\t${t}`).join("\n")}\n${e}\t)`:"";return`${e}\t${i}${n}`}),s=this.children.map(e=>e.toString(t+1)),a=[];if(r.length>0&&a.push(...r),s.length>0){r.length>0&&a.push("");for(let t=0;t<s.length;t++)a.push(s[t]),t<s.length-1&&a.push("")}const o=a.join("\n"),l=this.type?this.type+" ":"";return`${e}def ${l}"${this.name}"${n}\n${e}{\n${o}\n${e}}`}}class LS{constructor(){this.textureUtils=null}setTextureUtils(t){this.textureUtils=t}parse(t,e,i,n){this.parseAsync(t,n).then(e).catch(i)}async parseAsync(t,e={}){e=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},includeAnchoringProperties:!0,onlyVisible:!0,quickLookCompatible:!1,maxTextureSize:1024},e);const i=new Set,n={},r="model.usda";n[r]=null;const s=new DS("Root","Xform"),a=new DS("Scenes","Scope");a.addMetadata("kind",'"sceneLibrary"'),s.addChild(a);const o="Scene",l=new DS(o,"Xform");let c;l.addMetadata("customData",["bool preliminary_collidesWithEnvironment = 0",`string sceneName = "${o}"`]),l.addMetadata("sceneName",`"${o}"`),e.includeAnchoringProperties&&(l.addProperty(`token preliminary:anchoring:type = "${e.ar.anchoring.type}"`),l.addProperty(`token preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"`)),a.addChild(l);const h={},u={};OS(t,l,h,i,n,e);const d=function(t,e,i=!1){const n=new DS("Materials");for(const r in t){const s=t[r];n.addChild(jS(s,e,i))}return n}(h,u,e.quickLookCompatible);c=NS()+"\n"+s.toString()+"\n\n"+d.toString(),n[r]=IS(c),c=null;for(const t in u){let i=u[t];if(!0===i.isCompressedTexture){if(null===this.textureUtils)throw new Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");i=await this.textureUtils.decompress(i)}const r=FS(i.image,i.flipY,e.maxTextureSize),s=await new Promise(t=>r.toBlob(t,"image/png",1));n[`textures/Texture_${t}.png`]=new Uint8Array(await s.arrayBuffer())}let p=0;for(const t in n){const e=n[t];p+=34+t.length;const i=63&p;if(4!==i){const r=new Uint8Array(64-i);n[t]=[e,{extra:{12345:r}}]}p=e.length}return RS(n,{level:0})}}function PS(t,e){let i=t.name;return i=i.replace(/[^A-Za-z0-9_]/g,""),/^[0-9]/.test(i)&&(i="_"+i),""===i&&(i=t.isCamera?"Camera":"Object"),e.has(i)&&(i=i+"_"+t.id),e.add(i),i}function FS(t,e,i){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=i/Math.max(t.width,t.height),r=document.createElement("canvas");r.width=t.width*Math.min(1,n),r.height=t.height*Math.min(1,n);const s=r.getContext("2d");return!0===e&&(s.translate(0,r.height),s.scale(1,-1)),s.drawImage(t,0,0,r.width,r.height),r}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const US=7;function NS(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n'}function OS(t,e,i,n,r,s){for(let a=0,o=t.children.length;a<o;a++){const o=t.children[a];if(!1===o.visible&&!0===s.onlyVisible)continue;let l;if(o.isMesh){const t=o.geometry,e=o.material;if(e.isMeshStandardMaterial){const s="geometries/Geometry_"+t.id+".usda";if(!(s in r)){const e=HS(t);r[s]=IS(NS()+"\n"+e.toString())}e.uuid in i||(i[e.uuid]=e),l=QS(o,t,i[e.uuid],n)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",o)}else l=o.isCamera?KS(o,n):kS(o,n);l&&(e.addChild(l),OS(o,l,i,n,r,s))}}function kS(t,e){const i=PS(t,e);t.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);const n=new DS(i,"Xform");if(null!==t.pivot){const e=t.position,i=t.quaternion,r=t.scale,s=t.pivot;n.addProperty(`float3 xformOp:translate = (${e.x.toPrecision(US)}, ${e.y.toPrecision(US)}, ${e.z.toPrecision(US)})`),n.addProperty(`float3 xformOp:translate:pivot = (${s.x.toPrecision(US)}, ${s.y.toPrecision(US)}, ${s.z.toPrecision(US)})`),n.addProperty(`quatf xformOp:orient = (${i.w.toPrecision(US)}, ${i.x.toPrecision(US)}, ${i.y.toPrecision(US)}, ${i.z.toPrecision(US)})`),n.addProperty(`float3 xformOp:scale = (${r.x.toPrecision(US)}, ${r.y.toPrecision(US)}, ${r.z.toPrecision(US)})`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]')}else{const e=GS(t.matrix);n.addProperty(`matrix4d xformOp:transform = ${e}`),n.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]')}return n}function QS(t,e,i,n){const r=kS(t,n);return r.addMetadata("prepend references",`@./geometries/Geometry_${e.id}.usda@</Geometry>`),r.addMetadata("prepend apiSchemas",'["MaterialBindingAPI"]'),r.addProperty(`rel material:binding = </Materials/Material_${i.id}>`),r}function GS(t){const e=t.elements;return`( ${zS(e,0)}, ${zS(e,4)}, ${zS(e,8)}, ${zS(e,12)} )`}function zS(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function HS(t){const e=new DS("Geometry"),i=function(t){const e="Geometry",i=t.attributes,n=i.position.count,r=new DS(e,"Mesh");r.addProperty(`int[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]`),r.addProperty(`int[] faceVertexIndices = [${function(t){const e=t.index,i=[];if(null!==e)for(let t=0;t<e.count;t++)i.push(e.getX(t));else{const e=t.attributes.position.count;for(let t=0;t<e;t++)i.push(t)}return i.join(", ")}(t)}]`),r.addProperty(`normal3f[] normals = [${VS(i.normal,n)}]`,['interpolation = "vertex"']),r.addProperty(`point3f[] points = [${VS(i.position,n)}]`);for(let t=0;t<4;t++){const e=t>0?t:"",n=i["uv"+e];void 0!==n&&r.addProperty(`texCoord2f[] primvars:st${e} = [${qS(n)}]`,['interpolation = "vertex"'])}const s=i.color;void 0!==s&&r.addProperty(`color3f[] primvars:displayColor = [${VS(s,n)}]`,['interpolation = "vertex"']);return r.addProperty('uniform token subdivisionScheme = "none"'),r}(t);return e.addChild(i),e}function VS(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const i=[];for(let e=0;e<t.count;e++){const n=t.getX(e),r=t.getY(e),s=t.getZ(e);i.push(`(${n.toPrecision(US)}, ${r.toPrecision(US)}, ${s.toPrecision(US)})`)}return i.join(", ")}function qS(t){const e=[];for(let i=0;i<t.count;i++){const n=t.getX(i),r=t.getY(i);e.push(`(${n.toPrecision(US)}, ${1-r.toPrecision(US)})`)}return e.join(", ")}function jS(t,e,i=!1){const n=new DS(`Material_${t.id}`,"Material");function r(n,r,s){const a=n.source.id+"_"+n.flipY;e[a]=n;const o=n.channel>0?"st"+n.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=n.repeat.clone(),h=n.offset.clone(),u=n.rotation,d=Math.sin(u),p=Math.cos(u);h.y=1-h.y-c.y,i?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=p-1):(h.x+=d*c.x,h.y+=(1-p)*c.y);const A=new DS(`PrimvarReader_${r}`,"Shader");A.addProperty('uniform token info:id = "UsdPrimvarReader_float2"'),A.addProperty("float2 inputs:fallback = (0.0, 0.0)"),A.addProperty(`string inputs:varname = "${o}"`),A.addProperty("float2 outputs:result");const g=new DS(`Transform2d_${r}`,"Shader");g.addProperty('uniform token info:id = "UsdTransform2d"'),g.addProperty(`float2 inputs:in.connect = </Materials/Material_${t.id}/PrimvarReader_${r}.outputs:result>`),g.addProperty(`float inputs:rotation = ${(u*(180/Math.PI)).toFixed(US)}`),g.addProperty(`float2 inputs:scale = ${XS(c)}`),g.addProperty(`float2 inputs:translation = ${XS(h)}`),g.addProperty("float2 outputs:result");const m=new DS(`Texture_${n.id}_${r}`,"Shader");return m.addProperty('uniform token info:id = "UsdUVTexture"'),m.addProperty(`asset inputs:file = @textures/Texture_${a}.png@`),m.addProperty(`float2 inputs:st.connect = </Materials/Material_${t.id}/Transform2d_${r}.outputs:result>`),void 0!==s&&m.addProperty(`float4 inputs:scale = ${function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s)}`),"normal"===r&&(m.addProperty("float4 inputs:scale = (2, 2, 2, 1)"),m.addProperty("float4 inputs:bias = (-1, -1, -1, 0)")),m.addProperty(`token inputs:sourceColorSpace = "${n.colorSpace===Ri?"raw":"sRGB"}"`),m.addProperty(`token inputs:wrapS = "${l[n.wrapS]}"`),m.addProperty(`token inputs:wrapT = "${l[n.wrapT]}"`),m.addProperty("float outputs:r"),m.addProperty("float outputs:g"),m.addProperty("float outputs:b"),m.addProperty("float3 outputs:rgb"),(t.transparent||t.alphaTest>0)&&m.addProperty("float outputs:a"),[A,g,m]}2===t.side&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t);const s=new DS("PreviewSurface","Shader");if(s.addProperty('uniform token info:id = "UsdPreviewSurface"'),null!==t.map){s.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:rgb>`),t.transparent?s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`):t.alphaTest>0&&(s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`),s.addProperty(`float inputs:opacityThreshold = ${t.alphaTest}`));r(t.map,"diffuse",t.color).forEach(t=>n.addChild(t))}else s.addProperty(`color3f inputs:diffuseColor = ${WS(t.color)}`);if(null!==t.emissiveMap){s.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${t.id}/Texture_${t.emissiveMap.id}_emissive.outputs:rgb>`);const e=new Sr(t.emissive.r*t.emissiveIntensity,t.emissive.g*t.emissiveIntensity,t.emissive.b*t.emissiveIntensity);r(t.emissiveMap,"emissive",e).forEach(t=>n.addChild(t))}else t.emissive.getHex()>0&&s.addProperty(`color3f inputs:emissiveColor = ${WS(t.emissive)}`);if(null!==t.normalMap){s.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${t.id}/Texture_${t.normalMap.id}_normal.outputs:rgb>`);r(t.normalMap,"normal").forEach(t=>n.addChild(t))}if(null!==t.aoMap){s.addProperty(`float inputs:occlusion.connect = </Materials/Material_${t.id}/Texture_${t.aoMap.id}_occlusion.outputs:r>`);const e=new Sr(t.aoMapIntensity,t.aoMapIntensity,t.aoMapIntensity);r(t.aoMap,"occlusion",e).forEach(t=>n.addChild(t))}if(null!==t.roughnessMap){s.addProperty(`float inputs:roughness.connect = </Materials/Material_${t.id}/Texture_${t.roughnessMap.id}_roughness.outputs:g>`);const e=new Sr(t.roughness,t.roughness,t.roughness);r(t.roughnessMap,"roughness",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:roughness = ${t.roughness}`);if(null!==t.metalnessMap){s.addProperty(`float inputs:metallic.connect = </Materials/Material_${t.id}/Texture_${t.metalnessMap.id}_metallic.outputs:b>`);const e=new Sr(t.metalness,t.metalness,t.metalness);r(t.metalnessMap,"metallic",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:metallic = ${t.metalness}`);if(null!==t.alphaMap){s.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.alphaMap.id}_opacity.outputs:r>`),s.addProperty("float inputs:opacityThreshold = 0.0001");r(t.alphaMap,"opacity").forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:opacity = ${t.opacity}`);if(t.isMeshPhysicalMaterial){if(null!==t.clearcoatMap){s.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatMap.id}_clearcoat.outputs:r>`);const e=new Sr(t.clearcoat,t.clearcoat,t.clearcoat);r(t.clearcoatMap,"clearcoat",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:clearcoat = ${t.clearcoat}`);if(null!==t.clearcoatRoughnessMap){s.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);const e=new Sr(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness);r(t.clearcoatRoughnessMap,"clearcoatRoughness",e).forEach(t=>n.addChild(t))}else s.addProperty(`float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`);s.addProperty(`float inputs:ior = ${t.ior}`)}return s.addProperty("int inputs:useSpecularWorkflow = 0"),s.addProperty("token outputs:surface"),n.addChild(s),n.addProperty(`token outputs:surface.connect = </Materials/Material_${t.id}/PreviewSurface.outputs:surface>`),n}function WS(t){return`(${t.r}, ${t.g}, ${t.b})`}function XS(t){return`(${t.x}, ${t.y})`}function KS(t,e){const i=PS(t,e),n=GS(t.matrix);t.matrix.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);const r=new DS(i,"Camera");r.addProperty(`matrix4d xformOp:transform = ${n}`),r.addProperty('uniform token[] xformOpOrder = ["xformOp:transform"]');const s=t.isOrthographicCamera?"orthographic":"perspective";r.addProperty(`token projection = "${s}"`);const a=`(${t.near.toPrecision(US)}, ${t.far.toPrecision(US)})`;let o,l;if(r.addProperty(`float2 clippingRange = ${a}`),o=t.isOrthographicCamera?(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(US):t.getFilmWidth().toPrecision(US),r.addProperty(`float horizontalAperture = ${o}`),l=t.isOrthographicCamera?(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(US):t.getFilmHeight().toPrecision(US),r.addProperty(`float verticalAperture = ${l}`),t.isPerspectiveCamera){const e=t.getFocalLength().toPrecision(US);r.addProperty(`float focalLength = ${e}`);const i=t.focus.toPrecision(US);r.addProperty(`float focusDistance = ${i}`)}return r}/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1084,7 +1084,7 @@ var kE=Uint8Array,QE=Uint16Array,GE=Int32Array,zE=new kE([0,0,0,0,0,0,0,0,1,1,1,* See the License for the specific language governing permissions and* limitations under the License.*/-var KS=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};let JS=!1,YS=!1;const $S="#model-viewer-no-ar-fallback",ZS=(tC=["quick-look","scene-viewer","webxr","none"],t=>{try{const e=$m(t),i=(e.length?e[0].terms:[]).filter(t=>t&&"ident"===t.type).map(t=>t.value).filter(t=>tC.indexOf(t)>-1);return new Set(i)}catch(t){}return new Set});var tC;const eC="quick-look",iC="scene-viewer",nC="webxr",rC="none",sC=Symbol("arButtonContainer"),aC=Symbol("enterARWithWebXR"),oC=Symbol("openSceneViewer"),lC=Symbol("openIOSARQuickLook"),cC=Symbol("canActivateAR"),hC=Symbol("arMode"),uC=Symbol("arModes"),dC=Symbol("arAnchor"),pC=Symbol("preload"),AC=Symbol("onARButtonContainerClick"),gC=Symbol("onARStatus"),mC=Symbol("onARTracking"),fC=Symbol("onARTap"),bC=Symbol("selectARMode"),vC=Symbol("triggerLoad");+var JS=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};let YS=!1,$S=!1;const ZS="#model-viewer-no-ar-fallback",tC=(eC=["quick-look","scene-viewer","webxr","none"],t=>{try{const e=$m(t),i=(e.length?e[0].terms:[]).filter(t=>t&&"ident"===t.type).map(t=>t.value).filter(t=>eC.indexOf(t)>-1);return new Set(i)}catch(t){}return new Set});var eC;const iC="quick-look",nC="scene-viewer",rC="webxr",sC="none",aC=Symbol("arButtonContainer"),oC=Symbol("enterARWithWebXR"),lC=Symbol("openSceneViewer"),cC=Symbol("openIOSARQuickLook"),hC=Symbol("canActivateAR"),uC=Symbol("arMode"),dC=Symbol("arModes"),pC=Symbol("arAnchor"),AC=Symbol("preload"),gC=Symbol("onARButtonContainerClick"),mC=Symbol("onARStatus"),fC=Symbol("onARTracking"),bC=Symbol("onARTap"),vC=Symbol("selectARMode"),yC=Symbol("triggerLoad");/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1099,7 +1099,7 @@ var KS=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.* See the License for the specific language governing permissions and* limitations under the License.*/-var yC=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const xC="auto",_C="auto",EC="eager",SC=Symbol("defaultProgressBarElement"),CC=Symbol("posterContainerElement"),wC=Symbol("defaultPosterElement"),MC=Symbol("shouldDismissPoster"),IC=Symbol("hidePoster"),TC=Symbol("modelIsRevealed"),BC=Symbol("updateProgressBar"),RC=Symbol("ariaLabelCallToAction"),DC=Symbol("onProgress");+var xC=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const _C="auto",EC="auto",SC="eager",CC=Symbol("defaultProgressBarElement"),wC=Symbol("posterContainerElement"),MC=Symbol("defaultPosterElement"),IC=Symbol("shouldDismissPoster"),TC=Symbol("hidePoster"),BC=Symbol("modelIsRevealed"),RC=Symbol("updateProgressBar"),DC=Symbol("ariaLabelCallToAction"),LC=Symbol("onProgress");/* @license* Copyright 2019 Google LLC. All Rights Reserved.* Licensed under the Apache License, Version 2.0 (the 'License');@@ -1114,5 +1114,5 @@ var yC=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.* See the License for the specific language governing permissions and* limitations under the License.*/-var LC=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const PC=Math.PI/32,FC={basis:[lf(Ym(PC,"rad"))],keywords:{auto:[null]}},UC=Symbol("autoRotateStartTime"),NC=Symbol("radiansPerSecond"),OC=Symbol("syncRotationRate"),kC=Symbol("onCameraChange"),QC=(t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this[e]=new Map,this[i]=t=>{t.forEach(t=>{t instanceof MutationRecord&&"childList"!==t.type||(t.addedNodes.forEach(t=>{this[NE](t)}),t.removedNodes.forEach(t=>{this[OE](t)}),this[AE]())})},this[n]=new MutationObserver(this[FE])}connectedCallback(){super.connectedCallback();for(let t=0;t<this.children.length;++t)this[NE](this.children[t]);const{ShadyDOM:t}=self;null==t?this[UE].observe(this,{childList:!0}):this[UE]=t.observeChildren(this,this[FE])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:t}=self;null==t?this[UE].disconnect():t.unobserveChildren(this[UE])}[(e=PE,i=FE,n=UE,mE)](){super[mE]();const t=this[pE];t.forHotspots(e=>{t.updateHotspotAttachment(e),t.updateSurfaceHotspot(e)})}[gE](t,e){super[gE](t,e);const i=this[pE],{annotationRenderer:n}=i,r=i.getCamera();i.shouldRender()&&(i.animateSurfaceHotspots(),i.updateHotspotsVisibility(r.position),n.domElement.style.display="",n.render(i,r))}updateHotspot(t){const e=this[PE].get(t.name);null!=e&&(e.updatePosition(t.position),e.updateNormal(t.normal),e.surface=t.surface,void 0!==t.modelIndex&&null!==t.modelIndex&&(e.modelIndex=t.modelIndex),this[pE].updateSurfaceHotspot(e),this[AE]())}queryHotspot(t){const e=this[PE].get(t);if(null==e)return null;const i=EE(e.position),n=EE(e.normal),r=e.facingCamera,s=this[pE],a=s.getCamera(),o=new vn;o.setFromMatrixPosition(e.matrixWorld),o.project(a);const l=s.width/2,c=s.height/2;o.x=o.x*l+l,o.y=-o.y*c+c;const h=EE(new vn(o.x,o.y,o.z));return Number.isFinite(h.x)&&Number.isFinite(h.y)?{position:i,normal:n,canvasPosition:h,facingCamera:r}:null}positionAndNormalFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e),r=i.positionAndNormalFromPoint(n);if(null==r)return null;const s=r.worldToModel,a=EE(r.position.applyMatrix4(s)),o=EE(r.normal.transformDirection(s));let l=null;return null!=r.uv&&(l=SE(r.uv)),{position:a,normal:o,uv:l,modelIndex:r.modelIndex}}surfaceFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e);return i.surfaceFromPoint(n)}[NE](t){if(!(t instanceof HTMLElement&&0===t.slot.indexOf("hotspot")))return;let e=this[PE].get(t.slot);if(null!=e){e.increment();const i=t.dataset.visibilityAttribute;if(null!=i){const n=`data-${i}`;t.toggleAttribute(n,e.facingCamera)}t.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e.facingCamera}}))}else e=new d_({name:t.slot,position:t.dataset.position,normal:t.dataset.normal,surface:t.dataset.surface,modelIndex:null!=t.dataset.modelIndex?parseInt(t.dataset.modelIndex):null}),this[PE].set(t.slot,e),this[pE].addHotspot(e);this[pE].queueRender()}[OE](t){if(!(t instanceof HTMLElement))return;const e=this[PE].get(t.slot);e&&(e.decrement()&&(this[pE].removeHotspot(e),this[PE].delete(t.slot)),this[pE].queueRender())}}return r})((t=>{var e,i,n,r;class s extends t{constructor(){super(...arguments),this[e]=void 0,this[i]=[],this[n]=null,this[r]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[e_]}get extraModels(){return this[i_]}get availableVariants(){return this.model?this.model[Wx]():[]}get originalGltfJson(){return this[t_]}[(e=e_,i=i_,n=Zx,r=t_,n_)](){return()=>{this[AE]()}}[r_](t){return t.colorSpace=Di,t.wrapS=le,t.wrapT=le,new qy(this[n_](),t)}async createTexture(t,e="image/png"){const{textureUtils:i}=this[bE],n=await i.loadImage(t,this.withCredentials,e),r="image/ktx2"===e?"image/png":e;return n.userData.mimeType=r,this[r_](n)}async createLottieTexture(t,e=1){const{textureUtils:i}=this[bE],n=await i.loadLottie(t,e,this.withCredentials);return this[r_](n)}createVideoTexture(t){const e=document.createElement("video");e.crossOrigin=this.withCredentials?"use-credentials":"anonymous",e.src=t,e.muted=!0,e.playsInline=!0,e.loop=!0,e.play();const i=new Ja(e);return this[r_](i)}createCanvasTexture(){const t=document.createElement("canvas"),e=new eo(t);return this[r_](e)}async updated(t){if(super.updated(t),t.has("variantName")){const t=this[vE].beginActivity("variant-update");t(.1);const e=this[e_],{variantName:i}=this;null!=e&&(await e[zx](i),this[AE](),this.dispatchEvent(new CustomEvent("variant-applied"))),t(1)}if(t.has("orientation")||t.has("scale")){if(!this.loaded)return;const t=this[pE];t.applyTransform(),t.updateBoundingBox(),t.updateShadow(),this[bE].arRenderer.onUpdateScene(),this[AE]()}}[mE](){super[mE]();const{currentGLTFs:t}=this[pE],e=t.length>0?t[0]:null;if(null!=e){const{correlatedSceneGraph:t}=e;null!=t&&e!==this[Zx]&&(this[e_]=new Yx(t,this[n_]()),this[t_]=JSON.parse(JSON.stringify(t.gltf))),"variants"in e.userData&&this.requestUpdate("variantName")}this[i_]=[];const i=Array.from(this.querySelectorAll("extra-model"));for(let e=1;e<t.length;e++){const n=t[e];if(null!=n&&null!=n.correlatedSceneGraph){const t=new Yx(n.correlatedSceneGraph,this[n_]());this[i_].push(t),i[e-1]&&(i[e-1].model=t)}}this[Zx]=e}async exportScene(t){const e=this[pE];return new Promise(async(i,n)=>{const r={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(r,t),r.animations=e.animations,r.truncateDrawRange=!0;const s=e.shadow;let a=!1;null!=s&&(a=s.visible,s.visible=!1),await this[e_][Gx]();const o=(new Vg).register(t=>new Hm(t));let l;if(o.setTextureUtils({decompress:(t,e)=>function(t,e=1/0,i=null){Om||(Om=new el(2,2,1,1)),km||(km=new ll({uniforms:{blitTexture:new Bc(t)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),km.uniforms.blitTexture.value=t,km.defines.IS_SRGB=t.colorSpace==Di,km.needsUpdate=!0,Qm||(Qm=new Ks(Om,km),Qm.frustumCulled=!1);const n=new nc,r=new wr;r.add(Qm),null===i&&(i=Nm=new Id({antialias:!1}));const s=Math.min(t.image.width,e),a=Math.min(t.image.height,e);i.setSize(s,a),i.clear(),i.render(r,n);const o=document.createElement("canvas"),l=o.getContext("2d");o.width=s,o.height=a,l.drawImage(i.domElement,0,0,s,a);const c=new eo(o);return c.minFilter=t.minFilter,c.magFilter=t.magFilter,c.wrapS=t.wrapS,c.wrapT=t.wrapT,c.colorSpace=t.colorSpace,c.name=t.name,Nm&&(Nm.forceContextLoss(),Nm.dispose(),Nm=null),c}(t,null!=e?e:1/0,void 0)}),e.models.length>1){l=new mr;for(const t of e.models)l.add(t)}else l=e.models[0];o.parse(l,t=>{if(e.models.length>1)for(const t of e.models)e.target.add(t);else e.target.add(e.models[0]);return i(new Blob([r.binary?t:JSON.stringify(t)],{type:r.binary?"application/octet-stream":"application/json"}))},()=>n("glTF export failed"),r),null!=s&&(s.visible=a)})}materialFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e),r=i.hitFromPoint(n);if(null==r||null==r.face)return null;const s=this[e_];if(null!=s){const t=s[Hx](r);if(null!=t)return t}for(const t of this[i_]){const e=t[Hx](r);if(null!=e)return e}return null}}return $x([ht({type:String,attribute:"variant-name"})],s.prototype,"variantName",void 0),$x([ht({type:String,attribute:"orientation"})],s.prototype,"orientation",void 0),$x([ht({type:String,attribute:"scale"})],s.prototype,"scale",void 0),s})((t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[e]=performance.now(),this[i]=0,this[n]=t=>{this.autoRotate&&"user-interaction"===t.detail.source&&(this[UC]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[kC]),this[UC]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[kC]),this[UC]=performance.now()}updated(t){super.updated(t),t.has("autoRotate")&&(this[UC]=performance.now())}[(e=UC,i=NC,OC)](t){this[NC]=t[0]}[gE](t,e){if(super[gE](t,e),!this.autoRotate||!this[xE]()||this[bE].isPresenting)return;const i=Math.min(e,t-this[UC]-this.autoRotateDelay);i>0&&(this[pE].yaw=this.turntableRotation+this[NC]*i*.001)}get turntableRotation(){return this[pE].yaw}resetTurntableRotation(t=0){this[pE].yaw=t}}return n=kC,LC([ht({type:Boolean,attribute:"auto-rotate"})],r.prototype,"autoRotate",void 0),LC([ht({type:Number,attribute:"auto-rotate-delay"})],r.prototype,"autoRotateDelay",void 0),LC([Xf({intrinsics:FC,updateHandler:OC}),ht({type:String,attribute:"rotation-per-second"})],r.prototype,"rotationPerSecond",void 0),r})((t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this.toneMapping="auto",this.skyboxHeight="0",this[e]=null,this[i]=null,this[n]=null}updated(t){var e;if(super.updated(t),t.has("shadowIntensity")&&(this[pE].setShadowIntensity(.5*this.shadowIntensity),this[AE]()),t.has("shadowSoftness")&&(this[pE].setShadowSoftness(this.shadowSoftness),this[AE]()),t.has("exposure")&&(this[pE].exposure=this.exposure,this[AE]()),t.has("toneMapping")){const t=new Map([["aces",4],["agx",6],["reinhard",2],["cineon",3],["linear",1],["none",0]]);this[pE].toneMapping=null!==(e=t.get(this.toneMapping))&&void 0!==e?e:7,this[AE]()}(t.has("environmentImage")||t.has("skyboxImage"))&&this[_E]()&&this[Yd](),t.has("skyboxHeight")&&(this[pE].setGroundedSkybox(),this[AE]())}hasBakedShadow(){return this[pE].bakedShadows.size>0}async[(e=Kd,i=Jd,n=$d,Yd)](){const{skyboxImage:t,environmentImage:e}=this;null!=this[$d]&&(this[$d](),this[$d]=null);const{textureUtils:i}=this[bE];if(null==i)return;const n=this[vE].beginActivity("environment-update");try{const{environmentMap:r,skybox:s}=await i.generateEnvironmentMapAndSkybox(zd(t),e,t=>n(jd(t,0,1)),this.withCredentials);this[Kd]!==r&&(this[Kd]=r,this.dispatchEvent(new CustomEvent("environment-change"))),this[Jd]=null!=s?s.name===r.name?r:s:null,this[pE].setEnvironmentAndSkybox(this[Kd],this[Jd])}catch(t){if(t instanceof Error)throw this[pE].setEnvironmentAndSkybox(null,null),t}finally{n(1)}}}return Xd([ht({type:String,attribute:"environment-image"})],r.prototype,"environmentImage",void 0),Xd([ht({type:String,attribute:"skybox-image"})],r.prototype,"skyboxImage",void 0),Xd([ht({type:Number,attribute:"shadow-intensity"})],r.prototype,"shadowIntensity",void 0),Xd([ht({type:Number,attribute:"shadow-softness"})],r.prototype,"shadowSoftness",void 0),Xd([ht({type:Number})],r.prototype,"exposure",void 0),Xd([ht({type:String,attribute:"tone-mapping"})],r.prototype,"toneMapping",void 0),Xd([ht({type:String,attribute:"skybox-height"})],r.prototype,"skyboxHeight",void 0),r})((t=>{var e,i,n,r,s,a,o,l,c,h,u,d,p,A,g,m,f,b;class v extends t{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=eb,this.cameraTarget="auto auto auto",this.fieldOfView="auto",this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=3e3,this.interactionPrompt=rb,this.interactionPromptStyle=ab,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=ob,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this.a11y=null,this[e]=this.shadowRoot.querySelector(".interaction-prompt"),this[i]=this.shadowRoot.querySelector("#prompt"),this[n]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[r]=this.shadowRoot.querySelector(".pan-target"),this[s]=0,this[a]=1/0,this[o]=!1,this[l]=!1,this[c]=$b.AUTOMATIC,this[h]=new Zb(this[pE].camera,this[uE],this[pE]),this[u]=new Pc,this[d]=!1,this[p]=!1,this[A]=!1,this[g]={},this[m]=()=>{const t=this[bb].changeSource;this[Fb]=t,t===$b.USER_INTERACTION&&(this[Db]=!0,this[Eb]())},this[f]=()=>{this[Sb](),this[AE]();const t=this[bb].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:t}}))},this[b]=t=>{this[hE].classList.toggle("pointer-tumbling","pointer-change-start"===t.type)}}get inputSensitivity(){return this[bb].inputSensitivity}set inputSensitivity(t){this[bb].inputSensitivity=t}getCameraOrbit(){const{theta:t,phi:e,radius:i}=this[Ub];return{theta:t,phi:e,radius:i,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return EE(this[bE].isPresenting?this[bE].arRenderer.target:this[pE].getDynamicTarget())}getFieldOfView(){return this[bb].getFieldOfView()}getMinimumFieldOfView(){return this[bb].options.minimumFieldOfView}getMaximumFieldOfView(){return this[bb].options.maximumFieldOfView}getIdealAspect(){return this[pE].idealAspect}jumpCameraToGoal(){this[Nb]=!0,this.requestUpdate(Nb,!1)}resetInteractionPrompt(){this[Pb]=0,this[Lb]=1/0,this[Db]=!1,this[Rb]=this.interactionPrompt===rb&&this.cameraControls}zoom(t){const e=new WheelEvent("wheel",{deltaY:-30*t});this[uE].dispatchEvent(e)}connectedCallback(){super.connectedCallback(),this[bb].addEventListener("user-interaction",this[Ib]),this[bb].addEventListener("pointer-change-start",this[Bb]),this[bb].addEventListener("pointer-change-end",this[Bb])}disconnectedCallback(){super.disconnectedCallback(),this[bb].removeEventListener("user-interaction",this[Ib]),this[bb].removeEventListener("pointer-change-start",this[Bb]),this[bb].removeEventListener("pointer-change-end",this[Bb])}updated(t){super.updated(t);const e=this[bb],i=this[pE];if(t.has("cameraControls")&&(this.cameraControls?(e.enableInteraction(),this.interactionPrompt===rb&&(this[Rb]=!0)):(e.disableInteraction(),this[Eb]()),this[uE].setAttribute("aria-label",this[nE])),t.has("disableZoom")&&(e.disableZoom=this.disableZoom),t.has("disablePan")&&(e.enablePan=!this.disablePan),t.has("disableTap")&&(e.enableTap=!this.disableTap),(t.has("interactionPrompt")||t.has("cameraControls")||t.has("src"))&&(this.interactionPrompt===rb&&this.cameraControls&&!this[Db]?this[Rb]=!0:this[Eb]()),t.has("interactionPromptStyle")&&(this[xb].style.opacity=this.interactionPromptStyle==sb?"1":"0"),t.has("touchAction")){const t=this.touchAction;e.applyOptions({touchAction:t}),e.updateTouchActionStyle()}t.has("orbitSensitivity")&&(e.orbitSensitivity=this.orbitSensitivity),t.has("zoomSensitivity")&&(e.zoomSensitivity=this.zoomSensitivity),t.has("panSensitivity")&&(e.panSensitivity=this.panSensitivity),t.has("interpolationDecay")&&(e.setDamperDecayTime(this.interpolationDecay),i.setTargetDamperDecayTime(this.interpolationDecay)),t.has("a11y")&&this[wb](),!0===this[Nb]&&Promise.resolve().then(()=>{e.jumpToGoal(),i.jumpToGoal(),this[Tb](),this[Nb]=!1})}async updateFraming(){const t=this[pE],e=t.adjustedFoV(t.framedFoVDeg);await t.updateFraming();const i=t.adjustedFoV(t.framedFoVDeg),n=this[bb].getFieldOfView()/e;this[bb].setFieldOfView(i*n),this[kb]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(t,e,i){const n=this[uE],r=this[_b];if("1"===r[0].style.opacity)return void console.warn("interact() failed because an existing interaction is running.");const s=new Array;s.push({x:Yf(e.x),y:Yf(e.y)});const a=[{x:s[0].x(0),y:s[0].y(0)}];null!=i&&(s.push({x:Yf(i.x),y:Yf(i.y)}),a.push({x:s[1].x(0),y:s[1].y(0)}));let o=performance.now();const{width:l,height:c}=this[pE],h=this.getBoundingClientRect(),u=t=>{for(const[e,i]of a.entries()){const{style:s}=r[e];s.transform=`translateX(${l*i.x}px) translateY(${c*i.y}px)`,"pointerdown"===t?s.opacity="1":"pointerup"===t&&(s.opacity="0");const a={pointerId:e-5678,pointerType:"touch",target:n,clientX:l*i.x+h.x,clientY:c*i.y+h.y,altKey:!0};n.dispatchEvent(new PointerEvent(t,a))}},d=()=>{const e=this[Fb];if(e!==$b.AUTOMATIC||!n.isConnected){for(const t of this[_b])t.style.opacity="0";return u("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:e}})),void document.removeEventListener("visibilitychange",p)}const i=Math.min(1,(performance.now()-o)/t);for(const[t,e]of a.entries())e.x=s[t].x(i),e.y=s[t].y(i);u("pointermove"),i<1?requestAnimationFrame(d):(u("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:$b.AUTOMATIC}})),document.removeEventListener("visibilitychange",p))},p=()=>{let t=0;"hidden"===document.visibilityState?t=performance.now()-o:o=performance.now()-t};document.addEventListener("visibilitychange",p),u("pointerdown"),this[Fb]=$b.AUTOMATIC,requestAnimationFrame(d)}[(e=yb,i=xb,n=_b,r=vb,s=Pb,a=Lb,o=Db,l=Rb,c=Fb,h=bb,u=Ub,d=Nb,p=Ob,A=kb,g=Cb,Gb)](t){const e=this[bb],i=this[pE];i.framedFoVDeg=180*t[0]/Math.PI,e.changeSource=$b.NONE,e.setFieldOfView(i.adjustedFoV(i.framedFoVDeg)),this[Ib]()}[Qb](t){const e=this[bb];if(this[kb]){const{theta:e,phi:i}=this.getCameraOrbit();t[0]=e,t[1]=i,this[kb]=!1}e.changeSource=$b.NONE,e.setOrbit(t[0],t[1],t[2]),this[Ib]()}[Hb](t){this[bb].applyOptions({minimumAzimuthalAngle:t[0],minimumPolarAngle:t[1],minimumRadius:t[2]}),this.jumpCameraToGoal()}[Vb](t){this[bb].applyOptions({maximumAzimuthalAngle:t[0],maximumPolarAngle:t[1],maximumRadius:t[2]}),this[Mb](t[2]),this.jumpCameraToGoal()}[qb](t){this[bb].applyOptions({minimumFieldOfView:180*t[0]/Math.PI}),this.jumpCameraToGoal()}[jb](t){const e=this[pE].adjustedFoV(180*t[0]/Math.PI);this[bb].applyOptions({maximumFieldOfView:e}),this.jumpCameraToGoal()}[zb](t){const[e,i,n]=t;this[bE].arRenderer.isPresenting||this[pE].setTarget(e,i,n),this[bb].changeSource=$b.NONE,this[bE].arRenderer.updateTarget(),this[Ib]()}[gE](t,e){if(super[gE](t,e),this[bE].isPresenting||!this[xE]())return;const i=this[bb],n=this[pE],r=performance.now();if(this[Rb]&&this.loaded&&r>this[oE]+this.interactionPromptThreshold&&(this[Rb]=!1,this[Lb]=r,this[yb].classList.add("visible")),isFinite(this[Lb])&&this.interactionPromptStyle===ab){const t=(r-this[Lb])/5e3%1,e=Zf(t),s=tb(t);if(this[xb].style.opacity=`${s}`,e!==this[Pb]){const t=e*n.width*.05,r=(e-this[Pb])*Math.PI/16;this[xb].style.transform=`translateX(${t}px)`,i.changeSource=$b.AUTOMATIC,i.adjustOrbit(r,0,0),this[Pb]=e}}const s=i.update(t,e),a=n.updateTarget(e);(s||a)&&this[Tb]()}[Eb](){this[Rb]=!1,this[yb].classList.remove("visible"),this[Lb]=1/0}[Mb](t){const e=Math.max(this[pE].farRadius(),t),i=Math.abs(2*e);this[bb].updateNearFar(0,i)}[Sb](){const{theta:t,phi:e}=this[bb].getCameraSpherical(this[Ub]),i=(4+Math.floor((t%fb+mb)/Ab))%4,n=Math.floor(e/gb),r=`${nb[n]}${ib[i]}`,s=r;s in this[Cb]?this[aE](this[Cb][s]):this[aE](`View from stage ${r}`)}get[nE](){let t=". Use mouse, touch or arrow keys to move.";return"interaction-prompt"in this[Cb]&&(t=`. ${this[Cb]["interaction-prompt"]}`),super[nE].replace(/\.$/,"")+(this.cameraControls?t:"")}async[fE](t){const e=this[bb],i=this[pE],n=i.adjustedFoV(i.framedFoVDeg);super[fE](t);const r=i.adjustedFoV(i.framedFoVDeg)/n,s=e.getFieldOfView()*(isFinite(r)?r:1);e.updateAspect(this[pE].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[bb].setFieldOfView(s),this.jumpCameraToGoal()}[mE](){super[mE](),this[Ob]?this[kb]=!0:this[Ob]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}[(m=Ib,f=Tb,b=Bb,wb)](){if("string"==typeof this.a11y)if(this.a11y.startsWith("{"))try{this[Cb]=JSON.parse(this.a11y)}catch(t){console.warn("Error parsing a11y JSON:",t)}else this.a11y.length>0?console.warn("Error not supported format, should be a JSON string:",this.a11y):this[Cb]={};else"object"==typeof this.a11y&&null!=this.a11y?this[Cb]=Object.assign({},this.a11y):this[Cb]={};this[uE].setAttribute("aria-label",this[nE])}}return $f([ht({type:Boolean,attribute:"camera-controls"})],v.prototype,"cameraControls",void 0),$f([Xf({intrinsics:hb,observeEffects:!0,updateHandler:Qb}),ht({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],v.prototype,"cameraOrbit",void 0),$f([Xf({intrinsics:pb,observeEffects:!0,updateHandler:zb}),ht({type:String,attribute:"camera-target",hasChanged:()=>!0})],v.prototype,"cameraTarget",void 0),$f([Xf({intrinsics:lb,observeEffects:!0,updateHandler:Gb}),ht({type:String,attribute:"field-of-view",hasChanged:()=>!0})],v.prototype,"fieldOfView",void 0),$f([Xf({intrinsics:ub,updateHandler:Hb}),ht({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],v.prototype,"minCameraOrbit",void 0),$f([Xf({intrinsics:db,updateHandler:Vb}),ht({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],v.prototype,"maxCameraOrbit",void 0),$f([Xf({intrinsics:cb,updateHandler:qb}),ht({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],v.prototype,"minFieldOfView",void 0),$f([Xf({intrinsics:lb,updateHandler:jb}),ht({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],v.prototype,"maxFieldOfView",void 0),$f([ht({type:Number,attribute:"interaction-prompt-threshold"})],v.prototype,"interactionPromptThreshold",void 0),$f([ht({type:String,attribute:"interaction-prompt"})],v.prototype,"interactionPrompt",void 0),$f([ht({type:String,attribute:"interaction-prompt-style"})],v.prototype,"interactionPromptStyle",void 0),$f([ht({type:Number,attribute:"orbit-sensitivity"})],v.prototype,"orbitSensitivity",void 0),$f([ht({type:Number,attribute:"zoom-sensitivity"})],v.prototype,"zoomSensitivity",void 0),$f([ht({type:Number,attribute:"pan-sensitivity"})],v.prototype,"panSensitivity",void 0),$f([ht({type:String,attribute:"touch-action"})],v.prototype,"touchAction",void 0),$f([ht({type:Boolean,attribute:"disable-zoom"})],v.prototype,"disableZoom",void 0),$f([ht({type:Boolean,attribute:"disable-pan"})],v.prototype,"disablePan",void 0),$f([ht({type:Boolean,attribute:"disable-tap"})],v.prototype,"disableTap",void 0),$f([ht({type:Number,attribute:"interpolation-decay"})],v.prototype,"interpolationDecay",void 0),$f([ht()],v.prototype,"a11y",void 0),v})((t=>{var e,i,n,r,s,a,o,l,c,h;class u extends t{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arUsdzMaxTextureSize="auto",this.arPlacement="floor",this.arModes="webxr scene-viewer quick-look",this.iosSrc=null,this.xrEnvironment=!1,this[e]=!1,this[i]=this.shadowRoot.querySelector(".ar-button"),this[n]=document.createElement("a"),this[r]=new Set,this[s]=rC,this[a]=!1,this[o]=t=>{t.preventDefault(),this.activateAR()},this[l]=({status:t})=>{t!==gv&&this[bE].arRenderer.presentedScene!==this[pE]||(this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}})),t===gv?this.removeAttribute("ar-tracking"):t===mv&&this.setAttribute("ar-tracking",vv))},this[c]=({status:t})=>{this.setAttribute("ar-tracking",t),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:t}}))},this[h]=t=>{"_apple_ar_quicklook_button_tapped"==t.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[hC]!==rC}connectedCallback(){super.connectedCallback(),null!=this[bE].arRenderer&&(this[bE].arRenderer.addEventListener("status",this[gC]),this.setAttribute("ar-status",gv),this[bE].arRenderer.addEventListener("tracking",this[mC])),this[dC].addEventListener("message",this[fC])}disconnectedCallback(){super.disconnectedCallback(),null!=this[bE].arRenderer&&(this[bE].arRenderer.removeEventListener("status",this[gC]),this[bE].arRenderer.removeEventListener("tracking",this[mC])),this[dC].removeEventListener("message",this[fC])}update(t){super.update(t),t.has("arScale")&&(this[pE].canScale="fixed"!==this.arScale),t.has("arPlacement")&&(this[pE].updateShadow(),this[AE]()),t.has("arModes")&&(this[uC]=ZS(this.arModes)),(t.has("ar")||t.has("arModes")||t.has("src")||t.has("iosSrc")||t.has("arUsdzMaxTextureSize"))&&this[bC]()}async activateAR(){switch(this[hC]){case eC:await this[lC]();break;case nC:await this[aC]();break;case iC:await this[oC]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(e=cC,i=sC,n=dC,r=uC,s=hC,a=pC,o=AC,l=gC,c=mC,h=fC,bC)](){var t;let e=rC;if(this.ar){if(null!=this.src)for(const i of this[uC]){if("webxr"===i&&Ld&&!JS&&await this[bE].arRenderer.supportsPresentation()){e=nC;break}if("scene-viewer"===i&&!YS&&(Qd||navigator.userAgentData&&navigator.userAgentData.getHighEntropyValues&&(null===(t=(await navigator.userAgentData.getHighEntropyValues(["formFactor"])).formFactor)||void 0===t?void 0:t.includes("XR")))){e=iC;break}if("quick-look"===i&&Gd&&!kd&&(!Od||null!=this.iosSrc)){e=eC;break}}e===rC&&null!=this.iosSrc&&Gd&&!kd&&(e=eC)}if(e!==rC)this[sC].classList.add("enabled"),this[sC].addEventListener("click",this[AC]);else if(this[sC].classList.contains("enabled")){this[sC].removeEventListener("click",this[AC]),this[sC].classList.remove("enabled");const t=bv;this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}}))}this[hC]=e}async[aC](){console.log("Attempting to present in AR with WebXR..."),await this[vC]();try{this[sC].removeEventListener("click",this[AC]);const{arRenderer:t}=this[bE];t.placeOnWall="wall"===this.arPlacement,await t.present(this[pE],this.xrEnvironment)}catch(t){console.warn("Error while trying to present in AR with WebXR"),console.error(t),await this[bE].arRenderer.stopPresenting(),JS=!0,console.warn("Falling back to next ar-mode"),await this[bC](),this.activateAR()}finally{this[bC]()}}async[vC](){this.loaded||(this[pC]=!0,this[lE](),await((t,e,i=null)=>new Promise(n=>{t.addEventListener(e,function r(s){i&&!i(s)||(n(s),t.removeEventListener(e,r))})}))(this,"load"),this[pC]=!1)}[_E](){return super[_E]()||this[pC]}async[oC](){const t=self.location.toString(),e=new URL(t),i=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),n=this.src||i[0]||null;if(!n)return void console.warn("No src or extra-model provided for Scene Viewer fallback.");let r=new URL(n,t);r.hash&&(r.hash="");const s=new URLSearchParams(r.search);if(e.hash=$S,s.set("mode","ar_preferred"),s.has("disable_occlusion")||s.set("disable_occlusion","true"),"fixed"===this.arScale&&s.set("resizable","false"),"wall"===this.arPlacement&&s.set("enable_vertical_placement","true"),s.has("sound")){const e=new URL(s.get("sound"),t);s.set("sound",e.toString())}if(s.has("link")){const e=new URL(s.get("link"),t);s.set("link",e.toString())}const a=`intent://arvr.google.com/scene-viewer/1.2?${s.toString()+"&file="+encodeURIComponent(r.toString())}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e.toString())};end;`;self.addEventListener("hashchange",()=>{self.location.hash===$S&&(YS=!0,self.history.back(),console.warn("Error while trying to present in AR with Scene Viewer"),console.warn("Falling back to next ar-mode"),this[bC]())},{once:!0}),this[dC].setAttribute("href",a),console.log("Attempting to present in AR with Scene Viewer..."),this[dC].click()}async[lC](){const t=!this.iosSrc;this[sC].classList.remove("enabled");const e=t?await this.prepareUSDZ():this.iosSrc,i=new URL(e,self.location.toString());if(t){const t=self.location.toString(),e=new URL(t),n=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),r=this.src||n[0]||null;if(r){const t=new URL(r,e);t.hash&&(i.hash=t.hash)}}"fixed"===this.arScale&&(i.hash&&(i.hash+="&"),i.hash+="allowsContentScaling=0");const n=this[dC];n.setAttribute("rel","ar");const r=document.createElement("img");n.appendChild(r),n.setAttribute("href",i.toString()),t&&n.setAttribute("download","model.usdz"),n.style.display="none",n.isConnected||this.shadowRoot.appendChild(n),console.log("Attempting to present in AR with Quick Look..."),n.click(),n.removeChild(r),t&&URL.revokeObjectURL(e),this[sC].classList.add("enabled")}async prepareUSDZ(){const t=this[vE].beginActivity("usdz-conversion");await this[vC]();const{models:e,shadow:i,target:n}=this[pE];if(0===e.length||null==e[0])return"";let r=!1;null!=i&&(r=i.visible,i.visible=!1),t(.2);const s=new DS,a=new mr;a.position.copy(n.position);for(const t of e)n.remove(t),a.add(t);a.updateWorldMatrix(!1,!0);const o=await s.parseAsync(a,{maxTextureSize:isNaN(this.arUsdzMaxTextureSize)?1/0:Math.max(parseInt(this.arUsdzMaxTextureSize),16)});for(const t of e)a.remove(t),n.add(t);const l=new Blob([o],{type:"model/vnd.usdz+zip"}),c=URL.createObjectURL(l);return t(1),null!=i&&(i.visible=r),c}}return KS([ht({type:Boolean,attribute:"ar"})],u.prototype,"ar",void 0),KS([ht({type:String,attribute:"ar-scale"})],u.prototype,"arScale",void 0),KS([ht({type:String,attribute:"ar-usdz-max-texture-size"})],u.prototype,"arUsdzMaxTextureSize",void 0),KS([ht({type:String,attribute:"ar-placement"})],u.prototype,"arPlacement",void 0),KS([ht({type:String,attribute:"ar-modes"})],u.prototype,"arModes",void 0),KS([ht({type:String,attribute:"ios-src"})],u.prototype,"iosSrc",void 0),KS([ht({type:Boolean,attribute:"xr-environment"})],u.prototype,"xrEnvironment",void 0),u})((t=>{var e,i,n,r,s,a,o,l;class c extends t{static set dracoDecoderLocation(t){Pg.setDRACODecoderLocation(t)}static get dracoDecoderLocation(){return Pg.getDRACODecoderLocation()}static set ktx2TranscoderLocation(t){Pg.setKTX2TranscoderLocation(t)}static get ktx2TranscoderLocation(){return Pg.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(t){Pg.setMeshoptDecoderLocation(t)}static get meshoptDecoderLocation(){return Pg.getMeshoptDecoderLocation()}static set lottieLoaderLocation(t){fy.singleton.textureUtils.lottieLoaderUrl=t}static get lottieLoaderLocation(){return fy.singleton.textureUtils.lottieLoaderUrl}static mapURLs(t){fy.singleton.loader[Rg].manager.setURLModifier(t)}dismissPoster(){this.loaded?this[IC]():(this[MC]=!0,this[lE]())}showPoster(){const t=this[CC];if(t.classList.contains("show"))return;t.classList.add("show"),this[uE].classList.remove("show");const e=this[wC];e.removeAttribute("tabindex"),e.removeAttribute("aria-hidden");const i=this.modelIsVisible;this[TC]=!1,this[iE](i)}getDimensions(){return this[pE].updateBoundingBoxAndShadowIfDirty(),EE(this[pE].size)}getBoundingBoxCenter(){return this[pE].updateBoundingBoxAndShadowIfDirty(),EE(this[pE].boundingBox.getCenter(new vn))}constructor(...t){super(...t),this.poster=null,this.reveal=xC,this.loading=_C,this[e]=!1,this[i]=!1,this[n]=this.shadowRoot.querySelector(".slot.poster"),this[r]=this.shadowRoot.querySelector("#default-poster"),this[s]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[a]=this[wC].getAttribute("aria-label"),this[o]=((t,e)=>{let i=null;const n=(...n)=>{null==i&&(t(...n),i=self.setTimeout(()=>i=null,e))};return n.flush=()=>{null!=i&&(self.clearTimeout(i),i=null)},n})(t=>{const e=this[SC].parentNode;requestAnimationFrame(()=>{this[SC].style.transform=`scaleX(${t})`,0===t&&(e.removeChild(this[SC]),e.appendChild(this[SC])),this[SC].classList.toggle("hide",1===t)})},100),this[l]=t=>{const e=t.detail.totalProgress,i=t.detail.reason;1===e&&(this[BC].flush(),this.loaded&&(this[MC]||this.reveal===xC)&&this[IC]()),this[BC](e),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:e,reason:i}}))};const c=self.ModelViewerElement||{},h=c.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";Pg.setDRACODecoderLocation(h);const u=c.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";Pg.setKTX2TranscoderLocation(u),c.meshoptDecoderLocation&&Pg.setMeshoptDecoderLocation(c.meshoptDecoderLocation);const d=c.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/loaders/LottieLoader.js";null!=fy.singleton.textureUtils&&(fy.singleton.textureUtils.lottieLoaderUrl=d)}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[vE].addEventListener("progress",this[DC])}disconnectedCallback(){super.disconnectedCallback(),this[vE].removeEventListener("progress",this[DC])}async updated(t){super.updated(t),t.has("poster")&&null!=this.poster&&(this[wC].style.backgroundImage=`url(${this.poster})`),t.has("alt")&&this[wC].setAttribute("aria-label",this[rE]),(t.has("reveal")||t.has("loading"))&&this[lE]()}[(e=TC,i=MC,n=CC,r=wC,s=SC,a=RC,o=BC,l=DC,_E)](){const t=Array.from(this.querySelectorAll("extra-model"));return!!(this.src||t.length>0)&&(this[MC]||this.loading===EC||this.reveal===xC&&this[eE])}[IC](){this[MC]=!1;const t=this[CC];if(!t.classList.contains("show"))return;t.classList.remove("show"),this[uE].classList.add("show");const e=this.modelIsVisible;this[TC]=!0,this[iE](e);const i=this.getRootNode();i&&i.activeElement===this&&this[uE].focus();const n=this[wC];n.setAttribute("aria-hidden","true"),n.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[xE](){return super[xE]()&&this[TC]}}return yC([ht({type:String})],c.prototype,"poster",void 0),yC([ht({type:String})],c.prototype,"reveal",void 0),yC([ht({type:String})],c.prototype,"loading",void 0),c})((t=>{var e;class i extends t{constructor(...t){super(t),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[e]=!0,this[pE].subscribeMixerEvent("loop",t=>{const e=t.action._loopCount,i=t.action._clip.name,n=t.action._clip.uuid,r=this[pE].markedAnimations.find(t=>t.name===i);if(r){this[pE].updateAnimationLoop(r.name,r.loopMode,r.repetitionCount);const t=this[pE].markedAnimations.filter(t=>t.name!==i);this[pE].markedAnimations=t}this.dispatchEvent(new CustomEvent("loop",{detail:{count:e,name:i,uuid:n}}))}),this[pE].subscribeMixerEvent("finished",t=>{if(this[pE].appendedAnimations.includes(t.action._clip.name)){const e=this[pE].appendedAnimations.filter(e=>e!==t.action._clip.name);this[pE].appendedAnimations=e}else this[BE]=!0;this.dispatchEvent(new CustomEvent("finished"))})}get availableAnimations(){return this.loaded?this[pE].animationNames:[]}get duration(){return this[pE].duration}get paused(){return this[pE].isAllAnimationsPaused()}get currentTime(){return this[pE].animationTime}get appendedAnimations(){return this[pE].appendedAnimations}set currentTime(t){this[pE].animationTime=t,this[AE]()}get timeScale(){return this[pE].animationTimeScale}set timeScale(t){this[pE].animationTimeScale=t}pause(t){var e;if(null==(null==t?void 0:t.modelIndex)&&this.paused)return;const i=null!==(e=null==t?void 0:t.modelIndex)&&void 0!==e?e:null;this[pE].pauseAnimation(i),this.dispatchEvent(new CustomEvent("pause"))}play(t){var e;if(this.availableAnimations.length>0){const i=null!==(e=null==t?void 0:t.modelIndex)&&void 0!==e?e:null;this[pE].unpauseAnimation(i),this[ME](t),this.dispatchEvent(new CustomEvent("play"))}}appendAnimation(t,e){var i;this.availableAnimations.length>0&&(this[BE]=!1,this[pE].unpauseAnimation(null!==(i=null==e?void 0:e.modelIndex)&&void 0!==i?i:null),this[IE](t,e),this.dispatchEvent(new CustomEvent("append-animation")))}detachAnimation(t,e){var i;this.availableAnimations.length>0&&(this[BE]=!1,this[pE].unpauseAnimation(null!==(i=null==e?void 0:e.modelIndex)&&void 0!==i?i:null),this[TE](t,e),this.dispatchEvent(new CustomEvent("detach-animation")))}[(e=BE,mE)](){super[mE](),this[pE].pauseAnimation(),null!=this.animationName&&this[ME](),this.autoplay&&this.play()}[gE](t,e){super[gE](t,e),this.paused||!this[xE]()&&!this[bE].isPresenting||(this[pE].updateAnimation(e/1e3),this[AE]())}updated(t){super.updated(t),t.has("autoplay")&&this.autoplay&&this.play(),t.has("animationName")&&this[ME]()}[ME](t=RE){var e;const i=null!==(e=t.repetitions)&&void 0!==e?e:1/0,n=t.pingpong?Ei:1===i?xi:_i;this[pE].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,n,i,t.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}[IE](t="",e={}){var i;const n=Object.assign(Object.assign({},DE),e),r=null!==(i=n.repetitions)&&void 0!==i?i:1/0,s=n.pingpong?Ei:1===r?xi:_i,a=!!e.repetitions||"pingpong"in e;this[pE].appendAnimation(t||this.animationName,s,r,n.weight,n.timeScale,n.fade,n.warp,n.relativeWarp,n.time,a,n.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}[TE](t="",e={}){const i=Object.assign(Object.assign({},LE),e);this[pE].detachAnimation(t||this.animationName,i.fade,i.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}}return wE([ht({type:Boolean})],i.prototype,"autoplay",void 0),wE([ht({type:String,attribute:"animation-name"})],i.prototype,"animationName",void 0),wE([ht({type:Number,attribute:"animation-crossfade-duration"})],i.prototype,"animationCrossfadeDuration",void 0),i})(CE))))))));customElements.define("model-viewer",QC);export{eo as CanvasTexture,Ql as FileLoader,Nl as Loader,QC as ModelViewerElement,ue as NearestFilter};+var PC=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const FC=Math.PI/32,UC={basis:[lf(Ym(FC,"rad"))],keywords:{auto:[null]}},NC=Symbol("autoRotateStartTime"),OC=Symbol("radiansPerSecond"),kC=Symbol("syncRotationRate"),QC=Symbol("onCameraChange"),GC=(t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this[e]=new Map,this[i]=t=>{t.forEach(t=>{t instanceof MutationRecord&&"childList"!==t.type||(t.addedNodes.forEach(t=>{this[OE](t)}),t.removedNodes.forEach(t=>{this[kE](t)}),this[AE]())})},this[n]=new MutationObserver(this[UE])}connectedCallback(){super.connectedCallback();for(let t=0;t<this.children.length;++t)this[OE](this.children[t]);const{ShadyDOM:t}=self;null==t?this[NE].observe(this,{childList:!0}):this[NE]=t.observeChildren(this,this[UE])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:t}=self;null==t?this[NE].disconnect():t.unobserveChildren(this[NE])}[(e=FE,i=UE,n=NE,mE)](){super[mE]();const t=this[pE];t.forHotspots(e=>{t.updateHotspotAttachment(e),t.updateSurfaceHotspot(e)})}[gE](t,e){super[gE](t,e);const i=this[pE],{annotationRenderer:n}=i,r=i.getCamera();i.shouldRender()&&(i.animateSurfaceHotspots(),i.updateHotspotsVisibility(r.position),n.domElement.style.display="",n.render(i,r))}updateHotspot(t){const e=this[FE].get(t.name);null!=e&&(e.updatePosition(t.position),e.updateNormal(t.normal),e.surface=t.surface,void 0!==t.modelIndex&&null!==t.modelIndex&&(e.modelIndex=t.modelIndex),this[pE].updateSurfaceHotspot(e),this[AE]())}queryHotspot(t){const e=this[FE].get(t);if(null==e)return null;const i=EE(e.position),n=EE(e.normal),r=e.facingCamera,s=this[pE],a=s.getCamera(),o=new vn;o.setFromMatrixPosition(e.matrixWorld),o.project(a);const l=s.width/2,c=s.height/2;o.x=o.x*l+l,o.y=-o.y*c+c;const h=EE(new vn(o.x,o.y,o.z));return Number.isFinite(h.x)&&Number.isFinite(h.y)?{position:i,normal:n,canvasPosition:h,facingCamera:r}:null}positionAndNormalFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e),r=i.positionAndNormalFromPoint(n);if(null==r)return null;const s=r.worldToModel,a=EE(r.position.applyMatrix4(s)),o=EE(r.normal.transformDirection(s));let l=null;return null!=r.uv&&(l=SE(r.uv)),{position:a,normal:o,uv:l,modelIndex:r.modelIndex}}surfaceFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e);return i.surfaceFromPoint(n)}[OE](t){if(!(t instanceof HTMLElement&&0===t.slot.indexOf("hotspot")))return;let e=this[FE].get(t.slot);if(null!=e){e.increment();const i=t.dataset.visibilityAttribute;if(null!=i){const n=`data-${i}`;t.toggleAttribute(n,e.facingCamera)}t.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e.facingCamera}}))}else e=new d_({name:t.slot,position:t.dataset.position,normal:t.dataset.normal,surface:t.dataset.surface,modelIndex:null!=t.dataset.modelIndex?parseInt(t.dataset.modelIndex):null}),this[FE].set(t.slot,e),this[pE].addHotspot(e);this[pE].queueRender()}[kE](t){if(!(t instanceof HTMLElement))return;const e=this[FE].get(t.slot);e&&(e.decrement()&&(this[pE].removeHotspot(e),this[FE].delete(t.slot)),this[pE].queueRender())}}return r})((t=>{var e,i,n,r;class s extends t{constructor(){super(...arguments),this[e]=void 0,this[i]=[],this[n]=null,this[r]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[e_]}get extraModels(){return this[i_]}get availableVariants(){return this.model?this.model[Wx]():[]}get originalGltfJson(){return this[t_]}[(e=e_,i=i_,n=Zx,r=t_,n_)](){return()=>{this[AE]()}}[r_](t){return t.colorSpace=Di,t.wrapS=le,t.wrapT=le,new qy(this[n_](),t)}async createTexture(t,e="image/png"){const{textureUtils:i}=this[bE],n=await i.loadImage(t,this.withCredentials,e),r="image/ktx2"===e?"image/png":e;return n.userData.mimeType=r,this[r_](n)}async createLottieTexture(t,e=1){const{textureUtils:i}=this[bE],n=await i.loadLottie(t,e,this.withCredentials);return this[r_](n)}createVideoTexture(t){const e=document.createElement("video");e.crossOrigin=this.withCredentials?"use-credentials":"anonymous",e.src=t,e.muted=!0,e.playsInline=!0,e.loop=!0,e.play();const i=new Ja(e);return this[r_](i)}createCanvasTexture(){const t=document.createElement("canvas"),e=new eo(t);return this[r_](e)}async updated(t){if(super.updated(t),t.has("variantName")){const t=this[vE].beginActivity("variant-update");t(.1);const e=this[e_],{variantName:i}=this;null!=e&&(await e[zx](i),this[AE](),this.dispatchEvent(new CustomEvent("variant-applied"))),t(1)}if(t.has("orientation")||t.has("scale")){if(!this.loaded)return;const t=this[pE];t.applyTransform(),t.updateBoundingBox(),t.updateShadow(),this[bE].arRenderer.onUpdateScene(),this[AE]()}}[mE](){super[mE]();const{currentGLTFs:t}=this[pE],e=t.length>0?t[0]:null;if(null!=e){const{correlatedSceneGraph:t}=e;null!=t&&e!==this[Zx]&&(this[e_]=new Yx(t,this[n_]()),this[t_]=JSON.parse(JSON.stringify(t.gltf))),"variants"in e.userData&&this.requestUpdate("variantName")}this[i_]=[];const i=Array.from(this.querySelectorAll("extra-model"));for(let e=1;e<t.length;e++){const n=t[e];if(null!=n&&null!=n.correlatedSceneGraph){const t=new Yx(n.correlatedSceneGraph,this[n_]());this[i_].push(t),i[e-1]&&(i[e-1].model=t)}}this[Zx]=e}async exportScene(t){const e=this[pE];return new Promise(async(i,n)=>{const r={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(r,t),r.animations=e.animations,r.truncateDrawRange=!0;const s=e.shadow;let a=!1;null!=s&&(a=s.visible,s.visible=!1),await this[e_][Gx]();const o=(new Vg).register(t=>new Hm(t));let l;if(o.setTextureUtils({decompress:(t,e)=>function(t,e=1/0,i=null){Om||(Om=new el(2,2,1,1)),km||(km=new ll({uniforms:{blitTexture:new Bc(t)},vertexShader:"\n\t\t\tvarying vec2 vUv;\n\t\t\tvoid main(){\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = vec4(position.xy * 1.0,0.,.999999);\n\t\t\t}",fragmentShader:"\n\t\t\tuniform sampler2D blitTexture; \n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main(){ \n\t\t\t\tgl_FragColor = vec4(vUv.xy, 0, 1);\n\t\t\t\t\n\t\t\t\t#ifdef IS_SRGB\n\t\t\t\tgl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );\n\t\t\t\t#else\n\t\t\t\tgl_FragColor = texture2D( blitTexture, vUv);\n\t\t\t\t#endif\n\t\t\t}"})),km.uniforms.blitTexture.value=t,km.defines.IS_SRGB=t.colorSpace==Di,km.needsUpdate=!0,Qm||(Qm=new Ks(Om,km),Qm.frustumCulled=!1);const n=new nc,r=new wr;r.add(Qm),null===i&&(i=Nm=new Id({antialias:!1}));const s=Math.min(t.image.width,e),a=Math.min(t.image.height,e);i.setSize(s,a),i.clear(),i.render(r,n);const o=document.createElement("canvas"),l=o.getContext("2d");o.width=s,o.height=a,l.drawImage(i.domElement,0,0,s,a);const c=new eo(o);return c.minFilter=t.minFilter,c.magFilter=t.magFilter,c.wrapS=t.wrapS,c.wrapT=t.wrapT,c.colorSpace=t.colorSpace,c.name=t.name,Nm&&(Nm.forceContextLoss(),Nm.dispose(),Nm=null),c}(t,null!=e?e:1/0,void 0)}),e.models.length>1){l=new mr;for(const t of e.models)l.add(t)}else l=e.models[0];o.parse(l,t=>{if(e.models.length>1)for(const t of e.models)e.target.add(t);else e.target.add(e.models[0]);return i(new Blob([r.binary?t:JSON.stringify(t)],{type:r.binary?"application/octet-stream":"application/json"}))},()=>n("glTF export failed"),r),null!=s&&(s.visible=a)})}materialFromPoint(t,e){const i=this[pE],n=i.getNDC(t,e),r=i.hitFromPoint(n);if(null==r||null==r.face)return null;const s=this[e_];if(null!=s){const t=s[Hx](r);if(null!=t)return t}for(const t of this[i_]){const e=t[Hx](r);if(null!=e)return e}return null}}return $x([ht({type:String,attribute:"variant-name"})],s.prototype,"variantName",void 0),$x([ht({type:String,attribute:"orientation"})],s.prototype,"orientation",void 0),$x([ht({type:String,attribute:"scale"})],s.prototype,"scale",void 0),s})((t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[e]=performance.now(),this[i]=0,this[n]=t=>{this.autoRotate&&"user-interaction"===t.detail.source&&(this[NC]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[QC]),this[NC]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[QC]),this[NC]=performance.now()}updated(t){super.updated(t),t.has("autoRotate")&&(this[NC]=performance.now())}[(e=NC,i=OC,kC)](t){this[OC]=t[0]}[gE](t,e){if(super[gE](t,e),!this.autoRotate||!this[xE]()||this[bE].isPresenting)return;const i=Math.min(e,t-this[NC]-this.autoRotateDelay);i>0&&(this[pE].yaw=this.turntableRotation+this[OC]*i*.001)}get turntableRotation(){return this[pE].yaw}resetTurntableRotation(t=0){this[pE].yaw=t}}return n=QC,PC([ht({type:Boolean,attribute:"auto-rotate"})],r.prototype,"autoRotate",void 0),PC([ht({type:Number,attribute:"auto-rotate-delay"})],r.prototype,"autoRotateDelay",void 0),PC([Xf({intrinsics:UC,updateHandler:kC}),ht({type:String,attribute:"rotation-per-second"})],r.prototype,"rotationPerSecond",void 0),r})((t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this.toneMapping="auto",this.skyboxHeight="0",this[e]=null,this[i]=null,this[n]=null}updated(t){var e;if(super.updated(t),t.has("shadowIntensity")&&(this[pE].setShadowIntensity(.5*this.shadowIntensity),this[AE]()),t.has("shadowSoftness")&&(this[pE].setShadowSoftness(this.shadowSoftness),this[AE]()),t.has("exposure")&&(this[pE].exposure=this.exposure,this[AE]()),t.has("toneMapping")){const t=new Map([["aces",4],["agx",6],["reinhard",2],["cineon",3],["linear",1],["none",0]]);this[pE].toneMapping=null!==(e=t.get(this.toneMapping))&&void 0!==e?e:7,this[AE]()}(t.has("environmentImage")||t.has("skyboxImage"))&&this[_E]()&&this[Yd](),t.has("skyboxHeight")&&(this[pE].setGroundedSkybox(),this[AE]())}hasBakedShadow(){return this[pE].bakedShadows.size>0}async[(e=Kd,i=Jd,n=$d,Yd)](){const{skyboxImage:t,environmentImage:e}=this;null!=this[$d]&&(this[$d](),this[$d]=null);const{textureUtils:i}=this[bE];if(null==i)return;const n=this[vE].beginActivity("environment-update");try{const{environmentMap:r,skybox:s}=await i.generateEnvironmentMapAndSkybox(zd(t),e,t=>n(jd(t,0,1)),this.withCredentials);this[Kd]!==r&&(this[Kd]=r,this.dispatchEvent(new CustomEvent("environment-change"))),this[Jd]=null!=s?s.name===r.name?r:s:null,this[pE].setEnvironmentAndSkybox(this[Kd],this[Jd])}catch(t){if(t instanceof Error)throw this[pE].setEnvironmentAndSkybox(null,null),t}finally{n(1)}}}return Xd([ht({type:String,attribute:"environment-image"})],r.prototype,"environmentImage",void 0),Xd([ht({type:String,attribute:"skybox-image"})],r.prototype,"skyboxImage",void 0),Xd([ht({type:Number,attribute:"shadow-intensity"})],r.prototype,"shadowIntensity",void 0),Xd([ht({type:Number,attribute:"shadow-softness"})],r.prototype,"shadowSoftness",void 0),Xd([ht({type:Number})],r.prototype,"exposure",void 0),Xd([ht({type:String,attribute:"tone-mapping"})],r.prototype,"toneMapping",void 0),Xd([ht({type:String,attribute:"skybox-height"})],r.prototype,"skyboxHeight",void 0),r})((t=>{var e,i,n,r,s,a,o,l,c,h,u,d,p,A,g,m,f,b;class v extends t{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=eb,this.cameraTarget="auto auto auto",this.fieldOfView="auto",this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=3e3,this.interactionPrompt=rb,this.interactionPromptStyle=ab,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=ob,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this.a11y=null,this[e]=this.shadowRoot.querySelector(".interaction-prompt"),this[i]=this.shadowRoot.querySelector("#prompt"),this[n]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[r]=this.shadowRoot.querySelector(".pan-target"),this[s]=0,this[a]=1/0,this[o]=!1,this[l]=!1,this[c]=$b.AUTOMATIC,this[h]=new Zb(this[pE].camera,this[uE],this[pE]),this[u]=new Pc,this[d]=!1,this[p]=!1,this[A]=!1,this[g]={},this[m]=()=>{const t=this[bb].changeSource;this[Fb]=t,t===$b.USER_INTERACTION&&(this[Db]=!0,this[Eb]())},this[f]=()=>{this[Sb](),this[AE]();const t=this[bb].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:t}}))},this[b]=t=>{this[hE].classList.toggle("pointer-tumbling","pointer-change-start"===t.type)}}get inputSensitivity(){return this[bb].inputSensitivity}set inputSensitivity(t){this[bb].inputSensitivity=t}getCameraOrbit(){const{theta:t,phi:e,radius:i}=this[Ub];return{theta:t,phi:e,radius:i,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return EE(this[bE].isPresenting?this[bE].arRenderer.target:this[pE].getDynamicTarget())}getFieldOfView(){return this[bb].getFieldOfView()}getMinimumFieldOfView(){return this[bb].options.minimumFieldOfView}getMaximumFieldOfView(){return this[bb].options.maximumFieldOfView}getIdealAspect(){return this[pE].idealAspect}jumpCameraToGoal(){this[Nb]=!0,this.requestUpdate(Nb,!1)}resetInteractionPrompt(){this[Pb]=0,this[Lb]=1/0,this[Db]=!1,this[Rb]=this.interactionPrompt===rb&&this.cameraControls}zoom(t){const e=new WheelEvent("wheel",{deltaY:-30*t});this[uE].dispatchEvent(e)}connectedCallback(){super.connectedCallback(),this[bb].addEventListener("user-interaction",this[Ib]),this[bb].addEventListener("pointer-change-start",this[Bb]),this[bb].addEventListener("pointer-change-end",this[Bb])}disconnectedCallback(){super.disconnectedCallback(),this[bb].removeEventListener("user-interaction",this[Ib]),this[bb].removeEventListener("pointer-change-start",this[Bb]),this[bb].removeEventListener("pointer-change-end",this[Bb])}updated(t){super.updated(t);const e=this[bb],i=this[pE];if(t.has("cameraControls")&&(this.cameraControls?(e.enableInteraction(),this.interactionPrompt===rb&&(this[Rb]=!0)):(e.disableInteraction(),this[Eb]()),this[uE].setAttribute("aria-label",this[nE])),t.has("disableZoom")&&(e.disableZoom=this.disableZoom),t.has("disablePan")&&(e.enablePan=!this.disablePan),t.has("disableTap")&&(e.enableTap=!this.disableTap),(t.has("interactionPrompt")||t.has("cameraControls")||t.has("src"))&&(this.interactionPrompt===rb&&this.cameraControls&&!this[Db]?this[Rb]=!0:this[Eb]()),t.has("interactionPromptStyle")&&(this[xb].style.opacity=this.interactionPromptStyle==sb?"1":"0"),t.has("touchAction")){const t=this.touchAction;e.applyOptions({touchAction:t}),e.updateTouchActionStyle()}t.has("orbitSensitivity")&&(e.orbitSensitivity=this.orbitSensitivity),t.has("zoomSensitivity")&&(e.zoomSensitivity=this.zoomSensitivity),t.has("panSensitivity")&&(e.panSensitivity=this.panSensitivity),t.has("interpolationDecay")&&(e.setDamperDecayTime(this.interpolationDecay),i.setTargetDamperDecayTime(this.interpolationDecay)),t.has("a11y")&&this[wb](),!0===this[Nb]&&Promise.resolve().then(()=>{e.jumpToGoal(),i.jumpToGoal(),this[Tb](),this[Nb]=!1})}async updateFraming(){const t=this[pE],e=t.adjustedFoV(t.framedFoVDeg);await t.updateFraming();const i=t.adjustedFoV(t.framedFoVDeg),n=this[bb].getFieldOfView()/e;this[bb].setFieldOfView(i*n),this[kb]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(t,e,i){const n=this[uE],r=this[_b];if("1"===r[0].style.opacity)return void console.warn("interact() failed because an existing interaction is running.");const s=new Array;s.push({x:Yf(e.x),y:Yf(e.y)});const a=[{x:s[0].x(0),y:s[0].y(0)}];null!=i&&(s.push({x:Yf(i.x),y:Yf(i.y)}),a.push({x:s[1].x(0),y:s[1].y(0)}));let o=performance.now();const{width:l,height:c}=this[pE],h=this.getBoundingClientRect(),u=t=>{for(const[e,i]of a.entries()){const{style:s}=r[e];s.transform=`translateX(${l*i.x}px) translateY(${c*i.y}px)`,"pointerdown"===t?s.opacity="1":"pointerup"===t&&(s.opacity="0");const a={pointerId:e-5678,pointerType:"touch",target:n,clientX:l*i.x+h.x,clientY:c*i.y+h.y,altKey:!0};n.dispatchEvent(new PointerEvent(t,a))}},d=()=>{const e=this[Fb];if(e!==$b.AUTOMATIC||!n.isConnected){for(const t of this[_b])t.style.opacity="0";return u("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:e}})),void document.removeEventListener("visibilitychange",p)}const i=Math.min(1,(performance.now()-o)/t);for(const[t,e]of a.entries())e.x=s[t].x(i),e.y=s[t].y(i);u("pointermove"),i<1?requestAnimationFrame(d):(u("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:$b.AUTOMATIC}})),document.removeEventListener("visibilitychange",p))},p=()=>{let t=0;"hidden"===document.visibilityState?t=performance.now()-o:o=performance.now()-t};document.addEventListener("visibilitychange",p),u("pointerdown"),this[Fb]=$b.AUTOMATIC,requestAnimationFrame(d)}[(e=yb,i=xb,n=_b,r=vb,s=Pb,a=Lb,o=Db,l=Rb,c=Fb,h=bb,u=Ub,d=Nb,p=Ob,A=kb,g=Cb,Gb)](t){const e=this[bb],i=this[pE];i.framedFoVDeg=180*t[0]/Math.PI,e.changeSource=$b.NONE,e.setFieldOfView(i.adjustedFoV(i.framedFoVDeg)),this[Ib]()}[Qb](t){const e=this[bb];if(this[kb]){const{theta:e,phi:i}=this.getCameraOrbit();t[0]=e,t[1]=i,this[kb]=!1}e.changeSource=$b.NONE,e.setOrbit(t[0],t[1],t[2]),this[Ib]()}[Hb](t){this[bb].applyOptions({minimumAzimuthalAngle:t[0],minimumPolarAngle:t[1],minimumRadius:t[2]}),this.jumpCameraToGoal()}[Vb](t){this[bb].applyOptions({maximumAzimuthalAngle:t[0],maximumPolarAngle:t[1],maximumRadius:t[2]}),this[Mb](t[2]),this.jumpCameraToGoal()}[qb](t){this[bb].applyOptions({minimumFieldOfView:180*t[0]/Math.PI}),this.jumpCameraToGoal()}[jb](t){const e=this[pE].adjustedFoV(180*t[0]/Math.PI);this[bb].applyOptions({maximumFieldOfView:e}),this.jumpCameraToGoal()}[zb](t){var e;const[i,n,r]=t;this[bE].isPresenting||this[pE].setTarget(i,n,r),this[bb].changeSource=$b.NONE,null===(e=this[bE].arRenderer)||void 0===e||e.updateTarget(),this[Ib]()}[gE](t,e){if(super[gE](t,e),this[bE].isPresenting||!this[xE]())return;const i=this[bb],n=this[pE],r=performance.now();if(this[Rb]&&this.loaded&&r>this[oE]+this.interactionPromptThreshold&&(this[Rb]=!1,this[Lb]=r,this[yb].classList.add("visible")),isFinite(this[Lb])&&this.interactionPromptStyle===ab){const t=(r-this[Lb])/5e3%1,e=Zf(t),s=tb(t);if(this[xb].style.opacity=`${s}`,e!==this[Pb]){const t=e*n.width*.05,r=(e-this[Pb])*Math.PI/16;this[xb].style.transform=`translateX(${t}px)`,i.changeSource=$b.AUTOMATIC,i.adjustOrbit(r,0,0),this[Pb]=e}}const s=i.update(t,e),a=n.updateTarget(e);(s||a)&&this[Tb]()}[Eb](){this[Rb]=!1,this[yb].classList.remove("visible"),this[Lb]=1/0}[Mb](t){const e=Math.max(this[pE].farRadius(),t),i=Math.abs(2*e);this[bb].updateNearFar(0,i)}[Sb](){const{theta:t,phi:e}=this[bb].getCameraSpherical(this[Ub]),i=(4+Math.floor((t%fb+mb)/Ab))%4,n=Math.floor(e/gb),r=`${nb[n]}${ib[i]}`,s=r;s in this[Cb]?this[aE](this[Cb][s]):this[aE](`View from stage ${r}`)}get[nE](){let t=". Use mouse, touch or arrow keys to move.";return"interaction-prompt"in this[Cb]&&(t=`. ${this[Cb]["interaction-prompt"]}`),super[nE].replace(/\.$/,"")+(this.cameraControls?t:"")}async[fE](t){const e=this[bb],i=this[pE],n=i.adjustedFoV(i.framedFoVDeg);super[fE](t);const r=i.adjustedFoV(i.framedFoVDeg)/n,s=e.getFieldOfView()*(isFinite(r)?r:1);e.updateAspect(this[pE].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[bb].setFieldOfView(s),this.jumpCameraToGoal()}[mE](){super[mE](),this[Ob]?this[kb]=!0:this[Ob]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}[(m=Ib,f=Tb,b=Bb,wb)](){if("string"==typeof this.a11y)if(this.a11y.startsWith("{"))try{this[Cb]=JSON.parse(this.a11y)}catch(t){console.warn("Error parsing a11y JSON:",t)}else this.a11y.length>0?console.warn("Error not supported format, should be a JSON string:",this.a11y):this[Cb]={};else"object"==typeof this.a11y&&null!=this.a11y?this[Cb]=Object.assign({},this.a11y):this[Cb]={};this[uE].setAttribute("aria-label",this[nE])}}return $f([ht({type:Boolean,attribute:"camera-controls"})],v.prototype,"cameraControls",void 0),$f([Xf({intrinsics:hb,observeEffects:!0,updateHandler:Qb}),ht({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],v.prototype,"cameraOrbit",void 0),$f([Xf({intrinsics:pb,observeEffects:!0,updateHandler:zb}),ht({type:String,attribute:"camera-target",hasChanged:()=>!0})],v.prototype,"cameraTarget",void 0),$f([Xf({intrinsics:lb,observeEffects:!0,updateHandler:Gb}),ht({type:String,attribute:"field-of-view",hasChanged:()=>!0})],v.prototype,"fieldOfView",void 0),$f([Xf({intrinsics:ub,updateHandler:Hb}),ht({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],v.prototype,"minCameraOrbit",void 0),$f([Xf({intrinsics:db,updateHandler:Vb}),ht({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],v.prototype,"maxCameraOrbit",void 0),$f([Xf({intrinsics:cb,updateHandler:qb}),ht({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],v.prototype,"minFieldOfView",void 0),$f([Xf({intrinsics:lb,updateHandler:jb}),ht({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],v.prototype,"maxFieldOfView",void 0),$f([ht({type:Number,attribute:"interaction-prompt-threshold"})],v.prototype,"interactionPromptThreshold",void 0),$f([ht({type:String,attribute:"interaction-prompt"})],v.prototype,"interactionPrompt",void 0),$f([ht({type:String,attribute:"interaction-prompt-style"})],v.prototype,"interactionPromptStyle",void 0),$f([ht({type:Number,attribute:"orbit-sensitivity"})],v.prototype,"orbitSensitivity",void 0),$f([ht({type:Number,attribute:"zoom-sensitivity"})],v.prototype,"zoomSensitivity",void 0),$f([ht({type:Number,attribute:"pan-sensitivity"})],v.prototype,"panSensitivity",void 0),$f([ht({type:String,attribute:"touch-action"})],v.prototype,"touchAction",void 0),$f([ht({type:Boolean,attribute:"disable-zoom"})],v.prototype,"disableZoom",void 0),$f([ht({type:Boolean,attribute:"disable-pan"})],v.prototype,"disablePan",void 0),$f([ht({type:Boolean,attribute:"disable-tap"})],v.prototype,"disableTap",void 0),$f([ht({type:Number,attribute:"interpolation-decay"})],v.prototype,"interpolationDecay",void 0),$f([ht()],v.prototype,"a11y",void 0),v})((t=>{var e,i,n,r,s,a,o,l,c,h;class u extends t{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arUsdzMaxTextureSize="auto",this.arPlacement="floor",this.arModes="webxr scene-viewer quick-look",this.iosSrc=null,this.xrEnvironment=!1,this[e]=!1,this[i]=this.shadowRoot.querySelector(".ar-button"),this[n]=document.createElement("a"),this[r]=new Set,this[s]=sC,this[a]=!1,this[o]=t=>{t.preventDefault(),this.activateAR()},this[l]=({status:t})=>{t!==gv&&this[bE].arRenderer.presentedScene!==this[pE]||(this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}})),t===gv?this.removeAttribute("ar-tracking"):t===mv&&this.setAttribute("ar-tracking",vv))},this[c]=({status:t})=>{this.setAttribute("ar-tracking",t),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:t}}))},this[h]=t=>{"_apple_ar_quicklook_button_tapped"==t.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[uC]!==sC}connectedCallback(){super.connectedCallback(),null!=this[bE].arRenderer&&(this[bE].arRenderer.addEventListener("status",this[mC]),this.setAttribute("ar-status",gv),this[bE].arRenderer.addEventListener("tracking",this[fC])),this[pC].addEventListener("message",this[bC])}disconnectedCallback(){super.disconnectedCallback(),null!=this[bE].arRenderer&&(this[bE].arRenderer.removeEventListener("status",this[mC]),this[bE].arRenderer.removeEventListener("tracking",this[fC])),this[pC].removeEventListener("message",this[bC])}update(t){super.update(t),t.has("arScale")&&(this[pE].canScale="fixed"!==this.arScale),t.has("arPlacement")&&(this[pE].updateShadow(),this[AE]()),t.has("arModes")&&(this[dC]=tC(this.arModes)),(t.has("ar")||t.has("arModes")||t.has("src")||t.has("iosSrc")||t.has("arUsdzMaxTextureSize"))&&this[vC]()}async activateAR(){switch(this[uC]){case iC:await this[cC]();break;case rC:await this[oC]();break;case nC:await this[lC]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(e=hC,i=aC,n=pC,r=dC,s=uC,a=AC,o=gC,l=mC,c=fC,h=bC,vC)](){var t;let e=sC;if(this.ar){if(null!=this.src)for(const i of this[dC]){if("webxr"===i&&Ld&&!YS&&await this[bE].arRenderer.supportsPresentation()){e=rC;break}if("scene-viewer"===i&&!$S&&(Qd||navigator.userAgentData&&navigator.userAgentData.getHighEntropyValues&&(null===(t=(await navigator.userAgentData.getHighEntropyValues(["formFactor"])).formFactor)||void 0===t?void 0:t.includes("XR")))){e=nC;break}if("quick-look"===i&&Gd&&!kd){e=iC;break}}e===sC&&null!=this.iosSrc&&Gd&&!kd&&(e=iC)}if(e!==sC)this[aC].classList.add("enabled"),this[aC].addEventListener("click",this[gC]);else if(this[aC].classList.contains("enabled")){this[aC].removeEventListener("click",this[gC]),this[aC].classList.remove("enabled");const t=bv;this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}}))}this[uC]=e}async[oC](){await this[yC]();try{this[aC].removeEventListener("click",this[gC]);const{arRenderer:t}=this[bE];t.placeOnWall="wall"===this.arPlacement,await t.present(this[pE],this.xrEnvironment)}catch(t){console.warn("Error while trying to present in AR with WebXR"),console.error(t),await this[bE].arRenderer.stopPresenting(),YS=!0,console.warn("Falling back to next ar-mode"),await this[vC](),this.activateAR()}finally{this[vC]()}}async[yC](){this.loaded||(this[AC]=!0,this[lE](),await((t,e,i=null)=>new Promise(n=>{t.addEventListener(e,function r(s){i&&!i(s)||(n(s),t.removeEventListener(e,r))})}))(this,"load"),this[AC]=!1)}[_E](){return super[_E]()||this[AC]}async[lC](){const t=self.location.toString(),e=new URL(t),i=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),n=this.src||i[0]||null;if(!n)return void console.warn("No src or extra-model provided for Scene Viewer fallback.");let r=new URL(n,t);r.hash&&(r.hash="");const s=new URLSearchParams(r.search);if(e.hash=ZS,s.set("mode","ar_preferred"),s.has("disable_occlusion")||s.set("disable_occlusion","true"),"fixed"===this.arScale&&s.set("resizable","false"),"wall"===this.arPlacement&&s.set("enable_vertical_placement","true"),s.has("sound")){const e=new URL(s.get("sound"),t);s.set("sound",e.toString())}if(s.has("link")){const e=new URL(s.get("link"),t);s.set("link",e.toString())}const a=`intent://arvr.google.com/scene-viewer/1.2?${s.toString()+"&file="+encodeURIComponent(r.toString())}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e.toString())};end;`;self.addEventListener("hashchange",()=>{self.location.hash===ZS&&($S=!0,self.history.back(),console.warn("Error while trying to present in AR with Scene Viewer"),console.warn("Falling back to next ar-mode"),this[vC]())},{once:!0}),this[pC].setAttribute("href",a),this[pC].click()}async[cC](){const t=!this.iosSrc;let e;this[aC].classList.remove("enabled");try{e=t?await this.prepareUSDZ():this.iosSrc}catch(t){throw this[aC].classList.add("enabled"),t}const i=new URL(e,self.location.toString());if(t){const t=self.location.toString(),e=new URL(t),n=Array.from(this.querySelectorAll("extra-model")).map(t=>t.src).filter(t=>null!=t),r=this.src||n[0]||null;if(r){const t=new URL(r,e);t.hash&&(i.hash=t.hash)}}"fixed"===this.arScale&&(i.hash&&(i.hash+="&"),i.hash+="allowsContentScaling=0");const n=this[pC];n.setAttribute("rel","ar");const r=document.createElement("img");n.appendChild(r),n.setAttribute("href",i.toString()),t&&n.setAttribute("download","model.usdz"),n.style.display="none",n.isConnected||this.shadowRoot.appendChild(n),n.click(),n.removeChild(r),t&&URL.revokeObjectURL(e),this[aC].classList.add("enabled")}async prepareUSDZ(){const t=this[vE].beginActivity("usdz-conversion");await this[yC]();const{models:e,shadow:i,target:n}=this[pE];if(0===e.length||null==e[0])return"";let r=!1;null!=i&&(r=i.visible,i.visible=!1),t(.2);const s="wall"===this.arPlacement?{includeAnchoringProperties:!1}:{},a=new LS,o=new mr;o.position.copy(n.position);for(const t of e)n.remove(t),o.add(t);let l;o.updateWorldMatrix(!1,!0);try{l=await a.parseAsync(o,Object.assign(Object.assign({},s),{maxTextureSize:isNaN(this.arUsdzMaxTextureSize)?1/0:Math.max(parseInt(this.arUsdzMaxTextureSize),16)}))}finally{for(const t of e)o.remove(t),n.add(t);null!=i&&(i.visible=r),t(1)}const c=new Blob([l],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(c)}}return JS([ht({type:Boolean,attribute:"ar"})],u.prototype,"ar",void 0),JS([ht({type:String,attribute:"ar-scale"})],u.prototype,"arScale",void 0),JS([ht({type:String,attribute:"ar-usdz-max-texture-size"})],u.prototype,"arUsdzMaxTextureSize",void 0),JS([ht({type:String,attribute:"ar-placement"})],u.prototype,"arPlacement",void 0),JS([ht({type:String,attribute:"ar-modes"})],u.prototype,"arModes",void 0),JS([ht({type:String,attribute:"ios-src"})],u.prototype,"iosSrc",void 0),JS([ht({type:Boolean,attribute:"xr-environment"})],u.prototype,"xrEnvironment",void 0),u})((t=>{var e,i,n,r,s,a,o,l;class c extends t{static set dracoDecoderLocation(t){Pg.setDRACODecoderLocation(t)}static get dracoDecoderLocation(){return Pg.getDRACODecoderLocation()}static set ktx2TranscoderLocation(t){Pg.setKTX2TranscoderLocation(t)}static get ktx2TranscoderLocation(){return Pg.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(t){Pg.setMeshoptDecoderLocation(t)}static get meshoptDecoderLocation(){return Pg.getMeshoptDecoderLocation()}static set lottieLoaderLocation(t){fy.singleton.textureUtils.lottieLoaderUrl=t}static get lottieLoaderLocation(){return fy.singleton.textureUtils.lottieLoaderUrl}static mapURLs(t){fy.singleton.loader[Rg].manager.setURLModifier(t)}dismissPoster(){this.loaded?this[TC]():(this[IC]=!0,this[lE]())}showPoster(){const t=this[wC];if(t.classList.contains("show"))return;t.classList.add("show"),this[uE].classList.remove("show");const e=this[MC];e.removeAttribute("tabindex"),e.removeAttribute("aria-hidden");const i=this.modelIsVisible;this[BC]=!1,this[iE](i)}getDimensions(){return this[pE].updateBoundingBoxAndShadowIfDirty(),EE(this[pE].size)}getBoundingBoxCenter(){return this[pE].updateBoundingBoxAndShadowIfDirty(),EE(this[pE].boundingBox.getCenter(new vn))}constructor(...t){super(...t),this.poster=null,this.reveal=_C,this.loading=EC,this[e]=!1,this[i]=!1,this[n]=this.shadowRoot.querySelector(".slot.poster"),this[r]=this.shadowRoot.querySelector("#default-poster"),this[s]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[a]=this[MC].getAttribute("aria-label"),this[o]=((t,e)=>{let i=null;const n=(...n)=>{null==i&&(t(...n),i=self.setTimeout(()=>i=null,e))};return n.flush=()=>{null!=i&&(self.clearTimeout(i),i=null)},n})(t=>{const e=this[CC].parentNode;requestAnimationFrame(()=>{this[CC].style.transform=`scaleX(${t})`,0===t&&(e.removeChild(this[CC]),e.appendChild(this[CC])),this[CC].classList.toggle("hide",1===t)})},100),this[l]=t=>{const e=t.detail.totalProgress,i=t.detail.reason;1===e&&(this[RC].flush(),this.loaded&&(this[IC]||this.reveal===_C)&&this[TC]()),this[RC](e),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:e,reason:i}}))};const c=self.ModelViewerElement||{},h=c.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";Pg.setDRACODecoderLocation(h);const u=c.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";Pg.setKTX2TranscoderLocation(u),c.meshoptDecoderLocation&&Pg.setMeshoptDecoderLocation(c.meshoptDecoderLocation);const d=c.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/loaders/LottieLoader.js";null!=fy.singleton.textureUtils&&(fy.singleton.textureUtils.lottieLoaderUrl=d)}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[vE].addEventListener("progress",this[LC])}disconnectedCallback(){super.disconnectedCallback(),this[vE].removeEventListener("progress",this[LC])}async updated(t){super.updated(t),t.has("poster")&&null!=this.poster&&(this[MC].style.backgroundImage=`url(${this.poster})`),t.has("alt")&&this[MC].setAttribute("aria-label",this[rE]),(t.has("reveal")||t.has("loading"))&&this[lE]()}[(e=BC,i=IC,n=wC,r=MC,s=CC,a=DC,o=RC,l=LC,_E)](){const t=Array.from(this.querySelectorAll("extra-model"));return!!(this.src||t.length>0)&&(this[IC]||this.loading===SC||this.reveal===_C&&this[eE])}[TC](){this[IC]=!1;const t=this[wC];if(!t.classList.contains("show"))return;t.classList.remove("show"),this[uE].classList.add("show");const e=this.modelIsVisible;this[BC]=!0,this[iE](e);const i=this.getRootNode();i&&i.activeElement===this&&this[uE].focus();const n=this[MC];n.setAttribute("aria-hidden","true"),n.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[xE](){return super[xE]()&&this[BC]}}return xC([ht({type:String})],c.prototype,"poster",void 0),xC([ht({type:String})],c.prototype,"reveal",void 0),xC([ht({type:String})],c.prototype,"loading",void 0),c})((t=>{var e,i;class n extends t{constructor(...t){super(t),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[e]=!0,this[i]=DE,this[pE].subscribeMixerEvent("loop",t=>{const e=t.action._loopCount,i=t.action._clip.name,n=t.action._clip.uuid,r=this[pE].markedAnimations.find(t=>t.name===i);if(r){this[pE].updateAnimationLoop(r.name,r.loopMode,r.repetitionCount);const t=this[pE].markedAnimations.filter(t=>t.name!==i);this[pE].markedAnimations=t}this.dispatchEvent(new CustomEvent("loop",{detail:{count:e,name:i,uuid:n}}))}),this[pE].subscribeMixerEvent("finished",t=>{if(this[pE].appendedAnimations.includes(t.action._clip.name)){const e=this[pE].appendedAnimations.filter(e=>e!==t.action._clip.name);this[pE].appendedAnimations=e}else this[BE]=!0;this.dispatchEvent(new CustomEvent("finished"))})}get availableAnimations(){return this.loaded?this[pE].animationNames:[]}get duration(){return this[pE].duration}get paused(){return this[pE].isAllAnimationsPaused()}get currentTime(){return this[pE].animationTime}get appendedAnimations(){return this[pE].appendedAnimations}set currentTime(t){this[pE].animationTime=t,this[AE]()}get timeScale(){return this[pE].animationTimeScale}set timeScale(t){this[pE].animationTimeScale=t}pause(t){var e;if(null==(null==t?void 0:t.modelIndex)&&this.paused)return;const i=null!==(e=null==t?void 0:t.modelIndex)&&void 0!==e?e:null;this[pE].pauseAnimation(i),this.dispatchEvent(new CustomEvent("pause"))}play(t){var e;if(this.availableAnimations.length>0){const i=null!==(e=null==t?void 0:t.modelIndex)&&void 0!==e?e:null;this[pE].unpauseAnimation(i),this[RE]=Object.assign(Object.assign({},DE),t),this[ME](this[RE]),this.dispatchEvent(new CustomEvent("play"))}}appendAnimation(t,e){var i;this.availableAnimations.length>0&&(this[BE]=!1,this[pE].unpauseAnimation(null!==(i=null==e?void 0:e.modelIndex)&&void 0!==i?i:null),this[IE](t,e),this.dispatchEvent(new CustomEvent("append-animation")))}detachAnimation(t,e){var i;this.availableAnimations.length>0&&(this[BE]=!1,this[pE].unpauseAnimation(null!==(i=null==e?void 0:e.modelIndex)&&void 0!==i?i:null),this[TE](t,e),this.dispatchEvent(new CustomEvent("detach-animation")))}[(e=BE,i=RE,mE)](){super[mE](),this[pE].pauseAnimation(),null!=this.animationName&&this[ME](),this.autoplay&&this.play()}[gE](t,e){super[gE](t,e),this.paused||!this[xE]()&&!this[bE].isPresenting||(this[pE].updateAnimation(e/1e3),this[AE]())}updated(t){super.updated(t),t.has("autoplay")&&this.autoplay&&this.play(),t.has("animationName")&&this[ME]()}[ME](t){var e;const i=null!=t?t:this[RE],n=null!==(e=i.repetitions)&&void 0!==e?e:1/0,r=i.pingpong?Ei:1===n?xi:_i;this[pE].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,r,n,i.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}[IE](t="",e={}){var i;const n=Object.assign(Object.assign({},LE),e),r=null!==(i=n.repetitions)&&void 0!==i?i:1/0,s=n.pingpong?Ei:1===r?xi:_i,a=!!e.repetitions||"pingpong"in e;this[pE].appendAnimation(t||this.animationName,s,r,n.weight,n.timeScale,n.fade,n.warp,n.relativeWarp,n.time,a,n.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}[TE](t="",e={}){const i=Object.assign(Object.assign({},PE),e);this[pE].detachAnimation(t||this.animationName,i.fade,i.modelIndex),this[BE]&&(this[pE].updateAnimation(0),this[AE]())}}return wE([ht({type:Boolean})],n.prototype,"autoplay",void 0),wE([ht({type:String,attribute:"animation-name"})],n.prototype,"animationName",void 0),wE([ht({type:Number,attribute:"animation-crossfade-duration"})],n.prototype,"animationCrossfadeDuration",void 0),n})(CE))))))));customElements.define("model-viewer",GC);export{eo as CanvasTexture,Ql as FileLoader,Nl as Loader,GC as ModelViewerElement,ue as NearestFilter};//# sourceMappingURL=model-viewer.min.js.mapdiff --git a/pages/marketplace.html b/pages/marketplace.htmlindex 468774891..462416580 100644--- a/pages/marketplace.html+++ b/pages/marketplace.html@@ -23,7 +23,7 @@<link rel="canonical" href="https://three.ws/marketplace" /><!-- Agent cards mount model-viewer (4.0.0) lazily from this CDN; warm theconnection so the handshake is paid before the bundle is requested. -->- <link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin /><link rel="preload" href="/fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin /><link rel="preload" href="/fonts/space-grotesk-latin.woff2" as="font" type="font/woff2" crossorigin /><link rel="stylesheet" href="/style.css" />@@ -3191,8 +3191,8 @@<script src="/model-viewer-meshopt.js" defer></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><link rel="stylesheet" href="/nav.css" />diff --git a/pages/materialize-order.html b/pages/materialize-order.htmlindex e3af40908..f55154d6d 100644--- a/pages/materialize-order.html+++ b/pages/materialize-order.html@@ -12,7 +12,7 @@<link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/fonts/fonts.css" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {--mo-line: rgba(255, 255, 255, 0.09);diff --git a/pages/materialize.html b/pages/materialize.htmlindex 654418171..291e4a2be 100644--- a/pages/materialize.html+++ b/pages/materialize.html@@ -20,7 +20,7 @@<link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/fonts/fonts.css" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {--mz-line: rgba(255, 255, 255, 0.09);diff --git a/pages/mine.html b/pages/mine.htmlindex bbf3d33d7..1a0cc6bf7 100644--- a/pages/mine.html+++ b/pages/mine.html@@ -38,7 +38,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/mint-success.html b/pages/mint-success.htmlindex ae2b5b684..11f556d1f 100644--- a/pages/mint-success.html+++ b/pages/mint-success.html@@ -9,7 +9,7 @@<meta name="robots" content="noindex" /><link rel="icon" href="/favicon.ico" sizes="any" /><link rel="stylesheet" href="/fonts/fonts.css" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }diff --git a/pages/minted.html b/pages/minted.htmlindex 8ad302a2b..acb1d8794 100644--- a/pages/minted.html+++ b/pages/minted.html@@ -46,7 +46,7 @@<meta property="og:locale" content="en_US" /><meta property="og:image:alt" content="Minted 3D Assets — three.ws" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/model.html b/pages/model.htmlindex 12884de6b..f15cb0f55 100644--- a/pages/model.html+++ b/pages/model.html@@ -39,7 +39,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/nim-forge.html b/pages/nim-forge.htmlindex 5040a776d..c627d8100 100644--- a/pages/nim-forge.html+++ b/pages/nim-forge.html@@ -10,12 +10,12 @@<link rel="icon" href="/favicon.ico" sizes="any" /><link rel="icon" type="image/svg+xml" href="/favicon.svg" /><link rel="stylesheet" href="/style.css" />- <link rel="preconnect" href="https://ajax.googleapis.com" />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" /><script src="/model-viewer-meshopt.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/objects.html b/pages/objects.htmlindex 66c2efeed..7a3621349 100644--- a/pages/objects.html+++ b/pages/objects.html@@ -28,7 +28,7 @@<meta property="og:locale" content="en_US" /><link rel="shortcut icon" href="/favicon.ico" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/model-viewer-meshopt.js"></script><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" />diff --git a/pages/pitch.html b/pages/pitch.htmlindex f70f69c37..3ff58c375 100644--- a/pages/pitch.html+++ b/pages/pitch.html@@ -44,8 +44,8 @@<script src="/model-viewer-meshopt.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>@@ -747,7 +747,7 @@// labelled fallback that says so and offers a real retry, instead of// leaving a "Live - drag to orbit" badge over nothing.const MODEL_VIEWER_SRC =- 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';const MODEL_VIEWER_TIMEOUT = 6000;function stageOf(mv) { return mv.closest('.title-stage'); }diff --git a/pages/playground.html b/pages/playground.htmlindex d7b303380..878754fa8 100644--- a/pages/playground.html+++ b/pages/playground.html@@ -18,8 +18,8 @@<link rel="stylesheet" href="/mobile.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script defer src="/footer-newsletter.js"></script>@@ -1229,7 +1229,7 @@/* ── embed code ── */const VIEWER_TAG =- '<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"><\/script>';+ '<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"><\/script>';const snippetFor = (src) =>VIEWER_TAG +diff --git a/pages/profile.html b/pages/profile.htmlindex c43015ef7..8ef234d72 100644--- a/pages/profile.html+++ b/pages/profile.html@@ -24,8 +24,8 @@<link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/pump-dashboard.html b/pages/pump-dashboard.htmlindex 4630580fd..07f02cf22 100644--- a/pages/pump-dashboard.html+++ b/pages/pump-dashboard.html@@ -40,8 +40,8 @@<script defer src="/footer-newsletter.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/pages/search.html b/pages/search.htmlindex 50a5e6e88..12f879daa 100644--- a/pages/search.html+++ b/pages/search.html@@ -43,7 +43,7 @@<meta property="og:locale" content="en_US" /><meta property="og:image:alt" content="Search — three.ws" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script></head><body><header><div id="nav-container"></div></header>diff --git a/pages/tutorial.html b/pages/tutorial.htmlindex 43d75c049..feece56bd 100644--- a/pages/tutorial.html+++ b/pages/tutorial.html@@ -70,8 +70,8 @@<script defer src="/live-steps.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/tutorials.html b/pages/tutorials.htmlindex afb12ee40..ecfffc355 100644--- a/pages/tutorials.html+++ b/pages/tutorials.html@@ -51,8 +51,8 @@<script defer src="/tutorials-manifest.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/vault.html b/pages/vault.htmlindex 881c121b0..11b18ef2d 100644--- a/pages/vault.html+++ b/pages/vault.html@@ -58,7 +58,7 @@<meta property="og:locale" content="en_US" /><meta property="og:image:alt" content="three.ws vault — encrypted 3D models gated by BNB Chain + Greenfield" /><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><script type="application/ld+json">{diff --git a/pages/wardrobe.html b/pages/wardrobe.htmlindex 253e9ce3d..a82b9da77 100644--- a/pages/wardrobe.html+++ b/pages/wardrobe.html@@ -29,7 +29,7 @@<meta property="og:image:alt" content="Wardrobe, three.ws" /><link rel="shortcut icon" href="/favicon.ico" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/model-viewer-meshopt.js"></script><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" />diff --git a/pages/what-is.html b/pages/what-is.htmlindex acb71e521..f90651b60 100644--- a/pages/what-is.html+++ b/pages/what-is.html@@ -45,8 +45,8 @@<scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/pages/worlds.html b/pages/worlds.htmlindex 8a5a44c5a..96b1e4785 100644--- a/pages/worlds.html+++ b/pages/worlds.html@@ -44,8 +44,8 @@<!-- model-viewer powers the live avatar preview in the onboarding panel. --><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script>diff --git a/public/3d.html b/public/3d.htmlindex 3b084c04c..c61cb3d08 100644--- a/public/3d.html+++ b/public/3d.html@@ -15,8 +15,8 @@<link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><script- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"type="module"></script>diff --git a/public/agenc/embed.js b/public/agenc/embed.jsindex 2645b0cef..84063f5b6 100644--- a/public/agenc/embed.js+++ b/public/agenc/embed.js@@ -36,7 +36,7 @@// The element is dependency-free apart from <model-viewer>, which is loaded// lazily from the npm CDN on first connect (the same source three.ws uses).-const MODEL_VIEWER_CDN = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';+const MODEL_VIEWER_CDN = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';// Served from three.ws rather than a public CDN: the decoder is a hard// dependency of every compressed avatar, so it must have the same availability// as the embed script itself.diff --git a/public/ar-forge.html b/public/ar-forge.htmlindex 11050f67a..57e8e25ed 100644--- a/public/ar-forge.html+++ b/public/ar-forge.html@@ -26,7 +26,7 @@<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"AR Forge","url":"https://three.ws/ar","applicationCategory":"DesignApplication","operatingSystem":"Any","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"description":"Type a prompt, get a 3D model, and place it in your room. Free text-to-3D with instant AR on your phone.","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script><!-- Meshopt decoder must register before <model-viewer> starts loading (Forge GLBs are meshopt-compressed). Classic script runs during parse, before the model-viewer module. --><script src="/model-viewer-meshopt.js"></script>- <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>:root { color-scheme: dark; --accent: #6ea8fe; --ink: #e8eaf0; --muted: #9aa3b2; --line: rgba(255,255,255,0.09); }* { box-sizing: border-box; }diff --git a/public/cookbook/recipes/asset_pack.py b/public/cookbook/recipes/asset_pack.pyindex 2415c3777..767612a6d 100644--- a/public/cookbook/recipes/asset_pack.py+++ b/public/cookbook/recipes/asset_pack.py@@ -184,7 +184,7 @@ def write_gallery(out: Path, assets: list[Asset], elapsed: float) -> None:<meta name="viewport" content="width=device-width, initial-scale=1"><title>Asset pack ({built} models)</title><style>{GALLERY_CSS}</style>-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script></head><body><h1>Asset pack</h1>diff --git a/public/cookbook/self-correcting-3d/index.html b/public/cookbook/self-correcting-3d/index.htmlindex ce0913eba..0e5f59477 100644--- a/public/cookbook/self-correcting-3d/index.html+++ b/public/cookbook/self-correcting-3d/index.html@@ -8218,7 +8218,7 @@ grid; static views still see the models.</p><div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div><div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline"><div class="cm-editor cm-s-jupyter">-<div class="highlight hl-ipython3"><pre><span></span><span class="n">_MV</span> <span class="o">=</span> <span class="s2">"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"</span>+<div class="highlight hl-ipython3"><pre><span></span><span class="n">_MV</span> <span class="o">=</span> <span class="s2">"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"</span><span class="n">_CSS</span> <span class="o">=</span> <span class="s2">"""</span><span class="s2">.twg{--panel:#141821;--line:#232838;--txt:#e7e9f0;--muted:#8b93a7;--accent:#8b7bf7;</span><span class="s2"> background:radial-gradient(1100px 380px at 18</span><span class="si">% -20%</span><span class="s2">,#1a1f2e 0%,#0b0d12 62%);</span>@@ -8439,7 +8439,7 @@ the batch. Every model below was generated live by this cell.</p>padding:3px 9px;border-radius:999px;transition:.15s;}.twg .links a:hover{color:var(--txt);border-color:var(--accent);}</style>-<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script><div class="head"><span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling">// three.ws × function calling</span><h3 data-i18n="cookbook_index.a_wizard_s_study">A wizard's study</h3><p class="sub" data-i18n="cookbook_index.four_props_one_sentence_each_generated_on">Four props, one sentence each, generated on the free three.ws draft lane and rendered inline. Drag to orbit; tap AR on a phone.</p>@@ -8756,7 +8756,7 @@ If you want:padding:3px 9px;border-radius:999px;transition:.15s;}.twg .links a:hover{color:var(--txt);border-color:var(--accent);}</style>-<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script><div class="head"><span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_2">// three.ws × function calling</span><h3 data-i18n="cookbook_index.a_windowsill_of_houseplants">A windowsill of houseplants</h3><p class="sub" data-i18n="cookbook_index.designed_and_built_by_the_model_from">Designed and built by the model from a single-line brief.</p>@@ -9323,7 +9323,7 @@ human.</p>padding:3px 9px;border-radius:999px;transition:.15s;}.twg .links a:hover{color:var(--txt);border-color:var(--accent);}</style>-<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script><div class="head"><span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_3">// three.ws × function calling</span><h3 data-i18n="cookbook_index.a_windowsill_of_houseplants_after_qa">A windowsill of houseplants, after QA</h3><p class="sub" data-i18n="cookbook_index.every_prop_was_inspected_by_the_model">Every prop was inspected by the model; failures were rebuilt from the critic's own revised prompt.</p>@@ -9526,7 +9526,7 @@ If you want variations (e.g., more weathering, different color palette, high-polpadding:3px 9px;border-radius:999px;transition:.15s;}.twg .links a:hover{color:var(--txt);border-color:var(--accent);}</style>-<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script>+<script src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" type="module"></script><div class="head"><span class="eyebrow" data-i18n="cookbook_index.three_ws_function_calling_4">// three.ws × function calling</span><h3 data-i18n="cookbook_index.a_deep_sea_explorer_s_cabin">A deep-sea explorer's cabin</h3><p class="sub" data-i18n="cookbook_index.art_directed_built_inspected_and_repaired_by">Art-directed, built, inspected, and repaired by the model from one sentence. Drag to orbit; tap AR on a phone.</p>diff --git a/public/cookbook/text_to_3d_with_function_calling.ipynb b/public/cookbook/text_to_3d_with_function_calling.ipynbindex f0f7146ef..06de0e9c3 100644--- a/public/cookbook/text_to_3d_with_function_calling.ipynb+++ b/public/cookbook/text_to_3d_with_function_calling.ipynb@@ -357,7 +357,7 @@"metadata": {},"outputs": [],"source": [- "_MV = \"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"\n",+ "_MV = \"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"\n","_CSS = \"\"\"\n",".twg{--panel:#141821;--line:#232838;--txt:#e7e9f0;--muted:#8b93a7;--accent:#8b7bf7;\n"," background:radial-gradient(1100px 380px at 18% -20%,#1a1f2e 0%,#0b0d12 62%);\n",@@ -536,7 +536,7 @@" padding:3px 9px;border-radius:999px;transition:.15s;}\n",".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n","</style>\n",- " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n"," <div class=\"head\">\n"," <span class=\"eyebrow\">// three.ws × function calling</span>\n"," <h3>A wizard's study</h3><p class=\"sub\">Four props, one sentence each, generated on the free three.ws draft lane and rendered inline. Drag to orbit; tap AR on a phone.</p>\n",@@ -860,7 +860,7 @@" padding:3px 9px;border-radius:999px;transition:.15s;}\n",".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n","</style>\n",- " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n"," <div class=\"head\">\n"," <span class=\"eyebrow\">// three.ws × function calling</span>\n"," <h3>A windowsill of houseplants</h3><p class=\"sub\">Designed and built by the model from a single-line brief.</p>\n",@@ -1340,7 +1340,7 @@" padding:3px 9px;border-radius:999px;transition:.15s;}\n",".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n","</style>\n",- " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n"," <div class=\"head\">\n"," <span class=\"eyebrow\">// three.ws × function calling</span>\n"," <h3>A windowsill of houseplants, after QA</h3><p class=\"sub\">Every prop was inspected by the model; failures were rebuilt from the critic's own revised prompt.</p>\n",@@ -1568,7 +1568,7 @@" padding:3px 9px;border-radius:999px;transition:.15s;}\n",".twg .links a:hover{color:var(--txt);border-color:var(--accent);}\n","</style>\n",- " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n",+ " <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n"," <div class=\"head\">\n"," <span class=\"eyebrow\">// three.ws × function calling</span>\n"," <h3>A deep-sea explorer's cabin</h3><p class=\"sub\">Art-directed, built, inspected, and repaired by the model from one sentence. Drag to orbit; tap AR on a phone.</p>\n",diff --git a/public/dashboard/index.html b/public/dashboard/index.htmlindex d17e87810..569ab59cc 100644--- a/public/dashboard/index.html+++ b/public/dashboard/index.html@@ -1310,8 +1310,8 @@</style><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><script type="module" src="/session-client.js"></script>diff --git a/public/demos-embed/gallery.html b/public/demos-embed/gallery.htmlindex 94ebcb3b5..23ffe0167 100644--- a/public/demos-embed/gallery.html+++ b/public/demos-embed/gallery.html@@ -5,7 +5,7 @@<meta name="viewport" content="width=device-width,initial-scale=1"><title data-i18n="demos_embed_gallery.meta_title">Avatar Gallery · three.ws</title><meta name="robots" content="noindex">- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><link rel="stylesheet" href="/style.css"><link rel="stylesheet" href="/gallery/gallery.css"><link rel="stylesheet" href="/fonts/fonts.css">diff --git a/public/demos/create-v2.html b/public/demos/create-v2.htmlindex 5834f4fbf..d4d686832 100644--- a/public/demos/create-v2.html+++ b/public/demos/create-v2.html@@ -5,7 +5,7 @@<meta name="viewport" content="width=device-width, initial-scale=1" /><title data-i18n="demos_create_v2.meta_title">Create avatar v2 demo · three.ws</title><meta name="robots" content="noindex" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {color-scheme: dark;diff --git a/public/demos/gallery-picker.html b/public/demos/gallery-picker.htmlindex bea8be234..ad52dbb66 100644--- a/public/demos/gallery-picker.html+++ b/public/demos/gallery-picker.html@@ -9,7 +9,7 @@<link rel="stylesheet" href="/nav.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root { color-scheme: dark; }diff --git a/public/demos/usdz-ar.html b/public/demos/usdz-ar.htmlindex d960df125..1920bd676 100644--- a/public/demos/usdz-ar.html+++ b/public/demos/usdz-ar.html@@ -9,7 +9,7 @@<link rel="stylesheet" href="/nav.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root { color-scheme: dark; }diff --git a/public/docs-widgets.html b/public/docs-widgets.htmlindex 8ec7e995f..d1e401424 100644--- a/public/docs-widgets.html+++ b/public/docs-widgets.html@@ -26,7 +26,7 @@<link rel="stylesheet" href="/widgets-gallery/gallery.css" /><link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/nav.css" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>.docs-main {max-width: 760px;diff --git a/public/embed/v1.js b/public/embed/v1.jsindex 8828b45d0..add572770 100644--- a/public/embed/v1.js+++ b/public/embed/v1.js@@ -42,7 +42,7 @@}})();- var MV_CDN = 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ var MV_CDN = 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';// Served from the same origin this embed script came from (ORIGIN above), not// a public CDN: the decoder is a hard dependency of every compressed avatar,// so it must have exactly the same availability as the embed itself.diff --git a/public/error-reporter.js b/public/error-reporter.jsindex aae34bc80..0e4adff3d 100644--- a/public/error-reporter.js+++ b/public/error-reporter.js@@ -80,7 +80,7 @@const IGNORED_RESOURCE_SOURCES =/\/_vercel\/(insights|speed-insights)\/|\/ingest\/|\.i\.posthog\.com\//;// Exceptions thrown *inside* third-party CDN libraries we load but don't- // control. model-viewer (served from ajax.googleapis.com) throws internally+ // control. model-viewer (served from jsdelivr, cdnjs or unpkg) throws internally// when the browser can't give it a WebGL context — context budget exhausted,// GPU blocklist, headless. It degrades to its poster on its own; the throw is// neither our bug nor fixable from here, so it only adds noise. Vercel's@@ -88,7 +88,7 @@// "history.pushState is undefined" inside wallet browsers) — analytics// degrading on an exotic UA is not actionable.const IGNORED_THIRD_PARTY_CODE =- /ajax\.googleapis\.com\/ajax\/libs\/model-viewer\/|\/_vercel\/(insights|speed-insights)\/script|\/ingest\/static\/|\.i\.posthog\.com\//;+ /\/(?:ajax\/libs\/model-viewer\/|npm\/@google\/model-viewer@|@google\/model-viewer@)|\/_vercel\/(insights|speed-insights)\/script|\/ingest\/static\/|\.i\.posthog\.com\//;// WalletConnect's sign-client (loaded from esm.sh) raises an unhandled rejection// — "No matching key. session topic doesn't exist: <hex>" — when a relay event// arrives for a session the client has already torn down (the user disconnected,diff --git a/public/footer.js b/public/footer.jsindex 49ba35d95..133f6a98c 100644--- a/public/footer.js+++ b/public/footer.js@@ -95,7 +95,7 @@// model-viewer load and the element injection behind it.ensureScript({ src: '/model-viewer-meshopt.js' }).then(() => {ensureScript({- src: 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js',+ src: 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js',type: 'module',});// model-viewer needs a <model-viewer> element; swap the canvas for one.diff --git a/public/forgot-password.html b/public/forgot-password.htmlindex d72b1e570..a5deab9e4 100644--- a/public/forgot-password.html+++ b/public/forgot-password.html@@ -9,7 +9,7 @@<link rel="stylesheet" href="/auth.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root { color-scheme: dark; }diff --git a/public/gallery/index.html b/public/gallery/index.htmlindex 5cdfa5443..1429b144c 100644--- a/public/gallery/index.html+++ b/public/gallery/index.html@@ -29,7 +29,7 @@<meta name="twitter:image" content="https://three.ws/api/page-og?s=main&t=Avatar+Gallery&d=Every+public+3D+avatar+in+the+system%2C+browsable+as+a+grid.&p=%2Fgallery" /><link rel="shortcut icon" href="/favicon.ico" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/gallery/gallery.css" />diff --git a/public/gmgn.html b/public/gmgn.htmlindex 71e3b47ac..2b71354e2 100644--- a/public/gmgn.html+++ b/public/gmgn.html@@ -22,7 +22,7 @@<link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/fonts/fonts.css" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script defer src="/footer-newsletter.js"></script><style>:root { color-scheme: dark; --accent: #ffffff; --gmgn: #00c896; --border: #1f1f1f; --bg: #000000; --panel: #141414; --muted: #888; --header-h: 48px; }diff --git a/public/login.html b/public/login.htmlindex 6ccedf76f..2efa91f34 100644--- a/public/login.html+++ b/public/login.html@@ -15,7 +15,7 @@<link rel="icon" href="/favicon.ico" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><meta name="wc-project-id" content="e8a3fdf0b2dc66fa96b47582f55ec3d9" /><link rel="stylesheet" href="/wallet-connect.css" />diff --git a/public/lookup.html b/public/lookup.htmlindex c849a564d..55d9447f8 100644--- a/public/lookup.html+++ b/public/lookup.html@@ -16,7 +16,7 @@<script defer src="/footer-newsletter.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>/* Lookup-local aliases mapped onto the site design tokens (/tokens.css)diff --git a/public/next/index.html b/public/next/index.htmlindex ce5263cb1..39511baca 100644--- a/public/next/index.html+++ b/public/next/index.html@@ -10,7 +10,7 @@<meta property="og:title" content="three.ws — the 3d layer of the internet" data-i18n-attr="content:next_index.meta_og_title"/><meta property="og:description" content="Embodied AI agents. One tag. Any website." data-i18n-attr="content:next_index.meta_og_description"/>- <link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />+ <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin /><style>:root {--ink: #fff;@@ -277,7 +277,7 @@footer .links { display: flex; gap: 20px; flex-wrap: wrap; }</style>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/embed/v1.js" defer></script><script src="/model-viewer-meshopt.js"></script></head>diff --git a/public/pay/calls/index.html b/public/pay/calls/index.htmlindex 0b7ec1f13..ec654ad94 100644--- a/public/pay/calls/index.html+++ b/public/pay/calls/index.html@@ -13,7 +13,7 @@<meta name="twitter:card" content="summary_large_image" /><meta name="twitter:image" content="" id="twImage" /><meta name="theme-color" content="#0b0b0b" />-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {--bg: #0b0b0b; --bg-2: #111111;diff --git a/public/pay/index.html b/public/pay/index.htmlindex eff7f3dd6..74c5c54be 100644--- a/public/pay/index.html+++ b/public/pay/index.html@@ -16,7 +16,7 @@<meta name="twitter:image" content="https://three.ws/api/x402-pay/og" /><meta name="theme-color" content="#0b0b0b" /><link rel="preconnect" href="https://api.mainnet-beta.solana.com" />-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {--bg: #0b0b0b;diff --git a/public/persona/demo.html b/public/persona/demo.htmlindex 18ea37a85..e8bc04ea5 100644--- a/public/persona/demo.html+++ b/public/persona/demo.html@@ -247,7 +247,7 @@ if (!res.ok) throw new Error(claims.error_description);</div></main>-<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script src="/persona/widget.js" defer></script><script>const $log = document.getElementById('log');diff --git a/public/pumpfun.html b/public/pumpfun.htmlindex c7280daa5..a8a775ad3 100644--- a/public/pumpfun.html+++ b/public/pumpfun.html@@ -11,7 +11,7 @@<link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/fonts/fonts.css" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><script defer src="/footer-newsletter.js"></script><style>:root { color-scheme: dark; --accent: #ffffff; --border: #202020; --bg: #0a0a0a; --panel: #151515; --muted: #888;diff --git a/public/register.html b/public/register.htmlindex 5efab417f..60bc6a1a0 100644--- a/public/register.html+++ b/public/register.html@@ -12,7 +12,7 @@<link rel="stylesheet" href="/mobile.css" /><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>:root {diff --git a/public/reputation/index.html b/public/reputation/index.htmlindex c2cb3450c..aa3271073 100644--- a/public/reputation/index.html+++ b/public/reputation/index.html@@ -31,7 +31,7 @@<script defer src="/footer-newsletter.js"></script><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>diff --git a/public/spatial-mcp/index.html b/public/spatial-mcp/index.htmlindex d21fe3d07..f3aa2b07a 100644--- a/public/spatial-mcp/index.html+++ b/public/spatial-mcp/index.html@@ -6,7 +6,7 @@<title data-i18n="spatial_mcp_index.meta_title">Spatial MCP: reference renderer</title><meta name="description" content="The open standard for returning a live, interactive 3D scene as a first-class MCP tool result, with a framework-free reference renderer that displays any conformant artifact: including ones transformed from other tools." data-i18n-attr="content:spatial_mcp_index.meta_description"/><script src="/model-viewer-meshopt.js"></script>-<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script>+<script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script><style>:root { color-scheme: dark; --accent:#6ea8fe; }* { box-sizing:border-box; }diff --git a/public/tour/atlas.json b/public/tour/atlas.jsonindex e8b190330..7b9cf5844 100644--- a/public/tour/atlas.json+++ b/public/tour/atlas.json@@ -1319,7 +1319,7 @@},"consoleErrors": 1,"consoleSamples": [- "TypeError: Failed to fetch\n at Zl.load (https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js:17:506510)\n at Ru.load (https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js:528:4494)\n at https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/mo"+ "TypeError: Failed to fetch\n at Zl.load (https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:17:506510)\n at Ru.load (https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js:528:4494)\n at https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/mo"],"notes": ["anchored by the director's generic fallback, not a curated selector for this page"diff --git a/public/vanity-wallet.html b/public/vanity-wallet.htmlindex 5cdd9b132..d9e730d48 100644--- a/public/vanity-wallet.html+++ b/public/vanity-wallet.html@@ -12,7 +12,7 @@<link rel="stylesheet" href="/fonts/fonts.css" /><script defer src="/footer-newsletter.js"></script><script src="/x402.js" type="module"></script>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><style>* { box-sizing: border-box; }:root {diff --git a/public/viewer.html b/public/viewer.htmlindex 9cf2130e3..da5e730c9 100644--- a/public/viewer.html+++ b/public/viewer.html@@ -25,8 +25,8 @@fails the build if any of them drifts off the shared version. --><scripttype="module"- src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"- integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW"+ src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"+ integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"crossorigin="anonymous"></script><style>diff --git a/public/widgets-gallery/index.html b/public/widgets-gallery/index.htmlindex 122458686..a288df53a 100644--- a/public/widgets-gallery/index.html+++ b/public/widgets-gallery/index.html@@ -28,7 +28,7 @@<link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/widgets-gallery/gallery.css" /><link rel="stylesheet" href="/footer.css" />- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js" integrity="sha384-cprcVQt7wbUl0xngF3PGP6yBB7n4/t+4AoAMG9biiMCGFiWOdzUH10Ie2COTqFNW" crossorigin="anonymous"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js" integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p" crossorigin="anonymous"></script><meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="Widgets Gallery · three.ws" data-i18n-attr="content:widgets_gallery_index.meta_twitter_title">diff --git a/scripts/check-model-viewer-version.mjs b/scripts/check-model-viewer-version.mjsindex c3b08ee17..45d9a2fa5 100755--- a/scripts/check-model-viewer-version.mjs+++ b/scripts/check-model-viewer-version.mjs@@ -75,6 +75,17 @@ const SKIPPED = [// rogue sixth version.const INTERPOLATED = /^\$\{/;+// Published builds that must never be the pin again, with the reason. 4.3.x is+// the first line that decodes KHR_meshopt_compression (api/_lib/bake.js emits+// it), but Google shipped it with debug console.log calls left in+// ("[$updateSource] called!", "BAILING OUT EARLY!", "IntersectionObserver+// fired!"), so every page with a viewer flooded the visitor's console. Fixed+// upstream in 4.4.0 (google/model-viewer#5182).+const BANNED = {+ '4.3.0': 'ships leftover debug console.log calls on every source update (fixed in 4.4.0)',+ '4.3.1': 'ships leftover debug console.log calls on every source update (fixed in 4.4.0)',+};+function trackedFiles() {const listed = (args) => execFileSync('git', args, { encoding: 'utf8', maxBuffer: 1 << 28 }).split('\n');return [...listed(['ls-files']), ...listed(['ls-files', '-o', '--exclude-standard'])]@@ -142,6 +153,11 @@ if (versions.size === 0) {);}+for (const [version, files] of versions) {+ if (!BANNED[version]) continue;+ failures.push(`model-viewer ${version} ${BANNED[version]}; it is referenced in ${files.size} file(s), e.g. ${[...files][0]}`);+}+for (const [version, byHash] of integrities) {if (byHash.size < 2) continue;const lines = [...byHash.entries()].map(@@ -150,7 +166,7 @@ for (const [version, byHash] of integrities) {failures.push(`model-viewer ${version} is served with ${byHash.size} different integrity hashes:\n${lines.join('\n')}\n` +` One of these is stale (a bumped URL with its SRI left behind). Recompute:\n` +- ` curl -s https://ajax.googleapis.com/ajax/libs/model-viewer/${version}/model-viewer.min.js | openssl dgst -sha384 -binary | openssl base64 -A`,+ ` curl -s https://cdn.jsdelivr.net/npm/@google/model-viewer@${version}/dist/model-viewer.min.js | openssl dgst -sha384 -binary | openssl base64 -A`,);}@@ -172,7 +188,7 @@ if (versions.size === 1 && integrities.has(pinned)) {` expected ${expected}\n` +` actual ${actual}\n` +` Restage it:\n` +- ` curl -sSfo ${VENDORED} https://ajax.googleapis.com/ajax/libs/model-viewer/${pinned}/model-viewer.min.js`,+ ` curl -sSfo ${VENDORED} https://cdn.jsdelivr.net/npm/@google/model-viewer@${pinned}/dist/model-viewer.min.js`,);}}diff --git a/scripts/glb-thumbnail-harness.html b/scripts/glb-thumbnail-harness.htmlindex 95eb2e5fc..742d1ecd0 100644--- a/scripts/glb-thumbnail-harness.html+++ b/scripts/glb-thumbnail-harness.html@@ -10,7 +10,7 @@background: radial-gradient(120% 120% at 50% 20%, #1a1b26, #0a0b12);}</style>- <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js"></script>+ <script type="module" src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"></script></head><body><model-viewerdiff --git a/scripts/render-glb-poster.mjs b/scripts/render-glb-poster.mjsindex 1e8b08f5e..dc98e8603 100644--- a/scripts/render-glb-poster.mjs+++ b/scripts/render-glb-poster.mjs@@ -65,7 +65,9 @@ const glbName = basename(glb);// model-viewer does not wire a decoder for on its own, so the shared shim is// injected ahead of the model-viewer module exactly as every page does it.const MESHOPT_SHIM = resolve(root, 'public/model-viewer-meshopt.js');-const MV_TAG = '<script type="module" src="https://ajax.googleapis.com';+// Any CDN shape of the pinned build: the pin's host has moved before (Google's+// mirror to jsdelivr), and a literal host here silently stopped the shim.+const MV_TAG = /<script type="module" src="[^"]*model-viewer[^"]*\.min\.js"><\/script>/;const server = createServer((req, res) => {// '/model/' with the slash: '/model-viewer-meshopt.js' also starts with// '/model', and serving it the GLB's bytes made the shim fail to parse and@@ -80,10 +82,9 @@ const server = createServer((req, res) => {res.end(readFileSync(MESHOPT_SHIM));return;}- const html = readFileSync(HARNESS, 'utf8').replace(- MV_TAG,- `<script src="/model-viewer-meshopt.js"></script>${MV_TAG}`,- );+ const harness = readFileSync(HARNESS, 'utf8');+ if (!MV_TAG.test(harness)) throw new Error(`${HARNESS} has no model-viewer <script> to inject the meshopt shim ahead of`);+ const html = harness.replace(MV_TAG, (tag) => `<script src="/model-viewer-meshopt.js"></script>${tag}`);res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });res.end(html);});diff --git a/src/forge-embed-snippets.js b/src/forge-embed-snippets.jsindex e9cab95bd..7ff30f827 100644--- a/src/forge-embed-snippets.js+++ b/src/forge-embed-snippets.js@@ -18,7 +18,7 @@const ORIGIN = 'https://three.ws';const MODEL_VIEWER_CDN =- 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';// Major-version CDN channel (specs/EMBED_SPEC.md): follows minor/patch// releases automatically without pinning exact bytes like a demo snippet// would ("latest" is explicitly demo-only per that spec).diff --git a/src/forge-studio/forge-embed-snippets.js b/src/forge-studio/forge-embed-snippets.jsindex 5d12c2c32..66b6de3fe 100644--- a/src/forge-studio/forge-embed-snippets.js+++ b/src/forge-studio/forge-embed-snippets.js@@ -13,7 +13,7 @@const ORIGIN = 'https://three.ws';const MODEL_VIEWER_CDN =- 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.3.1/model-viewer.min.js';+ 'https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js';export const EMBED_SIZES = [{ id: 'wide', label: '16 : 9', w: 640, h: 360, ratio: '16 / 9' },diff --git a/src/shared/model-viewer-loader.js b/src/shared/model-viewer-loader.jsindex e887f8d35..1ff00cc26 100644--- a/src/shared/model-viewer-loader.js+++ b/src/shared/model-viewer-loader.js@@ -10,11 +10,13 @@//// The same version is served from three independent CDNs; any one of them is// the whole library, so the first that loads wins and the rest are never hit.+// Google's own ajax.googleapis.com mirror is not in the chain: it never+// published 4.4.0, so that rung would only ever 404.-const VERSION = '4.3.1';+const VERSION = '4.4.0';const SOURCES = [- `https://ajax.googleapis.com/ajax/libs/model-viewer/${VERSION}/model-viewer.min.js`,`https://cdn.jsdelivr.net/npm/@google/model-viewer@${VERSION}/dist/model-viewer.min.js`,+ `https://cdnjs.cloudflare.com/ajax/libs/model-viewer/${VERSION}/model-viewer.min.js`,`https://unpkg.com/@google/model-viewer@${VERSION}/dist/model-viewer.min.js`,];// A script that neither loads nor errors (a black-holed CDN) is treated asdiff --git a/tests/site-audit-regressions.test.js b/tests/site-audit-regressions.test.jsindex e8ea1813e..1aa9fe3eb 100644--- a/tests/site-audit-regressions.test.js+++ b/tests/site-audit-regressions.test.js@@ -19,7 +19,7 @@ describe('production page-audit regressions', () => {expect(js).toContain("from '../shared/model-viewer-loader.js'");expect(js).not.toContain('ajax.googleapis.com/ajax/libs/model-viewer/');const loader = source('src/shared/model-viewer-loader.js');- expect(loader).toContain("const VERSION = '4.3.1';");+ expect(loader).toContain("const VERSION = '4.4.0';");});it('marks only the intentional voice error preview as audit documentation', () => {