@shgroup/dsh-serenity-hooks 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/README.md +56 -0
- package/assets/serenity-voyage-preview.png +0 -0
- package/assets/serenity-voyage.html +2755 -0
- package/dsh.plugin.json +1 -1
- package/lib/client.js +14 -5
- package/lib/index.js +138 -68
- package/lib/seams/keeper.d.ts +10 -4
- package/lib/voyage-page.d.ts +45 -0
- package/package.json +4 -1
|
@@ -0,0 +1,2755 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
6
|
+
<meta name="color-scheme" content="dark">
|
|
7
|
+
<title>Serenity · 认知星空</title>
|
|
8
|
+
<style>
|
|
9
|
+
:root{
|
|
10
|
+
--ink:#d8ece6;
|
|
11
|
+
--ink-2:#8fb3aa;
|
|
12
|
+
--ink-3:#5f7f79;
|
|
13
|
+
--jade:#7fe3c4;
|
|
14
|
+
--amber:#ffcf7a;
|
|
15
|
+
--glass:rgba(9,20,25,.40);
|
|
16
|
+
--glass-line:rgba(150,220,205,.15);
|
|
17
|
+
--shadow:0 10px 40px rgba(0,0,0,.45);
|
|
18
|
+
--hei:"Heiti SC","STHeiti","PingFang SC","Hiragino Sans GB","Source Han Sans SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
|
|
19
|
+
--latin:system-ui,-apple-system,"Helvetica Neue","Segoe UI",Roboto,sans-serif;
|
|
20
|
+
--ping:"PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
|
|
21
|
+
--mono:"SF Mono",ui-monospace,Menlo,Consolas,monospace;
|
|
22
|
+
}
|
|
23
|
+
*{box-sizing:border-box;margin:0;padding:0}
|
|
24
|
+
html,body{height:100%;overflow:hidden;background:#02050a}
|
|
25
|
+
body{font-family:var(--ping);color:var(--ink);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
|
|
26
|
+
|
|
27
|
+
#gl{position:fixed;inset:0;display:block;width:100%;height:100%}
|
|
28
|
+
|
|
29
|
+
.veil{
|
|
30
|
+
position:fixed;inset:0;pointer-events:none;
|
|
31
|
+
background:
|
|
32
|
+
radial-gradient(135% 95% at 50% 44%,transparent 46%,rgba(0,0,0,.55) 100%),
|
|
33
|
+
linear-gradient(to bottom,rgba(3,8,12,.4),transparent 24%,transparent 74%,rgba(1,4,8,.5));
|
|
34
|
+
}
|
|
35
|
+
.grain{
|
|
36
|
+
position:fixed;inset:0;pointer-events:none;opacity:.045;mix-blend-mode:overlay;
|
|
37
|
+
background-image:radial-gradient(rgba(255,255,255,.9) 1px,transparent 1px);
|
|
38
|
+
background-size:3px 3px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ui{position:fixed;inset:0;pointer-events:none;padding:clamp(16px,2.6vw,40px);
|
|
42
|
+
display:flex;flex-direction:column;justify-content:space-between}
|
|
43
|
+
.row{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
|
|
44
|
+
.row.bottom{align-items:flex-end}
|
|
45
|
+
|
|
46
|
+
/* ---------- 品牌区 ---------- */
|
|
47
|
+
.brand{max-width:min(54vw,560px)}
|
|
48
|
+
.eyebrow{font-size:clamp(10px,.95vw,12px);letter-spacing:.44em;color:var(--ink-3);margin-bottom:13px}
|
|
49
|
+
.brand h1{
|
|
50
|
+
font-family:var(--latin);font-weight:700;
|
|
51
|
+
font-size:clamp(38px,6vw,86px);letter-spacing:.09em;line-height:1.02;
|
|
52
|
+
/* 深色描边压住发光:星场亮起来后,纯辉光 text-shadow 会让标题被背景字符吃掉层次 */
|
|
53
|
+
text-shadow:0 2px 40px rgba(80,220,190,.24),
|
|
54
|
+
0 2px 5px rgba(0,0,0,.9),
|
|
55
|
+
0 0 26px rgba(0,0,0,.75);
|
|
56
|
+
}
|
|
57
|
+
.eyebrow,.brand p{text-shadow:0 1px 3px rgba(0,0,0,.92),0 0 16px rgba(0,0,0,.8)}
|
|
58
|
+
.brand p{margin-top:15px;font-size:clamp(12px,1.15vw,15px);line-height:1.9;color:var(--ink-2);letter-spacing:.08em}
|
|
59
|
+
.brand p .l2{display:block;color:var(--ink-3);font-size:.94em;margin-top:3px}
|
|
60
|
+
|
|
61
|
+
/* ---------- 状态 ---------- */
|
|
62
|
+
.status{
|
|
63
|
+
display:flex;align-items:center;gap:10px;padding:9px 16px;border-radius:999px;
|
|
64
|
+
background:var(--glass);border:1px solid var(--glass-line);
|
|
65
|
+
backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
|
|
66
|
+
font-size:clamp(10px,1vw,12px);letter-spacing:.16em;color:var(--ink-2);white-space:nowrap;
|
|
67
|
+
}
|
|
68
|
+
.dot{width:7px;height:7px;border-radius:50%;background:var(--jade);
|
|
69
|
+
box-shadow:0 0 12px 2px rgba(127,227,196,.7);animation:breathe 3s ease-in-out infinite}
|
|
70
|
+
@keyframes breathe{0%,100%{opacity:.35;transform:scale(.82)}50%{opacity:1;transform:scale(1)}}
|
|
71
|
+
|
|
72
|
+
/* ---------- 左下:航速读数(自行起伏,无需操作)---------- */
|
|
73
|
+
.speed{display:flex;align-items:flex-end;gap:9px}
|
|
74
|
+
.speed .num{
|
|
75
|
+
font-family:var(--mono);font-weight:600;font-size:clamp(44px,7.2vw,100px);line-height:.86;
|
|
76
|
+
font-variant-numeric:tabular-nums;letter-spacing:-.02em;color:#eafff8;
|
|
77
|
+
text-shadow:0 0 44px rgba(127,227,196,.32);
|
|
78
|
+
}
|
|
79
|
+
.speed .unit{display:flex;flex-direction:column;gap:7px;padding-bottom:8px}
|
|
80
|
+
.speed .unit b{font-size:clamp(11px,1.1vw,14px);font-weight:500;color:var(--ink-2);letter-spacing:.3em}
|
|
81
|
+
.speed .unit em{font-style:normal;font-size:clamp(10px,1vw,12px);color:var(--ink-3);letter-spacing:.16em}
|
|
82
|
+
|
|
83
|
+
/* ---------- 右下:容器规模(被动事实陈列)---------- */
|
|
84
|
+
.facts{
|
|
85
|
+
display:grid;grid-template-columns:auto auto;gap:3px 16px;
|
|
86
|
+
font-size:clamp(9.5px,1vw,12px);line-height:1.7;
|
|
87
|
+
padding:14px 18px;border-radius:16px;
|
|
88
|
+
background:var(--glass);border:1px solid var(--glass-line);
|
|
89
|
+
backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
|
|
90
|
+
}
|
|
91
|
+
.facts span{color:var(--ink-3);letter-spacing:.14em}
|
|
92
|
+
.facts b{color:var(--amber);font-weight:600;text-align:right;font-variant-numeric:tabular-nums}
|
|
93
|
+
|
|
94
|
+
footer{
|
|
95
|
+
text-align:center;font-family:var(--hei);
|
|
96
|
+
font-size:clamp(11px,1.05vw,13.5px);letter-spacing:.34em;color:var(--ink-3);
|
|
97
|
+
padding-top:16px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* ---------- 加载 / 错误 ---------- */
|
|
101
|
+
#load{
|
|
102
|
+
position:fixed;inset:0;z-index:40;display:grid;place-items:center;background:#02050a;
|
|
103
|
+
transition:opacity .9s ease;
|
|
104
|
+
font-family:var(--hei);font-size:clamp(13px,1.4vw,17px);letter-spacing:.44em;color:var(--ink-2);
|
|
105
|
+
}
|
|
106
|
+
#load b{display:block;font-weight:400;animation:fade 2.2s ease-in-out infinite}
|
|
107
|
+
@keyframes fade{0%,100%{opacity:.4}50%{opacity:1}}
|
|
108
|
+
#load.off{opacity:0;pointer-events:none}
|
|
109
|
+
|
|
110
|
+
#err{position:fixed;inset:0;z-index:50;display:none;place-items:center;padding:24px;background:rgba(2,5,10,.95)}
|
|
111
|
+
#err.on{display:grid}
|
|
112
|
+
#err .card{max-width:520px;padding:30px 32px;border-radius:20px;
|
|
113
|
+
background:rgba(11,24,29,.75);border:1px solid var(--glass-line);box-shadow:var(--shadow)}
|
|
114
|
+
#err h2{font-family:var(--hei);font-size:20px;letter-spacing:.2em;margin-bottom:14px;color:var(--amber)}
|
|
115
|
+
#err p{font-size:13px;line-height:2;color:var(--ink-2);letter-spacing:.06em}
|
|
116
|
+
#err code{font-family:var(--mono);font-size:11px;color:var(--ink-3);word-break:break-all}
|
|
117
|
+
|
|
118
|
+
/* ---------- 响应式 ---------- */
|
|
119
|
+
@media (max-width:900px){ .brand{max-width:76vw} }
|
|
120
|
+
@media (max-width:680px){
|
|
121
|
+
.ui{padding:16px}
|
|
122
|
+
.row{flex-direction:column;align-items:flex-start}
|
|
123
|
+
.row.bottom{flex-direction:row;align-items:flex-end}
|
|
124
|
+
.brand h1{letter-spacing:.12em}
|
|
125
|
+
.status{position:absolute;top:16px;right:16px;font-size:10px}
|
|
126
|
+
.facts{display:none}
|
|
127
|
+
}
|
|
128
|
+
@media (max-height:560px){
|
|
129
|
+
.brand p{display:none}
|
|
130
|
+
.brand h1{font-size:clamp(26px,4.2vw,42px)}
|
|
131
|
+
.speed .num{font-size:clamp(32px,5.6vw,54px)}
|
|
132
|
+
.facts{display:none}
|
|
133
|
+
footer{display:none}
|
|
134
|
+
}
|
|
135
|
+
@media (prefers-reduced-motion:reduce){
|
|
136
|
+
.dot{animation:none}
|
|
137
|
+
#load b{animation:none}
|
|
138
|
+
*{transition-duration:.01ms !important}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* ---------- 卡片模式(?card=1,2026-09-15 S142)----------
|
|
142
|
+
用途:作为 CCC 卡片展开态的**背景层**。同一套引擎,但作品自带的一整层 UI
|
|
143
|
+
(标题 / 品牌语 / 状态胶囊 / 航速 / 事实面板)与加载页全部让位——那些文字
|
|
144
|
+
属于全屏构图,在 340px 卡片里会与宿主正文抢戏(实测结论)。
|
|
145
|
+
只留:认知星野 + 飞船 + 一层更淡的暗角。 */
|
|
146
|
+
body.card .ui, body.card #load, body.card #err{display:none !important}
|
|
147
|
+
body.card .veil{opacity:.45}
|
|
148
|
+
body.card .grain{opacity:.26}
|
|
149
|
+
</style>
|
|
150
|
+
</head>
|
|
151
|
+
<body>
|
|
152
|
+
<canvas id="gl" role="img" aria-label="三维动画:宁静号飞船在由代码字符构成的认知星野中航行。"></canvas>
|
|
153
|
+
<div class="veil" aria-hidden="true"></div>
|
|
154
|
+
<div class="grain" aria-hidden="true"></div>
|
|
155
|
+
|
|
156
|
+
<div class="ui">
|
|
157
|
+
<div class="row">
|
|
158
|
+
<div class="brand">
|
|
159
|
+
<h1>Serenity</h1>
|
|
160
|
+
<p>不赶路,只航行</p>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="status" role="status" aria-live="polite">
|
|
163
|
+
<span class="dot" aria-hidden="true"></span>
|
|
164
|
+
<span>航行中</span>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div class="row bottom">
|
|
169
|
+
<div class="speed">
|
|
170
|
+
<div class="num" id="speedNum" aria-hidden="true">26</div>
|
|
171
|
+
<div class="unit">
|
|
172
|
+
<b>节</b>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="facts" role="group" aria-label="宁静号容器规模">
|
|
176
|
+
<span>仓库</span><b id="m-repo">—</b>
|
|
177
|
+
<span>技能</span><b id="m-skill">—</b>
|
|
178
|
+
<span>工具</span><b id="m-msm">—</b>
|
|
179
|
+
<span>本体</span><b id="m-onto">—</b>
|
|
180
|
+
<span>公理</span><b id="m-axiom">—</b>
|
|
181
|
+
<span>会话</span><b id="m-sess">—</b>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div id="load"><b>航线正在展开…</b></div>
|
|
187
|
+
<div id="err" role="alert">
|
|
188
|
+
<div class="card">
|
|
189
|
+
<h2>航线没能展开</h2>
|
|
190
|
+
<p id="errMsg">浏览器未能启动 WebGL 三维渲染。请尝试更新浏览器、开启硬件加速,或改用 Chrome / Edge / Safari 打开本文件。</p>
|
|
191
|
+
<p style="margin-top:14px"><code id="errDetail"></code></p>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<noscript>
|
|
195
|
+
<div style="position:fixed;inset:0;display:grid;place-items:center;background:#02050a;color:#d8ece6;
|
|
196
|
+
font-family:var(--hei);letter-spacing:.3em;z-index:60">
|
|
197
|
+
需要启用 JavaScript,宁静号才能起航。
|
|
198
|
+
</div>
|
|
199
|
+
</noscript>
|
|
200
|
+
|
|
201
|
+
<script>
|
|
202
|
+
/* three.js r180 · core+module 合并为全局 THREE(由 build.ts 机械转换生成) */
|
|
203
|
+
(function(){
|
|
204
|
+
"use strict";
|
|
205
|
+
var __CORE = (function(){
|
|
206
|
+
"use strict";
|
|
207
|
+
/**
|
|
208
|
+
* @license
|
|
209
|
+
* Copyright 2010-2025 Three.js Authors
|
|
210
|
+
* SPDX-License-Identifier: MIT
|
|
211
|
+
*/
|
|
212
|
+
const t="180",e={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},s={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},i=0,r=1,n=2,a=3,o=0,h=1,l=2,c=3,u=0,d=1,p=2,m=0,y=1,g=2,f=3,x=4,b=5,v=100,w=101,M=102,S=103,_=104,A=200,T=201,z=202,C=203,I=204,B=205,k=206,E=207,R=208,P=209,O=210,N=211,V=212,F=213,L=214,j=0,D=1,W=2,U=3,H=4,q=5,J=6,X=7,Y=0,Z=1,G=2,$=0,Q=1,K=2,tt=3,et=4,st=5,it=6,rt=7,nt="attached",at="detached",ot=300,ht=301,lt=302,ct=303,ut=304,dt=306,pt=1e3,mt=1001,yt=1002,gt=1003,ft=1004,xt=1004,bt=1005,vt=1005,wt=1006,Mt=1007,St=1007,_t=1008,At=1008,Tt=1009,zt=1010,Ct=1011,It=1012,Bt=1013,kt=1014,Et=1015,Rt=1016,Pt=1017,Ot=1018,Nt=1020,Vt=35902,Ft=35899,Lt=1021,jt=1022,Dt=1023,Wt=1026,Ut=1027,Ht=1028,qt=1029,Jt=1030,Xt=1031,Yt=1032,Zt=1033,Gt=33776,$t=33777,Qt=33778,Kt=33779,te=35840,ee=35841,se=35842,ie=35843,re=36196,ne=37492,ae=37496,oe=37808,he=37809,le=37810,ce=37811,ue=37812,de=37813,pe=37814,me=37815,ye=37816,ge=37817,fe=37818,xe=37819,be=37820,ve=37821,we=36492,Me=36494,Se=36495,_e=36283,Ae=36284,Te=36285,ze=36286,Ce=2200,Ie=2201,Be=2202,ke=2300,Ee=2301,Re=2302,Pe=2400,Oe=2401,Ne=2402,Ve=2500,Fe=2501,Le=0,je=1,De=2,We=3200,Ue=3201,He=3202,qe=3203,Je=0,Xe=1,Ye="",Ze="srgb",Ge="srgb-linear",$e="linear",Qe="srgb",Ke=0,ts=7680,es=7681,ss=7682,is=7683,rs=34055,ns=34056,as=5386,os=512,hs=513,ls=514,cs=515,us=516,ds=517,ps=518,ms=519,ys=512,gs=513,fs=514,xs=515,bs=516,vs=517,ws=518,Ms=519,Ss=35044,_s=35048,As=35040,Ts=35045,zs=35049,Cs=35041,Is=35046,Bs=35050,ks=35042,Es="100",Rs="300 es",Ps=2e3,Os=2001,Ns={COMPUTE:"compute",RENDER:"render"},Vs={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},Fs={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};class Ls{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const s=this._listeners;void 0===s[t]&&(s[t]=[]),-1===s[t].indexOf(e)&&s[t].push(e)}hasEventListener(t,e){const s=this._listeners;return void 0!==s&&(void 0!==s[t]&&-1!==s[t].indexOf(e))}removeEventListener(t,e){const s=this._listeners;if(void 0===s)return;const i=s[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const s=e[t.type];if(void 0!==s){t.target=this;const e=s.slice(0);for(let s=0,i=e.length;s<i;s++)e[s].call(this,t);t.target=null}}}const js=["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 Ds=1234567;const Ws=Math.PI/180,Us=180/Math.PI;function Hs(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,s=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(js[255&t]+js[t>>8&255]+js[t>>16&255]+js[t>>24&255]+"-"+js[255&e]+js[e>>8&255]+"-"+js[e>>16&15|64]+js[e>>24&255]+"-"+js[63&s|128]+js[s>>8&255]+"-"+js[s>>16&255]+js[s>>24&255]+js[255&i]+js[i>>8&255]+js[i>>16&255]+js[i>>24&255]).toLowerCase()}function qs(t,e,s){return Math.max(e,Math.min(s,t))}function Js(t,e){return(t%e+e)%e}function Xs(t,e,s){return(1-s)*t+s*e}function Ys(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Zs(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Gs={DEG2RAD:Ws,RAD2DEG:Us,generateUUID:Hs,clamp:qs,euclideanModulo:Js,mapLinear:function(t,e,s,i,r){return i+(t-e)*(r-i)/(s-e)},inverseLerp:function(t,e,s){return t!==e?(s-t)/(e-t):0},lerp:Xs,damp:function(t,e,s,i){return Xs(t,e,1-Math.exp(-s*i))},pingpong:function(t,e=1){return e-Math.abs(Js(t,2*e)-e)},smoothstep:function(t,e,s){return t<=e?0:t>=s?1:(t=(t-e)/(s-e))*t*(3-2*t)},smootherstep:function(t,e,s){return t<=e?0:t>=s?1:(t=(t-e)/(s-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Ds=t);let e=Ds+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Ws},radToDeg:function(t){return t*Us},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,s,i,r){const n=Math.cos,a=Math.sin,o=n(s/2),h=a(s/2),l=n((e+i)/2),c=a((e+i)/2),u=n((e-i)/2),d=a((e-i)/2),p=n((i-e)/2),m=a((i-e)/2);switch(r){case"XYX":t.set(o*c,h*u,h*d,o*l);break;case"YZY":t.set(h*d,o*c,h*u,o*l);break;case"ZXZ":t.set(h*u,h*d,o*c,o*l);break;case"XZX":t.set(o*c,h*m,h*p,o*l);break;case"YXY":t.set(h*p,o*c,h*m,o*l);break;case"ZYZ":t.set(h*m,h*p,o*c,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Zs,denormalize:Ys};class $s{constructor(t=0,e=0){$s.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,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[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=qs(this.x,t.x,e.x),this.y=qs(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=qs(this.x,t,e),this.y=qs(this.y,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(qs(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(qs(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}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,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,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 s=Math.cos(e),i=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*s-n*i+t.x,this.y=r*i+n*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Qs{constructor(t=0,e=0,s=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=s,this._w=i}static slerpFlat(t,e,s,i,r,n,a){let o=s[i+0],h=s[i+1],l=s[i+2],c=s[i+3];const u=r[n+0],d=r[n+1],p=r[n+2],m=r[n+3];if(0===a)return t[e+0]=o,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===a)return t[e+0]=u,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==u||h!==d||l!==p){let t=1-a;const e=o*u+h*d+l*p+c*m,s=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),n=Math.atan2(r,e*s);t=Math.sin(t*n)/r,a=Math.sin(a*n)/r}const r=a*s;if(o=o*t+u*r,h=h*t+d*r,l=l*t+p*r,c=c*t+m*r,t===1-a){const t=1/Math.sqrt(o*o+h*h+l*l+c*c);o*=t,h*=t,l*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,s,i,r,n){const a=s[i],o=s[i+1],h=s[i+2],l=s[i+3],c=r[n],u=r[n+1],d=r[n+2],p=r[n+3];return t[e]=a*p+l*c+o*d-h*u,t[e+1]=o*p+l*u+h*c-a*d,t[e+2]=h*p+l*d+a*u-o*c,t[e+3]=l*p-a*c-o*u-h*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,s,i){return this._x=t,this._y=e,this._z=s,this._w=i,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=!0){const s=t._x,i=t._y,r=t._z,n=t._order,a=Math.cos,o=Math.sin,h=a(s/2),l=a(i/2),c=a(r/2),u=o(s/2),d=o(i/2),p=o(r/2);switch(n){case"XYZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"YXZ":this._x=u*l*c+h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"ZXY":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c-u*d*p;break;case"ZYX":this._x=u*l*c-h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c+u*d*p;break;case"YZX":this._x=u*l*c+h*d*p,this._y=h*d*c+u*l*p,this._z=h*l*p-u*d*c,this._w=h*l*c-u*d*p;break;case"XZY":this._x=u*l*c-h*d*p,this._y=h*d*c-u*l*p,this._z=h*l*p+u*d*c,this._w=h*l*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,i=Math.sin(s);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],i=e[4],r=e[8],n=e[1],a=e[5],o=e[9],h=e[2],l=e[6],c=e[10],u=s+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(n-i)*t}else if(s>a&&s>c){const t=2*Math.sqrt(1+s-a-c);this._w=(l-o)/t,this._x=.25*t,this._y=(i+n)/t,this._z=(r+h)/t}else if(a>c){const t=2*Math.sqrt(1+a-s-c);this._w=(r-h)/t,this._x=(i+n)/t,this._y=.25*t,this._z=(o+l)/t}else{const t=2*Math.sqrt(1+c-s-a);this._w=(n-i)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<1e-8?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(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=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(qs(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(0===s)return this;const i=Math.min(1,e/s);return this.slerp(t,i),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 s=t._x,i=t._y,r=t._z,n=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=s*l+n*a+i*h-r*o,this._y=i*l+n*o+r*a-s*h,this._z=r*l+n*h+s*o-i*a,this._w=n*l-s*a-i*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const s=this._x,i=this._y,r=this._z,n=this._w;let a=n*t._w+s*t._x+i*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=n,this._x=s,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*n+e*this._w,this._x=t*s+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(o),l=Math.atan2(h,a),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=n*c+this._w*u,this._x=s*c+this._x*u,this._y=i*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}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._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ks{constructor(t=0,e=0,s=0){Ks.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return void 0===s&&(s=this.z),this.x=t,this.y=e,this.z=s,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(ei.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ei.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6]*i,this.y=r[1]*e+r[4]*s+r[7]*i,this.z=r[2]*e+r[5]*s+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,i=this.z,r=t.elements,n=1/(r[3]*e+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*s+r[8]*i+r[12])*n,this.y=(r[1]*e+r[5]*s+r[9]*i+r[13])*n,this.z=(r[2]*e+r[6]*s+r[10]*i+r[14])*n,this}applyQuaternion(t){const e=this.x,s=this.y,i=this.z,r=t.x,n=t.y,a=t.z,o=t.w,h=2*(n*i-a*s),l=2*(a*e-r*i),c=2*(r*s-n*e);return this.x=e+o*h+n*c-a*l,this.y=s+o*l+a*h-r*c,this.z=i+o*c+r*l-n*h,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,s=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*s+r[8]*i,this.y=r[1]*e+r[5]*s+r[9]*i,this.z=r[2]*e+r[6]*s+r[10]*i,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=qs(this.x,t.x,e.x),this.y=qs(this.y,t.y,e.y),this.z=qs(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=qs(this.x,t,e),this.y=qs(this.y,t,e),this.z=qs(this.z,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(qs(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,i=t.y,r=t.z,n=e.x,a=e.y,o=e.z;return this.x=i*o-r*a,this.y=r*n-s*o,this.z=s*a-i*n,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return ti.copy(this).projectOnVector(t),this.sub(ti)}reflect(t){return this.sub(ti.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 s=this.dot(t)/e;return Math.acos(qs(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}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,s){const i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,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(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,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}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,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=Math.random()*Math.PI*2,e=2*Math.random()-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ti=new Ks,ei=new Qs;class si{constructor(t,e,s,i,r,n,a,o,h){si.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,s,i,r,n,a,o,h)}set(t,e,s,i,r,n,a,o,h){const l=this.elements;return l[0]=t,l[1]=i,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=s,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.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 s=t.elements,i=e.elements,r=this.elements,n=s[0],a=s[3],o=s[6],h=s[1],l=s[4],c=s[7],u=s[2],d=s[5],p=s[8],m=i[0],y=i[3],g=i[6],f=i[1],x=i[4],b=i[7],v=i[2],w=i[5],M=i[8];return r[0]=n*m+a*f+o*v,r[3]=n*y+a*x+o*w,r[6]=n*g+a*b+o*M,r[1]=h*m+l*f+c*v,r[4]=h*y+l*x+c*w,r[7]=h*g+l*b+c*M,r[2]=u*m+d*f+p*v,r[5]=u*y+d*x+p*w,r[8]=u*g+d*b+p*M,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],s=t[1],i=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*n*l-e*a*h-s*r*l+s*a*o+i*r*h-i*n*o}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=l*n-a*h,u=a*o-l*r,d=h*r-n*o,p=e*c+s*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=c*m,t[1]=(i*h-l*s)*m,t[2]=(a*s-i*n)*m,t[3]=u*m,t[4]=(l*e-i*o)*m,t[5]=(i*r-a*e)*m,t[6]=d*m,t[7]=(s*o-h*e)*m,t[8]=(n*e-s*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,s,i,r,n,a){const o=Math.cos(r),h=Math.sin(r);return this.set(s*o,s*h,-s*(o*n+h*a)+n+t,-i*h,i*o,-i*(-h*n+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ii.makeScale(t,e)),this}rotate(t){return this.premultiply(ii.makeRotation(-t)),this}translate(t,e){return this.premultiply(ii.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,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,s=t.elements;for(let t=0;t<9;t++)if(e[t]!==s[t])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ii=new si;function ri(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}const ni={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ai(t,e){return new ni[t](e)}function oi(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function hi(){const t=oi("canvas");return t.style.display="block",t}const li={};function ci(t){t in li||(li[t]=!0,console.warn(t))}function ui(t,e,s){return new Promise(function(i,r){setTimeout(function n(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(n,s);break;default:i()}},s)})}const di=(new si).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pi=(new si).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function mi(){const t={enabled:!0,workingColorSpace:Ge,spaces:{},convert:function(t,e,s){return!1!==this.enabled&&e!==s&&e&&s?(this.spaces[e].transfer===Qe&&(t.r=gi(t.r),t.g=gi(t.g),t.b=gi(t.b)),this.spaces[e].primaries!==this.spaces[s].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Qe&&(t.r=fi(t.r),t.g=fi(t.g),t.b=fi(t.b)),t):t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?$e:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,s){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,s){return ci("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,s)},toWorkingColorSpace:function(e,s){return ci("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,s)}},e=[.64,.33,.3,.6,.15,.06],s=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Ge]:{primaries:e,whitePoint:i,transfer:$e,toXYZ:di,fromXYZ:pi,luminanceCoefficients:s,workingColorSpaceConfig:{unpackColorSpace:Ze},outputColorSpaceConfig:{drawingBufferColorSpace:Ze}},[Ze]:{primaries:e,whitePoint:i,transfer:Qe,toXYZ:di,fromXYZ:pi,luminanceCoefficients:s,outputColorSpaceConfig:{drawingBufferColorSpace:Ze}}}),t}const yi=mi();function gi(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function fi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let xi;class bi{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let s;if(t instanceof HTMLCanvasElement)s=t;else{void 0===xi&&(xi=oi("canvas")),xi.width=t.width,xi.height=t.height;const e=xi.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),s=xi}return s.toDataURL(e)}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=oi("canvas");e.width=t.width,e.height=t.height;const s=e.getContext("2d");s.drawImage(t,0,0,t.width,t.height);const i=s.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*gi(r[t]/255);return s.putImageData(i,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*gi(e[t]/255)):e[t]=gi(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}}let vi=0;class wi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:vi++}),this.uuid=Hs(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}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 s={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,s=i.length;e<s;e++)i[e].isDataTexture?t.push(Mi(i[e].image)):t.push(Mi(i[e]))}else t=Mi(i);s.url=t}return e||(t.images[this.uuid]=s),s}}function Mi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?bi.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 Si=0;const _i=new Ks;class Ai extends Ls{constructor(t=Ai.DEFAULT_IMAGE,e=Ai.DEFAULT_MAPPING,s=1001,i=1001,r=1006,n=1008,a=1023,o=1009,h=Ai.DEFAULT_ANISOTROPY,l=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Si++}),this.uuid=Hs(),this.name="",this.source=new wi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=r,this.minFilter=n,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new $s(0,0),this.repeat=new $s(1,1),this.center=new $s(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new si,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(_i).x}get height(){return this.source.getSize(_i).y}get depth(){return this.source.getSize(_i).z}get image(){return this.source.data}set image(t=null){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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.channel=t.channel,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.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const s=t[e];if(void 0===s){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[e]=s:console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),e||(t.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ot)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case pt:t.x=t.x-Math.floor(t.x);break;case mt:t.x=t.x<0?0:1;break;case yt: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 pt:t.y=t.y-Math.floor(t.y);break;case mt:t.y=t.y<0?0:1;break;case yt: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)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}Ai.DEFAULT_IMAGE=null,Ai.DEFAULT_MAPPING=ot,Ai.DEFAULT_ANISOTROPY=1;class Ti{constructor(t=0,e=0,s=0,i=1){Ti.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}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,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,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,s=this.y,i=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i+n[12]*r,this.y=n[1]*e+n[5]*s+n[9]*i+n[13]*r,this.z=n[2]*e+n[6]*s+n[10]*i+n[14]*r,this.w=n[3]*e+n[7]*s+n[11]*i+n[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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,s,i,r;const n=.01,a=.1,o=t.elements,h=o[0],l=o[4],c=o[8],u=o[1],d=o[5],p=o[9],m=o[2],y=o[6],g=o[10];if(Math.abs(l-u)<n&&Math.abs(c-m)<n&&Math.abs(p-y)<n){if(Math.abs(l+u)<a&&Math.abs(c+m)<a&&Math.abs(p+y)<a&&Math.abs(h+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,o=(d+1)/2,f=(g+1)/2,x=(l+u)/4,b=(c+m)/4,v=(p+y)/4;return t>o&&t>f?t<n?(s=0,i=.707106781,r=.707106781):(s=Math.sqrt(t),i=x/s,r=b/s):o>f?o<n?(s=.707106781,i=0,r=.707106781):(i=Math.sqrt(o),s=x/i,r=v/i):f<n?(s=.707106781,i=.707106781,r=0):(r=Math.sqrt(f),s=b/r,i=v/r),this.set(s,i,r,e),this}let f=Math.sqrt((y-p)*(y-p)+(c-m)*(c-m)+(u-l)*(u-l));return Math.abs(f)<.001&&(f=1),this.x=(y-p)/f,this.y=(c-m)/f,this.z=(u-l)/f,this.w=Math.acos((h+d+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],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=qs(this.x,t.x,e.x),this.y=qs(this.y,t.y,e.y),this.z=qs(this.z,t.z,e.z),this.w=qs(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=qs(this.x,t,e),this.y=qs(this.y,t,e),this.z=qs(this.z,t,e),this.w=qs(this.w,t,e),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(qs(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,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 zi extends Ls{constructor(t=1,e=1,s={}){super(),s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},s),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=s.depth,this.scissor=new Ti(0,0,t,e),this.scissorTest=!1,this.viewport=new Ti(0,0,t,e);const i={width:t,height:e,depth:s.depth},r=new Ai(i);this.textures=[];const n=s.count;for(let t=0;t<n;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(s),this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=s.depthTexture,this.samples=s.samples,this.multiview=s.multiview}_setTextureOptions(t={}){const e={minFilter:wt,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==t.mapping&&(e.mapping=t.mapping),void 0!==t.wrapS&&(e.wrapS=t.wrapS),void 0!==t.wrapT&&(e.wrapT=t.wrapT),void 0!==t.wrapR&&(e.wrapR=t.wrapR),void 0!==t.magFilter&&(e.magFilter=t.magFilter),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.format&&(e.format=t.format),void 0!==t.type&&(e.type=t.type),void 0!==t.anisotropy&&(e.anisotropy=t.anisotropy),void 0!==t.colorSpace&&(e.colorSpace=t.colorSpace),void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.generateMipmaps&&(e.generateMipmaps=t.generateMipmaps),void 0!==t.internalFormat&&(e.internalFormat=t.internalFormat);for(let t=0;t<this.textures.length;t++){this.textures[t].setValues(e)}}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==t&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,s=1){if(this.width!==t||this.height!==e||this.depth!==s){this.width=t,this.height=e,this.depth=s;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=s,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;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.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,s=t.textures.length;e<s;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const s=Object.assign({},t.textures[e].image);this.textures[e].source=new wi(s)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ci extends zi{constructor(t=1,e=1,s={}){super(t,e,s),this.isWebGLRenderTarget=!0}}class Ii extends Ai{constructor(t=null,e=1,s=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:s,depth:i},this.magFilter=gt,this.minFilter=gt,this.wrapR=mt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Bi extends Ci{constructor(t=1,e=1,s=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=s,this.texture=new Ii(null,t,e,s),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class ki extends Ai{constructor(t=null,e=1,s=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:s,depth:i},this.magFilter=gt,this.minFilter=gt,this.wrapR=mt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ei extends Ci{constructor(t=1,e=1,s=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=s,this.texture=new ki(null,t,e,s),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Ri{constructor(t=new Ks(1/0,1/0,1/0),e=new Ks(-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){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(Oi.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,s=t.count;e<s;e++)this.expandByPoint(Oi.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Oi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),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 s=t.geometry;if(void 0!==s){const i=s.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,s=i.count;e<s;e++)!0===t.isMesh?t.getVertexPosition(e,Oi):Oi.fromBufferAttribute(i,e),Oi.applyMatrix4(t.matrixWorld),this.expandByPoint(Oi);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Ni.copy(t.boundingBox)):(null===s.boundingBox&&s.computeBoundingBox(),Ni.copy(s.boundingBox)),Ni.applyMatrix4(t.matrixWorld),this.union(Ni)}const i=t.children;for(let t=0,s=i.length;t<s;t++)this.expandByObject(i[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,Oi),Oi.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ui),Hi.subVectors(this.max,Ui),Vi.subVectors(t.a,Ui),Fi.subVectors(t.b,Ui),Li.subVectors(t.c,Ui),ji.subVectors(Fi,Vi),Di.subVectors(Li,Fi),Wi.subVectors(Vi,Li);let e=[0,-ji.z,ji.y,0,-Di.z,Di.y,0,-Wi.z,Wi.y,ji.z,0,-ji.x,Di.z,0,-Di.x,Wi.z,0,-Wi.x,-ji.y,ji.x,0,-Di.y,Di.x,0,-Wi.y,Wi.x,0];return!!Xi(e,Vi,Fi,Li,Hi)&&(e=[1,0,0,0,1,0,0,0,1],!!Xi(e,Vi,Fi,Li,Hi)&&(qi.crossVectors(ji,Di),e=[qi.x,qi.y,qi.z],Xi(e,Vi,Fi,Li,Hi)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Oi).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(Oi).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()||(Pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pi)),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Pi=[new Ks,new Ks,new Ks,new Ks,new Ks,new Ks,new Ks,new Ks],Oi=new Ks,Ni=new Ri,Vi=new Ks,Fi=new Ks,Li=new Ks,ji=new Ks,Di=new Ks,Wi=new Ks,Ui=new Ks,Hi=new Ks,qi=new Ks,Ji=new Ks;function Xi(t,e,s,i,r){for(let n=0,a=t.length-3;n<=a;n+=3){Ji.fromArray(t,n);const a=r.x*Math.abs(Ji.x)+r.y*Math.abs(Ji.y)+r.z*Math.abs(Ji.z),o=e.dot(Ji),h=s.dot(Ji),l=i.dot(Ji);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>a)return!1}return!0}const Yi=new Ri,Zi=new Ks,Gi=new Ks;class $i{constructor(t=new Ks,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const s=this.center;void 0!==e?s.copy(e):Yi.setFromPoints(t).getCenter(s);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,s.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),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 s=this.center.distanceToSquared(t);return e.copy(t),s>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;Zi.subVectors(t,this.center);const e=Zi.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),s=.5*(t-this.radius);this.center.addScaledVector(Zi,s/t),this.radius+=s}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):(Gi.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Zi.copy(t.center).add(Gi)),this.expandByPoint(Zi.copy(t.center).sub(Gi))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Qi=new Ks,Ki=new Ks,tr=new Ks,er=new Ks,sr=new Ks,ir=new Ks,rr=new Ks;class nr{constructor(t=new Ks,e=new Ks(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.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Qi)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const s=e.dot(this.direction);return s<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Qi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Qi.copy(this.origin).addScaledVector(this.direction,e),Qi.distanceToSquared(t))}distanceSqToSegment(t,e,s,i){Ki.copy(t).add(e).multiplyScalar(.5),tr.copy(e).sub(t).normalize(),er.copy(this.origin).sub(Ki);const r=.5*t.distanceTo(e),n=-this.direction.dot(tr),a=er.dot(this.direction),o=-er.dot(tr),h=er.lengthSq(),l=Math.abs(1-n*n);let c,u,d,p;if(l>0)if(c=n*o-a,u=n*a-o,p=r*l,c>=0)if(u>=-p)if(u<=p){const t=1/l;c*=t,u*=t,d=c*(c+n*u+2*a)+u*(n*c+u+2*o)+h}else u=r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u=-r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;else u<=-p?(c=Math.max(0,-(-n*r+a)),u=c>0?-r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h):u<=p?(c=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+h):(c=Math.max(0,-(n*r+a)),u=c>0?r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+h);else u=n>0?-r:r,c=Math.max(0,-(n*u+a)),d=-c*c+u*(u+2*o)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,c),i&&i.copy(Ki).addScaledVector(tr,u),d}intersectSphere(t,e){Qi.subVectors(t.center,this.origin);const s=Qi.dot(this.direction),i=Qi.dot(Qi)-s*s,r=t.radius*t.radius;if(i>r)return null;const n=Math.sqrt(r-i),a=s-n,o=s+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&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 s=-(this.origin.dot(t.normal)+t.constant)/e;return s>=0?s:null}intersectPlane(t,e){const s=this.distanceToPlane(t);return null===s?null:this.at(s,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 s,i,r,n,a,o;const h=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return h>=0?(s=(t.min.x-u.x)*h,i=(t.max.x-u.x)*h):(s=(t.max.x-u.x)*h,i=(t.min.x-u.x)*h),l>=0?(r=(t.min.y-u.y)*l,n=(t.max.y-u.y)*l):(r=(t.max.y-u.y)*l,n=(t.min.y-u.y)*l),s>n||r>i?null:((r>s||isNaN(s))&&(s=r),(n<i||isNaN(i))&&(i=n),c>=0?(a=(t.min.z-u.z)*c,o=(t.max.z-u.z)*c):(a=(t.max.z-u.z)*c,o=(t.min.z-u.z)*c),s>o||a>i?null:((a>s||s!=s)&&(s=a),(o<i||i!=i)&&(i=o),i<0?null:this.at(s>=0?s:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Qi)}intersectTriangle(t,e,s,i,r){sr.subVectors(e,t),ir.subVectors(s,t),rr.crossVectors(sr,ir);let n,a=this.direction.dot(rr);if(a>0){if(i)return null;n=1}else{if(!(a<0))return null;n=-1,a=-a}er.subVectors(this.origin,t);const o=n*this.direction.dot(ir.crossVectors(er,ir));if(o<0)return null;const h=n*this.direction.dot(sr.cross(er));if(h<0)return null;if(o+h>a)return null;const l=-n*er.dot(rr);return l<0?null:this.at(l/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 ar{constructor(t,e,s,i,r,n,a,o,h,l,c,u,d,p,m,y){ar.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,s,i,r,n,a,o,h,l,c,u,d,p,m,y)}set(t,e,s,i,r,n,a,o,h,l,c,u,d,p,m,y){const g=this.elements;return g[0]=t,g[4]=e,g[8]=s,g[12]=i,g[1]=r,g[5]=n,g[9]=a,g[13]=o,g[2]=h,g[6]=l,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=y,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 ar).fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[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,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,i=1/or.setFromMatrixColumn(t,0).length(),r=1/or.setFromMatrixColumn(t,1).length(),n=1/or.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*r,e[5]=s[5]*r,e[6]=s[6]*r,e[7]=0,e[8]=s[8]*n,e[9]=s[9]*n,e[10]=s[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,s=t.x,i=t.y,r=t.z,n=Math.cos(s),a=Math.sin(s),o=Math.cos(i),h=Math.sin(i),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=n*l,s=n*c,i=a*l,r=a*c;e[0]=o*l,e[4]=-o*c,e[8]=h,e[1]=s+i*h,e[5]=t-r*h,e[9]=-a*o,e[2]=r-t*h,e[6]=i+s*h,e[10]=n*o}else if("YXZ"===t.order){const t=o*l,s=o*c,i=h*l,r=h*c;e[0]=t+r*a,e[4]=i*a-s,e[8]=n*h,e[1]=n*c,e[5]=n*l,e[9]=-a,e[2]=s*a-i,e[6]=r+t*a,e[10]=n*o}else if("ZXY"===t.order){const t=o*l,s=o*c,i=h*l,r=h*c;e[0]=t-r*a,e[4]=-n*c,e[8]=i+s*a,e[1]=s+i*a,e[5]=n*l,e[9]=r-t*a,e[2]=-n*h,e[6]=a,e[10]=n*o}else if("ZYX"===t.order){const t=n*l,s=n*c,i=a*l,r=a*c;e[0]=o*l,e[4]=i*h-s,e[8]=t*h+r,e[1]=o*c,e[5]=r*h+t,e[9]=s*h-i,e[2]=-h,e[6]=a*o,e[10]=n*o}else if("YZX"===t.order){const t=n*o,s=n*h,i=a*o,r=a*h;e[0]=o*l,e[4]=r-t*c,e[8]=i*c+s,e[1]=c,e[5]=n*l,e[9]=-a*l,e[2]=-h*l,e[6]=s*c+i,e[10]=t-r*c}else if("XZY"===t.order){const t=n*o,s=n*h,i=a*o,r=a*h;e[0]=o*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=n*l,e[9]=s*c-i,e[2]=i*c-s,e[6]=a*l,e[10]=r*c+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(lr,t,cr)}lookAt(t,e,s){const i=this.elements;return pr.subVectors(t,e),0===pr.lengthSq()&&(pr.z=1),pr.normalize(),ur.crossVectors(s,pr),0===ur.lengthSq()&&(1===Math.abs(s.z)?pr.x+=1e-4:pr.z+=1e-4,pr.normalize(),ur.crossVectors(s,pr)),ur.normalize(),dr.crossVectors(pr,ur),i[0]=ur.x,i[4]=dr.x,i[8]=pr.x,i[1]=ur.y,i[5]=dr.y,i[9]=pr.y,i[2]=ur.z,i[6]=dr.z,i[10]=pr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,i=e.elements,r=this.elements,n=s[0],a=s[4],o=s[8],h=s[12],l=s[1],c=s[5],u=s[9],d=s[13],p=s[2],m=s[6],y=s[10],g=s[14],f=s[3],x=s[7],b=s[11],v=s[15],w=i[0],M=i[4],S=i[8],_=i[12],A=i[1],T=i[5],z=i[9],C=i[13],I=i[2],B=i[6],k=i[10],E=i[14],R=i[3],P=i[7],O=i[11],N=i[15];return r[0]=n*w+a*A+o*I+h*R,r[4]=n*M+a*T+o*B+h*P,r[8]=n*S+a*z+o*k+h*O,r[12]=n*_+a*C+o*E+h*N,r[1]=l*w+c*A+u*I+d*R,r[5]=l*M+c*T+u*B+d*P,r[9]=l*S+c*z+u*k+d*O,r[13]=l*_+c*C+u*E+d*N,r[2]=p*w+m*A+y*I+g*R,r[6]=p*M+m*T+y*B+g*P,r[10]=p*S+m*z+y*k+g*O,r[14]=p*_+m*C+y*E+g*N,r[3]=f*w+x*A+b*I+v*R,r[7]=f*M+x*T+b*B+v*P,r[11]=f*S+x*z+b*k+v*O,r[15]=f*_+x*C+b*E+v*N,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],s=t[4],i=t[8],r=t[12],n=t[1],a=t[5],o=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*o*c-i*h*c-r*a*u+s*h*u+i*a*d-s*o*d)+t[7]*(+e*o*d-e*h*u+r*n*u-i*n*d+i*h*l-r*o*l)+t[11]*(+e*h*c-e*a*d-r*n*c+s*n*d+r*a*l-s*h*l)+t[15]*(-i*a*l-e*o*c+e*a*u+i*n*c-s*n*u+s*o*l)}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,s){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],i=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],p=t[12],m=t[13],y=t[14],g=t[15],f=c*y*h-m*u*h+m*o*d-a*y*d-c*o*g+a*u*g,x=p*u*h-l*y*h-p*o*d+n*y*d+l*o*g-n*u*g,b=l*m*h-p*c*h+p*a*d-n*m*d-l*a*g+n*c*g,v=p*c*o-l*m*o-p*a*u+n*m*u+l*a*y-n*c*y,w=e*f+s*x+i*b+r*v;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/w;return t[0]=f*M,t[1]=(m*u*r-c*y*r-m*i*d+s*y*d+c*i*g-s*u*g)*M,t[2]=(a*y*r-m*o*r+m*i*h-s*y*h-a*i*g+s*o*g)*M,t[3]=(c*o*r-a*u*r-c*i*h+s*u*h+a*i*d-s*o*d)*M,t[4]=x*M,t[5]=(l*y*r-p*u*r+p*i*d-e*y*d-l*i*g+e*u*g)*M,t[6]=(p*o*r-n*y*r-p*i*h+e*y*h+n*i*g-e*o*g)*M,t[7]=(n*u*r-l*o*r+l*i*h-e*u*h-n*i*d+e*o*d)*M,t[8]=b*M,t[9]=(p*c*r-l*m*r-p*s*d+e*m*d+l*s*g-e*c*g)*M,t[10]=(n*m*r-p*a*r+p*s*h-e*m*h-n*s*g+e*a*g)*M,t[11]=(l*a*r-n*c*r-l*s*h+e*c*h+n*s*d-e*a*d)*M,t[12]=v*M,t[13]=(l*m*i-p*c*i+p*s*u-e*m*u-l*s*y+e*c*y)*M,t[14]=(p*a*i-n*m*i-p*s*o+e*m*o+n*s*y-e*a*y)*M,t[15]=(n*c*i-l*a*i+l*s*o-e*c*o-n*s*u+e*a*u)*M,this}scale(t){const e=this.elements,s=t.x,i=t.y,r=t.z;return e[0]*=s,e[4]*=i,e[8]*=r,e[1]*=s,e[5]*=i,e[9]*=r,e[2]*=s,e[6]*=i,e[10]*=r,e[3]*=s,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),i=Math.sin(e),r=1-s,n=t.x,a=t.y,o=t.z,h=r*n,l=r*a;return this.set(h*n+s,h*a-i*o,h*o+i*a,0,h*a+i*o,l*a+s,l*o-i*n,0,h*o-i*a,l*o+i*n,r*o*o+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,r,n){return this.set(1,s,r,0,t,1,n,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){const i=this.elements,r=e._x,n=e._y,a=e._z,o=e._w,h=r+r,l=n+n,c=a+a,u=r*h,d=r*l,p=r*c,m=n*l,y=n*c,g=a*c,f=o*h,x=o*l,b=o*c,v=s.x,w=s.y,M=s.z;return i[0]=(1-(m+g))*v,i[1]=(d+b)*v,i[2]=(p-x)*v,i[3]=0,i[4]=(d-b)*w,i[5]=(1-(u+g))*w,i[6]=(y+f)*w,i[7]=0,i[8]=(p+x)*M,i[9]=(y-f)*M,i[10]=(1-(u+m))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){const i=this.elements;let r=or.set(i[0],i[1],i[2]).length();const n=or.set(i[4],i[5],i[6]).length(),a=or.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],hr.copy(this);const o=1/r,h=1/n,l=1/a;return hr.elements[0]*=o,hr.elements[1]*=o,hr.elements[2]*=o,hr.elements[4]*=h,hr.elements[5]*=h,hr.elements[6]*=h,hr.elements[8]*=l,hr.elements[9]*=l,hr.elements[10]*=l,e.setFromRotationMatrix(hr),s.x=r,s.y=n,s.z=a,this}makePerspective(t,e,s,i,r,n,a=2e3,o=!1){const h=this.elements,l=2*r/(e-t),c=2*r/(s-i),u=(e+t)/(e-t),d=(s+i)/(s-i);let p,m;if(o)p=r/(n-r),m=n*r/(n-r);else if(a===Ps)p=-(n+r)/(n-r),m=-2*n*r/(n-r);else{if(a!==Os)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-n/(n-r),m=-n*r/(n-r)}return h[0]=l,h[4]=0,h[8]=u,h[12]=0,h[1]=0,h[5]=c,h[9]=d,h[13]=0,h[2]=0,h[6]=0,h[10]=p,h[14]=m,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,e,s,i,r,n,a=2e3,o=!1){const h=this.elements,l=2/(e-t),c=2/(s-i),u=-(e+t)/(e-t),d=-(s+i)/(s-i);let p,m;if(o)p=1/(n-r),m=n/(n-r);else if(a===Ps)p=-2/(n-r),m=-(n+r)/(n-r);else{if(a!==Os)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=-1/(n-r),m=-r/(n-r)}return h[0]=l,h[4]=0,h[8]=0,h[12]=u,h[1]=0,h[5]=c,h[9]=0,h[13]=d,h[2]=0,h[6]=0,h[10]=p,h[14]=m,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(t){const e=this.elements,s=t.elements;for(let t=0;t<16;t++)if(e[t]!==s[t])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}}const or=new Ks,hr=new ar,lr=new Ks(0,0,0),cr=new Ks(1,1,1),ur=new Ks,dr=new Ks,pr=new Ks,mr=new ar,yr=new Qs;class gr{constructor(t=0,e=0,s=0,i=gr.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=s,this._order=i}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,s,i=this._order){return this._x=t,this._y=e,this._z=s,this._order=i,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,s=!0){const i=t.elements,r=i[0],n=i[4],a=i[8],o=i[1],h=i[5],l=i[9],c=i[2],u=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(qs(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-qs(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(qs(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-qs(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(qs(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-qs(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===s&&this._onChangeCallback(),this}setFromQuaternion(t,e,s){return mr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(mr,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return yr.setFromEuler(this),this.setFromQuaternion(yr,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}}gr.DEFAULT_ORDER="XYZ";class fr{constructor(){this.mask=1}set(t){this.mask=1<<t>>>0}enable(t){this.mask|=1<<t}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t}disable(t){this.mask&=~(1<<t)}disableAll(){this.mask=0}test(t){return 0!==(this.mask&t.mask)}isEnabled(t){return!!(this.mask&1<<t)}}let xr=0;const br=new Ks,vr=new Qs,wr=new ar,Mr=new Ks,Sr=new Ks,_r=new Ks,Ar=new Qs,Tr=new Ks(1,0,0),zr=new Ks(0,1,0),Cr=new Ks(0,0,1),Ir={type:"added"},Br={type:"removed"},kr={type:"childadded",child:null},Er={type:"childremoved",child:null};class Rr extends Ls{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xr++}),this.uuid=Hs(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Rr.DEFAULT_UP.clone();const t=new Ks,e=new gr,s=new Qs,i=new Ks(1,1,1);e._onChange(function(){s.setFromEuler(e,!1)}),s._onChange(function(){e.setFromQuaternion(s,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:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ar},normalMatrix:{value:new si}}),this.matrix=new ar,this.matrixWorld=new ar,this.matrixAutoUpdate=Rr.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Rr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}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 vr.setFromAxisAngle(t,e),this.quaternion.multiply(vr),this}rotateOnWorldAxis(t,e){return vr.setFromAxisAngle(t,e),this.quaternion.premultiply(vr),this}rotateX(t){return this.rotateOnAxis(Tr,t)}rotateY(t){return this.rotateOnAxis(zr,t)}rotateZ(t){return this.rotateOnAxis(Cr,t)}translateOnAxis(t,e){return br.copy(t).applyQuaternion(this.quaternion),this.position.add(br.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Tr,t)}translateY(t){return this.translateOnAxis(zr,t)}translateZ(t){return this.translateOnAxis(Cr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(wr.copy(this.matrixWorld).invert())}lookAt(t,e,s){t.isVector3?Mr.copy(t):Mr.set(t,e,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Sr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wr.lookAt(Sr,Mr,this.up):wr.lookAt(Mr,Sr,this.up),this.quaternion.setFromRotationMatrix(wr),i&&(wr.extractRotation(i.matrixWorld),vr.setFromRotationMatrix(wr),this.quaternion.premultiply(vr.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?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Ir),kr.child=t,this.dispatchEvent(kr),kr.child=null):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(Br),Er.child=t,this.dispatchEvent(Er),Er.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),wr.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),wr.multiply(t.parent.matrixWorld)),t.applyMatrix4(wr),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Ir),kr.child=t,this.dispatchEvent(kr),kr.child=null,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 s=0,i=this.children.length;s<i;s++){const i=this.children[s].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,s=[]){this[t]===e&&s.push(this);const i=this.children;for(let r=0,n=i.length;r<n;r++)i[r].getObjectsByProperty(t,e,s);return s}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sr,t,_r),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Sr,Ar,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 s=0,i=e.length;s<i;s++)e[s].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let s=0,i=e.length;s<i;s++)e[s].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)&&(!0===this.matrixWorldAutoUpdate&&(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 s=0,i=e.length;s<i;s++){e[s].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const s=this.parent;if(!0===t&&null!==s&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(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,s=t.length;e<s;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,s={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,s){return void 0===e[s.uuid]&&(e[s.uuid]=s.toJSON(t)),s.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(t=>({...t})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const s=e.shapes;if(Array.isArray(s))for(let e=0,i=s.length;e<i;e++){const i=s[e];r(t.shapes,i)}else r(t.shapes,s)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let s=0,i=this.material.length;s<i;s++)e.push(r(t.materials,this.material[s]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const s=this.animations[e];i.animations.push(r(t.animations,s))}}if(e){const e=n(t.geometries),i=n(t.materials),r=n(t.textures),a=n(t.images),o=n(t.shapes),h=n(t.skeletons),l=n(t.animations),c=n(t.nodes);e.length>0&&(s.geometries=e),i.length>0&&(s.materials=i),r.length>0&&(s.textures=r),a.length>0&&(s.images=a),o.length>0&&(s.shapes=o),h.length>0&&(s.skeletons=h),l.length>0&&(s.animations=l),c.length>0&&(s.nodes=c)}return s.object=i,s;function n(t){const e=[];for(const s in t){const i=t[s];delete i.metadata,e.push(i)}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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,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.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const s=t.children[e];this.add(s.clone())}return this}}Rr.DEFAULT_UP=new Ks(0,1,0),Rr.DEFAULT_MATRIX_AUTO_UPDATE=!0,Rr.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Pr=new Ks,Or=new Ks,Nr=new Ks,Vr=new Ks,Fr=new Ks,Lr=new Ks,jr=new Ks,Dr=new Ks,Wr=new Ks,Ur=new Ks,Hr=new Ti,qr=new Ti,Jr=new Ti;class Xr{constructor(t=new Ks,e=new Ks,s=new Ks){this.a=t,this.b=e,this.c=s}static getNormal(t,e,s,i){i.subVectors(s,e),Pr.subVectors(t,e),i.cross(Pr);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,s,i,r){Pr.subVectors(i,e),Or.subVectors(s,e),Nr.subVectors(t,e);const n=Pr.dot(Pr),a=Pr.dot(Or),o=Pr.dot(Nr),h=Or.dot(Or),l=Or.dot(Nr),c=n*h-a*a;if(0===c)return r.set(0,0,0),null;const u=1/c,d=(h*o-a*l)*u,p=(n*l-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,s,i){return null!==this.getBarycoord(t,e,s,i,Vr)&&(Vr.x>=0&&Vr.y>=0&&Vr.x+Vr.y<=1)}static getInterpolation(t,e,s,i,r,n,a,o){return null===this.getBarycoord(t,e,s,i,Vr)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,Vr.x),o.addScaledVector(n,Vr.y),o.addScaledVector(a,Vr.z),o)}static getInterpolatedAttribute(t,e,s,i,r,n){return Hr.setScalar(0),qr.setScalar(0),Jr.setScalar(0),Hr.fromBufferAttribute(t,e),qr.fromBufferAttribute(t,s),Jr.fromBufferAttribute(t,i),n.setScalar(0),n.addScaledVector(Hr,r.x),n.addScaledVector(qr,r.y),n.addScaledVector(Jr,r.z),n}static isFrontFacing(t,e,s,i){return Pr.subVectors(s,e),Or.subVectors(t,e),Pr.cross(Or).dot(i)<0}set(t,e,s){return this.a.copy(t),this.b.copy(e),this.c.copy(s),this}setFromPointsAndIndices(t,e,s,i){return this.a.copy(t[e]),this.b.copy(t[s]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,s,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,s),this.c.fromBufferAttribute(t,i),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 Pr.subVectors(this.c,this.b),Or.subVectors(this.a,this.b),.5*Pr.cross(Or).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Xr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Xr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,s,i,r){return Xr.getInterpolation(t,this.a,this.b,this.c,e,s,i,r)}containsPoint(t){return Xr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Xr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const s=this.a,i=this.b,r=this.c;let n,a;Fr.subVectors(i,s),Lr.subVectors(r,s),Dr.subVectors(t,s);const o=Fr.dot(Dr),h=Lr.dot(Dr);if(o<=0&&h<=0)return e.copy(s);Wr.subVectors(t,i);const l=Fr.dot(Wr),c=Lr.dot(Wr);if(l>=0&&c<=l)return e.copy(i);const u=o*c-l*h;if(u<=0&&o>=0&&l<=0)return n=o/(o-l),e.copy(s).addScaledVector(Fr,n);Ur.subVectors(t,r);const d=Fr.dot(Ur),p=Lr.dot(Ur);if(p>=0&&d<=p)return e.copy(r);const m=d*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(s).addScaledVector(Lr,a);const y=l*p-d*c;if(y<=0&&c-l>=0&&d-p>=0)return jr.subVectors(r,i),a=(c-l)/(c-l+(d-p)),e.copy(i).addScaledVector(jr,a);const g=1/(y+m+u);return n=m*g,a=u*g,e.copy(s).addScaledVector(Fr,n).addScaledVector(Lr,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Yr={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},Zr={h:0,s:0,l:0},Gr={h:0,s:0,l:0};function $r(t,e,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+6*(e-t)*(2/3-s):t}class Qr{constructor(t,e,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,s)}set(t,e,s){if(void 0===e&&void 0===s){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,s);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ze){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,yi.colorSpaceToWorking(this,e),this}setRGB(t,e,s,i=yi.workingColorSpace){return this.r=t,this.g=e,this.b=s,yi.colorSpaceToWorking(this,i),this}setHSL(t,e,s,i=yi.workingColorSpace){if(t=Js(t,1),e=qs(e,0,1),s=qs(s,0,1),0===e)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+e):s+e-s*e,r=2*s-i;this.r=$r(r,i,t+1/3),this.g=$r(r,i,t),this.b=$r(r,i,t-1/3)}return yi.colorSpaceToWorking(this,i),this}setStyle(t,e=Ze){function s(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const n=i[1],a=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],r=s.length;if(3===r)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ze){const s=Yr[t.toLowerCase()];return void 0!==s?this.setHex(s,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=gi(t.r),this.g=gi(t.g),this.b=gi(t.b),this}copyLinearToSRGB(t){return this.r=fi(t.r),this.g=fi(t.g),this.b=fi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ze){return yi.workingToColorSpace(Kr.copy(this),t),65536*Math.round(qs(255*Kr.r,0,255))+256*Math.round(qs(255*Kr.g,0,255))+Math.round(qs(255*Kr.b,0,255))}getHexString(t=Ze){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=yi.workingColorSpace){yi.workingToColorSpace(Kr.copy(this),e);const s=Kr.r,i=Kr.g,r=Kr.b,n=Math.max(s,i,r),a=Math.min(s,i,r);let o,h;const l=(a+n)/2;if(a===n)o=0,h=0;else{const t=n-a;switch(h=l<=.5?t/(n+a):t/(2-n-a),n){case s:o=(i-r)/t+(i<r?6:0);break;case i:o=(r-s)/t+2;break;case r:o=(s-i)/t+4}o/=6}return t.h=o,t.s=h,t.l=l,t}getRGB(t,e=yi.workingColorSpace){return yi.workingToColorSpace(Kr.copy(this),e),t.r=Kr.r,t.g=Kr.g,t.b=Kr.b,t}getStyle(t=Ze){yi.workingToColorSpace(Kr.copy(this),t);const e=Kr.r,s=Kr.g,i=Kr.b;return t!==Ze?`color(${t} ${e.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*s)},${Math.round(255*i)})`}offsetHSL(t,e,s){return this.getHSL(Zr),this.setHSL(Zr.h+t,Zr.s+e,Zr.l+s)}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,s){return this.r=t.r+(e.r-t.r)*s,this.g=t.g+(e.g-t.g)*s,this.b=t.b+(e.b-t.b)*s,this}lerpHSL(t,e){this.getHSL(Zr),t.getHSL(Gr);const s=Xs(Zr.h,Gr.h,e),i=Xs(Zr.s,Gr.s,e),r=Xs(Zr.l,Gr.l,e);return this.setHSL(s,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,s=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*s+r[6]*i,this.g=r[1]*e+r[4]*s+r[7]*i,this.b=r[2]*e+r[5]*s+r[8]*i,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}}const Kr=new Qr;Qr.NAMES=Yr;let tn=0;class en extends Ls{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:tn++}),this.uuid=Hs(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Qr(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ts,this.stencilZFail=ts,this.stencilZPass=ts,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const s=t[e];if(void 0===s){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[e]=s:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const s={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(t){const e=[];for(const s in t){const i=t[s];delete i.metadata,e.push(i)}return e}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),void 0!==this.roughness&&(s.roughness=this.roughness),void 0!==this.metalness&&(s.metalness=this.metalness),void 0!==this.sheen&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(s.shininess=this.shininess),void 0!==this.clearcoat&&(s.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(s.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(s.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(s.dispersion=this.dispersion),void 0!==this.iridescence&&(s.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(s.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(s.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(t).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(t).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(t).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(t).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(t).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(s.combine=this.combine)),void 0!==this.envMapRotation&&(s.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(s.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(s.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(s.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(s.size=this.size),null!==this.shadowSide&&(s.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(s.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(s.blending=this.blending),0!==this.side&&(s.side=this.side),!0===this.vertexColors&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),!0===this.transparent&&(s.transparent=!0),204!==this.blendSrc&&(s.blendSrc=this.blendSrc),205!==this.blendDst&&(s.blendDst=this.blendDst),100!==this.blendEquation&&(s.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(s.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(s.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(s.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(s.depthFunc=this.depthFunc),!1===this.depthTest&&(s.depthTest=this.depthTest),!1===this.depthWrite&&(s.depthWrite=this.depthWrite),!1===this.colorWrite&&(s.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(s.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(s.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(s.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ts&&(s.stencilFail=this.stencilFail),this.stencilZFail!==ts&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==ts&&(s.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(s.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(s.rotation=this.rotation),!0===this.polygonOffset&&(s.polygonOffset=!0),0!==this.polygonOffsetFactor&&(s.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(s.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(s.linewidth=this.linewidth),void 0!==this.dashSize&&(s.dashSize=this.dashSize),void 0!==this.gapSize&&(s.gapSize=this.gapSize),void 0!==this.scale&&(s.scale=this.scale),!0===this.dithering&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),!0===this.alphaHash&&(s.alphaHash=!0),!0===this.alphaToCoverage&&(s.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(s.premultipliedAlpha=!0),!0===this.forceSinglePass&&(s.forceSinglePass=!0),!0===this.wireframe&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(s.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(s.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(s.flatShading=!0),!1===this.visible&&(s.visible=!1),!1===this.toneMapped&&(s.toneMapped=!1),!1===this.fog&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData),e){const e=i(t.textures),r=i(t.images);e.length>0&&(s.textures=e),r.length>0&&(s.images=r)}return s}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.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,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 s=null;if(null!==e){const t=e.length;s=new Array(t);for(let i=0;i!==t;++i)s[i]=e[i].clone()}return this.clippingPlanes=s,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.alphaHash=t.alphaHash,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 sn extends en{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gr,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.envMapRotation.copy(t.envMapRotation),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 rn=nn();function nn(){const t=new ArrayBuffer(4),e=new Float32Array(t),s=new Uint32Array(t),i=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){const e=t-127;e<-27?(i[t]=0,i[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(i[t]=1024>>-e-14,i[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(i[t]=e+15<<10,i[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(i[t]=31744,i[256|t]=64512,r[t]=24,r[256|t]=24):(i[t]=31744,i[256|t]=64512,r[t]=13,r[256|t]=13)}const n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,s=0;for(;!(8388608&e);)e<<=1,s-=8388608;e&=-8388609,s+=947912704,n[t]=e|s}for(let t=1024;t<2048;++t)n[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:s,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}function an(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=qs(t,-65504,65504),rn.floatView[0]=t;const e=rn.uint32View[0],s=e>>23&511;return rn.baseTable[s]+((8388607&e)>>rn.shiftTable[s])}function on(t){const e=t>>10;return rn.uint32View[0]=rn.mantissaTable[rn.offsetTable[e]+(1023&t)]+rn.exponentTable[e],rn.floatView[0]}class hn{static toHalfFloat(t){return an(t)}static fromHalfFloat(t){return on(t)}}const ln=new Ks,cn=new $s;let un=0;class dn{constructor(t,e,s=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:un++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=s,this.usage=Ss,this.updateRanges=[],this.gpuType=Et,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.gpuType=t.gpuType,this}copyAt(t,e,s){t*=this.itemSize,s*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[s+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,s=this.count;e<s;e++)cn.fromBufferAttribute(this,e),cn.applyMatrix3(t),this.setXY(e,cn.x,cn.y);else if(3===this.itemSize)for(let e=0,s=this.count;e<s;e++)ln.fromBufferAttribute(this,e),ln.applyMatrix3(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}applyMatrix4(t){for(let e=0,s=this.count;e<s;e++)ln.fromBufferAttribute(this,e),ln.applyMatrix4(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)ln.fromBufferAttribute(this,e),ln.applyNormalMatrix(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)ln.fromBufferAttribute(this,e),ln.transformDirection(t),this.setXYZ(e,ln.x,ln.y,ln.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let s=this.array[t*this.itemSize+e];return this.normalized&&(s=Ys(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=Zs(s,this.array)),this.array[t*this.itemSize+e]=s,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ys(e,this.array)),e}setX(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ys(e,this.array)),e}setY(t,e){return this.normalized&&(e=Zs(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=Ys(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Zs(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=Ys(e,this.array)),e}setW(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array)),this.array[t+0]=e,this.array[t+1]=s,this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,this}setXYZW(t,e,s,i,r){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array),r=Zs(r,this.array)),this.array[t+0]=e,this.array[t+1]=s,this.array[t+2]=i,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!==Ss&&(t.usage=this.usage),t}}class pn extends dn{constructor(t,e,s){super(new Int8Array(t),e,s)}}class mn extends dn{constructor(t,e,s){super(new Uint8Array(t),e,s)}}class yn extends dn{constructor(t,e,s){super(new Uint8ClampedArray(t),e,s)}}class gn extends dn{constructor(t,e,s){super(new Int16Array(t),e,s)}}class fn extends dn{constructor(t,e,s){super(new Uint16Array(t),e,s)}}class xn extends dn{constructor(t,e,s){super(new Int32Array(t),e,s)}}class bn extends dn{constructor(t,e,s){super(new Uint32Array(t),e,s)}}class vn extends dn{constructor(t,e,s){super(new Uint16Array(t),e,s),this.isFloat16BufferAttribute=!0}getX(t){let e=on(this.array[t*this.itemSize]);return this.normalized&&(e=Ys(e,this.array)),e}setX(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize]=an(e),this}getY(t){let e=on(this.array[t*this.itemSize+1]);return this.normalized&&(e=Ys(e,this.array)),e}setY(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize+1]=an(e),this}getZ(t){let e=on(this.array[t*this.itemSize+2]);return this.normalized&&(e=Ys(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize+2]=an(e),this}getW(t){let e=on(this.array[t*this.itemSize+3]);return this.normalized&&(e=Ys(e,this.array)),e}setW(t,e){return this.normalized&&(e=Zs(e,this.array)),this.array[t*this.itemSize+3]=an(e),this}setXY(t,e,s){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array)),this.array[t+0]=an(e),this.array[t+1]=an(s),this}setXYZ(t,e,s,i){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array)),this.array[t+0]=an(e),this.array[t+1]=an(s),this.array[t+2]=an(i),this}setXYZW(t,e,s,i,r){return t*=this.itemSize,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array),r=Zs(r,this.array)),this.array[t+0]=an(e),this.array[t+1]=an(s),this.array[t+2]=an(i),this.array[t+3]=an(r),this}}class wn extends dn{constructor(t,e,s){super(new Float32Array(t),e,s)}}let Mn=0;const Sn=new ar,_n=new Rr,An=new Ks,Tn=new Ri,zn=new Ri,Cn=new Ks;class In extends Ls{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Mn++}),this.uuid=Hs(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(ri(t)?bn:fn)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}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,s=0){this.groups.push({start:t,count:e,materialIndex:s})}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 s=this.attributes.normal;if(void 0!==s){const e=(new si).getNormalMatrix(t);s.applyNormalMatrix(e),s.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Sn.makeRotationFromQuaternion(t),this.applyMatrix4(Sn),this}rotateX(t){return Sn.makeRotationX(t),this.applyMatrix4(Sn),this}rotateY(t){return Sn.makeRotationY(t),this.applyMatrix4(Sn),this}rotateZ(t){return Sn.makeRotationZ(t),this.applyMatrix4(Sn),this}translate(t,e,s){return Sn.makeTranslation(t,e,s),this.applyMatrix4(Sn),this}scale(t,e,s){return Sn.makeScale(t,e,s),this.applyMatrix4(Sn),this}lookAt(t){return _n.lookAt(t),_n.updateMatrix(),this.applyMatrix4(_n.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(An).negate(),this.translate(An.x,An.y,An.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];e.push(i.x,i.y,i.z||0)}this.setAttribute("position",new wn(e,3))}else{const s=Math.min(t.length,e.count);for(let i=0;i<s;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ri);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.",this),void this.boundingBox.set(new Ks(-1/0,-1/0,-1/0),new Ks(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const s=e[t];Tn.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(this.boundingBox.min,Tn.min),this.boundingBox.expandByPoint(Cn),Cn.addVectors(this.boundingBox.max,Tn.max),this.boundingBox.expandByPoint(Cn)):(this.boundingBox.expandByPoint(Tn.min),this.boundingBox.expandByPoint(Tn.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 $i);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.",this),void this.boundingSphere.set(new Ks,1/0);if(t){const s=this.boundingSphere.center;if(Tn.setFromBufferAttribute(t),e)for(let t=0,s=e.length;t<s;t++){const s=e[t];zn.setFromBufferAttribute(s),this.morphTargetsRelative?(Cn.addVectors(Tn.min,zn.min),Tn.expandByPoint(Cn),Cn.addVectors(Tn.max,zn.max),Tn.expandByPoint(Cn)):(Tn.expandByPoint(zn.min),Tn.expandByPoint(zn.max))}Tn.getCenter(s);let i=0;for(let e=0,r=t.count;e<r;e++)Cn.fromBufferAttribute(t,e),i=Math.max(i,s.distanceToSquared(Cn));if(e)for(let r=0,n=e.length;r<n;r++){const n=e[r],a=this.morphTargetsRelative;for(let e=0,r=n.count;e<r;e++)Cn.fromBufferAttribute(n,e),a&&(An.fromBufferAttribute(t,e),Cn.add(An)),i=Math.max(i,s.distanceToSquared(Cn))}this.boundingSphere.radius=Math.sqrt(i),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 s=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new dn(new Float32Array(4*s.count),4));const n=this.getAttribute("tangent"),a=[],o=[];for(let t=0;t<s.count;t++)a[t]=new Ks,o[t]=new Ks;const h=new Ks,l=new Ks,c=new Ks,u=new $s,d=new $s,p=new $s,m=new Ks,y=new Ks;function g(t,e,i){h.fromBufferAttribute(s,t),l.fromBufferAttribute(s,e),c.fromBufferAttribute(s,i),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,i),l.sub(h),c.sub(h),d.sub(u),p.sub(u);const n=1/(d.x*p.y-p.x*d.y);isFinite(n)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(n),y.copy(c).multiplyScalar(d.x).addScaledVector(l,-p.x).multiplyScalar(n),a[t].add(m),a[e].add(m),a[i].add(m),o[t].add(y),o[e].add(y),o[i].add(y))}let f=this.groups;0===f.length&&(f=[{start:0,count:t.count}]);for(let e=0,s=f.length;e<s;++e){const s=f[e],i=s.start;for(let e=i,r=i+s.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const x=new Ks,b=new Ks,v=new Ks,w=new Ks;function M(t){v.fromBufferAttribute(i,t),w.copy(v);const e=a[t];x.copy(e),x.sub(v.multiplyScalar(v.dot(e))).normalize(),b.crossVectors(w,e);const s=b.dot(o[t])<0?-1:1;n.setXYZW(t,x.x,x.y,x.z,s)}for(let e=0,s=f.length;e<s;++e){const s=f[e],i=s.start;for(let e=i,r=i+s.count;e<r;e+=3)M(t.getX(e+0)),M(t.getX(e+1)),M(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let s=this.getAttribute("normal");if(void 0===s)s=new dn(new Float32Array(3*e.count),3),this.setAttribute("normal",s);else for(let t=0,e=s.count;t<e;t++)s.setXYZ(t,0,0,0);const i=new Ks,r=new Ks,n=new Ks,a=new Ks,o=new Ks,h=new Ks,l=new Ks,c=new Ks;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);i.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),n.fromBufferAttribute(e,m),l.subVectors(n,r),c.subVectors(i,r),l.cross(c),a.fromBufferAttribute(s,d),o.fromBufferAttribute(s,p),h.fromBufferAttribute(s,m),a.add(l),o.add(l),h.add(l),s.setXYZ(d,a.x,a.y,a.z),s.setXYZ(p,o.x,o.y,o.z),s.setXYZ(m,h.x,h.y,h.z)}else for(let t=0,a=e.count;t<a;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),n.fromBufferAttribute(e,t+2),l.subVectors(n,r),c.subVectors(i,r),l.cross(c),s.setXYZ(t+0,l.x,l.y,l.z),s.setXYZ(t+1,l.x,l.y,l.z),s.setXYZ(t+2,l.x,l.y,l.z);this.normalizeNormals(),s.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,s=t.count;e<s;e++)Cn.fromBufferAttribute(t,e),Cn.normalize(),t.setXYZ(e,Cn.x,Cn.y,Cn.z)}toNonIndexed(){function t(t,e){const s=t.array,i=t.itemSize,r=t.normalized,n=new s.constructor(e.length*i);let a=0,o=0;for(let r=0,h=e.length;r<h;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)n[o++]=s[a++]}return new dn(n,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new In,s=this.index.array,i=this.attributes;for(const r in i){const n=t(i[r],s);e.setAttribute(r,n)}const r=this.morphAttributes;for(const i in r){const n=[],a=r[i];for(let e=0,i=a.length;e<i;e++){const i=t(a[e],s);n.push(i)}e.morphAttributes[i]=n}e.morphTargetsRelative=this.morphTargetsRelative;const n=this.groups;for(let t=0,s=n.length;t<s;t++){const s=n[t];e.addGroup(s.start,s.count,s.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,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 s in e)void 0!==e[s]&&(t[s]=e[s]);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 s=this.attributes;for(const e in s){const i=s[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const s=this.morphAttributes[e],n=[];for(let e=0,i=s.length;e<i;e++){const i=s[e];n.push(i.toJSON(t.data))}n.length>0&&(i[e]=n,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const n=this.groups;n.length>0&&(t.data.groups=JSON.parse(JSON.stringify(n)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.toJSON()),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 s=t.index;null!==s&&this.setIndex(s.clone());const i=t.attributes;for(const t in i){const s=i[t];this.setAttribute(t,s.clone(e))}const r=t.morphAttributes;for(const t in r){const s=[],i=r[t];for(let t=0,r=i.length;t<r;t++)s.push(i[t].clone(e));this.morphAttributes[t]=s}this.morphTargetsRelative=t.morphTargetsRelative;const n=t.groups;for(let t=0,e=n.length;t<e;t++){const e=n[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,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Bn=new ar,kn=new nr,En=new $i,Rn=new Ks,Pn=new Ks,On=new Ks,Nn=new Ks,Vn=new Ks,Fn=new Ks,Ln=new Ks,jn=new Ks;class Dn extends Rr{constructor(t=new In,e=new sn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,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=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const s=t[e[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=s.length;t<e;t++){const e=s[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const s=this.geometry,i=s.attributes.position,r=s.morphAttributes.position,n=s.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(r&&a){Fn.set(0,0,0);for(let s=0,i=r.length;s<i;s++){const i=a[s],o=r[s];0!==i&&(Vn.fromBufferAttribute(o,t),n?Fn.addScaledVector(Vn,i):Fn.addScaledVector(Vn.sub(e),i))}e.add(Fn)}return e}raycast(t,e){const s=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===s.boundingSphere&&s.computeBoundingSphere(),En.copy(s.boundingSphere),En.applyMatrix4(r),kn.copy(t.ray).recast(t.near),!1===En.containsPoint(kn.origin)){if(null===kn.intersectSphere(En,Rn))return;if(kn.origin.distanceToSquared(Rn)>(t.far-t.near)**2)return}Bn.copy(r).invert(),kn.copy(t.ray).applyMatrix4(Bn),null!==s.boundingBox&&!1===kn.intersectsBox(s.boundingBox)||this._computeIntersections(t,e,kn)}}_computeIntersections(t,e,s){let i;const r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=n[o.materialIndex];for(let r=Math.max(o.start,d.start),n=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<n;r+=3){i=Wn(this,p,t,s,h,l,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){i=Wn(this,n,t,s,h,l,c,a.getX(r),a.getX(r+1),a.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==o)if(Array.isArray(n))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=n[a.materialIndex];for(let r=Math.max(a.start,d.start),n=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<n;r+=3){i=Wn(this,p,t,s,h,l,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=a.materialIndex,e.push(i))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){i=Wn(this,n,t,s,h,l,c,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function Wn(t,e,s,i,r,n,a,o,h,l){t.getVertexPosition(o,Pn),t.getVertexPosition(h,On),t.getVertexPosition(l,Nn);const c=function(t,e,s,i,r,n,a,o){let h;if(h=1===e.side?i.intersectTriangle(a,n,r,!0,o):i.intersectTriangle(r,n,a,0===e.side,o),null===h)return null;jn.copy(o),jn.applyMatrix4(t.matrixWorld);const l=s.ray.origin.distanceTo(jn);return l<s.near||l>s.far?null:{distance:l,point:jn.clone(),object:t}}(t,e,s,i,Pn,On,Nn,Ln);if(c){const t=new Ks;Xr.getBarycoord(Ln,Pn,On,Nn,t),r&&(c.uv=Xr.getInterpolatedAttribute(r,o,h,l,t,new $s)),n&&(c.uv1=Xr.getInterpolatedAttribute(n,o,h,l,t,new $s)),a&&(c.normal=Xr.getInterpolatedAttribute(a,o,h,l,t,new Ks),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:h,c:l,normal:new Ks,materialIndex:0};Xr.getNormal(Pn,On,Nn,e.normal),c.face=e,c.barycoord=t}return c}class Un extends In{constructor(t=1,e=1,s=1,i=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:s,widthSegments:i,heightSegments:r,depthSegments:n};const a=this;i=Math.floor(i),r=Math.floor(r),n=Math.floor(n);const o=[],h=[],l=[],c=[];let u=0,d=0;function p(t,e,s,i,r,n,p,m,y,g,f){const x=n/y,b=p/g,v=n/2,w=p/2,M=m/2,S=y+1,_=g+1;let A=0,T=0;const z=new Ks;for(let n=0;n<_;n++){const a=n*b-w;for(let o=0;o<S;o++){const u=o*x-v;z[t]=u*i,z[e]=a*r,z[s]=M,h.push(z.x,z.y,z.z),z[t]=0,z[e]=0,z[s]=m>0?1:-1,l.push(z.x,z.y,z.z),c.push(o/y),c.push(1-n/g),A+=1}}for(let t=0;t<g;t++)for(let e=0;e<y;e++){const s=u+e+S*t,i=u+e+S*(t+1),r=u+(e+1)+S*(t+1),n=u+(e+1)+S*t;o.push(s,i,n),o.push(i,r,n),T+=6}a.addGroup(d,T,f),d+=T,u+=A}p("z","y","x",-1,-1,s,e,t,n,r,0),p("z","y","x",1,-1,s,e,-t,n,r,1),p("x","z","y",1,1,t,s,e,i,n,2),p("x","z","y",1,-1,t,s,-e,i,n,3),p("x","y","z",1,-1,t,e,s,i,r,4),p("x","y","z",-1,-1,t,e,-s,i,r,5),this.setIndex(o),this.setAttribute("position",new wn(h,3)),this.setAttribute("normal",new wn(l,3)),this.setAttribute("uv",new wn(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Un(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Hn(t){const e={};for(const s in t){e[s]={};for(const i in t[s]){const r=t[s][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[s][i]=null):e[s][i]=r.clone():Array.isArray(r)?e[s][i]=r.slice():e[s][i]=r}}return e}function qn(t){const e={};for(let s=0;s<t.length;s++){const i=Hn(t[s]);for(const t in i)e[t]=i[t]}return e}function Jn(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:yi.workingColorSpace}const Xn={clone:Hn,merge:qn};class Yn extends en{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_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.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[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=Hn(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].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 s in this.uniforms){const i=this.uniforms[s].value;i&&i.isTexture?e.uniforms[s]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[s]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[s]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[s]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[s]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[s]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[s]={type:"m4",value:i.toArray()}:e.uniforms[s]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const s={};for(const t in this.extensions)!0===this.extensions[t]&&(s[t]=!0);return Object.keys(s).length>0&&(e.extensions=s),e}}class Zn extends Rr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ar,this.projectionMatrix=new ar,this.projectionMatrixInverse=new ar,this.coordinateSystem=Ps,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}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)}}const Gn=new Ks,$n=new $s,Qn=new $s;class Kn extends Zn{constructor(t=50,e=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=s,this.far=i,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*Us*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Ws*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Us*Math.atan(Math.tan(.5*Ws*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,s){Gn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z),Gn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z)}getViewSize(t,e){return this.getViewBounds(t,$n,Qn),e.subVectors(Qn,$n)}setViewOffset(t,e,s,i,r,n){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=s,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Ws*this.fov)/this.zoom,s=2*e,i=this.aspect*s,r=-.5*i;const n=this.view;if(null!==this.view&&this.view.enabled){const t=n.fullWidth,a=n.fullHeight;r+=n.offsetX*i/t,e-=n.offsetY*s/a,i*=n.width/t,s*=n.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-s,t,this.far,this.coordinateSystem,this.reversedDepth),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 ta=-90;class ea extends Rr{constructor(t,e,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Kn(ta,1,t,e);i.layers=this.layers,this.add(i);const r=new Kn(ta,1,t,e);r.layers=this.layers,this.add(r);const n=new Kn(ta,1,t,e);n.layers=this.layers,this.add(n);const a=new Kn(ta,1,t,e);a.layers=this.layers,this.add(a);const o=new Kn(ta,1,t,e);o.layers=this.layers,this.add(o);const h=new Kn(ta,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[s,i,r,n,a,o]=e;for(const t of e)this.remove(t);if(t===Ps)s.up.set(0,1,0),s.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==Os)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);s.up.set(0,-1,0),s.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,n,a,o,h,l]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=s.texture.generateMipmaps;s.texture.generateMipmaps=!1,t.setRenderTarget(s,0,i),t.render(e,r),t.setRenderTarget(s,1,i),t.render(e,n),t.setRenderTarget(s,2,i),t.render(e,a),t.setRenderTarget(s,3,i),t.render(e,o),t.setRenderTarget(s,4,i),t.render(e,h),s.texture.generateMipmaps=m,t.setRenderTarget(s,5,i),t.render(e,l),t.setRenderTarget(c,u,d),t.xr.enabled=p,s.texture.needsPMREMUpdate=!0}}class sa extends Ai{constructor(t=[],e=301,s,i,r,n,a,o,h,l){super(t,e,s,i,r,n,a,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ia extends Ci{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const s={width:t,height:t,depth:1},i=[s,s,s,s,s,s];this.texture=new sa(i),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const s={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Un(5,5,5),r=new Yn({name:"CubemapFromEquirect",uniforms:Hn(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const n=new Dn(i,r),a=e.minFilter;e.minFilter===_t&&(e.minFilter=wt);return new ea(1,10,this).update(t,n),e.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(t,e=!0,s=!0,i=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,s,i);t.setRenderTarget(r)}}class ra extends Rr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const na={type:"move"};class aa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ra,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 ra,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ks,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ks),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ra,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ks,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ks),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 s of t.hand.values())this._getHandJoint(e,s)}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,s){let i=null,r=null,n=null;const a=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){n=!0;for(const i of t.hand.values()){const t=e.getJointPose(i,s),r=this._getHandJoint(h,i);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const i=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=i.position.distanceTo(r.position),o=.02,l=.005;h.inputState.pinching&&a>o+l?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&a<=o-l&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,s),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,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&&(i=e.getPose(t.targetRaySpace,s),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(na)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==n),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const s=new ra;s.matrixAutoUpdate=!1,s.visible=!1,t.joints[e.jointName]=s,t.add(s)}return t.joints[e.jointName]}}class oa{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new Qr(t),this.density=e}clone(){return new oa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ha{constructor(t,e=1,s=1e3){this.isFog=!0,this.name="",this.color=new Qr(t),this.near=e,this.far=s}clone(){return new ha(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class la extends Rr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new gr,this.environmentIntensity=1,this.environmentRotation=new gr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ca{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Ss,this.updateRanges=[],this.version=0,this.uuid=Hs()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,s){t*=this.stride,s*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[s+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Hs()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),s=new this.constructor(e,this.stride);return s.setUsage(this.usage),s}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Hs()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ua=new Ks;class da{constructor(t,e,s,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=s,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,s=this.data.count;e<s;e++)ua.fromBufferAttribute(this,e),ua.applyMatrix4(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}applyNormalMatrix(t){for(let e=0,s=this.count;e<s;e++)ua.fromBufferAttribute(this,e),ua.applyNormalMatrix(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}transformDirection(t){for(let e=0,s=this.count;e<s;e++)ua.fromBufferAttribute(this,e),ua.transformDirection(t),this.setXYZ(e,ua.x,ua.y,ua.z);return this}getComponent(t,e){let s=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(s=Ys(s,this.array)),s}setComponent(t,e,s){return this.normalized&&(s=Zs(s,this.array)),this.data.array[t*this.data.stride+this.offset+e]=s,this}setX(t,e){return this.normalized&&(e=Zs(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Zs(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Zs(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Zs(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ys(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ys(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ys(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ys(e,this.array)),e}setXY(t,e,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this}setXYZ(t,e,s,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this}setXYZW(t,e,s,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Zs(e,this.array),s=Zs(s,this.array),i=Zs(i,this.array),r=Zs(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=s,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const s=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[s+e])}return new dn(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new da(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const s=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[s+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class pa extends en{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let ma;const ya=new Ks,ga=new Ks,fa=new Ks,xa=new $s,ba=new $s,va=new ar,wa=new Ks,Ma=new Ks,Sa=new Ks,_a=new $s,Aa=new $s,Ta=new $s;class za extends Rr{constructor(t=new pa){if(super(),this.isSprite=!0,this.type="Sprite",void 0===ma){ma=new In;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new ca(t,5);ma.setIndex([0,1,2,0,2,3]),ma.setAttribute("position",new da(e,3,0,!1)),ma.setAttribute("uv",new da(e,2,3,!1))}this.geometry=ma,this.material=t,this.center=new $s(.5,.5),this.count=1}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ga.setFromMatrixScale(this.matrixWorld),va.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),fa.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&ga.multiplyScalar(-fa.z);const s=this.material.rotation;let i,r;0!==s&&(r=Math.cos(s),i=Math.sin(s));const n=this.center;Ca(wa.set(-.5,-.5,0),fa,n,ga,i,r),Ca(Ma.set(.5,-.5,0),fa,n,ga,i,r),Ca(Sa.set(.5,.5,0),fa,n,ga,i,r),_a.set(0,0),Aa.set(1,0),Ta.set(1,1);let a=t.ray.intersectTriangle(wa,Ma,Sa,!1,ya);if(null===a&&(Ca(Ma.set(-.5,.5,0),fa,n,ga,i,r),Aa.set(0,1),a=t.ray.intersectTriangle(wa,Sa,Ma,!1,ya),null===a))return;const o=t.ray.origin.distanceTo(ya);o<t.near||o>t.far||e.push({distance:o,point:ya.clone(),uv:Xr.getInterpolation(ya,wa,Ma,Sa,_a,Aa,Ta,new $s),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Ca(t,e,s,i,r,n){xa.subVectors(t,s).addScalar(.5).multiply(i),void 0!==r?(ba.x=n*xa.x-r*xa.y,ba.y=r*xa.x+n*xa.y):ba.copy(xa),t.copy(e),t.x+=ba.x,t.y+=ba.y,t.applyMatrix4(va)}const Ia=new Ks,Ba=new Ks;class ka extends Rr{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let t=0,s=e.length;t<s;t++){const s=e[t];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,s=0){e=Math.abs(e);const i=this.levels;let r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:s,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let s=0;s<e.length;s++)if(e[s].distance===t){const t=e.splice(s,1);return this.remove(t[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let s,i;for(s=1,i=e.length;s<i;s++){let i=e[s].distance;if(e[s].object.visible&&(i-=i*e[s].hysteresis),t<i)break}return e[s-1].object}return null}raycast(t,e){if(this.levels.length>0){Ia.setFromMatrixPosition(this.matrixWorld);const s=t.ray.origin.distanceTo(Ia);this.getObjectForDistance(s).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){Ia.setFromMatrixPosition(t.matrixWorld),Ba.setFromMatrixPosition(this.matrixWorld);const s=Ia.distanceTo(Ba)/t.zoom;let i,r;for(e[0].object.visible=!0,i=1,r=e.length;i<r;i++){let t=e[i].distance;if(e[i].object.visible&&(t-=t*e[i].hysteresis),!(s>=t))break;e[i-1].object.visible=!1,e[i].object.visible=!0}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){const e=super.toJSON(t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const s=this.levels;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return e}}const Ea=new Ks,Ra=new Ti,Pa=new Ti,Oa=new Ks,Na=new ar,Va=new Ks,Fa=new $i,La=new ar,ja=new nr;class Da extends Dn{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nt,this.bindMatrix=new ar,this.bindMatrixInverse=new ar,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new Ri),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Va),this.boundingBox.expandByPoint(Va)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new $i),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,Va),this.boundingSphere.expandByPoint(Va)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const s=this.material,i=this.matrixWorld;void 0!==s&&(null===this.boundingSphere&&this.computeBoundingSphere(),Fa.copy(this.boundingSphere),Fa.applyMatrix4(i),!1!==t.ray.intersectsSphere(Fa)&&(La.copy(i).invert(),ja.copy(t.ray).applyMatrix4(La),null!==this.boundingBox&&!1===ja.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,ja)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Ti,e=this.geometry.attributes.skinWeight;for(let s=0,i=e.count;s<i;s++){t.fromBufferAttribute(e,s);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(s,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===nt?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===at?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const s=this.skeleton,i=this.geometry;Ra.fromBufferAttribute(i.attributes.skinIndex,t),Pa.fromBufferAttribute(i.attributes.skinWeight,t),Ea.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=Pa.getComponent(t);if(0!==i){const r=Ra.getComponent(t);Na.multiplyMatrices(s.bones[r].matrixWorld,s.boneInverses[r]),e.addScaledVector(Oa.copy(Ea).applyMatrix4(Na),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Wa extends Rr{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ua extends Ai{constructor(t=null,e=1,s=1,i,r,n,a,o,h=1003,l=1003,c,u){super(null,n,a,o,h,l,i,r,c,u),this.isDataTexture=!0,this.image={data:t,width:e,height:s},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ha=new ar,qa=new ar;class Ja{constructor(t=[],e=[]){this.uuid=Hs(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new ar)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new ar;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}}update(){const t=this.bones,e=this.boneInverses,s=this.boneMatrices,i=this.boneTexture;for(let i=0,r=t.length;i<r;i++){const r=t[i]?t[i].matrixWorld:qa;Ha.multiplyMatrices(r,e[i]),Ha.toArray(s,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new Ja(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(4*this.bones.length);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const s=new Ua(e,t,t,Dt,Et);return s.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=s,this}getBoneByName(t){for(let e=0,s=this.bones.length;e<s;e++){const s=this.bones[e];if(s.name===t)return s}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let s=0,i=t.bones.length;s<i;s++){const i=t.bones[s];let r=e[i];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),r=new Wa),this.bones.push(r),this.boneInverses.push((new ar).fromArray(t.boneInverses[s]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,s=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const r=e[i];t.bones.push(r.uuid);const n=s[i];t.boneInverses.push(n.toArray())}return t}}class Xa extends dn{constructor(t,e,s,i=1){super(t,e,s),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const Ya=new ar,Za=new ar,Ga=[],$a=new Ri,Qa=new ar,Ka=new Dn,to=new $i;class eo extends Dn{constructor(t,e,s){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Xa(new Float32Array(16*s),16),this.instanceColor=null,this.morphTexture=null,this.count=s,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<s;t++)this.setMatrixAt(t,Qa)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new Ri),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let s=0;s<e;s++)this.getMatrixAt(s,Ya),$a.copy(t.boundingBox).applyMatrix4(Ya),this.boundingBox.union($a)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new $i),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let s=0;s<e;s++)this.getMatrixAt(s,Ya),to.copy(t.boundingSphere).applyMatrix4(Ya),this.boundingSphere.union(to)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const s=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(s.length+1)+1;for(let t=0;t<s.length;t++)s[t]=i[r+t]}raycast(t,e){const s=this.matrixWorld,i=this.count;if(Ka.geometry=this.geometry,Ka.material=this.material,void 0!==Ka.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),to.copy(this.boundingSphere),to.applyMatrix4(s),!1!==t.ray.intersectsSphere(to)))for(let r=0;r<i;r++){this.getMatrixAt(r,Ya),Za.multiplyMatrices(s,Ya),Ka.matrixWorld=Za,Ka.raycast(t,Ga);for(let t=0,s=Ga.length;t<s;t++){const s=Ga[t];s.instanceId=r,s.object=this,e.push(s)}Ga.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new Xa(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const s=e.morphTargetInfluences,i=s.length+1;null===this.morphTexture&&(this.morphTexture=new Ua(new Float32Array(i*this.count),i,this.count,Ht,Et));const r=this.morphTexture.source.data.data;let n=0;for(let t=0;t<s.length;t++)n+=s[t];const a=this.geometry.morphTargetsRelative?1:1-n,o=i*t;r[o]=a,r.set(s,o+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}const so=new Ks,io=new Ks,ro=new si;class no{constructor(t=new Ks(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,s,i){return this.normal.set(t,e,s),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const i=so.subVectors(s,e).cross(io.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const s=t.delta(so),i=this.normal.dot(s);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(s,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),s=this.distanceToPoint(t.end);return e<0&&s>0||s<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 s=e||ro.getNormalMatrix(t),i=this.coplanarPoint(so).applyMatrix4(t),r=this.normal.applyMatrix3(s).normalize();return this.constant=-i.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 ao=new $i,oo=new $s(.5,.5),ho=new Ks;class lo{constructor(t=new no,e=new no,s=new no,i=new no,r=new no,n=new no){this.planes=[t,e,s,i,r,n]}set(t,e,s,i,r,n){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(s),a[3].copy(i),a[4].copy(r),a[5].copy(n),this}copy(t){const e=this.planes;for(let s=0;s<6;s++)e[s].copy(t.planes[s]);return this}setFromProjectionMatrix(t,e=2e3,s=!1){const i=this.planes,r=t.elements,n=r[0],a=r[1],o=r[2],h=r[3],l=r[4],c=r[5],u=r[6],d=r[7],p=r[8],m=r[9],y=r[10],g=r[11],f=r[12],x=r[13],b=r[14],v=r[15];if(i[0].setComponents(h-n,d-l,g-p,v-f).normalize(),i[1].setComponents(h+n,d+l,g+p,v+f).normalize(),i[2].setComponents(h+a,d+c,g+m,v+x).normalize(),i[3].setComponents(h-a,d-c,g-m,v-x).normalize(),s)i[4].setComponents(o,u,y,b).normalize(),i[5].setComponents(h-o,d-u,g-y,v-b).normalize();else if(i[4].setComponents(h-o,d-u,g-y,v-b).normalize(),e===Ps)i[5].setComponents(h+o,d+u,g+y,v+b).normalize();else{if(e!==Os)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(o,u,y,b).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),ao.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),ao.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ao)}intersectsSprite(t){ao.center.set(0,0,0);const e=oo.distanceTo(t.center);return ao.radius=.7071067811865476+e,ao.applyMatrix4(t.matrixWorld),this.intersectsSphere(ao)}intersectsSphere(t){const e=this.planes,s=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(s)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let s=0;s<6;s++){const i=e[s];if(ho.x=i.normal.x>0?t.max.x:t.min.x,ho.y=i.normal.y>0?t.max.y:t.min.y,ho.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ho)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let s=0;s<6;s++)if(e[s].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}const co=new ar,uo=new lo;class po{constructor(){this.coordinateSystem=Ps}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let s=0;s<e.cameras.length;s++){const i=e.cameras[s];if(co.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),uo.setFromProjectionMatrix(co,i.coordinateSystem,i.reversedDepth),uo.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let s=0;s<e.cameras.length;s++){const i=e.cameras[s];if(co.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),uo.setFromProjectionMatrix(co,i.coordinateSystem,i.reversedDepth),uo.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let s=0;s<e.cameras.length;s++){const i=e.cameras[s];if(co.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),uo.setFromProjectionMatrix(co,i.coordinateSystem,i.reversedDepth),uo.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let s=0;s<e.cameras.length;s++){const i=e.cameras[s];if(co.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),uo.setFromProjectionMatrix(co,i.coordinateSystem,i.reversedDepth),uo.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||0===e.cameras.length)return!1;for(let s=0;s<e.cameras.length;s++){const i=e.cameras[s];if(co.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),uo.setFromProjectionMatrix(co,i.coordinateSystem,i.reversedDepth),uo.containsPoint(t))return!0}return!1}clone(){return new po}}function mo(t,e){return t-e}function yo(t,e){return t.z-e.z}function go(t,e){return e.z-t.z}class fo{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,s,i){const r=this.pool,n=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];n.push(a),this.index++,a.start=t,a.count=e,a.z=s,a.index=i}reset(){this.list.length=0,this.index=0}}const xo=new ar,bo=new Qr(1,1,1),vo=new lo,wo=new po,Mo=new Ri,So=new $i,_o=new Ks,Ao=new Ks,To=new Ks,zo=new fo,Co=new Dn,Io=[];function Bo(t,e,s=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let n=0;n<r;n++)for(let r=0;r<i;r++)e.setComponent(n+s,r,t.getComponent(n,r))}else e.array.set(t.array,s*i);e.needsUpdate=!0}function ko(t,e){if(t.constructor!==e.constructor){const s=Math.min(t.length,e.length);for(let i=0;i<s;i++)e[i]=t[i]}else{const s=Math.min(t.length,e.length);e.set(new t.constructor(t.buffer,0,s))}}class Eo extends Dn{constructor(t,e,s=2*e,i){super(new In,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=s,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(4*this._maxInstanceCount);t=4*Math.ceil(t/4),t=Math.max(t,4);const e=new Float32Array(t*t*4),s=new Ua(e,t,t,Dt,Et);this._matricesTexture=s}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),s=new Ua(e,t,t,qt,kt);this._indirectTexture=s}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),s=new Ua(e,t,t,Dt,Et);s.colorSpace=yi.workingColorSpace,this._colorsTexture=s}_initializeGeometry(t){const e=this.geometry,s=this._maxVertexCount,i=this._maxIndexCount;if(!1===this._geometryInitialized){for(const i in t.attributes){const r=t.getAttribute(i),{array:n,itemSize:a,normalized:o}=r,h=new n.constructor(s*a),l=new dn(h,a,o);e.setAttribute(i,l)}if(null!==t.getIndex()){const t=s>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new dn(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(Boolean(t.getIndex())!==Boolean(e.getIndex()))throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const s in e.attributes){if(!t.hasAttribute(s))throw new Error(`THREE.BatchedMesh: Added geometry missing "${s}". All geometries must have consistent attributes.`);const i=t.getAttribute(s),r=e.getAttribute(s);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ri);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let s=0,i=e.length;s<i;s++){if(!1===e[s].active)continue;const i=e[s].geometryIndex;this.getMatrixAt(s,xo),this.getBoundingBoxAt(i,Mo).applyMatrix4(xo),t.union(Mo)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new $i);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let s=0,i=e.length;s<i;s++){if(!1===e[s].active)continue;const i=e[s].geometryIndex;this.getMatrixAt(s,xo),this.getBoundingSphereAt(i,So).applyMatrix4(xo),t.union(So)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const e={visible:!0,active:!0,geometryIndex:t};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(mo),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=e):(s=this._instanceInfo.length,this._instanceInfo.push(e));const i=this._matricesTexture;xo.identity().toArray(i.image.data,16*s),i.needsUpdate=!0;const r=this._colorsTexture;return r&&(bo.toArray(r.image.data,4*s),r.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(t,e=-1,s=-1){this._initializeGeometry(t),this._validateGeometry(t);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=-1===e?t.getAttribute("position").count:e;const n=t.getIndex();if(null!==n&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=-1===s?n.count:s),-1!==i.indexStart&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(mo),a=this._availableGeometryIds.shift(),r[a]=i):(a=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(a,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const s=this.geometry,i=null!==s.getIndex(),r=s.getIndex(),n=e.getIndex(),a=this._geometryInfo[t];if(i&&n.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,h=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const t in s.attributes){const i=e.getAttribute(t),r=s.getAttribute(t);Bo(i,r,o);const n=i.itemSize;for(let t=i.count,e=h;t<e;t++){const e=o+t;for(let t=0;t<n;t++)r.setComponent(e,t,0)}r.needsUpdate=!0,r.addUpdateRange(o*n,h*n)}if(i){const t=a.indexStart,s=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let e=0;e<n.count;e++)r.setX(t+e,o+n.getX(e));for(let e=n.count,i=s;e<i;e++)r.setX(t+e,o);r.needsUpdate=!0,r.addUpdateRange(t,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,null!==e.boundingBox&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,null!==e.boundingSphere&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||!1===e[t].active)return this;const s=this._instanceInfo;for(let e=0,i=s.length;e<i;e++)s[e].active&&s[e].geometryIndex===t&&this.deleteInstance(e);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const s=this._geometryInfo,i=s.map((t,e)=>e).sort((t,e)=>s[t].vertexStart-s[e].vertexStart),r=this.geometry;for(let n=0,a=s.length;n<a;n++){const a=i[n],o=s[a];if(!1!==o.active){if(null!==r.index){if(o.indexStart!==e){const{indexStart:s,vertexStart:i,reservedIndexCount:n}=o,a=r.index,h=a.array,l=t-i;for(let t=s;t<s+n;t++)h[t]=h[t]+l;a.array.copyWithin(e,s,s+n),a.addUpdateRange(e,n),o.indexStart=e}e+=o.reservedIndexCount}if(o.vertexStart!==t){const{vertexStart:e,reservedVertexCount:s}=o,i=r.attributes;for(const r in i){const n=i[r],{array:a,itemSize:o}=n;a.copyWithin(t*o,e*o,(e+s)*o),n.addUpdateRange(t*o,s*o)}o.vertexStart=t}t+=o.reservedVertexCount,o.start=r.index?o.indexStart:o.vertexStart,this._nextIndexStart=r.index?o.indexStart+o.reservedIndexCount:0,this._nextVertexStart=o.vertexStart+o.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const s=this.geometry,i=this._geometryInfo[t];if(null===i.boundingBox){const t=new Ri,e=s.index,r=s.attributes.position;for(let s=i.start,n=i.start+i.count;s<n;s++){let i=s;e&&(i=e.getX(i)),t.expandByPoint(_o.fromBufferAttribute(r,i))}i.boundingBox=t}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const s=this.geometry,i=this._geometryInfo[t];if(null===i.boundingSphere){const e=new $i;this.getBoundingBoxAt(t,Mo),Mo.getCenter(e.center);const r=s.index,n=s.attributes.position;let a=0;for(let t=i.start,s=i.start+i.count;t<s;t++){let s=t;r&&(s=r.getX(s)),_o.fromBufferAttribute(n,s),a=Math.max(a,e.center.distanceToSquared(_o))}e.radius=Math.sqrt(a),i.boundingSphere=e}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const s=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,16*t),s.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,16*t)}setColorAt(t,e){return this.validateInstanceId(t),null===this._colorsTexture&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,4*t),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,4*t)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e||(this._instanceInfo[t].visible=e,this._visibilityChanged=!0),this}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const s=this._geometryInfo[t];return e.vertexStart=s.vertexStart,e.vertexCount=s.vertexCount,e.reservedVertexCount=s.reservedVertexCount,e.indexStart=s.indexStart,e.indexCount=s.indexCount,e.reservedIndexCount=s.reservedIndexCount,e.start=s.start,e.count=s.count,e}setInstanceCount(t){const e=this._availableInstanceIds,s=this._instanceInfo;for(e.sort(mo);e[e.length-1]===s.length-1;)s.pop(),e.pop();if(t<s.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const i=new Int32Array(t),r=new Int32Array(t);ko(this._multiDrawCounts,i),ko(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;const n=this._indirectTexture,a=this._matricesTexture,o=this._colorsTexture;n.dispose(),this._initIndirectTexture(),ko(n.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),ko(a.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),ko(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const s=[...this._geometryInfo].filter(t=>t.active);if(Math.max(...s.map(t=>t.vertexStart+t.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index){if(Math.max(...s.map(t=>t.indexStart+t.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`)}const i=this.geometry;i.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new In,this._initializeGeometry(i));const r=this.geometry;i.index&&ko(i.index.array,r.index.array);for(const t in i.attributes)ko(i.attributes[t].array,r.attributes[t].array)}raycast(t,e){const s=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,n=this.geometry;Co.material=this.material,Co.geometry.index=n.index,Co.geometry.attributes=n.attributes,null===Co.geometry.boundingBox&&(Co.geometry.boundingBox=new Ri),null===Co.geometry.boundingSphere&&(Co.geometry.boundingSphere=new $i);for(let n=0,a=s.length;n<a;n++){if(!s[n].visible||!s[n].active)continue;const a=s[n].geometryIndex,o=i[a];Co.geometry.setDrawRange(o.start,o.count),this.getMatrixAt(n,Co.matrixWorld).premultiply(r),this.getBoundingBoxAt(a,Co.geometry.boundingBox),this.getBoundingSphereAt(a,Co.geometry.boundingSphere),Co.raycast(t,Io);for(let t=0,s=Io.length;t<s;t++){const s=Io[t];s.object=this,s.batchId=n,e.push(s)}Io.length=0}Co.material=null,Co.geometry.index=null,Co.geometry.attributes={},Co.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=null!==t.boundingBox?t.boundingBox.clone():null,this.boundingSphere=null!==t.boundingSphere?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(t=>({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(t=>({...t})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,s,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const n=i.getIndex(),a=null===n?1:n.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,c=this._geometryInfo,u=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,m=s.isArrayCamera?wo:vo;u&&!s.isArrayCamera&&(xo.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse).multiply(this.matrixWorld),vo.setFromProjectionMatrix(xo,s.coordinateSystem,s.reversedDepth));let y=0;if(this.sortObjects){xo.copy(this.matrixWorld).invert(),_o.setFromMatrixPosition(s.matrixWorld).applyMatrix4(xo),Ao.set(0,0,-1).transformDirection(s.matrixWorld).transformDirection(xo);for(let t=0,e=o.length;t<e;t++)if(o[t].visible&&o[t].active){const e=o[t].geometryIndex;this.getMatrixAt(t,xo),this.getBoundingSphereAt(e,So).applyMatrix4(xo);let i=!1;if(u&&(i=!m.intersectsSphere(So,s)),!i){const s=c[e],i=To.subVectors(So.center,_o).dot(Ao);zo.push(s.start,s.count,i,t)}}const t=zo.list,e=this.customSort;null===e?t.sort(r.transparent?go:yo):e.call(this,t,s);for(let e=0,s=t.length;e<s;e++){const s=t[e];h[y]=s.start*a,l[y]=s.count,p[y]=s.index,y++}zo.reset()}else for(let t=0,e=o.length;t<e;t++)if(o[t].visible&&o[t].active){const e=o[t].geometryIndex;let i=!1;if(u&&(this.getMatrixAt(t,xo),this.getBoundingSphereAt(e,So).applyMatrix4(xo),i=!m.intersectsSphere(So,s)),!i){const s=c[e];h[y]=s.start*a,l[y]=s.count,p[y]=t,y++}}d.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(t,e,s,i,r,n){this.onBeforeRender(t,null,i,r,n)}}class Ro extends en{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qr(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Po=new Ks,Oo=new Ks,No=new ar,Vo=new nr,Fo=new $i,Lo=new Ks,jo=new Ks;class Do extends Rr{constructor(t=new In,e=new Ro){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,s=[0];for(let t=1,i=e.count;t<i;t++)Po.fromBufferAttribute(e,t-1),Oo.fromBufferAttribute(e,t),s[t]=s[t-1],s[t]+=Po.distanceTo(Oo);t.setAttribute("lineDistance",new wn(s,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const s=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,n=s.drawRange;if(null===s.boundingSphere&&s.computeBoundingSphere(),Fo.copy(s.boundingSphere),Fo.applyMatrix4(i),Fo.radius+=r,!1===t.ray.intersectsSphere(Fo))return;No.copy(i).invert(),Vo.copy(t.ray).applyMatrix4(No);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=this.isLineSegments?2:1,l=s.index,c=s.attributes.position;if(null!==l){const s=Math.max(0,n.start),i=Math.min(l.count,n.start+n.count);for(let r=s,n=i-1;r<n;r+=h){const s=l.getX(r),i=l.getX(r+1),n=Wo(this,t,Vo,o,s,i,r);n&&e.push(n)}if(this.isLineLoop){const r=l.getX(i-1),n=l.getX(s),a=Wo(this,t,Vo,o,r,n,i-1);a&&e.push(a)}}else{const s=Math.max(0,n.start),i=Math.min(c.count,n.start+n.count);for(let r=s,n=i-1;r<n;r+=h){const s=Wo(this,t,Vo,o,r,r+1,r);s&&e.push(s)}if(this.isLineLoop){const r=Wo(this,t,Vo,o,i-1,s,i-1);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const s=t[e[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=s.length;t<e;t++){const e=s[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Wo(t,e,s,i,r,n,a){const o=t.geometry.attributes.position;Po.fromBufferAttribute(o,r),Oo.fromBufferAttribute(o,n);if(s.distanceSqToSegment(Po,Oo,Lo,jo)>i)return;Lo.applyMatrix4(t.matrixWorld);const h=e.ray.origin.distanceTo(Lo);return h<e.near||h>e.far?void 0:{distance:h,point:jo.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const Uo=new Ks,Ho=new Ks;class qo extends Do{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,s=[];for(let t=0,i=e.count;t<i;t+=2)Uo.fromBufferAttribute(e,t),Ho.fromBufferAttribute(e,t+1),s[t]=0===t?0:s[t-1],s[t+1]=s[t]+Uo.distanceTo(Ho);t.setAttribute("lineDistance",new wn(s,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Jo extends Do{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Xo extends en{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Qr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Yo=new ar,Zo=new nr,Go=new $i,$o=new Ks;class Qo extends Rr{constructor(t=new In,e=new Xo){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const s=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,n=s.drawRange;if(null===s.boundingSphere&&s.computeBoundingSphere(),Go.copy(s.boundingSphere),Go.applyMatrix4(i),Go.radius+=r,!1===t.ray.intersectsSphere(Go))return;Yo.copy(i).invert(),Zo.copy(t.ray).applyMatrix4(Yo);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=s.index,l=s.attributes.position;if(null!==h){for(let s=Math.max(0,n.start),r=Math.min(h.count,n.start+n.count);s<r;s++){const r=h.getX(s);$o.fromBufferAttribute(l,r),Ko($o,r,o,i,t,e,this)}}else{for(let s=Math.max(0,n.start),r=Math.min(l.count,n.start+n.count);s<r;s++)$o.fromBufferAttribute(l,s),Ko($o,s,o,i,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const s=t[e[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=s.length;t<e;t++){const e=s[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Ko(t,e,s,i,r,n,a){const o=Zo.distanceSqToPoint(t);if(o<s){const s=new Ks;Zo.closestPointToPoint(t,s),s.applyMatrix4(i);const h=r.ray.origin.distanceTo(s);if(h<r.near||h>r.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:s,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class th extends Ai{constructor(t,e,s,i,r=1006,n=1006,a,o,h){super(t,e,s,i,r,n,a,o,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const l=this;"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(function e(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}}class eh extends th{constructor(t,e,s,i,r,n,a,o){super({},t,e,s,i,r,n,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return(new this.constructor).copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class sh extends Ai{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=gt,this.minFilter=gt,this.generateMipmaps=!1,this.needsUpdate=!0}}class ih extends Ai{constructor(t,e,s,i,r,n,a,o,h,l,c,u){super(null,n,a,o,h,l,i,r,c,u),this.isCompressedTexture=!0,this.image={width:e,height:s},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rh extends ih{constructor(t,e,s,i,r,n){super(t,e,s,r,n),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=mt,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class nh extends ih{constructor(t,e,s){super(void 0,t[0].width,t[0].height,e,s,ht),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ah extends Ai{constructor(t,e,s,i,r,n,a,o,h){super(t,e,s,i,r,n,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class oh extends Ai{constructor(t,e,s=1014,i,r,n,a=1003,o=1003,h,l=1026,c=1){if(l!==Wt&&1027!==l)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},i,r,n,a,o,l,s,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new wi(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class hh extends Ai{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class lh extends In{constructor(t=1,e=1,s=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:s,radialSegments:i,heightSegments:r},e=Math.max(0,e),s=Math.max(1,Math.floor(s)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));const n=[],a=[],o=[],h=[],l=e/2,c=Math.PI/2*t,u=e,d=2*c+u,p=2*s+r,m=i+1,y=new Ks,g=new Ks;for(let f=0;f<=p;f++){let x=0,b=0,v=0,w=0;if(f<=s){const e=f/s,i=e*Math.PI/2;b=-l-t*Math.cos(i),v=t*Math.sin(i),w=-t*Math.cos(i),x=e*c}else if(f<=s+r){const i=(f-s)/r;b=i*e-l,v=t,w=0,x=c+i*u}else{const e=(f-s-r)/s,i=e*Math.PI/2;b=l+t*Math.sin(i),v=t*Math.cos(i),w=t*Math.sin(i),x=c+u+e*c}const M=Math.max(0,Math.min(1,x/d));let S=0;0===f?S=.5/i:f===p&&(S=-.5/i);for(let t=0;t<=i;t++){const e=t/i,s=e*Math.PI*2,r=Math.sin(s),n=Math.cos(s);g.x=-v*n,g.y=b,g.z=v*r,a.push(g.x,g.y,g.z),y.set(-v*n,w,v*r),y.normalize(),o.push(y.x,y.y,y.z),h.push(e+S,M)}if(f>0){const t=(f-1)*m;for(let e=0;e<i;e++){const s=t+e,i=t+e+1,r=f*m+e,a=f*m+e+1;n.push(s,i,r),n.push(i,a,r)}}}this.setIndex(n),this.setAttribute("position",new wn(a,3)),this.setAttribute("normal",new wn(o,3)),this.setAttribute("uv",new wn(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new lh(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}}class ch extends In{constructor(t=1,e=32,s=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:s,thetaLength:i},e=Math.max(3,e);const r=[],n=[],a=[],o=[],h=new Ks,l=new $s;n.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,c=3;r<=e;r++,c+=3){const u=s+r/e*i;h.x=t*Math.cos(u),h.y=t*Math.sin(u),n.push(h.x,h.y,h.z),a.push(0,0,1),l.x=(n[c]/t+1)/2,l.y=(n[c+1]/t+1)/2,o.push(l.x,l.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new wn(n,3)),this.setAttribute("normal",new wn(a,3)),this.setAttribute("uv",new wn(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ch(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class uh extends In{constructor(t=1,e=1,s=1,i=32,r=1,n=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:s,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:o};const h=this;i=Math.floor(i),r=Math.floor(r);const l=[],c=[],u=[],d=[];let p=0;const m=[],y=s/2;let g=0;function f(s){const r=p,n=new $s,m=new Ks;let f=0;const x=!0===s?t:e,b=!0===s?1:-1;for(let t=1;t<=i;t++)c.push(0,y*b,0),u.push(0,b,0),d.push(.5,.5),p++;const v=p;for(let t=0;t<=i;t++){const e=t/i*o+a,s=Math.cos(e),r=Math.sin(e);m.x=x*r,m.y=y*b,m.z=x*s,c.push(m.x,m.y,m.z),u.push(0,b,0),n.x=.5*s+.5,n.y=.5*r*b+.5,d.push(n.x,n.y),p++}for(let t=0;t<i;t++){const e=r+t,i=v+t;!0===s?l.push(i,i+1,e):l.push(i+1,i,e),f+=3}h.addGroup(g,f,!0===s?1:2),g+=f}!function(){const n=new Ks,f=new Ks;let x=0;const b=(e-t)/s;for(let h=0;h<=r;h++){const l=[],g=h/r,x=g*(e-t)+t;for(let t=0;t<=i;t++){const e=t/i,r=e*o+a,h=Math.sin(r),m=Math.cos(r);f.x=x*h,f.y=-g*s+y,f.z=x*m,c.push(f.x,f.y,f.z),n.set(h,b,m).normalize(),u.push(n.x,n.y,n.z),d.push(e,1-g),l.push(p++)}m.push(l)}for(let s=0;s<i;s++)for(let i=0;i<r;i++){const n=m[i][s],a=m[i+1][s],o=m[i+1][s+1],h=m[i][s+1];(t>0||0!==i)&&(l.push(n,a,h),x+=3),(e>0||i!==r-1)&&(l.push(a,o,h),x+=3)}h.addGroup(g,x,0),g+=x}(),!1===n&&(t>0&&f(!0),e>0&&f(!1)),this.setIndex(l),this.setAttribute("position",new wn(c,3)),this.setAttribute("normal",new wn(u,3)),this.setAttribute("uv",new wn(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new uh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class dh extends uh{constructor(t=1,e=1,s=32,i=1,r=!1,n=0,a=2*Math.PI){super(0,t,e,s,i,r,n,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:s,heightSegments:i,openEnded:r,thetaStart:n,thetaLength:a}}static fromJSON(t){return new dh(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ph extends In{constructor(t=[],e=[],s=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:s,detail:i};const r=[],n=[];function a(t,e,s,i){const r=i+1,n=[];for(let i=0;i<=r;i++){n[i]=[];const a=t.clone().lerp(s,i/r),o=e.clone().lerp(s,i/r),h=r-i;for(let t=0;t<=h;t++)n[i][t]=0===t&&i===r?a:a.clone().lerp(o,t/h)}for(let t=0;t<r;t++)for(let e=0;e<2*(r-t)-1;e++){const s=Math.floor(e/2);e%2==0?(o(n[t][s+1]),o(n[t+1][s]),o(n[t][s])):(o(n[t][s+1]),o(n[t+1][s+1]),o(n[t+1][s]))}}function o(t){r.push(t.x,t.y,t.z)}function h(e,s){const i=3*e;s.x=t[i+0],s.y=t[i+1],s.z=t[i+2]}function l(t,e,s,i){i<0&&1===t.x&&(n[e]=t.x-1),0===s.x&&0===s.z&&(n[e]=i/2/Math.PI+.5)}function c(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){const s=new Ks,i=new Ks,r=new Ks;for(let n=0;n<e.length;n+=3)h(e[n+0],s),h(e[n+1],i),h(e[n+2],r),a(s,i,r,t)}(i),function(t){const e=new Ks;for(let s=0;s<r.length;s+=3)e.x=r[s+0],e.y=r[s+1],e.z=r[s+2],e.normalize().multiplyScalar(t),r[s+0]=e.x,r[s+1]=e.y,r[s+2]=e.z}(s),function(){const t=new Ks;for(let e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];const s=c(t)/2/Math.PI+.5,i=u(t)/Math.PI+.5;n.push(s,1-i)}(function(){const t=new Ks,e=new Ks,s=new Ks,i=new Ks,a=new $s,o=new $s,h=new $s;for(let u=0,d=0;u<r.length;u+=9,d+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),s.set(r[u+6],r[u+7],r[u+8]),a.set(n[d+0],n[d+1]),o.set(n[d+2],n[d+3]),h.set(n[d+4],n[d+5]),i.copy(t).add(e).add(s).divideScalar(3);const p=c(i);l(a,d+0,t,p),l(o,d+2,e,p),l(h,d+4,s,p)}})(),function(){for(let t=0;t<n.length;t+=6){const e=n[t+0],s=n[t+2],i=n[t+4],r=Math.max(e,s,i),a=Math.min(e,s,i);r>.9&&a<.1&&(e<.2&&(n[t+0]+=1),s<.2&&(n[t+2]+=1),i<.2&&(n[t+4]+=1))}}()}(),this.setAttribute("position",new wn(r,3)),this.setAttribute("normal",new wn(r.slice(),3)),this.setAttribute("uv",new wn(n,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ph(t.vertices,t.indices,t.radius,t.details)}}class mh extends ph{constructor(t=1,e=0){const s=(1+Math.sqrt(5))/2,i=1/s;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-s,0,-i,s,0,i,-s,0,i,s,-i,-s,0,-i,s,0,i,-s,0,i,s,0,-s,0,-i,s,0,-i,-s,0,i,s,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new mh(t.radius,t.detail)}}const yh=new Ks,gh=new Ks,fh=new Ks,xh=new Xr;class bh extends In{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const s=4,i=Math.pow(10,s),r=Math.cos(Ws*e),n=t.getIndex(),a=t.getAttribute("position"),o=n?n.count:a.count,h=[0,0,0],l=["a","b","c"],c=new Array(3),u={},d=[];for(let t=0;t<o;t+=3){n?(h[0]=n.getX(t),h[1]=n.getX(t+1),h[2]=n.getX(t+2)):(h[0]=t,h[1]=t+1,h[2]=t+2);const{a:e,b:s,c:o}=xh;if(e.fromBufferAttribute(a,h[0]),s.fromBufferAttribute(a,h[1]),o.fromBufferAttribute(a,h[2]),xh.getNormal(fh),c[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,c[1]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,c[2]=`${Math.round(o.x*i)},${Math.round(o.y*i)},${Math.round(o.z*i)}`,c[0]!==c[1]&&c[1]!==c[2]&&c[2]!==c[0])for(let t=0;t<3;t++){const e=(t+1)%3,s=c[t],i=c[e],n=xh[l[t]],a=xh[l[e]],o=`${s}_${i}`,p=`${i}_${s}`;p in u&&u[p]?(fh.dot(u[p].normal)<=r&&(d.push(n.x,n.y,n.z),d.push(a.x,a.y,a.z)),u[p]=null):o in u||(u[o]={index0:h[t],index1:h[e],normal:fh.clone()})}}for(const t in u)if(u[t]){const{index0:e,index1:s}=u[t];yh.fromBufferAttribute(a,e),gh.fromBufferAttribute(a,s),d.push(yh.x,yh.y,yh.z),d.push(gh.x,gh.y,gh.z)}this.setAttribute("position",new wn(d,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class vh{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){const s=this.getUtoTmapping(t);return this.getPoint(s,e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let s,i=this.getPoint(0),r=0;e.push(0);for(let n=1;n<=t;n++)s=this.getPoint(n/t),r+=s.distanceTo(i),e.push(r),i=s;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const s=this.getLengths();let i=0;const r=s.length;let n;n=e||t*s[r-1];let a,o=0,h=r-1;for(;o<=h;)if(i=Math.floor(o+(h-o)/2),a=s[i]-n,a<0)o=i+1;else{if(!(a>0)){h=i;break}h=i-1}if(i=h,s[i]===n)return i/(r-1);const l=s[i];return(i+(n-l)/(s[i+1]-l))/(r-1)}getTangent(t,e){const s=1e-4;let i=t-s,r=t+s;i<0&&(i=0),r>1&&(r=1);const n=this.getPoint(i),a=this.getPoint(r),o=e||(n.isVector2?new $s:new Ks);return o.copy(a).sub(n).normalize(),o}getTangentAt(t,e){const s=this.getUtoTmapping(t);return this.getTangent(s,e)}computeFrenetFrames(t,e=!1){const s=new Ks,i=[],r=[],n=[],a=new Ks,o=new ar;for(let e=0;e<=t;e++){const s=e/t;i[e]=this.getTangentAt(s,new Ks)}r[0]=new Ks,n[0]=new Ks;let h=Number.MAX_VALUE;const l=Math.abs(i[0].x),c=Math.abs(i[0].y),u=Math.abs(i[0].z);l<=h&&(h=l,s.set(1,0,0)),c<=h&&(h=c,s.set(0,1,0)),u<=h&&s.set(0,0,1),a.crossVectors(i[0],s).normalize(),r[0].crossVectors(i[0],a),n[0].crossVectors(i[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),n[e]=n[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(qs(i[e-1].dot(i[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}n[e].crossVectors(i[e],r[e])}if(!0===e){let e=Math.acos(qs(r[0].dot(r[t]),-1,1));e/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let s=1;s<=t;s++)r[s].applyMatrix4(o.makeRotationAxis(i[s],e*s)),n[s].crossVectors(i[s],r[s])}return{tangents:i,normals:r,binormals:n}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class wh extends vh{constructor(t=0,e=0,s=1,i=1,r=0,n=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=s,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new $s){const s=e,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const n=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=n?0:i),!0!==this.aClockwise||n||(r===i?r=-i:r-=i);const a=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(a),h=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),s=o-this.aX,i=h-this.aY;o=s*t-i*e+this.aX,h=s*e+i*t+this.aY}return s.set(o,h)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class Mh extends wh{constructor(t,e,s,i,r,n){super(t,e,s,s,i,r,n),this.isArcCurve=!0,this.type="ArcCurve"}}function Sh(){let t=0,e=0,s=0,i=0;function r(r,n,a,o){t=r,e=a,s=-3*r+3*n-2*a-o,i=2*r-2*n+a+o}return{initCatmullRom:function(t,e,s,i,n){r(e,s,n*(s-t),n*(i-e))},initNonuniformCatmullRom:function(t,e,s,i,n,a,o){let h=(e-t)/n-(s-t)/(n+a)+(s-e)/a,l=(s-e)/a-(i-e)/(a+o)+(i-s)/o;h*=a,l*=a,r(e,s,h,l)},calc:function(r){const n=r*r;return t+e*r+s*n+i*(n*r)}}}const _h=new Ks,Ah=new Sh,Th=new Sh,zh=new Sh;class Ch extends vh{constructor(t=[],e=!1,s="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=s,this.tension=i}getPoint(t,e=new Ks){const s=e,i=this.points,r=i.length,n=(r-(this.closed?0:1))*t;let a,o,h=Math.floor(n),l=n-h;this.closed?h+=h>0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?a=i[(h-1)%r]:(_h.subVectors(i[0],i[1]).add(i[0]),a=_h);const c=i[h%r],u=i[(h+1)%r];if(this.closed||h+2<r?o=i[(h+2)%r]:(_h.subVectors(i[r-1],i[r-2]).add(i[r-1]),o=_h),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),s=Math.pow(c.distanceToSquared(u),t),i=Math.pow(u.distanceToSquared(o),t);s<1e-4&&(s=1),e<1e-4&&(e=s),i<1e-4&&(i=s),Ah.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,s,i),Th.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,s,i),zh.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,s,i)}else"catmullrom"===this.curveType&&(Ah.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Th.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),zh.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return s.set(Ah.calc(l),Th.calc(l),zh.calc(l)),s}copy(t){super.copy(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,s=this.points.length;e<s;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++){const s=t.points[e];this.points.push((new Ks).fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Ih(t,e,s,i,r){const n=.5*(i-e),a=.5*(r-s),o=t*t;return(2*s-2*i+n+a)*(t*o)+(-3*s+3*i-2*n-a)*o+n*t+s}function Bh(t,e,s,i){return function(t,e){const s=1-t;return s*s*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,s)+function(t,e){return t*t*e}(t,i)}function kh(t,e,s,i,r){return function(t,e){const s=1-t;return s*s*s*e}(t,e)+function(t,e){const s=1-t;return 3*s*s*t*e}(t,s)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}class Eh extends vh{constructor(t=new $s,e=new $s,s=new $s,i=new $s){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=s,this.v3=i}getPoint(t,e=new $s){const s=e,i=this.v0,r=this.v1,n=this.v2,a=this.v3;return s.set(kh(t,i.x,r.x,n.x,a.x),kh(t,i.y,r.y,n.y,a.y)),s}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Rh extends vh{constructor(t=new Ks,e=new Ks,s=new Ks,i=new Ks){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=s,this.v3=i}getPoint(t,e=new Ks){const s=e,i=this.v0,r=this.v1,n=this.v2,a=this.v3;return s.set(kh(t,i.x,r.x,n.x,a.x),kh(t,i.y,r.y,n.y,a.y),kh(t,i.z,r.z,n.z,a.z)),s}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Ph extends vh{constructor(t=new $s,e=new $s){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new $s){const s=e;return 1===t?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(t).add(this.v1)),s}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new $s){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Oh extends vh{constructor(t=new Ks,e=new Ks){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Ks){const s=e;return 1===t?s.copy(this.v2):(s.copy(this.v2).sub(this.v1),s.multiplyScalar(t).add(this.v1)),s}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Ks){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Nh extends vh{constructor(t=new $s,e=new $s,s=new $s){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=s}getPoint(t,e=new $s){const s=e,i=this.v0,r=this.v1,n=this.v2;return s.set(Bh(t,i.x,r.x,n.x),Bh(t,i.y,r.y,n.y)),s}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Vh extends vh{constructor(t=new Ks,e=new Ks,s=new Ks){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=s}getPoint(t,e=new Ks){const s=e,i=this.v0,r=this.v1,n=this.v2;return s.set(Bh(t,i.x,r.x,n.x),Bh(t,i.y,r.y,n.y),Bh(t,i.z,r.z,n.z)),s}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Fh extends vh{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new $s){const s=e,i=this.points,r=(i.length-1)*t,n=Math.floor(r),a=r-n,o=i[0===n?n:n-1],h=i[n],l=i[n>i.length-2?i.length-1:n+1],c=i[n>i.length-3?i.length-1:n+2];return s.set(Ih(a,o.x,h.x,l.x,c.x),Ih(a,o.y,h.y,l.y,c.y)),s}copy(t){super.copy(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,s=this.points.length;e<s;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++){const s=t.points[e];this.points.push((new $s).fromArray(s))}return this}}var Lh=Object.freeze({__proto__:null,ArcCurve:Mh,CatmullRomCurve3:Ch,CubicBezierCurve:Eh,CubicBezierCurve3:Rh,EllipseCurve:wh,LineCurve:Ph,LineCurve3:Oh,QuadraticBezierCurve:Nh,QuadraticBezierCurve3:Vh,SplineCurve:Fh});class jh extends vh{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const s=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Lh[s](e,t))}return this}getPoint(t,e){const s=t*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=s){const t=i[r]-s,n=this.curves[r],a=n.getLength(),o=0===a?0:1-t/a;return n.getPointAt(o,e)}r++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let s=0,i=this.curves.length;s<i;s++)e+=this.curves[s].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let s;for(let i=0,r=this.curves;i<r.length;i++){const n=r[i],a=n.isEllipseCurve?2*t:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?t*n.points.length:t,o=n.getPoints(a);for(let t=0;t<o.length;t++){const i=o[t];s&&s.equals(i)||(e.push(i),s=i)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,s=t.curves.length;e<s;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,s=this.curves.length;e<s;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,s=t.curves.length;e<s;e++){const s=t.curves[e];this.curves.push((new Lh[s.type]).fromJSON(s))}return this}}class Dh extends jh{constructor(t){super(),this.type="Path",this.currentPoint=new $s,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,s=t.length;e<s;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const s=new Ph(this.currentPoint.clone(),new $s(t,e));return this.curves.push(s),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,s,i){const r=new Nh(this.currentPoint.clone(),new $s(t,e),new $s(s,i));return this.curves.push(r),this.currentPoint.set(s,i),this}bezierCurveTo(t,e,s,i,r,n){const a=new Eh(this.currentPoint.clone(),new $s(t,e),new $s(s,i),new $s(r,n));return this.curves.push(a),this.currentPoint.set(r,n),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),s=new Fh(e);return this.curves.push(s),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,s,i,r,n){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,s,i,r,n),this}absarc(t,e,s,i,r,n){return this.absellipse(t,e,s,s,i,r,n),this}ellipse(t,e,s,i,r,n,a,o){const h=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(t+h,e+l,s,i,r,n,a,o),this}absellipse(t,e,s,i,r,n,a,o){const h=new wh(t,e,s,i,r,n,a,o);if(this.curves.length>0){const t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Wh extends Dh{constructor(t){super(t),this.uuid=Hs(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let s=0,i=this.holes.length;s<i;s++)e[s]=this.holes[s].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,s=t.holes.length;e<s;e++){const s=t.holes[e];this.holes.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,s=this.holes.length;e<s;e++){const s=this.holes[e];t.holes.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,s=t.holes.length;e<s;e++){const s=t.holes[e];this.holes.push((new Dh).fromJSON(s))}return this}}function Uh(t,e,s=2){const i=e&&e.length,r=i?e[0]*s:t.length;let n=Hh(t,0,r,s,!0);const a=[];if(!n||n.next===n.prev)return a;let o,h,l;if(i&&(n=function(t,e,s,i){const r=[];for(let s=0,n=e.length;s<n;s++){const a=Hh(t,e[s]*i,s<n-1?e[s+1]*i:t.length,i,!1);a===a.next&&(a.steiner=!0),r.push(el(a))}r.sort($h);for(let t=0;t<r.length;t++)s=Qh(r[t],s);return s}(t,e,n,s)),t.length>80*s){o=1/0,h=1/0;let e=-1/0,i=-1/0;for(let n=s;n<r;n+=s){const s=t[n],r=t[n+1];s<o&&(o=s),r<h&&(h=r),s>e&&(e=s),r>i&&(i=r)}l=Math.max(e-o,i-h),l=0!==l?32767/l:0}return Jh(n,a,s,o,h,l,0),a}function Hh(t,e,s,i,r){let n;if(r===function(t,e,s,i){let r=0;for(let n=e,a=s-i;n<s;n+=i)r+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return r}(t,e,s,i)>0)for(let r=e;r<s;r+=i)n=dl(r/i|0,t[r],t[r+1],n);else for(let r=s-i;r>=e;r-=i)n=dl(r/i|0,t[r],t[r+1],n);return n&&al(n,n.next)&&(pl(n),n=n.next),n}function qh(t,e){if(!t)return t;e||(e=t);let s,i=t;do{if(s=!1,i.steiner||!al(i,i.next)&&0!==nl(i.prev,i,i.next))i=i.next;else{if(pl(i),i=e=i.prev,i===i.next)break;s=!0}}while(s||i!==e);return e}function Jh(t,e,s,i,r,n,a){if(!t)return;!a&&n&&function(t,e,s,i){let r=t;do{0===r.z&&(r.z=tl(r.x,r.y,e,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,s=1;do{let i,r=t;t=null;let n=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t<s&&(o++,a=a.nextZ,a);t++);let h=s;for(;o>0||h>0&&a;)0!==o&&(0===h||!a||r.z<=a.z)?(i=r,r=r.nextZ,o--):(i=a,a=a.nextZ,h--),n?n.nextZ=i:t=i,i.prevZ=n,n=i;r=a}n.nextZ=null,s*=2}while(e>1)}(r)}(t,i,r,n);let o=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(n?Yh(t,i,r,n):Xh(t))e.push(h.i,t.i,l.i),pl(t),t=l.next,o=l.next;else if((t=l)===o){a?1===a?Jh(t=Zh(qh(t),e),e,s,i,r,n,2):2===a&&Gh(t,e,s,i,r,n):Jh(qh(t),e,s,i,r,n,1);break}}}function Xh(t){const e=t.prev,s=t,i=t.next;if(nl(e,s,i)>=0)return!1;const r=e.x,n=s.x,a=i.x,o=e.y,h=s.y,l=i.y,c=Math.min(r,n,a),u=Math.min(o,h,l),d=Math.max(r,n,a),p=Math.max(o,h,l);let m=i.next;for(;m!==e;){if(m.x>=c&&m.x<=d&&m.y>=u&&m.y<=p&&il(r,o,n,h,a,l,m.x,m.y)&&nl(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Yh(t,e,s,i){const r=t.prev,n=t,a=t.next;if(nl(r,n,a)>=0)return!1;const o=r.x,h=n.x,l=a.x,c=r.y,u=n.y,d=a.y,p=Math.min(o,h,l),m=Math.min(c,u,d),y=Math.max(o,h,l),g=Math.max(c,u,d),f=tl(p,m,e,s,i),x=tl(y,g,e,s,i);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=f&&v&&v.z<=x;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=f;){if(b.x>=p&&b.x<=y&&b.y>=m&&b.y<=g&&b!==r&&b!==a&&il(o,c,h,u,l,d,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=g&&v!==r&&v!==a&&il(o,c,h,u,l,d,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Zh(t,e){let s=t;do{const i=s.prev,r=s.next.next;!al(i,r)&&ol(i,s,s.next,r)&&cl(i,r)&&cl(r,i)&&(e.push(i.i,s.i,r.i),pl(s),pl(s.next),s=t=r),s=s.next}while(s!==t);return qh(s)}function Gh(t,e,s,i,r,n){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&rl(a,t)){let o=ul(a,t);return a=qh(a,a.next),o=qh(o,o.next),Jh(a,e,s,i,r,n,0),void Jh(o,e,s,i,r,n,0)}t=t.next}a=a.next}while(a!==t)}function $h(t,e){let s=t.x-e.x;if(0===s&&(s=t.y-e.y,0===s)){s=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return s}function Qh(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,a=-1/0;if(al(t,s))return s;do{if(al(t,s.next))return s.next;if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>a&&(a=t,n=s.x<s.next.x?s:s.next,t===i))return n}s=s.next}while(s!==e);if(!n)return null;const o=n,h=n.x,l=n.y;let c=1/0;s=n;do{if(i>=s.x&&s.x>=h&&i!==s.x&&sl(r<l?i:a,r,h,l,r<l?a:i,r,s.x,s.y)){const e=Math.abs(r-s.y)/(i-s.x);cl(s,t)&&(e<c||e===c&&(s.x>n.x||s.x===n.x&&Kh(n,s)))&&(n=s,c=e)}s=s.next}while(s!==o);return n}(t,e);if(!s)return e;const i=ul(s,t);return qh(i,i.next),qh(s,s.next)}function Kh(t,e){return nl(t.prev,t,e.prev)<0&&nl(e.next,t,t.next)<0}function tl(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function el(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function sl(t,e,s,i,r,n,a,o){return(r-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(i-o)>=(s-a)*(e-o)&&(s-a)*(n-o)>=(r-a)*(i-o)}function il(t,e,s,i,r,n,a,o){return!(t===a&&e===o)&&sl(t,e,s,i,r,n,a,o)}function rl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==e.i&&s.next.i!==e.i&&ol(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&(cl(t,e)&&cl(e,t)&&function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)&&(nl(t.prev,t,e.prev)||nl(t,e.prev,e))||al(t,e)&&nl(t.prev,t,t.next)>0&&nl(e.prev,e,e.next)>0)}function nl(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function al(t,e){return t.x===e.x&&t.y===e.y}function ol(t,e,s,i){const r=ll(nl(t,e,s)),n=ll(nl(t,e,i)),a=ll(nl(s,i,t)),o=ll(nl(s,i,e));return r!==n&&a!==o||(!(0!==r||!hl(t,s,e))||(!(0!==n||!hl(t,i,e))||(!(0!==a||!hl(s,t,i))||!(0!==o||!hl(s,e,i)))))}function hl(t,e,s){return e.x<=Math.max(t.x,s.x)&&e.x>=Math.min(t.x,s.x)&&e.y<=Math.max(t.y,s.y)&&e.y>=Math.min(t.y,s.y)}function ll(t){return t>0?1:t<0?-1:0}function cl(t,e){return nl(t.prev,t,t.next)<0?nl(t,e,t.next)>=0&&nl(t,t.prev,e)>=0:nl(t,e,t.prev)<0||nl(t,t.next,e)<0}function ul(t,e){const s=ml(t.i,t.x,t.y),i=ml(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function dl(t,e,s,i){const r=ml(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function pl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ml(t,e,s){return{i:t,x:e,y:s,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class yl{static triangulate(t,e,s=2){return Uh(t,e,s)}}class gl{static area(t){const e=t.length;let s=0;for(let i=e-1,r=0;r<e;i=r++)s+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*s}static isClockWise(t){return gl.area(t)<0}static triangulateShape(t,e){const s=[],i=[],r=[];fl(t),xl(s,t);let n=t.length;e.forEach(fl);for(let t=0;t<e.length;t++)i.push(n),n+=e[t].length,xl(s,e[t]);const a=yl.triangulate(s,i);for(let t=0;t<a.length;t+=3)r.push(a.slice(t,t+3));return r}}function fl(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function xl(t,e){for(let s=0;s<e.length;s++)t.push(e[s].x),t.push(e[s].y)}class bl extends In{constructor(t=new Wh([new $s(.5,.5),new $s(-.5,.5),new $s(-.5,-.5),new $s(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const s=this,i=[],r=[];for(let e=0,s=t.length;e<s;e++){n(t[e])}function n(t){const n=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,h=void 0!==e.depth?e.depth:1;let l=void 0===e.bevelEnabled||e.bevelEnabled,c=void 0!==e.bevelThickness?e.bevelThickness:.2,u=void 0!==e.bevelSize?e.bevelSize:c-.1,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const m=e.extrudePath,y=void 0!==e.UVGenerator?e.UVGenerator:vl;let g,f,x,b,v,w=!1;m&&(g=m.getSpacedPoints(o),w=!0,l=!1,f=m.computeFrenetFrames(o,!1),x=new Ks,b=new Ks,v=new Ks),l||(p=0,c=0,u=0,d=0);const M=t.extractPoints(a);let S=M.shape;const _=M.holes;if(!gl.isClockWise(S)){S=S.reverse();for(let t=0,e=_.length;t<e;t++){const e=_[t];gl.isClockWise(e)&&(_[t]=e.reverse())}}function A(t){const e=1e-10*1e-10;let s=t[0];for(let i=1;i<=t.length;i++){const r=i%t.length,n=t[r],a=n.x-s.x,o=n.y-s.y,h=a*a+o*o,l=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(s.x),Math.abs(s.y));h<=e*l*l?(t.splice(r,1),i--):s=n}}A(S),_.forEach(A);const T=_.length,z=S;for(let t=0;t<T;t++){const e=_[t];S=S.concat(e)}function C(t,e,s){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,s)}const I=S.length;function B(t,e,s){let i,r,n;const a=t.x-e.x,o=t.y-e.y,h=s.x-t.x,l=s.y-t.y,c=a*a+o*o,u=a*l-o*h;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(h*h+l*l),p=e.x-o/u,m=e.y+a/u,y=((s.x-l/d-p)*l-(s.y+h/d-m)*h)/(a*l-o*h);i=p+a*y-t.x,r=m+o*y-t.y;const g=i*i+r*r;if(g<=2)return new $s(i,r);n=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?h>Number.EPSILON&&(t=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(l)&&(t=!0),t?(i=-o,r=a,n=Math.sqrt(c)):(i=a,r=o,n=Math.sqrt(c/2))}return new $s(i/n,r/n)}const k=[];for(let t=0,e=z.length,s=e-1,i=t+1;t<e;t++,s++,i++)s===e&&(s=0),i===e&&(i=0),k[t]=B(z[t],z[s],z[i]);const E=[];let R,P,O=k.concat();for(let t=0,e=T;t<e;t++){const e=_[t];R=[];for(let t=0,s=e.length,i=s-1,r=t+1;t<s;t++,i++,r++)i===s&&(i=0),r===s&&(r=0),R[t]=B(e[t],e[i],e[r]);E.push(R),O=O.concat(R)}if(0===p)P=gl.triangulateShape(z,_);else{const t=[],e=[];for(let s=0;s<p;s++){const i=s/p,r=c*Math.cos(i*Math.PI/2),n=u*Math.sin(i*Math.PI/2)+d;for(let e=0,s=z.length;e<s;e++){const s=C(z[e],k[e],n);L(s.x,s.y,-r),0===i&&t.push(s)}for(let t=0,s=T;t<s;t++){const s=_[t];R=E[t];const a=[];for(let t=0,e=s.length;t<e;t++){const e=C(s[t],R[t],n);L(e.x,e.y,-r),0===i&&a.push(e)}0===i&&e.push(a)}}P=gl.triangulateShape(t,e)}const N=P.length,V=u+d;for(let t=0;t<I;t++){const e=l?C(S[t],O[t],V):S[t];w?(b.copy(f.normals[0]).multiplyScalar(e.x),x.copy(f.binormals[0]).multiplyScalar(e.y),v.copy(g[0]).add(b).add(x),L(v.x,v.y,v.z)):L(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<I;e++){const s=l?C(S[e],O[e],V):S[e];w?(b.copy(f.normals[t]).multiplyScalar(s.x),x.copy(f.binormals[t]).multiplyScalar(s.y),v.copy(g[t]).add(b).add(x),L(v.x,v.y,v.z)):L(s.x,s.y,h/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,s=c*Math.cos(e*Math.PI/2),i=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=z.length;t<e;t++){const e=C(z[t],k[t],i);L(e.x,e.y,h+s)}for(let t=0,e=_.length;t<e;t++){const e=_[t];R=E[t];for(let t=0,r=e.length;t<r;t++){const r=C(e[t],R[t],i);w?L(r.x,r.y+g[o-1].y,g[o-1].x+s):L(r.x,r.y,h+s)}}}function F(t,e){let s=t.length;for(;--s>=0;){const i=s;let r=s-1;r<0&&(r=t.length-1);for(let t=0,s=o+2*p;t<s;t++){const s=I*t,n=I*(t+1);D(e+i+s,e+r+s,e+r+n,e+i+n)}}}function L(t,e,s){n.push(t),n.push(e),n.push(s)}function j(t,e,r){W(t),W(e),W(r);const n=i.length/3,a=y.generateTopUV(s,i,n-3,n-2,n-1);U(a[0]),U(a[1]),U(a[2])}function D(t,e,r,n){W(t),W(e),W(n),W(e),W(r),W(n);const a=i.length/3,o=y.generateSideWallUV(s,i,a-6,a-3,a-2,a-1);U(o[0]),U(o[1]),U(o[3]),U(o[1]),U(o[2]),U(o[3])}function W(t){i.push(n[3*t+0]),i.push(n[3*t+1]),i.push(n[3*t+2])}function U(t){r.push(t.x),r.push(t.y)}!function(){const t=i.length/3;if(l){let t=0,e=I*t;for(let t=0;t<N;t++){const s=P[t];j(s[2]+e,s[1]+e,s[0]+e)}t=o+2*p,e=I*t;for(let t=0;t<N;t++){const s=P[t];j(s[0]+e,s[1]+e,s[2]+e)}}else{for(let t=0;t<N;t++){const e=P[t];j(e[2],e[1],e[0])}for(let t=0;t<N;t++){const e=P[t];j(e[0]+I*o,e[1]+I*o,e[2]+I*o)}}s.addGroup(t,i.length/3-t,0)}(),function(){const t=i.length/3;let e=0;F(z,e),e+=z.length;for(let t=0,s=_.length;t<s;t++){const s=_[t];F(s,e),e+=s.length}s.addGroup(t,i.length/3-t,1)}()}this.setAttribute("position",new wn(i,3)),this.setAttribute("uv",new wn(r,2)),this.computeVertexNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e,s){if(s.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){const i=t[e];s.shapes.push(i.uuid)}else s.shapes.push(t.uuid);s.options=Object.assign({},e),void 0!==e.extrudePath&&(s.options.extrudePath=e.extrudePath.toJSON());return s}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const s=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];s.push(r)}const i=t.options.extrudePath;return void 0!==i&&(t.options.extrudePath=(new Lh[i.type]).fromJSON(i)),new bl(s,t.options)}}const vl={generateTopUV:function(t,e,s,i,r){const n=e[3*s],a=e[3*s+1],o=e[3*i],h=e[3*i+1],l=e[3*r],c=e[3*r+1];return[new $s(n,a),new $s(o,h),new $s(l,c)]},generateSideWallUV:function(t,e,s,i,r,n){const a=e[3*s],o=e[3*s+1],h=e[3*s+2],l=e[3*i],c=e[3*i+1],u=e[3*i+2],d=e[3*r],p=e[3*r+1],m=e[3*r+2],y=e[3*n],g=e[3*n+1],f=e[3*n+2];return Math.abs(o-c)<Math.abs(a-l)?[new $s(a,1-h),new $s(l,1-u),new $s(d,1-m),new $s(y,1-f)]:[new $s(o,1-h),new $s(c,1-u),new $s(p,1-m),new $s(g,1-f)]}};class wl extends ph{constructor(t=1,e=0){const s=(1+Math.sqrt(5))/2;super([-1,s,0,1,s,0,-1,-s,0,1,-s,0,0,-1,s,0,1,s,0,-1,-s,0,1,-s,s,0,-1,s,0,1,-s,0,-1,-s,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new wl(t.radius,t.detail)}}class Ml extends In{constructor(t=[new $s(0,-.5),new $s(.5,0),new $s(0,.5)],e=12,s=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:s,phiLength:i},e=Math.floor(e),i=qs(i,0,2*Math.PI);const r=[],n=[],a=[],o=[],h=[],l=1/e,c=new Ks,u=new $s,d=new Ks,p=new Ks,m=new Ks;let y=0,g=0;for(let e=0;e<=t.length-1;e++)switch(e){case 0:y=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-y,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:y=t[e+1].x-t[e].x,g=t[e+1].y-t[e].y,d.x=1*g,d.y=-y,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=e;r++){const d=s+r*l*i,p=Math.sin(d),m=Math.cos(d);for(let s=0;s<=t.length-1;s++){c.x=t[s].x*p,c.y=t[s].y,c.z=t[s].x*m,n.push(c.x,c.y,c.z),u.x=r/e,u.y=s/(t.length-1),a.push(u.x,u.y);const i=o[3*s+0]*p,l=o[3*s+1],d=o[3*s+0]*m;h.push(i,l,d)}}for(let s=0;s<e;s++)for(let e=0;e<t.length-1;e++){const i=e+s*t.length,n=i,a=i+t.length,o=i+t.length+1,h=i+1;r.push(n,a,h),r.push(o,h,a)}this.setIndex(r),this.setAttribute("position",new wn(n,3)),this.setAttribute("uv",new wn(a,2)),this.setAttribute("normal",new wn(h,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ml(t.points,t.segments,t.phiStart,t.phiLength)}}class Sl extends ph{constructor(t=1,e=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Sl(t.radius,t.detail)}}class _l extends In{constructor(t=1,e=1,s=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:s,heightSegments:i};const r=t/2,n=e/2,a=Math.floor(s),o=Math.floor(i),h=a+1,l=o+1,c=t/a,u=e/o,d=[],p=[],m=[],y=[];for(let t=0;t<l;t++){const e=t*u-n;for(let s=0;s<h;s++){const i=s*c-r;p.push(i,-e,0),m.push(0,0,1),y.push(s/a),y.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const s=e+h*t,i=e+h*(t+1),r=e+1+h*(t+1),n=e+1+h*t;d.push(s,i,n),d.push(i,r,n)}this.setIndex(d),this.setAttribute("position",new wn(p,3)),this.setAttribute("normal",new wn(m,3)),this.setAttribute("uv",new wn(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new _l(t.width,t.height,t.widthSegments,t.heightSegments)}}class Al extends In{constructor(t=.5,e=1,s=32,i=1,r=0,n=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:s,phiSegments:i,thetaStart:r,thetaLength:n},s=Math.max(3,s);const a=[],o=[],h=[],l=[];let c=t;const u=(e-t)/(i=Math.max(1,i)),d=new Ks,p=new $s;for(let t=0;t<=i;t++){for(let t=0;t<=s;t++){const i=r+t/s*n;d.x=c*Math.cos(i),d.y=c*Math.sin(i),o.push(d.x,d.y,d.z),h.push(0,0,1),p.x=(d.x/e+1)/2,p.y=(d.y/e+1)/2,l.push(p.x,p.y)}c+=u}for(let t=0;t<i;t++){const e=t*(s+1);for(let t=0;t<s;t++){const i=t+e,r=i,n=i+s+1,o=i+s+2,h=i+1;a.push(r,n,h),a.push(n,o,h)}}this.setIndex(a),this.setAttribute("position",new wn(o,3)),this.setAttribute("normal",new wn(h,3)),this.setAttribute("uv",new wn(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Al(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Tl extends In{constructor(t=new Wh([new $s(0,.5),new $s(-.5,-.5),new $s(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const s=[],i=[],r=[],n=[];let a=0,o=0;if(!1===Array.isArray(t))h(t);else for(let e=0;e<t.length;e++)h(t[e]),this.addGroup(a,o,e),a+=o,o=0;function h(t){const a=i.length/3,h=t.extractPoints(e);let l=h.shape;const c=h.holes;!1===gl.isClockWise(l)&&(l=l.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===gl.isClockWise(e)&&(c[t]=e.reverse())}const u=gl.triangulateShape(l,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];l=l.concat(e)}for(let t=0,e=l.length;t<e;t++){const e=l[t];i.push(e.x,e.y,0),r.push(0,0,1),n.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],i=e[0]+a,r=e[1]+a,n=e[2]+a;s.push(i,r,n),o+=3}}this.setIndex(s),this.setAttribute("position",new wn(i,3)),this.setAttribute("normal",new wn(r,3)),this.setAttribute("uv",new wn(n,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return function(t,e){if(e.shapes=[],Array.isArray(t))for(let s=0,i=t.length;s<i;s++){const i=t[s];e.shapes.push(i.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const s=[];for(let i=0,r=t.shapes.length;i<r;i++){const r=e[t.shapes[i]];s.push(r)}return new Tl(s,t.curveSegments)}}class zl extends In{constructor(t=1,e=32,s=16,i=0,r=2*Math.PI,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:s,phiStart:i,phiLength:r,thetaStart:n,thetaLength:a},e=Math.max(3,Math.floor(e)),s=Math.max(2,Math.floor(s));const o=Math.min(n+a,Math.PI);let h=0;const l=[],c=new Ks,u=new Ks,d=[],p=[],m=[],y=[];for(let d=0;d<=s;d++){const g=[],f=d/s;let x=0;0===d&&0===n?x=.5/e:d===s&&o===Math.PI&&(x=-.5/e);for(let s=0;s<=e;s++){const o=s/e;c.x=-t*Math.cos(i+o*r)*Math.sin(n+f*a),c.y=t*Math.cos(n+f*a),c.z=t*Math.sin(i+o*r)*Math.sin(n+f*a),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),y.push(o+x,1-f),g.push(h++)}l.push(g)}for(let t=0;t<s;t++)for(let i=0;i<e;i++){const e=l[t][i+1],r=l[t][i],a=l[t+1][i],h=l[t+1][i+1];(0!==t||n>0)&&d.push(e,r,h),(t!==s-1||o<Math.PI)&&d.push(r,a,h)}this.setIndex(d),this.setAttribute("position",new wn(p,3)),this.setAttribute("normal",new wn(m,3)),this.setAttribute("uv",new wn(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new zl(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Cl extends ph{constructor(t=1,e=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Cl(t.radius,t.detail)}}class Il extends In{constructor(t=1,e=.4,s=12,i=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:s,tubularSegments:i,arc:r},s=Math.floor(s),i=Math.floor(i);const n=[],a=[],o=[],h=[],l=new Ks,c=new Ks,u=new Ks;for(let n=0;n<=s;n++)for(let d=0;d<=i;d++){const p=d/i*r,m=n/s*Math.PI*2;c.x=(t+e*Math.cos(m))*Math.cos(p),c.y=(t+e*Math.cos(m))*Math.sin(p),c.z=e*Math.sin(m),a.push(c.x,c.y,c.z),l.x=t*Math.cos(p),l.y=t*Math.sin(p),u.subVectors(c,l).normalize(),o.push(u.x,u.y,u.z),h.push(d/i),h.push(n/s)}for(let t=1;t<=s;t++)for(let e=1;e<=i;e++){const s=(i+1)*t+e-1,r=(i+1)*(t-1)+e-1,a=(i+1)*(t-1)+e,o=(i+1)*t+e;n.push(s,r,o),n.push(r,a,o)}this.setIndex(n),this.setAttribute("position",new wn(a,3)),this.setAttribute("normal",new wn(o,3)),this.setAttribute("uv",new wn(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Il(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Bl extends In{constructor(t=1,e=.4,s=64,i=8,r=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:s,radialSegments:i,p:r,q:n},s=Math.floor(s),i=Math.floor(i);const a=[],o=[],h=[],l=[],c=new Ks,u=new Ks,d=new Ks,p=new Ks,m=new Ks,y=new Ks,g=new Ks;for(let a=0;a<=s;++a){const x=a/s*r*Math.PI*2;f(x,r,n,t,d),f(x+.01,r,n,t,p),y.subVectors(p,d),g.addVectors(p,d),m.crossVectors(y,g),g.crossVectors(m,y),m.normalize(),g.normalize();for(let t=0;t<=i;++t){const r=t/i*Math.PI*2,n=-e*Math.cos(r),p=e*Math.sin(r);c.x=d.x+(n*g.x+p*m.x),c.y=d.y+(n*g.y+p*m.y),c.z=d.z+(n*g.z+p*m.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),h.push(u.x,u.y,u.z),l.push(a/s),l.push(t/i)}}for(let t=1;t<=s;t++)for(let e=1;e<=i;e++){const s=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),n=(i+1)*t+e,o=(i+1)*(t-1)+e;a.push(s,r,o),a.push(r,n,o)}function f(t,e,s,i,r){const n=Math.cos(t),a=Math.sin(t),o=s/e*t,h=Math.cos(o);r.x=i*(2+h)*.5*n,r.y=i*(2+h)*a*.5,r.z=i*Math.sin(o)*.5}this.setIndex(a),this.setAttribute("position",new wn(o,3)),this.setAttribute("normal",new wn(h,3)),this.setAttribute("uv",new wn(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bl(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class kl extends In{constructor(t=new Vh(new Ks(-1,-1,0),new Ks(-1,1,0),new Ks(1,1,0)),e=64,s=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:s,radialSegments:i,closed:r};const n=t.computeFrenetFrames(e,r);this.tangents=n.tangents,this.normals=n.normals,this.binormals=n.binormals;const a=new Ks,o=new Ks,h=new $s;let l=new Ks;const c=[],u=[],d=[],p=[];function m(r){l=t.getPointAt(r/e,l);const h=n.normals[r],d=n.binormals[r];for(let t=0;t<=i;t++){const e=t/i*Math.PI*2,r=Math.sin(e),n=-Math.cos(e);o.x=n*h.x+r*d.x,o.y=n*h.y+r*d.y,o.z=n*h.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=l.x+s*o.x,a.y=l.y+s*o.y,a.z=l.z+s*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)m(t);m(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let s=0;s<=i;s++)h.x=t/e,h.y=s/i,d.push(h.x,h.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=i;e++){const s=(i+1)*(t-1)+(e-1),r=(i+1)*t+(e-1),n=(i+1)*t+e,a=(i+1)*(t-1)+e;p.push(s,r,a),p.push(r,n,a)}}()}(),this.setIndex(p),this.setAttribute("position",new wn(c,3)),this.setAttribute("normal",new wn(u,3)),this.setAttribute("uv",new wn(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new kl((new Lh[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class El extends In{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},null!==t){const e=[],s=new Set,i=new Ks,r=new Ks;if(null!==t.index){const n=t.attributes.position,a=t.index;let o=t.groups;0===o.length&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let t=0,h=o.length;t<h;++t){const h=o[t],l=h.start;for(let t=l,o=l+h.count;t<o;t+=3)for(let o=0;o<3;o++){const h=a.getX(t+o),l=a.getX(t+(o+1)%3);i.fromBufferAttribute(n,h),r.fromBufferAttribute(n,l),!0===Rl(i,r,s)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{const n=t.attributes.position;for(let t=0,a=n.count/3;t<a;t++)for(let a=0;a<3;a++){const o=3*t+a,h=3*t+(a+1)%3;i.fromBufferAttribute(n,o),r.fromBufferAttribute(n,h),!0===Rl(i,r,s)&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new wn(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Rl(t,e,s){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==s.has(i)&&!0!==s.has(r)&&(s.add(i),s.add(r),!0)}var Pl=Object.freeze({__proto__:null,BoxGeometry:Un,CapsuleGeometry:lh,CircleGeometry:ch,ConeGeometry:dh,CylinderGeometry:uh,DodecahedronGeometry:mh,EdgesGeometry:bh,ExtrudeGeometry:bl,IcosahedronGeometry:wl,LatheGeometry:Ml,OctahedronGeometry:Sl,PlaneGeometry:_l,PolyhedronGeometry:ph,RingGeometry:Al,ShapeGeometry:Tl,SphereGeometry:zl,TetrahedronGeometry:Cl,TorusGeometry:Il,TorusKnotGeometry:Bl,TubeGeometry:kl,WireframeGeometry:El});class Ol extends en{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Qr(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class Nl extends Yn{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Vl extends en{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Qr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Qr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Fl extends Vl{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new $s(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return qs(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Qr(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Qr(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Qr(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Ll extends en{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Qr(16777215),this.specular=new Qr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Qr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),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.flatShading=t.flatShading,this.fog=t.fog,this}}class jl extends en{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Qr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Qr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class Dl extends en{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Wl extends en{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Qr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Qr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),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.flatShading=t.flatShading,this.fog=t.fog,this}}class Ul extends en{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 Hl extends en{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",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.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class ql extends en{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Qr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new $s(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Jl extends Ro{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function Xl(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function Yl(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zl(t){const e=t.length,s=new Array(e);for(let t=0;t!==e;++t)s[t]=t;return s.sort(function(e,s){return t[e]-t[s]}),s}function Gl(t,e,s){const i=t.length,r=new t.constructor(i);for(let n=0,a=0;a!==i;++n){const i=s[n]*e;for(let s=0;s!==e;++s)r[a++]=t[i+s]}return r}function $l(t,e,s,i){let r=1,n=t[0];for(;void 0!==n&&void 0===n[i];)n=t[r++];if(void 0===n)return;let a=n[i];if(void 0!==a)if(Array.isArray(a))do{a=n[i],void 0!==a&&(e.push(n.time),s.push(...a)),n=t[r++]}while(void 0!==n);else if(void 0!==a.toArray)do{a=n[i],void 0!==a&&(e.push(n.time),a.toArray(s,s.length)),n=t[r++]}while(void 0!==n);else do{a=n[i],void 0!==a&&(e.push(n.time),s.push(a)),n=t[r++]}while(void 0!==n)}class Ql{static convertArray(t,e){return Xl(t,e)}static isTypedArray(t){return Yl(t)}static getKeyframeOrder(t){return Zl(t)}static sortedArray(t,e,s){return Gl(t,e,s)}static flattenJSON(t,e,s,i){$l(t,e,s,i)}static subclip(t,e,s,i,r=30){return function(t,e,s,i,r=30){const n=t.clone();n.name=e;const a=[];for(let t=0;t<n.tracks.length;++t){const e=n.tracks[t],o=e.getValueSize(),h=[],l=[];for(let t=0;t<e.times.length;++t){const n=e.times[t]*r;if(!(n<s||n>=i)){h.push(e.times[t]);for(let s=0;s<o;++s)l.push(e.values[t*o+s])}}0!==h.length&&(e.times=Xl(h,e.times.constructor),e.values=Xl(l,e.values.constructor),a.push(e))}n.tracks=a;let o=1/0;for(let t=0;t<n.tracks.length;++t)o>n.tracks[t].times[0]&&(o=n.tracks[t].times[0]);for(let t=0;t<n.tracks.length;++t)n.tracks[t].shift(-1*o);return n.resetDuration(),n}(t,e,s,i,r)}static makeClipAdditive(t,e=0,s=t,i=30){return function(t,e=0,s=t,i=30){i<=0&&(i=30);const r=s.tracks.length,n=e/i;for(let e=0;e<r;++e){const i=s.tracks[e],r=i.ValueTypeName;if("bool"===r||"string"===r)continue;const a=t.tracks.find(function(t){return t.name===i.name&&t.ValueTypeName===r});if(void 0===a)continue;let o=0;const h=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let l=0;const c=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);const u=i.times.length-1;let d;if(n<=i.times[0]){const t=o,e=h-o;d=i.values.slice(t,e)}else if(n>=i.times[u]){const t=u*h+o,e=t+h-o;d=i.values.slice(t,e)}else{const t=i.createInterpolant(),e=o,s=h-o;t.evaluate(n),d=t.resultBuffer.slice(e,s)}"quaternion"===r&&(new Qs).fromArray(d).normalize().conjugate().toArray(d);const p=a.times.length;for(let t=0;t<p;++t){const e=t*c+l;if("quaternion"===r)Qs.multiplyQuaternionsFlat(a.values,e,d,0,a.values,e);else{const t=c-2*l;for(let s=0;s<t;++s)a.values[e+s]-=d[s]}}}return t.blendMode=Fe,t}(t,e,s,i)}}class Kl{constructor(t,e,s,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(s),this.sampleValues=e,this.valueSize=s,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let s=this._cachedIndex,i=e[s],r=e[s-1];t:{e:{let n;s:{i:if(!(t<i)){for(let n=s+2;;){if(void 0===i){if(t<r)break i;return s=e.length,this._cachedIndex=s,this.copySampleValue_(s-1)}if(s===n)break;if(r=i,i=e[++s],t<i)break e}n=e.length;break s}if(!(t>=r)){const a=e[1];t<a&&(s=2,r=a);for(let n=s-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(s===n)break;if(i=r,r=e[--s-1],t>=r)break e}n=s,s=0;break s}break t}for(;s<n;){const i=s+n>>>1;t<e[i]?n=i:s=i+1}if(i=e[s],r=e[s-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return s=e.length,this._cachedIndex=s,this.copySampleValue_(s-1)}this._cachedIndex=s,this.intervalChanged_(s,r,i)}return this.interpolate_(s,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,i=this.valueSize,r=t*i;for(let t=0;t!==i;++t)e[t]=s[r+t];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class tc extends Kl{constructor(t,e,s,i){super(t,e,s,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Pe,endingEnd:Pe}}intervalChanged_(t,e,s){const i=this.parameterPositions;let r=t-2,n=t+1,a=i[r],o=i[n];if(void 0===a)switch(this.getSettings_().endingStart){case Oe:r=t,a=2*e-s;break;case Ne:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=s}if(void 0===o)switch(this.getSettings_().endingEnd){case Oe:n=t,o=2*s-e;break;case Ne:n=1,o=s+i[1]-i[0];break;default:n=t-1,o=e}const h=.5*(s-e),l=this.valueSize;this._weightPrev=h/(e-a),this._weightNext=h/(o-s),this._offsetPrev=r*l,this._offsetNext=n*l}interpolate_(t,e,s,i){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=t*a,h=o-a,l=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(s-e)/(i-e),m=p*p,y=m*p,g=-u*y+2*u*m-u*p,f=(1+u)*y+(-1.5-2*u)*m+(-.5+u)*p+1,x=(-1-d)*y+(1.5+d)*m+.5*p,b=d*y-d*m;for(let t=0;t!==a;++t)r[t]=g*n[l+t]+f*n[h+t]+x*n[o+t]+b*n[c+t];return r}}class ec extends Kl{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t,e,s,i){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=t*a,h=o-a,l=(s-e)/(i-e),c=1-l;for(let t=0;t!==a;++t)r[t]=n[h+t]*c+n[o+t]*l;return r}}class sc extends Kl{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class ic{constructor(t,e,s,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Xl(e,this.TimeBufferType),this.values=Xl(s,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let s;if(e.toJSON!==this.toJSON)s=e.toJSON(t);else{s={name:t.name,times:Xl(t.times,Array),values:Xl(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(s.interpolation=e)}return s.type=t.ValueTypeName,s}InterpolantFactoryMethodDiscrete(t){return new sc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ec(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new tc(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case ke:e=this.InterpolantFactoryMethodDiscrete;break;case Ee:e=this.InterpolantFactoryMethodLinear;break;case Re:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ke;case this.InterpolantFactoryMethodLinear:return Ee;case this.InterpolantFactoryMethodSmooth:return Re}}getValueSize(){return this.values.length/this.times.length}shift(t){if(0!==t){const e=this.times;for(let s=0,i=e.length;s!==i;++s)e[s]+=t}return this}scale(t){if(1!==t){const e=this.times;for(let s=0,i=e.length;s!==i;++s)e[s]*=t}return this}trim(t,e){const s=this.times,i=s.length;let r=0,n=i-1;for(;r!==i&&s[r]<t;)++r;for(;-1!==n&&s[n]>e;)--n;if(++n,0!==r||n!==i){r>=n&&(n=Math.max(n,1),r=n-1);const t=this.getValueSize();this.times=s.slice(r,n),this.values=this.values.slice(r*t,n*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const s=this.times,i=this.values,r=s.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let n=null;for(let e=0;e!==r;e++){const i=s[e];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,i),t=!1;break}if(null!==n&&n>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,i,n),t=!1;break}n=i}if(void 0!==i&&Yl(i))for(let e=0,s=i.length;e!==s;++e){const s=i[e];if(isNaN(s)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,s),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),s=this.getValueSize(),i=this.getInterpolation()===Re,r=t.length-1;let n=1;for(let a=1;a<r;++a){let r=!1;const o=t[a];if(o!==t[a+1]&&(1!==a||o!==t[0]))if(i)r=!0;else{const t=a*s,i=t-s,n=t+s;for(let a=0;a!==s;++a){const s=e[t+a];if(s!==e[i+a]||s!==e[n+a]){r=!0;break}}}if(r){if(a!==n){t[n]=t[a];const i=a*s,r=n*s;for(let t=0;t!==s;++t)e[r+t]=e[i+t]}++n}}if(r>0){t[n]=t[r];for(let t=r*s,i=n*s,a=0;a!==s;++a)e[i+a]=e[t+a];++n}return n!==t.length?(this.times=t.slice(0,n),this.values=e.slice(0,n*s)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),s=new(0,this.constructor)(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}}ic.prototype.ValueTypeName="",ic.prototype.TimeBufferType=Float32Array,ic.prototype.ValueBufferType=Float32Array,ic.prototype.DefaultInterpolation=Ee;class rc extends ic{constructor(t,e,s){super(t,e,s)}}rc.prototype.ValueTypeName="bool",rc.prototype.ValueBufferType=Array,rc.prototype.DefaultInterpolation=ke,rc.prototype.InterpolantFactoryMethodLinear=void 0,rc.prototype.InterpolantFactoryMethodSmooth=void 0;class nc extends ic{constructor(t,e,s,i){super(t,e,s,i)}}nc.prototype.ValueTypeName="color";class ac extends ic{constructor(t,e,s,i){super(t,e,s,i)}}ac.prototype.ValueTypeName="number";class oc extends Kl{constructor(t,e,s,i){super(t,e,s,i)}interpolate_(t,e,s,i){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(s-e)/(i-e);let h=t*a;for(let t=h+a;h!==t;h+=4)Qs.slerpFlat(r,0,n,h-a,n,h,o);return r}}class hc extends ic{constructor(t,e,s,i){super(t,e,s,i)}InterpolantFactoryMethodLinear(t){return new oc(this.times,this.values,this.getValueSize(),t)}}hc.prototype.ValueTypeName="quaternion",hc.prototype.InterpolantFactoryMethodSmooth=void 0;class lc extends ic{constructor(t,e,s){super(t,e,s)}}lc.prototype.ValueTypeName="string",lc.prototype.ValueBufferType=Array,lc.prototype.DefaultInterpolation=ke,lc.prototype.InterpolantFactoryMethodLinear=void 0,lc.prototype.InterpolantFactoryMethodSmooth=void 0;class cc extends ic{constructor(t,e,s,i){super(t,e,s,i)}}cc.prototype.ValueTypeName="vector";class uc{constructor(t="",e=-1,s=[],i=2500){this.name=t,this.tracks=s,this.duration=e,this.blendMode=i,this.uuid=Hs(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],s=t.tracks,i=1/(t.fps||1);for(let t=0,r=s.length;t!==r;++t)e.push(dc(s[t]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],s=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,i=s.length;t!==i;++t)e.push(ic.toJSON(s[t]));return i}static CreateFromMorphTargetSequence(t,e,s,i){const r=e.length,n=[];for(let t=0;t<r;t++){let a=[],o=[];a.push((t+r-1)%r,t,(t+1)%r),o.push(0,1,0);const h=Zl(a);a=Gl(a,1,h),o=Gl(o,1,h),i||0!==a[0]||(a.push(r),o.push(o[0])),n.push(new ac(".morphTargetInfluences["+e[t].name+"]",a,o).scale(1/s))}return new this(t,-1,n)}static findByName(t,e){let s=t;if(!Array.isArray(t)){const e=t;s=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<s.length;t++)if(s[t].name===e)return s[t];return null}static CreateClipsFromMorphTargetSequences(t,e,s){const i={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,s=t.length;e<s;e++){const s=t[e],n=s.name.match(r);if(n&&n.length>1){const t=n[1];let e=i[t];e||(i[t]=e=[]),e.push(s)}}const n=[];for(const t in i)n.push(this.CreateFromMorphTargetSequence(t,i[t],e,s));return n}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const s=function(t,e,s,i,r){if(0!==s.length){const n=[],a=[];$l(s,n,a,i),0!==n.length&&r.push(new t(e,n,a))}},i=[],r=t.name||"default",n=t.fps||30,a=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let t=0;t<h.length;t++){const r=h[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let s=0;s<r[e].morphTargets.length;s++)t[r[e].morphTargets[s]]=-1;for(const s in t){const t=[],n=[];for(let i=0;i!==r[e].morphTargets.length;++i){const i=r[e];t.push(i.time),n.push(i.morphTarget===s?1:0)}i.push(new ac(".morphTargetInfluence["+s+"]",t,n))}o=t.length*n}else{const n=".bones["+e[t].name+"]";s(cc,n+".position",r,"pos",i),s(hc,n+".quaternion",r,"rot",i),s(cc,n+".scale",r,"scl",i)}}if(0===i.length)return null;return new this(r,o,i,a)}resetDuration(){let t=0;for(let e=0,s=this.tracks.length;e!==s;++e){const s=this.tracks[e];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function dc(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ac;case"vector":case"vector2":case"vector3":case"vector4":return cc;case"color":return nc;case"quaternion":return hc;case"bool":case"boolean":return rc;case"string":return lc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],s=[];$l(t.keys,e,s,"value"),t.times=e,t.values=s}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}const pc={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class mc{constructor(t,e,s){const i=this;let r,n=!1,a=0,o=0;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s,this.abortController=new AbortController,this.itemStart=function(t){o++,!1===n&&void 0!==i.onStart&&i.onStart(t,a,o),n=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(n=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return h.push(t,e),this},this.removeHandler=function(t){const e=h.indexOf(t);return-1!==e&&h.splice(e,2),this},this.getHandler=function(t){for(let e=0,s=h.length;e<s;e+=2){const s=h[e],i=h[e+1];if(s.global&&(s.lastIndex=0),s.test(t))return i}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const yc=new mc;class gc{constructor(t){this.manager=void 0!==t?t:yc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const s=this;return new Promise(function(i,r){s.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}gc.DEFAULT_MATERIAL_NAME="__DEFAULT";const fc={};class xc extends Error{constructor(t,e){super(t),this.response=e}}class bc extends gc{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,s,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=pc.get(`file:${t}`);if(void 0!==r)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(void 0!==fc[t])return void fc[t].push({onLoad:e,onProgress:s,onError:i});fc[t]=[],fc[t].push({onLoad:e,onProgress:s,onError:i});const n=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(n).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const s=fc[t],i=e.body.getReader(),r=e.headers.get("X-File-Size")||e.headers.get("Content-Length"),n=r?parseInt(r):0,a=0!==n;let o=0;const h=new ReadableStream({start(t){!function e(){i.read().then(({done:i,value:r})=>{if(i)t.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:n});for(let t=0,e=s.length;t<e;t++){const e=s[t];e.onProgress&&e.onProgress(i)}t.enqueue(r),e()}},e=>{t.error(e)})}()}});return new Response(h)}throw new xc(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>(new DOMParser).parseFromString(t,a));case"json":return t.json();default:if(""===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),s=e&&e[1]?e[1].toLowerCase():void 0,i=new TextDecoder(s);return t.arrayBuffer().then(t=>i.decode(t))}}}).then(e=>{pc.add(`file:${t}`,e);const s=fc[t];delete fc[t];for(let t=0,i=s.length;t<i;t++){const i=s[t];i.onLoad&&i.onLoad(e)}}).catch(e=>{const s=fc[t];if(void 0===s)throw this.manager.itemError(t),e;delete fc[t];for(let t=0,i=s.length;t<i;t++){const i=s[t];i.onError&&i.onError(e)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class vc extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=new bc(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(s){try{e(r.parse(JSON.parse(s)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}},s,i)}parse(t){const e=[];for(let s=0;s<t.length;s++){const i=uc.parse(t[s]);e.push(i)}return e}}class wc extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=[],a=new ih,o=new bc(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let h=0;function l(l){o.load(t[l],function(t){const s=r.parse(t,!0);n[l]={width:s.width,height:s.height,format:s.format,mipmaps:s.mipmaps},h+=1,6===h&&(1===s.mipmapCount&&(a.minFilter=wt),a.image=n,a.format=s.format,a.needsUpdate=!0,e&&e(a))},s,i)}if(Array.isArray(t))for(let e=0,s=t.length;e<s;++e)l(e);else o.load(t,function(t){const s=r.parse(t,!0);if(s.isCubemap){const t=s.mipmaps.length/s.mipmapCount;for(let e=0;e<t;e++){n[e]={mipmaps:[]};for(let t=0;t<s.mipmapCount;t++)n[e].mipmaps.push(s.mipmaps[e*s.mipmapCount+t]),n[e].format=s.format,n[e].width=s.width,n[e].height=s.height}a.image=n}else a.image.width=s.width,a.image.height=s.height,a.mipmaps=s.mipmaps;1===s.mipmapCount&&(a.minFilter=wt),a.format=s.format,a.needsUpdate=!0,e&&e(a)},s,i);return a}}const Mc=new WeakMap;class Sc extends gc{constructor(t){super(t)}load(t,e,s,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,n=pc.get(`image:${t}`);if(void 0!==n){if(!0===n.complete)r.manager.itemStart(t),setTimeout(function(){e&&e(n),r.manager.itemEnd(t)},0);else{let t=Mc.get(n);void 0===t&&(t=[],Mc.set(n,t)),t.push({onLoad:e,onError:i})}return n}const a=oi("img");function o(){l(),e&&e(this);const s=Mc.get(this)||[];for(let t=0;t<s.length;t++){const e=s[t];e.onLoad&&e.onLoad(this)}Mc.delete(this),r.manager.itemEnd(t)}function h(e){l(),i&&i(e),pc.remove(`image:${t}`);const s=Mc.get(this)||[];for(let t=0;t<s.length;t++){const i=s[t];i.onError&&i.onError(e)}Mc.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function l(){a.removeEventListener("load",o,!1),a.removeEventListener("error",h,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",h,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),pc.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}}class _c extends gc{constructor(t){super(t)}load(t,e,s,i){const r=new sa;r.colorSpace=Ze;const n=new Sc(this.manager);n.setCrossOrigin(this.crossOrigin),n.setPath(this.path);let a=0;function o(s){n.load(t[s],function(t){r.images[s]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,i)}for(let e=0;e<t.length;++e)o(e);return r}}class Ac extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=new Ua,a=new bc(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(t){let s;try{s=r.parse(t)}catch(t){if(void 0===i)return void console.error(t);i(t)}void 0!==s.image?n.image=s.image:void 0!==s.data&&(n.image.width=s.width,n.image.height=s.height,n.image.data=s.data),n.wrapS=void 0!==s.wrapS?s.wrapS:mt,n.wrapT=void 0!==s.wrapT?s.wrapT:mt,n.magFilter=void 0!==s.magFilter?s.magFilter:wt,n.minFilter=void 0!==s.minFilter?s.minFilter:wt,n.anisotropy=void 0!==s.anisotropy?s.anisotropy:1,void 0!==s.colorSpace&&(n.colorSpace=s.colorSpace),void 0!==s.flipY&&(n.flipY=s.flipY),void 0!==s.format&&(n.format=s.format),void 0!==s.type&&(n.type=s.type),void 0!==s.mipmaps&&(n.mipmaps=s.mipmaps,n.minFilter=_t),1===s.mipmapCount&&(n.minFilter=wt),void 0!==s.generateMipmaps&&(n.generateMipmaps=s.generateMipmaps),n.needsUpdate=!0,e&&e(n,s)},s,i),n}}class Tc extends gc{constructor(t){super(t)}load(t,e,s,i){const r=new Ai,n=new Sc(this.manager);return n.setCrossOrigin(this.crossOrigin),n.setPath(this.path),n.load(t,function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)},s,i),r}}class zc extends Rr{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Qr(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(e.object.target=this.target.uuid),e}}class Cc extends zc{constructor(t,e,s){super(t,s),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Rr.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Qr(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Ic=new ar,Bc=new Ks,kc=new Ks;class Ec{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new $s(512,512),this.mapType=Tt,this.map=null,this.mapPass=null,this.matrix=new ar,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lo,this._frameExtents=new $s(1,1),this._viewportCount=1,this._viewports=[new Ti(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,s=this.matrix;Bc.setFromMatrixPosition(t.matrixWorld),e.position.copy(Bc),kc.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(kc),e.updateMatrixWorld(),Ic.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ic,e.coordinateSystem,e.reversedDepth),e.reversedDepth?s.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):s.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),s.multiply(Ic)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 1!==this.intensity&&(t.intensity=this.intensity),0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class Rc extends Ec{constructor(){super(new Kn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,s=2*Us*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;s===e.fov&&i===e.aspect&&r===e.far||(e.fov=s,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Pc extends zc{constructor(t,e,s=0,i=Math.PI/3,r=0,n=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Rr.DEFAULT_UP),this.updateMatrix(),this.target=new Rr,this.distance=s,this.angle=i,this.penumbra=r,this.decay=n,this.map=null,this.shadow=new Rc}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Oc=new ar,Nc=new Ks,Vc=new Ks;class Fc extends Ec{constructor(){super(new Kn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new $s(4,2),this._viewportCount=6,this._viewports=[new Ti(2,1,1,1),new Ti(0,1,1,1),new Ti(3,1,1,1),new Ti(1,1,1,1),new Ti(3,0,1,1),new Ti(1,0,1,1)],this._cubeDirections=[new Ks(1,0,0),new Ks(-1,0,0),new Ks(0,0,1),new Ks(0,0,-1),new Ks(0,1,0),new Ks(0,-1,0)],this._cubeUps=[new Ks(0,1,0),new Ks(0,1,0),new Ks(0,1,0),new Ks(0,1,0),new Ks(0,0,1),new Ks(0,0,-1)]}updateMatrices(t,e=0){const s=this.camera,i=this.matrix,r=t.distance||s.far;r!==s.far&&(s.far=r,s.updateProjectionMatrix()),Nc.setFromMatrixPosition(t.matrixWorld),s.position.copy(Nc),Vc.copy(s.position),Vc.add(this._cubeDirections[e]),s.up.copy(this._cubeUps[e]),s.lookAt(Vc),s.updateMatrixWorld(),i.makeTranslation(-Nc.x,-Nc.y,-Nc.z),Oc.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Oc,s.coordinateSystem,s.reversedDepth)}}class Lc extends zc{constructor(t,e,s=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=s,this.decay=i,this.shadow=new Fc}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class jc extends Zn{constructor(t=-1,e=1,s=1,i=-1,r=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=s,this.bottom=i,this.near=r,this.far=n,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,s,i,r,n){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=s,this.view.offsetY=i,this.view.width=r,this.view.height=n,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),s=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=s-t,n=s+t,a=i+e,o=i-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,n=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,n,a,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),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}}class Dc extends Ec{constructor(){super(new jc(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Wc extends zc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Rr.DEFAULT_UP),this.updateMatrix(),this.target=new Rr,this.shadow=new Dc}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Uc extends zc{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Hc extends zc{constructor(t,e,s=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=s,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class qc{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new Ks)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const s=t.x,i=t.y,r=t.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.282095),e.addScaledVector(n[1],.488603*i),e.addScaledVector(n[2],.488603*r),e.addScaledVector(n[3],.488603*s),e.addScaledVector(n[4],s*i*1.092548),e.addScaledVector(n[5],i*r*1.092548),e.addScaledVector(n[6],.315392*(3*r*r-1)),e.addScaledVector(n[7],s*r*1.092548),e.addScaledVector(n[8],.546274*(s*s-i*i)),e}getIrradianceAt(t,e){const s=t.x,i=t.y,r=t.z,n=this.coefficients;return e.copy(n[0]).multiplyScalar(.886227),e.addScaledVector(n[1],1.023328*i),e.addScaledVector(n[2],1.023328*r),e.addScaledVector(n[3],1.023328*s),e.addScaledVector(n[4],.858086*s*i),e.addScaledVector(n[5],.858086*i*r),e.addScaledVector(n[6],.743125*r*r-.247708),e.addScaledVector(n[7],.858086*s*r),e.addScaledVector(n[8],.429043*(s*s-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let s=0;s<9;s++)this.coefficients[s].addScaledVector(t.coefficients[s],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let s=0;s<9;s++)this.coefficients[s].lerp(t.coefficients[s],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const s=this.coefficients;for(let i=0;i<9;i++)s[i].fromArray(t,e+3*i);return this}toArray(t=[],e=0){const s=this.coefficients;for(let i=0;i<9;i++)s[i].toArray(t,e+3*i);return t}static getBasisAt(t,e){const s=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*s,e[4]=1.092548*s*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*s*r,e[8]=.546274*(s*s-i*i)}}class Jc extends zc{constructor(t=new qc,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Xc extends gc{constructor(t){super(t),this.textures={}}load(t,e,s,i){const r=this,n=new bc(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,function(s){try{e(r.parse(JSON.parse(s)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}},s,i)}parse(t){const e=this.textures;function s(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const i=this.createMaterialFromType(t.type);if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new Qr).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(i.dispersion=t.dispersion),void 0!==t.iridescence&&(i.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(i.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(i.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(i.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(i.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(i.depthFunc=t.depthFunc),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(i.blendSrc=t.blendSrc),void 0!==t.blendDst&&(i.blendDst=t.blendDst),void 0!==t.blendEquation&&(i.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(i.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(i.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(i.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==i.blendColor&&i.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(i.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),void 0!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(i.forceSinglePass=t.forceSinglePass),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(i.uniforms[e]={},r.type){case"t":i.uniforms[e].value=s(r.value);break;case"c":i.uniforms[e].value=(new Qr).setHex(r.value);break;case"v2":i.uniforms[e].value=(new $s).fromArray(r.value);break;case"v3":i.uniforms[e].value=(new Ks).fromArray(r.value);break;case"v4":i.uniforms[e].value=(new Ti).fromArray(r.value);break;case"m3":i.uniforms[e].value=(new si).fromArray(r.value);break;case"m4":i.uniforms[e].value=(new ar).fromArray(r.value);break;default:i.uniforms[e].value=r.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(i.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)i.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(i.lights=t.lights),void 0!==t.clipping&&(i.clipping=t.clipping),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=s(t.map)),void 0!==t.matcap&&(i.matcap=s(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=s(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=s(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=s(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new $s).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=s(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=s(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=s(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=s(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=s(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=s(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=s(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=s(t.envMap)),void 0!==t.envMapRotation&&i.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=s(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=s(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=s(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=s(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=s(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=s(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new $s).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(i.iridescenceMap=s(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(i.iridescenceThicknessMap=s(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(i.transmissionMap=s(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=s(t.thicknessMap)),void 0!==t.anisotropyMap&&(i.anisotropyMap=s(t.anisotropyMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=s(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=s(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Xc.createMaterialFromType(t)}static createMaterialFromType(t){return new{ShadowMaterial:Ol,SpriteMaterial:pa,RawShaderMaterial:Nl,ShaderMaterial:Yn,PointsMaterial:Xo,MeshPhysicalMaterial:Fl,MeshStandardMaterial:Vl,MeshPhongMaterial:Ll,MeshToonMaterial:jl,MeshNormalMaterial:Dl,MeshLambertMaterial:Wl,MeshDepthMaterial:Ul,MeshDistanceMaterial:Hl,MeshBasicMaterial:sn,MeshMatcapMaterial:ql,LineDashedMaterial:Jl,LineBasicMaterial:Ro,Material:en}[t]}}class Yc{static extractUrlBase(t){const e=t.lastIndexOf("/");return-1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class Zc extends In{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Gc extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=new bc(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,function(s){try{e(r.parse(JSON.parse(s)))}catch(e){i?i(e):console.error(e),r.manager.itemError(t)}},s,i)}parse(t){const e={},s={};function i(t,i){if(void 0!==e[i])return e[i];const r=t.interleavedBuffers[i],n=function(t,e){if(void 0!==s[e])return s[e];const i=t.arrayBuffers,r=i[e],n=new Uint32Array(r).buffer;return s[e]=n,n}(t,r.buffer),a=ai(r.type,n),o=new ca(a,r.stride);return o.uuid=r.uuid,e[i]=o,o}const r=t.isInstancedBufferGeometry?new Zc:new In,n=t.data.index;if(void 0!==n){const t=ai(n.type,n.array);r.setIndex(new dn(t,1))}const a=t.data.attributes;for(const e in a){const s=a[e];let n;if(s.isInterleavedBufferAttribute){const e=i(t.data,s.data);n=new da(e,s.itemSize,s.offset,s.normalized)}else{const t=ai(s.type,s.array);n=new(s.isInstancedBufferAttribute?Xa:dn)(t,s.itemSize,s.normalized)}void 0!==s.name&&(n.name=s.name),void 0!==s.usage&&n.setUsage(s.usage),r.setAttribute(e,n)}const o=t.data.morphAttributes;if(o)for(const e in o){const s=o[e],n=[];for(let e=0,r=s.length;e<r;e++){const r=s[e];let a;if(r.isInterleavedBufferAttribute){const e=i(t.data,r.data);a=new da(e,r.itemSize,r.offset,r.normalized)}else{const t=ai(r.type,r.array);a=new dn(t,r.itemSize,r.normalized)}void 0!==r.name&&(a.name=r.name),n.push(a)}r.morphAttributes[e]=n}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const h=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==h)for(let t=0,e=h.length;t!==e;++t){const e=h[t];r.addGroup(e.start,e.count,e.materialIndex)}const l=t.data.boundingSphere;return void 0!==l&&(r.boundingSphere=(new $i).fromJSON(l)),t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}class $c extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=""===this.path?Yc.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||n;const a=new bc(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(s){let n=null;try{n=JSON.parse(s)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}const a=n.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("THREE.ObjectLoader: Can't load "+t)),void console.error("THREE.ObjectLoader: Can't load "+t);r.parse(n,e)},s,i)}async loadAsync(t,e){const s=""===this.path?Yc.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const i=new bc(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const r=await i.loadAsync(t,e),n=JSON.parse(r),a=n.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+t);return await this.parseAsync(n)}parse(t,e){const s=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),n=this.parseImages(t.images,function(){void 0!==e&&e(h)}),a=this.parseTextures(t.textures,n),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,r,o,a,s),l=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,l),this.bindLightTargets(h),void 0!==e){let t=!1;for(const e in n)if(n[e].data instanceof HTMLImageElement){t=!0;break}!1===t&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),s=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,s),r=await this.parseImagesAsync(t.images),n=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,n),o=this.parseObject(t.object,i,a,n,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(void 0!==t)for(let s=0,i=t.length;s<i;s++){const i=(new Wh).fromJSON(t[s]);e[i.uuid]=i}return e}parseSkeletons(t,e){const s={},i={};if(e.traverse(function(t){t.isBone&&(i[t.uuid]=t)}),void 0!==t)for(let e=0,r=t.length;e<r;e++){const r=(new Ja).fromJSON(t[e],i);s[r.uuid]=r}return s}parseGeometries(t,e){const s={};if(void 0!==t){const i=new Gc;for(let r=0,n=t.length;r<n;r++){let n;const a=t[r];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":n=i.parse(a);break;default:a.type in Pl?n=Pl[a.type].fromJSON(a,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}n.uuid=a.uuid,void 0!==a.name&&(n.name=a.name),void 0!==a.userData&&(n.userData=a.userData),s[a.uuid]=n}}return s}parseMaterials(t,e){const s={},i={};if(void 0!==t){const r=new Xc;r.setTextures(e);for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0===s[n.uuid]&&(s[n.uuid]=r.parse(n)),i[n.uuid]=s[n.uuid]}}return i}parseAnimations(t){const e={};if(void 0!==t)for(let s=0;s<t.length;s++){const i=t[s],r=uc.parse(i);e[r.uuid]=r}return e}parseImages(t,e){const s=this,i={};let r;function n(t){if("string"==typeof t){const e=t;return function(t){return s.manager.itemStart(t),r.load(t,function(){s.manager.itemEnd(t)},void 0,function(){s.manager.itemError(t),s.manager.itemEnd(t)})}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(e)?e:s.resourcePath+e)}return t.data?{data:ai(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){const s=new mc(e);r=new Sc(s),r.setCrossOrigin(this.crossOrigin);for(let e=0,s=t.length;e<s;e++){const s=t[e],r=s.url;if(Array.isArray(r)){const t=[];for(let e=0,s=r.length;e<s;e++){const s=n(r[e]);null!==s&&(s instanceof HTMLImageElement?t.push(s):t.push(new Ua(s.data,s.width,s.height)))}i[s.uuid]=new wi(t)}else{const t=n(s.url);i[s.uuid]=new wi(t)}}}return i}async parseImagesAsync(t){const e=this,s={};let i;async function r(t){if("string"==typeof t){const s=t,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(s)?s:e.resourcePath+s;return await i.loadAsync(r)}return t.data?{data:ai(t.type,t.data),width:t.width,height:t.height}:null}if(void 0!==t&&t.length>0){i=new Sc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e<i;e++){const i=t[e],n=i.url;if(Array.isArray(n)){const t=[];for(let e=0,s=n.length;e<s;e++){const s=n[e],i=await r(s);null!==i&&(i instanceof HTMLImageElement?t.push(i):t.push(new Ua(i.data,i.width,i.height)))}s[i.uuid]=new wi(t)}else{const t=await r(i.url);s[i.uuid]=new wi(t)}}}return s}parseTextures(t,e){function s(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}const i={};if(void 0!==t)for(let r=0,n=t.length;r<n;r++){const n=t[r];void 0===n.image&&console.warn('THREE.ObjectLoader: No "image" specified for',n.uuid),void 0===e[n.image]&&console.warn("THREE.ObjectLoader: Undefined image",n.image);const a=e[n.image],o=a.data;let h;Array.isArray(o)?(h=new sa,6===o.length&&(h.needsUpdate=!0)):(h=o&&o.data?new Ua:new Ai,o&&(h.needsUpdate=!0)),h.source=a,h.uuid=n.uuid,void 0!==n.name&&(h.name=n.name),void 0!==n.mapping&&(h.mapping=s(n.mapping,Qc)),void 0!==n.channel&&(h.channel=n.channel),void 0!==n.offset&&h.offset.fromArray(n.offset),void 0!==n.repeat&&h.repeat.fromArray(n.repeat),void 0!==n.center&&h.center.fromArray(n.center),void 0!==n.rotation&&(h.rotation=n.rotation),void 0!==n.wrap&&(h.wrapS=s(n.wrap[0],Kc),h.wrapT=s(n.wrap[1],Kc)),void 0!==n.format&&(h.format=n.format),void 0!==n.internalFormat&&(h.internalFormat=n.internalFormat),void 0!==n.type&&(h.type=n.type),void 0!==n.colorSpace&&(h.colorSpace=n.colorSpace),void 0!==n.minFilter&&(h.minFilter=s(n.minFilter,tu)),void 0!==n.magFilter&&(h.magFilter=s(n.magFilter,tu)),void 0!==n.anisotropy&&(h.anisotropy=n.anisotropy),void 0!==n.flipY&&(h.flipY=n.flipY),void 0!==n.generateMipmaps&&(h.generateMipmaps=n.generateMipmaps),void 0!==n.premultiplyAlpha&&(h.premultiplyAlpha=n.premultiplyAlpha),void 0!==n.unpackAlignment&&(h.unpackAlignment=n.unpackAlignment),void 0!==n.compareFunction&&(h.compareFunction=n.compareFunction),void 0!==n.userData&&(h.userData=n.userData),i[n.uuid]=h}return i}parseObject(t,e,s,i,r){let n,a,o;function h(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function l(t){if(void 0!==t){if(Array.isArray(t)){const e=[];for(let i=0,r=t.length;i<r;i++){const r=t[i];void 0===s[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),e.push(s[r])}return e}return void 0===s[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),s[t]}}function c(t){return void 0===i[t]&&console.warn("THREE.ObjectLoader: Undefined texture",t),i[t]}switch(t.type){case"Scene":n=new la,void 0!==t.background&&(Number.isInteger(t.background)?n.background=new Qr(t.background):n.background=c(t.background)),void 0!==t.environment&&(n.environment=c(t.environment)),void 0!==t.fog&&("Fog"===t.fog.type?n.fog=new ha(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(n.fog=new oa(t.fog.color,t.fog.density)),""!==t.fog.name&&(n.fog.name=t.fog.name)),void 0!==t.backgroundBlurriness&&(n.backgroundBlurriness=t.backgroundBlurriness),void 0!==t.backgroundIntensity&&(n.backgroundIntensity=t.backgroundIntensity),void 0!==t.backgroundRotation&&n.backgroundRotation.fromArray(t.backgroundRotation),void 0!==t.environmentIntensity&&(n.environmentIntensity=t.environmentIntensity),void 0!==t.environmentRotation&&n.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":n=new Kn(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(n.focus=t.focus),void 0!==t.zoom&&(n.zoom=t.zoom),void 0!==t.filmGauge&&(n.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(n.filmOffset=t.filmOffset),void 0!==t.view&&(n.view=Object.assign({},t.view));break;case"OrthographicCamera":n=new jc(t.left,t.right,t.top,t.bottom,t.near,t.far),void 0!==t.zoom&&(n.zoom=t.zoom),void 0!==t.view&&(n.view=Object.assign({},t.view));break;case"AmbientLight":n=new Uc(t.color,t.intensity);break;case"DirectionalLight":n=new Wc(t.color,t.intensity),n.target=t.target||"";break;case"PointLight":n=new Lc(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":n=new Hc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":n=new Pc(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),n.target=t.target||"";break;case"HemisphereLight":n=new Cc(t.color,t.groundColor,t.intensity);break;case"LightProbe":n=(new Jc).fromJSON(t);break;case"SkinnedMesh":a=h(t.geometry),o=l(t.material),n=new Da(a,o),void 0!==t.bindMode&&(n.bindMode=t.bindMode),void 0!==t.bindMatrix&&n.bindMatrix.fromArray(t.bindMatrix),void 0!==t.skeleton&&(n.skeleton=t.skeleton);break;case"Mesh":a=h(t.geometry),o=l(t.material),n=new Dn(a,o);break;case"InstancedMesh":a=h(t.geometry),o=l(t.material);const e=t.count,s=t.instanceMatrix,i=t.instanceColor;n=new eo(a,o,e),n.instanceMatrix=new Xa(new Float32Array(s.array),16),void 0!==i&&(n.instanceColor=new Xa(new Float32Array(i.array),i.itemSize));break;case"BatchedMesh":a=h(t.geometry),o=l(t.material),n=new Eo(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,o),n.geometry=a,n.perObjectFrustumCulled=t.perObjectFrustumCulled,n.sortObjects=t.sortObjects,n._drawRanges=t.drawRanges,n._reservedRanges=t.reservedRanges,n._geometryInfo=t.geometryInfo.map(t=>{let e=null,s=null;return void 0!==t.boundingBox&&(e=(new Ri).fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(s=(new $i).fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:s}}),n._instanceInfo=t.instanceInfo,n._availableInstanceIds=t._availableInstanceIds,n._availableGeometryIds=t._availableGeometryIds,n._nextIndexStart=t.nextIndexStart,n._nextVertexStart=t.nextVertexStart,n._geometryCount=t.geometryCount,n._maxInstanceCount=t.maxInstanceCount,n._maxVertexCount=t.maxVertexCount,n._maxIndexCount=t.maxIndexCount,n._geometryInitialized=t.geometryInitialized,n._matricesTexture=c(t.matricesTexture.uuid),n._indirectTexture=c(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(n._colorsTexture=c(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(n.boundingSphere=(new $i).fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(n.boundingBox=(new Ri).fromJSON(t.boundingBox));break;case"LOD":n=new ka;break;case"Line":n=new Do(h(t.geometry),l(t.material));break;case"LineLoop":n=new Jo(h(t.geometry),l(t.material));break;case"LineSegments":n=new qo(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":n=new Qo(h(t.geometry),l(t.material));break;case"Sprite":n=new za(l(t.material));break;case"Group":n=new ra;break;case"Bone":n=new Wa;break;default:n=new Rr}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.up&&n.up.fromArray(t.up),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(n.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(n.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children){const a=t.children;for(let t=0;t<a.length;t++)n.add(this.parseObject(a[t],e,s,i,r))}if(void 0!==t.animations){const e=t.animations;for(let t=0;t<e.length;t++){const s=e[t];n.animations.push(r[s])}}if("LOD"===t.type){void 0!==t.autoUpdate&&(n.autoUpdate=t.autoUpdate);const e=t.levels;for(let t=0;t<e.length;t++){const s=e[t],i=n.getObjectByProperty("uuid",s.object);void 0!==i&&n.addLevel(i,s.distance,s.hysteresis)}}return n}bindSkeletons(t,e){0!==Object.keys(e).length&&t.traverse(function(t){if(!0===t.isSkinnedMesh&&void 0!==t.skeleton){const s=e[t.skeleton];void 0===s?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",t.skeleton):t.bind(s,t.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const s=e.target,i=t.getObjectByProperty("uuid",s);e.target=void 0!==i?i:new Rr}})}}const Qc={UVMapping:ot,CubeReflectionMapping:ht,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,CubeUVReflectionMapping:306},Kc={RepeatWrapping:pt,ClampToEdgeWrapping:mt,MirroredRepeatWrapping:yt},tu={NearestFilter:gt,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:1005,LinearFilter:wt,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:_t},eu=new WeakMap;class su extends gc{constructor(t){super(t),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,s,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,n=pc.get(`image-bitmap:${t}`);if(void 0!==n)return r.manager.itemStart(t),n.then?void n.then(s=>{if(!0!==eu.has(n))return e&&e(s),r.manager.itemEnd(t),s;i&&i(eu.get(n)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(n),r.manager.itemEnd(t)},0),n);const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(s){return pc.add(`image-bitmap:${t}`,s),e&&e(s),r.manager.itemEnd(t),s}).catch(function(e){i&&i(e),eu.set(o,e),pc.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});pc.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let iu;class ru{static getContext(){return void 0===iu&&(iu=new(window.AudioContext||window.webkitAudioContext)),iu}static setContext(t){iu=t}}class nu extends gc{constructor(t){super(t)}load(t,e,s,i){const r=this,n=new bc(this.manager);function a(e){i?i(e):console.error(e),r.manager.itemError(t)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(t){try{const s=t.slice(0);ru.getContext().decodeAudioData(s,function(t){e(t)}).catch(a)}catch(t){a(t)}},s,i)}}const au=new ar,ou=new ar,hu=new ar;class lu{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Kn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Kn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,hu.copy(t.projectionMatrix);const s=e.eyeSep/2,i=s*e.near/e.focus,r=e.near*Math.tan(Ws*e.fov*.5)/e.zoom;let n,a;ou.elements[12]=-s,au.elements[12]=s,n=-r*e.aspect+i,a=r*e.aspect+i,hu.elements[0]=2*e.near/(a-n),hu.elements[8]=(a+n)/(a-n),this.cameraL.projectionMatrix.copy(hu),n=-r*e.aspect-i,a=r*e.aspect-i,hu.elements[0]=2*e.near/(a-n),hu.elements[8]=(a+n)/(a-n),this.cameraR.projectionMatrix.copy(hu)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(ou),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(au)}}class cu extends Kn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class uu{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}const du=new Ks,pu=new Qs,mu=new Ks,yu=new Ks,gu=new Ks;class fu extends Rr{constructor(){super(),this.type="AudioListener",this.context=ru.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new uu}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(du,pu,mu),yu.set(0,0,-1).applyQuaternion(pu),gu.set(0,1,0).applyQuaternion(pu),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(du.x,t),e.positionY.linearRampToValueAtTime(du.y,t),e.positionZ.linearRampToValueAtTime(du.z,t),e.forwardX.linearRampToValueAtTime(yu.x,t),e.forwardY.linearRampToValueAtTime(yu.y,t),e.forwardZ.linearRampToValueAtTime(yu.z,t),e.upX.linearRampToValueAtTime(gu.x,t),e.upY.linearRampToValueAtTime(gu.y,t),e.upZ.linearRampToValueAtTime(gu.z,t)}else e.setPosition(du.x,du.y,du.z),e.setOrientation(yu.x,yu.y,yu.z,gu.x,gu.y,gu.z)}}class xu extends Rr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(t=0){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(!1!==this._connected){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,!0===this.isPlaying&&void 0!==this.source.detune&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),"buffer"!==t.sourceType?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const bu=new Ks,vu=new Qs,wu=new Ks,Mu=new Ks;class Su extends xu{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,s){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=s,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(bu,vu,wu),Mu.set(0,0,1).applyQuaternion(vu);const e=this.panner;if(e.positionX){const t=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(bu.x,t),e.positionY.linearRampToValueAtTime(bu.y,t),e.positionZ.linearRampToValueAtTime(bu.z,t),e.orientationX.linearRampToValueAtTime(Mu.x,t),e.orientationY.linearRampToValueAtTime(Mu.y,t),e.orientationZ.linearRampToValueAtTime(Mu.z,t)}else e.setPosition(bu.x,bu.y,bu.z),e.setOrientation(Mu.x,Mu.y,Mu.z)}}class _u{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let s=0;s<e.length;s++)t+=e[s];return t/e.length}}class Au{constructor(t,e,s){let i,r,n;switch(this.binding=t,this.valueSize=s,e){case"quaternion":i=this._slerp,r=this._slerpAdditive,n=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*s),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,n=this._setAdditiveIdentityOther,this.buffer=new Array(5*s);break;default:i=this._lerp,r=this._lerpAdditive,n=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*s)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=n,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const s=this.buffer,i=this.valueSize,r=t*i+i;let n=this.cumulativeWeight;if(0===n){for(let t=0;t!==i;++t)s[r+t]=s[t];n=e}else{n+=e;const t=e/n;this._mixBufferRegion(s,r,0,t,i)}this.cumulativeWeight=n}accumulateAdditive(t){const e=this.buffer,s=this.valueSize,i=s*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,s),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,s=this.buffer,i=t*e+e,r=this.cumulativeWeight,n=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(s,i,t,1-r,e)}n>0&&this._mixBufferRegionAdditive(s,i,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(s[t]!==s[t+e]){a.setValue(s,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,s=this.valueSize,i=s*this._origIndex;t.getValue(e,i);for(let t=s,r=i;t!==r;++t)e[t]=e[i+t%s];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let s=t;s<e;s++)this.buffer[s]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let s=0;s<this.valueSize;s++)this.buffer[e+s]=this.buffer[t+s]}_select(t,e,s,i,r){if(i>=.5)for(let i=0;i!==r;++i)t[e+i]=t[s+i]}_slerp(t,e,s,i){Qs.slerpFlat(t,e,t,e,t,s,i)}_slerpAdditive(t,e,s,i,r){const n=this._workIndex*r;Qs.multiplyQuaternionsFlat(t,n,t,e,t,s),Qs.slerpFlat(t,e,t,e,t,n,i)}_lerp(t,e,s,i,r){const n=1-i;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*n+t[s+a]*i}}_lerpAdditive(t,e,s,i,r){for(let n=0;n!==r;++n){const r=e+n;t[r]=t[r]+t[s+n]*i}}}const Tu="\\[\\]\\.:\\/",zu=new RegExp("["+Tu+"]","g"),Cu="[^"+Tu+"]",Iu="[^"+Tu.replace("\\.","")+"]",Bu=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Cu)+/(WCOD+)?/.source.replace("WCOD",Iu)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cu)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cu)+"$"),ku=["material","materials","bones","map"];class Eu{constructor(t,e,s){this.path=e,this.parsedPath=s||Eu.parseTrackName(e),this.node=Eu.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,s){return t&&t.isAnimationObjectGroup?new Eu.Composite(t,e,s):new Eu(t,e,s)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(zu,"")}static parseTrackName(t){const e=Bu.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const s={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=s.nodeName&&s.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const t=s.nodeName.substring(i+1);-1!==ku.indexOf(t)&&(s.nodeName=s.nodeName.substring(0,i),s.objectName=t)}if(null===s.propertyName||0===s.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return s}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const s=t.skeleton.getBoneByName(e);if(void 0!==s)return s}if(t.children){const s=function(t){for(let i=0;i<t.length;i++){const r=t[i];if(r.name===e||r.uuid===e)return r;const n=s(r.children);if(n)return n}return null},i=s(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const s=this.resolvedProperty;for(let i=0,r=s.length;i!==r;++i)t[e++]=s[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const s=this.resolvedProperty;for(let i=0,r=s.length;i!==r;++i)s[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const s=this.resolvedProperty;for(let i=0,r=s.length;i!==r;++i)s[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const s=this.resolvedProperty;for(let i=0,r=s.length;i!==r;++i)s[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,s=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=Eu.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");if(s){let i=e.objectIndex;switch(s){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===i){i=e;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);t=t.material.map;break;default:if(void 0===t[s])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[s]}if(void 0!==i){if(void 0===t[i])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[i]}}const n=t[i];if(void 0===n){const s=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+s+"."+i+" but it wasn't found.",t)}let a=this.Versioning.None;this.targetObject=t,!0===t.isMaterial?a=this.Versioning.NeedsUpdate:!0===t.isObject3D&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=r}else void 0!==n.fromArray&&void 0!==n.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=i;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Eu.Composite=class{constructor(t,e,s){const i=s||Eu.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const s=this._targetGroup.nCachedObjects_,i=this._bindings[s];void 0!==i&&i.getValue(t,e)}setValue(t,e){const s=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=s.length;i!==r;++i)s[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,s=t.length;e!==s;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,s=t.length;e!==s;++e)t[e].unbind()}},Eu.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Eu.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Eu.prototype.GetterByBindingType=[Eu.prototype._getValue_direct,Eu.prototype._getValue_array,Eu.prototype._getValue_arrayElement,Eu.prototype._getValue_toArray],Eu.prototype.SetterByBindingTypeAndVersioning=[[Eu.prototype._setValue_direct,Eu.prototype._setValue_direct_setNeedsUpdate,Eu.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Eu.prototype._setValue_array,Eu.prototype._setValue_array_setNeedsUpdate,Eu.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Eu.prototype._setValue_arrayElement,Eu.prototype._setValue_arrayElement_setNeedsUpdate,Eu.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Eu.prototype._setValue_fromArray,Eu.prototype._setValue_fromArray_setNeedsUpdate,Eu.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ru{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Hs(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,s=arguments.length;e!==s;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,s=this._paths,i=this._parsedPaths,r=this._bindings,n=r.length;let a,o=t.length,h=this.nCachedObjects_;for(let l=0,c=arguments.length;l!==c;++l){const c=arguments[l],u=c.uuid;let d=e[u];if(void 0===d){d=o++,e[u]=d,t.push(c);for(let t=0,e=n;t!==e;++t)r[t].push(new Eu(c,s[t],i[t]))}else if(d<h){a=t[d];const o=--h,l=t[o];e[l.uuid]=d,t[d]=l,e[u]=o,t[o]=c;for(let t=0,e=n;t!==e;++t){const e=r[t],n=e[o];let a=e[d];e[d]=n,void 0===a&&(a=new Eu(c,s[t],i[t])),e[o]=a}}else t[d]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,s=this._bindings,i=s.length;let r=this.nCachedObjects_;for(let n=0,a=arguments.length;n!==a;++n){const a=arguments[n],o=a.uuid,h=e[o];if(void 0!==h&&h>=r){const n=r++,l=t[n];e[l.uuid]=h,t[h]=l,e[o]=n,t[n]=a;for(let t=0,e=i;t!==e;++t){const e=s[t],i=e[n],r=e[h];e[h]=i,e[n]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,s=this._bindings,i=s.length;let r=this.nCachedObjects_,n=t.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,h=e[o];if(void 0!==h)if(delete e[o],h<r){const a=--r,o=t[a],l=--n,c=t[l];e[o.uuid]=h,t[h]=o,e[c.uuid]=a,t[a]=c,t.pop();for(let t=0,e=i;t!==e;++t){const e=s[t],i=e[a],r=e[l];e[h]=i,e[a]=r,e.pop()}}else{const r=--n,a=t[r];r>0&&(e[a.uuid]=h),t[h]=a,t.pop();for(let t=0,e=i;t!==e;++t){const e=s[t];e[h]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const s=this._bindingsIndicesByPath;let i=s[t];const r=this._bindings;if(void 0!==i)return r[i];const n=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,c=new Array(h);i=r.length,s[t]=i,n.push(t),a.push(e),r.push(c);for(let s=l,i=o.length;s!==i;++s){const i=o[s];c[s]=new Eu(i,t,e)}return c}unsubscribe_(t){const e=this._bindingsIndicesByPath,s=e[t];if(void 0!==s){const i=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length-1,o=n[a];e[t[a]]=s,n[s]=o,n.pop(),r[s]=r[a],r.pop(),i[s]=i[a],i.pop()}}}class Pu{constructor(t,e,s=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=s,this.blendMode=i;const r=e.tracks,n=r.length,a=new Array(n),o={endingStart:Pe,endingEnd:Pe};for(let t=0;t!==n;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,s=!1){if(t.fadeOut(e),this.fadeIn(e),!0===s){const s=this._clip.duration,i=t._clip.duration,r=i/s,n=s/i;t.warp(1,r,e),this.warp(n,1,e)}return this}crossFadeTo(t,e,s=!1){return t.crossFadeFrom(this,e,s)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,s){const i=this._mixer,r=i.time,n=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+s,h[0]=t/n,h[1]=e/n,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,s,i){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const i=(t-r)*s;i<0||0===s?e=0:(this._startTime=null,e=s*i)}e*=this._updateTimeScale(t);const n=this._updateTime(e),a=this._updateWeight(t);if(a>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===Fe)for(let s=0,i=t.length;s!==i;++s)t[s].evaluate(n),e[s].accumulateAdditive(a);else for(let s=0,r=t.length;s!==r;++s)t[s].evaluate(n),e[s].accumulate(i,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const s=this._weightInterpolant;if(null!==s){const i=s.evaluate(t)[0];e*=i,t>s.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const s=this._timeScaleInterpolant;if(null!==s){e*=s.evaluate(t)[0],t>s.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,s=this.loop;let i=this.time+t,r=this._loopCount;const n=2202===s;if(0===t)return-1===r||!n||1&~r?i:e-i;if(2200===s){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else{if(!(i<0)){this.time=i;break t}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),i>=e||i<0){const s=Math.floor(i/e);i-=e*s,r+=Math.abs(s);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}}else this.time=i;if(n&&!(1&~r))return e-i}return i}_setEndings(t,e,s){const i=this._interpolantSettings;s?(i.endingStart=Oe,i.endingEnd=Oe):(i.endingStart=t?this.zeroSlopeAtStart?Oe:Pe:Ne,i.endingEnd=e?this.zeroSlopeAtEnd?Oe:Pe:Ne)}_scheduleFading(t,e,s){const i=this._mixer,r=i.time;let n=this._weightInterpolant;null===n&&(n=i._lendControlInterpolant(),this._weightInterpolant=n);const a=n.parameterPositions,o=n.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=s,this}}const Ou=new Float32Array(1);class Nu extends Ls{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const s=t._localRoot||this._root,i=t._clip.tracks,r=i.length,n=t._propertyBindings,a=t._interpolants,o=s.uuid,h=this._bindingsByRootAndName;let l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){const r=i[t],h=r.name;let c=l[h];if(void 0!==c)++c.referenceCount,n[t]=c;else{if(c=n[t],void 0!==c){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,h));continue}const i=e&&e._propertyBindings[t].binding.parsedPath;c=new Au(Eu.create(s,h,i),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,h),n[t]=c}a[t].resultBuffer=c.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,s=t._clip.uuid,i=this._actionsByClip[s];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,s,e)}const e=t._propertyBindings;for(let t=0,s=e.length;t!==s;++t){const s=e[t];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,s=e.length;t!==s;++t){const s=e[t];0===--s.useCount&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(t,e,s){const i=this._actions,r=this._actionsByClip;let n=r[e];if(void 0===n)n={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=n;else{const e=n.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=i.length,i.push(t),n.actionByRoot[s]=t}_removeInactiveAction(t){const e=this._actions,s=e[e.length-1],i=t._cacheIndex;s._cacheIndex=i,e[i]=s,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,n=this._actionsByClip,a=n[r],o=a.knownActions,h=o[o.length-1],l=t._byClipCacheIndex;h._byClipCacheIndex=l,o[l]=h,o.pop(),t._byClipCacheIndex=null;delete a.actionByRoot[(t._localRoot||this._root).uuid],0===o.length&&delete n[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let t=0,s=e.length;t!==s;++t){const s=e[t];0===--s.referenceCount&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,s=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=s,e[s]=r}_takeBackAction(t){const e=this._actions,s=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=s,e[s]=r}_addInactiveBinding(t,e,s){const i=this._bindingsByRootAndName,r=this._bindings;let n=i[e];void 0===n&&(n={},i[e]=n),n[s]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){const e=this._bindings,s=t.binding,i=s.rootNode.uuid,r=s.path,n=this._bindingsByRootAndName,a=n[i],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[r],0===Object.keys(a).length&&delete n[i]}_lendBinding(t){const e=this._bindings,s=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=s,e[s]=r}_takeBackBinding(t){const e=this._bindings,s=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=s,e[s]=r}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let s=t[e];return void 0===s&&(s=new ec(new Float32Array(2),new Float32Array(2),1,Ou),s.__cacheIndex=e,t[e]=s),s}_takeBackControlInterpolant(t){const e=this._controlInterpolants,s=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=s,e[s]=r}clipAction(t,e,s){const i=e||this._root,r=i.uuid;let n="string"==typeof t?uc.findByName(i,t):t;const a=null!==n?n.uuid:t,o=this._actionsByClip[a];let h=null;if(void 0===s&&(s=null!==n?n.blendMode:Ve),void 0!==o){const t=o.actionByRoot[r];if(void 0!==t&&t.blendMode===s)return t;h=o.knownActions[0],null===n&&(n=h._clip)}if(null===n)return null;const l=new Pu(this,n,e,s);return this._bindAction(l,h),this._addInactiveAction(l,a,r),l}existingAction(t,e){const s=e||this._root,i=s.uuid,r="string"==typeof t?uc.findByName(s,t):t,n=r?r.uuid:t,a=this._actionsByClip[n];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,s=this._nActiveActions,i=this.time+=t,r=Math.sign(t),n=this._accuIndex^=1;for(let a=0;a!==s;++a){e[a]._update(i,t,r,n)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(n);return this}setTime(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,s=t.uuid,i=this._actionsByClip,r=i[s];if(void 0!==r){const t=r.knownActions;for(let s=0,i=t.length;s!==i;++s){const i=t[s];this._deactivateAction(i);const r=i._cacheIndex,n=e[e.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,n._cacheIndex=r,e[r]=n,e.pop(),this._removeInactiveBindingsForAction(i)}delete i[s]}}uncacheRoot(t){const e=t.uuid,s=this._actionsByClip;for(const t in s){const i=s[t].actionByRoot[e];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[e];if(void 0!==i)for(const t in i){const e=i[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(t,e){const s=this.existingAction(t,e);null!==s&&(this._deactivateAction(s),this._removeInactiveAction(s))}}class Vu extends zi{constructor(t=1,e=1,s=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=s,this.texture=new ki(null,t,e,s),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}}class Fu{constructor(t){this.value=t}clone(){return new Fu(void 0===this.value.clone?this.value:this.value.clone())}}let Lu=0;class ju extends Ls{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Lu++}),this.name="",this.usage=Ss,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return-1!==e&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let t=0,s=e.length;t<s;t++){const s=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0;t<s.length;t++)this.uniforms.push(s[t].clone())}return this}clone(){return(new this.constructor).copy(this)}}class Du extends ca{constructor(t,e,s=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class Wu{constructor(t,e,s,i,r,n=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=s,this.elementSize=i,this.count=r,this.normalized=n,this.version=0}set needsUpdate(t){!0===t&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const Uu=new ar;class Hu{constructor(t,e,s=0,i=1/0){this.ray=new nr(t,e),this.near=s,this.far=i,this.camera=null,this.layers=new fr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Uu.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Uu),this}intersectObject(t,e=!0,s=[]){return Ju(t,this,s,e),s.sort(qu),s}intersectObjects(t,e=!0,s=[]){for(let i=0,r=t.length;i<r;i++)Ju(t[i],this,s,e);return s.sort(qu),s}}function qu(t,e){return t.distance-e.distance}function Ju(t,e,s,i){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,s)&&(r=!1)}if(!0===r&&!0===i){const i=t.children;for(let t=0,r=i.length;t<r;t++)Ju(i[t],e,s,!0)}}class Xu{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,void 0!==t.hidden&&(this._pageVisibilityHandler=Yu.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){null!==this._pageVisibilityHandler&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return null!==this._pageVisibilityHandler&&!0===this._document.hidden?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(void 0!==t?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Yu(){!1===this._document.hidden&&this.reset()}class Zu{constructor(t=1,e=0,s=0){this.radius=t,this.phi=e,this.theta=s}set(t,e,s){return this.radius=t,this.phi=e,this.theta=s,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=qs(this.phi,t,Math.PI-t),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,s){return this.radius=Math.sqrt(t*t+e*e+s*s),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,s),this.phi=Math.acos(qs(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Gu{constructor(t=1,e=0,s=0){this.radius=t,this.theta=e,this.y=s}set(t,e,s){return this.radius=t,this.theta=e,this.y=s,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,s){return this.radius=Math.sqrt(t*t+s*s),this.theta=Math.atan2(t,s),this.y=e,this}clone(){return(new this.constructor).copy(this)}}class $u{constructor(t,e,s,i){$u.prototype.isMatrix2=!0,this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=s,r[3]=i,this}}const Qu=new $s;class Ku{constructor(t=new $s(1/0,1/0),e=new $s(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Qu.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(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}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}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}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Qu).distanceTo(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}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 td=new Ks,ed=new Ks,sd=new Ks,id=new Ks,rd=new Ks,nd=new Ks,ad=new Ks;class od{constructor(t=new Ks,e=new Ks){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){td.subVectors(t,this.start),ed.subVectors(this.end,this.start);const s=ed.dot(ed);let i=ed.dot(td)/s;return e&&(i=qs(i,0,1)),i}closestPointToPoint(t,e,s){const i=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=nd,s=ad){const i=1e-8*1e-8;let r,n;const a=this.start,o=t.start,h=this.end,l=t.end;sd.subVectors(h,a),id.subVectors(l,o),rd.subVectors(a,o);const c=sd.dot(sd),u=id.dot(id),d=id.dot(rd);if(c<=i&&u<=i)return e.copy(a),s.copy(o),e.sub(s),e.dot(e);if(c<=i)r=0,n=d/u,n=qs(n,0,1);else{const t=sd.dot(rd);if(u<=i)n=0,r=qs(-t/c,0,1);else{const e=sd.dot(id),s=c*u-e*e;r=0!==s?qs((e*d-t*u)/s,0,1):0,n=(e*r+d)/u,n<0?(n=0,r=qs(-t/c,0,1)):n>1&&(n=1,r=qs((e-t)/c,0,1))}}return e.copy(a).add(sd.multiplyScalar(r)),s.copy(o).add(id.multiplyScalar(n)),e.sub(s),e.dot(e)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const hd=new Ks;class ld extends Rr{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const s=new In,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1,s=32;t<s;t++,e++){const r=t/s*Math.PI*2,n=e/s*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(n),Math.sin(n),1)}s.setAttribute("position",new wn(i,3));const r=new Ro({fog:!1,toneMapped:!1});this.cone=new qo(s,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),hd.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(hd),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const cd=new Ks,ud=new ar,dd=new ar;class pd extends qo{constructor(t){const e=md(t),s=new In,i=[],r=[];for(let t=0;t<e.length;t++){const s=e[t];s.parent&&s.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}s.setAttribute("position",new wn(i,3)),s.setAttribute("color",new wn(r,3));super(s,new Ro({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;const n=new Qr(255),a=new Qr(65280);this.setColors(n,a)}updateMatrixWorld(t){const e=this.bones,s=this.geometry,i=s.getAttribute("position");dd.copy(this.root.matrixWorld).invert();for(let t=0,s=0;t<e.length;t++){const r=e[t];r.parent&&r.parent.isBone&&(ud.multiplyMatrices(dd,r.matrixWorld),cd.setFromMatrixPosition(ud),i.setXYZ(s,cd.x,cd.y,cd.z),ud.multiplyMatrices(dd,r.parent.matrixWorld),cd.setFromMatrixPosition(ud),i.setXYZ(s+1,cd.x,cd.y,cd.z),s+=2)}s.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){const s=this.geometry.getAttribute("color");for(let i=0;i<s.count;i+=2)s.setXYZ(i,t.r,t.g,t.b),s.setXYZ(i+1,e.r,e.g,e.b);return s.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function md(t){const e=[];!0===t.isBone&&e.push(t);for(let s=0;s<t.children.length;s++)e.push(...md(t.children[s]));return e}class yd extends Dn{constructor(t,e,s){super(new zl(e,4,2),new sn({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=s,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const gd=new Ks,fd=new Qr,xd=new Qr;class bd extends Rr{constructor(t,e,s){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=s,this.type="HemisphereLightHelper";const i=new Sl(e);i.rotateY(.5*Math.PI),this.material=new sn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),n=new Float32Array(3*r.count);i.setAttribute("color",new dn(n,3)),this.add(new Dn(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");fd.copy(this.light.color),xd.copy(this.light.groundColor);for(let t=0,s=e.count;t<s;t++){const i=t<s/2?fd:xd;e.setXYZ(t,i.r,i.g,i.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(gd.setFromMatrixPosition(this.light.matrixWorld).negate())}}class vd extends qo{constructor(t=10,e=10,s=4473924,i=8947848){s=new Qr(s),i=new Qr(i);const r=e/2,n=t/e,a=t/2,o=[],h=[];for(let t=0,l=0,c=-a;t<=e;t++,c+=n){o.push(-a,0,c,a,0,c),o.push(c,0,-a,c,0,a);const e=t===r?s:i;e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3,e.toArray(h,l),l+=3}const l=new In;l.setAttribute("position",new wn(o,3)),l.setAttribute("color",new wn(h,3));super(l,new Ro({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class wd extends qo{constructor(t=10,e=16,s=8,i=64,r=4473924,n=8947848){r=new Qr(r),n=new Qr(n);const a=[],o=[];if(e>1)for(let s=0;s<e;s++){const i=s/e*(2*Math.PI),h=Math.sin(i)*t,l=Math.cos(i)*t;a.push(0,0,0),a.push(h,0,l);const c=1&s?r:n;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let e=0;e<s;e++){const h=1&e?r:n,l=t-t/s*e;for(let t=0;t<i;t++){let e=t/i*(2*Math.PI),s=Math.sin(e)*l,r=Math.cos(e)*l;a.push(s,0,r),o.push(h.r,h.g,h.b),e=(t+1)/i*(2*Math.PI),s=Math.sin(e)*l,r=Math.cos(e)*l,a.push(s,0,r),o.push(h.r,h.g,h.b)}}const h=new In;h.setAttribute("position",new wn(a,3)),h.setAttribute("color",new wn(o,3));super(h,new Ro({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const Md=new Ks,Sd=new Ks,_d=new Ks;class Ad extends Rr{constructor(t,e,s){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=s,this.type="DirectionalLightHelper",void 0===e&&(e=1);let i=new In;i.setAttribute("position",new wn([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new Ro({fog:!1,toneMapped:!1});this.lightPlane=new Do(i,r),this.add(this.lightPlane),i=new In,i.setAttribute("position",new wn([0,0,0,0,0,1],3)),this.targetLine=new Do(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Md.setFromMatrixPosition(this.light.matrixWorld),Sd.setFromMatrixPosition(this.light.target.matrixWorld),_d.subVectors(Sd,Md),this.lightPlane.lookAt(Sd),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Sd),this.targetLine.scale.z=_d.length()}}const Td=new Ks,zd=new Zn;class Cd extends qo{constructor(t){const e=new In,s=new Ro({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],n={};function a(t,e){o(t),o(e)}function o(t){i.push(0,0,0),r.push(0,0,0),void 0===n[t]&&(n[t]=[]),n[t].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),e.setAttribute("position",new wn(i,3)),e.setAttribute("color",new wn(r,3)),super(e,s),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();const h=new Qr(16755200),l=new Qr(16711680),c=new Qr(43775),u=new Qr(16777215),d=new Qr(3355443);this.setColors(h,l,c,u,d)}setColors(t,e,s,i,r){const n=this.geometry.getAttribute("color");return n.setXYZ(0,t.r,t.g,t.b),n.setXYZ(1,t.r,t.g,t.b),n.setXYZ(2,t.r,t.g,t.b),n.setXYZ(3,t.r,t.g,t.b),n.setXYZ(4,t.r,t.g,t.b),n.setXYZ(5,t.r,t.g,t.b),n.setXYZ(6,t.r,t.g,t.b),n.setXYZ(7,t.r,t.g,t.b),n.setXYZ(8,t.r,t.g,t.b),n.setXYZ(9,t.r,t.g,t.b),n.setXYZ(10,t.r,t.g,t.b),n.setXYZ(11,t.r,t.g,t.b),n.setXYZ(12,t.r,t.g,t.b),n.setXYZ(13,t.r,t.g,t.b),n.setXYZ(14,t.r,t.g,t.b),n.setXYZ(15,t.r,t.g,t.b),n.setXYZ(16,t.r,t.g,t.b),n.setXYZ(17,t.r,t.g,t.b),n.setXYZ(18,t.r,t.g,t.b),n.setXYZ(19,t.r,t.g,t.b),n.setXYZ(20,t.r,t.g,t.b),n.setXYZ(21,t.r,t.g,t.b),n.setXYZ(22,t.r,t.g,t.b),n.setXYZ(23,t.r,t.g,t.b),n.setXYZ(24,e.r,e.g,e.b),n.setXYZ(25,e.r,e.g,e.b),n.setXYZ(26,e.r,e.g,e.b),n.setXYZ(27,e.r,e.g,e.b),n.setXYZ(28,e.r,e.g,e.b),n.setXYZ(29,e.r,e.g,e.b),n.setXYZ(30,e.r,e.g,e.b),n.setXYZ(31,e.r,e.g,e.b),n.setXYZ(32,s.r,s.g,s.b),n.setXYZ(33,s.r,s.g,s.b),n.setXYZ(34,s.r,s.g,s.b),n.setXYZ(35,s.r,s.g,s.b),n.setXYZ(36,s.r,s.g,s.b),n.setXYZ(37,s.r,s.g,s.b),n.setXYZ(38,i.r,i.g,i.b),n.setXYZ(39,i.r,i.g,i.b),n.setXYZ(40,r.r,r.g,r.b),n.setXYZ(41,r.r,r.g,r.b),n.setXYZ(42,r.r,r.g,r.b),n.setXYZ(43,r.r,r.g,r.b),n.setXYZ(44,r.r,r.g,r.b),n.setXYZ(45,r.r,r.g,r.b),n.setXYZ(46,r.r,r.g,r.b),n.setXYZ(47,r.r,r.g,r.b),n.setXYZ(48,r.r,r.g,r.b),n.setXYZ(49,r.r,r.g,r.b),n.needsUpdate=!0,this}update(){const t=this.geometry,e=this.pointMap;let s,i;if(zd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),!0===this.camera.reversedDepth)s=1,i=0;else if(this.camera.coordinateSystem===Ps)s=-1,i=1;else{if(this.camera.coordinateSystem!==Os)throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);s=0,i=1}Id("c",e,t,zd,0,0,s),Id("t",e,t,zd,0,0,i),Id("n1",e,t,zd,-1,-1,s),Id("n2",e,t,zd,1,-1,s),Id("n3",e,t,zd,-1,1,s),Id("n4",e,t,zd,1,1,s),Id("f1",e,t,zd,-1,-1,i),Id("f2",e,t,zd,1,-1,i),Id("f3",e,t,zd,-1,1,i),Id("f4",e,t,zd,1,1,i),Id("u1",e,t,zd,.7,1.1,s),Id("u2",e,t,zd,-.7,1.1,s),Id("u3",e,t,zd,0,2,s),Id("cf1",e,t,zd,-1,0,i),Id("cf2",e,t,zd,1,0,i),Id("cf3",e,t,zd,0,-1,i),Id("cf4",e,t,zd,0,1,i),Id("cn1",e,t,zd,-1,0,s),Id("cn2",e,t,zd,1,0,s),Id("cn3",e,t,zd,0,-1,s),Id("cn4",e,t,zd,0,1,s),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Id(t,e,s,i,r,n,a){Td.set(r,n,a).unproject(i);const o=e[t];if(void 0!==o){const t=s.getAttribute("position");for(let e=0,s=o.length;e<s;e++)t.setXYZ(o[e],Td.x,Td.y,Td.z)}}const Bd=new Ri;class kd extends qo{constructor(t,e=16776960){const s=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new In;r.setIndex(new dn(s,1)),r.setAttribute("position",new dn(i,3)),super(r,new Ro({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(void 0!==this.object&&Bd.setFromObject(this.object),Bd.isEmpty())return;const t=Bd.min,e=Bd.max,s=this.geometry.attributes.position,i=s.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,s.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ed extends qo{constructor(t,e=16776960){const s=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new In;i.setIndex(new dn(s,1)),i.setAttribute("position",new wn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Ro({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rd extends Do{constructor(t,e=1,s=16776960){const i=s,r=new In;r.setAttribute("position",new wn([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new Ro({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const n=new In;n.setAttribute("position",new wn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),n.computeBoundingSphere(),this.add(new Dn(n,new sn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Pd=new Ks;let Od,Nd;class Vd extends Rr{constructor(t=new Ks(0,0,1),e=new Ks(0,0,0),s=1,i=16776960,r=.2*s,n=.2*r){super(),this.type="ArrowHelper",void 0===Od&&(Od=new In,Od.setAttribute("position",new wn([0,0,0,0,1,0],3)),Nd=new dh(.5,1,5,1),Nd.translate(0,-.5,0)),this.position.copy(e),this.line=new Do(Od,new Ro({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Dn(Nd,new sn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(s,r,n)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Pd.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Pd,e)}}setLength(t,e=.2*t,s=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(s,e,s),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Fd extends qo{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],s=new In;s.setAttribute("position",new wn(e,3)),s.setAttribute("color",new wn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(s,new Ro({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,s){const i=new Qr,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(s),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ld{constructor(){this.type="ShapePath",this.color=new Qr,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Dh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,s,i){return this.currentPath.quadraticCurveTo(t,e,s,i),this}bezierCurveTo(t,e,s,i,r,n){return this.currentPath.bezierCurveTo(t,e,s,i,r,n),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const s=e.length;let i=!1;for(let r=s-1,n=0;n<s;r=n++){let s=e[r],a=e[n],o=a.x-s.x,h=a.y-s.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(s=e[n],o=-o,a=e[r],h=-h),t.y<s.y||t.y>a.y)continue;if(t.y===s.y){if(t.x===s.x)return!0}else{const e=h*(t.x-s.x)-o*(t.y-s.y);if(0===e)return!0;if(e<0)continue;i=!i}}else{if(t.y!==s.y)continue;if(a.x<=t.x&&t.x<=s.x||s.x<=t.x&&t.x<=a.x)return!0}}return i}const s=gl.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,n,a;const o=[];if(1===i.length)return n=i[0],a=new Wh,a.curves=n.curves,o.push(a),o;let h=!s(i[0].getPoints());h=t?!h:h;const l=[],c=[];let u,d,p=[],m=0;c[m]=void 0,p[m]=[];for(let e=0,a=i.length;e<a;e++)n=i[e],u=n.getPoints(),r=s(u),r=t?!r:r,r?(!h&&c[m]&&m++,c[m]={s:new Wh,p:u},c[m].s.curves=n.curves,h&&m++,p[m]=[]):p[m].push({h:n,p:u[0]});if(!c[0])return function(t){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s],r=new Wh;r.curves=i.curves,e.push(r)}return e}(i);if(c.length>1){let t=!1,s=0;for(let t=0,e=c.length;t<e;t++)l[t]=[];for(let i=0,r=c.length;i<r;i++){const r=p[i];for(let n=0;n<r.length;n++){const a=r[n];let o=!0;for(let r=0;r<c.length;r++)e(a.p,c[r].p)&&(i!==r&&s++,o?(o=!1,l[r].push(a)):t=!0);o&&l[i].push(a)}}s>0&&!1===t&&(p=l)}for(let t=0,e=c.length;t<e;t++){a=c[t].s,o.push(a),d=p[t];for(let t=0,e=d.length;t<e;t++)a.holes.push(d[t].h)}return o}}class jd extends Ls{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){void 0!==t?(null!==this.domElement&&this.disconnect(),this.domElement=t):console.warn("THREE.Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}}function Dd(t,e,s,i){const r=function(t){switch(t){case Tt:case zt:return{byteLength:1,components:1};case It:case Ct:case Rt:return{byteLength:2,components:1};case Pt:case Ot:return{byteLength:2,components:4};case kt:case Bt:case Et:return{byteLength:4,components:1};case Vt:case Ft:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}(i);switch(s){case 1021:return t*e;case Ht:case qt:return t*e/r.components*r.byteLength;case 1030:case 1031:return t*e*2/r.components*r.byteLength;case 1022:return t*e*3/r.components*r.byteLength;case Dt:case 1033:return t*e*4/r.components*r.byteLength;case 33776:case 33777:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 33778:case 33779:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 35841:case 35843:return Math.max(t,16)*Math.max(e,8)/4;case 35840:case 35842:return Math.max(t,8)*Math.max(e,8)/2;case 36196:case 37492:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case 37496:case 37808:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case 37809:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case 37810:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case 37811:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case 37812:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case 37813:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case 37814:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case 37815:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case 37816:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case 37817:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case 37818:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case 37819:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case 37820:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case 37821:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case 36492:case 36494:case 36495:return Math.ceil(t/4)*Math.ceil(e/4)*16;case 36283:case 36284:return Math.ceil(t/4)*Math.ceil(e/4)*8;case 36285:case 36286:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${s} format.`)}class Wd{static contain(t,e){return function(t,e){const s=t.image&&t.image.width?t.image.width/t.image.height:1;return s>e?(t.repeat.x=1,t.repeat.y=s/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/s,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}(t,e)}static cover(t,e){return function(t,e){const s=t.image&&t.image.width?t.image.width/t.image.height:1;return s>e?(t.repeat.x=e/s,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=s/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}(t,e)}static fill(t){return function(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}(t)}static getByteLength(t,e,s,i){return Dd(t,e,s,i)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
"ACESFilmicToneMapping": et,
|
|
216
|
+
"AddEquation": v,
|
|
217
|
+
"AddOperation": G,
|
|
218
|
+
"AdditiveAnimationBlendMode": Fe,
|
|
219
|
+
"AdditiveBlending": g,
|
|
220
|
+
"AgXToneMapping": it,
|
|
221
|
+
"AlphaFormat": Lt,
|
|
222
|
+
"AlwaysCompare": Ms,
|
|
223
|
+
"AlwaysDepth": D,
|
|
224
|
+
"AlwaysStencilFunc": ms,
|
|
225
|
+
"AmbientLight": Uc,
|
|
226
|
+
"AnimationAction": Pu,
|
|
227
|
+
"AnimationClip": uc,
|
|
228
|
+
"AnimationLoader": vc,
|
|
229
|
+
"AnimationMixer": Nu,
|
|
230
|
+
"AnimationObjectGroup": Ru,
|
|
231
|
+
"AnimationUtils": Ql,
|
|
232
|
+
"ArcCurve": Mh,
|
|
233
|
+
"ArrayCamera": cu,
|
|
234
|
+
"ArrowHelper": Vd,
|
|
235
|
+
"AttachedBindMode": nt,
|
|
236
|
+
"Audio": xu,
|
|
237
|
+
"AudioAnalyser": _u,
|
|
238
|
+
"AudioContext": ru,
|
|
239
|
+
"AudioListener": fu,
|
|
240
|
+
"AudioLoader": nu,
|
|
241
|
+
"AxesHelper": Fd,
|
|
242
|
+
"BackSide": d,
|
|
243
|
+
"BasicDepthPacking": We,
|
|
244
|
+
"BasicShadowMap": o,
|
|
245
|
+
"BatchedMesh": Eo,
|
|
246
|
+
"Bone": Wa,
|
|
247
|
+
"BooleanKeyframeTrack": rc,
|
|
248
|
+
"Box2": Ku,
|
|
249
|
+
"Box3": Ri,
|
|
250
|
+
"Box3Helper": Ed,
|
|
251
|
+
"BoxGeometry": Un,
|
|
252
|
+
"BoxHelper": kd,
|
|
253
|
+
"BufferAttribute": dn,
|
|
254
|
+
"BufferGeometry": In,
|
|
255
|
+
"BufferGeometryLoader": Gc,
|
|
256
|
+
"ByteType": zt,
|
|
257
|
+
"Cache": pc,
|
|
258
|
+
"Camera": Zn,
|
|
259
|
+
"CameraHelper": Cd,
|
|
260
|
+
"CanvasTexture": ah,
|
|
261
|
+
"CapsuleGeometry": lh,
|
|
262
|
+
"CatmullRomCurve3": Ch,
|
|
263
|
+
"CineonToneMapping": tt,
|
|
264
|
+
"CircleGeometry": ch,
|
|
265
|
+
"ClampToEdgeWrapping": mt,
|
|
266
|
+
"Clock": uu,
|
|
267
|
+
"Color": Qr,
|
|
268
|
+
"ColorKeyframeTrack": nc,
|
|
269
|
+
"ColorManagement": yi,
|
|
270
|
+
"CompressedArrayTexture": rh,
|
|
271
|
+
"CompressedCubeTexture": nh,
|
|
272
|
+
"CompressedTexture": ih,
|
|
273
|
+
"CompressedTextureLoader": wc,
|
|
274
|
+
"ConeGeometry": dh,
|
|
275
|
+
"ConstantAlphaFactor": F,
|
|
276
|
+
"ConstantColorFactor": N,
|
|
277
|
+
"Controls": jd,
|
|
278
|
+
"CubeCamera": ea,
|
|
279
|
+
"CubeReflectionMapping": ht,
|
|
280
|
+
"CubeRefractionMapping": lt,
|
|
281
|
+
"CubeTexture": sa,
|
|
282
|
+
"CubeTextureLoader": _c,
|
|
283
|
+
"CubeUVReflectionMapping": dt,
|
|
284
|
+
"CubicBezierCurve": Eh,
|
|
285
|
+
"CubicBezierCurve3": Rh,
|
|
286
|
+
"CubicInterpolant": tc,
|
|
287
|
+
"CullFaceBack": r,
|
|
288
|
+
"CullFaceFront": n,
|
|
289
|
+
"CullFaceFrontBack": a,
|
|
290
|
+
"CullFaceNone": i,
|
|
291
|
+
"Curve": vh,
|
|
292
|
+
"CurvePath": jh,
|
|
293
|
+
"CustomBlending": b,
|
|
294
|
+
"CustomToneMapping": st,
|
|
295
|
+
"CylinderGeometry": uh,
|
|
296
|
+
"Cylindrical": Gu,
|
|
297
|
+
"Data3DTexture": ki,
|
|
298
|
+
"DataArrayTexture": Ii,
|
|
299
|
+
"DataTexture": Ua,
|
|
300
|
+
"DataTextureLoader": Ac,
|
|
301
|
+
"DataUtils": hn,
|
|
302
|
+
"DecrementStencilOp": is,
|
|
303
|
+
"DecrementWrapStencilOp": ns,
|
|
304
|
+
"DefaultLoadingManager": yc,
|
|
305
|
+
"DepthFormat": Wt,
|
|
306
|
+
"DepthStencilFormat": Ut,
|
|
307
|
+
"DepthTexture": oh,
|
|
308
|
+
"DetachedBindMode": at,
|
|
309
|
+
"DirectionalLight": Wc,
|
|
310
|
+
"DirectionalLightHelper": Ad,
|
|
311
|
+
"DiscreteInterpolant": sc,
|
|
312
|
+
"DodecahedronGeometry": mh,
|
|
313
|
+
"DoubleSide": p,
|
|
314
|
+
"DstAlphaFactor": k,
|
|
315
|
+
"DstColorFactor": R,
|
|
316
|
+
"DynamicCopyUsage": Bs,
|
|
317
|
+
"DynamicDrawUsage": _s,
|
|
318
|
+
"DynamicReadUsage": zs,
|
|
319
|
+
"EdgesGeometry": bh,
|
|
320
|
+
"EllipseCurve": wh,
|
|
321
|
+
"EqualCompare": fs,
|
|
322
|
+
"EqualDepth": H,
|
|
323
|
+
"EqualStencilFunc": ls,
|
|
324
|
+
"EquirectangularReflectionMapping": ct,
|
|
325
|
+
"EquirectangularRefractionMapping": ut,
|
|
326
|
+
"Euler": gr,
|
|
327
|
+
"EventDispatcher": Ls,
|
|
328
|
+
"ExternalTexture": hh,
|
|
329
|
+
"ExtrudeGeometry": bl,
|
|
330
|
+
"FileLoader": bc,
|
|
331
|
+
"Float16BufferAttribute": vn,
|
|
332
|
+
"Float32BufferAttribute": wn,
|
|
333
|
+
"FloatType": Et,
|
|
334
|
+
"Fog": ha,
|
|
335
|
+
"FogExp2": oa,
|
|
336
|
+
"FramebufferTexture": sh,
|
|
337
|
+
"FrontSide": u,
|
|
338
|
+
"Frustum": lo,
|
|
339
|
+
"FrustumArray": po,
|
|
340
|
+
"GLBufferAttribute": Wu,
|
|
341
|
+
"GLSL1": Es,
|
|
342
|
+
"GLSL3": Rs,
|
|
343
|
+
"GreaterCompare": bs,
|
|
344
|
+
"GreaterDepth": J,
|
|
345
|
+
"GreaterEqualCompare": ws,
|
|
346
|
+
"GreaterEqualDepth": q,
|
|
347
|
+
"GreaterEqualStencilFunc": ps,
|
|
348
|
+
"GreaterStencilFunc": us,
|
|
349
|
+
"GridHelper": vd,
|
|
350
|
+
"Group": ra,
|
|
351
|
+
"HalfFloatType": Rt,
|
|
352
|
+
"HemisphereLight": Cc,
|
|
353
|
+
"HemisphereLightHelper": bd,
|
|
354
|
+
"IcosahedronGeometry": wl,
|
|
355
|
+
"ImageBitmapLoader": su,
|
|
356
|
+
"ImageLoader": Sc,
|
|
357
|
+
"ImageUtils": bi,
|
|
358
|
+
"IncrementStencilOp": ss,
|
|
359
|
+
"IncrementWrapStencilOp": rs,
|
|
360
|
+
"InstancedBufferAttribute": Xa,
|
|
361
|
+
"InstancedBufferGeometry": Zc,
|
|
362
|
+
"InstancedInterleavedBuffer": Du,
|
|
363
|
+
"InstancedMesh": eo,
|
|
364
|
+
"Int16BufferAttribute": gn,
|
|
365
|
+
"Int32BufferAttribute": xn,
|
|
366
|
+
"Int8BufferAttribute": pn,
|
|
367
|
+
"IntType": Bt,
|
|
368
|
+
"InterleavedBuffer": ca,
|
|
369
|
+
"InterleavedBufferAttribute": da,
|
|
370
|
+
"Interpolant": Kl,
|
|
371
|
+
"InterpolateDiscrete": ke,
|
|
372
|
+
"InterpolateLinear": Ee,
|
|
373
|
+
"InterpolateSmooth": Re,
|
|
374
|
+
"InterpolationSamplingMode": Fs,
|
|
375
|
+
"InterpolationSamplingType": Vs,
|
|
376
|
+
"InvertStencilOp": as,
|
|
377
|
+
"KeepStencilOp": ts,
|
|
378
|
+
"KeyframeTrack": ic,
|
|
379
|
+
"LOD": ka,
|
|
380
|
+
"LatheGeometry": Ml,
|
|
381
|
+
"Layers": fr,
|
|
382
|
+
"LessCompare": gs,
|
|
383
|
+
"LessDepth": W,
|
|
384
|
+
"LessEqualCompare": xs,
|
|
385
|
+
"LessEqualDepth": U,
|
|
386
|
+
"LessEqualStencilFunc": cs,
|
|
387
|
+
"LessStencilFunc": hs,
|
|
388
|
+
"Light": zc,
|
|
389
|
+
"LightProbe": Jc,
|
|
390
|
+
"Line": Do,
|
|
391
|
+
"Line3": od,
|
|
392
|
+
"LineBasicMaterial": Ro,
|
|
393
|
+
"LineCurve": Ph,
|
|
394
|
+
"LineCurve3": Oh,
|
|
395
|
+
"LineDashedMaterial": Jl,
|
|
396
|
+
"LineLoop": Jo,
|
|
397
|
+
"LineSegments": qo,
|
|
398
|
+
"LinearFilter": wt,
|
|
399
|
+
"LinearInterpolant": ec,
|
|
400
|
+
"LinearMipMapLinearFilter": At,
|
|
401
|
+
"LinearMipMapNearestFilter": St,
|
|
402
|
+
"LinearMipmapLinearFilter": _t,
|
|
403
|
+
"LinearMipmapNearestFilter": Mt,
|
|
404
|
+
"LinearSRGBColorSpace": Ge,
|
|
405
|
+
"LinearToneMapping": Q,
|
|
406
|
+
"LinearTransfer": $e,
|
|
407
|
+
"Loader": gc,
|
|
408
|
+
"LoaderUtils": Yc,
|
|
409
|
+
"LoadingManager": mc,
|
|
410
|
+
"LoopOnce": Ce,
|
|
411
|
+
"LoopPingPong": Be,
|
|
412
|
+
"LoopRepeat": Ie,
|
|
413
|
+
"MOUSE": e,
|
|
414
|
+
"Material": en,
|
|
415
|
+
"MaterialLoader": Xc,
|
|
416
|
+
"MathUtils": Gs,
|
|
417
|
+
"Matrix2": $u,
|
|
418
|
+
"Matrix3": si,
|
|
419
|
+
"Matrix4": ar,
|
|
420
|
+
"MaxEquation": _,
|
|
421
|
+
"Mesh": Dn,
|
|
422
|
+
"MeshBasicMaterial": sn,
|
|
423
|
+
"MeshDepthMaterial": Ul,
|
|
424
|
+
"MeshDistanceMaterial": Hl,
|
|
425
|
+
"MeshLambertMaterial": Wl,
|
|
426
|
+
"MeshMatcapMaterial": ql,
|
|
427
|
+
"MeshNormalMaterial": Dl,
|
|
428
|
+
"MeshPhongMaterial": Ll,
|
|
429
|
+
"MeshPhysicalMaterial": Fl,
|
|
430
|
+
"MeshStandardMaterial": Vl,
|
|
431
|
+
"MeshToonMaterial": jl,
|
|
432
|
+
"MinEquation": S,
|
|
433
|
+
"MirroredRepeatWrapping": yt,
|
|
434
|
+
"MixOperation": Z,
|
|
435
|
+
"MultiplyBlending": x,
|
|
436
|
+
"MultiplyOperation": Y,
|
|
437
|
+
"NearestFilter": gt,
|
|
438
|
+
"NearestMipMapLinearFilter": vt,
|
|
439
|
+
"NearestMipMapNearestFilter": xt,
|
|
440
|
+
"NearestMipmapLinearFilter": bt,
|
|
441
|
+
"NearestMipmapNearestFilter": ft,
|
|
442
|
+
"NeutralToneMapping": rt,
|
|
443
|
+
"NeverCompare": ys,
|
|
444
|
+
"NeverDepth": j,
|
|
445
|
+
"NeverStencilFunc": os,
|
|
446
|
+
"NoBlending": m,
|
|
447
|
+
"NoColorSpace": Ye,
|
|
448
|
+
"NoToneMapping": $,
|
|
449
|
+
"NormalAnimationBlendMode": Ve,
|
|
450
|
+
"NormalBlending": y,
|
|
451
|
+
"NotEqualCompare": vs,
|
|
452
|
+
"NotEqualDepth": X,
|
|
453
|
+
"NotEqualStencilFunc": ds,
|
|
454
|
+
"NumberKeyframeTrack": ac,
|
|
455
|
+
"Object3D": Rr,
|
|
456
|
+
"ObjectLoader": $c,
|
|
457
|
+
"ObjectSpaceNormalMap": Xe,
|
|
458
|
+
"OctahedronGeometry": Sl,
|
|
459
|
+
"OneFactor": T,
|
|
460
|
+
"OneMinusConstantAlphaFactor": L,
|
|
461
|
+
"OneMinusConstantColorFactor": V,
|
|
462
|
+
"OneMinusDstAlphaFactor": E,
|
|
463
|
+
"OneMinusDstColorFactor": P,
|
|
464
|
+
"OneMinusSrcAlphaFactor": B,
|
|
465
|
+
"OneMinusSrcColorFactor": C,
|
|
466
|
+
"OrthographicCamera": jc,
|
|
467
|
+
"PCFShadowMap": h,
|
|
468
|
+
"PCFSoftShadowMap": l,
|
|
469
|
+
"Path": Dh,
|
|
470
|
+
"PerspectiveCamera": Kn,
|
|
471
|
+
"Plane": no,
|
|
472
|
+
"PlaneGeometry": _l,
|
|
473
|
+
"PlaneHelper": Rd,
|
|
474
|
+
"PointLight": Lc,
|
|
475
|
+
"PointLightHelper": yd,
|
|
476
|
+
"Points": Qo,
|
|
477
|
+
"PointsMaterial": Xo,
|
|
478
|
+
"PolarGridHelper": wd,
|
|
479
|
+
"PolyhedronGeometry": ph,
|
|
480
|
+
"PositionalAudio": Su,
|
|
481
|
+
"PropertyBinding": Eu,
|
|
482
|
+
"PropertyMixer": Au,
|
|
483
|
+
"QuadraticBezierCurve": Nh,
|
|
484
|
+
"QuadraticBezierCurve3": Vh,
|
|
485
|
+
"Quaternion": Qs,
|
|
486
|
+
"QuaternionKeyframeTrack": hc,
|
|
487
|
+
"QuaternionLinearInterpolant": oc,
|
|
488
|
+
"RAD2DEG": Us,
|
|
489
|
+
"RED_GREEN_RGTC2_Format": Te,
|
|
490
|
+
"RED_RGTC1_Format": _e,
|
|
491
|
+
"REVISION": t,
|
|
492
|
+
"RGBADepthPacking": Ue,
|
|
493
|
+
"RGBAFormat": Dt,
|
|
494
|
+
"RGBAIntegerFormat": Zt,
|
|
495
|
+
"RGBA_ASTC_10x10_Format": xe,
|
|
496
|
+
"RGBA_ASTC_10x5_Format": ye,
|
|
497
|
+
"RGBA_ASTC_10x6_Format": ge,
|
|
498
|
+
"RGBA_ASTC_10x8_Format": fe,
|
|
499
|
+
"RGBA_ASTC_12x10_Format": be,
|
|
500
|
+
"RGBA_ASTC_12x12_Format": ve,
|
|
501
|
+
"RGBA_ASTC_4x4_Format": oe,
|
|
502
|
+
"RGBA_ASTC_5x4_Format": he,
|
|
503
|
+
"RGBA_ASTC_5x5_Format": le,
|
|
504
|
+
"RGBA_ASTC_6x5_Format": ce,
|
|
505
|
+
"RGBA_ASTC_6x6_Format": ue,
|
|
506
|
+
"RGBA_ASTC_8x5_Format": de,
|
|
507
|
+
"RGBA_ASTC_8x6_Format": pe,
|
|
508
|
+
"RGBA_ASTC_8x8_Format": me,
|
|
509
|
+
"RGBA_BPTC_Format": we,
|
|
510
|
+
"RGBA_ETC2_EAC_Format": ae,
|
|
511
|
+
"RGBA_PVRTC_2BPPV1_Format": ie,
|
|
512
|
+
"RGBA_PVRTC_4BPPV1_Format": se,
|
|
513
|
+
"RGBA_S3TC_DXT1_Format": $t,
|
|
514
|
+
"RGBA_S3TC_DXT3_Format": Qt,
|
|
515
|
+
"RGBA_S3TC_DXT5_Format": Kt,
|
|
516
|
+
"RGBDepthPacking": He,
|
|
517
|
+
"RGBFormat": jt,
|
|
518
|
+
"RGBIntegerFormat": Yt,
|
|
519
|
+
"RGB_BPTC_SIGNED_Format": Me,
|
|
520
|
+
"RGB_BPTC_UNSIGNED_Format": Se,
|
|
521
|
+
"RGB_ETC1_Format": re,
|
|
522
|
+
"RGB_ETC2_Format": ne,
|
|
523
|
+
"RGB_PVRTC_2BPPV1_Format": ee,
|
|
524
|
+
"RGB_PVRTC_4BPPV1_Format": te,
|
|
525
|
+
"RGB_S3TC_DXT1_Format": Gt,
|
|
526
|
+
"RGDepthPacking": qe,
|
|
527
|
+
"RGFormat": Jt,
|
|
528
|
+
"RGIntegerFormat": Xt,
|
|
529
|
+
"RawShaderMaterial": Nl,
|
|
530
|
+
"Ray": nr,
|
|
531
|
+
"Raycaster": Hu,
|
|
532
|
+
"RectAreaLight": Hc,
|
|
533
|
+
"RedFormat": Ht,
|
|
534
|
+
"RedIntegerFormat": qt,
|
|
535
|
+
"ReinhardToneMapping": K,
|
|
536
|
+
"RenderTarget": zi,
|
|
537
|
+
"RenderTarget3D": Vu,
|
|
538
|
+
"RepeatWrapping": pt,
|
|
539
|
+
"ReplaceStencilOp": es,
|
|
540
|
+
"ReverseSubtractEquation": M,
|
|
541
|
+
"RingGeometry": Al,
|
|
542
|
+
"SIGNED_RED_GREEN_RGTC2_Format": ze,
|
|
543
|
+
"SIGNED_RED_RGTC1_Format": Ae,
|
|
544
|
+
"SRGBColorSpace": Ze,
|
|
545
|
+
"SRGBTransfer": Qe,
|
|
546
|
+
"Scene": la,
|
|
547
|
+
"ShaderMaterial": Yn,
|
|
548
|
+
"ShadowMaterial": Ol,
|
|
549
|
+
"Shape": Wh,
|
|
550
|
+
"ShapeGeometry": Tl,
|
|
551
|
+
"ShapePath": Ld,
|
|
552
|
+
"ShapeUtils": gl,
|
|
553
|
+
"ShortType": Ct,
|
|
554
|
+
"Skeleton": Ja,
|
|
555
|
+
"SkeletonHelper": pd,
|
|
556
|
+
"SkinnedMesh": Da,
|
|
557
|
+
"Source": wi,
|
|
558
|
+
"Sphere": $i,
|
|
559
|
+
"SphereGeometry": zl,
|
|
560
|
+
"Spherical": Zu,
|
|
561
|
+
"SphericalHarmonics3": qc,
|
|
562
|
+
"SplineCurve": Fh,
|
|
563
|
+
"SpotLight": Pc,
|
|
564
|
+
"SpotLightHelper": ld,
|
|
565
|
+
"Sprite": za,
|
|
566
|
+
"SpriteMaterial": pa,
|
|
567
|
+
"SrcAlphaFactor": I,
|
|
568
|
+
"SrcAlphaSaturateFactor": O,
|
|
569
|
+
"SrcColorFactor": z,
|
|
570
|
+
"StaticCopyUsage": Is,
|
|
571
|
+
"StaticDrawUsage": Ss,
|
|
572
|
+
"StaticReadUsage": Ts,
|
|
573
|
+
"StereoCamera": lu,
|
|
574
|
+
"StreamCopyUsage": ks,
|
|
575
|
+
"StreamDrawUsage": As,
|
|
576
|
+
"StreamReadUsage": Cs,
|
|
577
|
+
"StringKeyframeTrack": lc,
|
|
578
|
+
"SubtractEquation": w,
|
|
579
|
+
"SubtractiveBlending": f,
|
|
580
|
+
"TOUCH": s,
|
|
581
|
+
"TangentSpaceNormalMap": Je,
|
|
582
|
+
"TetrahedronGeometry": Cl,
|
|
583
|
+
"Texture": Ai,
|
|
584
|
+
"TextureLoader": Tc,
|
|
585
|
+
"TextureUtils": Wd,
|
|
586
|
+
"Timer": Xu,
|
|
587
|
+
"TimestampQuery": Ns,
|
|
588
|
+
"TorusGeometry": Il,
|
|
589
|
+
"TorusKnotGeometry": Bl,
|
|
590
|
+
"Triangle": Xr,
|
|
591
|
+
"TriangleFanDrawMode": De,
|
|
592
|
+
"TriangleStripDrawMode": je,
|
|
593
|
+
"TrianglesDrawMode": Le,
|
|
594
|
+
"TubeGeometry": kl,
|
|
595
|
+
"UVMapping": ot,
|
|
596
|
+
"Uint16BufferAttribute": fn,
|
|
597
|
+
"Uint32BufferAttribute": bn,
|
|
598
|
+
"Uint8BufferAttribute": mn,
|
|
599
|
+
"Uint8ClampedBufferAttribute": yn,
|
|
600
|
+
"Uniform": Fu,
|
|
601
|
+
"UniformsGroup": ju,
|
|
602
|
+
"UniformsUtils": Xn,
|
|
603
|
+
"UnsignedByteType": Tt,
|
|
604
|
+
"UnsignedInt101111Type": Ft,
|
|
605
|
+
"UnsignedInt248Type": Nt,
|
|
606
|
+
"UnsignedInt5999Type": Vt,
|
|
607
|
+
"UnsignedIntType": kt,
|
|
608
|
+
"UnsignedShort4444Type": Pt,
|
|
609
|
+
"UnsignedShort5551Type": Ot,
|
|
610
|
+
"UnsignedShortType": It,
|
|
611
|
+
"VSMShadowMap": c,
|
|
612
|
+
"Vector2": $s,
|
|
613
|
+
"Vector3": Ks,
|
|
614
|
+
"Vector4": Ti,
|
|
615
|
+
"VectorKeyframeTrack": cc,
|
|
616
|
+
"VideoFrameTexture": eh,
|
|
617
|
+
"VideoTexture": th,
|
|
618
|
+
"WebGL3DRenderTarget": Ei,
|
|
619
|
+
"WebGLArrayRenderTarget": Bi,
|
|
620
|
+
"WebGLCoordinateSystem": Ps,
|
|
621
|
+
"WebGLCubeRenderTarget": ia,
|
|
622
|
+
"WebGLRenderTarget": Ci,
|
|
623
|
+
"WebGPUCoordinateSystem": Os,
|
|
624
|
+
"WebXRController": aa,
|
|
625
|
+
"WireframeGeometry": El,
|
|
626
|
+
"WrapAroundEnding": Ne,
|
|
627
|
+
"ZeroCurvatureEnding": Pe,
|
|
628
|
+
"ZeroFactor": A,
|
|
629
|
+
"ZeroSlopeEnding": Oe,
|
|
630
|
+
"ZeroStencilOp": Ke,
|
|
631
|
+
"arrayNeedsUint32": ri,
|
|
632
|
+
"cloneUniforms": Hn,
|
|
633
|
+
"createCanvasElement": hi,
|
|
634
|
+
"createElementNS": oi,
|
|
635
|
+
"getByteLength": Dd,
|
|
636
|
+
"getUnlitUniformColorSpace": Jn,
|
|
637
|
+
"mergeUniforms": qn,
|
|
638
|
+
"probeAsync": ui,
|
|
639
|
+
"warnOnce": ci
|
|
640
|
+
};
|
|
641
|
+
})();
|
|
642
|
+
var __EXTRA = (function(__CORE){
|
|
643
|
+
"use strict";
|
|
644
|
+
const { Matrix3: e, Vector2: t, Color: n, mergeUniforms: r, Vector3: i, CubeUVReflectionMapping: a, Mesh: o, BoxGeometry: s, ShaderMaterial: l, BackSide: c, cloneUniforms: d, Euler: u, Matrix4: f, ColorManagement: p, SRGBTransfer: m, PlaneGeometry: h, FrontSide: _, getUnlitUniformColorSpace: g, IntType: v, HalfFloatType: E, UnsignedByteType: S, FloatType: T, RGBAFormat: M, Plane: x, EquirectangularReflectionMapping: R, EquirectangularRefractionMapping: A, WebGLCubeRenderTarget: b, CubeReflectionMapping: C, CubeRefractionMapping: L, OrthographicCamera: P, PerspectiveCamera: U, NoToneMapping: D, MeshBasicMaterial: w, NoBlending: I, WebGLRenderTarget: y, BufferGeometry: N, BufferAttribute: O, LinearSRGBColorSpace: F, LinearFilter: B, warnOnce: H, Uint32BufferAttribute: G, Uint16BufferAttribute: V, arrayNeedsUint32: z, Vector4: k, DataArrayTexture: W, CubeTexture: X, Data3DTexture: Y, LessEqualCompare: K, DepthTexture: q, Texture: j, GLSL3: Z, PCFShadowMap: $, PCFSoftShadowMap: Q, VSMShadowMap: J, CustomToneMapping: ee, NeutralToneMapping: te, AgXToneMapping: ne, ACESFilmicToneMapping: re, CineonToneMapping: ie, ReinhardToneMapping: ae, LinearToneMapping: oe, LinearTransfer: se, AddOperation: le, MixOperation: ce, MultiplyOperation: de, UniformsUtils: ue, DoubleSide: fe, NormalBlending: pe, TangentSpaceNormalMap: me, ObjectSpaceNormalMap: he, Layers: _e, Frustum: ge, MeshDepthMaterial: ve, RGBADepthPacking: Ee, MeshDistanceMaterial: Se, NearestFilter: Te, LessEqualDepth: Me, ReverseSubtractEquation: xe, SubtractEquation: Re, AddEquation: Ae, OneMinusConstantAlphaFactor: be, ConstantAlphaFactor: Ce, OneMinusConstantColorFactor: Le, ConstantColorFactor: Pe, OneMinusDstAlphaFactor: Ue, OneMinusDstColorFactor: De, OneMinusSrcAlphaFactor: we, OneMinusSrcColorFactor: Ie, DstAlphaFactor: ye, DstColorFactor: Ne, SrcAlphaSaturateFactor: Oe, SrcAlphaFactor: Fe, SrcColorFactor: Be, OneFactor: He, ZeroFactor: Ge, NotEqualDepth: Ve, GreaterDepth: ze, GreaterEqualDepth: ke, EqualDepth: We, LessDepth: Xe, AlwaysDepth: Ye, NeverDepth: Ke, CullFaceNone: qe, CullFaceBack: je, CullFaceFront: Ze, CustomBlending: $e, MultiplyBlending: Qe, SubtractiveBlending: Je, AdditiveBlending: et, MinEquation: tt, MaxEquation: nt, MirroredRepeatWrapping: rt, ClampToEdgeWrapping: it, RepeatWrapping: at, LinearMipmapLinearFilter: ot, LinearMipmapNearestFilter: st, NearestMipmapLinearFilter: lt, NearestMipmapNearestFilter: ct, NotEqualCompare: dt, GreaterCompare: ut, GreaterEqualCompare: ft, EqualCompare: pt, LessCompare: mt, AlwaysCompare: ht, NeverCompare: _t, NoColorSpace: gt, DepthStencilFormat: vt, getByteLength: Et, DepthFormat: St, UnsignedIntType: Tt, UnsignedInt248Type: Mt, UnsignedShortType: xt, createElementNS: Rt, UnsignedShort4444Type: At, UnsignedShort5551Type: bt, UnsignedInt5999Type: Ct, UnsignedInt101111Type: Lt, ByteType: Pt, ShortType: Ut, AlphaFormat: Dt, RGBFormat: wt, RedFormat: It, RedIntegerFormat: yt, RGFormat: Nt, RGIntegerFormat: Ot, RGBAIntegerFormat: Ft, RGB_S3TC_DXT1_Format: Bt, RGBA_S3TC_DXT1_Format: Ht, RGBA_S3TC_DXT3_Format: Gt, RGBA_S3TC_DXT5_Format: Vt, RGB_PVRTC_4BPPV1_Format: zt, RGB_PVRTC_2BPPV1_Format: kt, RGBA_PVRTC_4BPPV1_Format: Wt, RGBA_PVRTC_2BPPV1_Format: Xt, RGB_ETC1_Format: Yt, RGB_ETC2_Format: Kt, RGBA_ETC2_EAC_Format: qt, RGBA_ASTC_4x4_Format: jt, RGBA_ASTC_5x4_Format: Zt, RGBA_ASTC_5x5_Format: $t, RGBA_ASTC_6x5_Format: Qt, RGBA_ASTC_6x6_Format: Jt, RGBA_ASTC_8x5_Format: en, RGBA_ASTC_8x6_Format: tn, RGBA_ASTC_8x8_Format: nn, RGBA_ASTC_10x5_Format: rn, RGBA_ASTC_10x6_Format: an, RGBA_ASTC_10x8_Format: on, RGBA_ASTC_10x10_Format: sn, RGBA_ASTC_12x10_Format: ln, RGBA_ASTC_12x12_Format: cn, RGBA_BPTC_Format: dn, RGB_BPTC_SIGNED_Format: un, RGB_BPTC_UNSIGNED_Format: fn, RED_RGTC1_Format: pn, SIGNED_RED_RGTC1_Format: mn, RED_GREEN_RGTC2_Format: hn, SIGNED_RED_GREEN_RGTC2_Format: _n, ExternalTexture: gn, EventDispatcher: vn, ArrayCamera: En, WebXRController: Sn, RAD2DEG: Tn, createCanvasElement: Mn, SRGBColorSpace: xn, REVISION: Rn, WebGLCoordinateSystem: An, probeAsync: bn } = __CORE;
|
|
645
|
+
/**
|
|
646
|
+
* @license
|
|
647
|
+
* Copyright 2010-2025 Three.js Authors
|
|
648
|
+
* SPDX-License-Identifier: MIT
|
|
649
|
+
*/
|
|
650
|
+
function Cn(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Ln(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))},update:function(n,r){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.version<n.version)&&t.set(n,{buffer:n.buffer,type:n.type,bytesPerElement:n.elementSize,version:n.version}))}const i=t.get(n);if(void 0===i)t.set(n,function(t,n){const r=t.array,i=t.usage,a=r.byteLength,o=e.createBuffer();let s;if(e.bindBuffer(n,o),e.bufferData(n,r,i),t.onUploadCallback(),r instanceof Float32Array)s=e.FLOAT;else if("undefined"!=typeof Float16Array&&r instanceof Float16Array)s=e.HALF_FLOAT;else if(r instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)s=e.SHORT;else if(r instanceof Uint32Array)s=e.UNSIGNED_INT;else if(r instanceof Int32Array)s=e.INT;else if(r instanceof Int8Array)s=e.BYTE;else if(r instanceof Uint8Array)s=e.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);s=e.UNSIGNED_BYTE}return{buffer:o,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:a}}(n,r));else if(i.version<n.version){if(i.size!==n.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");!function(t,n,r){const i=n.array,a=n.updateRanges;if(e.bindBuffer(r,t),0===a.length)e.bufferSubData(r,0,i);else{a.sort((e,t)=>e.start-t.start);let t=0;for(let e=1;e<a.length;e++){const n=a[t],r=a[e];r.start<=n.start+n.count+1?n.count=Math.max(n.count,r.start+r.count-n.start):(++t,a[t]=r)}a.length=t+1;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.bufferSubData(r,n.start*i.BYTES_PER_ELEMENT,i,n.start,n.count)}n.clearUpdateRanges()}n.onUploadCallback()}(i.buffer,n,r),i.version=n.version}}}}const Pn={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn 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 ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#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 ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform 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 {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_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 {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\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 IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\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 ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn 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 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn 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 ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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#else\nvoid 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#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn 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 ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\tfloat depth = unpackRGBAToDepth( texture2D( depths, uv ) );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\treturn step( depth, compare );\n\t\t#else\n\t\t\treturn step( compare, depth );\n\t\t#endif\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow( sampler2D shadow, vec2 uv, float compare ) {\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\tfloat hard_shadow = step( distribution.x, compare );\n\t\t#else\n\t\t\tfloat hard_shadow = step( compare, distribution.x );\n\t\t#endif\n\t\tif ( hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t#else\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\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() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\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 <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\tfloat fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n\t#else\n\t\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n\t#endif\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\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() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform 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 <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\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() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#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 <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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 <alphahash_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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform 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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform 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 <alphahash_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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\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() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#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() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform 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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying 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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_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() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform 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 <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_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() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#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>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#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 <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#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 <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#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() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#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 <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Un={common:{diffuse:{value:new n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new e},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new e}},envmap:{envMap:{value:null},envMapRotation:{value:new e},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new e}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new e}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new e},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new e},normalScale:{value:new t(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new e},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new e}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new e}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new e}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new n(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0},uvTransform:{value:new e}},sprite:{diffuse:{value:new n(16777215)},opacity:{value:1},center:{value:new t(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new e},alphaMap:{value:null},alphaMapTransform:{value:new e},alphaTest:{value:0}}},Dn={basic:{uniforms:r([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.fog]),vertexShader:Pn.meshbasic_vert,fragmentShader:Pn.meshbasic_frag},lambert:{uniforms:r([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,Un.lights,{emissive:{value:new n(0)}}]),vertexShader:Pn.meshlambert_vert,fragmentShader:Pn.meshlambert_frag},phong:{uniforms:r([Un.common,Un.specularmap,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,Un.lights,{emissive:{value:new n(0)},specular:{value:new n(1118481)},shininess:{value:30}}]),vertexShader:Pn.meshphong_vert,fragmentShader:Pn.meshphong_frag},standard:{uniforms:r([Un.common,Un.envmap,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.roughnessmap,Un.metalnessmap,Un.fog,Un.lights,{emissive:{value:new n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag},toon:{uniforms:r([Un.common,Un.aomap,Un.lightmap,Un.emissivemap,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.gradientmap,Un.fog,Un.lights,{emissive:{value:new n(0)}}]),vertexShader:Pn.meshtoon_vert,fragmentShader:Pn.meshtoon_frag},matcap:{uniforms:r([Un.common,Un.bumpmap,Un.normalmap,Un.displacementmap,Un.fog,{matcap:{value:null}}]),vertexShader:Pn.meshmatcap_vert,fragmentShader:Pn.meshmatcap_frag},points:{uniforms:r([Un.points,Un.fog]),vertexShader:Pn.points_vert,fragmentShader:Pn.points_frag},dashed:{uniforms:r([Un.common,Un.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pn.linedashed_vert,fragmentShader:Pn.linedashed_frag},depth:{uniforms:r([Un.common,Un.displacementmap]),vertexShader:Pn.depth_vert,fragmentShader:Pn.depth_frag},normal:{uniforms:r([Un.common,Un.bumpmap,Un.normalmap,Un.displacementmap,{opacity:{value:1}}]),vertexShader:Pn.meshnormal_vert,fragmentShader:Pn.meshnormal_frag},sprite:{uniforms:r([Un.sprite,Un.fog]),vertexShader:Pn.sprite_vert,fragmentShader:Pn.sprite_frag},background:{uniforms:{uvTransform:{value:new e},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Pn.background_vert,fragmentShader:Pn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new e}},vertexShader:Pn.backgroundCube_vert,fragmentShader:Pn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Pn.cube_vert,fragmentShader:Pn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pn.equirect_vert,fragmentShader:Pn.equirect_frag},distanceRGBA:{uniforms:r([Un.common,Un.displacementmap,{referencePosition:{value:new i},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pn.distanceRGBA_vert,fragmentShader:Pn.distanceRGBA_frag},shadow:{uniforms:r([Un.lights,Un.fog,{color:{value:new n(0)},opacity:{value:1}}]),vertexShader:Pn.shadow_vert,fragmentShader:Pn.shadow_frag}};Dn.physical={uniforms:r([Dn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new e},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new e},clearcoatNormalScale:{value:new t(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new e},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new e},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new e},sheen:{value:0},sheenColor:{value:new n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new e},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new e},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new e},transmissionSamplerSize:{value:new t},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new e},attenuationDistance:{value:0},attenuationColor:{value:new n(0)},specularColor:{value:new n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new e},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new e},anisotropyVector:{value:new t},anisotropyMap:{value:null},anisotropyMapTransform:{value:new e}}]),vertexShader:Pn.meshphysical_vert,fragmentShader:Pn.meshphysical_frag};const wn={r:0,b:0,g:0},In=new u,yn=new f;function Nn(e,t,r,i,u,f,v){const E=new n(0);let S,T,M=!0===f?0:1,x=null,R=0,A=null;function b(e){let n=!0===e.isScene?e.background:null;if(n&&n.isTexture){n=(e.backgroundBlurriness>0?r:t).get(n)}return n}function C(t,n){t.getRGB(wn,g(e)),i.buffers.color.setClear(wn.r,wn.g,wn.b,n,v)}return{getClearColor:function(){return E},setClearColor:function(e,t=1){E.set(e),M=t,C(E,M)},getClearAlpha:function(){return M},setClearAlpha:function(e){M=e,C(E,M)},render:function(t){let n=!1;const r=b(t);null===r?C(E,M):r&&r.isColor&&(C(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,v):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,v),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const r=b(n);r&&(r.isCubeTexture||r.mapping===a)?(void 0===T&&(T=new o(new s(1,1,1),new l({name:"BackgroundCubeMaterial",uniforms:d(Dn.backgroundCube.uniforms),vertexShader:Dn.backgroundCube.vertexShader,fragmentShader:Dn.backgroundCube.fragmentShader,side:c,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),T.geometry.deleteAttribute("normal"),T.geometry.deleteAttribute("uv"),T.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(T.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),u.update(T)),In.copy(n.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(In.y*=-1,In.z*=-1),T.material.uniforms.envMap.value=r,T.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,T.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,T.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,T.material.uniforms.backgroundRotation.value.setFromMatrix4(yn.makeRotationFromEuler(In)),T.material.toneMapped=p.getTransfer(r.colorSpace)!==m,x===r&&R===r.version&&A===e.toneMapping||(T.material.needsUpdate=!0,x=r,R=r.version,A=e.toneMapping),T.layers.enableAll(),t.unshift(T,T.geometry,T.material,0,0,null)):r&&r.isTexture&&(void 0===S&&(S=new o(new h(2,2),new l({name:"BackgroundMaterial",uniforms:d(Dn.background.uniforms),vertexShader:Dn.background.vertexShader,fragmentShader:Dn.background.fragmentShader,side:_,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),S.geometry.deleteAttribute("normal"),Object.defineProperty(S.material,"map",{get:function(){return this.uniforms.t2D.value}}),u.update(S)),S.material.uniforms.t2D.value=r,S.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,S.material.toneMapped=p.getTransfer(r.colorSpace)!==m,!0===r.matrixAutoUpdate&&r.updateMatrix(),S.material.uniforms.uvTransform.value.copy(r.matrix),x===r&&R===r.version&&A===e.toneMapping||(S.material.needsUpdate=!0,x=r,R=r.version,A=e.toneMapping),S.layers.enableAll(),t.unshift(S,S.geometry,S.material,0,0,null))},dispose:function(){void 0!==T&&(T.geometry.dispose(),T.material.dispose(),T=void 0),void 0!==S&&(S.geometry.dispose(),S.material.dispose(),S=void 0)}}}function On(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=c(null);let a=i,o=!1;function s(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function d(){const e=a.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function u(e){f(e,0)}function f(t,n){const r=a.newAttributes,i=a.enabledAttributes,o=a.attributeDivisors;r[t]=1,0===i[t]&&(e.enableVertexAttribArray(t),i[t]=1),o[t]!==n&&(e.vertexAttribDivisor(t,n),o[t]=n)}function p(){const t=a.newAttributes,n=a.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function m(t,n,r,i,a,o,s){!0===s?e.vertexAttribIPointer(t,n,r,a,o):e.vertexAttribPointer(t,n,r,i,a,o)}function h(){_(),o=!0,a!==i&&(a=i,s(a.object))}function _(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:function(n,i,l,h,_){let g=!1;const E=function(t,n,i){const a=!0===i.wireframe;let o=r[t.id];void 0===o&&(o={},r[t.id]=o);let s=o[n.id];void 0===s&&(s={},o[n.id]=s);let l=s[a];void 0===l&&(l=c(e.createVertexArray()),s[a]=l);return l}(h,l,i);a!==E&&(a=E,s(a.object)),g=function(e,t,n,r){const i=a.attributes,o=t.attributes;let s=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){const n=i[t];let r=o[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;s++}}return a.attributesNum!==s||a.index!==r}(n,h,l,_),g&&function(e,t,n,r){const i={},o=t.attributes;let s=0;const l=n.getAttributes();for(const t in l){if(l[t].location>=0){let n=o[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}}a.attributes=i,a.attributesNum=s,a.index=r}(n,h,l,_),null!==_&&t.update(_,e.ELEMENT_ARRAY_BUFFER),(g||o)&&(o=!1,function(n,r,i,a){d();const o=a.attributes,s=i.getAttributes(),l=r.defaultAttributeValues;for(const r in s){const i=s[r];if(i.location>=0){let s=o[r];if(void 0===s&&("instanceMatrix"===r&&n.instanceMatrix&&(s=n.instanceMatrix),"instanceColor"===r&&n.instanceColor&&(s=n.instanceColor)),void 0!==s){const r=s.normalized,o=s.itemSize,l=t.get(s);if(void 0===l)continue;const c=l.buffer,d=l.type,p=l.bytesPerElement,h=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===v;if(s.isInterleavedBufferAttribute){const t=s.data,l=t.stride,_=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)f(i.location+e,t.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<i.locationSize;e++)u(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<i.locationSize;e++)m(i.location+e,o/i.locationSize,d,r,l*p,(_+o/i.locationSize*e)*p,h)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)f(i.location+e,s.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<i.locationSize;e++)u(i.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<i.locationSize;e++)m(i.location+e,o/i.locationSize,d,r,o*p,o/i.locationSize*e*p,h)}}else if(void 0!==l){const t=l[r];if(void 0!==t)switch(t.length){case 2:e.vertexAttrib2fv(i.location,t);break;case 3:e.vertexAttrib3fv(i.location,t);break;case 4:e.vertexAttrib4fv(i.location,t);break;default:e.vertexAttrib1fv(i.location,t)}}}}p()}(n,i,l,h),null!==_&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(_).buffer))},reset:h,resetDefaultState:_,dispose:function(){h();for(const e in r){const t=r[e];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete r[e]}},releaseStatesOfGeometry:function(e){if(void 0===r[e.id])return;const t=r[e.id];for(const e in t){const n=t[e];for(const e in n)l(n[e].object),delete n[e];delete t[e]}delete r[e.id]},releaseStatesOfProgram:function(e){for(const t in r){const n=r[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)l(i[e].object),delete i[e];delete n[e.id]}},initAttributes:d,enableAttribute:u,disableUnusedAttributes:p}}function Fn(e,t,n){let r;function i(t,i,a){0!==a&&(e.drawArraysInstanced(r,t,i,a),n.update(i,r,a))}this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r,1)},this.renderInstances=i,this.renderMultiDraw=function(e,i,a){if(0===a)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,e,0,i,0,a);let o=0;for(let e=0;e<a;e++)o+=i[e];n.update(o,r,1)},this.renderMultiDrawInstances=function(e,a,o,s){if(0===o)return;const l=t.get("WEBGL_multi_draw");if(null===l)for(let t=0;t<e.length;t++)i(e[t],a[t],s[t]);else{l.multiDrawArraysInstancedWEBGL(r,e,0,a,0,s,0,o);let t=0;for(let e=0;e<o;e++)t+=a[e]*s[e];n.update(t,r,1)}}}function Bn(e,t,n,r){let i;function a(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==n.precision?n.precision:"highp";const s=a(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:a,textureFormatReadable:function(t){return t===M||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const i=n===E&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==S&&r.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==T&&!i)},precision:o,logarithmicDepthBuffer:l,reversedDepthBuffer:c,maxTextures:d,maxVertexTextures:u,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:u>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Hn(t){const n=this;let r=null,i=0,a=!1,o=!1;const s=new x,l=new e,c={value:null,needsUpdate:!1};function d(e,t,r,i){const a=null!==e?e.length:0;let o=null;if(0!==a){if(o=c.value,!0!==i||null===o){const n=r+4*a,i=t.matrixWorldInverse;l.getNormalMatrix(i),(null===o||o.length<n)&&(o=new Float32Array(n));for(let t=0,n=r;t!==a;++t,n+=4)s.copy(e[t]).applyMatrix4(i,l),s.normal.toArray(o,n),o[n+3]=s.constant}c.value=o,c.needsUpdate=!0}return n.numPlanes=a,n.numIntersection=0,o}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==i||a;return a=t,i=e.length,n},this.beginShadows=function(){o=!0,d(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(e,t){r=d(e,t,0)},this.setState=function(e,s,l){const u=e.clippingPlanes,f=e.clipIntersection,p=e.clipShadows,m=t.get(e);if(!a||null===u||0===u.length||o&&!p)o?d(null):function(){c.value!==r&&(c.value=r,c.needsUpdate=i>0);n.numPlanes=i,n.numIntersection=0}();else{const e=o?0:i,t=4*e;let n=m.clippingState||null;c.value=n,n=d(u,s,t,l);for(let e=0;e!==t;++e)n[e]=r[e];m.clippingState=n,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}}}function Gn(e){let t=new WeakMap;function n(e,t){return t===R?e.mapping=C:t===A&&(e.mapping=L),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const a=i.mapping;if(a===R||a===A){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const a=i.image;if(a&&a.height>0){const o=new b(a.height);return o.fromEquirectangularTexture(e,i),t.set(i,o),i.addEventListener("dispose",r),n(o.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}const Vn=[.125,.215,.35,.446,.526,.582],zn=20,kn=new P,Wn=new n;let Xn=null,Yn=0,Kn=0,qn=!1;const jn=(1+Math.sqrt(5))/2,Zn=1/jn,$n=[new i(-jn,Zn,0),new i(jn,Zn,0),new i(-Zn,0,jn),new i(Zn,0,jn),new i(0,jn,-Zn),new i(0,jn,Zn),new i(-1,1,-1),new i(1,1,-1),new i(-1,1,1),new i(1,1,1)],Qn=new i;class Jn{constructor(e){this._renderer=e,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(e,t=0,n=.1,r=100,i={}){const{size:a=256,position:o=Qn}=i;Xn=this._renderer.getRenderTarget(),Yn=this._renderer.getActiveCubeFace(),Kn=this._renderer.getActiveMipmapLevel(),qn=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s,o),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=rr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=nr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Xn,Yn,Kn),this._renderer.xr.enabled=qn,e.scissorTest=!1,tr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===C||e.mapping===L?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Xn=this._renderer.getRenderTarget(),Yn=this._renderer.getActiveCubeFace(),Kn=this._renderer.getActiveMipmapLevel(),qn=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:B,minFilter:B,generateMipmaps:!1,type:E,format:M,colorSpace:F,depthBuffer:!1},r=er(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=er(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const a=e-4+1+Vn.length;for(let o=0;o<a;o++){const a=Math.pow(2,i);n.push(a);let s=1/a;o>e-4?s=Vn[o-e+4-1]:0===o&&(s=0),r.push(s);const l=1/(a-2),c=-l,d=1+l,u=[c,c,d,c,d,d,c,c,d,d,c,d],f=6,p=6,m=3,h=2,_=1,g=new Float32Array(m*p*f),v=new Float32Array(h*p*f),E=new Float32Array(_*p*f);for(let e=0;e<f;e++){const t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(r,m*p*e),v.set(u,h*p*e);const i=[e,e,e,e,e,e];E.set(i,_*p*e)}const S=new N;S.setAttribute("position",new O(g,m)),S.setAttribute("uv",new O(v,h)),S.setAttribute("faceIndex",new O(E,_)),t.push(S),i>4&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(zn),a=new i(0,1,0),o=new l({name:"SphericalGaussianBlur",defines:{n:zn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:ir(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1});return o}(r,e,t)}return r}_compileMaterial(e){const t=new o(this._lodPlanes[0],e);this._renderer.compile(t,kn)}_sceneToCubeUV(e,t,n,r,i){const a=new U(90,1,t,n),l=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,p=u.toneMapping;u.getClearColor(Wn),u.toneMapping=D,u.autoClear=!1;u.state.buffers.depth.getReversed()&&(u.setRenderTarget(r),u.clearDepth(),u.setRenderTarget(null));const m=new w({name:"PMREM.Background",side:c,depthWrite:!1,depthTest:!1}),h=new o(new s,m);let _=!1;const g=e.background;g?g.isColor&&(m.color.copy(g),e.background=null,_=!0):(m.color.copy(Wn),_=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(a.up.set(0,l[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+d[t],i.y,i.z)):1===n?(a.up.set(0,0,l[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+d[t],i.z)):(a.up.set(0,l[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+d[t]));const o=this._cubeSize;tr(r,n*o,t>2?o:0,o,o),u.setRenderTarget(r),_&&u.render(h,a),u.render(e,a)}h.geometry.dispose(),h.material.dispose(),u.toneMapping=p,u.autoClear=f,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===C||e.mapping===L;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=rr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=nr());const i=r?this._cubemapMaterial:this._equirectMaterial,a=new o(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const s=this._cubeSize;tr(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,kn)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let t=1;t<r;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=$n[(r-t-1)%$n.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",i),this._halfBlur(a,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,a,s){const l=this._renderer,c=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const d=new o(this._lodPlanes[r],c),u=c.uniforms,f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/39,m=i/p,h=isFinite(i)?1+Math.floor(3*m):zn;h>zn&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to 20`);const _=[];let g=0;for(let e=0;e<zn;++e){const t=e/m,n=Math.exp(-t*t/2);_.push(n),0===e?g+=n:e<h&&(g+=2*n)}for(let e=0;e<_.length;e++)_[e]=_[e]/g;u.envMap.value=e.texture,u.samples.value=h,u.weights.value=_,u.latitudinal.value="latitudinal"===a,s&&(u.poleAxis.value=s);const{_lodMax:v}=this;u.dTheta.value=p,u.mipInt.value=v-n;const E=this._sizeLods[r];tr(t,3*E*(r>v-4?r-v+4:0),4*(this._cubeSize-E),3*E,2*E),l.setRenderTarget(t),l.render(d,kn)}}function er(e,t,n){const r=new y(e,t,n);return r.texture.mapping=a,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function tr(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function nr(){return new l({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ir(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function rr(){return new l({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ir(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:I,depthTest:!1,depthWrite:!1})}function ir(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function ar(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const a=i.mapping,o=a===R||a===A,s=a===C||a===L;if(o||s){let a=t.get(i);const l=void 0!==a?a.texture.pmremVersion:0;if(i.isRenderTargetTexture&&i.pmremVersion!==l)return null===n&&(n=new Jn(e)),a=o?n.fromEquirectangular(i,a):n.fromCubemap(i,a),a.texture.pmremVersion=i.pmremVersion,t.set(i,a),a.texture;if(void 0!==a)return a.texture;{const l=i.image;return o&&l&&l.height>0||s&&l&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(l)?(null===n&&(n=new Jn(e)),a=o?n.fromEquirectangular(i):n.fromCubemap(i),a.texture.pmremVersion=i.pmremVersion,t.set(i,a),i.addEventListener("dispose",r),a.texture):null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function or(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&H("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function sr(e,t,n,r){const i={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete i[s.id];const l=a.get(s);l&&(t.remove(l),a.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],r=e.index,i=e.attributes.position;let o=0;if(null!==r){const e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else{if(void 0===i)return;{const e=i.array;o=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}}const s=new(z(n)?G:V)(n,1);s.version=o;const l=a.get(e);l&&t.remove(l),a.set(e,s)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",o),i[t.id]=!0,n.memory.geometries++),t},update:function(n){const r=n.attributes;for(const n in r)t.update(r[n],e.ARRAY_BUFFER)},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return a.get(e)}}}function lr(e,t,n){let r,i,a;function o(t,o,s){0!==s&&(e.drawElementsInstanced(r,o,i,t*a,s),n.update(o,r,s))}this.setMode=function(e){r=e},this.setIndex=function(e){i=e.type,a=e.bytesPerElement},this.render=function(t,o){e.drawElements(r,o,i,t*a),n.update(o,r,1)},this.renderInstances=o,this.renderMultiDraw=function(e,a,o){if(0===o)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,a,0,i,e,0,o);let s=0;for(let e=0;e<o;e++)s+=a[e];n.update(s,r,1)},this.renderMultiDrawInstances=function(e,s,l,c){if(0===l)return;const d=t.get("WEBGL_multi_draw");if(null===d)for(let t=0;t<e.length;t++)o(e[t]/a,s[t],c[t]);else{d.multiDrawElementsInstancedWEBGL(r,s,0,i,e,0,c,0,l);let t=0;for(let e=0;e<l;e++)t+=s[e]*c[e];n.update(t,r,1)}}}function cr(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(n,r,i){switch(t.calls++,r){case e.TRIANGLES:t.triangles+=i*(n/3);break;case e.LINES:t.lines+=i*(n/2);break;case e.LINE_STRIP:t.lines+=i*(n-1);break;case e.LINE_LOOP:t.lines+=i*n;break;case e.POINTS:t.points+=i*n;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}}}function dr(e,n,r){const i=new WeakMap,a=new k;return{update:function(o,s,l){const c=o.morphTargetInfluences,d=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,u=void 0!==d?d.length:0;let f=i.get(s);if(void 0===f||f.count!==u){void 0!==f&&f.texture.dispose();const p=void 0!==s.morphAttributes.position,m=void 0!==s.morphAttributes.normal,h=void 0!==s.morphAttributes.color,_=s.morphAttributes.position||[],g=s.morphAttributes.normal||[],v=s.morphAttributes.color||[];let E=0;!0===p&&(E=1),!0===m&&(E=2),!0===h&&(E=3);let S=s.attributes.position.count*E,M=1;S>n.maxTextureSize&&(M=Math.ceil(S/n.maxTextureSize),S=n.maxTextureSize);const x=new Float32Array(S*M*4*u),R=new W(x,S,M,u);R.type=T,R.needsUpdate=!0;const A=4*E;for(let C=0;C<u;C++){const L=_[C],P=g[C],U=v[C],D=S*M*4*C;for(let w=0;w<L.count;w++){const I=w*A;!0===p&&(a.fromBufferAttribute(L,w),x[D+I+0]=a.x,x[D+I+1]=a.y,x[D+I+2]=a.z,x[D+I+3]=0),!0===m&&(a.fromBufferAttribute(P,w),x[D+I+4]=a.x,x[D+I+5]=a.y,x[D+I+6]=a.z,x[D+I+7]=0),!0===h&&(a.fromBufferAttribute(U,w),x[D+I+8]=a.x,x[D+I+9]=a.y,x[D+I+10]=a.z,x[D+I+11]=4===U.itemSize?a.w:1)}}function b(){R.dispose(),i.delete(s),s.removeEventListener("dispose",b)}f={count:u,texture:R,size:new t(S,M)},i.set(s,f),s.addEventListener("dispose",b)}if(!0===o.isInstancedMesh&&null!==o.morphTexture)l.getUniforms().setValue(e,"morphTexture",o.morphTexture,r);else{let y=0;for(let O=0;O<c.length;O++)y+=c[O];const N=s.morphTargetsRelative?1:1-y;l.getUniforms().setValue(e,"morphTargetBaseInfluence",N),l.getUniforms().setValue(e,"morphTargetInfluences",c)}l.getUniforms().setValue(e,"morphTargetsTexture",f.texture,r),l.getUniforms().setValue(e,"morphTargetsTextureSize",f.size)}}}function ur(e,t,n,r){let i=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(o){const s=r.render.frame,l=o.geometry,c=t.get(o,l);if(i.get(c)!==s&&(t.update(c),i.set(c,s)),o.isInstancedMesh&&(!1===o.hasEventListener("dispose",a)&&o.addEventListener("dispose",a),i.get(o)!==s&&(n.update(o.instanceMatrix,e.ARRAY_BUFFER),null!==o.instanceColor&&n.update(o.instanceColor,e.ARRAY_BUFFER),i.set(o,s))),o.isSkinnedMesh){const e=o.skeleton;i.get(e)!==s&&(e.update(),i.set(e,s))}return c},dispose:function(){i=new WeakMap}}}const fr=new j,pr=new q(1,1),mr=new W,hr=new Y,_r=new X,gr=[],vr=[],Er=new Float32Array(16),Sr=new Float32Array(9),Tr=new Float32Array(4);function Mr(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let a=gr[i];if(void 0===a&&(a=new Float32Array(i),gr[i]=a),0!==t){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function xr(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function Rr(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function Ar(e,t){let n=vr[t];void 0===n&&(n=new Int32Array(t),vr[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function br(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Cr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(xr(n,t))return;e.uniform2fv(this.addr,t),Rr(n,t)}}function Lr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(xr(n,t))return;e.uniform3fv(this.addr,t),Rr(n,t)}}function Pr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(xr(n,t))return;e.uniform4fv(this.addr,t),Rr(n,t)}}function Ur(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(xr(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Rr(n,t)}else{if(xr(n,r))return;Tr.set(r),e.uniformMatrix2fv(this.addr,!1,Tr),Rr(n,r)}}function Dr(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(xr(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Rr(n,t)}else{if(xr(n,r))return;Sr.set(r),e.uniformMatrix3fv(this.addr,!1,Sr),Rr(n,r)}}function wr(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(xr(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Rr(n,t)}else{if(xr(n,r))return;Er.set(r),e.uniformMatrix4fv(this.addr,!1,Er),Rr(n,r)}}function Ir(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function yr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(xr(n,t))return;e.uniform2iv(this.addr,t),Rr(n,t)}}function Nr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(xr(n,t))return;e.uniform3iv(this.addr,t),Rr(n,t)}}function Or(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(xr(n,t))return;e.uniform4iv(this.addr,t),Rr(n,t)}}function Fr(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Br(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(xr(n,t))return;e.uniform2uiv(this.addr,t),Rr(n,t)}}function Hr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(xr(n,t))return;e.uniform3uiv(this.addr,t),Rr(n,t)}}function Gr(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(xr(n,t))return;e.uniform4uiv(this.addr,t),Rr(n,t)}}function Vr(e,t,n){const r=this.cache,i=n.allocateTextureUnit();let a;r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),this.type===e.SAMPLER_2D_SHADOW?(pr.compareFunction=K,a=pr):a=fr,n.setTexture2D(t||a,i)}function zr(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||hr,i)}function kr(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||_r,i)}function Wr(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||mr,i)}function Xr(e,t){e.uniform1fv(this.addr,t)}function Yr(e,t){const n=Mr(t,this.size,2);e.uniform2fv(this.addr,n)}function Kr(e,t){const n=Mr(t,this.size,3);e.uniform3fv(this.addr,n)}function qr(e,t){const n=Mr(t,this.size,4);e.uniform4fv(this.addr,n)}function jr(e,t){const n=Mr(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Zr(e,t){const n=Mr(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function $r(e,t){const n=Mr(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Qr(e,t){e.uniform1iv(this.addr,t)}function Jr(e,t){e.uniform2iv(this.addr,t)}function ei(e,t){e.uniform3iv(this.addr,t)}function ti(e,t){e.uniform4iv(this.addr,t)}function ni(e,t){e.uniform1uiv(this.addr,t)}function ri(e,t){e.uniform2uiv(this.addr,t)}function ii(e,t){e.uniform3uiv(this.addr,t)}function ai(e,t){e.uniform4uiv(this.addr,t)}function oi(e,t,n){const r=this.cache,i=t.length,a=Ar(n,i);xr(r,a)||(e.uniform1iv(this.addr,a),Rr(r,a));for(let e=0;e!==i;++e)n.setTexture2D(t[e]||fr,a[e])}function si(e,t,n){const r=this.cache,i=t.length,a=Ar(n,i);xr(r,a)||(e.uniform1iv(this.addr,a),Rr(r,a));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||hr,a[e])}function li(e,t,n){const r=this.cache,i=t.length,a=Ar(n,i);xr(r,a)||(e.uniform1iv(this.addr,a),Rr(r,a));for(let e=0;e!==i;++e)n.setTextureCube(t[e]||_r,a[e])}function ci(e,t,n){const r=this.cache,i=t.length,a=Ar(n,i);xr(r,a)||(e.uniform1iv(this.addr,a),Rr(r,a));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||mr,a[e])}class di{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=function(e){switch(e){case 5126:return br;case 35664:return Cr;case 35665:return Lr;case 35666:return Pr;case 35674:return Ur;case 35675:return Dr;case 35676:return wr;case 5124:case 35670:return Ir;case 35667:case 35671:return yr;case 35668:case 35672:return Nr;case 35669:case 35673:return Or;case 5125:return Fr;case 36294:return Br;case 36295:return Hr;case 36296:return Gr;case 35678:case 36198:case 36298:case 36306:case 35682:return Vr;case 35679:case 36299:case 36307:return zr;case 35680:case 36300:case 36308:case 36293:return kr;case 36289:case 36303:case 36311:case 36292:return Wr}}(t.type)}}class ui{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Xr;case 35664:return Yr;case 35665:return Kr;case 35666:return qr;case 35674:return jr;case 35675:return Zr;case 35676:return $r;case 5124:case 35670:return Qr;case 35667:case 35671:return Jr;case 35668:case 35672:return ei;case 35669:case 35673:return ti;case 5125:return ni;case 36294:return ri;case 36295:return ii;case 36296:return ai;case 35678:case 36198:case 36298:case 36306:case 35682:return oi;case 35679:case 36299:case 36307:return si;case 35680:case 36300:case 36308:case 36293:return li;case 36289:case 36303:case 36311:case 36292:return ci}}(t.type)}}class fi{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,a=r.length;i!==a;++i){const a=r[i];a.setValue(e,t[a.id],n)}}}const pi=/(\w+)(\])?(\[|\.)?/g;function mi(e,t){e.seq.push(t),e.map[t.id]=t}function hi(e,t,n){const r=e.name,i=r.length;for(pi.lastIndex=0;;){const a=pi.exec(r),o=pi.lastIndex;let s=a[1];const l="]"===a[2],c=a[3];if(l&&(s|=0),void 0===c||"["===c&&o+2===i){mi(n,void 0===c?new di(s,e,t):new ui(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new fi(s),mi(n,e)),n=e}}}class _i{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);hi(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){const a=t[i],o=n[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function gi(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let vi=0;const Ei=new e;function Si(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||"").trim();if(r&&""===i)return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const r=parseInt(a[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){const i=e+1;r.push(`${i===t?">":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function Ti(e,t){const n=function(e){p._getMatrix(Ei,p.workingColorSpace,e);const t=`mat3( ${Ei.elements.map(e=>e.toFixed(4))} )`;switch(p.getTransfer(e)){case se:return[t,"LinearTransferOETF"];case m:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Mi(e,t){let n;switch(t){case oe:n="Linear";break;case ae:n="Reinhard";break;case ie:n="Cineon";break;case re:n="ACESFilmic";break;case ne:n="AgX";break;case te:n="Neutral";break;case ee:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const xi=new i;function Ri(){p.getLuminanceCoefficients(xi);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${xi.x.toFixed(4)}, ${xi.y.toFixed(4)}, ${xi.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Ai(e){return""!==e}function bi(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ci(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Li=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pi(e){return e.replace(Li,Di)}const Ui=new Map;function Di(e,t){let n=Pn[t];if(void 0===n){const e=Ui.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Pn[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Pi(n)}const wi=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Ii(e){return e.replace(wi,yi)}function yi(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function Ni(e){let t=`precision ${e.precision} float;\n\tprecision ${e.precision} int;\n\tprecision ${e.precision} sampler2D;\n\tprecision ${e.precision} samplerCube;\n\tprecision ${e.precision} sampler3D;\n\tprecision ${e.precision} sampler2DArray;\n\tprecision ${e.precision} sampler2DShadow;\n\tprecision ${e.precision} samplerCubeShadow;\n\tprecision ${e.precision} sampler2DArrayShadow;\n\tprecision ${e.precision} isampler2D;\n\tprecision ${e.precision} isampler3D;\n\tprecision ${e.precision} isamplerCube;\n\tprecision ${e.precision} isampler2DArray;\n\tprecision ${e.precision} usampler2D;\n\tprecision ${e.precision} usampler3D;\n\tprecision ${e.precision} usamplerCube;\n\tprecision ${e.precision} usampler2DArray;\n\t`;return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Oi(e,t,n,r){const i=e.getContext(),o=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===$?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===Q?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===J&&(t="SHADOWMAP_TYPE_VSM"),t}(n),d=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case C:case L:t="ENVMAP_TYPE_CUBE";break;case a:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),u=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===L&&(t="ENVMAP_MODE_REFRACTION");return t}(n),f=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case de:t="ENVMAP_BLENDING_MULTIPLY";break;case ce:t="ENVMAP_BLENDING_MIX";break;case le:t="ENVMAP_BLENDING_ADD"}return t}(n),p=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),m=function(e){return[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ai).join("\n")}(n),h=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(o),_=i.createProgram();let g,v,E=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,h].filter(Ai).join("\n"),g.length>0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,h].filter(Ai).join("\n"),v.length>0&&(v+="\n")):(g=[Ni(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,h,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ai).join("\n"),v=[Ni(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,h,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.envMap?"#define "+u:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==D?"#define TONE_MAPPING":"",n.toneMapping!==D?Pn.tonemapping_pars_fragment:"",n.toneMapping!==D?Mi("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Pn.colorspace_pars_fragment,Ti("linearToOutputTexel",n.outputColorSpace),Ri(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ai).join("\n")),s=Pi(s),s=bi(s,n),s=Ci(s,n),l=Pi(l),l=bi(l,n),l=Ci(l,n),s=Ii(s),l=Ii(l),!0!==n.isRawShaderMaterial&&(E="#version 300 es\n",g=[m,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Z?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Z?"":"#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"+v);const S=E+g+s,T=E+v+l,M=gi(i,i.VERTEX_SHADER,S),x=gi(i,i.FRAGMENT_SHADER,T);function R(t){if(e.debug.checkShaderErrors){const n=i.getProgramInfoLog(_)||"",r=i.getShaderInfoLog(M)||"",a=i.getShaderInfoLog(x)||"",o=n.trim(),s=r.trim(),l=a.trim();let c=!0,d=!0;if(!1===i.getProgramParameter(_,i.LINK_STATUS))if(c=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(i,_,M,x);else{const e=Si(i,M,"vertex"),n=Si(i,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+o+"\n"+e+"\n"+n)}else""!==o?console.warn("THREE.WebGLProgram: Program Info Log:",o):""!==s&&""!==l||(d=!1);d&&(t.diagnostics={runnable:c,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:l,prefix:v}})}i.deleteShader(M),i.deleteShader(x),A=new _i(i,_),b=function(e,t){const n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),a=r.name;let o=1;r.type===e.FLOAT_MAT2&&(o=2),r.type===e.FLOAT_MAT3&&(o=3),r.type===e.FLOAT_MAT4&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}(i,_)}let A,b;i.attachShader(_,M),i.attachShader(_,x),void 0!==n.index0AttributeName?i.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_),this.getUniforms=function(){return void 0===A&&R(this),A},this.getAttributes=function(){return void 0===b&&R(this),b};let P=!1===n.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===P&&(P=i.getProgramParameter(_,37297)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=vi++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=M,this.fragmentShader=x,this}let Fi=0;class Bi{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(r)&&(a.add(r),r.usedTimes++),!1===a.has(i)&&(a.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Hi(e),t.set(e,n)),n}}class Hi{constructor(e){this.id=Fi++,this.code=e,this.usedTimes=0}}function Gi(e,t,n,r,i,o,s){const l=new _e,d=new Bi,u=new Set,f=[],h=i.logarithmicDepthBuffer,_=i.vertexTextures;let g=i.precision;const v={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"};function E(e){return u.add(e),0===e?"uv":`uv${e}`}return{getParameters:function(o,l,f,S,T){const M=S.fog,x=T.geometry,R=o.isMeshStandardMaterial?S.environment:null,A=(o.isMeshStandardMaterial?n:t).get(o.envMap||R),b=A&&A.mapping===a?A.image.height:null,C=v[o.type];null!==o.precision&&(g=i.getMaxPrecision(o.precision),g!==o.precision&&console.warn("THREE.WebGLProgram.getParameters:",o.precision,"not supported, using",g,"instead."));const L=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,P=void 0!==L?L.length:0;let U,w,I,y,N=0;if(void 0!==x.morphAttributes.position&&(N=1),void 0!==x.morphAttributes.normal&&(N=2),void 0!==x.morphAttributes.color&&(N=3),C){const e=Dn[C];U=e.vertexShader,w=e.fragmentShader}else U=o.vertexShader,w=o.fragmentShader,d.update(o),I=d.getVertexShaderID(o),y=d.getFragmentShaderID(o);const O=e.getRenderTarget(),B=e.state.buffers.depth.getReversed(),H=!0===T.isInstancedMesh,G=!0===T.isBatchedMesh,V=!!o.map,z=!!o.matcap,k=!!A,W=!!o.aoMap,X=!!o.lightMap,Y=!!o.bumpMap,K=!!o.normalMap,q=!!o.displacementMap,j=!!o.emissiveMap,Z=!!o.metalnessMap,$=!!o.roughnessMap,Q=o.anisotropy>0,J=o.clearcoat>0,ee=o.dispersion>0,te=o.iridescence>0,ne=o.sheen>0,re=o.transmission>0,ie=Q&&!!o.anisotropyMap,ae=J&&!!o.clearcoatMap,oe=J&&!!o.clearcoatNormalMap,se=J&&!!o.clearcoatRoughnessMap,le=te&&!!o.iridescenceMap,ce=te&&!!o.iridescenceThicknessMap,de=ne&&!!o.sheenColorMap,ue=ne&&!!o.sheenRoughnessMap,_e=!!o.specularMap,ge=!!o.specularColorMap,ve=!!o.specularIntensityMap,Ee=re&&!!o.transmissionMap,Se=re&&!!o.thicknessMap,Te=!!o.gradientMap,Me=!!o.alphaMap,xe=o.alphaTest>0,Re=!!o.alphaHash,Ae=!!o.extensions;let be=D;o.toneMapped&&(null!==O&&!0!==O.isXRRenderTarget||(be=e.toneMapping));const Ce={shaderID:C,shaderType:o.type,shaderName:o.name,vertexShader:U,fragmentShader:w,defines:o.defines,customVertexShaderID:I,customFragmentShaderID:y,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:g,batching:G,batchingColor:G&&null!==T._colorsTexture,instancing:H,instancingColor:H&&null!==T.instanceColor,instancingMorph:H&&null!==T.morphTexture,supportsVertexTextures:_,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:F,alphaToCoverage:!!o.alphaToCoverage,map:V,matcap:z,envMap:k,envMapMode:k&&A.mapping,envMapCubeUVHeight:b,aoMap:W,lightMap:X,bumpMap:Y,normalMap:K,displacementMap:_&&q,emissiveMap:j,normalMapObjectSpace:K&&o.normalMapType===he,normalMapTangentSpace:K&&o.normalMapType===me,metalnessMap:Z,roughnessMap:$,anisotropy:Q,anisotropyMap:ie,clearcoat:J,clearcoatMap:ae,clearcoatNormalMap:oe,clearcoatRoughnessMap:se,dispersion:ee,iridescence:te,iridescenceMap:le,iridescenceThicknessMap:ce,sheen:ne,sheenColorMap:de,sheenRoughnessMap:ue,specularMap:_e,specularColorMap:ge,specularIntensityMap:ve,transmission:re,transmissionMap:Ee,thicknessMap:Se,gradientMap:Te,opaque:!1===o.transparent&&o.blending===pe&&!1===o.alphaToCoverage,alphaMap:Me,alphaTest:xe,alphaHash:Re,combine:o.combine,mapUv:V&&E(o.map.channel),aoMapUv:W&&E(o.aoMap.channel),lightMapUv:X&&E(o.lightMap.channel),bumpMapUv:Y&&E(o.bumpMap.channel),normalMapUv:K&&E(o.normalMap.channel),displacementMapUv:q&&E(o.displacementMap.channel),emissiveMapUv:j&&E(o.emissiveMap.channel),metalnessMapUv:Z&&E(o.metalnessMap.channel),roughnessMapUv:$&&E(o.roughnessMap.channel),anisotropyMapUv:ie&&E(o.anisotropyMap.channel),clearcoatMapUv:ae&&E(o.clearcoatMap.channel),clearcoatNormalMapUv:oe&&E(o.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&E(o.clearcoatRoughnessMap.channel),iridescenceMapUv:le&&E(o.iridescenceMap.channel),iridescenceThicknessMapUv:ce&&E(o.iridescenceThicknessMap.channel),sheenColorMapUv:de&&E(o.sheenColorMap.channel),sheenRoughnessMapUv:ue&&E(o.sheenRoughnessMap.channel),specularMapUv:_e&&E(o.specularMap.channel),specularColorMapUv:ge&&E(o.specularColorMap.channel),specularIntensityMapUv:ve&&E(o.specularIntensityMap.channel),transmissionMapUv:Ee&&E(o.transmissionMap.channel),thicknessMapUv:Se&&E(o.thicknessMap.channel),alphaMapUv:Me&&E(o.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(K||Q),vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===T.isPoints&&!!x.attributes.uv&&(V||Me),fog:!!M,useFog:!0===o.fog,fogExp2:!!M&&M.isFogExp2,flatShading:!0===o.flatShading&&!1===o.wireframe,sizeAttenuation:!0===o.sizeAttenuation,logarithmicDepthBuffer:h,reversedDepthBuffer:B,skinning:!0===T.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:P,morphTextureStride:N,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&f.length>0,shadowMapType:e.shadowMap.type,toneMapping:be,decodeVideoTexture:V&&!0===o.map.isVideoTexture&&p.getTransfer(o.map.colorSpace)===m,decodeVideoTextureEmissive:j&&!0===o.emissiveMap.isVideoTexture&&p.getTransfer(o.emissiveMap.colorSpace)===m,premultipliedAlpha:o.premultipliedAlpha,doubleSided:o.side===fe,flipSided:o.side===c,useDepthPacking:o.depthPacking>=0,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionClipCullDistance:Ae&&!0===o.extensions.clipCullDistance&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ae&&!0===o.extensions.multiDraw||G)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:o.customProgramCacheKey()};return Ce.vertexUv1s=u.has(1),Ce.vertexUv2s=u.has(2),Ce.vertexUv3s=u.has(3),u.clear(),Ce},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){l.disableAll(),t.supportsVertexTextures&&l.enable(0);t.instancing&&l.enable(1);t.instancingColor&&l.enable(2);t.instancingMorph&&l.enable(3);t.matcap&&l.enable(4);t.envMap&&l.enable(5);t.normalMapObjectSpace&&l.enable(6);t.normalMapTangentSpace&&l.enable(7);t.clearcoat&&l.enable(8);t.iridescence&&l.enable(9);t.alphaTest&&l.enable(10);t.vertexColors&&l.enable(11);t.vertexAlphas&&l.enable(12);t.vertexUv1s&&l.enable(13);t.vertexUv2s&&l.enable(14);t.vertexUv3s&&l.enable(15);t.vertexTangents&&l.enable(16);t.anisotropy&&l.enable(17);t.alphaHash&&l.enable(18);t.batching&&l.enable(19);t.dispersion&&l.enable(20);t.batchingColor&&l.enable(21);t.gradientMap&&l.enable(22);e.push(l.mask),l.disableAll(),t.fog&&l.enable(0);t.useFog&&l.enable(1);t.flatShading&&l.enable(2);t.logarithmicDepthBuffer&&l.enable(3);t.reversedDepthBuffer&&l.enable(4);t.skinning&&l.enable(5);t.morphTargets&&l.enable(6);t.morphNormals&&l.enable(7);t.morphColors&&l.enable(8);t.premultipliedAlpha&&l.enable(9);t.shadowMapEnabled&&l.enable(10);t.doubleSided&&l.enable(11);t.flipSided&&l.enable(12);t.useDepthPacking&&l.enable(13);t.dithering&&l.enable(14);t.transmission&&l.enable(15);t.sheen&&l.enable(16);t.opaque&&l.enable(17);t.pointsUvs&&l.enable(18);t.decodeVideoTexture&&l.enable(19);t.decodeVideoTextureEmissive&&l.enable(20);t.alphaToCoverage&&l.enable(21);e.push(l.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=v[e.type];let n;if(t){const e=Dn[t];n=ue.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=f.length;e<t;e++){const t=f[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Oi(e,n,t,o),f.push(r)),r},releaseProgram:function(e){if(0===--e.usedTimes){const t=f.indexOf(e);f[t]=f[f.length-1],f.pop(),e.destroy()}},releaseShaderCache:function(e){d.remove(e)},programs:f,dispose:function(){d.dispose()}}}function Vi(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function zi(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function ki(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Wi(){const e=[];let t=0;const n=[],r=[],i=[];function a(n,r,i,a,o,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:r,material:i,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=o,l.group=s),t++,l}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,o,s,l,c){const d=a(e,t,o,s,l,c);o.transmission>0?r.push(d):!0===o.transparent?i.push(d):n.push(d)},unshift:function(e,t,o,s,l,c){const d=a(e,t,o,s,l,c);o.transmission>0?r.unshift(d):!0===o.transparent?i.unshift(d):n.unshift(d)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||zi),r.length>1&&r.sort(t||ki),i.length>1&&i.sort(t||ki)}}}function Xi(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new Wi,e.set(t,[i])):n>=r.length?(i=new Wi,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Yi(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let r;switch(t.type){case"DirectionalLight":r={direction:new i,color:new n};break;case"SpotLight":r={position:new i,direction:new i,color:new n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":r={position:new i,color:new n,distance:0,decay:0};break;case"HemisphereLight":r={direction:new i,skyColor:new n,groundColor:new n};break;case"RectAreaLight":r={color:new n,position:new i,halfWidth:new i,halfHeight:new i}}return e[t.id]=r,r}}}let Ki=0;function qi(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ji(e){const n=new Yi,r=function(){const e={};return{get:function(n){if(void 0!==e[n.id])return e[n.id];let r;switch(n.type){case"DirectionalLight":case"SpotLight":r={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t};break;case"PointLight":r={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t,shadowCameraNear:1,shadowCameraFar:1e3}}return e[n.id]=r,r}}}(),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let e=0;e<9;e++)a.probe.push(new i);const o=new i,s=new f,l=new f;return{setup:function(t){let i=0,o=0,s=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let l=0,c=0,d=0,u=0,f=0,p=0,m=0,h=0,_=0,g=0,v=0;t.sort(qi);for(let e=0,E=t.length;e<E;e++){const E=t[e],S=E.color,T=E.intensity,M=E.distance,x=E.shadow&&E.shadow.map?E.shadow.map.texture:null;if(E.isAmbientLight)i+=S.r*T,o+=S.g*T,s+=S.b*T;else if(E.isLightProbe){for(let e=0;e<9;e++)a.probe[e].addScaledVector(E.sh.coefficients[e],T);v++}else if(E.isDirectionalLight){const e=n.get(E);if(e.color.copy(E.color).multiplyScalar(E.intensity),E.castShadow){const e=E.shadow,t=r.get(E);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,a.directionalShadow[l]=t,a.directionalShadowMap[l]=x,a.directionalShadowMatrix[l]=E.shadow.matrix,p++}a.directional[l]=e,l++}else if(E.isSpotLight){const e=n.get(E);e.position.setFromMatrixPosition(E.matrixWorld),e.color.copy(S).multiplyScalar(T),e.distance=M,e.coneCos=Math.cos(E.angle),e.penumbraCos=Math.cos(E.angle*(1-E.penumbra)),e.decay=E.decay,a.spot[d]=e;const t=E.shadow;if(E.map&&(a.spotLightMap[_]=E.map,_++,t.updateMatrices(E),E.castShadow&&g++),a.spotLightMatrix[d]=t.matrix,E.castShadow){const e=r.get(E);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,a.spotShadow[d]=e,a.spotShadowMap[d]=x,h++}d++}else if(E.isRectAreaLight){const e=n.get(E);e.color.copy(S).multiplyScalar(T),e.halfWidth.set(.5*E.width,0,0),e.halfHeight.set(0,.5*E.height,0),a.rectArea[u]=e,u++}else if(E.isPointLight){const e=n.get(E);if(e.color.copy(E.color).multiplyScalar(E.intensity),e.distance=E.distance,e.decay=E.decay,E.castShadow){const e=E.shadow,t=r.get(E);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,a.pointShadow[c]=t,a.pointShadowMap[c]=x,a.pointShadowMatrix[c]=E.shadow.matrix,m++}a.point[c]=e,c++}else if(E.isHemisphereLight){const e=n.get(E);e.skyColor.copy(E.color).multiplyScalar(T),e.groundColor.copy(E.groundColor).multiplyScalar(T),a.hemi[f]=e,f++}}u>0&&(!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=Un.LTC_FLOAT_1,a.rectAreaLTC2=Un.LTC_FLOAT_2):(a.rectAreaLTC1=Un.LTC_HALF_1,a.rectAreaLTC2=Un.LTC_HALF_2)),a.ambient[0]=i,a.ambient[1]=o,a.ambient[2]=s;const E=a.hash;E.directionalLength===l&&E.pointLength===c&&E.spotLength===d&&E.rectAreaLength===u&&E.hemiLength===f&&E.numDirectionalShadows===p&&E.numPointShadows===m&&E.numSpotShadows===h&&E.numSpotMaps===_&&E.numLightProbes===v||(a.directional.length=l,a.spot.length=d,a.rectArea.length=u,a.point.length=c,a.hemi.length=f,a.directionalShadow.length=p,a.directionalShadowMap.length=p,a.pointShadow.length=m,a.pointShadowMap.length=m,a.spotShadow.length=h,a.spotShadowMap.length=h,a.directionalShadowMatrix.length=p,a.pointShadowMatrix.length=m,a.spotLightMatrix.length=h+_-g,a.spotLightMap.length=_,a.numSpotLightShadowsWithMaps=g,a.numLightProbes=v,E.directionalLength=l,E.pointLength=c,E.spotLength=d,E.rectAreaLength=u,E.hemiLength=f,E.numDirectionalShadows=p,E.numPointShadows=m,E.numSpotShadows=h,E.numSpotMaps=_,E.numLightProbes=v,a.version=Ki++)},setupView:function(e,t){let n=0,r=0,i=0,c=0,d=0;const u=t.matrixWorldInverse;for(let t=0,f=e.length;t<f;t++){const f=e[t];if(f.isDirectionalLight){const e=a.directional[n];e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),n++}else if(f.isSpotLight){const e=a.spot[i];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(f.matrixWorld),o.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(o),e.direction.transformDirection(u),i++}else if(f.isRectAreaLight){const e=a.rectArea[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),l.identity(),s.copy(f.matrixWorld),s.premultiply(u),l.extractRotation(s),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(l),e.halfHeight.applyMatrix4(l),c++}else if(f.isPointLight){const e=a.point[r];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(u),r++}else if(f.isHemisphereLight){const e=a.hemi[d];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(u),d++}}},state:a}}function Zi(e){const t=new ji(e),n=[],r=[];const i={lightsArray:n,shadowsArray:r,camera:null,lights:t,transmissionRenderTarget:{}};return{init:function(e){i.camera=e,n.length=0,r.length=0},state:i,setupLights:function(){t.setup(n)},setupLightsView:function(e){t.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function $i(e){let t=new WeakMap;return{get:function(n,r=0){const i=t.get(n);let a;return void 0===i?(a=new Zi(e),t.set(n,[a])):r>=i.length?(a=new Zi(e),i.push(a)):a=i[r],a},dispose:function(){t=new WeakMap}}}function Qi(e,n,r){let i=new ge;const a=new t,s=new t,d=new k,u=new ve({depthPacking:Ee}),f=new Se,p={},m=r.maxTextureSize,h={[_]:c,[c]:_,[fe]:fe},g=new l({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new t},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),v=g.clone();v.defines.HORIZONTAL_PASS=1;const E=new N;E.setAttribute("position",new O(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new o(E,g),T=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=$;let M=this.type;function x(t,r){const i=n.update(S);g.defines.VSM_SAMPLES!==t.blurSamples&&(g.defines.VSM_SAMPLES=t.blurSamples,v.defines.VSM_SAMPLES=t.blurSamples,g.needsUpdate=!0,v.needsUpdate=!0),null===t.mapPass&&(t.mapPass=new y(a.x,a.y)),g.uniforms.shadow_pass.value=t.map.texture,g.uniforms.resolution.value=t.mapSize,g.uniforms.radius.value=t.radius,e.setRenderTarget(t.mapPass),e.clear(),e.renderBufferDirect(r,null,i,g,S,null),v.uniforms.shadow_pass.value=t.mapPass.texture,v.uniforms.resolution.value=t.mapSize,v.uniforms.radius.value=t.radius,e.setRenderTarget(t.map),e.clear(),e.renderBufferDirect(r,null,i,v,S,null)}function R(t,n,r,i){let a=null;const o=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===r.isPointLight?f:u,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){const e=a.uuid,t=n.uuid;let r=p[e];void 0===r&&(r={},p[e]=r);let i=r[t];void 0===i&&(i=a.clone(),r[t]=i,n.addEventListener("dispose",b)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=i===J?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===r.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=r}return a}function A(t,r,a,o,s){if(!1===t.visible)return;if(t.layers.test(r.layers)&&(t.isMesh||t.isLine||t.isPoints)&&(t.castShadow||t.receiveShadow&&s===J)&&(!t.frustumCulled||i.intersectsObject(t))){t.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,t.matrixWorld);const i=n.update(t),l=t.material;if(Array.isArray(l)){const n=i.groups;for(let c=0,d=n.length;c<d;c++){const d=n[c],u=l[d.materialIndex];if(u&&u.visible){const n=R(t,u,o,s);t.onBeforeShadow(e,t,r,a,i,n,d),e.renderBufferDirect(a,null,i,n,t,d),t.onAfterShadow(e,t,r,a,i,n,d)}}}else if(l.visible){const n=R(t,l,o,s);t.onBeforeShadow(e,t,r,a,i,n,null),e.renderBufferDirect(a,null,i,n,t,null),t.onAfterShadow(e,t,r,a,i,n,null)}}const l=t.children;for(let e=0,t=l.length;e<t;e++)A(l[e],r,a,o,s)}function b(e){e.target.removeEventListener("dispose",b);for(const t in p){const n=p[t],r=e.target.uuid;if(r in n){n[r].dispose(),delete n[r]}}}this.render=function(t,n,r){if(!1===T.enabled)return;if(!1===T.autoUpdate&&!1===T.needsUpdate)return;if(0===t.length)return;const o=e.getRenderTarget(),l=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),u=e.state;u.setBlending(I),!0===u.buffers.depth.getReversed()?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1),u.buffers.depth.setTest(!0),u.setScissorTest(!1);const f=M!==J&&this.type===J,p=M===J&&this.type!==J;for(let o=0,l=t.length;o<l;o++){const l=t[o],c=l.shadow;if(void 0===c){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===c.autoUpdate&&!1===c.needsUpdate)continue;a.copy(c.mapSize);const h=c.getFrameExtents();if(a.multiply(h),s.copy(c.mapSize),(a.x>m||a.y>m)&&(a.x>m&&(s.x=Math.floor(m/h.x),a.x=s.x*h.x,c.mapSize.x=s.x),a.y>m&&(s.y=Math.floor(m/h.y),a.y=s.y*h.y,c.mapSize.y=s.y)),null===c.map||!0===f||!0===p){const e=this.type!==J?{minFilter:Te,magFilter:Te}:{};null!==c.map&&c.map.dispose(),c.map=new y(a.x,a.y,e),c.map.texture.name=l.name+".shadowMap",c.camera.updateProjectionMatrix()}e.setRenderTarget(c.map),e.clear();const _=c.getViewportCount();for(let e=0;e<_;e++){const t=c.getViewport(e);d.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),u.viewport(d),c.updateMatrices(l,e),i=c.getFrustum(),A(n,r,c.camera,l,this.type)}!0!==c.isPointLightShadow&&this.type===J&&x(c,r),c.needsUpdate=!1}M=this.type,T.needsUpdate=!1,e.setRenderTarget(o,l,c)}}const Ji={[Ke]:Ye,[Xe]:ze,[We]:Ve,[Me]:ke,[Ye]:Ke,[ze]:Xe,[Ve]:We,[ke]:Me};function ea(e,t){const r=new function(){let t=!1;const n=new k;let r=null;const i=new k(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){!0===s&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),!1===i.equals(n)&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},i=new function(){let n=!1,r=!1,i=null,a=null,o=null;return{setReversed:function(e){if(r!==e){const n=t.get("EXT_clip_control");e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),r=e;const i=o;o=null,this.setClear(i)}},getReversed:function(){return r},setTest:function(t){t?W(e.DEPTH_TEST):X(e.DEPTH_TEST)},setMask:function(t){i===t||n||(e.depthMask(t),i=t)},setFunc:function(t){if(r&&(t=Ji[t]),a!==t){switch(t){case Ke:e.depthFunc(e.NEVER);break;case Ye:e.depthFunc(e.ALWAYS);break;case Xe:e.depthFunc(e.LESS);break;case Me:e.depthFunc(e.LEQUAL);break;case We:e.depthFunc(e.EQUAL);break;case ke:e.depthFunc(e.GEQUAL);break;case ze:e.depthFunc(e.GREATER);break;case Ve:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(r&&(t=1-t),e.clearDepth(t),o=t)},reset:function(){n=!1,i=null,a=null,o=null,r=!1}}},a=new function(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(n){t||(n?W(e.STENCIL_TEST):X(e.STENCIL_TEST))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,o){r===t&&i===n&&a===o||(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){o===t&&s===n&&l===r||(e.stencilOp(t,n,r),o=t,s=n,l=r)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,l=null,c=null}}},o=new WeakMap,s=new WeakMap;let l={},d={},u=new WeakMap,f=[],p=null,m=!1,h=null,_=null,g=null,v=null,E=null,S=null,T=null,M=new n(0,0,0),x=0,R=!1,A=null,b=null,C=null,L=null,P=null;const U=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let D=!1,w=0;const y=e.getParameter(e.VERSION);-1!==y.indexOf("WebGL")?(w=parseFloat(/^WebGL (\d)/.exec(y)[1]),D=w>=1):-1!==y.indexOf("OpenGL ES")&&(w=parseFloat(/^OpenGL ES (\d)/.exec(y)[1]),D=w>=2);let N=null,O={};const F=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),H=(new k).fromArray(F),G=(new k).fromArray(B);function V(t,n,r,i){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}const z={};function W(t){!0!==l[t]&&(e.enable(t),l[t]=!0)}function X(t){!1!==l[t]&&(e.disable(t),l[t]=!1)}z[e.TEXTURE_2D]=V(e.TEXTURE_2D,e.TEXTURE_2D,1),z[e.TEXTURE_CUBE_MAP]=V(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),z[e.TEXTURE_2D_ARRAY]=V(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),z[e.TEXTURE_3D]=V(e.TEXTURE_3D,e.TEXTURE_3D,1,1),r.setClear(0,0,0,1),i.setClear(1),a.setClear(0),W(e.DEPTH_TEST),i.setFunc(Me),j(!1),Z(je),W(e.CULL_FACE),q(I);const Y={[Ae]:e.FUNC_ADD,[Re]:e.FUNC_SUBTRACT,[xe]:e.FUNC_REVERSE_SUBTRACT};Y[tt]=e.MIN,Y[nt]=e.MAX;const K={[Ge]:e.ZERO,[He]:e.ONE,[Be]:e.SRC_COLOR,[Fe]:e.SRC_ALPHA,[Oe]:e.SRC_ALPHA_SATURATE,[Ne]:e.DST_COLOR,[ye]:e.DST_ALPHA,[Ie]:e.ONE_MINUS_SRC_COLOR,[we]:e.ONE_MINUS_SRC_ALPHA,[De]:e.ONE_MINUS_DST_COLOR,[Ue]:e.ONE_MINUS_DST_ALPHA,[Pe]:e.CONSTANT_COLOR,[Le]:e.ONE_MINUS_CONSTANT_COLOR,[Ce]:e.CONSTANT_ALPHA,[be]:e.ONE_MINUS_CONSTANT_ALPHA};function q(t,n,r,i,a,o,s,l,c,d){if(t!==I){if(!1===m&&(W(e.BLEND),m=!0),t===$e)a=a||n,o=o||r,s=s||i,n===_&&a===E||(e.blendEquationSeparate(Y[n],Y[a]),_=n,E=a),r===g&&i===v&&o===S&&s===T||(e.blendFuncSeparate(K[r],K[i],K[o],K[s]),g=r,v=i,S=o,T=s),!1!==l.equals(M)&&c===x||(e.blendColor(l.r,l.g,l.b,c),M.copy(l),x=c),h=t,R=!1;else if(t!==h||d!==R){if(_===Ae&&E===Ae||(e.blendEquation(e.FUNC_ADD),_=Ae,E=Ae),d)switch(t){case pe:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case et:e.blendFunc(e.ONE,e.ONE);break;case Je:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case Qe:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case pe:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case et:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case Je:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Qe:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}g=null,v=null,S=null,T=null,M.set(0,0,0),x=0,h=t,R=d}}else!0===m&&(X(e.BLEND),m=!1)}function j(t){A!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),A=t)}function Z(t){t!==qe?(W(e.CULL_FACE),t!==b&&(t===je?e.cullFace(e.BACK):t===Ze?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):X(e.CULL_FACE),b=t}function $(t,n,r){t?(W(e.POLYGON_OFFSET_FILL),L===n&&P===r||(e.polygonOffset(n,r),L=n,P=r)):X(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:i,stencil:a},enable:W,disable:X,bindFramebuffer:function(t,n){return d[t]!==n&&(e.bindFramebuffer(t,n),d[t]=n,t===e.DRAW_FRAMEBUFFER&&(d[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(d[e.DRAW_FRAMEBUFFER]=n),!0)},drawBuffers:function(t,n){let r=f,i=!1;if(t){r=u.get(n),void 0===r&&(r=[],u.set(n,r));const a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)},useProgram:function(t){return p!==t&&(e.useProgram(t),p=t,!0)},setBlending:q,setMaterial:function(t,n){t.side===fe?X(e.CULL_FACE):W(e.CULL_FACE);let o=t.side===c;n&&(o=!o),j(o),t.blending===pe&&!1===t.transparent?q(I):q(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),i.setFunc(t.depthFunc),i.setTest(t.depthTest),i.setMask(t.depthWrite),r.setMask(t.colorWrite);const s=t.stencilWrite;a.setTest(s),s&&(a.setMask(t.stencilWriteMask),a.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),a.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),$(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?W(e.SAMPLE_ALPHA_TO_COVERAGE):X(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:j,setCullFace:Z,setLineWidth:function(t){t!==C&&(D&&e.lineWidth(t),C=t)},setPolygonOffset:$,setScissorTest:function(t){t?W(e.SCISSOR_TEST):X(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+U-1),N!==t&&(e.activeTexture(t),N=t)},bindTexture:function(t,n,r){void 0===r&&(r=null===N?e.TEXTURE0+U-1:N);let i=O[r];void 0===i&&(i={type:void 0,texture:void 0},O[r]=i),i.type===t&&i.texture===n||(N!==r&&(e.activeTexture(r),N=r),e.bindTexture(t,n||z[t]),i.type=t,i.texture=n)},unbindTexture:function(){const t=O[N];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let r=s.get(n);void 0===r&&(r=new WeakMap,s.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=s.get(n).get(t);o.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),o.set(n,r))},texStorage2D:function(){try{e.texStorage2D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D(...arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===H.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),H.copy(t))},viewport:function(t){!1===G.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),G.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),i.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),l={},N=null,O={},d={},u=new WeakMap,f=[],p=null,m=!1,h=null,_=null,g=null,v=null,E=null,S=null,T=null,M=new n(0,0,0),x=0,R=!1,A=null,b=null,C=null,L=null,P=null,H.set(0,0,e.canvas.width,e.canvas.height),G.set(0,0,e.canvas.width,e.canvas.height),r.reset(),i.reset(),a.reset()}}}function ta(e,n,r,i,a,o,s){const l=n.has("WEBGL_multisampled_render_to_texture")?n.get("WEBGL_multisampled_render_to_texture"):null,c="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),d=new t,u=new WeakMap;let f;const h=new WeakMap;let _=!1;try{_="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function g(e,t){return _?new OffscreenCanvas(e,t):Rt("canvas")}function v(e,t,n){let r=1;const i=Q(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(r*i.width),a=Math.floor(r*i.height);void 0===f&&(f=g(n,a));const o=t?g(n,a):f;o.width=n,o.height=a;return o.getContext("2d").drawImage(e,0,0,n,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+i.width+"x"+i.height+") to ("+n+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+i.width+"x"+i.height+")."),e}return e}function E(e){return e.generateMipmaps}function x(t){e.generateMipmap(t)}function R(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function A(t,r,i,a,o=!1){if(null!==t){if(void 0!==e[t])return e[t];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}let s=r;if(r===e.RED&&(i===e.FLOAT&&(s=e.R32F),i===e.HALF_FLOAT&&(s=e.R16F),i===e.UNSIGNED_BYTE&&(s=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.R8UI),i===e.UNSIGNED_SHORT&&(s=e.R16UI),i===e.UNSIGNED_INT&&(s=e.R32UI),i===e.BYTE&&(s=e.R8I),i===e.SHORT&&(s=e.R16I),i===e.INT&&(s=e.R32I)),r===e.RG&&(i===e.FLOAT&&(s=e.RG32F),i===e.HALF_FLOAT&&(s=e.RG16F),i===e.UNSIGNED_BYTE&&(s=e.RG8)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RG8UI),i===e.UNSIGNED_SHORT&&(s=e.RG16UI),i===e.UNSIGNED_INT&&(s=e.RG32UI),i===e.BYTE&&(s=e.RG8I),i===e.SHORT&&(s=e.RG16I),i===e.INT&&(s=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RGB8UI),i===e.UNSIGNED_SHORT&&(s=e.RGB16UI),i===e.UNSIGNED_INT&&(s=e.RGB32UI),i===e.BYTE&&(s=e.RGB8I),i===e.SHORT&&(s=e.RGB16I),i===e.INT&&(s=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(s=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(s=e.RGBA16UI),i===e.UNSIGNED_INT&&(s=e.RGBA32UI),i===e.BYTE&&(s=e.RGBA8I),i===e.SHORT&&(s=e.RGBA16I),i===e.INT&&(s=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(s=e.R11F_G11F_B10F)),r===e.RGBA){const t=o?se:p.getTransfer(a);i===e.FLOAT&&(s=e.RGBA32F),i===e.HALF_FLOAT&&(s=e.RGBA16F),i===e.UNSIGNED_BYTE&&(s=t===m?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}return s!==e.R16F&&s!==e.R32F&&s!==e.RG16F&&s!==e.RG32F&&s!==e.RGBA16F&&s!==e.RGBA32F||n.get("EXT_color_buffer_float"),s}function b(t,n){let r;return t?null===n||n===Tt||n===Mt?r=e.DEPTH24_STENCIL8:n===T?r=e.DEPTH32F_STENCIL8:n===xt&&(r=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===Tt||n===Mt?r=e.DEPTH_COMPONENT24:n===T?r=e.DEPTH_COMPONENT32F:n===xt&&(r=e.DEPTH_COMPONENT16),r}function C(e,t){return!0===E(e)||e.isFramebufferTexture&&e.minFilter!==Te&&e.minFilter!==B?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function L(e){const t=e.target;t.removeEventListener("dispose",L),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=h.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&U(e),0===Object.keys(r).length&&h.delete(n)}i.remove(e)}(t),t.isVideoTexture&&u.delete(t)}function P(t){const n=t.target;n.removeEventListener("dispose",P),function(t){const n=i.get(t);t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture));if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}const r=t.textures;for(let t=0,n=r.length;t<n;t++){const n=i.get(r[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),s.memory.textures--),i.remove(r[t])}i.remove(t)}(n)}function U(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const r=t.source;delete h.get(r)[n.__cacheKey],s.memory.textures--}let D=0;function w(t,n){const a=i.get(t);if(t.isVideoTexture&&function(e){const t=s.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&!0!==t.isExternalTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void V(a,t,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);r.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+n)}const I={[at]:e.REPEAT,[it]:e.CLAMP_TO_EDGE,[rt]:e.MIRRORED_REPEAT},y={[Te]:e.NEAREST,[ct]:e.NEAREST_MIPMAP_NEAREST,[lt]:e.NEAREST_MIPMAP_LINEAR,[B]:e.LINEAR,[st]:e.LINEAR_MIPMAP_NEAREST,[ot]:e.LINEAR_MIPMAP_LINEAR},N={[_t]:e.NEVER,[ht]:e.ALWAYS,[mt]:e.LESS,[K]:e.LEQUAL,[pt]:e.EQUAL,[ft]:e.GEQUAL,[ut]:e.GREATER,[dt]:e.NOTEQUAL};function O(t,r){if(r.type!==T||!1!==n.has("OES_texture_float_linear")||r.magFilter!==B&&r.magFilter!==st&&r.magFilter!==lt&&r.magFilter!==ot&&r.minFilter!==B&&r.minFilter!==st&&r.minFilter!==lt&&r.minFilter!==ot||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(t,e.TEXTURE_WRAP_S,I[r.wrapS]),e.texParameteri(t,e.TEXTURE_WRAP_T,I[r.wrapT]),t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY||e.texParameteri(t,e.TEXTURE_WRAP_R,I[r.wrapR]),e.texParameteri(t,e.TEXTURE_MAG_FILTER,y[r.magFilter]),e.texParameteri(t,e.TEXTURE_MIN_FILTER,y[r.minFilter]),r.compareFunction&&(e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,N[r.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic")){if(r.magFilter===Te)return;if(r.minFilter!==lt&&r.minFilter!==ot)return;if(r.type===T&&!1===n.has("OES_texture_float_linear"))return;if(r.anisotropy>1||i.get(r).__currentAnisotropy){const o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,a.getMaxAnisotropy())),i.get(r).__currentAnisotropy=r.anisotropy}}}function H(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",L));const i=n.source;let a=h.get(i);void 0===a&&(a={},h.set(i,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),a[o].usedTimes++;const i=a[t.__cacheKey];void 0!==i&&(a[t.__cacheKey].usedTimes--,0===i.usedTimes&&U(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return r}function G(e,t,n){return Math.floor(Math.floor(e/n)/t)}function V(t,n,s){let l=e.TEXTURE_2D;(n.isDataArrayTexture||n.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),n.isData3DTexture&&(l=e.TEXTURE_3D);const c=H(t,n),d=n.source;r.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);const u=i.get(d);if(d.version!==u.__version||!0===c){r.activeTexture(e.TEXTURE0+s);const t=p.getPrimaries(p.workingColorSpace),i=n.colorSpace===gt?null:p.getPrimaries(n.colorSpace),f=n.colorSpace===gt||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let m=v(n.image,!1,a.maxTextureSize);m=$(n,m);const h=o.convert(n.format,n.colorSpace),_=o.convert(n.type);let g,S=A(n.internalFormat,h,_,n.colorSpace,n.isVideoTexture);O(l,n);const T=n.mipmaps,R=!0!==n.isVideoTexture,L=void 0===u.__version||!0===c,P=d.dataReady,U=C(n,m);if(n.isDepthTexture)S=b(n.format===vt,n.type),L&&(R?r.texStorage2D(e.TEXTURE_2D,1,S,m.width,m.height):r.texImage2D(e.TEXTURE_2D,0,S,m.width,m.height,0,h,_,null));else if(n.isDataTexture)if(T.length>0){R&&L&&r.texStorage2D(e.TEXTURE_2D,U,S,T[0].width,T[0].height);for(let t=0,n=T.length;t<n;t++)g=T[t],R?P&&r.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,_,g.data):r.texImage2D(e.TEXTURE_2D,t,S,g.width,g.height,0,h,_,g.data);n.generateMipmaps=!1}else R?(L&&r.texStorage2D(e.TEXTURE_2D,U,S,m.width,m.height),P&&function(t,n,i,a){const o=t.updateRanges;if(0===o.length)r.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,i,a,n.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){const t=o[s],r=o[e],i=t.start+t.count,a=G(r.start,n.width,4),l=G(t.start,n.width,4);r.start<=i+1&&a===l&&G(r.start+r.count-1,n.width,4)===a?t.count=Math.max(t.count,r.start+r.count-t.start):(++s,o[s]=r)}o.length=s+1;const l=e.getParameter(e.UNPACK_ROW_LENGTH),c=e.getParameter(e.UNPACK_SKIP_PIXELS),d=e.getParameter(e.UNPACK_SKIP_ROWS);e.pixelStorei(e.UNPACK_ROW_LENGTH,n.width);for(let t=0,s=o.length;t<s;t++){const s=o[t],l=Math.floor(s.start/4),c=Math.ceil(s.count/4),d=l%n.width,u=Math.floor(l/n.width),f=c,p=1;e.pixelStorei(e.UNPACK_SKIP_PIXELS,d),e.pixelStorei(e.UNPACK_SKIP_ROWS,u),r.texSubImage2D(e.TEXTURE_2D,0,d,u,f,p,i,a,n.data)}t.clearUpdateRanges(),e.pixelStorei(e.UNPACK_ROW_LENGTH,l),e.pixelStorei(e.UNPACK_SKIP_PIXELS,c),e.pixelStorei(e.UNPACK_SKIP_ROWS,d)}}(n,m,h,_)):r.texImage2D(e.TEXTURE_2D,0,S,m.width,m.height,0,h,_,m.data);else if(n.isCompressedTexture)if(n.isCompressedArrayTexture){R&&L&&r.texStorage3D(e.TEXTURE_2D_ARRAY,U,S,T[0].width,T[0].height,m.depth);for(let t=0,i=T.length;t<i;t++)if(g=T[t],n.format!==M)if(null!==h)if(R){if(P)if(n.layerUpdates.size>0){const i=Et(g.width,g.height,n.format,n.type);for(const a of n.layerUpdates){const n=g.data.subarray(a*i/g.data.BYTES_PER_ELEMENT,(a+1)*i/g.data.BYTES_PER_ELEMENT);r.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,a,g.width,g.height,1,h,n)}n.clearLayerUpdates()}else r.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,m.depth,h,g.data)}else r.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,S,g.width,g.height,m.depth,0,g.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else R?P&&r.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,g.width,g.height,m.depth,h,_,g.data):r.texImage3D(e.TEXTURE_2D_ARRAY,t,S,g.width,g.height,m.depth,0,h,_,g.data)}else{R&&L&&r.texStorage2D(e.TEXTURE_2D,U,S,T[0].width,T[0].height);for(let t=0,i=T.length;t<i;t++)g=T[t],n.format!==M?null!==h?R?P&&r.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,g.data):r.compressedTexImage2D(e.TEXTURE_2D,t,S,g.width,g.height,0,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):R?P&&r.texSubImage2D(e.TEXTURE_2D,t,0,0,g.width,g.height,h,_,g.data):r.texImage2D(e.TEXTURE_2D,t,S,g.width,g.height,0,h,_,g.data)}else if(n.isDataArrayTexture)if(R){if(L&&r.texStorage3D(e.TEXTURE_2D_ARRAY,U,S,m.width,m.height,m.depth),P)if(n.layerUpdates.size>0){const t=Et(m.width,m.height,n.format,n.type);for(const i of n.layerUpdates){const n=m.data.subarray(i*t/m.data.BYTES_PER_ELEMENT,(i+1)*t/m.data.BYTES_PER_ELEMENT);r.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,m.width,m.height,1,h,_,n)}n.clearLayerUpdates()}else r.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,h,_,m.data)}else r.texImage3D(e.TEXTURE_2D_ARRAY,0,S,m.width,m.height,m.depth,0,h,_,m.data);else if(n.isData3DTexture)R?(L&&r.texStorage3D(e.TEXTURE_3D,U,S,m.width,m.height,m.depth),P&&r.texSubImage3D(e.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,h,_,m.data)):r.texImage3D(e.TEXTURE_3D,0,S,m.width,m.height,m.depth,0,h,_,m.data);else if(n.isFramebufferTexture){if(L)if(R)r.texStorage2D(e.TEXTURE_2D,U,S,m.width,m.height);else{let t=m.width,n=m.height;for(let i=0;i<U;i++)r.texImage2D(e.TEXTURE_2D,i,S,t,n,0,h,_,null),t>>=1,n>>=1}}else if(T.length>0){if(R&&L){const t=Q(T[0]);r.texStorage2D(e.TEXTURE_2D,U,S,t.width,t.height)}for(let t=0,n=T.length;t<n;t++)g=T[t],R?P&&r.texSubImage2D(e.TEXTURE_2D,t,0,0,h,_,g):r.texImage2D(e.TEXTURE_2D,t,S,h,_,g);n.generateMipmaps=!1}else if(R){if(L){const t=Q(m);r.texStorage2D(e.TEXTURE_2D,U,S,t.width,t.height)}P&&r.texSubImage2D(e.TEXTURE_2D,0,0,0,h,_,m)}else r.texImage2D(e.TEXTURE_2D,0,S,h,_,m);E(n)&&x(l),u.__version=d.version,n.onUpdate&&n.onUpdate(n)}t.__version=n.version}function z(t,n,a,s,c,d){const u=o.convert(a.format,a.colorSpace),f=o.convert(a.type),p=A(a.internalFormat,u,f,a.colorSpace),m=i.get(n),h=i.get(a);if(h.__renderTarget=n,!m.__hasExternalTextures){const t=Math.max(1,n.width>>d),i=Math.max(1,n.height>>d);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?r.texImage3D(c,d,p,t,i,n.depth,0,u,f,null):r.texImage2D(c,d,p,t,i,0,u,f,null)}r.bindFramebuffer(e.FRAMEBUFFER,t),Z(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,h.__webglTexture,0,j(n)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,h.__webglTexture,d),r.bindFramebuffer(e.FRAMEBUFFER,null)}function k(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=b(n.stencilBuffer,a),s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=j(n);Z(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i<t.length;i++){const a=t[i],s=o.convert(a.format,a.colorSpace),c=o.convert(a.type),d=A(a.internalFormat,s,c,a.colorSpace),u=j(n);r&&!1===Z(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,d,n.width,n.height):Z(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,d,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,d,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function W(t,n){if(n&&n.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(r.bindFramebuffer(e.FRAMEBUFFER,t),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(n.depthTexture);a.__renderTarget=n,a.__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),w(n.depthTexture,0);const o=a.__webglTexture,s=j(n);if(n.depthTexture.format===St)Z(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o,0);else{if(n.depthTexture.format!==vt)throw new Error("Unknown depthTexture format");Z(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0,s):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,o,0)}}function X(t){const n=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(n.__boundDepthTexture!==t.depthTexture){const e=t.depthTexture;if(n.__depthDisposeCallback&&n.__depthDisposeCallback(),e){const t=()=>{delete n.__boundDepthTexture,delete n.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),n.__depthDisposeCallback=t}n.__boundDepthTexture=e}if(t.depthTexture&&!n.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");const e=t.texture.mipmaps;e&&e.length>0?W(n.__webglFramebuffer[0],t):W(n.__webglFramebuffer,t)}else if(a){n.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(r.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[i]),void 0===n.__webglDepthbuffer[i])n.__webglDepthbuffer[i]=e.createRenderbuffer(),k(n.__webglDepthbuffer[i],t,!1);else{const r=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=n.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,r,e.RENDERBUFFER,a)}}else{const i=t.texture.mipmaps;if(i&&i.length>0?r.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[0]):r.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),void 0===n.__webglDepthbuffer)n.__webglDepthbuffer=e.createRenderbuffer(),k(n.__webglDepthbuffer,t,!1);else{const r=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=n.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,r,e.RENDERBUFFER,i)}}r.bindFramebuffer(e.FRAMEBUFFER,null)}const Y=[],q=[];function j(e){return Math.min(a.maxSamples,e.samples)}function Z(e){const t=i.get(e);return e.samples>0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==t.__useRenderToTexture}function $(e,t){const n=e.colorSpace,r=e.format,i=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==F&&n!==gt&&(p.getTransfer(n)===m?r===M&&i===S||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function Q(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(d.width=e.naturalWidth||e.width,d.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(d.width=e.displayWidth,d.height=e.displayHeight):(d.width=e.width,d.height=e.height),d}this.allocateTextureUnit=function(){const e=D;return e>=a.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),D+=1,e},this.resetTextureUnits=function(){D=0},this.setTexture2D=w,this.setTexture2DArray=function(t,n){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?V(a,t,n):r.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+n)},this.setTexture3D=function(t,n){const a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?V(a,t,n):r.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+n)},this.setTextureCube=function(t,n){const s=i.get(t);t.version>0&&s.__version!==t.version?function(t,n,s){if(6!==n.image.length)return;const l=H(t,n),c=n.source;r.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);const d=i.get(c);if(c.version!==d.__version||!0===l){r.activeTexture(e.TEXTURE0+s);const t=p.getPrimaries(p.workingColorSpace),i=n.colorSpace===gt?null:p.getPrimaries(n.colorSpace),u=n.colorSpace===gt||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const f=n.isCompressedTexture||n.image[0].isCompressedTexture,m=n.image[0]&&n.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=f||m?m?n.image[e].image:n.image[e]:v(n.image[e],!0,a.maxCubemapSize),h[e]=$(n,h[e]);const _=h[0],g=o.convert(n.format,n.colorSpace),S=o.convert(n.type),T=A(n.internalFormat,g,S,n.colorSpace),R=!0!==n.isVideoTexture,b=void 0===d.__version||!0===l,L=c.dataReady;let P,U=C(n,_);if(O(e.TEXTURE_CUBE_MAP,n),f){R&&b&&r.texStorage2D(e.TEXTURE_CUBE_MAP,U,T,_.width,_.height);for(let t=0;t<6;t++){P=h[t].mipmaps;for(let i=0;i<P.length;i++){const a=P[i];n.format!==M?null!==g?R?L&&r.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,g,a.data):r.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,T,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):R?L&&r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,0,0,a.width,a.height,g,S,a.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,i,T,a.width,a.height,0,g,S,a.data)}}}else{if(P=n.mipmaps,R&&b){P.length>0&&U++;const t=Q(h[0]);r.texStorage2D(e.TEXTURE_CUBE_MAP,U,T,t.width,t.height)}for(let t=0;t<6;t++)if(m){R?L&&r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,g,S,h[t].data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,h[t].width,h[t].height,0,g,S,h[t].data);for(let n=0;n<P.length;n++){const i=P[n].image[t].image;R?L&&r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,i.width,i.height,g,S,i.data):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,i.width,i.height,0,g,S,i.data)}}else{R?L&&r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,S,h[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,T,g,S,h[t]);for(let n=0;n<P.length;n++){const i=P[n];R?L&&r.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,g,S,i.image[t]):r.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,T,g,S,i.image[t])}}}E(n)&&x(e.TEXTURE_CUBE_MAP),d.__version=c.version,n.onUpdate&&n.onUpdate(n)}t.__version=n.version}(s,t,n):r.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+n)},this.rebindTextures=function(t,n,r){const a=i.get(t);void 0!==n&&z(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&X(t)},this.setupRenderTarget=function(t){const n=t.texture,a=i.get(t),l=i.get(n);t.addEventListener("dispose",P);const c=t.textures,d=!0===t.isWebGLCubeRenderTarget,u=c.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=n.version,s.memory.textures++),d){a.__webglFramebuffer=[];for(let t=0;t<6;t++)if(n.mipmaps&&n.mipmaps.length>0){a.__webglFramebuffer[t]=[];for(let r=0;r<n.mipmaps.length;r++)a.__webglFramebuffer[t][r]=e.createFramebuffer()}else a.__webglFramebuffer[t]=e.createFramebuffer()}else{if(n.mipmaps&&n.mipmaps.length>0){a.__webglFramebuffer=[];for(let t=0;t<n.mipmaps.length;t++)a.__webglFramebuffer[t]=e.createFramebuffer()}else a.__webglFramebuffer=e.createFramebuffer();if(u)for(let t=0,n=c.length;t<n;t++){const n=i.get(c[t]);void 0===n.__webglTexture&&(n.__webglTexture=e.createTexture(),s.memory.textures++)}if(t.samples>0&&!1===Z(t)){a.__webglMultisampledFramebuffer=e.createFramebuffer(),a.__webglColorRenderbuffer=[],r.bindFramebuffer(e.FRAMEBUFFER,a.__webglMultisampledFramebuffer);for(let n=0;n<c.length;n++){const r=c[n];a.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,a.__webglColorRenderbuffer[n]);const i=o.convert(r.format,r.colorSpace),s=o.convert(r.type),l=A(r.internalFormat,i,s,r.colorSpace,!0===t.isXRRenderTarget),d=j(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,d,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,a.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(a.__webglDepthRenderbuffer=e.createRenderbuffer(),k(a.__webglDepthRenderbuffer,t,!0)),r.bindFramebuffer(e.FRAMEBUFFER,null)}}if(d){r.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture),O(e.TEXTURE_CUBE_MAP,n);for(let r=0;r<6;r++)if(n.mipmaps&&n.mipmaps.length>0)for(let i=0;i<n.mipmaps.length;i++)z(a.__webglFramebuffer[r][i],t,n,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,i);else z(a.__webglFramebuffer[r],t,n,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0);E(n)&&x(e.TEXTURE_CUBE_MAP),r.unbindTexture()}else if(u){for(let n=0,o=c.length;n<o;n++){const o=c[n],s=i.get(o);let l=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),r.bindTexture(l,s.__webglTexture),O(l,o),z(a.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0+n,l,0),E(o)&&x(l)}r.unbindTexture()}else{let i=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(i=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),r.bindTexture(i,l.__webglTexture),O(i,n),n.mipmaps&&n.mipmaps.length>0)for(let r=0;r<n.mipmaps.length;r++)z(a.__webglFramebuffer[r],t,n,e.COLOR_ATTACHMENT0,i,r);else z(a.__webglFramebuffer,t,n,e.COLOR_ATTACHMENT0,i,0);E(n)&&x(i),r.unbindTexture()}t.depthBuffer&&X(t)},this.updateRenderTargetMipmap=function(e){const t=e.textures;for(let n=0,a=t.length;n<a;n++){const a=t[n];if(E(a)){const t=R(e),n=i.get(a).__webglTexture;r.bindTexture(t,n),x(t),r.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.samples>0)if(!1===Z(t)){const n=t.textures,a=t.width,o=t.height;let s=e.COLOR_BUFFER_BIT;const l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=i.get(t),u=n.length>1;if(u)for(let t=0;t<n.length;t++)r.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),r.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);r.bindFramebuffer(e.READ_FRAMEBUFFER,d.__webglMultisampledFramebuffer);const f=t.texture.mipmaps;f&&f.length>0?r.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer[0]):r.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let r=0;r<n.length;r++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),u){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,d.__webglColorRenderbuffer[r]);const t=i.get(n[r]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),!0===c&&(Y.length=0,q.length=0,Y.push(e.COLOR_ATTACHMENT0+r),t.depthBuffer&&!1===t.resolveDepthBuffer&&(Y.push(l),q.push(l),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,q)),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,Y))}if(r.bindFramebuffer(e.READ_FRAMEBUFFER,null),r.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<n.length;t++){r.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,d.__webglColorRenderbuffer[t]);const a=i.get(n[t]).__webglTexture;r.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}r.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&!1===t.resolveDepthBuffer&&c){const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}},this.setupDepthRenderbuffer=X,this.setupFrameBufferTexture=z,this.useMultisampledRTT=Z}function na(e,t){return{convert:function(n,r=gt){let i;const a=p.getTransfer(r);if(n===S)return e.UNSIGNED_BYTE;if(n===At)return e.UNSIGNED_SHORT_4_4_4_4;if(n===bt)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Ct)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===Lt)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===Pt)return e.BYTE;if(n===Ut)return e.SHORT;if(n===xt)return e.UNSIGNED_SHORT;if(n===v)return e.INT;if(n===Tt)return e.UNSIGNED_INT;if(n===T)return e.FLOAT;if(n===E)return e.HALF_FLOAT;if(n===Dt)return e.ALPHA;if(n===wt)return e.RGB;if(n===M)return e.RGBA;if(n===St)return e.DEPTH_COMPONENT;if(n===vt)return e.DEPTH_STENCIL;if(n===It)return e.RED;if(n===yt)return e.RED_INTEGER;if(n===Nt)return e.RG;if(n===Ot)return e.RG_INTEGER;if(n===Ft)return e.RGBA_INTEGER;if(n===Bt||n===Ht||n===Gt||n===Vt)if(a===m){if(i=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===i)return null;if(n===Bt)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ht)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Gt)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Vt)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(i=t.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(n===Bt)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ht)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Gt)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Vt)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===zt||n===kt||n===Wt||n===Xt){if(i=t.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(n===zt)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===kt)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Wt)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Xt)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Yt||n===Kt||n===qt){if(i=t.get("WEBGL_compressed_texture_etc"),null===i)return null;if(n===Yt||n===Kt)return a===m?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===qt)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}if(n===jt||n===Zt||n===$t||n===Qt||n===Jt||n===en||n===tn||n===nn||n===rn||n===an||n===on||n===sn||n===ln||n===cn){if(i=t.get("WEBGL_compressed_texture_astc"),null===i)return null;if(n===jt)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Zt)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===$t)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Qt)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Jt)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===en)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===tn)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===nn)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===rn)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===an)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===on)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===sn)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ln)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===cn)return a===m?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===dn||n===un||n===fn){if(i=t.get("EXT_texture_compression_bptc"),null===i)return null;if(n===dn)return a===m?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===un)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===fn)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===pn||n===mn||n===hn||n===_n){if(i=t.get("EXT_texture_compression_rgtc"),null===i)return null;if(n===pn)return i.COMPRESSED_RED_RGTC1_EXT;if(n===mn)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===hn)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===_n)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Mt?e.UNSIGNED_INT_24_8:void 0!==e[n]?e[n]:null}}}class ra{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){const n=new gn(e.texture);e.depthNear===t.depthNear&&e.depthFar===t.depthFar||(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new l({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new o(new h(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class ia extends vn{constructor(e,n){super();const r=this;let a=null,o=1,s=null,l="local-floor",c=1,d=null,u=null,f=null,p=null,m=null,h=null;const _="undefined"!=typeof XRWebGLBinding,g=new ra,v={},E=n.getContextAttributes();let T=null,x=null;const R=[],A=[],b=new t;let C=null;const L=new U;L.viewport=new k;const P=new U;P.viewport=new k;const D=[L,P],w=new En;let I=null,N=null;function O(e){const t=A.indexOf(e.inputSource);if(-1===t)return;const n=R[t];void 0!==n&&(n.update(e.inputSource,e.frame,d||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function F(){a.removeEventListener("select",O),a.removeEventListener("selectstart",O),a.removeEventListener("selectend",O),a.removeEventListener("squeeze",O),a.removeEventListener("squeezestart",O),a.removeEventListener("squeezeend",O),a.removeEventListener("end",F),a.removeEventListener("inputsourceschange",B);for(let e=0;e<R.length;e++){const t=A[e];null!==t&&(A[e]=null,R[e].disconnect(t))}I=null,N=null,g.reset();for(const e in v)delete v[e];e.setRenderTarget(T),m=null,p=null,f=null,a=null,x=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(C),e.setSize(b.width,b.height,!1),r.dispatchEvent({type:"sessionend"})}function B(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=A.indexOf(n);r>=0&&(A[r]=null,R[r].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=A.indexOf(n);if(-1===r){for(let e=0;e<R.length;e++){if(e>=A.length){A.push(n),r=e;break}if(null===A[e]){A[e]=n,r=e;break}}if(-1===r)break}const i=R[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=R[e];return void 0===t&&(t=new Sn,R[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=R[e];return void 0===t&&(t=new Sn,R[e]=t),t.getGripSpace()},this.getHand=function(e){let t=R[e];return void 0===t&&(t=new Sn,R[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){l=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||s},this.setReferenceSpace=function(e){d=e},this.getBaseLayer=function(){return null!==p?p:m},this.getBinding=function(){return null===f&&_&&(f=new XRWebGLBinding(a,n)),f},this.getFrame=function(){return h},this.getSession=function(){return a},this.setSession=async function(t){if(a=t,null!==a){T=e.getRenderTarget(),a.addEventListener("select",O),a.addEventListener("selectstart",O),a.addEventListener("selectend",O),a.addEventListener("squeeze",O),a.addEventListener("squeezestart",O),a.addEventListener("squeezeend",O),a.addEventListener("end",F),a.addEventListener("inputsourceschange",B),!0!==E.xrCompatible&&await n.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(b);if(_&&"createProjectionLayer"in XRWebGLBinding.prototype){let t=null,r=null,i=null;E.depth&&(i=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,t=E.stencil?vt:St,r=E.stencil?Mt:Tt);const s={colorFormat:n.RGBA8,depthFormat:i,scaleFactor:o};f=this.getBinding(),p=f.createProjectionLayer(s),a.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),x=new y(p.textureWidth,p.textureHeight,{format:M,type:S,depthTexture:new q(p.textureWidth,p.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,t),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:!1===p.ignoreDepthValues,resolveStencilBuffer:!1===p.ignoreDepthValues})}else{const t={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:o};m=new XRWebGLLayer(a,n,t),a.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new y(m.framebufferWidth,m.framebufferHeight,{format:M,type:S,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:!1===m.ignoreDepthValues,resolveStencilBuffer:!1===m.ignoreDepthValues})}x.isXRRenderTarget=!0,this.setFoveation(c),d=null,s=await a.requestReferenceSpace(l),W.setContext(a),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==a)return a.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};const H=new i,G=new i;function V(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===a)return;let t=e.near,n=e.far;null!==g.texture&&(g.depthNear>0&&(t=g.depthNear),g.depthFar>0&&(n=g.depthFar)),w.near=P.near=L.near=t,w.far=P.far=L.far=n,I===w.near&&N===w.far||(a.updateRenderState({depthNear:w.near,depthFar:w.far}),I=w.near,N=w.far),w.layers.mask=6|e.layers.mask,L.layers.mask=3&w.layers.mask,P.layers.mask=5&w.layers.mask;const r=e.parent,i=w.cameras;V(w,r);for(let e=0;e<i.length;e++)V(i[e],r);2===i.length?function(e,t,n){H.setFromMatrixPosition(t.matrixWorld),G.setFromMatrixPosition(n.matrixWorld);const r=H.distanceTo(G),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),l=(i[9]+1)/i[5],c=(i[9]-1)/i[5],d=(i[8]-1)/i[0],u=(a[8]+1)/a[0],f=o*d,p=o*u,m=r/(-d+u),h=m*-d;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===i[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{const t=o+m,n=s+m,i=f-h,a=p+(r-h),d=l*s/n*t,u=c*s/n*t;e.projectionMatrix.makePerspective(i,a,d,u,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(w,L,P):w.projectionMatrix.copy(L.projectionMatrix),function(e,t,n){null===n?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*Tn*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,w,r)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==p||null!==m)return c},this.setFoveation=function(e){c=e,null!==p&&(p.fixedFoveation=e),null!==m&&void 0!==m.fixedFoveation&&(m.fixedFoveation=e)},this.hasDepthSensing=function(){return null!==g.texture},this.getDepthSensingMesh=function(){return g.getMesh(w)},this.getCameraTexture=function(e){return v[e]};let z=null;const W=new Cn;W.setAnimationLoop(function(t,n){if(u=n.getViewerPose(d||s),h=n,null!==u){const t=u.views;null!==m&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let n=!1;t.length!==w.cameras.length&&(w.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let a=null;if(null!==m)a=m.getViewport(i);else{const t=f.getViewSubImage(p,i);a=t.viewport,0===r&&(e.setRenderTargetTextures(x,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(x))}let o=D[r];void 0===o&&(o=new U,o.layers.enable(r),o.viewport=new k,D[r]=o),o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(i.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&(w.matrix.copy(o.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===n&&w.cameras.push(o)}const i=a.enabledFeatures;if(i&&i.includes("depth-sensing")&&"gpu-optimized"==a.depthUsage&&_){f=r.getBinding();const e=f.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&g.init(e,a.renderState)}if(i&&i.includes("camera-access")&&_){e.state.unbindTexture(),f=r.getBinding();for(let e=0;e<t.length;e++){const n=t[e].camera;if(n){let e=v[n];e||(e=new gn,v[n]=e);const t=f.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<R.length;e++){const t=A[e],r=R[e];null!==t&&void 0!==r&&r.update(t,n,d||s)}z&&z(t,n),n.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:n}),h=null}),this.setAnimationLoop=function(e){z=e},this.dispose=function(){}}}const aa=new u,oa=new f;function sa(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function r(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===c&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===c&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);const i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,aa.copy(o),aa.x*=-1,aa.y*=-1,aa.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(aa.y*=-1,aa.z*=-1),e.envMapRotation.value.setFromMatrix4(oa.makeRotationFromEuler(aa)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,g(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,a,o,s){i.isMeshBasicMaterial||i.isMeshLambertMaterial?r(e,i):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(r(e,i),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform));e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform));t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===c&&e.clearcoatNormalScale.value.negate()));t.dispersion>0&&(e.dispersion.value=t.dispersion);t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,s)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){const r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,a,o):i.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function la(e,t,n,r){let i={},a={},o=[];const s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,r){const i=e.value,a=t+"_"+n;if(void 0===r[a])return r[a]="number"==typeof i||"boolean"==typeof i?i:i.clone(),!0;{const e=r[a];if("number"==typeof i||"boolean"==typeof i){if(e!==i)return r[a]=i,!0}else if(!1===e.equals(i))return e.copy(i),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function d(t){const n=t.target;n.removeEventListener("dispose",d);const r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,u){let f=i[n.id];void 0===f&&(!function(e){const t=e.uniforms;let n=0;const r=16;for(let e=0,i=t.length;e<i;e++){const i=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=i.length;e<t;e++){const t=i[e],a=Array.isArray(t.value)?t.value:[t.value];for(let e=0,i=a.length;e<i;e++){const i=c(a[e]),o=n%r,s=o%i.boundary,l=o+s;n+=s,0!==l&&r-l<i.storage&&(n+=r-l),t.__data=new Float32Array(i.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=i.storage}}}const i=n%r;i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),f=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===o.indexOf(e))return o.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}(n),i[n.id]=f,n.addEventListener("dispose",d));const p=u.program;r.updateUBOMapping(n,p);const m=t.render.frame;a[n.id]!==m&&(!function(t){const n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){const n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){const i=n[r];if(!0===l(i,t,r,a)){const t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value];let r=0;for(let a=0;a<n.length;a++){const o=n[a],s=c(o);"number"==typeof o||"boolean"==typeof o?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(n),a[n.id]=m)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}}}class ca{constructor(e={}){const{canvas:t=Mn(),context:r=null,depth:a=!0,stencil:o=!1,alpha:s=!1,antialias:l=!1,premultipliedAlpha:d=!0,preserveDrawingBuffer:u=!1,powerPreference:m="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:g=!1}=e;let v;if(this.isWebGLRenderer=!0,null!==r){if("undefined"!=typeof WebGLRenderingContext&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=r.getContextAttributes().alpha}else v=s;const T=new Uint32Array(4),M=new Int32Array(4);let x=null,R=null;const A=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=D,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let L=!1;this._outputColorSpace=xn;let P=0,U=0,w=null,I=-1,N=null;const O=new k,B=new k;let G=null;const V=new n(0);let z=0,W=t.width,X=t.height,Y=1,K=null,q=null;const j=new k(0,0,W,X),Z=new k(0,0,W,X);let $=!1;const Q=new ge;let J=!1,ee=!1;const te=new f,ne=new i,re=new k,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ae=!1;function oe(){return null===w?Y:1}let se,le,ce,de,ue,pe,me,he,_e,ve,Ee,Se,Te,Me,xe,Re,Ae,be,Ce,Le,Pe,Ue,De,we,Ie=r;function ye(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:a,stencil:o,antialias:l,premultipliedAlpha:d,preserveDrawingBuffer:u,powerPreference:m,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Rn}`),t.addEventListener("webglcontextlost",Fe,!1),t.addEventListener("webglcontextrestored",Be,!1),t.addEventListener("webglcontextcreationerror",He,!1),null===Ie){const t="webgl2";if(Ie=ye(t,e),null===Ie)throw ye(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ne(){se=new or(Ie),se.init(),Ue=new na(Ie,se),le=new Bn(Ie,se,e,Ue),ce=new ea(Ie,se),le.reversedDepthBuffer&&g&&ce.buffers.depth.setReversed(!0),de=new cr(Ie),ue=new Vi,pe=new ta(Ie,se,ce,ue,le,Ue,de),me=new Gn(C),he=new ar(C),_e=new Ln(Ie),De=new On(Ie,_e),ve=new sr(Ie,_e,de,De),Ee=new ur(Ie,ve,_e,de),Ce=new dr(Ie,le,pe),Re=new Hn(ue),Se=new Gi(C,me,he,se,le,De,Re),Te=new sa(C,ue),Me=new Xi,xe=new $i(se),be=new Nn(C,me,he,ce,Ee,v,d),Ae=new Qi(C,Ee,le),we=new la(Ie,de,le,ce),Le=new Fn(Ie,se,de),Pe=new lr(Ie,se,de),de.programs=Se.programs,C.capabilities=le,C.extensions=se,C.properties=ue,C.renderLists=Me,C.shadowMap=Ae,C.state=ce,C.info=de}Ne();const Oe=new ia(C,Ie);function Fe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function Be(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;const e=de.autoReset,t=Ae.enabled,n=Ae.autoUpdate,r=Ae.needsUpdate,i=Ae.type;Ne(),de.autoReset=e,Ae.enabled=t,Ae.autoUpdate=n,Ae.needsUpdate=r,Ae.type=i}function He(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Ge(e){const t=e.target;t.removeEventListener("dispose",Ge),function(e){(function(e){const t=ue.get(e).programs;void 0!==t&&(t.forEach(function(e){Se.releaseProgram(e)}),e.isShaderMaterial&&Se.releaseShaderCache(e))})(e),ue.remove(e)}(t)}function Ve(e,t,n){!0===e.transparent&&e.side===fe&&!1===e.forceSinglePass?(e.side=c,e.needsUpdate=!0,$e(e,t,n),e.side=_,e.needsUpdate=!0,$e(e,t,n),e.side=fe):$e(e,t,n)}this.xr=Oe,this.getContext=function(){return Ie},this.getContextAttributes=function(){return Ie.getContextAttributes()},this.forceContextLoss=function(){const e=se.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=se.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return Y},this.setPixelRatio=function(e){void 0!==e&&(Y=e,this.setSize(W,X,!1))},this.getSize=function(e){return e.set(W,X)},this.setSize=function(e,n,r=!0){Oe.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(W=e,X=n,t.width=Math.floor(e*Y),t.height=Math.floor(n*Y),!0===r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(W*Y,X*Y).floor()},this.setDrawingBufferSize=function(e,n,r){W=e,X=n,Y=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(j)},this.setViewport=function(e,t,n,r){e.isVector4?j.set(e.x,e.y,e.z,e.w):j.set(e,t,n,r),ce.viewport(O.copy(j).multiplyScalar(Y).round())},this.getScissor=function(e){return e.copy(Z)},this.setScissor=function(e,t,n,r){e.isVector4?Z.set(e.x,e.y,e.z,e.w):Z.set(e,t,n,r),ce.scissor(B.copy(Z).multiplyScalar(Y).round())},this.getScissorTest=function(){return $},this.setScissorTest=function(e){ce.setScissorTest($=e)},this.setOpaqueSort=function(e){K=e},this.setTransparentSort=function(e){q=e},this.getClearColor=function(e){return e.copy(be.getClearColor())},this.setClearColor=function(){be.setClearColor(...arguments)},this.getClearAlpha=function(){return be.getClearAlpha()},this.setClearAlpha=function(){be.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(null!==w){const t=w.texture.format;e=t===Ft||t===Ot||t===yt}if(e){const e=w.texture.type,t=e===S||e===Tt||e===xt||e===Mt||e===At||e===bt,n=be.getClearColor(),r=be.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(T[0]=i,T[1]=a,T[2]=o,T[3]=r,Ie.clearBufferuiv(Ie.COLOR,0,T)):(M[0]=i,M[1]=a,M[2]=o,M[3]=r,Ie.clearBufferiv(Ie.COLOR,0,M))}else r|=Ie.COLOR_BUFFER_BIT}t&&(r|=Ie.DEPTH_BUFFER_BIT),n&&(r|=Ie.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Ie.clear(r)},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(){t.removeEventListener("webglcontextlost",Fe,!1),t.removeEventListener("webglcontextrestored",Be,!1),t.removeEventListener("webglcontextcreationerror",He,!1),be.dispose(),Me.dispose(),xe.dispose(),ue.dispose(),me.dispose(),he.dispose(),Ee.dispose(),De.dispose(),we.dispose(),Se.dispose(),Oe.dispose(),Oe.removeEventListener("sessionstart",ke),Oe.removeEventListener("sessionend",We),Xe.stop()},this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=ie);const o=i.isMesh&&i.matrixWorld.determinant()<0,s=function(e,t,n,r,i){!0!==t.isScene&&(t=ie);pe.resetTextureUnits();const a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=null===w?C.outputColorSpace:!0===w.isXRRenderTarget?w.texture.colorSpace:F,l=(r.isMeshStandardMaterial?he:me).get(r.envMap||o),c=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),u=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let m=D;r.toneMapped&&(null!==w&&!0!==w.isXRRenderTarget||(m=C.toneMapping));const h=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==h?h.length:0,g=ue.get(r),v=R.state.lights;if(!0===J&&(!0===ee||e!==N)){const t=e===N&&r.id===I;Re.setState(r,e,t)}let E=!1;r.version===g.__version?g.needsLights&&g.lightsStateVersion!==v.state.version||g.outputColorSpace!==s||i.isBatchedMesh&&!1===g.batching?E=!0:i.isBatchedMesh||!0!==g.batching?i.isBatchedMesh&&!0===g.batchingColor&&null===i.colorTexture||i.isBatchedMesh&&!1===g.batchingColor&&null!==i.colorTexture||i.isInstancedMesh&&!1===g.instancing?E=!0:i.isInstancedMesh||!0!==g.instancing?i.isSkinnedMesh&&!1===g.skinning?E=!0:i.isSkinnedMesh||!0!==g.skinning?i.isInstancedMesh&&!0===g.instancingColor&&null===i.instanceColor||i.isInstancedMesh&&!1===g.instancingColor&&null!==i.instanceColor||i.isInstancedMesh&&!0===g.instancingMorph&&null===i.morphTexture||i.isInstancedMesh&&!1===g.instancingMorph&&null!==i.morphTexture||g.envMap!==l||!0===r.fog&&g.fog!==a?E=!0:void 0===g.numClippingPlanes||g.numClippingPlanes===Re.numPlanes&&g.numIntersection===Re.numIntersection?(g.vertexAlphas!==c||g.vertexTangents!==d||g.morphTargets!==u||g.morphNormals!==f||g.morphColors!==p||g.toneMapping!==m||g.morphTargetsCount!==_)&&(E=!0):E=!0:E=!0:E=!0:E=!0:(E=!0,g.__version=r.version);let S=g.currentProgram;!0===E&&(S=$e(r,t,i));let T=!1,M=!1,x=!1;const A=S.getUniforms(),b=g.uniforms;ce.useProgram(S.program)&&(T=!0,M=!0,x=!0);r.id!==I&&(I=r.id,M=!0);if(T||N!==e){ce.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(Ie,"projectionMatrix",e.projectionMatrix),A.setValue(Ie,"viewMatrix",e.matrixWorldInverse);const t=A.map.cameraPosition;void 0!==t&&t.setValue(Ie,ne.setFromMatrixPosition(e.matrixWorld)),le.logarithmicDepthBuffer&&A.setValue(Ie,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&A.setValue(Ie,"isOrthographic",!0===e.isOrthographicCamera),N!==e&&(N=e,M=!0,x=!0)}if(i.isSkinnedMesh){A.setOptional(Ie,i,"bindMatrix"),A.setOptional(Ie,i,"bindMatrixInverse");const e=i.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(Ie,"boneTexture",e.boneTexture,pe))}i.isBatchedMesh&&(A.setOptional(Ie,i,"batchingTexture"),A.setValue(Ie,"batchingTexture",i._matricesTexture,pe),A.setOptional(Ie,i,"batchingIdTexture"),A.setValue(Ie,"batchingIdTexture",i._indirectTexture,pe),A.setOptional(Ie,i,"batchingColorTexture"),null!==i._colorsTexture&&A.setValue(Ie,"batchingColorTexture",i._colorsTexture,pe));const L=n.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||Ce.update(i,n,S);(M||g.receiveShadow!==i.receiveShadow)&&(g.receiveShadow=i.receiveShadow,A.setValue(Ie,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(b.envMap.value=l,b.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);r.isMeshStandardMaterial&&null===r.envMap&&null!==t.environment&&(b.envMapIntensity.value=t.environmentIntensity);M&&(A.setValue(Ie,"toneMappingExposure",C.toneMappingExposure),g.needsLights&&(U=x,(P=b).ambientLightColor.needsUpdate=U,P.lightProbe.needsUpdate=U,P.directionalLights.needsUpdate=U,P.directionalLightShadows.needsUpdate=U,P.pointLights.needsUpdate=U,P.pointLightShadows.needsUpdate=U,P.spotLights.needsUpdate=U,P.spotLightShadows.needsUpdate=U,P.rectAreaLights.needsUpdate=U,P.hemisphereLights.needsUpdate=U),a&&!0===r.fog&&Te.refreshFogUniforms(b,a),Te.refreshMaterialUniforms(b,r,Y,X,R.state.transmissionRenderTarget[e.id]),_i.upload(Ie,Qe(g),b,pe));var P,U;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(_i.upload(Ie,Qe(g),b,pe),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&A.setValue(Ie,"center",i.center);if(A.setValue(Ie,"modelViewMatrix",i.modelViewMatrix),A.setValue(Ie,"normalMatrix",i.normalMatrix),A.setValue(Ie,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){const n=e[t];we.update(n,S),we.bind(n,S)}}return S}(e,t,n,r,i);ce.setMaterial(r,o);let l=n.index,c=1;if(!0===r.wireframe){if(l=ve.getWireframeAttribute(n),void 0===l)return;c=2}const d=n.drawRange,u=n.attributes.position;let f=d.start*c,p=(d.start+d.count)*c;null!==a&&(f=Math.max(f,a.start*c),p=Math.min(p,(a.start+a.count)*c)),null!==l?(f=Math.max(f,0),p=Math.min(p,l.count)):null!=u&&(f=Math.max(f,0),p=Math.min(p,u.count));const m=p-f;if(m<0||m===1/0)return;let h;De.setup(i,r,s,n,l);let _=Le;if(null!==l&&(h=_e.get(l),_=Pe,_.setIndex(h)),i.isMesh)!0===r.wireframe?(ce.setLineWidth(r.wireframeLinewidth*oe()),_.setMode(Ie.LINES)):_.setMode(Ie.TRIANGLES);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),ce.setLineWidth(e*oe()),i.isLineSegments?_.setMode(Ie.LINES):i.isLineLoop?_.setMode(Ie.LINE_LOOP):_.setMode(Ie.LINE_STRIP)}else i.isPoints?_.setMode(Ie.POINTS):i.isSprite&&_.setMode(Ie.TRIANGLES);if(i.isBatchedMesh)if(null!==i._multiDrawInstances)H("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),_.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(se.get("WEBGL_multi_draw"))_.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{const e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=l?_e.get(l).bytesPerElement:1,o=ue.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(Ie,"_gl_DrawID",r),_.render(e[r]/a,t[r])}else if(i.isInstancedMesh)_.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);_.renderInstances(f,m,t)}else _.render(f,m)},this.compile=function(e,t,n=null){null===n&&(n=e),R=xe.get(n),R.init(t),b.push(R),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(R.pushLight(e),e.castShadow&&R.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(R.pushLight(e),e.castShadow&&R.pushShadow(e))}),R.setupLights();const r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){const a=t[i];Ve(a,n,e),r.add(a)}else Ve(t,n,e),r.add(t)}),R=b.pop(),r},this.compileAsync=function(e,t,n=null){const r=this.compile(e,t,n);return new Promise(t=>{function n(){r.forEach(function(e){ue.get(e).currentProgram.isReady()&&r.delete(e)}),0!==r.size?setTimeout(n,10):t(e)}null!==se.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)})};let ze=null;function ke(){Xe.stop()}function We(){Xe.start()}const Xe=new Cn;function Ye(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)R.pushLight(e),e.castShadow&&R.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Q.intersectsSprite(e)){r&&re.setFromMatrixPosition(e.matrixWorld).applyMatrix4(te);const t=Ee.update(e),i=e.material;i.visible&&x.push(e,t,i,n,re.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||Q.intersectsObject(e))){const t=Ee.update(e),i=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),re.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),re.copy(t.boundingSphere.center)),re.applyMatrix4(e.matrixWorld).applyMatrix4(te)),Array.isArray(i)){const r=t.groups;for(let a=0,o=r.length;a<o;a++){const o=r[a],s=i[o.materialIndex];s&&s.visible&&x.push(e,t,s,n,re.z,o)}}else i.visible&&x.push(e,t,i,n,re.z,null)}const i=e.children;for(let e=0,a=i.length;e<a;e++)Ye(i[e],t,n,r)}function Ke(e,t,n,r){const i=e.opaque,a=e.transmissive,o=e.transparent;R.setupLightsView(n),!0===J&&Re.setGlobalState(C.clippingPlanes,n),r&&ce.viewport(O.copy(r)),i.length>0&&je(i,t,n),a.length>0&&je(a,t,n),o.length>0&&je(o,t,n),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function qe(e,t,n,r){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===R.state.transmissionRenderTarget[r.id]&&(R.state.transmissionRenderTarget[r.id]=new y(1,1,{generateMipmaps:!0,type:se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float")?E:S,minFilter:ot,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:p.workingColorSpace}));const i=R.state.transmissionRenderTarget[r.id],a=r.viewport||O;i.setSize(a.z*C.transmissionResolutionScale,a.w*C.transmissionResolutionScale);const s=C.getRenderTarget(),l=C.getActiveCubeFace(),d=C.getActiveMipmapLevel();C.setRenderTarget(i),C.getClearColor(V),z=C.getClearAlpha(),z<1&&C.setClearColor(16777215,.5),C.clear(),ae&&be.render(n);const u=C.toneMapping;C.toneMapping=D;const f=r.viewport;if(void 0!==r.viewport&&(r.viewport=void 0),R.setupLightsView(r),!0===J&&Re.setGlobalState(C.clippingPlanes,r),je(e,n,r),pe.updateMultisampleRenderTarget(i),pe.updateRenderTargetMipmap(i),!1===se.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let i=0,a=t.length;i<a;i++){const a=t[i],o=a.object,s=a.geometry,l=a.material,d=a.group;if(l.side===fe&&o.layers.test(r.layers)){const t=l.side;l.side=c,l.needsUpdate=!0,Ze(o,n,r,s,l,d),l.side=t,l.needsUpdate=!0,e=!0}}!0===e&&(pe.updateMultisampleRenderTarget(i),pe.updateRenderTargetMipmap(i))}C.setRenderTarget(s,l,d),C.setClearColor(V,z),void 0!==f&&(r.viewport=f),C.toneMapping=u}function je(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){const a=e[i],o=a.object,s=a.geometry,l=a.group;let c=a.material;!0===c.allowOverride&&null!==r&&(c=r),o.layers.test(n.layers)&&Ze(o,t,n,s,c,l)}}function Ze(e,t,n,r,i,a){e.onBeforeRender(C,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(C,t,n,r,e,a),!0===i.transparent&&i.side===fe&&!1===i.forceSinglePass?(i.side=c,i.needsUpdate=!0,C.renderBufferDirect(n,t,r,i,e,a),i.side=_,i.needsUpdate=!0,C.renderBufferDirect(n,t,r,i,e,a),i.side=fe):C.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(C,t,n,r,i,a)}function $e(e,t,n){!0!==t.isScene&&(t=ie);const r=ue.get(e),i=R.state.lights,a=R.state.shadowsArray,o=i.state.version,s=Se.getParameters(e,i.state,a,t,n),l=Se.getProgramCacheKey(s);let c=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?he:me).get(e.envMap||r.environment),r.envMapRotation=null!==r.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation,void 0===c&&(e.addEventListener("dispose",Ge),c=new Map,r.programs=c);let d=c.get(l);if(void 0!==d){if(r.currentProgram===d&&r.lightsStateVersion===o)return Je(e,s),d}else s.uniforms=Se.getUniforms(e),e.onBeforeCompile(s,C),d=Se.acquireProgram(s,l),c.set(l,d),r.uniforms=s.uniforms;const u=r.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=Re.uniform),Je(e,s),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=o,r.needsLights&&(u.ambientLightColor.value=i.state.ambient,u.lightProbe.value=i.state.probe,u.directionalLights.value=i.state.directional,u.directionalLightShadows.value=i.state.directionalShadow,u.spotLights.value=i.state.spot,u.spotLightShadows.value=i.state.spotShadow,u.rectAreaLights.value=i.state.rectArea,u.ltc_1.value=i.state.rectAreaLTC1,u.ltc_2.value=i.state.rectAreaLTC2,u.pointLights.value=i.state.point,u.pointLightShadows.value=i.state.pointShadow,u.hemisphereLights.value=i.state.hemi,u.directionalShadowMap.value=i.state.directionalShadowMap,u.directionalShadowMatrix.value=i.state.directionalShadowMatrix,u.spotShadowMap.value=i.state.spotShadowMap,u.spotLightMatrix.value=i.state.spotLightMatrix,u.spotLightMap.value=i.state.spotLightMap,u.pointShadowMap.value=i.state.pointShadowMap,u.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=d,r.uniformsList=null,d}function Qe(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=_i.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Je(e,t){const n=ue.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Xe.setAnimationLoop(function(e){ze&&ze(e)}),"undefined"!=typeof self&&Xe.setContext(self),this.setAnimationLoop=function(e){ze=e,Oe.setAnimationLoop(e),null===e?Xe.stop():Xe.start()},Oe.addEventListener("sessionstart",ke),Oe.addEventListener("sessionend",We),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===L)return;if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Oe.enabled&&!0===Oe.isPresenting&&(!0===Oe.cameraAutoUpdate&&Oe.updateCamera(t),t=Oe.getCamera()),!0===e.isScene&&e.onBeforeRender(C,e,t,w),R=xe.get(e,b.length),R.init(t),b.push(R),te.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Q.setFromProjectionMatrix(te,An,t.reversedDepth),ee=this.localClippingEnabled,J=Re.init(this.clippingPlanes,ee),x=Me.get(e,A.length),x.init(),A.push(x),!0===Oe.enabled&&!0===Oe.isPresenting){const e=C.xr.getDepthSensingMesh();null!==e&&Ye(e,t,-1/0,C.sortObjects)}Ye(e,t,0,C.sortObjects),x.finish(),!0===C.sortObjects&&x.sort(K,q),ae=!1===Oe.enabled||!1===Oe.isPresenting||!1===Oe.hasDepthSensing(),ae&&be.addToRenderList(x,e),this.info.render.frame++,!0===J&&Re.beginShadows();const n=R.state.shadowsArray;Ae.render(n,e,t),!0===J&&Re.endShadows(),!0===this.info.autoReset&&this.info.reset();const r=x.opaque,i=x.transmissive;if(R.setupLights(),t.isArrayCamera){const n=t.cameras;if(i.length>0)for(let t=0,a=n.length;t<a;t++){qe(r,i,e,n[t])}ae&&be.render(e);for(let t=0,r=n.length;t<r;t++){const r=n[t];Ke(x,e,r,r.viewport)}}else i.length>0&&qe(r,i,e,t),ae&&be.render(e),Ke(x,e,t);null!==w&&0===U&&(pe.updateMultisampleRenderTarget(w),pe.updateRenderTargetMipmap(w)),!0===e.isScene&&e.onAfterRender(C,e,t),De.resetDefaultState(),I=-1,N=null,b.pop(),b.length>0?(R=b[b.length-1],!0===J&&Re.setGlobalState(C.clippingPlanes,R.state.camera)):R=null,A.pop(),x=A.length>0?A[A.length-1]:null},this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return U},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){const r=ue.get(e);r.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===r.__autoAllocateDepthBuffer&&(r.__useRenderToTexture=!1),ue.get(e.texture).__webglTexture=t,ue.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){const n=ue.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const et=Ie.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){w=e,P=t,U=n;let r=!0,i=null,a=!1,o=!1;if(e){const s=ue.get(e);if(void 0!==s.__useDefaultFramebuffer)ce.bindFramebuffer(Ie.FRAMEBUFFER,null),r=!1;else if(void 0===s.__webglFramebuffer)pe.setupRenderTarget(e);else if(s.__hasExternalTextures)pe.rebindTextures(e,ue.get(e.texture).__webglTexture,ue.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(s.__boundDepthTexture!==t){if(null!==t&&ue.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");pe.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(o=!0);const c=ue.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(c[t])?c[t][n]:c[t],a=!0):i=e.samples>0&&!1===pe.useMultisampledRTT(e)?ue.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,O.copy(e.viewport),B.copy(e.scissor),G=e.scissorTest}else O.copy(j).multiplyScalar(Y).floor(),B.copy(Z).multiplyScalar(Y).floor(),G=$;0!==n&&(i=et);if(ce.bindFramebuffer(Ie.FRAMEBUFFER,i)&&r&&ce.drawBuffers(e,i),ce.viewport(O),ce.scissor(B),ce.setScissorTest(G),a){const r=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){const r=t;for(let t=0;t<e.textures.length;t++){const i=ue.get(e.textures[t]);Ie.framebufferTextureLayer(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(null!==e&&0!==n){const t=ue.get(e.texture);Ie.framebufferTexture2D(Ie.FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,t.__webglTexture,n)}I=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);try{const o=e.textures[s],l=o.format,c=o.type;if(!le.textureFormatReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&(e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),Ie.readPixels(t,n,r,i,Ue.convert(l),Ue.convert(c),a))}finally{const e=null!==w?ue.get(w).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ue.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){ce.bindFramebuffer(Ie.FRAMEBUFFER,l);const o=e.textures[s],c=o.format,d=o.type;if(!le.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=Ie.createBuffer();Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.bufferData(Ie.PIXEL_PACK_BUFFER,a.byteLength,Ie.STREAM_READ),e.textures.length>1&&Ie.readBuffer(Ie.COLOR_ATTACHMENT0+s),Ie.readPixels(t,n,r,i,Ue.convert(c),Ue.convert(d),0);const f=null!==w?ue.get(w).__webglFramebuffer:null;ce.bindFramebuffer(Ie.FRAMEBUFFER,f);const p=Ie.fenceSync(Ie.SYNC_GPU_COMMANDS_COMPLETE,0);return Ie.flush(),await bn(Ie,p,4),Ie.bindBuffer(Ie.PIXEL_PACK_BUFFER,u),Ie.getBufferSubData(Ie.PIXEL_PACK_BUFFER,0,a),Ie.deleteBuffer(u),Ie.deleteSync(p),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=null!==t?t.x:0,s=null!==t?t.y:0;pe.setTexture2D(e,0),Ie.copyTexSubImage2D(Ie.TEXTURE_2D,n,0,0,o,s,i,a),ce.unbindTexture()};const tt=Ie.createFramebuffer(),nt=Ie.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=null){let o,s,l,c,d,u,f,p,m;null===a&&(0!==i?(H("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),a=i,i=0):a=0);const h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)o=n.max.x-n.min.x,s=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,d=n.min.y,u=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-i);o=Math.floor(h.width*t),s=Math.floor(h.height*t),l=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,c=0,d=0,u=0}null!==r?(f=r.x,p=r.y,m=r.z):(f=0,p=0,m=0);const _=Ue.convert(t.format),g=Ue.convert(t.type);let v;t.isData3DTexture?(pe.setTexture3D(t,0),v=Ie.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(pe.setTexture2DArray(t,0),v=Ie.TEXTURE_2D_ARRAY):(pe.setTexture2D(t,0),v=Ie.TEXTURE_2D),Ie.pixelStorei(Ie.UNPACK_FLIP_Y_WEBGL,t.flipY),Ie.pixelStorei(Ie.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),Ie.pixelStorei(Ie.UNPACK_ALIGNMENT,t.unpackAlignment);const E=Ie.getParameter(Ie.UNPACK_ROW_LENGTH),S=Ie.getParameter(Ie.UNPACK_IMAGE_HEIGHT),T=Ie.getParameter(Ie.UNPACK_SKIP_PIXELS),M=Ie.getParameter(Ie.UNPACK_SKIP_ROWS),x=Ie.getParameter(Ie.UNPACK_SKIP_IMAGES);Ie.pixelStorei(Ie.UNPACK_ROW_LENGTH,h.width),Ie.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,h.height),Ie.pixelStorei(Ie.UNPACK_SKIP_PIXELS,c),Ie.pixelStorei(Ie.UNPACK_SKIP_ROWS,d),Ie.pixelStorei(Ie.UNPACK_SKIP_IMAGES,u);const R=e.isDataArrayTexture||e.isData3DTexture,A=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=ue.get(e),r=ue.get(t),h=ue.get(n.__renderTarget),_=ue.get(r.__renderTarget);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,h.__webglFramebuffer),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,_.__webglFramebuffer);for(let n=0;n<l;n++)R&&(Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(e).__webglTexture,i,u+n),Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,ue.get(t).__webglTexture,a,m+n)),Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.DEPTH_BUFFER_BIT,Ie.NEAREST);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else if(0!==i||e.isRenderTargetTexture||ue.has(e)){const n=ue.get(e),r=ue.get(t);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,tt),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,nt);for(let e=0;e<l;e++)R?Ie.framebufferTextureLayer(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,n.__webglTexture,i,u+e):Ie.framebufferTexture2D(Ie.READ_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,n.__webglTexture,i),A?Ie.framebufferTextureLayer(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):Ie.framebufferTexture2D(Ie.DRAW_FRAMEBUFFER,Ie.COLOR_ATTACHMENT0,Ie.TEXTURE_2D,r.__webglTexture,a),0!==i?Ie.blitFramebuffer(c,d,o,s,f,p,o,s,Ie.COLOR_BUFFER_BIT,Ie.NEAREST):A?Ie.copyTexSubImage3D(v,a,f,p,m+e,c,d,o,s):Ie.copyTexSubImage2D(v,a,f,p,c,d,o,s);ce.bindFramebuffer(Ie.READ_FRAMEBUFFER,null),ce.bindFramebuffer(Ie.DRAW_FRAMEBUFFER,null)}else A?e.isDataTexture||e.isData3DTexture?Ie.texSubImage3D(v,a,f,p,m,o,s,l,_,g,h.data):t.isCompressedArrayTexture?Ie.compressedTexSubImage3D(v,a,f,p,m,o,s,l,_,h.data):Ie.texSubImage3D(v,a,f,p,m,o,s,l,_,g,h):e.isDataTexture?Ie.texSubImage2D(Ie.TEXTURE_2D,a,f,p,o,s,_,g,h.data):e.isCompressedTexture?Ie.compressedTexSubImage2D(Ie.TEXTURE_2D,a,f,p,h.width,h.height,_,h.data):Ie.texSubImage2D(Ie.TEXTURE_2D,a,f,p,o,s,_,g,h);Ie.pixelStorei(Ie.UNPACK_ROW_LENGTH,E),Ie.pixelStorei(Ie.UNPACK_IMAGE_HEIGHT,S),Ie.pixelStorei(Ie.UNPACK_SKIP_PIXELS,T),Ie.pixelStorei(Ie.UNPACK_SKIP_ROWS,M),Ie.pixelStorei(Ie.UNPACK_SKIP_IMAGES,x),0===a&&t.generateMipmaps&&Ie.generateMipmap(v),ce.unbindTexture()},this.initRenderTarget=function(e){void 0===ue.get(e).__webglFramebuffer&&pe.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?pe.setTextureCube(e,0):e.isData3DTexture?pe.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?pe.setTexture2DArray(e,0):pe.setTexture2D(e,0),ce.unbindTexture()},this.resetState=function(){P=0,U=0,w=null,ce.reset(),De.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return An}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=p._getDrawingBufferColorSpace(e),t.unpackColorSpace=p._getUnpackColorSpace()}}
|
|
651
|
+
|
|
652
|
+
return {
|
|
653
|
+
"ACESFilmicToneMapping": re,
|
|
654
|
+
"AddEquation": Ae,
|
|
655
|
+
"AddOperation": le,
|
|
656
|
+
"AdditiveBlending": et,
|
|
657
|
+
"AgXToneMapping": ne,
|
|
658
|
+
"AlphaFormat": Dt,
|
|
659
|
+
"AlwaysCompare": ht,
|
|
660
|
+
"AlwaysDepth": Ye,
|
|
661
|
+
"ArrayCamera": En,
|
|
662
|
+
"BackSide": c,
|
|
663
|
+
"BoxGeometry": s,
|
|
664
|
+
"BufferAttribute": O,
|
|
665
|
+
"BufferGeometry": N,
|
|
666
|
+
"ByteType": Pt,
|
|
667
|
+
"CineonToneMapping": ie,
|
|
668
|
+
"ClampToEdgeWrapping": it,
|
|
669
|
+
"Color": n,
|
|
670
|
+
"ColorManagement": p,
|
|
671
|
+
"ConstantAlphaFactor": Ce,
|
|
672
|
+
"ConstantColorFactor": Pe,
|
|
673
|
+
"CubeReflectionMapping": C,
|
|
674
|
+
"CubeRefractionMapping": L,
|
|
675
|
+
"CubeTexture": X,
|
|
676
|
+
"CubeUVReflectionMapping": a,
|
|
677
|
+
"CullFaceBack": je,
|
|
678
|
+
"CullFaceFront": Ze,
|
|
679
|
+
"CullFaceNone": qe,
|
|
680
|
+
"CustomBlending": $e,
|
|
681
|
+
"CustomToneMapping": ee,
|
|
682
|
+
"Data3DTexture": Y,
|
|
683
|
+
"DataArrayTexture": W,
|
|
684
|
+
"DepthFormat": St,
|
|
685
|
+
"DepthStencilFormat": vt,
|
|
686
|
+
"DepthTexture": q,
|
|
687
|
+
"DoubleSide": fe,
|
|
688
|
+
"DstAlphaFactor": ye,
|
|
689
|
+
"DstColorFactor": Ne,
|
|
690
|
+
"EqualCompare": pt,
|
|
691
|
+
"EqualDepth": We,
|
|
692
|
+
"EquirectangularReflectionMapping": R,
|
|
693
|
+
"EquirectangularRefractionMapping": A,
|
|
694
|
+
"Euler": u,
|
|
695
|
+
"EventDispatcher": vn,
|
|
696
|
+
"ExternalTexture": gn,
|
|
697
|
+
"FloatType": T,
|
|
698
|
+
"FrontSide": _,
|
|
699
|
+
"Frustum": ge,
|
|
700
|
+
"GLSL3": Z,
|
|
701
|
+
"GreaterCompare": ut,
|
|
702
|
+
"GreaterDepth": ze,
|
|
703
|
+
"GreaterEqualCompare": ft,
|
|
704
|
+
"GreaterEqualDepth": ke,
|
|
705
|
+
"HalfFloatType": E,
|
|
706
|
+
"IntType": v,
|
|
707
|
+
"Layers": _e,
|
|
708
|
+
"LessCompare": mt,
|
|
709
|
+
"LessDepth": Xe,
|
|
710
|
+
"LessEqualCompare": K,
|
|
711
|
+
"LessEqualDepth": Me,
|
|
712
|
+
"LinearFilter": B,
|
|
713
|
+
"LinearMipmapLinearFilter": ot,
|
|
714
|
+
"LinearMipmapNearestFilter": st,
|
|
715
|
+
"LinearSRGBColorSpace": F,
|
|
716
|
+
"LinearToneMapping": oe,
|
|
717
|
+
"LinearTransfer": se,
|
|
718
|
+
"Matrix3": e,
|
|
719
|
+
"Matrix4": f,
|
|
720
|
+
"MaxEquation": nt,
|
|
721
|
+
"Mesh": o,
|
|
722
|
+
"MeshBasicMaterial": w,
|
|
723
|
+
"MeshDepthMaterial": ve,
|
|
724
|
+
"MeshDistanceMaterial": Se,
|
|
725
|
+
"MinEquation": tt,
|
|
726
|
+
"MirroredRepeatWrapping": rt,
|
|
727
|
+
"MixOperation": ce,
|
|
728
|
+
"MultiplyBlending": Qe,
|
|
729
|
+
"MultiplyOperation": de,
|
|
730
|
+
"NearestFilter": Te,
|
|
731
|
+
"NearestMipmapLinearFilter": lt,
|
|
732
|
+
"NearestMipmapNearestFilter": ct,
|
|
733
|
+
"NeutralToneMapping": te,
|
|
734
|
+
"NeverCompare": _t,
|
|
735
|
+
"NeverDepth": Ke,
|
|
736
|
+
"NoBlending": I,
|
|
737
|
+
"NoColorSpace": gt,
|
|
738
|
+
"NoToneMapping": D,
|
|
739
|
+
"NormalBlending": pe,
|
|
740
|
+
"NotEqualCompare": dt,
|
|
741
|
+
"NotEqualDepth": Ve,
|
|
742
|
+
"ObjectSpaceNormalMap": he,
|
|
743
|
+
"OneFactor": He,
|
|
744
|
+
"OneMinusConstantAlphaFactor": be,
|
|
745
|
+
"OneMinusConstantColorFactor": Le,
|
|
746
|
+
"OneMinusDstAlphaFactor": Ue,
|
|
747
|
+
"OneMinusDstColorFactor": De,
|
|
748
|
+
"OneMinusSrcAlphaFactor": we,
|
|
749
|
+
"OneMinusSrcColorFactor": Ie,
|
|
750
|
+
"OrthographicCamera": P,
|
|
751
|
+
"PCFShadowMap": $,
|
|
752
|
+
"PCFSoftShadowMap": Q,
|
|
753
|
+
"PMREMGenerator": Jn,
|
|
754
|
+
"PerspectiveCamera": U,
|
|
755
|
+
"Plane": x,
|
|
756
|
+
"PlaneGeometry": h,
|
|
757
|
+
"RED_GREEN_RGTC2_Format": hn,
|
|
758
|
+
"RED_RGTC1_Format": pn,
|
|
759
|
+
"REVISION": Rn,
|
|
760
|
+
"RGBADepthPacking": Ee,
|
|
761
|
+
"RGBAFormat": M,
|
|
762
|
+
"RGBAIntegerFormat": Ft,
|
|
763
|
+
"RGBA_ASTC_10x10_Format": sn,
|
|
764
|
+
"RGBA_ASTC_10x5_Format": rn,
|
|
765
|
+
"RGBA_ASTC_10x6_Format": an,
|
|
766
|
+
"RGBA_ASTC_10x8_Format": on,
|
|
767
|
+
"RGBA_ASTC_12x10_Format": ln,
|
|
768
|
+
"RGBA_ASTC_12x12_Format": cn,
|
|
769
|
+
"RGBA_ASTC_4x4_Format": jt,
|
|
770
|
+
"RGBA_ASTC_5x4_Format": Zt,
|
|
771
|
+
"RGBA_ASTC_5x5_Format": $t,
|
|
772
|
+
"RGBA_ASTC_6x5_Format": Qt,
|
|
773
|
+
"RGBA_ASTC_6x6_Format": Jt,
|
|
774
|
+
"RGBA_ASTC_8x5_Format": en,
|
|
775
|
+
"RGBA_ASTC_8x6_Format": tn,
|
|
776
|
+
"RGBA_ASTC_8x8_Format": nn,
|
|
777
|
+
"RGBA_BPTC_Format": dn,
|
|
778
|
+
"RGBA_ETC2_EAC_Format": qt,
|
|
779
|
+
"RGBA_PVRTC_2BPPV1_Format": Xt,
|
|
780
|
+
"RGBA_PVRTC_4BPPV1_Format": Wt,
|
|
781
|
+
"RGBA_S3TC_DXT1_Format": Ht,
|
|
782
|
+
"RGBA_S3TC_DXT3_Format": Gt,
|
|
783
|
+
"RGBA_S3TC_DXT5_Format": Vt,
|
|
784
|
+
"RGBFormat": wt,
|
|
785
|
+
"RGB_BPTC_SIGNED_Format": un,
|
|
786
|
+
"RGB_BPTC_UNSIGNED_Format": fn,
|
|
787
|
+
"RGB_ETC1_Format": Yt,
|
|
788
|
+
"RGB_ETC2_Format": Kt,
|
|
789
|
+
"RGB_PVRTC_2BPPV1_Format": kt,
|
|
790
|
+
"RGB_PVRTC_4BPPV1_Format": zt,
|
|
791
|
+
"RGB_S3TC_DXT1_Format": Bt,
|
|
792
|
+
"RGFormat": Nt,
|
|
793
|
+
"RGIntegerFormat": Ot,
|
|
794
|
+
"RedFormat": It,
|
|
795
|
+
"RedIntegerFormat": yt,
|
|
796
|
+
"ReinhardToneMapping": ae,
|
|
797
|
+
"RepeatWrapping": at,
|
|
798
|
+
"ReverseSubtractEquation": xe,
|
|
799
|
+
"SIGNED_RED_GREEN_RGTC2_Format": _n,
|
|
800
|
+
"SIGNED_RED_RGTC1_Format": mn,
|
|
801
|
+
"SRGBColorSpace": xn,
|
|
802
|
+
"SRGBTransfer": m,
|
|
803
|
+
"ShaderChunk": Pn,
|
|
804
|
+
"ShaderLib": Dn,
|
|
805
|
+
"ShaderMaterial": l,
|
|
806
|
+
"ShortType": Ut,
|
|
807
|
+
"SrcAlphaFactor": Fe,
|
|
808
|
+
"SrcAlphaSaturateFactor": Oe,
|
|
809
|
+
"SrcColorFactor": Be,
|
|
810
|
+
"SubtractEquation": Re,
|
|
811
|
+
"SubtractiveBlending": Je,
|
|
812
|
+
"TangentSpaceNormalMap": me,
|
|
813
|
+
"Texture": j,
|
|
814
|
+
"Uint16BufferAttribute": V,
|
|
815
|
+
"Uint32BufferAttribute": G,
|
|
816
|
+
"UniformsLib": Un,
|
|
817
|
+
"UniformsUtils": ue,
|
|
818
|
+
"UnsignedByteType": S,
|
|
819
|
+
"UnsignedInt101111Type": Lt,
|
|
820
|
+
"UnsignedInt248Type": Mt,
|
|
821
|
+
"UnsignedInt5999Type": Ct,
|
|
822
|
+
"UnsignedIntType": Tt,
|
|
823
|
+
"UnsignedShort4444Type": At,
|
|
824
|
+
"UnsignedShort5551Type": bt,
|
|
825
|
+
"UnsignedShortType": xt,
|
|
826
|
+
"VSMShadowMap": J,
|
|
827
|
+
"Vector2": t,
|
|
828
|
+
"Vector3": i,
|
|
829
|
+
"Vector4": k,
|
|
830
|
+
"WebGLCoordinateSystem": An,
|
|
831
|
+
"WebGLCubeRenderTarget": b,
|
|
832
|
+
"WebGLRenderTarget": y,
|
|
833
|
+
"WebGLRenderer": ca,
|
|
834
|
+
"WebGLUtils": na,
|
|
835
|
+
"WebXRController": Sn,
|
|
836
|
+
"ZeroFactor": Ge,
|
|
837
|
+
"createCanvasElement": Mn
|
|
838
|
+
};
|
|
839
|
+
})(__CORE);
|
|
840
|
+
window.THREE = Object.assign({}, __CORE, __EXTRA);
|
|
841
|
+
})();
|
|
842
|
+
</script>
|
|
843
|
+
<script>
|
|
844
|
+
/* ═══════════════════════════════════════════════════════════════════════
|
|
845
|
+
宁静号 · Serenity — 航行于认知星空
|
|
846
|
+
───────────────────────────────────────────────────────────────────────
|
|
847
|
+
纯动画场景:无交互控件,运镜自动推进。
|
|
848
|
+
全局依赖:window.THREE(three r180,构建时内联)
|
|
849
|
+
|
|
850
|
+
船体依据(公开资料 · 03-K64 Firefly-class Serenity):
|
|
851
|
+
· 尺寸 58m × 35m × 20m → 长:宽:高 ≈ 2.9 : 1.75 : 1
|
|
852
|
+
· 鳃部(前)驾驶舱 → 细颈 → 胸腔 → 腹部机房 → 尾部膨大光子反应堆
|
|
853
|
+
· 尾部反应堆加速时发光,故名"萤火虫"级;尾部有两侧/下方延伸杆
|
|
854
|
+
· 上甲板两侧各挂一艘穿梭艇;前部货舱门向外下方翻转为坡道
|
|
855
|
+
· 两台短舱可如 VTOL 下转
|
|
856
|
+
═══════════════════════════════════════════════════════════════════════ */
|
|
857
|
+
(function () {
|
|
858
|
+
'use strict';
|
|
859
|
+
|
|
860
|
+
var T = window.THREE;
|
|
861
|
+
|
|
862
|
+
function fail(msg, detail) {
|
|
863
|
+
document.getElementById('errMsg').textContent = msg;
|
|
864
|
+
document.getElementById('errDetail').textContent = detail || '';
|
|
865
|
+
document.getElementById('err').classList.add('on');
|
|
866
|
+
document.getElementById('load').classList.add('off');
|
|
867
|
+
}
|
|
868
|
+
if (!T) { fail('三维引擎未能装载。', 'window.THREE 缺失 —— 构建产物不完整。'); return; }
|
|
869
|
+
|
|
870
|
+
var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
871
|
+
|
|
872
|
+
var PAL = {
|
|
873
|
+
skyTop: 0x01030a, skyMid: 0x05121f, skyLow: 0x0a2a3a,
|
|
874
|
+
fog: 0x03101a, fogD: 0.0010,
|
|
875
|
+
hemiSky: 0x2c5a74, hemiGround: 0x03070d, hemiI: 0.40,
|
|
876
|
+
key: 0xdcefff, keyI: 3.8,
|
|
877
|
+
rim: 0xffb877, rimI: 2.6,
|
|
878
|
+
rim2: 0x7fc8ff, rim2I: 1.7,
|
|
879
|
+
fill: 0x2f6a86, fillI: 0.5,
|
|
880
|
+
exposure: 1.06,
|
|
881
|
+
glyphA: 0xe6fdff, glyphB: 0x6cf8bc,
|
|
882
|
+
star: 0xcfe8ff,
|
|
883
|
+
flameBlue: 0x3f7dff, flameRed: 0xff2b0a
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
// ───────────────────────── 1. 渲染器 ─────────────────────────
|
|
887
|
+
// 卡片模式(?card=1,2026-09-15 S142 增):同一套引擎,按「小卡片背景」重新构图——
|
|
888
|
+
// 隐藏作品自带的整层 UI(标题/航速/事实面板/加载页),把镜头拉远让飞船变小、
|
|
889
|
+
// 星野调暗,留出负空间。判据来自实测:全屏构图直接缩到 340px 会「满、挤、抢戏」。
|
|
890
|
+
var CARD = /[?&]card(=|&|$)/.test(location.search);
|
|
891
|
+
if (CARD) document.body.classList.add('card');
|
|
892
|
+
|
|
893
|
+
var canvas = document.getElementById('gl');
|
|
894
|
+
var renderer;
|
|
895
|
+
try {
|
|
896
|
+
renderer = new T.WebGLRenderer({ canvas: canvas, antialias: true, powerPreference: 'high-performance' });
|
|
897
|
+
} catch (e) {
|
|
898
|
+
fail('浏览器未能启动 WebGL 三维渲染。请尝试更新浏览器、开启硬件加速,或改用 Chrome / Edge / Safari 打开本文件。', String((e && e.message) || e));
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
|
|
902
|
+
renderer.setSize(window.innerWidth, window.innerHeight, false);
|
|
903
|
+
renderer.outputColorSpace = T.SRGBColorSpace;
|
|
904
|
+
renderer.toneMapping = T.ACESFilmicToneMapping;
|
|
905
|
+
renderer.toneMappingExposure = PAL.exposure;
|
|
906
|
+
var MAXA = renderer.capabilities.getMaxAnisotropy ? Math.min(8, renderer.capabilities.getMaxAnisotropy()) : 1;
|
|
907
|
+
|
|
908
|
+
canvas.addEventListener('webglcontextlost', function (ev) {
|
|
909
|
+
ev.preventDefault();
|
|
910
|
+
fail('三维上下文丢失。这通常由显卡驱动重置或标签页长时间挂起引起,刷新页面即可重新起航。', 'webglcontextlost');
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
var scene = new T.Scene();
|
|
914
|
+
scene.fog = new T.FogExp2(PAL.fog, PAL.fogD);
|
|
915
|
+
|
|
916
|
+
var camera = new T.PerspectiveCamera(38, window.innerWidth / window.innerHeight, 0.5, 6000);
|
|
917
|
+
camera.position.set(26, 12, 34);
|
|
918
|
+
|
|
919
|
+
var clock = new T.Clock();
|
|
920
|
+
var uTime = { value: 0 };
|
|
921
|
+
var SIM = { t: 0, speed: 26, frames: 0, ready: false };
|
|
922
|
+
|
|
923
|
+
// ───────────────────────── 2. 程序化贴图 ─────────────────────────
|
|
924
|
+
function cv2d(w, h) {
|
|
925
|
+
var c = document.createElement('canvas'); c.width = w; c.height = h;
|
|
926
|
+
return { c: c, x: c.getContext('2d') };
|
|
927
|
+
}
|
|
928
|
+
function mkTex(c, srgb) {
|
|
929
|
+
var t = new T.CanvasTexture(c);
|
|
930
|
+
t.colorSpace = srgb === false ? T.NoColorSpace : T.SRGBColorSpace;
|
|
931
|
+
t.wrapS = t.wrapT = T.RepeatWrapping;
|
|
932
|
+
t.anisotropy = MAXA;
|
|
933
|
+
return t;
|
|
934
|
+
}
|
|
935
|
+
// 每张贴图按部件尺寸独立平铺,否则 UV 被拉伸,细节读不出来
|
|
936
|
+
function rng(seed) {
|
|
937
|
+
return function () {
|
|
938
|
+
seed |= 0; seed = seed + 0x6D2B79F5 | 0;
|
|
939
|
+
var t = Math.imul(seed ^ seed >>> 15, 1 | seed);
|
|
940
|
+
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
941
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// —— 字形图集:黑底亮字,着色器以亮度通道取掩码 ——
|
|
946
|
+
var GLYPHS = '01{}[]()<>/*+-=;:,.!?$#@&%_|~^λΩ∑∆π√∞≡∈∀∃∇†‡アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワンアカサタナハマヤラワ';
|
|
947
|
+
var AC = 16, AR = 8, CELL = 64;
|
|
948
|
+
var atlasCv = cv2d(AC * CELL, AR * CELL);
|
|
949
|
+
atlasCv.x.fillStyle = '#000'; atlasCv.x.fillRect(0, 0, atlasCv.c.width, atlasCv.c.height);
|
|
950
|
+
atlasCv.x.font = '700 46px "SF Mono",ui-monospace,Menlo,monospace';
|
|
951
|
+
atlasCv.x.textAlign = 'center'; atlasCv.x.textBaseline = 'middle';
|
|
952
|
+
for (var gi = 0; gi < AC * AR; gi++) {
|
|
953
|
+
atlasCv.x.fillStyle = gi % 9 === 0 ? '#ffffff' : '#ddfff2';
|
|
954
|
+
atlasCv.x.fillText(GLYPHS.charAt(gi % GLYPHS.length), (gi % AC) * CELL + CELL / 2, Math.floor(gi / AC) * CELL + CELL / 2);
|
|
955
|
+
}
|
|
956
|
+
var atlasTex = mkTex(atlasCv.c, false);
|
|
957
|
+
atlasTex.magFilter = T.NearestFilter;
|
|
958
|
+
atlasTex.wrapS = atlasTex.wrapT = T.ClampToEdgeWrapping;
|
|
959
|
+
|
|
960
|
+
var dotCv = cv2d(64, 64);
|
|
961
|
+
var dg = dotCv.x.createRadialGradient(32, 32, 0, 32, 32, 32);
|
|
962
|
+
dg.addColorStop(0, 'rgba(255,255,255,1)');
|
|
963
|
+
dg.addColorStop(0.3, 'rgba(255,255,255,.5)');
|
|
964
|
+
dg.addColorStop(1, 'rgba(255,255,255,0)');
|
|
965
|
+
dotCv.x.fillStyle = dg; dotCv.x.fillRect(0, 0, 64, 64);
|
|
966
|
+
var dotTex = mkTex(dotCv.c, false);
|
|
967
|
+
|
|
968
|
+
/* ── CCC 词元招牌 ──────────────────────────────────────────────────────
|
|
969
|
+
星空里漂浮的不是随机字符,而是宁静号的**真实名字**:技能、公理、机械、
|
|
970
|
+
本体文件,外加中文隐喻词。中英混排的霓虹招牌 —— 一如 Firefly 那个
|
|
971
|
+
中英并置的"寰宇",也正是"太空牛仔"该有的样子。
|
|
972
|
+
分类着色:0 技能·翡翠 / 1 公理·琥珀 / 2 机械·青 / 3 本体·紫 / 4 中文·暖白 */
|
|
973
|
+
/* 词元出处(2026-09-15 S142 重播):技能 ← `.opencode/skills/*`;公理 ← ACC Metaphor
|
|
974
|
+
十事实(英文名)+ EAP/CCE 判据名;机械 ← `mech-registry.json` 的 MSM 名;本体 ←
|
|
975
|
+
现行 `*.ttl` 文件名;中文 ← ACC Metaphor(两边共有,原样保留)。 */
|
|
976
|
+
var WORDS = [
|
|
977
|
+
['home-serenity', 0], ['home-session', 0], ['home-desk', 0], ['home-ontology', 0],
|
|
978
|
+
['home-memory', 0], ['home-zhihu', 0], ['home-search', 0], ['home-mail', 0],
|
|
979
|
+
['home-media', 0], ['home-media-production', 0], ['home-video-production', 0], ['h3-screenwriting', 0],
|
|
980
|
+
['home-ppt-master', 0], ['home-rhetoric', 0], ['home-compass', 0], ['home-research', 0],
|
|
981
|
+
['home-landscape', 0], ['home-network', 0], ['home-git', 0], ['home-wealth', 0],
|
|
982
|
+
['home-xrp', 0], ['home-cloudflare', 0], ['home-quality-review', 0], ['home-serenity-sqc', 0],
|
|
983
|
+
['home-serenity-server', 0], ['home-ubuntu-server-management', 0], ['home-pve-management', 0], ['home-skiff-log', 0],
|
|
984
|
+
['home-yh-exist', 0], ['family-profiles', 0], ['zhaocai-memory', 0], ['cce', 0],
|
|
985
|
+
['yanghang-ubuntu-desktop', 0], ['osp-serenity-plugin-development', 0], ['dsh-serenity-plugin-development', 0],
|
|
986
|
+
|
|
987
|
+
['HULL', 1], ['DECK-ORDER', 1], ['ENGINEERING-DRAWINGS', 1],
|
|
988
|
+
['MACHINERY', 1], ['MANIFEST', 1], ['DEPARTURE-CHECK', 1],
|
|
989
|
+
['SHIPS-LOG', 1], ['THESEUS', 1], ['CREW-ROTATION', 1],
|
|
990
|
+
['BLUEPRINT-OVER-STATUE', 1], ['BOUNDED-SPACE', 1], ['FIRST-ANCHOR', 1],
|
|
991
|
+
['ENTROPY-H-OP', 1], ['DETERMINISM-FIRST', 1], ['SINGLE-TRUTH-SOURCE', 1],
|
|
992
|
+
['EAP-E-UP', 1], ['EAP-R-DOWN', 1], ['EAP-S-UP', 1],
|
|
993
|
+
|
|
994
|
+
['ssh-connect', 2], ['housekeeper', 2], ['autopilot-round', 2], ['autopilot-todo', 2],
|
|
995
|
+
['anysearch', 2], ['web-search', 2], ['zhihu-tool', 2], ['doc-fetch', 2],
|
|
996
|
+
['memory-tool', 2], ['zhaocai-memory', 2], ['mail-tool', 2], ['session-log-tool', 2],
|
|
997
|
+
['desk-observe', 2], ['desk-output', 2], ['pve-connect', 2], ['network-tool', 2],
|
|
998
|
+
['landscape-tool', 2], ['ppt-master', 2], ['xrp-dev', 2],
|
|
999
|
+
|
|
1000
|
+
['ccc-ontology.ttl', 3], ['cce-ontology.ttl', 3], ['serenity-skills-ontology.ttl', 3],
|
|
1001
|
+
['home-media-acquisition.ttl', 3], ['home-memory-domain.ttl', 3], ['home-mail-domain.ttl', 3],
|
|
1002
|
+
['home-ppt-master-domain.ttl', 3], ['home-rhetoric-domain.ttl', 3], ['home-skiff-log-domain.ttl', 3],
|
|
1003
|
+
['home-video-production.ttl', 3], ['home-zhihu-domain.ttl', 3], ['zhaocai-memory-domain.ttl', 3],
|
|
1004
|
+
|
|
1005
|
+
['船体', 4], ['甲板秩序', 4], ['工程图纸', 4], ['机械', 4], ['清单', 4], ['出航检查', 4],
|
|
1006
|
+
['日志', 4], ['忒修斯之船', 4], ['船员轮换', 4], ['图纸优于雕像', 4], ['有界空间', 4], ['第一锚点', 4],
|
|
1007
|
+
['罗盘', 4], ['货舱', 4], ['船坞', 4], ['交接', 4], ['源代码确认', 4], ['会话先行', 4]
|
|
1008
|
+
];
|
|
1009
|
+
|
|
1010
|
+
var WC = 256, WH = 64, WCOLS = 8, WROWS = 16;
|
|
1011
|
+
var wordCv = cv2d(WCOLS * WC, WROWS * WH);
|
|
1012
|
+
wordCv.x.fillStyle = '#000'; wordCv.x.fillRect(0, 0, wordCv.c.width, wordCv.c.height);
|
|
1013
|
+
wordCv.x.textAlign = 'center'; wordCv.x.textBaseline = 'middle';
|
|
1014
|
+
var MFONT = '"SF Mono",ui-monospace,Menlo,monospace';
|
|
1015
|
+
var CFONT = '"Heiti SC","STHeiti","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif';
|
|
1016
|
+
WORDS.forEach(function (w, i) {
|
|
1017
|
+
if (i >= WCOLS * WROWS) return;
|
|
1018
|
+
var cx = (i % WCOLS) * WC, cy = Math.floor(i / WCOLS) * WH;
|
|
1019
|
+
var isCJK = /[\u4e00-\u9fa5]/.test(w[0]);
|
|
1020
|
+
// 长名字自动缩字号塞进单元格,避免溢出到相邻格子
|
|
1021
|
+
var fs = isCJK ? 42 : 34;
|
|
1022
|
+
var font = function (size) { return '700 ' + size + 'px ' + (isCJK ? CFONT : MFONT); };
|
|
1023
|
+
wordCv.x.font = font(fs);
|
|
1024
|
+
var tw = wordCv.x.measureText(w[0]).width;
|
|
1025
|
+
if (tw > WC - 18) { fs = Math.max(12, Math.floor(fs * (WC - 18) / tw)); wordCv.x.font = font(fs); }
|
|
1026
|
+
wordCv.x.fillStyle = '#ffffff';
|
|
1027
|
+
wordCv.x.fillText(w[0], cx + WC / 2, cy + WH / 2);
|
|
1028
|
+
});
|
|
1029
|
+
var wordTex = mkTex(wordCv.c, false);
|
|
1030
|
+
wordTex.magFilter = T.LinearFilter;
|
|
1031
|
+
wordTex.wrapS = wordTex.wrapT = T.ClampToEdgeWrapping;
|
|
1032
|
+
|
|
1033
|
+
/* ── 船体三贴图:albedo + normal + roughness ───────────────────────────
|
|
1034
|
+
先画一张「高度图」,再由它用 Sobel 求法线 —— 面板缝隙、铆钉、蒙皮起伏
|
|
1035
|
+
都会真实参与光照,而不是只画在颜色上(这是"精致感"的主要来源)。
|
|
1036
|
+
高度 / 颜色 / 粗糙三者共用同一套面板布局,保证语义一致。 */
|
|
1037
|
+
// —— 贴花:舷号 / 船名 / 危险标记 ——
|
|
1038
|
+
function makeDecal(draw, w, h) {
|
|
1039
|
+
var d = cv2d(w, h);
|
|
1040
|
+
d.x.clearRect(0, 0, w, h);
|
|
1041
|
+
draw(d.x, w, h);
|
|
1042
|
+
var t = mkTex(d.c, true);
|
|
1043
|
+
t.wrapS = t.wrapT = T.ClampToEdgeWrapping;
|
|
1044
|
+
return t;
|
|
1045
|
+
}
|
|
1046
|
+
var decalReg = makeDecal(function (g, w, h) {
|
|
1047
|
+
g.font = '700 54px "SF Mono",ui-monospace,Menlo,monospace';
|
|
1048
|
+
g.textAlign = 'center'; g.textBaseline = 'middle';
|
|
1049
|
+
g.fillStyle = 'rgba(232,238,228,.82)';
|
|
1050
|
+
g.fillText('03-K64', w / 2, h / 2);
|
|
1051
|
+
g.strokeStyle = 'rgba(232,238,228,.5)'; g.lineWidth = 3;
|
|
1052
|
+
g.strokeRect(6, 8, w - 12, h - 16);
|
|
1053
|
+
}, 256, 96);
|
|
1054
|
+
var decalName = makeDecal(function (g, w, h) {
|
|
1055
|
+
g.font = '700 62px system-ui,-apple-system,"Helvetica Neue",sans-serif';
|
|
1056
|
+
g.textAlign = 'center'; g.textBaseline = 'middle';
|
|
1057
|
+
g.fillStyle = 'rgba(226,234,224,.72)';
|
|
1058
|
+
g.fillText('SERENITY', w / 2, h / 2);
|
|
1059
|
+
}, 512, 96);
|
|
1060
|
+
var decalHaz = makeDecal(function (g, w, h) {
|
|
1061
|
+
for (var i = 0; i < 20; i++) {
|
|
1062
|
+
g.fillStyle = i % 2 ? 'rgba(26,26,22,.9)' : 'rgba(206,166,60,.9)';
|
|
1063
|
+
g.save();
|
|
1064
|
+
g.beginPath(); g.rect(0, 0, w, h); g.clip();
|
|
1065
|
+
g.translate(i * 18 - 24, 0);
|
|
1066
|
+
g.transform(1, 0, -0.5, 1, 0, 0);
|
|
1067
|
+
g.fillRect(0, 0, 12, h);
|
|
1068
|
+
g.restore();
|
|
1069
|
+
}
|
|
1070
|
+
}, 256, 64);
|
|
1071
|
+
|
|
1072
|
+
// —— 代码碑贴图:顶部挂上真实名字 ——
|
|
1073
|
+
function makeCodeSlabTex(name) {
|
|
1074
|
+
var W2 = 512, H2 = 512, R = rng(77 + name.length * 13);
|
|
1075
|
+
var g = cv2d(W2, H2);
|
|
1076
|
+
g.x.fillStyle = '#000'; g.x.fillRect(0, 0, W2, H2);
|
|
1077
|
+
g.x.textBaseline = 'middle';
|
|
1078
|
+
for (var y = 92; y < H2; y += 17) {
|
|
1079
|
+
var indent = (R() * 6 | 0) * 14;
|
|
1080
|
+
for (var x = 8 + indent; x < W2 - 10; x += 10) {
|
|
1081
|
+
if (R() < 0.34) continue;
|
|
1082
|
+
var lum = 0.34 + R() * 0.52;
|
|
1083
|
+
g.x.font = '700 15px "SF Mono",ui-monospace,Menlo,monospace';
|
|
1084
|
+
g.x.fillStyle = R() < 0.12 ? 'rgba(255,208,140,' + lum.toFixed(2) + ')' : 'rgba(120,255,206,' + lum.toFixed(2) + ')';
|
|
1085
|
+
g.x.fillText(GLYPHS.charAt((R() * GLYPHS.length) | 0), x, y);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
// 顶部大号牌名(像一块立在星空里的金属铭牌)
|
|
1089
|
+
var isCJK = /[\u4e00-\u9fa5]/.test(name);
|
|
1090
|
+
var fs = isCJK ? 62 : 46;
|
|
1091
|
+
var font = function (s2) { return '700 ' + s2 + 'px ' + (isCJK ? CFONT : '"SF Mono",ui-monospace,Menlo,monospace'); };
|
|
1092
|
+
g.x.font = font(fs);
|
|
1093
|
+
var tw = g.x.measureText(name).width;
|
|
1094
|
+
if (tw > W2 - 48) { fs = Math.floor(fs * (W2 - 48) / tw); g.x.font = font(fs); }
|
|
1095
|
+
g.x.fillStyle = 'rgba(255,228,176,.96)';
|
|
1096
|
+
g.x.fillText(name, 24, 46);
|
|
1097
|
+
g.x.fillStyle = 'rgba(255,228,176,.45)';
|
|
1098
|
+
g.x.fillRect(24, 72, W2 - 48, 3);
|
|
1099
|
+
return mkTex(g.c, true);
|
|
1100
|
+
}
|
|
1101
|
+
// 🔴 2026-09-15 S142 内容扫尾:原为 ['SERENITY','03-K64','认知星空','TIANGONG','宁静号']——
|
|
1102
|
+
// **`TIANGONG` 是另一个容器(tiangong-serenity)的名字**,属"他们的内容"第 3 处。
|
|
1103
|
+
// 我上一轮的残留验收把它漏了:grep 用了小写 `tiangong`,而这里是全大写 ⇒ 判据覆盖面失守
|
|
1104
|
+
// (同 §12.25 那次"漏相对导入形态"的教训)。已改为我们自己的容器名,验收改用 `grep -i`。
|
|
1105
|
+
var SLAB_NAMES = ['SERENITY', '03-K64', 'HOME-SERENITY', '认知星空', '宁静号'];
|
|
1106
|
+
var slabTexes = SLAB_NAMES.map(makeCodeSlabTex);
|
|
1107
|
+
|
|
1108
|
+
// ───────────────────────── 3. 天穹与光 ─────────────────────────
|
|
1109
|
+
var skyMat = new T.ShaderMaterial({
|
|
1110
|
+
side: T.BackSide, depthWrite: false, fog: false,
|
|
1111
|
+
uniforms: {
|
|
1112
|
+
uTop: { value: new T.Color(PAL.skyTop) },
|
|
1113
|
+
uMid: { value: new T.Color(PAL.skyMid) },
|
|
1114
|
+
uLow: { value: new T.Color(PAL.skyLow) }
|
|
1115
|
+
},
|
|
1116
|
+
vertexShader: 'varying vec3 vP;\nvoid main(){ vP = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }',
|
|
1117
|
+
fragmentShader: [
|
|
1118
|
+
'uniform vec3 uTop, uMid, uLow; varying vec3 vP;',
|
|
1119
|
+
'void main(){',
|
|
1120
|
+
' float h = normalize(vP).y;',
|
|
1121
|
+
' vec3 c = mix(uLow, uMid, smoothstep(-0.12, 0.30, h));',
|
|
1122
|
+
' c = mix(c, uTop, smoothstep(0.30, 0.9, h));',
|
|
1123
|
+
' gl_FragColor = vec4(c, 1.0);',
|
|
1124
|
+
'}'
|
|
1125
|
+
].join('\n')
|
|
1126
|
+
});
|
|
1127
|
+
var sky = new T.Mesh(new T.SphereGeometry(2600, 32, 20), skyMat);
|
|
1128
|
+
sky.frustumCulled = false;
|
|
1129
|
+
scene.add(sky);
|
|
1130
|
+
|
|
1131
|
+
scene.add(new T.HemisphereLight(PAL.hemiSky, PAL.hemiGround, PAL.hemiI));
|
|
1132
|
+
|
|
1133
|
+
// 主光跟随相机:任何机位下飞船都被照亮,而背景保持深空 ⇒ 飞船始终是主体
|
|
1134
|
+
var key = new T.DirectionalLight(PAL.key, PAL.keyI);
|
|
1135
|
+
key.position.set(30, 22, 24);
|
|
1136
|
+
scene.add(key); scene.add(key.target);
|
|
1137
|
+
|
|
1138
|
+
// 双轮廓光:后上暖 / 后下冷,勾出舰体边缘
|
|
1139
|
+
var rim = new T.DirectionalLight(PAL.rim, PAL.rimI);
|
|
1140
|
+
rim.position.set(-26, 14, -22); scene.add(rim);
|
|
1141
|
+
var rim2 = new T.DirectionalLight(PAL.rim2, PAL.rim2I);
|
|
1142
|
+
rim2.position.set(-8, -22, -16); scene.add(rim2);
|
|
1143
|
+
var fill = new T.DirectionalLight(PAL.fill, PAL.fillI);
|
|
1144
|
+
fill.position.set(-14, 14, 28); scene.add(fill);
|
|
1145
|
+
|
|
1146
|
+
(function stars() {
|
|
1147
|
+
var n = 2600, pos = new Float32Array(n * 3), R = rng(4242);
|
|
1148
|
+
for (var i = 0; i < n; i++) {
|
|
1149
|
+
var th = R() * Math.PI * 2, ph = Math.acos(R() * 1.7 - 0.65), r = 1900;
|
|
1150
|
+
pos[i * 3] = r * Math.sin(ph) * Math.cos(th);
|
|
1151
|
+
pos[i * 3 + 1] = r * Math.cos(ph);
|
|
1152
|
+
pos[i * 3 + 2] = r * Math.sin(ph) * Math.sin(th);
|
|
1153
|
+
}
|
|
1154
|
+
var g = new T.BufferGeometry();
|
|
1155
|
+
g.setAttribute('position', new T.BufferAttribute(pos, 3));
|
|
1156
|
+
var p = new T.Points(g, new T.PointsMaterial({
|
|
1157
|
+
size: 2.6, sizeAttenuation: false, map: dotTex, color: PAL.star,
|
|
1158
|
+
transparent: true, opacity: 0.9, depthWrite: false, blending: T.AdditiveBlending, fog: false
|
|
1159
|
+
}));
|
|
1160
|
+
p.frustumCulled = false;
|
|
1161
|
+
scene.add(p);
|
|
1162
|
+
})();
|
|
1163
|
+
|
|
1164
|
+
(function nebula() {
|
|
1165
|
+
var R = rng(999);
|
|
1166
|
+
for (var i = 0; i < 12; i++) {
|
|
1167
|
+
var s = new T.Sprite(new T.SpriteMaterial({
|
|
1168
|
+
map: dotTex, color: i % 3 === 0 ? 0x2f8f9c : (i % 3 === 1 ? 0x2d4a86 : 0x4a3570),
|
|
1169
|
+
transparent: true, opacity: 0.11 + R() * 0.1,
|
|
1170
|
+
blending: T.AdditiveBlending, depthWrite: false, fog: false
|
|
1171
|
+
}));
|
|
1172
|
+
var sc = 520 + R() * 900;
|
|
1173
|
+
s.scale.set(sc, sc * (0.45 + R() * 0.45), 1);
|
|
1174
|
+
var a = R() * Math.PI * 2, rad = 700 + R() * 1100;
|
|
1175
|
+
s.position.set(Math.cos(a) * rad, (R() - 0.32) * 520, Math.sin(a) * rad);
|
|
1176
|
+
scene.add(s);
|
|
1177
|
+
}
|
|
1178
|
+
})();
|
|
1179
|
+
|
|
1180
|
+
// ───────────────────────── 4. 飞船 ─────────────────────────
|
|
1181
|
+
// 舰体由**侧型线 + 截面比例 + 前端非轴对称整形**生成(见 build/ship.js 的 hullPoint)。
|
|
1182
|
+
// 球鼻 / 细颈 / 宽胸 / 膨大尾部一次成型,这是 Firefly 级可辨识轮廓的来源。
|
|
1183
|
+
//
|
|
1184
|
+
// ★ 2026-09-16 第三轮的返工:用户判定「飞船那个大圆头好丑」。
|
|
1185
|
+
// 根因不是细节不够,而是**首部型线本身是错的**:旧版首部一路鼓到 1.80
|
|
1186
|
+
// (≈ 船身最粗 2.26 的 80%),再花 1.45 长收成一个半球 ⇒ 侧影就是一个"大圆头"。
|
|
1187
|
+
// 两处独立参考(官方总布置图 Port Outboard Profile / Firefly 蓝图)读数一致:
|
|
1188
|
+
// · 首部是**斜切钝楔**,不是圆顶;背脊前伸、下颌后收("上突下收")
|
|
1189
|
+
// · 前端是**有宽度的钝前缘**,不是收成一点
|
|
1190
|
+
// · 首部最粗 ≈ 船身最粗的 **一半**
|
|
1191
|
+
// ⇒ 本版把首部峰值从 1.80 压到 **1.32**(≈ 船身最粗的 58%),
|
|
1192
|
+
// 并把收尾段改成**等斜率直线(真锥面 = 斜切)**而不是渐进圆弧。
|
|
1193
|
+
var HULL_PROFILE = [
|
|
1194
|
+
[0.42, -8.78], [1.28, -8.52], [1.96, -8.10], [2.38, -7.42], [2.45, -6.62],
|
|
1195
|
+
[2.36, -5.82], [2.12, -5.12], [1.86, -4.42], [1.74, -3.62], [1.78, -2.62],
|
|
1196
|
+
[1.86, -1.42], [1.88, -0.22], [1.84, 0.90], [1.72, 1.90], [1.48, 2.70],
|
|
1197
|
+
[1.16, 3.30], [0.94, 3.90], [0.88, 4.50],
|
|
1198
|
+
// ── 颈前段 → 首部:鼓到 1.45 就收。**不能太小**:座舱风挡就贴在这段上,
|
|
1199
|
+
// 首部半径直接决定风挡能有多大;1.32 时实测风挡只有 ~800px ⇒ 读不出"驾驶舱"。
|
|
1200
|
+
[0.90, 4.50], [1.00, 4.95], [1.18, 5.35], [1.34, 5.75], [1.43, 6.05], [1.45, 6.28],
|
|
1201
|
+
// ── 等斜率直线段(≈1.0/单位)= 真正的斜切锥面;旧版这里是一串越来越陡的点 ──
|
|
1202
|
+
[1.41, 6.38], [1.15, 6.66], [0.89, 6.94], [0.66, 7.16], [0.50, 7.32]
|
|
1203
|
+
];
|
|
1204
|
+
// ── 船体直径的全局比例(2026-09-16 按真实尺寸校正)──────────────────────
|
|
1205
|
+
// 真实 Firefly 级:长 58m × 宽 35m(含两侧短舱)× 高 20m ⇒
|
|
1206
|
+
// 长:宽 = 1.66、长:船体自身直径 ≈ 2.9。
|
|
1207
|
+
// 实测本模型:长:宽 = 16.7:10.1 = 1.65 ✅ 但 长:船体直径 = 16.7:4.9 = 3.4 ❌
|
|
1208
|
+
// ⇒ 船体(不含短舱)偏瘦约 18%,侧影因此读成"导弹/鱼雷"而不是"短粗货船"。
|
|
1209
|
+
// 用**一个系数**统一放大型线半径:所有贴壳部件都走 hullRadius()/surfPoint(),
|
|
1210
|
+
// 因此会整体跟着变粗,不需要逐个改位置。
|
|
1211
|
+
var HULL_R_SCALE = 1.15;
|
|
1212
|
+
function hullRadius(x) {
|
|
1213
|
+
for (var i = 0; i < HULL_PROFILE.length - 1; i++) {
|
|
1214
|
+
var a = HULL_PROFILE[i], b = HULL_PROFILE[i + 1];
|
|
1215
|
+
if (x >= a[1] && x <= b[1]) {
|
|
1216
|
+
var f = (x - a[1]) / (b[1] - a[1]);
|
|
1217
|
+
return (a[0] + (b[0] - a[0]) * f) * HULL_R_SCALE;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
return 0.3 * HULL_R_SCALE;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/* ═══════════════════════════════════════════════════════════════════════════
|
|
1224
|
+
S132 · 飞船建造器 v2(重做版)
|
|
1225
|
+
|
|
1226
|
+
用户判定上一版「建模太烂」;VLM 近景评审结论:像用球/圆柱/方块随手拼的
|
|
1227
|
+
玩具,而非一艘可信的载具。根因是四条系统性问题,本版逐条立规反制:
|
|
1228
|
+
|
|
1229
|
+
R1 **禁止裸基础几何体**:所有板件/箱体一律走 `slabGeo()`(圆角 + 倒角挤出)。
|
|
1230
|
+
无倒角是「廉价感」的第一来源 —— 真实工业件的转折处必有倒角。
|
|
1231
|
+
R2 **部件之间必须有过渡**:模块交界处一律加 interstage 环 / 桁架 / 管路,
|
|
1232
|
+
不允许「圆柱直接怼在球上」这种零过渡硬接。
|
|
1233
|
+
R3 **面板刻线是真几何**:基壳压暗沉在下面,蒙皮板整体抬升 `PLATE_OFF`,
|
|
1234
|
+
板间留缝 ⇒ 缝隙露出暗底,形成**有深度的**刻线(而不是贴图上画线)。
|
|
1235
|
+
R4 **细节沿结构线分布,不许随机撒**:铆钉贴着板缝走,greeble 成组贴在
|
|
1236
|
+
「检修区」,密度由结构决定。
|
|
1237
|
+
|
|
1238
|
+
设计语言:**磨损的实用货运船**(Firefly 级)—— 功能优先、外露机械、铆接蒙皮。
|
|
1239
|
+
选它还有一个工程理由:做旧与铆钉能掩盖程序化建模的精度不足,
|
|
1240
|
+
而「极简光洁」风格会把每一处误差都放大。
|
|
1241
|
+
|
|
1242
|
+
★ 本版最重要的实现纪律(上一稿正是在这里翻车的):
|
|
1243
|
+
**凡是要贴到壳体上的部件,一律用 `surfPoint()/surfNrm()` 从型线参数化
|
|
1244
|
+
求出位置与法线,绝不用「猜一个 y/z 坐标」。**
|
|
1245
|
+
上一稿的驾驶舱与背脊都是固定 y 值,而壳体顶部从 x=4.5 的 0.81 一路升到
|
|
1246
|
+
x=6.45 的 1.66 —— 固定坐标必然在前段被壳体吞掉(K4 缺陷类)。
|
|
1247
|
+
|
|
1248
|
+
模块划分(每段有独立做法,段间必有过渡环):
|
|
1249
|
+
① 舰首/驾驶舱 5.2→7.4 对接环 + 探针 + **贴合壳面的曲面座舱玻璃**
|
|
1250
|
+
② 颈部 3.3→5.2 收细 + 加强箍 + 外露管路
|
|
1251
|
+
③ 主货舱 -3.4→3.3 最大体量;腹部货舱门 + 已放下坡道 + 舷窗 + 侧舱门
|
|
1252
|
+
④ 腹部机房 -4.6→-3.4 散热格栅 + 成组 greeble
|
|
1253
|
+
⑤ 尾部反应堆 -9.6→-4.6 膨大 + 散热鳍 + 主喷口 + 热变色 + 延伸杆 + 桁架
|
|
1254
|
+
⑥ 两侧短舱 z≈±3.4 法兰 + 挂架 + 斜撑 + 回连管路 + 进气道 + 喷口
|
|
1255
|
+
⑦ 背脊 -4.9→2.6 贴壳脊段 + 检修舱盖 + 散热翼 + 天线
|
|
1256
|
+
⑧ 上甲板 x≈1.7 两艘穿梭艇 + 托架
|
|
1257
|
+
═══════════════════════════════════════════════════════════════════════════ */
|
|
1258
|
+
|
|
1259
|
+
/* ── 蒙皮贴图:底漆 + 色斑 + 锈 + 流痕 + 划痕 + 紧固件底影 ───────────────
|
|
1260
|
+
面板刻线交给**几何**(R3),贴图只负责「脏」,避免双重刻线打架。 */
|
|
1261
|
+
function makeShipSkin() {
|
|
1262
|
+
var S = 1024, R = rng(20260915);
|
|
1263
|
+
var A = cv2d(S, S), H = cv2d(S, S), G = cv2d(S, S);
|
|
1264
|
+
|
|
1265
|
+
A.x.fillStyle = '#8d9488'; A.x.fillRect(0, 0, S, S);
|
|
1266
|
+
H.x.fillStyle = '#808080'; H.x.fillRect(0, 0, S, S);
|
|
1267
|
+
G.x.fillStyle = '#8c8c8c'; G.x.fillRect(0, 0, S, S);
|
|
1268
|
+
|
|
1269
|
+
// 1) 底漆色斑:大块轻微色差,打破「一张纯色贴图走天下」
|
|
1270
|
+
for (var i = 0; i < 260; i++) {
|
|
1271
|
+
var x = R() * S, y = R() * S, w = 40 + R() * 190, h = 30 + R() * 150;
|
|
1272
|
+
var v = 0.80 + R() * 0.34;
|
|
1273
|
+
A.x.fillStyle = 'rgba(' + ((132 * v) | 0) + ',' + ((140 * v) | 0) + ',' + ((126 * v) | 0) + ',' + (0.25 + R() * 0.4).toFixed(2) + ')';
|
|
1274
|
+
A.x.fillRect(x, y, w, h);
|
|
1275
|
+
G.x.fillStyle = 'rgba(' + ((120 + R() * 90) | 0) + ',0,0,.25)';
|
|
1276
|
+
G.x.fillRect(x, y, w, h);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// 2) 锈斑:同心圆堆出「渗开」感,且局部更粗糙
|
|
1280
|
+
for (var r2 = 0; r2 < 46; r2++) {
|
|
1281
|
+
var rx = R() * S, ry = R() * S, rr = 10 + R() * 52;
|
|
1282
|
+
for (var k = 5; k >= 1; k--) {
|
|
1283
|
+
A.x.beginPath(); A.x.arc(rx, ry, rr * k / 5, 0, 6.2832);
|
|
1284
|
+
A.x.fillStyle = 'rgba(122,84,50,' + (0.055 * (6 - k)).toFixed(3) + ')';
|
|
1285
|
+
A.x.fill();
|
|
1286
|
+
}
|
|
1287
|
+
G.x.beginPath(); G.x.arc(rx, ry, rr, 0, 6.2832);
|
|
1288
|
+
G.x.fillStyle = 'rgba(215,215,215,.5)'; G.x.fill();
|
|
1289
|
+
H.x.beginPath(); H.x.arc(rx, ry, rr * 0.8, 0, 6.2832);
|
|
1290
|
+
H.x.fillStyle = 'rgba(120,120,120,.35)'; H.x.fill();
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// 3) 流痕:自上而下的暗色条纹(最能出「旧」的味道)
|
|
1294
|
+
for (var s2 = 0; s2 < 190; s2++) {
|
|
1295
|
+
var sx = R() * S, sy = R() * S, len = 40 + R() * 240, wd = 1 + R() * 4;
|
|
1296
|
+
var grad = A.x.createLinearGradient(0, sy, 0, sy + len);
|
|
1297
|
+
grad.addColorStop(0, 'rgba(38,40,34,.34)');
|
|
1298
|
+
grad.addColorStop(1, 'rgba(38,40,34,0)');
|
|
1299
|
+
A.x.fillStyle = grad; A.x.fillRect(sx, sy, wd, len);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// 4) 划痕:细线,露出下层金属
|
|
1303
|
+
A.x.lineWidth = 1;
|
|
1304
|
+
for (var c = 0; c < 260; c++) {
|
|
1305
|
+
var cx = R() * S, cy = R() * S, ang = R() * 6.2832, ln = 6 + R() * 70;
|
|
1306
|
+
A.x.strokeStyle = R() < 0.5 ? 'rgba(196,202,190,.34)' : 'rgba(60,62,56,.30)';
|
|
1307
|
+
A.x.beginPath(); A.x.moveTo(cx, cy);
|
|
1308
|
+
A.x.lineTo(cx + Math.cos(ang) * ln, cy + Math.sin(ang) * ln); A.x.stroke();
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// 5) 紧固件底影:与几何铆钉呼应,强化「铆接蒙皮」读感
|
|
1312
|
+
for (var b = 0; b < 900; b++) {
|
|
1313
|
+
var bx = R() * S, by = R() * S;
|
|
1314
|
+
A.x.beginPath(); A.x.arc(bx, by, 2.1, 0, 6.2832);
|
|
1315
|
+
A.x.fillStyle = 'rgba(48,50,44,.42)'; A.x.fill();
|
|
1316
|
+
A.x.beginPath(); A.x.arc(bx - 0.7, by - 0.7, 1.1, 0, 6.2832);
|
|
1317
|
+
A.x.fillStyle = 'rgba(206,212,200,.30)'; A.x.fill();
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// 由高度图 Sobel 求法线:蒙皮起伏参与光照,最便宜的一档「精致感」
|
|
1321
|
+
var N = cv2d(S, S);
|
|
1322
|
+
var hd = H.x.getImageData(0, 0, S, S).data;
|
|
1323
|
+
var nd = N.x.createImageData(S, S), od = nd.data;
|
|
1324
|
+
function at(px, py) { return hd[(((py + S) % S) * S + ((px + S) % S)) * 4] / 255; }
|
|
1325
|
+
for (var yy = 0; yy < S; yy++) {
|
|
1326
|
+
for (var xx = 0; xx < S; xx++) {
|
|
1327
|
+
var gx = (at(xx + 1, yy - 1) + 2 * at(xx + 1, yy) + at(xx + 1, yy + 1))
|
|
1328
|
+
- (at(xx - 1, yy - 1) + 2 * at(xx - 1, yy) + at(xx - 1, yy + 1));
|
|
1329
|
+
var gy = (at(xx - 1, yy + 1) + 2 * at(xx, yy + 1) + at(xx + 1, yy + 1))
|
|
1330
|
+
- (at(xx - 1, yy - 1) + 2 * at(xx, yy - 1) + at(xx + 1, yy - 1));
|
|
1331
|
+
var o = (yy * S + xx) * 4;
|
|
1332
|
+
od[o] = 128 + gx * 90; od[o + 1] = 128 + gy * 90; od[o + 2] = 255; od[o + 3] = 255;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
N.x.putImageData(nd, 0, 0);
|
|
1336
|
+
return { map: mkTex(A.c, true), rough: mkTex(G.c, false), normal: mkTex(N.c, false) };
|
|
1337
|
+
}
|
|
1338
|
+
var SKIN = makeShipSkin();
|
|
1339
|
+
|
|
1340
|
+
/* ── 尾焰热变色:喷口附近的 本色→金→紫→蓝 回火序列(真实受热金属的颜色)── */
|
|
1341
|
+
function makeHeatTex() {
|
|
1342
|
+
var W = 256, H = 64, g = cv2d(W, H);
|
|
1343
|
+
var grd = g.x.createLinearGradient(0, 0, W, 0);
|
|
1344
|
+
grd.addColorStop(0.00, '#b9beb4');
|
|
1345
|
+
grd.addColorStop(0.34, '#9a8a6e');
|
|
1346
|
+
grd.addColorStop(0.55, '#c8a24a');
|
|
1347
|
+
grd.addColorStop(0.72, '#8b5aa8');
|
|
1348
|
+
grd.addColorStop(0.87, '#4a6fb0');
|
|
1349
|
+
grd.addColorStop(1.00, '#2b3a4a');
|
|
1350
|
+
g.x.fillStyle = grd; g.x.fillRect(0, 0, W, H);
|
|
1351
|
+
g.x.globalAlpha = 0.30;
|
|
1352
|
+
for (var i = 0; i < 120; i++) {
|
|
1353
|
+
g.x.fillStyle = Math.random() < 0.5 ? '#000' : '#fff';
|
|
1354
|
+
g.x.fillRect(Math.random() * W, Math.random() * H, 2 + Math.random() * 14, 1);
|
|
1355
|
+
}
|
|
1356
|
+
var t = mkTex(g.c, true);
|
|
1357
|
+
t.wrapS = t.wrapT = T.ClampToEdgeWrapping;
|
|
1358
|
+
return t;
|
|
1359
|
+
}
|
|
1360
|
+
var HEAT = makeHeatTex();
|
|
1361
|
+
|
|
1362
|
+
/* ── 环境贴图:金属/漆面接收的环境光 ──────────────────────────────────
|
|
1363
|
+
旧版这张图**整体压得很暗**(#0c1a24 一路到 #04070b),配上当时的高金属度,
|
|
1364
|
+
整船只剩反射、没有 albedo ⇒ 读成"黑铬/暗塑料"(用户本轮反馈的「金属光泽不太对」)。
|
|
1365
|
+
现改为**偏亮的冷天光 + 暖侧光**:即使金属度低,漆面也能拿到像样的环境照明,
|
|
1366
|
+
露出灰绿的本色;高金属度的少数件(铆钉/喷口)反光也不再是漆黑一片。 */
|
|
1367
|
+
(function applyShipEnv() {
|
|
1368
|
+
try {
|
|
1369
|
+
var W = 256, H = 128, g = cv2d(W, H);
|
|
1370
|
+
var grd = g.x.createLinearGradient(0, 0, 0, H);
|
|
1371
|
+
grd.addColorStop(0.00, '#dfeaf5');
|
|
1372
|
+
grd.addColorStop(0.34, '#8ea6b8');
|
|
1373
|
+
grd.addColorStop(0.50, '#48596a');
|
|
1374
|
+
grd.addColorStop(0.70, '#2b3846');
|
|
1375
|
+
grd.addColorStop(1.00, '#141b23');
|
|
1376
|
+
g.x.fillStyle = grd; g.x.fillRect(0, 0, W, H);
|
|
1377
|
+
function blob(cx, cy, rr, col) {
|
|
1378
|
+
var rg = g.x.createRadialGradient(cx, cy, 0, cx, cy, rr);
|
|
1379
|
+
rg.addColorStop(0, col); rg.addColorStop(1, 'rgba(0,0,0,0)');
|
|
1380
|
+
g.x.fillStyle = rg; g.x.fillRect(0, 0, W, H);
|
|
1381
|
+
}
|
|
1382
|
+
blob(W * 0.30, H * 0.20, 78, 'rgba(255,250,235,1.0)'); // 主光方向
|
|
1383
|
+
blob(W * 0.74, H * 0.42, 56, 'rgba(176,214,255,0.62)'); // 冷补光
|
|
1384
|
+
blob(W * 0.06, H * 0.62, 44, 'rgba(255,176,116,0.34)'); // 暖反弹
|
|
1385
|
+
|
|
1386
|
+
var tex = new T.CanvasTexture(g.c);
|
|
1387
|
+
tex.mapping = T.EquirectangularReflectionMapping;
|
|
1388
|
+
tex.colorSpace = T.SRGBColorSpace;
|
|
1389
|
+
var pmrem = new T.PMREMGenerator(renderer);
|
|
1390
|
+
scene.environment = pmrem.fromEquirectangular(tex).texture;
|
|
1391
|
+
pmrem.dispose();
|
|
1392
|
+
} catch (e) { /* 环境贴图只是增强手段,失败不阻断场景 */ }
|
|
1393
|
+
})();
|
|
1394
|
+
|
|
1395
|
+
/* ═══════════════════ 几何工具(R1 / R3 的执行者)═══════════════════════ */
|
|
1396
|
+
|
|
1397
|
+
/* R1:圆角 + 倒角挤出板。所有箱体类部件都走这里,杜绝裸 BoxGeometry。 */
|
|
1398
|
+
function slabGeo(w, h, d, b, rad) {
|
|
1399
|
+
b = (b === undefined) ? 0.035 : b;
|
|
1400
|
+
rad = (rad === undefined) ? b * 1.8 : rad;
|
|
1401
|
+
var hw = Math.max(0.004, w / 2 - b), hh = Math.max(0.004, h / 2 - b);
|
|
1402
|
+
rad = Math.max(0.002, Math.min(rad, hw, hh));
|
|
1403
|
+
var s = new T.Shape();
|
|
1404
|
+
s.moveTo(-hw + rad, -hh);
|
|
1405
|
+
s.lineTo(hw - rad, -hh); s.quadraticCurveTo(hw, -hh, hw, -hh + rad);
|
|
1406
|
+
s.lineTo(hw, hh - rad); s.quadraticCurveTo(hw, hh, hw - rad, hh);
|
|
1407
|
+
s.lineTo(-hw + rad, hh); s.quadraticCurveTo(-hw, hh, -hw, hh - rad);
|
|
1408
|
+
s.lineTo(-hw, -hh + rad); s.quadraticCurveTo(-hw, -hh, -hw + rad, -hh);
|
|
1409
|
+
var depth = Math.max(0.006, d - 2 * b);
|
|
1410
|
+
var g = new T.ExtrudeGeometry(s, {
|
|
1411
|
+
depth: depth, bevelEnabled: true, bevelThickness: b, bevelSize: b,
|
|
1412
|
+
bevelSegments: 2, curveSegments: 3, steps: 1
|
|
1413
|
+
});
|
|
1414
|
+
g.translate(0, 0, -depth / 2);
|
|
1415
|
+
return g;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/* ═══════════ R3 的核心:**唯一的船体形状函数** ═══════════════════════════════
|
|
1419
|
+
船体本体、每一块蒙皮板、一切贴附件的法线,**全部由 hullPoint() 派生**。
|
|
1420
|
+
只有一个形状来源 ⇒ 结构上不可能出现"板与壳对不上""部件跑到另一侧"。
|
|
1421
|
+
|
|
1422
|
+
φ = 船体极角 φ_hull:0=腹部、π/2=+Z 舷侧、π=背脊。
|
|
1423
|
+
|
|
1424
|
+
▸ 截面比例 (KY, KZ):真实 Firefly 是**宽而扁**的;旧值 (0.92, 0.87) 反而"高比宽大"
|
|
1425
|
+
⇒ 侧影读成火箭筒。现 KY=0.84 / KZ=1.00(宽:高 ≈ 1.19:1)。
|
|
1426
|
+
▸ 前端整形 noseW/noseSlant(本轮最关键的一条):两处独立参考读数一致 ——
|
|
1427
|
+
官方总布置图 Port Outboard Profile + Firefly 蓝图都说船头**不是圆顶**,而是
|
|
1428
|
+
**斜切钝楔**:背脊前伸、下颌后收("上突下收",Firefly 辨识度最高的剪影特征),
|
|
1429
|
+
前端收成一段**有宽度的钝前缘**而不是收成一点;头部最粗 ≈ 船身最粗的一半。
|
|
1430
|
+
做法:把型线站位沿周向平移 noseSlant·(−cos φ)·noseW(x) ——
|
|
1431
|
+
背脊(φ=π) +S、下颌(φ=0) −S、中间余弦过渡。
|
|
1432
|
+
一个连续函数就把"球顶"掰成"斜切楔",且**船身段 noseW=0 ⇒ 完全不受影响**。
|
|
1433
|
+
▸ 旧版用 LatheGeometry(旋转面)打天下,这是"大圆头/圆筒"的根因:
|
|
1434
|
+
旋转面只能生成"圆叠圆",永远做不出上突下收的楔形。 */
|
|
1435
|
+
var KY = 0.84, KZ = 1.00;
|
|
1436
|
+
var HULL_X0 = HULL_PROFILE[0][1]; // 尾端站位
|
|
1437
|
+
var HULL_X1 = HULL_PROFILE[HULL_PROFILE.length - 1][1]; // 首端站位(末端钝面所在)
|
|
1438
|
+
var NOSE_X0 = 4.40, NOSE_X1 = 5.60; // 前端整形的过渡带(只吃颈前段,船身毫发无损)
|
|
1439
|
+
var NOSE_SLANT = 0.65; // 背脊前伸 / 下颌后收 的幅度(世界单位)
|
|
1440
|
+
|
|
1441
|
+
function noseW(x) {
|
|
1442
|
+
if (x <= NOSE_X0) return 0;
|
|
1443
|
+
if (x >= NOSE_X1) return 1;
|
|
1444
|
+
var t = (x - NOSE_X0) / (NOSE_X1 - NOSE_X0);
|
|
1445
|
+
return t * t * (3 - 2 * t); // smoothstep
|
|
1446
|
+
}
|
|
1447
|
+
function hullPoint(x, phi, out) {
|
|
1448
|
+
var r = Math.max(0.015, hullRadius(x) + (out || 0));
|
|
1449
|
+
var xs = x + NOSE_SLANT * (-Math.cos(phi)) * noseW(x);
|
|
1450
|
+
return new T.Vector3(xs, -Math.cos(phi) * r * KY, Math.sin(phi) * r * KZ);
|
|
1451
|
+
}
|
|
1452
|
+
function surfPoint(x, phi, out) { return hullPoint(x, phi, out); }
|
|
1453
|
+
|
|
1454
|
+
/* 法线:船身段(noseW=0)用解析式(省算力、且与旧版逐字一致);
|
|
1455
|
+
整形段用数值差分的两个切向叉乘 —— 保证与 hullPoint 永远一致。 */
|
|
1456
|
+
function surfNrm(phi, x) {
|
|
1457
|
+
if (x === undefined || noseW(x) === 0) {
|
|
1458
|
+
return new T.Vector3(0, -Math.cos(phi) / KY, Math.sin(phi) / KZ).normalize();
|
|
1459
|
+
}
|
|
1460
|
+
var d = 2e-3;
|
|
1461
|
+
var tx = hullPoint(x + d, phi, 0).sub(hullPoint(x - d, phi, 0));
|
|
1462
|
+
var tp = hullPoint(x, phi + d, 0).sub(hullPoint(x, phi - d, 0));
|
|
1463
|
+
return new T.Vector3().crossVectors(tx, tp).normalize(); // tx × tφ = 朝外
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/* (x, φ) 参数网格面片 —— 蒙皮板 / 基壳 / 力场壳都由它生成。
|
|
1467
|
+
不再有 LatheGeometry 的 π/2 镜像陷阱:**参数就是 φ_hull**。
|
|
1468
|
+
缠绕方向 (a,b,d)+(c,d,b) ⇒ 面法线 = tx × tφ = 朝外。 */
|
|
1469
|
+
function hullPatchGeo(x0, x1, phi0, phiLen, out, segX, segPhi) {
|
|
1470
|
+
var nx = Math.max(1, segX), np = Math.max(2, segPhi);
|
|
1471
|
+
var pos = new Float32Array((nx + 1) * (np + 1) * 3), k = 0;
|
|
1472
|
+
for (var i = 0; i <= nx; i++) {
|
|
1473
|
+
var x = x0 + (x1 - x0) * (i / nx);
|
|
1474
|
+
for (var j = 0; j <= np; j++) {
|
|
1475
|
+
var p = hullPoint(x, phi0 + phiLen * (j / np), out);
|
|
1476
|
+
pos[k++] = p.x; pos[k++] = p.y; pos[k++] = p.z;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
var row = np + 1, idx = [];
|
|
1480
|
+
for (var i2 = 0; i2 < nx; i2++) {
|
|
1481
|
+
for (var j2 = 0; j2 < np; j2++) {
|
|
1482
|
+
var a = i2 * row + j2, b = a + row, c = b + 1, dd = a + 1;
|
|
1483
|
+
idx.push(a, b, dd, c, dd, b);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
var g = new T.BufferGeometry();
|
|
1487
|
+
g.setAttribute('position', new T.BufferAttribute(pos, 3));
|
|
1488
|
+
g.setIndex(idx);
|
|
1489
|
+
g.computeVertexNormals();
|
|
1490
|
+
// 整圈(首尾列重合)时把末列法线抄成首列,否则腹部会出现一道着色硬边
|
|
1491
|
+
if (Math.abs(phiLen - Math.PI * 2) < 1e-6) {
|
|
1492
|
+
var na = g.attributes.normal;
|
|
1493
|
+
for (var i3 = 0; i3 <= nx; i3++) {
|
|
1494
|
+
var i0 = i3 * row, iN = i0 + np;
|
|
1495
|
+
na.setXYZ(iN, na.getX(i0), na.getY(i0), na.getZ(i0));
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
return g;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/* 前端钝面封盖:把 x=xEnd 处的环用三角扇收到形心 ⇒ 得到一个**斜切的钝面**,
|
|
1502
|
+
而不是让曲面收成一点。参考图明确要求"前端是有宽度的钝前缘"。 */
|
|
1503
|
+
function hullCapGeo(xEnd, phi0, phiLen, out, seg) {
|
|
1504
|
+
var np = Math.max(3, seg || 48), pos = [], cx = 0, cy = 0, cz = 0;
|
|
1505
|
+
for (var j = 0; j <= np; j++) {
|
|
1506
|
+
var p = hullPoint(xEnd, phi0 + phiLen * (j / np), out);
|
|
1507
|
+
pos.push(p); cx += p.x; cy += p.y; cz += p.z;
|
|
1508
|
+
}
|
|
1509
|
+
cx /= (np + 1); cy /= (np + 1); cz /= (np + 1);
|
|
1510
|
+
var n = pos.length, arr = new Float32Array((n + 1) * 3), k = 0;
|
|
1511
|
+
for (var i = 0; i < n; i++) { arr[k++] = pos[i].x; arr[k++] = pos[i].y; arr[k++] = pos[i].z; }
|
|
1512
|
+
arr[k++] = cx; arr[k++] = cy; arr[k++] = cz;
|
|
1513
|
+
var idx = [];
|
|
1514
|
+
for (var t = 0; t < n - 1; t++) idx.push(t + 1, t, n);
|
|
1515
|
+
var g = new T.BufferGeometry();
|
|
1516
|
+
g.setAttribute('position', new T.BufferAttribute(arr, 3));
|
|
1517
|
+
g.setIndex(idx);
|
|
1518
|
+
g.computeVertexNormals();
|
|
1519
|
+
return g;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/* 蒙皮板:贴型线抬升 off(与基壳之间留缝 = 真实刻线),角度直接给 φ_hull。
|
|
1523
|
+
▸ x 方向的分段数按板长自适应:固定 6 段在首部斜切段(板长 1.9)会读成折线面
|
|
1524
|
+
—— 近景 VLM 明确报了"多边形面拼合的折线感",根因就在这里。 */
|
|
1525
|
+
function hullPlate(x0, x1, phiHull0, phiLenHull, off, mat, seg) {
|
|
1526
|
+
var segX = Math.max(3, Math.min(16, Math.round(Math.abs(x1 - x0) * 6)));
|
|
1527
|
+
return new T.Mesh(hullPatchGeo(x0, x1, phiHull0, phiLenHull, off, segX, seg || 18), mat);
|
|
1528
|
+
}
|
|
1529
|
+
/* 管路:CatmullRom + TubeGeometry,用来做模块之间的「功能连接」 */
|
|
1530
|
+
function pipeGeo(points, radius) {
|
|
1531
|
+
var v = points.map(function (p) { return new T.Vector3(p[0], p[1], p[2]); });
|
|
1532
|
+
return new T.TubeGeometry(new T.CatmullRomCurve3(v), Math.max(8, v.length * 8), radius, 6, false);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/* ═══════════════════════════ 造船 ═══════════════════════════════════════ */
|
|
1536
|
+
function buildSerenity() {
|
|
1537
|
+
var root = new T.Group();
|
|
1538
|
+
var R = rng(31337);
|
|
1539
|
+
|
|
1540
|
+
var PLATE_OFF = 0.045; // R3:蒙皮板抬升量 = 刻线深度
|
|
1541
|
+
var phiStep = Math.PI * 2 / 6; // 周向 6 块蒙皮
|
|
1542
|
+
var SEAM = 0.052; // 周向留缝(弧度):0.030 时缝宽仅 ~1.4px,
|
|
1543
|
+
// ① 的发光缝读不出来 ⇒ 加宽到 0.052(≈4.7px)。
|
|
1544
|
+
// 注意缝变宽后桁条更不能压在缝上(见 ③ 段注释)
|
|
1545
|
+
function surf(x, phi, out) { return surfPoint(x, phi, out); }
|
|
1546
|
+
|
|
1547
|
+
/* ── 材质:有环境贴图后金属度可以给足,高光才有方向性 ── */
|
|
1548
|
+
function skin(rx, ry) {
|
|
1549
|
+
var m = SKIN.map.clone(); m.needsUpdate = true;
|
|
1550
|
+
m.wrapS = m.wrapT = T.RepeatWrapping; m.repeat.set(rx, ry);
|
|
1551
|
+
var r = SKIN.rough.clone(); r.needsUpdate = true;
|
|
1552
|
+
r.wrapS = r.wrapT = T.RepeatWrapping; r.repeat.set(rx, ry);
|
|
1553
|
+
var n = SKIN.normal.clone(); n.needsUpdate = true;
|
|
1554
|
+
n.wrapS = n.wrapT = T.RepeatWrapping; n.repeat.set(rx, ry);
|
|
1555
|
+
return { map: m, rough: r, normal: n };
|
|
1556
|
+
}
|
|
1557
|
+
var _matCache = {};
|
|
1558
|
+
/* ── 材质:**做旧货运船**的金属响应(2026-09-16 用户反馈「金属光泽不太对」后重定)
|
|
1559
|
+
▸ 症结:旧参数 metalness 0.62 + envMapIntensity 1.15,而我们的环境贴图**整体很暗**
|
|
1560
|
+
(从天顶到地面是 #e6f2ff → #0c1a24 → #04070b)。金属度高的表面几乎不显示
|
|
1561
|
+
baseColor,只反射环境 —— 于是整船读成"黑铬/暗塑料",既不是金属也不是漆面。
|
|
1562
|
+
▸ 真实 Serenity 是**哑光、脏、灰绿**的旧货船:漆面为主、金属只在少数机械件上露出来。
|
|
1563
|
+
⇒ 金属度整体压到 0.2~0.3(让 albedo 重新主导)、粗糙度抬到 0.7 以上(高光散开)、
|
|
1564
|
+
envMapIntensity 降到 0.55(环境只做很淡的补光,不再主导外观)。
|
|
1565
|
+
⇒ 只有真正该是裸金属的少数件(铆钉/热变色喷口/太阳能板)保留较高金属度。 */
|
|
1566
|
+
function mat(color, rough, metal, rx, ry, nScale) {
|
|
1567
|
+
var key = [color, rough, metal, rx, ry, nScale].join('|');
|
|
1568
|
+
if (_matCache[key]) return _matCache[key];
|
|
1569
|
+
var t = skin(rx || 2.6, ry || 1.7);
|
|
1570
|
+
var m = new T.MeshStandardMaterial({
|
|
1571
|
+
map: t.map, roughnessMap: t.rough, normalMap: t.normal,
|
|
1572
|
+
normalScale: new T.Vector2(nScale || 0.55, nScale || 0.55),
|
|
1573
|
+
color: color, metalness: metal === undefined ? 0.26 : metal,
|
|
1574
|
+
roughness: rough === undefined ? 0.72 : rough,
|
|
1575
|
+
envMapIntensity: 0.55
|
|
1576
|
+
});
|
|
1577
|
+
_matCache[key] = m;
|
|
1578
|
+
return m;
|
|
1579
|
+
}
|
|
1580
|
+
var mPlate = mat(0xffffff, 0.74, 0.26, 2.6, 1.7, 0.55); // 主蒙皮:哑光漆面
|
|
1581
|
+
var mPanel = mat(0xb9c0b0, 0.80, 0.20, 3.1, 2.0, 0.50); // 次色面板
|
|
1582
|
+
var mBase = mat(0x4c5248, 0.88, 0.22, 2.0, 1.3, 0.45); // 暗基壳(缝里露出的那层)
|
|
1583
|
+
var mDark = mat(0x767c70, 0.78, 0.24, 3.4, 2.2, 0.50); // 结构件
|
|
1584
|
+
var mRust = new T.MeshStandardMaterial({ color: 0x7d5a3c, metalness: 0.12, roughness: 0.96, envMapIntensity: 0.5 });
|
|
1585
|
+
var mRivet = new T.MeshStandardMaterial({ color: 0xb6bcae, metalness: 0.55, roughness: 0.55, envMapIntensity: 0.9 });
|
|
1586
|
+
var mHot = new T.MeshStandardMaterial({ map: HEAT, metalness: 0.60, roughness: 0.48, envMapIntensity: 1.0 });
|
|
1587
|
+
var mGlass = new T.MeshStandardMaterial({
|
|
1588
|
+
color: 0x0b2831, emissive: 0x9cf0ff, emissiveIntensity: 2.2,
|
|
1589
|
+
metalness: 0.15, roughness: 0.06, envMapIntensity: 1.6
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
var mGlowB = new T.MeshBasicMaterial({ color: 0xeaf8ff, transparent: true, opacity: 0.95, blending: T.AdditiveBlending, depthWrite: false, fog: false });
|
|
1593
|
+
var mGlowR = new T.MeshBasicMaterial({ color: 0xffb08a, transparent: true, opacity: 0.95, blending: T.AdditiveBlending, depthWrite: false, fog: false });
|
|
1594
|
+
|
|
1595
|
+
function put(m, x, y, z) { m.position.set(x || 0, y || 0, z || 0); m.castShadow = true; root.add(m); return m; }
|
|
1596
|
+
function axCyl(rt, rb, h, seg) { var g = new T.CylinderGeometry(rt, rb, h, seg); g.rotateZ(-Math.PI / 2); return g; }
|
|
1597
|
+
function ringX(r, tube, seg) { var g = new T.TorusGeometry(r, tube, 6, seg); g.rotateY(Math.PI / 2); return g; }
|
|
1598
|
+
/* 把一块板件按「表面点 + 法线」贴上去(R3 的统一入口) */
|
|
1599
|
+
function plate(x, phi, out, w, h, thick, m) {
|
|
1600
|
+
var p = surf(x, phi, out), n = surfNrm(phi, x);
|
|
1601
|
+
var mesh = new T.Mesh(slabGeo(w, h, thick, Math.min(0.04, thick * 0.3)), m);
|
|
1602
|
+
mesh.position.copy(p);
|
|
1603
|
+
mesh.lookAt(p.clone().add(n));
|
|
1604
|
+
root.add(mesh);
|
|
1605
|
+
return mesh;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/* 铆钉收集器:全场共用一个 InstancedMesh(上万颗也不拖慢) */
|
|
1609
|
+
var rivets = [];
|
|
1610
|
+
function rivetAt(v, n) { rivets.push([v.x, v.y, v.z, n.x, n.y, n.z]); }
|
|
1611
|
+
function rivetSeam(x0, x1, phi, count, out) {
|
|
1612
|
+
var n = surfNrm(phi, (x0 + x1) / 2);
|
|
1613
|
+
for (var i = 0; i < count; i++) {
|
|
1614
|
+
var x = x0 + (x1 - x0) * (i / Math.max(1, count - 1));
|
|
1615
|
+
rivetAt(surf(x, phi, out), n);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
/* greeble 收集器:小方块沿结构线成组出现(R4),不随机撒 */
|
|
1619
|
+
var greebles = [];
|
|
1620
|
+
function greebleAt(v, n, w, h, d) {
|
|
1621
|
+
var zA = n.clone();
|
|
1622
|
+
var xA = new T.Vector3(0, 1, 0).cross(zA).normalize();
|
|
1623
|
+
if (xA.lengthSq() < 0.01) xA.set(1, 0, 0);
|
|
1624
|
+
var yA = zA.clone().cross(xA).normalize();
|
|
1625
|
+
greebles.push({ p: v, x: xA, y: yA, z: zA, w: w, h: h, d: d });
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
/* ═══ ① 基壳:整条放样体 —— 它只从蒙皮板的缝里露出,所以把它做成「会发光的能量层」═══
|
|
1629
|
+
▸ 未来感的关键判断:用户已认可精细度,不能再加部件(只会更乱),
|
|
1630
|
+
也不能改轮廓(会破坏 Firefly 保真)。**唯一的杠杆是光**。
|
|
1631
|
+
▸ 而我们的板缝是**真实建出来的几何**(R3),缝下这层基壳天然构成一张覆盖
|
|
1632
|
+
全船的光网 —— 等于免费拿到「能量在船体里流动」的效果。
|
|
1633
|
+
▸ 再用一条沿 x 传播的脉冲(uTime 由主循环驱动),把静止的网变成"活的"。 */
|
|
1634
|
+
var mEnergy = new T.ShaderMaterial({
|
|
1635
|
+
uniforms: {
|
|
1636
|
+
uTime: uTime, // 复用主循环的全局时间
|
|
1637
|
+
uCool: { value: new T.Color(0x2a7d92) }, // 缝隙常态:暗青
|
|
1638
|
+
uHot: { value: new T.Color(0x9df6ff) } // 脉冲峰值:亮青
|
|
1639
|
+
},
|
|
1640
|
+
vertexShader: [
|
|
1641
|
+
'varying vec3 vP;',
|
|
1642
|
+
'void main(){ vP = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }'
|
|
1643
|
+
].join('\n'),
|
|
1644
|
+
fragmentShader: [
|
|
1645
|
+
'uniform float uTime; uniform vec3 uCool, uHot; varying vec3 vP;',
|
|
1646
|
+
'void main(){',
|
|
1647
|
+
// 两条错开相位的纵向能量脉冲(一快一慢,避免节奏太机械)
|
|
1648
|
+
' float a = fract(vP.x * 0.055 - uTime * 0.20);',
|
|
1649
|
+
' float pa = smoothstep(0.0, 0.05, a) * (1.0 - smoothstep(0.05, 0.24, a));',
|
|
1650
|
+
' float b = fract(vP.x * 0.021 + uTime * 0.12);',
|
|
1651
|
+
' float pb = smoothstep(0.0, 0.09, b) * (1.0 - smoothstep(0.09, 0.34, b));',
|
|
1652
|
+
' float g = 0.20 + 0.90 * max(pa, pb * 0.72);',
|
|
1653
|
+
' gl_FragColor = vec4(mix(uCool, uHot, clamp(g, 0.0, 1.0)), 1.0);',
|
|
1654
|
+
'}'
|
|
1655
|
+
].join('\n')
|
|
1656
|
+
});
|
|
1657
|
+
/* ⚠️ 调色警告(本轮实测认知,勿凭 hex 直觉调):自定义 ShaderMaterial **不会**
|
|
1658
|
+
走 three 的 tone mapping / 输出色彩空间转换(那两步只写在 ShaderMaterial 的
|
|
1659
|
+
内置 chunk 里),gl_FragColor 是原样写进帧缓冲的。而本场景开着
|
|
1660
|
+
ACESFilmicToneMapping + outputColorSpace=SRGB ⇒
|
|
1661
|
+
· 同一个 hex,在自定义 shader 里比在 MeshBasicMaterial 里**更亮更饱和**
|
|
1662
|
+
· `new T.Color(0x2a7d92)` 送进 shader 后,屏幕上大致落在 #063449 一档
|
|
1663
|
+
⇒ 结论:这两个颜色只能对着**渲染结果**调,不能对着色卡调。
|
|
1664
|
+
(本文件里的 app.js 星场 shader 也是同一约定,全场景自洽。) */
|
|
1665
|
+
var baseGeo = hullPatchGeo(HULL_X0, HULL_X1, 0, Math.PI * 2, 0, 72, 72);
|
|
1666
|
+
var baseHull = new T.Mesh(baseGeo, mEnergy);
|
|
1667
|
+
root.add(baseHull);
|
|
1668
|
+
// 前端钝面封盖(斜切面),别让曲面收成一点 —— 参考图要求"有宽度的钝前缘"
|
|
1669
|
+
var capHull = new T.Mesh(hullCapGeo(HULL_X1, 0, Math.PI * 2, 0, 48), mEnergy);
|
|
1670
|
+
root.add(capHull);
|
|
1671
|
+
var capPlate = new T.Mesh(hullCapGeo(HULL_X1, 0, Math.PI * 2, PLATE_OFF, 48), mPanel);
|
|
1672
|
+
root.add(capPlate);
|
|
1673
|
+
|
|
1674
|
+
/* ═══ ② 蒙皮:沿 x 分 13 段 × 周向 6 块,板间留缝 ⇒ 真实刻线 ═══
|
|
1675
|
+
⚠️ 段数从 12 加到 13(补球鼻段)是 ① 的必要配套:
|
|
1676
|
+
原 12 段只铺到 x=6.25,而型线一直到船首末端 ⇒ 船首那一大段**没有蒙皮板**,
|
|
1677
|
+
直接露出基壳。旧版基壳是暗哑光材质,露出来没人看得出来;
|
|
1678
|
+
本轮基壳改成**发光能量层**后,船首会变成一大块发光体 ——
|
|
1679
|
+
差分像素法实测:摘掉基壳全船掉 0.968(占飞船总贡献 3.586 的 27%),
|
|
1680
|
+
远超"只从缝里漏光"应有的比例 ⇒ 正是这段裸奔的船首。
|
|
1681
|
+
补上首段后,基壳只从板缝露出,"光从缝里漏出来"这个概念才成立。 */
|
|
1682
|
+
var BANDS = [
|
|
1683
|
+
[-8.74, -7.30], [-7.20, -5.90], [-5.80, -4.70], [-4.60, -3.55],
|
|
1684
|
+
[-3.45, -2.20], [-2.10, -0.85], [-0.75, 0.55], [0.65, 1.95],
|
|
1685
|
+
[2.05, 3.20], [3.30, 4.25], [4.35, 5.25], [5.35, 6.25], [6.30, 7.21]
|
|
1686
|
+
];
|
|
1687
|
+
var bi, pi;
|
|
1688
|
+
for (bi = 0; bi < BANDS.length; bi++) {
|
|
1689
|
+
var x0 = BANDS[bi][0], x1 = BANDS[bi][1];
|
|
1690
|
+
for (pi = 0; pi < 6; pi++) {
|
|
1691
|
+
root.add(hullPlate(x0, x1, pi * phiStep + SEAM / 2, phiStep - SEAM, PLATE_OFF,
|
|
1692
|
+
(bi * 6 + pi) % 5 === 0 ? mPanel : mPlate, 20));
|
|
1693
|
+
}
|
|
1694
|
+
for (pi = 0; pi < 6; pi++) { // R4:铆钉只走板缝
|
|
1695
|
+
rivetSeam(x0, x1, pi * phiStep + SEAM / 2 - 0.06, 7, PLATE_OFF + 0.012);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
for (bi = 0; bi < BANDS.length - 1; bi++) {
|
|
1699
|
+
for (pi = 0; pi < 6; pi++) {
|
|
1700
|
+
rivetSeam(BANDS[bi][1] - 0.02, BANDS[bi][1] + 0.02, pi * phiStep + phiStep * 0.5, 2, PLATE_OFF + 0.012);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
/* ═══ ②′ 航道灯带:沿型线走的自发光带(**不能用直板**:要么悬空、要么埋进壳里)═══
|
|
1705
|
+
▸ 角度用 **φ_hull**(hullPlate 已统一换算)。
|
|
1706
|
+
▸ 位置有三条硬约束,全部来自实测过的缺陷类(K4 埋没 / K10 遮挡):
|
|
1707
|
+
1. 舷窗排占住船体角 ±90°(窗框半高 0.245)⇒ 灯带必须让开
|
|
1708
|
+
2. 周向板缝在船体角 k·60°(本轮会发光)⇒ 灯带不能压缝,否则读成"缝变歪了"
|
|
1709
|
+
3. 短舱中心 y=1.02、半径 0.60 ⇒ 纯侧视遮挡带 y∈[0.42,1.62] ⇒ 上灯带取其上
|
|
1710
|
+
▸ 下灯带定在 φ=0.78:落在 0°~60° 那块板的中间偏下,距两条缝各 0.78/0.27 rad,
|
|
1711
|
+
距舷窗排 0.79 rad(y≈−1.23,远离窗框下沿 −0.245)—— 侧视全程可见。
|
|
1712
|
+
▸ 加色混合 + depthWrite:false ⇒ 读成「自发光通道」,而不是「贴了一条亮色板」。 */
|
|
1713
|
+
var stripMats = [];
|
|
1714
|
+
function stripMat(color, op) {
|
|
1715
|
+
var m = new T.MeshBasicMaterial({
|
|
1716
|
+
color: color, transparent: true, opacity: op,
|
|
1717
|
+
blending: T.AdditiveBlending, depthWrite: false, fog: false
|
|
1718
|
+
});
|
|
1719
|
+
stripMats.push({ m: m, base: op, phase: stripMats.length * 1.9 });
|
|
1720
|
+
return m;
|
|
1721
|
+
}
|
|
1722
|
+
var STRIP_OUT = PLATE_OFF + 0.055; // 略高于蒙皮板,避免与板共面
|
|
1723
|
+
var glowParts = []; // 本轮全部发光件(灯带 + 发光环)
|
|
1724
|
+
function strip(x0, x1, phi0, phiLen, out, mat) {
|
|
1725
|
+
var m = hullPlate(x0, x1, phi0, phiLen, out, mat, 14);
|
|
1726
|
+
root.add(m); glowParts.push(m); return m;
|
|
1727
|
+
}
|
|
1728
|
+
var mStripC = stripMat(0x7ff0ff, 0.85); // 主航道灯带:亮青
|
|
1729
|
+
var mStripW = stripMat(0xcfefff, 0.95); // 上舷灯带:冷白(贴轮廓线,靠亮度取胜)
|
|
1730
|
+
[1, -1].forEach(function (s) {
|
|
1731
|
+
// 下舷侧贯穿灯带(y≈−1.23):在舷窗排下方、两条板缝之间 ⇒ 纯侧视全程可见
|
|
1732
|
+
strip(-7.55, 6.35, s * 0.78 - 0.045, 0.090, STRIP_OUT, mStripC);
|
|
1733
|
+
// 上舷灯带(y≈1.76,贴着背脊两侧的轮廓线):在短舱遮挡带之上、太阳能板顶(≈1.65)之上、
|
|
1734
|
+
// 脊段(|z|≤0.43)之外。⚠️ 拆成首/尾两段:中段 x∈[-4.83,0.63] 是 3 片散热翼所在的 x 带,
|
|
1735
|
+
// 散热翼绕 X 偏转后最低角刚好压到同一条 y ⇒ 整段贯通会穿模。
|
|
1736
|
+
[[-7.20, -5.05], [0.85, 6.20]].forEach(function (xr) {
|
|
1737
|
+
strip(xr[0], xr[1], Math.PI + s * 0.30 - 0.045, 0.090, PLATE_OFF + 0.075, mStripW);
|
|
1738
|
+
});
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
/* ═══ ③ R2:模块过渡环 —— 段与段之间绝不硬接 ═══ */
|
|
1742
|
+
[-5.92, -4.58, -3.52, 2.02, 3.26, 4.32, -7.32].forEach(function (fx) {
|
|
1743
|
+
var rg = new T.Mesh(ringX(hullRadius(fx) + 0.105, 0.075, 30), mDark);
|
|
1744
|
+
rg.position.set(fx, 0, 0); rg.scale.set(1, KY, KZ); root.add(rg);
|
|
1745
|
+
for (var i = 0; i < 30; i++) { // 环两侧的紧固件 ⇒ 读成法兰对接
|
|
1746
|
+
var a = (i / 30) * Math.PI * 2;
|
|
1747
|
+
rivetAt(surf(fx, a, 0.19), surfNrm(a, fx));
|
|
1748
|
+
}
|
|
1749
|
+
});
|
|
1750
|
+
// 纵向桁条:**必须同时让开两条线**,否则本轮两处成果都会被打掉:
|
|
1751
|
+
// ① 周向板缝(6 条,船体角 k·60°)—— 桁条压上去会把 ① 的发光缝整条盖死;
|
|
1752
|
+
// ② 舷窗排(船体角 ±90°)—— 桁条管半径 0.032 与该处窗框同处一个径向带,会穿模。
|
|
1753
|
+
// 桁条落在「板缝 → 板中心」之间 1/5 处:距缝 0.209 rad、距舷窗 0.314 rad,两条线都让开,
|
|
1754
|
+
// 且仍是 6 条均布的结构加强筋(φ_hull 由 hullPlate 统一解释,见文件头角度约定)。
|
|
1755
|
+
for (pi = 0; pi < 6; pi++) {
|
|
1756
|
+
var sa = pi * phiStep + phiStep * 0.2, sp = [];
|
|
1757
|
+
for (var q = 0; q <= 10; q++) {
|
|
1758
|
+
var qv = surf(-8.5 + 14.0 * q / 10, sa, PLATE_OFF + 0.028);
|
|
1759
|
+
sp.push([qv.x, qv.y, qv.z]);
|
|
1760
|
+
}
|
|
1761
|
+
root.add(new T.Mesh(pipeGeo(sp, 0.032), mDark));
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
/* ═══ ④ 舰首:坞环 + 探针 + **贴合壳面的曲面座舱玻璃** ═══
|
|
1765
|
+
驾驶舱不能是「固定 y 值的球顶」(那样必然被前段壳体吞掉),
|
|
1766
|
+
而是直接在前上部壳体上做一段带框格的曲面玻璃舱。
|
|
1767
|
+
|
|
1768
|
+
分格按**官方总布置图**:一块被切角的大风挡,被**中央竖向框**分成左/右
|
|
1769
|
+
两大块,每块内再用**横向分隔条**切成数格。
|
|
1770
|
+
|
|
1771
|
+
★ 本轮随首部型线一起重定:首端从 x=7.90 收到 7.23、首部峰值从 1.80 压到 1.32,
|
|
1772
|
+
玻璃舱必须跟着缩到 [5.55, 7.00],否则前缘会伸到船体之外悬空。
|
|
1773
|
+
玻璃落在**首部斜切段的背脊侧**(noseSlant 让背脊前伸)⇒ 侧视时是一片
|
|
1774
|
+
带倾角的大风挡,而不是"圆脑门上一道横带"。 */
|
|
1775
|
+
var CX0 = 5.42, CX1 = 7.18, CSPAN = 1.26; // 玻璃舱 x 范围与半展角
|
|
1776
|
+
var MIDGAP = 0.075; // 中央竖向窗框半宽
|
|
1777
|
+
// 左/右两大块玻璃
|
|
1778
|
+
root.add(hullPlate(CX0, CX1, Math.PI + MIDGAP, CSPAN - MIDGAP, PLATE_OFF + 0.070, mGlass, 18));
|
|
1779
|
+
root.add(hullPlate(CX0, CX1, Math.PI - CSPAN, CSPAN - MIDGAP, PLATE_OFF + 0.070, mGlass, 18));
|
|
1780
|
+
// 横向分隔条 ×3:把每块大玻璃切成 4 格
|
|
1781
|
+
for (var hi = 1; hi <= 3; hi++) {
|
|
1782
|
+
var hx = CX0 + (CX1 - CX0) * hi / 4;
|
|
1783
|
+
root.add(hullPlate(hx - 0.026, hx + 0.026, Math.PI - CSPAN, 2 * CSPAN, PLATE_OFF + 0.096, mDark, 20));
|
|
1784
|
+
}
|
|
1785
|
+
// 中央竖向框 + 左右两条外边框
|
|
1786
|
+
root.add(hullPlate(CX0 - 0.04, CX1 + 0.04, Math.PI - MIDGAP, 2 * MIDGAP, PLATE_OFF + 0.098, mDark, 8));
|
|
1787
|
+
[Math.PI - CSPAN, Math.PI + CSPAN].forEach(function (fa2) {
|
|
1788
|
+
root.add(hullPlate(CX0 - 0.05, CX1 + 0.05, fa2 - 0.030, 0.060, PLATE_OFF + 0.098, mDark, 6));
|
|
1789
|
+
});
|
|
1790
|
+
[CX0 - 0.06, CX1 + 0.06].forEach(function (fx2) { // 前后缘框
|
|
1791
|
+
var fr = new T.Mesh(ringX(hullRadius(fx2) + PLATE_OFF + 0.055, 0.055, 34), mDark);
|
|
1792
|
+
fr.position.set(fx2, 0, 0); fr.scale.set(1, KY, KZ); root.add(fr);
|
|
1793
|
+
});
|
|
1794
|
+
// 顶部装甲脊:沿壳面一段抬高护条(防撞)。**必须让开座舱玻璃**:
|
|
1795
|
+
// 玻璃舱占首部背脊,旧写法正好横盖在玻璃正中央(且抬得比玻璃高 0.105)
|
|
1796
|
+
// ⇒ 读成"舱盖上压了根锈条"。现移到座舱**之后**的细颈背脊。
|
|
1797
|
+
root.add(hullPlate(4.40, 5.05, Math.PI - 0.30, 0.60, PLATE_OFF + 0.175, mRust, 10));
|
|
1798
|
+
// 对接环 + 探针阵列:解决「船首光秃秃一个锥体」
|
|
1799
|
+
// ⚠️ 本轮首部型线改了(首端从 x=7.90 收到 7.23,且做了斜切整形)⇒
|
|
1800
|
+
// 旧的 7.34/7.60/7.92 三个站位全部落到船体之外,必须一起前移。
|
|
1801
|
+
// 对接环落在首部**最粗处的稍前**(x=6.30)作为坞环,探针从坞环向前伸。
|
|
1802
|
+
var dock = new T.Mesh(ringX(hullRadius(6.30) + 0.075, 0.095, 24), mDark);
|
|
1803
|
+
dock.position.set(6.30, 0, 0); dock.scale.set(1, KY, KZ); root.add(dock);
|
|
1804
|
+
put(new T.Mesh(axCyl(0.26, 0.36, 0.34, 18), mPanel), 6.42, 0, 0);
|
|
1805
|
+
[0.95, -0.95].forEach(function (a) {
|
|
1806
|
+
var px = 6.55, py = Math.cos(a) * 0.52, pz = Math.sin(a) * 0.50;
|
|
1807
|
+
var pr = put(new T.Mesh(axCyl(0.015, 0.048, 1.35, 8), mRivet), px, py, pz);
|
|
1808
|
+
pr.rotation.z = 0.10;
|
|
1809
|
+
put(new T.Mesh(new T.SphereGeometry(0.042, 8, 6), mGlowB), px + 0.70, py + 0.10, pz);
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
/* ═══ ⑤ 颈部(3.3→5.2):外露管路,避免「收细」变成空洞 ═══ */
|
|
1813
|
+
[1, -1].forEach(function (s) {
|
|
1814
|
+
root.add(new T.Mesh(pipeGeo([
|
|
1815
|
+
[3.34, s * 0.50, s * 0.60], [3.95, s * 0.43, s * 0.56],
|
|
1816
|
+
[4.55, s * 0.38, s * 0.50], [5.10, s * 0.48, s * 0.58]
|
|
1817
|
+
], 0.045), mRust));
|
|
1818
|
+
root.add(new T.Mesh(pipeGeo([
|
|
1819
|
+
[3.38, -s * 0.28, s * 0.70], [4.10, -s * 0.26, s * 0.64], [4.80, -s * 0.32, s * 0.58]
|
|
1820
|
+
], 0.030), mDark));
|
|
1821
|
+
});
|
|
1822
|
+
|
|
1823
|
+
/* ═══ ⑥ 舷窗:**圆角矩形横窗 ×8 / 舷**(按官方总布置图 Port Outboard Profile)═══
|
|
1824
|
+
⚠️ 上一版做成「正圆 + 凸出的金属圆环窗套 + 圆形玻璃」是**我自己发明的**,
|
|
1825
|
+
与原著对不上(用户直接指出)。
|
|
1826
|
+
设定图实测:单排 **8 个**、**圆角矩形(横向长条,非正圆)**、沿腰线 φ=±π/2
|
|
1827
|
+
等距分布、位于**宽胸中段**(细颈之后 → 尾舱环之前)、窗高约为船体最大高度的 1/10。
|
|
1828
|
+
⇒ 本版改为**嵌入式方窗**:暗色窗框微凸 + 几乎齐平的玻璃,**取消圆环窗套**。 */
|
|
1829
|
+
var windows = [];
|
|
1830
|
+
function porthole(x, phi, w, h) {
|
|
1831
|
+
var out = PLATE_OFF + 0.030;
|
|
1832
|
+
var p = surf(x, phi, out), n = surfNrm(phi, x);
|
|
1833
|
+
// 窗框:比玻璃大一圈,略微凸出壳面
|
|
1834
|
+
var frame = new T.Mesh(slabGeo(w + 0.13, h + 0.13, 0.065, 0.020), mDark);
|
|
1835
|
+
frame.position.copy(p);
|
|
1836
|
+
frame.lookAt(p.clone().add(n)); // 局部 +Z=法线;对 φ=±π/2,局部 X=船体纵轴 ⇒ 天然横窗
|
|
1837
|
+
root.add(frame);
|
|
1838
|
+
// 玻璃:只比窗框外表面再高出一点,避免共面 z-fighting
|
|
1839
|
+
var glass = new T.Mesh(slabGeo(w, h, 0.045, 0.012), mGlass);
|
|
1840
|
+
var gp = p.clone().add(n.clone().multiplyScalar(0.018));
|
|
1841
|
+
glass.position.copy(gp);
|
|
1842
|
+
glass.lookAt(gp.clone().add(n));
|
|
1843
|
+
root.add(glass);
|
|
1844
|
+
// 窗框四角紧固件(R4:细节沿结构线走)
|
|
1845
|
+
[-1, 1].forEach(function (sx) {
|
|
1846
|
+
[-1, 1].forEach(function (sy) {
|
|
1847
|
+
var v = new T.Vector3(sx * (w / 2 + 0.062), sy * (h / 2 + 0.062), 0);
|
|
1848
|
+
rivetAt(v.applyQuaternion(frame.quaternion).add(p), n);
|
|
1849
|
+
});
|
|
1850
|
+
});
|
|
1851
|
+
return frame;
|
|
1852
|
+
}
|
|
1853
|
+
// 8 个站位:自细颈之后(x=-4.15)均匀排到尾舱环之前(x=2.65)
|
|
1854
|
+
(function () {
|
|
1855
|
+
var N = 8, X0 = -4.15, X1 = 2.65;
|
|
1856
|
+
for (var i = 0; i < N; i++) {
|
|
1857
|
+
var x = X0 + (X1 - X0) * i / (N - 1);
|
|
1858
|
+
[1, -1].forEach(function (s) { windows.push(porthole(x, s * Math.PI / 2, 0.72, 0.36)); });
|
|
1859
|
+
}
|
|
1860
|
+
})();
|
|
1861
|
+
|
|
1862
|
+
/* 蓝色太阳能板阵:设定图上成对成行布置在中段上侧(π±0.53) */
|
|
1863
|
+
var mSolar = new T.MeshStandardMaterial({
|
|
1864
|
+
color: 0x1b3f8f, metalness: 0.55, roughness: 0.26, envMapIntensity: 1.5
|
|
1865
|
+
});
|
|
1866
|
+
[Math.PI - 0.53, Math.PI + 0.53].forEach(function (phi) {
|
|
1867
|
+
for (var i = 0; i < 7; i++) {
|
|
1868
|
+
var sol = new T.Mesh(slabGeo(0.78, 0.40, 0.055, 0.018), mSolar);
|
|
1869
|
+
var sp = surf(-3.60 + i * 0.94, phi, PLATE_OFF + 0.026);
|
|
1870
|
+
sol.position.copy(sp);
|
|
1871
|
+
sol.lookAt(sp.clone().add(surfNrm(phi, -3.60 + i * 0.94)));
|
|
1872
|
+
root.add(sol);
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
|
|
1876
|
+
/* ═══ ⑦ 主货舱:腹部货舱门(贴壳)+ 已放下的坡道(真铰链 + 液压杆)═══ */
|
|
1877
|
+
root.add(hullPlate(2.30, 4.05, -0.44, 0.88, PLATE_OFF + 0.012, mPanel, 16)); // 舱门本身
|
|
1878
|
+
var hingeX = 4.00, hy = -hullRadius(hingeX) * KY - 0.03;
|
|
1879
|
+
[1, -1].forEach(function (s) {
|
|
1880
|
+
var hg = put(new T.Mesh(axCyl(0.085, 0.085, 0.34, 10), mDark), hingeX, hy, s * 1.00);
|
|
1881
|
+
hg.rotation.x = Math.PI / 2;
|
|
1882
|
+
var hp = new T.Mesh(pipeGeo([[3.45, hy + 0.30, s * 0.74], [4.30, hy - 0.36, s * 0.86]], 0.042), mRivet);
|
|
1883
|
+
root.add(hp); // 液压杆
|
|
1884
|
+
});
|
|
1885
|
+
var ramp = new T.Group();
|
|
1886
|
+
// 注意:Object3D.add() 返回的是**父对象**(this),不是子对象。
|
|
1887
|
+
// 写成 ramp.add(x).position.set(...) 会去挪 ramp 自己的位置 —— 必须先建后 add。
|
|
1888
|
+
var rampDeck = new T.Mesh(slabGeo(2.35, 0.17, 2.00, 0.045), mPanel);
|
|
1889
|
+
rampDeck.position.set(1.14, 0, 0); // 从铰链向前伸出
|
|
1890
|
+
ramp.add(rampDeck);
|
|
1891
|
+
for (var rr2 = 0; rr2 < 4; rr2++) {
|
|
1892
|
+
var rib2 = new T.Mesh(slabGeo(0.11, 0.22, 2.05, 0.028), mDark);
|
|
1893
|
+
rib2.position.set(0.34 + rr2 * 0.56, 0.10, 0);
|
|
1894
|
+
ramp.add(rib2);
|
|
1895
|
+
}
|
|
1896
|
+
[1, -1].forEach(function (s) { // 坡道面危险条纹(真贴花)
|
|
1897
|
+
var hz = new T.Mesh(new T.PlaneGeometry(1.42, 0.30), new T.MeshStandardMaterial({
|
|
1898
|
+
map: decalHaz, transparent: true, metalness: 0.3, roughness: 0.7,
|
|
1899
|
+
depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3
|
|
1900
|
+
}));
|
|
1901
|
+
hz.position.set(1.14, 0.10, s * 1.02);
|
|
1902
|
+
if (s < 0) hz.rotation.y = Math.PI;
|
|
1903
|
+
ramp.add(hz);
|
|
1904
|
+
});
|
|
1905
|
+
ramp.position.set(hingeX, hy, 0);
|
|
1906
|
+
ramp.rotation.z = -0.44;
|
|
1907
|
+
root.add(ramp);
|
|
1908
|
+
// EVA 舱门:贴壳放置。**必须让开腰线**——腰线 φ=±π/2 已被 8 个舷窗占满,
|
|
1909
|
+
// 故移到舷窗段之后的尾部舱体(x=-5.55,位于 -5.92 环与 -4.58 环之间)。
|
|
1910
|
+
[1, -1].forEach(function (s) {
|
|
1911
|
+
var phi = s > 0 ? Math.PI / 2 : -Math.PI / 2;
|
|
1912
|
+
var hatch = plate(-5.55, phi, PLATE_OFF + 0.045, 1.05, 0.74, 0.11, mPanel);
|
|
1913
|
+
var p0 = hatch.position, n0 = surfNrm(phi, -5.55);
|
|
1914
|
+
var hb = new T.Mesh(new T.TorusGeometry(0.12, 0.026, 6, 14), mRivet);
|
|
1915
|
+
hb.position.copy(p0).add(n0.clone().multiplyScalar(0.075));
|
|
1916
|
+
hb.lookAt(p0.clone().add(n0.clone().multiplyScalar(2)));
|
|
1917
|
+
root.add(hb);
|
|
1918
|
+
});
|
|
1919
|
+
|
|
1920
|
+
/* ═══ ⑧ 腹部机房:散热格栅(贴壳)+ 成组 greeble(R4)═══ */
|
|
1921
|
+
for (var gf = 0; gf < 3; gf++) {
|
|
1922
|
+
var gxx = -3.10 - gf * 0.62;
|
|
1923
|
+
plate(gxx, 0, PLATE_OFF + 0.02, 0.50, 1.30, 0.09, mRust);
|
|
1924
|
+
var belly = surf(gxx, 0, 0); // φ=0 就是腹部
|
|
1925
|
+
for (var bl = 0; bl < 6; bl++) {
|
|
1926
|
+
var blade = new T.Mesh(slabGeo(0.42, 0.10, 0.045, 0.012), mDark);
|
|
1927
|
+
blade.position.set(gxx, belly.y - 0.075, -0.55 + bl * 0.22);
|
|
1928
|
+
root.add(blade);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
// 贴着腹部结构线成组的检修件(按结构线分布,不是随机撒)
|
|
1932
|
+
var GREEBLE_LINES = [[-3.40, 0.95], [-2.20, 0.95], [-1.00, 0.95], [0.20, 0.95], [1.40, 0.95],
|
|
1933
|
+
[-3.00, 2.30], [-1.60, 2.30], [-0.20, 2.30], [1.20, 2.30]];
|
|
1934
|
+
GREEBLE_LINES.forEach(function (gl, idx) {
|
|
1935
|
+
for (var g2 = 0; g2 < 3; g2++) {
|
|
1936
|
+
var ph2 = gl[1] + g2 * 0.14 - 0.14;
|
|
1937
|
+
var pv = surf(gl[0] + g2 * 0.30, ph2, PLATE_OFF);
|
|
1938
|
+
greebleAt(pv, surfNrm(ph2, gl[0] + g2 * 0.30), 0.16 + R() * 0.26, 0.10 + R() * 0.13, 0.09 + R() * 0.14);
|
|
1939
|
+
}
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
/* ═══ ⑨ 尾部反应堆:膨大 + 散热鳍 + 主喷口 + 热变色 + 延伸杆 + 桁架 ═══
|
|
1943
|
+
⚠️ 本节 4 处部件原本**整个埋在壳体里**(K4 缺陷类:部件半径 < 所在站位母体半径)。
|
|
1944
|
+
成因:尾段型线最粗处 hullRadius(-6.62)=2.26(y 向半高 2.26×0.92=2.08),
|
|
1945
|
+
而旧代码把环/鳍/喷口按「固定的 1.42/1.60/1.06」摆 —— 全部小于 2.08。 */
|
|
1946
|
+
var drive = put(new T.Mesh(new T.SphereGeometry(1.55, 26, 18), mPanel), -6.62, 0, 0);
|
|
1947
|
+
drive.scale.set(1.42, 0.98, 0.98);
|
|
1948
|
+
[-7.50, -6.62, -5.72].forEach(function (hx) { // 反应堆环带(热变色)
|
|
1949
|
+
// 旧:ringX(1.42 − i2*0.05, …) ⇒ 半径 1.32~1.42 < 壳体 2.08 ⇒ 全埋
|
|
1950
|
+
// 新:贴着该站位的壳面(+0.075 让管心半嵌在蒙皮板里,读成"箍带"而非浮环)
|
|
1951
|
+
var hr = new T.Mesh(ringX(hullRadius(hx) + 0.075, 0.055, 28), mHot);
|
|
1952
|
+
hr.position.set(hx, 0, 0); hr.scale.set(1, KY, KZ); root.add(hr);
|
|
1953
|
+
});
|
|
1954
|
+
for (var f2 = 0; f2 < 18; f2++) { // 散热鳍:沿周向均匀
|
|
1955
|
+
var fa = (f2 / 18) * Math.PI * 2;
|
|
1956
|
+
// 旧:固定半径 1.60 ⇒ 整片鳍埋在 2.08 的壳里;新:由型线参数化取位置与朝向。
|
|
1957
|
+
// 朝向推导:surfPoint 的径向 ∝ (0, −cosφ, sinφ),绕 X 转 α 后局部 +Z = (0, −sinα, cosα)
|
|
1958
|
+
// ⇒ 令二者同向得 α = π/2 − φ。非均一缩放下用 lookAt 会因 up 退化而产生任意滚转,
|
|
1959
|
+
// 故此处**不用 lookAt**,直接给解析角。
|
|
1960
|
+
var fp = surf(-6.62, fa, PLATE_OFF + 0.20);
|
|
1961
|
+
var fin = put(new T.Mesh(slabGeo(2.35, 0.085, 0.44, 0.02), mDark), fp.x, fp.y, fp.z);
|
|
1962
|
+
fin.rotation.x = Math.PI / 2 - fa;
|
|
1963
|
+
}
|
|
1964
|
+
put(new T.Mesh(new T.CylinderGeometry(1.06, 0.86, 1.05, 26, 1, true), mHot), -8.30, 0, 0).rotation.z = -Math.PI / 2;
|
|
1965
|
+
put(new T.Mesh(ringX(1.03, 0.075, 26), mRivet), -8.84, 0, 0);
|
|
1966
|
+
put(new T.Mesh(axCyl(0.86, 0.98, 0.30, 26), mDark), -8.93, 0, 0);
|
|
1967
|
+
// 主喷口发光环:主喷口(半径 1.06)从船尾开口(型线末端 r=0.42)伸出,
|
|
1968
|
+
// 只靠一个铆钉环读不出"引擎在工作" ⇒ 加一圈自发光环(③ 的同族语汇)
|
|
1969
|
+
var mainGlow = new T.Mesh(ringX(1.075, 0.060, 30), stripMat(0x9fe8ff, 0.95));
|
|
1970
|
+
mainGlow.position.set(-8.87, 0, 0);
|
|
1971
|
+
root.add(mainGlow); glowParts.push(mainGlow);
|
|
1972
|
+
[[0.92, 1.85], [-0.92, 1.85], [1.42, -1.22], [-1.42, -1.22], [0, -1.98]].forEach(function (p2, i3) {
|
|
1973
|
+
var rod = put(new T.Mesh(axCyl(0.05, 0.085, 2.9, 8), mRust), -9.30 - (i3 % 2) * 0.55, p2[0], p2[1]);
|
|
1974
|
+
rod.rotation.z = 0.03;
|
|
1975
|
+
});
|
|
1976
|
+
// R2:反应堆与主货舱之间的桁架过渡(6 根撑杆)
|
|
1977
|
+
[0, Math.PI / 3, 2 * Math.PI / 3, Math.PI, 4 * Math.PI / 3, 5 * Math.PI / 3].forEach(function (a3) {
|
|
1978
|
+
var p1 = surf(-5.02, a3, 0.10);
|
|
1979
|
+
root.add(new T.Mesh(pipeGeo([
|
|
1980
|
+
[p1.x, p1.y, p1.z], [-5.55, Math.cos(a3) * 1.72, Math.sin(a3) * 1.72],
|
|
1981
|
+
[-6.05, Math.cos(a3) * 1.78, Math.sin(a3) * 1.78]
|
|
1982
|
+
], 0.045), mDark));
|
|
1983
|
+
});
|
|
1984
|
+
|
|
1985
|
+
/* ═══ ⑩ 背脊:贴壳脊段(分段贴合,不再用一根直梁硬撑)═══ */
|
|
1986
|
+
for (var sx = -4.80; sx < 2.50; sx += 0.62) {
|
|
1987
|
+
var sxc = sx + 0.31;
|
|
1988
|
+
var top = surf(sxc, Math.PI, PLATE_OFF);
|
|
1989
|
+
var seg = new T.Mesh(slabGeo(0.58, 0.34, 0.86, 0.05), mDark);
|
|
1990
|
+
seg.position.set(sxc, top.y + 0.11, 0);
|
|
1991
|
+
root.add(seg);
|
|
1992
|
+
if (((sx + 4.80) / 0.62) % 4 < 1) { // 每 4 段插一个检修舱盖
|
|
1993
|
+
var hcap = new T.Mesh(slabGeo(0.50, 0.16, 0.66, 0.035), mPanel);
|
|
1994
|
+
hcap.position.set(sxc, top.y + 0.30, 0);
|
|
1995
|
+
root.add(hcap);
|
|
1996
|
+
for (var i4 = 0; i4 < 6; i4++) {
|
|
1997
|
+
var aa = (i4 / 6) * Math.PI * 2 + 0.3;
|
|
1998
|
+
rivetAt(new T.Vector3(sxc + Math.cos(aa) * 0.19, top.y + 0.38, Math.sin(aa) * 0.26),
|
|
1999
|
+
new T.Vector3(0, 1, 0));
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
// 散热翼:三片,有明确功能暗示(带支撑臂)
|
|
2004
|
+
[0, 1, 2].forEach(function (i5) {
|
|
2005
|
+
var rx2 = -3.55 + i5 * 1.45;
|
|
2006
|
+
var tp = surf(rx2, Math.PI, PLATE_OFF);
|
|
2007
|
+
var rad2 = new T.Mesh(slabGeo(2.55, 0.07, 1.30, 0.02), mPanel);
|
|
2008
|
+
rad2.position.set(rx2, tp.y + 0.52, 0.34);
|
|
2009
|
+
rad2.rotation.z = -0.26 - i5 * 0.06; rad2.rotation.x = 0.20;
|
|
2010
|
+
root.add(rad2);
|
|
2011
|
+
var arm = new T.Mesh(slabGeo(0.16, 0.46, 0.16, 0.03), mDark);
|
|
2012
|
+
arm.position.set(rx2, tp.y + 0.26, 0.30);
|
|
2013
|
+
root.add(arm);
|
|
2014
|
+
});
|
|
2015
|
+
// 天线(tick 让它绕 Y 转)
|
|
2016
|
+
var radar = new T.Mesh(slabGeo(0.98, 0.09, 0.13, 0.025), mRivet);
|
|
2017
|
+
radar.position.set(-5.30, surf(-5.30, Math.PI, PLATE_OFF).y + 0.40, 0);
|
|
2018
|
+
radar.rotation.z = 0.12;
|
|
2019
|
+
root.add(radar);
|
|
2020
|
+
put(new T.Mesh(axCyl(0.032, 0.048, 0.42, 8), mDark),
|
|
2021
|
+
-5.30, surf(-5.30, Math.PI, PLATE_OFF).y + 0.16, 0);
|
|
2022
|
+
|
|
2023
|
+
/* ═══ ⑪ 两侧短舱(Firefly 的第二号识别特征)═══
|
|
2024
|
+
★ 历史修正一:短舱必须**抬到腰线以上**,否则会把整排舷窗挡死
|
|
2025
|
+
(旧版短舱中心在 y=0、z=±3.42,正好盖在 z≈1.6 的舷窗正前方,实测挡掉 5/8)。
|
|
2026
|
+
★ 历史修正二(本轮):抬上去之后又**太贴身、太细**了 —— 侧视时与船体轮廓糊在一起,
|
|
2027
|
+
近景 VLM 直接判定"看不出有外挂短舱"。真实 Firefly 的短舱是挂在**粗短翼**上、
|
|
2028
|
+
明显甩在船体轮廓**之外**的一对圆柱。
|
|
2029
|
+
⇒ 本轮把短舱从 z=±3.30 甩到 **±4.25**(船体最宽处 z≈2.45 ⇒ 留出 1.0 的明确间隙)、
|
|
2030
|
+
半径从 0.60 加到 **0.80**、挂架从 2.05 加长到 3.30 读成"翼"。
|
|
2031
|
+
甩出去之后舷窗遮挡风险进一步下降(舷窗在 z≈±1.9)。 */
|
|
2032
|
+
/* ★ 历史修正三(本轮):船体半径 ×1.15 加粗后,舷窗从 z≈1.88 外移到 z≈2.16,
|
|
2033
|
+
侧视时视线更贴近短舱 ⇒ 实测舷窗可见性从 8/8 掉到 **2/8**(短舱挡住 6 个)。
|
|
2034
|
+
射线上验算:相机在 (0,6,52) 略微俯视,视线到舷窗时在短舱所在的 z≈4.45 处
|
|
2035
|
+
y≈0.27,而短舱(中心 y=0.95、半径 0.88)在 y∈[0.07,1.83] ⇒ 正好挡住。
|
|
2036
|
+
把短舱抬到 y=1.48(下沿 +0.60 > 视线高度)即可让视线从短舱**下方**通过,
|
|
2037
|
+
而这同时更贴近真实 Firefly 的「上肩部短翼挂引擎舱」形态。
|
|
2038
|
+
▸ 实测方式(可复用):**不用重新构建**,直接在页面里改 `ud.nacelles[i].position.y`
|
|
2039
|
+
做增量扫描 —— dy=0 时 3/8,dy=+0.2 起四个机位全部 8/8。 */
|
|
2040
|
+
var NAC_Y = 1.48, NAC_Z = 4.45, NAC_PHI = 2.10, NAC_X = -0.90, NAC_R = 0.88;
|
|
2041
|
+
var nacelles = [];
|
|
2042
|
+
[1, -1].forEach(function (s) {
|
|
2043
|
+
var phi = s > 0 ? NAC_PHI : -NAC_PHI;
|
|
2044
|
+
var g = new T.Group();
|
|
2045
|
+
// 法兰:挂架与壳体的对接板(贴壳,解决「硬怼」)
|
|
2046
|
+
var rootP = surf(NAC_X, phi, PLATE_OFF + 0.05), rootN = surfNrm(phi, NAC_X);
|
|
2047
|
+
var flange = new T.Mesh(slabGeo(1.85, 0.68, 0.19, 0.05), mRivet);
|
|
2048
|
+
flange.position.copy(rootP);
|
|
2049
|
+
flange.lookAt(rootP.clone().add(rootN));
|
|
2050
|
+
root.add(flange);
|
|
2051
|
+
// 主翼:自上肩部向外伸到短舱。**要读成"短翼"而不是"贴片"**(用户/VLM 反复指出
|
|
2052
|
+
// 短舱像"用螺栓钉上去的独立模块")⇒ 加厚翼根整流罩 + 前缘倒角 + 明显的上下斜撑。
|
|
2053
|
+
var pyl = new T.Mesh(slabGeo(2.10, 0.44, 3.30, 0.07), mDark);
|
|
2054
|
+
pyl.position.set(NAC_X, NAC_Y - 0.20, s * 2.75);
|
|
2055
|
+
pyl.rotation.x = -s * 0.14;
|
|
2056
|
+
g.add(pyl);
|
|
2057
|
+
// 翼根整流罩:把翼与壳体的交界做成一个鼓包(消除"硬怼"的读感)
|
|
2058
|
+
var fair = new T.Mesh(slabGeo(2.55, 0.78, 1.15, 0.14, 0.42), mPanel);
|
|
2059
|
+
fair.position.set(NAC_X, NAC_Y - 0.34, s * 1.35);
|
|
2060
|
+
fair.rotation.x = -s * 0.10;
|
|
2061
|
+
g.add(fair);
|
|
2062
|
+
// 前缘:一条从壳体前伸到短舱的薄整流边
|
|
2063
|
+
g.add(new T.Mesh(pipeGeo([
|
|
2064
|
+
[NAC_X + 1.05, NAC_Y - 0.16, s * 1.15], [NAC_X + 0.35, NAC_Y - 0.10, s * 2.60],
|
|
2065
|
+
[NAC_X - 0.55, NAC_Y - 0.06, s * 3.95]
|
|
2066
|
+
], 0.075), mPanel));
|
|
2067
|
+
// 斜撑桁架 ×2:把翼读成结构而非「贴上去的板」
|
|
2068
|
+
g.add(new T.Mesh(pipeGeo([
|
|
2069
|
+
[NAC_X + 0.92, NAC_Y + 0.26, s * 1.30], [NAC_X + 0.30, NAC_Y + 0.36, s * 2.70],
|
|
2070
|
+
[NAC_X - 0.52, NAC_Y + 0.28, s * 3.95]
|
|
2071
|
+
], 0.050), mRust));
|
|
2072
|
+
g.add(new T.Mesh(pipeGeo([
|
|
2073
|
+
[NAC_X + 0.92, NAC_Y - 0.42, s * 1.30], [NAC_X + 0.30, NAC_Y - 0.48, s * 2.65],
|
|
2074
|
+
[NAC_X - 0.52, NAC_Y - 0.30, s * 3.90]
|
|
2075
|
+
], 0.050), mRust));
|
|
2076
|
+
// 短舱本体 + 三段加强环(环上带铆钉)
|
|
2077
|
+
var body = new T.Mesh(axCyl(NAC_R, NAC_R, 4.30, 26), mPlate);
|
|
2078
|
+
body.position.set(NAC_X, NAC_Y, s * NAC_Z); g.add(body);
|
|
2079
|
+
[-1.75, -0.20, 1.35].forEach(function (o2) {
|
|
2080
|
+
var bd = new T.Mesh(ringX(NAC_R + 0.045, 0.045, 24), mDark);
|
|
2081
|
+
bd.position.set(NAC_X + o2, NAC_Y, s * NAC_Z); g.add(bd);
|
|
2082
|
+
for (var i6 = 0; i6 < 16; i6++) {
|
|
2083
|
+
var a6 = (i6 / 16) * Math.PI * 2;
|
|
2084
|
+
rivetAt(new T.Vector3(NAC_X + o2, NAC_Y + Math.cos(a6) * (NAC_R + 0.065), s * NAC_Z + Math.sin(a6) * (NAC_R + 0.065)),
|
|
2085
|
+
new T.Vector3(0, Math.cos(a6), Math.sin(a6)));
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
// 进气道:喉部 + 唇口环 + 内部格栅
|
|
2089
|
+
var intake = new T.Mesh(axCyl(NAC_R + 0.04, 0.46, 0.85, 24), mDark);
|
|
2090
|
+
intake.position.set(NAC_X + 2.44, NAC_Y, s * NAC_Z); g.add(intake);
|
|
2091
|
+
// ⚠️ 唇口/尾口两个环的半径必须**大于当地锥面半径**(进气道口 NAC_R+0.04 / 喷口 NAC_R+0.06),
|
|
2092
|
+
// 旧值都小于锥面 ⇒ 整环埋没(K4 缺陷类)。
|
|
2093
|
+
// 且发光环比金属环**再大一圈**:同 x 处金属环若半径更大,会在侧视时把发光环挡住
|
|
2094
|
+
// (实测:金属 0.71 + 发光 0.655 同 x ⇒ 发光环贡献从 0.011 掉到 0.0001)。
|
|
2095
|
+
var lip = new T.Mesh(ringX(NAC_R + 0.085, 0.055, 24), mRivet);
|
|
2096
|
+
lip.position.set(NAC_X + 2.83, NAC_Y, s * NAC_Z); g.add(lip);
|
|
2097
|
+
// ③ 进气道唇口发光环:套在金属唇环**外面** ⇒ 读成"口沿一圈能量光环"
|
|
2098
|
+
var lipGlow = new T.Mesh(ringX(NAC_R + 0.150, 0.050, 26), stripMat(0x8ff2ff, 0.92));
|
|
2099
|
+
lipGlow.position.set(NAC_X + 2.83, NAC_Y, s * NAC_Z); g.add(lipGlow); glowParts.push(lipGlow);
|
|
2100
|
+
for (var gr = 0; gr < 5; gr++) {
|
|
2101
|
+
var gb = new T.Mesh(slabGeo(0.05, NAC_R * 1.45, 0.05, 0.012), mRust);
|
|
2102
|
+
gb.position.set(NAC_X + 2.32, NAC_Y, s * NAC_Z - NAC_R * 0.58 + gr * NAC_R * 0.29); g.add(gb);
|
|
2103
|
+
}
|
|
2104
|
+
// 尾部喷口(热变色)
|
|
2105
|
+
var noz = new T.Mesh(axCyl(NAC_R - 0.04, NAC_R + 0.06, 0.75, 24), mHot);
|
|
2106
|
+
noz.position.set(NAC_X - 2.40, NAC_Y, s * NAC_Z); g.add(noz);
|
|
2107
|
+
var nzr = new T.Mesh(ringX(NAC_R + 0.105, 0.050, 24), mRivet);
|
|
2108
|
+
nzr.position.set(NAC_X - 2.78, NAC_Y, s * NAC_Z); g.add(nzr);
|
|
2109
|
+
// ③ 尾喷口发光环(琥珀色 —— 与红焰同色系,让"推力"从短舱里读得出来)
|
|
2110
|
+
var nozGlow = new T.Mesh(ringX(NAC_R + 0.170, 0.050, 26), stripMat(0xffb877, 0.90));
|
|
2111
|
+
nozGlow.position.set(NAC_X - 2.78, NAC_Y, s * NAC_Z); g.add(nozGlow); glowParts.push(nozGlow);
|
|
2112
|
+
// R2:回连管路 —— 短舱到船体的功能连接
|
|
2113
|
+
g.add(new T.Mesh(pipeGeo([
|
|
2114
|
+
[NAC_X - 0.60, NAC_Y + 0.10, s * (NAC_Z - 0.16)], [NAC_X - 0.32, NAC_Y + 0.16, s * 3.05],
|
|
2115
|
+
[NAC_X - 0.14, NAC_Y - 0.10, s * 2.05], [NAC_X + 0.04, NAC_Y - 0.26, s * 1.45]
|
|
2116
|
+
], 0.052), mRust));
|
|
2117
|
+
// 短舱船名贴花
|
|
2118
|
+
var nm = new T.Mesh(new T.PlaneGeometry(2.05, 0.39), new T.MeshStandardMaterial({
|
|
2119
|
+
map: decalName, transparent: true, metalness: 0.3, roughness: 0.66,
|
|
2120
|
+
depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3
|
|
2121
|
+
}));
|
|
2122
|
+
nm.position.set(NAC_X - 0.35, NAC_Y, s * (NAC_Z + NAC_R + 0.03));
|
|
2123
|
+
if (s < 0) nm.rotation.y = Math.PI;
|
|
2124
|
+
g.add(nm);
|
|
2125
|
+
nacelles.push(g); root.add(g);
|
|
2126
|
+
});
|
|
2127
|
+
// 舷号贴花:**必须让开腰线**(φ=±π/2 已被 8 个舷窗占满)。
|
|
2128
|
+
// 移到船头下方(φ=±0.60)—— 那片壳面是空的,且侧视时正好在驾驶舱下方可见。
|
|
2129
|
+
[1, -1].forEach(function (s) {
|
|
2130
|
+
var phi = s * 0.60;
|
|
2131
|
+
var dp = surf(6.30, phi, PLATE_OFF + 0.050);
|
|
2132
|
+
var rg2 = new T.Mesh(new T.PlaneGeometry(0.86, 0.34), new T.MeshStandardMaterial({
|
|
2133
|
+
map: decalReg, transparent: true, metalness: 0.3, roughness: 0.66,
|
|
2134
|
+
depthWrite: false, polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3
|
|
2135
|
+
}));
|
|
2136
|
+
rg2.position.copy(dp);
|
|
2137
|
+
rg2.lookAt(dp.clone().add(surfNrm(phi, 6.30)));
|
|
2138
|
+
root.add(rg2);
|
|
2139
|
+
});
|
|
2140
|
+
|
|
2141
|
+
/* ═══ ⑫ 上甲板穿梭艇:托架与船体相连(不再是浮在旁边的球)═══ */
|
|
2142
|
+
var shuttles = [];
|
|
2143
|
+
[1, -1].forEach(function (s) {
|
|
2144
|
+
var sh = new T.Group();
|
|
2145
|
+
var pod = new T.Mesh(slabGeo(2.10, 0.72, 1.16, 0.16, 0.30), mPlate);
|
|
2146
|
+
pod.position.set(0.05, 0, 0); sh.add(pod);
|
|
2147
|
+
var nose = new T.Mesh(new T.SphereGeometry(0.58, 18, 12), mPlate);
|
|
2148
|
+
nose.scale.set(1.05, 0.62, 0.98); nose.position.set(1.15, 0.02, 0); sh.add(nose);
|
|
2149
|
+
var ck2 = new T.Mesh(slabGeo(0.78, 0.30, 0.90, 0.05), mGlass);
|
|
2150
|
+
ck2.position.set(1.02, 0.28, 0); sh.add(ck2);
|
|
2151
|
+
var fin3 = new T.Mesh(slabGeo(0.66, 0.52, 0.055, 0.018), mDark);
|
|
2152
|
+
fin3.position.set(-1.02, 0.42, 0); sh.add(fin3);
|
|
2153
|
+
var eng = new T.Mesh(axCyl(0.19, 0.24, 0.52, 14), mHot);
|
|
2154
|
+
eng.position.set(-1.30, 0, 0); sh.add(eng);
|
|
2155
|
+
// 托架:把艇「架」在肩部壳体上(R2)
|
|
2156
|
+
var cra = new T.Mesh(slabGeo(2.20, 0.40, 0.82, 0.05), mDark);
|
|
2157
|
+
cra.position.set(0, -0.66, s * -0.14); sh.add(cra);
|
|
2158
|
+
var shp = surf(1.66, s > 0 ? 2.05 : -2.05, 0.06);
|
|
2159
|
+
sh.position.set(1.66, shp.y + 0.86, s * 1.72);
|
|
2160
|
+
shuttles.push(sh); root.add(sh);
|
|
2161
|
+
// 支撑立柱:艇架 → 壳体肩部
|
|
2162
|
+
root.add(new T.Mesh(pipeGeo([
|
|
2163
|
+
[1.05, shp.y + 0.30, s * 1.60], [1.66, shp.y + 0.62, s * 1.70], [2.25, shp.y + 0.30, s * 1.60]
|
|
2164
|
+
], 0.045), mDark));
|
|
2165
|
+
});
|
|
2166
|
+
|
|
2167
|
+
/* ═══ ⑬ 尾焰:轴向分段(近红远蓝),FrontSide 保色相 ═══ */
|
|
2168
|
+
function flameMat(color, op) {
|
|
2169
|
+
// DoubleSide 会让锥体前后面片在加色混合下各加一次,红焰溢出成黄;
|
|
2170
|
+
// 单层面片才保得住色相,体积感交给 glow 精灵。
|
|
2171
|
+
return new T.MeshBasicMaterial({
|
|
2172
|
+
color: color, transparent: true, opacity: op,
|
|
2173
|
+
blending: T.AdditiveBlending, depthWrite: false, side: T.FrontSide, fog: false
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
var flameRed = new T.Mesh(axCyl(1.05, 0.72, 4.4, 22), flameMat(PAL.flameRed, 0.80));
|
|
2177
|
+
flameRed.position.set(-11.0, 0, 0); root.add(flameRed);
|
|
2178
|
+
var flameBlue = new T.Mesh(axCyl(0.72, 0.10, 9.2, 22), flameMat(PAL.flameBlue, 0.62));
|
|
2179
|
+
flameBlue.position.set(-17.9, 0, 0); root.add(flameBlue);
|
|
2180
|
+
var nacFlames = [];
|
|
2181
|
+
[1, -1].forEach(function (s) {
|
|
2182
|
+
var f3 = new T.Mesh(axCyl(0.50, 0.08, 5.0, 18), flameMat(PAL.flameRed, 0.82));
|
|
2183
|
+
f3.position.set(NAC_X - 3.05, NAC_Y, s * NAC_Z); root.add(f3); nacFlames.push(f3);
|
|
2184
|
+
});
|
|
2185
|
+
|
|
2186
|
+
var glowR = new T.Sprite(new T.SpriteMaterial({
|
|
2187
|
+
map: dotTex, color: 0xff3a10, transparent: true, opacity: 0.26,
|
|
2188
|
+
blending: T.AdditiveBlending, depthWrite: false, fog: false
|
|
2189
|
+
}));
|
|
2190
|
+
glowR.scale.set(4.0, 4.0, 1); glowR.position.set(-9.6, 0, 0); root.add(glowR);
|
|
2191
|
+
var glowB = new T.Sprite(new T.SpriteMaterial({
|
|
2192
|
+
map: dotTex, color: 0x6fb4ff, transparent: true, opacity: 0.36,
|
|
2193
|
+
blending: T.AdditiveBlending, depthWrite: false, fog: false
|
|
2194
|
+
}));
|
|
2195
|
+
glowB.scale.set(5.4, 5.4, 1); glowB.position.set(-14.6, 0, 0); root.add(glowB);
|
|
2196
|
+
|
|
2197
|
+
var lightR = new T.PointLight(0xff6a2a, 26, 34, 2); lightR.position.set(-10.0, 0, 0); root.add(lightR);
|
|
2198
|
+
var lightB = new T.PointLight(0x6fb4ff, 30, 50, 2); lightB.position.set(-14.5, 0, 0); root.add(lightB);
|
|
2199
|
+
|
|
2200
|
+
/* ═══ ⑮ 能量场边缘光壳(fresnel):最省的一档「护盾/力场」视觉签名 ═══
|
|
2201
|
+
▸ 做法:把放样体**沿半径整体外扩 0.115**(不能用 scale 放大:船首 r=0.88 处
|
|
2202
|
+
放大 1.045 只外扩 0.040 < 蒙皮板的 PLATE_OFF=0.045 ⇒ 在最细处会缩回板内被板挡住)。
|
|
2203
|
+
▸ 片元按 pow(1−|N·V|, 3) 出光:正对镜头几乎透明、掠射角最亮
|
|
2204
|
+
⇒ 只在**轮廓线**上发亮,读成"护盾边缘",而不是给船镀一层膜。
|
|
2205
|
+
▸ 加色混合 + depthWrite:false(不写深度 ⇒ 不会把船体挡在后面)。 */
|
|
2206
|
+
var fresGeo = hullPatchGeo(HULL_X0, HULL_X1, 0, Math.PI * 2, 0.115, 56, 64);
|
|
2207
|
+
var mShield = new T.ShaderMaterial({
|
|
2208
|
+
uniforms: {
|
|
2209
|
+
uColor: { value: new T.Color(0x63e2ff) },
|
|
2210
|
+
uPow: { value: 3.0 },
|
|
2211
|
+
uAmp: { value: 1.05 }
|
|
2212
|
+
},
|
|
2213
|
+
vertexShader: [
|
|
2214
|
+
'varying vec3 vN; varying vec3 vV;',
|
|
2215
|
+
'void main(){',
|
|
2216
|
+
' vec4 mv = modelViewMatrix * vec4(position, 1.0);',
|
|
2217
|
+
' vN = normalize(normalMatrix * normal);',
|
|
2218
|
+
' vV = normalize(-mv.xyz);',
|
|
2219
|
+
' gl_Position = projectionMatrix * mv;',
|
|
2220
|
+
'}'
|
|
2221
|
+
].join('\n'),
|
|
2222
|
+
fragmentShader: [
|
|
2223
|
+
'uniform vec3 uColor; uniform float uPow, uAmp; varying vec3 vN; varying vec3 vV;',
|
|
2224
|
+
'void main(){',
|
|
2225
|
+
' float f = pow(1.0 - clamp(abs(dot(normalize(vN), normalize(vV))), 0.0, 1.0), uPow);',
|
|
2226
|
+
' gl_FragColor = vec4(uColor * f * uAmp, f);',
|
|
2227
|
+
'}'
|
|
2228
|
+
].join('\n'),
|
|
2229
|
+
transparent: true, blending: T.AdditiveBlending, depthWrite: false
|
|
2230
|
+
});
|
|
2231
|
+
var shield = new T.Mesh(fresGeo, mShield);
|
|
2232
|
+
root.add(shield);
|
|
2233
|
+
|
|
2234
|
+
/* ═══ ⑭ 汇总:铆钉 / greeble 各用一个 InstancedMesh ═══ */
|
|
2235
|
+
if (rivets.length) {
|
|
2236
|
+
var im = new T.InstancedMesh(new T.SphereGeometry(1, 6, 5), mRivet, rivets.length);
|
|
2237
|
+
var mtx = new T.Matrix4(), q = new T.Quaternion(), sc = new T.Vector3(0.026, 0.026, 0.026);
|
|
2238
|
+
var upV = new T.Vector3(0, 1, 0), nv = new T.Vector3();
|
|
2239
|
+
for (var i7 = 0; i7 < rivets.length; i7++) {
|
|
2240
|
+
var rv = rivets[i7];
|
|
2241
|
+
nv.set(rv[3], rv[4], rv[5]).normalize();
|
|
2242
|
+
q.setFromUnitVectors(upV, nv);
|
|
2243
|
+
mtx.compose(new T.Vector3(rv[0], rv[1], rv[2]), q, sc);
|
|
2244
|
+
im.setMatrixAt(i7, mtx);
|
|
2245
|
+
}
|
|
2246
|
+
im.instanceMatrix.needsUpdate = true;
|
|
2247
|
+
im.frustumCulled = false;
|
|
2248
|
+
root.add(im);
|
|
2249
|
+
}
|
|
2250
|
+
if (greebles.length) {
|
|
2251
|
+
var ig = new T.InstancedMesh(slabGeo(1, 1, 1, 0.09, 0.10), mPanel, greebles.length);
|
|
2252
|
+
var m2 = new T.Matrix4(), q2 = new T.Quaternion(), basis = new T.Matrix4();
|
|
2253
|
+
for (var i8 = 0; i8 < greebles.length; i8++) {
|
|
2254
|
+
var gr2 = greebles[i8];
|
|
2255
|
+
basis.makeBasis(gr2.x, gr2.y, gr2.z);
|
|
2256
|
+
q2.setFromRotationMatrix(basis);
|
|
2257
|
+
m2.compose(gr2.p, q2, new T.Vector3(gr2.w, gr2.h, gr2.d));
|
|
2258
|
+
ig.setMatrixAt(i8, m2);
|
|
2259
|
+
}
|
|
2260
|
+
ig.instanceMatrix.needsUpdate = true;
|
|
2261
|
+
ig.frustumCulled = false;
|
|
2262
|
+
root.add(ig);
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
root.userData = {
|
|
2266
|
+
flameBlue: flameBlue, flameRed: flameRed, nacFlames: nacFlames,
|
|
2267
|
+
glowB: glowB, glowR: glowR, lightB: lightB, lightR: lightR,
|
|
2268
|
+
nacelles: nacelles, windows: windows, radar: radar, shuttles: shuttles,
|
|
2269
|
+
// tick 只用到 .material.emissiveIntensity,故给一个轻量引用而非假 Mesh
|
|
2270
|
+
canopy: { material: mGlass },
|
|
2271
|
+
// ⑥ 灯带/发光环的脉动:{m:材质, base:基准不透明度, phase:相位}
|
|
2272
|
+
// 由 app.js 的 tick 统一改 opacity(呼吸节奏错开,避免整船同频闪)
|
|
2273
|
+
pulseMats: stripMats,
|
|
2274
|
+
shield: mShield, energy: mEnergy,
|
|
2275
|
+
// 验收用引用:差分像素法要能把"本轮新增的发光件"整体摘出来(K7)
|
|
2276
|
+
glowParts: glowParts, shieldMesh: shield, baseHull: baseHull,
|
|
2277
|
+
rivetCount: rivets.length, greebleCount: greebles.length
|
|
2278
|
+
};
|
|
2279
|
+
return root;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
|
|
2283
|
+
var ship = buildSerenity();
|
|
2284
|
+
scene.add(ship);
|
|
2285
|
+
|
|
2286
|
+
// ───────────────────────── 5. 认知星场 ─────────────────────────
|
|
2287
|
+
// 用「实例化四边形」承载字形,而不是 THREE.Points:
|
|
2288
|
+
// 实测本环境下 Points 逐像素取字形所依赖的 gl_PointCoord 恒为空
|
|
2289
|
+
// (固定 UV 对照实验证明纹理与采样器正常),整片星场会被 discard。
|
|
2290
|
+
// 四边形自带真实 uv,行为确定。
|
|
2291
|
+
var SPAN = 620, BEHIND = 120;
|
|
2292
|
+
var QUAD = new T.PlaneGeometry(1, 1);
|
|
2293
|
+
|
|
2294
|
+
function glyphMaterial(opts, bodyVert) {
|
|
2295
|
+
return new T.ShaderMaterial({
|
|
2296
|
+
uniforms: {
|
|
2297
|
+
uTime: uTime, uAtlas: { value: atlasTex },
|
|
2298
|
+
uScroll: { value: 0 }, uSpan: { value: SPAN }, uBehind: { value: BEHIND },
|
|
2299
|
+
uColA: { value: new T.Color(PAL.glyphA) },
|
|
2300
|
+
uColB: { value: new T.Color(PAL.glyphB) },
|
|
2301
|
+
uCell: { value: new T.Vector2(1 / AC, 1 / AR) },
|
|
2302
|
+
uOpacity: { value: opts.opacity },
|
|
2303
|
+
uRad0: { value: opts.rad0 || 0 },
|
|
2304
|
+
uRad1: { value: opts.rad1 || 0 },
|
|
2305
|
+
uTwist: { value: opts.twist || 0 }
|
|
2306
|
+
},
|
|
2307
|
+
vertexShader: [
|
|
2308
|
+
'uniform float uTime, uScroll, uSpan, uBehind, uRad0, uRad1, uTwist;',
|
|
2309
|
+
'attribute vec3 aBase; attribute float aSpeed, aSeed, aSize;',
|
|
2310
|
+
'uniform vec2 uCell;',
|
|
2311
|
+
'varying vec2 vUv; varying float vA;',
|
|
2312
|
+
'float hash(float n){ return fract(sin(n)*43758.5453123); }',
|
|
2313
|
+
'void main(){',
|
|
2314
|
+
bodyVert,
|
|
2315
|
+
' vec4 mv = modelViewMatrix * vec4(p, 1.0);',
|
|
2316
|
+
// 与招牌同一套「角尺寸下限+上限」:旧式 min(aSize, 0.062*d) 让近处字形涨到
|
|
2317
|
+
// 9% 屏高(~82px)而远处退化成 6px 点 ⇒ 字号差异过大、画面被字符淹没。
|
|
2318
|
+
// 现压到 6~40px 的稳定带内,字符雨只做质感,不再抢主体。
|
|
2319
|
+
' float dd = max(-mv.z, 1.0);',
|
|
2320
|
+
' float sz = min(max(aSize, 0.0075 * dd * aSize), 0.024 * dd);',
|
|
2321
|
+
' mv.xy += position.xy * sz;',
|
|
2322
|
+
' gl_Position = projectionMatrix * mv;',
|
|
2323
|
+
' float gg = floor(hash(aSeed + floor(uTime*2.0 + aSeed*0.31)) * 128.0);',
|
|
2324
|
+
' vUv = (vec2(mod(gg, 16.0), floor(gg / 16.0)) + uv) * uCell;',
|
|
2325
|
+
' vA = voxelAlpha * (1.0 - smoothstep(340.0, 1000.0, -mv.z)) * smoothstep(1.5, 8.0, dd);',
|
|
2326
|
+
'}'
|
|
2327
|
+
].join('\n'),
|
|
2328
|
+
fragmentShader: [
|
|
2329
|
+
'uniform sampler2D uAtlas; uniform vec3 uColA, uColB; uniform float uOpacity;',
|
|
2330
|
+
'varying vec2 vUv; varying float vA;',
|
|
2331
|
+
'void main(){',
|
|
2332
|
+
' if(vA < 0.02) discard;',
|
|
2333
|
+
' float mask = texture2D(uAtlas, vUv).r;',
|
|
2334
|
+
' if(mask < 0.06) discard;',
|
|
2335
|
+
' gl_FragColor = vec4(mix(uColB, uColA, vA) * mask, vA * uOpacity);',
|
|
2336
|
+
'}'
|
|
2337
|
+
].join('\n'),
|
|
2338
|
+
transparent: true, depthWrite: false, blending: T.AdditiveBlending, side: T.DoubleSide
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
function makeGlyphField(count, opts) {
|
|
2343
|
+
var R = rng(opts.seed);
|
|
2344
|
+
var base = new Float32Array(count * 3), spd = new Float32Array(count);
|
|
2345
|
+
var seed = new Float32Array(count), siz = new Float32Array(count);
|
|
2346
|
+
for (var i = 0; i < count; i++) {
|
|
2347
|
+
var a = R() * Math.PI * 2;
|
|
2348
|
+
var rad = opts.rMin + Math.pow(R(), opts.bias || 0.6) * (opts.rMax - opts.rMin);
|
|
2349
|
+
base[i * 3] = R() * SPAN - BEHIND;
|
|
2350
|
+
base[i * 3 + 1] = Math.cos(a) * rad;
|
|
2351
|
+
base[i * 3 + 2] = Math.sin(a) * rad;
|
|
2352
|
+
spd[i] = 0.7 + R() * 0.7;
|
|
2353
|
+
seed[i] = R() * 1000;
|
|
2354
|
+
siz[i] = opts.size[0] + R() * (opts.size[1] - opts.size[0]);
|
|
2355
|
+
}
|
|
2356
|
+
var g = new T.InstancedBufferGeometry();
|
|
2357
|
+
g.setIndex(QUAD.index);
|
|
2358
|
+
g.setAttribute('position', QUAD.attributes.position);
|
|
2359
|
+
g.setAttribute('uv', QUAD.attributes.uv);
|
|
2360
|
+
g.setAttribute('aBase', new T.InstancedBufferAttribute(base, 3));
|
|
2361
|
+
g.setAttribute('aSpeed', new T.InstancedBufferAttribute(spd, 1));
|
|
2362
|
+
g.setAttribute('aSeed', new T.InstancedBufferAttribute(seed, 1));
|
|
2363
|
+
g.setAttribute('aSize', new T.InstancedBufferAttribute(siz, 1));
|
|
2364
|
+
g.instanceCount = count;
|
|
2365
|
+
var m = glyphMaterial(opts, [
|
|
2366
|
+
' vec3 p = aBase;',
|
|
2367
|
+
' p.x = mod(aBase.x - uScroll*aSpeed + uBehind, uSpan) - uBehind;',
|
|
2368
|
+
' float t01 = clamp(p.x / uSpan, 0.0, 1.0);',
|
|
2369
|
+
' float voxelAlpha = (1.0 - smoothstep(0.42, 0.95, t01)) * smoothstep(-uBehind, -uBehind*0.3, p.x);'
|
|
2370
|
+
].join('\n'));
|
|
2371
|
+
var mesh = new T.Mesh(g, m);
|
|
2372
|
+
mesh.frustumCulled = false;
|
|
2373
|
+
scene.add(mesh);
|
|
2374
|
+
return { mesh: mesh, mat: m };
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
// 尺寸为世界单位;过小会退化成"像素点"(实测该尺度下字形不可辨),故取 0.5~2.3
|
|
2378
|
+
// 密度经两轮实测下调:星场修好(uAtlas 形态 bug)后字符雨第一次真正显形,
|
|
2379
|
+
// 原始 2600/1800/900 会把飞船埋掉、也让标题失去对比度。现总量约为原始的 1/9。
|
|
2380
|
+
var layerFar = makeGlyphField(300, { seed: 11, rMin: 46, rMax: 420, size: [0.50, 1.00], opacity: 0.26, bias: 0.8 });
|
|
2381
|
+
var layerMid = makeGlyphField(220, { seed: 22, rMin: 18, rMax: 150, size: [0.85, 1.65], opacity: 0.40, bias: 0.7 });
|
|
2382
|
+
var layerNear = makeGlyphField(120, { seed: 33, rMin: 11, rMax: 60, size: [1.05, 1.85], opacity: 0.55, bias: 0.6 });
|
|
2383
|
+
|
|
2384
|
+
// —— 招牌场:把真实名字做成漂浮的霓虹标识 ——
|
|
2385
|
+
// 与字形场同一套实例化四边形机制,差别在于每格是一整个词、
|
|
2386
|
+
// 每个实例自带格号(aCell)与颜色(aColor),并按 4:1 的格子比例拉伸。
|
|
2387
|
+
var WASPECT = WC / WH;
|
|
2388
|
+
var PALETTE = [0x6cf8bc, 0xffc46a, 0x7fdcff, 0xc79bff, 0xffe6c0];
|
|
2389
|
+
|
|
2390
|
+
function makeWordField(count) {
|
|
2391
|
+
var R = rng(8080);
|
|
2392
|
+
var base = new Float32Array(count * 3), spd = new Float32Array(count), siz = new Float32Array(count);
|
|
2393
|
+
var cell = new Float32Array(count * 2), col = new Float32Array(count * 3);
|
|
2394
|
+
var tmp = new T.Color();
|
|
2395
|
+
for (var i = 0; i < count; i++) {
|
|
2396
|
+
var wi = (R() * WORDS.length) | 0;
|
|
2397
|
+
var a = R() * Math.PI * 2;
|
|
2398
|
+
var rad = 16 + Math.pow(R(), 0.95) * 140;
|
|
2399
|
+
base[i * 3] = R() * SPAN - BEHIND;
|
|
2400
|
+
base[i * 3 + 1] = Math.cos(a) * rad;
|
|
2401
|
+
base[i * 3 + 2] = Math.sin(a) * rad;
|
|
2402
|
+
spd[i] = 0.62 + R() * 0.66;
|
|
2403
|
+
siz[i] = 0.85 + R() * 0.70;
|
|
2404
|
+
cell[i * 2] = (wi % WCOLS) / WCOLS;
|
|
2405
|
+
cell[i * 2 + 1] = Math.floor(wi / WCOLS) / WROWS;
|
|
2406
|
+
tmp.setHex(PALETTE[WORDS[wi][1]]);
|
|
2407
|
+
col[i * 3] = tmp.r; col[i * 3 + 1] = tmp.g; col[i * 3 + 2] = tmp.b;
|
|
2408
|
+
}
|
|
2409
|
+
var g = new T.InstancedBufferGeometry();
|
|
2410
|
+
g.setIndex(QUAD.index);
|
|
2411
|
+
g.setAttribute('position', QUAD.attributes.position);
|
|
2412
|
+
g.setAttribute('uv', QUAD.attributes.uv);
|
|
2413
|
+
g.setAttribute('aBase', new T.InstancedBufferAttribute(base, 3));
|
|
2414
|
+
g.setAttribute('aSpeed', new T.InstancedBufferAttribute(spd, 1));
|
|
2415
|
+
g.setAttribute('aSize', new T.InstancedBufferAttribute(siz, 1));
|
|
2416
|
+
g.setAttribute('aCell', new T.InstancedBufferAttribute(cell, 2));
|
|
2417
|
+
g.setAttribute('aColor', new T.InstancedBufferAttribute(col, 3));
|
|
2418
|
+
g.instanceCount = count;
|
|
2419
|
+
|
|
2420
|
+
var m = new T.ShaderMaterial({
|
|
2421
|
+
uniforms: {
|
|
2422
|
+
uTime: uTime, uAtlas: { value: wordTex },
|
|
2423
|
+
uScroll: { value: 0 }, uSpan: { value: SPAN }, uBehind: { value: BEHIND },
|
|
2424
|
+
uCell: { value: new T.Vector2(1 / WCOLS, 1 / WROWS) },
|
|
2425
|
+
uAspect: { value: WASPECT }, uOpacity: { value: 0.95 }
|
|
2426
|
+
},
|
|
2427
|
+
vertexShader: [
|
|
2428
|
+
'uniform float uTime, uScroll, uSpan, uBehind, uAspect, uOpacity;',
|
|
2429
|
+
'attribute vec3 aBase, aColor; attribute float aSpeed, aSize; attribute vec2 aCell;',
|
|
2430
|
+
'uniform vec2 uCell;',
|
|
2431
|
+
'varying vec2 vUv; varying float vA; varying vec3 vCol;',
|
|
2432
|
+
'void main(){',
|
|
2433
|
+
' vec3 p = aBase;',
|
|
2434
|
+
' p.x = mod(aBase.x - uScroll*aSpeed + uBehind, uSpan) - uBehind;',
|
|
2435
|
+
' float t01 = clamp(p.x / uSpan, 0.0, 1.0);',
|
|
2436
|
+
' float voxelAlpha = (1.0 - smoothstep(0.40, 0.94, t01)) * smoothstep(-uBehind, -uBehind*0.3, p.x);',
|
|
2437
|
+
' vec4 mv = modelViewMatrix * vec4(p, 1.0);',
|
|
2438
|
+
// 招牌尺寸 = 视空间恒定角尺寸的**下限 + 上限**(这是"看得见"与"读得出"的分界):
|
|
2439
|
+
// 旧式 min(aSize, 0.052*d):远场退化成 aSize≈1 世界单位,实测中位距离 187 处
|
|
2440
|
+
// 屏幕上只有 8.7px、320 条里仅 2 条 ≥14px ⇒ 整片招牌读不出(VLM 实测)。
|
|
2441
|
+
// max(...) 给出可读角尺寸下限,min(...) 防止贴脸时铺满屏幕。
|
|
2442
|
+
' float dd = max(-mv.z, 1.0);',
|
|
2443
|
+
' float sz = min(max(aSize, 0.026 * dd * aSize), 0.070 * dd);',
|
|
2444
|
+
// 招牌是 4:1 的长条,按格子比例横拉,避免文字被压扁
|
|
2445
|
+
' mv.xy += vec2(position.x * sz * uAspect, position.y * sz);',
|
|
2446
|
+
' gl_Position = projectionMatrix * mv;',
|
|
2447
|
+
' vUv = aCell + uv * uCell;',
|
|
2448
|
+
' vCol = aColor;',
|
|
2449
|
+
// 霓虹灯管的轻微明灭
|
|
2450
|
+
' float fl = 0.74 + 0.26 * sin(uTime * (1.7 + fract(aSpeed) * 2.6) + aBase.x * 0.11);',
|
|
2451
|
+
// 近端淡出:招牌场半径 16~156 会穿过相机轨道(半径 ~48),
|
|
2452
|
+
// 贴脸时 0.070*dd 的封顶在 dist<1 处失去作用,单块招牌实测铺到 552px。
|
|
2453
|
+
// 用 dd∈[1,9] 淡入,把"穿脸闪一帧"变成自然的擦身而过。
|
|
2454
|
+
' vA = voxelAlpha * fl * (1.0 - smoothstep(380.0, 1100.0, -mv.z)) * smoothstep(1.5, 9.0, dd);',
|
|
2455
|
+
'}'
|
|
2456
|
+
].join('\n'),
|
|
2457
|
+
fragmentShader: [
|
|
2458
|
+
'uniform sampler2D uAtlas; uniform float uOpacity;',
|
|
2459
|
+
'varying vec2 vUv; varying float vA; varying vec3 vCol;',
|
|
2460
|
+
'void main(){',
|
|
2461
|
+
' if(vA < 0.02) discard;',
|
|
2462
|
+
' float mask = texture2D(uAtlas, vUv).r;',
|
|
2463
|
+
' if(mask < 0.06) discard;',
|
|
2464
|
+
' gl_FragColor = vec4(vCol * mask, vA * uOpacity);',
|
|
2465
|
+
'}'
|
|
2466
|
+
].join('\n'),
|
|
2467
|
+
transparent: true, depthWrite: false, blending: T.AdditiveBlending, side: T.DoubleSide
|
|
2468
|
+
});
|
|
2469
|
+
var mesh = new T.Mesh(g, m);
|
|
2470
|
+
mesh.frustumCulled = false;
|
|
2471
|
+
scene.add(mesh);
|
|
2472
|
+
return { mesh: mesh, mat: m };
|
|
2473
|
+
}
|
|
2474
|
+
var wordField = makeWordField(230);
|
|
2475
|
+
|
|
2476
|
+
function makeHelix(count, rad0, rad1, twist, seedN) {
|
|
2477
|
+
var R = rng(seedN);
|
|
2478
|
+
var base = new Float32Array(count * 3), spd = new Float32Array(count);
|
|
2479
|
+
var seed = new Float32Array(count), siz = new Float32Array(count);
|
|
2480
|
+
for (var i = 0; i < count; i++) {
|
|
2481
|
+
base[i * 3] = (i / count) * SPAN - BEHIND;
|
|
2482
|
+
spd[i] = 1.0; seed[i] = R() * 1000; siz[i] = 0.85 + R() * 1.0;
|
|
2483
|
+
}
|
|
2484
|
+
var g = new T.InstancedBufferGeometry();
|
|
2485
|
+
g.setIndex(QUAD.index);
|
|
2486
|
+
g.setAttribute('position', QUAD.attributes.position);
|
|
2487
|
+
g.setAttribute('uv', QUAD.attributes.uv);
|
|
2488
|
+
g.setAttribute('aBase', new T.InstancedBufferAttribute(base, 3));
|
|
2489
|
+
g.setAttribute('aSpeed', new T.InstancedBufferAttribute(spd, 1));
|
|
2490
|
+
g.setAttribute('aSeed', new T.InstancedBufferAttribute(seed, 1));
|
|
2491
|
+
g.setAttribute('aSize', new T.InstancedBufferAttribute(siz, 1));
|
|
2492
|
+
g.instanceCount = count;
|
|
2493
|
+
var m = glyphMaterial({ opacity: 0.8, rad0: rad0, rad1: rad1, twist: twist }, [
|
|
2494
|
+
' float x = mod(aBase.x - uScroll*aSpeed + uBehind, uSpan) - uBehind;',
|
|
2495
|
+
' float t01 = x / uSpan;',
|
|
2496
|
+
' float rr = mix(uRad0, uRad1, t01);',
|
|
2497
|
+
' float ang = t01 * uTwist + uTime * 0.14;',
|
|
2498
|
+
' vec3 p = vec3(x, cos(ang) * rr, sin(ang) * rr);',
|
|
2499
|
+
' float voxelAlpha = (1.0 - smoothstep(0.38, 0.9, t01)) * smoothstep(-uBehind, -uBehind*0.3, x);'
|
|
2500
|
+
].join('\n'));
|
|
2501
|
+
var mesh = new T.Mesh(g, m);
|
|
2502
|
+
mesh.frustumCulled = false;
|
|
2503
|
+
scene.add(mesh);
|
|
2504
|
+
return { mesh: mesh, mat: m };
|
|
2505
|
+
}
|
|
2506
|
+
var helixes = [
|
|
2507
|
+
makeHelix(150, 18, 62, 5.2, 101),
|
|
2508
|
+
makeHelix(130, 26, 92, -4.1, 102),
|
|
2509
|
+
makeHelix(95, 44, 150, 3.0, 103)
|
|
2510
|
+
];
|
|
2511
|
+
|
|
2512
|
+
(function slabs() {
|
|
2513
|
+
var R = rng(555);
|
|
2514
|
+
for (var i = 0; i < 18; i++) {
|
|
2515
|
+
var w = 9 + R() * 26, h = 6 + R() * 20;
|
|
2516
|
+
var tx2 = slabTexes[i % slabTexes.length];
|
|
2517
|
+
var mSlab = new T.MeshStandardMaterial({
|
|
2518
|
+
map: tx2, emissiveMap: tx2, emissive: 0x7effd0, emissiveIntensity: 1.15,
|
|
2519
|
+
color: 0x0c1e20, metalness: 0.2, roughness: 0.7, side: T.DoubleSide
|
|
2520
|
+
});
|
|
2521
|
+
var b = new T.Mesh(new T.BoxGeometry(0.6, h, w), mSlab);
|
|
2522
|
+
var a = R() * Math.PI * 2, rad = 80 + R() * 240;
|
|
2523
|
+
b.position.set(R() * 420 - 70, Math.cos(a) * rad * 0.55, Math.sin(a) * rad);
|
|
2524
|
+
b.rotation.x = R() * 0.5; b.rotation.y = R() * 1.2; b.rotation.z = R() * 0.4;
|
|
2525
|
+
b.userData.rz = (R() - 0.5) * 0.03;
|
|
2526
|
+
scene.add(b);
|
|
2527
|
+
}
|
|
2528
|
+
})();
|
|
2529
|
+
|
|
2530
|
+
// ───────────────────────── 6. 尾迹 ─────────────────────────
|
|
2531
|
+
var TRAIL_N = 520;
|
|
2532
|
+
var trail = (function () {
|
|
2533
|
+
var pos = new Float32Array(TRAIL_N * 3), vel = new Float32Array(TRAIL_N * 3), life = new Float32Array(TRAIL_N);
|
|
2534
|
+
for (var i = 0; i < TRAIL_N; i++) { life[i] = 0; pos[i * 3 + 1] = 1e5; }
|
|
2535
|
+
var g = new T.BufferGeometry();
|
|
2536
|
+
g.setAttribute('position', new T.BufferAttribute(pos, 3));
|
|
2537
|
+
var p = new T.Points(g, new T.PointsMaterial({
|
|
2538
|
+
size: 1.7, map: dotTex, color: 0xcaf3ff, transparent: true, opacity: 0.55,
|
|
2539
|
+
depthWrite: false, blending: T.AdditiveBlending, sizeAttenuation: true
|
|
2540
|
+
}));
|
|
2541
|
+
p.frustumCulled = false;
|
|
2542
|
+
scene.add(p);
|
|
2543
|
+
return { points: p, geo: g, pos: pos, vel: vel, life: life, head: 0 };
|
|
2544
|
+
})();
|
|
2545
|
+
|
|
2546
|
+
function spawnTrail(n, speed) {
|
|
2547
|
+
for (var k = 0; k < n; k++) {
|
|
2548
|
+
var i = trail.head; trail.head = (trail.head + 1) % TRAIL_N;
|
|
2549
|
+
var i3 = i * 3;
|
|
2550
|
+
var main = Math.random() < 0.55;
|
|
2551
|
+
trail.pos[i3] = main ? -9.4 : -3.9;
|
|
2552
|
+
trail.pos[i3 + 1] = main ? (Math.random() - 0.5) * 1.6 : (Math.random() - 0.5) * 0.8;
|
|
2553
|
+
trail.pos[i3 + 2] = main ? (Math.random() - 0.5) * 1.6
|
|
2554
|
+
: (Math.random() < 0.5 ? 1 : -1) * 4.25 + (Math.random() - 0.5) * 0.7;
|
|
2555
|
+
trail.vel[i3] = -16 - Math.random() * 20 - speed * 0.35;
|
|
2556
|
+
trail.vel[i3 + 1] = (Math.random() - 0.5) * 2.6;
|
|
2557
|
+
trail.vel[i3 + 2] = (Math.random() - 0.5) * 2.6;
|
|
2558
|
+
trail.life[i] = 1;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// ── 卡片模式:把星野整体调暗(三步降透明度),让背景"退后"不抢宿主的正文 ──
|
|
2563
|
+
// 另:**铭牌(code slabs)在卡片模式下整层关掉**——那是"立在星空里的金属铭牌",
|
|
2564
|
+
// 全屏看是风景,340px 卡片里就是"一根竖虚线 + 半截被切掉的标题",纯噪点(实测)。
|
|
2565
|
+
if (CARD) {
|
|
2566
|
+
var dim = function (f, k) { if (f && f.mat && f.mat.uniforms.uOpacity) f.mat.uniforms.uOpacity.value *= k; };
|
|
2567
|
+
// 词元压到 0.22:它们是画面里唯一"高饱和"的东西(紫/琥珀),叠白正文会打架(实测两轮)
|
|
2568
|
+
dim(layerFar, 0.58); dim(layerMid, 0.48); dim(layerNear, 0.34); dim(wordField, 0.22);
|
|
2569
|
+
helixes.forEach(function (h) { dim(h, 0.40); });
|
|
2570
|
+
renderer.toneMappingExposure = PAL.exposure * 0.72;
|
|
2571
|
+
scene.traverse(function (o) {
|
|
2572
|
+
if (o.userData && o.userData.rz !== undefined) o.visible = false;
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
// ───────────────────────── 7. 自动运镜 ─────────────────────────
|
|
2577
|
+
var lookAt = new T.Vector3();
|
|
2578
|
+
function driveCamera(t) {
|
|
2579
|
+
var az = t * 0.052;
|
|
2580
|
+
// 卡片模式:半径 43→62(飞船约缩到 69%,实测 76 会"孤零零")、仰角摆动收窄,让构图安静下来
|
|
2581
|
+
var rad = (CARD ? 62 : 43) + Math.sin(t * 0.037) * (CARD ? 6 : 10) + Math.sin(t * 0.011) * (CARD ? 3 : 5);
|
|
2582
|
+
var el = (CARD ? 7 : 10) + Math.sin(t * 0.043) * (CARD ? 3 : 6) + Math.sin(t * 0.017) * (CARD ? 1.5 : 3);
|
|
2583
|
+
camera.position.set(
|
|
2584
|
+
Math.cos(az) * rad * 0.62 + 8 + Math.sin(t * 0.53) * 0.6,
|
|
2585
|
+
el + Math.cos(t * 0.47) * 0.5,
|
|
2586
|
+
Math.sin(az) * rad
|
|
2587
|
+
);
|
|
2588
|
+
// 卡片模式:飞船整体下压到画面下三分之一——合成实测(§12.44)显示,居中时船体最亮的
|
|
2589
|
+
// 舷窗/灯带正落在宿主卡片的正文行后面,白字被亮部冲淡。抬 lookAt 即把主体推低。
|
|
2590
|
+
lookAt.set(ship.position.x - 3.6, ship.position.y + (CARD ? 3.8 : 0.3), ship.position.z);
|
|
2591
|
+
camera.lookAt(lookAt);
|
|
2592
|
+
camera.rotation.z += Math.sin(t * 0.29) * 0.012;
|
|
2593
|
+
|
|
2594
|
+
key.position.set(camera.position.x + 24, camera.position.y + 26, camera.position.z + 20);
|
|
2595
|
+
key.target.position.set(ship.position.x, ship.position.y, ship.position.z);
|
|
2596
|
+
key.target.updateMatrixWorld();
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
// ───────────────────────── 8. 被动 HUD ─────────────────────────
|
|
2600
|
+
// 实测快照 2026-09-15(口径:仓库 = AI_LAB/INFRA/NETWORK/HOME 下含 .git 的目录数;
|
|
2601
|
+
// 技能 = `.opencode/skills/*` 目录数;工具 = mech-registry entries 数;本体 = 现行 *.ttl;
|
|
2602
|
+
// 公理 = 现行 *.ttl 的 `sr:axiom` 计数;会话 = AGENT_SESSIONS 现行 + _archived)
|
|
2603
|
+
[['m-repo', 19], ['m-skill', 35], ['m-msm', 84], ['m-onto', 12], ['m-axiom', 56], ['m-sess', 190]]
|
|
2604
|
+
.forEach(function (p) {
|
|
2605
|
+
var el = document.getElementById(p[0]);
|
|
2606
|
+
if (el) el.textContent = String(p[1]);
|
|
2607
|
+
});
|
|
2608
|
+
|
|
2609
|
+
var speedNum = document.getElementById('speedNum');
|
|
2610
|
+
function autoSpeed(t) { return 22 + Math.sin(t * 0.21) * 7 + Math.sin(t * 0.53) * 3; }
|
|
2611
|
+
|
|
2612
|
+
window.addEventListener('resize', function () {
|
|
2613
|
+
camera.aspect = window.innerWidth / window.innerHeight;
|
|
2614
|
+
camera.updateProjectionMatrix();
|
|
2615
|
+
renderer.setSize(window.innerWidth, window.innerHeight, false);
|
|
2616
|
+
});
|
|
2617
|
+
|
|
2618
|
+
// ── 出厂自检(K7):ShaderMaterial 的每个 uniform 必须是 { value: X } 形态 ──
|
|
2619
|
+
// 踩过的坑:`uAtlas: atlasTex`(裸 Texture,而非 `{ value: atlasTex }`)
|
|
2620
|
+
// ⇒ three.js 取 `uniform.value` 得 undefined ⇒ 采样器无绑定 ⇒ `mask` 恒为 0
|
|
2621
|
+
// ⇒ `if (mask < 0.06) discard;` 让**整片代码星场与全部词元招牌一个像素都不渲染**,
|
|
2622
|
+
// 且控制台不报任何错。构建期的语法/沙箱闸门都抓不到——只有运行时断言能拦。
|
|
2623
|
+
scene.traverse(function (o) {
|
|
2624
|
+
var u = o.material && o.material.uniforms;
|
|
2625
|
+
if (!u) return;
|
|
2626
|
+
Object.keys(u).forEach(function (k) {
|
|
2627
|
+
var e = u[k];
|
|
2628
|
+
if (!e || typeof e !== 'object' || !('value' in e)) {
|
|
2629
|
+
throw new Error('uniform 形态错误(应为 {value:X}): ' + k + ' @ ' + (o.type || '?'));
|
|
2630
|
+
}
|
|
2631
|
+
});
|
|
2632
|
+
});
|
|
2633
|
+
|
|
2634
|
+
// ── 验收句柄(只读引用,不参与任何渲染逻辑)─────────────────────────────
|
|
2635
|
+
// 本文件整体在一个 IIFE 里,scene/camera/renderer/ship 从外部(browser-pool js)
|
|
2636
|
+
// 拿不到 ⇒ 上一轮只能靠 VLM 目测,而 K9 已证明 VLM 不能用于"精确计数/精确位置"。
|
|
2637
|
+
// 把引用挂到 window 后,自动化验收可以做到**机械测量**:
|
|
2638
|
+
// · 射线求交:从相机朝每个舷窗中心投射,断言首个命中是它自己(K10 的回归测试)
|
|
2639
|
+
// · 差分像素法:render → gl.readPixels 求均值 → 隐藏嫌疑对象 → 再 render 再读(K7)
|
|
2640
|
+
window.SERENITY = {
|
|
2641
|
+
T: T, scene: scene, camera: camera, renderer: renderer, ship: ship,
|
|
2642
|
+
uTime: uTime, SIM: SIM
|
|
2643
|
+
};
|
|
2644
|
+
|
|
2645
|
+
// ───────────────────────── 9. 主循环 ─────────────────────────
|
|
2646
|
+
var slabs = [];
|
|
2647
|
+
scene.traverse(function (o) { if (o.userData && o.userData.rz !== undefined) slabs.push(o); });
|
|
2648
|
+
|
|
2649
|
+
function tick() {
|
|
2650
|
+
var dt = Math.min(clock.getDelta(), 0.05);
|
|
2651
|
+
if (!reduce) SIM.t += dt;
|
|
2652
|
+
var t = SIM.t;
|
|
2653
|
+
uTime.value = t;
|
|
2654
|
+
SIM.speed = autoSpeed(t);
|
|
2655
|
+
|
|
2656
|
+
ship.position.y = Math.sin(t * 0.42) * 0.5 + Math.sin(t * 0.19) * 0.3;
|
|
2657
|
+
ship.rotation.z = Math.sin(t * 0.31) * 0.045 + Math.sin(t * 0.12) * 0.03;
|
|
2658
|
+
ship.rotation.x = Math.sin(t * 0.26) * 0.05;
|
|
2659
|
+
ship.rotation.y = Math.sin(t * 0.17) * 0.035;
|
|
2660
|
+
|
|
2661
|
+
var ud = ship.userData;
|
|
2662
|
+
var beat = 0.76 + 0.24 * Math.sin(t * 3.1) + SIM.speed / 300;
|
|
2663
|
+
// 焰体几何已 rotateZ(-90°):轴向落在 X,缩放长度要改 X 而非 Y
|
|
2664
|
+
ud.flameRed.scale.set(0.5 + beat * 0.7, 1, 1);
|
|
2665
|
+
ud.flameRed.material.opacity = 0.40 + beat * 0.24;
|
|
2666
|
+
ud.flameBlue.scale.set(0.55 + beat * 0.65, 1, 1);
|
|
2667
|
+
ud.flameBlue.material.opacity = 0.42 + beat * 0.26;
|
|
2668
|
+
ud.nacFlames.forEach(function (f, i) {
|
|
2669
|
+
f.scale.set(0.55 + beat * 0.6 + i * 0.05, 1, 1);
|
|
2670
|
+
f.material.opacity = 0.6 + beat * 0.28;
|
|
2671
|
+
});
|
|
2672
|
+
// 尾焰辉光:VLM 反馈"尾部那个光球过曝、与船体脱节" ⇒ 缩小并压低不透明度,
|
|
2673
|
+
// 让它读成"喷口周围的热辉"而不是一颗独立的发光球。
|
|
2674
|
+
ud.glowR.scale.setScalar(3.0 + beat * 1.2);
|
|
2675
|
+
ud.glowB.scale.setScalar(4.2 + beat * 1.6);
|
|
2676
|
+
ud.lightR.intensity = 16 + beat * 22;
|
|
2677
|
+
ud.lightB.intensity = 20 + beat * 28;
|
|
2678
|
+
ud.canopy.material.emissiveIntensity = 1.8 + 0.55 * Math.sin(t * 2.3);
|
|
2679
|
+
// ⑥ 航道灯带 / 发光环的呼吸:各条相位错开,避免整船同频闪(同频会读成"故障")
|
|
2680
|
+
var pm = ud.pulseMats;
|
|
2681
|
+
for (var pmi = 0; pmi < pm.length; pmi++) {
|
|
2682
|
+
pm[pmi].m.opacity = pm[pmi].base * (0.70 + 0.30 * Math.sin(t * 1.7 + pm[pmi].phase));
|
|
2683
|
+
}
|
|
2684
|
+
// ⑤ 力场壳:脉动幅度小一些(护盾是"常亮 + 微呼吸",闪太狠会抢主体)
|
|
2685
|
+
if (ud.shield) ud.shield.uniforms.uAmp.value = 1.05 + 0.28 * Math.sin(t * 1.15 + 0.7);
|
|
2686
|
+
// ① 能量脉冲层(基壳)无需在此驱动:它的 uTime 就是主循环的 uTime,已自动在跑。
|
|
2687
|
+
ud.radar.rotation.y = t * 0.9;
|
|
2688
|
+
// 短舱怠速微摆:绕 **X** 轴(滚转)才有意义 —— 绕 Z 轴旋转时,位于 z=±3.42
|
|
2689
|
+
// 的舱体在 XY 平面上的投影不变,等于什么都没动(上一版就是这个空动作)。
|
|
2690
|
+
ud.nacelles.forEach(function (n, i) { n.rotation.x = Math.sin(t * 0.37 + i * 1.7) * 0.050; });
|
|
2691
|
+
|
|
2692
|
+
var sc = SIM.speed * 0.55;
|
|
2693
|
+
layerFar.mat.uniforms.uScroll.value = t * sc * 0.55;
|
|
2694
|
+
layerMid.mat.uniforms.uScroll.value = t * sc * 0.95;
|
|
2695
|
+
layerNear.mat.uniforms.uScroll.value = t * sc * 1.7;
|
|
2696
|
+
wordField.mat.uniforms.uScroll.value = t * sc * 0.72;
|
|
2697
|
+
helixes.forEach(function (h, i) { h.mat.uniforms.uScroll.value = t * sc * (0.8 + i * 0.35); });
|
|
2698
|
+
|
|
2699
|
+
for (var si = 0; si < slabs.length; si++) {
|
|
2700
|
+
var s = slabs[si];
|
|
2701
|
+
s.position.x -= dt * (2.2 + SIM.speed * 0.06);
|
|
2702
|
+
s.rotation.z += s.userData.rz * dt * 6;
|
|
2703
|
+
if (s.position.x < -260) s.position.x = 430;
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
spawnTrail(reduce ? 0 : 3, SIM.speed);
|
|
2707
|
+
var tp = trail.pos, tv = trail.vel, tl = trail.life;
|
|
2708
|
+
for (var i = 0; i < TRAIL_N; i++) {
|
|
2709
|
+
if (tl[i] <= 0) continue;
|
|
2710
|
+
var i3 = i * 3;
|
|
2711
|
+
tl[i] -= dt * 0.42;
|
|
2712
|
+
tp[i3] += (tv[i3] - SIM.speed * 0.35) * dt;
|
|
2713
|
+
tp[i3 + 1] += tv[i3 + 1] * dt;
|
|
2714
|
+
tp[i3 + 2] += tv[i3 + 2] * dt;
|
|
2715
|
+
if (tl[i] <= 0) tp[i3 + 1] = 1e5;
|
|
2716
|
+
}
|
|
2717
|
+
trail.geo.attributes.position.needsUpdate = true;
|
|
2718
|
+
|
|
2719
|
+
sky.position.copy(camera.position);
|
|
2720
|
+
driveCamera(t);
|
|
2721
|
+
|
|
2722
|
+
if (speedNum) speedNum.textContent = String(Math.round(SIM.speed));
|
|
2723
|
+
renderer.render(scene, camera);
|
|
2724
|
+
|
|
2725
|
+
SIM.frames++;
|
|
2726
|
+
if (!SIM.ready && SIM.frames >= 2) {
|
|
2727
|
+
SIM.ready = true;
|
|
2728
|
+
var ld = document.getElementById('load');
|
|
2729
|
+
ld.classList.add('off');
|
|
2730
|
+
setTimeout(function () { ld.style.display = 'none'; }, 1000);
|
|
2731
|
+
}
|
|
2732
|
+
requestAnimationFrame(tick);
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
// ───────────────────────── 10. 启动 ─────────────────────────
|
|
2736
|
+
driveCamera(0);
|
|
2737
|
+
renderer.render(scene, camera);
|
|
2738
|
+
if (speedNum) speedNum.textContent = String(Math.round(autoSpeed(0)));
|
|
2739
|
+
requestAnimationFrame(tick);
|
|
2740
|
+
|
|
2741
|
+
window.__serenity = {
|
|
2742
|
+
getState: function () {
|
|
2743
|
+
return {
|
|
2744
|
+
frames: SIM.frames, ready: SIM.ready, reducedMotion: reduce,
|
|
2745
|
+
three: T.REVISION, speed: Math.round(SIM.speed),
|
|
2746
|
+
camDist: +camera.position.length().toFixed(2), objects: slabs.length
|
|
2747
|
+
};
|
|
2748
|
+
},
|
|
2749
|
+
scene: scene, camera: camera, renderer: renderer, ship: ship, atlas: atlasTex
|
|
2750
|
+
};
|
|
2751
|
+
})();
|
|
2752
|
+
|
|
2753
|
+
</script>
|
|
2754
|
+
</body>
|
|
2755
|
+
</html>
|