Landscape
aadmin2026-09-16 发布3D6 阅读

Landscape

类型:3D · 分类:Three.js · 收录:2026-09-16 21:09:01 · 源码:会员可见

[hidecontent type="vip1"]
# Landscape
A tower-free procedural terrain whose light, sky, fog, stars, rain, lightning, snow, grass, and stones move through seven authored environment states.

> 来源:ThreeUI Community · https://threeui.com · MIT License(Meng To / Design+Code)
> 组件页:https://threeui.com/component/landscape · 预览动画:https://threeui.com/previews/landscape.webm
> 分类:Three.js
> 包含变体(7):sunrise、noon、sunset、night、rain、storm、snow

/* ===== src/shaders/landscape/LandscapeScene.tsx (tsx) ===== */
import { useEffect, useMemo, useState } from "react";

export const LANDSCAPE_VARIANTS = ["sunrise", "noon", "sunset", "night", "rain", "storm", "snow"] as const;
export type LandscapeVariant = (typeof LANDSCAPE_VARIANTS)[number];

const LANDSCAPE_STATES: Record<LandscapeVariant, { time: string; weather: string; label: string }> = {
  sunrise: { time: "morning", weather: "clear", label: "sunrise" },
  noon: { time: "noon", weather: "clear", label: "noon" },
  sunset: { time: "sunset", weather: "clear", label: "sunset" },
  night: { time: "night", weather: "clear", label: "night" },
  rain: { time: "noon", weather: "rain", label: "rain" },
  storm: { time: "sunset", weather: "storm", label: "storm" },
  snow: { time: "noon", weather: "snow", label: "snow" },
};

export type LandscapeSceneProps = {
  className?: string;
  sourceUrl?: string;
  variant?: LandscapeVariant;
};

export function LandscapeScene({
  className = "",
  sourceUrl = "/landscape.html",
  variant = "sunrise",
}: LandscapeSceneProps) {
  const [ready, setReady] = useState(false);
  const frameSource = useMemo(() => {
    const state = LANDSCAPE_STATES[variant];
    const hashIndex = sourceUrl.indexOf("#");
    const base = hashIndex >= 0 ? sourceUrl.slice(0, hashIndex) : sourceUrl;
    const hash = hashIndex >= 0 ? sourceUrl.slice(hashIndex) : "";
    const separator = base.includes("?") ? "&" : "?";
    return `${base}${separator}variant=${variant}&time=${state.time}&weather=${state.weather}${hash}`;
  }, [sourceUrl, variant]);

  useEffect(() => setReady(false), [frameSource]);

  return (
    <div
      className={`landscape-scene${className ? ` ${className}` : ""}`}
      data-state={ready ? "ready" : "loading"}
      data-variant={variant}
    >
      <iframe
        key={variant}
        className={`landscape-scene__frame${ready ? " is-ready" : ""}`}
        title={`Procedural landscape at ${LANDSCAPE_STATES[variant].label}`}
        src={frameSource}
        sandbox="allow-scripts"
        loading="eager"
        onLoad={() => setReady(true)}
      />
    </div>
  );
}

/* ===== scripts/generate-landscape.mjs (text) ===== */
import { readFile, writeFile } from "node:fs/promises";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const sourcePath = join(packageRoot, "src", "shaders", "japanese-tower", "Towers.html");
const outputPath = join(packageRoot, "public", "landscape.html");

const landscapeOnlyStyle = `<style data-threeui-landscape>
header,
.col-l,
.col-r,
.tag,
.plaque,
.bigpct,
footer,
.bg-grid2,
.bg-rings,
.bg-wash {
  display: none !important;
}

html,
body,
#app {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#stage {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

#stage.dragging {
  cursor: grabbing;
}
</style>`;

const landscapeSelector = `const LANDSCAPE_PRESETS={
  sunrise:{time:'morning',weather:'clear'},
  noon:{time:'noon',weather:'clear'},
  sunset:{time:'sunset',weather:'clear'},
  night:{time:'night',weather:'clear'},
  rain:{time:'noon',weather:'rain'},
  storm:{time:'sunset',weather:'storm'},
  snow:{time:'noon',weather:'snow'}
};
const LANDSCAPE_TIME_INDEX={morning:0,sunrise:0,noon:1,sunset:2,night:3};
const LANDSCAPE_WEATHER_INDEX={clear:0,rain:1,storm:2,snow:3};
const landscapeParams=new URLSearchParams(location.search);
const requestedLandscape=landscapeParams.get('variant')||'sunrise';
const landscapePreset=LANDSCAPE_PRESETS[requestedLandscape]||LANDSCAPE_PRESETS.sunrise;
const requestedTime=(landscapeParams.get('time')||landscapePreset.time).toLowerCase();
const requestedWeather=(landscapeParams.get('weather')||landscapePreset.weather).toLowerCase();
const landscapeStyle=STYLES[0];
CAPS=[];
STAGES=landscapeStyle.stages.map((x,k)=>({t:STAGE_T[k],cn:x[0],en:x[1],to:x[2]}));
scafGroups=[];
playing=false;
applyTime(DUR);
ground.visible=false;
capMesh.visible=false;
applyWeather(LANDSCAPE_WEATHER_INDEX[requestedWeather]??0,true);
applyTheme(LANDSCAPE_TIME_INDEX[requestedTime]??0,true);
if(requestedWeather==='snow'){
  snowPack=0.72;
  refreshLook();
}
document.documentElement.setAttribute('data-landscape-variant',requestedLandscape);
document.documentElement.setAttribute('data-landscape-weather',requestedWeather);
window.__landscapeState={variant:requestedLandscape,time:THEMES[themeIdx].id,weather:WEATHER[wxIdx].id,towerVisible:false};`;

function replaceExact(source, needle, replacement, label) {
  if (!source.includes(needle)) throw new Error(`Landscape adapter could not find ${label}.`);
  return source.replace(needle, replacement);
}

let output = await readFile(sourcePath, "utf8");
output = replaceExact(output, "<title>Towers</title>", "<title>Landscape — Time & Weather</title>", "the source title");
output = replaceExact(output, "</head>", `${landscapeOnlyStyle}</head>`, "the document head");
output = replaceExact(output, "let actx=null,soundOn=true", "let actx=null,soundOn=false", "the audio default");
output = replaceExact(
  output,
  "const UNITS_TALL=14.56,CAM_H=7.065,CAM_D=80;",
  "const UNITS_TALL=34,CAM_H=3.4,CAM_D=80;",
  "the authored camera constants",
);
output = replaceExact(output, "const UNITS_WIDE=10.4;", "const UNITS_WIDE=48;", "the authored horizontal fit");
output = replaceExact(output, "const CAM_FLOOR=3.4;", "const CAM_FLOOR=CAM_H;", "the authored camera floor");
output = replaceExact(output, "(CAM_FLOOR-7.065)/80", "(CAM_FLOOR-CAM_H)/CAM_D", "the authored elevation clamp");
output = replaceExact(
  output,
  "applyStyle(0);napplyWeather(0,true);napplyTheme(0,true);",
  landscapeSelector,
  "the authored initial environment",
);

await writeFile(outputPath, output);

/* ===== public/landscape.html (html) ===== */
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<title>Landscape — Time & Weather</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' fill='%23ecdcbc'/><g fill='%232e2515'><path d='M4 12h24l-3 3H7z'/><path d='M6 19h20l-3 3H9z'/><path d='M8.5 26h15l-2 3h-11z'/><rect x='11' y='15' width='10' height='4'/><rect x='12.5' y='22' width='7' height='4'/><rect x='15' y='4' width='2' height='5'/><path d='M9 12l7-6 7 6z'/></g></svg>">
<style>
:root{
  --k:1;
  --paper:#ecdcbc; --w0:#fdf1d6; --w1:#f7e5c6; --w2:#ebd9b6;
  --ink:#2e2515; --ink2:#8b7c5c; --ink3:#3f3520;
  --accent:#a8621f;
  --line:#d9caa6; --rule2:#c2b18c; --divider:rgba(62,44,18,.30); --hairline:rgba(58,40,14,.40);
  --grid:rgba(96,74,32,.07);
  --pl-a:#fdf8e8; --pl-b:#f0e6cc; --pl-br:#ddceac; --pl-fg:#3f3520;
  --track:#dccba8; --fillc:#96551b;
  --btn:#332a17; --btn-fg:#f6eed8;
  --sans:"Helvetica Neue",Helvetica,Arial,system-ui,sans-serif;
  --mincho:"Hiragino Mincho ProN","Yu Mincho",YuMincho,"HiraMinProN-W3","Noto Serif JP","Songti SC",serif;
}
body,header,footer,.tbtn,.brand,.top-mid,.eyebrow,.big-cn,.sub-cn,.quote,.quote i,
.pager,.pager .bar,.pager .dim,.title-cn,.roman,.tag,.plaque,.track,.fill,.time,.replay{
  transition:background-color .55s ease,color .55s ease,border-color .55s ease;
}
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%}
body{
  background:var(--paper);color:var(--ink);
  font-family:var(--sans);overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
#app{position:fixed;inset:0;overflow:hidden}

/* ---------- background ---------- */
.bg-wash{position:absolute;inset:0;
  background:radial-gradient(118% 80% at 50% 40%,
    var(--w0) 0%, var(--w0) 26%, var(--w1) 58%, var(--w2) 84%, var(--paper) 100%);
  transition:background .55s ease;}
.bg-grid{position:absolute;inset:0;pointer-events:none;
  background-image:repeating-linear-gradient(to right,
    var(--grid) 0 1px, transparent 1px calc(100% / 9.09));}
.bg-rings{position:absolute;inset:0;pointer-events:none}


/* ---------- webgl ---------- */
#stage{position:absolute;left:0;display:block;cursor:grab;touch-action:none}
#stage.dragging{cursor:grabbing}

/* ---------- header ---------- */
header{position:absolute;left:0;right:0;top:0;
  height:calc(54px * var(--k));
  padding:0 calc(45px * var(--k));
  display:flex;align-items:center;
  border-bottom:1px solid var(--hairline);}
.brand{font-weight:700;font-size:calc(36.5px * var(--k));line-height:1;position:relative;top:calc(-2.4px * var(--k));
  letter-spacing:calc(-0.2px * var(--k));
  transform:scaleX(.72);transform-origin:left center;color:var(--ink);}
.top-mid{position:absolute;left:50%;top:calc(24px * var(--k));
  transform:translate(-50%,-50%);
  font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(1.15px * var(--k));
  color:var(--ink2);white-space:nowrap;}
.top-right{margin-left:auto;display:flex;align-items:flex-start;gap:calc(19px * var(--k));
  padding-top:calc(4px * var(--k));}
.tbtn{font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(0.9px * var(--k));
  color:var(--ink);background:none;border:0;font-family:inherit;
  padding:0 0 calc(7px * var(--k)) 0;
  border-bottom:1px solid var(--hairline);cursor:pointer;white-space:nowrap;
  transition:color .18s,border-color .18s;}
.tbtn:hover{color:var(--accent);border-color:var(--accent)}
.tbtn b{font-weight:700}
.tbtn b::after{content:" / "}

/* ---------- left column ---------- */
.col-l{position:absolute;left:calc(55.5px * var(--k));top:calc(266px * var(--k));
  width:calc(320px * var(--k));}
.eyebrow{font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(1.3px * var(--k));color:var(--ink2);line-height:1;}
.big-cn{font-family:var(--mincho);font-size:calc(65.5px * var(--k));line-height:1;
  color:var(--ink);margin-top:calc(22.7px * var(--k));letter-spacing:0;}
.sub-cn{font-size:calc(12px * var(--k));font-weight:700;line-height:1;
  letter-spacing:calc(1.5px * var(--k));color:var(--accent);margin-top:calc(13px * var(--k));}
.quote{font-family:var(--mincho);font-size:calc(15px * var(--k));
  line-height:calc(27px * var(--k));color:var(--ink3);
  margin-top:calc(27px * var(--k));letter-spacing:calc(.1px * var(--k));}
.quote i{font-style:normal;border-bottom:1px solid var(--rule2);
  padding-bottom:calc(4px * var(--k));}
.pager{margin-top:calc(30px * var(--k));display:flex;align-items:center;
  gap:calc(13px * var(--k));font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(1px * var(--k));color:var(--ink);line-height:1;}
.pager .bar{height:1px;background:var(--rule2);width:calc(58px * var(--k));display:block}
.pager .dim{color:var(--ink2)}

/* ---------- right column ---------- */
.col-r{position:absolute;left:calc(1119px * var(--k));top:calc(230px * var(--k));}
.glyphs{display:flex;gap:calc(19.5px * var(--k));align-items:center;height:calc(11px * var(--k))}
.glyphs svg{display:block;width:calc(10.5px * var(--k));height:calc(10.5px * var(--k))}
.title-cn{font-family:var(--mincho);font-size:calc(116px * var(--k));
  line-height:calc(113px * var(--k));color:var(--ink);
  margin-top:calc(49.9px * var(--k));white-space:pre;}
.title-cn b{font-weight:400;display:block}
.roman{font-family:var(--mincho);font-size:calc(14px * var(--k));
  letter-spacing:calc(.4px * var(--k));color:var(--ink3);
  margin-top:calc(-6px * var(--k));padding-left:calc(131px * var(--k));}
[data-style="thai"] .title-cn{font-size:calc(86px * var(--k));line-height:calc(96px * var(--k))}
[data-style="thai"] .big-cn{font-size:calc(56px * var(--k))}
[data-style="cambodia"] .title-cn{font-size:calc(62px * var(--k));line-height:calc(86px * var(--k))}
[data-style="cambodia"] .big-cn{font-size:calc(48px * var(--k))}
[data-style="turkey"] .title-cn{font-size:calc(74px * var(--k));line-height:calc(82px * var(--k));
  letter-spacing:calc(-1px * var(--k))}
[data-style="turkey"] .big-cn{font-size:calc(58px * var(--k))}
[data-style="vietnam"] .big-cn{font-size:calc(62px * var(--k))}
.tag{position:absolute;right:calc(46px * var(--k));top:calc(593.6px * var(--k));
  padding-left:calc(9px * var(--k));
  border-left:calc(2px * var(--k)) solid var(--accent);
  font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(.45px * var(--k));line-height:calc(14.5px * var(--k));
  color:var(--accent);}

/* ---------- stage plaque ---------- */
.plaque{position:absolute;transform:translate(-50%,-50%);
  background:linear-gradient(var(--pl-a),var(--pl-b));
  border:1px solid var(--pl-br);
  box-shadow:0 calc(2px * var(--k)) calc(4px * var(--k)) rgba(70,58,40,.12);
  padding:calc(7px * var(--k)) calc(14px * var(--k)) calc(6px * var(--k));
  font-size:calc(11px * var(--k));font-weight:600;
  letter-spacing:calc(1.05px * var(--k));color:var(--pl-fg);white-space:nowrap;
  font-family:var(--mincho);pointer-events:none;}
.plaque em{font-style:normal;font-family:var(--sans);font-weight:700;
  letter-spacing:calc(1.5px * var(--k));}

/* ---------- footer ---------- */
footer{position:absolute;left:0;right:0;bottom:0;
  height:calc(63px * var(--k));border-top:1px solid var(--hairline);
  padding:0 calc(46px * var(--k));display:flex;align-items:center;
  gap:calc(18px * var(--k));}
.replay{width:calc(30px * var(--k));height:calc(30px * var(--k));
  border-radius:50%;background:none;color:var(--ink);
  border:1px solid var(--hairline);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;flex:0 0 auto;transition:background .18s;}
.replay svg{width:calc(11px * var(--k));height:calc(11px * var(--k));display:block}
.replay:hover{color:var(--accent);border-color:var(--accent)}
.track{position:relative;flex:1 1 auto;height:calc(2.5px * var(--k));
  background:var(--hairline);cursor:pointer;}
.fill{position:absolute;left:0;top:0;bottom:0;width:0;background:var(--ink);opacity:.78}
.time{font-size:calc(11px * var(--k));font-weight:700;
  letter-spacing:calc(.5px * var(--k));color:var(--ink);opacity:.72;white-space:nowrap;
  font-variant-numeric:tabular-nums;min-width:calc(96px * var(--k));text-align:right;}
.bigpct{position:absolute;right:calc(46px * var(--k));
  bottom:calc(76px * var(--k));
  font-weight:700;font-size:calc(150px * var(--k));line-height:.76;
  letter-spacing:calc(-5px * var(--k));color:var(--ink);opacity:.88;
  font-variant-numeric:tabular-nums;pointer-events:none;
  transition:opacity .65s ease,color .55s ease;}
.bigpct i{font-style:normal;font-size:calc(44px * var(--k));
  letter-spacing:0;margin-left:calc(7px * var(--k));opacity:.5}
.bigpct.done{opacity:0}

/* ---------- lightning ---------- */
/* over the scene but under the type, so a strike lights the sky without
   washing out the page it is printed on */
.flash{position:absolute;inset:0;pointer-events:none;opacity:0;
  background:#dce6ff;mix-blend-mode:screen;}

/* ---------- phones ---------- */
/* the desktop layout is absolutely placed on a 1512x856 grid, so the small
   screen is not that grid scaled down — it is a different arrangement:
   type moves into the sky above the tower, and the controls come down into
   a scrolling strip within reach of a thumb. */
@media (max-width:760px),(max-height:460px){
  :root{--k:1}
  header{height:52px;padding:0 16px}
  .brand{font-size:29px;top:-1.6px}
  .top-mid{display:none}
  .top-right{position:fixed;left:0;right:0;bottom:52px;margin:0;
    gap:18px;padding:12px 16px 13px;align-items:center;
    border-top:1px solid var(--hairline);
    overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;
    -webkit-overflow-scrolling:touch;}
  .top-right::-webkit-scrollbar{display:none}
  .top-right{justify-content:space-between;gap:10px}
  .tbtn{padding-bottom:6px;flex:0 0 auto;
    display:flex;flex-direction:column;align-items:flex-start;gap:3px;
    line-height:1;text-align:left;}
  .tbtn b{color:var(--ink2);letter-spacing:.9px}
  .tbtn b::after{content:none}
  #rebuildBtn{display:none}          /* the footer already has one */

  .col-l{left:16px;top:62px;width:auto}
  .col-l .quote,.col-l .pager{display:none}
  .eyebrow{font-size:11px}
  .big-cn{font-size:42px;margin-top:9px}
  .sub-cn{font-size:11px;margin-top:7px;letter-spacing:1px}

  .col-r{left:auto;right:16px;top:58px;text-align:right}
  .glyphs{justify-content:flex-end;gap:14px}
  .title-cn{font-size:48px;line-height:47px;margin-top:13px}
  .roman{font-size:11px;padding-left:0;margin-top:4px}
  [data-style="thai"] .title-cn{font-size:36px;line-height:40px}
  [data-style="thai"] .big-cn{font-size:36px}
  .tag{display:none}

  /* the stage plaque rides up the middle of the frame with the cut plane, so
     the percentage moves to the other side of it rather than fighting it */
  .bigpct{font-size:58px;left:16px;right:auto;bottom:124px;letter-spacing:-2px}
  .bigpct i{font-size:19px;margin-left:4px}

  /* and on a phone the chrome sits over the landscape instead of over sky,
     so it gets just enough ground under it to stay readable */
  .top-right{background:linear-gradient(to bottom,rgba(0,0,0,0),var(--paper) 58%)}
  footer{background:var(--paper)}
  footer{height:52px;padding:0 16px;gap:13px}
  .replay{width:28px;height:28px}
  .replay svg{width:10px;height:10px}
  .time{font-size:11px;min-width:76px}
  .plaque{font-size:11px;padding:6px 11px 5px}
}
/* landscape phones are short rather than narrow: keep the strip, drop the
   headline type that would otherwise sit on the roof */
@media (max-height:460px){
  .col-l,.col-r{display:none}
  .bigpct{font-size:54px;bottom:112px}
}
</style>
<style data-threeui-landscape>
header,
.col-l,
.col-r,
.tag,
.plaque,
.bigpct,
footer,
.bg-grid2,
.bg-rings,
.bg-wash {
  display: none !important;
}

html,
body,
#app {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#stage {
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

#stage.dragging {
  cursor: grabbing;
}
</style></head>
<body>
<div id="app">
  <div class="bg-wash"></div>
  <canvas id="stage"></canvas>
  <div class="flash" id="flash"></div>
  <div class="bg-grid2"></div>
  <div class="bg-rings" id="rings"></div>

  <header>
    <div class="brand">TOWERS</div>
    <div class="top-mid">CONSTRUCTION STUDY / 01</div>
    <div class="top-right">
      <button class="tbtn" id="styleBtn" aria-label="STYLE: JAPAN"><b>STYLE</b><span>JAPAN</span></button>
      <button class="tbtn" id="wxBtn" aria-label="WEATHER: CLEAR"><b>WEATHER</b><span>CLEAR</span></button>
      <button class="tbtn" id="timeBtn" aria-label="TIME: MORNING"><b>TIME</b><span>MORNING</span></button>
      <button class="tbtn" id="soundBtn" aria-label="SOUND: ON"><b>SOUND</b><span>ON</span></button>
      <button class="tbtn" id="rebuildBtn">↻ REBUILD</button>
    </div>
  </header>

  <div class="col-l">
    <div class="eyebrow">FRAME / 365</div>
    <div class="big-cn">普請</div>
    <div class="sub-cn">TENSHU GROWTH STUDY</div>
    <div class="quote">
      <div><i>“The viewpoint never moves.</i></div>
      <div><i>Stone, timber and tile converge</i></div>
      <div><i>from scattered heaps into place,</i></div>
      <div><i>assembling from the ground up.”</i></div>
    </div>
    <div class="pager"><span>01</span><span class="bar"></span><span class="dim">05</span></div>
  </div>

  <div class="col-r">
    <div class="glyphs">
      <svg viewBox="0 0 16 16"><defs><clipPath id="hc"><rect x="0" y="8" width="16" height="8"/></clipPath></defs><circle cx="8" cy="8" r="7" fill="none" stroke="#968c7a" stroke-width="1.2"/><circle cx="8" cy="8" r="7" fill="#968c7a" clip-path="url(#hc)"/></svg>
      <svg viewBox="0 0 16 16"><path d="M8 1.6 L14.8 14 L1.2 14 Z" fill="none" stroke="#968c7a" stroke-width="1.2"/></svg>
      <svg viewBox="0 0 16 16"><path d="M8 1.2 L14.8 8 L8 14.8 L1.2 8 Z" fill="none" stroke="#968c7a" stroke-width="1.2"/></svg>
    </div>
    <div class="title-cn"><b>天守</b><b>生長</b></div>
    <div class="roman">(Tsuku · 築)</div>
  </div>
  <div class="tag">ORIGINAL<br>RECONSTRUCTION</div>

  <div class="plaque" id="plaque">準備 / <em>READY</em></div>
  <div class="bigpct" id="bigpct"><span id="bigpctNum">0</span><i>%</i></div>

  <footer>
    <button class="replay" id="replayBtn" aria-label="rebuild">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
        <path d="M20 11a8 8 0 1 0-2.3 5.7"/><path d="M20 4v7h-7"/>
      </svg>
    </button>
    <div class="track" id="track"><div class="fill" id="fill"></div></div>
    <div class="time" id="time">0.00 / 4.40</div>
  </footer>
</div>

<script>/**
 * @license
 * Copyright 2010-2023 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).THREE={})}(this,(function(t){"use strict";const e="149",i=100,n=300,r=301,s=302,a=303,o=304,l=306,c=1e3,h=1001,u=1002,d=1003,p=1004,m=1005,f=1006,g=1007,v=1008,x=1009,_=1012,y=1014,M=1015,b=1016,S=1020,w=1023,T=1026,A=1027,E=33776,C=33777,L=33778,R=33779,P=35840,I=35841,D=35842,N=35843,O=37492,z=37496,U=37808,B=37809,F=37810,k=37811,G=37812,V=37813,H=37814,W=37815,j=37816,q=37817,X=37818,Y=37819,Z=37820,J=37821,K=36492,$=36284,Q=36285,tt=36286,et=2300,it=2301,nt=2302,rt=2400,st=2401,at=2402,ot=2500,lt=2501,ct=3e3,ht=3001,ut="srgb",dt="srgb-linear",pt=7680,mt=35044,ft="300 es",gt=1035;class vt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t);t.target=null}}}const xt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let _t=1234567;const yt=Math.PI/180,Mt=180/Math.PI;function bt(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(xt[255&t]+xt[t>>8&255]+xt[t>>16&255]+xt[t>>24&255]+"-"+xt[255&e]+xt[e>>8&255]+"-"+xt[e>>16&15|64]+xt[e>>24&255]+"-"+xt[63&i|128]+xt[i>>8&255]+"-"+xt[i>>16&255]+xt[i>>24&255]+xt[255&n]+xt[n>>8&255]+xt[n>>16&255]+xt[n>>24&255]).toLowerCase()}function St(t,e,i){return Math.max(e,Math.min(i,t))}function wt(t,e){return(t%e+e)%e}function Tt(t,e,i){return(1-i)*t+i*e}function At(t){return 0==(t&t-1)&&0!==t}function Et(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Lt(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Rt(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}var Pt=Object.freeze({__proto__:null,DEG2RAD:yt,RAD2DEG:Mt,ceilPowerOfTwo:Et,clamp:St,damp:function(t,e,i,n){return Tt(t,e,1-Math.exp(-i*n))},degToRad:function(t){return t*yt},denormalize:Lt,euclideanModulo:wt,floorPowerOfTwo:Ct,generateUUID:bt,inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},isPowerOfTwo:At,lerp:Tt,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},normalize:Rt,pingpong:function(t,e=1){return e-Math.abs(wt(t,2*e)-e)},radToDeg:function(t){return t*Mt},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},seededRandom:function(t){void 0!==t&&(_t=t);let e=_t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),m=a((n-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*m,l*p,o*c);break;case"YXY":t.set(l*p,o*h,l*m,o*c);break;case"ZYZ":t.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}});class It{constructor(t=0,e=0){It.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Dt{constructor(){Dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,i,n,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=i,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],l=i[1],c=i[4],h=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],v=n[1],x=n[4],_=n[7],y=n[2],M=n[5],b=n[8];return r[0]=s*m+a*v+o*y,r[3]=s*f+a*x+o*M,r[6]=s*g+a*_+o*b,r[1]=l*m+c*v+h*y,r[4]=l*f+c*x+h*M,r[7]=l*g+c*_+h*b,r[2]=u*m+d*v+p*y,r[5]=u*f+d*x+p*M,r[8]=u*g+d*_+p*b,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-i*r*c+i*a*o+n*r*l-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=e*h+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=h*m,t[1]=(n*l-c*i)*m,t[2]=(a*i-n*s)*m,t[3]=u*m,t[4]=(c*e-n*o)*m,t[5]=(n*r-a*e)*m,t[6]=d*m,t[7]=(i*o-l*e)*m,t[8]=(s*e-i*r)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*s+l*a)+s+t,-n*l,n*o,-n*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Nt.makeScale(t,e)),this}rotate(t){return this.premultiply(Nt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Nt.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const Nt=new Dt;function Ot(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const zt={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Ut(t,e){return new zt[t](e)}function Bt(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ft(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function kt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const Gt={[ut]:{[dt]:Ft},[dt]:{[ut]:kt}},Vt={legacyMode:!0,get workingColorSpace(){return dt},set workingColorSpace(t){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(t,e,i){if(this.legacyMode||e===i||!e||!i)return t;if(Gt[e]&&void 0!==Gt[e][i]){const n=Gt[e][i];return t.r=n(t.r),t.g=n(t.g),t.b=n(t.b),t}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)}},Ht={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},Wt={r:0,g:0,b:0},jt={h:0,s:0,l:0},qt={h:0,s:0,l:0};function Xt(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Yt(t,e){return e.r=t.r,e.g=t.g,e.b=t.b,e}class Zt{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ut){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Vt.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=Vt.workingColorSpace){return this.r=t,this.g=e,this.b=i,Vt.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=Vt.workingColorSpace){if(t=wt(t,1),e=St(e,0,1),i=St(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Xt(r,n,t+1/3),this.g=Xt(r,n,t),this.b=Xt(r,n,t-1/3)}return Vt.toWorkingColorSpace(this,n),this}setStyle(t,e=ut){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)(([^)]*))/.exec(t)){let t;const r=n[1],s=n[2];switch(r){case"rgb":case"rgba":if(t=/^s*(d+)s*,s*(d+)s*,s*(d+)s*(?:,s*(d*.?d+)s*)?$/.exec(s))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,Vt.toWorkingColorSpace(this,e),i(t[4]),this;if(t=/^s*(d+)%s*,s*(d+)%s*,s*(d+)%s*(?:,s*(d*.?d+)s*)?$/.exec(s))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,Vt.toWorkingColorSpace(this,e),i(t[4]),this;break;case"hsl":case"hsla":if(t=/^s*(d*.?d+)s*,s*(d*.?d+)%s*,s*(d*.?d+)%s*(?:,s*(d*.?d+)s*)?$/.exec(s)){const n=parseFloat(t[1])/360,r=parseFloat(t[2])/100,s=parseFloat(t[3])/100;return i(t[4]),this.setHSL(n,r,s,e)}}}else if(n=/^#([A-Fa-fd]+)$/.exec(t)){const t=n[1],i=t.length;if(3===i)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,Vt.toWorkingColorSpace(this,e),this;if(6===i)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,Vt.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e=ut){const i=Ht[t.toLowerCase()];return void 0!==i?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ft(t.r),this.g=Ft(t.g),this.b=Ft(t.b),this}copyLinearToSRGB(t){return this.r=kt(t.r),this.g=kt(t.g),this.b=kt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ut){return Vt.fromWorkingColorSpace(Yt(this,Wt),t),St(255*Wt.r,0,255)<<16^St(255*Wt.g,0,255)<<8^St(255*Wt.b,0,255)<<0}getHexString(t=ut){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vt.workingColorSpace){Vt.fromWorkingColorSpace(Yt(this,Wt),e);const i=Wt.r,n=Wt.g,r=Wt.b,s=Math.max(i,n,r),a=Math.min(i,n,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case i:o=(n-r)/t+(n<r?6:0);break;case n:o=(r-i)/t+2;break;case r:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=c,t}getRGB(t,e=Vt.workingColorSpace){return Vt.fromWorkingColorSpace(Yt(this,Wt),e),t.r=Wt.r,t.g=Wt.g,t.b=Wt.b,t}getStyle(t=ut){return Vt.fromWorkingColorSpace(Yt(this,Wt),t),t!==ut?`color(${t} ${Wt.r} ${Wt.g} ${Wt.b})`:`rgb(${255*Wt.r|0},${255*Wt.g|0},${255*Wt.b|0})`}offsetHSL(t,e,i){return this.getHSL(jt),jt.h+=t,jt.s+=e,jt.l+=i,this.setHSL(jt.h,jt.s,jt.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(jt),t.getHSL(qt);const i=Tt(jt.h,qt.h,e),n=Tt(jt.s,qt.s,e),r=Tt(jt.l,qt.l,e);return this.setHSL(i,n,r),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let Jt;Zt.NAMES=Ht;class Kt{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Jt&&(Jt=Bt("canvas")),Jt.width=t.width,Jt.height=t.height;const i=Jt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=Jt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=Bt("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t<r.length;t++)r[t]=255*Ft(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Ft(e[t]/255)):e[t]=Ft(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}class $t{constructor(t=null){this.isSource=!0,this.uuid=bt(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(Qt(n[e].image)):t.push(Qt(n[e]))}else t=Qt(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function Qt(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Kt.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let te=0;class ee extends vt{constructor(t=ee.DEFAULT_IMAGE,e=ee.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=1009,l=ee.DEFAULT_ANISOTROPY,c=3e3){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:te++}),this.uuid=bt(),this.name="",this.source=new $t(t),this.mipmaps=[],this.mapping=e,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new It(0,0),this.repeat=new It(1,1),this.center=new It(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Dt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,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,type:this.type,encoding:this.encoding,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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==n)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case c:t.x=t.x-Math.floor(t.x);break;case h:t.x=t.x<0?0:1;break;case u:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case c:t.y=t.y-Math.floor(t.y);break;case h:t.y=t.y<0?0:1;break;case u:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}}ee.DEFAULT_IMAGE=null,ee.DEFAULT_MAPPING=n,ee.DEFAULT_ANISOTROPY=1;class ie{constructor(t=0,e=0,i=0,n=1){ie.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(h-m)<s&&Math.abs(p-f)<s){if(Math.abs(c+u)<a&&Math.abs(h+m)<a&&Math.abs(p+f)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,v=(g+1)/2,x=(c+u)/4,_=(h+m)/4,y=(p+f)/4;return t>o&&t>v?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=x/i,r=_/i):o>v?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=x/n,r=y/n):v<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(v),i=_/r,n=y/r),this.set(i,n,r,e),this}let v=Math.sqrt((f-p)*(f-p)+(h-m)*(h-m)+(u-c)*(u-c));return Math.abs(v)<.001&&(v=1),this.x=(f-p)/v,this.y=(h-m)/v,this.z=(u-c)/v,this.w=Math.acos((l+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}}class ne extends vt{constructor(t=1,e=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ie(0,0,t,e),this.scissorTest=!1,this.viewport=new ie(0,0,t,e);const n={width:t,height:e,depth:1};this.texture=new ee(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:f,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(t,e,i=1){this.width===t&&this.height===e&&this.depth===i||(this.width=t,this.height=e,this.depth=i,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new $t(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class re extends ee{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=d,this.minFilter=d,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class se extends ee{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=d,this.minFilter=d,this.wrapR=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ae{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,s,a){let o=i[n+0],l=i[n+1],c=i[n+2],h=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return t[e+0]=o,t[e+1]=l,t[e+2]=c,void(t[e+3]=h);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(h!==m||o!==u||l!==d||c!==p){let t=1-a;const e=o*u+l*d+c*p+h*m,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*t+u*r,l=l*t+d*r,c=c*t+p*r,h=h*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],l=i[n+2],c=i[n+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+c*h+o*d-l*u,t[e+1]=o*p+c*u+l*h-a*d,t[e+2]=l*p+c*d+a*u-o*h,t[e+3]=c*p-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(i/2),c=a(n/2),h=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=i+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>h){const t=2*Math.sqrt(1+i-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-i-h);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(St(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=i*c+s*a+n*l-r*o,this._y=n*c+s*o+r*a-i*l,this._z=r*c+s*l+i*o-n*a,this._w=s*c-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*t._w+i*t._x+n*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(r),i*Math.cos(r),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class oe{constructor(t=0,e=0,i=0){oe.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ce.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ce.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=o*e+s*n-a*i,c=o*i+a*e-r*n,h=o*n+r*i-s*e,u=-r*e-s*i-a*n;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return le.copy(this).projectOnVector(t),this.sub(le)}reflect(t){return this.sub(le.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(St(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const le=new oe,ce=new ae;class he{constructor(t=new oe(1/0,1/0,1/0),e=new oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,l=t.length;o<l;o+=3){const l=t[o],c=t[o+1],h=t[o+2];l<e&&(e=l),c<i&&(i=c),h<n&&(n=h),l>r&&(r=l),c>s&&(s=c),h>a&&(a=h)}return this.min.set(e,i,n),this.max.set(r,s,a),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,l=t.count;o<l;o++){const l=t.getX(o),c=t.getY(o),h=t.getZ(o);l<e&&(e=l),c<i&&(i=c),h<n&&(n=h),l>r&&(r=l),c>s&&(s=c),h>a&&(a=h)}return this.min.set(e,i,n),this.max.set(r,s,a),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=de.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(void 0!==i)if(e&&null!=i.attributes&&void 0!==i.attributes.position){const e=i.attributes.position;for(let i=0,n=e.count;i<n;i++)de.fromBufferAttribute(e,i).applyMatrix4(t.matrixWorld),this.expandByPoint(de)}else null===i.boundingBox&&i.computeBoundingBox(),pe.copy(i.boundingBox),pe.applyMatrix4(t.matrixWorld),this.union(pe);const n=t.children;for(let t=0,i=n.length;t<i;t++)this.expandByObject(n[t],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,de),de.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ye),Me.subVectors(this.max,ye),me.subVectors(t.a,ye),fe.subVectors(t.b,ye),ge.subVectors(t.c,ye),ve.subVectors(fe,me),xe.subVectors(ge,fe),_e.subVectors(me,ge);let e=[0,-ve.z,ve.y,0,-xe.z,xe.y,0,-_e.z,_e.y,ve.z,0,-ve.x,xe.z,0,-xe.x,_e.z,0,-_e.x,-ve.y,ve.x,0,-xe.y,xe.x,0,-_e.y,_e.x,0];return!!we(e,me,fe,ge,Me)&&(e=[1,0,0,0,1,0,0,0,1],!!we(e,me,fe,ge,Me)&&(be.crossVectors(ve,xe),e=[be.x,be.y,be.z],we(e,me,fe,ge,Me)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return de.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(de).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(ue[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ue[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ue[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ue[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ue[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ue[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ue[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ue[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ue)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ue=[new oe,new oe,new oe,new oe,new oe,new oe,new oe,new oe],de=new oe,pe=new he,me=new oe,fe=new oe,ge=new oe,ve=new oe,xe=new oe,_e=new oe,ye=new oe,Me=new oe,be=new oe,Se=new oe;function we(t,e,i,n,r){for(let s=0,a=t.length-3;s<=a;s+=3){Se.fromArray(t,s);const a=r.x*Math.abs(Se.x)+r.y*Math.abs(Se.y)+r.z*Math.abs(Se.z),o=e.dot(Se),l=i.dot(Se),c=n.dot(Se);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Te=new he,Ae=new oe,Ee=new oe;class Ce{constructor(t=new oe,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Te.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ae.subVectors(t,this.center);const e=Ae.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Ae,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ee.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ae.copy(t.center).add(Ee)),this.expandByPoint(Ae.copy(t.center).sub(Ee))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Le=new oe,Re=new oe,Pe=new oe,Ie=new oe,De=new oe,Ne=new oe,Oe=new oe;class ze{constructor(t=new oe,e=new oe(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Le)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Le.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Le.copy(this.direction).multiplyScalar(e).add(this.origin),Le.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Re.copy(t).add(e).multiplyScalar(.5),Pe.copy(e).sub(t).normalize(),Ie.copy(this.origin).sub(Re);const r=.5*t.distanceTo(e),s=-this.direction.dot(Pe),a=Ie.dot(this.direction),o=-Ie.dot(Pe),l=Ie.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return i&&i.copy(this.direction).multiplyScalar(h).add(this.origin),n&&n.copy(Pe).multiplyScalar(u).add(Re),d}intersectSphere(t,e){Le.subVectors(t.center,this.origin);const i=Le.dot(this.direction),n=Le.dot(Le)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return a<0&&o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),i>s||r>n?null:((r>i||isNaN(i))&&(i=r),(s<n||isNaN(n))&&(n=s),h>=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Le)}intersectTriangle(t,e,i,n,r){De.subVectors(e,t),Ne.subVectors(i,t),Oe.crossVectors(De,Ne);let s,a=this.direction.dot(Oe);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Ie.subVectors(this.origin,t);const o=s*this.direction.dot(Ne.crossVectors(Ie,Ne));if(o<0)return null;const l=s*this.direction.dot(De.cross(Ie));if(l<0)return null;if(o+l>a)return null;const c=-s*Ie.dot(Oe);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Ue{constructor(){Ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,i,n,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ue).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Be.setFromMatrixColumn(t,0).length(),r=1/Be.setFromMatrixColumn(t,1).length(),s=1/Be.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,i=s*h,n=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=n+i*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,i=o*h,n=l*c,r=l*h;e[0]=t+r*a,e[4]=n*a-i,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=i*a-n,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,i=o*h,n=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=n+i*a,e[1]=i+n*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,i=s*h,n=a*c,r=a*h;e[0]=o*c,e[4]=n*l-i,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=n*h+i,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=i*h+n,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=i*h-n,e[2]=n*h-i,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ke,t,Ge)}lookAt(t,e,i){const n=this.elements;return We.subVectors(t,e),0===We.lengthSq()&&(We.z=1),We.normalize(),Ve.crossVectors(i,We),0===Ve.lengthSq()&&(1===Math.abs(i.z)?We.x+=1e-4:We.z+=1e-4,We.normalize(),Ve.crossVectors(i,We)),Ve.normalize(),He.crossVectors(We,Ve),n[0]=Ve.x,n[4]=He.x,n[8]=We.x,n[1]=Ve.y,n[5]=He.y,n[9]=We.y,n[2]=Ve.z,n[6]=He.z,n[10]=We.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[4],o=i[8],l=i[12],c=i[1],h=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],v=i[3],x=i[7],_=i[11],y=i[15],M=n[0],b=n[4],S=n[8],w=n[12],T=n[1],A=n[5],E=n[9],C=n[13],L=n[2],R=n[6],P=n[10],I=n[14],D=n[3],N=n[7],O=n[11],z=n[15];return r[0]=s*M+a*T+o*L+l*D,r[4]=s*b+a*A+o*R+l*N,r[8]=s*S+a*E+o*P+l*O,r[12]=s*w+a*C+o*I+l*z,r[1]=c*M+h*T+u*L+d*D,r[5]=c*b+h*A+u*R+d*N,r[9]=c*S+h*E+u*P+d*O,r[13]=c*w+h*C+u*I+d*z,r[2]=p*M+m*T+f*L+g*D,r[6]=p*b+m*A+f*R+g*N,r[10]=p*S+m*E+f*P+g*O,r[14]=p*w+m*C+f*I+g*z,r[3]=v*M+x*T+_*L+y*D,r[7]=v*b+x*A+_*R+y*N,r[11]=v*S+x*E+_*P+y*O,r[15]=v*w+x*C+_*I+y*z,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-n*l*h-r*a*u+i*l*u+n*a*d-i*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-n*s*d+n*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+i*s*d+r*a*c-i*l*c)+t[15]*(-n*a*c-e*o*h+e*a*u+n*s*h-i*s*u+i*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],p=t[12],m=t[13],f=t[14],g=t[15],v=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,x=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,_=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,y=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,M=e*v+i*x+n*_+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/M;return t[0]=v*b,t[1]=(m*u*r-h*f*r-m*n*d+i*f*d+h*n*g-i*u*g)*b,t[2]=(a*f*r-m*o*r+m*n*l-i*f*l-a*n*g+i*o*g)*b,t[3]=(h*o*r-a*u*r-h*n*l+i*u*l+a*n*d-i*o*d)*b,t[4]=x*b,t[5]=(c*f*r-p*u*r+p*n*d-e*f*d-c*n*g+e*u*g)*b,t[6]=(p*o*r-s*f*r-p*n*l+e*f*l+s*n*g-e*o*g)*b,t[7]=(s*u*r-c*o*r+c*n*l-e*u*l-s*n*d+e*o*d)*b,t[8]=_*b,t[9]=(p*h*r-c*m*r-p*i*d+e*m*d+c*i*g-e*h*g)*b,t[10]=(s*m*r-p*a*r+p*i*l-e*m*l-s*i*g+e*a*g)*b,t[11]=(c*a*r-s*h*r-c*i*l+e*h*l+s*i*d-e*a*d)*b,t[12]=y*b,t[13]=(c*m*n-p*h*n+p*i*u-e*m*u-c*i*f+e*h*f)*b,t[14]=(p*a*n-s*m*n-p*i*o+e*m*o+s*i*f-e*a*f)*b,t[15]=(s*h*n-c*a*n+c*i*o-e*h*o-s*i*u+e*a*u)*b,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+i,l*a-n*o,l*o+n*a,0,l*a+n*o,c*a+i,c*o-n*s,0,l*o-n*a,c*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,s){return this.set(1,i,r,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,v=o*l,x=o*c,_=o*h,y=i.x,M=i.y,b=i.z;return n[0]=(1-(m+g))*y,n[1]=(d+_)*y,n[2]=(p-x)*y,n[3]=0,n[4]=(d-_)*M,n[5]=(1-(u+g))*M,n[6]=(f+v)*M,n[7]=0,n[8]=(p+x)*b,n[9]=(f-v)*b,n[10]=(1-(u+m))*b,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=Be.set(n[0],n[1],n[2]).length();const s=Be.set(n[4],n[5],n[6]).length(),a=Be.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],Fe.copy(this);const o=1/r,l=1/s,c=1/a;return Fe.elements[0]*=o,Fe.elements[1]*=o,Fe.elements[2]*=o,Fe.elements[4]*=l,Fe.elements[5]*=l,Fe.elements[6]*=l,Fe.elements[8]*=c,Fe.elements[9]*=c,Fe.elements[10]*=c,e.setFromRotationMatrix(Fe),i.x=r,i.y=s,i.z=a,this}makePerspective(t,e,i,n,r,s){const a=this.elements,o=2*r/(e-t),l=2*r/(i-n),c=(e+t)/(e-t),h=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return a[0]=o,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,n,r,s){const a=this.elements,o=1/(e-t),l=1/(i-n),c=1/(s-r),h=(e+t)*o,u=(i+n)*l,d=(s+r)*c;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Be=new oe,Fe=new Ue,ke=new oe(0,0,0),Ge=new oe(1,1,1),Ve=new oe,He=new oe,We=new oe,je=new Ue,qe=new ae;class Xe{constructor(t=0,e=0,i=0,n=Xe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],s=n[4],a=n[8],o=n[1],l=n[5],c=n[9],h=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(St(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-St(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(St(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-St(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(St(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-St(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return je.makeRotationFromQuaternion(t),this.setFromRotationMatrix(je,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return qe.setFromEuler(this),this.setFromQuaternion(qe,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Xe.DEFAULT_ORDER="XYZ";class Ye{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}isEnabled(t){return 0!=(this.mask&(1<<t|0))}}let Ze=0;const Je=new oe,Ke=new ae,$e=new Ue,Qe=new oe,ti=new oe,ei=new oe,ii=new ae,ni=new oe(1,0,0),ri=new oe(0,1,0),si=new oe(0,0,1),ai={type:"added"},oi={type:"removed"};class li extends vt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ze++}),this.uuid=bt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=li.DEFAULT_UP.clone();const t=new oe,e=new Xe,i=new ae,n=new oe(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Ue},normalMatrix:{value:new Dt}}),this.matrix=new Ue,this.matrixWorld=new Ue,this.matrixAutoUpdate=li.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=li.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ye,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ke.setFromAxisAngle(t,e),this.quaternion.multiply(Ke),this}rotateOnWorldAxis(t,e){return Ke.setFromAxisAngle(t,e),this.quaternion.premultiply(Ke),this}rotateX(t){return this.rotateOnAxis(ni,t)}rotateY(t){return this.rotateOnAxis(ri,t)}rotateZ(t){return this.rotateOnAxis(si,t)}translateOnAxis(t,e){return Je.copy(t).applyQuaternion(this.quaternion),this.position.add(Je.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ni,t)}translateY(t){return this.translateOnAxis(ri,t)}translateZ(t){return this.translateOnAxis(si,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4($e.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Qe.copy(t):Qe.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),ti.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$e.lookAt(ti,Qe,this.up):$e.lookAt(Qe,ti,this.up),this.quaternion.setFromRotationMatrix($e),n&&($e.extractRotation(n.matrixWorld),Ke.setFromRotationMatrix($e),this.quaternion.premultiply(Ke.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(ai)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(oi)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(oi)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),$e.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),$e.multiply(t.parent.matrixWorld)),t.applyMatrix4($e),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e){let i=[];this[t]===e&&i.push(this);for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectsByProperty(t,e);r.length>0&&(i=i.concat(r))}return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ti,t,ei),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ti,ii,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){const n=e[i];!0!==n.matrixWorldAutoUpdate&&!0!==t||n.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(!0===t&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++){const i=t[e];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=s(t.geometries),n=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),c=s(t.animations),h=s(t.nodes);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c),h.length>0&&(i.nodes=h)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}}li.DEFAULT_UP=new oe(0,1,0),li.DEFAULT_MATRIX_AUTO_UPDATE=!0,li.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ci=new oe,hi=new oe,ui=new oe,di=new oe,pi=new oe,mi=new oe,fi=new oe,gi=new oe,vi=new oe,xi=new oe;class _i{constructor(t=new oe,e=new oe,i=new oe){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),ci.subVectors(t,e),n.cross(ci);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){ci.subVectors(n,e),hi.subVectors(i,e),ui.subVectors(t,e);const s=ci.dot(ci),a=ci.dot(hi),o=ci.dot(ui),l=hi.dot(hi),c=hi.dot(ui),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,di),di.x>=0&&di.y>=0&&di.x+di.y<=1}static getUV(t,e,i,n,r,s,a,o){return this.getBarycoord(t,e,i,n,di),o.set(0,0),o.addScaledVector(r,di.x),o.addScaledVector(s,di.y),o.addScaledVector(a,di.z),o}static isFrontFacing(t,e,i,n){return ci.subVectors(i,e),hi.subVectors(t,e),ci.cross(hi).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ci.subVectors(this.c,this.b),hi.subVectors(this.a,this.b),.5*ci.cross(hi).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return _i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return _i.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return _i.getUV(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return _i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return _i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let s,a;pi.subVectors(n,i),mi.subVectors(r,i),gi.subVectors(t,i);const o=pi.dot(gi),l=mi.dot(gi);if(o<=0&&l<=0)return e.copy(i);vi.subVectors(t,n);const c=pi.dot(vi),h=mi.dot(vi);if(c>=0&&h<=c)return e.copy(n);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(i).addScaledVector(pi,s);xi.subVectors(t,r);const d=pi.dot(xi),p=mi.dot(xi);if(p>=0&&d<=p)return e.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector(mi,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return fi.subVectors(r,n),a=(h-c)/(h-c+(d-p)),e.copy(n).addScaledVector(fi,a);const g=1/(f+m+u);return s=m*g,a=u*g,e.copy(i).addScaledVector(pi,s).addScaledVector(mi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let yi=0;class Mi extends vt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:yi++}),this.uuid=bt(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pt,this.stencilZFail=pt,this.stencilZPass=pt,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class bi extends Mi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(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.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Si=new oe,wi=new It;class Ti{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=mt,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)wi.fromBufferAttribute(this,e),wi.applyMatrix3(t),this.setXY(e,wi.x,wi.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)Si.fromBufferAttribute(this,e),Si.applyMatrix3(t),this.setXYZ(e,Si.x,Si.y,Si.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)Si.fromBufferAttribute(this,e),Si.applyMatrix4(t),this.setXYZ(e,Si.x,Si.y,Si.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Si.fromBufferAttribute(this,e),Si.applyNormalMatrix(t),this.setXYZ(e,Si.x,Si.y,Si.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Si.fromBufferAttribute(this,e),Si.transformDirection(t),this.setXYZ(e,Si.x,Si.y,Si.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Lt(e,this.array)),e}setX(t,e){return this.normalized&&(e=Rt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Lt(e,this.array)),e}setY(t,e){return this.normalized&&(e=Rt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Lt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Rt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Lt(e,this.array)),e}setW(t,e){return this.normalized&&(e=Rt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Rt(e,this.array),i=Rt(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Rt(e,this.array),i=Rt(i,this.array),n=Rt(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Rt(e,this.array),i=Rt(i,this.array),n=Rt(n,this.array),r=Rt(r,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==mt&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class Ai extends Ti{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class Ei extends Ti{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class Ci extends Ti{constructor(t,e,i){super(new Float32Array(t),e,i)}}let Li=0;const Ri=new Ue,Pi=new li,Ii=new oe,Di=new he,Ni=new he,Oi=new oe;class zi extends vt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Li++}),this.uuid=bt(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Ot(t)?Ei:Ai)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new Dt).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ri.makeRotationFromQuaternion(t),this.applyMatrix4(Ri),this}rotateX(t){return Ri.makeRotationX(t),this.applyMatrix4(Ri),this}rotateY(t){return Ri.makeRotationY(t),this.applyMatrix4(Ri),this}rotateZ(t){return Ri.makeRotationZ(t),this.applyMatrix4(Ri),this}translate(t,e,i){return Ri.makeTranslation(t,e,i),this.applyMatrix4(Ri),this}scale(t,e,i){return Ri.makeScale(t,e,i),this.applyMatrix4(Ri),this}lookAt(t){return Pi.lookAt(t),Pi.updateMatrix(),this.applyMatrix4(Pi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ii).negate(),this.translate(Ii.x,Ii.y,Ii.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Ci(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new he);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new oe(-1/0,-1/0,-1/0),new oe(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];Di.setFromBufferAttribute(i),this.morphTargetsRelative?(Oi.addVectors(this.boundingBox.min,Di.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,Di.max),this.boundingBox.expandByPoint(Oi)):(this.boundingBox.expandByPoint(Di.min),this.boundingBox.expandByPoint(Di.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ce);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new oe,1/0);if(t){const i=this.boundingSphere.center;if(Di.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];Ni.setFromBufferAttribute(i),this.morphTargetsRelative?(Oi.addVectors(Di.min,Ni.min),Di.expandByPoint(Oi),Oi.addVectors(Di.max,Ni.max),Di.expandByPoint(Oi)):(Di.expandByPoint(Ni.min),Di.expandByPoint(Ni.max))}Di.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)Oi.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(Oi));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)Oi.fromBufferAttribute(s,e),a&&(Ii.fromBufferAttribute(t,e),Oi.add(Ii)),n=Math.max(n,i.distanceToSquared(Oi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.array,n=e.position.array,r=e.normal.array,s=e.uv.array,a=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Ti(new Float32Array(4*a),4));const o=this.getAttribute("tangent").array,l=[],c=[];for(let t=0;t<a;t++)l[t]=new oe,c[t]=new oe;const h=new oe,u=new oe,d=new oe,p=new It,m=new It,f=new It,g=new oe,v=new oe;function x(t,e,i){h.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(s,2*t),m.fromArray(s,2*e),f.fromArray(s,2*i),u.sub(h),d.sub(h),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),v.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),l[t].add(g),l[e].add(g),l[i].add(g),c[t].add(v),c[e].add(v),c[i].add(v))}let _=this.groups;0===_.length&&(_=[{start:0,count:i.length}]);for(let t=0,e=_.length;t<e;++t){const e=_[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)x(i[t+0],i[t+1],i[t+2])}const y=new oe,M=new oe,b=new oe,S=new oe;function w(t){b.fromArray(r,3*t),S.copy(b);const e=l[t];y.copy(e),y.sub(b.multiplyScalar(b.dot(e))).normalize(),M.crossVectors(S,e);const i=M.dot(c[t])<0?-1:1;o[4*t]=y.x,o[4*t+1]=y.y,o[4*t+2]=y.z,o[4*t+3]=i}for(let t=0,e=_.length;t<e;++t){const e=_[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)w(i[t+0]),w(i[t+1]),w(i[t+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new Ti(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new oe,r=new oe,s=new oe,a=new oe,o=new oe,l=new oe,c=new oe,h=new oe;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),m=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),c.subVectors(s,r),h.subVectors(n,r),c.cross(h),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),a.add(c),o.add(c),l.add(c),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),c.subVectors(s,r),h.subVectors(n,r),c.cross(h),i.setXYZ(t+0,c.x,c.y,c.z),i.setXYZ(t+1,c.x,c.y,c.z),i.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Oi.fromBufferAttribute(t,e),Oi.normalize(),t.setXYZ(e,Oi.x,Oi.y,Oi.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,s=new i.constructor(e.length*n);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*n;for(let t=0;t<n;t++)s[o++]=i[a++]}return new Ti(s,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new zi,i=this.index.array,n=this.attributes;for(const r in n){const s=t(n[r],i);e.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],a=r[n];for(let e=0,n=a.length;e<n;e++){const n=t(a[e],i);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.addGroup(i.start,i.count,i.materialIndex)}return e}toJSON(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];s.push(n.toJSON(t.data))}s.length>0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,void 0!==t.parameters&&(this.parameters=Object.assign({},t.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const Ui=new Ue,Bi=new ze,Fi=new Ce,ki=new oe,Gi=new oe,Vi=new oe,Hi=new oe,Wi=new oe,ji=new It,qi=new It,Xi=new It,Yi=new oe,Zi=new oe;class Ji extends li{constructor(t=new zi,e=new bi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,s=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(r&&a){Wi.set(0,0,0);for(let i=0,n=r.length;i<n;i++){const n=a[i],o=r[i];0!==n&&(Hi.fromBufferAttribute(o,t),s?Wi.addScaledVector(Hi,n):Wi.addScaledVector(Hi.sub(e),n))}e.add(Wi)}return this.isSkinnedMesh&&this.boneTransform(t,e),e}raycast(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Fi.copy(i.boundingSphere),Fi.applyMatrix4(r),!1===t.ray.intersectsSphere(Fi))return;if(Ui.copy(r).invert(),Bi.copy(t.ray).applyMatrix4(Ui),null!==i.boundingBox&&!1===Bi.intersectsBox(i.boundingBox))return;let s;const a=i.index,o=i.attributes.position,l=i.attributes.uv,c=i.attributes.uv2,h=i.groups,u=i.drawRange;if(null!==a)if(Array.isArray(n))for(let i=0,r=h.length;i<r;i++){const r=h[i],o=n[r.materialIndex];for(let i=Math.max(r.start,u.start),n=Math.min(a.count,Math.min(r.start+r.count,u.start+u.count));i<n;i+=3){const n=a.getX(i),h=a.getX(i+1),u=a.getX(i+2);s=Ki(this,o,t,Bi,l,c,n,h,u),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,e.push(s))}}else{for(let i=Math.max(0,u.start),r=Math.min(a.count,u.start+u.count);i<r;i+=3){const r=a.getX(i),o=a.getX(i+1),h=a.getX(i+2);s=Ki(this,n,t,Bi,l,c,r,o,h),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}else if(void 0!==o)if(Array.isArray(n))for(let i=0,r=h.length;i<r;i++){const r=h[i],a=n[r.materialIndex];for(let i=Math.max(r.start,u.start),n=Math.min(o.count,Math.min(r.start+r.count,u.start+u.count));i<n;i+=3){s=Ki(this,a,t,Bi,l,c,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,e.push(s))}}else{for(let i=Math.max(0,u.start),r=Math.min(o.count,u.start+u.count);i<r;i+=3){s=Ki(this,n,t,Bi,l,c,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}}}function Ki(t,e,i,n,r,s,a,o,l){t.getVertexPosition(a,ki),t.getVertexPosition(o,Gi),t.getVertexPosition(l,Vi);const c=function(t,e,i,n,r,s,a,o){let l;if(l=1===e.side?n.intersectTriangle(a,s,r,!0,o):n.intersectTriangle(r,s,a,0===e.side,o),null===l)return null;Zi.copy(o),Zi.applyMatrix4(t.matrixWorld);const c=i.ray.origin.distanceTo(Zi);return c<i.near||c>i.far?null:{distance:c,point:Zi.clone(),object:t}}(t,e,i,n,ki,Gi,Vi,Yi);if(c){r&&(ji.fromBufferAttribute(r,a),qi.fromBufferAttribute(r,o),Xi.fromBufferAttribute(r,l),c.uv=_i.getUV(Yi,ki,Gi,Vi,ji,qi,Xi,new It)),s&&(ji.fromBufferAttribute(s,a),qi.fromBufferAttribute(s,o),Xi.fromBufferAttribute(s,l),c.uv2=_i.getUV(Yi,ki,Gi,Vi,ji,qi,Xi,new It));const t={a:a,b:o,c:l,normal:new oe,materialIndex:0};_i.getNormal(ki,Gi,Vi,t.normal),c.face=t}return c}class $i extends zi{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(t,e,i,n,r,s,p,m,f,g,v){const x=s/f,_=p/g,y=s/2,M=p/2,b=m/2,S=f+1,w=g+1;let T=0,A=0;const E=new oe;for(let s=0;s<w;s++){const a=s*_-M;for(let o=0;o<S;o++){const u=o*x-y;E[t]=u*n,E[e]=a*r,E[i]=b,l.push(E.x,E.y,E.z),E[t]=0,E[e]=0,E[i]=m>0?1:-1,c.push(E.x,E.y,E.z),h.push(o/f),h.push(1-s/g),T+=1}}for(let t=0;t<g;t++)for(let e=0;e<f;e++){const i=u+e+S*t,n=u+e+S*(t+1),r=u+(e+1)+S*(t+1),s=u+(e+1)+S*t;o.push(i,n,s),o.push(n,r,s),A+=6}a.addGroup(d,A,v),d+=A,u+=T}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new Ci(l,3)),this.setAttribute("normal",new Ci(c,3)),this.setAttribute("uv",new Ci(h,2))}static fromJSON(t){return new $i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Qi(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}}return e}function tn(t){const e={};for(let i=0;i<t.length;i++){const n=Qi(t[i]);for(const t in n)e[t]=n[t]}return e}function en(t){return null===t.getRenderTarget()&&t.outputEncoding===ht?ut:dt}const nn={clone:Qi,merge:tn};class rn extends Mi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {ntgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );n}",this.fragmentShader="void main() {ntgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Qi(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class sn extends li{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ue,this.projectionMatrix=new Ue,this.projectionMatrixInverse=new Ue}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class an extends sn{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Mt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*yt*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Mt*Math.atan(Math.tan(.5*yt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*yt*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/a,n*=s.width/t,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const on=-90;class ln extends li{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i;const n=new an(on,1,t,e);n.layers=this.layers,n.up.set(0,1,0),n.lookAt(1,0,0),this.add(n);const r=new an(on,1,t,e);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(-1,0,0),this.add(r);const s=new an(on,1,t,e);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(0,1,0),this.add(s);const a=new an(on,1,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);const o=new an(on,1,t,e);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(0,0,1),this.add(o);const l=new an(on,1,t,e);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(0,0,-1),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,s,a,o,l]=this.children,c=t.getRenderTarget(),h=t.toneMapping,u=t.xr.enabled;t.toneMapping=0,t.xr.enabled=!1;const d=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,s),t.setRenderTarget(i,3),t.render(e,a),t.setRenderTarget(i,4),t.render(e,o),i.texture.generateMipmaps=d,t.setRenderTarget(i,5),t.render(e,l),t.setRenderTarget(c),t.toneMapping=h,t.xr.enabled=u,i.texture.needsPMREMUpdate=!0}}class cn extends ee{constructor(t,e,i,n,s,a,o,l,c,h){super(t=void 0!==t?t:[],e=void 0!==e?e:r,i,n,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class hn extends ne{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];this.texture=new cn(n,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:f}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"nnttttvarying vec3 vWorldDirection;nnttttvec3 transformDirection( in vec3 dir, in mat4 matrix ) {nntttttreturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );nntttt}nnttttvoid main() {nntttttvWorldDirection = transformDirection( position, modelMatrix );nnttttt#include <begin_vertex>nttttt#include <project_vertex>nntttt}nttt",fragmentShader:"nnttttuniform sampler2D tEquirect;nnttttvarying vec3 vWorldDirection;nntttt#include <common>nnttttvoid main() {nntttttvec3 direction = normalize( vWorldDirection );nntttttvec2 sampleUV = equirectUv( direction );nntttttgl_FragColor = texture2D( tEquirect, sampleUV );nntttt}nttt"},n=new $i(5,5,5),r=new rn({name:"CubemapFromEquirect",uniforms:Qi(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Ji(n,r),a=e.minFilter;e.minFilter===v&&(e.minFilter=f);return new ln(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}const un=new oe,dn=new oe,pn=new Dt;class mn{constructor(t=new oe(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=un.subVectors(i,e).cross(dn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const i=t.delta(un),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:e.copy(i).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||pn.getNormalMatrix(t),n=this.coplanarPoint(un).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const fn=new Ce,gn=new oe;class vn{constructor(t=new mn,e=new mn,i=new mn,n=new mn,r=new mn,s=new mn){this.planes=[t,e,i,n,r,s]}set(t,e,i,n,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],r=i[1],s=i[2],a=i[3],o=i[4],l=i[5],c=i[6],h=i[7],u=i[8],d=i[9],p=i[10],m=i[11],f=i[12],g=i[13],v=i[14],x=i[15];return e[0].setComponents(a-n,h-o,m-u,x-f).normalize(),e[1].setComponents(a+n,h+o,m+u,x+f).normalize(),e[2].setComponents(a+r,h+l,m+d,x+g).normalize(),e[3].setComponents(a-r,h-l,m-d,x-g).normalize(),e[4].setComponents(a-s,h-c,m-p,x-v).normalize(),e[5].setComponents(a+s,h+c,m+p,x+v).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),fn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(fn)}intersectsSprite(t){return fn.center.set(0,0,0),fn.radius=.7071067811865476,fn.applyMatrix4(t.matrixWorld),this.intersectsSphere(fn)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(gn.x=n.normal.x>0?t.max.x:t.min.x,gn.y=n.normal.y>0?t.max.y:t.min.y,gn.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(gn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function xn(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function _n(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const s=n.get(e);void 0===s?n.set(e,function(e,n){const r=e.array,s=e.usage,a=t.createBuffer();let o;if(t.bindBuffer(n,a),t.bufferData(n,r,s),e.onUploadCallback(),r instanceof Float32Array)o=5126;else if(r instanceof Uint16Array)if(e.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");o=5131}else o=5123;else if(r instanceof Int16Array)o=5122;else if(r instanceof Uint32Array)o=5125;else if(r instanceof Int32Array)o=5124;else if(r instanceof Int8Array)o=5120;else if(r instanceof Uint8Array)o=5121;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);o=5121}return{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):s.version<e.version&&(!function(e,n,r){const s=n.array,a=n.updateRange;t.bindBuffer(r,e),-1===a.count?t.bufferSubData(r,0,s):(i?t.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s,a.offset,a.count):t.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1),n.onUploadCallback()}(s.buffer,e,r),s.version=e.version)}}}class yn extends zi{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,s=e/2,a=Math.floor(i),o=Math.floor(n),l=a+1,c=o+1,h=t/a,u=e/o,d=[],p=[],m=[],f=[];for(let t=0;t<c;t++){const e=t*u-s;for(let i=0;i<l;i++){const n=i*h-r;p.push(n,-e,0),m.push(0,0,1),f.push(i/a),f.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=e+l*t,n=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Ci(p,3)),this.setAttribute("normal",new Ci(m,3)),this.setAttribute("uv",new Ci(f,2))}static fromJSON(t){return new yn(t.width,t.height,t.widthSegments,t.heightSegments)}}const Mn={alphamap_fragment:"#ifdef USE_ALPHAMAPntdiffuseColor.a *= texture2D( alphaMap, vUv ).g;n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAPntuniform sampler2D alphaMap;n#endif",alphatest_fragment:"#ifdef USE_ALPHATESTntif ( diffuseColor.a < alphaTest ) discard;n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATESTntuniform float alphaTest;n#endif",aomap_fragment:"#ifdef USE_AOMAPntfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;ntreflectedLight.indirectDiffuse *= ambientOcclusion;nt#if defined( USE_ENVMAP ) && defined( STANDARD )nttfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );nttreflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );nt#endifn#endif",aomap_pars_fragment:"#ifdef USE_AOMAPntuniform sampler2D aoMap;ntuniform float aoMapIntensity;n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );n#ifdef USE_TANGENTntvec3 objectTangent = vec3( tangent.xyz );n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {ntreturn RECIPROCAL_PI * diffuseColor;n}nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {ntfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );ntreturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );n}nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {ntfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );ntreturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );n}nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {n    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );n    float x2 = x * x;n    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );n    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );n}nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {ntfloat a2 = pow2( alpha );ntfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );ntfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );ntreturn 0.5 / max( gv + gl, EPSILON );n}nfloat D_GGX( const in float alpha, const in float dotNH ) {ntfloat a2 = pow2( alpha );ntfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;ntreturn RECIPROCAL_PI * a2 / pow2( denom );n}nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {ntfloat alpha = pow2( roughness );ntvec3 halfDir = normalize( lightDir + viewDir );ntfloat dotNL = saturate( dot( normal, lightDir ) );ntfloat dotNV = saturate( dot( normal, viewDir ) );ntfloat dotNH = saturate( dot( normal, halfDir ) );ntfloat dotVH = saturate( dot( viewDir, halfDir ) );ntvec3 F = F_Schlick( f0, f90, dotVH );ntfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );ntfloat D = D_GGX( alpha, dotNH );ntreturn F * ( V * D );n}n#ifdef USE_IRIDESCENCEntvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {nttfloat alpha = pow2( roughness );nttvec3 halfDir = normalize( lightDir + viewDir );nttfloat dotNL = saturate( dot( normal, lightDir ) );nttfloat dotNV = saturate( dot( normal, viewDir ) );nttfloat dotNH = saturate( dot( normal, halfDir ) );nttfloat dotVH = saturate( dot( viewDir, halfDir ) );nttvec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );nttfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );nttfloat D = D_GGX( alpha, dotNH );nttreturn F * ( V * D );nt}n#endifnvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {ntconst float LUT_SIZE = 64.0;ntconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;ntconst float LUT_BIAS = 0.5 / LUT_SIZE;ntfloat dotNV = saturate( dot( N, V ) );ntvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );ntuv = uv * LUT_SCALE + LUT_BIAS;ntreturn uv;n}nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {ntfloat l = length( f );ntreturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );n}nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {ntfloat x = dot( v1, v2 );ntfloat y = abs( x );ntfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;ntfloat b = 3.4175940 + ( 4.1616724 + y ) * y;ntfloat v = a / b;ntfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;ntreturn cross( v1, v2 ) * theta_sintheta;n}nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {ntvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];ntvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];ntvec3 lightNormal = cross( v1, v2 );ntif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );ntvec3 T1, T2;ntT1 = normalize( V - N * dot( V, N ) );ntT2 = - cross( N, T1 );ntmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );ntvec3 coords[ 4 ];ntcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );ntcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );ntcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );ntcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );ntcoords[ 0 ] = normalize( coords[ 0 ] );ntcoords[ 1 ] = normalize( coords[ 1 ] );ntcoords[ 2 ] = normalize( coords[ 2 ] );ntcoords[ 3 ] = normalize( coords[ 3 ] );ntvec3 vectorFormFactor = vec3( 0.0 );ntvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );ntvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );ntvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );ntvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );ntfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );ntreturn vec3( result );n}nfloat G_BlinnPhong_Implicit( ) {ntreturn 0.25;n}nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {ntreturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );n}nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {ntvec3 halfDir = normalize( lightDir + viewDir );ntfloat dotNH = saturate( dot( normal, halfDir ) );ntfloat dotVH = saturate( dot( viewDir, halfDir ) );ntvec3 F = F_Schlick( specularColor, 1.0, dotVH );ntfloat G = G_BlinnPhong_Implicit( );ntfloat D = D_BlinnPhong( shininess, dotNH );ntreturn F * ( G * D );n}n#if defined( USE_SHEEN )nfloat D_Charlie( float roughness, float dotNH ) {ntfloat alpha = pow2( roughness );ntfloat invAlpha = 1.0 / alpha;ntfloat cos2h = dotNH * dotNH;ntfloat sin2h = max( 1.0 - cos2h, 0.0078125 );ntreturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );n}nfloat V_Neubelt( float dotNV, float dotNL ) {ntreturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );n}nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {ntvec3 halfDir = normalize( lightDir + viewDir );ntfloat dotNL = saturate( dot( normal, lightDir ) );ntfloat dotNV = saturate( dot( normal, viewDir ) );ntfloat dotNH = saturate( dot( normal, halfDir ) );ntfloat D = D_Charlie( sheenRoughness, dotNH );ntfloat V = V_Neubelt( dotNV, dotNL );ntreturn sheenColor * ( D * V );n}n#endif",iridescence_fragment:"#ifdef USE_IRIDESCENCEntconst mat3 XYZ_TO_REC709 = mat3(ntt 3.2404542, -0.9692660,  0.0556434,ntt-1.5371385,  1.8760108, -0.2040259,ntt-0.4985314,  0.0415560,  1.0572252nt);ntvec3 Fresnel0ToIor( vec3 fresnel0 ) {nttvec3 sqrtF0 = sqrt( fresnel0 );nttreturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );nt}ntvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {nttreturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );nt}ntfloat IorToFresnel0( float transmittedIor, float incidentIor ) {nttreturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));nt}ntvec3 evalSensitivity( float OPD, vec3 shift ) {nttfloat phase = 2.0 * PI * OPD * 1.0e-9;nttvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );nttvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );nttvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );nttvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );nttxyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );nttxyz /= 1.0685e-7;nttvec3 rgb = XYZ_TO_REC709 * xyz;nttreturn rgb;nt}ntvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {nttvec3 I;nttfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );nttfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );nttfloat cosTheta2Sq = 1.0 - sinTheta2Sq;nttif ( cosTheta2Sq < 0.0 ) {nttt return vec3( 1.0 );ntt}nttfloat cosTheta2 = sqrt( cosTheta2Sq );nttfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );nttfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );nttfloat R21 = R12;nttfloat T121 = 1.0 - R12;nttfloat phi12 = 0.0;nttif ( iridescenceIOR < outsideIOR ) phi12 = PI;nttfloat phi21 = PI - phi12;nttvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );ttvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );nttvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );nttvec3 phi23 = vec3( 0.0 );nttif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;nttif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;nttif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;nttfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;nttvec3 phi = vec3( phi21 ) + phi23;nttvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );nttvec3 r123 = sqrt( R123 );nttvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );nttvec3 C0 = R12 + Rs;nttI = C0;nttvec3 Cm = Rs - T121;nttfor ( int m = 1; m <= 2; ++ m ) {ntttCm *= r123;ntttvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );ntttI += Cm * Sm;ntt}nttreturn max( I, vec3( 0.0 ) );nt}n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAPntuniform sampler2D bumpMap;ntuniform float bumpScale;ntvec2 dHdxy_fwd() {nttvec2 dSTdx = dFdx( vUv );nttvec2 dSTdy = dFdy( vUv );nttfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;nttfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;nttfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;nttreturn vec2( dBx, dBy );nt}ntvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {nttvec3 vSigmaX = dFdx( surf_pos.xyz );nttvec3 vSigmaY = dFdy( surf_pos.xyz );nttvec3 vN = surf_norm;nttvec3 R1 = cross( vSigmaY, vN );nttvec3 R2 = cross( vN, vSigmaX );nttfloat fDet = dot( vSigmaX, R1 ) * faceDirection;nttvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );nttreturn normalize( abs( fDet ) * surf_norm - vGrad );nt}n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0ntvec4 plane;nt#pragma unroll_loop_startntfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {nttplane = clippingPlanes[ i ];nttif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;nt}nt#pragma unroll_loop_endnt#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANESnttbool clipped = true;ntt#pragma unroll_loop_startnttfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {ntttplane = clippingPlanes[ i ];ntttclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;ntt}ntt#pragma unroll_loop_endnttif ( clipped ) discard;nt#endifn#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0ntvarying vec3 vClipPosition;ntuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0ntvarying vec3 vClipPosition;n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0ntvClipPosition = - mvPosition.xyz;n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )ntdiffuseColor *= vColor;n#elif defined( USE_COLOR )ntdiffuseColor.rgb *= vColor;n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )ntvarying vec4 vColor;n#elif defined( USE_COLOR )ntvarying vec3 vColor;n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )ntvarying vec4 vColor;n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )ntvarying vec3 vColor;n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )ntvColor = vec4( 1.0 );n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )ntvColor = vec3( 1.0 );n#endifn#ifdef USE_COLORntvColor *= color;n#endifn#ifdef USE_INSTANCING_COLORntvColor.xyz *= instanceColor.xyz;n#endif",common:"#define PI 3.141592653589793n#define PI2 6.283185307179586n#define PI_HALF 1.5707963267948966n#define RECIPROCAL_PI 0.3183098861837907n#define RECIPROCAL_PI2 0.15915494309189535n#define EPSILON 1e-6n#ifndef saturaten#define saturate( a ) clamp( a, 0.0, 1.0 )n#endifn#define whiteComplement( a ) ( 1.0 - saturate( a ) )nfloat pow2( const in float x ) { return x*x; }nvec3 pow2( const in vec3 x ) { return x*x; }nfloat pow3( const in float x ) { return x*x*x; }nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }nhighp float rand( const in vec2 uv ) {ntconst highp float a = 12.9898, b = 78.233, c = 43758.5453;nthighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );ntreturn fract( sin( sn ) * c );n}n#ifdef HIGH_PRECISIONntfloat precisionSafeLength( vec3 v ) { return length( v ); }n#elsentfloat precisionSafeLength( vec3 v ) {nttfloat maxComponent = max3( abs( v ) );nttreturn length( v / maxComponent ) * maxComponent;nt}n#endifnstruct IncidentLight {ntvec3 color;ntvec3 direction;ntbool visible;n};nstruct ReflectedLight {ntvec3 directDiffuse;ntvec3 directSpecular;ntvec3 indirectDiffuse;ntvec3 indirectSpecular;n};nstruct GeometricContext {ntvec3 position;ntvec3 normal;ntvec3 viewDir;n#ifdef USE_CLEARCOATntvec3 clearcoatNormal;n#endifn};nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {ntreturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );n}nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {ntreturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );n}nmat3 transposeMat3( const in mat3 m ) {ntmat3 tmp;nttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );nttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );nttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );ntreturn tmp;n}nfloat luminance( const in vec3 rgb ) {ntconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );ntreturn dot( weights, rgb );n}nbool isPerspectiveMatrix( mat4 m ) {ntreturn m[ 2 ][ 3 ] == - 1.0;n}nvec2 equirectUv( in vec3 dir ) {ntfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;ntfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;ntreturn vec2( u, v );n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UVnt#define cubeUV_minMipLevel 4.0nt#define cubeUV_minTileSize 16.0ntfloat getFace( vec3 direction ) {nttvec3 absDirection = abs( direction );nttfloat face = - 1.0;nttif ( absDirection.x > absDirection.z ) {ntttif ( absDirection.x > absDirection.y )nttttface = direction.x > 0.0 ? 0.0 : 3.0;ntttelsenttttface = direction.y > 0.0 ? 1.0 : 4.0;ntt} else {ntttif ( absDirection.z > absDirection.y )nttttface = direction.z > 0.0 ? 2.0 : 5.0;ntttelsenttttface = direction.y > 0.0 ? 1.0 : 4.0;ntt}nttreturn face;nt}ntvec2 getUV( vec3 direction, float face ) {nttvec2 uv;nttif ( face == 0.0 ) {ntttuv = vec2( direction.z, direction.y ) / abs( direction.x );ntt} else if ( face == 1.0 ) {ntttuv = vec2( - direction.x, - direction.z ) / abs( direction.y );ntt} else if ( face == 2.0 ) {ntttuv = vec2( - direction.x, direction.y ) / abs( direction.z );ntt} else if ( face == 3.0 ) {ntttuv = vec2( - direction.z, direction.y ) / abs( direction.x );ntt} else if ( face == 4.0 ) {ntttuv = vec2( - direction.x, direction.z ) / abs( direction.y );ntt} else {ntttuv = vec2( direction.x, direction.y ) / abs( direction.z );ntt}nttreturn 0.5 * ( uv + 1.0 );nt}ntvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {nttfloat face = getFace( direction );nttfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );nttmipInt = max( mipInt, cubeUV_minMipLevel );nttfloat faceSize = exp2( mipInt );ntthighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;nttif ( face > 2.0 ) {ntttuv.y += faceSize;ntttface -= 3.0;ntt}nttuv.x += face * faceSize;nttuv.x += filterInt * 3.0 * cubeUV_minTileSize;nttuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );nttuv.x *= CUBEUV_TEXEL_WIDTH;nttuv.y *= CUBEUV_TEXEL_HEIGHT;ntt#ifdef texture2DGradEXTntttreturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;ntt#elsentttreturn texture2D( envMap, uv ).rgb;ntt#endifnt}nt#define cubeUV_r0 1.0nt#define cubeUV_v0 0.339nt#define cubeUV_m0 - 2.0nt#define cubeUV_r1 0.8nt#define cubeUV_v1 0.276nt#define cubeUV_m1 - 1.0nt#define cubeUV_r4 0.4nt#define cubeUV_v4 0.046nt#define cubeUV_m4 2.0nt#define cubeUV_r5 0.305nt#define cubeUV_v5 0.016nt#define cubeUV_m5 3.0nt#define cubeUV_r6 0.21nt#define cubeUV_v6 0.0038nt#define cubeUV_m6 4.0ntfloat roughnessToMip( float roughness ) {nttfloat mip = 0.0;nttif ( roughness >= cubeUV_r1 ) {ntttmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;ntt} else if ( roughness >= cubeUV_r4 ) {ntttmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;ntt} else if ( roughness >= cubeUV_r5 ) {ntttmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;ntt} else if ( roughness >= cubeUV_r6 ) {ntttmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;ntt} else {ntttmip = - 2.0 * log2( 1.16 * roughness );tt}nttreturn mip;nt}ntvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {nttfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );nttfloat mipF = fract( mip );nttfloat mipInt = floor( mip );nttvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );nttif ( mipF == 0.0 ) {ntttreturn vec4( color0, 1.0 );ntt} else {ntttvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );ntttreturn vec4( mix( color0, color1, mipF ), 1.0 );ntt}nt}n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;n#ifdef USE_INSTANCINGntmat3 m = mat3( instanceMatrix );nttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );nttransformedNormal = m * transformedNormal;n#endifntransformedNormal = normalMatrix * transformedNormal;n#ifdef FLIP_SIDEDnttransformedNormal = - transformedNormal;n#endifn#ifdef USE_TANGENTntvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;nt#ifdef FLIP_SIDEDntttransformedTangent = - transformedTangent;nt#endifn#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAPntuniform sampler2D displacementMap;ntuniform float displacementScale;ntuniform float displacementBias;n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAPnttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAPntvec4 emissiveColor = texture2D( emissiveMap, vUv );nttotalEmissiveRadiance *= emissiveColor.rgb;n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAPntuniform sampler2D emissiveMap;n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {ntreturn value;n}nvec4 LinearTosRGB( in vec4 value ) {ntreturn 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 );n}",envmap_fragment:"#ifdef USE_ENVMAPnt#ifdef ENV_WORLDPOSnttvec3 cameraToFrag;nttif ( isOrthographic ) {ntttcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );ntt} else {ntttcameraToFrag = normalize( vWorldPosition - cameraPosition );ntt}nttvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );ntt#ifdef ENVMAP_MODE_REFLECTIONntttvec3 reflectVec = reflect( cameraToFrag, worldNormal );ntt#elsentttvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );ntt#endifnt#elsenttvec3 reflectVec = vReflect;nt#endifnt#ifdef ENVMAP_TYPE_CUBEnttvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );nt#elsenttvec4 envColor = vec4( 0.0 );nt#endifnt#ifdef ENVMAP_BLENDING_MULTIPLYnttoutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );nt#elif defined( ENVMAP_BLENDING_MIX )nttoutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );nt#elif defined( ENVMAP_BLENDING_ADD )nttoutgoingLight += envColor.xyz * specularStrength * reflectivity;nt#endifn#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAPntuniform float envMapIntensity;ntuniform float flipEnvMap;nt#ifdef ENVMAP_TYPE_CUBEnttuniform samplerCube envMap;nt#elsenttuniform sampler2D envMap;nt#endifntn#endif",envmap_pars_fragment:"#ifdef USE_ENVMAPntuniform float reflectivity;nt#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )ntt#define ENV_WORLDPOSnt#endifnt#ifdef ENV_WORLDPOSnttvarying vec3 vWorldPosition;nttuniform float refractionRatio;nt#elsenttvarying vec3 vReflect;nt#endifn#endif",envmap_pars_vertex:"#ifdef USE_ENVMAPnt#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )ntt#define ENV_WORLDPOSnt#endifnt#ifdef ENV_WORLDPOSnttnttvarying vec3 vWorldPosition;nt#elsenttvarying vec3 vReflect;nttuniform float refractionRatio;nt#endifn#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )ntvec3 getIBLIrradiance( const in vec3 normal ) {ntt#if defined( ENVMAP_TYPE_CUBE_UV )ntttvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );ntttvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );ntttreturn PI * envMapColor.rgb * envMapIntensity;ntt#elsentttreturn vec3( 0.0 );ntt#endifnt}ntvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {ntt#if defined( ENVMAP_TYPE_CUBE_UV )ntttvec3 reflectVec = reflect( - viewDir, normal );ntttreflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );ntttreflectVec = inverseTransformDirection( reflectVec, viewMatrix );ntttvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );ntttreturn envMapColor.rgb * envMapIntensity;ntt#elsentttreturn vec3( 0.0 );ntt#endifnt}n#endif",envmap_vertex:"#ifdef USE_ENVMAPnt#ifdef ENV_WORLDPOSnttvWorldPosition = worldPosition.xyz;nt#elsenttvec3 cameraToVertex;nttif ( isOrthographic ) {ntttcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );ntt} else {ntttcameraToVertex = normalize( worldPosition.xyz - cameraPosition );ntt}nttvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );ntt#ifdef ENVMAP_MODE_REFLECTIONntttvReflect = reflect( cameraToVertex, worldNormal );ntt#elsentttvReflect = refract( cameraToVertex, worldNormal, refractionRatio );ntt#endifnt#endifn#endif",fog_vertex:"#ifdef USE_FOGntvFogDepth = - mvPosition.z;n#endif",fog_pars_vertex:"#ifdef USE_FOGntvarying float vFogDepth;n#endif",fog_fragment:"#ifdef USE_FOGnt#ifdef FOG_EXP2nttfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );nt#elsenttfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );nt#endifntgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );n#endif",fog_pars_fragment:"#ifdef USE_FOGntuniform vec3 fogColor;ntvarying float vFogDepth;nt#ifdef FOG_EXP2nttuniform float fogDensity;nt#elsenttuniform float fogNear;nttuniform float fogFar;nt#endifn#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAPntuniform sampler2D gradientMap;n#endifnvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {ntfloat dotNL = dot( normal, lightDirection );ntvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );nt#ifdef USE_GRADIENTMAPnttreturn vec3( texture2D( gradientMap, coord ).r );nt#elsenttvec2 fw = fwidth( coord ) * 0.5;nttreturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );nt#endifn}",lightmap_fragment:"#ifdef USE_LIGHTMAPntvec4 lightMapTexel = texture2D( lightMap, vUv2 );ntvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;ntreflectedLight.indirectDiffuse += lightMapIrradiance;n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAPntuniform sampler2D lightMap;ntuniform float lightMapIntensity;n#endif",lights_lambert_fragment:"LambertMaterial material;nmaterial.diffuseColor = diffuseColor.rgb;nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;nstruct LambertMaterial {ntvec3 diffuseColor;ntfloat specularStrength;n};nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {ntfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );ntvec3 irradiance = dotNL * directLight.color;ntreflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {ntreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}n#define RE_DirectttttRE_Direct_Lambertn#define RE_IndirectDiffusettRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;nuniform vec3 ambientLightColor;nuniform vec3 lightProbe[ 9 ];nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {ntfloat x = normal.x, y = normal.y, z = normal.z;ntvec3 result = shCoefficients[ 0 ] * 0.886227;ntresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;ntresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;ntresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;ntresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;ntresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;ntresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );ntresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;ntresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );ntreturn result;n}nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {ntvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );ntvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );ntreturn irradiance;n}nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {ntvec3 irradiance = ambientLightColor;ntreturn irradiance;n}nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {nt#if defined ( PHYSICALLY_CORRECT_LIGHTS )nttfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );nttif ( cutoffDistance > 0.0 ) {ntttdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );ntt}nttreturn distanceFalloff;nt#elsenttif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {ntttreturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );ntt}nttreturn 1.0;nt#endifn}nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {ntreturn smoothstep( coneCosine, penumbraCosine, angleCosine );n}n#if NUM_DIR_LIGHTS > 0ntstruct DirectionalLight {nttvec3 direction;nttvec3 color;nt};ntuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];ntvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {nttlight.color = directionalLight.color;nttlight.direction = directionalLight.direction;nttlight.visible = true;nt}n#endifn#if NUM_POINT_LIGHTS > 0ntstruct PointLight {nttvec3 position;nttvec3 color;nttfloat distance;nttfloat decay;nt};ntuniform PointLight pointLights[ NUM_POINT_LIGHTS ];ntvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {nttvec3 lVector = pointLight.position - geometry.position;nttlight.direction = normalize( lVector );nttfloat lightDistance = length( lVector );nttlight.color = pointLight.color;nttlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );nttlight.visible = ( light.color != vec3( 0.0 ) );nt}n#endifn#if NUM_SPOT_LIGHTS > 0ntstruct SpotLight {nttvec3 position;nttvec3 direction;nttvec3 color;nttfloat distance;nttfloat decay;nttfloat coneCos;nttfloat penumbraCos;nt};ntuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];ntvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {nttvec3 lVector = spotLight.position - geometry.position;nttlight.direction = normalize( lVector );nttfloat angleCos = dot( light.direction, spotLight.direction );nttfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );nttif ( spotAttenuation > 0.0 ) {ntttfloat lightDistance = length( lVector );ntttlight.color = spotLight.color * spotAttenuation;ntttlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );ntttlight.visible = ( light.color != vec3( 0.0 ) );ntt} else {ntttlight.color = vec3( 0.0 );ntttlight.visible = false;ntt}nt}n#endifn#if NUM_RECT_AREA_LIGHTS > 0ntstruct RectAreaLight {nttvec3 color;nttvec3 position;nttvec3 halfWidth;nttvec3 halfHeight;nt};ntuniform sampler2D ltc_1;tuniform sampler2D ltc_2;ntuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];n#endifn#if NUM_HEMI_LIGHTS > 0ntstruct HemisphereLight {nttvec3 direction;nttvec3 skyColor;nttvec3 groundColor;nt};ntuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];ntvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {nttfloat dotNL = dot( normal, hemiLight.direction );nttfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;nttvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );nttreturn irradiance;nt}n#endif",lights_toon_fragment:"ToonMaterial material;nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;nstruct ToonMaterial {ntvec3 diffuseColor;n};nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {ntvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;ntreflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {ntreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}n#define RE_DirectttttRE_Direct_Toonn#define RE_IndirectDiffusettRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;nmaterial.diffuseColor = diffuseColor.rgb;nmaterial.specularColor = specular;nmaterial.specularShininess = shininess;nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;nstruct BlinnPhongMaterial {ntvec3 diffuseColor;ntvec3 specularColor;ntfloat specularShininess;ntfloat specularStrength;n};nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {ntfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );ntvec3 irradiance = dotNL * directLight.color;ntreflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );ntreflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;n}nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {ntreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}n#define RE_DirectttttRE_Direct_BlinnPhongn#define RE_IndirectDiffusettRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;nmaterial.roughness = min( material.roughness, 1.0 );n#ifdef IORntmaterial.ior = ior;nt#ifdef SPECULARnttfloat specularIntensityFactor = specularIntensity;nttvec3 specularColorFactor = specularColor;ntt#ifdef USE_SPECULARINTENSITYMAPntttspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;ntt#endifntt#ifdef USE_SPECULARCOLORMAPntttspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;ntt#endifnttmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );nt#elsenttfloat specularIntensityFactor = 1.0;nttvec3 specularColorFactor = vec3( 1.0 );nttmaterial.specularF90 = 1.0;nt#endifntmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );n#elsentmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );ntmaterial.specularF90 = 1.0;n#endifn#ifdef USE_CLEARCOATntmaterial.clearcoat = clearcoat;ntmaterial.clearcoatRoughness = clearcoatRoughness;ntmaterial.clearcoatF0 = vec3( 0.04 );ntmaterial.clearcoatF90 = 1.0;nt#ifdef USE_CLEARCOATMAPnttmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;nt#endifnt#ifdef USE_CLEARCOAT_ROUGHNESSMAPnttmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;nt#endifntmaterial.clearcoat = saturate( material.clearcoat );tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );ntmaterial.clearcoatRoughness += geometryRoughness;ntmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );n#endifn#ifdef USE_IRIDESCENCEntmaterial.iridescence = iridescence;ntmaterial.iridescenceIOR = iridescenceIOR;nt#ifdef USE_IRIDESCENCEMAPnttmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;nt#endifnt#ifdef USE_IRIDESCENCE_THICKNESSMAPnttmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;nt#elsenttmaterial.iridescenceThickness = iridescenceThicknessMaximum;nt#endifn#endifn#ifdef USE_SHEENntmaterial.sheenColor = sheenColor;nt#ifdef USE_SHEENCOLORMAPnttmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;nt#endifntmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );nt#ifdef USE_SHEENROUGHNESSMAPnttmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;nt#endifn#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {ntvec3 diffuseColor;ntfloat roughness;ntvec3 specularColor;ntfloat specularF90;nt#ifdef USE_CLEARCOATnttfloat clearcoat;nttfloat clearcoatRoughness;nttvec3 clearcoatF0;nttfloat clearcoatF90;nt#endifnt#ifdef USE_IRIDESCENCEnttfloat iridescence;nttfloat iridescenceIOR;nttfloat iridescenceThickness;nttvec3 iridescenceFresnel;nttvec3 iridescenceF0;nt#endifnt#ifdef USE_SHEENnttvec3 sheenColor;nttfloat sheenRoughness;nt#endifnt#ifdef IORnttfloat ior;nt#endifnt#ifdef USE_TRANSMISSIONnttfloat transmission;nttfloat transmissionAlpha;nttfloat thickness;nttfloat attenuationDistance;nttvec3 attenuationColor;nt#endifn};nvec3 clearcoatSpecular = vec3( 0.0 );nvec3 sheenSpecular = vec3( 0.0 );nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {ntfloat dotNV = saturate( dot( normal, viewDir ) );ntfloat r2 = roughness * roughness;ntfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;ntfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;ntfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );ntreturn saturate( DG * RECIPROCAL_PI );n}nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {ntfloat dotNV = saturate( dot( normal, viewDir ) );ntconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );ntconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );ntvec4 r = roughness * c0 + c1;ntfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;ntvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;ntreturn fab;n}nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {ntvec2 fab = DFGApprox( normal, viewDir, roughness );ntreturn specularColor * fab.x + specularF90 * fab.y;n}n#ifdef USE_IRIDESCENCEnvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {n#elsenvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {n#endifntvec2 fab = DFGApprox( normal, viewDir, roughness );nt#ifdef USE_IRIDESCENCEnttvec3 Fr = mix( specularColor, iridescenceF0, iridescence );nt#elsenttvec3 Fr = specularColor;nt#endifntvec3 FssEss = Fr * fab.x + specularF90 * fab.y;ntfloat Ess = fab.x + fab.y;ntfloat Ems = 1.0 - Ess;ntvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );ntsingleScatter += FssEss;ntmultiScatter += Fms * Ems;n}n#if NUM_RECT_AREA_LIGHTS > 0ntvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {nttvec3 normal = geometry.normal;nttvec3 viewDir = geometry.viewDir;nttvec3 position = geometry.position;nttvec3 lightPos = rectAreaLight.position;nttvec3 halfWidth = rectAreaLight.halfWidth;nttvec3 halfHeight = rectAreaLight.halfHeight;nttvec3 lightColor = rectAreaLight.color;nttfloat roughness = material.roughness;nttvec3 rectCoords[ 4 ];nttrectCoords[ 0 ] = lightPos + halfWidth - halfHeight;ttrectCoords[ 1 ] = lightPos - halfWidth - halfHeight;nttrectCoords[ 2 ] = lightPos - halfWidth + halfHeight;nttrectCoords[ 3 ] = lightPos + halfWidth + halfHeight;nttvec2 uv = LTC_Uv( normal, viewDir, roughness );nttvec4 t1 = texture2D( ltc_1, uv );nttvec4 t2 = texture2D( ltc_2, uv );nttmat3 mInv = mat3(ntttvec3( t1.x, 0, t1.y ),ntttvec3(    0, 1,    0 ),ntttvec3( t1.z, 0, t1.w )ntt);nttvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );nttreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );nttreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );nt}n#endifnvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {ntfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );ntvec3 irradiance = dotNL * directLight.color;nt#ifdef USE_CLEARCOATnttfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );nttvec3 ccIrradiance = dotNLcc * directLight.color;nttclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );nt#endifnt#ifdef USE_SHEENnttsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );nt#endifnt#ifdef USE_IRIDESCENCEnttreflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );nt#elsenttreflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );nt#endifntreflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {ntreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );n}nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {nt#ifdef USE_CLEARCOATnttclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );nt#endifnt#ifdef USE_SHEENnttsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );nt#endifntvec3 singleScattering = vec3( 0.0 );ntvec3 multiScattering = vec3( 0.0 );ntvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;nt#ifdef USE_IRIDESCENCEnttcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );nt#elsenttcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );nt#endifntvec3 totalScattering = singleScattering + multiScattering;ntvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );ntreflectedLight.indirectSpecular += radiance * singleScattering;ntreflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;ntreflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;n}n#define RE_DirectttttRE_Direct_Physicaln#define RE_Direct_RectAreattRE_Direct_RectArea_Physicaln#define RE_IndirectDiffusettRE_IndirectDiffuse_Physicaln#define RE_IndirectSpecularttRE_IndirectSpecular_Physicalnfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {ntreturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );n}",lights_fragment_begin:"nGeometricContext geometry;ngeometry.position = - vViewPosition;ngeometry.normal = normal;ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );n#ifdef USE_CLEARCOATntgeometry.clearcoatNormal = clearcoatNormal;n#endifn#ifdef USE_IRIDESCENCEntfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );ntif ( material.iridescenceThickness == 0.0 ) {nttmaterial.iridescence = 0.0;nt} else {nttmaterial.iridescence = saturate( material.iridescence );nt}ntif ( material.iridescence > 0.0 ) {nttmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );nttmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );nt}n#endifnIncidentLight directLight;n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )ntPointLight pointLight;nt#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0ntPointLightShadow pointLightShadow;nt#endifnt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {nttpointLight = pointLights[ i ];nttgetPointLightInfo( pointLight, geometry, directLight );ntt#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )nttpointLightShadow = pointLightShadows[ i ];nttdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;ntt#endifnttRE_Direct( directLight, geometry, material, reflectedLight );nt}nt#pragma unroll_loop_endn#endifn#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )ntSpotLight spotLight;ntvec4 spotColor;ntvec3 spotLightCoord;ntbool inSpotLightMap;nt#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0ntSpotLightShadow spotLightShadow;nt#endifnt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {nttspotLight = spotLights[ i ];nttgetSpotLightInfo( spotLight, geometry, directLight );ntt#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )ntt#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEXntt#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )ntt#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPSntt#elsentt#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )ntt#endifntt#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )ntttspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;ntttinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );ntttspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );ntttdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;ntt#endifntt#undef SPOT_LIGHT_MAP_INDEXntt#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )nttspotLightShadow = spotLightShadows[ i ];nttdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;ntt#endifnttRE_Direct( directLight, geometry, material, reflectedLight );nt}nt#pragma unroll_loop_endn#endifn#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )ntDirectionalLight directionalLight;nt#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0ntDirectionalLightShadow directionalLightShadow;nt#endifnt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {nttdirectionalLight = directionalLights[ i ];nttgetDirectionalLightInfo( directionalLight, geometry, directLight );ntt#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )nttdirectionalLightShadow = directionalLightShadows[ i ];nttdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;ntt#endifnttRE_Direct( directLight, geometry, material, reflectedLight );nt}nt#pragma unroll_loop_endn#endifn#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )ntRectAreaLight rectAreaLight;nt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {nttrectAreaLight = rectAreaLights[ i ];nttRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );nt}nt#pragma unroll_loop_endn#endifn#if defined( RE_IndirectDiffuse )ntvec3 iblIrradiance = vec3( 0.0 );ntvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );ntirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );nt#if ( NUM_HEMI_LIGHTS > 0 )ntt#pragma unroll_loop_startnttfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {ntttirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );ntt}ntt#pragma unroll_loop_endnt#endifn#endifn#if defined( RE_IndirectSpecular )ntvec3 radiance = vec3( 0.0 );ntvec3 clearcoatRadiance = vec3( 0.0 );n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )nt#ifdef USE_LIGHTMAPnttvec4 lightMapTexel = texture2D( lightMap, vUv2 );nttvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;nttirradiance += lightMapIrradiance;nt#endifnt#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )nttiblIrradiance += getIBLIrradiance( geometry.normal );nt#endifn#endifn#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )ntradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );nt#ifdef USE_CLEARCOATnttclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );nt#endifn#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )ntRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );n#endifn#if defined( RE_IndirectSpecular )ntRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )ntgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )ntuniform float logDepthBufFC;ntvarying float vFragDepth;ntvarying float vIsPerspective;n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUFnt#ifdef USE_LOGDEPTHBUF_EXTnttvarying float vFragDepth;nttvarying float vIsPerspective;nt#elsenttuniform float logDepthBufFC;nt#endifn#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUFnt#ifdef USE_LOGDEPTHBUF_EXTnttvFragDepth = 1.0 + gl_Position.w;nttvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );nt#elsenttif ( isPerspectiveMatrix( projectionMatrix ) ) {ntttgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;ntttgl_Position.z *= gl_Position.w;ntt}nt#endifn#endif",map_fragment:"#ifdef USE_MAPntvec4 sampledDiffuseColor = texture2D( map, vUv );nt#ifdef DECODE_VIDEO_TEXTUREnttsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );nt#endifntdiffuseColor *= sampledDiffuseColor;n#endif",map_pars_fragment:"#ifdef USE_MAPntuniform sampler2D map;n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )ntvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;n#endifn#ifdef USE_MAPntdiffuseColor *= texture2D( map, uv );n#endifn#ifdef USE_ALPHAMAPntdiffuseColor.a *= texture2D( alphaMap, uv ).g;n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )ntuniform mat3 uvTransform;n#endifn#ifdef USE_MAPntuniform sampler2D map;n#endifn#ifdef USE_ALPHAMAPntuniform sampler2D alphaMap;n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;n#ifdef USE_METALNESSMAPntvec4 texelMetalness = texture2D( metalnessMap, vUv );ntmetalnessFactor *= texelMetalness.b;n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAPntuniform sampler2D metalnessMap;n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )ntvColor *= morphTargetBaseInfluence;ntfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {ntt#if defined( USE_COLOR_ALPHA )ntttif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];ntt#elif defined( USE_COLOR )ntttif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];ntt#endifnt}n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALSntobjectNormal *= morphTargetBaseInfluence;nt#ifdef MORPHTARGETS_TEXTUREnttfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {ntttif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];ntt}nt#elsenttobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];nttobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];nttobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];nttobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];nt#endifn#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETSntuniform float morphTargetBaseInfluence;nt#ifdef MORPHTARGETS_TEXTUREnttuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];nttuniform sampler2DArray morphTargetsTexture;nttuniform ivec2 morphTargetsTextureSize;nttvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {ntttint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;ntttint y = texelIndex / morphTargetsTextureSize.x;ntttint x = texelIndex - y * morphTargetsTextureSize.x;ntttivec3 morphUV = ivec3( x, y, morphTargetIndex );ntttreturn texelFetch( morphTargetsTexture, morphUV, 0 );ntt}nt#elsentt#ifndef USE_MORPHNORMALSntttuniform float morphTargetInfluences[ 8 ];ntt#elsentttuniform float morphTargetInfluences[ 4 ];ntt#endifnt#endifn#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETSnttransformed *= morphTargetBaseInfluence;nt#ifdef MORPHTARGETS_TEXTUREnttfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {ntttif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];ntt}nt#elsentttransformed += morphTarget0 * morphTargetInfluences[ 0 ];ntttransformed += morphTarget1 * morphTargetInfluences[ 1 ];ntttransformed += morphTarget2 * morphTargetInfluences[ 2 ];ntttransformed += morphTarget3 * morphTargetInfluences[ 3 ];ntt#ifndef USE_MORPHNORMALSnttttransformed += morphTarget4 * morphTargetInfluences[ 4 ];nttttransformed += morphTarget5 * morphTargetInfluences[ 5 ];nttttransformed += morphTarget6 * morphTargetInfluences[ 6 ];nttttransformed += morphTarget7 * morphTargetInfluences[ 7 ];ntt#endifnt#endifn#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;n#ifdef FLAT_SHADEDntvec3 fdx = dFdx( vViewPosition );ntvec3 fdy = dFdy( vViewPosition );ntvec3 normal = normalize( cross( fdx, fdy ) );n#elsentvec3 normal = normalize( vNormal );nt#ifdef DOUBLE_SIDEDnttnormal = normal * faceDirection;nt#endifnt#ifdef USE_TANGENTnttvec3 tangent = normalize( vTangent );nttvec3 bitangent = normalize( vBitangent );ntt#ifdef DOUBLE_SIDEDnttttangent = tangent * faceDirection;ntttbitangent = bitangent * faceDirection;ntt#endifntt#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )ntttmat3 vTBN = mat3( tangent, bitangent, normal );ntt#endifnt#endifn#endifnvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAPntnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;nt#ifdef FLIP_SIDEDnttnormal = - normal;nt#endifnt#ifdef DOUBLE_SIDEDnttnormal = normal * faceDirection;nt#endifntnormal = normalize( normalMatrix * normal );n#elif defined( TANGENTSPACE_NORMALMAP )ntvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;ntmapN.xy *= normalScale;nt#ifdef USE_TANGENTnttnormal = normalize( vTBN * mapN );nt#elsenttnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );nt#endifn#elif defined( USE_BUMPMAP )ntnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );n#endif",normal_pars_fragment:"#ifndef FLAT_SHADEDntvarying vec3 vNormal;nt#ifdef USE_TANGENTnttvarying vec3 vTangent;nttvarying vec3 vBitangent;nt#endifn#endif",normal_pars_vertex:"#ifndef FLAT_SHADEDntvarying vec3 vNormal;nt#ifdef USE_TANGENTnttvarying vec3 vTangent;nttvarying vec3 vBitangent;nt#endifn#endif",normal_vertex:"#ifndef FLAT_SHADEDntvNormal = normalize( transformedNormal );nt#ifdef USE_TANGENTnttvTangent = normalize( transformedTangent );nttvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );nt#endifn#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAPntuniform sampler2D normalMap;ntuniform vec2 normalScale;n#endifn#ifdef OBJECTSPACE_NORMALMAPntuniform mat3 normalMatrix;n#endifn#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )ntvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {nttvec3 q0 = dFdx( eye_pos.xyz );nttvec3 q1 = dFdy( eye_pos.xyz );nttvec2 st0 = dFdx( vUv.st );nttvec2 st1 = dFdy( vUv.st );nttvec3 N = surf_norm;nttvec3 q1perp = cross( q1, N );nttvec3 q0perp = cross( N, q0 );nttvec3 T = q1perp * st0.x + q0perp * st1.x;nttvec3 B = q1perp * st0.y + q0perp * st1.y;nttfloat det = max( dot( T, T ), dot( B, B ) );nttfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );nttreturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );nt}n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOATntvec3 clearcoatNormal = geometryNormal;n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAPntvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;ntclearcoatMapN.xy *= clearcoatNormalScale;nt#ifdef USE_TANGENTnttclearcoatNormal = normalize( vTBN * clearcoatMapN );nt#elsenttclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );nt#endifn#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAPntuniform sampler2D clearcoatMap;n#endifn#ifdef USE_CLEARCOAT_ROUGHNESSMAPntuniform sampler2D clearcoatRoughnessMap;n#endifn#ifdef USE_CLEARCOAT_NORMALMAPntuniform sampler2D clearcoatNormalMap;ntuniform vec2 clearcoatNormalScale;n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAPntuniform sampler2D iridescenceMap;n#endifn#ifdef USE_IRIDESCENCE_THICKNESSMAPntuniform sampler2D iridescenceThicknessMap;n#endif",output_fragment:"#ifdef OPAQUEndiffuseColor.a = 1.0;n#endifn#ifdef USE_TRANSMISSIONndiffuseColor.a *= material.transmissionAlpha + 0.1;n#endifngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {ntreturn normalize( normal ) * 0.5 + 0.5;n}nvec3 unpackRGBToNormal( const in vec3 rgb ) {ntreturn 2.0 * rgb.xyz - 1.0;n}nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );nconst float ShiftRight8 = 1. / 256.;nvec4 packDepthToRGBA( const in float v ) {ntvec4 r = vec4( fract( v * PackFactors ), v );ntr.yzw -= r.xyz * ShiftRight8;treturn r * PackUpscale;n}nfloat unpackRGBAToDepth( const in vec4 v ) {ntreturn dot( v, UnpackFactors );n}nvec2 packDepthToRG( in highp float v ) {ntreturn packDepthToRGBA( v ).yx;n}nfloat unpackRGToDepth( const in highp vec2 v ) {ntreturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );n}nvec4 pack2HalfToRGBA( vec2 v ) {ntvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );ntreturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );n}nvec2 unpackRGBATo2Half( vec4 v ) {ntreturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );n}nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {ntreturn ( viewZ + near ) / ( near - far );n}nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {ntreturn linearClipZ * ( near - far ) - near;n}nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {ntreturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );n}nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {ntreturn ( near * far ) / ( ( far - near ) * invClipZ - far );n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHAntgl_FragColor.rgb *= gl_FragColor.a;n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );n#ifdef USE_INSTANCINGntmvPosition = instanceMatrix * mvPosition;n#endifnmvPosition = modelViewMatrix * mvPosition;ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERINGntgl_FragColor.rgb = dithering( gl_FragColor.rgb );n#endif",dithering_pars_fragment:"#ifdef DITHERINGntvec3 dithering( vec3 color ) {nttfloat grid_position = rand( gl_FragCoord.xy );nttvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );nttdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );nttreturn color + dither_shift_RGB;nt}n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;n#ifdef USE_ROUGHNESSMAPntvec4 texelRoughness = texture2D( roughnessMap, vUv );ntroughnessFactor *= texelRoughness.g;n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAPntuniform sampler2D roughnessMap;n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0n  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];n#endifn#if NUM_SPOT_LIGHT_MAPS > 0n  uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];n#endifn#ifdef USE_SHADOWMAPnt#if NUM_DIR_LIGHT_SHADOWS > 0nttuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];nttvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];nttstruct DirectionalLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntt};nttuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];nt#endifnt#if NUM_SPOT_LIGHT_SHADOWS > 0nttuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];nttstruct SpotLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntt};nttuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];nt#endifnt#if NUM_POINT_LIGHT_SHADOWS > 0nttuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];nttvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];nttstruct PointLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntttfloat shadowCameraNear;ntttfloat shadowCameraFar;ntt};nttuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];nt#endifntfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {nttreturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );nt}ntvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {nttreturn unpackRGBATo2Half( texture2D( shadow, uv ) );nt}ntfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){nttfloat occlusion = 1.0;nttvec2 distribution = texture2DDistribution( shadow, uv );nttfloat hard_shadow = step( compare , distribution.x );nttif (hard_shadow != 1.0 ) {ntttfloat distance = compare - distribution.x ;ntttfloat variance = max( 0.00000, distribution.y * distribution.y );ntttfloat softness_probability = variance / (variance + distance * distance );tttsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );tttocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );ntt}nttreturn occlusion;nt}ntfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {nttfloat shadow = 1.0;nttshadowCoord.xyz /= shadowCoord.w;nttshadowCoord.z += shadowBias;nttbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;nttbool frustumTest = inFrustum && shadowCoord.z <= 1.0;nttif ( frustumTest ) {ntt#if defined( SHADOWMAP_TYPE_PCF )ntttvec2 texelSize = vec2( 1.0 ) / shadowMapSize;ntttfloat dx0 = - texelSize.x * shadowRadius;ntttfloat dy0 = - texelSize.y * shadowRadius;ntttfloat dx1 = + texelSize.x * shadowRadius;ntttfloat dy1 = + texelSize.y * shadowRadius;ntttfloat dx2 = dx0 / 2.0;ntttfloat dy2 = dy0 / 2.0;ntttfloat dx3 = dx1 / 2.0;ntttfloat dy3 = dy1 / 2.0;ntttshadow = (ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )nttt) * ( 1.0 / 17.0 );ntt#elif defined( SHADOWMAP_TYPE_PCF_SOFT )ntttvec2 texelSize = vec2( 1.0 ) / shadowMapSize;ntttfloat dx = texelSize.x;ntttfloat dy = texelSize.y;ntttvec2 uv = shadowCoord.xy;ntttvec2 f = fract( uv * shadowMapSize + 0.5 );ntttuv -= f * texelSize;ntttshadow = (ntttttexture2DCompare( shadowMap, uv, shadowCoord.z ) +ntttttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +ntttttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +nttttmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),nttttt texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),nttttt f.x ) +nttttmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),nttttt texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),nttttt f.x ) +nttttmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),nttttt texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),nttttt f.y ) +nttttmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),nttttt texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),nttttt f.y ) +nttttmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),ntttttt  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),ntttttt  f.x ),nttttt mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),ntttttt  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),ntttttt  f.x ),nttttt f.y )nttt) * ( 1.0 / 9.0 );ntt#elif defined( SHADOWMAP_TYPE_VSM )ntttshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );ntt#elsentttshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );ntt#endifntt}nttreturn shadow;nt}ntvec2 cubeToUV( vec3 v, float texelSizeY ) {nttvec3 absV = abs( v );nttfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );nttabsV *= scaleToCube;nttv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );nttvec2 planar = v.xy;nttfloat almostATexel = 1.5 * texelSizeY;nttfloat almostOne = 1.0 - almostATexel;nttif ( absV.z >= almostOne ) {ntttif ( v.z > 0.0 )nttttplanar.x = 4.0 - v.x;ntt} else if ( absV.x >= almostOne ) {ntttfloat signX = sign( v.x );ntttplanar.x = v.z * signX + 2.0 * signX;ntt} else if ( absV.y >= almostOne ) {ntttfloat signY = sign( v.y );ntttplanar.x = v.x + 2.0 * signY + 2.0;ntttplanar.y = v.z * signY - 2.0;ntt}nttreturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );nt}ntfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {nttvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );nttvec3 lightToPosition = shadowCoord.xyz;nttfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );ttdp += shadowBias;nttvec3 bd3D = normalize( lightToPosition );ntt#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )ntttvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;ntttreturn (ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +ntttttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )nttt) * ( 1.0 / 9.0 );ntt#elsentttreturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );ntt#endifnt}n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0n  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];n  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];n#endifn#ifdef USE_SHADOWMAPnt#if NUM_DIR_LIGHT_SHADOWS > 0nttuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];nttvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];nttstruct DirectionalLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntt};nttuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];nt#endifnt#if NUM_SPOT_LIGHT_SHADOWS > 0nttstruct SpotLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntt};nttuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];nt#endifnt#if NUM_POINT_LIGHT_SHADOWS > 0nttuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];nttvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];nttstruct PointLightShadow {ntttfloat shadowBias;ntttfloat shadowNormalBias;ntttfloat shadowRadius;ntttvec2 shadowMapSize;ntttfloat shadowCameraNear;ntttfloat shadowCameraFar;ntt};nttuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];nt#endifn#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )ntvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );ntvec4 shadowWorldPosition;n#endifn#if defined( USE_SHADOWMAP )nt#if NUM_DIR_LIGHT_SHADOWS > 0ntt#pragma unroll_loop_startnttfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {ntttshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );ntttvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;ntt}ntt#pragma unroll_loop_endnt#endifnt#if NUM_POINT_LIGHT_SHADOWS > 0ntt#pragma unroll_loop_startnttfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {ntttshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );ntttvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;ntt}ntt#pragma unroll_loop_endnt#endifn#endifn#if NUM_SPOT_LIGHT_COORDS > 0nt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {nttshadowWorldPosition = worldPosition;ntt#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )ntttshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;ntt#endifnttvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;nt}nt#pragma unroll_loop_endn#endif",shadowmask_pars_fragment:"float getShadowMask() {ntfloat shadow = 1.0;nt#ifdef USE_SHADOWMAPnt#if NUM_DIR_LIGHT_SHADOWS > 0ntDirectionalLightShadow directionalLight;nt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {nttdirectionalLight = directionalLightShadows[ i ];nttshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;nt}nt#pragma unroll_loop_endnt#endifnt#if NUM_SPOT_LIGHT_SHADOWS > 0ntSpotLightShadow spotLight;nt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {nttspotLight = spotLightShadows[ i ];nttshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;nt}nt#pragma unroll_loop_endnt#endifnt#if NUM_POINT_LIGHT_SHADOWS > 0ntPointLightShadow pointLight;nt#pragma unroll_loop_startntfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {nttpointLight = pointLightShadows[ i ];nttshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;nt}nt#pragma unroll_loop_endnt#endifnt#endifntreturn shadow;n}",skinbase_vertex:"#ifdef USE_SKINNINGntmat4 boneMatX = getBoneMatrix( skinIndex.x );ntmat4 boneMatY = getBoneMatrix( skinIndex.y );ntmat4 boneMatZ = getBoneMatrix( skinIndex.z );ntmat4 boneMatW = getBoneMatrix( skinIndex.w );n#endif",skinning_pars_vertex:"#ifdef USE_SKINNINGntuniform mat4 bindMatrix;ntuniform mat4 bindMatrixInverse;ntuniform highp sampler2D boneTexture;ntuniform int boneTextureSize;ntmat4 getBoneMatrix( const in float i ) {nttfloat j = i * 4.0;nttfloat x = mod( j, float( boneTextureSize ) );nttfloat y = floor( j / float( boneTextureSize ) );nttfloat dx = 1.0 / float( boneTextureSize );nttfloat dy = 1.0 / float( boneTextureSize );ntty = dy * ( y + 0.5 );nttvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );nttvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );nttvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );nttvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );nttmat4 bone = mat4( v1, v2, v3, v4 );nttreturn bone;nt}n#endif",skinning_vertex:"#ifdef USE_SKINNINGntvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );ntvec4 skinned = vec4( 0.0 );ntskinned += boneMatX * skinVertex * skinWeight.x;ntskinned += boneMatY * skinVertex * skinWeight.y;ntskinned += boneMatZ * skinVertex * skinWeight.z;ntskinned += boneMatW * skinVertex * skinWeight.w;nttransformed = ( bindMatrixInverse * skinned ).xyz;n#endif",skinnormal_vertex:"#ifdef USE_SKINNINGntmat4 skinMatrix = mat4( 0.0 );ntskinMatrix += skinWeight.x * boneMatX;ntskinMatrix += skinWeight.y * boneMatY;ntskinMatrix += skinWeight.z * boneMatZ;ntskinMatrix += skinWeight.w * boneMatW;ntskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;ntobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;nt#ifdef USE_TANGENTnttobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;nt#endifn#endif",specularmap_fragment:"float specularStrength;n#ifdef USE_SPECULARMAPntvec4 texelSpecular = texture2D( specularMap, vUv );ntspecularStrength = texelSpecular.r;n#elsentspecularStrength = 1.0;n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAPntuniform sampler2D specularMap;n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )ntgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );n#endif",tonemapping_pars_fragment:"#ifndef saturaten#define saturate( a ) clamp( a, 0.0, 1.0 )n#endifnuniform float toneMappingExposure;nvec3 LinearToneMapping( vec3 color ) {ntreturn toneMappingExposure * color;n}nvec3 ReinhardToneMapping( vec3 color ) {ntcolor *= toneMappingExposure;ntreturn saturate( color / ( vec3( 1.0 ) + color ) );n}nvec3 OptimizedCineonToneMapping( vec3 color ) {ntcolor *= toneMappingExposure;ntcolor = max( vec3( 0.0 ), color - 0.004 );ntreturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );n}nvec3 RRTAndODTFit( vec3 v ) {ntvec3 a = v * ( v + 0.0245786 ) - 0.000090537;ntvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;ntreturn a / b;n}nvec3 ACESFilmicToneMapping( vec3 color ) {ntconst mat3 ACESInputMat = mat3(nttvec3( 0.59719, 0.07600, 0.02840 ),ttvec3( 0.35458, 0.90834, 0.13383 ),nttvec3( 0.04823, 0.01566, 0.83777 )nt);ntconst mat3 ACESOutputMat = mat3(nttvec3(  1.60475, -0.10208, -0.00327 ),ttvec3( -0.53108,  1.10813, -0.07276 ),nttvec3( -0.07367, -0.00605,  1.07602 )nt);ntcolor *= toneMappingExposure / 0.6;ntcolor = ACESInputMat * color;ntcolor = RRTAndODTFit( color );ntcolor = ACESOutputMat * color;ntreturn saturate( color );n}nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSIONntmaterial.transmission = transmission;ntmaterial.transmissionAlpha = 1.0;ntmaterial.thickness = thickness;ntmaterial.attenuationDistance = attenuationDistance;ntmaterial.attenuationColor = attenuationColor;nt#ifdef USE_TRANSMISSIONMAPnttmaterial.transmission *= texture2D( transmissionMap, vUv ).r;nt#endifnt#ifdef USE_THICKNESSMAPnttmaterial.thickness *= texture2D( thicknessMap, vUv ).g;nt#endifntvec3 pos = vWorldPosition;ntvec3 v = normalize( cameraPosition - pos );ntvec3 n = inverseTransformDirection( normal, viewMatrix );ntvec4 transmission = getIBLVolumeRefraction(nttn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,nttpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,nttmaterial.attenuationColor, material.attenuationDistance );ntmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );nttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSIONntuniform float transmission;ntuniform float thickness;ntuniform float attenuationDistance;ntuniform vec3 attenuationColor;nt#ifdef USE_TRANSMISSIONMAPnttuniform sampler2D transmissionMap;nt#endifnt#ifdef USE_THICKNESSMAPnttuniform sampler2D thicknessMap;nt#endifntuniform vec2 transmissionSamplerSize;ntuniform sampler2D transmissionSamplerMap;ntuniform mat4 modelMatrix;ntuniform mat4 projectionMatrix;ntvarying vec3 vWorldPosition;ntvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {nttvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );nttvec3 modelScale;nttmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );nttmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );nttmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );nttreturn normalize( refractionVector ) * thickness * modelScale;nt}ntfloat applyIorToRoughness( const in float roughness, const in float ior ) {nttreturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );nt}ntvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {nttfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );ntt#ifdef texture2DLodEXTntttreturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );ntt#elsentttreturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );ntt#endifnt}ntvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {nttif ( isinf( attenuationDistance ) ) {ntttreturn radiance;ntt} else {ntttvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;ntttvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );tttreturn transmittance * radiance;ntt}nt}ntvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,nttconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,nttconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,nttconst in vec3 attenuationColor, const in float attenuationDistance ) {nttvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );nttvec3 refractedRayExit = position + transmissionRay;nttvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );nttvec2 refractionCoords = ndcPos.xy / ndcPos.w;nttrefractionCoords += 1.0;nttrefractionCoords /= 2.0;nttvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );nttvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );nttvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );nttreturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );nt}n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )ntvarying vec2 vUv;n#endif",uv_pars_vertex:"#ifdef USE_UVnt#ifdef UVS_VERTEX_ONLYnttvec2 vUv;nt#elsenttvarying vec2 vUv;nt#endifntuniform mat3 uvTransform;n#endif",uv_vertex:"#ifdef USE_UVntvUv = ( uvTransform * vec3( uv, 1 ) ).xy;n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )ntvarying vec2 vUv2;n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )ntattribute vec2 uv2;ntvarying vec2 vUv2;ntuniform mat3 uv2Transform;n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )ntvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0ntvec4 worldPosition = vec4( transformed, 1.0 );nt#ifdef USE_INSTANCINGnttworldPosition = instanceMatrix * worldPosition;nt#endifntworldPosition = modelMatrix * worldPosition;n#endif",background_vert:"varying vec2 vUv;nuniform mat3 uvTransform;nvoid main() {ntvUv = ( uvTransform * vec3( uv, 1 ) ).xy;ntgl_Position = vec4( position.xy, 1.0, 1.0 );n}",background_frag:"uniform sampler2D t2D;nuniform float backgroundIntensity;nvarying vec2 vUv;nvoid main() {ntvec4 texColor = texture2D( t2D, vUv );nt#ifdef DECODE_VIDEO_TEXTUREntttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );nt#endifnttexColor.rgb *= backgroundIntensity;ntgl_FragColor = texColor;nt#include <tonemapping_fragment>nt#include <encodings_fragment>n}",backgroundCube_vert:"varying vec3 vWorldDirection;n#include <common>nvoid main() {ntvWorldDirection = transformDirection( position, modelMatrix );nt#include <begin_vertex>nt#include <project_vertex>ntgl_Position.z = gl_Position.w;n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBEntuniform samplerCube envMap;n#elif defined( ENVMAP_TYPE_CUBE_UV )ntuniform sampler2D envMap;n#endifnuniform float flipEnvMap;nuniform float backgroundBlurriness;nuniform float backgroundIntensity;nvarying vec3 vWorldDirection;n#include <cube_uv_reflection_fragment>nvoid main() {nt#ifdef ENVMAP_TYPE_CUBEnttvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );nt#elif defined( ENVMAP_TYPE_CUBE_UV )nttvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );nt#elsenttvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );nt#endifnttexColor.rgb *= backgroundIntensity;ntgl_FragColor = texColor;nt#include <tonemapping_fragment>nt#include <encodings_fragment>n}",cube_vert:"varying vec3 vWorldDirection;n#include <common>nvoid main() {ntvWorldDirection = transformDirection( position, modelMatrix );nt#include <begin_vertex>nt#include <project_vertex>ntgl_Position.z = gl_Position.w;n}",cube_frag:"uniform samplerCube tCube;nuniform float tFlip;nuniform float opacity;nvarying vec3 vWorldDirection;nvoid main() {ntvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );ntgl_FragColor = texColor;ntgl_FragColor.a *= opacity;nt#include <tonemapping_fragment>nt#include <encodings_fragment>n}",depth_vert:"#include <common>n#include <uv_pars_vertex>n#include <displacementmap_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvarying vec2 vHighPrecisionZW;nvoid main() {nt#include <uv_vertex>nt#include <skinbase_vertex>nt#ifdef USE_DISPLACEMENTMAPntt#include <beginnormal_vertex>ntt#include <morphnormal_vertex>ntt#include <skinnormal_vertex>nt#endifnt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>ntvHighPrecisionZW = gl_Position.zw;n}",depth_frag:"#if DEPTH_PACKING == 3200ntuniform float opacity;n#endifn#include <common>n#include <packing>n#include <uv_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvarying vec2 vHighPrecisionZW;nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( 1.0 );nt#if DEPTH_PACKING == 3200nttdiffuseColor.a = opacity;nt#endifnt#include <map_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <logdepthbuf_fragment>ntfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;nt#if DEPTH_PACKING == 3200nttgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );nt#elif DEPTH_PACKING == 3201nttgl_FragColor = packDepthToRGBA( fragCoordZ );nt#endifn}",distanceRGBA_vert:"#define DISTANCEnvarying vec3 vWorldPosition;n#include <common>n#include <uv_pars_vertex>n#include <displacementmap_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <skinbase_vertex>nt#ifdef USE_DISPLACEMENTMAPntt#include <beginnormal_vertex>ntt#include <morphnormal_vertex>ntt#include <skinnormal_vertex>nt#endifnt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <worldpos_vertex>nt#include <clipping_planes_vertex>ntvWorldPosition = worldPosition.xyz;n}",distanceRGBA_frag:"#define DISTANCEnuniform vec3 referencePosition;nuniform float nearDistance;nuniform float farDistance;nvarying vec3 vWorldPosition;n#include <common>n#include <packing>n#include <uv_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main () {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( 1.0 );nt#include <map_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>ntfloat dist = length( vWorldPosition - referencePosition );ntdist = ( dist - nearDistance ) / ( farDistance - nearDistance );ntdist = saturate( dist );ntgl_FragColor = packDepthToRGBA( dist );n}",equirect_vert:"varying vec3 vWorldDirection;n#include <common>nvoid main() {ntvWorldDirection = transformDirection( position, modelMatrix );nt#include <begin_vertex>nt#include <project_vertex>n}",equirect_frag:"uniform sampler2D tEquirect;nvarying vec3 vWorldDirection;n#include <common>nvoid main() {ntvec3 direction = normalize( vWorldDirection );ntvec2 sampleUV = equirectUv( direction );ntgl_FragColor = texture2D( tEquirect, sampleUV );nt#include <tonemapping_fragment>nt#include <encodings_fragment>n}",linedashed_vert:"uniform float scale;nattribute float lineDistance;nvarying float vLineDistance;n#include <common>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <morphtarget_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {ntvLineDistance = scale * lineDistance;nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>nt#include <fog_vertex>n}",linedashed_frag:"uniform vec3 diffuse;nuniform float opacity;nuniform float dashSize;nuniform float totalSize;nvarying float vLineDistance;n#include <common>n#include <color_pars_fragment>n#include <fog_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntif ( mod( vLineDistance, totalSize ) > dashSize ) {nttdiscard;nt}ntvec3 outgoingLight = vec3( 0.0 );ntvec4 diffuseColor = vec4( diffuse, opacity );nt#include <logdepthbuf_fragment>nt#include <color_fragment>ntoutgoingLight = diffuseColor.rgb;nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>n}",meshbasic_vert:"#include <common>n#include <uv_pars_vertex>n#include <uv2_pars_vertex>n#include <envmap_pars_vertex>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <uv2_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )ntt#include <beginnormal_vertex>ntt#include <morphnormal_vertex>ntt#include <skinbase_vertex>ntt#include <skinnormal_vertex>ntt#include <defaultnormal_vertex>nt#endifnt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>nt#include <worldpos_vertex>nt#include <envmap_vertex>nt#include <fog_vertex>n}",meshbasic_frag:"uniform vec3 diffuse;nuniform float opacity;n#ifndef FLAT_SHADEDntvarying vec3 vNormal;n#endifn#include <common>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <uv2_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <aomap_pars_fragment>n#include <lightmap_pars_fragment>n#include <envmap_common_pars_fragment>n#include <envmap_pars_fragment>n#include <fog_pars_fragment>n#include <specularmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <specularmap_fragment>ntReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );nt#ifdef USE_LIGHTMAPnttvec4 lightMapTexel = texture2D( lightMap, vUv2 );nttreflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;nt#elsenttreflectedLight.indirectDiffuse += vec3( 1.0 );nt#endifnt#include <aomap_fragment>ntreflectedLight.indirectDiffuse *= diffuseColor.rgb;ntvec3 outgoingLight = reflectedLight.indirectDiffuse;nt#include <envmap_fragment>nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",meshlambert_vert:"#define LAMBERTnvarying vec3 vViewPosition;n#include <common>n#include <uv_pars_vertex>n#include <uv2_pars_vertex>n#include <displacementmap_pars_vertex>n#include <envmap_pars_vertex>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <shadowmap_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <uv2_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>ntvViewPosition = - mvPosition.xyz;nt#include <worldpos_vertex>nt#include <envmap_vertex>nt#include <shadowmap_vertex>nt#include <fog_vertex>n}",meshlambert_frag:"#define LAMBERTnuniform vec3 diffuse;nuniform vec3 emissive;nuniform float opacity;n#include <common>n#include <packing>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <uv2_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <aomap_pars_fragment>n#include <lightmap_pars_fragment>n#include <emissivemap_pars_fragment>n#include <envmap_common_pars_fragment>n#include <envmap_pars_fragment>n#include <fog_pars_fragment>n#include <bsdfs>n#include <lights_pars_begin>n#include <normal_pars_fragment>n#include <lights_lambert_pars_fragment>n#include <shadowmap_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <specularmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );ntReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );ntvec3 totalEmissiveRadiance = emissive;nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <specularmap_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>nt#include <emissivemap_fragment>nt#include <lights_lambert_fragment>nt#include <lights_fragment_begin>nt#include <lights_fragment_maps>nt#include <lights_fragment_end>nt#include <aomap_fragment>ntvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;nt#include <envmap_fragment>nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",meshmatcap_vert:"#define MATCAPnvarying vec3 vViewPosition;n#include <common>n#include <uv_pars_vertex>n#include <color_pars_vertex>n#include <displacementmap_pars_vertex>n#include <fog_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>nt#include <fog_vertex>ntvViewPosition = - mvPosition.xyz;n}",meshmatcap_frag:"#define MATCAPnuniform vec3 diffuse;nuniform float opacity;nuniform sampler2D matcap;nvarying vec3 vViewPosition;n#include <common>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <fog_pars_fragment>n#include <normal_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>ntvec3 viewDir = normalize( vViewPosition );ntvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );ntvec3 y = cross( viewDir, x );ntvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;nt#ifdef USE_MATCAPnttvec4 matcapColor = texture2D( matcap, uv );nt#elsenttvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );nt#endifntvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",meshnormal_vert:"#define NORMALn#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )ntvarying vec3 vViewPosition;n#endifn#include <common>n#include <uv_pars_vertex>n#include <displacementmap_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )ntvViewPosition = - mvPosition.xyz;n#endifn}",meshnormal_frag:"#define NORMALnuniform float opacity;n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )ntvarying vec3 vViewPosition;n#endifn#include <packing>n#include <uv_pars_fragment>n#include <normal_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>nt#include <logdepthbuf_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>ntgl_FragColor = vec4( packNormalToRGB( normal ), opacity );nt#ifdef OPAQUEnttgl_FragColor.a = 1.0;nt#endifn}",meshphong_vert:"#define PHONGnvarying vec3 vViewPosition;n#include <common>n#include <uv_pars_vertex>n#include <uv2_pars_vertex>n#include <displacementmap_pars_vertex>n#include <envmap_pars_vertex>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <shadowmap_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <uv2_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>ntvViewPosition = - mvPosition.xyz;nt#include <worldpos_vertex>nt#include <envmap_vertex>nt#include <shadowmap_vertex>nt#include <fog_vertex>n}",meshphong_frag:"#define PHONGnuniform vec3 diffuse;nuniform vec3 emissive;nuniform vec3 specular;nuniform float shininess;nuniform float opacity;n#include <common>n#include <packing>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <uv2_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <aomap_pars_fragment>n#include <lightmap_pars_fragment>n#include <emissivemap_pars_fragment>n#include <envmap_common_pars_fragment>n#include <envmap_pars_fragment>n#include <fog_pars_fragment>n#include <bsdfs>n#include <lights_pars_begin>n#include <normal_pars_fragment>n#include <lights_phong_pars_fragment>n#include <shadowmap_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <specularmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );ntReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );ntvec3 totalEmissiveRadiance = emissive;nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <specularmap_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>nt#include <emissivemap_fragment>nt#include <lights_phong_fragment>nt#include <lights_fragment_begin>nt#include <lights_fragment_maps>nt#include <lights_fragment_end>nt#include <aomap_fragment>ntvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;nt#include <envmap_fragment>nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",meshphysical_vert:"#define STANDARDnvarying vec3 vViewPosition;n#ifdef USE_TRANSMISSIONntvarying vec3 vWorldPosition;n#endifn#include <common>n#include <uv_pars_vertex>n#include <uv2_pars_vertex>n#include <displacementmap_pars_vertex>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <shadowmap_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <uv2_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>ntvViewPosition = - mvPosition.xyz;nt#include <worldpos_vertex>nt#include <shadowmap_vertex>nt#include <fog_vertex>n#ifdef USE_TRANSMISSIONntvWorldPosition = worldPosition.xyz;n#endifn}",meshphysical_frag:"#define STANDARDn#ifdef PHYSICALnt#define IORnt#define SPECULARn#endifnuniform vec3 diffuse;nuniform vec3 emissive;nuniform float roughness;nuniform float metalness;nuniform float opacity;n#ifdef IORntuniform float ior;n#endifn#ifdef SPECULARntuniform float specularIntensity;ntuniform vec3 specularColor;nt#ifdef USE_SPECULARINTENSITYMAPnttuniform sampler2D specularIntensityMap;nt#endifnt#ifdef USE_SPECULARCOLORMAPnttuniform sampler2D specularColorMap;nt#endifn#endifn#ifdef USE_CLEARCOATntuniform float clearcoat;ntuniform float clearcoatRoughness;n#endifn#ifdef USE_IRIDESCENCEntuniform float iridescence;ntuniform float iridescenceIOR;ntuniform float iridescenceThicknessMinimum;ntuniform float iridescenceThicknessMaximum;n#endifn#ifdef USE_SHEENntuniform vec3 sheenColor;ntuniform float sheenRoughness;nt#ifdef USE_SHEENCOLORMAPnttuniform sampler2D sheenColorMap;nt#endifnt#ifdef USE_SHEENROUGHNESSMAPnttuniform sampler2D sheenRoughnessMap;nt#endifn#endifnvarying vec3 vViewPosition;n#include <common>n#include <packing>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <uv2_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <aomap_pars_fragment>n#include <lightmap_pars_fragment>n#include <emissivemap_pars_fragment>n#include <bsdfs>n#include <iridescence_fragment>n#include <cube_uv_reflection_fragment>n#include <envmap_common_pars_fragment>n#include <envmap_physical_pars_fragment>n#include <fog_pars_fragment>n#include <lights_pars_begin>n#include <normal_pars_fragment>n#include <lights_physical_pars_fragment>n#include <transmission_pars_fragment>n#include <shadowmap_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <clearcoat_pars_fragment>n#include <iridescence_pars_fragment>n#include <roughnessmap_pars_fragment>n#include <metalnessmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );ntReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );ntvec3 totalEmissiveRadiance = emissive;nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <roughnessmap_fragment>nt#include <metalnessmap_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>nt#include <clearcoat_normal_fragment_begin>nt#include <clearcoat_normal_fragment_maps>nt#include <emissivemap_fragment>nt#include <lights_physical_fragment>nt#include <lights_fragment_begin>nt#include <lights_fragment_maps>nt#include <lights_fragment_end>nt#include <aomap_fragment>ntvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;ntvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;nt#include <transmission_fragment>ntvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;nt#ifdef USE_SHEENnttfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );nttoutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;nt#endifnt#ifdef USE_CLEARCOATnttfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );nttvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );nttoutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;nt#endifnt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",meshtoon_vert:"#define TOONnvarying vec3 vViewPosition;n#include <common>n#include <uv_pars_vertex>n#include <uv2_pars_vertex>n#include <displacementmap_pars_vertex>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <normal_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <shadowmap_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>nt#include <uv2_vertex>nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <normal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <displacementmap_vertex>nt#include <project_vertex>nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>ntvViewPosition = - mvPosition.xyz;nt#include <worldpos_vertex>nt#include <shadowmap_vertex>nt#include <fog_vertex>n}",meshtoon_frag:"#define TOONnuniform vec3 diffuse;nuniform vec3 emissive;nuniform float opacity;n#include <common>n#include <packing>n#include <dithering_pars_fragment>n#include <color_pars_fragment>n#include <uv_pars_fragment>n#include <uv2_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <aomap_pars_fragment>n#include <lightmap_pars_fragment>n#include <emissivemap_pars_fragment>n#include <gradientmap_pars_fragment>n#include <fog_pars_fragment>n#include <bsdfs>n#include <lights_pars_begin>n#include <normal_pars_fragment>n#include <lights_toon_pars_fragment>n#include <shadowmap_pars_fragment>n#include <bumpmap_pars_fragment>n#include <normalmap_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec4 diffuseColor = vec4( diffuse, opacity );ntReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );ntvec3 totalEmissiveRadiance = emissive;nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <color_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>nt#include <normal_fragment_begin>nt#include <normal_fragment_maps>nt#include <emissivemap_fragment>nt#include <lights_toon_fragment>nt#include <lights_fragment_begin>nt#include <lights_fragment_maps>nt#include <lights_fragment_end>nt#include <aomap_fragment>ntvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>nt#include <dithering_fragment>n}",points_vert:"uniform float size;nuniform float scale;n#include <common>n#include <color_pars_vertex>n#include <fog_pars_vertex>n#include <morphtarget_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <color_vertex>nt#include <morphcolor_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <project_vertex>ntgl_PointSize = size;nt#ifdef USE_SIZEATTENUATIONnttbool isPerspective = isPerspectiveMatrix( projectionMatrix );nttif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );nt#endifnt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>nt#include <worldpos_vertex>nt#include <fog_vertex>n}",points_frag:"uniform vec3 diffuse;nuniform float opacity;n#include <common>n#include <color_pars_fragment>n#include <map_particle_pars_fragment>n#include <alphatest_pars_fragment>n#include <fog_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec3 outgoingLight = vec3( 0.0 );ntvec4 diffuseColor = vec4( diffuse, opacity );nt#include <logdepthbuf_fragment>nt#include <map_particle_fragment>nt#include <color_fragment>nt#include <alphatest_fragment>ntoutgoingLight = diffuseColor.rgb;nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>nt#include <premultiplied_alpha_fragment>n}",shadow_vert:"#include <common>n#include <fog_pars_vertex>n#include <morphtarget_pars_vertex>n#include <skinning_pars_vertex>n#include <shadowmap_pars_vertex>nvoid main() {nt#include <beginnormal_vertex>nt#include <morphnormal_vertex>nt#include <skinbase_vertex>nt#include <skinnormal_vertex>nt#include <defaultnormal_vertex>nt#include <begin_vertex>nt#include <morphtarget_vertex>nt#include <skinning_vertex>nt#include <project_vertex>nt#include <worldpos_vertex>nt#include <shadowmap_vertex>nt#include <fog_vertex>n}",shadow_frag:"uniform vec3 color;nuniform float opacity;n#include <common>n#include <packing>n#include <fog_pars_fragment>n#include <bsdfs>n#include <lights_pars_begin>n#include <shadowmap_pars_fragment>n#include <shadowmask_pars_fragment>nvoid main() {ntgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>n}",sprite_vert:"uniform float rotation;nuniform vec2 center;n#include <common>n#include <uv_pars_vertex>n#include <fog_pars_vertex>n#include <logdepthbuf_pars_vertex>n#include <clipping_planes_pars_vertex>nvoid main() {nt#include <uv_vertex>ntvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );ntvec2 scale;ntscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );ntscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );nt#ifndef USE_SIZEATTENUATIONnttbool isPerspective = isPerspectiveMatrix( projectionMatrix );nttif ( isPerspective ) scale *= - mvPosition.z;nt#endifntvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;ntvec2 rotatedPosition;ntrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;ntrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;ntmvPosition.xy += rotatedPosition;ntgl_Position = projectionMatrix * mvPosition;nt#include <logdepthbuf_vertex>nt#include <clipping_planes_vertex>nt#include <fog_vertex>n}",sprite_frag:"uniform vec3 diffuse;nuniform float opacity;n#include <common>n#include <uv_pars_fragment>n#include <map_pars_fragment>n#include <alphamap_pars_fragment>n#include <alphatest_pars_fragment>n#include <fog_pars_fragment>n#include <logdepthbuf_pars_fragment>n#include <clipping_planes_pars_fragment>nvoid main() {nt#include <clipping_planes_fragment>ntvec3 outgoingLight = vec3( 0.0 );ntvec4 diffuseColor = vec4( diffuse, opacity );nt#include <logdepthbuf_fragment>nt#include <map_fragment>nt#include <alphamap_fragment>nt#include <alphatest_fragment>ntoutgoingLight = diffuseColor.rgb;nt#include <output_fragment>nt#include <tonemapping_fragment>nt#include <encodings_fragment>nt#include <fog_fragment>n}"},bn={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Dt},uv2Transform:{value:new Dt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new It(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Dt}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new It(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Dt}}},Sn={basic:{uniforms:tn([bn.common,bn.specularmap,bn.envmap,bn.aomap,bn.lightmap,bn.fog]),vertexShader:Mn.meshbasic_vert,fragmentShader:Mn.meshbasic_frag},lambert:{uniforms:tn([bn.common,bn.specularmap,bn.envmap,bn.aomap,bn.lightmap,bn.emissivemap,bn.bumpmap,bn.normalmap,bn.displacementmap,bn.fog,bn.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Mn.meshlambert_vert,fragmentShader:Mn.meshlambert_frag},phong:{uniforms:tn([bn.common,bn.specularmap,bn.envmap,bn.aomap,bn.lightmap,bn.emissivemap,bn.bumpmap,bn.normalmap,bn.displacementmap,bn.fog,bn.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:Mn.meshphong_vert,fragmentShader:Mn.meshphong_frag},standard:{uniforms:tn([bn.common,bn.envmap,bn.aomap,bn.lightmap,bn.emissivemap,bn.bumpmap,bn.normalmap,bn.displacementmap,bn.roughnessmap,bn.metalnessmap,bn.fog,bn.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mn.meshphysical_vert,fragmentShader:Mn.meshphysical_frag},toon:{uniforms:tn([bn.common,bn.aomap,bn.lightmap,bn.emissivemap,bn.bumpmap,bn.normalmap,bn.displacementmap,bn.gradientmap,bn.fog,bn.lights,{emissive:{value:new Zt(0)}}]),vertexShader:Mn.meshtoon_vert,fragmentShader:Mn.meshtoon_frag},matcap:{uniforms:tn([bn.common,bn.bumpmap,bn.normalmap,bn.displacementmap,bn.fog,{matcap:{value:null}}]),vertexShader:Mn.meshmatcap_vert,fragmentShader:Mn.meshmatcap_frag},points:{uniforms:tn([bn.points,bn.fog]),vertexShader:Mn.points_vert,fragmentShader:Mn.points_frag},dashed:{uniforms:tn([bn.common,bn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mn.linedashed_vert,fragmentShader:Mn.linedashed_frag},depth:{uniforms:tn([bn.common,bn.displacementmap]),vertexShader:Mn.depth_vert,fragmentShader:Mn.depth_frag},normal:{uniforms:tn([bn.common,bn.bumpmap,bn.normalmap,bn.displacementmap,{opacity:{value:1}}]),vertexShader:Mn.meshnormal_vert,fragmentShader:Mn.meshnormal_frag},sprite:{uniforms:tn([bn.sprite,bn.fog]),vertexShader:Mn.sprite_vert,fragmentShader:Mn.sprite_frag},background:{uniforms:{uvTransform:{value:new Dt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mn.background_vert,fragmentShader:Mn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Mn.backgroundCube_vert,fragmentShader:Mn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mn.cube_vert,fragmentShader:Mn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mn.equirect_vert,fragmentShader:Mn.equirect_frag},distanceRGBA:{uniforms:tn([bn.common,bn.displacementmap,{referencePosition:{value:new oe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mn.distanceRGBA_vert,fragmentShader:Mn.distanceRGBA_frag},shadow:{uniforms:tn([bn.lights,bn.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:Mn.shadow_vert,fragmentShader:Mn.shadow_frag}};Sn.physical={uniforms:tn([Sn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new It(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new It},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Mn.meshphysical_vert,fragmentShader:Mn.meshphysical_frag};const wn={r:0,b:0,g:0};function Tn(t,e,i,n,r,s,a){const o=new Zt(0);let c,h,u=!0===s?0:1,d=null,p=0,m=null;function f(e,i){e.getRGB(wn,en(t)),n.buffers.color.setClear(wn.r,wn.g,wn.b,i,a)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),u=e,f(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(t){u=t,f(o,u)},render:function(n,s){let a=!1,g=!0===s.isScene?s.background:null;if(g&&g.isTexture){g=(s.backgroundBlurriness>0?i:e).get(g)}const v=t.xr,x=v.getSession&&v.getSession();x&&"additive"===x.environmentBlendMode&&(g=null),null===g?f(o,u):g&&g.isColor&&(f(g,1),a=!0),(t.autoClear||a)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),g&&(g.isCubeTexture||g.mapping===l)?(void 0===h&&(h=new Ji(new $i(1,1,1),new rn({name:"BackgroundCubeMaterial",uniforms:Qi(Sn.backgroundCube.uniforms),vertexShader:Sn.backgroundCube.vertexShader,fragmentShader:Sn.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=g,h.material.uniforms.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=s.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=s.backgroundIntensity,h.material.toneMapped=g.encoding!==ht,d===g&&p===g.version&&m===t.toneMapping||(h.material.needsUpdate=!0,d=g,p=g.version,m=t.toneMapping),h.layers.enableAll(),n.unshift(h,h.geometry,h.material,0,0,null)):g&&g.isTexture&&(void 0===c&&(c=new Ji(new yn(2,2),new rn({name:"BackgroundMaterial",uniforms:Qi(Sn.background.uniforms),vertexShader:Sn.background.vertexShader,fragmentShader:Sn.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=g,c.material.uniforms.backgroundIntensity.value=s.backgroundIntensity,c.material.toneMapped=g.encoding!==ht,!0===g.matrixAutoUpdate&&g.updateMatrix(),c.material.uniforms.uvTransform.value.copy(g.matrix),d===g&&p===g.version&&m===t.toneMapping||(c.material.needsUpdate=!0,d=g,p=g.version,m=t.toneMapping),c.layers.enableAll(),n.unshift(c,c.geometry,c.material,0,0,null))}}}function An(t,e,i,n){const r=t.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(e){return n.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function d(e){return n.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let t=0;t<r;t++)e[t]=0,i[t]=0,n[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function m(){const t=c.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){g(t,0)}function g(i,r){const s=c.newAttributes,a=c.enabledAttributes,o=c.attributeDivisors;if(s[i]=1,0===a[i]&&(t.enableVertexAttribArray(i),a[i]=1),o[i]!==r){(n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),o[i]=r}}function v(){const e=c.newAttributes,i=c.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function x(e,i,r,s,a,o){!0!==n.isWebGL2||5124!==r&&5125!==r?t.vertexAttribPointer(e,i,r,s,a,o):t.vertexAttribIPointer(e,i,r,a,o)}function _(){y(),h=!0,c!==l&&(c=l,u(c.object))}function y(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,_,y){let M=!1;if(a){const e=function(e,i,r){const a=!0===r.wireframe;let l=o[e.id];void 0===l&&(l={},o[e.id]=l);let c=l[i.id];void 0===c&&(c={},l[i.id]=c);let h=c[a];void 0===h&&(h=p(n.isWebGL2?t.createVertexArray():s.createVertexArrayOES()),c[a]=h);return h}(_,d,l);c!==e&&(c=e,u(c.object)),M=function(t,e,i,n){const r=c.attributes,s=e.attributes;let a=0;const o=i.getAttributes();for(const e in o){if(o[e].location>=0){const i=r[e];let n=s[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;a++}}return c.attributesNum!==a||c.index!==n}(r,_,d,y),M&&function(t,e,i,n){const r={},s=e.attributes;let a=0;const o=i.getAttributes();for(const e in o){if(o[e].location>=0){let i=s[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,a++}}c.attributes=r,c.attributesNum=a,c.index=n}(r,_,d,y)}else{const t=!0===l.wireframe;c.geometry===_.id&&c.program===d.id&&c.wireframe===t||(c.geometry=_.id,c.program=d.id,c.wireframe=t,M=!0)}null!==y&&i.update(y,34963),(M||h)&&(h=!1,function(r,s,a,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const e in c){const n=c[e];if(n.location>=0){let s=l[e];if(void 0===s&&("instanceMatrix"===e&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===e&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const e=s.normalized,a=s.itemSize,l=i.get(s);if(void 0===l)continue;const c=l.buffer,h=l.type,u=l.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,l=i.stride,d=s.offset;if(i.isInstancedInterleavedBuffer){for(let t=0;t<n.locationSize;t++)g(n.location+t,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let t=0;t<n.locationSize;t++)f(n.location+t);t.bindBuffer(34962,c);for(let t=0;t<n.locationSize;t++)x(n.location+t,a/n.locationSize,h,e,l*u,(d+a/n.locationSize*t)*u)}else{if(s.isInstancedBufferAttribute){for(let t=0;t<n.locationSize;t++)g(n.location+t,s.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let t=0;t<n.locationSize;t++)f(n.location+t);t.bindBuffer(34962,c);for(let t=0;t<n.locationSize;t++)x(n.location+t,a/n.locationSize,h,e,a*u,a/n.locationSize*t*u)}}else if(void 0!==h){const i=h[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(n.location,i);break;case 3:t.vertexAttrib3fv(n.location,i);break;case 4:t.vertexAttrib4fv(n.location,i);break;default:t.vertexAttrib1fv(n.location,i)}}}}v()}(r,l,d,_),null!==y&&t.bindBuffer(34963,i.get(y).buffer))},reset:_,resetDefaultState:y,dispose:function(){_();for(const t in o){const e=o[t];for(const t in e){const i=e[t];for(const t in i)d(i[t].object),delete i[t];delete e[t]}delete o[t]}},releaseStatesOfGeometry:function(t){if(void 0===o[t.id])return;const e=o[t.id];for(const t in e){const i=e[t];for(const t in i)d(i[t].object),delete i[t];delete e[t]}delete o[t.id]},releaseStatesOfProgram:function(t){for(const e in o){const i=o[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)d(n[t].object),delete n[t];delete i[t.id]}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:v}}function En(t,e,i,n){const r=n.isWebGL2;let s;this.setMode=function(t){s=t},this.render=function(e,n){t.drawArrays(s,e,n),i.update(n,s,1)},this.renderInstances=function(n,a,o){if(0===o)return;let l,c;if(r)l=t,c="drawArraysInstanced";else if(l=e.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](s,n,a,o),i.update(a,s,o)}}function Cn(t,e,i){let n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||e.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=t.getParameter(34930),u=t.getParameter(35660),d=t.getParameter(3379),p=t.getParameter(34076),m=t.getParameter(34921),f=t.getParameter(36347),g=t.getParameter(36348),v=t.getParameter(36349),x=u>0,_=s||e.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:x,floatFragmentTextures:_,floatVertexTextures:x&&_,maxSamples:s?t.getParameter(36183):0}}function Ln(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new mn,o=new Dt,l={value:null,needsUpdate:!1};function c(t,i,n,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<e)&&(c=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(c,i),c[i+3]=a.constant}l.value=c,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=c(t,e,0)},this.setState=function(a,o,h){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,m=t.get(a);if(!r||null===u||0===u.length||s&&!p)s?c(null):function(){l.value!==i&&(l.value=i,l.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=m.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=i[t];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Rn(t){let e=new WeakMap;function i(t,e){return e===a?t.mapping=r:e===o&&(t.mapping=s),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===a||s===o){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new hn(s.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class Pn extends sn{constructor(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const In=[.125,.215,.35,.446,.526,.582],Dn=20,Nn=new Pn,On=new Zt;let zn=null;const Un=(1+Math.sqrt(5))/2,Bn=1/Un,Fn=[new oe(1,1,1),new oe(-1,1,1),new oe(1,1,-1),new oe(-1,1,-1),new oe(0,Un,Bn),new oe(0,Un,-Bn),new oe(Bn,0,Un),new oe(-Bn,0,Un),new oe(Un,Bn,0),new oe(-Un,Bn,0)];class kn{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){zn=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Wn(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Hn(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(zn),t.scissorTest=!1,Vn(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===r||t.mapping===s?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),zn=this._renderer.getRenderTarget();const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:f,minFilter:f,generateMipmaps:!1,type:b,format:w,encoding:ct,depthBuffer:!1},n=Gn(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Gn(t,e,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+In.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);i.push(s);let o=1/s;a>t-4?o=In[a-t+4-1]:0===a&&(o=0),n.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*d),x=new Float32Array(f*p*d),_=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];v.set(n,m*p*t),x.set(u,f*p*t);const r=[t,t,t,t,t,t];_.set(r,g*p*t)}const y=new zi;y.setAttribute("position",new Ti(v,m)),y.setAttribute("uv",new Ti(x,f)),y.setAttribute("faceIndex",new Ti(_,g)),e.push(y),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Dn),r=new oe(0,1,0),s=new rn({name:"SphericalGaussianBlur",defines:{n:Dn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:jn(),fragmentShader:"nntttprecision mediump float;ntttprecision mediump int;nntttvarying vec3 vOutputDirection;nntttuniform sampler2D envMap;ntttuniform int samples;ntttuniform float weights[ n ];ntttuniform bool latitudinal;ntttuniform float dTheta;ntttuniform float mipInt;ntttuniform vec3 poleAxis;nnttt#define ENVMAP_TYPE_CUBE_UVnttt#include <cube_uv_reflection_fragment>nntttvec3 getSample( float theta, vec3 axis ) {nnttttfloat cosTheta = cos( theta );ntttt// Rodrigues' axis-angle rotationnttttvec3 sampleDirection = vOutputDirection * cosThetanttttt+ cross( axis, vOutputDirection ) * sin( theta )nttttt+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );nnttttreturn bilinearCubeUV( envMap, sampleDirection, mipInt );nnttt}nntttvoid main() {nnttttvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );nnttttif ( all( equal( axis, vec3( 0.0 ) ) ) ) {nntttttaxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );nntttt}nnttttaxis = normalize( axis );nnttttgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );nttttgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );nnttttfor ( int i = 1; i < n; i++ ) {nntttttif ( i >= samples ) {nnttttttbreak;nnttttt}nntttttfloat theta = dTheta * float( i );ntttttgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );ntttttgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );nntttt}nnttt}ntt",blending:0,depthTest:!1,depthWrite:!1});return s}(n,t,e)}return n}_compileMaterial(t){const e=new Ji(this._lodPlanes[0],t);this._renderer.compile(e,Nn)}_sceneToCubeUV(t,e,i,n){const r=new an(90,1,e,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(On),o.toneMapping=0,o.autoClear=!1;const h=new bi({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new Ji(new $i,h);let d=!1;const p=t.background;p?p.isColor&&(h.color.copy(p),t.background=null,d=!0):(h.color.copy(On),d=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===i?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;Vn(n,i*l,e>2?l:0,l,l),o.setRenderTarget(n),d&&o.render(u,r),o.render(t,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,t.background=p}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===r||t.mapping===s;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Wn()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Hn());const a=n?this._cubemapMaterial:this._equirectMaterial,o=new Ji(this._lodPlanes[0],a);a.uniforms.envMap.value=t;const l=this._cubeSize;Vn(e,0,0,3*l,2*l),i.setRenderTarget(e),i.render(o,Nn)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;e<this._lodPlanes.length;e++){const i=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),n=Fn[(e-1)%Fn.length];this._blur(t,e-1,e,i,n)}e.autoClear=i}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new Ji(this._lodPlanes[n],l),h=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):Dn;m>Dn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let t=0;t<Dn;++t){const e=t/p,i=Math.exp(-e*e/2);f.push(i),0===t?g+=i:t<m&&(g+=2*i)}for(let t=0;t<f.length;t++)f[t]=f[t]/g;h.envMap.value=t.texture,h.samples.value=m,h.weights.value=f,h.latitudinal.value="latitudinal"===s,a&&(h.poleAxis.value=a);const{_lodMax:v}=this;h.dTheta.value=d,h.mipInt.value=v-i;const x=this._sizeLods[n];Vn(e,3*x*(n>v-4?n-v+4:0),4*(this._cubeSize-x),3*x,2*x),o.setRenderTarget(e),o.render(c,Nn)}}function Gn(t,e,i){const n=new ne(t,e,i);return n.texture.mapping=l,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Vn(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function Hn(){return new rn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:jn(),fragmentShader:"nntttprecision mediump float;ntttprecision mediump int;nntttvarying vec3 vOutputDirection;nntttuniform sampler2D envMap;nnttt#include <common>nntttvoid main() {nnttttvec3 outputDirection = normalize( vOutputDirection );nttttvec2 uv = equirectUv( outputDirection );nnttttgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );nnttt}ntt",blending:0,depthTest:!1,depthWrite:!1})}function Wn(){return new rn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jn(),fragmentShader:"nntttprecision mediump float;ntttprecision mediump int;nntttuniform float flipEnvMap;nntttvarying vec3 vOutputDirection;nntttuniform samplerCube envMap;nntttvoid main() {nnttttgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );nnttt}ntt",blending:0,depthTest:!1,depthWrite:!1})}function jn(){return"nnttprecision mediump float;nttprecision mediump int;nnttattribute float faceIndex;nnttvarying vec3 vOutputDirection;nntt// RH coordinate system; PMREM face-indexing conventionnttvec3 getDirection( vec2 uv, float face ) {nntttuv = 2.0 * uv - 1.0;nntttvec3 direction = vec3( uv, 1.0 );nntttif ( face == 0.0 ) {nnttttdirection = direction.zyx; // ( 1, v, u ) pos xnnttt} else if ( face == 1.0 ) {nnttttdirection = direction.xzy;nttttdirection.xz *= -1.0; // ( -u, 1, -v ) pos ynnttt} else if ( face == 2.0 ) {nnttttdirection.x *= -1.0; // ( -u, v, 1 ) pos znnttt} else if ( face == 3.0 ) {nnttttdirection = direction.zyx;nttttdirection.xz *= -1.0; // ( -1, v, -u ) neg xnnttt} else if ( face == 4.0 ) {nnttttdirection = direction.xzy;nttttdirection.xy *= -1.0; // ( -u, -1, v ) neg ynnttt} else if ( face == 5.0 ) {nnttttdirection.z *= -1.0; // ( u, v, -1 ) neg znnttt}nntttreturn direction;nntt}nnttvoid main() {nntttvOutputDirection = getDirection( uv, faceIndex );ntttgl_Position = vec4( position, 1.0 );nntt}nt"}function qn(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(l){if(l&&l.isTexture){const c=l.mapping,h=c===a||c===o,u=c===r||c===s;if(h||u){if(l.isRenderTargetTexture&&!0===l.needsPMREMUpdate){l.needsPMREMUpdate=!1;let n=e.get(l);return null===i&&(i=new kn(t)),n=h?i.fromEquirectangular(l,n):i.fromCubemap(l,n),e.set(l,n),n.texture}if(e.has(l))return e.get(l).texture;{const r=l.image;if(h&&r&&r.height>0||u&&r&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(r)){null===i&&(i=new kn(t));const r=h?i.fromEquirectangular(l):i.fromCubemap(l);return e.set(l,r),l.addEventListener("dispose",n),r.texture}return null}}}return l},dispose:function(){e=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Xn(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Yn(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const o=new(Ot(i)?Ei:Ai)(i,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(t){const i=t.attributes;for(const t in i)e.update(i[t],34962);const n=t.morphAttributes;for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t++)e.update(i[t],34962)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function Zn(t,e,i,n){const r=n.isWebGL2;let s,a,o;this.setMode=function(t){s=t},this.setIndex=function(t){a=t.type,o=t.bytesPerElement},this.render=function(e,n){t.drawElements(s,n,a,e*o),i.update(n,s,1)},this.renderInstances=function(n,l,c){if(0===c)return;let h,u;if(r)h=t,u="drawElementsInstanced";else if(h=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[u](s,l,a,n*o,c),i.update(l,s,c)}}function Jn(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,i,n){switch(e.calls++,i){case 4:e.triangles+=n*(t/3);break;case 1:e.lines+=n*(t/2);break;case 3:e.lines+=n*(t-1);break;case 2:e.lines+=n*t;break;case 0:e.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function Kn(t,e){return t[0]-e[0]}function $n(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Qn(t,e,i){const n={},r=new Float32Array(8),s=new WeakMap,a=new ie,o=[];for(let t=0;t<8;t++)o[t]=[t,0];return{update:function(l,c,h,u){const d=l.morphTargetInfluences;if(!0===e.isWebGL2){const p=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,m=void 0!==p?p.length:0;let f=s.get(c);if(void 0===f||f.count!==m){void 0!==f&&f.texture.dispose();const x=void 0!==c.morphAttributes.position,_=void 0!==c.morphAttributes.normal,y=void 0!==c.morphAttributes.color,b=c.morphAttributes.position||[],S=c.morphAttributes.normal||[],w=c.morphAttributes.color||[];let T=0;!0===x&&(T=1),!0===_&&(T=2),!0===y&&(T=3);let A=c.attributes.position.count*T,E=1;A>e.maxTextureSize&&(E=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const C=new Float32Array(A*E*4*m),L=new re(C,A,E,m);L.type=M,L.needsUpdate=!0;const R=4*T;for(let I=0;I<m;I++){const D=b[I],N=S[I],O=w[I],z=A*E*4*I;for(let U=0;U<D.count;U++){const B=U*R;!0===x&&(a.fromBufferAttribute(D,U),C[z+B+0]=a.x,C[z+B+1]=a.y,C[z+B+2]=a.z,C[z+B+3]=0),!0===_&&(a.fromBufferAttribute(N,U),C[z+B+4]=a.x,C[z+B+5]=a.y,C[z+B+6]=a.z,C[z+B+7]=0),!0===y&&(a.fromBufferAttribute(O,U),C[z+B+8]=a.x,C[z+B+9]=a.y,C[z+B+10]=a.z,C[z+B+11]=4===O.itemSize?a.w:1)}}function P(){L.dispose(),s.delete(c),c.removeEventListener("dispose",P)}f={count:m,texture:L,size:new It(A,E)},s.set(c,f),c.addEventListener("dispose",P)}let g=0;for(let F=0;F<d.length;F++)g+=d[F];const v=c.morphTargetsRelative?1:1-g;u.getUniforms().setValue(t,"morphTargetBaseInfluence",v),u.getUniforms().setValue(t,"morphTargetInfluences",d),u.getUniforms().setValue(t,"morphTargetsTexture",f.texture,i),u.getUniforms().setValue(t,"morphTargetsTextureSize",f.size)}else{const k=void 0===d?0:d.length;let G=n[c.id];if(void 0===G||G.length!==k){G=[];for(let q=0;q<k;q++)G[q]=[q,0];n[c.id]=G}for(let X=0;X<k;X++){const Y=G[X];Y[0]=X,Y[1]=d[X]}G.sort($n);for(let Z=0;Z<8;Z++)Z<k&&G[Z][1]?(o[Z][0]=G[Z][0],o[Z][1]=G[Z][1]):(o[Z][0]=Number.MAX_SAFE_INTEGER,o[Z][1]=0);o.sort(Kn);const V=c.morphAttributes.position,H=c.morphAttributes.normal;let W=0;for(let J=0;J<8;J++){const K=o[J],$=K[0],Q=K[1];$!==Number.MAX_SAFE_INTEGER&&Q?(V&&c.getAttribute("morphTarget"+J)!==V[$]&&c.setAttribute("morphTarget"+J,V[$]),H&&c.getAttribute("morphNormal"+J)!==H[$]&&c.setAttribute("morphNormal"+J,H[$]),r[J]=Q,W+=Q):(V&&!0===c.hasAttribute("morphTarget"+J)&&c.deleteAttribute("morphTarget"+J),H&&!0===c.hasAttribute("morphNormal"+J)&&c.deleteAttribute("morphNormal"+J),r[J]=0)}const j=c.morphTargetsRelative?1:1-W;u.getUniforms().setValue(t,"morphTargetBaseInfluence",j),u.getUniforms().setValue(t,"morphTargetInfluences",r)}}}}function tr(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(t){const a=n.render.frame,o=t.geometry,l=e.get(t,o);return r.get(l)!==a&&(e.update(l),r.set(l,a)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",s)&&t.addEventListener("dispose",s),i.update(t.instanceMatrix,34962),null!==t.instanceColor&&i.update(t.instanceColor,34962)),l},dispose:function(){r=new WeakMap}}}const er=new ee,ir=new re,nr=new se,rr=new cn,sr=[],ar=[],or=new Float32Array(16),lr=new Float32Array(9),cr=new Float32Array(4);function hr(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=sr[r];if(void 0===s&&(s=new Float32Array(r),sr[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function ur(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function dr(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function pr(t,e){let i=ar[e];void 0===i&&(i=new Int32Array(e),ar[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function mr(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function fr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(ur(i,e))return;t.uniform2fv(this.addr,e),dr(i,e)}}function gr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(ur(i,e))return;t.uniform3fv(this.addr,e),dr(i,e)}}function vr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(ur(i,e))return;t.uniform4fv(this.addr,e),dr(i,e)}}function xr(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ur(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),dr(i,e)}else{if(ur(i,n))return;cr.set(n),t.uniformMatrix2fv(this.addr,!1,cr),dr(i,n)}}function _r(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ur(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),dr(i,e)}else{if(ur(i,n))return;lr.set(n),t.uniformMatrix3fv(this.addr,!1,lr),dr(i,n)}}function yr(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(ur(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),dr(i,e)}else{if(ur(i,n))return;or.set(n),t.uniformMatrix4fv(this.addr,!1,or),dr(i,n)}}function Mr(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function br(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(ur(i,e))return;t.uniform2iv(this.addr,e),dr(i,e)}}function Sr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(ur(i,e))return;t.uniform3iv(this.addr,e),dr(i,e)}}function wr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(ur(i,e))return;t.uniform4iv(this.addr,e),dr(i,e)}}function Tr(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Ar(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(ur(i,e))return;t.uniform2uiv(this.addr,e),dr(i,e)}}function Er(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(ur(i,e))return;t.uniform3uiv(this.addr,e),dr(i,e)}}function Cr(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(ur(i,e))return;t.uniform4uiv(this.addr,e),dr(i,e)}}function Lr(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2D(e||er,r)}function Rr(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||nr,r)}function Pr(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||rr,r)}function Ir(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||ir,r)}function Dr(t,e){t.uniform1fv(this.addr,e)}function Nr(t,e){const i=hr(e,this.size,2);t.uniform2fv(this.addr,i)}function Or(t,e){const i=hr(e,this.size,3);t.uniform3fv(this.addr,i)}function zr(t,e){const i=hr(e,this.size,4);t.uniform4fv(this.addr,i)}function Ur(t,e){const i=hr(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Br(t,e){const i=hr(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Fr(t,e){const i=hr(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function kr(t,e){t.uniform1iv(this.addr,e)}function Gr(t,e){t.uniform2iv(this.addr,e)}function Vr(t,e){t.uniform3iv(this.addr,e)}function Hr(t,e){t.uniform4iv(this.addr,e)}function Wr(t,e){t.uniform1uiv(this.addr,e)}function jr(t,e){t.uniform2uiv(this.addr,e)}function qr(t,e){t.uniform3uiv(this.addr,e)}function Xr(t,e){t.uniform4uiv(this.addr,e)}function Yr(t,e,i){const n=this.cache,r=e.length,s=pr(i,r);ur(n,s)||(t.uniform1iv(this.addr,s),dr(n,s));for(let t=0;t!==r;++t)i.setTexture2D(e[t]||er,s[t])}function Zr(t,e,i){const n=this.cache,r=e.length,s=pr(i,r);ur(n,s)||(t.uniform1iv(this.addr,s),dr(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||nr,s[t])}function Jr(t,e,i){const n=this.cache,r=e.length,s=pr(i,r);ur(n,s)||(t.uniform1iv(this.addr,s),dr(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||rr,s[t])}function Kr(t,e,i){const n=this.cache,r=e.length,s=pr(i,r);ur(n,s)||(t.uniform1iv(this.addr,s),dr(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||ir,s[t])}class $r{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return mr;case 35664:return fr;case 35665:return gr;case 35666:return vr;case 35674:return xr;case 35675:return _r;case 35676:return yr;case 5124:case 35670:return Mr;case 35667:case 35671:return br;case 35668:case 35672:return Sr;case 35669:case 35673:return wr;case 5125:return Tr;case 36294:return Ar;case 36295:return Er;case 36296:return Cr;case 35678:case 36198:case 36298:case 36306:case 35682:return Lr;case 35679:case 36299:case 36307:return Rr;case 35680:case 36300:case 36308:case 36293:return Pr;case 36289:case 36303:case 36311:case 36292:return Ir}}(e.type)}}class Qr{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Dr;case 35664:return Nr;case 35665:return Or;case 35666:return zr;case 35674:return Ur;case 35675:return Br;case 35676:return Fr;case 5124:case 35670:return kr;case 35667:case 35671:return Gr;case 35668:case 35672:return Vr;case 35669:case 35673:return Hr;case 5125:return Wr;case 36294:return jr;case 36295:return qr;case 36296:return Xr;case 35678:case 36198:case 36298:case 36306:case 35682:return Yr;case 35679:case 36299:case 36307:return Zr;case 35680:case 36300:case 36308:case 36293:return Jr;case 36289:case 36303:case 36311:case 36292:return Kr}}(e.type)}}class ts{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const es=/(w+)(])?([|.)?/g;function is(t,e){t.seq.push(e),t.map[e.id]=e}function ns(t,e,i){const n=t.name,r=n.length;for(es.lastIndex=0;;){const s=es.exec(n),a=es.lastIndex;let o=s[1];const l="]"===s[2],c=s[3];if(l&&(o|=0),void 0===c||"["===c&&a+2===r){is(i,void 0===c?new $r(o,t,e):new Qr(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new ts(o),is(i,t)),i=t}}}class rs{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,35718);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);ns(i,t.getUniformLocation(e,i.name),this)}}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function ss(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let as=0;function os(t,e,i){const n=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";const s=/ERROR: 0:(d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"nn"+r+"nn"+function(t,e){const i=t.split("n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("n")}(t.getShaderSource(e),n)}return r}function ls(t,e){const i=function(t){switch(t){case ct:return["Linear","( value )"];case ht:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function cs(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function hs(t){return""!==t}function us(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ds(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ps=/^[ t]*#include +<([wd./]+)>/gm;function ms(t){return t.replace(ps,fs)}function fs(t,e){const i=Mn[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ms(i)}const gs=/#pragma unroll_loop_starts+fors*(s*ints+is*=s*(d+)s*;s*is*<s*(d+)s*;s*is*++s*)s*{([sS]+?)}s+#pragma unroll_loop_end/g;function vs(t){return t.replace(gs,xs)}function xs(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/[s*is*]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function _s(t){let e="precision "+t.precision+" float;nprecision "+t.precision+" int;";return"highp"===t.precision?e+="n#define HIGH_PRECISION":"mediump"===t.precision?e+="n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="n#define LOW_PRECISION"),e}function ys(t,e,i,n){const a=t.getContext(),o=i.defines;let c=i.vertexShader,h=i.fragmentShader;const u=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),d=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case r:case s:e="ENVMAP_TYPE_CUBE";break;case l:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),p=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===s&&(e="ENVMAP_MODE_REFRACTION");return e}(i),m=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),f=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),g=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(hs).join("n")}(i),v=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("n")}(o),x=a.createProgram();let _,y,M=i.glslVersion?"#version "+i.glslVersion+"n":"";i.isRawShaderMaterial?(_=[v].filter(hs).join("n"),_.length>0&&(_+="n"),y=[g,v].filter(hs).join("n"),y.length>0&&(y+="n")):(_=[_s(i),"#define SHADER_NAME "+i.shaderName,v,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+p:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","tattribute vec4 color;","#elif defined( USE_COLOR )","tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","tattribute vec3 morphTarget0;","tattribute vec3 morphTarget1;","tattribute vec3 morphTarget2;","tattribute vec3 morphTarget3;","t#ifdef USE_MORPHNORMALS","ttattribute vec3 morphNormal0;","ttattribute vec3 morphNormal1;","ttattribute vec3 morphNormal2;","ttattribute vec3 morphNormal3;","t#else","ttattribute vec3 morphTarget4;","ttattribute vec3 morphTarget5;","ttattribute vec3 morphTarget6;","ttattribute vec3 morphTarget7;","t#endif","#endif","#ifdef USE_SKINNING","tattribute vec4 skinIndex;","tattribute vec4 skinWeight;","#endif","n"].filter(hs).join("n"),y=[g,_s(i),"#define SHADER_NAME "+i.shaderName,v,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+p:"",i.envMap?"#define "+m:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Mn.tonemapping_pars_fragment:"",0!==i.toneMapping?cs("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Mn.encodings_pars_fragment,ls("linearToOutputTexel",i.outputEncoding),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","n"].filter(hs).join("n")),c=ms(c),c=us(c,i),c=ds(c,i),h=ms(h),h=us(h,i),h=ds(h,i),c=vs(c),h=vs(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(M="#version 300 esn",_=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("n")+"n"+_,y=["#define varying in",i.glslVersion===ft?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===ft?"":"#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("n")+"n"+y);const b=M+y+h,S=ss(a,35633,M+_+c),w=ss(a,35632,b);if(a.attachShader(x,S),a.attachShader(x,w),void 0!==i.index0AttributeName?a.bindAttribLocation(x,0,i.index0AttributeName):!0===i.morphTargets&&a.bindAttribLocation(x,0,"position"),a.linkProgram(x),t.debug.checkShaderErrors){const t=a.getProgramInfoLog(x).trim(),e=a.getShaderInfoLog(S).trim(),i=a.getShaderInfoLog(w).trim();let n=!0,r=!0;if(!1===a.getProgramParameter(x,35714)){n=!1;const e=os(a,S,"vertex"),i=os(a,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+a.getError()+" - VALIDATE_STATUS "+a.getProgramParameter(x,35715)+"nnProgram Info Log: "+t+"n"+e+"n"+i)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:_},fragmentShader:{log:i,prefix:y}})}let T,A;return a.deleteShader(S),a.deleteShader(w),this.getUniforms=function(){return void 0===T&&(T=new rs(a,x)),T},this.getAttributes=function(){return void 0===A&&(A=function(t,e){const i={},n=t.getProgramParameter(e,35721);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;35674===n.type&&(a=2),35675===n.type&&(a=3),35676===n.type&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(a,x)),A},this.destroy=function(){n.releaseStatesOfProgram(this),a.deleteProgram(x),this.program=void 0},this.name=i.shaderName,this.id=as++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=w,this}let Ms=0;class bs{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,i=t.fragmentShader,n=this._getShaderStage(e),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(t);return!1===s.has(n)&&(s.add(n),n.usedTimes++),!1===s.has(r)&&(s.add(r),r.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new Ss(t),e.set(t,i)),i}}class Ss{constructor(t){this.id=Ms++,this.code=t,this.usedTimes=0}}function ws(t,e,i,n,r,s,a){const o=new Ye,c=new bs,h=[],u=r.isWebGL2,d=r.logarithmicDepthBuffer,p=r.vertexTextures;let m=r.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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"};return{getParameters:function(s,o,h,g,v){const x=g.fog,_=v.geometry,y=s.isMeshStandardMaterial?g.environment:null,M=(s.isMeshStandardMaterial?i:e).get(s.envMap||y),b=M&&M.mapping===l?M.image.height:null,S=f[s.type];null!==s.precision&&(m=r.getMaxPrecision(s.precision),m!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",m,"instead."));const w=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,T=void 0!==w?w.length:0;let A,E,C,L,R=0;if(void 0!==_.morphAttributes.position&&(R=1),void 0!==_.morphAttributes.normal&&(R=2),void 0!==_.morphAttributes.color&&(R=3),S){const t=Sn[S];A=t.vertexShader,E=t.fragmentShader}else A=s.vertexShader,E=s.fragmentShader,c.update(s),C=c.getVertexShaderID(s),L=c.getFragmentShaderID(s);const P=t.getRenderTarget(),I=s.alphaTest>0,D=s.clearcoat>0,N=s.iridescence>0;return{isWebGL2:u,shaderID:S,shaderName:s.type,vertexShader:A,fragmentShader:E,defines:s.defines,customVertexShaderID:C,customFragmentShaderID:L,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:m,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:p,outputEncoding:null===P?t.outputEncoding:!0===P.isXRRenderTarget?P.texture.encoding:ct,map:!!s.map,matcap:!!s.matcap,envMap:!!M,envMapMode:M&&M.mapping,envMapCubeUVHeight:b,lightMap:!!s.lightMap,aoMap:!!s.aoMap,emissiveMap:!!s.emissiveMap,bumpMap:!!s.bumpMap,normalMap:!!s.normalMap,objectSpaceNormalMap:1===s.normalMapType,tangentSpaceNormalMap:0===s.normalMapType,decodeVideoTexture:!!s.map&&!0===s.map.isVideoTexture&&s.map.encoding===ht,clearcoat:D,clearcoatMap:D&&!!s.clearcoatMap,clearcoatRoughnessMap:D&&!!s.clearcoatRoughnessMap,clearcoatNormalMap:D&&!!s.clearcoatNormalMap,iridescence:N,iridescenceMap:N&&!!s.iridescenceMap,iridescenceThicknessMap:N&&!!s.iridescenceThicknessMap,displacementMap:!!s.displacementMap,roughnessMap:!!s.roughnessMap,metalnessMap:!!s.metalnessMap,specularMap:!!s.specularMap,specularIntensityMap:!!s.specularIntensityMap,specularColorMap:!!s.specularColorMap,opaque:!1===s.transparent&&1===s.blending,alphaMap:!!s.alphaMap,alphaTest:I,gradientMap:!!s.gradientMap,sheen:s.sheen>0,sheenColorMap:!!s.sheenColorMap,sheenRoughnessMap:!!s.sheenRoughnessMap,transmission:s.transmission>0,transmissionMap:!!s.transmissionMap,thicknessMap:!!s.thicknessMap,combine:s.combine,vertexTangents:!!s.normalMap&&!!_.attributes.tangent,vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!_.attributes.color&&4===_.attributes.color.itemSize,vertexUvs:!!(s.map||s.bumpMap||s.normalMap||s.specularMap||s.alphaMap||s.emissiveMap||s.roughnessMap||s.metalnessMap||s.clearcoatMap||s.clearcoatRoughnessMap||s.clearcoatNormalMap||s.iridescenceMap||s.iridescenceThicknessMap||s.displacementMap||s.transmissionMap||s.thicknessMap||s.specularIntensityMap||s.specularColorMap||s.sheenColorMap||s.sheenRoughnessMap),uvsVertexOnly:!(s.map||s.bumpMap||s.normalMap||s.specularMap||s.alphaMap||s.emissiveMap||s.roughnessMap||s.metalnessMap||s.clearcoatNormalMap||s.iridescenceMap||s.iridescenceThicknessMap||s.transmission>0||s.transmissionMap||s.thicknessMap||s.specularIntensityMap||s.specularColorMap||s.sheen>0||s.sheenColorMap||s.sheenRoughnessMap||!s.displacementMap),fog:!!x,useFog:!0===s.fog,fogExp2:x&&x.isFogExp2,flatShading:!!s.flatShading,sizeAttenuation:s.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==_.morphAttributes.position,morphNormals:void 0!==_.morphAttributes.normal,morphColors:void 0!==_.morphAttributes.color,morphTargetsCount:T,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:s.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,useDepthPacking:!!s.depthPacking,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:s.extensions&&s.extensions.derivatives,extensionFragDepth:s.extensions&&s.extensions.fragDepth,extensionDrawBuffers:s.extensions&&s.extensions.drawBuffers,extensionShaderTextureLOD:s.extensions&&s.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputEncoding),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.combine),t.push(e.vertexUvs),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.isWebGL2&&o.enable(0);e.supportsVertexTextures&&o.enable(1);e.instancing&&o.enable(2);e.instancingColor&&o.enable(3);e.map&&o.enable(4);e.matcap&&o.enable(5);e.envMap&&o.enable(6);e.lightMap&&o.enable(7);e.aoMap&&o.enable(8);e.emissiveMap&&o.enable(9);e.bumpMap&&o.enable(10);e.normalMap&&o.enable(11);e.objectSpaceNormalMap&&o.enable(12);e.tangentSpaceNormalMap&&o.enable(13);e.clearcoat&&o.enable(14);e.clearcoatMap&&o.enable(15);e.clearcoatRoughnessMap&&o.enable(16);e.clearcoatNormalMap&&o.enable(17);e.iridescence&&o.enable(18);e.iridescenceMap&&o.enable(19);e.iridescenceThicknessMap&&o.enable(20);e.displacementMap&&o.enable(21);e.specularMap&&o.enable(22);e.roughnessMap&&o.enable(23);e.metalnessMap&&o.enable(24);e.gradientMap&&o.enable(25);e.alphaMap&&o.enable(26);e.alphaTest&&o.enable(27);e.vertexColors&&o.enable(28);e.vertexAlphas&&o.enable(29);e.vertexUvs&&o.enable(30);e.vertexTangents&&o.enable(31);e.uvsVertexOnly&&o.enable(32);t.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.skinning&&o.enable(4);e.morphTargets&&o.enable(5);e.morphNormals&&o.enable(6);e.morphColors&&o.enable(7);e.premultipliedAlpha&&o.enable(8);e.shadowMapEnabled&&o.enable(9);e.physicallyCorrectLights&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.specularIntensityMap&&o.enable(15);e.specularColorMap&&o.enable(16);e.transmission&&o.enable(17);e.transmissionMap&&o.enable(18);e.thicknessMap&&o.enable(19);e.sheen&&o.enable(20);e.sheenColorMap&&o.enable(21);e.sheenRoughnessMap&&o.enable(22);e.decodeVideoTexture&&o.enable(23);e.opaque&&o.enable(24);t.push(o.mask)}(i,e),i.push(t.outputEncoding)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=f[t.type];let i;if(e){const t=Sn[e];i=nn.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new ys(t,i,e,s),h.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),t.destroy()}},releaseShaderCache:function(t){c.remove(t)},programs:h,dispose:function(){c.dispose()}}}function Ts(){let t=new WeakMap;return{get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function As(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Es(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Cs(){const t=[];let e=0;const i=[],n=[],r=[];function s(i,n,r,s,a,o){let l=t[e];return void 0===l?(l={id:i.id,object:i,geometry:n,material:r,groupOrder:s,renderOrder:i.renderOrder,z:a,group:o},t[e]=l):(l.id=i.id,l.object=i,l.geometry=n,l.material=r,l.groupOrder=s,l.renderOrder=i.renderOrder,l.z=a,l.group=o),e++,l}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?n.push(h):!0===a.transparent?r.push(h):i.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?n.unshift(h):!0===a.transparent?r.unshift(h):i.unshift(h)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){i.length>1&&i.sort(t||As),n.length>1&&n.sort(e||Es),r.length>1&&r.sort(e||Es)}}}function Ls(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new Cs,t.set(e,[r])):i>=n.length?(r=new Cs,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function Rs(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new oe,color:new Zt};break;case"SpotLight":i={position:new oe,direction:new oe,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new oe,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":i={direction:new oe,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":i={color:new Zt,position:new oe,halfWidth:new oe,halfHeight:new oe}}return t[e.id]=i,i}}}let Ps=0;function Is(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Ds(t,e){const i=new Rs,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new It};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new It,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let t=0;t<9;t++)r.probe.push(new oe);const s=new oe,a=new Ue,o=new Ue;return{setup:function(s,a){let o=0,l=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,v=0,x=0,_=0;s.sort(Is);const y=!0!==a?Math.PI:1;for(let t=0,e=s.length;t<e;t++){const e=s[t],a=e.color,M=e.intensity,b=e.distance,S=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=a.r*M*y,l+=a.g*M*y,c+=a.b*M*y;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],M);else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*y),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.directionalShadow[h]=i,r.directionalShadowMap[h]=S,r.directionalShadowMatrix[h]=e.shadow.matrix,f++}r.directional[h]=t,h++}else if(e.isSpotLight){const t=i.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(a).multiplyScalar(M*y),t.distance=b,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,r.spot[d]=t;const s=e.shadow;if(e.map&&(r.spotLightMap[x]=e.map,x++,s.updateMatrices(e),e.castShadow&&_++),r.spotLightMatrix[d]=s.matrix,e.castShadow){const t=n.get(e);t.shadowBias=s.bias,t.shadowNormalBias=s.normalBias,t.shadowRadius=s.radius,t.shadowMapSize=s.mapSize,r.spotShadow[d]=t,r.spotShadowMap[d]=S,v++}d++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(a).multiplyScalar(M),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[p]=t,p++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*y),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,r.pointShadow[u]=i,r.pointShadowMap[u]=S,r.pointShadowMatrix[u]=e.shadow.matrix,g++}r.point[u]=t,u++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(M*y),t.groundColor.copy(e.groundColor).multiplyScalar(M*y),r.hemi[m]=t,m++}}p>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=bn.LTC_FLOAT_1,r.rectAreaLTC2=bn.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=bn.LTC_HALF_1,r.rectAreaLTC2=bn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const M=r.hash;M.directionalLength===h&&M.pointLength===u&&M.spotLength===d&&M.rectAreaLength===p&&M.hemiLength===m&&M.numDirectionalShadows===f&&M.numPointShadows===g&&M.numSpotShadows===v&&M.numSpotMaps===x||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+x-_,r.spotLightMap.length=x,r.numSpotLightShadowsWithMaps=_,M.directionalLength=h,M.pointLength=u,M.spotLength=d,M.rectAreaLength=p,M.hemiLength=m,M.numDirectionalShadows=f,M.numPointShadows=g,M.numSpotShadows=v,M.numSpotMaps=x,r.version=Ps++)},setupView:function(t,e){let i=0,n=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=r.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const t=r.rectArea[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),o.identity(),a.copy(d.matrixWorld),a.premultiply(u),o.extractRotation(a),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(o),t.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const t=r.point[n];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const t=r.hemi[h];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),h++}}},state:r}}function Ns(t,e){const i=new Ds(t,e),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(t){i.setup(n,t)},setupLightsView:function(t){i.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){r.push(t)}}}function Os(t,e){let i=new WeakMap;return{get:function(n,r=0){const s=i.get(n);let a;return void 0===s?(a=new Ns(t,e),i.set(n,[a])):r>=s.length?(a=new Ns(t,e),s.push(a)):a=s[r],a},dispose:function(){i=new WeakMap}}}class zs extends Mi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Us extends Mi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new oe,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function Bs(t,e,i){let n=new vn;const r=new It,s=new It,a=new ie,o=new zs({depthPacking:3201}),l=new Us,c={},h=i.maxTextureSize,u={0:1,1:0,2:2},p=new rn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new It},radius:{value:4}},vertexShader:"void main() {ntgl_Position = vec4( position, 1.0 );n}",fragmentShader:"uniform sampler2D shadow_pass;nuniform vec2 resolution;nuniform float radius;n#include <packing>nvoid main() {ntconst float samples = float( VSM_SAMPLES );ntfloat mean = 0.0;ntfloat squared_mean = 0.0;ntfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );ntfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;ntfor ( float i = 0.0; i < samples; i ++ ) {nttfloat uvOffset = uvStart + i * uvStride;ntt#ifdef HORIZONTAL_PASSntttvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );ntttmean += distribution.x;ntttsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;ntt#elsentttfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );ntttmean += depth;ntttsquared_mean += depth * depth;ntt#endifnt}ntmean = mean / samples;ntsquared_mean = squared_mean / samples;ntfloat std_dev = sqrt( squared_mean - mean * mean );ntgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );n}"}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const f=new zi;f.setAttribute("position",new Ti(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Ji(f,p),v=this;function x(i,n){const s=e.update(g);p.defines.VSM_SAMPLES!==i.blurSamples&&(p.defines.VSM_SAMPLES=i.blurSamples,m.defines.VSM_SAMPLES=i.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new ne(r.x,r.y)),p.uniforms.shadow_pass.value=i.map.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,p,g,null),m.uniforms.shadow_pass.value=i.mapPass.texture,m.uniforms.resolution.value=i.mapSize,m.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,m,g,null)}function _(e,i,n,r,s,a){let h=null;const d=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==d)h=d;else if(h=!0===n.isPointLight?l:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=h.uuid,e=i.uuid;let n=c[t];void 0===n&&(n={},c[t]=n);let r=n[e];void 0===r&&(r=h.clone(),n[e]=r),h=r}return h.visible=i.visible,h.wireframe=i.wireframe,h.side=3===a?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],h.alphaMap=i.alphaMap,h.alphaTest=i.alphaTest,h.map=i.map,h.clipShadows=i.clipShadows,h.clippingPlanes=i.clippingPlanes,h.clipIntersection=i.clipIntersection,h.displacementMap=i.displacementMap,h.displacementScale=i.displacementScale,h.displacementBias=i.displacementBias,h.wireframeLinewidth=i.wireframeLinewidth,h.linewidth=i.linewidth,!0===n.isPointLight&&!0===h.isMeshDistanceMaterial&&(h.referencePosition.setFromMatrixPosition(n.matrixWorld),h.nearDistance=r,h.farDistance=s),h}function y(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let l=0,c=e.length;l<c;l++){const c=e[l],h=r[c.materialIndex];if(h&&h.visible){const e=_(i,h,a,s.near,s.far,o);t.renderBufferDirect(s,null,n,e,i,c)}}}else if(r.visible){const e=_(i,r,a,s.near,s.far,o);t.renderBufferDirect(s,null,n,e,i,null)}}const l=i.children;for(let t=0,e=l.length;t<e;t++)y(l[t],r,s,a,o)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,i,o){if(!1===v.enabled)return;if(!1===v.autoUpdate&&!1===v.needsUpdate)return;if(0===e.length)return;const l=t.getRenderTarget(),c=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),p=t.state;p.setBlending(0),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(let l=0,c=e.length;l<c;l++){const c=e[l],u=c.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const m=u.getFrameExtents();if(r.multiply(m),s.copy(u.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/m.x),r.x=s.x*m.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/m.y),r.y=s.y*m.y,u.mapSize.y=s.y)),null===u.map){const t=3!==this.type?{minFilter:d,magFilter:d}:{};u.map=new ne(r.x,r.y,t),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const e=u.getViewport(t);a.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),p.viewport(a),u.updateMatrices(c,t),n=u.getFrustum(),y(i,o,u.camera,c,this.type)}!0!==u.isPointLightShadow&&3===this.type&&x(u,o),u.needsUpdate=!1}v.needsUpdate=!1,t.setRenderTarget(l,c,u)}}function Fs(t,e,n){const r=n.isWebGL2;const s=new function(){let e=!1;const i=new ie;let n=null;const r=new ie(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},a=new function(){let e=!1,i=null,n=null,r=null;return{setTest:function(t){t?G(2929):V(2929)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:default:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517)}n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},o=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,c=null;return{setTest:function(t){e||(t?G(2960):V(2960))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&l===n||(t.stencilOp(e,i,n),a=e,o=i,l=n)},setLocked:function(t){e=t},setClear:function(e){c!==e&&(t.clearStencil(e),c=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,c=null}}},l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,p=[],m=null,f=!1,g=null,v=null,x=null,_=null,y=null,M=null,b=null,S=!1,w=null,T=null,A=null,E=null,C=null;const L=t.getParameter(35661);let R=!1,P=0;const I=t.getParameter(7938);-1!==I.indexOf("WebGL")?(P=parseFloat(/^WebGL (d)/.exec(I)[1]),R=P>=1):-1!==I.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (d)/.exec(I)[1]),R=P>=2);let D=null,N={};const O=t.getParameter(3088),z=t.getParameter(2978),U=(new ie).fromArray(O),B=(new ie).fromArray(z);function F(e,i,n){const r=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<n;e++)t.texImage2D(i+e,0,6408,1,1,0,6408,5121,r);return s}const k={};function G(e){!0!==h[e]&&(t.enable(e),h[e]=!0)}function V(e){!1!==h[e]&&(t.disable(e),h[e]=!1)}k[3553]=F(3553,3553,1),k[34067]=F(34067,34069,6),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),G(2929),a.setFunc(3),q(!1),X(1),G(2884),j(0);const H={[i]:32774,101:32778,102:32779};if(r)H[103]=32775,H[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(H[103]=t.MIN_EXT,H[104]=t.MAX_EXT)}const W={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function j(e,n,r,s,a,o,l,c){if(0!==e){if(!1===f&&(G(3042),f=!0),5===e)a=a||n,o=o||r,l=l||s,n===v&&a===y||(t.blendEquationSeparate(H[n],H[a]),v=n,y=a),r===x&&s===_&&o===M&&l===b||(t.blendFuncSeparate(W[r],W[s],W[o],W[l]),x=r,_=s,M=o,b=l),g=e,S=!1;else if(e!==g||c!==S){if(v===i&&y===i||(t.blendEquation(32774),v=i,y=i),c)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,769,0,1);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFuncSeparate(0,769,0,1);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}x=null,_=null,M=null,b=null,g=e,S=c}}else!0===f&&(V(3042),f=!1)}function q(e){w!==e&&(e?t.frontFace(2304):t.frontFace(2305),w=e)}function X(e){0!==e?(G(2884),e!==T&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):V(2884),T=e}function Y(e,i,n){e?(G(32823),E===i&&C===n||(t.polygonOffset(i,n),E=i,C=n)):V(32823)}return{buffers:{color:s,depth:a,stencil:o},enable:G,disable:V,bindFramebuffer:function(e,i){return u[e]!==i&&(t.bindFramebuffer(e,i),u[e]=i,r&&(36009===e&&(u[36160]=i),36160===e&&(u[36009]=i)),!0)},drawBuffers:function(i,r){let s=p,a=!1;if(i)if(s=d.get(r),void 0===s&&(s=[],d.set(r,s)),i.isWebGLMultipleRenderTargets){const t=i.texture;if(s.length!==t.length||36064!==s[0]){for(let e=0,i=t.length;e<i;e++)s[e]=36064+e;s.length=t.length,a=!0}}else 36064!==s[0]&&(s[0]=36064,a=!0);else 1029!==s[0]&&(s[0]=1029,a=!0);a&&(n.isWebGL2?t.drawBuffers(s):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(s))},useProgram:function(e){return m!==e&&(t.useProgram(e),m=e,!0)},setBlending:j,setMaterial:function(t,e){2===t.side?V(2884):G(2884);let i=1===t.side;e&&(i=!i),q(i),1===t.blending&&!1===t.transparent?j(0):j(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),s.setMask(t.colorWrite);const n=t.stencilWrite;o.setTest(n),n&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),Y(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?G(32926):V(32926)},setFlipSided:q,setCullFace:X,setLineWidth:function(e){e!==A&&(R&&t.lineWidth(e),A=e)},setPolygonOffset:Y,setScissorTest:function(t){t?G(3089):V(3089)},activeTexture:function(e){void 0===e&&(e=33984+L-1),D!==e&&(t.activeTexture(e),D=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===D?33984+L-1:D);let r=N[n];void 0===r&&(r={type:void 0,texture:void 0},N[n]=r),r.type===e&&r.texture===i||(D!==n&&(t.activeTexture(n),D=n),t.bindTexture(e,i||k[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=N[D];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,i){let n=c.get(i);void 0===n&&(n=new WeakMap,c.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=c.get(i).get(e);l.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),l.set(i,n))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===U.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),U.copy(e))},viewport:function(e){!1===B.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),B.copy(e))},reset:function(){t.disable(3042),t.disable(2884),t.disable(2929),t.disable(32823),t.disable(3089),t.disable(2960),t.disable(32926),t.blendEquation(32774),t.blendFunc(1,0),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(513),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(519,0,4294967295),t.stencilOp(7680,7680,7680),t.clearStencil(0),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.activeTexture(33984),t.bindFramebuffer(36160,null),!0===r&&(t.bindFramebuffer(36009,null),t.bindFramebuffer(36008,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),h={},D=null,N={},u={},d=new WeakMap,p=[],m=null,f=!1,g=null,v=null,x=null,_=null,y=null,M=null,b=null,S=!1,w=null,T=null,A=null,E=null,C=null,U.set(0,0,t.canvas.width,t.canvas.height),B.set(0,0,t.canvas.width,t.canvas.height),s.reset(),a.reset(),o.reset()}}}function ks(t,e,i,n,r,s,a){const o=r.isWebGL2,l=r.maxTextures,E=r.maxCubemapSize,C=r.maxTextureSize,L=r.maxSamples,R=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,P="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),I=new WeakMap;let D;const N=new WeakMap;let O=!1;try{O="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function z(t,e){return O?new OffscreenCanvas(t,e):Bt("canvas")}function U(t,e,i,n){let r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?Ct:Math.floor,s=n(r*t.width),a=n(r*t.height);void 0===D&&(D=z(s,a));const o=i?z(s,a):D;o.width=s,o.height=a;return o.getContext("2d").drawImage(t,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+a+")."),o}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function B(t){return At(t.width)&&At(t.height)}function F(t,e){return t.generateMipmaps&&e&&t.minFilter!==d&&t.minFilter!==f}function k(e){t.generateMipmap(e)}function G(i,n,r,s,a=!1){if(!1===o)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=n;return 6403===n&&(5126===r&&(l=33326),5131===r&&(l=33325),5121===r&&(l=33321)),33319===n&&(5126===r&&(l=33328),5131===r&&(l=33327),5121===r&&(l=33323)),6408===n&&(5126===r&&(l=34836),5131===r&&(l=34842),5121===r&&(l=s===ht&&!1===a?35907:32856),32819===r&&(l=32854),32820===r&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||e.get("EXT_color_buffer_float"),l}function V(t,e,i){return!0===F(t,i)||t.isFramebufferTexture&&t.minFilter!==d&&t.minFilter!==f?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function H(t){return t===d||t===p||t===m?9728:9729}function W(t){const e=t.target;e.removeEventListener("dispose",W),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=N.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&q(t),0===Object.keys(r).length&&N.delete(i)}n.remove(t)}(e),e.isVideoTexture&&I.delete(e)}function j(e){const i=e.target;i.removeEventListener("dispose",j),function(e){const i=e.texture,r=n.get(e),s=n.get(i);void 0!==s.__webglTexture&&(t.deleteTexture(s.__webglTexture),a.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e]);else{if(t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let e=0;e<r.__webglColorRenderbuffer.length;e++)r.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(r.__webglColorRenderbuffer[e]);r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let e=0,r=i.length;e<r;e++){const r=n.get(i[e]);r.__webglTexture&&(t.deleteTexture(r.__webglTexture),a.memory.textures--),n.remove(i[e])}n.remove(i),n.remove(e)}(i)}function q(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete N.get(r)[i.__cacheKey],a.memory.textures--}let X=0;function Y(t,e){const r=n.get(t);if(t.isVideoTexture&&function(t){const e=a.render.frame;I.get(t)!==e&&(I.set(t,e),t.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&r.__version!==t.version){const i=t.image;if(null===i)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==i.complete)return void Q(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(3553,r.__webglTexture,33984+e)}const Z={[c]:10497,[h]:33071,[u]:33648},J={[d]:9728,[p]:9984,[m]:9986,[f]:9729,[g]:9985,[v]:9987};function K(i,s,a){if(a?(t.texParameteri(i,10242,Z[s.wrapS]),t.texParameteri(i,10243,Z[s.wrapT]),32879!==i&&35866!==i||t.texParameteri(i,32882,Z[s.wrapR]),t.texParameteri(i,10240,J[s.magFilter]),t.texParameteri(i,10241,J[s.minFilter])):(t.texParameteri(i,10242,33071),t.texParameteri(i,10243,33071),32879!==i&&35866!==i||t.texParameteri(i,32882,33071),s.wrapS===h&&s.wrapT===h||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,10240,H(s.magFilter)),t.texParameteri(i,10241,H(s.minFilter)),s.minFilter!==d&&s.minFilter!==f&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(s.magFilter===d)return;if(s.minFilter!==m&&s.minFilter!==v)return;if(s.type===M&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&s.type===b&&!1===e.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function $(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",W));const r=i.source;let s=N.get(r);void 0===s&&(s={},N.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.encoding),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&q(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function Q(e,r,a){let l=3553;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=35866),r.isData3DTexture&&(l=32879);const c=$(e,r),u=r.source;i.bindTexture(l,e.__webglTexture,33984+a);const p=n.get(u);if(u.version!==p.__version||!0===c){i.activeTexture(33984+a),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const e=function(t){return!o&&(t.wrapS!==h||t.wrapT!==h||t.minFilter!==d&&t.minFilter!==f)}(r)&&!1===B(r.image);let n=U(r.image,e,!1,C);n=st(r,n);const m=B(n)||o,g=s.convert(r.format,r.encoding);let v,x=s.convert(r.type),b=G(r.internalFormat,g,x,r.encoding,r.isVideoTexture);K(l,r,m);const E=r.mipmaps,L=o&&!0!==r.isVideoTexture,R=void 0===p.__version||!0===c,P=V(r,n,m);if(r.isDepthTexture)b=6402,o?b=r.type===M?36012:r.type===y?33190:r.type===S?35056:33189:r.type===M&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===T&&6402===b&&r.type!==_&&r.type!==y&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=y,x=s.convert(r.type)),r.format===A&&6402===b&&(b=34041,r.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=S,x=s.convert(r.type))),R&&(L?i.texStorage2D(3553,1,b,n.width,n.height):i.texImage2D(3553,0,b,n.width,n.height,0,g,x,null));else if(r.isDataTexture)if(E.length>0&&m){L&&R&&i.texStorage2D(3553,P,b,E[0].width,E[0].height);for(let t=0,e=E.length;t<e;t++)v=E[t],L?i.texSubImage2D(3553,t,0,0,v.width,v.height,g,x,v.data):i.texImage2D(3553,t,b,v.width,v.height,0,g,x,v.data);r.generateMipmaps=!1}else L?(R&&i.texStorage2D(3553,P,b,n.width,n.height),i.texSubImage2D(3553,0,0,0,n.width,n.height,g,x,n.data)):i.texImage2D(3553,0,b,n.width,n.height,0,g,x,n.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){L&&R&&i.texStorage3D(35866,P,b,E[0].width,E[0].height,n.depth);for(let t=0,e=E.length;t<e;t++)v=E[t],r.format!==w?null!==g?L?i.compressedTexSubImage3D(35866,t,0,0,0,v.width,v.height,n.depth,g,v.data,0,0):i.compressedTexImage3D(35866,t,b,v.width,v.height,n.depth,0,v.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?i.texSubImage3D(35866,t,0,0,0,v.width,v.height,n.depth,g,x,v.data):i.texImage3D(35866,t,b,v.width,v.height,n.depth,0,g,x,v.data)}else{L&&R&&i.texStorage2D(3553,P,b,E[0].width,E[0].height);for(let t=0,e=E.length;t<e;t++)v=E[t],r.format!==w?null!==g?L?i.compressedTexSubImage2D(3553,t,0,0,v.width,v.height,g,v.data):i.compressedTexImage2D(3553,t,b,v.width,v.height,0,v.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):L?i.texSubImage2D(3553,t,0,0,v.width,v.height,g,x,v.data):i.texImage2D(3553,t,b,v.width,v.height,0,g,x,v.data)}else if(r.isDataArrayTexture)L?(R&&i.texStorage3D(35866,P,b,n.width,n.height,n.depth),i.texSubImage3D(35866,0,0,0,0,n.width,n.height,n.depth,g,x,n.data)):i.texImage3D(35866,0,b,n.width,n.height,n.depth,0,g,x,n.data);else if(r.isData3DTexture)L?(R&&i.texStorage3D(32879,P,b,n.width,n.height,n.depth),i.texSubImage3D(32879,0,0,0,0,n.width,n.height,n.depth,g,x,n.data)):i.texImage3D(32879,0,b,n.width,n.height,n.depth,0,g,x,n.data);else if(r.isFramebufferTexture){if(R)if(L)i.texStorage2D(3553,P,b,n.width,n.height);else{let t=n.width,e=n.height;for(let n=0;n<P;n++)i.texImage2D(3553,n,b,t,e,0,g,x,null),t>>=1,e>>=1}}else if(E.length>0&&m){L&&R&&i.texStorage2D(3553,P,b,E[0].width,E[0].height);for(let t=0,e=E.length;t<e;t++)v=E[t],L?i.texSubImage2D(3553,t,0,0,g,x,v):i.texImage2D(3553,t,b,g,x,v);r.generateMipmaps=!1}else L?(R&&i.texStorage2D(3553,P,b,n.width,n.height),i.texSubImage2D(3553,0,0,0,g,x,n)):i.texImage2D(3553,0,b,g,x,n);F(r,m)&&k(l),p.__version=u.version,r.onUpdate&&r.onUpdate(r)}e.__version=r.version}function tt(e,r,a,o,l){const c=s.convert(a.format,a.encoding),h=s.convert(a.type),u=G(a.internalFormat,c,h,a.encoding);n.get(r).__hasExternalTextures||(32879===l||35866===l?i.texImage3D(l,0,u,r.width,r.height,r.depth,0,c,h,null):i.texImage2D(l,0,u,r.width,r.height,0,c,h,null)),i.bindFramebuffer(36160,e),rt(r)?R.framebufferTexture2DMultisampleEXT(36160,o,l,n.get(a).__webglTexture,0,nt(r)):(3553===l||l>=34069&&l<=34074)&&t.framebufferTexture2D(36160,o,l,n.get(a).__webglTexture,0),i.bindFramebuffer(36160,null)}function et(e,i,n){if(t.bindRenderbuffer(36161,e),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n||rt(i)){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===M?r=36012:e.type===y&&(r=33190));const n=nt(i);rt(i)?R.renderbufferStorageMultisampleEXT(36161,n,r,i.width,i.height):t.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else t.renderbufferStorage(36161,r,i.width,i.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(i.depthBuffer&&i.stencilBuffer){const r=nt(i);n&&!1===rt(i)?t.renderbufferStorageMultisample(36161,r,35056,i.width,i.height):rt(i)?R.renderbufferStorageMultisampleEXT(36161,r,35056,i.width,i.height):t.renderbufferStorage(36161,34041,i.width,i.height),t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let r=0;r<e.length;r++){const a=e[r],o=s.convert(a.format,a.encoding),l=s.convert(a.type),c=G(a.internalFormat,o,l,a.encoding),h=nt(i);n&&!1===rt(i)?t.renderbufferStorageMultisample(36161,h,c,i.width,i.height):rt(i)?R.renderbufferStorageMultisampleEXT(36161,h,c,i.width,i.height):t.renderbufferStorage(36161,c,i.width,i.height)}}t.bindRenderbuffer(36161,null)}function it(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!r.__autoAllocateDepthBuffer){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),Y(r.depthTexture,0);const s=n.get(r.depthTexture).__webglTexture,a=nt(r);if(r.depthTexture.format===T)rt(r)?R.framebufferTexture2DMultisampleEXT(36160,36096,3553,s,0,a):t.framebufferTexture2D(36160,36096,3553,s,0);else{if(r.depthTexture.format!==A)throw new Error("Unknown depthTexture format");rt(r)?R.framebufferTexture2DMultisampleEXT(36160,33306,3553,s,0,a):t.framebufferTexture2D(36160,33306,3553,s,0)}}(r.__webglFramebuffer,e)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(36160,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=t.createRenderbuffer(),et(r.__webglDepthbuffer[n],e,!1)}else i.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=t.createRenderbuffer(),et(r.__webglDepthbuffer,e,!1);i.bindFramebuffer(36160,null)}function nt(t){return Math.min(L,t.samples)}function rt(t){const i=n.get(t);return o&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function st(t,i){const n=t.encoding,r=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===gt||n!==ct&&(n===ht?!1===o?!0===e.has("EXT_sRGB")&&r===w?(t.format=gt,t.minFilter=f,t.generateMipmaps=!1):i=Kt.sRGBToLinear(i):r===w&&s===x||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",n)),i}this.allocateTextureUnit=function(){const t=X;return t>=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),X+=1,t},this.resetTextureUnits=function(){X=0},this.setTexture2D=Y,this.setTexture2DArray=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?Q(r,t,e):i.bindTexture(35866,r.__webglTexture,33984+e)},this.setTexture3D=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?Q(r,t,e):i.bindTexture(32879,r.__webglTexture,33984+e)},this.setTextureCube=function(e,r){const a=n.get(e);e.version>0&&a.__version!==e.version?function(e,r,a){if(6!==r.image.length)return;const l=$(e,r),c=r.source;i.bindTexture(34067,e.__webglTexture,33984+a);const h=n.get(c);if(c.version!==h.__version||!0===l){i.activeTexture(33984+a),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const e=r.isCompressedTexture||r.image[0].isCompressedTexture,n=r.image[0]&&r.image[0].isDataTexture,u=[];for(let t=0;t<6;t++)u[t]=e||n?n?r.image[t].image:r.image[t]:U(r.image[t],!1,!0,E),u[t]=st(r,u[t]);const d=u[0],p=B(d)||o,m=s.convert(r.format,r.encoding),f=s.convert(r.type),g=G(r.internalFormat,m,f,r.encoding),v=o&&!0!==r.isVideoTexture,x=void 0===h.__version||!0===l;let _,y=V(r,d,p);if(K(34067,r,p),e){v&&x&&i.texStorage2D(34067,y,g,d.width,d.height);for(let t=0;t<6;t++){_=u[t].mipmaps;for(let e=0;e<_.length;e++){const n=_[e];r.format!==w?null!==m?v?i.compressedTexSubImage2D(34069+t,e,0,0,n.width,n.height,m,n.data):i.compressedTexImage2D(34069+t,e,g,n.width,n.height,0,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v?i.texSubImage2D(34069+t,e,0,0,n.width,n.height,m,f,n.data):i.texImage2D(34069+t,e,g,n.width,n.height,0,m,f,n.data)}}}else{_=r.mipmaps,v&&x&&(_.length>0&&y++,i.texStorage2D(34067,y,g,u[0].width,u[0].height));for(let t=0;t<6;t++)if(n){v?i.texSubImage2D(34069+t,0,0,0,u[t].width,u[t].height,m,f,u[t].data):i.texImage2D(34069+t,0,g,u[t].width,u[t].height,0,m,f,u[t].data);for(let e=0;e<_.length;e++){const n=_[e].image[t].image;v?i.texSubImage2D(34069+t,e+1,0,0,n.width,n.height,m,f,n.data):i.texImage2D(34069+t,e+1,g,n.width,n.height,0,m,f,n.data)}}else{v?i.texSubImage2D(34069+t,0,0,0,m,f,u[t]):i.texImage2D(34069+t,0,g,m,f,u[t]);for(let e=0;e<_.length;e++){const n=_[e];v?i.texSubImage2D(34069+t,e+1,0,0,m,f,n.image[t]):i.texImage2D(34069+t,e+1,g,m,f,n.image[t])}}}F(r,p)&&k(34067),h.__version=c.version,r.onUpdate&&r.onUpdate(r)}e.__version=r.version}(a,e,r):i.bindTexture(34067,a.__webglTexture,33984+r)},this.rebindTextures=function(t,e,i){const r=n.get(t);void 0!==e&&tt(r.__webglFramebuffer,t,t.texture,36064,3553),void 0!==i&&it(t)},this.setupRenderTarget=function(e){const l=e.texture,c=n.get(e),h=n.get(l);e.addEventListener("dispose",j),!0!==e.isWebGLMultipleRenderTargets&&(void 0===h.__webglTexture&&(h.__webglTexture=t.createTexture()),h.__version=l.version,a.memory.textures++);const u=!0===e.isWebGLCubeRenderTarget,d=!0===e.isWebGLMultipleRenderTargets,p=B(e)||o;if(u){c.__webglFramebuffer=[];for(let e=0;e<6;e++)c.__webglFramebuffer[e]=t.createFramebuffer()}else{if(c.__webglFramebuffer=t.createFramebuffer(),d)if(r.drawBuffers){const i=e.texture;for(let e=0,r=i.length;e<r;e++){const r=n.get(i[e]);void 0===r.__webglTexture&&(r.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&e.samples>0&&!1===rt(e)){const n=d?l:[l];c.__webglMultisampledFramebuffer=t.createFramebuffer(),c.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){const r=n[i];c.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(36161,c.__webglColorRenderbuffer[i]);const a=s.convert(r.format,r.encoding),o=s.convert(r.type),l=G(r.internalFormat,a,o,r.encoding,!0===e.isXRRenderTarget),h=nt(e);t.renderbufferStorageMultisample(36161,h,l,e.width,e.height),t.framebufferRenderbuffer(36160,36064+i,36161,c.__webglColorRenderbuffer[i])}t.bindRenderbuffer(36161,null),e.depthBuffer&&(c.__webglDepthRenderbuffer=t.createRenderbuffer(),et(c.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(36160,null)}}if(u){i.bindTexture(34067,h.__webglTexture),K(34067,l,p);for(let t=0;t<6;t++)tt(c.__webglFramebuffer[t],e,l,36064,34069+t);F(l,p)&&k(34067),i.unbindTexture()}else if(d){const t=e.texture;for(let r=0,s=t.length;r<s;r++){const s=t[r],a=n.get(s);i.bindTexture(3553,a.__webglTexture),K(3553,s,p),tt(c.__webglFramebuffer,e,s,36064+r,3553),F(s,p)&&k(3553)}i.unbindTexture()}else{let t=3553;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(o?t=e.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(t,h.__webglTexture),K(t,l,p),tt(c.__webglFramebuffer,e,l,36064,t),F(l,p)&&k(t),i.unbindTexture()}e.depthBuffer&&it(e)},this.updateRenderTargetMipmap=function(t){const e=B(t)||o,r=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let s=0,a=r.length;s<a;s++){const a=r[s];if(F(a,e)){const e=t.isWebGLCubeRenderTarget?34067:3553,r=n.get(a).__webglTexture;i.bindTexture(e,r),k(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(o&&e.samples>0&&!1===rt(e)){const r=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],s=e.width,a=e.height;let o=16384;const l=[],c=e.stencilBuffer?33306:36096,h=n.get(e),u=!0===e.isWebGLMultipleRenderTargets;if(u)for(let e=0;e<r.length;e++)i.bindFramebuffer(36160,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064+e,36161,null),i.bindFramebuffer(36160,h.__webglFramebuffer),t.framebufferTexture2D(36009,36064+e,3553,null,0);i.bindFramebuffer(36008,h.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,h.__webglFramebuffer);for(let i=0;i<r.length;i++){l.push(36064+i),e.depthBuffer&&l.push(c);const d=void 0!==h.__ignoreDepthValues&&h.__ignoreDepthValues;if(!1===d&&(e.depthBuffer&&(o|=256),e.stencilBuffer&&(o|=1024)),u&&t.framebufferRenderbuffer(36008,36064,36161,h.__webglColorRenderbuffer[i]),!0===d&&(t.invalidateFramebuffer(36008,[c]),t.invalidateFramebuffer(36009,[c])),u){const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(36009,36064,3553,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,9728),P&&t.invalidateFramebuffer(36008,l)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),u)for(let e=0;e<r.length;e++){i.bindFramebuffer(36160,h.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064+e,36161,h.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(36160,h.__webglFramebuffer),t.framebufferTexture2D(36009,36064+e,3553,s,0)}i.bindFramebuffer(36009,h.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=it,this.setupFrameBufferTexture=tt,this.useMultisampledRTT=rt}function Gs(t,e,i){const n=i.isWebGL2;return{convert:function(i,r=null){let s;if(i===x)return 5121;if(1017===i)return 32819;if(1018===i)return 32820;if(1010===i)return 5120;if(1011===i)return 5122;if(i===_)return 5123;if(1013===i)return 5124;if(i===y)return 5125;if(i===M)return 5126;if(i===b)return n?5131:(s=e.get("OES_texture_half_float"),null!==s?s.HALF_FLOAT_OES:null);if(1021===i)return 6406;if(i===w)return 6408;if(1024===i)return 6409;if(1025===i)return 6410;if(i===T)return 6402;if(i===A)return 34041;if(i===gt)return s=e.get("EXT_sRGB"),null!==s?s.SRGB_ALPHA_EXT:null;if(1028===i)return 6403;if(1029===i)return 36244;if(1030===i)return 33319;if(1031===i)return 33320;if(1033===i)return 36249;if(i===E||i===C||i===L||i===R)if(r===ht){if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===s)return null;if(i===E)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===C)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===L)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===R)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(s=e.get("WEBGL_compressed_texture_s3tc"),null===s)return null;if(i===E)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===C)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===L)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===R)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===P||i===I||i===D||i===N){if(s=e.get("WEBGL_compressed_texture_pvrtc"),null===s)return null;if(i===P)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===I)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===D)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===N)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===i)return s=e.get("WEBGL_compressed_texture_etc1"),null!==s?s.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===O||i===z){if(s=e.get("WEBGL_compressed_texture_etc"),null===s)return null;if(i===O)return r===ht?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===z)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}if(i===U||i===B||i===F||i===k||i===G||i===V||i===H||i===W||i===j||i===q||i===X||i===Y||i===Z||i===J){if(s=e.get("WEBGL_compressed_texture_astc"),null===s)return null;if(i===U)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===B)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===F)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===k)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===G)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===V)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===H)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===W)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===j)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===q)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===X)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Y)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Z)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===J)return r===ht?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===K){if(s=e.get("EXT_texture_compression_bptc"),null===s)return null;if(i===K)return r===ht?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===i||i===$||i===Q||i===tt){if(s=e.get("EXT_texture_compression_rgtc"),null===s)return null;if(i===K)return s.COMPRESSED_RED_RGTC1_EXT;if(i===$)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Q)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===tt)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===S?n?34042:(s=e.get("WEBGL_depth_texture"),null!==s?s.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[i]?t[i]:null}}}class Vs extends an{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Hs extends li{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ws={type:"move"};class js{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Hs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Hs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new oe),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Hs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new oe),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i),r=this._getHandJoint(l,n);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=t.radius),r.visible=null!==t}const n=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=n.position.distanceTo(r.position),o=.02,c=.005;l.inputState.pinching&&a>o+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Ws)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new Hs;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class qs extends ee{constructor(t,e,i,n,r,s,a,o,l,c){if((c=void 0!==c?c:T)!==T&&c!==A)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===T&&(i=y),void 0===i&&c===A&&(i=S),super(null,n,r,s,a,o,c,i,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:d,this.minFilter=void 0!==o?o:d,this.flipY=!1,this.generateMipmaps=!1}}class Xs extends vt{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const m=e.getContextAttributes();let f=null,g=null;const v=[],_=[],M=new Set,b=new Map,E=new an;E.layers.enable(1),E.viewport=new ie;const C=new an;C.layers.enable(2),C.viewport=new ie;const L=[E,C],R=new Vs;R.layers.enable(1),R.layers.enable(2);let P=null,I=null;function D(t){const e=_.indexOf(t.inputSource);if(-1===e)return;const i=v[e];void 0!==i&&i.dispatchEvent({type:t.type,data:t.inputSource})}function N(){n.removeEventListener("select",D),n.removeEventListener("selectstart",D),n.removeEventListener("selectend",D),n.removeEventListener("squeeze",D),n.removeEventListener("squeezestart",D),n.removeEventListener("squeezeend",D),n.removeEventListener("end",N),n.removeEventListener("inputsourceschange",O);for(let t=0;t<v.length;t++){const e=_[t];null!==e&&(_[t]=null,v[t].disconnect(e))}P=null,I=null,t.setRenderTarget(f),d=null,u=null,h=null,n=null,g=null,k.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function O(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=_.indexOf(i);n>=0&&(_[n]=null,v[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=_.indexOf(i);if(-1===n){for(let t=0;t<v.length;t++){if(t>=_.length){_.push(i),n=t;break}if(null===_[t]){_[t]=i,n=t;break}}if(-1===n)break}const r=v[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=v[t];return void 0===e&&(e=new js,v[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=v[t];return void 0===e&&(e=new js,v[t]=e),e.getGripSpace()},this.getHand=function(t){let e=v[t];return void 0===e&&(e=new js,v[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(c){if(n=c,null!==n){if(f=t.getRenderTarget(),n.addEventListener("select",D),n.addEventListener("selectstart",D),n.addEventListener("selectend",D),n.addEventListener("squeeze",D),n.addEventListener("squeezestart",D),n.addEventListener("squeezeend",D),n.addEventListener("end",N),n.addEventListener("inputsourceschange",O),!0!==m.xrCompatible&&await e.makeXRCompatible(),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||m.antialias,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),g=new ne(d.framebufferWidth,d.framebufferHeight,{format:w,type:x,encoding:t.outputEncoding,stencilBuffer:m.stencil})}else{let i=null,s=null,a=null;m.depth&&(a=m.stencil?35056:33190,i=m.stencil?A:T,s=m.stencil?S:y);const o={colorFormat:32856,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(n,e),u=h.createProjectionLayer(o),n.updateRenderState({layers:[u]}),g=new ne(u.textureWidth,u.textureHeight,{format:w,type:x,depthTexture:new qs(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,encoding:t.outputEncoding,samples:m.antialias?4:0});t.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await n.requestReferenceSpace(a),k.setContext(n),k.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const z=new oe,U=new oe;function B(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;R.near=C.near=E.near=t.near,R.far=C.far=E.far=t.far,P===R.near&&I===R.far||(n.updateRenderState({depthNear:R.near,depthFar:R.far}),P=R.near,I=R.far);const e=t.parent,i=R.cameras;B(R,e);for(let t=0;t<i.length;t++)B(i[t],e);R.matrixWorld.decompose(R.position,R.quaternion,R.scale),t.matrix.copy(R.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const r=t.children;for(let t=0,e=r.length;t<e;t++)r[t].updateMatrixWorld(!0);2===i.length?function(t,e,i){z.setFromMatrixPosition(e.matrixWorld),U.setFromMatrixPosition(i.matrixWorld);const n=z.distanceTo(U),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],c=(r[9]-1)/r[5],h=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*h,p=a*u,m=n/(-h+u),f=m*-h;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(f),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=a+m,v=o+m,x=d-f,_=p+(n-f),y=l*o/v*g,M=c*o/v*g;t.projectionMatrix.makePerspective(x,_,y,M,g,v)}(R,E,C):R.projectionMatrix.copy(E.projectionMatrix)},this.getCamera=function(){return R},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.getPlanes=function(){return M};let F=null;const k=new xn;k.setAnimationLoop((function(e,n){if(c=n.getViewerPose(l||s),p=n,null!==c){const e=c.views;null!==d&&(t.setRenderTargetFramebuffer(g,d.framebuffer),t.setRenderTarget(g));let i=!1;e.length!==R.cameras.length&&(R.cameras.length=0,i=!0);for(let n=0;n<e.length;n++){const r=e[n];let s=null;if(null!==d)s=d.getViewport(r);else{const e=h.getViewSubImage(u,r);s=e.viewport,0===n&&(t.setRenderTargetTextures(g,e.colorTexture,u.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(g))}let a=L[n];void 0===a&&(a=new an,a.layers.enable(n),a.viewport=new ie,L[n]=a),a.matrix.fromArray(r.transform.matrix),a.projectionMatrix.fromArray(r.projectionMatrix),a.viewport.set(s.x,s.y,s.width,s.height),0===n&&R.matrix.copy(a.matrix),!0===i&&R.cameras.push(a)}}for(let t=0;t<v.length;t++){const e=_[t],i=v[t];null!==e&&void 0!==i&&i.update(e,n,l||s)}if(F&&F(e,n),n.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:n.detectedPlanes});let t=null;for(const e of M)n.detectedPlanes.has(e)||(null===t&&(t=[]),t.push(e));if(null!==t)for(const e of t)M.delete(e),b.delete(e),i.dispatchEvent({type:"planeremoved",data:e});for(const t of n.detectedPlanes)if(M.has(t)){const e=b.get(t);t.lastChangedTime>e&&(b.set(t,t.lastChangedTime),i.dispatchEvent({type:"planechanged",data:t}))}else M.add(t),b.set(t,n.lastChangedTime),i.dispatchEvent({type:"planeadded",data:t})}p=null})),this.setAnimationLoop=function(t){F=t},this.dispose=function(){}}}function Ys(t,e){function i(i,n){i.opacity.value=n.opacity,n.color&&i.diffuse.value.copy(n.color),n.emissive&&i.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(i.map.value=n.map),n.alphaMap&&(i.alphaMap.value=n.alphaMap),n.bumpMap&&(i.bumpMap.value=n.bumpMap,i.bumpScale.value=n.bumpScale,1===n.side&&(i.bumpScale.value*=-1)),n.displacementMap&&(i.displacementMap.value=n.displacementMap,i.displacementScale.value=n.displacementScale,i.displacementBias.value=n.displacementBias),n.emissiveMap&&(i.emissiveMap.value=n.emissiveMap),n.normalMap&&(i.normalMap.value=n.normalMap,i.normalScale.value.copy(n.normalScale),1===n.side&&i.normalScale.value.negate()),n.specularMap&&(i.specularMap.value=n.specularMap),n.alphaTest>0&&(i.alphaTest.value=n.alphaTest);const r=e.get(n).envMap;if(r&&(i.envMap.value=r,i.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,i.reflectivity.value=n.reflectivity,i.ior.value=n.ior,i.refractionRatio.value=n.refractionRatio),n.lightMap){i.lightMap.value=n.lightMap;const e=!0!==t.physicallyCorrectLights?Math.PI:1;i.lightMapIntensity.value=n.lightMapIntensity*e}let s,a;n.aoMap&&(i.aoMap.value=n.aoMap,i.aoMapIntensity.value=n.aoMapIntensity),n.map?s=n.map:n.specularMap?s=n.specularMap:n.displacementMap?s=n.displacementMap:n.normalMap?s=n.normalMap:n.bumpMap?s=n.bumpMap:n.roughnessMap?s=n.roughnessMap:n.metalnessMap?s=n.metalnessMap:n.alphaMap?s=n.alphaMap:n.emissiveMap?s=n.emissiveMap:n.clearcoatMap?s=n.clearcoatMap:n.clearcoatNormalMap?s=n.clearcoatNormalMap:n.clearcoatRoughnessMap?s=n.clearcoatRoughnessMap:n.iridescenceMap?s=n.iridescenceMap:n.iridescenceThicknessMap?s=n.iridescenceThicknessMap:n.specularIntensityMap?s=n.specularIntensityMap:n.specularColorMap?s=n.specularColorMap:n.transmissionMap?s=n.transmissionMap:n.thicknessMap?s=n.thicknessMap:n.sheenColorMap?s=n.sheenColorMap:n.sheenRoughnessMap&&(s=n.sheenRoughnessMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),i.uvTransform.value.copy(s.matrix)),n.aoMap?a=n.aoMap:n.lightMap&&(a=n.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),i.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,en(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,n,r,s,a){n.isMeshBasicMaterial||n.isMeshLambertMaterial?i(t,n):n.isMeshToonMaterial?(i(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,n)):n.isMeshPhongMaterial?(i(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,n)):n.isMeshStandardMaterial?(i(t,n),function(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap);i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap);const n=e.get(i).envMap;n&&(t.envMapIntensity.value=i.envMapIntensity)}(t,n),n.isMeshPhysicalMaterial&&function(t,e,i){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate()));e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=i.texture,t.transmissionSamplerSize.value.set(i.width,i.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap);e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,n,a)):n.isMeshMatcapMaterial?(i(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,n)):n.isMeshDepthMaterial?i(t,n):n.isMeshDistanceMaterial?(i(t,n),function(t,e){t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?i(t,n):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n,r,s):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Zs(t,e,i,n){let r={},s={},a=[];const o=i.isWebGL2?t.getParameter(35375):0;function l(t,e,i){const n=t.value;if(void 0===i[e]){if("number"==typeof n)i[e]=n;else{const t=Array.isArray(n)?n:[n],r=[];for(let e=0;e<t.length;e++)r.push(t[e].clone());i[e]=r}return!0}if("number"==typeof n){if(i[e]!==n)return i[e]=n,!0}else{const t=Array.isArray(i[e])?i[e]:[i[e]],r=Array.isArray(n)?n:[n];for(let e=0;e<t.length;e++){const i=t[e];if(!1===i.equals(r[e]))return i.copy(r[e]),!0}}return!1}function c(t){const e={boundary:0,storage:0};return"number"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),e}function h(e){const i=e.target;i.removeEventListener("dispose",h);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,u){let d=r[i.id];void 0===d&&(!function(t){const e=t.uniforms;let i=0;const n=16;let r=0;for(let t=0,s=e.length;t<s;t++){const s=e[t],a={boundary:0,storage:0},o=Array.isArray(s.value)?s.value:[s.value];for(let t=0,e=o.length;t<e;t++){const e=c(o[t]);a.boundary+=e.boundary,a.storage+=e.storage}if(s.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),s.__offset=i,t>0){r=i%n;0!==r&&n-r-a.boundary<0&&(i+=n-r,s.__offset=i)}i+=a.storage}r=i%n,r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(35345,n),t.bufferData(35345,r,s),t.bindBuffer(35345,null),t.bindBufferBase(35345,i,n),n}(i),r[i.id]=d,i.addEventListener("dispose",h));const p=u.program;n.updateUBOMapping(i,p);const m=e.render.frame;s[i.id]!==m&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(35345,i);for(let e=0,i=n.length;e<i;e++){const i=n[e];if(!0===l(i,e,s)){const e=i.__offset,n=Array.isArray(i.value)?i.value:[i.value];let r=0;for(let s=0;s<n.length;s++){const a=n[s],o=c(a);"number"==typeof a?(i.__data[0]=a,t.bufferSubData(35345,e+r,i.__data)):a.isMatrix3?(i.__data[0]=a.elements[0],i.__data[1]=a.elements[1],i.__data[2]=a.elements[2],i.__data[3]=a.elements[0],i.__data[4]=a.elements[3],i.__data[5]=a.elements[4],i.__data[6]=a.elements[5],i.__data[7]=a.elements[0],i.__data[8]=a.elements[6],i.__data[9]=a.elements[7],i.__data[10]=a.elements[8],i.__data[11]=a.elements[0]):(a.toArray(i.__data,r),r+=o.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(35345,e,i.__data)}}t.bindBuffer(35345,null)}(i),s[i.id]=m)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}function Js(t={}){this.isWebGLRenderer=!0;const i=void 0!==t.canvas?t.canvas:function(){const t=Bt("canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,r=void 0===t.depth||t.depth,s=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,o=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=void 0!==t.powerPreference?t.powerPreference:"default",h=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==t.alpha&&t.alpha;let d=null,p=null;const m=[],f=[];this.domElement=i,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ct,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const g=this;let _=!1,y=0,S=0,T=null,A=-1,E=null;const C=new ie,L=new ie;let R=null,P=i.width,I=i.height,D=1,N=null,O=null;const z=new ie(0,0,P,I),U=new ie(0,0,P,I);let B=!1;const F=new vn;let k=!1,G=!1,V=null;const H=new Ue,W=new It,j=new oe,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function X(){return null===T?D:1}let Y,Z,J,K,$,Q,tt,et,it,nt,rt,st,at,ot,lt,ht,ut,dt,pt,mt,ft,gt,vt,xt,_t=n;function yt(t,e){for(let n=0;n<t.length;n++){const r=t[n],s=i.getContext(r,e);if(null!==s)return s}return null}try{const t={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:l,powerPreference:c,failIfMajorPerformanceCaveat:h};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${e}`),i.addEventListener("webglcontextlost",St,!1),i.addEventListener("webglcontextrestored",wt,!1),i.addEventListener("webglcontextcreationerror",Tt,!1),null===_t){const e=["webgl2","webgl","experimental-webgl"];if(!0===g.isWebGL1Renderer&&e.shift(),_t=yt(e,t),null===_t)throw yt(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===_t.getShaderPrecisionFormat&&(_t.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function Mt(){Y=new Xn(_t),Z=new Cn(_t,Y,t),Y.init(Z),gt=new Gs(_t,Y,Z),J=new Fs(_t,Y,Z),K=new Jn,$=new Ts,Q=new ks(_t,Y,J,$,Z,gt,K),tt=new Rn(g),et=new qn(g),it=new _n(_t,Z),vt=new An(_t,Y,it,Z),nt=new Yn(_t,it,K,vt),rt=new tr(_t,nt,it,K),pt=new Qn(_t,Z,Q),ht=new Ln($),st=new ws(g,tt,et,Y,Z,vt,ht),at=new Ys(g,$),ot=new Ls,lt=new Os(Y,Z),dt=new Tn(g,tt,et,J,rt,u,o),ut=new Bs(g,rt,Z),xt=new Zs(_t,K,Z,J),mt=new En(_t,Y,K,Z),ft=new Zn(_t,Y,K,Z),K.programs=st.programs,g.capabilities=Z,g.extensions=Y,g.properties=$,g.renderLists=ot,g.shadowMap=ut,g.state=J,g.info=K}Mt();const bt=new Xs(g,_t);function St(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function wt(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;const t=K.autoReset,e=ut.enabled,i=ut.autoUpdate,n=ut.needsUpdate,r=ut.type;Mt(),K.autoReset=t,ut.enabled=e,ut.autoUpdate=i,ut.needsUpdate=n,ut.type=r}function Tt(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function At(t){const e=t.target;e.removeEventListener("dispose",At),function(t){(function(t){const e=$.get(t).programs;void 0!==e&&(e.forEach((function(t){st.releaseProgram(t)})),t.isShaderMaterial&&st.releaseShaderCache(t))})(t),$.remove(t)}(e)}this.xr=bt,this.getContext=function(){return _t},this.getContextAttributes=function(){return _t.getContextAttributes()},this.forceContextLoss=function(){const t=Y.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=Y.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return D},this.setPixelRatio=function(t){void 0!==t&&(D=t,this.setSize(P,I,!1))},this.getSize=function(t){return t.set(P,I)},this.setSize=function(t,e,n){bt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(P=t,I=e,i.width=Math.floor(t*D),i.height=Math.floor(e*D),!1!==n&&(i.style.width=t+"px",i.style.height=e+"px"),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(t){return t.set(P*D,I*D).floor()},this.setDrawingBufferSize=function(t,e,n){P=t,I=e,D=n,i.width=Math.floor(t*n),i.height=Math.floor(e*n),this.setViewport(0,0,t,e)},this.getCurrentViewport=function(t){return t.copy(C)},this.getViewport=function(t){return t.copy(z)},this.setViewport=function(t,e,i,n){t.isVector4?z.set(t.x,t.y,t.z,t.w):z.set(t,e,i,n),J.viewport(C.copy(z).multiplyScalar(D).floor())},this.getScissor=function(t){return t.copy(U)},this.setScissor=function(t,e,i,n){t.isVector4?U.set(t.x,t.y,t.z,t.w):U.set(t,e,i,n),J.scissor(L.copy(U).multiplyScalar(D).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){J.setScissorTest(B=t)},this.setOpaqueSort=function(t){N=t},this.setTransparentSort=function(t){O=t},this.getClearColor=function(t){return t.copy(dt.getClearColor())},this.setClearColor=function(){dt.setClearColor.apply(dt,arguments)},this.getClearAlpha=function(){return dt.getClearAlpha()},this.setClearAlpha=function(){dt.setClearAlpha.apply(dt,arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;t&&(n|=16384),e&&(n|=256),i&&(n|=1024),_t.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){i.removeEventListener("webglcontextlost",St,!1),i.removeEventListener("webglcontextrestored",wt,!1),i.removeEventListener("webglcontextcreationerror",Tt,!1),ot.dispose(),lt.dispose(),$.dispose(),tt.dispose(),et.dispose(),rt.dispose(),vt.dispose(),xt.dispose(),st.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",Lt),bt.removeEventListener("sessionend",Rt),V&&(V.dispose(),V=null),Pt.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=q);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=q);Q.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial?e.environment:null,o=null===T?g.outputEncoding:!0===T.isXRRenderTarget?T.texture.encoding:ct,l=(n.isMeshStandardMaterial?et:tt).get(n.envMap||a),c=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,h=!!n.normalMap&&!!i.attributes.tangent,u=!!i.morphAttributes.position,d=!!i.morphAttributes.normal,m=!!i.morphAttributes.color,f=n.toneMapped?g.toneMapping:0,v=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,x=void 0!==v?v.length:0,_=$.get(n),y=p.state.lights;if(!0===k&&(!0===G||t!==E)){const e=t===E&&n.id===A;ht.setState(n,t,e)}let M=!1;n.version===_.__version?_.needsLights&&_.lightsStateVersion!==y.state.version||_.outputEncoding!==o||r.isInstancedMesh&&!1===_.instancing?M=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?M=!0:r.isSkinnedMesh||!0!==_.skinning?_.envMap!==l||!0===n.fog&&_.fog!==s?M=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===ht.numPlanes&&_.numIntersection===ht.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==h||_.morphTargets!==u||_.morphNormals!==d||_.morphColors!==m||_.toneMapping!==f||!0===Z.isWebGL2&&_.morphTargetsCount!==x)&&(M=!0):M=!0:M=!0:M=!0:(M=!0,_.__version=n.version);let b=_.currentProgram;!0===M&&(b=Ut(n,e,r));let S=!1,w=!1,C=!1;const L=b.getUniforms(),R=_.uniforms;J.useProgram(b.program)&&(S=!0,w=!0,C=!0);n.id!==A&&(A=n.id,w=!0);if(S||E!==t){if(L.setValue(_t,"projectionMatrix",t.projectionMatrix),Z.logarithmicDepthBuffer&&L.setValue(_t,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),E!==t&&(E=t,w=!0,C=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const e=L.map.cameraPosition;void 0!==e&&e.setValue(_t,j.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&L.setValue(_t,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&L.setValue(_t,"viewMatrix",t.matrixWorldInverse)}if(r.isSkinnedMesh){L.setOptional(_t,r,"bindMatrix"),L.setOptional(_t,r,"bindMatrixInverse");const t=r.skeleton;t&&(Z.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),L.setValue(_t,"boneTexture",t.boneTexture,Q),L.setValue(_t,"boneTextureSize",t.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const P=i.morphAttributes;(void 0!==P.position||void 0!==P.normal||void 0!==P.color&&!0===Z.isWebGL2)&&pt.update(r,i,n,b);(w||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,L.setValue(_t,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);w&&(L.setValue(_t,"toneMappingExposure",g.toneMappingExposure),_.needsLights&&(O=C,(N=R).ambientLightColor.needsUpdate=O,N.lightProbe.needsUpdate=O,N.directionalLights.needsUpdate=O,N.directionalLightShadows.needsUpdate=O,N.pointLights.needsUpdate=O,N.pointLightShadows.needsUpdate=O,N.spotLights.needsUpdate=O,N.spotLightShadows.needsUpdate=O,N.rectAreaLights.needsUpdate=O,N.hemisphereLights.needsUpdate=O),s&&!0===n.fog&&at.refreshFogUniforms(R,s),at.refreshMaterialUniforms(R,n,D,I,V),rs.upload(_t,_.uniformsList,R,Q));var N,O;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(rs.upload(_t,_.uniformsList,R,Q),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&L.setValue(_t,"center",r.center);if(L.setValue(_t,"modelViewMatrix",r.modelViewMatrix),L.setValue(_t,"normalMatrix",r.normalMatrix),L.setValue(_t,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++)if(Z.isWebGL2){const i=t[e];xt.update(i,b),xt.bind(i,b)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return b}(t,e,i,n,r);J.setMaterial(n,a);let l=i.index,c=1;!0===n.wireframe&&(l=nt.getWireframeAttribute(i),c=2);const h=i.drawRange,u=i.attributes.position;let d=h.start*c,m=(h.start+h.count)*c;null!==s&&(d=Math.max(d,s.start*c),m=Math.min(m,(s.start+s.count)*c)),null!==l?(d=Math.max(d,0),m=Math.min(m,l.count)):null!=u&&(d=Math.max(d,0),m=Math.min(m,u.count));const f=m-d;if(f<0||f===1/0)return;let v;vt.setup(r,n,o,i,l);let x=mt;if(null!==l&&(v=it.get(l),x=ft,x.setIndex(v)),r.isMesh)!0===n.wireframe?(J.setLineWidth(n.wireframeLinewidth*X()),x.setMode(1)):x.setMode(4);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),J.setLineWidth(t*X()),r.isLineSegments?x.setMode(1):r.isLineLoop?x.setMode(2):x.setMode(3)}else r.isPoints?x.setMode(0):r.isSprite&&x.setMode(4);if(r.isInstancedMesh)x.renderInstances(d,f,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);x.renderInstances(d,f,e)}else x.render(d,f)},this.compile=function(t,e){function i(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,Ut(t,e,i),t.side=0,t.needsUpdate=!0,Ut(t,e,i),t.side=2):Ut(t,e,i)}p=lt.get(t),p.init(),f.push(p),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(p.pushLight(t),t.castShadow&&p.pushShadow(t))})),p.setupLights(g.physicallyCorrectLights),t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++){i(n[r],t,e)}else i(n,t,e)})),f.pop(),p=null};let Et=null;function Lt(){Pt.stop()}function Rt(){Pt.start()}const Pt=new xn;function Dt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)p.pushLight(t),t.castShadow&&p.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||F.intersectsSprite(t)){n&&j.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);const e=rt.update(t),r=t.material;r.visible&&d.push(t,e,r,i,j.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==K.render.frame&&(t.skeleton.update(),t.skeleton.frame=K.render.frame),!t.frustumCulled||F.intersectsObject(t))){n&&j.setFromMatrixPosition(t.matrixWorld).applyMatrix4(H);const e=rt.update(t),r=t.material;if(Array.isArray(r)){const n=e.groups;for(let s

/* …… 文件过大已截断(原 2371 KB),完整文件见官方仓库 https://github.com/MengTo/threeui …… */
[/hidecontent]
← 返回首页