diff --git a/.github/extensions/badge-simulator/README.md b/.github/extensions/badge-simulator/README.md index 8a618d0f..deb0b219 100644 --- a/.github/extensions/badge-simulator/README.md +++ b/.github/extensions/badge-simulator/README.md @@ -20,15 +20,26 @@ Copilot loads it automatically for anyone who clones this repository. It finishes by rebooting the badge so it leaves mass-storage, REPL and test modes and returns to the menu. - **Theme**: follows the Copilot app's light or dark theme. -- **HOME** runs the app's `on_exit` and restarts it, because there is no menu. +- **MonaOS mode**: choose `monaos` (or open the canvas with + `{ "app": "monaos" }`) to run the whole OS instead of one app. It loads the + real launcher from `badge/apps/menu` with every app in `badge/apps` and the + files in `badge/assets`, laid out like the badge's `/system` volume. Select + opens an app and HOME returns to the menu. Any change under those folders + reruns it, except edits to assets the simulator runtime already ships at the + same path (such as `badge/assets/icons.png`), which are read-only there and + only show on the badge. Deploy and `check_app` need a single app, so they + reject `monaos`. The payload is about 11 MiB, so it loads more slowly than one + app. +- **HOME** runs the app's `on_exit` and restarts it, because a single app has + no menu. In MonaOS mode it returns to the menu instead. - **Output** shows `print()` output and tracebacks from MicroPython. ## Using it Ask Copilot to "open the Badge Simulator for flappy_mona", or have the agent call `open_canvas` with `canvasId: "badge-simulator"` and -`input: { "app": "" }`. You can also choose an app -from the drop-down in the canvas. +`input: { "app": "" }`, or `"monaos"` for the whole +OS. You can also choose an app from the drop-down in the canvas. The repository's Copilot instructions make the simulator the default: when you ask Copilot to build, run or deploy an app, it opens the app here first, @@ -39,7 +50,7 @@ The agent can drive the canvas with `invoke_canvas_action`: | Action | Input | Purpose | | --- | --- | --- | -| `load_app` | `{ "app": "snake" }` | Switch to another app | +| `load_app` | `{ "app": "snake" }` | Switch to another app, or `"monaos"` for the whole OS | | `reload` | `{ "restart_runtime"?: true }` | Rerun now (normally automatic) | | `get_output` | `{ "lines"?: 80, "since"?: cursor }` | Status (running, crashed, fps, frames, resolution, orientation, backlight), recent output and the last error mapped to `badge/apps/...:line` | | `press` | `{ "button": "select", "duration_ms"?: 120 }` | Press `up`, `down`, `left`, `right`, `select`, `home`, `back`, `menu` (or `a`/`b`/`c`); combine with `"a+b"` | diff --git a/.github/extensions/badge-simulator/extension.mjs b/.github/extensions/badge-simulator/extension.mjs index b43d5f09..9efddd7c 100644 --- a/.github/extensions/badge-simulator/extension.mjs +++ b/.github/extensions/badge-simulator/extension.mjs @@ -39,6 +39,11 @@ function repoRoot(ctx) { return resolve(extDir, "..", "..", ".."); } const appsDir = (root) => join(root, "badge", "apps"); +const assetsDir = (root) => join(root, "badge", "assets"); +// Reserved app name that runs the whole OS instead of one app: the real menu +// launcher plus every app in badge/apps and every asset in badge/assets. +const OS_APP = "monaos"; +const appTitle = (app) => (app === OS_APP ? "MonaOS" : app); function listApps(root) { try { return readdirSync(appsDir(root), { withFileTypes: true }) @@ -49,15 +54,22 @@ function listApps(root) { return []; } } -function appFiles(dir, base = dir, out = []) { +const appChoices = (root) => [OS_APP, ...listApps(root)]; +const isApp = (root, app) => app === OS_APP || listApps(root).includes(app); +function appFiles(dir, prefix = "", base = dir, out = []) { for (const entry of readdirSync(dir, { withFileTypes: true })) { if (ignoredFile(entry.name)) continue; const full = join(dir, entry.name); - if (entry.isDirectory()) appFiles(full, base, out); - else if (entry.isFile()) out.push({ path: relative(base, full).split(sep).join("/"), data: readFileSync(full).toString("base64") }); + if (entry.isDirectory()) appFiles(full, prefix, base, out); + else if (entry.isFile()) out.push({ path: prefix + relative(base, full).split(sep).join("/"), data: readFileSync(full).toString("base64") }); } return out; } +// MonaOS payload: paths are relative to /system, like the BADGER USB drive. +const osFiles = (root) => [ + ...appFiles(appsDir(root), "apps/"), + ...(existsSync(assetsDir(root)) ? appFiles(assetsDir(root), "assets/") : []), +]; // ---- persisted selection -------------------------------------------------------- const stateFile = () => (session?.workspacePath ? join(session.workspacePath, "files", "badge-simulator.json") : null); @@ -118,22 +130,26 @@ function broadcast(inst, event) { } function watchApp(inst) { - inst.watcher?.close(); - inst.watcher = null; + for (const watcher of inst.watchers) watcher.close(); + inst.watchers = []; clearTimeout(inst.reloadTimer); if (!inst.app) return; - try { - inst.watcher = watch(join(appsDir(inst.root), inst.app), { recursive: true }, (_type, name) => { - if (name && String(name).split(/[\\/]/).some(ignoredFile)) return; - clearTimeout(inst.reloadTimer); - inst.reloadTimer = setTimeout(() => { - inst.revision++; - broadcast(inst, { type: "reload", app: inst.app, revision: inst.revision }); - }, 300); - }); - inst.watcher.on("error", () => {}); - } catch (error) { - session?.log(`badge-simulator: could not watch ${inst.app}: ${error.message}`, { level: "warning" }); + const dirs = inst.app === OS_APP ? [appsDir(inst.root), assetsDir(inst.root)] : [join(appsDir(inst.root), inst.app)]; + for (const dir of dirs) { + try { + const watcher = watch(dir, { recursive: true }, (_type, name) => { + if (name && String(name).split(/[\\/]/).some(ignoredFile)) return; + clearTimeout(inst.reloadTimer); + inst.reloadTimer = setTimeout(() => { + inst.revision++; + broadcast(inst, { type: "reload", app: inst.app, revision: inst.revision }); + }, 300); + }); + watcher.on("error", () => {}); + inst.watchers.push(watcher); + } catch (error) { + session?.log(`badge-simulator: could not watch ${relative(inst.root, dir)}: ${error.message}`, { level: "warning" }); + } } } @@ -176,17 +192,20 @@ function ingestLog(inst, lines) { if (inst.execCurrent) { inst.execCurrent.lines.push(line); continue; } // badgeware.fatal_error() prints "- ERROR: ..." and parks on an error screen. if (line.startsWith("- ERROR:")) inst.fatal = true; - if (line.startsWith("[simulator] Running ") || line.startsWith("[simulator] Restarting app")) inst.fatal = false; + // A new run, a restart, or MonaOS going back to its menu or launching an app clears a crash. + if (/^\[simulator\] (Running |Restarting app|MonaOS menu|Launching )/.test(line)) inst.fatal = false; inst.log.push(line); } if (inst.log.length > LOG_LIMIT) { const drop = inst.log.length - LOG_LIMIT; inst.log.splice(0, drop); inst.logBase += drop; } notify(inst); } -// Turns the latest MicroPython traceback in the current run into repo paths. +// Turns the latest MicroPython traceback in the current run into repo paths. In +// MonaOS mode each app launch and each return to the menu starts a new run, so +// an earlier app's crash isn't reported against the menu or the next app. function lastError(inst) { let start = 0; - for (let i = inst.log.length - 1; i >= 0; i--) if (inst.log[i].startsWith("[simulator] Running ")) { start = i; break; } + for (let i = inst.log.length - 1; i >= 0; i--) if (/^\[simulator\] (Running |Launching |MonaOS menu)/.test(inst.log[i])) { start = i; break; } const run = inst.log.slice(start); let tb = -1; for (let i = run.length - 1; i >= 0; i--) if (/^(Traceback \(most recent call last\):|- ERROR:)/.test(run[i])) { tb = i; break; } @@ -205,7 +224,8 @@ function lastError(inst) { } else if (offset > 0 && !/^\s/.test(line)) { message = line; break; } else if (offset === 0 && line.startsWith("- ERROR:")) message = line.slice(8).trim(); } - const inApp = [...frames].reverse().find((f) => f.repo_path?.startsWith(`badge/apps/${inst.app}/`)) ?? [...frames].reverse().find((f) => f.repo_path); + const ownFrame = (f) => f.repo_path?.startsWith(inst.app === OS_APP ? "badge/apps/" : `badge/apps/${inst.app}/`); + const inApp = [...frames].reverse().find(ownFrame) ?? [...frames].reverse().find((f) => f.repo_path); return { message, location: inApp?.repo_path ?? null, frames, traceback: traceback.join("\n") }; } @@ -225,10 +245,10 @@ function snapshot(inst) { } function selectApp(inst, app) { - if (app && !listApps(inst.root).includes(app)) throw new Error(`Unknown app "${app}". Apps live in badge/apps//__init__.py.`); + if (app && !isApp(inst.root, app)) throw new Error(`Unknown app "${app}". Apps live in badge/apps//__init__.py; use "${OS_APP}" to run the whole OS.`); inst.app = app || null; inst.revision++; - inst.status = inst.app ? `Loading ${inst.app}` : "Choose an app to run"; + inst.status = inst.app ? `Loading ${appTitle(inst.app)}` : "Choose an app to run"; inst.state = ""; clearLog(inst); saveLastApp(inst.app); @@ -274,9 +294,13 @@ async function handle(inst, req, res) { req.on("close", () => { clearInterval(ping); inst.clients.delete(res); }); return; } - if (path === "/api/state") return json(res, 200, { apps: listApps(inst.root), app: inst.app }); + if (path === "/api/state") return json(res, 200, { apps: appChoices(inst.root), app: inst.app }); if (path === "/api/app") { if (!inst.app) { res.writeHead(204); return res.end(); } + if (inst.app === OS_APP) { + if (!existsSync(join(appsDir(inst.root), "menu", "__init__.py"))) return json(res, 404, { error: "badge/apps/menu/__init__.py not found, so MonaOS cannot start" }); + return json(res, 200, { app: OS_APP, os: true, revision: inst.revision, files: osFiles(inst.root) }); + } const dir = join(appsDir(inst.root), inst.app); if (!existsSync(join(dir, "__init__.py"))) return json(res, 404, { error: `badge/apps/${inst.app}/__init__.py not found` }); return json(res, 200, { app: inst.app, revision: inst.revision, files: appFiles(dir) }); @@ -319,6 +343,7 @@ async function handle(inst, req, res) { if (path === "/api/deploy") { const app = body.app || inst.app; if (!app) return json(res, 400, { error: "No app selected" }); + if (app === OS_APP) return json(res, 400, { error: "MonaOS runs every app. Pick a single app to deploy it." }); if (!listApps(inst.root).includes(app)) return json(res, 400, { error: `Unknown app "${app}"` }); await session.send({ prompt: deployPrompt(app) }); return json(res, 200, { ok: true }); @@ -346,10 +371,10 @@ async function startInstance(ctx) { const inst = { root, app: null, revision: 0, status: "Starting", state: "", log: [], logBase: 0, stats: null, statsAt: 0, waiters: new Set(), execs: new Map(), execCurrent: null, - clients: new Set(), statsBy: new Map(), screenshots: new Map(), recordings: new Map(), watcher: null, reloadTimer: null, server: null, url: "", + clients: new Set(), statsBy: new Map(), screenshots: new Map(), recordings: new Map(), watchers: [], reloadTimer: null, server: null, url: "", }; const remembered = loadLastApp(); - if (remembered && listApps(root).includes(remembered)) inst.app = remembered; + if (remembered && isApp(root, remembered)) inst.app = remembered; inst.server = createServer((req, res) => void handle(inst, req, res)); await new Promise((r) => inst.server.listen(0, "127.0.0.1", r)); inst.url = `http://127.0.0.1:${inst.server.address().port}/`; @@ -357,7 +382,7 @@ async function startInstance(ctx) { try { inst.appsWatcher = watch(appsDir(root), () => { clearTimeout(appsTimer); - appsTimer = setTimeout(() => broadcast(inst, { type: "apps", apps: listApps(root) }), 500); + appsTimer = setTimeout(() => broadcast(inst, { type: "apps", apps: appChoices(root) }), 500); }); inst.appsWatcher.on("error", () => {}); } catch {} @@ -625,6 +650,7 @@ function readmeDescription(text) { function checkApp(inst, app) { app = app || inst.app; if (!app) throw new Error("No app selected."); + if (app === OS_APP) throw new Error(`MonaOS runs every app, so check_app needs a single app name, e.g. {"app": "snake"}.`); const dir = join(appsDir(inst.root), app); if (!existsSync(dir)) throw new Error(`badge/apps/${app} does not exist.`); const errors = [], warnings = []; @@ -660,15 +686,15 @@ session = await joinSession({ id: "badge-simulator", displayName: "Badge Simulator", description: - "Runs a Universe 2026 badge app from badge/apps/ in the 3D badge simulator. The canvas reloads automatically whenever the app's files change, mirrors the app theme, and has a Deploy button that asks Copilot to install the app on a connected badge. Open it with input {app: \"\"} while building or testing an app.", + "Runs a Universe 2026 badge app from badge/apps/ in the 3D badge simulator. The canvas reloads automatically whenever the app's files change, mirrors the app theme, and has a Deploy button that asks Copilot to install the app on a connected badge. Open it with input {app: \"\"} while building or testing an app. Use {app: \"monaos\"} to run the whole MonaOS from badge/ instead: the real menu launcher with every app and asset, where select opens an app and HOME returns to the menu.", inputSchema: { type: "object", - properties: { app: { type: "string", description: "Folder name under badge/apps to run, e.g. flappy_mona" } }, + properties: { app: { type: "string", description: "Folder name under badge/apps to run, e.g. flappy_mona, or \"monaos\" for the full OS (menu plus every app)" } }, }, actions: [ { name: "load_app", - description: "Switch the simulator to another app in badge/apps.", + description: "Switch the simulator to another app in badge/apps, or to \"monaos\" for the whole OS (the real menu with every app; HOME returns to the menu).", inputSchema: { type: "object", properties: { app: { type: "string" } }, required: ["app"] }, handler: (ctx) => { const inst = instanceFor(ctx); selectApp(inst, ctx.input?.app); return { app: inst.app }; }, }, @@ -789,7 +815,7 @@ session = await joinSession({ }, { name: "check_app", - description: "Static pre-flight checks for an app (default: the current one): __init__.py, 24x24 icon.png, README description rules from the PR check, and 2025-era API usage that breaks on 2026 firmware.", + description: "Static pre-flight checks for an app (default: the current one; MonaOS mode needs an explicit app): __init__.py, 24x24 icon.png, README description rules from the PR check, and 2025-era API usage that breaks on 2026 firmware.", inputSchema: { type: "object", properties: { app: { type: "string" } } }, handler: (ctx) => checkApp(instanceFor(ctx), ctx.input?.app), }, @@ -802,13 +828,13 @@ session = await joinSession({ } const app = ctx.input && typeof ctx.input === "object" ? ctx.input.app : undefined; if (app && app !== inst.app) selectApp(inst, app); - return { title: inst.app ? `Badge Simulator · ${inst.app}` : "Badge Simulator", url: inst.url }; + return { title: inst.app ? `Badge Simulator · ${appTitle(inst.app)}` : "Badge Simulator", url: inst.url }; }, onClose: async (ctx) => { const inst = instances.get(ctx.instanceId); if (!inst) return; instances.delete(ctx.instanceId); - inst.watcher?.close(); + for (const watcher of inst.watchers) watcher.close(); inst.appsWatcher?.close(); clearTimeout(inst.reloadTimer); for (const client of inst.clients) client.end(); diff --git a/.github/extensions/badge-simulator/src/entry.ts b/.github/extensions/badge-simulator/src/entry.ts index b3b67b7a..2ae26e82 100644 --- a/.github/extensions/badge-simulator/src/entry.ts +++ b/.github/extensions/badge-simulator/src/entry.ts @@ -10,7 +10,7 @@ import { fileBytes, projectFile, simulationSource } from '@site/lib/badge-editor import { firmwareCompat } from '@site/lib/badge-firmware-compat' type AppFile = { path: string; data: string } -type AppPayload = { app: string; revision: number; files: AppFile[] } +type AppPayload = { app: string; revision: number; files: AppFile[]; os?: boolean } type ServerEvent = | { type: 'reload'; app: string | null; revision: number } | { type: 'apps'; apps: string[] } @@ -23,6 +23,10 @@ type ServerEvent = | { type: 'record-stop'; id: string } const appRoot = '/system/apps' +// Reserved app name for the whole OS: the menu launcher plus every app in badge/. +const osApp = 'monaos' +const appLabel = (name: string) => (name === osApp ? 'MonaOS (all apps)' : name) +const payloadTitle = (payload: AppPayload | null) => (payload?.os ? 'MonaOS' : payload?.app ?? 'App') const $ = (selector: string) => document.querySelector(selector)! const root = $('#sim') @@ -59,9 +63,9 @@ def _sim_exec(tag, code, scope): ` const execFile = '/tmp/_sim_exec.py' -// Mirrors badge/main.py for a single app: run it, and when HOME is pressed run -// its on_exit hook and start it again (there is no menu in this canvas). -function launcher(target: string) { +// Setup shared by both launchers: services the canvas `exec` action between +// frames and turns HOME (and the firmware's reset()) into a jump back to the loop. +function launcherSetup(target: string) { return ` import builtins, machine, os, sys, time, badgeware ${execHelper} @@ -125,7 +129,13 @@ def _release(): while badge.held(): time.sleep(0.02) badge.poll() +` +} +// Mirrors badge/main.py for a single app: run it, and when HOME is pressed run +// its on_exit hook and start it again (there is no menu in this mode). +function launcher(target: string) { + return `${launcherSetup(target)} while True: badge.mode(LORES | VSYNC) badge.autorotate(True) @@ -148,6 +158,50 @@ while True: ` } +// Mirrors badge/main.py for the whole OS: run the menu, launch the app it +// returns, and come back to the menu when the app exits or HOME is pressed. +function osLauncher(menu: string) { + return `${launcherSetup(menu)} +_default_clear = badge.default_clear + +def _watchdog_cause(): + return machine.WDT_RESET + +first_boot = True +while True: + badge.mode(LORES | VSYNC) + badge.autorotate(True) + badge.default_clear = _default_clear + badgeware.set_backlight(1.0) + _release() + if not first_boot: + # On the badge reset() is a watchdog reset, so the menu skips its opening animation. + machine.reset_cause = _watchdog_cause + first_boot = False + saved_path = list(sys.path) + try: + _target = ${JSON.stringify(menu)} + _armed = True + print("[simulator] MonaOS menu") + chosen = launch(_target) + _armed = False + if chosen: + _release() + badge.mode(LORES | VSYNC) + _target = str(chosen) + _armed = True + print("[simulator] Launching " + _target) + launch(_target) + print("[simulator] Returned from " + _target) + except _ReturnHome: + pass + finally: + _armed = False + sys.path[:] = saved_path + time.sleep(0.05) +` +} + function decode(data: string) { const binary = atob(data) const bytes = new Uint8Array(binary.length) @@ -155,14 +209,17 @@ function decode(data: string) { return bytes } +// A single app's file paths are relative to its folder; MonaOS payload paths are +// relative to /system (apps//..., assets/...), like the badge's USB drive. function request(payload: AppPayload) { - const target = `${appRoot}/${payload.app}` + const base = payload.os ? '/system' : `${appRoot}/${payload.app}` const files = payload.files.map(({ path, data }) => { const file = projectFile(path, decode(data)) const text = path.endsWith('.py') && file.text !== null ? simulationSource(file.text) : file.text - return { name: `${target}/${path}`, content: fileBytes({ ...file, text }) } + return { name: `${base}/${path}`, content: fileBytes({ ...file, text }) } }) - return { program: `${prelude}\n${launcher(target)}`, files } + const loop = payload.os ? osLauncher(`${appRoot}/menu`) : launcher(base) + return { program: `${prelude}\n${loop}`, files } } const prelude = `import editor_support\nimport sys\nsys.path[:0] = ["/system/lib", "/lib", "/system"]\n${firmwareCompat}` @@ -301,10 +358,10 @@ function run(payload: AppPayload) { const req = request(payload) for (const path of paths) written.add(path) lines.length = 0 - log(`[simulator] Running ${payload.app} (revision ${payload.revision})`) + log(`[simulator] Running ${payloadTitle(payload)} (revision ${payload.revision})`) worker.postMessage({ ...req, debug: false }) worker.postMessage({ pause: document.hidden }) - setStatus(`Running ${payload.app}`, 'running') + setStatus(`Running ${payloadTitle(payload)}`, 'running') } catch (error) { log(`[simulator] ${error instanceof Error ? error.message : String(error)}`) setStatus('Could not start app', 'error') @@ -326,7 +383,7 @@ function startWorker() { if (data.running) running = true if (data.completed) running = false if (data.bootError) { log(`[simulator] ${data.bootError}`); setStatus('Simulator failed to boot', 'error') } - if (data.failed) setStatus(`${current?.app ?? 'App'} crashed — see output`, 'error') + if (data.failed) setStatus(`${payloadTitle(current)} crashed — see output`, 'error') if (data.stuck) { log('[simulator] App did not stop; restarting the runtime.'); startWorker() } if (data.ready) { ready = true @@ -350,10 +407,18 @@ function startWorker() { } } +const deployTitle = deployButton.title +// Deploy installs one app, so it stays off while the whole OS is selected. +function syncDeploy() { + const wholeOs = appSelect.value === osApp + deployButton.disabled = !appSelect.value || wholeOs + deployButton.title = wholeOs ? 'Pick a single app to deploy it to the connected badge' : deployTitle +} + function setApps(apps: string[], selected: string | null) { - appSelect.replaceChildren(new Option('Choose app…', ''), ...apps.map(name => new Option(name, name))) + appSelect.replaceChildren(new Option('Choose app…', ''), ...apps.map(name => new Option(appLabel(name), name))) appSelect.value = selected ?? '' - deployButton.disabled = !selected + syncDeploy() } async function loadApp() { @@ -369,9 +434,9 @@ async function loadApp() { } if (!response.ok) { setStatus(await response.text(), 'error'); return } const payload = await response.json() as AppPayload - if (![...appSelect.options].some(option => option.value === payload.app)) appSelect.add(new Option(payload.app, payload.app)) + if (![...appSelect.options].some(option => option.value === payload.app)) appSelect.add(new Option(appLabel(payload.app), payload.app)) appSelect.value = payload.app - deployButton.disabled = false + syncDeploy() run(payload) } @@ -511,13 +576,13 @@ function connect() { appSelect.addEventListener('change', () => { void post('/api/select', { app: appSelect.value || null }) }) reloadButton.addEventListener('click', () => { void loadApp() }) deployButton.addEventListener('click', async () => { - if (!appSelect.value) return + if (!appSelect.value || appSelect.value === osApp) return deployButton.disabled = true const response = await fetch('/api/deploy', { method: 'POST', headers: postHeaders, body: JSON.stringify({ app: appSelect.value }) }).catch(() => null) const message = response?.ok ? `Asked Copilot to deploy ${appSelect.value} to your badge` : 'Could not ask Copilot to deploy' setStatus(message, response?.ok ? 'deploying' : 'error') log(`[simulator] ${message}`) - window.setTimeout(() => { deployButton.disabled = false }, 4000) + window.setTimeout(syncDeploy, 4000) }) $('[data-clear-output]').addEventListener('click', () => { lines.length = 0; output.textContent = '' }) diff --git a/.github/extensions/badge-simulator/web/BUILD_INFO.json b/.github/extensions/badge-simulator/web/BUILD_INFO.json index 81bdad19..90057d9a 100644 --- a/.github/extensions/badge-simulator/web/BUILD_INFO.json +++ b/.github/extensions/badge-simulator/web/BUILD_INFO.json @@ -1,5 +1,5 @@ { "source": "https://github.com/badger/badger.github.io", "revision": "2da92a8a89afd551261e7ae7eff8397f7237e093", - "builtAt": "2026-10-26T06:12:23.197Z" + "builtAt": "2026-11-02T02:21:19.542Z" } diff --git a/.github/extensions/badge-simulator/web/simulator.js b/.github/extensions/badge-simulator/web/simulator.js index 3258c5bd..1eed40bc 100644 --- a/.github/extensions/badge-simulator/web/simulator.js +++ b/.github/extensions/badge-simulator/web/simulator.js @@ -1,11 +1,11 @@ // Built from badger/badger.github.io@2da92a8a89afd551261e7ae7eff8397f7237e093 by build.mjs. Do not edit. -var Dt={BASE_URL:"/"};function gf(i){return{ArrowLeft:16,ArrowRight:8,ArrowUp:2,ArrowDown:1," ":4,Enter:4,Escape:32,w:2048,a:256,s:4096,d:512,j:1024,k:8192,u:16384}[i.length===1?i.toLowerCase():i]||0}var Yr=class{constructor(e){this.changed=e}held=new Map;set(e,t,n){n?this.held.set(e,t):this.held.delete(e),this.changed([...this.held.values()].reduce((s,r)=>s|r,0))}clear(){this.held.clear(),this.changed(0)}};function Rh(i,e){let t=new Map,n=o=>{let a=o.code||o.key;if(o.type==="keyup"&&t.has(a)){e.set(`key:${a}`,t.get(a),!1),t.delete(a),o.preventDefault(),o.stopPropagation();return}let l=o.target instanceof Element?o.target:null;if(o.type!=="keydown"||o.metaKey||o.ctrlKey||o.altKey||o.isComposing||l?.closest('input, textarea, select, [contenteditable="true"], [role="textbox"]')||l?.closest("button")&&[" ","Enter"].includes(o.key))return;let c=gf(o.key);c&&(t.set(a,c),e.set(`key:${a}`,c,!0),o.preventDefault(),o.stopPropagation())},s=()=>{t.clear(),e.clear()},r=o=>{(!(o.relatedTarget instanceof Node)||!i.contains(o.relatedTarget))&&s()};return i.addEventListener("keydown",n),i.addEventListener("keyup",n),i.addEventListener("focusout",r),window.addEventListener("blur",s),()=>{s(),i.removeEventListener("keydown",n),i.removeEventListener("keyup",n),i.removeEventListener("focusout",r),window.removeEventListener("blur",s)}}function Ch(i,e,t=15e3){let n=new AbortController,s,r,o=!1,a=!1,l=0,c=1,h=!1,d=!1;function u(v=s){try{v?.dispose()}catch{}}function f(v){if(o)return;o=!0,clearTimeout(r),n.abort();let m=s;s=void 0,e(v),u(m)}function g(v){if(!(!s||o))try{v(s)}catch(m){f(m)}}return{start(){a||o||(a=!0,r=setTimeout(()=>f(new Error("The 3D view took too long to load.")),t),Promise.resolve().then(()=>i(n.signal,f)).then(async v=>{if(o){u(v),await v.ready.catch(()=>{});return}s=v,g(m=>{m.setButtons(l),m.setBacklight(c),m.setRotated?.(h),m.setDisplayRotated?.(d)}),await v.ready,o||clearTimeout(r)}).catch(f))},updateFrame(){g(v=>v.updateFrame())},setButtons(v){l=v,g(m=>m.setButtons(v))},setBacklight(v){c=v,g(m=>m.setBacklight(v))},setRotated(v){h=v,g(m=>m.setRotated?.(v))},setDisplayRotated(v){d=v,g(m=>m.setDisplayRotated?.(v))},capture(v,m){if(!s?.capture||o)throw new Error("The 3D badge is unavailable. Reload to try again.");return s.capture(v,m)},dispose(){o=!0,clearTimeout(r),n.abort();let v=s;s=void 0,u(v)}}}var Mi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Si={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},mu=0,Vl=1,gu=2;var Cr=1,_u=2,Ls=3,Bn=0,qt=1,Qt=2,kn=0,Ns=1,Hl=2,Gl=3,Wl=4,xu=5;var Hi=100,yu=101,vu=102,Mu=103,Su=104,bu=200,Tu=201,wu=202,Eu=203,Xl=204,ql=205,Au=206,Ru=207,Cu=208,Pu=209,Iu=210,Lu=211,Nu=212,Du=213,Uu=214,bo=0,To=1,wo=2,fs=3,Eo=4,Ao=5,Ro=6,Co=7,Yl=0,Fu=1,Ou=2,Tn=0,Zl=1,Kl=2,$l=3,Jl=4,jl=5,Ql=6,ec=7,Rl="attached",Bu="detached",tc=300,bi=301,Gi=302,Zo=303,Ko=304,Pr=306,gi=1e3,dn=1001,ps=1002,mt=1003,$o=1004;var Wi=1005;var gt=1006,Ds=1007;var wn=1008;var en=1009,nc=1010,ic=1011,Us=1012,Jo=1013,En=1014,ln=1015,An=1016,jo=1017,Qo=1018,Fs=1020,sc=35902,rc=35899,oc=1021,ac=1022,cn=1023,Dn=1026,Ti=1027,ea=1028,ta=1029,wi=1030,na=1031;var ia=1033,Ir=33776,Lr=33777,Nr=33778,Dr=33779,sa=35840,ra=35841,oa=35842,aa=35843,la=36196,ca=37492,ha=37496,ua=37488,da=37489,Ur=37490,fa=37491,pa=37808,ma=37809,ga=37810,_a=37811,xa=37812,ya=37813,va=37814,Ma=37815,Sa=37816,ba=37817,Ta=37818,wa=37819,Ea=37820,Aa=37821,Ra=36492,Ca=36494,Pa=36495,Ia=36283,La=36284,Fr=36285,Na=36286;var Ui=2300,Fi=2301,vo=2302,Cl=2303,Pl=2400,Il=2401,Ll=2402,ku=2500;var lc=0,Or=1,Os=2,zu=3200;var Da=0,Vu=1,si="",pt="srgb",Xt="srgb-linear",sr="linear",je="srgb";var Mo=7680;var Hu=519,Gu=512,Wu=513,Xu=514,Ua=515,qu=516,Yu=517,Fa=518,Zu=519,cc=35044;var hc="300 es",vn=2e3,ms=2001;function _f(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function xf(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function gs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ku(){let i=gs("canvas");return i.style.display="block",i}var Ph={},_s=null;function rr(...i){let e="THREE."+i.shift();_s?_s("log",e,...i):console.log(e,...i)}function $u(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ee(...i){i=$u(i);let e="THREE."+i.shift();if(_s)_s("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Le(...i){i=$u(i);let e="THREE."+i.shift();if(_s)_s("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Di(...i){let e=i.join(" ");e in Ph||(Ph[e]=!0,Ee(...i))}function Ju(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var ju={[bo]:To,[wo]:Ro,[Eo]:Co,[fs]:Ao,[To]:bo,[Ro]:wo,[Co]:Eo,[Ao]:fs},bn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ot[i>>16&255]+Ot[i>>24&255]+"-"+Ot[e&255]+Ot[e>>8&255]+"-"+Ot[e>>16&15|64]+Ot[e>>24&255]+"-"+Ot[t&63|128]+Ot[t>>8&255]+"-"+Ot[t>>16&255]+Ot[t>>24&255]+Ot[n&255]+Ot[n>>8&255]+Ot[n>>16&255]+Ot[n>>24&255]).toLowerCase()}function Ge(i,e,t){return Math.max(e,Math.min(t,i))}function uc(i,e){return(i%e+e)%e}function yf(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function vf(i,e,t){return i!==e?(t-i)/(e-i):0}function ir(i,e,t){return(1-t)*i+t*e}function Mf(i,e,t,n){return ir(i,e,1-Math.exp(-t*n))}function Sf(i,e=1){return e-Math.abs(uc(i,e*2)-e)}function bf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Tf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function wf(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Ef(i,e){return i+Math.random()*(e-i)}function Af(i){return i*(.5-Math.random())}function Rf(i){i!==void 0&&(Ih=i);let e=Ih+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Cf(i){return i*nr}function Pf(i){return i*Oi}function If(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Lf(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Nf(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Df(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),d=r((e-n)/2),u=o((e-n)/2),f=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:Ee("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function yn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function tt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Br={DEG2RAD:nr,RAD2DEG:Oi,generateUUID:Sn,clamp:Ge,euclideanModulo:uc,mapLinear:yf,inverseLerp:vf,lerp:ir,damp:Mf,pingpong:Sf,smoothstep:bf,smootherstep:Tf,randInt:wf,randFloat:Ef,randFloatSpread:Af,seededRandom:Rf,degToRad:Cf,radToDeg:Pf,isPowerOfTwo:If,ceilPowerOfTwo:Lf,floorPowerOfTwo:Nf,setQuaternionFromProperEuler:Df,normalize:tt,denormalize:yn},Ce=class i{static{i.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},kt=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],g=r[o+2],v=r[o+3];if(d!==v||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*v;m<0&&(u=-u,f=-f,g=-g,v=-v,m=-m);let p=1-a;if(m<.9995){let w=Math.acos(m),R=Math.sin(w);p=Math.sin(p*w)/R,a=Math.sin(a*w)/R,l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+v*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+v*a;let w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-a*f,e[t+2]=c*g+h*f+a*u-l*d,e[t+3]=h*g-a*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ee("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ge(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},D=class i{static{i.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Lh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Lh.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sl.copy(this).projectOnVector(e),this.sub(sl)}reflect(e){return this.sub(sl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},sl=new D,Lh=new kt,Ue=class i{static{i.prototype.isMatrix3=!0}constructor(e,t,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],v=s[0],m=s[3],p=s[6],w=s[1],R=s[4],M=s[7],S=s[2],b=s[5],A=s[8];return r[0]=o*v+a*w+l*S,r[3]=o*m+a*R+l*b,r[6]=o*p+a*M+l*A,r[1]=c*v+h*w+d*S,r[4]=c*m+h*R+d*b,r[7]=c*p+h*M+d*A,r[2]=u*v+f*w+g*S,r[5]=u*m+f*R+g*b,r[8]=u*p+f*M+g*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,g=t*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/g;return e[0]=d*v,e[1]=(s*c-h*n)*v,e[2]=(a*n-s*o)*v,e[3]=u*v,e[4]=(h*t-s*l)*v,e[5]=(s*r-a*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(o*t-n*r)*v,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return Di("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(rl.makeScale(e,t)),this}rotate(e){return Di("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(rl.makeRotation(-e)),this}translate(e,t){return Di("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(rl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},rl=new Ue,Nh=new Ue().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Dh=new Ue().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Uf(){let i={enabled:!0,workingColorSpace:Xt,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===je&&(s.r=$n(s.r),s.g=$n(s.g),s.b=$n(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===je&&(s.r=ds(s.r),s.g=ds(s.g),s.b=ds(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===si?sr:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Di("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Di("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Xt]:{primaries:e,whitePoint:n,transfer:sr,toXYZ:Nh,fromXYZ:Dh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pt},outputColorSpaceConfig:{drawingBufferColorSpace:pt}},[pt]:{primaries:e,whitePoint:n,transfer:je,toXYZ:Nh,fromXYZ:Dh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pt}}}),i}var He=Uf();function $n(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ds(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ji,Po=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ji===void 0&&(ji=gs("canvas")),ji.width=e.width,ji.height=e.height;let s=ji.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ji}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=gs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(al).x}get height(){return this.source.getSize(al).y}get depth(){return this.source.getSize(al).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ee(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ee(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==tc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gi:e.x=e.x-Math.floor(e.x);break;case dn:e.x=e.x<0?0:1;break;case ps:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case gi:e.y=e.y-Math.floor(e.y);break;case dn:e.y=e.y<0?0:1;break;case ps:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=tc;At.DEFAULT_ANISOTROPY=1;var nt=class i{static{i.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],v=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let R=(c+1)/2,M=(f+1)/2,S=(p+1)/2,b=(h+u)/4,A=(d+v)/4,x=(g+m)/4;return R>M&&R>S?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=b/n,r=A/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=x/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=x/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-g)*(m-g)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(d-v)/w,this.z=(u-h)/w,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this.w=Ge(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this.w=Ge(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Io=class extends bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:gt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new At(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nf+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Wf)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Mn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Qu={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},hi={h:0,s:0,l:0},$r={h:0,s:0,l:0};function cl(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Ie=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,He.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=He.workingColorSpace){return this.r=e,this.g=t,this.b=n,He.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=He.workingColorSpace){if(e=uc(e,1),t=Ge(t,0,1),n=Ge(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=cl(o,r,e+1/3),this.g=cl(o,r,e),this.b=cl(o,r,e-1/3)}return He.colorSpaceToWorking(this,s),this}setStyle(e,t=pt){function n(r){r!==void 0&&parseFloat(r)<1&&Ee("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ee("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);Ee("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pt){let n=Qu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ee("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=ds(e.r),this.g=ds(e.g),this.b=ds(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pt){return He.workingToColorSpace(Bt.copy(this),e),Math.round(Ge(Bt.r*255,0,255))*65536+Math.round(Ge(Bt.g*255,0,255))*256+Math.round(Ge(Bt.b*255,0,255))}getHexString(e=pt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=He.workingColorSpace){He.workingToColorSpace(Bt.copy(this),t);let n=Bt.r,s=Bt.g,r=Bt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){_n.subVectors(s,t),Xn.subVectors(n,t),hl.subVectors(e,t);let o=_n.dot(_n),a=_n.dot(Xn),l=_n.dot(hl),c=Xn.dot(Xn),h=Xn.dot(hl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,qn)===null?!1:qn.x>=0&&qn.y>=0&&qn.x+qn.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,qn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,qn.x),l.addScaledVector(o,qn.y),l.addScaledVector(a,qn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return pl.setScalar(0),ml.setScalar(0),gl.setScalar(0),pl.fromBufferAttribute(e,t),ml.fromBufferAttribute(e,n),gl.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(pl,r.x),o.addScaledVector(ml,r.y),o.addScaledVector(gl,r.z),o}static isFrontFacing(e,t,n,s){return _n.subVectors(n,t),Xn.subVectors(e,t),_n.cross(Xn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return _n.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),_n.cross(Xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;ns.subVectors(s,n),is.subVectors(r,n),ul.subVectors(e,n);let l=ns.dot(ul),c=is.dot(ul);if(l<=0&&c<=0)return t.copy(n);dl.subVectors(e,s);let h=ns.dot(dl),d=is.dot(dl);if(h>=0&&d<=h)return t.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(ns,o);fl.subVectors(e,r);let f=ns.dot(fl),g=is.dot(fl);if(g>=0&&f<=g)return t.copy(r);let v=f*c-l*g;if(v<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(is,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return Hh.subVectors(r,s),a=(d-h)/(d-h+(f-g)),t.copy(s).addScaledVector(Hh,a);let p=1/(m+v+u);return o=v*p,a=u*p,t.copy(n).addScaledVector(ns,o).addScaledVector(is,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Rt=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,xn),xn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ks),jr.subVectors(this.max,Ks),ss.subVectors(e.a,Ks),rs.subVectors(e.b,Ks),os.subVectors(e.c,Ks),ui.subVectors(rs,ss),di.subVectors(os,rs),Pi.subVectors(ss,os);let t=[0,-ui.z,ui.y,0,-di.z,di.y,0,-Pi.z,Pi.y,ui.z,0,-ui.x,di.z,0,-di.x,Pi.z,0,-Pi.x,-ui.y,ui.x,0,-di.y,di.x,0,-Pi.y,Pi.x,0];return!_l(t,ss,rs,os,jr)||(t=[1,0,0,0,1,0,0,0,1],!_l(t,ss,rs,os,jr))?!1:(Qr.crossVectors(ui,di),t=[Qr.x,Qr.y,Qr.z],_l(t,ss,rs,os,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,xn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(xn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Yn=[new D,new D,new D,new D,new D,new D,new D,new D],xn=new D,Jr=new Rt,ss=new D,rs=new D,os=new D,ui=new D,di=new D,Pi=new D,Ks=new D,jr=new D,Qr=new D,Ii=new D;function _l(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Ii.fromArray(i,r);let a=s.x*Math.abs(Ii.x)+s.y*Math.abs(Ii.y)+s.z*Math.abs(Ii.z),l=e.dot(Ii),c=t.dot(Ii),h=n.dot(Ii);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Tt=new D,eo=new Ce,Xf=0,Et=class extends bn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Xf++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=cc,this.updateRanges=[],this.gpuType=ln,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$s.subVectors(e,this.center);let t=$s.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector($s,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(xl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($s.copy(e.center).add(xl)),this.expandByPoint($s.copy(e.center).sub(xl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Yf=0,un=new De,yl=new dt,as=new D,sn=new Rt,Js=new Rt,Lt=new D,zt=class i extends bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yf++}),this.uuid=Sn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(_f(e)?cr:lr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ue().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return un.makeRotationFromQuaternion(e),this.applyMatrix4(un),this}rotateX(e){return un.makeRotationX(e),this.applyMatrix4(un),this}rotateY(e){return un.makeRotationY(e),this.applyMatrix4(un),this}rotateZ(e){return un.makeRotationZ(e),this.applyMatrix4(un),this}translate(e,t,n){return un.makeTranslation(e,t,n),this.applyMatrix4(un),this}scale(e,t,n){return un.makeScale(e,t,n),this.applyMatrix4(un),this}lookAt(e){return yl.lookAt(e),yl.updateMatrix(),this.applyMatrix4(yl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(as).negate(),this.translate(as.x,as.y,as.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;st.count&&Ee("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Rt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Le("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Kf.getNormalMatrix(e),s=this.coplanarPoint(vl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},$f=0,$t=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$f++}),this.uuid=Sn(),this.name="",this.type="Material",this.blending=Ns,this.side=Bn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xl,this.blendDst=ql,this.blendEquation=Hi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=fs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Hu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Mo,this.stencilZFail=Mo,this.stencilZPass=Mo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Ee(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ee(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new rn().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ce().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var Zn=new D,Ml=new D,to=new D,no=new D,Un=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Zn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Zn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zn.copy(this.origin).addScaledVector(this.direction,t),Zn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Ml.copy(e).add(t).multiplyScalar(.5),to.copy(t).sub(e).normalize(),no.copy(this.origin).sub(Ml);let r=e.distanceTo(t)*.5,o=-this.direction.dot(to),a=no.dot(this.direction),l=-no.dot(to),c=no.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let v=1/h;d*=v,u*=v,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Ml).addScaledVector(to,u),f}intersectSphere(e,t){if(e.radius<0)return null;Zn.subVectors(e.center,this.origin);let n=Zn.dot(this.direction),s=Zn.dot(Zn)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Zn)!==null}intersectTriangle(e,t,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=e.x-o.x,u=e.y-o.y,f=e.z-o.z,g=t.x-o.x,v=t.y-o.y,m=t.z-o.z,p=n.x-o.x,w=n.y-o.y,R=n.z-o.z,M=Math.abs(l),S=Math.abs(c),b=Math.abs(h),A,x,E,U,L,V,W,F,G,J,Z,re;if(M>=S&&M>=b?(E=l,V=d,G=g,re=p,l>=0?(A=c,x=h,U=u,L=f,W=v,F=m,J=w,Z=R):(A=h,x=c,U=f,L=u,W=m,F=v,J=R,Z=w)):S>=b?(E=c,V=u,G=v,re=w,c>=0?(A=h,x=l,U=f,L=d,W=m,F=g,J=R,Z=p):(A=l,x=h,U=d,L=f,W=g,F=m,J=p,Z=R)):(E=h,V=f,G=m,re=R,h>=0?(A=l,x=c,U=d,L=u,W=g,F=v,J=p,Z=w):(A=c,x=l,U=u,L=d,W=v,F=g,J=w,Z=p)),E===0)return null;let Y=A/E,ee=x/E,se=1/E,Ae=U-Y*V,ve=L-ee*V,Qe=W-Y*G,Be=F-ee*G,Ye=J-Y*re,$=Z-ee*re,te=Ye*Be-$*Qe,xe=Ae*$-ve*Ye,Ne=Qe*ve-Be*Ae;if(s){if(te<0||xe<0||Ne<0)return null}else if((te<0||xe<0||Ne<0)&&(te>0||xe>0||Ne>0))return null;let ge=te+xe+Ne;if(ge===0)return null;let Fe=se*(te*V+xe*G+Ne*re);return(ge>0?Fe<0:Fe>0)?null:this.at(Fe/ge,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},on=class extends $t{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jn,this.combine=Yl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Gh=new De,Li=new Un,io=new Kt,Wh=new D,so=new D,ro=new D,oo=new D,Sl=new D,ao=new D,Xh=new D,lo=new D,yt=class extends dt{constructor(e=new zt,t=new on){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(e.far-e.near)**2))&&(Gh.copy(r).invert(),Li.copy(e.ray).applyMatrix4(Gh),!(n.boundingBox!==null&&Li.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Li)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=u.length;gt.far?null:{distance:c,point:lo.clone(),object:i}}function co(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,so),i.getVertexPosition(l,ro),i.getVertexPosition(c,oo);let h=Jf(i,e,t,n,so,ro,oo,Xh);if(h){let d=new D;mi.getBarycoord(Xh,so,ro,oo,d),s&&(h.uv=mi.getInterpolatedAttribute(s,a,l,c,d,new Ce)),r&&(h.uv1=mi.getInterpolatedAttribute(r,a,l,c,d,new Ce)),o&&(h.normal=mi.getInterpolatedAttribute(o,a,l,c,d,new D),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new D,materialIndex:0};mi.getNormal(so,ro,oo,u.normal),h.face=u,h.barycoord=d}return h}var js=new nt,qh=new nt,Yh=new nt,jf=new nt,Zh=new De,ho=new D,bl=new Kt,Kh=new De,Tl=new Un,hr=class extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Rl,this.bindMatrix=new De,this.bindMatrixInverse=new De,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Rt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n0?e.max.x:e.min.x,fo.y=s.normal.y>0?e.max.y:e.min.y,fo.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fo)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var Es=class extends $t{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},No=new D,Do=new D,Qh=new De,tr=new Un,po=new Kt,wl=new D,eu=new D,Bi=class extends dt{constructor(e=new zt,t=new Es){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;wl.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(wl);if(!(ce.far))return{distance:c,point:eu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var tu=new D,nu=new D,fr=class extends Bi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var gr=class extends At{constructor(e=[],t=bi,n,s,r,o,a,l,c,h){super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ki=class extends At{constructor(e,t,n,s,r,o,a,l,c){super(e,t,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var _i=class extends At{constructor(e,t,n=En,s,r,o,a=mt,l=mt,c,h=Dn,d=1){if(h!==Dn&&h!==Ti)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new xs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Uo=class extends _i{constructor(e,t=En,n=bi,s,r,o=mt,a=mt,l,c=Dn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},_r=class extends At{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Rs=class i extends zt{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Wt(c,3)),this.setAttribute("normal",new Wt(h,3)),this.setAttribute("uv",new Wt(d,2));function g(v,m,p,w,R,M,S,b,A,x,E){let U=M/A,L=S/x,V=M/2,W=S/2,F=b/2,G=A+1,J=x+1,Z=0,re=0,Y=new D;for(let ee=0;ee0?1:-1,h.push(Y.x,Y.y,Y.z),d.push(Ae/A),d.push(1-ee/x),Z+=1}}for(let ee=0;ees|r,0))}clear(){this.held.clear(),this.changed(0)}};function Ih(i,e){let t=new Map,n=o=>{let a=o.code||o.key;if(o.type==="keyup"&&t.has(a)){e.set(`key:${a}`,t.get(a),!1),t.delete(a),o.preventDefault(),o.stopPropagation();return}let l=o.target instanceof Element?o.target:null;if(o.type!=="keydown"||o.metaKey||o.ctrlKey||o.altKey||o.isComposing||l?.closest('input, textarea, select, [contenteditable="true"], [role="textbox"]')||l?.closest("button")&&[" ","Enter"].includes(o.key))return;let c=Sf(o.key);c&&(t.set(a,c),e.set(`key:${a}`,c,!0),o.preventDefault(),o.stopPropagation())},s=()=>{t.clear(),e.clear()},r=o=>{(!(o.relatedTarget instanceof Node)||!i.contains(o.relatedTarget))&&s()};return i.addEventListener("keydown",n),i.addEventListener("keyup",n),i.addEventListener("focusout",r),window.addEventListener("blur",s),()=>{s(),i.removeEventListener("keydown",n),i.removeEventListener("keyup",n),i.removeEventListener("focusout",r),window.removeEventListener("blur",s)}}function Lh(i,e,t=15e3){let n=new AbortController,s,r,o=!1,a=!1,l=0,c=1,h=!1,d=!1;function u(v=s){try{v?.dispose()}catch{}}function f(v){if(o)return;o=!0,clearTimeout(r),n.abort();let m=s;s=void 0,e(v),u(m)}function g(v){if(!(!s||o))try{v(s)}catch(m){f(m)}}return{start(){a||o||(a=!0,r=setTimeout(()=>f(new Error("The 3D view took too long to load.")),t),Promise.resolve().then(()=>i(n.signal,f)).then(async v=>{if(o){u(v),await v.ready.catch(()=>{});return}s=v,g(m=>{m.setButtons(l),m.setBacklight(c),m.setRotated?.(h),m.setDisplayRotated?.(d)}),await v.ready,o||clearTimeout(r)}).catch(f))},updateFrame(){g(v=>v.updateFrame())},setButtons(v){l=v,g(m=>m.setButtons(v))},setBacklight(v){c=v,g(m=>m.setBacklight(v))},setRotated(v){h=v,g(m=>m.setRotated?.(v))},setDisplayRotated(v){d=v,g(m=>m.setDisplayRotated?.(v))},capture(v,m){if(!s?.capture||o)throw new Error("The 3D badge is unavailable. Reload to try again.");return s.capture(v,m)},dispose(){o=!0,clearTimeout(r),n.abort();let v=s;s=void 0,u(v)}}}var Mi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Si={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},xu=0,Vl=1,yu=2;var Cr=1,vu=2,Ls=3,Bn=0,qt=1,Qt=2,kn=0,Ns=1,Hl=2,Gl=3,Wl=4,Mu=5;var Hi=100,Su=101,bu=102,Tu=103,wu=104,Eu=200,Au=201,Ru=202,Cu=203,Xl=204,ql=205,Pu=206,Iu=207,Lu=208,Nu=209,Du=210,Uu=211,Fu=212,Ou=213,Bu=214,bo=0,To=1,wo=2,fs=3,Eo=4,Ao=5,Ro=6,Co=7,Yl=0,ku=1,zu=2,wn=0,Zl=1,Kl=2,$l=3,Jl=4,jl=5,Ql=6,ec=7,Rl="attached",Vu="detached",tc=300,bi=301,Gi=302,Zo=303,Ko=304,Pr=306,gi=1e3,fn=1001,ps=1002,mt=1003,$o=1004;var Wi=1005;var gt=1006,Ds=1007;var En=1008;var en=1009,nc=1010,ic=1011,Us=1012,Jo=1013,An=1014,cn=1015,Rn=1016,jo=1017,Qo=1018,Fs=1020,sc=35902,rc=35899,oc=1021,ac=1022,hn=1023,Dn=1026,Ti=1027,ea=1028,ta=1029,wi=1030,na=1031;var ia=1033,Ir=33776,Lr=33777,Nr=33778,Dr=33779,sa=35840,ra=35841,oa=35842,aa=35843,la=36196,ca=37492,ha=37496,ua=37488,da=37489,Ur=37490,fa=37491,pa=37808,ma=37809,ga=37810,_a=37811,xa=37812,ya=37813,va=37814,Ma=37815,Sa=37816,ba=37817,Ta=37818,wa=37819,Ea=37820,Aa=37821,Ra=36492,Ca=36494,Pa=36495,Ia=36283,La=36284,Fr=36285,Na=36286;var Ui=2300,Fi=2301,vo=2302,Cl=2303,Pl=2400,Il=2401,Ll=2402,Hu=2500;var lc=0,Or=1,Os=2,Gu=3200;var Da=0,Wu=1,si="",pt="srgb",Xt="srgb-linear",sr="linear",je="srgb";var Mo=7680;var Xu=519,qu=512,Yu=513,Zu=514,Ua=515,Ku=516,$u=517,Fa=518,Ju=519,cc=35044;var hc="300 es",Mn=2e3,ms=2001;function bf(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Tf(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function gs(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ju(){let i=gs("canvas");return i.style.display="block",i}var Nh={},_s=null;function rr(...i){let e="THREE."+i.shift();_s?_s("log",e,...i):console.log(e,...i)}function Qu(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ee(...i){i=Qu(i);let e="THREE."+i.shift();if(_s)_s("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Le(...i){i=Qu(i);let e="THREE."+i.shift();if(_s)_s("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Di(...i){let e=i.join(" ");e in Nh||(Nh[e]=!0,Ee(...i))}function ed(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var td={[bo]:To,[wo]:Ro,[Eo]:Co,[fs]:Ao,[To]:bo,[Ro]:wo,[Co]:Eo,[Ao]:fs},Tn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Ot[i>>16&255]+Ot[i>>24&255]+"-"+Ot[e&255]+Ot[e>>8&255]+"-"+Ot[e>>16&15|64]+Ot[e>>24&255]+"-"+Ot[t&63|128]+Ot[t>>8&255]+"-"+Ot[t>>16&255]+Ot[t>>24&255]+Ot[n&255]+Ot[n>>8&255]+Ot[n>>16&255]+Ot[n>>24&255]).toLowerCase()}function Ge(i,e,t){return Math.max(e,Math.min(t,i))}function uc(i,e){return(i%e+e)%e}function wf(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Ef(i,e,t){return i!==e?(t-i)/(e-i):0}function ir(i,e,t){return(1-t)*i+t*e}function Af(i,e,t,n){return ir(i,e,1-Math.exp(-t*n))}function Rf(i,e=1){return e-Math.abs(uc(i,e*2)-e)}function Cf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Pf(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function If(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Lf(i,e){return i+Math.random()*(e-i)}function Nf(i){return i*(.5-Math.random())}function Df(i){i!==void 0&&(Dh=i);let e=Dh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Uf(i){return i*nr}function Ff(i){return i*Oi}function Of(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function Bf(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function kf(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function zf(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),d=r((e-n)/2),u=o((e-n)/2),f=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*h,a*c);break;default:Ee("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function vn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:case Uint8ClampedArray:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function tt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:case Uint8ClampedArray:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}var Br={DEG2RAD:nr,RAD2DEG:Oi,generateUUID:bn,clamp:Ge,euclideanModulo:uc,mapLinear:wf,inverseLerp:Ef,lerp:ir,damp:Af,pingpong:Rf,smoothstep:Cf,smootherstep:Pf,randInt:If,randFloat:Lf,randFloatSpread:Nf,seededRandom:Df,degToRad:Uf,radToDeg:Ff,isPowerOfTwo:Of,ceilPowerOfTwo:Bf,floorPowerOfTwo:kf,setQuaternionFromProperEuler:zf,normalize:tt,denormalize:vn},Ce=class i{static{i.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},kt=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],g=r[o+2],v=r[o+3];if(d!==v||l!==u||c!==f||h!==g){let m=l*u+c*f+h*g+d*v;m<0&&(u=-u,f=-f,g=-g,v=-v,m=-m);let p=1-a;if(m<.9995){let w=Math.acos(m),R=Math.sin(w);p=Math.sin(p*w)/R,a=Math.sin(a*w)/R,l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+v*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+g*a,d=d*p+v*a;let w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+h*d+l*f-c*u,e[t+1]=l*g+h*u+c*d-a*f,e[t+2]=c*g+h*f+a*u-l*d,e[t+3]=h*g-a*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"YXZ":this._x=u*h*d+c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"ZXY":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d-u*f*g;break;case"ZYX":this._x=u*h*d-c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d+u*f*g;break;case"YZX":this._x=u*h*d+c*f*g,this._y=c*f*d+u*h*g,this._z=c*h*g-u*f*d,this._w=c*h*d-u*f*g;break;case"XZY":this._x=u*h*d-c*f*g,this._y=c*f*d-u*h*g,this._z=c*h*g+u*f*d,this._w=c*h*d+u*f*g;break;default:Ee("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(h-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ge(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},D=class i{static{i.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Uh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Uh.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sl.copy(this).projectOnVector(e),this.sub(sl)}reflect(e){return this.sub(sl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},sl=new D,Uh=new kt,Ue=class i{static{i.prototype.isMatrix3=!0}constructor(e,t,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],g=n[8],v=s[0],m=s[3],p=s[6],w=s[1],R=s[4],M=s[7],S=s[2],b=s[5],A=s[8];return r[0]=o*v+a*w+l*S,r[3]=o*m+a*R+l*b,r[6]=o*p+a*M+l*A,r[1]=c*v+h*w+d*S,r[4]=c*m+h*R+d*b,r[7]=c*p+h*M+d*A,r[2]=u*v+f*w+g*S,r[5]=u*m+f*R+g*b,r[8]=u*p+f*M+g*A,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,g=t*d+n*u+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/g;return e[0]=d*v,e[1]=(s*c-h*n)*v,e[2]=(a*n-s*o)*v,e[3]=u*v,e[4]=(h*t-s*l)*v,e[5]=(s*r-a*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(o*t-n*r)*v,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return Di("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(rl.makeScale(e,t)),this}rotate(e){return Di("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(rl.makeRotation(-e)),this}translate(e,t){return Di("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(rl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},rl=new Ue,Fh=new Ue().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Oh=new Ue().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Vf(){let i={enabled:!0,workingColorSpace:Xt,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===je&&(s.r=$n(s.r),s.g=$n(s.g),s.b=$n(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===je&&(s.r=ds(s.r),s.g=ds(s.g),s.b=ds(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===si?sr:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Di("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Di("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Xt]:{primaries:e,whitePoint:n,transfer:sr,toXYZ:Fh,fromXYZ:Oh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pt},outputColorSpaceConfig:{drawingBufferColorSpace:pt}},[pt]:{primaries:e,whitePoint:n,transfer:je,toXYZ:Fh,fromXYZ:Oh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pt}}}),i}var He=Vf();function $n(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ds(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ji,Po=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ji===void 0&&(ji=gs("canvas")),ji.width=e.width,ji.height=e.height;let s=ji.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ji}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=gs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(al).x}get height(){return this.source.getSize(al).y}get depth(){return this.source.getSize(al).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ee(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ee(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==tc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gi:e.x=e.x-Math.floor(e.x);break;case fn:e.x=e.x<0?0:1;break;case ps:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case gi:e.y=e.y-Math.floor(e.y);break;case fn:e.y=e.y<0?0:1;break;case ps:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};At.DEFAULT_IMAGE=null;At.DEFAULT_MAPPING=tc;At.DEFAULT_ANISOTROPY=1;var nt=class i{static{i.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],g=l[9],v=l[2],m=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+v)<.1&&Math.abs(g+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let R=(c+1)/2,M=(f+1)/2,S=(p+1)/2,b=(h+u)/4,A=(d+v)/4,x=(g+m)/4;return R>M&&R>S?R<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(R),s=b/n,r=A/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=x/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=x/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-g)*(m-g)+(d-v)*(d-v)+(u-h)*(u-h));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(d-v)/w,this.z=(u-h)/w,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ge(this.x,e.x,t.x),this.y=Ge(this.y,e.y,t.y),this.z=Ge(this.z,e.z,t.z),this.w=Ge(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ge(this.x,e,t),this.y=Ge(this.y,e,t),this.z=Ge(this.z,e,t),this.w=Ge(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ge(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Io=class extends Tn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:gt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new At(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nf+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent($f)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Sn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},nd={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},hi={h:0,s:0,l:0},$r={h:0,s:0,l:0};function cl(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Ie=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,He.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=He.workingColorSpace){return this.r=e,this.g=t,this.b=n,He.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=He.workingColorSpace){if(e=uc(e,1),t=Ge(t,0,1),n=Ge(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=cl(o,r,e+1/3),this.g=cl(o,r,e),this.b=cl(o,r,e-1/3)}return He.colorSpaceToWorking(this,s),this}setStyle(e,t=pt){function n(r){r!==void 0&&parseFloat(r)<1&&Ee("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ee("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);Ee("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pt){let n=nd[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ee("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=ds(e.r),this.g=ds(e.g),this.b=ds(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pt){return He.workingToColorSpace(Bt.copy(this),e),Math.round(Ge(Bt.r*255,0,255))*65536+Math.round(Ge(Bt.g*255,0,255))*256+Math.round(Ge(Bt.b*255,0,255))}getHexString(e=pt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=He.workingColorSpace){He.workingToColorSpace(Bt.copy(this),t);let n=Bt.r,s=Bt.g,r=Bt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){xn.subVectors(s,t),Xn.subVectors(n,t),hl.subVectors(e,t);let o=xn.dot(xn),a=xn.dot(Xn),l=xn.dot(hl),c=Xn.dot(Xn),h=Xn.dot(hl),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,g=(o*h-a*l)*u;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,qn)===null?!1:qn.x>=0&&qn.y>=0&&qn.x+qn.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,qn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,qn.x),l.addScaledVector(o,qn.y),l.addScaledVector(a,qn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return pl.setScalar(0),ml.setScalar(0),gl.setScalar(0),pl.fromBufferAttribute(e,t),ml.fromBufferAttribute(e,n),gl.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(pl,r.x),o.addScaledVector(ml,r.y),o.addScaledVector(gl,r.z),o}static isFrontFacing(e,t,n,s){return xn.subVectors(n,t),Xn.subVectors(e,t),xn.cross(Xn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return xn.subVectors(this.c,this.b),Xn.subVectors(this.a,this.b),xn.cross(Xn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;ns.subVectors(s,n),is.subVectors(r,n),ul.subVectors(e,n);let l=ns.dot(ul),c=is.dot(ul);if(l<=0&&c<=0)return t.copy(n);dl.subVectors(e,s);let h=ns.dot(dl),d=is.dot(dl);if(h>=0&&d<=h)return t.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(ns,o);fl.subVectors(e,r);let f=ns.dot(fl),g=is.dot(fl);if(g>=0&&f<=g)return t.copy(r);let v=f*c-l*g;if(v<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(is,a);let m=h*g-f*d;if(m<=0&&d-h>=0&&f-g>=0)return Xh.subVectors(r,s),a=(d-h)/(d-h+(f-g)),t.copy(s).addScaledVector(Xh,a);let p=1/(m+v+u);return o=v*p,a=u*p,t.copy(n).addScaledVector(ns,o).addScaledVector(is,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Rt=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,yn),yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ks),jr.subVectors(this.max,Ks),ss.subVectors(e.a,Ks),rs.subVectors(e.b,Ks),os.subVectors(e.c,Ks),ui.subVectors(rs,ss),di.subVectors(os,rs),Pi.subVectors(ss,os);let t=[0,-ui.z,ui.y,0,-di.z,di.y,0,-Pi.z,Pi.y,ui.z,0,-ui.x,di.z,0,-di.x,Pi.z,0,-Pi.x,-ui.y,ui.x,0,-di.y,di.x,0,-Pi.y,Pi.x,0];return!_l(t,ss,rs,os,jr)||(t=[1,0,0,0,1,0,0,0,1],!_l(t,ss,rs,os,jr))?!1:(Qr.crossVectors(ui,di),t=[Qr.x,Qr.y,Qr.z],_l(t,ss,rs,os,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(yn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Yn=[new D,new D,new D,new D,new D,new D,new D,new D],yn=new D,Jr=new Rt,ss=new D,rs=new D,os=new D,ui=new D,di=new D,Pi=new D,Ks=new D,jr=new D,Qr=new D,Ii=new D;function _l(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Ii.fromArray(i,r);let a=s.x*Math.abs(Ii.x)+s.y*Math.abs(Ii.y)+s.z*Math.abs(Ii.z),l=e.dot(Ii),c=t.dot(Ii),h=n.dot(Ii);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var Tt=new D,eo=new Ce,Jf=0,Et=class extends Tn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Jf++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=cc,this.updateRanges=[],this.gpuType=cn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$s.subVectors(e,this.center);let t=$s.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector($s,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(xl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($s.copy(e.center).add(xl)),this.expandByPoint($s.copy(e.center).sub(xl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},Qf=0,dn=new De,yl=new dt,as=new D,rn=new Rt,Js=new Rt,Lt=new D,zt=class i extends Tn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qf++}),this.uuid=bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(bf(e)?cr:lr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ue().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return dn.makeRotationFromQuaternion(e),this.applyMatrix4(dn),this}rotateX(e){return dn.makeRotationX(e),this.applyMatrix4(dn),this}rotateY(e){return dn.makeRotationY(e),this.applyMatrix4(dn),this}rotateZ(e){return dn.makeRotationZ(e),this.applyMatrix4(dn),this}translate(e,t,n){return dn.makeTranslation(e,t,n),this.applyMatrix4(dn),this}scale(e,t,n){return dn.makeScale(e,t,n),this.applyMatrix4(dn),this}lookAt(e){return yl.lookAt(e),yl.updateMatrix(),this.applyMatrix4(yl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(as).negate(),this.translate(as.x,as.y,as.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;st.count&&Ee("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Rt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Le("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||tp.getNormalMatrix(e),s=this.coplanarPoint(vl).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},np=0,$t=class extends Tn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:np++}),this.uuid=bn(),this.name="",this.type="Material",this.blending=Ns,this.side=Bn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xl,this.blendDst=ql,this.blendEquation=Hi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ie(0,0,0),this.blendAlpha=0,this.depthFunc=fs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Xu,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Mo,this.stencilZFail=Mo,this.stencilZPass=Mo,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Ee(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ee(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ie().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new on().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ce().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var Zn=new D,Ml=new D,to=new D,no=new D,Un=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Zn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Zn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zn.copy(this.origin).addScaledVector(this.direction,t),Zn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Ml.copy(e).add(t).multiplyScalar(.5),to.copy(t).sub(e).normalize(),no.copy(this.origin).sub(Ml);let r=e.distanceTo(t)*.5,o=-this.direction.dot(to),a=no.dot(this.direction),l=-no.dot(to),c=no.lengthSq(),h=Math.abs(1-o*o),d,u,f,g;if(h>0)if(d=o*l-a,u=o*a-l,g=r*h,d>=0)if(u>=-g)if(u<=g){let v=1/h;d*=v,u*=v,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-g?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=g?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Ml).addScaledVector(to,u),f}intersectSphere(e,t){if(e.radius<0)return null;Zn.subVectors(e.center,this.origin);let n=Zn.dot(this.direction),s=Zn.dot(Zn)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Zn)!==null}intersectTriangle(e,t,n,s,r){let o=this.origin,a=this.direction,l=a.x,c=a.y,h=a.z,d=e.x-o.x,u=e.y-o.y,f=e.z-o.z,g=t.x-o.x,v=t.y-o.y,m=t.z-o.z,p=n.x-o.x,w=n.y-o.y,R=n.z-o.z,M=Math.abs(l),S=Math.abs(c),b=Math.abs(h),A,x,E,U,L,V,W,F,G,J,Z,re;if(M>=S&&M>=b?(E=l,V=d,G=g,re=p,l>=0?(A=c,x=h,U=u,L=f,W=v,F=m,J=w,Z=R):(A=h,x=c,U=f,L=u,W=m,F=v,J=R,Z=w)):S>=b?(E=c,V=u,G=v,re=w,c>=0?(A=h,x=l,U=f,L=d,W=m,F=g,J=R,Z=p):(A=l,x=h,U=d,L=f,W=g,F=m,J=p,Z=R)):(E=h,V=f,G=m,re=R,h>=0?(A=l,x=c,U=d,L=u,W=g,F=v,J=p,Z=w):(A=c,x=l,U=u,L=d,W=v,F=g,J=w,Z=p)),E===0)return null;let Y=A/E,ee=x/E,se=1/E,Ae=U-Y*V,ve=L-ee*V,Qe=W-Y*G,Be=F-ee*G,Ye=J-Y*re,$=Z-ee*re,te=Ye*Be-$*Qe,xe=Ae*$-ve*Ye,Ne=Qe*ve-Be*Ae;if(s){if(te<0||xe<0||Ne<0)return null}else if((te<0||xe<0||Ne<0)&&(te>0||xe>0||Ne>0))return null;let ge=te+xe+Ne;if(ge===0)return null;let Fe=se*(te*V+xe*G+Ne*re);return(ge>0?Fe<0:Fe>0)?null:this.at(Fe/ge,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},an=class extends $t{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ie(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jn,this.combine=Yl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},qh=new De,Li=new Un,io=new Kt,Yh=new D,so=new D,ro=new D,oo=new D,Sl=new D,ao=new D,Zh=new D,lo=new D,yt=class extends dt{constructor(e=new zt,t=new an){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(e.far-e.near)**2))&&(qh.copy(r).invert(),Li.copy(e.ray).applyMatrix4(qh),!(n.boundingBox!==null&&Li.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Li)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,v=u.length;gt.far?null:{distance:c,point:lo.clone(),object:i}}function co(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,so),i.getVertexPosition(l,ro),i.getVertexPosition(c,oo);let h=ip(i,e,t,n,so,ro,oo,Zh);if(h){let d=new D;mi.getBarycoord(Zh,so,ro,oo,d),s&&(h.uv=mi.getInterpolatedAttribute(s,a,l,c,d,new Ce)),r&&(h.uv1=mi.getInterpolatedAttribute(r,a,l,c,d,new Ce)),o&&(h.normal=mi.getInterpolatedAttribute(o,a,l,c,d,new D),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new D,materialIndex:0};mi.getNormal(so,ro,oo,u.normal),h.face=u,h.barycoord=d}return h}var js=new nt,Kh=new nt,$h=new nt,sp=new nt,Jh=new De,ho=new D,bl=new Kt,jh=new De,Tl=new Un,hr=class extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Rl,this.bindMatrix=new De,this.bindMatrixInverse=new De,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Rt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n0?e.max.x:e.min.x,fo.y=s.normal.y>0?e.max.y:e.min.y,fo.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fo)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var Es=class extends $t{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ie(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},No=new D,Do=new D,nu=new De,tr=new Un,po=new Kt,wl=new D,iu=new D,Bi=class extends dt{constructor(e=new zt,t=new Es){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;wl.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(wl);if(!(ce.far))return{distance:c,point:iu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var su=new D,ru=new D,fr=class extends Bi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var gr=class extends At{constructor(e=[],t=bi,n,s,r,o,a,l,c,h){super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ki=class extends At{constructor(e,t,n,s,r,o,a,l,c){super(e,t,n,s,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var _i=class extends At{constructor(e,t,n=An,s,r,o,a=mt,l=mt,c,h=Dn,d=1){if(h!==Dn&&h!==Ti)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new xs(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Uo=class extends _i{constructor(e,t=An,n=bi,s,r,o=mt,a=mt,l,c=Dn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},_r=class extends At{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Rs=class i extends zt{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],h=[],d=[],u=0,f=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Wt(c,3)),this.setAttribute("normal",new Wt(h,3)),this.setAttribute("uv",new Wt(d,2));function g(v,m,p,w,R,M,S,b,A,x,E){let U=M/A,L=S/x,V=M/2,W=S/2,F=b/2,G=A+1,J=x+1,Z=0,re=0,Y=new D;for(let ee=0;ee0?1:-1,h.push(Y.x,Y.y,Y.z),d.push(Ae/A),d.push(1-ee/x),Z+=1}}for(let ee=0;ee0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Ie().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ce().fromArray(s.value);break;case"v3":this.uniforms[n].value=new D().fromArray(s.value);break;case"v4":this.uniforms[n].value=new nt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ue().fromArray(s.value);break;case"m4":this.uniforms[n].value=new De().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Fo=class extends an{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},zi=class extends $t{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Da,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Jt=class extends zi{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ce(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ge(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};var Oo=class extends $t{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=zu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Bo=class extends $t{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function pi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function So(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function rp(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function ou(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let l=0;l!==e;++l)s[o++]=i[a+l]}return s}function op(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push(...o)),r=i[s++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=i[s++];while(r!==void 0)}var Fn=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e=r)){let a=t[1];e=r)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Le("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Le("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Le("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Le("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&xf(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Le("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===vo,r=e.length-1,o=1;for(let a=1;a0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,So(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function au(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}jt.prototype.ValueTypeName="";jt.prototype.TimeBufferType=Float32Array;jt.prototype.ValueBufferType=Float32Array;jt.prototype.DefaultInterpolation=Fi;var Qn=class extends jt{constructor(e,t,n){super(e,t,n)}};Qn.prototype.ValueTypeName="bool";Qn.prototype.ValueBufferType=Array;Qn.prototype.DefaultInterpolation=Ui;Qn.prototype.InterpolantFactoryMethodLinear=void 0;Qn.prototype.InterpolantFactoryMethodSmooth=void 0;var yr=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};yr.prototype.ValueTypeName="color";var ei=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};ei.prototype.ValueTypeName="number";var Go=class extends Fn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)kt.slerpFlat(r,0,o,c-a,o,c,l);return r}},ti=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Go(this.times,this.values,this.getValueSize(),e)}};ti.prototype.ValueTypeName="quaternion";ti.prototype.InterpolantFactoryMethodSmooth=void 0;var ni=class extends jt{constructor(e,t,n){super(e,t,n)}};ni.prototype.ValueTypeName="string";ni.prototype.ValueBufferType=Array;ni.prototype.DefaultInterpolation=Ui;ni.prototype.InterpolantFactoryMethodLinear=void 0;ni.prototype.InterpolantFactoryMethodSmooth=void 0;var xi=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};xi.prototype.ValueTypeName="vector";var vr=class{constructor(e="",t=-1,n=[],s=ku){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Sn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(hp(n[o]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,o=n.length;r!==o;++r)t.push(jt.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,o=[];for(let a=0;a1){let d=h[1],u=s[d];u||(s[d]=u=[]),u.push(c)}}let o=[];for(let a in s)o.push(this.CreateFromMorphTargetSequence(a,s[a],t,n));return o}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(r),this.manager.itemEnd(e)},0);return}if(Kn[e]!==void 0){Kn[e].push({onLoad:t,onProgress:n,onError:s});return}Kn[e]=[],Kn[e].push({onLoad:t,onProgress:n,onError:s});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ee("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Kn[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,g=f!==0,v=0,m=new ReadableStream({start(p){w();function w(){d.read().then(({done:R,value:M})=>{if(R)p.close();else{v+=M.byteLength;let S=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let b=0,A=h.length;b{p.error(R)})}}});return new Response(m)}else throw new Dl(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Nn.add(`file:${e}`,c);let h=Kn[e];delete Kn[e];for(let d=0,u=h.length;d{let h=Kn[e];if(h===void 0)throw this.manager.itemError(e),c;delete Kn[e];for(let d=0,u=h.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var cs=new WeakMap,Xo=class extends On{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Nn.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);else{let d=cs.get(o);d===void 0&&(d=[],cs.set(o,d)),d.push({onLoad:t,onError:s})}return o}let a=gs("img");function l(){h(),t&&t(this);let d=cs.get(this)||[];for(let u=0;u"u"&&Ee("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ee("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Nn.get(`image-bitmap:${e}`);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{Al.has(o)===!0?(s&&s(Al.get(o)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(c),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Nn.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),Al.set(l,c),Nn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Nn.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var hs=-90,us=1,qo=class extends dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new wt(hs,us,e,t);s.layers=this.layers,this.add(s);let r=new wt(hs,us,e,t);r.layers=this.layers,this.add(r);let o=new wt(hs,us,e,t);o.layers=this.layers,this.add(o);let a=new wt(hs,us,e,t);a.layers=this.layers,this.add(a);let l=new wt(hs,us,e,t);l.layers=this.layers,this.add(l);let c=new wt(hs,us,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===vn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ms)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Yo=class extends wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var fc="\\[\\]\\.:\\/",up=new RegExp("["+fc+"]","g"),pc="[^"+fc+"]",dp="[^"+fc.replace("\\.","")+"]",fp=/((?:WC+[\/:])*)/.source.replace("WC",pc),pp=/(WCOD+)?/.source.replace("WCOD",dp),mp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pc),gp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pc),_p=new RegExp("^"+fp+pp+mp+gp+"$"),xp=["material","materials","bones","map"],Bl=class{constructor(e,t,n){let s=n||at.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},at=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(up,"")}static parseTrackName(e){let t=_p.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);xp.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;of.start-g.start);let u=0;for(let f=1;f0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Ie().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ce().fromArray(s.value);break;case"v3":this.uniforms[n].value=new D().fromArray(s.value);break;case"v4":this.uniforms[n].value=new nt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ue().fromArray(s.value);break;case"m4":this.uniforms[n].value=new De().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Fo=class extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},zi=class extends $t{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ie(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ie(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Da,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Jn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Jt=class extends zi{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ce(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ge(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ie(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ie(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ie(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};var Oo=class extends $t{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Gu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Bo=class extends $t{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function pi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function So(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function up(i){function e(s,r){return i[s]-i[r]}let t=i.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function cu(i,e,t){let n=i.length,s=new i.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let l=0;l!==e;++l)s[o++]=i[a+l]}return s}function dp(i,e,t,n){let s=1,r=i[0];for(;r!==void 0&&r[n]===void 0;)r=i[s++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push(...o)),r=i[s++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=i[s++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=i[s++];while(r!==void 0)}var Fn=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e=r)){let a=t[1];e=r)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Le("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Le("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Le("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Le("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&Tf(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Le("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===vo,r=e.length-1,o=1;for(let a=1;a0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,So(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function hu(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}jt.prototype.ValueTypeName="";jt.prototype.TimeBufferType=Float32Array;jt.prototype.ValueBufferType=Float32Array;jt.prototype.DefaultInterpolation=Fi;var Qn=class extends jt{constructor(e,t,n){super(e,t,n)}};Qn.prototype.ValueTypeName="bool";Qn.prototype.ValueBufferType=Array;Qn.prototype.DefaultInterpolation=Ui;Qn.prototype.InterpolantFactoryMethodLinear=void 0;Qn.prototype.InterpolantFactoryMethodSmooth=void 0;var yr=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};yr.prototype.ValueTypeName="color";var ei=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};ei.prototype.ValueTypeName="number";var Go=class extends Fn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)kt.slerpFlat(r,0,o,c-a,o,c,l);return r}},ti=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new Go(this.times,this.values,this.getValueSize(),e)}};ti.prototype.ValueTypeName="quaternion";ti.prototype.InterpolantFactoryMethodSmooth=void 0;var ni=class extends jt{constructor(e,t,n){super(e,t,n)}};ni.prototype.ValueTypeName="string";ni.prototype.ValueBufferType=Array;ni.prototype.DefaultInterpolation=Ui;ni.prototype.InterpolantFactoryMethodLinear=void 0;ni.prototype.InterpolantFactoryMethodSmooth=void 0;var xi=class extends jt{constructor(e,t,n,s){super(e,t,n,s)}};xi.prototype.ValueTypeName="vector";var vr=class{constructor(e="",t=-1,n=[],s=Hu){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=bn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,s=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(gp(n[o]).scale(s));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,o=n.length;r!==o;++r)t.push(jt.toJSON(n[r]));return s}static CreateFromMorphTargetSequence(e,t,n,s){let r=t.length,o=[];for(let a=0;a1){let d=h[1],u=s[d];u||(s[d]=u=[]),u.push(c)}}let o=[];for(let a in s)o.push(this.CreateFromMorphTargetSequence(a,s[a],t,n));return o}resetDuration(){let e=this.tracks,t=0;for(let n=0,s=e.length;n!==s;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(r),this.manager.itemEnd(e)},0);return}if(Kn[e]!==void 0){Kn[e].push({onLoad:t,onProgress:n,onError:s});return}Kn[e]=[],Kn[e].push({onLoad:t,onProgress:n,onError:s});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ee("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let h=Kn[e],d=c.body.getReader(),u=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=u?parseInt(u):0,g=f!==0,v=0,m=new ReadableStream({start(p){w();function w(){d.read().then(({done:R,value:M})=>{if(R)p.close();else{v+=M.byteLength;let S=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let b=0,A=h.length;b{p.error(R)})}}});return new Response(m)}else throw new Dl(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return c.json();default:if(a==="")return c.text();{let d=/charset="?([^;"\s]*)"?/i.exec(a),u=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(u);return c.arrayBuffer().then(g=>f.decode(g))}}}).then(c=>{Nn.add(`file:${e}`,c);let h=Kn[e];delete Kn[e];for(let d=0,u=h.length;d{let h=Kn[e];if(h===void 0)throw this.manager.itemError(e),c;delete Kn[e];for(let d=0,u=h.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var cs=new WeakMap,Xo=class extends On{constructor(e){super(e)}load(e,t,n,s){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Nn.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);else{let d=cs.get(o);d===void 0&&(d=[],cs.set(o,d)),d.push({onLoad:t,onError:s})}return o}let a=gs("img");function l(){h(),t&&t(this);let d=cs.get(this)||[];for(let u=0;u"u"&&Ee("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ee("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Nn.get(`image-bitmap:${e}`);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{Al.has(o)===!0?(s&&s(Al.get(o)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(c),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0);return}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Nn.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){s&&s(c),Al.set(l,c),Nn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Nn.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var hs=-90,us=1,qo=class extends dt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new wt(hs,us,e,t);s.layers=this.layers,this.add(s);let r=new wt(hs,us,e,t);r.layers=this.layers,this.add(r);let o=new wt(hs,us,e,t);o.layers=this.layers,this.add(o);let a=new wt(hs,us,e,t);a.layers=this.layers,this.add(a);let l=new wt(hs,us,e,t);l.layers=this.layers,this.add(l);let c=new wt(hs,us,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===Mn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ms)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Yo=class extends wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}};var fc="\\[\\]\\.:\\/",_p=new RegExp("["+fc+"]","g"),pc="[^"+fc+"]",xp="[^"+fc.replace("\\.","")+"]",yp=/((?:WC+[\/:])*)/.source.replace("WC",pc),vp=/(WCOD+)?/.source.replace("WCOD",xp),Mp=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pc),Sp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pc),bp=new RegExp("^"+yp+vp+Mp+Sp+"$"),Tp=["material","materials","bones","map"],Bl=class{constructor(e,t,n){let s=n||at.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},at=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_p,"")}static parseTrackName(e){let t=bp.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Tp.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;of.start-g.start);let u=0;for(let f=1;f 0 +#endif`,Gp=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; @@ -255,20 +255,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve if ( clipped ) discard; #endif #endif -#endif`,Bp=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Wp=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,kp=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Xp=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,zp=`#if NUM_CLIPPING_PLANES > 0 +#endif`,qp=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,Vp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,Yp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,Hp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,Zp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,Gp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,Kp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,Wp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,$p=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA @@ -281,7 +281,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); -#endif`,Xp=`#define PI 3.141592653589793 +#endif`,Jp=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -352,7 +352,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,qp=`#ifdef ENVMAP_TYPE_CUBE_UV +} // validated`,jp=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { @@ -445,7 +445,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { return vec4( mix( color0, color1, mipF ), 1.0 ); } } -#endif`,Yp=`vec3 transformedNormal = objectNormal; +#endif`,Qp=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -471,21 +471,21 @@ transformedNormal = normalMatrix * transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; -#endif`,Zp=`#ifdef USE_DISPLACEMENTMAP +#endif`,em=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,Kp=`#ifdef USE_DISPLACEMENTMAP +#endif`,tm=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,$p=`#ifdef USE_EMISSIVEMAP +#endif`,nm=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Jp=`#ifdef USE_EMISSIVEMAP +#endif`,im=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,jp="gl_FragColor = linearToOutputTexel( gl_FragColor );",Qp=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,sm="gl_FragColor = linearToOutputTexel( gl_FragColor );",rm=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { @@ -493,7 +493,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) { } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,em=`#ifdef USE_ENVMAP +}`,om=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -520,7 +520,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif -#endif`,tm=`#ifdef USE_ENVMAP +#endif`,am=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE @@ -528,7 +528,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else uniform sampler2D envMap; #endif -#endif`,nm=`#ifdef USE_ENVMAP +#endif`,lm=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -539,7 +539,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,im=`#ifdef USE_ENVMAP +#endif`,cm=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -550,7 +550,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,sm=`#ifdef USE_ENVMAP +#endif`,hm=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -567,18 +567,18 @@ vec4 sRGBTransferOETF( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,rm=`#ifdef USE_FOG +#endif`,um=`#ifdef USE_FOG vFogDepth = - mvPosition.z; -#endif`,om=`#ifdef USE_FOG +#endif`,dm=`#ifdef USE_FOG varying float vFogDepth; -#endif`,am=`#ifdef USE_FOG +#endif`,fm=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,lm=`#ifdef USE_FOG +#endif`,pm=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -587,7 +587,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,cm=`#ifdef USE_GRADIENTMAP +#endif`,mm=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -599,12 +599,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,hm=`#ifdef USE_LIGHTMAP +}`,gm=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,um=`LambertMaterial material; +#endif`,_m=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,dm=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,xm=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -618,7 +618,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,fm=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ym=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -747,7 +747,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi return irradiance; } #endif -#include `,pm=`#ifdef USE_ENVMAP +#include `,vm=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); @@ -804,8 +804,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi } #endif #endif -#endif`,mm=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,gm=`varying vec3 vViewPosition; +#endif`,Mm=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Sm=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -817,11 +817,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,_m=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,bm=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,xm=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,Tm=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -838,7 +838,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ym=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,wm=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; @@ -931,7 +931,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,vm=`uniform sampler2D dfgLUT; +#endif`,Em=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; @@ -1298,7 +1298,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,Mm=` +}`,Am=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1446,7 +1446,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,Sm=`#if defined( RE_IndirectDiffuse ) +#endif`,Rm=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1476,7 +1476,7 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,bm=`#if defined( RE_IndirectDiffuse ) +#endif`,Cm=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif @@ -1484,7 +1484,7 @@ IncidentLight directLight; #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,Tm=`#ifdef USE_LIGHT_PROBES_GRID +#endif`,Pm=`#ifdef USE_LIGHT_PROBES_GRID uniform highp sampler3D probesSH; uniform vec3 probesMin; uniform vec3 probesMax; @@ -1529,27 +1529,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } -#endif`,wm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,Im=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,Em=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,Lm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,Am=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,Nm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,Rm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,Dm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,Cm=`#ifdef USE_MAP +#endif`,Um=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,Pm=`#ifdef USE_MAP +#endif`,Fm=`#ifdef USE_MAP uniform sampler2D map; -#endif`,Im=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,Om=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1561,7 +1561,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,Lm=`#if defined( USE_POINTS_UV ) +#endif`,Bm=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1573,19 +1573,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,Nm=`float metalnessFactor = metalness; +#endif`,km=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,Dm=`#ifdef USE_METALNESSMAP +#endif`,zm=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,Um=`#ifdef USE_INSTANCING_MORPH +#endif`,Vm=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } -#endif`,Fm=`#if defined( USE_MORPHCOLORS ) +#endif`,Hm=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) @@ -1594,12 +1594,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,Om=`#ifdef USE_MORPHNORMALS +#endif`,Gm=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } -#endif`,Bm=`#ifdef USE_MORPHTARGETS +#endif`,Wm=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1613,12 +1613,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } -#endif`,km=`#ifdef USE_MORPHTARGETS +#endif`,Xm=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } -#endif`,zm=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,qm=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1659,7 +1659,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,Vm=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,Ym=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1677,19 +1677,19 @@ vec3 nonPerturbedNormal = normal;`,Vm=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,Hm=`#ifndef FLAT_SHADED +#endif`,Zm=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,Gm=`#ifndef FLAT_SHADED +#endif`,Km=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif -#endif`,Wm=`#ifndef FLAT_SHADED +#endif`,$m=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1698,7 +1698,7 @@ vec3 nonPerturbedNormal = normal;`,Vm=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,Xm=`#ifdef USE_NORMALMAP +#endif`,Jm=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1720,13 +1720,13 @@ vec3 nonPerturbedNormal = normal;`,Vm=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,qm=`#ifdef USE_CLEARCOAT +#endif`,jm=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,Ym=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,Qm=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,Zm=`#ifdef USE_CLEARCOATMAP +#endif`,eg=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1735,18 +1735,18 @@ vec3 nonPerturbedNormal = normal;`,Vm=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,Km=`#ifdef USE_IRIDESCENCEMAP +#endif`,tg=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,$m=`#ifdef OPAQUE +#endif`,ng=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Jm=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ig=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1825,9 +1825,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif -}`,jm=`#ifdef PREMULTIPLIED_ALPHA +}`,sg=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,Qm=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,rg=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1835,22 +1835,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,og=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,tg=`#ifdef DITHERING +#endif`,ag=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,ng=`float roughnessFactor = roughness; +#endif`,lg=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,ig=`#ifdef USE_ROUGHNESSMAP +#endif`,cg=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,sg=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,hg=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -2101,7 +2101,7 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING } #endif #endif -#endif`,rg=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,ug=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -2146,7 +2146,7 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,og=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,dg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2186,7 +2186,7 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,ag=`float getShadowMask() { +#endif`,fg=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2227,12 +2227,12 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING #endif #endif return shadow; -}`,lg=`#ifdef USE_SKINNING +}`,pg=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,cg=`#ifdef USE_SKINNING +#endif`,mg=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2247,7 +2247,7 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,hg=`#ifdef USE_SKINNING +#endif`,gg=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2255,7 +2255,7 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,ug=`#ifdef USE_SKINNING +#endif`,_g=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2266,17 +2266,17 @@ gl_Position = projectionMatrix * mvPosition;`,eg=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,dg=`float specularStrength; +#endif`,xg=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,fg=`#ifdef USE_SPECULARMAP +#endif`,yg=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,pg=`#if defined( TONE_MAPPING ) +#endif`,vg=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,mg=`#ifndef saturate +#endif`,Mg=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2373,7 +2373,7 @@ vec3 NeutralToneMapping( vec3 color ) { float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,Sg=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2394,7 +2394,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,_g=`#ifdef USE_TRANSMISSION +#endif`,bg=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2520,7 +2520,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,xg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Tg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2590,7 +2590,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,yg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,wg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2684,7 +2684,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,vg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,Eg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2755,7 +2755,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,Mg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,Ag=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2764,12 +2764,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,gg=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,Sg=`varying vec2 vUv; +#endif`,Rg=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,bg=`uniform sampler2D t2D; +}`,Cg=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2781,14 +2781,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,Tg=`varying vec3 vWorldDirection; +}`,Pg=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,wg=`#ifdef ENVMAP_TYPE_CUBE +}`,Ig=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; @@ -2810,14 +2810,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,Eg=`varying vec3 vWorldDirection; +}`,Lg=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,Ag=`uniform samplerCube tCube; +}`,Ng=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2827,7 +2827,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,Rg=`#include +}`,Dg=`#include #include #include #include @@ -2854,7 +2854,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,Cg=`#if DEPTH_PACKING == 3200 +}`,Ug=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2892,7 +2892,7 @@ void main() { #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif -}`,Pg=`#define DISTANCE +}`,Fg=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2919,7 +2919,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,Ig=`#define DISTANCE +}`,Og=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2942,13 +2942,13 @@ void main() { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); -}`,Lg=`varying vec3 vWorldDirection; +}`,Bg=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,Ng=`uniform sampler2D tEquirect; +}`,kg=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2957,7 +2957,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,Dg=`uniform float scale; +}`,zg=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2979,7 +2979,7 @@ void main() { #include #include #include -}`,Ug=`uniform vec3 diffuse; +}`,Vg=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3007,7 +3007,7 @@ void main() { #include #include #include -}`,Fg=`#include +}`,Hg=`#include #include #include #include @@ -3039,7 +3039,7 @@ void main() { #include #include #include -}`,Og=`uniform vec3 diffuse; +}`,Gg=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3087,7 +3087,7 @@ void main() { #include #include #include -}`,Bg=`#define LAMBERT +}`,Wg=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3126,7 +3126,7 @@ void main() { #include #include #include -}`,kg=`#define LAMBERT +}`,Xg=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3184,7 +3184,7 @@ void main() { #include #include #include -}`,zg=`#define MATCAP +}`,qg=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3218,7 +3218,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,Vg=`#define MATCAP +}`,Yg=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3264,7 +3264,7 @@ void main() { #include #include #include -}`,Hg=`#define NORMAL +}`,Zg=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -3297,7 +3297,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,Gg=`#define NORMAL +}`,Kg=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -3318,7 +3318,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,Wg=`#define PHONG +}`,$g=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3357,7 +3357,7 @@ void main() { #include #include #include -}`,Xg=`#define PHONG +}`,Jg=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3417,7 +3417,7 @@ void main() { #include #include #include -}`,qg=`#define STANDARD +}`,jg=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3460,7 +3460,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,Yg=`#define STANDARD +}`,Qg=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3588,7 +3588,7 @@ void main() { #include #include #include -}`,Zg=`#define TOON +}`,e_=`#define TOON varying vec3 vViewPosition; #include #include @@ -3625,7 +3625,7 @@ void main() { #include #include #include -}`,Kg=`#define TOON +}`,t_=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3677,7 +3677,7 @@ void main() { #include #include #include -}`,$g=`uniform float size; +}`,n_=`uniform float size; uniform float scale; #include #include @@ -3708,7 +3708,7 @@ void main() { #include #include #include -}`,Jg=`uniform vec3 diffuse; +}`,i_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3733,7 +3733,7 @@ void main() { #include #include #include -}`,jg=`#include +}`,s_=`#include #include #include #include @@ -3756,7 +3756,7 @@ void main() { #include #include #include -}`,Qg=`uniform vec3 color; +}`,r_=`uniform vec3 color; uniform float opacity; #include #include @@ -3772,7 +3772,7 @@ void main() { #include #include #include -}`,e_=`uniform float rotation; +}`,o_=`uniform float rotation; uniform vec2 center; #include #include @@ -3796,7 +3796,7 @@ void main() { #include #include #include -}`,t_=`uniform vec3 diffuse; +}`,a_=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3821,7 +3821,7 @@ void main() { #include #include #include -}`,ze={alphahash_fragment:Sp,alphahash_pars_fragment:bp,alphamap_fragment:Tp,alphamap_pars_fragment:wp,alphatest_fragment:Ep,alphatest_pars_fragment:Ap,aomap_fragment:Rp,aomap_pars_fragment:Cp,batching_pars_vertex:Pp,batching_vertex:Ip,begin_vertex:Lp,beginnormal_vertex:Np,bsdfs:Dp,iridescence_fragment:Up,bumpmap_pars_fragment:Fp,clipping_planes_fragment:Op,clipping_planes_pars_fragment:Bp,clipping_planes_pars_vertex:kp,clipping_planes_vertex:zp,color_fragment:Vp,color_pars_fragment:Hp,color_pars_vertex:Gp,color_vertex:Wp,common:Xp,cube_uv_reflection_fragment:qp,defaultnormal_vertex:Yp,displacementmap_pars_vertex:Zp,displacementmap_vertex:Kp,emissivemap_fragment:$p,emissivemap_pars_fragment:Jp,colorspace_fragment:jp,colorspace_pars_fragment:Qp,envmap_fragment:em,envmap_common_pars_fragment:tm,envmap_pars_fragment:nm,envmap_pars_vertex:im,envmap_physical_pars_fragment:pm,envmap_vertex:sm,fog_vertex:rm,fog_pars_vertex:om,fog_fragment:am,fog_pars_fragment:lm,gradientmap_pars_fragment:cm,lightmap_pars_fragment:hm,lights_lambert_fragment:um,lights_lambert_pars_fragment:dm,lights_pars_begin:fm,lights_toon_fragment:mm,lights_toon_pars_fragment:gm,lights_phong_fragment:_m,lights_phong_pars_fragment:xm,lights_physical_fragment:ym,lights_physical_pars_fragment:vm,lights_fragment_begin:Mm,lights_fragment_maps:Sm,lights_fragment_end:bm,lightprobes_pars_fragment:Tm,logdepthbuf_fragment:wm,logdepthbuf_pars_fragment:Em,logdepthbuf_pars_vertex:Am,logdepthbuf_vertex:Rm,map_fragment:Cm,map_pars_fragment:Pm,map_particle_fragment:Im,map_particle_pars_fragment:Lm,metalnessmap_fragment:Nm,metalnessmap_pars_fragment:Dm,morphinstance_vertex:Um,morphcolor_vertex:Fm,morphnormal_vertex:Om,morphtarget_pars_vertex:Bm,morphtarget_vertex:km,normal_fragment_begin:zm,normal_fragment_maps:Vm,normal_pars_fragment:Hm,normal_pars_vertex:Gm,normal_vertex:Wm,normalmap_pars_fragment:Xm,clearcoat_normal_fragment_begin:qm,clearcoat_normal_fragment_maps:Ym,clearcoat_pars_fragment:Zm,iridescence_pars_fragment:Km,opaque_fragment:$m,packing:Jm,premultiplied_alpha_fragment:jm,project_vertex:Qm,dithering_fragment:eg,dithering_pars_fragment:tg,roughnessmap_fragment:ng,roughnessmap_pars_fragment:ig,shadowmap_pars_fragment:sg,shadowmap_pars_vertex:rg,shadowmap_vertex:og,shadowmask_pars_fragment:ag,skinbase_vertex:lg,skinning_pars_vertex:cg,skinning_vertex:hg,skinnormal_vertex:ug,specularmap_fragment:dg,specularmap_pars_fragment:fg,tonemapping_fragment:pg,tonemapping_pars_fragment:mg,transmission_fragment:gg,transmission_pars_fragment:_g,uv_pars_fragment:xg,uv_pars_vertex:yg,uv_vertex:vg,worldpos_vertex:Mg,background_vert:Sg,background_frag:bg,backgroundCube_vert:Tg,backgroundCube_frag:wg,cube_vert:Eg,cube_frag:Ag,depth_vert:Rg,depth_frag:Cg,distance_vert:Pg,distance_frag:Ig,equirect_vert:Lg,equirect_frag:Ng,linedashed_vert:Dg,linedashed_frag:Ug,meshbasic_vert:Fg,meshbasic_frag:Og,meshlambert_vert:Bg,meshlambert_frag:kg,meshmatcap_vert:zg,meshmatcap_frag:Vg,meshnormal_vert:Hg,meshnormal_frag:Gg,meshphong_vert:Wg,meshphong_frag:Xg,meshphysical_vert:qg,meshphysical_frag:Yg,meshtoon_vert:Zg,meshtoon_frag:Kg,points_vert:$g,points_frag:Jg,shadow_vert:jg,shadow_frag:Qg,sprite_vert:e_,sprite_frag:t_},ue={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ue}},envmap:{envMap:{value:null},envMapRotation:{value:new Ue},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ue}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ue}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ue},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ue},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ue},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ue}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ue}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ue}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0},uvTransform:{value:new Ue}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}}},Vn={basic:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},envMapIntensity:{value:1}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Vt([ue.common,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.roughnessmap,ue.metalnessmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Vt([ue.common,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.gradientmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Vt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Vt([ue.points,ue.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Vt([ue.common,ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Vt([ue.common,ue.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Vt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Vt([ue.sprite,ue.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ue},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ue}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distance:{uniforms:Vt([ue.common,ue.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distance_vert,fragmentShader:ze.distance_frag},shadow:{uniforms:Vt([ue.lights,ue.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};Vn.physical={uniforms:Vt([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ue},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ue},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ue},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ue},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ue},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ue},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ue},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ue},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ue},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ue},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ue},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ue}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};var Oa={r:0,b:0,g:0},n_=new De,wd=new Ue;wd.set(-1,0,0,0,1,0,0,0,1);function i_(i,e,t,n,s,r){let o=new Ie(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(w){let R=w.isScene===!0?w.background:null;if(R&&R.isTexture){let M=w.backgroundBlurriness>0;R=e.get(R,M)}return R}function g(w){let R=!1,M=f(w);M===null?m(o,a):M&&M.isColor&&(m(M,1),R=!0);let S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function v(w,R){let M=f(R);M&&(M.isCubeTexture||M.mapping===Pr)?(c===void 0&&(c=new yt(new Rs(1,1,1),new an({name:"BackgroundCubeMaterial",uniforms:Xi(Vn.backgroundCube.uniforms),vertexShader:Vn.backgroundCube.vertexShader,fragmentShader:Vn.backgroundCube.fragmentShader,side:qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,b,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(n_.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(wd),c.material.toneMapped=He.getTransfer(M.colorSpace)!==je,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new yt(new xr(2,2),new an({name:"BackgroundMaterial",uniforms:Xi(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:Bn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.toneMapped=He.getTransfer(M.colorSpace)!==je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null))}function m(w,R){w.getRGB(Oa,dc(i)),t.buffers.color.setClear(Oa.r,Oa.g,Oa.b,R,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,R=1){o.set(w),a=R,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(w){a=w,m(o,a)},render:g,addToRenderList:v,dispose:p}}function s_(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(L,V,W,F,G){let J=!1,Z=d(L,F,W,V);r!==Z&&(r=Z,c(r.object)),J=f(L,F,W,G),J&&g(L,F,W,G),G!==null&&e.update(G,i.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,M(L,V,W,F),G!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(G).buffer))}function l(){return i.createVertexArray()}function c(L){return i.bindVertexArray(L)}function h(L){return i.deleteVertexArray(L)}function d(L,V,W,F){let G=F.wireframe===!0,J=n[V.id];J===void 0&&(J={},n[V.id]=J);let Z=L.isInstancedMesh===!0?L.id:0,re=J[Z];re===void 0&&(re={},J[Z]=re);let Y=re[W.id];Y===void 0&&(Y={},re[W.id]=Y);let ee=Y[G];return ee===void 0&&(ee=u(l()),Y[G]=ee),ee}function u(L){let V=[],W=[],F=[];for(let G=0;G=0){let se=G[Y],Ae=J[Y];if(Ae===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(Ae=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(Ae=L.instanceColor)),se===void 0||se.attribute!==Ae||Ae&&se.data!==Ae.data)return!0;Z++}return r.attributesNum!==Z||r.index!==F}function g(L,V,W,F){let G={},J=V.attributes,Z=0,re=W.getAttributes();for(let Y in re)if(re[Y].location>=0){let se=J[Y];se===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(se=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(se=L.instanceColor));let Ae={};Ae.attribute=se,se&&se.data&&(Ae.data=se.data),G[Y]=Ae,Z++}r.attributes=G,r.attributesNum=Z,r.index=F}function v(){let L=r.newAttributes;for(let V=0,W=L.length;V=0){let ee=G[re];if(ee===void 0&&(re==="instanceMatrix"&&L.instanceMatrix&&(ee=L.instanceMatrix),re==="instanceColor"&&L.instanceColor&&(ee=L.instanceColor)),ee!==void 0){let se=ee.normalized,Ae=ee.itemSize,ve=e.get(ee);if(ve===void 0)continue;let Qe=ve.buffer,Be=ve.type,Ye=ve.bytesPerElement,$=Be===i.INT||Be===i.UNSIGNED_INT||ee.gpuType===Jo;if(ee.isInterleavedBufferAttribute){let te=ee.data,xe=te.stride,Ne=ee.offset;if(te.isInstancedInterleavedBuffer){for(let ge=0;ge0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(Ee("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Ee("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:w,maxVaryings:R,maxFragmentUniforms:M,maxSamples:S,samples:b}}function a_(i){let e=this,t=null,n=0,s=!1,r=!1,o=new rn,a=new Ue,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let w=r?0:n,R=w*4,M=p.clippingState||null;l.value=M,M=h(g,u,R,f);for(let S=0;S!==R;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){let v=d!==null?d.length:0,m=null;if(v!==0){if(m=l.value,g!==!0||m===null){let p=f+v*4,w=u.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=od(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=rd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?S:0,S,S),d.setRenderTarget(s),p&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=w}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===bi||e.mapping===Gi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=od()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=rd());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;Bs(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,kr)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-ks?n-g+ks:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Bs(r,m,p,3*v,2*v),s.setRenderTarget(r),s.render(a,kr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Bs(e,m,p,3*v,2*v),s.setRenderTarget(e),s.render(a,kr)}_blur(e,t,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,o),this._blurPass(r,e,n,n,o)}_blurPass(e,t,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-ks?s-this._lodMax+ks:0),u=4*(this._cubeSize-h);Bs(t,d,u,3*h,2*h),o.setRenderTarget(t),o.render(l,kr)}};function d_(i){let e=[],t=[],n=i,s=i-ks+1+l_;for(let r=0;r2?0:-1,M=[w,R,0,w+2/3,R,0,w+2/3,R+1,0,w,R,0,w+2/3,R+1,0,w,R+1,0];g.set(M,f*u*p);for(let S=0;Sks&&n--}return{lodMeshes:t,sizeLods:e}}function sd(i,e,t){let n=new Zt(i,e,t);return n.texture.mapping=Pr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Bs(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function f_(i,e,t){return new an({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:h_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ha(),fragmentShader:` +}`,ze={alphahash_fragment:Rp,alphahash_pars_fragment:Cp,alphamap_fragment:Pp,alphamap_pars_fragment:Ip,alphatest_fragment:Lp,alphatest_pars_fragment:Np,aomap_fragment:Dp,aomap_pars_fragment:Up,batching_pars_vertex:Fp,batching_vertex:Op,begin_vertex:Bp,beginnormal_vertex:kp,bsdfs:zp,iridescence_fragment:Vp,bumpmap_pars_fragment:Hp,clipping_planes_fragment:Gp,clipping_planes_pars_fragment:Wp,clipping_planes_pars_vertex:Xp,clipping_planes_vertex:qp,color_fragment:Yp,color_pars_fragment:Zp,color_pars_vertex:Kp,color_vertex:$p,common:Jp,cube_uv_reflection_fragment:jp,defaultnormal_vertex:Qp,displacementmap_pars_vertex:em,displacementmap_vertex:tm,emissivemap_fragment:nm,emissivemap_pars_fragment:im,colorspace_fragment:sm,colorspace_pars_fragment:rm,envmap_fragment:om,envmap_common_pars_fragment:am,envmap_pars_fragment:lm,envmap_pars_vertex:cm,envmap_physical_pars_fragment:vm,envmap_vertex:hm,fog_vertex:um,fog_pars_vertex:dm,fog_fragment:fm,fog_pars_fragment:pm,gradientmap_pars_fragment:mm,lightmap_pars_fragment:gm,lights_lambert_fragment:_m,lights_lambert_pars_fragment:xm,lights_pars_begin:ym,lights_toon_fragment:Mm,lights_toon_pars_fragment:Sm,lights_phong_fragment:bm,lights_phong_pars_fragment:Tm,lights_physical_fragment:wm,lights_physical_pars_fragment:Em,lights_fragment_begin:Am,lights_fragment_maps:Rm,lights_fragment_end:Cm,lightprobes_pars_fragment:Pm,logdepthbuf_fragment:Im,logdepthbuf_pars_fragment:Lm,logdepthbuf_pars_vertex:Nm,logdepthbuf_vertex:Dm,map_fragment:Um,map_pars_fragment:Fm,map_particle_fragment:Om,map_particle_pars_fragment:Bm,metalnessmap_fragment:km,metalnessmap_pars_fragment:zm,morphinstance_vertex:Vm,morphcolor_vertex:Hm,morphnormal_vertex:Gm,morphtarget_pars_vertex:Wm,morphtarget_vertex:Xm,normal_fragment_begin:qm,normal_fragment_maps:Ym,normal_pars_fragment:Zm,normal_pars_vertex:Km,normal_vertex:$m,normalmap_pars_fragment:Jm,clearcoat_normal_fragment_begin:jm,clearcoat_normal_fragment_maps:Qm,clearcoat_pars_fragment:eg,iridescence_pars_fragment:tg,opaque_fragment:ng,packing:ig,premultiplied_alpha_fragment:sg,project_vertex:rg,dithering_fragment:og,dithering_pars_fragment:ag,roughnessmap_fragment:lg,roughnessmap_pars_fragment:cg,shadowmap_pars_fragment:hg,shadowmap_pars_vertex:ug,shadowmap_vertex:dg,shadowmask_pars_fragment:fg,skinbase_vertex:pg,skinning_pars_vertex:mg,skinning_vertex:gg,skinnormal_vertex:_g,specularmap_fragment:xg,specularmap_pars_fragment:yg,tonemapping_fragment:vg,tonemapping_pars_fragment:Mg,transmission_fragment:Sg,transmission_pars_fragment:bg,uv_pars_fragment:Tg,uv_pars_vertex:wg,uv_vertex:Eg,worldpos_vertex:Ag,background_vert:Rg,background_frag:Cg,backgroundCube_vert:Pg,backgroundCube_frag:Ig,cube_vert:Lg,cube_frag:Ng,depth_vert:Dg,depth_frag:Ug,distance_vert:Fg,distance_frag:Og,equirect_vert:Bg,equirect_frag:kg,linedashed_vert:zg,linedashed_frag:Vg,meshbasic_vert:Hg,meshbasic_frag:Gg,meshlambert_vert:Wg,meshlambert_frag:Xg,meshmatcap_vert:qg,meshmatcap_frag:Yg,meshnormal_vert:Zg,meshnormal_frag:Kg,meshphong_vert:$g,meshphong_frag:Jg,meshphysical_vert:jg,meshphysical_frag:Qg,meshtoon_vert:e_,meshtoon_frag:t_,points_vert:n_,points_frag:i_,shadow_vert:s_,shadow_frag:r_,sprite_vert:o_,sprite_frag:a_},ue={common:{diffuse:{value:new Ie(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ue}},envmap:{envMap:{value:null},envMapRotation:{value:new Ue},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ue}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ue}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ue},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ue},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ue},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ue}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ue}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ue}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ie(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new Ie(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0},uvTransform:{value:new Ue}},sprite:{diffuse:{value:new Ie(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}}},Vn={basic:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},envMapIntensity:{value:1}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:Vt([ue.common,ue.specularmap,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},specular:{value:new Ie(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:Vt([ue.common,ue.envmap,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.roughnessmap,ue.metalnessmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:Vt([ue.common,ue.aomap,ue.lightmap,ue.emissivemap,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.gradientmap,ue.fog,ue.lights,{emissive:{value:new Ie(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:Vt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,ue.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:Vt([ue.points,ue.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:Vt([ue.common,ue.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:Vt([ue.common,ue.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:Vt([ue.common,ue.bumpmap,ue.normalmap,ue.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:Vt([ue.sprite,ue.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new Ue},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ue}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distance:{uniforms:Vt([ue.common,ue.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distance_vert,fragmentShader:ze.distance_frag},shadow:{uniforms:Vt([ue.lights,ue.fog,{color:{value:new Ie(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};Vn.physical={uniforms:Vt([Vn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ue},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ue},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ue},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ue},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ue},sheen:{value:0},sheenColor:{value:new Ie(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ue},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ue},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ue},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ue},attenuationDistance:{value:0},attenuationColor:{value:new Ie(0)},specularColor:{value:new Ie(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ue},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ue},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ue}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};var Oa={r:0,b:0,g:0},l_=new De,Rd=new Ue;Rd.set(-1,0,0,0,1,0,0,0,1);function c_(i,e,t,n,s,r){let o=new Ie(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(w){let R=w.isScene===!0?w.background:null;if(R&&R.isTexture){let M=w.backgroundBlurriness>0;R=e.get(R,M)}return R}function g(w){let R=!1,M=f(w);M===null?m(o,a):M&&M.isColor&&(m(M,1),R=!0);let S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||R)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function v(w,R){let M=f(R);M&&(M.isCubeTexture||M.mapping===Pr)?(c===void 0&&(c=new yt(new Rs(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:Xi(Vn.backgroundCube.uniforms),vertexShader:Vn.backgroundCube.vertexShader,fragmentShader:Vn.backgroundCube.fragmentShader,side:qt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,b,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=R.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(l_.makeRotationFromEuler(R.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Rd),c.material.toneMapped=He.getTransfer(M.colorSpace)!==je,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new yt(new xr(2,2),new ln({name:"BackgroundMaterial",uniforms:Xi(Vn.background.uniforms),vertexShader:Vn.background.vertexShader,fragmentShader:Vn.background.fragmentShader,side:Bn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=R.backgroundIntensity,l.material.toneMapped=He.getTransfer(M.colorSpace)!==je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null))}function m(w,R){w.getRGB(Oa,dc(i)),t.buffers.color.setClear(Oa.r,Oa.g,Oa.b,R,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,R=1){o.set(w),a=R,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(w){a=w,m(o,a)},render:g,addToRenderList:v,dispose:p}}function h_(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(L,V,W,F,G){let J=!1,Z=d(L,F,W,V);r!==Z&&(r=Z,c(r.object)),J=f(L,F,W,G),J&&g(L,F,W,G),G!==null&&e.update(G,i.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,M(L,V,W,F),G!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(G).buffer))}function l(){return i.createVertexArray()}function c(L){return i.bindVertexArray(L)}function h(L){return i.deleteVertexArray(L)}function d(L,V,W,F){let G=F.wireframe===!0,J=n[V.id];J===void 0&&(J={},n[V.id]=J);let Z=L.isInstancedMesh===!0?L.id:0,re=J[Z];re===void 0&&(re={},J[Z]=re);let Y=re[W.id];Y===void 0&&(Y={},re[W.id]=Y);let ee=Y[G];return ee===void 0&&(ee=u(l()),Y[G]=ee),ee}function u(L){let V=[],W=[],F=[];for(let G=0;G=0){let se=G[Y],Ae=J[Y];if(Ae===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(Ae=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(Ae=L.instanceColor)),se===void 0||se.attribute!==Ae||Ae&&se.data!==Ae.data)return!0;Z++}return r.attributesNum!==Z||r.index!==F}function g(L,V,W,F){let G={},J=V.attributes,Z=0,re=W.getAttributes();for(let Y in re)if(re[Y].location>=0){let se=J[Y];se===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(se=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(se=L.instanceColor));let Ae={};Ae.attribute=se,se&&se.data&&(Ae.data=se.data),G[Y]=Ae,Z++}r.attributes=G,r.attributesNum=Z,r.index=F}function v(){let L=r.newAttributes;for(let V=0,W=L.length;V=0){let ee=G[re];if(ee===void 0&&(re==="instanceMatrix"&&L.instanceMatrix&&(ee=L.instanceMatrix),re==="instanceColor"&&L.instanceColor&&(ee=L.instanceColor)),ee!==void 0){let se=ee.normalized,Ae=ee.itemSize,ve=e.get(ee);if(ve===void 0)continue;let Qe=ve.buffer,Be=ve.type,Ye=ve.bytesPerElement,$=Be===i.INT||Be===i.UNSIGNED_INT||ee.gpuType===Jo;if(ee.isInterleavedBufferAttribute){let te=ee.data,xe=te.stride,Ne=ee.offset;if(te.isInstancedInterleavedBuffer){for(let ge=0;ge0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(Ee("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Ee("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:w,maxVaryings:R,maxFragmentUniforms:M,maxSamples:S,samples:b}}function f_(i){let e=this,t=null,n=0,s=!1,r=!1,o=new on,a=new Ue,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,f){let g=d.clippingPlanes,v=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{let w=r?0:n,R=w*4,M=p.clippingState||null;l.value=M,M=h(g,u,R,f);for(let S=0;S!==R;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,f,g){let v=d!==null?d.length:0,m=null;if(v!==0){if(m=l.value,g!==!0||m===null){let p=f+v*4,w=u.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=cd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ld(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?S:0,S,S),d.setRenderTarget(s),p&&d.render(v,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=w}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===bi||e.mapping===Gi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=cd()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ld());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;Bs(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,kr)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rg-ks?n-g+ks:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Bs(r,m,p,3*v,2*v),s.setRenderTarget(r),s.render(a,kr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Bs(e,m,p,3*v,2*v),s.setRenderTarget(e),s.render(a,kr)}_blur(e,t,n,s){let r=this._pingPongRenderTarget,o=Math.min(s,Math.PI)/Math.SQRT2;this._blurPass(e,r,t,n,o),this._blurPass(r,e,n,n,o)}_blurPass(e,t,n,s,r){let o=this._renderer,a=this._blurMaterial,l=this._lodMeshes[s];l.material=a;let c=a.uniforms;c.envMap.value=e.texture,c.sigma.value=r,c.mipInt.value=this._lodMax-n;let h=this._sizeLods[s],d=3*h*(s>this._lodMax-ks?s-this._lodMax+ks:0),u=4*(this._cubeSize-h);Bs(t,d,u,3*h,2*h),o.setRenderTarget(t),o.render(l,kr)}};function x_(i){let e=[],t=[],n=i,s=i-ks+1+p_;for(let r=0;r2?0:-1,M=[w,R,0,w+2/3,R,0,w+2/3,R+1,0,w,R,0,w+2/3,R+1,0,w,R+1,0];g.set(M,f*u*p);for(let S=0;Sks&&n--}return{lodMeshes:t,sizeLods:e}}function ad(i,e,t){let n=new Zt(i,e,t);return n.texture.mapping=Pr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Bs(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function y_(i,e,t){return new ln({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:g_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ha(),fragmentShader:` precision highp float; precision highp int; @@ -3925,7 +3925,7 @@ void main() { gl_FragColor = vec4(prefilteredColor, 1.0); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function p_(i,e,t){return new an({name:"SphericalGaussianBlur",defines:{SAMPLES:c_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ha(),fragmentShader:` + `,blending:kn,depthTest:!1,depthWrite:!1})}function v_(i,e,t){return new ln({name:"SphericalGaussianBlur",defines:{SAMPLES:m_,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},sigma:{value:0},mipInt:{value:0}},vertexShader:Ha(),fragmentShader:` precision highp float; precision highp int; @@ -3985,7 +3985,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function rd(){return new an({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ha(),fragmentShader:` + `,blending:kn,depthTest:!1,depthWrite:!1})}function ld(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ha(),fragmentShader:` precision mediump float; precision mediump int; @@ -4004,7 +4004,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:kn,depthTest:!1,depthWrite:!1})}function od(){return new an({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ha(),fragmentShader:` + `,blending:kn,depthTest:!1,depthWrite:!1})}function cd(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ha(),fragmentShader:` precision mediump float; precision mediump int; @@ -4070,7 +4070,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},s=new Rs(5,5,5),r=new an({name:"CubemapFromEquirect",uniforms:Xi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:qt,blending:kn});r.uniforms.tEquirect.value=t;let o=new yt(s,r),a=t.minFilter;return t.minFilter===wn&&(t.minFilter=gt),new qo(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}};function m_(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,f=!1){return u==null?null:f?o(u):r(u)}function r(u){if(u&&u.isTexture){let f=u.mapping;if(f===Zo||f===Ko)if(e.has(u)){let g=e.get(u).texture;return a(g,u.mapping)}else{let g=u.image;if(g&&g.height>0){let v=new za(g.height);return v.fromEquirectangularTexture(i,u),e.set(u,v),u.addEventListener("dispose",c),a(v.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,g=f===Zo||f===Ko,v=f===bi||f===Gi;if(g||v){let m=t.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new ka(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{let w=u.image;return g&&w&&w.height>0||v&&w&&l(w)?(n===null&&(n=new ka(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===Zo?u.mapping=bi:f===Ko&&(u.mapping=Gi),u}function l(u){let f=0,g=6;for(let v=0;v=65535?cr:lr)(u,1);m.version=v;let p=r.get(d);p&&e.remove(p),r.set(d,m)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versione.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let b=new Float32Array(M*S*4*d),A=new or(b,M,S,d);A.type=ln,A.needsUpdate=!0;let x=R*4;for(let U=0;U0){let v=new za(g.height);return v.fromEquirectangularTexture(i,u),e.set(u,v),u.addEventListener("dispose",c),a(v.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,g=f===Zo||f===Ko,v=f===bi||f===Gi;if(g||v){let m=t.get(u),p=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new ka(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{let w=u.image;return g&&w&&w.height>0||v&&w&&l(w)?(n===null&&(n=new ka(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,f){return f===Zo?u.mapping=bi:f===Ko&&(u.mapping=Gi),u}function l(u){let f=0,g=6;for(let v=0;v=65535?cr:lr)(u,1);m.version=v;let p=r.get(d);p&&e.remove(p),r.set(d,m)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versione.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let b=new Float32Array(M*S*4*d),A=new or(b,M,S,d);A.type=cn,A.needsUpdate=!0;let x=R*4;for(let U=0;U0&&w[0].isRenderPass===!0;let S=o.width,b=o.height;w.length>0&&a===null&&(a=new Zt(S,b,{type:An,depthBuffer:!1,stencilBuffer:!1}),l=new Zt(S,b,{type:An,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=e*t,r=ad[s];if(r===void 0&&(r=new Float32Array(s),ad[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Ct(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function fd(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var u0=37297,d0=0;function f0(i,e){let t=i.split(` + }`,depthTest:!1,depthWrite:!1}),d=new yt(c,h),u=new yi(-1,1,1,-1,0,1),f=null,g=null,v=!1,m,p=null,w=[],R=!1;this.setSize=function(M,S){o.setSize(M,S),a!==null&&a.setSize(M,S),l!==null&&l.setSize(M,S);for(let b=0;b0&&w[0].isRenderPass===!0;let S=o.width,b=o.height;w.length>0&&a===null&&(a=new Zt(S,b,{type:Rn,depthBuffer:!1,stencilBuffer:!1}),l=new Zt(S,b,{type:Rn,depthBuffer:!1,stencilBuffer:!1}));for(let A=0;A0)return i;let s=e*t,r=hd[s];if(r===void 0&&(r=new Float32Array(s),hd[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Ct(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function gd(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var _0=37297,x0=0;function y0(i,e){let t=i.split(` `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o":" "} ${a}: ${t[o]}`)}return n.join(` -`)}var pd=new Ue;function p0(i){He._getMatrix(pd,He.workingColorSpace,i);let e=`mat3( ${pd.elements.map(t=>t.toFixed(4))} )`;switch(He.getTransfer(i)){case sr:return[e,"LinearTransferOETF"];case je:return[e,"sRGBTransferOETF"];default:return Ee("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function md(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` +`)}var _d=new Ue;function v0(i){He._getMatrix(_d,He.workingColorSpace,i);let e=`mat3( ${_d.elements.map(t=>t.toFixed(4))} )`;switch(He.getTransfer(i)){case sr:return[e,"LinearTransferOETF"];case je:return[e,"sRGBTransferOETF"];default:return Ee("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function xd(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` `+r+` -`+f0(i.getShaderSource(e),a)}else return r}function m0(i,e){let t=p0(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` -`)}var g0={[Zl]:"Linear",[Kl]:"Reinhard",[$l]:"Cineon",[Jl]:"ACESFilmic",[Ql]:"AgX",[ec]:"Neutral",[jl]:"Custom"};function _0(i,e){let t=g0[e];return t===void 0?(Ee("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Ba=new D;function x0(){He.getLuminanceCoefficients(Ba);let i=Ba.x.toFixed(4),e=Ba.y.toFixed(4),t=Ba.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` -`)}function y0(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Vr).join(` -`)}function v0(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function M0(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Ec(i){return i.replace(S0,T0)}var b0=new Map;function T0(i,e){let t=ze[e];if(t===void 0){let n=b0.get(e);if(n!==void 0)t=ze[n],Ee('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ec(t)}var w0=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function xd(i){return i.replace(w0,E0)}function E0(i,e,t,n){let s="";for(let r=parseInt(e);r/gm;function Ec(i){return i.replace(R0,P0)}var C0=new Map;function P0(i,e){let t=ze[e];if(t===void 0){let n=C0.get(e);if(n!==void 0)t=ze[n],Ee('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ec(t)}var I0=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Md(i){return i.replace(I0,L0)}function L0(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(m+=` `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Vr).join(` `),p.length>0&&(p+=` -`)):(m=[yd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`)):(m=[Sd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Vr).join(` -`),p=[yd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Tn?"#define TONE_MAPPING":"",t.toneMapping!==Tn?ze.tonemapping_pars_fragment:"",t.toneMapping!==Tn?_0("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,m0("linearToOutputTexel",t.outputColorSpace),x0(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`),p=[Sd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==wn?"#define TONE_MAPPING":"",t.toneMapping!==wn?ze.tonemapping_pars_fragment:"",t.toneMapping!==wn?b0("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,M0("linearToOutputTexel",t.outputColorSpace),T0(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Vr).join(` -`)),o=Ec(o),o=gd(o,t),o=_d(o,t),a=Ec(a),a=gd(a,t),a=_d(a,t),o=xd(o),a=xd(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es +`)),o=Ec(o),o=yd(o,t),o=vd(o,t),a=Ec(a),a=yd(a,t),a=vd(a,t),o=Md(o),a=Md(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+m,p=["#define varying in",t.glslVersion===hc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===hc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` -`+p);let R=w+m+o,M=w+p+a,S=fd(s,s.VERTEX_SHADER,R),b=fd(s,s.FRAGMENT_SHADER,M);s.attachShader(v,S),s.attachShader(v,b),t.index0AttributeName!==void 0?s.bindAttribLocation(v,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v);function A(L){if(i.debug.checkShaderErrors){let V=s.getProgramInfoLog(v)||"",W=s.getShaderInfoLog(S)||"",F=s.getShaderInfoLog(b)||"",G=V.trim(),J=W.trim(),Z=F.trim(),re=!0,Y=!0;if(s.getProgramParameter(v,s.LINK_STATUS)===!1)if(re=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,v,S,b);else{let ee=md(s,S,"vertex"),se=md(s,b,"fragment");Le("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+` +`+p);let R=w+m+o,M=w+p+a,S=gd(s,s.VERTEX_SHADER,R),b=gd(s,s.FRAGMENT_SHADER,M);s.attachShader(v,S),s.attachShader(v,b),t.index0AttributeName!==void 0?s.bindAttribLocation(v,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v);function A(L){if(i.debug.checkShaderErrors){let V=s.getProgramInfoLog(v)||"",W=s.getShaderInfoLog(S)||"",F=s.getShaderInfoLog(b)||"",G=V.trim(),J=W.trim(),Z=F.trim(),re=!0,Y=!0;if(s.getProgramParameter(v,s.LINK_STATUS)===!1)if(re=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,v,S,b);else{let ee=xd(s,S,"vertex"),se=xd(s,b,"fragment");Le("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+` Material Name: `+L.name+` Material Type: `+L.type+` Program Info Log: `+G+` `+ee+` -`+se)}else G!==""?Ee("WebGLProgram: Program Info Log:",G):(J===""||Z==="")&&(Y=!1);Y&&(L.diagnostics={runnable:re,programLog:G,vertexShader:{log:J,prefix:m},fragmentShader:{log:Z,prefix:p}})}s.deleteShader(S),s.deleteShader(b),x=new zs(s,v),E=M0(s,v)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=s.getProgramParameter(v,u0)),U},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=d0++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}var O0=0,Ac=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Rc(e),t.set(e,n)),n}},Rc=class{constructor(e){this.id=O0++,this.code=e,this.usedTimes=0}};function B0(i){return i===wi||i===Ur||i===Fr}function k0(i,e,t,n,s,r){let o=new ys,a=new Ac,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,E,U,L,V,W){let F=L.fog,G=V.geometry,J=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?L.environment:null,Z=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,re=e.get(x.envMap||J,Z),Y=re&&re.mapping===Pr?re.image.height:null,ee=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ee("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let se=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Ae=se!==void 0?se.length:0,ve=0;G.morphAttributes.position!==void 0&&(ve=1),G.morphAttributes.normal!==void 0&&(ve=2),G.morphAttributes.color!==void 0&&(ve=3);let Qe,Be,Ye,$;if(ee){let ct=Vn[ee];Qe=ct.vertexShader,Be=ct.fragmentShader}else{Qe=x.vertexShader,Be=x.fragmentShader;let ct=a.getVertexShaderStage(x),$e=a.getFragmentShaderStage(x);a.update(x,ct,$e),Ye=ct.id,$=$e.id}let te=i.getRenderTarget(),xe=i.state.buffers.depth.getReversed(),Ne=V.isInstancedMesh===!0,ge=V.isBatchedMesh===!0,Fe=!!x.map,_t=!!x.matcap,Oe=!!re,qe=!!x.aoMap,et=!!x.lightMap,Ve=!!x.bumpMap&&x.wireframe===!1,rt=!!x.normalMap,Mt=!!x.displacementMap,Ut=!!x.emissiveMap,lt=!!x.metalnessMap,ft=!!x.roughnessMap,N=x.anisotropy>0,St=x.clearcoat>0,Ke=x.dispersion>0,T=x.retroreflectivity>0,_=x.iridescence>0,B=x.sheen>0,H=x.transmission>0,K=N&&!!x.anisotropyMap,ae=St&&!!x.clearcoatMap,ce=St&&!!x.clearcoatNormalMap,C=St&&!!x.clearcoatRoughnessMap,O=_&&!!x.iridescenceMap,q=_&&!!x.iridescenceThicknessMap,ne=B&&!!x.sheenColorMap,Q=B&&!!x.sheenRoughnessMap,ie=!!x.specularMap,de=!!x.specularColorMap,_e=!!x.specularIntensityMap,Pe=H&&!!x.transmissionMap,P=H&&!!x.thicknessMap,le=!!x.gradientMap,j=!!x.alphaMap,he=x.alphaTest>0,me=!!x.alphaHash,oe=!!x.extensions,Re=Tn;x.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Re=i.toneMapping);let Te={shaderID:ee,shaderType:x.type,shaderName:x.name,vertexShader:Qe,fragmentShader:Be,defines:x.defines,customVertexShaderID:Ye,customFragmentShaderID:$,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ge,batchingColor:ge&&V._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&V.instanceColor!==null,instancingMorph:Ne&&V.morphTexture!==null,outputColorSpace:te===null?i.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:He.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Fe,matcap:_t,envMap:Oe,envMapMode:Oe&&re.mapping,envMapCubeUVHeight:Y,aoMap:qe,lightMap:et,bumpMap:Ve,normalMap:rt,displacementMap:Mt,emissiveMap:Ut,normalMapObjectSpace:rt&&x.normalMapType===Vu,normalMapTangentSpace:rt&&x.normalMapType===Da,packedNormalMap:rt&&x.normalMapType===Da&&B0(x.normalMap.format),metalnessMap:lt,roughnessMap:ft,anisotropy:N,anisotropyMap:K,clearcoat:St,clearcoatMap:ae,clearcoatNormalMap:ce,clearcoatRoughnessMap:C,dispersion:Ke,retroreflection:T,iridescence:_,iridescenceMap:O,iridescenceThicknessMap:q,sheen:B,sheenColorMap:ne,sheenRoughnessMap:Q,specularMap:ie,specularColorMap:de,specularIntensityMap:_e,transmission:H,transmissionMap:Pe,thicknessMap:P,gradientMap:le,opaque:x.transparent===!1&&x.blending===Ns&&x.alphaToCoverage===!1,alphaMap:j,alphaTest:he,alphaHash:me,combine:x.combine,mapUv:Fe&&g(x.map.channel),aoMapUv:qe&&g(x.aoMap.channel),lightMapUv:et&&g(x.lightMap.channel),bumpMapUv:Ve&&g(x.bumpMap.channel),normalMapUv:rt&&g(x.normalMap.channel),displacementMapUv:Mt&&g(x.displacementMap.channel),emissiveMapUv:Ut&&g(x.emissiveMap.channel),metalnessMapUv:lt&&g(x.metalnessMap.channel),roughnessMapUv:ft&&g(x.roughnessMap.channel),anisotropyMapUv:K&&g(x.anisotropyMap.channel),clearcoatMapUv:ae&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:ce&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:C&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:O&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:q&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:ne&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:Q&&g(x.sheenRoughnessMap.channel),specularMapUv:ie&&g(x.specularMap.channel),specularColorMapUv:de&&g(x.specularColorMap.channel),specularIntensityMapUv:_e&&g(x.specularIntensityMap.channel),transmissionMapUv:Pe&&g(x.transmissionMap.channel),thicknessMapUv:P&&g(x.thicknessMap.channel),alphaMapUv:j&&g(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(rt||N),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!G.attributes.uv&&(Fe||j),fog:!!F,useFog:x.fog===!0,fogExp2:!!F&&F.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&rt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:V.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Ae,morphTextureStride:ve,numSunLights:E.sun.length,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numSunLightShadows:E.sunShadowMap.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:Re,decodeVideoTexture:Fe&&x.map.isVideoTexture===!0&&He.getTransfer(x.map.colorSpace)===je,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&He.getTransfer(x.emissiveMap.colorSpace)===je,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Qt,flipSided:x.side===qt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:oe&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(oe&&x.extensions.multiDraw===!0||ge)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function m(x){let E=[];if(x.shaderID?E.push(x.shaderID):(E.push(x.customVertexShaderID),E.push(x.customFragmentShaderID)),x.defines!==void 0)for(let U in x.defines)E.push(U),E.push(x.defines[U]);return x.isRawShaderMaterial===!1&&(p(E,x),w(E,x),E.push(i.outputColorSpace)),E.push(x.customProgramCacheKey),E.join()}function p(x,E){x.push(E.precision),x.push(E.outputColorSpace),x.push(E.envMapMode),x.push(E.envMapCubeUVHeight),x.push(E.mapUv),x.push(E.alphaMapUv),x.push(E.lightMapUv),x.push(E.aoMapUv),x.push(E.bumpMapUv),x.push(E.normalMapUv),x.push(E.displacementMapUv),x.push(E.emissiveMapUv),x.push(E.metalnessMapUv),x.push(E.roughnessMapUv),x.push(E.anisotropyMapUv),x.push(E.clearcoatMapUv),x.push(E.clearcoatNormalMapUv),x.push(E.clearcoatRoughnessMapUv),x.push(E.iridescenceMapUv),x.push(E.iridescenceThicknessMapUv),x.push(E.sheenColorMapUv),x.push(E.sheenRoughnessMapUv),x.push(E.specularMapUv),x.push(E.specularColorMapUv),x.push(E.specularIntensityMapUv),x.push(E.transmissionMapUv),x.push(E.thicknessMapUv),x.push(E.combine),x.push(E.fogExp2),x.push(E.sizeAttenuation),x.push(E.morphTargetsCount),x.push(E.morphAttributeCount),x.push(E.numSunLights),x.push(E.numDirLights),x.push(E.numPointLights),x.push(E.numSpotLights),x.push(E.numSpotLightMaps),x.push(E.numHemiLights),x.push(E.numRectAreaLights),x.push(E.numSunLightShadows),x.push(E.numDirLightShadows),x.push(E.numPointLightShadows),x.push(E.numSpotLightShadows),x.push(E.numSpotLightShadowsWithMaps),x.push(E.numLightProbes),x.push(E.shadowMapType),x.push(E.toneMapping),x.push(E.numClippingPlanes),x.push(E.numClipIntersection),x.push(E.depthPacking)}function w(x,E){o.disableAll(),E.instancing&&o.enable(0),E.instancingColor&&o.enable(1),E.instancingMorph&&o.enable(2),E.matcap&&o.enable(3),E.envMap&&o.enable(4),E.normalMapObjectSpace&&o.enable(5),E.normalMapTangentSpace&&o.enable(6),E.clearcoat&&o.enable(7),E.iridescence&&o.enable(8),E.alphaTest&&o.enable(9),E.vertexColors&&o.enable(10),E.vertexAlphas&&o.enable(11),E.vertexUv1s&&o.enable(12),E.vertexUv2s&&o.enable(13),E.vertexUv3s&&o.enable(14),E.vertexTangents&&o.enable(15),E.anisotropy&&o.enable(16),E.alphaHash&&o.enable(17),E.batching&&o.enable(18),E.dispersion&&o.enable(19),E.retroreflection&&o.enable(24),E.batchingColor&&o.enable(20),E.gradientMap&&o.enable(21),E.packedNormalMap&&o.enable(22),E.vertexNormals&&o.enable(23),x.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.reversedDepthBuffer&&o.enable(4),E.skinning&&o.enable(5),E.morphTargets&&o.enable(6),E.morphNormals&&o.enable(7),E.morphColors&&o.enable(8),E.premultipliedAlpha&&o.enable(9),E.shadowMapEnabled&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.transmission&&o.enable(15),E.sheen&&o.enable(16),E.opaque&&o.enable(17),E.pointsUvs&&o.enable(18),E.decodeVideoTexture&&o.enable(19),E.decodeVideoTextureEmissive&&o.enable(20),E.alphaToCoverage&&o.enable(21),E.numLightProbeGrids>0&&o.enable(22),E.hasPositionAttribute&&o.enable(23),x.push(o.mask)}function R(x){let E=f[x.type],U;if(E){let L=Vn[E];U=ed.clone(L.uniforms)}else U=x.uniforms;return U}function M(x,E){let U=h.get(E);return U!==void 0?++U.usedTimes:(U=new F0(i,E,x,s),c.push(U),h.set(E,U)),U}function S(x){if(--x.usedTimes===0){let E=c.indexOf(x);c[E]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){a.remove(x)}function A(){a.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:R,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:c,dispose:A}}function z0(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function V0(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function vd(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Md(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,g,v,m,p){let w=i[e];return w===void 0?(w={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:v,renderOrder:u.renderOrder,z:m,group:p},i[e]=w):(w.id=u.id,w.object=u,w.geometry=f,w.material=g,w.materialVariant=o(u),w.groupOrder=v,w.renderOrder=u.renderOrder,w.z=m,w.group=p),e++,w}function l(u,f,g,v,m,p,w){w.reversedDepth===!0&&(m=-m);let R=a(u,f,g,v,m,p);g.transmission>0?n.push(R):g.transparent===!0?s.push(R):t.push(R)}function c(u,f,g,v,m,p){let w=a(u,f,g,v,m,p);g.transmission>0?n.unshift(w):g.transparent===!0?s.unshift(w):t.unshift(w)}function h(u,f){t.length>1&&t.sort(u||V0),n.length>1&&n.sort(f||vd),s.length>1&&s.sort(f||vd)}function d(){for(let u=e,f=i.length;u=r.length?(o=new Md,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function G0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new D,color:new Ie};break;case"SpotLight":t={position:new D,direction:new D,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function W0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var X0=0;function q0(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Y0(i){let e=new G0,t=W0(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new D);let s=new D,r=new De,o=new De;function a(c){let h=0,d=0,u=0;for(let V=0;V<9;V++)n.probe[V].set(0,0,0);let f=0,g=0,v=0,m=0,p=0,w=0,R=0,M=0,S=0,b=0,A=0,x=0,E=0,U=0;c.sort(q0);for(let V=0,W=c.length;V0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ue.LTC_FLOAT_1,n.rectAreaLTC2=ue.LTC_FLOAT_2):(n.rectAreaLTC1=ue.LTC_HALF_1,n.rectAreaLTC2=ue.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let L=n.hash;(L.sunLength!==f||L.directionalLength!==m||L.pointLength!==p||L.spotLength!==w||L.rectAreaLength!==R||L.hemiLength!==M||L.numSunShadows!==g||L.numDirectionalShadows!==S||L.numPointShadows!==b||L.numSpotShadows!==A||L.numSpotMaps!==x||L.numLightProbes!==U)&&(n.sun.length=f,n.directional.length=m,n.spot.length=w,n.rectArea.length=R,n.point.length=p,n.hemi.length=M,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=v,n.sunShadowCascade.length=v,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.directionalShadowMatrix.length=S,n.pointShadow.length=b,n.pointShadowMap.length=b,n.pointShadowMatrix.length=b,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-E,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=U,L.sunLength=f,L.directionalLength=m,L.pointLength=p,L.spotLength=w,L.rectAreaLength=R,L.hemiLength=M,L.numSunShadows=g,L.numDirectionalShadows=S,L.numPointShadows=b,L.numSpotShadows=A,L.numSpotMaps=x,L.numLightProbes=U,n.version=X0++)}function l(c,h){let d=0,u=0,f=0,g=0,v=0,m=0,p=h.matrixWorldInverse;for(let w=0,R=c.length;w=o.length?(a=new Sd(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var K0=`void main() { +`+se)}else G!==""?Ee("WebGLProgram: Program Info Log:",G):(J===""||Z==="")&&(Y=!1);Y&&(L.diagnostics={runnable:re,programLog:G,vertexShader:{log:J,prefix:m},fragmentShader:{log:Z,prefix:p}})}s.deleteShader(S),s.deleteShader(b),x=new zs(s,v),E=A0(s,v)}let x;this.getUniforms=function(){return x===void 0&&A(this),x};let E;this.getAttributes=function(){return E===void 0&&A(this),E};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=s.getProgramParameter(v,_0)),U},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=x0++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}var G0=0,Ac=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Rc(e),t.set(e,n)),n}},Rc=class{constructor(e){this.id=G0++,this.code=e,this.usedTimes=0}};function W0(i){return i===wi||i===Ur||i===Fr}function X0(i,e,t,n,s,r){let o=new ys,a=new Ac,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,E,U,L,V,W){let F=L.fog,G=V.geometry,J=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?L.environment:null,Z=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,re=e.get(x.envMap||J,Z),Y=re&&re.mapping===Pr?re.image.height:null,ee=f[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ee("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));let se=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Ae=se!==void 0?se.length:0,ve=0;G.morphAttributes.position!==void 0&&(ve=1),G.morphAttributes.normal!==void 0&&(ve=2),G.morphAttributes.color!==void 0&&(ve=3);let Qe,Be,Ye,$;if(ee){let ct=Vn[ee];Qe=ct.vertexShader,Be=ct.fragmentShader}else{Qe=x.vertexShader,Be=x.fragmentShader;let ct=a.getVertexShaderStage(x),$e=a.getFragmentShaderStage(x);a.update(x,ct,$e),Ye=ct.id,$=$e.id}let te=i.getRenderTarget(),xe=i.state.buffers.depth.getReversed(),Ne=V.isInstancedMesh===!0,ge=V.isBatchedMesh===!0,Fe=!!x.map,_t=!!x.matcap,Oe=!!re,qe=!!x.aoMap,et=!!x.lightMap,Ve=!!x.bumpMap&&x.wireframe===!1,rt=!!x.normalMap,Mt=!!x.displacementMap,Ut=!!x.emissiveMap,lt=!!x.metalnessMap,ft=!!x.roughnessMap,N=x.anisotropy>0,St=x.clearcoat>0,Ke=x.dispersion>0,T=x.retroreflectivity>0,_=x.iridescence>0,B=x.sheen>0,H=x.transmission>0,K=N&&!!x.anisotropyMap,ae=St&&!!x.clearcoatMap,ce=St&&!!x.clearcoatNormalMap,C=St&&!!x.clearcoatRoughnessMap,O=_&&!!x.iridescenceMap,q=_&&!!x.iridescenceThicknessMap,ne=B&&!!x.sheenColorMap,Q=B&&!!x.sheenRoughnessMap,ie=!!x.specularMap,de=!!x.specularColorMap,_e=!!x.specularIntensityMap,Pe=H&&!!x.transmissionMap,P=H&&!!x.thicknessMap,le=!!x.gradientMap,j=!!x.alphaMap,he=x.alphaTest>0,me=!!x.alphaHash,oe=!!x.extensions,Re=wn;x.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(Re=i.toneMapping);let Te={shaderID:ee,shaderType:x.type,shaderName:x.name,vertexShader:Qe,fragmentShader:Be,defines:x.defines,customVertexShaderID:Ye,customFragmentShaderID:$,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:ge,batchingColor:ge&&V._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&V.instanceColor!==null,instancingMorph:Ne&&V.morphTexture!==null,outputColorSpace:te===null?i.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:He.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Fe,matcap:_t,envMap:Oe,envMapMode:Oe&&re.mapping,envMapCubeUVHeight:Y,aoMap:qe,lightMap:et,bumpMap:Ve,normalMap:rt,displacementMap:Mt,emissiveMap:Ut,normalMapObjectSpace:rt&&x.normalMapType===Wu,normalMapTangentSpace:rt&&x.normalMapType===Da,packedNormalMap:rt&&x.normalMapType===Da&&W0(x.normalMap.format),metalnessMap:lt,roughnessMap:ft,anisotropy:N,anisotropyMap:K,clearcoat:St,clearcoatMap:ae,clearcoatNormalMap:ce,clearcoatRoughnessMap:C,dispersion:Ke,retroreflection:T,iridescence:_,iridescenceMap:O,iridescenceThicknessMap:q,sheen:B,sheenColorMap:ne,sheenRoughnessMap:Q,specularMap:ie,specularColorMap:de,specularIntensityMap:_e,transmission:H,transmissionMap:Pe,thicknessMap:P,gradientMap:le,opaque:x.transparent===!1&&x.blending===Ns&&x.alphaToCoverage===!1,alphaMap:j,alphaTest:he,alphaHash:me,combine:x.combine,mapUv:Fe&&g(x.map.channel),aoMapUv:qe&&g(x.aoMap.channel),lightMapUv:et&&g(x.lightMap.channel),bumpMapUv:Ve&&g(x.bumpMap.channel),normalMapUv:rt&&g(x.normalMap.channel),displacementMapUv:Mt&&g(x.displacementMap.channel),emissiveMapUv:Ut&&g(x.emissiveMap.channel),metalnessMapUv:lt&&g(x.metalnessMap.channel),roughnessMapUv:ft&&g(x.roughnessMap.channel),anisotropyMapUv:K&&g(x.anisotropyMap.channel),clearcoatMapUv:ae&&g(x.clearcoatMap.channel),clearcoatNormalMapUv:ce&&g(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:C&&g(x.clearcoatRoughnessMap.channel),iridescenceMapUv:O&&g(x.iridescenceMap.channel),iridescenceThicknessMapUv:q&&g(x.iridescenceThicknessMap.channel),sheenColorMapUv:ne&&g(x.sheenColorMap.channel),sheenRoughnessMapUv:Q&&g(x.sheenRoughnessMap.channel),specularMapUv:ie&&g(x.specularMap.channel),specularColorMapUv:de&&g(x.specularColorMap.channel),specularIntensityMapUv:_e&&g(x.specularIntensityMap.channel),transmissionMapUv:Pe&&g(x.transmissionMap.channel),thicknessMapUv:P&&g(x.thicknessMap.channel),alphaMapUv:j&&g(x.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(rt||N),vertexNormals:!!G.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!G.attributes.uv&&(Fe||j),fog:!!F,useFog:x.fog===!0,fogExp2:!!F&&F.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||G.attributes.normal===void 0&&rt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:V.isSkinnedMesh===!0,hasPositionAttribute:G.attributes.position!==void 0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:Ae,morphTextureStride:ve,numSunLights:E.sun.length,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numSunLightShadows:E.sunShadowMap.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:Re,decodeVideoTexture:Fe&&x.map.isVideoTexture===!0&&He.getTransfer(x.map.colorSpace)===je,decodeVideoTextureEmissive:Ut&&x.emissiveMap.isVideoTexture===!0&&He.getTransfer(x.emissiveMap.colorSpace)===je,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===Qt,flipSided:x.side===qt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:oe&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(oe&&x.extensions.multiDraw===!0||ge)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function m(x){let E=[];if(x.shaderID?E.push(x.shaderID):(E.push(x.customVertexShaderID),E.push(x.customFragmentShaderID)),x.defines!==void 0)for(let U in x.defines)E.push(U),E.push(x.defines[U]);return x.isRawShaderMaterial===!1&&(p(E,x),w(E,x),E.push(i.outputColorSpace)),E.push(x.customProgramCacheKey),E.join()}function p(x,E){x.push(E.precision),x.push(E.outputColorSpace),x.push(E.envMapMode),x.push(E.envMapCubeUVHeight),x.push(E.mapUv),x.push(E.alphaMapUv),x.push(E.lightMapUv),x.push(E.aoMapUv),x.push(E.bumpMapUv),x.push(E.normalMapUv),x.push(E.displacementMapUv),x.push(E.emissiveMapUv),x.push(E.metalnessMapUv),x.push(E.roughnessMapUv),x.push(E.anisotropyMapUv),x.push(E.clearcoatMapUv),x.push(E.clearcoatNormalMapUv),x.push(E.clearcoatRoughnessMapUv),x.push(E.iridescenceMapUv),x.push(E.iridescenceThicknessMapUv),x.push(E.sheenColorMapUv),x.push(E.sheenRoughnessMapUv),x.push(E.specularMapUv),x.push(E.specularColorMapUv),x.push(E.specularIntensityMapUv),x.push(E.transmissionMapUv),x.push(E.thicknessMapUv),x.push(E.combine),x.push(E.fogExp2),x.push(E.sizeAttenuation),x.push(E.morphTargetsCount),x.push(E.morphAttributeCount),x.push(E.numSunLights),x.push(E.numDirLights),x.push(E.numPointLights),x.push(E.numSpotLights),x.push(E.numSpotLightMaps),x.push(E.numHemiLights),x.push(E.numRectAreaLights),x.push(E.numSunLightShadows),x.push(E.numDirLightShadows),x.push(E.numPointLightShadows),x.push(E.numSpotLightShadows),x.push(E.numSpotLightShadowsWithMaps),x.push(E.numLightProbes),x.push(E.shadowMapType),x.push(E.toneMapping),x.push(E.numClippingPlanes),x.push(E.numClipIntersection),x.push(E.depthPacking)}function w(x,E){o.disableAll(),E.instancing&&o.enable(0),E.instancingColor&&o.enable(1),E.instancingMorph&&o.enable(2),E.matcap&&o.enable(3),E.envMap&&o.enable(4),E.normalMapObjectSpace&&o.enable(5),E.normalMapTangentSpace&&o.enable(6),E.clearcoat&&o.enable(7),E.iridescence&&o.enable(8),E.alphaTest&&o.enable(9),E.vertexColors&&o.enable(10),E.vertexAlphas&&o.enable(11),E.vertexUv1s&&o.enable(12),E.vertexUv2s&&o.enable(13),E.vertexUv3s&&o.enable(14),E.vertexTangents&&o.enable(15),E.anisotropy&&o.enable(16),E.alphaHash&&o.enable(17),E.batching&&o.enable(18),E.dispersion&&o.enable(19),E.retroreflection&&o.enable(24),E.batchingColor&&o.enable(20),E.gradientMap&&o.enable(21),E.packedNormalMap&&o.enable(22),E.vertexNormals&&o.enable(23),x.push(o.mask),o.disableAll(),E.fog&&o.enable(0),E.useFog&&o.enable(1),E.flatShading&&o.enable(2),E.logarithmicDepthBuffer&&o.enable(3),E.reversedDepthBuffer&&o.enable(4),E.skinning&&o.enable(5),E.morphTargets&&o.enable(6),E.morphNormals&&o.enable(7),E.morphColors&&o.enable(8),E.premultipliedAlpha&&o.enable(9),E.shadowMapEnabled&&o.enable(10),E.doubleSided&&o.enable(11),E.flipSided&&o.enable(12),E.useDepthPacking&&o.enable(13),E.dithering&&o.enable(14),E.transmission&&o.enable(15),E.sheen&&o.enable(16),E.opaque&&o.enable(17),E.pointsUvs&&o.enable(18),E.decodeVideoTexture&&o.enable(19),E.decodeVideoTextureEmissive&&o.enable(20),E.alphaToCoverage&&o.enable(21),E.numLightProbeGrids>0&&o.enable(22),E.hasPositionAttribute&&o.enable(23),x.push(o.mask)}function R(x){let E=f[x.type],U;if(E){let L=Vn[E];U=id.clone(L.uniforms)}else U=x.uniforms;return U}function M(x,E){let U=h.get(E);return U!==void 0?++U.usedTimes:(U=new H0(i,E,x,s),c.push(U),h.set(E,U)),U}function S(x){if(--x.usedTimes===0){let E=c.indexOf(x);c[E]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){a.remove(x)}function A(){a.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:R,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:c,dispose:A}}function q0(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Y0(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function bd(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Td(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,g,v,m,p){let w=i[e];return w===void 0?(w={id:u.id,object:u,geometry:f,material:g,materialVariant:o(u),groupOrder:v,renderOrder:u.renderOrder,z:m,group:p},i[e]=w):(w.id=u.id,w.object=u,w.geometry=f,w.material=g,w.materialVariant=o(u),w.groupOrder=v,w.renderOrder=u.renderOrder,w.z=m,w.group=p),e++,w}function l(u,f,g,v,m,p,w){w.reversedDepth===!0&&(m=-m);let R=a(u,f,g,v,m,p);g.transmission>0?n.push(R):g.transparent===!0?s.push(R):t.push(R)}function c(u,f,g,v,m,p){let w=a(u,f,g,v,m,p);g.transmission>0?n.unshift(w):g.transparent===!0?s.unshift(w):t.unshift(w)}function h(u,f){t.length>1&&t.sort(u||Y0),n.length>1&&n.sort(f||bd),s.length>1&&s.sort(f||bd)}function d(){for(let u=e,f=i.length;u=r.length?(o=new Td,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function K0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new D,color:new Ie};break;case"SpotLight":t={position:new D,direction:new D,color:new Ie,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new Ie,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new Ie,groundColor:new Ie};break;case"RectAreaLight":t={color:new Ie,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function $0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var J0=0;function j0(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Q0(i){let e=new K0,t=$0(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new D);let s=new D,r=new De,o=new De;function a(c){let h=0,d=0,u=0;for(let V=0;V<9;V++)n.probe[V].set(0,0,0);let f=0,g=0,v=0,m=0,p=0,w=0,R=0,M=0,S=0,b=0,A=0,x=0,E=0,U=0;c.sort(j0);for(let V=0,W=c.length;V0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ue.LTC_FLOAT_1,n.rectAreaLTC2=ue.LTC_FLOAT_2):(n.rectAreaLTC1=ue.LTC_HALF_1,n.rectAreaLTC2=ue.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let L=n.hash;(L.sunLength!==f||L.directionalLength!==m||L.pointLength!==p||L.spotLength!==w||L.rectAreaLength!==R||L.hemiLength!==M||L.numSunShadows!==g||L.numDirectionalShadows!==S||L.numPointShadows!==b||L.numSpotShadows!==A||L.numSpotMaps!==x||L.numLightProbes!==U)&&(n.sun.length=f,n.directional.length=m,n.spot.length=w,n.rectArea.length=R,n.point.length=p,n.hemi.length=M,n.sunShadow.length=g,n.sunShadowMap.length=g,n.sunShadowMatrix.length=v,n.sunShadowCascade.length=v,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.directionalShadowMatrix.length=S,n.pointShadow.length=b,n.pointShadowMap.length=b,n.pointShadowMatrix.length=b,n.spotShadow.length=A,n.spotShadowMap.length=A,n.spotLightMatrix.length=A+x-E,n.spotLightMap.length=x,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=U,L.sunLength=f,L.directionalLength=m,L.pointLength=p,L.spotLength=w,L.rectAreaLength=R,L.hemiLength=M,L.numSunShadows=g,L.numDirectionalShadows=S,L.numPointShadows=b,L.numSpotShadows=A,L.numSpotMaps=x,L.numLightProbes=U,n.version=J0++)}function l(c,h){let d=0,u=0,f=0,g=0,v=0,m=0,p=h.matrixWorldInverse;for(let w=0,R=c.length;w=o.length?(a=new wd(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var tx=`void main() { gl_Position = vec4( position, 1.0 ); -}`,$0=`uniform sampler2D shadow_pass; +}`,nx=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { @@ -4194,12 +4194,12 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,J0=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],j0=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],bd=new De,zr=new D,Mc=new D;function Q0(i,e,t){let n=new ws,s=new Ce,r=new Ce,o=new nt,a=new Oo,l=new Bo,c={},h=t.maxTextureSize,d={[Bn]:qt,[qt]:Bn,[Qt]:Qt},u=new an({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:K0,fragmentShader:$0}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new zt;g.setAttribute("position",new Et(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new yt(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Cr;let p=this.type;this.render=function(b,A,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===_u&&(Ee("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Cr);let E=i.getRenderTarget(),U=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),V=i.state;V.setBlending(kn),V.buffers.depth.getReversed()===!0?V.buffers.color.setClear(0,0,0,0):V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let W=p!==this.type;W&&A.traverse(function(F){F.material&&(Array.isArray(F.material)?F.material.forEach(G=>G.needsUpdate=!0):F.material.needsUpdate=!0)});for(let F=0,G=b.length;Fh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/re.x),s.x=r.x*re.x,Z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/re.y),s.y=r.y*re.y,Z.mapSize.y=r.y));let Y=i.state.buffers.depth.getReversed();if(Z.camera._reversedDepth=Y,Z.map===null||W===!0){if(Z.map!==null&&(Z.map.depthTexture!==null&&(Z.map.depthTexture.dispose(),Z.map.depthTexture=null),Z.map.dispose()),this.type===Ls){if(J.isPointLight){Ee("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}Z.map=new Zt(s.x,s.y,{format:wi,type:An,minFilter:gt,magFilter:gt,generateMipmaps:!1}),Z.map.texture.name=J.name+".shadowMap",Z.map.depthTexture=new _i(s.x,s.y,ln),Z.map.depthTexture.name=J.name+".shadowMapDepth",Z.map.depthTexture.format=Dn,Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=mt,Z.map.depthTexture.magFilter=mt}else J.isPointLight?(Z.map=new za(s.x),Z.map.depthTexture=new Uo(s.x,En)):(Z.map=new Zt(s.x,s.y),Z.map.depthTexture=new _i(s.x,s.y,En)),Z.map.depthTexture.name=J.name+".shadowMap",Z.map.depthTexture.format=Dn,this.type===Cr?(Z.map.depthTexture.compareFunction=Y?Fa:Ua,Z.map.depthTexture.minFilter=gt,Z.map.depthTexture.magFilter=gt):(Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=mt,Z.map.depthTexture.magFilter=mt);Z.camera.updateProjectionMatrix()}Z.map.isWebGLCubeRenderTarget!==!0&&(Z.map.width!==s.x||Z.map.height!==s.y)&&Z.map.setSize(s.x,s.y);let ee=Z.map.isWebGLCubeRenderTarget?6:Z.getViewportCount();J.isPointLight!==!0&&Z.updateMatrices(J,x);for(let se=0;se0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let V=U.uuid,W=A.uuid,F=c[V];F===void 0&&(F={},c[V]=F);let G=F[W];G===void 0&&(G=U.clone(),F[W]=G,A.addEventListener("dispose",S)),U=G}if(U.visible=A.visible,U.wireframe=A.wireframe,E===Ls?U.side=A.shadowSide!==null?A.shadowSide:A.side:U.side=A.shadowSide!==null?A.shadowSide:d[A.side],U.alphaMap=A.alphaMap,U.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,U.map=A.map,U.clipShadows=A.clipShadows,U.clippingPlanes=A.clippingPlanes,U.clipIntersection=A.clipIntersection,U.displacementMap=A.displacementMap,U.displacementScale=A.displacementScale,U.displacementBias=A.displacementBias,U.wireframeLinewidth=A.wireframeLinewidth,U.linewidth=A.linewidth,x.isPointLight===!0&&U.isMeshDistanceMaterial===!0){let V=i.properties.get(U);V.light=x}return U}function M(b,A,x,E,U){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&U===Ls)&&(!b.frustumCulled||b.intersectsFrustum(n))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);let W=e.update(b),F=b.material;if(Array.isArray(F)){let G=W.groups;for(let J=0,Z=G.length;J=1):Y.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),Z=re>=2);let ee=null,se={},Ae=i.getParameter(i.SCISSOR_BOX),ve=i.getParameter(i.VIEWPORT),Qe=new nt().fromArray(Ae),Be=new nt().fromArray(ve);function Ye(P,le,j,he){let me=new Uint8Array(4),oe=i.createTexture();i.bindTexture(P,oe),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Re=0;Re"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ce,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,_){return g?new OffscreenCanvas(T,_):gs("canvas")}function m(T,_,B){let H=1,K=Ke(T);if((K.width>B||K.height>B)&&(H=B/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){let ae=Math.floor(H*K.width),ce=Math.floor(H*K.height);u===void 0&&(u=v(ae,ce));let C=_?v(ae,ce):u;return C.width=ae,C.height=ce,C.getContext("2d").drawImage(T,0,0,ae,ce),Ee("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+ae+"x"+ce+")."),C}else return"data"in T&&Ee("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function w(T){i.generateMipmap(T)}function R(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,_,B,H,K,ae=!1){if(T!==null){if(i[T]!==void 0)return i[T];Ee("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ce;H&&(ce=e.get("EXT_texture_norm16"),ce||Ee("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let C=_;if(_===i.RED&&(B===i.FLOAT&&(C=i.R32F),B===i.HALF_FLOAT&&(C=i.R16F),B===i.UNSIGNED_BYTE&&(C=i.R8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.R16_EXT),B===i.SHORT&&ce&&(C=ce.R16_SNORM_EXT)),_===i.RED_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.R8UI),B===i.UNSIGNED_SHORT&&(C=i.R16UI),B===i.UNSIGNED_INT&&(C=i.R32UI),B===i.BYTE&&(C=i.R8I),B===i.SHORT&&(C=i.R16I),B===i.INT&&(C=i.R32I)),_===i.RG&&(B===i.FLOAT&&(C=i.RG32F),B===i.HALF_FLOAT&&(C=i.RG16F),B===i.UNSIGNED_BYTE&&(C=i.RG8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.RG16_EXT),B===i.SHORT&&ce&&(C=ce.RG16_SNORM_EXT)),_===i.RG_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RG8UI),B===i.UNSIGNED_SHORT&&(C=i.RG16UI),B===i.UNSIGNED_INT&&(C=i.RG32UI),B===i.BYTE&&(C=i.RG8I),B===i.SHORT&&(C=i.RG16I),B===i.INT&&(C=i.RG32I)),_===i.RGB_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RGB8UI),B===i.UNSIGNED_SHORT&&(C=i.RGB16UI),B===i.UNSIGNED_INT&&(C=i.RGB32UI),B===i.BYTE&&(C=i.RGB8I),B===i.SHORT&&(C=i.RGB16I),B===i.INT&&(C=i.RGB32I)),_===i.RGBA_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RGBA8UI),B===i.UNSIGNED_SHORT&&(C=i.RGBA16UI),B===i.UNSIGNED_INT&&(C=i.RGBA32UI),B===i.BYTE&&(C=i.RGBA8I),B===i.SHORT&&(C=i.RGBA16I),B===i.INT&&(C=i.RGBA32I)),_===i.RGB&&(B===i.UNSIGNED_SHORT&&ce&&(C=ce.RGB16_EXT),B===i.SHORT&&ce&&(C=ce.RGB16_SNORM_EXT),B===i.UNSIGNED_INT_5_9_9_9_REV&&(C=i.RGB9_E5),B===i.UNSIGNED_INT_10F_11F_11F_REV&&(C=i.R11F_G11F_B10F)),_===i.RGBA){let O=ae?sr:He.getTransfer(K);B===i.FLOAT&&(C=i.RGBA32F),B===i.HALF_FLOAT&&(C=i.RGBA16F),B===i.UNSIGNED_BYTE&&(C=O===je?i.SRGB8_ALPHA8:i.RGBA8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.RGBA16_EXT),B===i.SHORT&&ce&&(C=ce.RGBA16_SNORM_EXT),B===i.UNSIGNED_SHORT_4_4_4_4&&(C=i.RGBA4),B===i.UNSIGNED_SHORT_5_5_5_1&&(C=i.RGB5_A1)}return(C===i.R16F||C===i.R32F||C===i.RG16F||C===i.RG32F||C===i.RGBA16F||C===i.RGBA32F)&&e.get("EXT_color_buffer_float"),C}function S(T,_){let B;return T?_===null||_===En||_===Fs?B=i.DEPTH24_STENCIL8:_===ln?B=i.DEPTH32F_STENCIL8:_===Us&&(B=i.DEPTH24_STENCIL8,Ee("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===En||_===Fs?B=i.DEPTH_COMPONENT24:_===ln?B=i.DEPTH_COMPONENT32F:_===Us&&(B=i.DEPTH_COMPONENT16),B}function b(T,_){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==mt&&T.minFilter!==gt?Math.log2(Math.max(_.width,_.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?_.mipmaps.length:1}function A(T){let _=T.target;_.removeEventListener("dispose",A),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&d.delete(_)}function x(T){let _=T.target;_.removeEventListener("dispose",x),L(_)}function E(T){let _=n.get(T);if(_.__webglInit===void 0)return;let B=T.source,H=f.get(B);if(H){let K=H[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&U(T),Object.keys(H).length===0&&f.delete(B)}n.remove(T)}function U(T){let _=n.get(T);i.deleteTexture(_.__webglTexture);let B=T.source,H=f.get(B);delete H[_.__cacheKey],o.memory.textures--}function L(T){let _=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(_.__webglFramebuffer[H]))for(let K=0;K<_.__webglFramebuffer[H].length;K++)i.deleteFramebuffer(_.__webglFramebuffer[H][K]);else i.deleteFramebuffer(_.__webglFramebuffer[H]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[H])}else{if(Array.isArray(_.__webglFramebuffer))for(let H=0;H<_.__webglFramebuffer.length;H++)i.deleteFramebuffer(_.__webglFramebuffer[H]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let H=0;H<_.__webglColorRenderbuffer.length;H++)_.__webglColorRenderbuffer[H]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[H]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let B=T.textures;for(let H=0,K=B.length;H=s.maxTextures&&Ee("WebGLTextures: Trying to use "+(T+1)+" texture units while this GPU supports only "+s.maxTextures),V+=1,T}function Z(T){let _=[];return _.push(T.wrapS),_.push(T.wrapT),_.push(T.wrapR||0),_.push(T.magFilter),_.push(T.minFilter),_.push(T.anisotropy),_.push(T.internalFormat),_.push(T.format),_.push(T.type),_.push(T.generateMipmaps),_.push(T.premultiplyAlpha),_.push(T.flipY),_.push(T.unpackAlignment),_.push(T.colorSpace),_.join()}function re(T,_){let B=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&B.__version!==T.version){let H=T.image;if(H===null)Ee("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ee("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(B,T,_);return}}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,B.__webglTexture,i.TEXTURE0+_)}function Y(T,_){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){xe(B,T,_);return}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,B.__webglTexture,i.TEXTURE0+_)}function ee(T,_){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){xe(B,T,_);return}t.bindTexture(i.TEXTURE_3D,B.__webglTexture,i.TEXTURE0+_)}function se(T,_){let B=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&B.__version!==T.version){Ne(B,T,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,B.__webglTexture,i.TEXTURE0+_)}let Ae={[gi]:i.REPEAT,[dn]:i.CLAMP_TO_EDGE,[ps]:i.MIRRORED_REPEAT},ve={[mt]:i.NEAREST,[$o]:i.NEAREST_MIPMAP_NEAREST,[Wi]:i.NEAREST_MIPMAP_LINEAR,[gt]:i.LINEAR,[Ds]:i.LINEAR_MIPMAP_NEAREST,[wn]:i.LINEAR_MIPMAP_LINEAR},Qe={[Gu]:i.NEVER,[Zu]:i.ALWAYS,[Wu]:i.LESS,[Ua]:i.LEQUAL,[Xu]:i.EQUAL,[Fa]:i.GEQUAL,[qu]:i.GREATER,[Yu]:i.NOTEQUAL};function Be(T,_){if(_.type===ln&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===gt||_.magFilter===Ds||_.magFilter===Wi||_.magFilter===wn||_.minFilter===gt||_.minFilter===Ds||_.minFilter===Wi||_.minFilter===wn)&&Ee("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,Ae[_.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,Ae[_.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,Ae[_.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,ve[_.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,ve[_.minFilter]),_.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Qe[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===mt||_.minFilter!==Wi&&_.minFilter!==wn||_.type===ln&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){let B=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Ye(T,_){let B=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",A));let H=_.source,K=f.get(H);K===void 0&&(K={},f.set(H,K));let ae=Z(_);if(ae!==T.__cacheKey){K[ae]===void 0&&(K[ae]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,B=!0),K[ae].usedTimes++;let ce=K[T.__cacheKey];ce!==void 0&&(K[T.__cacheKey].usedTimes--,ce.usedTimes===0&&U(_)),T.__cacheKey=ae,T.__webglTexture=K[ae].texture}return B}function $(T,_,B){return Math.floor(Math.floor(T/B)/_)}function te(T,_,B,H){let ae=T.updateRanges;if(ae.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,B,H,_.data);else{ae.sort((ne,Q)=>ne.start-Q.start);let ce=0;for(let ne=1;ne0){_e&&Pe&&t.texStorage2D(i.TEXTURE_2D,le,Q,de[0].width,de[0].height);for(let j=0,he=de.length;j0){let me=mc(ie.width,ie.height,_.format,_.type);for(let oe of _.layerUpdates){let Re=ie.data.subarray(oe*me/ie.data.BYTES_PER_ELEMENT,(oe+1)*me/ie.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,oe,ie.width,ie.height,1,q,Re)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,0,ie.width,ie.height,O.depth,q,ie.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,j,Q,ie.width,ie.height,O.depth,0,ie.data,0,0);else Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,0,ie.width,ie.height,O.depth,q,ne,ie.data):t.texImage3D(i.TEXTURE_2D_ARRAY,j,Q,ie.width,ie.height,O.depth,0,q,ne,ie.data);_.layerUpdates.size>0&&_.clearLayerUpdates()}else{_e&&Pe&&t.texStorage2D(i.TEXTURE_2D,le,Q,de[0].width,de[0].height);for(let j=0,he=de.length;j0){let j=mc(O.width,O.height,_.format,_.type);for(let he of _.layerUpdates){let me=O.data.subarray(he*j/O.data.BYTES_PER_ELEMENT,(he+1)*j/O.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,O.width,O.height,1,q,ne,me)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,O.width,O.height,O.depth,q,ne,O.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Q,O.width,O.height,O.depth,0,q,ne,O.data);else if(_.isData3DTexture)_e?(Pe&&t.texStorage3D(i.TEXTURE_3D,le,Q,O.width,O.height,O.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,O.width,O.height,O.depth,q,ne,O.data)):t.texImage3D(i.TEXTURE_3D,0,Q,O.width,O.height,O.depth,0,q,ne,O.data);else if(_.isFramebufferTexture){if(Pe)if(_e)t.texStorage2D(i.TEXTURE_2D,le,Q,O.width,O.height);else{let j=O.width,he=O.height;for(let me=0;me>=1,he>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){let j=i.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),O.parentNode!==j){j.appendChild(O),d.add(_),j.onpaint=he=>{let me=he.changedElements;for(let oe of d)me.includes(oe.image)&&(oe.needsUpdate=!0)},j.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,O);else{let me=i.RGBA,oe=i.RGBA,Re=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,oe,Re,O)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(de.length>0){if(_e&&Pe){let j=Ke(de[0]);t.texStorage2D(i.TEXTURE_2D,le,Q,j.width,j.height)}for(let j=0,he=de.length;j0&&he++;let oe=Ke(Q[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Pe,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ne){P?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,Q[oe].width,Q[oe].height,de,_e,Q[oe].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Pe,Q[oe].width,Q[oe].height,0,de,_e,Q[oe].data);for(let Re=0;Re>ae),ie=Math.max(1,_.height>>ae);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,ae,O,Q,ie,_.depth,0,ce,C,null):t.texImage2D(K,ae,O,Q,ie,0,ce,C,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),ft(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,K,ne.__webglTexture,0,lt(_)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,H,K,ne.__webglTexture,ae),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Fe(T,_,B){if(i.bindRenderbuffer(i.RENDERBUFFER,T),_.depthBuffer){let H=_.depthTexture,K=H&&H.isDepthTexture?H.type:null,ae=S(_.stencilBuffer,K),ce=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ft(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,lt(_),ae,_.width,_.height):B?i.renderbufferStorageMultisample(i.RENDERBUFFER,lt(_),ae,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ae,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,T)}else{let H=_.textures;for(let K=0;K{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=H}if(T.depthTexture&&!_.__autoAllocateDepthBuffer)if(B)for(let H=0;H<6;H++)_t(_.__webglFramebuffer[H],T,H);else{let H=T.texture.mipmaps;H&&H.length>0?_t(_.__webglFramebuffer[0],T,0):_t(_.__webglFramebuffer,T,0)}else if(B){_.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[H]),_.__webglDepthbuffer[H]===void 0)_.__webglDepthbuffer[H]=i.createRenderbuffer(),Fe(_.__webglDepthbuffer[H],T,!1);else{let K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=_.__webglDepthbuffer[H];i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,ae)}}else{let H=T.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Fe(_.__webglDepthbuffer,T,!1);else{let K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,ae)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function qe(T,_,B){let H=n.get(T);_!==void 0&&ge(H.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),B!==void 0&&Oe(T)}function et(T){let _=T.texture,B=n.get(T),H=n.get(_);T.addEventListener("dispose",x);let K=T.textures,ae=T.isWebGLCubeRenderTarget===!0,ce=K.length>1;if(ce||(H.__webglTexture===void 0&&(H.__webglTexture=i.createTexture()),H.__version=_.version,o.memory.textures++),ae){B.__webglFramebuffer=[];for(let C=0;C<6;C++)if(_.mipmaps&&_.mipmaps.length>0){B.__webglFramebuffer[C]=[];for(let O=0;O<_.mipmaps.length;O++)B.__webglFramebuffer[C][O]=i.createFramebuffer()}else B.__webglFramebuffer[C]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){B.__webglFramebuffer=[];for(let C=0;C<_.mipmaps.length;C++)B.__webglFramebuffer[C]=i.createFramebuffer()}else B.__webglFramebuffer=i.createFramebuffer();if(ce)for(let C=0,O=K.length;C0&&ft(T)===!1){B.__webglMultisampledFramebuffer=i.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let C=0;C0)for(let O=0;O<_.mipmaps.length;O++)ge(B.__webglFramebuffer[C][O],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+C,O);else ge(B.__webglFramebuffer[C],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+C,0);p(_)&&w(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ce){for(let C=0,O=K.length;C0)for(let O=0;O<_.mipmaps.length;O++)ge(B.__webglFramebuffer[O],T,_,i.COLOR_ATTACHMENT0,C,O);else ge(B.__webglFramebuffer,T,_,i.COLOR_ATTACHMENT0,C,0);p(_)&&w(C),t.unbindTexture()}T.depthBuffer&&Oe(T)}function Ve(T){let _=T.textures;for(let B=0,H=_.length;B0){if(ft(T)===!1){let _=T.textures,B=T.width,H=T.height,K=i.COLOR_BUFFER_BIT,ae=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ce=n.get(T),C=_.length>1;if(C)for(let q=0;q<_.length;q++)t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer);let O=T.texture.mipmaps;O&&O.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let q=0;q<_.length;q++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),C){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ce.__webglColorRenderbuffer[q]);let ne=n.get(_[q]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ne,0)}i.blitFramebuffer(0,0,B,H,0,0,B,H,K,i.NEAREST),l===!0&&(rt.length=0,Mt.length=0,rt.push(i.COLOR_ATTACHMENT0+q),T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&(rt.push(ae),Mt.push(ae),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Mt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,rt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),C)for(let q=0;q<_.length;q++){t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,ce.__webglColorRenderbuffer[q]);let ne=n.get(_[q]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.TEXTURE_2D,ne,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&l){let _=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function lt(T){return Math.min(s.maxSamples,T.samples)}function ft(T){let _=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function N(T){let _=o.render.frame;h.get(T)!==_&&(h.set(T,_),T.update())}function St(T,_){let B=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||B!==Xt&&B!==si&&(He.getTransfer(B)===je?(H!==cn||K!==en)&&Ee("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Le("WebGLTextures: Unsupported texture color space:",B)),_}function Ke(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=J,this.resetTextureUnits=W,this.getTextureUnits=F,this.setTextureUnits=G,this.setTexture2D=re,this.setTexture2DArray=Y,this.setTexture3D=ee,this.setTextureCube=se,this.rebindTextures=qe,this.setupRenderTarget=et,this.updateRenderTargetMipmap=Ve,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=ft,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function nx(i,e){function t(n,s=si){let r,o=He.getTransfer(s);if(n===en)return i.UNSIGNED_BYTE;if(n===jo)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Qo)return i.UNSIGNED_SHORT_5_5_5_1;if(n===sc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===rc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===nc)return i.BYTE;if(n===ic)return i.SHORT;if(n===Us)return i.UNSIGNED_SHORT;if(n===Jo)return i.INT;if(n===En)return i.UNSIGNED_INT;if(n===ln)return i.FLOAT;if(n===An)return i.HALF_FLOAT;if(n===oc)return i.ALPHA;if(n===ac)return i.RGB;if(n===cn)return i.RGBA;if(n===Dn)return i.DEPTH_COMPONENT;if(n===Ti)return i.DEPTH_STENCIL;if(n===ea)return i.RED;if(n===ta)return i.RED_INTEGER;if(n===wi)return i.RG;if(n===na)return i.RG_INTEGER;if(n===ia)return i.RGBA_INTEGER;if(n===Ir||n===Lr||n===Nr||n===Dr)if(o===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ir)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ir)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===sa||n===ra||n===oa||n===aa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===sa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ra)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===oa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===aa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===la||n===ca||n===ha||n===ua||n===da||n===Ur||n===fa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===la||n===ca)return o===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ha)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ua)return r.COMPRESSED_R11_EAC;if(n===da)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ur)return r.COMPRESSED_RG11_EAC;if(n===fa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===pa||n===ma||n===ga||n===_a||n===xa||n===ya||n===va||n===Ma||n===Sa||n===ba||n===Ta||n===wa||n===Ea||n===Aa)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===pa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ma)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ga)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===_a)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===xa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ya)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===va)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ma)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Sa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ba)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ta)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===wa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ea)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Aa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ra||n===Ca||n===Pa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ra)return o===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ca)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Pa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ia||n===La||n===Fr||n===Na)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ia)return r.COMPRESSED_RED_RGTC1_EXT;if(n===La)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Na)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Fs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var ix=` +}`,ix=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],sx=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],Ed=new De,zr=new D,Mc=new D;function rx(i,e,t){let n=new ws,s=new Ce,r=new Ce,o=new nt,a=new Oo,l=new Bo,c={},h=t.maxTextureSize,d={[Bn]:qt,[qt]:Bn,[Qt]:Qt},u=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:tx,fragmentShader:nx}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let g=new zt;g.setAttribute("position",new Et(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new yt(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Cr;let p=this.type;this.render=function(b,A,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===vu&&(Ee("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Cr);let E=i.getRenderTarget(),U=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),V=i.state;V.setBlending(kn),V.buffers.depth.getReversed()===!0?V.buffers.color.setClear(0,0,0,0):V.buffers.color.setClear(1,1,1,1),V.buffers.depth.setTest(!0),V.setScissorTest(!1);let W=p!==this.type;W&&A.traverse(function(F){F.material&&(Array.isArray(F.material)?F.material.forEach(G=>G.needsUpdate=!0):F.material.needsUpdate=!0)});for(let F=0,G=b.length;Fh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/re.x),s.x=r.x*re.x,Z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/re.y),s.y=r.y*re.y,Z.mapSize.y=r.y));let Y=i.state.buffers.depth.getReversed();if(Z.camera._reversedDepth=Y,Z.map===null||W===!0){if(Z.map!==null&&(Z.map.depthTexture!==null&&(Z.map.depthTexture.dispose(),Z.map.depthTexture=null),Z.map.dispose()),this.type===Ls){if(J.isPointLight){Ee("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}Z.map=new Zt(s.x,s.y,{format:wi,type:Rn,minFilter:gt,magFilter:gt,generateMipmaps:!1}),Z.map.texture.name=J.name+".shadowMap",Z.map.depthTexture=new _i(s.x,s.y,cn),Z.map.depthTexture.name=J.name+".shadowMapDepth",Z.map.depthTexture.format=Dn,Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=mt,Z.map.depthTexture.magFilter=mt}else J.isPointLight?(Z.map=new za(s.x),Z.map.depthTexture=new Uo(s.x,An)):(Z.map=new Zt(s.x,s.y),Z.map.depthTexture=new _i(s.x,s.y,An)),Z.map.depthTexture.name=J.name+".shadowMap",Z.map.depthTexture.format=Dn,this.type===Cr?(Z.map.depthTexture.compareFunction=Y?Fa:Ua,Z.map.depthTexture.minFilter=gt,Z.map.depthTexture.magFilter=gt):(Z.map.depthTexture.compareFunction=null,Z.map.depthTexture.minFilter=mt,Z.map.depthTexture.magFilter=mt);Z.camera.updateProjectionMatrix()}Z.map.isWebGLCubeRenderTarget!==!0&&(Z.map.width!==s.x||Z.map.height!==s.y)&&Z.map.setSize(s.x,s.y);let ee=Z.map.isWebGLCubeRenderTarget?6:Z.getViewportCount();J.isPointLight!==!0&&Z.updateMatrices(J,x);for(let se=0;se0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){let V=U.uuid,W=A.uuid,F=c[V];F===void 0&&(F={},c[V]=F);let G=F[W];G===void 0&&(G=U.clone(),F[W]=G,A.addEventListener("dispose",S)),U=G}if(U.visible=A.visible,U.wireframe=A.wireframe,E===Ls?U.side=A.shadowSide!==null?A.shadowSide:A.side:U.side=A.shadowSide!==null?A.shadowSide:d[A.side],U.alphaMap=A.alphaMap,U.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,U.map=A.map,U.clipShadows=A.clipShadows,U.clippingPlanes=A.clippingPlanes,U.clipIntersection=A.clipIntersection,U.displacementMap=A.displacementMap,U.displacementScale=A.displacementScale,U.displacementBias=A.displacementBias,U.wireframeLinewidth=A.wireframeLinewidth,U.linewidth=A.linewidth,x.isPointLight===!0&&U.isMeshDistanceMaterial===!0){let V=i.properties.get(U);V.light=x}return U}function M(b,A,x,E,U){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&U===Ls)&&(!b.frustumCulled||b.intersectsFrustum(n))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);let W=e.update(b),F=b.material;if(Array.isArray(F)){let G=W.groups;for(let J=0,Z=G.length;J=1):Y.indexOf("OpenGL ES")!==-1&&(re=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),Z=re>=2);let ee=null,se={},Ae=i.getParameter(i.SCISSOR_BOX),ve=i.getParameter(i.VIEWPORT),Qe=new nt().fromArray(Ae),Be=new nt().fromArray(ve);function Ye(P,le,j,he){let me=new Uint8Array(4),oe=i.createTexture();i.bindTexture(P,oe),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Re=0;Re"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ce,h=new WeakMap,d=new Set,u,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,_){return g?new OffscreenCanvas(T,_):gs("canvas")}function m(T,_,B){let H=1,K=Ke(T);if((K.width>B||K.height>B)&&(H=B/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){let ae=Math.floor(H*K.width),ce=Math.floor(H*K.height);u===void 0&&(u=v(ae,ce));let C=_?v(ae,ce):u;return C.width=ae,C.height=ce,C.getContext("2d").drawImage(T,0,0,ae,ce),Ee("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+ae+"x"+ce+")."),C}else return"data"in T&&Ee("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function w(T){i.generateMipmap(T)}function R(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,_,B,H,K,ae=!1){if(T!==null){if(i[T]!==void 0)return i[T];Ee("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ce;H&&(ce=e.get("EXT_texture_norm16"),ce||Ee("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let C=_;if(_===i.RED&&(B===i.FLOAT&&(C=i.R32F),B===i.HALF_FLOAT&&(C=i.R16F),B===i.UNSIGNED_BYTE&&(C=i.R8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.R16_EXT),B===i.SHORT&&ce&&(C=ce.R16_SNORM_EXT)),_===i.RED_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.R8UI),B===i.UNSIGNED_SHORT&&(C=i.R16UI),B===i.UNSIGNED_INT&&(C=i.R32UI),B===i.BYTE&&(C=i.R8I),B===i.SHORT&&(C=i.R16I),B===i.INT&&(C=i.R32I)),_===i.RG&&(B===i.FLOAT&&(C=i.RG32F),B===i.HALF_FLOAT&&(C=i.RG16F),B===i.UNSIGNED_BYTE&&(C=i.RG8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.RG16_EXT),B===i.SHORT&&ce&&(C=ce.RG16_SNORM_EXT)),_===i.RG_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RG8UI),B===i.UNSIGNED_SHORT&&(C=i.RG16UI),B===i.UNSIGNED_INT&&(C=i.RG32UI),B===i.BYTE&&(C=i.RG8I),B===i.SHORT&&(C=i.RG16I),B===i.INT&&(C=i.RG32I)),_===i.RGB_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RGB8UI),B===i.UNSIGNED_SHORT&&(C=i.RGB16UI),B===i.UNSIGNED_INT&&(C=i.RGB32UI),B===i.BYTE&&(C=i.RGB8I),B===i.SHORT&&(C=i.RGB16I),B===i.INT&&(C=i.RGB32I)),_===i.RGBA_INTEGER&&(B===i.UNSIGNED_BYTE&&(C=i.RGBA8UI),B===i.UNSIGNED_SHORT&&(C=i.RGBA16UI),B===i.UNSIGNED_INT&&(C=i.RGBA32UI),B===i.BYTE&&(C=i.RGBA8I),B===i.SHORT&&(C=i.RGBA16I),B===i.INT&&(C=i.RGBA32I)),_===i.RGB&&(B===i.UNSIGNED_SHORT&&ce&&(C=ce.RGB16_EXT),B===i.SHORT&&ce&&(C=ce.RGB16_SNORM_EXT),B===i.UNSIGNED_INT_5_9_9_9_REV&&(C=i.RGB9_E5),B===i.UNSIGNED_INT_10F_11F_11F_REV&&(C=i.R11F_G11F_B10F)),_===i.RGBA){let O=ae?sr:He.getTransfer(K);B===i.FLOAT&&(C=i.RGBA32F),B===i.HALF_FLOAT&&(C=i.RGBA16F),B===i.UNSIGNED_BYTE&&(C=O===je?i.SRGB8_ALPHA8:i.RGBA8),B===i.UNSIGNED_SHORT&&ce&&(C=ce.RGBA16_EXT),B===i.SHORT&&ce&&(C=ce.RGBA16_SNORM_EXT),B===i.UNSIGNED_SHORT_4_4_4_4&&(C=i.RGBA4),B===i.UNSIGNED_SHORT_5_5_5_1&&(C=i.RGB5_A1)}return(C===i.R16F||C===i.R32F||C===i.RG16F||C===i.RG32F||C===i.RGBA16F||C===i.RGBA32F)&&e.get("EXT_color_buffer_float"),C}function S(T,_){let B;return T?_===null||_===An||_===Fs?B=i.DEPTH24_STENCIL8:_===cn?B=i.DEPTH32F_STENCIL8:_===Us&&(B=i.DEPTH24_STENCIL8,Ee("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===An||_===Fs?B=i.DEPTH_COMPONENT24:_===cn?B=i.DEPTH_COMPONENT32F:_===Us&&(B=i.DEPTH_COMPONENT16),B}function b(T,_){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==mt&&T.minFilter!==gt?Math.log2(Math.max(_.width,_.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?_.mipmaps.length:1}function A(T){let _=T.target;_.removeEventListener("dispose",A),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&d.delete(_)}function x(T){let _=T.target;_.removeEventListener("dispose",x),L(_)}function E(T){let _=n.get(T);if(_.__webglInit===void 0)return;let B=T.source,H=f.get(B);if(H){let K=H[_.__cacheKey];K.usedTimes--,K.usedTimes===0&&U(T),Object.keys(H).length===0&&f.delete(B)}n.remove(T)}function U(T){let _=n.get(T);i.deleteTexture(_.__webglTexture);let B=T.source,H=f.get(B);delete H[_.__cacheKey],o.memory.textures--}function L(T){let _=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(_.__webglFramebuffer[H]))for(let K=0;K<_.__webglFramebuffer[H].length;K++)i.deleteFramebuffer(_.__webglFramebuffer[H][K]);else i.deleteFramebuffer(_.__webglFramebuffer[H]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[H])}else{if(Array.isArray(_.__webglFramebuffer))for(let H=0;H<_.__webglFramebuffer.length;H++)i.deleteFramebuffer(_.__webglFramebuffer[H]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let H=0;H<_.__webglColorRenderbuffer.length;H++)_.__webglColorRenderbuffer[H]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[H]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}let B=T.textures;for(let H=0,K=B.length;H=s.maxTextures&&Ee("WebGLTextures: Trying to use "+(T+1)+" texture units while this GPU supports only "+s.maxTextures),V+=1,T}function Z(T){let _=[];return _.push(T.wrapS),_.push(T.wrapT),_.push(T.wrapR||0),_.push(T.magFilter),_.push(T.minFilter),_.push(T.anisotropy),_.push(T.internalFormat),_.push(T.format),_.push(T.type),_.push(T.generateMipmaps),_.push(T.premultiplyAlpha),_.push(T.flipY),_.push(T.unpackAlignment),_.push(T.colorSpace),_.join()}function re(T,_){let B=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&B.__version!==T.version){let H=T.image;if(H===null)Ee("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ee("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(B,T,_);return}}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,B.__webglTexture,i.TEXTURE0+_)}function Y(T,_){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){xe(B,T,_);return}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,B.__webglTexture,i.TEXTURE0+_)}function ee(T,_){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){xe(B,T,_);return}t.bindTexture(i.TEXTURE_3D,B.__webglTexture,i.TEXTURE0+_)}function se(T,_){let B=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&B.__version!==T.version){Ne(B,T,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,B.__webglTexture,i.TEXTURE0+_)}let Ae={[gi]:i.REPEAT,[fn]:i.CLAMP_TO_EDGE,[ps]:i.MIRRORED_REPEAT},ve={[mt]:i.NEAREST,[$o]:i.NEAREST_MIPMAP_NEAREST,[Wi]:i.NEAREST_MIPMAP_LINEAR,[gt]:i.LINEAR,[Ds]:i.LINEAR_MIPMAP_NEAREST,[En]:i.LINEAR_MIPMAP_LINEAR},Qe={[qu]:i.NEVER,[Ju]:i.ALWAYS,[Yu]:i.LESS,[Ua]:i.LEQUAL,[Zu]:i.EQUAL,[Fa]:i.GEQUAL,[Ku]:i.GREATER,[$u]:i.NOTEQUAL};function Be(T,_){if(_.type===cn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===gt||_.magFilter===Ds||_.magFilter===Wi||_.magFilter===En||_.minFilter===gt||_.minFilter===Ds||_.minFilter===Wi||_.minFilter===En)&&Ee("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,Ae[_.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,Ae[_.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,Ae[_.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,ve[_.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,ve[_.minFilter]),_.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Qe[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===mt||_.minFilter!==Wi&&_.minFilter!==En||_.type===cn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){let B=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Ye(T,_){let B=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",A));let H=_.source,K=f.get(H);K===void 0&&(K={},f.set(H,K));let ae=Z(_);if(ae!==T.__cacheKey){K[ae]===void 0&&(K[ae]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,B=!0),K[ae].usedTimes++;let ce=K[T.__cacheKey];ce!==void 0&&(K[T.__cacheKey].usedTimes--,ce.usedTimes===0&&U(_)),T.__cacheKey=ae,T.__webglTexture=K[ae].texture}return B}function $(T,_,B){return Math.floor(Math.floor(T/B)/_)}function te(T,_,B,H){let ae=T.updateRanges;if(ae.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,B,H,_.data);else{ae.sort((ne,Q)=>ne.start-Q.start);let ce=0;for(let ne=1;ne0){_e&&Pe&&t.texStorage2D(i.TEXTURE_2D,le,Q,de[0].width,de[0].height);for(let j=0,he=de.length;j0){let me=mc(ie.width,ie.height,_.format,_.type);for(let oe of _.layerUpdates){let Re=ie.data.subarray(oe*me/ie.data.BYTES_PER_ELEMENT,(oe+1)*me/ie.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,oe,ie.width,ie.height,1,q,Re)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,0,ie.width,ie.height,O.depth,q,ie.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,j,Q,ie.width,ie.height,O.depth,0,ie.data,0,0);else Ee("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else _e?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,j,0,0,0,ie.width,ie.height,O.depth,q,ne,ie.data):t.texImage3D(i.TEXTURE_2D_ARRAY,j,Q,ie.width,ie.height,O.depth,0,q,ne,ie.data);_.layerUpdates.size>0&&_.clearLayerUpdates()}else{_e&&Pe&&t.texStorage2D(i.TEXTURE_2D,le,Q,de[0].width,de[0].height);for(let j=0,he=de.length;j0){let j=mc(O.width,O.height,_.format,_.type);for(let he of _.layerUpdates){let me=O.data.subarray(he*j/O.data.BYTES_PER_ELEMENT,(he+1)*j/O.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,O.width,O.height,1,q,ne,me)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,O.width,O.height,O.depth,q,ne,O.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Q,O.width,O.height,O.depth,0,q,ne,O.data);else if(_.isData3DTexture)_e?(Pe&&t.texStorage3D(i.TEXTURE_3D,le,Q,O.width,O.height,O.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,O.width,O.height,O.depth,q,ne,O.data)):t.texImage3D(i.TEXTURE_3D,0,Q,O.width,O.height,O.depth,0,q,ne,O.data);else if(_.isFramebufferTexture){if(Pe)if(_e)t.texStorage2D(i.TEXTURE_2D,le,Q,O.width,O.height);else{let j=O.width,he=O.height;for(let me=0;me>=1,he>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){let j=i.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),O.parentNode!==j){j.appendChild(O),d.add(_),j.onpaint=he=>{let me=he.changedElements;for(let oe of d)me.includes(oe.image)&&(oe.needsUpdate=!0)},j.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,O);else{let me=i.RGBA,oe=i.RGBA,Re=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,oe,Re,O)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(de.length>0){if(_e&&Pe){let j=Ke(de[0]);t.texStorage2D(i.TEXTURE_2D,le,Q,j.width,j.height)}for(let j=0,he=de.length;j0&&he++;let oe=Ke(Q[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Pe,oe.width,oe.height)}for(let oe=0;oe<6;oe++)if(ne){P?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,0,0,Q[oe].width,Q[oe].height,de,_e,Q[oe].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+oe,0,Pe,Q[oe].width,Q[oe].height,0,de,_e,Q[oe].data);for(let Re=0;Re>ae),ie=Math.max(1,_.height>>ae);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?t.texImage3D(K,ae,O,Q,ie,_.depth,0,ce,C,null):t.texImage2D(K,ae,O,Q,ie,0,ce,C,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),ft(_)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,K,ne.__webglTexture,0,lt(_)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,H,K,ne.__webglTexture,ae),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Fe(T,_,B){if(i.bindRenderbuffer(i.RENDERBUFFER,T),_.depthBuffer){let H=_.depthTexture,K=H&&H.isDepthTexture?H.type:null,ae=S(_.stencilBuffer,K),ce=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ft(_)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,lt(_),ae,_.width,_.height):B?i.renderbufferStorageMultisample(i.RENDERBUFFER,lt(_),ae,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ae,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,T)}else{let H=_.textures;for(let K=0;K{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),_.__depthDisposeCallback=K}_.__boundDepthTexture=H}if(T.depthTexture&&!_.__autoAllocateDepthBuffer)if(B)for(let H=0;H<6;H++)_t(_.__webglFramebuffer[H],T,H);else{let H=T.texture.mipmaps;H&&H.length>0?_t(_.__webglFramebuffer[0],T,0):_t(_.__webglFramebuffer,T,0)}else if(B){_.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[H]),_.__webglDepthbuffer[H]===void 0)_.__webglDepthbuffer[H]=i.createRenderbuffer(),Fe(_.__webglDepthbuffer[H],T,!1);else{let K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=_.__webglDepthbuffer[H];i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,ae)}}else{let H=T.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Fe(_.__webglDepthbuffer,T,!1);else{let K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ae),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,ae)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function qe(T,_,B){let H=n.get(T);_!==void 0&&ge(H.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),B!==void 0&&Oe(T)}function et(T){let _=T.texture,B=n.get(T),H=n.get(_);T.addEventListener("dispose",x);let K=T.textures,ae=T.isWebGLCubeRenderTarget===!0,ce=K.length>1;if(ce||(H.__webglTexture===void 0&&(H.__webglTexture=i.createTexture()),H.__version=_.version,o.memory.textures++),ae){B.__webglFramebuffer=[];for(let C=0;C<6;C++)if(_.mipmaps&&_.mipmaps.length>0){B.__webglFramebuffer[C]=[];for(let O=0;O<_.mipmaps.length;O++)B.__webglFramebuffer[C][O]=i.createFramebuffer()}else B.__webglFramebuffer[C]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){B.__webglFramebuffer=[];for(let C=0;C<_.mipmaps.length;C++)B.__webglFramebuffer[C]=i.createFramebuffer()}else B.__webglFramebuffer=i.createFramebuffer();if(ce)for(let C=0,O=K.length;C0&&ft(T)===!1){B.__webglMultisampledFramebuffer=i.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let C=0;C0)for(let O=0;O<_.mipmaps.length;O++)ge(B.__webglFramebuffer[C][O],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+C,O);else ge(B.__webglFramebuffer[C],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+C,0);p(_)&&w(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ce){for(let C=0,O=K.length;C0)for(let O=0;O<_.mipmaps.length;O++)ge(B.__webglFramebuffer[O],T,_,i.COLOR_ATTACHMENT0,C,O);else ge(B.__webglFramebuffer,T,_,i.COLOR_ATTACHMENT0,C,0);p(_)&&w(C),t.unbindTexture()}T.depthBuffer&&Oe(T)}function Ve(T){let _=T.textures;for(let B=0,H=_.length;B0){if(ft(T)===!1){let _=T.textures,B=T.width,H=T.height,K=i.COLOR_BUFFER_BIT,ae=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ce=n.get(T),C=_.length>1;if(C)for(let q=0;q<_.length;q++)t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer);let O=T.texture.mipmaps;O&&O.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let q=0;q<_.length;q++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),C){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ce.__webglColorRenderbuffer[q]);let ne=n.get(_[q]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ne,0)}i.blitFramebuffer(0,0,B,H,0,0,B,H,K,i.NEAREST),l===!0&&(rt.length=0,Mt.length=0,rt.push(i.COLOR_ATTACHMENT0+q),T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&(rt.push(ae),Mt.push(ae),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Mt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,rt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),C)for(let q=0;q<_.length;q++){t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,ce.__webglColorRenderbuffer[q]);let ne=n.get(_[q]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.TEXTURE_2D,ne,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&l){let _=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function lt(T){return Math.min(s.maxSamples,T.samples)}function ft(T){let _=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function N(T){let _=o.render.frame;h.get(T)!==_&&(h.set(T,_),T.update())}function St(T,_){let B=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||B!==Xt&&B!==si&&(He.getTransfer(B)===je?(H!==hn||K!==en)&&Ee("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Le("WebGLTextures: Unsupported texture color space:",B)),_}function Ke(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=J,this.resetTextureUnits=W,this.getTextureUnits=F,this.setTextureUnits=G,this.setTexture2D=re,this.setTexture2DArray=Y,this.setTexture3D=ee,this.setTextureCube=se,this.rebindTextures=qe,this.setupRenderTarget=et,this.updateRenderTargetMipmap=Ve,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=ft,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function lx(i,e){function t(n,s=si){let r,o=He.getTransfer(s);if(n===en)return i.UNSIGNED_BYTE;if(n===jo)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Qo)return i.UNSIGNED_SHORT_5_5_5_1;if(n===sc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===rc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===nc)return i.BYTE;if(n===ic)return i.SHORT;if(n===Us)return i.UNSIGNED_SHORT;if(n===Jo)return i.INT;if(n===An)return i.UNSIGNED_INT;if(n===cn)return i.FLOAT;if(n===Rn)return i.HALF_FLOAT;if(n===oc)return i.ALPHA;if(n===ac)return i.RGB;if(n===hn)return i.RGBA;if(n===Dn)return i.DEPTH_COMPONENT;if(n===Ti)return i.DEPTH_STENCIL;if(n===ea)return i.RED;if(n===ta)return i.RED_INTEGER;if(n===wi)return i.RG;if(n===na)return i.RG_INTEGER;if(n===ia)return i.RGBA_INTEGER;if(n===Ir||n===Lr||n===Nr||n===Dr)if(o===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ir)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ir)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===sa||n===ra||n===oa||n===aa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===sa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ra)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===oa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===aa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===la||n===ca||n===ha||n===ua||n===da||n===Ur||n===fa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===la||n===ca)return o===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ha)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ua)return r.COMPRESSED_R11_EAC;if(n===da)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ur)return r.COMPRESSED_RG11_EAC;if(n===fa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===pa||n===ma||n===ga||n===_a||n===xa||n===ya||n===va||n===Ma||n===Sa||n===ba||n===Ta||n===wa||n===Ea||n===Aa)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===pa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ma)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ga)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===_a)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===xa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ya)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===va)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ma)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Sa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ba)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ta)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===wa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ea)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Aa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ra||n===Ca||n===Pa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ra)return o===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ca)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Pa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ia||n===La||n===Fr||n===Na)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ia)return r.COMPRESSED_RED_RGTC1_EXT;if(n===La)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Na)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Fs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var cx=` void main() { gl_Position = vec4( position, 1.0 ); -}`,sx=` +}`,hx=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4218,7 +4218,7 @@ void main() { } -}`,Cc=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _r(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new an({vertexShader:ix,fragmentShader:sx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new xr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Pc=class extends bn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,v=typeof XRWebGLBinding<"u",m=new Cc,p={},w=t.getContextAttributes(),R=null,M=null,S=[],b=[],A=new Ce,x=null,E=null,U=new wt;U.viewport=new nt;let L=new wt;L.viewport=new nt;let V=[U,L],W=new Yo,F=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getTargetRaySpace()},this.getControllerGrip=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getGripSpace()},this.getHand=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getHandSpace()};function J($){let te=b.indexOf($.inputSource);if(te===-1)return;let xe=S[te];xe!==void 0&&(xe.update($.inputSource,$.frame,c||o),xe.dispatchEvent({type:$.type,data:$.inputSource}))}function Z(){s.removeEventListener("select",J),s.removeEventListener("selectstart",J),s.removeEventListener("selectend",J),s.removeEventListener("squeeze",J),s.removeEventListener("squeezestart",J),s.removeEventListener("squeezeend",J),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",re);for(let $=0;$=0&&(b[Ne]=null,S[Ne].disconnect(xe))}for(let te=0;te<$.added.length;te++){let xe=$.added[te],Ne=b.indexOf(xe);if(Ne===-1){for(let Fe=0;Fe=b.length){b.push(xe),Ne=Fe;break}else if(b[Fe]===null){b[Fe]=xe,Ne=Fe;break}if(Ne===-1)break}let ge=S[Ne];ge&&ge.connect(xe)}}let Y=new D,ee=new D;function se($,te,xe){Y.setFromMatrixPosition(te.matrixWorld),ee.setFromMatrixPosition(xe.matrixWorld);let Ne=Y.distanceTo(ee),ge=te.projectionMatrix.elements,Fe=xe.projectionMatrix.elements,_t=ge[14]/(ge[10]-1),Oe=ge[14]/(ge[10]+1),qe=(ge[9]+1)/ge[5],et=(ge[9]-1)/ge[5],Ve=(ge[8]-1)/ge[0],rt=(Fe[8]+1)/Fe[0],Mt=_t*Ve,Ut=_t*rt,lt=Ne/(-Ve+rt),ft=lt*-Ve;if(te.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(ft),$.translateZ(lt),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),ge[10]===-1)$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{let N=_t+lt,St=Oe+lt,Ke=Mt-ft,T=Ut+(Ne-ft),_=qe*Oe/St*N,B=et*Oe/St*N;$.projectionMatrix.makePerspective(Ke,T,_,B,N,St),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function Ae($,te){te===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(te.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let te=$.near,xe=$.far;m.texture!==null&&(m.depthNear>0&&(te=m.depthNear),m.depthFar>0&&(xe=m.depthFar)),W.near=L.near=U.near=te,W.far=L.far=U.far=xe,(F!==W.near||G!==W.far)&&(s.updateRenderState({depthNear:W.near,depthFar:W.far}),F=W.near,G=W.far),W.layers.mask=$.layers.mask|6,U.layers.mask=W.layers.mask&-5,L.layers.mask=W.layers.mask&-3;let Ne=$.parent,ge=W.cameras;Ae(W,Ne);for(let Fe=0;Fe0&&(m.alphaTest.value=p.alphaTest);let w=e.get(p),R=w.envMap,M=w.envMapRotation;R&&(m.envMap.value=R,m.envMapRotation.value.setFromMatrix4(rx.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Pd),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,w,R){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=R*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,w){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===qt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){let w=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ax(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){let b=S.program;n.uniformBlockBinding(M,b)}function c(M,S){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",w));let A=S.program;n.updateUBOMapping(M,A);let x=e.render.frame;r[M.id]!==x&&(u(M),r[M.id]=x)}function h(M){let S=d();M.__bindingPointIndex=S;let b=i.createBuffer(),A=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function d(){for(let M=0;M0&&(b+=A-x),M.__size=b,M.__cache={},this}function p(M){let S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Ee("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Ee("WebGLRenderer: Unsupported uniform value type.",M),S}function w(M){let S=M.target;S.removeEventListener("dispose",w);let b=o.indexOf(S.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function R(){for(let M in s)i.deleteBuffer(s[M]);o=[],s={},r={}}return{bind:l,update:c,dispose:R}}var lx=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),zn=null;function cx(){return zn===null&&(zn=new Ts(lx,16,16,wi,An),zn.name="DFG_LUT",zn.minFilter=gt,zn.magFilter=gt,zn.wrapS=dn,zn.wrapT=dn,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}var Va=class{constructor(e={}){let{canvas:t=Ku(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=en}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let v=f,m=new Set([ia,na,ta]),p=new Set([en,En,Us,Fs,jo,Qo]),w=new Uint32Array(4),R=new Int32Array(4),M=new D,S=null,b=null,A=[],x=[],E=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Tn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let U=this,L=!1,V=null,W=null,F=null,G=null;this._outputColorSpace=pt;let J=0,Z=0,re=null,Y=-1,ee=null,se=new nt,Ae=new nt,ve=null,Qe=new Ie(0),Be=0,Ye=t.width,$=t.height,te=1,xe=null,Ne=null,ge=new nt(0,0,Ye,$),Fe=new nt(0,0,Ye,$),_t=!1,Oe=new ws,qe=!1,et=!1,Ve=new De,rt=new D,Mt=new nt,Ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},lt=!1;function ft(){return re===null?te:1}let N=n;function St(y,I){return t.getContext(y,I)}let Ke,T,_,B,H,K,ae,ce,C,O,q,ne,Q,ie,de,_e,Pe,P,le,j,he,me,oe;try{let y={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",ct,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",mn,!1),N===null){let I="webgl2";if(N=St(I,y),N===null)throw St(I)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Re()}catch(y){throw t.removeEventListener("webglcontextlost",ct,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",mn,!1),Le("WebGLRenderer: "+y.message),y}function Re(){Ke=new g_(N),Ke.init(),he=new nx(N,Ke),T=new o_(N,Ke,e,he),_=new ex(N,Ke),T.reversedDepthBuffer&&u&&_.buffers.depth.setReversed(!0),W=N.createFramebuffer(),F=N.createFramebuffer(),G=N.createFramebuffer(),B=new y_(N),H=new z0,K=new tx(N,Ke,_,H,T,he,B),ae=new m_(U),ce=new Mp(N),me=new s_(N,ce),C=new __(N,ce,B,me),O=new M_(N,C,ce,me,B),P=new v_(N,T,K),de=new a_(H),q=new k0(U,ae,Ke,T,me,de),ne=new ox(U,H),Q=new H0,ie=new Z0(Ke),Pe=new i_(U,ae,_,O,g,l),_e=new Q0(U,O,T),oe=new ax(N,B,T,_),le=new r_(N,Ke,B),j=new x_(N,Ke,B),B.programs=q.programs,U.capabilities=T,U.extensions=Ke,U.properties=H,U.renderLists=Q,U.shadowMap=_e,U.state=_,U.info=B}v!==en&&(E=new b_(v,t.width,t.height,a,s,r));let Te=new Pc(U,N);this.xr=Te,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let y=Ke.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Ke.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(y){y!==void 0&&(te=y,this.setSize(Ye,$,!1))},this.getSize=function(y){return y.set(Ye,$)},this.setSize=function(y,I,X=!0){if(Te.isPresenting){Ee("WebGLRenderer: Can't change size while VR device is presenting.");return}Ye=y,$=I,t.width=Math.floor(y*te),t.height=Math.floor(I*te),X===!0&&(t.style.width=y+"px",t.style.height=I+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,y,I)},this.getDrawingBufferSize=function(y){return y.set(Ye*te,$*te).floor()},this.setDrawingBufferSize=function(y,I,X){Ye=y,$=I,te=X,t.width=Math.floor(y*X),t.height=Math.floor(I*X),this.setViewport(0,0,y,I)},this.setEffects=function(y){if(v===en){Le("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let I=0;I{function pe(){if(k.forEach(function(Me){let Se=H.get(Me).currentProgram;(Se===void 0||Se.isReady())&&k.delete(Me)}),k.size===0){z(y);return}setTimeout(pe,10)}Ke.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let nl=null;function hf(y){nl&&nl(y)}function yh(){Ci.stop()}function vh(){Ci.start()}let Ci=new Td;Ci.setAnimationLoop(hf),typeof self<"u"&&Ci.setContext(self),this.setAnimationLoop=function(y){nl=y,Te.setAnimationLoop(y),y===null?Ci.stop():Ci.start()},Te.addEventListener("sessionstart",yh),Te.addEventListener("sessionend",vh),this.render=function(y,I){if(I!==void 0&&I.isCamera!==!0){Le("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;V!==null&&V.renderStart(y,I);let X=Te.enabled===!0&&Te.isPresenting===!0,k=E!==null&&(re===null||X)&&E.begin(U,re);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(I),I=Te.getCamera()),y.isScene===!0&&y.onBeforeRender(U,y,I,re),b=ie.get(y,x.length),b.init(I),b.state.textureUnits=K.getTextureUnits(),x.push(b),Ve.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Oe.setFromProjectionMatrix(Ve,vn,I.reversedDepth),et=this.localClippingEnabled,qe=de.init(this.clippingPlanes,et),S=Q.get(y,A.length),S.init(),A.push(S),Te.enabled===!0&&Te.isPresenting===!0){let Me=U.xr.getDepthSensingMesh();Me!==null&&il(Me,I,-1/0,U.sortObjects)}il(y,I,0,U.sortObjects),S.finish(),V!==null&&V.updateLights(b.state.lightsArray),U.sortObjects===!0&&S.sort(xe,Ne),lt=Te.enabled===!1||Te.isPresenting===!1||Te.hasDepthSensing()===!1,lt&&Pe.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&de.beginShadows();let z=b.state.shadowsArray;if(_e.render(z,y,I),qe===!0&&de.endShadows(),(k&&E.hasRenderPass())===!1){let Me=S.opaque,fe=S.transmissive;if(b.setupLights(),I.isArrayCamera){let Se=I.cameras;if(fe.length>0)for(let we=0,ke=Se.length;we0&&Sh(Me,fe,y,I),lt&&Pe.render(y),Mh(S,y,I)}re!==null&&Z===0&&(K.updateMultisampleRenderTarget(re),K.updateRenderTargetMipmap(re)),k&&E.end(U),y.isScene===!0&&y.onAfterRender(U,y,I),me.resetDefaultState(),Y=-1,ee=null,x.pop(),x.length>0?(b=x[x.length-1],K.setTextureUnits(b.state.textureUnits),qe===!0&&de.setGlobalState(U.clippingPlanes,b.state.camera)):b=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,V!==null&&V.renderEnd()};function il(y,I,X,k){if(y.visible===!1)return;if(y.layers.test(I.layers)){if(y.isGroup)X=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(I);else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight)b.pushLight(y),y.castShadow&&b.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(Oe)){k&&Mt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ve);let Me=O.update(y),fe=y.material;fe.visible&&S.push(y,Me,fe,X,Mt.z,null,I)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||y.intersectsFrustum(Oe))){let Me=O.update(y),fe=y.material;if(k&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Mt.copy(y.boundingSphere.center)):(Me.boundingSphere===null&&Me.computeBoundingSphere(),Mt.copy(Me.boundingSphere.center)),Mt.applyMatrix4(y.matrixWorld).applyMatrix4(Ve)),Array.isArray(fe)){let Se=Me.groups;for(let we=0,ke=Se.length;we0&&Xr(z,I,X),pe.length>0&&Xr(pe,I,X),Me.length>0&&Xr(Me,I,X),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function Sh(y,I,X,k){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new Zt(1,1,{generateMipmaps:!0,type:be?An:en,minFilter:wn,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:He.workingColorSpace})}let pe=b.state.transmissionRenderTarget[k.id],Me=k.viewport||se;pe.setSize(Me.z*U.transmissionResolutionScale,Me.w*U.transmissionResolutionScale);let fe=U.getRenderTarget(),Se=U.getActiveCubeFace(),we=U.getActiveMipmapLevel();U.setRenderTarget(pe),U.getClearColor(Qe),Be=U.getClearAlpha(),Be<1&&U.setClearColor(16777215,.5),U.clear(),lt&&Pe.render(X);let ke=U.toneMapping;U.toneMapping=Tn;let Xe=k.viewport;if(k.viewport!==void 0&&(k.viewport=void 0),b.setupLightsView(k),qe===!0&&de.setGlobalState(U.clippingPlanes,k),Xr(y,X,k),K.updateMultisampleRenderTarget(pe),K.updateRenderTargetMipmap(pe),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Je=0,bt=I.length;Je0,k.currentProgram=Xe,k.uniformsList=null,Xe}function Th(y){if(y.uniformsList===null){let I=y.currentProgram.getUniforms();y.uniformsList=zs.seqWithValue(I.seq,y.uniforms)}return y.uniformsList}function wh(y,I){let X=H.get(y);X.outputColorSpace=I.outputColorSpace,X.batching=I.batching,X.batchingColor=I.batchingColor,X.instancing=I.instancing,X.instancingColor=I.instancingColor,X.instancingMorph=I.instancingMorph,X.skinning=I.skinning,X.morphTargets=I.morphTargets,X.morphNormals=I.morphNormals,X.morphColors=I.morphColors,X.morphTargetsCount=I.morphTargetsCount,X.numClippingPlanes=I.numClippingPlanes,X.numIntersection=I.numClipIntersection,X.vertexAlphas=I.vertexAlphas,X.vertexTangents=I.vertexTangents,X.toneMapping=I.toneMapping}function uf(y,I){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(I.matrixWorld);for(let X=0,k=y.length;X0),be=!!X.morphAttributes.position,Je=!!X.morphAttributes.normal,bt=!!X.morphAttributes.color,ut=Tn;k.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(ut=U.toneMapping);let ot=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ft=ot!==void 0?ot.length:0,ye=H.get(k),Ht=b.state.lights;if(qe===!0&&(et===!0||y!==ee)){let ht=y===ee&&k.id===Y;de.setState(k,y,ht)}let Ze=!1;k.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Ht.state.version||ye.outputColorSpace!==fe||z.isBatchedMesh&&ye.batching===!1||!z.isBatchedMesh&&ye.batching===!0||z.isBatchedMesh&&ye.batchingColor===!0&&z._colorsTexture===null||z.isBatchedMesh&&ye.batchingColor===!1&&z._colorsTexture!==null||z.isInstancedMesh&&ye.instancing===!1||!z.isInstancedMesh&&ye.instancing===!0||z.isSkinnedMesh&&ye.skinning===!1||!z.isSkinnedMesh&&ye.skinning===!0||z.isInstancedMesh&&ye.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&ye.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&ye.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&ye.instancingMorph===!1&&z.morphTexture!==null||ye.envMap!==we||k.fog===!0&&ye.fog!==pe||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==de.numPlanes||ye.numIntersection!==de.numIntersection)||ye.vertexAlphas!==ke||ye.vertexTangents!==Xe||ye.morphTargets!==be||ye.morphNormals!==Je||ye.morphColors!==bt||ye.toneMapping!==ut||ye.morphTargetsCount!==Ft||!!ye.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ze=!0):(Ze=!0,ye.__version=k.version);let hn=ye.currentProgram;Ze===!0&&(hn=qr(k,I,z),V&&k.isNodeMaterial&&V.onUpdateProgram(k,hn,ye));let In=!1,oi=!1,$i=!1,st=hn.getUniforms(),xt=ye.uniforms;if(_.useProgram(hn.program)&&(In=!0,oi=!0,$i=!0),k.id!==Y&&(Y=k.id,oi=!0),ye.needsLights){let ht=uf(b.state.lightProbeGridArray,z);ye.lightProbeGrid!==ht&&(ye.lightProbeGrid=ht,oi=!0)}if(In||ee!==y){_.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),st.setValue(N,"projectionMatrix",y.projectionMatrix),st.setValue(N,"viewMatrix",y.matrixWorldInverse);let li=st.map.cameraPosition;li!==void 0&&li.setValue(N,rt.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&st.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)&&st.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),ee!==y&&(ee=y,oi=!0,$i=!0)}if(ye.needsLights&&(Ht.state.sunShadowMap.length>0&&st.setValue(N,"sunShadowMap",Ht.state.sunShadowMap,K),Ht.state.directionalShadowMap.length>0&&st.setValue(N,"directionalShadowMap",Ht.state.directionalShadowMap,K),Ht.state.spotShadowMap.length>0&&st.setValue(N,"spotShadowMap",Ht.state.spotShadowMap,K),Ht.state.pointShadowMap.length>0&&st.setValue(N,"pointShadowMap",Ht.state.pointShadowMap,K)),z.isSkinnedMesh){st.setOptional(N,z,"bindMatrix"),st.setOptional(N,z,"bindMatrixInverse");let ht=z.skeleton;ht&&(ht.boneTexture===null&&ht.computeBoneTexture(),st.setValue(N,"boneTexture",ht.boneTexture,K))}z.isBatchedMesh&&(st.setOptional(N,z,"batchingTexture"),st.setValue(N,"batchingTexture",z._matricesTexture,K),st.setOptional(N,z,"batchingIdTexture"),st.setValue(N,"batchingIdTexture",z._indirectTexture,K),st.setOptional(N,z,"batchingColorTexture"),z._colorsTexture!==null&&st.setValue(N,"batchingColorTexture",z._colorsTexture,K));let ai=X.morphAttributes;if((ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)&&P.update(z,X,hn),(oi||ye.receiveShadow!==z.receiveShadow)&&(ye.receiveShadow=z.receiveShadow,st.setValue(N,"receiveShadow",z.receiveShadow)),(k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&I.environment!==null&&(xt.envMapIntensity.value=I.environmentIntensity),xt.dfgLUT!==void 0&&(xt.dfgLUT.value=cx()),oi){if(st.setValue(N,"toneMappingExposure",U.toneMappingExposure),ye.needsLights&&ff(xt,$i),pe&&k.fog===!0&&ne.refreshFogUniforms(xt,pe),ne.refreshMaterialUniforms(xt,k,te,$,b.state.transmissionRenderTarget[y.id]),ye.needsLights&&ye.lightProbeGrid){let ht=ye.lightProbeGrid;xt.probesSH.value=ht.texture,xt.probesMin.value.copy(ht.boundingBox.min),xt.probesMax.value.copy(ht.boundingBox.max),xt.probesResolution.value.copy(ht.resolution)}zs.upload(N,Th(ye),xt,K)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0&&(zs.upload(N,Th(ye),xt,K),k.uniformsNeedUpdate=!1),k.isSpriteMaterial&&st.setValue(N,"center",z.center),st.setValue(N,"modelViewMatrix",z.modelViewMatrix),st.setValue(N,"normalMatrix",z.normalMatrix),st.setValue(N,"modelMatrix",z.matrixWorld),k.uniformsGroups!==void 0){let ht=k.uniformsGroups;for(let li=0,Ji=ht.length;li0&&K.useMultisampledRTT(y)===!1?k=H.get(y).__webglMultisampledFramebuffer:Array.isArray(we)?k=we[X]:k=we,se.copy(y.viewport),Ae.copy(y.scissor),ve=y.scissorTest}else se.copy(ge).multiplyScalar(te).floor(),Ae.copy(Fe).multiplyScalar(te).floor(),ve=_t;if(X!==0&&(k=W),_.bindFramebuffer(N.FRAMEBUFFER,k)&&_.drawBuffers(y,k),_.viewport(se),_.scissor(Ae),_.setScissorTest(ve),z){let fe=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+I,fe.__webglTexture,X)}else if(pe){let fe=I;for(let Se=0;Se1&&N.readBuffer(N.COLOR_ATTACHMENT0+fe);let be=Eh(we);if(be.__formatReadable===!1){Le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=y.width-k&&X>=0&&X<=y.height-z&&N.readPixels(I,X,k,z,he.convert(ke),he.convert(Xe),pe)}finally{let we=re!==null?H.get(re).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,we)}}},this.readRenderTargetPixelsAsync=async function(y,I,X,k,z,pe,Me,fe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Me!==void 0&&(Se=Se[Me]),Se)if(I>=0&&I<=y.width-k&&X>=0&&X<=y.height-z){_.bindFramebuffer(N.FRAMEBUFFER,Se);let we=y.textures[fe],ke=we.format,Xe=we.type;y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+fe);let be=Eh(we);if(be.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Je=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Je),N.bufferData(N.PIXEL_PACK_BUFFER,pe.byteLength,N.STREAM_READ),N.readPixels(I,X,k,z,he.convert(ke),he.convert(Xe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let bt=re!==null?H.get(re).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,bt);let ut=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Ju(N,ut,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Je),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,pe),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(Je),N.deleteSync(ut),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,I=null,X=0){let k=Math.pow(2,-X),z=Math.floor(y.image.width*k),pe=Math.floor(y.image.height*k),Me=I!==null?I.x:0,fe=I!==null?I.y:0;K.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,Me,fe,z,pe),_.unbindTexture()},this.copyTextureToTexture=function(y,I,X=null,k=null,z=0,pe=0){let Me,fe,Se,we,ke,Xe,be,Je,bt,ut=y.isCompressedTexture?y.mipmaps[pe]:y.image;if(X!==null)Me=X.max.x-X.min.x,fe=X.max.y-X.min.y,Se=X.isBox3?X.max.z-X.min.z:1,we=X.min.x,ke=X.min.y,Xe=X.isBox3?X.min.z:0;else{let xt=Math.pow(2,-z);Me=Math.floor(ut.width*xt),fe=Math.floor(ut.height*xt),y.isDataArrayTexture?Se=ut.depth:y.isData3DTexture?Se=Math.floor(ut.depth*xt):Se=1,we=0,ke=0,Xe=0}k!==null?(be=k.x,Je=k.y,bt=k.z):(be=0,Je=0,bt=0);let ot=he.convert(I.format),Ft=he.convert(I.type),ye;I.isData3DTexture?(K.setTexture3D(I,0),ye=N.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(K.setTexture2DArray(I,0),ye=N.TEXTURE_2D_ARRAY):(K.setTexture2D(I,0),ye=N.TEXTURE_2D),_.activeTexture(N.TEXTURE0),_.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,I.flipY),_.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),_.pixelStorei(N.UNPACK_ALIGNMENT,I.unpackAlignment);let Ht=_.getParameter(N.UNPACK_ROW_LENGTH),Ze=_.getParameter(N.UNPACK_IMAGE_HEIGHT),hn=_.getParameter(N.UNPACK_SKIP_PIXELS),In=_.getParameter(N.UNPACK_SKIP_ROWS),oi=_.getParameter(N.UNPACK_SKIP_IMAGES);_.pixelStorei(N.UNPACK_ROW_LENGTH,ut.width),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,ut.height),_.pixelStorei(N.UNPACK_SKIP_PIXELS,we),_.pixelStorei(N.UNPACK_SKIP_ROWS,ke),_.pixelStorei(N.UNPACK_SKIP_IMAGES,Xe);let $i=y.isDataArrayTexture||y.isData3DTexture,st=I.isDataArrayTexture||I.isData3DTexture;if(y.isDepthTexture){let xt=H.get(y),ai=H.get(I),ht=H.get(xt.__renderTarget),li=H.get(ai.__renderTarget);_.bindFramebuffer(N.READ_FRAMEBUFFER,ht.__webglFramebuffer),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,li.__webglFramebuffer);for(let Ji=0;Ji=2.0 are supported."));return}let c=new rh(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};function hx(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function vt(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}var We={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Uc=class{constructor(e){this.parser=e,this.name=We.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},Kc=class{constructor(e){this.parser=e,this.name=We.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},$c=class{constructor(e){this.parser=e,this.name=We.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},Wa=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let l=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,u=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,u,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){let f=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(f),h,d,u,s.mode,s.filter),f})})}else return null}},Jc=class{constructor(e){this.name=We.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let c of s.primitives)if(c.mode!==fn.TRIANGLES&&c.mode!==fn.TRIANGLE_STRIP&&c.mode!==fn.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let h=c.pop(),d=h.isGroup?h.children:[h],u=c[0].count,f=[];for(let g of d){let v=new De,m=new D,p=new kt,w=new D(1,1,1),R=new dr(g.geometry,g.material,u);for(let S=0;S0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var xx=new De,rh=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);s=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?this.textureLoader=new Mr(this.options.manager):this.textureLoader=new Er(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Cs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return Yi(r,a,s),Hn(a,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,h]of o.children.entries())r(h,a.children[c])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(E,b[A*l+1]),l>=3&&m.setZ(E,b[A*l+2]),l>=4&&m.setW(E,b[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let u=(r.samplers||{})[o.sampler]||{};return h.magFilter=Dd[u.magFilter]||gt,h.minFilter=Dd[u.minFilter]||wn,h.wrapS=Ud[u.wrapS]||gi,h.wrapT=Ud[u.wrapT]||gi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==mt&&h.minFilter!==gt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());let o=s.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;let u=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(u),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(l).then(function(d){return new Promise(function(u,f){let g=u;t.isImageBitmapLoader===!0&&(g=function(v){let m=new At(v);m.needsUpdate=!0,u(m)}),t.load(ii.resolveURL(d,r.path),g,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),Hn(d,o),d.userData.mimeType=o.mimeType||_x(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[We.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[We.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=r.associations.get(o);o=r.extensions[We.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new As,$t.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Es,$t.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return zi}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],o,a={},l=r.extensions||{},c=[];if(l[We.KHR_MATERIALS_UNLIT]){let d=s[We.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{let d=r.pbrMetallicRoughness||{};if(a.color=new Ie(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){let u=d.baseColorFactor;a.color.setRGB(u[0],u[1],u[2],Xt),a.opacity=u[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,pt)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(u){return u.getMaterialType&&u.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Qt);let h=r.alphaMode||Nc.OPAQUE;if(h===Nc.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Nc.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==on&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ce(1,1),r.normalTexture.scale!==void 0)){let d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==on&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==on){let d=r.emissiveFactor;a.emissive=new Ie().setRGB(d[0],d[1],d[2],Xt)}return r.emissiveTexture!==void 0&&o!==on&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,pt)),Promise.all(c).then(function(){let d=new o(a);return r.name&&(d.name=r.name),Hn(d,r),t.associations.set(d,{materials:e}),r.extensions&&Yi(s,d,r),d})}createUniqueName(e){let t=at.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[We.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Fd(l,a,t)})}let o=[];for(let a=0,l=e.length;aIc(f,Or)):c.mode===fn.TRIANGLE_FAN&&(u=u.then(f=>Ic(f,Os))),s[h]={primitive:c,promise:u},o.push(u)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l0&&mx(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Hn(p,r),m.extensions&&Yi(s,p,m),t.assignFinalMaterial(p),d.push(p)}for(let f=0,g=d.length;f0){let f=h.userData.pivot,g=d[0];h.pivot=new D().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],g.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new bs:c.length>1?h=new Mn:c.length===1?h=c[0]:h=new dt,h!==c[0])for(let d=0,u=c.length;d1){let d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new Mn;n.name&&(r.name=s.createUniqueName(n.name)),Hn(r,n),n.extensions&&Yi(t,r,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l{let d=new Map;for(let[u,f]of s.associations)(u instanceof $t||u instanceof At)&&d.set(u,f);return h.traverse(u=>{let f=s.associations.get(u);f!=null&&d.set(u,f)}),d};return s.associations=c(r),r})}_createAnimationTracks(e,t,n,s,r){let o=[],a=e.name?e.name:e.uuid,l=[];function c(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}Ei[r.path]===Ei.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(a);let h;switch(Ei[r.path]){case Ei.weights:h=ei;break;case Ei.rotation:h=ti;break;case Ei.translation:case Ei.scale:h=xi;break;default:switch(n.itemSize){case 1:h=ei;break;case 2:case 3:default:h=xi;break}break}let d=s.interpolation!==void 0?dx[s.interpolation]:Fi,u=this._getArrayFromAccessor(n);for(let f=0,g=l.length;fMath.PI&&(n-=tn),s<-Math.PI?s+=tn:s>Math.PI&&(s-=tn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(It.setFromSpherical(this._spherical),It.applyQuaternion(this._quatInverse),t.copy(this.target).add(It),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=It.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new D(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new D(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=It.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(qa.origin.copy(this.object.position),qa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(qa.direction))oh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>oh||this._lastTargetPosition.distanceToSquared(this.target)>oh?(this.dispatchEvent(Bd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?tn/60*this.autoRotateSpeed*e:tn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){It.setFromMatrixColumn(t,0),It.multiplyScalar(-e),this._panOffset.add(It)}_panUp(e,t){this.screenSpacePanning===!0?It.setFromMatrixColumn(t,1):(It.setFromMatrixColumn(t,0),It.crossVectors(this.object.up,It)),It.multiplyScalar(e),this._panOffset.add(It)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;It.copy(s).sub(this.target);let r=It.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tn.aborted||document.hidden||!l||s.matches||a||c||r.size>0||o.size>0,v=M=>{d=0,!g()&&(f!==void 0&&e(Math.min((M-f)/1e3,.1)),f=M,d=requestAnimationFrame(v))};function m(){if(cancelAnimationFrame(d),clearTimeout(u),d=0,f=void 0,g())return;let M=h-performance.now();M>0?u=setTimeout(m,M):d=requestAnimationFrame(v)}let p=()=>{h=performance.now()+3e4,m()};i.addEventListener("pointerenter",M=>{M.pointerType!=="touch"&&(a=!0,p())},{signal:n}),i.addEventListener("pointerleave",()=>{a=!1,p()},{signal:n}),i.addEventListener("pointermove",p,{signal:n}),document.addEventListener("pointerdown",M=>{r.add(M.pointerId),p()},{signal:n,capture:!0});let w=M=>{r.delete(M.pointerId),p()};window.addEventListener("pointerup",w,{signal:n,capture:!0}),window.addEventListener("pointercancel",w,{signal:n,capture:!0}),window.addEventListener("keydown",M=>{M.isTrusted&&(o.add(M.code),p())},{signal:n,capture:!0}),window.addEventListener("keyup",M=>{M.isTrusted&&(o.delete(M.code),p())},{signal:n,capture:!0}),document.addEventListener("wheel",p,{signal:n,passive:!0}),window.addEventListener("blur",()=>{r.clear(),o.clear(),a=!1,p()},{signal:n}),document.addEventListener("visibilitychange",p,{signal:n}),document.addEventListener("document-viewer:open",()=>{c=!0,p()},{signal:n}),document.addEventListener("document-viewer:close",()=>{c=!1,p()},{signal:n}),s.addEventListener("change",p,{signal:n});let R=new IntersectionObserver(M=>{l=M.some(S=>S.isIntersecting),m()});return R.observe(i),m(),{dispose(){t.abort(),cancelAnimationFrame(d),clearTimeout(u),R.disconnect()}}}function Za(i,e=Dt?.BASE_URL??"/"){if(!i.startsWith("/")||i.startsWith("//"))return i;let t=e.replace(/\/$/,"");return!t||i===t||i.startsWith(`${t}/`)?i:`${t}${i}`}var Nx=.0037,Ka={width:422,height:534},lh=[{bit:1024,shape:"circle",x0:94,y0:402,x1:141,y1:448},{bit:8192,shape:"circle",x0:50,y0:446,x1:96,y1:493},{bit:2048,shape:"box",x0:297,y0:403,x1:333,y1:439},{bit:256,shape:"box",x0:262,y0:439,x1:298,y1:475},{bit:512,shape:"box",x0:332,y0:439,x1:368,y1:475},{bit:4096,shape:"box",x0:297,y0:474,x1:333,y1:510},{bit:16384,shape:"pill",x0:161,y0:471,x1:192,y1:502},{bit:32,shape:"pill",x0:196,y0:471,x1:227,y1:502}];function Dx(i,e){let t=i*Ka.width,n=e*Ka.height;return lh.find(s=>t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1)?.bit??0}var Gd=.05;function Wd(i,e,t,n,s,r){let o=document.createElement("canvas");o.width=640,o.height=438;let a=o.getContext("2d");if(!a)throw new Error("Canvas rendering is unavailable.");let l=a,c=new Va({alpha:!0,antialias:!0});c.setPixelRatio(Math.min(window.devicePixelRatio,2)),c.outputColorSpace=pt;let h=c.domElement;h.tabIndex=0,h.setAttribute("role","img"),h.setAttribute("aria-label",r?.canvasLabel??"Interactive 3D badge. Drag to rotate, scroll to zoom. Arrow keys control the badge, Space selects. WASD and J control the gamepad."),i.append(h);let d=r?.displayOverlay,u=new ar,f=new wt(35,1,.001,2),g=new Ya(f,h);g.enablePan=!1,g.minDistance=.025,g.maxDistance=.6,u.add(new Sr(16777215,3158064,2.5));let v=new vi(16777215,3);v.position.set(-.1,.15,.3),u.add(v);let m=new vi(16777215,1.5);m.position.set(.2,-.1,-.2),u.add(m);let p=new ki(o);p.colorSpace=pt,p.flipY=!1,p.magFilter=mt,p.minFilter=gt,p.generateMipmaps=!1;let w=new on({map:p,side:Qt,toneMapped:!1,transparent:!0,depthWrite:!1}),R=new Ar,M=new Ce,S=new Map,b=new Map,A=new Set,x=r?.screen??document.getElementById("focus-badge-screen"),E=r?.full??document.getElementById("focus-badge-full"),U=r?.status??document.getElementById("model-status"),L,V,W,F=0,G=new Map,J=0,Z=0,re=!1,Y=x.getAttribute("aria-pressed")==="true",ee=!1,se=!1,Ae;function ve(){re||Z||document.hidden||(Z=requestAnimationFrame(()=>{if(Z=0,!re)try{c.render(u,f),Qe()}catch(C){s(C)}}))}function Qe(){if(!d||!V||d.hidden)return;let C=Vd(V,f,i.clientWidth,i.clientHeight,se);d.style.visibility=C?"visible":"hidden",C&&(d.style.transform=`matrix3d(${C.elements.join(",")})`)}function Be(){if(l.fillStyle="#000",l.fillRect(0,0,o.width,o.height),l.imageSmoothingEnabled=!1,l.save(),se&&(l.translate(o.width,o.height),l.rotate(Math.PI)),r?.displayFit==="stretch")l.drawImage(e,0,0,o.width,o.height);else{let C=Math.min(o.width/e.width,o.height/e.height);l.drawImage(e,(o.width-e.width*C)/2,(o.height-e.height*C)/2,e.width*C,e.height*C)}l.restore(),p.needsUpdate=!0,ve()}function Ye(){if(!W)return;let C=lh.reduce((Q,ie)=>Q|J&ie.bit,0);if(C===F)return;F=C;let{canvas:O,source:q}=W,ne=O.getContext("2d");if(ne){ne.drawImage(q,0,0,O.width,O.height),ne.save(),ne.scale(O.width/Ka.width,O.height/Ka.height),ne.globalAlpha=.6,ne.fillStyle=ne.strokeStyle="#5fed83",ne.lineCap="round",ne.lineWidth=13;for(let Q of lh)C&Q.bit&&(ne.beginPath(),Q.shape==="box"?ne.fillRect(Q.x0,Q.y0,Q.x1-Q.x0,Q.y1-Q.y0):Q.shape==="circle"?(ne.arc((Q.x0+Q.x1)/2,(Q.y0+Q.y1)/2,(Q.x1-Q.x0)/2,0,Math.PI*2),ne.fill()):(ne.moveTo(Q.x0+6,Q.y1-6),ne.lineTo(Q.x1-6,Q.y0+6),ne.stroke()));ne.restore(),W.texture.needsUpdate=!0}}function $(C){J=C;for(let[O,q]of b){let ne=!!(C&O);q.mesh.position.z=q.z-(ne?.0012:0),q.material.emissive.setHex(ne?6286723:0),q.material.emissiveIntensity=ne?.6:0}Ye(),ve()}function te(C){if(!L)return;let O=f.position.clone().sub(g.target),q=Math.min(g.maxDistance,Math.max(g.minDistance,O.length()*(C>0?1-Gd:1/(1-Gd))));f.position.copy(g.target).add(O.setLength(q)),g.update(),ve()}let xe=()=>te(1),Ne=()=>te(-1);function ge(C,O){let q=new Rt().setFromObject(C),ne=q.getSize(new D),Q=Math.max(ne.y,ne.x/f.aspect)/(2*Math.tan(f.fov*Math.PI/360))*O;return{center:q.getCenter(new D),distance:Q}}let Fe=!1;function _t(){if(Fe||!L||!V)return;let C=ge(L,1.12),O=ge(V,1.25),q=f.position.distanceTo(g.target),ne=Math.min(1,Math.max(0,(q-O.distance)/(C.distance-O.distance))),Q=O.center.lerp(C.center,ne).sub(g.target);Q.lengthSq()<1e-12||(Fe=!0,g.target.add(Q),f.position.add(Q),g.update(),Fe=!1)}function Oe(){if(!L)return;let{center:C,distance:O}=ge(Y&&V?V:L,Y?1.25:1.12);g.target.copy(C);let q=r?.idleRotation&&!Y;f.position.copy(C).add(new D(Y?0:O*(q?.2:.04),Y?0:O*(q?.08:.02),O)),g.update(),ve()}let qe=C=>{Y=C,x.setAttribute("aria-pressed",String(C)),E?.setAttribute("aria-pressed",String(!C)),Oe()},et=()=>qe(!0),Ve=()=>qe(!1);function rt(){if(!L)return;let C=new Rt().setFromObject(L).getCenter(new D);L.rotation.z=ee?Math.PI:0,L.updateMatrixWorld(!0),L.position.add(C.sub(new Rt().setFromObject(L).getCenter(new D))),L.updateMatrixWorld(!0),Y?Oe():(_t(),g.update(),ve())}function Mt(C){C!==ee&&(ee=C,rt())}function Ut(C){C!==se&&(se=C,Be())}let lt=new ResizeObserver(()=>{if(!(re||!i.clientWidth||!i.clientHeight))try{c.setSize(i.clientWidth,i.clientHeight,!1),f.aspect=i.clientWidth/i.clientHeight,f.updateProjectionMatrix(),ve()}catch(C){s(C)}});lt.observe(i);let ft=C=>{if(!L)return 0;let O=h.getBoundingClientRect();M.set((C.clientX-O.left)/O.width*2-1,-(C.clientY-O.top)/O.height*2+1),R.setFromCamera(M,f),L.updateMatrixWorld(!0);let q=R.intersectObject(L,!0).find(Q=>{let ie=Q.object,de=Array.isArray(ie.material)?ie.material:[ie.material];return ie.visible&&de.some(_e=>_e&&_e.opacity>=.5)});if(!q)return 0;let ne=S.get(q.object);return ne||(W&&q.object===W.mesh&&q.uv?Dx(q.uv.x,q.uv.y):0)},N=C=>{if(h.focus({preventScroll:!0}),C.button!==0||G.has(C.pointerId))return;let O=ft(C);if(O){C.preventDefault(),C.stopImmediatePropagation(),g.enabled=!1,G.set(C.pointerId,O);try{h.setPointerCapture(C.pointerId)}catch{}t(O,!0)}},St=C=>{let O=C===void 0?[...G.keys()]:[C];for(let q of O){let ne=G.get(q);ne&&(G.delete(q),t(ne,!1),h.hasPointerCapture(q)&&h.releasePointerCapture(q))}G.size||(g.enabled=!0)},Ke=C=>{G.has(C.pointerId)&&(C.stopImmediatePropagation(),St(C.pointerId))},T=C=>{h.style.cursor=G.size||ft(C)?"pointer":"grab"},_=C=>{C.preventDefault(),s(new Error("The browser lost its 3D graphics context."))};h.addEventListener("pointerdown",N,!0),h.addEventListener("pointermove",T),h.addEventListener("pointerup",Ke,!0),h.addEventListener("pointercancel",Ke,!0);let B=C=>St(C.pointerId);h.addEventListener("lostpointercapture",B),h.addEventListener("webglcontextlost",_);let H=()=>St();window.addEventListener("blur",H),document.addEventListener("visibilitychange",H),g.addEventListener("change",_t),g.addEventListener("change",ve),x.addEventListener("click",et),E?.addEventListener("click",Ve),r?.zoomIn?.addEventListener("click",xe),r?.zoomOut?.addEventListener("click",Ne);let K=fetch(Za("/simulator/models/github-mona-badge.glb"),{signal:n}).then(async C=>{if(!C.ok)throw new Error(`Could not load the badge model (HTTP ${C.status}).`);let O=await C.arrayBuffer();return n.throwIfAborted(),new Zi().parseAsync(O,Za("/simulator/models/"))}).then(C=>{if(L=C.scene,u.add(L),L.traverse(O=>{if(!(O instanceof yt))return;let q=Array.isArray(O.material)?O.material:[O.material];q.some(ie=>ie.name==="MONA OS display bright pixel graphics")&&(q.forEach(ie=>A.add(ie)),O.material=w,O.renderOrder=10,V=O,d&&(O.geometry.computeBoundingBox(),i.append(d))),q.some(ie=>ie.transparent)&&q.forEach(ie=>{ie.depthWrite=!1});let ne=q[0];if(ne.name==="front_top"&&ne.map?.image&&!W){let ie=ne.map.image,de=document.createElement("canvas");de.width=ie.width,de.height=ie.height,de.getContext("2d")?.drawImage(ie,0,0);let _e=new ki(de);_e.colorSpace=pt,_e.flipY=ne.map.flipY,_e.wrapS=ne.map.wrapS,_e.wrapT=ne.map.wrapT,_e.anisotropy=ne.map.anisotropy,_e.channel=ne.map.channel,ne.map.dispose(),ne.map=_e,W={mesh:O,material:ne,source:ie,canvas:de,texture:_e}}let Q=O.name.match(/Black_tactile_control_(left|middle|right|up|down)$/);if(Q){let ie={left:16,middle:8,right:4,up:2,down:1}[Q[1]],de=q[0].clone();q.forEach(Pe=>A.add(Pe)),O.material=de,b.set(ie,{mesh:O,z:O.position.z,material:de}),S.set(O,ie);let _e=L.getObjectByName(O.name.replace("Black_tactile_control","Metal_button_collar"));_e&&S.set(_e,ie)}}),!V||b.size!==5)throw new Error("The badge model is missing its screen or controls.");if(ae(L),re){ce();return}if(Be(),$(J),Oe(),ee&&rt(),c.render(u,f),Qe(),!(re||n.aborted))if(i.dataset.state="ready",U.hidden=!0,x.disabled=!1,E&&(E.disabled=!1),r?.zoomIn&&(r.zoomIn.disabled=!1),r?.zoomOut&&(r.zoomOut.disabled=!1),r?.capture){let O=g.target.clone(),q=f.position.clone().sub(O),ne=Q=>{let{angle:ie}=Q.detail;if(!Number.isFinite(ie))throw new Error("Capture angle must be finite.");g.target.copy(O),f.position.copy(q).applyAxisAngle(f.up,ie).add(O),g.update(),Be(),cancelAnimationFrame(Z),Z=0,c.render(u,f)};i.addEventListener("badge:capture",ne,{signal:n}),i.dataset.captureReady="true"}else r?.idleRotation&&(Ae=Hd(i,O=>{f.position.sub(g.target).applyAxisAngle(f.up,O*.06).add(g.target),g.update(),ve()}))});function ae(C){let O=C.getObjectByName("Inside_violet_circuit_board");if(!O)return;let q=new Rt().setFromObject(O);for(let ne of["Front_electronic_assembly_face","Back_electronics_silkscreen_print"]){let Q=C.getObjectByName(ne);if(!(Q instanceof yt)||Array.isArray(Q.material))continue;let ie=new Rt().setFromObject(Q),de=ie.max.x-ie.min.x,_e=ie.max.y-ie.min.y,Pe=document.createElement("canvas");Pe.width=1024,Pe.height=Math.round(1024*_e/de);let P=Pe.width/de,le=Pe.getContext("2d");if(!le)continue;le.fillStyle="#000",le.fillRect(0,0,Pe.width,Pe.height),le.fillStyle="#fff",le.beginPath(),le.roundRect((q.min.x-ie.min.x)*P,(ie.max.y-q.max.y)*P,(q.max.x-q.min.x)*P,(q.max.y-q.min.y)*P,Nx*P),le.fill();let j=new ki(Pe);j.flipY=!1;let he=Q.material;he.alphaMap=j,he.alphaTest=.5,he.needsUpdate=!0}}function ce(){let C=new Set(A),O=new Set([p]);L?.traverse(q=>{if(q instanceof yt){q.geometry.dispose();for(let ne of Array.isArray(q.material)?q.material:[q.material])C.add(ne)}});for(let q of C){for(let ne of Object.values(q))ne?.isTexture&&O.add(ne);q.dispose()}O.forEach(q=>q.dispose())}return{ready:K,updateFrame:Be,setButtons:$,zoom:te,setRotated:Mt,setDisplayRotated:Ut,capture(C,O){if(!L||re)throw new Error("The 3D badge is not ready.");let q=document.createElement("canvas");q.width=C,q.height=O;let ne=q.getContext("2d");if(!ne)throw new Error("Image export is unavailable in this browser.");Be(),c.render(u,f);let Q=Math.min(C/h.width,O/h.height),ie=h.width*Q,de=h.height*Q;return ne.drawImage(h,(C-ie)/2,(O-de)/2,ie,de),q},setBacklight(C){w.color.setScalar(Math.max(0,Math.min(1,C))),ve()},dispose(){re||(re=!0,Ae?.dispose(),H(),cancelAnimationFrame(Z),lt.disconnect(),g.dispose(),x.removeEventListener("click",et),E?.removeEventListener("click",Ve),r?.zoomIn?.removeEventListener("click",xe),r?.zoomOut?.removeEventListener("click",Ne),window.removeEventListener("blur",H),document.removeEventListener("visibilitychange",H),h.removeEventListener("webglcontextlost",_),h.removeEventListener("lostpointercapture",B),ce(),w.dispose(),c.dispose(),d?.parentElement===i&&d.remove(),h.remove())}}}var ch=1670.7030433430377,hh=14.29,Ux=16,Xd=i=>Math.max(-32768,Math.min(32767,Math.round(i)||0));function Fx(i,e,t=0){if(typeof i.x!="number")return null;let n=i.x,s=i.y??0,r=i.z??0,o=(Math.round(t/90)%4+4)%4;return o===1?[n,s]=[-s,n]:o===2?[n,s]=[-n,-s]:o===3&&([n,s]=[s,-n]),[n*ch,-s*ch,-r*ch,(e?.beta??0)*hh,-(e?.gamma??0)*hh,-(e?.alpha??0)*hh].map(Xd)}function qd(i,e,t){let n=!1,s=null,r=()=>{s&&e(n?s.map((h,d)=>d===2||d===5?h:Xd(-h)):s)},o={setFlipped(h){n!==h&&(n=h,r())}};if(typeof window.DeviceMotionEvent!="function")return o;let a=0;window.addEventListener("devicemotion",h=>{let d=performance.now();if(d-a{i.removeEventListener("pointerup",c),i.removeEventListener("keydown",c),l.call(DeviceMotionEvent).catch(()=>{})};return i.addEventListener("pointerup",c,{signal:t}),i.addEventListener("keydown",c,{signal:t}),o}var uh=` +}`,Cc=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new _r(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new ln({vertexShader:cx,fragmentShader:hx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new xr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Pc=class extends Tn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,g=null,v=typeof XRWebGLBinding<"u",m=new Cc,p={},w=t.getContextAttributes(),R=null,M=null,S=[],b=[],A=new Ce,x=null,E=null,U=new wt;U.viewport=new nt;let L=new wt;L.viewport=new nt;let V=[U,L],W=new Yo,F=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getTargetRaySpace()},this.getControllerGrip=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getGripSpace()},this.getHand=function($){let te=S[$];return te===void 0&&(te=new vs,S[$]=te),te.getHandSpace()};function J($){let te=b.indexOf($.inputSource);if(te===-1)return;let xe=S[te];xe!==void 0&&(xe.update($.inputSource,$.frame,c||o),xe.dispatchEvent({type:$.type,data:$.inputSource}))}function Z(){s.removeEventListener("select",J),s.removeEventListener("selectstart",J),s.removeEventListener("selectend",J),s.removeEventListener("squeeze",J),s.removeEventListener("squeezestart",J),s.removeEventListener("squeezeend",J),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",re);for(let $=0;$=0&&(b[Ne]=null,S[Ne].disconnect(xe))}for(let te=0;te<$.added.length;te++){let xe=$.added[te],Ne=b.indexOf(xe);if(Ne===-1){for(let Fe=0;Fe=b.length){b.push(xe),Ne=Fe;break}else if(b[Fe]===null){b[Fe]=xe,Ne=Fe;break}if(Ne===-1)break}let ge=S[Ne];ge&&ge.connect(xe)}}let Y=new D,ee=new D;function se($,te,xe){Y.setFromMatrixPosition(te.matrixWorld),ee.setFromMatrixPosition(xe.matrixWorld);let Ne=Y.distanceTo(ee),ge=te.projectionMatrix.elements,Fe=xe.projectionMatrix.elements,_t=ge[14]/(ge[10]-1),Oe=ge[14]/(ge[10]+1),qe=(ge[9]+1)/ge[5],et=(ge[9]-1)/ge[5],Ve=(ge[8]-1)/ge[0],rt=(Fe[8]+1)/Fe[0],Mt=_t*Ve,Ut=_t*rt,lt=Ne/(-Ve+rt),ft=lt*-Ve;if(te.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(ft),$.translateZ(lt),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),ge[10]===-1)$.projectionMatrix.copy(te.projectionMatrix),$.projectionMatrixInverse.copy(te.projectionMatrixInverse);else{let N=_t+lt,St=Oe+lt,Ke=Mt-ft,T=Ut+(Ne-ft),_=qe*Oe/St*N,B=et*Oe/St*N;$.projectionMatrix.makePerspective(Ke,T,_,B,N,St),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function Ae($,te){te===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(te.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let te=$.near,xe=$.far;m.texture!==null&&(m.depthNear>0&&(te=m.depthNear),m.depthFar>0&&(xe=m.depthFar)),W.near=L.near=U.near=te,W.far=L.far=U.far=xe,(F!==W.near||G!==W.far)&&(s.updateRenderState({depthNear:W.near,depthFar:W.far}),F=W.near,G=W.far),W.layers.mask=$.layers.mask|6,U.layers.mask=W.layers.mask&-5,L.layers.mask=W.layers.mask&-3;let Ne=$.parent,ge=W.cameras;Ae(W,Ne);for(let Fe=0;Fe0&&(m.alphaTest.value=p.alphaTest);let w=e.get(p),R=w.envMap,M=w.envMapRotation;R&&(m.envMap.value=R,m.envMapRotation.value.setFromMatrix4(ux.makeRotationFromEuler(M)).transpose(),R.isCubeTexture&&R.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Nd),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,w,R){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=R*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function u(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,w){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===qt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){let w=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function fx(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){let b=S.program;n.uniformBlockBinding(M,b)}function c(M,S){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",w));let A=S.program;n.updateUBOMapping(M,A);let x=e.render.frame;r[M.id]!==x&&(u(M),r[M.id]=x)}function h(M){let S=d();M.__bindingPointIndex=S;let b=i.createBuffer(),A=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,A,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function d(){for(let M=0;M0&&(b+=A-x),M.__size=b,M.__cache={},this}function p(M){let S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Ee("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Ee("WebGLRenderer: Unsupported uniform value type.",M),S}function w(M){let S=M.target;S.removeEventListener("dispose",w);let b=o.indexOf(S.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function R(){for(let M in s)i.deleteBuffer(s[M]);o=[],s={},r={}}return{bind:l,update:c,dispose:R}}var px=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),zn=null;function mx(){return zn===null&&(zn=new Ts(px,16,16,wi,Rn),zn.name="DFG_LUT",zn.minFilter=gt,zn.magFilter=gt,zn.wrapS=fn,zn.wrapT=fn,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}var Va=class{constructor(e={}){let{canvas:t=ju(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=en}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let v=f,m=new Set([ia,na,ta]),p=new Set([en,An,Us,Fs,jo,Qo]),w=new Uint32Array(4),R=new Int32Array(4),M=new D,S=null,b=null,A=[],x=[],E=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=wn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let U=this,L=!1,V=null,W=null,F=null,G=null;this._outputColorSpace=pt;let J=0,Z=0,re=null,Y=-1,ee=null,se=new nt,Ae=new nt,ve=null,Qe=new Ie(0),Be=0,Ye=t.width,$=t.height,te=1,xe=null,Ne=null,ge=new nt(0,0,Ye,$),Fe=new nt(0,0,Ye,$),_t=!1,Oe=new ws,qe=!1,et=!1,Ve=new De,rt=new D,Mt=new nt,Ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},lt=!1;function ft(){return re===null?te:1}let N=n;function St(y,I){return t.getContext(y,I)}let Ke,T,_,B,H,K,ae,ce,C,O,q,ne,Q,ie,de,_e,Pe,P,le,j,he,me,oe;try{let y={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"186"}`),t.addEventListener("webglcontextlost",ct,!1),t.addEventListener("webglcontextrestored",$e,!1),t.addEventListener("webglcontextcreationerror",gn,!1),N===null){let I="webgl2";if(N=St(I,y),N===null)throw St(I)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Re()}catch(y){throw t.removeEventListener("webglcontextlost",ct,!1),t.removeEventListener("webglcontextrestored",$e,!1),t.removeEventListener("webglcontextcreationerror",gn,!1),Le("WebGLRenderer: "+y.message),y}function Re(){Ke=new S_(N),Ke.init(),he=new lx(N,Ke),T=new d_(N,Ke,e,he),_=new ox(N,Ke),T.reversedDepthBuffer&&u&&_.buffers.depth.setReversed(!0),W=N.createFramebuffer(),F=N.createFramebuffer(),G=N.createFramebuffer(),B=new w_(N),H=new q0,K=new ax(N,Ke,_,H,T,he,B),ae=new M_(U),ce=new Ap(N),me=new h_(N,ce),C=new b_(N,ce,B,me),O=new A_(N,C,ce,me,B),P=new E_(N,T,K),de=new f_(H),q=new X0(U,ae,Ke,T,me,de),ne=new dx(U,H),Q=new Z0,ie=new ex(Ke),Pe=new c_(U,ae,_,O,g,l),_e=new rx(U,O,T),oe=new fx(N,B,T,_),le=new u_(N,Ke,B),j=new T_(N,Ke,B),B.programs=q.programs,U.capabilities=T,U.extensions=Ke,U.properties=H,U.renderLists=Q,U.shadowMap=_e,U.state=_,U.info=B}v!==en&&(E=new C_(v,t.width,t.height,a,s,r));let Te=new Pc(U,N);this.xr=Te,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let y=Ke.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=Ke.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(y){y!==void 0&&(te=y,this.setSize(Ye,$,!1))},this.getSize=function(y){return y.set(Ye,$)},this.setSize=function(y,I,X=!0){if(Te.isPresenting){Ee("WebGLRenderer: Can't change size while VR device is presenting.");return}Ye=y,$=I,t.width=Math.floor(y*te),t.height=Math.floor(I*te),X===!0&&(t.style.width=y+"px",t.style.height=I+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,y,I)},this.getDrawingBufferSize=function(y){return y.set(Ye*te,$*te).floor()},this.setDrawingBufferSize=function(y,I,X){Ye=y,$=I,te=X,t.width=Math.floor(y*X),t.height=Math.floor(I*X),this.setViewport(0,0,y,I)},this.setEffects=function(y){if(v===en){Le("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let I=0;I{function pe(){if(k.forEach(function(Me){let Se=H.get(Me).currentProgram;(Se===void 0||Se.isReady())&&k.delete(Me)}),k.size===0){z(y);return}setTimeout(pe,10)}Ke.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let nl=null;function gf(y){nl&&nl(y)}function Sh(){Ci.stop()}function bh(){Ci.start()}let Ci=new Ad;Ci.setAnimationLoop(gf),typeof self<"u"&&Ci.setContext(self),this.setAnimationLoop=function(y){nl=y,Te.setAnimationLoop(y),y===null?Ci.stop():Ci.start()},Te.addEventListener("sessionstart",Sh),Te.addEventListener("sessionend",bh),this.render=function(y,I){if(I!==void 0&&I.isCamera!==!0){Le("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;V!==null&&V.renderStart(y,I);let X=Te.enabled===!0&&Te.isPresenting===!0,k=E!==null&&(re===null||X)&&E.begin(U,re);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(I),I=Te.getCamera()),y.isScene===!0&&y.onBeforeRender(U,y,I,re),b=ie.get(y,x.length),b.init(I),b.state.textureUnits=K.getTextureUnits(),x.push(b),Ve.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),Oe.setFromProjectionMatrix(Ve,Mn,I.reversedDepth),et=this.localClippingEnabled,qe=de.init(this.clippingPlanes,et),S=Q.get(y,A.length),S.init(),A.push(S),Te.enabled===!0&&Te.isPresenting===!0){let Me=U.xr.getDepthSensingMesh();Me!==null&&il(Me,I,-1/0,U.sortObjects)}il(y,I,0,U.sortObjects),S.finish(),V!==null&&V.updateLights(b.state.lightsArray),U.sortObjects===!0&&S.sort(xe,Ne),lt=Te.enabled===!1||Te.isPresenting===!1||Te.hasDepthSensing()===!1,lt&&Pe.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&de.beginShadows();let z=b.state.shadowsArray;if(_e.render(z,y,I),qe===!0&&de.endShadows(),(k&&E.hasRenderPass())===!1){let Me=S.opaque,fe=S.transmissive;if(b.setupLights(),I.isArrayCamera){let Se=I.cameras;if(fe.length>0)for(let we=0,ke=Se.length;we0&&wh(Me,fe,y,I),lt&&Pe.render(y),Th(S,y,I)}re!==null&&Z===0&&(K.updateMultisampleRenderTarget(re),K.updateRenderTargetMipmap(re)),k&&E.end(U),y.isScene===!0&&y.onAfterRender(U,y,I),me.resetDefaultState(),Y=-1,ee=null,x.pop(),x.length>0?(b=x[x.length-1],K.setTextureUnits(b.state.textureUnits),qe===!0&&de.setGlobalState(U.clippingPlanes,b.state.camera)):b=null,A.pop(),A.length>0?S=A[A.length-1]:S=null,V!==null&&V.renderEnd()};function il(y,I,X,k){if(y.visible===!1)return;if(y.layers.test(I.layers)){if(y.isGroup)X=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(I);else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight)b.pushLight(y),y.castShadow&&b.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||y.intersectsFrustum(Oe)){k&&Mt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Ve);let Me=O.update(y),fe=y.material;fe.visible&&S.push(y,Me,fe,X,Mt.z,null,I)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||y.intersectsFrustum(Oe))){let Me=O.update(y),fe=y.material;if(k&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Mt.copy(y.boundingSphere.center)):(Me.boundingSphere===null&&Me.computeBoundingSphere(),Mt.copy(Me.boundingSphere.center)),Mt.applyMatrix4(y.matrixWorld).applyMatrix4(Ve)),Array.isArray(fe)){let Se=Me.groups;for(let we=0,ke=Se.length;we0&&Xr(z,I,X),pe.length>0&&Xr(pe,I,X),Me.length>0&&Xr(Me,I,X),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function wh(y,I,X,k){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[k.id]===void 0){let be=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[k.id]=new Zt(1,1,{generateMipmaps:!0,type:be?Rn:en,minFilter:En,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:He.workingColorSpace})}let pe=b.state.transmissionRenderTarget[k.id],Me=k.viewport||se;pe.setSize(Me.z*U.transmissionResolutionScale,Me.w*U.transmissionResolutionScale);let fe=U.getRenderTarget(),Se=U.getActiveCubeFace(),we=U.getActiveMipmapLevel();U.setRenderTarget(pe),U.getClearColor(Qe),Be=U.getClearAlpha(),Be<1&&U.setClearColor(16777215,.5),U.clear(),lt&&Pe.render(X);let ke=U.toneMapping;U.toneMapping=wn;let Xe=k.viewport;if(k.viewport!==void 0&&(k.viewport=void 0),b.setupLightsView(k),qe===!0&&de.setGlobalState(U.clippingPlanes,k),Xr(y,X,k),K.updateMultisampleRenderTarget(pe),K.updateRenderTargetMipmap(pe),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Je=0,bt=I.length;Je0,k.currentProgram=Xe,k.uniformsList=null,Xe}function Ah(y){if(y.uniformsList===null){let I=y.currentProgram.getUniforms();y.uniformsList=zs.seqWithValue(I.seq,y.uniforms)}return y.uniformsList}function Rh(y,I){let X=H.get(y);X.outputColorSpace=I.outputColorSpace,X.batching=I.batching,X.batchingColor=I.batchingColor,X.instancing=I.instancing,X.instancingColor=I.instancingColor,X.instancingMorph=I.instancingMorph,X.skinning=I.skinning,X.morphTargets=I.morphTargets,X.morphNormals=I.morphNormals,X.morphColors=I.morphColors,X.morphTargetsCount=I.morphTargetsCount,X.numClippingPlanes=I.numClippingPlanes,X.numIntersection=I.numClipIntersection,X.vertexAlphas=I.vertexAlphas,X.vertexTangents=I.vertexTangents,X.toneMapping=I.toneMapping}function _f(y,I){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(I.matrixWorld);for(let X=0,k=y.length;X0),be=!!X.morphAttributes.position,Je=!!X.morphAttributes.normal,bt=!!X.morphAttributes.color,ut=wn;k.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(ut=U.toneMapping);let ot=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ft=ot!==void 0?ot.length:0,ye=H.get(k),Ht=b.state.lights;if(qe===!0&&(et===!0||y!==ee)){let ht=y===ee&&k.id===Y;de.setState(k,y,ht)}let Ze=!1;k.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Ht.state.version||ye.outputColorSpace!==fe||z.isBatchedMesh&&ye.batching===!1||!z.isBatchedMesh&&ye.batching===!0||z.isBatchedMesh&&ye.batchingColor===!0&&z._colorsTexture===null||z.isBatchedMesh&&ye.batchingColor===!1&&z._colorsTexture!==null||z.isInstancedMesh&&ye.instancing===!1||!z.isInstancedMesh&&ye.instancing===!0||z.isSkinnedMesh&&ye.skinning===!1||!z.isSkinnedMesh&&ye.skinning===!0||z.isInstancedMesh&&ye.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&ye.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&ye.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&ye.instancingMorph===!1&&z.morphTexture!==null||ye.envMap!==we||k.fog===!0&&ye.fog!==pe||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==de.numPlanes||ye.numIntersection!==de.numIntersection)||ye.vertexAlphas!==ke||ye.vertexTangents!==Xe||ye.morphTargets!==be||ye.morphNormals!==Je||ye.morphColors!==bt||ye.toneMapping!==ut||ye.morphTargetsCount!==Ft||!!ye.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ze=!0):(Ze=!0,ye.__version=k.version);let un=ye.currentProgram;Ze===!0&&(un=qr(k,I,z),V&&k.isNodeMaterial&&V.onUpdateProgram(k,un,ye));let In=!1,oi=!1,$i=!1,st=un.getUniforms(),xt=ye.uniforms;if(_.useProgram(un.program)&&(In=!0,oi=!0,$i=!0),k.id!==Y&&(Y=k.id,oi=!0),ye.needsLights){let ht=_f(b.state.lightProbeGridArray,z);ye.lightProbeGrid!==ht&&(ye.lightProbeGrid=ht,oi=!0)}if(In||ee!==y){_.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),st.setValue(N,"projectionMatrix",y.projectionMatrix),st.setValue(N,"viewMatrix",y.matrixWorldInverse);let li=st.map.cameraPosition;li!==void 0&&li.setValue(N,rt.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&st.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(k.isMeshPhongMaterial||k.isMeshToonMaterial||k.isMeshLambertMaterial||k.isMeshBasicMaterial||k.isMeshStandardMaterial||k.isShaderMaterial)&&st.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),ee!==y&&(ee=y,oi=!0,$i=!0)}if(ye.needsLights&&(Ht.state.sunShadowMap.length>0&&st.setValue(N,"sunShadowMap",Ht.state.sunShadowMap,K),Ht.state.directionalShadowMap.length>0&&st.setValue(N,"directionalShadowMap",Ht.state.directionalShadowMap,K),Ht.state.spotShadowMap.length>0&&st.setValue(N,"spotShadowMap",Ht.state.spotShadowMap,K),Ht.state.pointShadowMap.length>0&&st.setValue(N,"pointShadowMap",Ht.state.pointShadowMap,K)),z.isSkinnedMesh){st.setOptional(N,z,"bindMatrix"),st.setOptional(N,z,"bindMatrixInverse");let ht=z.skeleton;ht&&(ht.boneTexture===null&&ht.computeBoneTexture(),st.setValue(N,"boneTexture",ht.boneTexture,K))}z.isBatchedMesh&&(st.setOptional(N,z,"batchingTexture"),st.setValue(N,"batchingTexture",z._matricesTexture,K),st.setOptional(N,z,"batchingIdTexture"),st.setValue(N,"batchingIdTexture",z._indirectTexture,K),st.setOptional(N,z,"batchingColorTexture"),z._colorsTexture!==null&&st.setValue(N,"batchingColorTexture",z._colorsTexture,K));let ai=X.morphAttributes;if((ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)&&P.update(z,X,un),(oi||ye.receiveShadow!==z.receiveShadow)&&(ye.receiveShadow=z.receiveShadow,st.setValue(N,"receiveShadow",z.receiveShadow)),(k.isMeshStandardMaterial||k.isMeshLambertMaterial||k.isMeshPhongMaterial)&&k.envMap===null&&I.environment!==null&&(xt.envMapIntensity.value=I.environmentIntensity),xt.dfgLUT!==void 0&&(xt.dfgLUT.value=mx()),oi){if(st.setValue(N,"toneMappingExposure",U.toneMappingExposure),ye.needsLights&&yf(xt,$i),pe&&k.fog===!0&&ne.refreshFogUniforms(xt,pe),ne.refreshMaterialUniforms(xt,k,te,$,b.state.transmissionRenderTarget[y.id]),ye.needsLights&&ye.lightProbeGrid){let ht=ye.lightProbeGrid;xt.probesSH.value=ht.texture,xt.probesMin.value.copy(ht.boundingBox.min),xt.probesMax.value.copy(ht.boundingBox.max),xt.probesResolution.value.copy(ht.resolution)}zs.upload(N,Ah(ye),xt,K)}if(k.isShaderMaterial&&k.uniformsNeedUpdate===!0&&(zs.upload(N,Ah(ye),xt,K),k.uniformsNeedUpdate=!1),k.isSpriteMaterial&&st.setValue(N,"center",z.center),st.setValue(N,"modelViewMatrix",z.modelViewMatrix),st.setValue(N,"normalMatrix",z.normalMatrix),st.setValue(N,"modelMatrix",z.matrixWorld),k.uniformsGroups!==void 0){let ht=k.uniformsGroups;for(let li=0,Ji=ht.length;li0&&K.useMultisampledRTT(y)===!1?k=H.get(y).__webglMultisampledFramebuffer:Array.isArray(we)?k=we[X]:k=we,se.copy(y.viewport),Ae.copy(y.scissor),ve=y.scissorTest}else se.copy(ge).multiplyScalar(te).floor(),Ae.copy(Fe).multiplyScalar(te).floor(),ve=_t;if(X!==0&&(k=W),_.bindFramebuffer(N.FRAMEBUFFER,k)&&_.drawBuffers(y,k),_.viewport(se),_.scissor(Ae),_.setScissorTest(ve),z){let fe=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+I,fe.__webglTexture,X)}else if(pe){let fe=I;for(let Se=0;Se1&&N.readBuffer(N.COLOR_ATTACHMENT0+fe);let be=Ch(we);if(be.__formatReadable===!1){Le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(be.__typeReadable===!1){Le("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=y.width-k&&X>=0&&X<=y.height-z&&N.readPixels(I,X,k,z,he.convert(ke),he.convert(Xe),pe)}finally{let we=re!==null?H.get(re).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,we)}}},this.readRenderTargetPixelsAsync=async function(y,I,X,k,z,pe,Me,fe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Me!==void 0&&(Se=Se[Me]),Se)if(I>=0&&I<=y.width-k&&X>=0&&X<=y.height-z){_.bindFramebuffer(N.FRAMEBUFFER,Se);let we=y.textures[fe],ke=we.format,Xe=we.type;y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+fe);let be=Ch(we);if(be.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(be.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Je=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Je),N.bufferData(N.PIXEL_PACK_BUFFER,pe.byteLength,N.STREAM_READ),N.readPixels(I,X,k,z,he.convert(ke),he.convert(Xe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let bt=re!==null?H.get(re).__webglFramebuffer:null;_.bindFramebuffer(N.FRAMEBUFFER,bt);let ut=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await ed(N,ut,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Je),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,pe),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(Je),N.deleteSync(ut),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,I=null,X=0){let k=Math.pow(2,-X),z=Math.floor(y.image.width*k),pe=Math.floor(y.image.height*k),Me=I!==null?I.x:0,fe=I!==null?I.y:0;K.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,Me,fe,z,pe),_.unbindTexture()},this.copyTextureToTexture=function(y,I,X=null,k=null,z=0,pe=0){let Me,fe,Se,we,ke,Xe,be,Je,bt,ut=y.isCompressedTexture?y.mipmaps[pe]:y.image;if(X!==null)Me=X.max.x-X.min.x,fe=X.max.y-X.min.y,Se=X.isBox3?X.max.z-X.min.z:1,we=X.min.x,ke=X.min.y,Xe=X.isBox3?X.min.z:0;else{let xt=Math.pow(2,-z);Me=Math.floor(ut.width*xt),fe=Math.floor(ut.height*xt),y.isDataArrayTexture?Se=ut.depth:y.isData3DTexture?Se=Math.floor(ut.depth*xt):Se=1,we=0,ke=0,Xe=0}k!==null?(be=k.x,Je=k.y,bt=k.z):(be=0,Je=0,bt=0);let ot=he.convert(I.format),Ft=he.convert(I.type),ye;I.isData3DTexture?(K.setTexture3D(I,0),ye=N.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(K.setTexture2DArray(I,0),ye=N.TEXTURE_2D_ARRAY):(K.setTexture2D(I,0),ye=N.TEXTURE_2D),_.activeTexture(N.TEXTURE0),_.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,I.flipY),_.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),_.pixelStorei(N.UNPACK_ALIGNMENT,I.unpackAlignment);let Ht=_.getParameter(N.UNPACK_ROW_LENGTH),Ze=_.getParameter(N.UNPACK_IMAGE_HEIGHT),un=_.getParameter(N.UNPACK_SKIP_PIXELS),In=_.getParameter(N.UNPACK_SKIP_ROWS),oi=_.getParameter(N.UNPACK_SKIP_IMAGES);_.pixelStorei(N.UNPACK_ROW_LENGTH,ut.width),_.pixelStorei(N.UNPACK_IMAGE_HEIGHT,ut.height),_.pixelStorei(N.UNPACK_SKIP_PIXELS,we),_.pixelStorei(N.UNPACK_SKIP_ROWS,ke),_.pixelStorei(N.UNPACK_SKIP_IMAGES,Xe);let $i=y.isDataArrayTexture||y.isData3DTexture,st=I.isDataArrayTexture||I.isData3DTexture;if(y.isDepthTexture){let xt=H.get(y),ai=H.get(I),ht=H.get(xt.__renderTarget),li=H.get(ai.__renderTarget);_.bindFramebuffer(N.READ_FRAMEBUFFER,ht.__webglFramebuffer),_.bindFramebuffer(N.DRAW_FRAMEBUFFER,li.__webglFramebuffer);for(let Ji=0;Ji=2.0 are supported."));return}let c=new rh(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(e,t){let n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}};function gx(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function vt(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}var We={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Uc=class{constructor(e){this.parser=e,this.name=We.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},Kc=class{constructor(e){this.parser=e,this.name=We.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},$c=class{constructor(e){this.parser=e,this.name=We.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=s.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},Wa=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let l=s.byteOffset||0,c=s.byteLength||0,h=s.count,d=s.byteStride,u=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,u,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){let f=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(f),h,d,u,s.mode,s.filter),f})})}else return null}},Jc=class{constructor(e){this.name=We.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let s=t.meshes[n.mesh];for(let c of s.primitives)if(c.mode!==pn.TRIANGLES&&c.mode!==pn.TRIANGLE_STRIP&&c.mode!==pn.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let h=c.pop(),d=h.isGroup?h.children:[h],u=c[0].count,f=[];for(let g of d){let v=new De,m=new D,p=new kt,w=new D(1,1,1),R=new dr(g.geometry,g.material,u);for(let S=0;S0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var Tx=new De,rh=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);s=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?this.textureLoader=new Mr(this.options.manager):this.textureLoader=new Er(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Cs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return Yi(r,a,s),Hn(a,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,h]of o.children.entries())r(h,a.children[c])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(E,b[A*l+1]),l>=3&&m.setZ(E,b[A*l+2]),l>=4&&m.setW(E,b[A*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let s=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let u=(r.samplers||{})[o.sampler]||{};return h.magFilter=Od[u.magFilter]||gt,h.minFilter=Od[u.minFilter]||En,h.wrapS=Bd[u.wrapS]||gi,h.wrapT=Bd[u.wrapT]||gi,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==mt&&h.minFilter!==gt,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());let o=s.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;let u=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(u),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(l).then(function(d){return new Promise(function(u,f){let g=u;t.isImageBitmapLoader===!0&&(g=function(v){let m=new At(v);m.needsUpdate=!0,u(m)}),t.load(ii.resolveURL(d,r.path),g,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),Hn(d,o),d.userData.mimeType=o.mimeType||bx(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[We.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[We.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=r.associations.get(o);o=r.extensions[We.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new As,$t.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Es,$t.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return zi}loadMaterial(e){let t=this,n=this.json,s=this.extensions,r=n.materials[e],o,a={},l=r.extensions||{},c=[];if(l[We.KHR_MATERIALS_UNLIT]){let d=s[We.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{let d=r.pbrMetallicRoughness||{};if(a.color=new Ie(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){let u=d.baseColorFactor;a.color.setRGB(u[0],u[1],u[2],Xt),a.opacity=u[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,pt)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(u){return u.getMaterialType&&u.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(u){return u.extendMaterialParams&&u.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Qt);let h=r.alphaMode||Nc.OPAQUE;if(h===Nc.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Nc.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==an&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ce(1,1),r.normalTexture.scale!==void 0)){let d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==an&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==an){let d=r.emissiveFactor;a.emissive=new Ie().setRGB(d[0],d[1],d[2],Xt)}return r.emissiveTexture!==void 0&&o!==an&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,pt)),Promise.all(c).then(function(){let d=new o(a);return r.name&&(d.name=r.name),Hn(d,r),t.associations.set(d,{materials:e}),r.extensions&&Yi(s,d,r),d})}createUniqueName(e){let t=at.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[We.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return kd(l,a,t)})}let o=[];for(let a=0,l=e.length;aIc(f,Or)):c.mode===pn.TRIANGLE_FAN&&(u=u.then(f=>Ic(f,Os))),s[h]={primitive:c,promise:u},o.push(u)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,s=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l0&&Mx(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),Hn(p,r),m.extensions&&Yi(s,p,m),t.assignFinalMaterial(p),d.push(p)}for(let f=0,g=d.length;f0){let f=h.userData.pivot,g=d[0];h.pivot=new D().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],g.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new bs:c.length>1?h=new Sn:c.length===1?h=c[0]:h=new dt,h!==c[0])for(let d=0,u=c.length;d1){let d=s.associations.get(h);s.associations.set(h,{...d})}return s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],s=this,r=new Sn;n.name&&(r.name=s.createUniqueName(n.name)),Hn(r,n),n.extensions&&Yi(t,r,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l{let d=new Map;for(let[u,f]of s.associations)(u instanceof $t||u instanceof At)&&d.set(u,f);return h.traverse(u=>{let f=s.associations.get(u);f!=null&&d.set(u,f)}),d};return s.associations=c(r),r})}_createAnimationTracks(e,t,n,s,r){let o=[],a=e.name?e.name:e.uuid,l=[];function c(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}Ei[r.path]===Ei.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(a);let h;switch(Ei[r.path]){case Ei.weights:h=ei;break;case Ei.rotation:h=ti;break;case Ei.translation:case Ei.scale:h=xi;break;default:switch(n.itemSize){case 1:h=ei;break;case 2:case 3:default:h=xi;break}break}let d=s.interpolation!==void 0?xx[s.interpolation]:Fi,u=this._getArrayFromAccessor(n);for(let f=0,g=l.length;fMath.PI&&(n-=tn),s<-Math.PI?s+=tn:s>Math.PI&&(s-=tn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(It.setFromSpherical(this._spherical),It.applyQuaternion(this._quatInverse),t.copy(this.target).add(It),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=It.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new D(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new D(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=It.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(qa.origin.copy(this.object.position),qa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(qa.direction))oh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>oh||this._lastTargetPosition.distanceToSquared(this.target)>oh?(this.dispatchEvent(Vd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?tn/60*this.autoRotateSpeed*e:tn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){It.setFromMatrixColumn(t,0),It.multiplyScalar(-e),this._panOffset.add(It)}_panUp(e,t){this.screenSpacePanning===!0?It.setFromMatrixColumn(t,1):(It.setFromMatrixColumn(t,0),It.crossVectors(this.object.up,It)),It.multiplyScalar(e),this._panOffset.add(It)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;It.copy(s).sub(this.target);let r=It.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tn.aborted||document.hidden||!l||s.matches||a||c||r.size>0||o.size>0,v=M=>{d=0,!g()&&(f!==void 0&&e(Math.min((M-f)/1e3,.1)),f=M,d=requestAnimationFrame(v))};function m(){if(cancelAnimationFrame(d),clearTimeout(u),d=0,f=void 0,g())return;let M=h-performance.now();M>0?u=setTimeout(m,M):d=requestAnimationFrame(v)}let p=()=>{h=performance.now()+3e4,m()};i.addEventListener("pointerenter",M=>{M.pointerType!=="touch"&&(a=!0,p())},{signal:n}),i.addEventListener("pointerleave",()=>{a=!1,p()},{signal:n}),i.addEventListener("pointermove",p,{signal:n}),document.addEventListener("pointerdown",M=>{r.add(M.pointerId),p()},{signal:n,capture:!0});let w=M=>{r.delete(M.pointerId),p()};window.addEventListener("pointerup",w,{signal:n,capture:!0}),window.addEventListener("pointercancel",w,{signal:n,capture:!0}),window.addEventListener("keydown",M=>{M.isTrusted&&(o.add(M.code),p())},{signal:n,capture:!0}),window.addEventListener("keyup",M=>{M.isTrusted&&(o.delete(M.code),p())},{signal:n,capture:!0}),document.addEventListener("wheel",p,{signal:n,passive:!0}),window.addEventListener("blur",()=>{r.clear(),o.clear(),a=!1,p()},{signal:n}),document.addEventListener("visibilitychange",p,{signal:n}),document.addEventListener("document-viewer:open",()=>{c=!0,p()},{signal:n}),document.addEventListener("document-viewer:close",()=>{c=!1,p()},{signal:n}),s.addEventListener("change",p,{signal:n});let R=new IntersectionObserver(M=>{l=M.some(S=>S.isIntersecting),m()});return R.observe(i),m(),{dispose(){t.abort(),cancelAnimationFrame(d),clearTimeout(u),R.disconnect()}}}function Za(i,e=Dt?.BASE_URL??"/"){if(!i.startsWith("/")||i.startsWith("//"))return i;let t=e.replace(/\/$/,"");return!t||i===t||i.startsWith(`${t}/`)?i:`${t}${i}`}var kx=.0037,Ka={width:422,height:534},lh=[{bit:1024,shape:"circle",x0:94,y0:402,x1:141,y1:448},{bit:8192,shape:"circle",x0:50,y0:446,x1:96,y1:493},{bit:2048,shape:"box",x0:297,y0:403,x1:333,y1:439},{bit:256,shape:"box",x0:262,y0:439,x1:298,y1:475},{bit:512,shape:"box",x0:332,y0:439,x1:368,y1:475},{bit:4096,shape:"box",x0:297,y0:474,x1:333,y1:510},{bit:16384,shape:"pill",x0:161,y0:471,x1:192,y1:502},{bit:32,shape:"pill",x0:196,y0:471,x1:227,y1:502}];function zx(i,e){let t=i*Ka.width,n=e*Ka.height;return lh.find(s=>t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1)?.bit??0}var qd=.05;function Yd(i,e,t,n,s,r){let o=document.createElement("canvas");o.width=640,o.height=438;let a=o.getContext("2d");if(!a)throw new Error("Canvas rendering is unavailable.");let l=a,c=new Va({alpha:!0,antialias:!0});c.setPixelRatio(Math.min(window.devicePixelRatio,2)),c.outputColorSpace=pt;let h=c.domElement;h.tabIndex=0,h.setAttribute("role","img"),h.setAttribute("aria-label",r?.canvasLabel??"Interactive 3D badge. Drag to rotate, scroll to zoom. Arrow keys control the badge, Space selects. WASD and J control the gamepad."),i.append(h);let d=r?.displayOverlay,u=new ar,f=new wt(35,1,.001,2),g=new Ya(f,h);g.enablePan=!1,g.minDistance=.025,g.maxDistance=.6,u.add(new Sr(16777215,3158064,2.5));let v=new vi(16777215,3);v.position.set(-.1,.15,.3),u.add(v);let m=new vi(16777215,1.5);m.position.set(.2,-.1,-.2),u.add(m);let p=new ki(o);p.colorSpace=pt,p.flipY=!1,p.magFilter=mt,p.minFilter=gt,p.generateMipmaps=!1;let w=new an({map:p,side:Qt,toneMapped:!1,transparent:!0,depthWrite:!1}),R=new Ar,M=new Ce,S=new Map,b=new Map,A=new Set,x=r?.screen??document.getElementById("focus-badge-screen"),E=r?.full??document.getElementById("focus-badge-full"),U=r?.status??document.getElementById("model-status"),L,V,W,F=0,G=new Map,J=0,Z=0,re=!1,Y=x.getAttribute("aria-pressed")==="true",ee=!1,se=!1,Ae;function ve(){re||Z||document.hidden||(Z=requestAnimationFrame(()=>{if(Z=0,!re)try{c.render(u,f),Qe()}catch(C){s(C)}}))}function Qe(){if(!d||!V||d.hidden)return;let C=Wd(V,f,i.clientWidth,i.clientHeight,se);d.style.visibility=C?"visible":"hidden",C&&(d.style.transform=`matrix3d(${C.elements.join(",")})`)}function Be(){if(l.fillStyle="#000",l.fillRect(0,0,o.width,o.height),l.imageSmoothingEnabled=!1,l.save(),se&&(l.translate(o.width,o.height),l.rotate(Math.PI)),r?.displayFit==="stretch")l.drawImage(e,0,0,o.width,o.height);else{let C=Math.min(o.width/e.width,o.height/e.height);l.drawImage(e,(o.width-e.width*C)/2,(o.height-e.height*C)/2,e.width*C,e.height*C)}l.restore(),p.needsUpdate=!0,ve()}function Ye(){if(!W)return;let C=lh.reduce((Q,ie)=>Q|J&ie.bit,0);if(C===F)return;F=C;let{canvas:O,source:q}=W,ne=O.getContext("2d");if(ne){ne.drawImage(q,0,0,O.width,O.height),ne.save(),ne.scale(O.width/Ka.width,O.height/Ka.height),ne.globalAlpha=.6,ne.fillStyle=ne.strokeStyle="#5fed83",ne.lineCap="round",ne.lineWidth=13;for(let Q of lh)C&Q.bit&&(ne.beginPath(),Q.shape==="box"?ne.fillRect(Q.x0,Q.y0,Q.x1-Q.x0,Q.y1-Q.y0):Q.shape==="circle"?(ne.arc((Q.x0+Q.x1)/2,(Q.y0+Q.y1)/2,(Q.x1-Q.x0)/2,0,Math.PI*2),ne.fill()):(ne.moveTo(Q.x0+6,Q.y1-6),ne.lineTo(Q.x1-6,Q.y0+6),ne.stroke()));ne.restore(),W.texture.needsUpdate=!0}}function $(C){J=C;for(let[O,q]of b){let ne=!!(C&O);q.mesh.position.z=q.z-(ne?.0012:0),q.material.emissive.setHex(ne?6286723:0),q.material.emissiveIntensity=ne?.6:0}Ye(),ve()}function te(C){if(!L)return;let O=f.position.clone().sub(g.target),q=Math.min(g.maxDistance,Math.max(g.minDistance,O.length()*(C>0?1-qd:1/(1-qd))));f.position.copy(g.target).add(O.setLength(q)),g.update(),ve()}let xe=()=>te(1),Ne=()=>te(-1);function ge(C,O){let q=new Rt().setFromObject(C),ne=q.getSize(new D),Q=Math.max(ne.y,ne.x/f.aspect)/(2*Math.tan(f.fov*Math.PI/360))*O;return{center:q.getCenter(new D),distance:Q}}let Fe=!1;function _t(){if(Fe||!L||!V)return;let C=ge(L,1.12),O=ge(V,1.25),q=f.position.distanceTo(g.target),ne=Math.min(1,Math.max(0,(q-O.distance)/(C.distance-O.distance))),Q=O.center.lerp(C.center,ne).sub(g.target);Q.lengthSq()<1e-12||(Fe=!0,g.target.add(Q),f.position.add(Q),g.update(),Fe=!1)}function Oe(){if(!L)return;let{center:C,distance:O}=ge(Y&&V?V:L,Y?1.25:1.12);g.target.copy(C);let q=r?.idleRotation&&!Y;f.position.copy(C).add(new D(Y?0:O*(q?.2:.04),Y?0:O*(q?.08:.02),O)),g.update(),ve()}let qe=C=>{Y=C,x.setAttribute("aria-pressed",String(C)),E?.setAttribute("aria-pressed",String(!C)),Oe()},et=()=>qe(!0),Ve=()=>qe(!1);function rt(){if(!L)return;let C=new Rt().setFromObject(L).getCenter(new D);L.rotation.z=ee?Math.PI:0,L.updateMatrixWorld(!0),L.position.add(C.sub(new Rt().setFromObject(L).getCenter(new D))),L.updateMatrixWorld(!0),Y?Oe():(_t(),g.update(),ve())}function Mt(C){C!==ee&&(ee=C,rt())}function Ut(C){C!==se&&(se=C,Be())}let lt=new ResizeObserver(()=>{if(!(re||!i.clientWidth||!i.clientHeight))try{c.setSize(i.clientWidth,i.clientHeight,!1),f.aspect=i.clientWidth/i.clientHeight,f.updateProjectionMatrix(),ve()}catch(C){s(C)}});lt.observe(i);let ft=C=>{if(!L)return 0;let O=h.getBoundingClientRect();M.set((C.clientX-O.left)/O.width*2-1,-(C.clientY-O.top)/O.height*2+1),R.setFromCamera(M,f),L.updateMatrixWorld(!0);let q=R.intersectObject(L,!0).find(Q=>{let ie=Q.object,de=Array.isArray(ie.material)?ie.material:[ie.material];return ie.visible&&de.some(_e=>_e&&_e.opacity>=.5)});if(!q)return 0;let ne=S.get(q.object);return ne||(W&&q.object===W.mesh&&q.uv?zx(q.uv.x,q.uv.y):0)},N=C=>{if(h.focus({preventScroll:!0}),C.button!==0||G.has(C.pointerId))return;let O=ft(C);if(O){C.preventDefault(),C.stopImmediatePropagation(),g.enabled=!1,G.set(C.pointerId,O);try{h.setPointerCapture(C.pointerId)}catch{}t(O,!0)}},St=C=>{let O=C===void 0?[...G.keys()]:[C];for(let q of O){let ne=G.get(q);ne&&(G.delete(q),t(ne,!1),h.hasPointerCapture(q)&&h.releasePointerCapture(q))}G.size||(g.enabled=!0)},Ke=C=>{G.has(C.pointerId)&&(C.stopImmediatePropagation(),St(C.pointerId))},T=C=>{h.style.cursor=G.size||ft(C)?"pointer":"grab"},_=C=>{C.preventDefault(),s(new Error("The browser lost its 3D graphics context."))};h.addEventListener("pointerdown",N,!0),h.addEventListener("pointermove",T),h.addEventListener("pointerup",Ke,!0),h.addEventListener("pointercancel",Ke,!0);let B=C=>St(C.pointerId);h.addEventListener("lostpointercapture",B),h.addEventListener("webglcontextlost",_);let H=()=>St();window.addEventListener("blur",H),document.addEventListener("visibilitychange",H),g.addEventListener("change",_t),g.addEventListener("change",ve),x.addEventListener("click",et),E?.addEventListener("click",Ve),r?.zoomIn?.addEventListener("click",xe),r?.zoomOut?.addEventListener("click",Ne);let K=fetch(Za("/simulator/models/github-mona-badge.glb"),{signal:n}).then(async C=>{if(!C.ok)throw new Error(`Could not load the badge model (HTTP ${C.status}).`);let O=await C.arrayBuffer();return n.throwIfAborted(),new Zi().parseAsync(O,Za("/simulator/models/"))}).then(C=>{if(L=C.scene,u.add(L),L.traverse(O=>{if(!(O instanceof yt))return;let q=Array.isArray(O.material)?O.material:[O.material];q.some(ie=>ie.name==="MONA OS display bright pixel graphics")&&(q.forEach(ie=>A.add(ie)),O.material=w,O.renderOrder=10,V=O,d&&(O.geometry.computeBoundingBox(),i.append(d))),q.some(ie=>ie.transparent)&&q.forEach(ie=>{ie.depthWrite=!1});let ne=q[0];if(ne.name==="front_top"&&ne.map?.image&&!W){let ie=ne.map.image,de=document.createElement("canvas");de.width=ie.width,de.height=ie.height,de.getContext("2d")?.drawImage(ie,0,0);let _e=new ki(de);_e.colorSpace=pt,_e.flipY=ne.map.flipY,_e.wrapS=ne.map.wrapS,_e.wrapT=ne.map.wrapT,_e.anisotropy=ne.map.anisotropy,_e.channel=ne.map.channel,ne.map.dispose(),ne.map=_e,W={mesh:O,material:ne,source:ie,canvas:de,texture:_e}}let Q=O.name.match(/Black_tactile_control_(left|middle|right|up|down)$/);if(Q){let ie={left:16,middle:8,right:4,up:2,down:1}[Q[1]],de=q[0].clone();q.forEach(Pe=>A.add(Pe)),O.material=de,b.set(ie,{mesh:O,z:O.position.z,material:de}),S.set(O,ie);let _e=L.getObjectByName(O.name.replace("Black_tactile_control","Metal_button_collar"));_e&&S.set(_e,ie)}}),!V||b.size!==5)throw new Error("The badge model is missing its screen or controls.");if(ae(L),re){ce();return}if(Be(),$(J),Oe(),ee&&rt(),c.render(u,f),Qe(),!(re||n.aborted))if(i.dataset.state="ready",U.hidden=!0,x.disabled=!1,E&&(E.disabled=!1),r?.zoomIn&&(r.zoomIn.disabled=!1),r?.zoomOut&&(r.zoomOut.disabled=!1),r?.capture){let O=g.target.clone(),q=f.position.clone().sub(O),ne=Q=>{let{angle:ie}=Q.detail;if(!Number.isFinite(ie))throw new Error("Capture angle must be finite.");g.target.copy(O),f.position.copy(q).applyAxisAngle(f.up,ie).add(O),g.update(),Be(),cancelAnimationFrame(Z),Z=0,c.render(u,f)};i.addEventListener("badge:capture",ne,{signal:n}),i.dataset.captureReady="true"}else r?.idleRotation&&(Ae=Xd(i,O=>{f.position.sub(g.target).applyAxisAngle(f.up,O*.06).add(g.target),g.update(),ve()}))});function ae(C){let O=C.getObjectByName("Inside_violet_circuit_board");if(!O)return;let q=new Rt().setFromObject(O);for(let ne of["Front_electronic_assembly_face","Back_electronics_silkscreen_print"]){let Q=C.getObjectByName(ne);if(!(Q instanceof yt)||Array.isArray(Q.material))continue;let ie=new Rt().setFromObject(Q),de=ie.max.x-ie.min.x,_e=ie.max.y-ie.min.y,Pe=document.createElement("canvas");Pe.width=1024,Pe.height=Math.round(1024*_e/de);let P=Pe.width/de,le=Pe.getContext("2d");if(!le)continue;le.fillStyle="#000",le.fillRect(0,0,Pe.width,Pe.height),le.fillStyle="#fff",le.beginPath(),le.roundRect((q.min.x-ie.min.x)*P,(ie.max.y-q.max.y)*P,(q.max.x-q.min.x)*P,(q.max.y-q.min.y)*P,kx*P),le.fill();let j=new ki(Pe);j.flipY=!1;let he=Q.material;he.alphaMap=j,he.alphaTest=.5,he.needsUpdate=!0}}function ce(){let C=new Set(A),O=new Set([p]);L?.traverse(q=>{if(q instanceof yt){q.geometry.dispose();for(let ne of Array.isArray(q.material)?q.material:[q.material])C.add(ne)}});for(let q of C){for(let ne of Object.values(q))ne?.isTexture&&O.add(ne);q.dispose()}O.forEach(q=>q.dispose())}return{ready:K,updateFrame:Be,setButtons:$,zoom:te,setRotated:Mt,setDisplayRotated:Ut,capture(C,O){if(!L||re)throw new Error("The 3D badge is not ready.");let q=document.createElement("canvas");q.width=C,q.height=O;let ne=q.getContext("2d");if(!ne)throw new Error("Image export is unavailable in this browser.");Be(),c.render(u,f);let Q=Math.min(C/h.width,O/h.height),ie=h.width*Q,de=h.height*Q;return ne.drawImage(h,(C-ie)/2,(O-de)/2,ie,de),q},setBacklight(C){w.color.setScalar(Math.max(0,Math.min(1,C))),ve()},dispose(){re||(re=!0,Ae?.dispose(),H(),cancelAnimationFrame(Z),lt.disconnect(),g.dispose(),x.removeEventListener("click",et),E?.removeEventListener("click",Ve),r?.zoomIn?.removeEventListener("click",xe),r?.zoomOut?.removeEventListener("click",Ne),window.removeEventListener("blur",H),document.removeEventListener("visibilitychange",H),h.removeEventListener("webglcontextlost",_),h.removeEventListener("lostpointercapture",B),ce(),w.dispose(),c.dispose(),d?.parentElement===i&&d.remove(),h.remove())}}}var ch=1670.7030433430377,hh=14.29,Vx=16,Zd=i=>Math.max(-32768,Math.min(32767,Math.round(i)||0));function Hx(i,e,t=0){if(typeof i.x!="number")return null;let n=i.x,s=i.y??0,r=i.z??0,o=(Math.round(t/90)%4+4)%4;return o===1?[n,s]=[-s,n]:o===2?[n,s]=[-n,-s]:o===3&&([n,s]=[s,-n]),[n*ch,-s*ch,-r*ch,(e?.beta??0)*hh,-(e?.gamma??0)*hh,-(e?.alpha??0)*hh].map(Zd)}function Kd(i,e,t){let n=!1,s=null,r=()=>{s&&e(n?s.map((h,d)=>d===2||d===5?h:Zd(-h)):s)},o={setFlipped(h){n!==h&&(n=h,r())}};if(typeof window.DeviceMotionEvent!="function")return o;let a=0;window.addEventListener("devicemotion",h=>{let d=performance.now();if(d-a{i.removeEventListener("pointerup",c),i.removeEventListener("keydown",c),l.call(DeviceMotionEvent).catch(()=>{})};return i.addEventListener("pointerup",c,{signal:t}),i.addEventListener("keydown",c,{signal:t}),o}var uh=` import builtins, js, json as _json, machine, missing_details, secrets, sys def _compat_module(name, force=False, **attributes): @@ -4586,9 +4586,9 @@ def _reset_into_msc(): powman.WAKE_DOUBLETAP = getattr(powman, "WAKE_DOUBLETAP", 254) powman.reset_into_msc = _reset_into_msc -`;var Ox=new TextEncoder,jS=16*1024*1024;function Bx(i){let e=i.split("/");if(!e.length||e.length>12||e.some(t=>!t||t==="."||t===".."||/[\\\x00-\x1f<>:"|?*]/.test(t)))throw new Error("Use a relative file path without empty folders, parent paths, or special characters.");return i}function Yd(i,e){Bx(i);let t=/\.(py|txt|json|csv|md|ini|toml|yaml|yml)$/i.test(i),n=null;if(t)try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{n=null}return{path:i,data:e,text:n}}function Zd(i){if(i.text===null)return i.data;let e=Ox.encode(i.text);if(i.data[0]!==239||i.data[1]!==187||i.data[2]!==191)return e;let t=new Uint8Array(e.length+3);return t.set([239,187,191]),t.set(e,3),t}function Kd(i){let e="",t=!1,n=!1;return i.split(` +`;var Gx=new TextEncoder,rb=16*1024*1024;function Wx(i){let e=i.split("/");if(!e.length||e.length>12||e.some(t=>!t||t==="."||t===".."||/[\\\x00-\x1f<>:"|?*]/.test(t)))throw new Error("Use a relative file path without empty folders, parent paths, or special characters.");return i}function $d(i,e){Wx(i);let t=/\.(py|txt|json|csv|md|ini|toml|yaml|yml)$/i.test(i),n=null;if(t)try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{n=null}return{path:i,data:e,text:n}}function Jd(i){if(i.text===null)return i.data;let e=Gx.encode(i.text);if(i.data[0]!==239||i.data[1]!==187||i.data[2]!==191)return e;let t=new Uint8Array(e.length+3);return t.set([239,187,191]),t.set(e,3),t}function jd(i){let e="",t=!1,n=!1;return i.split(` `).map(s=>{let r=e?s:s.replace(/^(\s*)@micropython\.(native|viper)\s*$/,"$1@editor_support.$2");for(let o=0;odocument.querySelector(i),qs=Yt("#sim"),zx=Yt("[data-model]"),Nt=Yt("[data-screen]"),Vx=Yt("[data-status]"),Cn=Yt("[data-app]"),$a=Yt("[data-output]"),dh=Yt("[data-model-rotate]"),Ws=Yt("[data-deploy]"),Hx=Yt("[data-reload]"),jd=[...document.querySelectorAll("[data-button]")],Qd=` +`)}var Qd="/system/apps",_h="monaos",nf=i=>i===_h?"MonaOS (all apps)":i,dh=i=>i?.os?"MonaOS":i?.app??"App",Yt=i=>document.querySelector(i),Xs=Yt("#sim"),Xx=Yt("[data-model]"),Nt=Yt("[data-screen]"),qx=Yt("[data-status]"),nn=Yt("[data-app]"),$a=Yt("[data-output]"),fh=Yt("[data-model-rotate]"),qs=Yt("[data-deploy]"),Yx=Yt("[data-reload]"),sf=[...document.querySelectorAll("[data-button]")],rf=` def _sim_exec(tag, code, scope): print("[sim-exec:%s:begin]" % tag) ok = True @@ -4605,19 +4605,19 @@ def _sim_exec(tag, code, scope): sys.print_exception(e) finally: print("[sim-exec:%s:%s]" % (tag, "ok" if ok else "error")) -`,fh="/tmp/_sim_exec.py";function Gx(i){return` +`,ph="/tmp/_sim_exec.py";function of(i){return` import builtins, machine, os, sys, time, badgeware -${Qd} +${rf} _exec_scope = {} def _service_exec(): try: - with open(${JSON.stringify(fh)}) as f: + with open(${JSON.stringify(ph)}) as f: src = f.read() except OSError: return try: - os.remove(${JSON.stringify(fh)}) + os.remove(${JSON.stringify(ph)}) except OSError: pass tag, _, code = src.partition("\\n") @@ -4668,7 +4668,7 @@ def _release(): while badge.held(): time.sleep(0.02) badge.poll() - +`}function Zx(i){return`${of(i)} while True: badge.mode(LORES | VSYNC) badge.autorotate(True) @@ -4688,17 +4688,55 @@ while True: finally: sys.path[:] = saved_path print("[simulator] Restarting app") -`}function Wx(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n{let r=Yd(n,Wx(s)),o=n.endsWith(".py")&&r.text!==null?Kd(r.text):r.text;return{name:`${e}/${n}`,content:Zd({...r,text:o})}});return{program:`${ef} -${Gx(e)}`,files:t}}var ef=`import editor_support +`}function Kx(i){return`${of(i)} +_default_clear = badge.default_clear + +def _watchdog_cause(): + return machine.WDT_RESET + +first_boot = True +while True: + badge.mode(LORES | VSYNC) + badge.autorotate(True) + badge.default_clear = _default_clear + badgeware.set_backlight(1.0) + _release() + if not first_boot: + # On the badge reset() is a watchdog reset, so the menu skips its opening animation. + machine.reset_cause = _watchdog_cause + first_boot = False + saved_path = list(sys.path) + try: + _target = ${JSON.stringify(i)} + _armed = True + print("[simulator] MonaOS menu") + chosen = launch(_target) + _armed = False + if chosen: + _release() + badge.mode(LORES | VSYNC) + _target = str(chosen) + _armed = True + print("[simulator] Launching " + _target) + launch(_target) + print("[simulator] Returned from " + _target) + except _ReturnHome: + pass + finally: + _armed = False + sys.path[:] = saved_path + time.sleep(0.05) +`}function $x(i){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n{let o=$d(s,$x(r)),a=s.endsWith(".py")&&o.text!==null?jd(o.text):o.text;return{name:`${e}/${s}`,content:Jd({...o,text:a})}}),n=i.os?Kx(`${Qd}/menu`):Zx(e);return{program:`${af} +${n}`,files:t}}var af=`import editor_support import sys sys.path[:0] = ["/system/lib", "/lib", "/system"] -${uh}`,qx=(i,e)=>`${ef} -${Qd} +${uh}`,jx=(i,e)=>`${af} +${rf} _sim_exec(${JSON.stringify(i)}, ${JSON.stringify(e)}, {"__name__": "__main__"}) -`,Gs=[],Ja=[],ph=0,tf={"Content-Type":"application/json","X-Badge-Simulator":"1"};function Ri(i,e){return fetch(i,{method:"POST",headers:tf,body:JSON.stringify(e)}).catch(()=>{})}function Yx(){if(ph=0,!Ja.length)return;let i=Ja;Ja=[],Ri("/api/log",{lines:i})}var $d=!1;function Rn(i){for(let e of i.split(` -`)){Ja.push(e);let t=/^\[sim-exec:[\w-]+:(begin|ok|error)\]$/.exec(e);if(t){$d=t[1]==="begin";continue}$d||Gs.push(e)}for(;Gs.length>400;)Gs.shift();$a.textContent=Gs.join(` -`),$a.scrollTop=$a.scrollHeight,ph||(ph=window.setTimeout(Yx,150))}function Gn(i,e=""){Vx.textContent=i,qs.dataset.runState=e,Ri("/api/status",{status:i,state:e})}var Zx=Zi.prototype.parseAsync;Zi.prototype.parseAsync=async function(...i){let e=await Zx.apply(this,i);return e.scene.traverse(t=>{/^usb-?c/i.test(t.name)&&(t.position.x=-t.position.x,t.scale.x=-t.scale.x)}),e};var Kx={screen:Yt("[data-model-screen]"),full:Yt("[data-model-full]"),status:Yt("[data-model-status]"),zoomIn:Yt("[data-model-zoom-in]"),zoomOut:Yt("[data-model-zoom-out]")},Ys=Ch(async(i,e)=>{let t=Wd(zx,Nt,(n,s)=>ri.set("model",n,s),i,e,Kx);return t.ready.then(()=>{qs.dataset.model="ready"},()=>{}),t},i=>{qs.dataset.model="flat",Rn(`[simulator] 3D badge unavailable (${i instanceof Error?i.message:String(i)}); showing the flat screen.`)}),pn=null,Ai=!1,nf=0,gh=()=>pn?.postMessage({buttons:nf|(Ai?32768:0)}),ri=new Yr(i=>{nf=i,gh();for(let e of jd)e.dataset.pressed=String((i&Number(e.dataset.button))!==0);Ys.setButtons(i)});Rh(qs,ri);var $x=qd(qs,i=>pn?.postMessage({motion:i}),new AbortController().signal);dh.addEventListener("click",()=>{Ai=!Ai,dh.setAttribute("aria-pressed",String(Ai)),Ys.setRotated(Ai),$x.setFlipped(Ai),gh()});for(let i of jd){let e=Number(i.dataset.button),t=()=>ri.set(`pointer:${e}`,e,!1);i.addEventListener("pointerdown",n=>{n.button===0&&(i.setPointerCapture(n.pointerId),ri.set(`pointer:${e}`,e,!0))}),i.addEventListener("pointerup",t),i.addEventListener("pointercancel",t),i.addEventListener("lostpointercapture",t),i.addEventListener("contextmenu",n=>n.preventDefault()),i.addEventListener("click",n=>{n.detail===0&&(ri.set(`click:${e}`,e,!0),window.setTimeout(()=>ri.set(`click:${e}`,e,!1),120))})}document.addEventListener("visibilitychange",()=>{ri.clear(),pn?.postMessage({pause:document.hidden})});var Xs=null,Qa=!1,Gr=!1,ja=0,el=!1,sf=Math.random().toString(36).slice(2),Jd=0,rf=1,mh=new Set;function of(i){if(Xs=i,el=!1,!pn||!Qa)return;let e=new Set(i.files.map(t=>`${i.app}/${t.path}`));if([...mh].some(t=>!e.has(t))){Wr();return}try{let t=Xx(i);for(let n of e)mh.add(n);Gs.length=0,Rn(`[simulator] Running ${i.app} (revision ${i.revision})`),pn.postMessage({...t,debug:!1}),pn.postMessage({pause:document.hidden}),Gn(`Running ${i.app}`,"running")}catch(t){Rn(`[simulator] ${t instanceof Error?t.message:String(t)}`),Gn("Could not start app","error")}}function Wr(){pn?.terminate(),mh.clear(),Qa=!1,Gr=!1,el=!1;let i=new Worker("/simulator/micropython.worker.js",{type:"module"});pn=i,i.onerror=e=>{e.preventDefault(),Rn(`[simulator] Worker error: ${e.message}`),Gn("Simulator error","error")},i.onmessage=({data:e})=>{if(i===pn){if(typeof e.stdout=="string"&&Rn(e.stdout),e.running&&(Gr=!0),e.completed&&(Gr=!1),e.bootError&&(Rn(`[simulator] ${e.bootError}`),Gn("Simulator failed to boot","error")),e.failed&&Gn(`${Xs?.app??"App"} crashed \u2014 see output`,"error"),e.stuck&&(Rn("[simulator] App did not stop; restarting the runtime."),Wr()),e.ready&&(Qa=!0,gh(),Xs?of(Xs):Gn("Choose an app to run")),e.frame){let{width:t,height:n,buffer:s}=e.frame;(Nt.width!==t||Nt.height!==n)&&(Nt.width=t,Nt.height=n),Nt.getContext("2d")?.putImageData(new ImageData(new Uint8ClampedArray(s),t,n),0,0),Ys.updateFrame(),ja++,el=!0,Ki&&Ki.rendered++,_h(),qs.dataset.framed="true"}e.backlight!==void 0&&(rf=e.backlight),e.backlight!==void 0&&Ys.setBacklight(Math.max(.15,Math.min(1,e.backlight)))}}}function af(i,e){Cn.replaceChildren(new Option("Choose app\u2026",""),...i.map(t=>new Option(t,t))),Cn.value=e??"",Ws.disabled=!e}async function tl(){let i=await fetch("/api/app");if(i.status===204){Xs=null,Ws.disabled=!0,Wr(),Nt.getContext("2d")?.clearRect(0,0,Nt.width,Nt.height),Ys.updateFrame(),Gn("Choose an app to run");return}if(!i.ok){Gn(await i.text(),"error");return}let e=await i.json();[...Cn.options].some(t=>t.value===e.app)||Cn.add(new Option(e.app,e.app)),Cn.value=e.app,Ws.disabled=!1,of(e)}function Jx(i,e){if(!pn||!Qa){Rn(`[sim-exec:${i}:begin]`),Rn("Simulator runtime is not ready yet."),Rn(`[sim-exec:${i}:error]`);return}Gr?pn.postMessage({file:{name:fh,code:`${i} -${e}`}}):(pn.postMessage({program:qx(i,e),files:[]}),Gn("Ran code in the simulator (app stopped; reload to restart it)","stopped"))}window.setInterval(()=>{Ri("/api/stats",{client:sf,fps:ja-Jd,frames:ja,width:Nt.width,height:Nt.height,running:Gr,paused:document.hidden,rotated:Ai,backlight:rf}),Jd=ja},1e3);var Ki=null;function jx(i){let e=new Uint32Array(i.buffer,i.byteOffset,i.byteLength>>2),t=2166136261^e.length;for(let n=0;n>>0}function _h(i=!1){let e=Ki;if(!e||!el||e.stopping)return;let t=performance.now();if(!i&&t-e.last{}))}function Qx(i,e,t,n){if(Ki){Ri("/api/record-done",{id:i,error:"A recording is already in progress in this canvas"});return}let s=performance.now();Ki={id:i,interval:1e3/e,start:s,last:-1/0,hash:-1,rendered:0,uploads:[],fps:e,scale:n,captureVideo:t,stopping:!1},_h(!0)}function ey(i){let e=document.createElement("canvas"),t=i.scale||(Nt.width>=320?2:4);e.width=Nt.width*t,e.height=Nt.height*t;try{let s=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm"].find(a=>MediaRecorder.isTypeSupported(a)),r=new MediaRecorder(e.captureStream(i.fps),s?{mimeType:s,videoBitsPerSecond:4e6}:void 0),o=[];r.ondataavailable=a=>{a.data.size&&o.push(a.data)},r.start(250),i.video={canvas:e,recorder:r,chunks:o}}catch(n){i.video={canvas:e,chunks:[],error:String(n)}}}async function ty(i){let e=Ki;if(!e||e.id!==i||e.stopping){Ri("/api/record-done",{id:i,error:"No active recording in this canvas"});return}_h(!0),e.stopping=!0;let t=performance.now()-e.start,n,s=e.video?.error;if(e.video?.recorder){let{recorder:r,chunks:o}=e.video;await new Promise(l=>{r.onstop=()=>l(),r.stop()});let a=new Blob(o,{type:r.mimeType});if(a.size){let l=new Uint8Array(await a.arrayBuffer()),c="";for(let h=0;h{let t=JSON.parse(e);t.type==="apps"?af(t.apps,Cn.value||null):t.type==="reload"?tl():t.type==="restart"?(Xs=null,Wr(),tl()):t.type==="screenshot"?ny(t.id):t.type==="exec"?Jx(t.id,t.code):t.type==="record-start"?Qx(t.id,t.fps,t.video,t.scale):t.type==="record-stop"?ty(t.id):t.type==="rotate"?(t.value===void 0||t.value!==Ai)&&dh.click():t.type==="press"&&(ri.set(`agent:${t.bit}`,t.bit,!0),window.setTimeout(()=>ri.set(`agent:${t.bit}`,t.bit,!1),t.ms))}}Cn.addEventListener("change",()=>{Ri("/api/select",{app:Cn.value||null})});Hx.addEventListener("click",()=>{tl()});Ws.addEventListener("click",async()=>{if(!Cn.value)return;Ws.disabled=!0;let i=await fetch("/api/deploy",{method:"POST",headers:tf,body:JSON.stringify({app:Cn.value})}).catch(()=>null),e=i?.ok?`Asked Copilot to deploy ${Cn.value} to your badge`:"Could not ask Copilot to deploy";Gn(e,i?.ok?"deploying":"error"),Rn(`[simulator] ${e}`),window.setTimeout(()=>{Ws.disabled=!1},4e3)});Yt("[data-clear-output]").addEventListener("click",()=>{Gs.length=0,$a.textContent=""});async function sy(){let i=await fetch("/api/state").then(e=>e.json());af(i.apps,i.app),Ys.start(),Wr(),i.app&&await tl(),iy()}sy(); +`,Gs=[],Ja=[],mh=0,lf={"Content-Type":"application/json","X-Badge-Simulator":"1"};function Ri(i,e){return fetch(i,{method:"POST",headers:lf,body:JSON.stringify(e)}).catch(()=>{})}function Qx(){if(mh=0,!Ja.length)return;let i=Ja;Ja=[],Ri("/api/log",{lines:i})}var ef=!1;function Cn(i){for(let e of i.split(` +`)){Ja.push(e);let t=/^\[sim-exec:[\w-]+:(begin|ok|error)\]$/.exec(e);if(t){ef=t[1]==="begin";continue}ef||Gs.push(e)}for(;Gs.length>400;)Gs.shift();$a.textContent=Gs.join(` +`),$a.scrollTop=$a.scrollHeight,mh||(mh=window.setTimeout(Qx,150))}function Gn(i,e=""){qx.textContent=i,Xs.dataset.runState=e,Ri("/api/status",{status:i,state:e})}var ey=Zi.prototype.parseAsync;Zi.prototype.parseAsync=async function(...i){let e=await ey.apply(this,i);return e.scene.traverse(t=>{/^usb-?c/i.test(t.name)&&(t.position.x=-t.position.x,t.scale.x=-t.scale.x)}),e};var ty={screen:Yt("[data-model-screen]"),full:Yt("[data-model-full]"),status:Yt("[data-model-status]"),zoomIn:Yt("[data-model-zoom-in]"),zoomOut:Yt("[data-model-zoom-out]")},Ys=Lh(async(i,e)=>{let t=Yd(Xx,Nt,(n,s)=>ri.set("model",n,s),i,e,ty);return t.ready.then(()=>{Xs.dataset.model="ready"},()=>{}),t},i=>{Xs.dataset.model="flat",Cn(`[simulator] 3D badge unavailable (${i instanceof Error?i.message:String(i)}); showing the flat screen.`)}),mn=null,Ai=!1,cf=0,xh=()=>mn?.postMessage({buttons:cf|(Ai?32768:0)}),ri=new Yr(i=>{cf=i,xh();for(let e of sf)e.dataset.pressed=String((i&Number(e.dataset.button))!==0);Ys.setButtons(i)});Ih(Xs,ri);var ny=Kd(Xs,i=>mn?.postMessage({motion:i}),new AbortController().signal);fh.addEventListener("click",()=>{Ai=!Ai,fh.setAttribute("aria-pressed",String(Ai)),Ys.setRotated(Ai),ny.setFlipped(Ai),xh()});for(let i of sf){let e=Number(i.dataset.button),t=()=>ri.set(`pointer:${e}`,e,!1);i.addEventListener("pointerdown",n=>{n.button===0&&(i.setPointerCapture(n.pointerId),ri.set(`pointer:${e}`,e,!0))}),i.addEventListener("pointerup",t),i.addEventListener("pointercancel",t),i.addEventListener("lostpointercapture",t),i.addEventListener("contextmenu",n=>n.preventDefault()),i.addEventListener("click",n=>{n.detail===0&&(ri.set(`click:${e}`,e,!0),window.setTimeout(()=>ri.set(`click:${e}`,e,!1),120))})}document.addEventListener("visibilitychange",()=>{ri.clear(),mn?.postMessage({pause:document.hidden})});var Ws=null,Qa=!1,Gr=!1,ja=0,el=!1,hf=Math.random().toString(36).slice(2),tf=0,uf=1,gh=new Set;function df(i){if(Ws=i,el=!1,!mn||!Qa)return;let e=new Set(i.files.map(t=>`${i.app}/${t.path}`));if([...gh].some(t=>!e.has(t))){Wr();return}try{let t=Jx(i);for(let n of e)gh.add(n);Gs.length=0,Cn(`[simulator] Running ${dh(i)} (revision ${i.revision})`),mn.postMessage({...t,debug:!1}),mn.postMessage({pause:document.hidden}),Gn(`Running ${dh(i)}`,"running")}catch(t){Cn(`[simulator] ${t instanceof Error?t.message:String(t)}`),Gn("Could not start app","error")}}function Wr(){mn?.terminate(),gh.clear(),Qa=!1,Gr=!1,el=!1;let i=new Worker("/simulator/micropython.worker.js",{type:"module"});mn=i,i.onerror=e=>{e.preventDefault(),Cn(`[simulator] Worker error: ${e.message}`),Gn("Simulator error","error")},i.onmessage=({data:e})=>{if(i===mn){if(typeof e.stdout=="string"&&Cn(e.stdout),e.running&&(Gr=!0),e.completed&&(Gr=!1),e.bootError&&(Cn(`[simulator] ${e.bootError}`),Gn("Simulator failed to boot","error")),e.failed&&Gn(`${dh(Ws)} crashed \u2014 see output`,"error"),e.stuck&&(Cn("[simulator] App did not stop; restarting the runtime."),Wr()),e.ready&&(Qa=!0,xh(),Ws?df(Ws):Gn("Choose an app to run")),e.frame){let{width:t,height:n,buffer:s}=e.frame;(Nt.width!==t||Nt.height!==n)&&(Nt.width=t,Nt.height=n),Nt.getContext("2d")?.putImageData(new ImageData(new Uint8ClampedArray(s),t,n),0,0),Ys.updateFrame(),ja++,el=!0,Ki&&Ki.rendered++,vh(),Xs.dataset.framed="true"}e.backlight!==void 0&&(uf=e.backlight),e.backlight!==void 0&&Ys.setBacklight(Math.max(.15,Math.min(1,e.backlight)))}}}var iy=qs.title;function yh(){let i=nn.value===_h;qs.disabled=!nn.value||i,qs.title=i?"Pick a single app to deploy it to the connected badge":iy}function ff(i,e){nn.replaceChildren(new Option("Choose app\u2026",""),...i.map(t=>new Option(nf(t),t))),nn.value=e??"",yh()}async function tl(){let i=await fetch("/api/app");if(i.status===204){Ws=null,qs.disabled=!0,Wr(),Nt.getContext("2d")?.clearRect(0,0,Nt.width,Nt.height),Ys.updateFrame(),Gn("Choose an app to run");return}if(!i.ok){Gn(await i.text(),"error");return}let e=await i.json();[...nn.options].some(t=>t.value===e.app)||nn.add(new Option(nf(e.app),e.app)),nn.value=e.app,yh(),df(e)}function sy(i,e){if(!mn||!Qa){Cn(`[sim-exec:${i}:begin]`),Cn("Simulator runtime is not ready yet."),Cn(`[sim-exec:${i}:error]`);return}Gr?mn.postMessage({file:{name:ph,code:`${i} +${e}`}}):(mn.postMessage({program:jx(i,e),files:[]}),Gn("Ran code in the simulator (app stopped; reload to restart it)","stopped"))}window.setInterval(()=>{Ri("/api/stats",{client:hf,fps:ja-tf,frames:ja,width:Nt.width,height:Nt.height,running:Gr,paused:document.hidden,rotated:Ai,backlight:uf}),tf=ja},1e3);var Ki=null;function ry(i){let e=new Uint32Array(i.buffer,i.byteOffset,i.byteLength>>2),t=2166136261^e.length;for(let n=0;n>>0}function vh(i=!1){let e=Ki;if(!e||!el||e.stopping)return;let t=performance.now();if(!i&&t-e.last{}))}function oy(i,e,t,n){if(Ki){Ri("/api/record-done",{id:i,error:"A recording is already in progress in this canvas"});return}let s=performance.now();Ki={id:i,interval:1e3/e,start:s,last:-1/0,hash:-1,rendered:0,uploads:[],fps:e,scale:n,captureVideo:t,stopping:!1},vh(!0)}function ay(i){let e=document.createElement("canvas"),t=i.scale||(Nt.width>=320?2:4);e.width=Nt.width*t,e.height=Nt.height*t;try{let s=["video/mp4;codecs=avc1","video/mp4","video/webm;codecs=vp9","video/webm"].find(a=>MediaRecorder.isTypeSupported(a)),r=new MediaRecorder(e.captureStream(i.fps),s?{mimeType:s,videoBitsPerSecond:4e6}:void 0),o=[];r.ondataavailable=a=>{a.data.size&&o.push(a.data)},r.start(250),i.video={canvas:e,recorder:r,chunks:o}}catch(n){i.video={canvas:e,chunks:[],error:String(n)}}}async function ly(i){let e=Ki;if(!e||e.id!==i||e.stopping){Ri("/api/record-done",{id:i,error:"No active recording in this canvas"});return}vh(!0),e.stopping=!0;let t=performance.now()-e.start,n,s=e.video?.error;if(e.video?.recorder){let{recorder:r,chunks:o}=e.video;await new Promise(l=>{r.onstop=()=>l(),r.stop()});let a=new Blob(o,{type:r.mimeType});if(a.size){let l=new Uint8Array(await a.arrayBuffer()),c="";for(let h=0;h{let t=JSON.parse(e);t.type==="apps"?ff(t.apps,nn.value||null):t.type==="reload"?tl():t.type==="restart"?(Ws=null,Wr(),tl()):t.type==="screenshot"?cy(t.id):t.type==="exec"?sy(t.id,t.code):t.type==="record-start"?oy(t.id,t.fps,t.video,t.scale):t.type==="record-stop"?ly(t.id):t.type==="rotate"?(t.value===void 0||t.value!==Ai)&&fh.click():t.type==="press"&&(ri.set(`agent:${t.bit}`,t.bit,!0),window.setTimeout(()=>ri.set(`agent:${t.bit}`,t.bit,!1),t.ms))}}nn.addEventListener("change",()=>{Ri("/api/select",{app:nn.value||null})});Yx.addEventListener("click",()=>{tl()});qs.addEventListener("click",async()=>{if(!nn.value||nn.value===_h)return;qs.disabled=!0;let i=await fetch("/api/deploy",{method:"POST",headers:lf,body:JSON.stringify({app:nn.value})}).catch(()=>null),e=i?.ok?`Asked Copilot to deploy ${nn.value} to your badge`:"Could not ask Copilot to deploy";Gn(e,i?.ok?"deploying":"error"),Cn(`[simulator] ${e}`),window.setTimeout(yh,4e3)});Yt("[data-clear-output]").addEventListener("click",()=>{Gs.length=0,$a.textContent=""});async function uy(){let i=await fetch("/api/state").then(e=>e.json());ff(i.apps,i.app),Ys.start(),Wr(),i.app&&await tl(),hy()}uy(); /*! Bundled license information: three/build/three.core.js: diff --git a/badge/apps/flappy_mona_redux/README.md b/badge/apps/flappy_mona_redux/README.md new file mode 100644 index 00000000..00889d78 --- /dev/null +++ b/badge/apps/flappy_mona_redux/README.md @@ -0,0 +1,40 @@ +# Flappy Mona Redux + +A full-resolution remake of Flappy Mona where fish make Mona immortal for 5 seconds and floating brick towers with stairs she can climb keep turning up between the walls. + +## Usage + +Press Select to start. In the air, Select flaps and steers Mona through the gaps in the walls. Once she is running on a tower, Select makes her jump. Your best score is saved on the badge. No extra hardware or network access is required. + +## What is new + +- The game runs at the badge's full 320x240 resolution, with redrawn artwork. +- Fish drift through the gaps of some walls and float above the towers. Grab one and Mona turns immortal for 5 seconds: she glows gold, flies straight through walls and can rest on the ground. +- The timer in the top right counts down the immortality, and the glow flickers for the last two seconds. Grabbing another fish restarts the 5 seconds. +- Walls Mona passes while immortal still count toward your score. +- The game opens with a big roof to climb, and after that a stair tower arrives every 3 to 5 walls. + +## The towers + +Fly into the stairs on the left of a tower and Mona climbs them on her own, then runs along the top. The camera rises with her and glides back down once she leaves the tower. She steps down the stairs on the right and drops back into flight. + +| Tower | Stairs up | Top | Stairs down | On top | +|-------|-----------|-----|-------------|--------| +| Steps | 4 | short | 4 | a fish to jump for | +| Hill | 6 | medium | 6 | a spike and a fish | +| Roof | 8 | long | 4 | 2 spikes, 2 rolling drums and 2 fish | + +The towers come in the order roof, steps, hill, steps and then repeat. + +- Touching a spike ends the run. A rolling drum that reaches Mona flattens her. Jump to clear each hazard: the timing window is about a third of a second. +- Fish float above the hazards, so a good jump also earns 5 seconds of immortality. While she glows, Mona passes straight through the hazards. +- Every tower is optional. A low tunnel, about 60 pixels high, runs underneath for pilots who prefer to fly, but the brick and the spikes on its underside are deadly. +- Clearing a tower scores 1 point. Immortality that runs out while Mona is inside the brick or overlapping a hazard ends the run. + +## Tuning + +- Fish frequency is set by `FIRST_FISH`, `FISH_EVERY` and `FISH_SPACING` in `course.py`, and the immortality length by `IMMORTAL_SECONDS` in `mona.py`. +- `TOWER_ORDER` and `TOWER_EVERY` in `course.py` choose which towers appear and how many plain walls separate them. `TOWER_CLEARANCE` sets the empty space before and after each tower. +- Each tower is a `Layout(up, deck_cols, down, ...)` in `LAYOUTS` in `tower.py`. `up` and `down` count the stairs, `deck_cols` sets the length of the top, and the `spikes`, `rollers` and `fish` lists place things along it. `FIRST_TREAD_Y` and `UNDERSIDE_Y` set the height of the tunnel. + +The artwork is generated by `tools/build_flappy_mona_redux_assets.py` from the original Flappy Mona sprites. The original game is still available as Flappy Mona. diff --git a/badge/apps/flappy_mona_redux/__init__.py b/badge/apps/flappy_mona_redux/__init__.py new file mode 100644 index 00000000..6a7f0b82 --- /dev/null +++ b/badge/apps/flappy_mona_redux/__init__.py @@ -0,0 +1,238 @@ +import math +import os +import sys + +APP_DIR = "/system/apps/flappy_mona_redux" + +os.chdir(APP_DIR) +sys.path.insert(0, APP_DIR) + +badge.mode(HIRES | VSYNC) + +from badgeware import State + +import effects +import ui +from course import Course +from fish import FRAMES as FISH_FRAMES +from mona import IMMORTAL_SECONDS, SIZE, Mona +from tower import ROLLER +from world import HEIGHT, WIDTH, World + +STATE_KEY = "flappy_mona_redux" +MAX_FRAME_MS = 50 +WARN_SECONDS = 2.0 # aura flickers when immortality is about to run out +RESTART_LOCKOUT_MS = 600 # stops a flapping thumb from instantly restarting +CAMERA_EASE = 5.0 # how eagerly the camera follows Mona up and down a tower +CAMERA_SPEED = 160 # px/s, so a drop off a tower glides instead of snapping + +INTRO = 1 +PLAYING = 2 +GAME_OVER = 3 + +save = {"highscore": 0} +State.load(STATE_KEY, save) +if not isinstance(save["highscore"], int) or save["highscore"] < 0: + save["highscore"] = 0 + +state = INTRO +world = World() +course = Course() +mona = Mona() +trail_clock = 0.0 +new_best = False +over_at = 0 +cam = 0.0 # how far the view has risen above the ground; screen y = world y + cam + + +def update(): + dt = min(badge.ticks_delta, MAX_FRAME_MS) / 1000 + if state == INTRO: + intro(dt) + elif state == PLAYING: + play(dt) + else: + game_over() + + +def start(): + global state, course, mona, trail_clock, cam + state = PLAYING + course = Course() + mona = Mona() + mona.flap() + trail_clock = 0.0 + cam = 0.0 + effects.clear() + + +def finish(): + global state, new_best, over_at + state = GAME_OVER + over_at = badge.ticks + new_best = mona.score > save["highscore"] + if new_best: + save["highscore"] = mona.score + try: + State.save(STATE_KEY, save) + except OSError: + pass + + +def intro(dt): + world.advance(dt) + ui.pixel_mode() + world.draw() + + t = badge.ticks / 280 + mona.x = (WIDTH - SIZE) / 2 + mona.y = 108 + math.sin(t) * 7 + mona.vy = math.cos(t) * 50 + mona.draw() + + ui.text_mode() + ui.centered("FLAPPY MONA", 20, 38, ui.WHITE, ui.NAVY) + ui.centered("REDUX", 62, 26, ui.GOLD, ui.NAVY) + ui.centered("High Score: %d" % save["highscore"], 168, 15) + if int(badge.ticks / 500) % 2: + ui.centered("Press Select to start", 190, 15) + + if badge.pressed(BUTTON_SELECT): + start() + + +def interact(): + mona.score += course.count_passed(mona.x) + + if not mona.is_immortal(): + hit = course.hits(mona.bounds(), mona.hazard_box()) + if hit == ROLLER: + mona.flatten() + return + if hit is not None: + mona.die() + return + + fish = course.take_fish(mona.bounds()) + if fish is not None: + mona.make_immortal() + cx, cy = mona.center() + effects.burst(fish.x + 24, fish.y() + 16) + effects.show_popup("IMMORTAL!", cx, cy + int(cam) - 44) + + +def follow_camera(dt): + """Rise with Mona as she climbs a tower and settle back once she is off it.""" + global cam + tower = course.tower + target = tower.camera_for(mona.ground_y) if mona.running and tower is not None else 0.0 + step = (target - cam) * min(1.0, CAMERA_EASE * dt) + limit = CAMERA_SPEED * dt + cam += max(-limit, min(limit, step)) + + +def draw_world(): + """The scenery and course. A flattened Mona goes under the roller that squashed her.""" + world.draw(int(cam)) + if mona.flat: + mona.draw(int(cam)) + course.draw(int(cam)) + + +def play(dt): + global state, trail_clock + + if not mona.is_dead(): + if badge.pressed(BUTTON_SELECT): + mona.press() + if not mona.is_dead() or mona.flat: + world.advance(dt) + course.update(dt) + + mona.update(dt, course.tower, cam) + + if not mona.is_dead(): + follow_camera(dt) + interact() + if mona.is_immortal(): + trail_clock += dt + if trail_clock > 0.07: + trail_clock = 0.0 + cx, cy = mona.center() + effects.trail(cx - 14, cy) + + effects.update(dt) + + ui.pixel_mode() + draw_world() + if not mona.flat: + if mona.is_immortal(): + draw_aura() + mona.draw(int(cam)) + effects.draw(int(cam)) + draw_hud() + + if mona.is_done_dying(): + finish() + + +def game_over(): + ui.pixel_mode() + draw_world() + screen.pen = ui.DIM + screen.rectangle(0, 0, WIDTH, HEIGHT) + + ui.text_mode() + ui.centered("GAME OVER", 36, 36, ui.WHITE, ui.NAVY) + ui.centered("Score: %d" % mona.score, 96, 22) + if new_best: + ui.centered("New best!", 126, 20, ui.GOLD) + else: + ui.centered("High Score: %d" % save["highscore"], 128, 16) + if int(badge.ticks / 500) % 2: + ui.centered("Press Select to retry", 180, 15) + + if badge.pressed(BUTTON_SELECT) and badge.ticks - over_at > RESTART_LOCKOUT_MS: + start() + + +def draw_aura(): + if mona.immortal < WARN_SECONDS and int(badge.ticks / 110) % 2: + return + + cx, cy = mona.center() + cy += int(cam) + mona.lift + pulse = 0.5 + 0.5 * math.sin(badge.ticks / 140) + radius = 29 + 3 * pulse + screen.antialias = image.X2 + screen.pen = color.rgb(255, 214, 80, 55 + int(35 * pulse)) + screen.shape(shape.circle(cx, cy, radius)) + screen.pen = color.rgb(255, 236, 140, 190) + screen.shape(shape.circle(cx, cy, radius).stroke(2)) + ui.pixel_mode() + + +def draw_hud(): + ui.text_mode() + label = "Score %d" % mona.score + width, _ = ui.measure(label, 16) + ui.panel(8, 6, width + 20, 26) + ui.shadow_text(label, 18, 8, 16) + + if mona.is_immortal(): + left = mona.immortal + x = WIDTH - 8 - 120 + ui.panel(x, 6, 120, 26) + ui.shadow_text("%ds" % math.ceil(left), x + 88, 8, 16) + + ui.pixel_mode() + screen.blit(FISH_FRAMES[0], rect(x + 6, 11, 24, 16)) + screen.pen = color.rgb(255, 255, 255, 60) + screen.rectangle(x + 36, 16, 46, 6) + screen.pen = ui.GOLD if left > WARN_SECONDS else color.rgb(255, 120, 80) + screen.rectangle(x + 36, 16, int(46 * left / IMMORTAL_SECONDS), 6) + + ui.pixel_mode() + + +run(update) diff --git a/badge/apps/flappy_mona_redux/assets/background.png b/badge/apps/flappy_mona_redux/assets/background.png new file mode 100644 index 00000000..c6b92087 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/background.png differ diff --git a/badge/apps/flappy_mona_redux/assets/cloud.png b/badge/apps/flappy_mona_redux/assets/cloud.png new file mode 100644 index 00000000..fdc041a5 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/cloud.png differ diff --git a/badge/apps/flappy_mona_redux/assets/far_hills.png b/badge/apps/flappy_mona_redux/assets/far_hills.png new file mode 100644 index 00000000..6652a1e0 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/far_hills.png differ diff --git a/badge/apps/flappy_mona_redux/assets/fish.png b/badge/apps/flappy_mona_redux/assets/fish.png new file mode 100644 index 00000000..cc18b606 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/fish.png differ diff --git a/badge/apps/flappy_mona_redux/assets/grass.png b/badge/apps/flappy_mona_redux/assets/grass.png new file mode 100644 index 00000000..4bfc66bb Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/grass.png differ diff --git a/badge/apps/flappy_mona_redux/assets/mona.png b/badge/apps/flappy_mona_redux/assets/mona.png new file mode 100644 index 00000000..f95eb998 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/mona.png differ diff --git a/badge/apps/flappy_mona_redux/assets/obstacles.png b/badge/apps/flappy_mona_redux/assets/obstacles.png new file mode 100644 index 00000000..f0bcdf12 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/obstacles.png differ diff --git a/badge/apps/flappy_mona_redux/assets/roller.png b/badge/apps/flappy_mona_redux/assets/roller.png new file mode 100644 index 00000000..a73ad495 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/roller.png differ diff --git a/badge/apps/flappy_mona_redux/assets/roof.png b/badge/apps/flappy_mona_redux/assets/roof.png new file mode 100644 index 00000000..beeed72b Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/roof.png differ diff --git a/badge/apps/flappy_mona_redux/assets/roof_lip.png b/badge/apps/flappy_mona_redux/assets/roof_lip.png new file mode 100644 index 00000000..fdd3c4c9 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/roof_lip.png differ diff --git a/badge/apps/flappy_mona_redux/assets/roof_under.png b/badge/apps/flappy_mona_redux/assets/roof_under.png new file mode 100644 index 00000000..1a35e040 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/roof_under.png differ diff --git a/badge/apps/flappy_mona_redux/assets/spike.png b/badge/apps/flappy_mona_redux/assets/spike.png new file mode 100644 index 00000000..e4171773 Binary files /dev/null and b/badge/apps/flappy_mona_redux/assets/spike.png differ diff --git a/badge/apps/flappy_mona_redux/course.py b/badge/apps/flappy_mona_redux/course.py new file mode 100644 index 00000000..b410569c --- /dev/null +++ b/badge/apps/flappy_mona_redux/course.py @@ -0,0 +1,121 @@ +import random + +from fish import HEIGHT as FISH_HEIGHT +from fish import WIDTH as FISH_WIDTH +from fish import Fish +from obstacle import GAP, TILE, Obstacle +from tower import LAYOUTS, WALL, Tower +from world import SPEED +from world import WIDTH as SCREEN_WIDTH + +FIRST_SPAWN = 0.5 # seconds until the first wall +SPAWN_EVERY = 1.5 # seconds between walls +FIRST_FISH = 3 # the third plain wall carries the first fish +FISH_EVERY = (4, 7) # then one fish every 4 to 7 plain walls +FISH_MARGIN = 14 # keeps fish off the spikes +FISH_SPACING = 3 # a wall fish never comes sooner than this many walls after a tower's fish +TOWER_ORDER = ("roof", "steps", "hill", "steps") # the roof opens the game, then the order repeats +TOWER_EVERY = (3, 5) # plain walls between towers (never fewer than 3, or two towers would overlap) +TOWER_CLEARANCE = 150 # clear space before and after a tower +TOWER_LEAD = (TOWER_CLEARANCE + TILE) / SPEED - SPAWN_EVERY # extra wait so the last wall clears a tower + + +class Course: + def __init__(self): + self.obstacles = [] + self.fish = [] + self.tower = None + self.holding = False # plain walls wait while a tower crosses the screen + self.spawn_in = FIRST_SPAWN + self.fish_in = FIRST_FISH + self.walls_to_tower = 0 # plain walls left before the next tower, which opens the game + self.towers = 0 + + def spawn(self): + if self.walls_to_tower <= 0: + self.spawn_tower() + else: + self.spawn_wall() + + def spawn_tower(self): + self.tower = Tower(LAYOUTS[TOWER_ORDER[self.towers % len(TOWER_ORDER)]]) + self.towers += 1 + self.holding = True + self.walls_to_tower = random.randint(TOWER_EVERY[0], TOWER_EVERY[1]) + fish = self.tower.make_fish() + if fish: + self.fish.extend(fish) + self.fish_in = max(self.fish_in, FISH_SPACING) + + def spawn_wall(self): + obstacle = Obstacle() + self.obstacles.append(obstacle) + + self.walls_to_tower -= 1 + if self.walls_to_tower <= 0: + self.spawn_in += TOWER_LEAD + + self.fish_in -= 1 + if self.fish_in <= 0: + self.fish_in = random.randint(FISH_EVERY[0], FISH_EVERY[1]) + low = obstacle.gap_y + FISH_MARGIN + high = obstacle.gap_y + GAP - FISH_HEIGHT - FISH_MARGIN + self.fish.append(Fish(obstacle.x + (TILE - FISH_WIDTH) / 2, random.randint(low, high))) + + def update(self, dt): + if self.holding and self.tower.right_end() <= SCREEN_WIDTH - TOWER_CLEARANCE: + self.holding = False + self.spawn_in = 0.0 + if not self.holding: + self.spawn_in -= dt + if self.spawn_in <= 0: + self.spawn_in += SPAWN_EVERY + self.spawn() + + if self.tower is not None: + self.tower.update(dt) + if self.tower.right_end() <= 0: + self.tower = None + for obstacle in self.obstacles: + obstacle.update(dt) + for fish in self.fish: + fish.update(dt) + + self.obstacles = [o for o in self.obstacles if o.x > -TILE] + self.fish = [f for f in self.fish if f.x > -FISH_WIDTH] + + def hits(self, box, hazard): + """What Mona ran into, if anything: WALL, SPIKE or ROLLER.""" + for obstacle in self.obstacles: + if obstacle.hits(box): + return WALL + if self.tower is not None: + return self.tower.hits(box, hazard) + return None + + def take_fish(self, box): + for fish in self.fish: + if fish.touches(box): + self.fish.remove(fish) + return fish + return None + + def count_passed(self, x): + count = 0 + for obstacle in self.obstacles: + if not obstacle.passed and obstacle.x < x: + obstacle.passed = True + count += 1 + tower = self.tower + if tower is not None and not tower.passed and tower.right_end() < x: + tower.passed = True + count += 1 + return count + + def draw(self, cam=0): + if self.tower is not None: + self.tower.draw(cam) + for obstacle in self.obstacles: + obstacle.draw(cam) + for fish in self.fish: + fish.draw(cam) diff --git a/badge/apps/flappy_mona_redux/effects.py b/badge/apps/flappy_mona_redux/effects.py new file mode 100644 index 00000000..c05732a6 --- /dev/null +++ b/badge/apps/flappy_mona_redux/effects.py @@ -0,0 +1,98 @@ +import math +import random + +import ui +from world import WIDTH + +MAX_SPARKLES = 48 +POPUP_SECONDS = 1.2 +POPUP_SIZE = 20 +POPUP_TOP = 36 # keeps the popup clear of the score panel when she is near the top +PALETTE = ((255, 214, 80), (255, 244, 170), (255, 160, 50), (255, 255, 255)) + +sparkles = [] # [x, y, vx, vy, age, life, size, colour index] +popup = None # [text, x, y, age] + + +def clear(): + global popup + del sparkles[:] + popup = None + + +def burst(x, y, count=18): + for _ in range(count): + if len(sparkles) >= MAX_SPARKLES: + return + angle = random.random() * 6.283 + speed = 40 + random.random() * 90 + sparkles.append( + [ + x, + y, + math.cos(angle) * speed, + math.sin(angle) * speed, + 0.0, + 0.5 + random.random() * 0.4, + 2 + random.randint(0, 2), + random.randint(0, len(PALETTE) - 1), + ] + ) + + +def trail(x, y): + if len(sparkles) >= MAX_SPARKLES: + return + sparkles.append( + [ + x + random.randint(-6, 6), + y + random.randint(-16, 16), + -50 - random.random() * 30, + random.randint(-14, 14), + 0.0, + 0.35 + random.random() * 0.25, + 2, + random.randint(0, len(PALETTE) - 1), + ] + ) + + +def show_popup(text, x, y): + global popup + popup = [text, x, y, 0.0] + + +def update(dt): + global popup + alive = [] + for s in sparkles: + s[4] += dt + if s[4] < s[5]: + s[0] += s[2] * dt + s[1] += s[3] * dt + s[3] += 60 * dt + alive.append(s) + sparkles[:] = alive + + if popup is not None: + popup[3] += dt + popup[2] -= 24 * dt + if popup[3] > POPUP_SECONDS: + popup = None + + +def draw(cam=0): + for s in sparkles: + r, g, b = PALETTE[s[7]] + screen.pen = color.rgb(r, g, b, int(255 * (1 - s[4] / s[5]))) + screen.rectangle(int(s[0]), int(s[1]) + cam, s[6], s[6]) + + if popup is not None: + text, x, y, age = popup + alpha = int(255 * min(1.0, (POPUP_SECONDS - age) / 0.4)) + ui.text_mode() + width, _ = ui.measure(text, POPUP_SIZE) + left = max(8, min(WIDTH - 8 - width, x - width / 2)) + y = max(POPUP_TOP, y) + ui.outlined_text(text, left, y, POPUP_SIZE, color.rgb(255, 214, 80, alpha), color.rgb(22, 44, 96, alpha), 1) + ui.pixel_mode() diff --git a/badge/apps/flappy_mona_redux/fish.py b/badge/apps/flappy_mona_redux/fish.py new file mode 100644 index 00000000..d2c06ea0 --- /dev/null +++ b/badge/apps/flappy_mona_redux/fish.py @@ -0,0 +1,40 @@ +import math +import random + +from world import HEIGHT as SCREEN_HEIGHT +from world import SPEED, overlaps + +sheet = image.load("assets/fish.png").spritesheet(4, 1) +FRAMES = [sheet.sprite(i, 0) for i in range(4)] + +WIDTH = 48 +HEIGHT = 32 +HIT = (4, 4, 40, 24) +WIGGLE_FPS = 8 +BOB_PIXELS = 4 + + +class Fish: + def __init__(self, x, y): + self.x = x + self.base_y = y + self.age = random.random() * 6.28 + + def update(self, dt): + self.x -= SPEED * dt + self.age += dt + + def y(self): + return self.base_y + math.sin(self.age * 4) * BOB_PIXELS + + def bounds(self): + return (self.x + HIT[0], self.y() + HIT[1], HIT[2], HIT[3]) + + def touches(self, box): + return overlaps(self.bounds(), box) + + def draw(self, cam=0): + y = int(self.y()) + cam + if -HEIGHT < y < SCREEN_HEIGHT: + frame = FRAMES[int(self.age * WIGGLE_FPS) % len(FRAMES)] + screen.blit(frame, vec2(int(self.x), y)) diff --git a/badge/apps/flappy_mona_redux/icon.png b/badge/apps/flappy_mona_redux/icon.png new file mode 100755 index 00000000..8eedb552 Binary files /dev/null and b/badge/apps/flappy_mona_redux/icon.png differ diff --git a/badge/apps/flappy_mona_redux/mona.py b/badge/apps/flappy_mona_redux/mona.py new file mode 100644 index 00000000..e92c5e8f --- /dev/null +++ b/badge/apps/flappy_mona_redux/mona.py @@ -0,0 +1,188 @@ +import math + +from world import GROUND_Y + +sprites = image.load("assets/mona.png").spritesheet(7, 2) +ALIVE_FRAMES = 7 +DEAD_FRAMES = 5 + +SIZE = 48 +START_X = 20 +START_Y = 96 +GRAVITY = 420 # while flying +FLAP_SPEED = -120 +RUN_GRAVITY = 700 # while running on a tower: a quick hop +RUN_JUMP = -366 # clears a spike or a roller with time to spare +HIT = (6, 4, 36, 40) # x, y, w, h inside the sprite +HAZARD = (12, 12, 24, 32) # spikes and rollers use a slimmer box than walls do +FEET = HIT[1] + HIT[3] # sprite y of the soles of her feet +FLOOR_Y = GROUND_Y + 4 - FEET # sprite y where her feet reach the lawn + +IMMORTAL_SECONDS = 5 +DEATH_FRAME_SECONDS = 0.1 +DEATH_DELAY_SECONDS = 0.9 + +LIFT_SPEED = 120 # px/s at which the pop up a stair eases out +BOB_PIXELS = 2 # bounce in her step while she runs +FLAT_SECONDS = 0.15 # how long a roller takes to squash her +FLAT_SIZE = (56, 12) # width and height of the pancake + + +class Mona: + def __init__(self): + self.x = START_X + self.y = START_Y + self.vy = 0 + self.score = 0 + self.immortal = 0.0 + self.dead_for = None + self.flat = False + self.running = False # on a tower's stairs or deck, where Select jumps + self.grounded = False + self.ground_y = 0 # the surface she last stood on, which the camera follows + self.lift = 0.0 # drawn this far below her real position, easing out + self.run_phase = 0.0 + + def is_dead(self): + return self.dead_for is not None + + def is_done_dying(self): + return self.dead_for is not None and self.dead_for > DEATH_DELAY_SECONDS + + def is_immortal(self): + return self.immortal > 0 + + def flap(self): + self.vy = FLAP_SPEED + + def press(self): + """Select flaps in the air and jumps once she is running on a tower.""" + if not self.running: + self.flap() + elif self.grounded: + self.vy = RUN_JUMP + self.grounded = False + + def make_immortal(self): + self.immortal = IMMORTAL_SECONDS + + def die(self): + if self.dead_for is None: + self.dead_for = 0.0 + self.immortal = 0.0 + + def flatten(self): + if self.dead_for is None: + self.die() + self.flat = True + self.lift = 0.0 + self.vy = 0 + + def update(self, dt, tower=None, cam=0): + if self.dead_for is not None: + self.dead_for += dt + if self.flat: + self.settle(dt, tower) + return + + if self.immortal > 0: + self.immortal = max(0.0, self.immortal - dt) + + prev_feet = self.y + FEET + if self.grounded: + self.vy = 0 + else: + self.vy += (RUN_GRAVITY if self.running else GRAVITY) * dt + self.y += self.vy * dt + + # the top of the screen is a ceiling, wherever the camera is + if self.y + cam < 0 and self.vy < 0: + self.y = -cam + self.vy = 0 + + self.stand_on(tower, prev_feet) + + if self.y > FLOOR_Y: + if self.immortal > 0: + self.y = FLOOR_Y + self.vy = 0 + else: + self.die() + + if self.lift > 0: + self.lift = max(0.0, self.lift - LIFT_SPEED * dt) + if self.grounded: + self.run_phase += dt + + def settle(self, dt, tower): + """A flattened Mona drops onto the roof under her and stays pinned there.""" + prev_feet = self.y + FEET + if not self.grounded: + self.vy += RUN_GRAVITY * dt + self.y += self.vy * dt + self.stand_on(tower, prev_feet) + if self.y > FLOOR_Y: + self.y = FLOOR_Y + self.vy = 0 + + def stand_on(self, tower, prev_feet): + """Land on a tower's stairs or deck, or step up onto a low ledge.""" + left = self.x + HIT[0] + right = left + HIT[2] + if tower is None: + self.running = self.grounded = False + return + first, last = tower.span(left, right) + if first > last: + self.running = self.grounded = False + return + + top = tower.landing(prev_feet, self.y + FEET, left, right) + if top is None: + self.grounded = False + return + + stand = top - FEET + if self.grounded and stand < self.y: + self.lift += self.y - stand # draw the step as a quick climb, not a teleport + self.y = stand + self.vy = 0 + self.grounded = True + self.running = True + self.ground_y = top + + def bounds(self): + return (self.x + HIT[0], self.y + HIT[1], HIT[2], HIT[3]) + + def hazard_box(self): + return (self.x + HAZARD[0], self.y + HAZARD[1], HAZARD[2], HAZARD[3]) + + def center(self): + return (self.x + SIZE / 2, self.y + SIZE / 2) + + def draw(self, cam=0): + cam = int(cam) + if self.flat: + self.draw_flat(cam) + return + + bob = 0 + if self.grounded and self.dead_for is None: + bob = int(BOB_PIXELS * abs(math.sin(self.run_phase * 12))) + pos = vec2(int(self.x), int(self.y + self.lift) + cam - bob) + if self.dead_for is None: + frame = max(-1, min(self.vy / 60, 2)) + 1 + screen.blit(sprites.sprite(int(frame * 2) % ALIVE_FRAMES, 0), pos) + return + + frame = int(self.dead_for / DEATH_FRAME_SECONDS) + if frame < DEAD_FRAMES: + screen.blit(sprites.sprite(frame, 1), pos) + + def draw_flat(self, cam): + """Squash her sprite flat against the roof, keeping her feet on the floor.""" + squash = max(0.0, 1.0 - self.dead_for / FLAT_SECONDS) + w = int(FLAT_SIZE[0] - (FLAT_SIZE[0] - SIZE) * squash) + h = int(FLAT_SIZE[1] + (SIZE - FLAT_SIZE[1]) * squash) + feet = int(self.y) + FEET + cam + screen.blit(sprites.sprite(2, 0), rect(int(self.x) - (w - SIZE) // 2, feet - h * FEET // SIZE, w, h)) diff --git a/badge/apps/flappy_mona_redux/obstacle.py b/badge/apps/flappy_mona_redux/obstacle.py new file mode 100644 index 00000000..031036ec --- /dev/null +++ b/badge/apps/flappy_mona_redux/obstacle.py @@ -0,0 +1,52 @@ +import random + +from world import HEIGHT, SPEED, WIDTH, overlaps + +sprites = image.load("assets/obstacles.png").spritesheet(2, 1) +BRICK = sprites.sprite(0, 0) +CAP = sprites.sprite(1, 0) + +TILE = 48 +GAP = 120 +MIN_WALL = 30 # shortest wall left above or below the gap +INSET = 4 # forgiving margin between the art and the hit area + + +class Obstacle: + def __init__(self): + self.x = float(WIDTH) + self.gap_y = random.randint(MIN_WALL, HEIGHT - GAP - MIN_WALL) + self.passed = False + + def update(self, dt): + self.x -= SPEED * dt + + def solids(self): + bottom = self.gap_y + GAP + return ( + (self.x, 0, TILE, self.gap_y - INSET), + (self.x, bottom + INSET, TILE, HEIGHT - bottom - INSET), + ) + + def hits(self, box): + for solid in self.solids(): + if overlaps(solid, box): + return True + return False + + def draw(self, cam=0): + x = int(self.x) + + y = self.gap_y - TILE + screen.blit(CAP, vec2(x, y + cam)) + y -= TILE + while y + cam > -TILE: + screen.blit(BRICK, vec2(x, y + cam)) + y -= TILE + + bottom = self.gap_y + GAP + screen.blit(CAP, rect(x, bottom + cam, TILE, -TILE)) + y = bottom + TILE + while y + cam < HEIGHT: + screen.blit(BRICK, rect(x, y + cam, TILE, -TILE)) + y += TILE diff --git a/badge/apps/flappy_mona_redux/tower.py b/badge/apps/flappy_mona_redux/tower.py new file mode 100644 index 00000000..0605652a --- /dev/null +++ b/badge/apps/flappy_mona_redux/tower.py @@ -0,0 +1,190 @@ +from fish import Fish +from world import HEIGHT, SPEED, WIDTH, overlaps + +# Floating islands of brick: stairs up the left, a deck on top, then steps down +# the right. The big roof also has spikes and rollers. A low tunnel runs +# underneath every island, so climbing is always optional. Positions are world +# coordinates (a tall deck sits above y=0); Course and Mona add the camera +# offset when they draw. + +roof = image.load("assets/roof.png").spritesheet(6, 1) +lip = image.load("assets/roof_lip.png").spritesheet(2, 1) +underside = image.load("assets/roof_under.png") +spike_art = image.load("assets/spike.png") +roller_art = image.load("assets/roller.png").spritesheet(4, 1) + +STRIPS = [roof.sprite(i, 0) for i in range(6)] # index = course * 2 + column parity +LIPS = [lip.sprite(i, 0) for i in range(2)] +ROLLER_FRAMES = [roller_art.sprite(i, 0) for i in range(4)] + +WALL, SPIKE, ROLLER = 1, 2, 3 # what hits() can report + +COL = 24 # width of one brick column +COURSE = 16 # height of one course of bricks +LIP_H = 4 +UNDER_W = 48 +UNDER_H = 20 + +FIRST_TREAD_Y = 88 # top of the lowest stair +TREAD_RISE = 16 +UNDERSIDE_Y = 124 # bottom of the artwork +INSET = 4 # forgiving margin between the underside art and its hit area +STEP_UP = 20 # tallest ledge Mona can haul herself onto +MASS_BOTTOM = UNDERSIDE_Y - INSET + +DECK_SCREEN_Y = 150 # where a deck sits on screen while Mona is up there + +SPIKE_H = 14 +SPIKE_HIT = (2, 2, 12, 12) # x, y, w, h inside the artwork + +ROLLER_SIZE = 32 +ROLLER_HIT = (3, 4, 26, 28) # x, y, w, h inside the artwork +ROLLER_SPEED = 60 # px/s along the roof, on top of the tower's own scroll +RELEASE_X = WIDTH + 10 # a roller waits off screen until it gets this close +ROLLER_LEAD = 137 # a roller waiting at roof x meets Mona where a spike at x - ROLLER_LEAD would +ROLLER_STARTS = tuple(meet + ROLLER_LEAD for meet in (160, 320)) +ROLLER_FRAME_PX = 6.25 # px rolled per frame: a 22.5 degree turn of the 16 px radius drum + + + +class Layout: + """The shape of one tower: stairs up, a flat deck, stairs down, and what sits on the deck.""" + + def __init__(self, up, deck_cols, down, spikes=(), rollers=(), fish=(), fish_lift=124): + self.deck_y = FIRST_TREAD_Y - TREAD_RISE * up # surface of the deck + self.deck_start = up * COL # x of the deck, measured from the tower's left edge + self.tops = tuple( + [FIRST_TREAD_Y - TREAD_RISE * i for i in range(up)] + + [self.deck_y] * deck_cols + + [self.deck_y + TREAD_RISE * (i + 1) for i in range(down)] + ) + self.columns = len(self.tops) # must be even: the underside is tiled two columns at a time + self.length = self.columns * COL + self.spikes = spikes # deck x of each spike + self.rollers = rollers # deck x where each roller waits + self.fish = fish # deck x of each fish + self.fish_y = self.deck_y - fish_lift # the default sits level with the top of a jump + self.cam_max = DECK_SCREEN_Y - self.deck_y # how far the camera rises to show the deck + + +LAYOUTS = { + # the big one: a long deck of spikes and rollers that ends on a cliff + "roof": Layout(8, 20, 4, spikes=(76, 240), rollers=ROLLER_STARTS, fish=(224, 300)), + # a lower deck with one spike and stairs all the way back down + "hill": Layout(6, 8, 6, spikes=(96,), fish=(80,)), + # a short hop up and over with nothing to fear and a fish to jump for + "steps": Layout(4, 4, 4, fish=(24,), fish_lift=96), +} + + +class Tower: + def __init__(self, layout): + self.layout = layout + self.x = float(WIDTH) + self.passed = False + + def update(self, dt): + self.x -= SPEED * dt + + def right_end(self): + return self.x + self.layout.length + + def make_fish(self): + layout = self.layout + left = self.x + layout.deck_start + return [Fish(left + u, layout.fish_y) for u in layout.fish] + + def camera_for(self, ground_y): + """How far the camera rises while Mona stands at this height on the tower.""" + layout = self.layout + t = (FIRST_TREAD_Y - ground_y) / (FIRST_TREAD_Y - layout.deck_y) + return layout.cam_max * max(0.0, min(1.0, t)) + + def span(self, left, right): + """The first and last columns that a box from left to right overlaps.""" + first = max(0, int((left - self.x) // COL)) + last = min(self.layout.columns - 1, int((right - self.x - 0.001) // COL)) + return first, last + + def landing(self, prev_feet, feet, left, right): + """Top of the highest column Mona can stand on or step up onto, if any.""" + tops = self.layout.tops + first, last = self.span(left, right) + best = None + for c in range(first, last + 1): + top = tops[c] + if feet >= top and prev_feet <= top + STEP_UP and (best is None or top < best): + best = top + return best + + def roller_x(self, start): + """Screen x of a roller and how far it has rolled; it speeds up once released.""" + s = self.x + self.layout.deck_start + start + rolled = max(0.0, RELEASE_X - s) * ROLLER_SPEED / SPEED + return s - rolled, rolled + + def hits(self, box, hazard): + layout = self.layout + tops = layout.tops + first, last = self.span(box[0], box[0] + box[2]) + for c in range(first, last + 1): + top = tops[c] + if overlaps((self.x + c * COL, top, COL, MASS_BOTTOM - top), box): + return WALL + + spike_top = layout.deck_y - SPIKE_H + for u in layout.spikes: + x = self.x + layout.deck_start + u + SPIKE_HIT[0] + if overlaps((x, spike_top + SPIKE_HIT[1], SPIKE_HIT[2], SPIKE_HIT[3]), hazard): + return SPIKE + + roller_top = layout.deck_y - ROLLER_SIZE + for start in layout.rollers: + x, _ = self.roller_x(start) + if overlaps((x + ROLLER_HIT[0], roller_top + ROLLER_HIT[1], ROLLER_HIT[2], ROLLER_HIT[3]), hazard): + return ROLLER + return None + + def draw(self, cam=0): + layout = self.layout + tops = layout.tops + cam = int(cam) + base = int(self.x) + first = max(0, (-base) // COL) + last = min(layout.columns - 1, (WIDTH - base) // COL) + course_end = UNDERSIDE_Y - UNDER_H + + for c in range(first, last + 1): + sx = base + c * COL + top = tops[c] + half = c % 2 + y = top + if y + cam + COURSE <= 0: + y += ((-cam - COURSE - y) // COURSE + 1) * COURSE # skip courses above the screen + while y < course_end and y + cam < HEIGHT: + index = (y - FIRST_TREAD_Y) // COURSE % 3 * 2 + half + screen.blit(STRIPS[index], vec2(sx, y + cam)) + y += COURSE + if -LIP_H < top + cam < HEIGHT: + screen.blit(LIPS[half], vec2(sx, top + cam)) + + under_y = course_end + cam + if under_y < HEIGHT: + for j in range(max(0, (-base) // UNDER_W), min(layout.length // UNDER_W - 1, (WIDTH - base) // UNDER_W) + 1): + screen.blit(underside, vec2(base + j * UNDER_W, under_y)) + + spike_y = layout.deck_y - SPIKE_H + cam + if -SPIKE_H < spike_y < HEIGHT: + for u in layout.spikes: + sx = base + layout.deck_start + u + if -16 < sx < WIDTH: + screen.blit(spike_art, vec2(sx, spike_y)) + + roller_y = layout.deck_y - ROLLER_SIZE + cam + if -ROLLER_SIZE < roller_y < HEIGHT: + for start in layout.rollers: + x, rolled = self.roller_x(start) + if -ROLLER_SIZE < x < WIDTH: + # rolling left turns the drum anticlockwise, so count the frames backwards + frame = ROLLER_FRAMES[-int(rolled / ROLLER_FRAME_PX) % 4] + screen.blit(frame, vec2(int(x), roller_y)) diff --git a/badge/apps/flappy_mona_redux/ui.py b/badge/apps/flappy_mona_redux/ui.py new file mode 100644 index 00000000..e1cb8d42 --- /dev/null +++ b/badge/apps/flappy_mona_redux/ui.py @@ -0,0 +1,53 @@ +from world import WIDTH + +typeface = font.load("/system/assets/fonts/DynaPuff-Medium.af") + +WHITE = color.rgb(255, 255, 255) +GOLD = color.rgb(255, 214, 80) +NAVY = color.rgb(22, 44, 96) +SHADOW = color.rgb(16, 36, 64, 150) +PANEL = color.rgb(16, 36, 64, 120) +DIM = color.rgb(16, 36, 64, 150) + + +def text_mode(): + screen.font = typeface + screen.fill_rule = image.EVEN_ODD + screen.antialias = image.X2 + + +def pixel_mode(): + screen.antialias = image.OFF + + +def measure(text, size): + return screen.measure_text(text, font_size=size) + + +def shadow_text(text, x, y, size, pen=WHITE): + screen.pen = SHADOW + screen.text(text, x + 2, y + 2, size) + screen.pen = pen + screen.text(text, x, y, size) + + +def outlined_text(text, x, y, size, fill, edge=NAVY, thickness=2): + screen.pen = edge + for dx, dy in ((-1, -1), (1, -1), (-1, 1), (1, 1), (0, 2), (0, -1)): + screen.text(text, x + dx * thickness, y + dy * thickness, size) + screen.pen = fill + screen.text(text, x, y, size) + + +def centered(text, y, size, pen=WHITE, outline=None): + width, _ = measure(text, size) + x = (WIDTH - width) / 2 + if outline is None: + shadow_text(text, x, y, size, pen) + else: + outlined_text(text, x, y, size, pen, outline) + + +def panel(x, y, w, h, radius=8, pen=PANEL): + screen.pen = pen + screen.shape(shape.rounded_rectangle(x, y, w, h, radius)) diff --git a/badge/apps/flappy_mona_redux/world.py b/badge/apps/flappy_mona_redux/world.py new file mode 100644 index 00000000..985df892 --- /dev/null +++ b/badge/apps/flappy_mona_redux/world.py @@ -0,0 +1,70 @@ +WIDTH = 320 +HEIGHT = 240 +GROUND_Y = 216 # top of the lawn +SPEED = 60 # px/s that walls, fish and the lawn travel left + +SKY_TOP = (46, 164, 244) +SKY_BOTTOM = (160, 234, 255) +SKY_BANDS = 12 +BAND_H = HEIGHT // SKY_BANDS + +far_hills = image.load("assets/far_hills.png") +hills = image.load("assets/background.png") +grass = image.load("assets/grass.png") +cloud = image.load("assets/cloud.png") + + +def lerp_color(a, b, t): + return color.rgb( + int(a[0] + (b[0] - a[0]) * t), + int(a[1] + (b[1] - a[1]) * t), + int(a[2] + (b[2] - a[2]) * t), + ) + + +sky = [lerp_color(SKY_TOP, SKY_BOTTOM, i / (SKY_BANDS - 1)) for i in range(SKY_BANDS)] + + +def overlaps(a, b): + return ( + a[0] < b[0] + b[2] + and b[0] < a[0] + a[2] + and a[1] < b[1] + b[3] + and b[1] < a[1] + a[3] + ) + + +def scatter(img, offset, y, period=None): + if y >= HEIGHT or y + img.height <= 0: + return + period = period or img.width + x = -(offset % period) + while x < WIDTH: + screen.blit(img, vec2(int(x), y)) + x += period + + +class World: + def __init__(self): + self.scroll = 0.0 + + def advance(self, dt): + self.scroll += SPEED * dt + + def draw(self, cam=0): + cam = int(cam) + drift = cam // 2 # clouds follow the camera at half speed + + y = 0 + for pen in sky: + screen.pen = pen + screen.rectangle(0, y, WIDTH, BAND_H) + y += BAND_H + + scroll = self.scroll + scatter(cloud, scroll * 0.10 + 90, -64 + drift, 320) + scatter(cloud, scroll * 0.10, 28 + drift, 300) + scatter(cloud, scroll * 0.10 + 170, 76 + drift, 340) + scatter(far_hills, scroll * 0.04, 112 + cam) + scatter(hills, scroll * 0.12, HEIGHT - hills.height + cam) + scatter(grass, scroll, HEIGHT - grass.height + cam) diff --git a/tools/build_flappy_mona_redux_assets.py b/tools/build_flappy_mona_redux_assets.py new file mode 100644 index 00000000..df40dbec --- /dev/null +++ b/tools/build_flappy_mona_redux_assets.py @@ -0,0 +1,319 @@ +#!/usr/bin/env python3 +"""Build the 320x240 artwork for Flappy Mona Redux. + +The original Flappy Mona art is drawn for the 160x120 display mode. Redux runs +at the full 320x240, so each sprite is re-rendered at twice the size with the +Scale2x (EPX) pixel-art algorithm, which keeps the hand-drawn look but smooths +the stair-stepped diagonals. The fish, far hills, roller and icon are drawn here, +and the roof tower's brick strips, mossy lip, underside spikes and floor spike +are cut from the scaled wall tiles so they match the walls exactly. + +Run from the repository root: + + python3 tools/build_flappy_mona_redux_assets.py +""" + +import math +from pathlib import Path + +from PIL import Image, ImageDraw, ImageOps + +ROOT = Path(__file__).resolve().parents[1] +SOURCE = ROOT / "badge/apps/flappy_mona/assets" +APP = ROOT / "badge/apps/flappy_mona_redux" +OUTPUT = APP / "assets" + +CLEAR = (0, 0, 0, 0) +WHITE = (255, 255, 255, 255) +MORTAR = (73, 36, 85, 255) # the dark outline and mortar of the wall tiles +MOSS = (36, 146, 0, 255) +LIGHT_MOSS = (73, 182, 0, 255) +NAVY = (36, 36, 85, 255) +GOLD = (255, 182, 0, 255) +STEEL = (109, 109, 170, 255) +STEEL_DARK = (73, 73, 130, 255) +STEEL_LIGHT = (170, 170, 215, 255) + + +def scale2x(image, edge="transparent"): + """Scale2x/EPX. `edge` is how pixels outside the image are read: + "transparent" for sprites, "clamp" for the bottom of tiles, and "wrap" to + keep horizontally repeating tiles seamless.""" + image = image.convert("RGBA") + width, height = image.size + source = image.load() + + def pixel(x, y): + if edge == "wrap": + x %= width + y = min(max(y, 0), height - 1) + elif edge == "clamp": + x = min(max(x, 0), width - 1) + y = min(max(y, 0), height - 1) + elif not (0 <= x < width and 0 <= y < height): + return CLEAR + return source[x, y] + + result = Image.new("RGBA", (width * 2, height * 2), CLEAR) + target = result.load() + for y in range(height): + for x in range(width): + p = pixel(x, y) + a, b = pixel(x, y - 1), pixel(x + 1, y) + c, d = pixel(x - 1, y), pixel(x, y + 1) + target[2 * x, 2 * y] = a if c == a and c != d and a != b else p + target[2 * x + 1, 2 * y] = b if a == b and a != c and b != d else p + target[2 * x, 2 * y + 1] = c if d == c and d != b and c != a else p + target[2 * x + 1, 2 * y + 1] = d if b == d and b != a and d != c else p + return result + + +def scale_sheet(path, columns, rows): + """Scale each frame of a sprite sheet on its own so frames never bleed.""" + sheet = Image.open(path).convert("RGBA") + frame_w, frame_h = sheet.width // columns, sheet.height // rows + result = Image.new("RGBA", (sheet.width * 2, sheet.height * 2), CLEAR) + for row in range(rows): + for column in range(columns): + box = (column * frame_w, row * frame_h, (column + 1) * frame_w, (row + 1) * frame_h) + frame = scale2x(sheet.crop(box)) + result.paste(frame, (column * frame_w * 2, row * frame_h * 2)) + return result + + +def outline(image, colour=WHITE): + """Add a one pixel outline around the opaque pixels of `image`.""" + width, height = image.size + source = image.load() + result = image.copy() + target = result.load() + for y in range(height): + for x in range(width): + if source[x, y][3]: + continue + for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)): + nx, ny = x + dx, y + dy + if 0 <= nx < width and 0 <= ny < height and source[nx, ny][3]: + target[x, y] = colour + break + return result + + +def far_hills(width=256, height=64): + """A soft, distant ridge line that tiles horizontally.""" + image = Image.new("RGBA", (width, height), CLEAR) + pixels = image.load() + sky_top = (118, 206, 232, 255) + sky_bottom = (150, 224, 240, 255) + for x in range(width): + t = 2 * math.pi * x / width + ridge = 26 + 11 * math.sin(t + 0.6) + 7 * math.sin(2 * t + 2.1) + 4 * math.sin(3 * t + 4.0) + for y in range(int(ridge), height): + mix = (y - ridge) / max(1, height - ridge) + pixels[x, y] = tuple( + round(sky_top[i] + (sky_bottom[i] - sky_top[i]) * mix) for i in range(3) + ) + (255,) + return image + + +def fish_frame(tail): + """One frame of the fish, facing left. `tail` swings the tail fin -2..2.""" + scale = 4 + size = (22 * scale, 14 * scale) + art = Image.new("RGBA", size, CLEAR) + draw = ImageDraw.Draw(art) + + def box(x0, y0, x1, y1): + return (x0 * scale, y0 * scale, x1 * scale - 1, y1 * scale - 1) + + def points(*coordinates): + return [(x * scale, y * scale) for x, y in coordinates] + + orange = (255, 150, 40, 255) + dark = (226, 98, 28, 255) + light = (255, 205, 96, 255) + # Tail fin first so the body overlaps its root. + swing = tail * 1.5 + draw.polygon(points((14, 7), (21, 3 + swing), (21, 11 + swing)), fill=dark) + # Dorsal and belly fins. + draw.polygon(points((8, 3.5), (11, 0.5), (13, 3.5)), fill=dark) + draw.polygon(points((9, 10.5), (11.5, 13), (13, 10.5)), fill=dark) + # Body, belly and highlight. + draw.ellipse(box(1, 2, 16, 12), fill=orange) + draw.ellipse(box(2, 7, 15, 12), fill=light) + draw.ellipse(box(2, 2, 15, 8), fill=orange) + # Stripes. + for x in (8, 11): + draw.line(points((x, 3.5), (x + 0.5, 10.5)), fill=dark, width=scale) + # Eye. + draw.ellipse(box(3, 4, 6, 7), fill=WHITE) + draw.ellipse(box(3.5, 5, 5.5, 7), fill=(30, 20, 60, 255)) + + # Flatten the 4x art to the 1x pixel grid, then thicken it into an outlined sprite. + small = art.resize((22, 14), Image.NEAREST) + pixels = small.load() + for y in range(14): + for x in range(22): + r, g, b, a = pixels[x, y] + pixels[x, y] = (r, g, b, 255 if a >= 128 else 0) + padded = Image.new("RGBA", (24, 16), CLEAR) + padded.paste(small, (1, 1)) + return scale2x(outline(padded)) + + +def build_fish(): + frames = [fish_frame(tail) for tail in (-2, 0, 2, 0)] + sheet = Image.new("RGBA", (frames[0].width * len(frames), frames[0].height), CLEAR) + for index, frame in enumerate(frames): + sheet.paste(frame, (index * frame.width, 0)) + return sheet + + +def roof_strips(brick): + """The brick tile's three 16px courses, each cut into 24px left and right + halves. The tile corners are cut away, so fill them with mortar to keep the + joined strips free of pin holes.""" + strips = Image.new("RGBA", (24 * 6, 16), CLEAR) + for course in range(3): + for half in range(2): + left = half * 24 + piece = brick.crop((left, course * 16, left + 24, course * 16 + 16)) + pixels = piece.load() + for y in range(16): + for x in range(24): + if not pixels[x, y][3]: + pixels[x, y] = MORTAR + strips.paste(piece, ((course * 2 + half) * 24, 0)) + return strips + + +def roof_lip(): + """A 4px mossy cap for the top of every tread, as left and right 24px halves.""" + lip = Image.new("RGBA", (48, 4), CLEAR) + pixels = lip.load() + for x in range(48): + pixels[x, 0] = MORTAR + pixels[x, 1] = LIGHT_MOSS + pixels[x, 2] = MOSS + if x % 8 in (0, 1, 2, 5, 6): + pixels[x, 3] = MOSS + return lip + + +def roof_spike(cap): + """One of the cap tile's downward spikes, flipped to stand on the roof.""" + spike = Image.new("RGBA", (16, 14), CLEAR) + spike.paste(ImageOps.flip(cap.crop((2, 34, 16, 48))), (1, 0)) + return spike + + +def roller_frame(step): + """One of four turns of a steel roller drum. The four spokes repeat every + quarter turn, so four frames close the loop.""" + scale = 8 + size = 14 * scale + middle = size / 2 + art = Image.new("RGBA", (size, size), CLEAR) + draw = ImageDraw.Draw(art) + + def disc(radius, fill): + draw.ellipse( + (middle - radius * scale, middle - radius * scale, middle + radius * scale - 1, middle + radius * scale - 1), + fill=fill, + ) + + disc(7, STEEL_LIGHT) + disc(5.6, STEEL) + disc(3.4, STEEL_DARK) + for spoke in range(4): + angle = math.radians(step * 22.5 + spoke * 90) + dx, dy = math.cos(angle), math.sin(angle) + px, py = -dy, dx + reach, half = 5.4 * scale, 0.7 * scale + draw.polygon( + [ + (middle + px * half, middle + py * half), + (middle + dx * reach + px * half, middle + dy * reach + py * half), + (middle + dx * reach - px * half, middle + dy * reach - py * half), + (middle - px * half, middle - py * half), + ], + fill=NAVY, + ) + draw.ellipse( + ( + middle + dx * 4.6 * scale - 0.8 * scale, + middle + dy * 4.6 * scale - 0.8 * scale, + middle + dx * 4.6 * scale + 0.8 * scale, + middle + dy * 4.6 * scale + 0.8 * scale, + ), + fill=STEEL_LIGHT, + ) + disc(1.7, GOLD) + + small = art.resize((14, 14), Image.NEAREST) + pixels = small.load() + for y in range(14): + for x in range(14): + r, g, b, a = pixels[x, y] + pixels[x, y] = (r, g, b, 255 if a >= 128 else 0) + # The light stays put while the drum turns, so paint the glint last. + for x, y in ((3, 2), (4, 1), (5, 1), (2, 3)): + pixels[x, y] = WHITE + + padded = Image.new("RGBA", (16, 16), CLEAR) + padded.paste(small, (1, 1)) + return scale2x(outline(padded, NAVY)) + + +def build_roller(): + frames = [roller_frame(step) for step in range(4)] + sheet = Image.new("RGBA", (frames[0].width * len(frames), frames[0].height), CLEAR) + for index, frame in enumerate(frames): + sheet.paste(frame, (index * frame.width, 0)) + return sheet + + +def build_icon(fish): + """The 24x24 menu icon the launcher expects: the original Mona with a fish.""" + icon = Image.new("RGBA", (24, 24), CLEAR) + icon.alpha_composite(Image.open(SOURCE / "mona.png").crop((0, 0, 24, 24)), (0, -1)) + small = fish.crop((0, 0, 48, 32)).resize((16, 10), Image.BOX) + pixels = small.load() + for y in range(small.height): + for x in range(small.width): + r, g, b, a = pixels[x, y] + pixels[x, y] = (r, g, b, 255 if a >= 128 else 0) + icon.alpha_composite(small, (8, 14)) + return icon + + +def save(image, name): + OUTPUT.mkdir(parents=True, exist_ok=True) + image.save(OUTPUT / name, optimize=True) + print(f"{name}: {image.width}x{image.height}") + + +def main(): + mona = scale_sheet(SOURCE / "mona.png", 7, 2) + fish = build_fish() + obstacles = scale_sheet(SOURCE / "obstacles.png", 2, 1) + brick, cap = obstacles.crop((0, 0, 48, 48)), obstacles.crop((48, 0, 96, 48)) + save(mona, "mona.png") + save(obstacles, "obstacles.png") + save(scale2x(Image.open(SOURCE / "cloud.png"), "clamp"), "cloud.png") + save(scale2x(Image.open(SOURCE / "background.png"), "wrap"), "background.png") + save(scale2x(Image.open(SOURCE / "grass.png"), "wrap"), "grass.png") + save(far_hills(), "far_hills.png") + save(fish, "fish.png") + save(roof_strips(brick), "roof.png") + save(roof_lip(), "roof_lip.png") + save(cap.crop((0, 28, 48, 48)), "roof_under.png") + save(roof_spike(cap), "spike.png") + save(build_roller(), "roller.png") + icon = build_icon(fish) + icon.save(APP / "icon.png", optimize=True) + print(f"icon.png: {icon.width}x{icon.height}") + + +if __name__ == "__main__": + main()