teechart.js 4.0.4 → 5.0.0-beta.1

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.
Files changed (274) hide show
  1. package/3D-COMPATIBILITY.md +45 -0
  2. package/README.md +463 -27
  3. package/dist/chunks/chart-p639xVyw.js +16 -0
  4. package/dist/chunks/chart-p639xVyw.js.map +1 -0
  5. package/dist/chunks/palette-series-DfyYptK1.js +16 -0
  6. package/dist/chunks/palette-series-DfyYptK1.js.map +1 -0
  7. package/dist/chunks/series-DeozLXIv.js +16 -0
  8. package/dist/chunks/series-DeozLXIv.js.map +1 -0
  9. package/dist/teechart.3d.esm.js +27 -0
  10. package/dist/teechart.3d.esm.js.map +1 -0
  11. package/dist/teechart.auto.esm.js +16 -0
  12. package/dist/teechart.auto.esm.js.map +1 -0
  13. package/dist/teechart.core.esm.js +16 -0
  14. package/dist/teechart.core.esm.js.map +1 -0
  15. package/dist/teechart.esm.js +16 -0
  16. package/dist/teechart.esm.js.map +1 -0
  17. package/dist/teechart.js +14 -3
  18. package/dist/teechart.js.map +1 -1
  19. package/dist/teechart.maps.esm.js +16 -0
  20. package/dist/teechart.maps.esm.js.map +1 -0
  21. package/dist/types/accessibility.d.ts +29 -0
  22. package/dist/types/accessibility.d.ts.map +1 -0
  23. package/dist/types/auto.d.ts +4 -0
  24. package/dist/types/auto.d.ts.map +1 -0
  25. package/dist/types/chart-options.d.ts +826 -0
  26. package/dist/types/chart-options.d.ts.map +1 -0
  27. package/dist/types/chart.d.ts +252 -0
  28. package/dist/types/chart.d.ts.map +1 -0
  29. package/dist/types/checkbox.d.ts +12 -0
  30. package/dist/types/checkbox.d.ts.map +1 -0
  31. package/dist/types/core/elements/axes.d.ts +17 -0
  32. package/dist/types/core/elements/axes.d.ts.map +1 -0
  33. package/dist/types/core/elements/axis-grid.d.ts +20 -0
  34. package/dist/types/core/elements/axis-grid.d.ts.map +1 -0
  35. package/dist/types/core/elements/axis-labels.d.ts +54 -0
  36. package/dist/types/core/elements/axis-labels.d.ts.map +1 -0
  37. package/dist/types/core/elements/axis-ticks.d.ts +19 -0
  38. package/dist/types/core/elements/axis-ticks.d.ts.map +1 -0
  39. package/dist/types/core/elements/axis-title.d.ts +16 -0
  40. package/dist/types/core/elements/axis-title.d.ts.map +1 -0
  41. package/dist/types/core/elements/axis.d.ts +125 -0
  42. package/dist/types/core/elements/axis.d.ts.map +1 -0
  43. package/dist/types/core/elements/chart-image.d.ts +13 -0
  44. package/dist/types/core/elements/chart-image.d.ts.map +1 -0
  45. package/dist/types/core/elements/font.d.ts +28 -0
  46. package/dist/types/core/elements/font.d.ts.map +1 -0
  47. package/dist/types/core/elements/format.d.ts +125 -0
  48. package/dist/types/core/elements/format.d.ts.map +1 -0
  49. package/dist/types/core/elements/gradient.d.ts +23 -0
  50. package/dist/types/core/elements/gradient.d.ts.map +1 -0
  51. package/dist/types/core/elements/legend-symbol.d.ts +49 -0
  52. package/dist/types/core/elements/legend-symbol.d.ts.map +1 -0
  53. package/dist/types/core/elements/legend.d.ts +131 -0
  54. package/dist/types/core/elements/legend.d.ts.map +1 -0
  55. package/dist/types/core/elements/margins.d.ts +9 -0
  56. package/dist/types/core/elements/margins.d.ts.map +1 -0
  57. package/dist/types/core/elements/panel.d.ts +13 -0
  58. package/dist/types/core/elements/panel.d.ts.map +1 -0
  59. package/dist/types/core/elements/scroll.d.ts +14 -0
  60. package/dist/types/core/elements/scroll.d.ts.map +1 -0
  61. package/dist/types/core/elements/shadow.d.ts +14 -0
  62. package/dist/types/core/elements/shadow.d.ts.map +1 -0
  63. package/dist/types/core/elements/stroke.d.ts +19 -0
  64. package/dist/types/core/elements/stroke.d.ts.map +1 -0
  65. package/dist/types/core/elements/wall.d.ts +13 -0
  66. package/dist/types/core/elements/wall.d.ts.map +1 -0
  67. package/dist/types/core/elements/zoom.d.ts +33 -0
  68. package/dist/types/core/elements/zoom.d.ts.map +1 -0
  69. package/dist/types/core/primitives.d.ts +33 -0
  70. package/dist/types/core/primitives.d.ts.map +1 -0
  71. package/dist/types/core.d.ts +96 -0
  72. package/dist/types/core.d.ts.map +1 -0
  73. package/dist/types/data/data-engine.d.ts +245 -0
  74. package/dist/types/data/data-engine.d.ts.map +1 -0
  75. package/dist/types/date.format.d.ts +5 -0
  76. package/dist/types/date.format.d.ts.map +1 -0
  77. package/dist/types/declarative-tools.d.ts +6 -0
  78. package/dist/types/declarative-tools.d.ts.map +1 -0
  79. package/dist/types/do-http-request.d.ts +2 -0
  80. package/dist/types/do-http-request.d.ts.map +1 -0
  81. package/dist/types/dom-tip.d.ts +41 -0
  82. package/dist/types/dom-tip.d.ts.map +1 -0
  83. package/dist/types/events.d.ts +82 -0
  84. package/dist/types/events.d.ts.map +1 -0
  85. package/dist/types/extras.d.ts +18 -0
  86. package/dist/types/extras.d.ts.map +1 -0
  87. package/dist/types/index.d.ts +5 -0
  88. package/dist/types/index.d.ts.map +1 -0
  89. package/dist/types/interaction.d.ts +67 -0
  90. package/dist/types/interaction.d.ts.map +1 -0
  91. package/dist/types/map-series-definition.d.ts +5 -0
  92. package/dist/types/map-series-definition.d.ts.map +1 -0
  93. package/dist/types/maps/africa-map.d.ts +10 -0
  94. package/dist/types/maps/africa-map.d.ts.map +1 -0
  95. package/dist/types/maps/asia-map.d.ts +10 -0
  96. package/dist/types/maps/asia-map.d.ts.map +1 -0
  97. package/dist/types/maps/australia-map.d.ts +10 -0
  98. package/dist/types/maps/australia-map.d.ts.map +1 -0
  99. package/dist/types/maps/europe-map.d.ts +10 -0
  100. package/dist/types/maps/europe-map.d.ts.map +1 -0
  101. package/dist/types/maps/europe27-map.d.ts +10 -0
  102. package/dist/types/maps/europe27-map.d.ts.map +1 -0
  103. package/dist/types/maps/layout-map.d.ts +51 -0
  104. package/dist/types/maps/layout-map.d.ts.map +1 -0
  105. package/dist/types/maps/map-types.d.ts +19 -0
  106. package/dist/types/maps/map-types.d.ts.map +1 -0
  107. package/dist/types/maps/south-america-map.d.ts +10 -0
  108. package/dist/types/maps/south-america-map.d.ts.map +1 -0
  109. package/dist/types/maps/spain-map.d.ts +11 -0
  110. package/dist/types/maps/spain-map.d.ts.map +1 -0
  111. package/dist/types/maps/svg-map.d.ts +37 -0
  112. package/dist/types/maps/svg-map.d.ts.map +1 -0
  113. package/dist/types/maps/usa-map.d.ts +12 -0
  114. package/dist/types/maps/usa-map.d.ts.map +1 -0
  115. package/dist/types/maps/world-map.d.ts +14 -0
  116. package/dist/types/maps/world-map.d.ts.map +1 -0
  117. package/dist/types/maps.d.ts +15 -0
  118. package/dist/types/maps.d.ts.map +1 -0
  119. package/dist/types/marks-animation.d.ts +16 -0
  120. package/dist/types/marks-animation.d.ts.map +1 -0
  121. package/dist/types/modern-theme.d.ts +14 -0
  122. package/dist/types/modern-theme.d.ts.map +1 -0
  123. package/dist/types/optional-options.d.ts +6 -0
  124. package/dist/types/optional-options.d.ts.map +1 -0
  125. package/dist/types/palette.d.ts +11 -0
  126. package/dist/types/palette.d.ts.map +1 -0
  127. package/dist/types/platform.d.ts +27 -0
  128. package/dist/types/platform.d.ts.map +1 -0
  129. package/dist/types/plugin.d.ts +80 -0
  130. package/dist/types/plugin.d.ts.map +1 -0
  131. package/dist/types/quadrants-plugin.d.ts +45 -0
  132. package/dist/types/quadrants-plugin.d.ts.map +1 -0
  133. package/dist/types/register-all.d.ts +3 -0
  134. package/dist/types/register-all.d.ts.map +1 -0
  135. package/dist/types/rendering/canvas-graphics.d.ts +65 -0
  136. package/dist/types/rendering/canvas-graphics.d.ts.map +1 -0
  137. package/dist/types/rendering/graphics.d.ts +59 -0
  138. package/dist/types/rendering/graphics.d.ts.map +1 -0
  139. package/dist/types/rendering/renderer.d.ts +58 -0
  140. package/dist/types/rendering/renderer.d.ts.map +1 -0
  141. package/dist/types/rendering/three-graphics.d.ts +22 -0
  142. package/dist/types/rendering/three-graphics.d.ts.map +1 -0
  143. package/dist/types/responsive.d.ts +8 -0
  144. package/dist/types/responsive.d.ts.map +1 -0
  145. package/dist/types/series/activity-gauge.d.ts +18 -0
  146. package/dist/types/series/activity-gauge.d.ts.map +1 -0
  147. package/dist/types/series/arc-gauge.d.ts +74 -0
  148. package/dist/types/series/arc-gauge.d.ts.map +1 -0
  149. package/dist/types/series/area.d.ts +24 -0
  150. package/dist/types/series/area.d.ts.map +1 -0
  151. package/dist/types/series/bar.d.ts +17 -0
  152. package/dist/types/series/bar.d.ts.map +1 -0
  153. package/dist/types/series/box-plot.d.ts +140 -0
  154. package/dist/types/series/box-plot.d.ts.map +1 -0
  155. package/dist/types/series/bubble.d.ts +25 -0
  156. package/dist/types/series/bubble.d.ts.map +1 -0
  157. package/dist/types/series/bullet.d.ts +86 -0
  158. package/dist/types/series/bullet.d.ts.map +1 -0
  159. package/dist/types/series/candle.d.ts +27 -0
  160. package/dist/types/series/candle.d.ts.map +1 -0
  161. package/dist/types/series/circular-gauge.d.ts +100 -0
  162. package/dist/types/series/circular-gauge.d.ts.map +1 -0
  163. package/dist/types/series/color-series.d.ts +59 -0
  164. package/dist/types/series/color-series.d.ts.map +1 -0
  165. package/dist/types/series/composed-series.d.ts +76 -0
  166. package/dist/types/series/composed-series.d.ts.map +1 -0
  167. package/dist/types/series/custom-bar.d.ts +63 -0
  168. package/dist/types/series/custom-bar.d.ts.map +1 -0
  169. package/dist/types/series/custom-series.d.ts +74 -0
  170. package/dist/types/series/custom-series.d.ts.map +1 -0
  171. package/dist/types/series/donut.d.ts +17 -0
  172. package/dist/types/series/donut.d.ts.map +1 -0
  173. package/dist/types/series/gantt.d.ts +47 -0
  174. package/dist/types/series/gantt.d.ts.map +1 -0
  175. package/dist/types/series/high-low-bar.d.ts +24 -0
  176. package/dist/types/series/high-low-bar.d.ts.map +1 -0
  177. package/dist/types/series/histogram.d.ts +36 -0
  178. package/dist/types/series/histogram.d.ts.map +1 -0
  179. package/dist/types/series/horiz-area.d.ts +11 -0
  180. package/dist/types/series/horiz-area.d.ts.map +1 -0
  181. package/dist/types/series/horiz-bar.d.ts +23 -0
  182. package/dist/types/series/horiz-bar.d.ts.map +1 -0
  183. package/dist/types/series/line.d.ts +22 -0
  184. package/dist/types/series/line.d.ts.map +1 -0
  185. package/dist/types/series/linear-gauge.d.ts +73 -0
  186. package/dist/types/series/linear-gauge.d.ts.map +1 -0
  187. package/dist/types/series/map-series.d.ts +82 -0
  188. package/dist/types/series/map-series.d.ts.map +1 -0
  189. package/dist/types/series/numeric-gauge.d.ts +96 -0
  190. package/dist/types/series/numeric-gauge.d.ts.map +1 -0
  191. package/dist/types/series/palette-series.d.ts +39 -0
  192. package/dist/types/series/palette-series.d.ts.map +1 -0
  193. package/dist/types/series/pie.d.ts +81 -0
  194. package/dist/types/series/pie.d.ts.map +1 -0
  195. package/dist/types/series/point-xy.d.ts +13 -0
  196. package/dist/types/series/point-xy.d.ts.map +1 -0
  197. package/dist/types/series/polar.d.ts +37 -0
  198. package/dist/types/series/polar.d.ts.map +1 -0
  199. package/dist/types/series/sankey.d.ts +90 -0
  200. package/dist/types/series/sankey.d.ts.map +1 -0
  201. package/dist/types/series/series-list.d.ts +127 -0
  202. package/dist/types/series/series-list.d.ts.map +1 -0
  203. package/dist/types/series/series-list.types.d.ts +43 -0
  204. package/dist/types/series/series-list.types.d.ts.map +1 -0
  205. package/dist/types/series/sliced.d.ts +13 -0
  206. package/dist/types/series/sliced.d.ts.map +1 -0
  207. package/dist/types/series/surface.d.ts +24 -0
  208. package/dist/types/series/surface.d.ts.map +1 -0
  209. package/dist/types/series/treemap.d.ts +107 -0
  210. package/dist/types/series/treemap.d.ts.map +1 -0
  211. package/dist/types/series/violin.d.ts +105 -0
  212. package/dist/types/series/violin.d.ts.map +1 -0
  213. package/dist/types/series/volume.d.ts +11 -0
  214. package/dist/types/series/volume.d.ts.map +1 -0
  215. package/dist/types/series-definitions.d.ts +30 -0
  216. package/dist/types/series-definitions.d.ts.map +1 -0
  217. package/dist/types/series-registry.d.ts +37 -0
  218. package/dist/types/series-registry.d.ts.map +1 -0
  219. package/dist/types/series-utils.d.ts +29 -0
  220. package/dist/types/series-utils.d.ts.map +1 -0
  221. package/dist/types/series.d.ts +342 -0
  222. package/dist/types/series.d.ts.map +1 -0
  223. package/dist/types/slider.d.ts +49 -0
  224. package/dist/types/slider.d.ts.map +1 -0
  225. package/dist/types/spline.d.ts +2 -0
  226. package/dist/types/spline.d.ts.map +1 -0
  227. package/dist/types/table/chart-table.d.ts +27 -0
  228. package/dist/types/table/chart-table.d.ts.map +1 -0
  229. package/dist/types/teechart-3d.d.ts +4 -0
  230. package/dist/types/teechart-3d.d.ts.map +1 -0
  231. package/dist/types/theme.d.ts +41 -0
  232. package/dist/types/theme.d.ts.map +1 -0
  233. package/dist/types/three/chart-3d.d.ts +77 -0
  234. package/dist/types/three/chart-3d.d.ts.map +1 -0
  235. package/dist/types/three/chart-options-3d.d.ts +5 -0
  236. package/dist/types/three/chart-options-3d.d.ts.map +1 -0
  237. package/dist/types/three/teechart-3d.d.ts +25 -0
  238. package/dist/types/three/teechart-3d.d.ts.map +1 -0
  239. package/dist/types/three-context.d.ts +184 -0
  240. package/dist/types/three-context.d.ts.map +1 -0
  241. package/dist/types/three-context.types.d.ts +177 -0
  242. package/dist/types/three-context.types.d.ts.map +1 -0
  243. package/dist/types/three-parametric-geometry.d.ts +7 -0
  244. package/dist/types/three-parametric-geometry.d.ts.map +1 -0
  245. package/dist/types/three.d.ts +6 -0
  246. package/dist/types/three.d.ts.map +1 -0
  247. package/dist/types/tools/animate-hover.d.ts +13 -0
  248. package/dist/types/tools/animate-hover.d.ts.map +1 -0
  249. package/dist/types/tools/annotation.d.ts +169 -0
  250. package/dist/types/tools/annotation.d.ts.map +1 -0
  251. package/dist/types/tools/base-animation.d.ts +83 -0
  252. package/dist/types/tools/base-animation.d.ts.map +1 -0
  253. package/dist/types/tools/cursor-tool.d.ts +51 -0
  254. package/dist/types/tools/cursor-tool.d.ts.map +1 -0
  255. package/dist/types/tools/drag-tool.d.ts +28 -0
  256. package/dist/types/tools/drag-tool.d.ts.map +1 -0
  257. package/dist/types/tools/index.d.ts +8 -0
  258. package/dist/types/tools/index.d.ts.map +1 -0
  259. package/dist/types/tools/tool.d.ts +27 -0
  260. package/dist/types/tools/tool.d.ts.map +1 -0
  261. package/dist/types/tools/tools.d.ts +33 -0
  262. package/dist/types/tools/tools.d.ts.map +1 -0
  263. package/dist/types/utils.d.ts +23 -0
  264. package/dist/types/utils.d.ts.map +1 -0
  265. package/dist/types/worker.d.ts +92 -0
  266. package/dist/types/worker.d.ts.map +1 -0
  267. package/package.json +74 -27
  268. package/dist/Tween.js +0 -13
  269. package/dist/date.format.js +0 -145
  270. package/dist/excanvas/canvas.text.js +0 -489
  271. package/dist/excanvas/excanvas.compiled.js +0 -35
  272. package/dist/excanvas/excanvas.js +0 -924
  273. package/dist/excanvas/excanvas_text.js +0 -1416
  274. package/dist/three.js +0 -990
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @preserve TeeChart(tm) for JavaScript(tm) * @fileOverview TeeChart for JavaScript(tm)
3
+ * v5.0.0-beta.1 Jun 2026
4
+ * Copyright(c) 2012-2026 by Steema Software SL. All Rights Reserved.
5
+ * https://www.steema.com
6
+ *
7
+ * Licensed with commercial and non-commercial attributes,
8
+ * specifically: https://www.steema.com/licensing/html5
9
+ *
10
+ * JavaScript is a trademark of Oracle Corporation.
11
+ * @author <a href="mailto:david@steema.com">Steema Software</a>
12
+ * @version 5.0.0-beta.1
13
+ */
14
+
15
+ import{C as t}from"./chunks/chart-p639xVyw.js";import"./chunks/series-DeozLXIv.js";
16
+ /**
17
+ * @license
18
+ * Copyright 2010-2026 Three.js Authors
19
+ * SPDX-License-Identifier: MIT
20
+ */const e="185",i=0,n=1,r=2,s=0,a=1,o=2,l=3,h=1,c=3,u=0,d=1,p=2,f=100,m=101,g=102,_=200,v=201,x=202,y=203,M=204,S=205,b=206,E=207,T=208,w=209,A=210,R=211,C=212,P=213,L=214,D=0,I=1,N=2,U=3,O=4,F=5,z=6,B=7,k=0,V=1,H=2,G=1,W=2,X=3,j=4,q=5,Y=6,Z=7,K=301,J=302,$=303,Q=304,tt=306,et=1e3,it=1001,nt=1002,rt=1003,st=1004,at=1005,ot=1006,lt=1007,ht=1008,ct=1009,ut=1010,dt=1011,pt=1012,ft=1013,mt=1014,gt=1015,_t=1016,vt=1017,xt=1018,yt=1020,Mt=35902,St=35899,bt=1023,Et=1026,Tt=1027,wt=1029,At=1030,Rt=1031,Ct=1033,Pt=33776,Lt=33777,Dt=33778,It=33779,Nt=35840,Ut=35841,Ot=35842,Ft=35843,zt=36196,Bt=37492,kt=37496,Vt=37488,Ht=37489,Gt=37490,Wt=37491,Xt=37808,jt=37809,qt=37810,Yt=37811,Zt=37812,Kt=37813,Jt=37814,$t=37815,Qt=37816,te=37817,ee=37818,ie=37819,ne=37820,re=37821,se=36492,ae=36494,oe=36495,le=36283,he=36284,ce=36285,ue=36286,de="",pe="srgb",fe="srgb-linear",me="linear",ge="srgb",_e=7680,ve=512,xe=513,ye=514,Me=515,Se=516,be=517,Ee=518,Te=519,we=35044,Ae="300 es",Re=2e3,Ce=2001;function Pe(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Le(){const t=Pe("canvas");return t.style.display="block",t}const De={};function Ie(...t){const e="THREE."+t.shift();console.log(e,...t)}function Ne(t){const e=t[0];if("string"==typeof e&&e.startsWith("TSL:")){const e=t[1];e&&e.isStackTrace?t[0]+=" "+e.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}function Ue(...t){const e="THREE."+(t=Ne(t)).shift();{const i=t[0];i&&i.isStackTrace?console.warn(i.getError(e)):console.warn(e,...t)}}function Oe(...t){const e="THREE."+(t=Ne(t)).shift();{const i=t[0];i&&i.isStackTrace?console.error(i.getError(e)):console.error(e,...t)}}function Fe(...t){const e=t.join(" ");e in De||(De[e]=!0,Ue(...t))}const ze={[D]:1,[N]:6,[O]:7,[U]:5,[I]:0,[z]:2,[B]:4,[F]:3};class Be{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i&&(void 0!==i[t]&&-1!==i[t].indexOf(e))}removeEventListener(t,e){const i=this._listeners;if(void 0===i)return;const n=i[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){const e=this._listeners;if(void 0===e)return;const i=e[t.type];if(void 0!==i){t.target=this;const e=i.slice(0);for(let i=0,n=e.length;i<n;i++)e[i].call(this,t);t.target=null}}}const ke=["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 Ve=1234567;const He=Math.PI/180,Ge=180/Math.PI;function We(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(ke[255&t]+ke[t>>8&255]+ke[t>>16&255]+ke[t>>24&255]+"-"+ke[255&e]+ke[e>>8&255]+"-"+ke[e>>16&15|64]+ke[e>>24&255]+"-"+ke[63&i|128]+ke[i>>8&255]+"-"+ke[i>>16&255]+ke[i>>24&255]+ke[255&n]+ke[n>>8&255]+ke[n>>16&255]+ke[n>>24&255]).toLowerCase()}function Xe(t,e,i){return Math.max(e,Math.min(i,t))}function je(t,e){return(t%e+e)%e}function qe(t,e,i){return(1-i)*t+i*e}function Ye(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("THREE.MathUtils: Invalid component type.")}}function Ze(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("THREE.MathUtils: Invalid component type.")}}const Ke={DEG2RAD:He,RAD2DEG:Ge,generateUUID:We,clamp:Xe,euclideanModulo:je,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:qe,damp:function(t,e,i,n){return qe(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(je(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-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&&(Ve=t);let e=Ve+=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*He},radToDeg:function(t){return t*Ge},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,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),h=s((e+n)/2),c=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),p=s((n-e)/2),f=a((n-e)/2);switch(r){case"XYX":t.set(o*c,l*u,l*d,o*h);break;case"YZY":t.set(l*d,o*c,l*u,o*h);break;case"ZXZ":t.set(l*u,l*d,o*c,o*h);break;case"XZX":t.set(o*c,l*f,l*p,o*h);break;case"YXY":t.set(l*p,o*c,l*f,o*h);break;case"ZYZ":t.set(l*f,l*p,o*c,o*h);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Ze,denormalize:Ye};class Je{static{Je.prototype.isVector2=!0}constructor(t=0,e=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("THREE.Vector2: 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("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Xe(this.x,t.x,e.x),this.y=Xe(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xe(this.x,t,e),this.y=Xe(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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 i=this.dot(t)/e;return Math.acos(Xe(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class $e{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,r,s,a){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3],u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(c!==f||o!==u||l!==d||h!==p){let t=o*u+l*d+h*p+c*f;t<0&&(u=-u,d=-d,p=-p,f=-f,t=-t);let e=1-a;if(t<.9995){const i=Math.acos(t),n=Math.sin(i);e=Math.sin(e*i)/n,o=o*e+u*(a=Math.sin(a*i)/n),l=l*e+d*a,h=h*e+p*a,c=c*e+f*a}else{o=o*e+u*a,l=l*e+d*a,h=h*e+p*a,c=c*e+f*a;const t=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=t,l*=t,h*=t,c*=t}}t[e]=o,t[e+1]=l,t[e+2]=h,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=a*p+h*c+o*d-l*u,t[e+1]=o*p+h*u+l*c-a*d,t[e+2]=l*p+h*d+a*u-o*c,t[e+3]=h*p-a*c-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(i/2),h=a(n/2),c=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],h=e[6],c=e[10],u=i+a+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(h-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+h)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Xe(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,h=e._w;return this._x=i*h+s*a+n*l-r*o,this._y=n*h+s*o+r*a-i*l,this._z=r*h+s*l+i*o-n*a,this._w=s*h-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,r=t._z,s=t._w,a=this.dot(t);a<0&&(i=-i,n=-n,r=-r,s=-s,a=-a);let o=1-e;if(a<.9995){const t=Math.acos(a),l=Math.sin(t);o=Math.sin(o*t)/l,e=Math.sin(e*t)/l,this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this._onChangeCallback()}else this._x=this._x*o+i*e,this._y=this._y*o+n*e,this._z=this._z*o+r*e,this._w=this._w*o+s*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(n*Math.sin(t),n*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 Qe{static{Qe.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: 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("THREE.Vector3: 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,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=2*(s*n-a*i),h=2*(a*e-r*n),c=2*(r*i-s*e);return this.x=e+o*l+s*c-a*h,this.y=i+o*h+a*l-r*c,this.z=n+o*c+r*h-s*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Xe(this.x,t.x,e.x),this.y=Xe(this.y,t.y,e.y),this.z=Xe(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xe(this.x,t,e),this.y=Xe(this.y,t,e),this.z=Xe(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return 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 i=this.dot(t)/e;return Math.acos(Xe(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ti=new Qe,ei=new $e;class ii{static{ii.prototype.isMatrix3=!0}constructor(t,e,i,n,r,s,a,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l)}set(t,e,i,n,r,s,a,o,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=a,h[3]=e,h[4]=r,h[5]=o,h[6]=i,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],_=n[1],v=n[4],x=n[7],y=n[2],M=n[5],S=n[8];return r[0]=s*f+a*_+o*y,r[3]=s*m+a*v+o*M,r[6]=s*g+a*x+o*S,r[1]=l*f+h*_+c*y,r[4]=l*m+h*v+c*M,r[7]=l*g+h*x+c*S,r[2]=u*f+d*_+p*y,r[5]=u*m+d*v+p*M,r[8]=u*g+d*x+p*S,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8];return e*s*h-e*a*l-i*r*h+i*a*o+n*r*l-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=h*s-a*l,u=a*o-h*r,d=l*r-s*o,p=e*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=c*f,t[1]=(n*l-h*i)*f,t[2]=(a*i-n*s)*f,t[3]=u*f,t[4]=(h*e-n*o)*f,t[5]=(n*r-a*e)*f,t[6]=d*f,t[7]=(i*o-l*e)*f,t[8]=(s*e-i*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*s+l*a)+s+t,-n*l,n*o,-n*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return Fe("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ni.makeScale(t,e)),this}rotate(t){return Fe("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ni.makeRotation(-t)),this}translate(t,e){return Fe("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ni.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),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const ni=new ii,ri=(new ii).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),si=(new ii).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ai(){const t={enabled:!0,workingColorSpace:fe,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i?(this.spaces[e].transfer===ge&&(t.r=li(t.r),t.g=li(t.g),t.b=li(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===ge&&(t.r=hi(t.r),t.g=hi(t.g),t.b=hi(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===de?me: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,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,i){return Fe("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(e,i)},toWorkingColorSpace:function(e,i){return Fe("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(e,i)}},e=[.64,.33,.3,.6,.15,.06],i=[.2126,.7152,.0722],n=[.3127,.329];return t.define({[fe]:{primaries:e,whitePoint:n,transfer:me,toXYZ:ri,fromXYZ:si,luminanceCoefficients:i,workingColorSpaceConfig:{unpackColorSpace:pe},outputColorSpaceConfig:{drawingBufferColorSpace:pe}},[pe]:{primaries:e,whitePoint:n,transfer:ge,toXYZ:ri,fromXYZ:si,luminanceCoefficients:i,outputColorSpaceConfig:{drawingBufferColorSpace:pe}}}),t}const oi=ai();function li(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function hi(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let ci;class ui{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{void 0===ci&&(ci=Pe("canvas")),ci.width=t.width,ci.height=t.height;const e=ci.getContext("2d");t instanceof ImageData?e.putImageData(t,0,0):e.drawImage(t,0,0,t.width,t.height),i=ci}return i.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=Pe("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t<r.length;t++)r[t]=255*li(r[t]/255);return i.putImageData(n,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*li(e[t]/255)):e[t]=li(e[t]);return{data:e,width:t.width,height:t.height}}return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let di=0;class pi{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:di++}),this.uuid=We(),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):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,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 i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(fi(n[e].image)):t.push(fi(n[e]))}else t=fi(n);i.url=t}return e||(t.images[this.uuid]=i),i}}function fi(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?ui.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Ue("Texture: Unable to serialize Texture."),{})}let mi=0;const gi=new Qe;class _i extends Be{constructor(t=_i.DEFAULT_IMAGE,e=_i.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=ct,l=_i.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mi++}),this.uuid=We(),this.name="",this.source=new pi(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new Je(0,0),this.repeat=new Je(1,1),this.center=new Je(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ii,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,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,this.normalized=!1}get width(){return this.source.getSize(gi).x}get height(){return this.source.getSize(gi).y}get depth(){return this.source.getSize(gi).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}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.normalized=t.normalized,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 i=t[e];if(void 0===i){Ue(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i:Ue(`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 i={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,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case et:t.x=t.x-Math.floor(t.x);break;case it:t.x=t.x<0?0:1;break;case nt: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 et:t.y=t.y-Math.floor(t.y);break;case it:t.y=t.y<0?0:1;break;case nt: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++}}_i.DEFAULT_IMAGE=null,_i.DEFAULT_MAPPING=300,_i.DEFAULT_ANISOTROPY=1;class vi{static{vi.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}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,i,n,r;const s=.01,a=.1,o=t.elements,l=o[0],h=o[4],c=o[8],u=o[1],d=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(h-u)<s&&Math.abs(c-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+u)<a&&Math.abs(c+f)<a&&Math.abs(p+m)<a&&Math.abs(l+d+g-3)<a)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,o=(d+1)/2,_=(g+1)/2,v=(h+u)/4,x=(c+f)/4,y=(p+m)/4;return t>o&&t>_?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=v/i,r=x/i):o>_?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=v/n,r=y/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=x/r,n=y/r),this.set(i,n,r,e),this}let _=Math.sqrt((m-p)*(m-p)+(c-f)*(c-f)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(c-f)/_,this.z=(u-h)/_,this.w=Math.acos((l+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=Xe(this.x,t.x,e.x),this.y=Xe(this.y,t.y,e.y),this.z=Xe(this.z,t.z,e.z),this.w=Xe(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xe(this.x,t,e),this.y=Xe(this.y,t,e),this.z=Xe(this.z,t,e),this.w=Xe(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Xe(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class xi extends Be{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ot,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new vi(0,0,t,e),this.scissorTest=!1,this.viewport=new vi(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},r=new _i(n),s=i.count;for(let t=0;t<s;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:ot,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,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,r=this.textures.length;n<r;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,!0!==this.textures[n].isData3DTexture&&(this.textures[n].isArrayTexture=this.textures[n].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,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new pi(i)}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.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class yi extends xi{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Mi extends _i{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=rt,this.minFilter=rt,this.wrapR=it,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Si extends _i{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=rt,this.minFilter=rt,this.wrapR=it,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class bi{static{bi.prototype.isMatrix4=!0}constructor(t,e,i,n,r,s,a,o,l,h,c,u,d,p,f,m){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,i,n,r,s,a,o,l,h,c,u,d,p,f,m)}set(t,e,i,n,r,s,a,o,l,h,c,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,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 bi).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return 0===this.determinantAffine()?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const e=this.elements,i=t.elements,n=1/Ei.setFromMatrixColumn(t,0).length(),r=1/Ei.setFromMatrixColumn(t,1).length(),s=1/Ei.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=-o*c,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=n+i*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t+r*a,e[4]=n*a-i,e[8]=s*l,e[1]=s*c,e[5]=s*h,e[9]=-a,e[2]=i*a-n,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*h,i=o*c,n=l*h,r=l*c;e[0]=t-r*a,e[4]=-s*c,e[8]=n+i*a,e[1]=i+n*a,e[5]=s*h,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*h,i=s*c,n=a*h,r=a*c;e[0]=o*h,e[4]=n*l-i,e[8]=t*l+r,e[1]=o*c,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=r-t*c,e[8]=n*c+i,e[1]=c,e[5]=s*h,e[9]=-a*h,e[2]=-l*h,e[6]=i*c+n,e[10]=t-r*c}else if("XZY"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*h,e[4]=-c,e[8]=l*h,e[1]=t*c+r,e[5]=s*h,e[9]=i*c-n,e[2]=n*c-i,e[6]=a*h,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(wi,t,Ai)}lookAt(t,e,i){const n=this.elements;return Pi.subVectors(t,e),0===Pi.lengthSq()&&(Pi.z=1),Pi.normalize(),Ri.crossVectors(i,Pi),0===Ri.lengthSq()&&(1===Math.abs(i.z)?Pi.x+=1e-4:Pi.z+=1e-4,Pi.normalize(),Ri.crossVectors(i,Pi)),Ri.normalize(),Ci.crossVectors(Pi,Ri),n[0]=Ri.x,n[4]=Ci.x,n[8]=Pi.x,n[1]=Ri.y,n[5]=Ci.y,n[9]=Pi.y,n[2]=Ri.z,n[6]=Ci.z,n[10]=Pi.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],_=i[3],v=i[7],x=i[11],y=i[15],M=n[0],S=n[4],b=n[8],E=n[12],T=n[1],w=n[5],A=n[9],R=n[13],C=n[2],P=n[6],L=n[10],D=n[14],I=n[3],N=n[7],U=n[11],O=n[15];return r[0]=s*M+a*T+o*C+l*I,r[4]=s*S+a*w+o*P+l*N,r[8]=s*b+a*A+o*L+l*U,r[12]=s*E+a*R+o*D+l*O,r[1]=h*M+c*T+u*C+d*I,r[5]=h*S+c*w+u*P+d*N,r[9]=h*b+c*A+u*L+d*U,r[13]=h*E+c*R+u*D+d*O,r[2]=p*M+f*T+m*C+g*I,r[6]=p*S+f*w+m*P+g*N,r[10]=p*b+f*A+m*L+g*U,r[14]=p*E+f*R+m*D+g*O,r[3]=_*M+v*T+x*C+y*I,r[7]=_*S+v*w+x*P+y*N,r[11]=_*b+v*A+x*L+y*U,r[15]=_*E+v*R+x*D+y*O,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],h=t[2],c=t[6],u=t[10],d=t[14],p=t[3],f=t[7],m=t[11],g=t[15],_=o*d-l*u,v=a*d-l*c,x=a*u-o*c,y=s*d-l*h,M=s*u-o*h,S=s*c-a*h;return e*(f*_-m*v+g*x)-i*(p*_-m*y+g*M)+n*(p*v-f*y+g*S)-r*(p*x-f*M+m*S)}determinantAffine(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[1],s=t[5],a=t[9],o=t[2],l=t[6],h=t[10];return e*(s*h-a*l)-i*(r*h-a*o)+n*(r*l-s*o)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],h=t[8],c=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=e*a-i*s,v=e*o-n*s,x=e*l-r*s,y=i*o-n*a,M=i*l-r*a,S=n*l-r*o,b=h*f-c*p,E=h*m-u*p,T=h*g-d*p,w=c*m-u*f,A=c*g-d*f,R=u*g-d*m,C=_*R-v*A+x*w+y*T-M*E+S*b;if(0===C)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/C;return t[0]=(a*R-o*A+l*w)*P,t[1]=(n*A-i*R-r*w)*P,t[2]=(f*S-m*M+g*y)*P,t[3]=(u*M-c*S-d*y)*P,t[4]=(o*T-s*R-l*E)*P,t[5]=(e*R-n*T+r*E)*P,t[6]=(m*x-p*S-g*v)*P,t[7]=(h*S-u*x+d*v)*P,t[8]=(s*A-a*T+l*b)*P,t[9]=(i*T-e*A-r*b)*P,t[10]=(p*M-f*x+g*_)*P,t[11]=(c*x-h*M-d*_)*P,t[12]=(a*E-s*w-o*b)*P,t[13]=(e*w-i*E+n*b)*P,t[14]=(f*v-p*y-m*_)*P,t[15]=(h*y-c*v+u*_)*P,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return 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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,a=t.y,o=t.z,l=r*s,h=r*a;return this.set(l*s+i,l*a-n*o,l*o+n*a,0,l*a+n*o,h*a+i,h*o-n*s,0,l*o-n*a,h*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,s){return this.set(1,i,r,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,h=s+s,c=a+a,u=r*l,d=r*h,p=r*c,f=s*h,m=s*c,g=a*c,_=o*l,v=o*h,x=o*c,y=i.x,M=i.y,S=i.z;return n[0]=(1-(f+g))*y,n[1]=(d+x)*y,n[2]=(p-v)*y,n[3]=0,n[4]=(d-x)*M,n[5]=(1-(u+g))*M,n[6]=(m+_)*M,n[7]=0,n[8]=(p+v)*S,n[9]=(m-_)*S,n[10]=(1-(u+f))*S,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const r=this.determinantAffine();if(0===r)return i.set(1,1,1),e.identity(),this;let s=Ei.set(n[0],n[1],n[2]).length();const a=Ei.set(n[4],n[5],n[6]).length(),o=Ei.set(n[8],n[9],n[10]).length();r<0&&(s=-s),Ti.copy(this);const l=1/s,h=1/a,c=1/o;return Ti.elements[0]*=l,Ti.elements[1]*=l,Ti.elements[2]*=l,Ti.elements[4]*=h,Ti.elements[5]*=h,Ti.elements[6]*=h,Ti.elements[8]*=c,Ti.elements[9]*=c,Ti.elements[10]*=c,e.setFromRotationMatrix(Ti),i.x=s,i.y=a,i.z=o,this}makePerspective(t,e,i,n,r,s,a=2e3,o=!1){const l=this.elements,h=2*r/(e-t),c=2*r/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,f;if(o)p=r/(s-r),f=s*r/(s-r);else if(a===Re)p=-(s+r)/(s-r),f=-2*s*r/(s-r);else{if(a!==Ce)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-r),f=-s*r/(s-r)}return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=c,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,r,s,a=2e3,o=!1){const l=this.elements,h=2/(e-t),c=2/(i-n),u=-(e+t)/(e-t),d=-(i+n)/(i-n);let p,f;if(o)p=1/(s-r),f=s/(s-r);else if(a===Re)p=-2/(s-r),f=-(s+r)/(s-r);else{if(a!==Ce)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=-1/(s-r),f=-r/(s-r)}return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=c,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Ei=new Qe,Ti=new bi,wi=new Qe(0,0,0),Ai=new Qe(1,1,1),Ri=new Qe,Ci=new Qe,Pi=new Qe,Li=new bi,Di=new $e;class Ii{constructor(t=0,e=0,i=0,n=Ii.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],s=n[4],a=n[8],o=n[1],l=n[5],h=n[9],c=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(Xe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xe(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Xe(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(-s,l));break;case"YZX":this._z=Math.asin(Xe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Xe(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Li.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Li,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Di.setFromEuler(this),this.setFromQuaternion(Di,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}}Ii.DEFAULT_ORDER="XYZ";class Ni{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 Ui=0;const Oi=new Qe,Fi=new $e,zi=new bi,Bi=new Qe,ki=new Qe,Vi=new Qe,Hi=new $e,Gi=new Qe(1,0,0),Wi=new Qe(0,1,0),Xi=new Qe(0,0,1),ji={type:"added"},qi={type:"removed"},Yi={type:"childadded",child:null},Zi={type:"childremoved",child:null};class Ki extends Be{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ui++}),this.uuid=We(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ki.DEFAULT_UP.clone();const t=new Qe,e=new Ii,i=new $e,n=new Qe(1,1,1);e._onChange(function(){i.setFromEuler(e,!1)}),i._onChange(function(){e.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new bi},normalMatrix:{value:new ii}}),this.matrix=new bi,this.matrixWorld=new bi,this.matrixAutoUpdate=Ki.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ki.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ni,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.static=!1,this.userData={},this.pivot=null}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 Fi.setFromAxisAngle(t,e),this.quaternion.multiply(Fi),this}rotateOnWorldAxis(t,e){return Fi.setFromAxisAngle(t,e),this.quaternion.premultiply(Fi),this}rotateX(t){return this.rotateOnAxis(Gi,t)}rotateY(t){return this.rotateOnAxis(Wi,t)}rotateZ(t){return this.rotateOnAxis(Xi,t)}translateOnAxis(t,e){return Oi.copy(t).applyQuaternion(this.quaternion),this.position.add(Oi.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Gi,t)}translateY(t){return this.translateOnAxis(Wi,t)}translateZ(t){return this.translateOnAxis(Xi,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(zi.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Bi.copy(t):Bi.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),ki.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?zi.lookAt(ki,Bi,this.up):zi.lookAt(Bi,ki,this.up),this.quaternion.setFromRotationMatrix(zi),n&&(zi.extractRotation(n.matrixWorld),Fi.setFromRotationMatrix(zi),this.quaternion.premultiply(Fi.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(Oe("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(ji),Yi.child=t,this.dispatchEvent(Yi),Yi.child=null):Oe("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(qi),Zi.child=t,this.dispatchEvent(Zi),Zi.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),zi.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),zi.multiply(t.parent.matrixWorld)),t.applyMatrix4(zi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(ji),Yi.child=t,this.dispatchEvent(Yi),Yi.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 i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let r=0,s=n.length;r<s;r++)n[r].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ki,t,Vi),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ki,Hi,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(null!==t){const e=t.x,i=t.y,n=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*i-r[8]*n,r[13]+=i-r[1]*e-r[5]*i-r[9]*n,r[14]+=n-r[2]*e-r[6]*i-r[10]*n}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 i=0,n=e.length;i<n;i++){e[i].updateMatrixWorld(t)}}updateWorldMatrix(t,e,i=!1){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0,i)}}}toJSON(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),!1!==this.static&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),null!==this.pivot&&(n.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(t=>({...t})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(n.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(n.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(n.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=s(t.geometries),n=s(t.materials),r=s(t.textures),a=s(t.images),o=s(t.shapes),l=s(t.skeletons),h=s(t.animations),c=s(t.nodes);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=null!==t.pivot?t.pivot.clone():null,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.static=t.static,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 i=t.children[e];this.add(i.clone())}return this}}Ki.DEFAULT_UP=new Qe(0,1,0),Ki.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ki.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Ji extends Ki{constructor(){super(),this.isGroup=!0,this.type="Group"}}const $i={type:"move"};class Qi{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Ji,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 Ji,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Qe),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Ji,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Qe,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let n=null,r=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(l&&t.hand){s=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i),r=this._getHandJoint(l,n);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}const n=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],a=n.position.distanceTo(r.position),o=.02,h=.005;l.inputState.pinching&&a>o+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),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,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:t,target:this})));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent($i)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new Ji;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const tn={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},en={h:0,s:0,l:0},nn={h:0,s:0,l:0};function rn(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class sn{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){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,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=pe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,oi.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=oi.workingColorSpace){return this.r=t,this.g=e,this.b=i,oi.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=oi.workingColorSpace){if(t=je(t,1),e=Xe(e,0,1),i=Xe(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=rn(r,n,t+1/3),this.g=rn(r,n,t),this.b=rn(r,n,t-1/3)}return oi.colorSpaceToWorking(this,n),this}setStyle(t,e=pe){function i(e){void 0!==e&&parseFloat(e)<1&&Ue("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=n[1],a=n[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(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 i(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 i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ue("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,16),e);Ue("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=pe){const i=tn[t.toLowerCase()];return void 0!==i?this.setHex(i,e):Ue("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=li(t.r),this.g=li(t.g),this.b=li(t.b),this}copyLinearToSRGB(t){return this.r=hi(t.r),this.g=hi(t.g),this.b=hi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=pe){return oi.workingToColorSpace(an.copy(this),t),65536*Math.round(Xe(255*an.r,0,255))+256*Math.round(Xe(255*an.g,0,255))+Math.round(Xe(255*an.b,0,255))}getHexString(t=pe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=oi.workingColorSpace){oi.workingToColorSpace(an.copy(this),e);const i=an.r,n=an.g,r=an.b,s=Math.max(i,n,r),a=Math.min(i,n,r);let o,l;const h=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=h<=.5?t/(s+a):t/(2-s-a),s){case i:o=(n-r)/t+(n<r?6:0);break;case n:o=(r-i)/t+2;break;case r:o=(i-n)/t+4}o/=6}return t.h=o,t.s=l,t.l=h,t}getRGB(t,e=oi.workingColorSpace){return oi.workingToColorSpace(an.copy(this),e),t.r=an.r,t.g=an.g,t.b=an.b,t}getStyle(t=pe){oi.workingToColorSpace(an.copy(this),t);const e=an.r,i=an.g,n=an.b;return t!==pe?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(t,e,i){return this.getHSL(en),this.setHSL(en.h+t,en.s+e,en.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(en),t.getHSL(nn);const i=qe(en.h,nn.h,e),n=qe(en.s,nn.s,e),r=qe(en.l,nn.l,e);return this.setHSL(i,n,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,r=t.elements;return this.r=r[0]*e+r[3]*i+r[6]*n,this.g=r[1]*e+r[4]*i+r[7]*n,this.b=r[2]*e+r[5]*i+r[8]*n,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 an=new sn;sn.NAMES=tn;class on extends Ki{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 Ii,this.environmentIntensity=1,this.environmentRotation=new Ii,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}}const ln=new Qe,hn=new Qe,cn=new Qe,un=new Qe,dn=new Qe,pn=new Qe,fn=new Qe,mn=new Qe,gn=new Qe,_n=new Qe,vn=new vi,xn=new vi,yn=new vi;class Mn{constructor(t=new Qe,e=new Qe,i=new Qe){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),ln.subVectors(t,e),n.cross(ln);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){ln.subVectors(n,e),hn.subVectors(i,e),cn.subVectors(t,e);const s=ln.dot(ln),a=ln.dot(hn),o=ln.dot(cn),l=hn.dot(hn),h=hn.dot(cn),c=s*l-a*a;if(0===c)return r.set(0,0,0),null;const u=1/c,d=(l*o-a*h)*u,p=(s*h-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return null!==this.getBarycoord(t,e,i,n,un)&&(un.x>=0&&un.y>=0&&un.x+un.y<=1)}static getInterpolation(t,e,i,n,r,s,a,o){return null===this.getBarycoord(t,e,i,n,un)?(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,un.x),o.addScaledVector(s,un.y),o.addScaledVector(a,un.z),o)}static getInterpolatedAttribute(t,e,i,n,r,s){return vn.setScalar(0),xn.setScalar(0),yn.setScalar(0),vn.fromBufferAttribute(t,e),xn.fromBufferAttribute(t,i),yn.fromBufferAttribute(t,n),s.setScalar(0),s.addScaledVector(vn,r.x),s.addScaledVector(xn,r.y),s.addScaledVector(yn,r.z),s}static isFrontFacing(t,e,i,n){return ln.subVectors(i,e),hn.subVectors(t,e),ln.cross(hn).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ln.subVectors(this.c,this.b),hn.subVectors(this.a,this.b),.5*ln.cross(hn).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Mn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Mn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,r){return Mn.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Mn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Mn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let s,a;dn.subVectors(n,i),pn.subVectors(r,i),mn.subVectors(t,i);const o=dn.dot(mn),l=pn.dot(mn);if(o<=0&&l<=0)return e.copy(i);gn.subVectors(t,n);const h=dn.dot(gn),c=pn.dot(gn);if(h>=0&&c<=h)return e.copy(n);const u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return s=o/(o-h),e.copy(i).addScaledVector(dn,s);_n.subVectors(t,r);const d=dn.dot(_n),p=pn.dot(_n);if(p>=0&&d<=p)return e.copy(r);const f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),e.copy(i).addScaledVector(pn,a);const m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return fn.subVectors(r,n),a=(c-h)/(c-h+(d-p)),e.copy(n).addScaledVector(fn,a);const g=1/(m+f+u);return s=f*g,a=u*g,e.copy(i).addScaledVector(dn,s).addScaledVector(pn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Sn{constructor(t=new Qe(1/0,1/0,1/0),e=new Qe(-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,i=t.length;e<i;e+=3)this.expandByPoint(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(En.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=En.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(void 0!==i){const n=i.getAttribute("position");if(!0===e&&void 0!==n&&!0!==t.isInstancedMesh)for(let e=0,i=n.count;e<i;e++)!0===t.isMesh?t.getVertexPosition(e,En):En.fromBufferAttribute(n,e),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),Tn.copy(t.boundingBox)):(null===i.boundingBox&&i.computeBoundingBox(),Tn.copy(i.boundingBox)),Tn.applyMatrix4(t.matrixWorld),this.union(Tn)}const n=t.children;for(let t=0,i=n.length;t<i;t++)this.expandByObject(n[t],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,En),En.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Dn),In.subVectors(this.max,Dn),wn.subVectors(t.a,Dn),An.subVectors(t.b,Dn),Rn.subVectors(t.c,Dn),Cn.subVectors(An,wn),Pn.subVectors(Rn,An),Ln.subVectors(wn,Rn);let e=[0,-Cn.z,Cn.y,0,-Pn.z,Pn.y,0,-Ln.z,Ln.y,Cn.z,0,-Cn.x,Pn.z,0,-Pn.x,Ln.z,0,-Ln.x,-Cn.y,Cn.x,0,-Pn.y,Pn.x,0,-Ln.y,Ln.x,0];return!!On(e,wn,An,Rn,In)&&(e=[1,0,0,0,1,0,0,0,1],!!On(e,wn,An,Rn,In)&&(Nn.crossVectors(Cn,Pn),e=[Nn.x,Nn.y,Nn.z],On(e,wn,An,Rn,In)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(En).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()||(bn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),bn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),bn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),bn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),bn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),bn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),bn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),bn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(bn)),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 bn=[new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe],En=new Qe,Tn=new Sn,wn=new Qe,An=new Qe,Rn=new Qe,Cn=new Qe,Pn=new Qe,Ln=new Qe,Dn=new Qe,In=new Qe,Nn=new Qe,Un=new Qe;function On(t,e,i,n,r){for(let s=0,a=t.length-3;s<=a;s+=3){Un.fromArray(t,s);const a=r.x*Math.abs(Un.x)+r.y*Math.abs(Un.y)+r.z*Math.abs(Un.z),o=e.dot(Un),l=i.dot(Un),h=n.dot(Un);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>a)return!1}return!0}const Fn=new Qe,zn=new Je;let Bn=0;class kn extends Be{constructor(t,e,i=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Bn++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=we,this.updateRanges=[],this.gpuType=gt,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,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)zn.fromBufferAttribute(this,e),zn.applyMatrix3(t),this.setXY(e,zn.x,zn.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)Fn.fromBufferAttribute(this,e),Fn.applyMatrix3(t),this.setXYZ(e,Fn.x,Fn.y,Fn.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)Fn.fromBufferAttribute(this,e),Fn.applyMatrix4(t),this.setXYZ(e,Fn.x,Fn.y,Fn.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Fn.fromBufferAttribute(this,e),Fn.applyNormalMatrix(t),this.setXYZ(e,Fn.x,Fn.y,Fn.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Fn.fromBufferAttribute(this,e),Fn.transformDirection(t),this.setXYZ(e,Fn.x,Fn.y,Fn.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Ye(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Ze(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ye(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ye(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ze(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=Ye(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ze(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=Ye(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array),n=Ze(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array),n=Ze(n,this.array),r=Ze(r,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==we&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Vn extends kn{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class Hn extends kn{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class Gn extends kn{constructor(t,e,i){super(new Float32Array(t),e,i)}}const Wn=new Sn,Xn=new Qe,jn=new Qe;class qn{constructor(t=new Qe,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 i=this.center;void 0!==e?i.copy(e):Wn.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Xn.subVectors(t,this.center);const e=Xn.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Xn,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(jn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Xn.copy(t.center).add(jn)),this.expandByPoint(Xn.copy(t.center).sub(jn))),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}}let Yn=0;const Zn=new bi,Kn=new Ki,Jn=new Qe,$n=new Sn,Qn=new Sn,tr=new Qe;class er extends Be{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yn++}),this.uuid=We(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?Hn:Vn)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,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,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new ii).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return Zn.makeRotationFromQuaternion(t),this.applyMatrix4(Zn),this}rotateX(t){return Zn.makeRotationX(t),this.applyMatrix4(Zn),this}rotateY(t){return Zn.makeRotationY(t),this.applyMatrix4(Zn),this}rotateZ(t){return Zn.makeRotationZ(t),this.applyMatrix4(Zn),this}translate(t,e,i){return Zn.makeTranslation(t,e,i),this.applyMatrix4(Zn),this}scale(t,e,i){return Zn.makeScale(t,e,i),this.applyMatrix4(Zn),this}lookAt(t){return Kn.lookAt(t),Kn.updateMatrix(),this.applyMatrix4(Kn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Jn).negate(),this.translate(Jn.x,Jn.y,Jn.z),this}setFromPoints(t){const e=this.getAttribute("position");if(void 0===e){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}this.setAttribute("position",new Gn(e,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const i=t[n];e.setXYZ(n,i.x,i.y,i.z||0)}t.length>e.count&&Ue("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 Sn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Oe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Qe(-1/0,-1/0,-1/0),new Qe(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];$n.setFromBufferAttribute(i),this.morphTargetsRelative?(tr.addVectors(this.boundingBox.min,$n.min),this.boundingBox.expandByPoint(tr),tr.addVectors(this.boundingBox.max,$n.max),this.boundingBox.expandByPoint(tr)):(this.boundingBox.expandByPoint($n.min),this.boundingBox.expandByPoint($n.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Oe('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 qn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return Oe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new Qe,1/0);if(t){const i=this.boundingSphere.center;if($n.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];Qn.setFromBufferAttribute(i),this.morphTargetsRelative?(tr.addVectors($n.min,Qn.min),$n.expandByPoint(tr),tr.addVectors($n.max,Qn.max),$n.expandByPoint(tr)):($n.expandByPoint(Qn.min),$n.expandByPoint(Qn.max))}$n.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)tr.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(tr));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],a=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)tr.fromBufferAttribute(s,e),a&&(Jn.fromBufferAttribute(t,e),tr.add(Jn)),n=Math.max(n,i.distanceToSquared(tr))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Oe('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 Oe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.position,n=e.normal,r=e.uv;let s=this.getAttribute("tangent");void 0!==s&&s.count===i.count||(s=new kn(new Float32Array(4*i.count),4),this.setAttribute("tangent",s));const a=[],o=[];for(let t=0;t<i.count;t++)a[t]=new Qe,o[t]=new Qe;const l=new Qe,h=new Qe,c=new Qe,u=new Je,d=new Je,p=new Je,f=new Qe,m=new Qe;function g(t,e,n){l.fromBufferAttribute(i,t),h.fromBufferAttribute(i,e),c.fromBufferAttribute(i,n),u.fromBufferAttribute(r,t),d.fromBufferAttribute(r,e),p.fromBufferAttribute(r,n),h.sub(l),c.sub(l),d.sub(u),p.sub(u);const s=1/(d.x*p.y-p.x*d.y);isFinite(s)&&(f.copy(h).multiplyScalar(p.y).addScaledVector(c,-d.y).multiplyScalar(s),m.copy(c).multiplyScalar(d.x).addScaledVector(h,-p.x).multiplyScalar(s),a[t].add(f),a[e].add(f),a[n].add(f),o[t].add(m),o[e].add(m),o[n].add(m))}let _=this.groups;0===_.length&&(_=[{start:0,count:t.count}]);for(let e=0,i=_.length;e<i;++e){const i=_[e],n=i.start;for(let e=n,r=n+i.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const v=new Qe,x=new Qe,y=new Qe,M=new Qe;function S(t){y.fromBufferAttribute(n,t),M.copy(y);const e=a[t];v.copy(e),v.sub(y.multiplyScalar(y.dot(e))).normalize(),x.crossVectors(M,e);const i=x.dot(o[t])<0?-1:1;s.setXYZW(t,v.x,v.y,v.z,i)}for(let e=0,i=_.length;e<i;++e){const i=_[e],n=i.start;for(let e=n,r=n+i.count;e<r;e+=3)S(t.getX(e+0)),S(t.getX(e+1)),S(t.getX(e+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i||i.count!==e.count)i=new kn(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new Qe,r=new Qe,s=new Qe,a=new Qe,o=new Qe,l=new Qe,h=new Qe,c=new Qe;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),c.subVectors(n,r),h.cross(c),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,f),a.add(h),o.add(h),l.add(h),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(f,l.x,l.y,l.z)}else for(let t=0,a=e.count;t<a;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),c.subVectors(n,r),h.cross(c),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)tr.fromBufferAttribute(t,e),tr.normalize(),t.setXYZ(e,tr.x,tr.y,tr.z)}toNonIndexed(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,s=new i.constructor(e.length*n);let a=0,o=0;for(let r=0,l=e.length;r<l;r++){a=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*n;for(let t=0;t<n;t++)s[o++]=i[a++]}return new kn(s,n,r)}if(null===this.index)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new er,i=this.index.array,n=this.attributes;for(const r in n){const s=t(n[r],i);e.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],a=r[n];for(let e=0,n=a.length;e<n;e++){const n=t(a[e],i);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.addGroup(i.start,i.count,i.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e];s.push(n.toJSON(t.data))}s.length>0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=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 i=t.index;null!==i&&this.setIndex(i.clone());const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const a=t.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=t.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ir{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=we,this.updateRanges=[],this.version=0,this.uuid=We()}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,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];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=We()),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]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}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=We()),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 nr=new Qe;class rr{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}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,i=this.data.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.applyMatrix4(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.applyNormalMatrix(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)nr.fromBufferAttribute(this,e),nr.transformDirection(t),this.setXYZ(e,nr.x,nr.y,nr.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Ye(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Ze(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=Ze(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Ze(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Ze(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Ze(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=Ye(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ye(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ye(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ye(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array),n=Ze(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Ze(e,this.array),i=Ze(i,this.array),n=Ze(n,this.array),r=Ze(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this}clone(t){if(void 0===t){Ie("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new kn(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 rr(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){Ie("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+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}}}let sr,ar=0;class or extends Be{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ar++}),this.uuid=We(),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=f,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new sn(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=_e,this.stencilZFail=_e,this.stencilZPass=_e,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 i=t[e];if(void 0===i){Ue(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:Ue(`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 i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),this.blendEquation!==f&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_e&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_e&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_e&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}fromJSON(t,e){if(void 0!==t.uuid&&(this.uuid=t.uuid),void 0!==t.name&&(this.name=t.name),void 0!==t.color&&void 0!==this.color&&this.color.setHex(t.color),void 0!==t.roughness&&(this.roughness=t.roughness),void 0!==t.metalness&&(this.metalness=t.metalness),void 0!==t.sheen&&(this.sheen=t.sheen),void 0!==t.sheenColor&&(this.sheenColor=(new sn).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(this.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==this.emissive&&this.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==this.specular&&this.specular.setHex(t.specular),void 0!==t.specularIntensity&&(this.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(this.shininess=t.shininess),void 0!==t.clearcoat&&(this.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(this.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.dispersion&&(this.dispersion=t.dispersion),void 0!==t.iridescence&&(this.iridescence=t.iridescence),void 0!==t.iridescenceIOR&&(this.iridescenceIOR=t.iridescenceIOR),void 0!==t.iridescenceThicknessRange&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),void 0!==t.transmission&&(this.transmission=t.transmission),void 0!==t.thickness&&(this.thickness=t.thickness),void 0!==t.attenuationDistance&&(this.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(t.attenuationColor),void 0!==t.anisotropy&&(this.anisotropy=t.anisotropy),void 0!==t.anisotropyRotation&&(this.anisotropyRotation=t.anisotropyRotation),void 0!==t.fog&&(this.fog=t.fog),void 0!==t.flatShading&&(this.flatShading=t.flatShading),void 0!==t.blending&&(this.blending=t.blending),void 0!==t.combine&&(this.combine=t.combine),void 0!==t.side&&(this.side=t.side),void 0!==t.shadowSide&&(this.shadowSide=t.shadowSide),void 0!==t.opacity&&(this.opacity=t.opacity),void 0!==t.transparent&&(this.transparent=t.transparent),void 0!==t.alphaTest&&(this.alphaTest=t.alphaTest),void 0!==t.alphaHash&&(this.alphaHash=t.alphaHash),void 0!==t.depthFunc&&(this.depthFunc=t.depthFunc),void 0!==t.depthTest&&(this.depthTest=t.depthTest),void 0!==t.depthWrite&&(this.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(this.colorWrite=t.colorWrite),void 0!==t.blendSrc&&(this.blendSrc=t.blendSrc),void 0!==t.blendDst&&(this.blendDst=t.blendDst),void 0!==t.blendEquation&&(this.blendEquation=t.blendEquation),void 0!==t.blendSrcAlpha&&(this.blendSrcAlpha=t.blendSrcAlpha),void 0!==t.blendDstAlpha&&(this.blendDstAlpha=t.blendDstAlpha),void 0!==t.blendEquationAlpha&&(this.blendEquationAlpha=t.blendEquationAlpha),void 0!==t.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(t.blendColor),void 0!==t.blendAlpha&&(this.blendAlpha=t.blendAlpha),void 0!==t.stencilWriteMask&&(this.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(this.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(this.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(this.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(this.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(this.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(this.stencilZPass=t.stencilZPass),void 0!==t.stencilWrite&&(this.stencilWrite=t.stencilWrite),void 0!==t.wireframe&&(this.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(this.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(this.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(this.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(this.rotation=t.rotation),void 0!==t.linewidth&&(this.linewidth=t.linewidth),void 0!==t.dashSize&&(this.dashSize=t.dashSize),void 0!==t.gapSize&&(this.gapSize=t.gapSize),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.polygonOffset&&(this.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(this.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(this.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(this.dithering=t.dithering),void 0!==t.alphaToCoverage&&(this.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(this.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.forceSinglePass&&(this.forceSinglePass=t.forceSinglePass),void 0!==t.allowOverride&&(this.allowOverride=t.allowOverride),void 0!==t.visible&&(this.visible=t.visible),void 0!==t.toneMapped&&(this.toneMapped=t.toneMapped),void 0!==t.userData&&(this.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),void 0!==t.size&&(this.size=t.size),void 0!==t.sizeAttenuation&&(this.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(this.map=e[t.map]||null),void 0!==t.matcap&&(this.matcap=e[t.matcap]||null),void 0!==t.alphaMap&&(this.alphaMap=e[t.alphaMap]||null),void 0!==t.bumpMap&&(this.bumpMap=e[t.bumpMap]||null),void 0!==t.bumpScale&&(this.bumpScale=t.bumpScale),void 0!==t.normalMap&&(this.normalMap=e[t.normalMap]||null),void 0!==t.normalMapType&&(this.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),this.normalScale=(new Je).fromArray(e)}return void 0!==t.displacementMap&&(this.displacementMap=e[t.displacementMap]||null),void 0!==t.displacementScale&&(this.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(this.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(this.roughnessMap=e[t.roughnessMap]||null),void 0!==t.metalnessMap&&(this.metalnessMap=e[t.metalnessMap]||null),void 0!==t.emissiveMap&&(this.emissiveMap=e[t.emissiveMap]||null),void 0!==t.emissiveIntensity&&(this.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(this.specularMap=e[t.specularMap]||null),void 0!==t.specularIntensityMap&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),void 0!==t.specularColorMap&&(this.specularColorMap=e[t.specularColorMap]||null),void 0!==t.envMap&&(this.envMap=e[t.envMap]||null),void 0!==t.envMapRotation&&this.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(this.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(this.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(this.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(this.lightMap=e[t.lightMap]||null),void 0!==t.lightMapIntensity&&(this.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(this.aoMap=e[t.aoMap]||null),void 0!==t.aoMapIntensity&&(this.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(this.gradientMap=e[t.gradientMap]||null),void 0!==t.clearcoatMap&&(this.clearcoatMap=e[t.clearcoatMap]||null),void 0!==t.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),void 0!==t.clearcoatNormalMap&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),void 0!==t.clearcoatNormalScale&&(this.clearcoatNormalScale=(new Je).fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(this.iridescenceMap=e[t.iridescenceMap]||null),void 0!==t.iridescenceThicknessMap&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),void 0!==t.transmissionMap&&(this.transmissionMap=e[t.transmissionMap]||null),void 0!==t.thicknessMap&&(this.thicknessMap=e[t.thicknessMap]||null),void 0!==t.anisotropyMap&&(this.anisotropyMap=e[t.anisotropyMap]||null),void 0!==t.sheenColorMap&&(this.sheenColorMap=e[t.sheenColorMap]||null),void 0!==t.sheenRoughnessMap&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,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 lr extends or{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new sn(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}}const hr=new Qe,cr=new Qe,ur=new Qe,dr=new Je,pr=new Je,fr=new bi,mr=new Qe,gr=new Qe,_r=new Qe,vr=new Je,xr=new Je,yr=new Je;class Mr extends Ki{constructor(t=new lr){if(super(),this.isSprite=!0,this.type="Sprite",void 0===sr){sr=new er;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 ir(t,5);sr.setIndex([0,1,2,0,2,3]),sr.setAttribute("position",new rr(e,3,0,!1)),sr.setAttribute("uv",new rr(e,2,3,!1))}this.geometry=sr,this.material=t,this.center=new Je(.5,.5),this.count=1}raycast(t,e){null===t.camera&&Oe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),cr.setFromMatrixScale(this.matrixWorld),fr.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ur.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&cr.multiplyScalar(-ur.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;Sr(mr.set(-.5,-.5,0),ur,s,cr,n,r),Sr(gr.set(.5,-.5,0),ur,s,cr,n,r),Sr(_r.set(.5,.5,0),ur,s,cr,n,r),vr.set(0,0),xr.set(1,0),yr.set(1,1);let a=t.ray.intersectTriangle(mr,gr,_r,!1,hr);if(null===a&&(Sr(gr.set(-.5,.5,0),ur,s,cr,n,r),xr.set(0,1),a=t.ray.intersectTriangle(mr,_r,gr,!1,hr),null===a))return;const o=t.ray.origin.distanceTo(hr);o<t.near||o>t.far||e.push({distance:o,point:hr.clone(),uv:Mn.getInterpolation(hr,mr,gr,_r,vr,xr,yr,new Je),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 Sr(t,e,i,n,r,s){dr.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(pr.x=s*dr.x-r*dr.y,pr.y=r*dr.x+s*dr.y):pr.copy(dr),t.copy(e),t.x+=pr.x,t.y+=pr.y,t.applyMatrix4(fr)}const br=new Qe,Er=new Qe,Tr=new Qe,wr=new Qe,Ar=new Qe,Rr=new Qe,Cr=new Qe;class Pr{constructor(t=new Qe,e=new Qe(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,br)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=br.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(br.copy(this.origin).addScaledVector(this.direction,e),br.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Er.copy(t).add(e).multiplyScalar(.5),Tr.copy(e).sub(t).normalize(),wr.copy(this.origin).sub(Er);const r=.5*t.distanceTo(e),s=-this.direction.dot(Tr),a=wr.dot(this.direction),o=-wr.dot(Tr),l=wr.lengthSq(),h=Math.abs(1-s*s);let c,u,d,p;if(h>0)if(c=s*o-a,u=s*a-o,p=r*h,c>=0)if(u>=-p)if(u<=p){const t=1/h;c*=t,u*=t,d=c*(c+s*u+2*a)+u*(s*c+u+2*o)+l}else u=r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;else u=-r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;else u<=-p?(c=Math.max(0,-(-s*r+a)),u=c>0?-r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+l):u<=p?(c=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(c=Math.max(0,-(s*r+a)),u=c>0?r:Math.min(Math.max(-r,-o),r),d=-c*c+u*(u+2*o)+l);else u=s>0?-r:r,c=Math.max(0,-(s*u+a)),d=-c*c+u*(u+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,c),n&&n.copy(Er).addScaledVector(Tr,u),d}intersectSphere(t,e){br.subVectors(t.center,this.origin);const i=br.dot(this.direction),n=br.dot(br)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return 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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,a,o;const l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),i>s||r>n?null:((r>i||isNaN(i))&&(i=r),(s<n||isNaN(n))&&(n=s),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),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,br)}intersectTriangle(t,e,i,n,r){Ar.subVectors(e,t),Rr.subVectors(i,t),Cr.crossVectors(Ar,Rr);let s,a=this.direction.dot(Cr);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}wr.subVectors(this.origin,t);const o=s*this.direction.dot(Rr.crossVectors(wr,Rr));if(o<0)return null;const l=s*this.direction.dot(Ar.cross(wr));if(l<0)return null;if(o+l>a)return null;const h=-s*wr.dot(Cr);return h<0?null:this.at(h/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 Lr extends or{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new sn(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 Ii,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 Dr=new bi,Ir=new Pr,Nr=new qn,Ur=new Qe,Or=new Qe,Fr=new Qe,zr=new Qe,Br=new Qe,kr=new Qe,Vr=new Qe,Hr=new Qe;class Gr extends Ki{constructor(t=new er,e=new Lr){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 i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,s=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(r&&a){kr.set(0,0,0);for(let i=0,n=r.length;i<n;i++){const n=a[i],o=r[i];0!==n&&(Br.fromBufferAttribute(o,t),s?kr.addScaledVector(Br,n):kr.addScaledVector(Br.sub(e),n))}e.add(kr)}return e}raycast(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),Nr.copy(i.boundingSphere),Nr.applyMatrix4(r),Ir.copy(t.ray).recast(t.near),!1===Nr.containsPoint(Ir.origin)){if(null===Ir.intersectSphere(Nr,Ur))return;if(Ir.origin.distanceToSquared(Ur)>(t.far-t.near)**2)return}Dr.copy(r).invert(),Ir.copy(t.ray).applyMatrix4(Dr),null!==i.boundingBox&&!1===Ir.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,Ir)}}_computeIntersections(t,e,i){let n;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;r<o;r++){const o=u[r],p=s[o.materialIndex];for(let r=Math.max(o.start,d.start),s=Math.min(a.count,Math.min(o.start+o.count,d.start+d.count));r<s;r+=3){n=Wr(this,p,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=o.materialIndex,e.push(n))}}else{for(let r=Math.max(0,d.start),o=Math.min(a.count,d.start+d.count);r<o;r+=3){n=Wr(this,s,t,i,l,h,c,a.getX(r),a.getX(r+1),a.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}else if(void 0!==o)if(Array.isArray(s))for(let r=0,a=u.length;r<a;r++){const a=u[r],p=s[a.materialIndex];for(let r=Math.max(a.start,d.start),s=Math.min(o.count,Math.min(a.start+a.count,d.start+d.count));r<s;r+=3){n=Wr(this,p,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=a.materialIndex,e.push(n))}}else{for(let r=Math.max(0,d.start),a=Math.min(o.count,d.start+d.count);r<a;r+=3){n=Wr(this,s,t,i,l,h,c,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),e.push(n))}}}}function Wr(t,e,i,n,r,s,a,o,l,h){t.getVertexPosition(o,Or),t.getVertexPosition(l,Fr),t.getVertexPosition(h,zr);const c=function(t,e,i,n,r,s,a,o){let l;if(l=1===e.side?n.intersectTriangle(a,s,r,!0,o):n.intersectTriangle(r,s,a,0===e.side,o),null===l)return null;Hr.copy(o),Hr.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(Hr);return h<i.near||h>i.far?null:{distance:h,point:Hr.clone(),object:t}}(t,e,i,n,Or,Fr,zr,Vr);if(c){const t=new Qe;Mn.getBarycoord(Vr,Or,Fr,zr,t),r&&(c.uv=Mn.getInterpolatedAttribute(r,o,l,h,t,new Je)),s&&(c.uv1=Mn.getInterpolatedAttribute(s,o,l,h,t,new Je)),a&&(c.normal=Mn.getInterpolatedAttribute(a,o,l,h,t,new Qe),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));const e={a:o,b:l,c:h,normal:new Qe,materialIndex:0};Mn.getNormal(Or,Fr,zr,e.normal),c.face=e,c.barycoord=t}return c}class Xr extends _i{constructor(t=null,e=1,i=1,n,r,s,a,o,l=1003,h=1003,c,u){super(null,s,a,o,l,h,n,r,c,u),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jr=new Qe,qr=new Qe,Yr=new ii;class Zr{constructor(t=new Qe(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=jr.subVectors(i,e).cross(qr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,i=!0){const n=t.delta(jr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return!0===i&&(s<0||s>1)?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||Yr.getNormalMatrix(t),n=this.coplanarPoint(jr).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Kr=new qn,Jr=new Je(.5,.5),$r=new Qe;class Qr{constructor(t=new Zr,e=new Zr,i=new Zr,n=new Zr,r=new Zr,s=new Zr){this.planes=[t,e,i,n,r,s]}set(t,e,i,n,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3,i=!1){const n=this.planes,r=t.elements,s=r[0],a=r[1],o=r[2],l=r[3],h=r[4],c=r[5],u=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],_=r[12],v=r[13],x=r[14],y=r[15];if(n[0].setComponents(l-s,d-h,g-p,y-_).normalize(),n[1].setComponents(l+s,d+h,g+p,y+_).normalize(),n[2].setComponents(l+a,d+c,g+f,y+v).normalize(),n[3].setComponents(l-a,d-c,g-f,y-v).normalize(),i)n[4].setComponents(o,u,m,x).normalize(),n[5].setComponents(l-o,d-u,g-m,y-x).normalize();else if(n[4].setComponents(l-o,d-u,g-m,y-x).normalize(),e===Re)n[5].setComponents(l+o,d+u,g+m,y+x).normalize();else{if(e!==Ce)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(o,u,m,x).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Kr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Kr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Kr)}intersectsSprite(t){Kr.center.set(0,0,0);const e=Jr.distanceTo(t.center);return Kr.radius=.7071067811865476+e,Kr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Kr)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if($r.x=n.normal.x>0?t.max.x:t.min.x,$r.y=n.normal.y>0?t.max.y:t.min.y,$r.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint($r)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}class ts extends or{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new sn(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 es=new Qe,is=new Qe,ns=new bi,rs=new Pr,ss=new qn,as=new Qe,os=new Qe;class ls extends Ki{constructor(t=new er,e=new ts){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,i=[0];for(let t=1,n=e.count;t<n;t++)es.fromBufferAttribute(e,t-1),is.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=es.distanceTo(is);t.setAttribute("lineDistance",new Gn(i,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),ss.copy(i.boundingSphere),ss.applyMatrix4(n),ss.radius+=r,!1===t.ray.intersectsSphere(ss))return;ns.copy(n).invert(),rs.copy(t.ray).applyMatrix4(ns);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=this.isLineSegments?2:1,h=i.index,c=i.attributes.position;if(null!==h){const i=Math.max(0,s.start),n=Math.min(h.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=h.getX(r),n=h.getX(r+1),s=hs(this,t,rs,o,i,n,r);s&&e.push(s)}if(this.isLineLoop){const r=h.getX(n-1),s=h.getX(i),a=hs(this,t,rs,o,r,s,n-1);a&&e.push(a)}}else{const i=Math.max(0,s.start),n=Math.min(c.count,s.start+s.count);for(let r=i,s=n-1;r<s;r+=l){const i=hs(this,t,rs,o,r,r+1,r);i&&e.push(i)}if(this.isLineLoop){const r=hs(this,t,rs,o,n-1,i,n-1);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function hs(t,e,i,n,r,s,a){const o=t.geometry.attributes.position;es.fromBufferAttribute(o,r),is.fromBufferAttribute(o,s);if(i.distanceSqToSegment(es,is,as,os)>n)return;as.applyMatrix4(t.matrixWorld);const l=e.ray.origin.distanceTo(as);return l<e.near||l>e.far?void 0:{distance:l,point:os.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const cs=new Qe,us=new Qe;class ds extends ls{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,i=[];for(let t=0,n=e.count;t<n;t+=2)cs.fromBufferAttribute(e,t),us.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+cs.distanceTo(us);t.setAttribute("lineDistance",new Gn(i,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class ps extends or{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new sn(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 fs=new bi,ms=new Pr,gs=new qn,_s=new Qe;class vs extends Ki{constructor(t=new er,e=new ps){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 i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),gs.copy(i.boundingSphere),gs.applyMatrix4(n),gs.radius+=r,!1===t.ray.intersectsSphere(gs))return;fs.copy(n).invert(),ms.copy(t.ray).applyMatrix4(fs);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=i.index,h=i.attributes.position;if(null!==l){for(let i=Math.max(0,s.start),r=Math.min(l.count,s.start+s.count);i<r;i++){const r=l.getX(i);_s.fromBufferAttribute(h,r),xs(_s,r,o,n,t,e,this)}}else{for(let i=Math.max(0,s.start),r=Math.min(h.count,s.start+s.count);i<r;i++)_s.fromBufferAttribute(h,i),xs(_s,i,o,n,t,e,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t<e;t++){const e=i[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function xs(t,e,i,n,r,s,a){const o=ms.distanceSqToPoint(t);if(o<i){const i=new Qe;ms.closestPointToPoint(t,i),i.applyMatrix4(n);const l=r.ray.origin.distanceTo(i);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class ys extends _i{constructor(t=[],e=301,i,n,r,s,a,o,l,h){super(t,e,i,n,r,s,a,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Ms extends _i{constructor(t,e,i,n,r,s,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ss extends _i{constructor(t,e,i=1014,n,r,s,a=1003,o=1003,l,h=1026,c=1){if(h!==Et&&h!==Tt)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:c},n,r,s,a,o,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new pi(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 bs extends Ss{constructor(t,e=1014,i=301,n,r,s=1003,a=1003,o,l=1026){const h={width:t,height:t,depth:1},c=[h,h,h,h,h,h];super(t,t,e,i,n,r,s,a,o,l),this.image=c,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Es extends _i{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Ts extends er{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],h=[],c=[];let u=0,d=0;function p(t,e,i,n,r,s,p,f,m,g,_){const v=s/m,x=p/g,y=s/2,M=p/2,S=f/2,b=m+1,E=g+1;let T=0,w=0;const A=new Qe;for(let s=0;s<E;s++){const a=s*x-M;for(let o=0;o<b;o++){const u=o*v-y;A[t]=u*n,A[e]=a*r,A[i]=S,l.push(A.x,A.y,A.z),A[t]=0,A[e]=0,A[i]=f>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),T+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const i=u+e+b*t,n=u+e+b*(t+1),r=u+(e+1)+b*(t+1),s=u+(e+1)+b*t;o.push(i,n,s),o.push(n,r,s),w+=6}a.addGroup(d,w,_),d+=w,u+=T}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new Gn(l,3)),this.setAttribute("normal",new Gn(h,3)),this.setAttribute("uv",new Gn(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ts(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class ws extends er{constructor(t=1,e=1,i=1,n=32,r=1,s=!1,a=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:o};const l=this;n=Math.floor(n),r=Math.floor(r);const h=[],c=[],u=[],d=[];let p=0;const f=[],m=i/2;let g=0;function _(i){const r=p,s=new Je,f=new Qe;let _=0;const v=!0===i?t:e,x=!0===i?1:-1;for(let t=1;t<=n;t++)c.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;const y=p;for(let t=0;t<=n;t++){const e=t/n*o+a,i=Math.cos(e),r=Math.sin(e);f.x=v*r,f.y=m*x,f.z=v*i,c.push(f.x,f.y,f.z),u.push(0,x,0),s.x=.5*i+.5,s.y=.5*r*x+.5,d.push(s.x,s.y),p++}for(let t=0;t<n;t++){const e=r+t,n=y+t;!0===i?h.push(n,n+1,e):h.push(n+1,n,e),_+=3}l.addGroup(g,_,!0===i?1:2),g+=_}!function(){const s=new Qe,_=new Qe;let v=0;const x=(e-t)/i;for(let l=0;l<=r;l++){const h=[],g=l/r,v=g*(e-t)+t;for(let t=0;t<=n;t++){const e=t/n,r=e*o+a,l=Math.sin(r),f=Math.cos(r);_.x=v*l,_.y=-g*i+m,_.z=v*f,c.push(_.x,_.y,_.z),s.set(l,x,f).normalize(),u.push(s.x,s.y,s.z),d.push(e,1-g),h.push(p++)}f.push(h)}for(let i=0;i<n;i++)for(let n=0;n<r;n++){const s=f[n][i],a=f[n+1][i],o=f[n+1][i+1],l=f[n][i+1];(t>0||0!==n)&&(h.push(s,a,l),v+=3),(e>0||n!==r-1)&&(h.push(a,o,l),v+=3)}l.addGroup(g,v,0),g+=v}(),!1===s&&(t>0&&_(!0),e>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(u,3)),this.setAttribute("uv",new Gn(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ws(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class As{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ue("Curve: .getPoint() not implemented.")}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/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 i,n=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)i=this.getPoint(s/t),r+=i.distanceTo(n),e.push(r),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const i=this.getLengths();let n=0;const r=i.length;let s;s=e||t*i[r-1];let a,o=0,l=r-1;for(;o<=l;)if(n=Math.floor(o+(l-o)/2),a=i[n]-s,a<0)o=n+1;else{if(!(a>0)){l=n;break}l=n-1}if(n=l,i[n]===s)return n/(r-1);const h=i[n];return(n+(s-h)/(i[n+1]-h))/(r-1)}getTangent(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),a=this.getPoint(r),o=e||(s.isVector2?new Je:new Qe);return o.copy(a).sub(s).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){const i=new Qe,n=[],r=[],s=[],a=new Qe,o=new bi;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new Qe)}r[0]=new Qe,s[0]=new Qe;let l=Number.MAX_VALUE;const h=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),s[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(n[e-1],n[e]),a.length()>Number.EPSILON){a.normalize();const t=Math.acos(Xe(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}s[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(Xe(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(n[i],e*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}}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 Rs extends As{constructor(t=0,e=0,i=1,n=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new Je){const i=e,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const a=this.aStartAngle+t*r;let o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=o-this.aX,n=l-this.aY;o=i*t-n*e+this.aX,l=i*e+n*t+this.aY}return i.set(o,l)}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}}function Cs(){let t=0,e=0,i=0,n=0;function r(r,s,a,o){t=r,e=a,i=-3*r+3*s-2*a-o,n=2*r-2*s+a+o}return{initCatmullRom:function(t,e,i,n,s){r(e,i,s*(i-t),s*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,s,a,o){let l=(e-t)/s-(i-t)/(s+a)+(i-e)/a,h=(i-e)/a-(n-e)/(a+o)+(n-i)/o;l*=a,h*=a,r(e,i,l,h)},calc:function(r){const s=r*r;return t+e*r+i*s+n*(s*r)}}}const Ps=new Qe,Ls=new Qe,Ds=new Cs,Is=new Cs,Ns=new Cs;class Us extends As{constructor(t=[],e=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}getPoint(t,e=new Qe){const i=e,n=this.points,r=n.length,s=(r-(this.closed?0:1))*t;let a,o,l=Math.floor(s),h=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===h&&l===r-1&&(l=r-2,h=1),this.closed||l>0?a=n[(l-1)%r]:(Ls.subVectors(n[0],n[1]).add(n[0]),a=Ls);const c=n[l%r],u=n[(l+1)%r];if(this.closed||l+2<r?o=n[(l+2)%r]:(Ps.subVectors(n[r-1],n[r-2]).add(n[r-1]),o=Ps),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(a.distanceToSquared(c),t),i=Math.pow(c.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(o),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),Ds.initNonuniformCatmullRom(a.x,c.x,u.x,o.x,e,i,n),Is.initNonuniformCatmullRom(a.y,c.y,u.y,o.y,e,i,n),Ns.initNonuniformCatmullRom(a.z,c.z,u.z,o.z,e,i,n)}else"catmullrom"===this.curveType&&(Ds.initCatmullRom(a.x,c.x,u.x,o.x,this.tension),Is.initCatmullRom(a.y,c.y,u.y,o.y,this.tension),Ns.initCatmullRom(a.z,c.z,u.z,o.z,this.tension));return i.set(Ds.calc(h),Is.calc(h),Ns.calc(h)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.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,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.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,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new Qe).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Os(t,e,i,n,r){const s=.5*(n-e),a=.5*(r-i),o=t*t;return(2*i-2*n+s+a)*(t*o)+(-3*i+3*n-2*s-a)*o+s*t+i}function Fs(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function zs(t,e,i,n,r){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}class Bs extends As{constructor(t=new Je,e=new Je,i=new Je,n=new Je){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Je){const i=e,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(zs(t,n.x,r.x,s.x,a.x),zs(t,n.y,r.y,s.y,a.y)),i}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 ks extends As{constructor(t=new Je,e=new Je){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Je){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Je){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 Vs extends As{constructor(t=new Je,e=new Je,i=new Je){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Je){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Fs(t,n.x,r.x,s.x),Fs(t,n.y,r.y,s.y)),i}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 Hs extends As{constructor(t=new Qe,e=new Qe,i=new Qe){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new Qe){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Fs(t,n.x,r.x,s.x),Fs(t,n.y,r.y,s.y),Fs(t,n.z,r.z,s.z)),i}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 Gs extends As{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Je){const i=e,n=this.points,r=(n.length-1)*t,s=Math.floor(r),a=r-s,o=n[0===s?s:s-1],l=n[s],h=n[s>n.length-2?n.length-1:s+1],c=n[s>n.length-3?n.length-1:s+2];return i.set(Os(a,o.x,l.x,h.x,c.x),Os(a,o.y,l.y,h.y,c.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new Je).fromArray(i))}return this}}var Ws=Object.freeze({__proto__:null,ArcCurve:class extends Rs{constructor(t,e,i,n,r,s){super(t,e,i,i,n,r,s),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:Us,CubicBezierCurve:Bs,CubicBezierCurve3:class extends As{constructor(t=new Qe,e=new Qe,i=new Qe,n=new Qe){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}getPoint(t,e=new Qe){const i=e,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(zs(t,n.x,r.x,s.x,a.x),zs(t,n.y,r.y,s.y,a.y),zs(t,n.z,r.z,s.z,a.z)),i}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}},EllipseCurve:Rs,LineCurve:ks,LineCurve3:class extends As{constructor(t=new Qe,e=new Qe){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new Qe){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Qe){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}},QuadraticBezierCurve:Vs,QuadraticBezierCurve3:Hs,SplineCurve:Gs});class Xs extends As{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 i=!0===t.isVector2?"LineCurve":"LineCurve3";this.curves.push(new Ws[i](e,t))}return this}getPoint(t,e){const i=t*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const t=n[r]-i,s=this.curves[r],a=s.getLength(),o=0===a?0:1-t/a;return s.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 i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],a=s.isEllipseCurve?2*t:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?t*s.points.length:t,o=s.getPoints(a);for(let t=0;t<o.length;t++){const n=o[t];i&&i.equals(n)||(e.push(n),i=n)}}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,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new Ws[i.type]).fromJSON(i))}return this}}class js extends Xs{constructor(t){super(),this.type="Path",this.currentPoint=new Je,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;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 i=new ks(this.currentPoint.clone(),new Je(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,n){const r=new Vs(this.currentPoint.clone(),new Je(t,e),new Je(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(t,e,i,n,r,s){const a=new Bs(this.currentPoint.clone(),new Je(t,e),new Je(i,n),new Je(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new Gs(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,n,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,i,n,r,s),this}absarc(t,e,i,n,r,s){return this.absellipse(t,e,i,i,n,r,s),this}ellipse(t,e,i,n,r,s,a,o){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+l,e+h,i,n,r,s,a,o),this}absellipse(t,e,i,n,r,s,a,o){const l=new Rs(t,e,i,n,r,s,a,o);if(this.curves.length>0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),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 qs extends js{constructor(t){super(t),this.uuid=We(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].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,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new js).fromJSON(i))}return this}}function Ys(t,e,i=2){const n=e&&e.length,r=n?e[0]*i:t.length;let s=Zs(t,0,r,i,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,h;if(n&&(s=function(t,e,i,n){const r=[];for(let i=0,s=e.length;i<s;i++){const a=Zs(t,e[i]*n,i<s-1?e[i+1]*n:t.length,n,!1);a===a.next&&(a.steiner=!0),r.push(aa(a))}r.sort(ia);for(let t=0;t<r.length;t++)i=na(r[t],i);return i}(t,e,s,i)),t.length>80*i){o=t[0],l=t[1];let e=o,n=l;for(let s=i;s<r;s+=i){const i=t[s],r=t[s+1];i<o&&(o=i),r<l&&(l=r),i>e&&(e=i),r>n&&(n=r)}h=Math.max(e-o,n-l),h=0!==h?32767/h:0}return Js(s,a,i,o,l,h,0),a}function Zs(t,e,i,n,r){let s;if(r===function(t,e,i,n){let r=0;for(let s=e,a=i-n;s<i;s+=n)r+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return r}(t,e,i,n)>0)for(let r=e;r<i;r+=n)s=_a(r/n|0,t[r],t[r+1],s);else for(let r=i-n;r>=e;r-=n)s=_a(r/n|0,t[r],t[r+1],s);return s&&ua(s,s.next)&&(va(s),s=s.next),s}function Ks(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!ua(n,n.next)&&0!==ca(n.prev,n,n.next))n=n.next;else{if(va(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Js(t,e,i,n,r,s,a){if(!t)return;!a&&s&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=sa(r.x,r.y,e,i,n)),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,i=1;do{let n,r=t;t=null;let s=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t<i&&(o++,a=a.nextZ,a);t++);let l=i;for(;o>0||l>0&&a;)0!==o&&(0===l||!a||r.z<=a.z)?(n=r,r=r.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=a}s.nextZ=null,i*=2}while(e>1)}(r)}(t,n,r,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(s?Qs(t,n,r,s):$s(t))e.push(l.i,t.i,h.i),va(t),t=h.next,o=h.next;else if((t=h)===o){a?1===a?Js(t=ta(Ks(t),e),e,i,n,r,s,2):2===a&&ea(t,e,i,n,r,s):Js(Ks(t),e,i,n,r,s,1);break}}}function $s(t){const e=t.prev,i=t,n=t.next;if(ca(e,i,n)>=0)return!1;const r=e.x,s=i.x,a=n.x,o=e.y,l=i.y,h=n.y,c=Math.min(r,s,a),u=Math.min(o,l,h),d=Math.max(r,s,a),p=Math.max(o,l,h);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&la(r,o,s,l,a,h,f.x,f.y)&&ca(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Qs(t,e,i,n){const r=t.prev,s=t,a=t.next;if(ca(r,s,a)>=0)return!1;const o=r.x,l=s.x,h=a.x,c=r.y,u=s.y,d=a.y,p=Math.min(o,l,h),f=Math.min(c,u,d),m=Math.max(o,l,h),g=Math.max(c,u,d),_=sa(p,f,e,i,n),v=sa(m,g,e,i,n);let x=t.prevZ,y=t.nextZ;for(;x&&x.z>=_&&y&&y.z<=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&la(o,c,l,u,h,d,x.x,x.y)&&ca(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&la(o,c,l,u,h,d,y.x,y.y)&&ca(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==a&&la(o,c,l,u,h,d,x.x,x.y)&&ca(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==a&&la(o,c,l,u,h,d,y.x,y.y)&&ca(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function ta(t,e){let i=t;do{const n=i.prev,r=i.next.next;!ua(n,r)&&da(n,i,i.next,r)&&ma(n,r)&&ma(r,n)&&(e.push(n.i,i.i,r.i),va(i),va(i.next),i=t=r),i=i.next}while(i!==t);return Ks(i)}function ea(t,e,i,n,r,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&ha(a,t)){let o=ga(a,t);return a=Ks(a,a.next),o=Ks(o,o.next),Js(a,e,i,n,r,s,0),void Js(o,e,i,n,r,s,0)}t=t.next}a=a.next}while(a!==t)}function ia(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function na(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let s,a=-1/0;if(ua(t,i))return i;do{if(ua(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>a&&(a=t,s=i.x<i.next.x?i:i.next,t===n))return s}i=i.next}while(i!==e);if(!s)return null;const o=s,l=s.x,h=s.y;let c=1/0;i=s;do{if(n>=i.x&&i.x>=l&&n!==i.x&&oa(r<h?n:a,r,l,h,r<h?a:n,r,i.x,i.y)){const e=Math.abs(r-i.y)/(n-i.x);ma(i,t)&&(e<c||e===c&&(i.x>s.x||i.x===s.x&&ra(s,i)))&&(s=i,c=e)}i=i.next}while(i!==o);return s}(t,e);if(!i)return e;const n=ga(i,t);return Ks(n,n.next),Ks(i,i.next)}function ra(t,e){return ca(t.prev,t,e.prev)<0&&ca(e.next,t,t.next)<0}function sa(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function aa(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function oa(t,e,i,n,r,s,a,o){return(r-a)*(e-o)>=(t-a)*(s-o)&&(t-a)*(n-o)>=(i-a)*(e-o)&&(i-a)*(s-o)>=(r-a)*(n-o)}function la(t,e,i,n,r,s,a,o){return!(t===a&&e===o)&&oa(t,e,i,n,r,s,a,o)}function ha(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&da(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(ma(t,e)&&ma(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(ca(t.prev,t,e.prev)||ca(t,e.prev,e))||ua(t,e)&&ca(t.prev,t,t.next)>0&&ca(e.prev,e,e.next)>0)}function ca(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function ua(t,e){return t.x===e.x&&t.y===e.y}function da(t,e,i,n){const r=fa(ca(t,e,i)),s=fa(ca(t,e,n)),a=fa(ca(i,n,t)),o=fa(ca(i,n,e));return r!==s&&a!==o||(!(0!==r||!pa(t,i,e))||(!(0!==s||!pa(t,n,e))||(!(0!==a||!pa(i,t,n))||!(0!==o||!pa(i,e,n)))))}function pa(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function fa(t){return t>0?1:t<0?-1:0}function ma(t,e){return ca(t.prev,t,t.next)<0?ca(t,e,t.next)>=0&&ca(t,t.prev,e)>=0:ca(t,e,t.prev)<0||ca(t,t.next,e)<0}function ga(t,e){const i=xa(t.i,t.x,t.y),n=xa(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function _a(t,e,i,n){const r=xa(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function va(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 xa(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ya{static triangulate(t,e,i=2){return Ys(t,e,i)}}class Ma{static area(t){const e=t.length;let i=0;for(let n=e-1,r=0;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i}static isClockWise(t){return Ma.area(t)<0}static triangulateShape(t,e){const i=[],n=[],r=[];Sa(t),ba(i,t);let s=t.length;e.forEach(Sa);for(let t=0;t<e.length;t++)n.push(s),s+=e[t].length,ba(i,e[t]);const a=ya.triangulate(i,n);for(let t=0;t<a.length;t+=3)r.push(a.slice(t,t+3));return r}}function Sa(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function ba(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Ea extends er{constructor(t=new qs([new Je(.5,.5),new Je(-.5,.5),new Je(-.5,-.5),new Je(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],r=[];for(let e=0,i=t.length;e<i;e++){s(t[e])}function s(t){const s=[],a=void 0!==e.curveSegments?e.curveSegments:12,o=void 0!==e.steps?e.steps:1,l=void 0!==e.depth?e.depth:1;let h=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 f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:Ta;let g,_,v,x,y,M=!1;if(f){g=f.getSpacedPoints(o),M=!0,h=!1;const t=!!f.isCatmullRomCurve3&&f.closed;_=f.computeFrenetFrames(o,t),v=new Qe,x=new Qe,y=new Qe}h||(p=0,c=0,u=0,d=0);const S=t.extractPoints(a);let b=S.shape;const E=S.holes;if(!Ma.isClockWise(b)){b=b.reverse();for(let t=0,e=E.length;t<e;t++){const e=E[t];Ma.isClockWise(e)&&(E[t]=e.reverse())}}function T(t){const e=1e-10*1e-10;let i=t[0];for(let n=1;n<=t.length;n++){const r=n%t.length,s=t[r],a=s.x-i.x,o=s.y-i.y,l=a*a+o*o,h=Math.max(Math.abs(s.x),Math.abs(s.y),Math.abs(i.x),Math.abs(i.y));l<=e*h*h?(t.splice(r,1),n--):i=s}}T(b),E.forEach(T);const w=E.length,A=b;for(let t=0;t<w;t++){const e=E[t];b=b.concat(e)}function R(t,e,i){return e||Oe("ExtrudeGeometry: vec does not exist"),t.clone().addScaledVector(e,i)}const C=b.length;function P(t,e,i){let n,r,s;const a=t.x-e.x,o=t.y-e.y,l=i.x-t.x,h=i.y-t.y,c=a*a+o*o,u=a*h-o*l;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=e.x-o/u,f=e.y+a/u,m=((i.x-h/d-p)*h-(i.y+l/d-f)*l)/(a*h-o*l);n=p+a*m-t.x,r=f+o*m-t.y;const g=n*n+r*r;if(g<=2)return new Je(n,r);s=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?l>Number.EPSILON&&(t=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(h)&&(t=!0),t?(n=-o,r=a,s=Math.sqrt(c)):(n=a,r=o,s=Math.sqrt(c/2))}return new Je(n/s,r/s)}const L=[];for(let t=0,e=A.length,i=e-1,n=t+1;t<e;t++,i++,n++)i===e&&(i=0),n===e&&(n=0),L[t]=P(A[t],A[i],A[n]);const D=[];let I,N,U=L.concat();for(let t=0,e=w;t<e;t++){const e=E[t];I=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),I[t]=P(e[t],e[n],e[r]);D.push(I),U=U.concat(I)}if(0===p)N=Ma.triangulateShape(A,E);else{const t=[],e=[];for(let i=0;i<p;i++){const n=i/p,r=c*Math.cos(n*Math.PI/2),s=u*Math.sin(n*Math.PI/2)+d;for(let e=0,i=A.length;e<i;e++){const i=R(A[e],L[e],s);B(i.x,i.y,-r),0===n&&t.push(i)}for(let t=0,i=w;t<i;t++){const i=E[t];I=D[t];const a=[];for(let t=0,e=i.length;t<e;t++){const e=R(i[t],I[t],s);B(e.x,e.y,-r),0===n&&a.push(e)}0===n&&e.push(a)}}N=Ma.triangulateShape(t,e)}const O=N.length,F=u+d;for(let t=0;t<C;t++){const e=h?R(b[t],U[t],F):b[t];M?(x.copy(_.normals[0]).multiplyScalar(e.x),v.copy(_.binormals[0]).multiplyScalar(e.y),y.copy(g[0]).add(x).add(v),B(y.x,y.y,y.z)):B(e.x,e.y,0)}for(let t=1;t<=o;t++)for(let e=0;e<C;e++){const i=h?R(b[e],U[e],F):b[e];M?(x.copy(_.normals[t]).multiplyScalar(i.x),v.copy(_.binormals[t]).multiplyScalar(i.y),y.copy(g[t]).add(x).add(v),B(y.x,y.y,y.z)):B(i.x,i.y,l/o*t)}for(let t=p-1;t>=0;t--){const e=t/p,i=c*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=A.length;t<e;t++){const e=R(A[t],L[t],n);B(e.x,e.y,l+i)}for(let t=0,e=E.length;t<e;t++){const e=E[t];I=D[t];for(let t=0,r=e.length;t<r;t++){const r=R(e[t],I[t],n);M?B(r.x,r.y+g[o-1].y,g[o-1].x+i):B(r.x,r.y,l+i)}}}function z(t,e){let i=t.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=o+2*p;t<i;t++){const i=C*t,s=C*(t+1);V(e+n+i,e+r+i,e+r+s,e+n+s)}}}function B(t,e,i){s.push(t),s.push(e),s.push(i)}function k(t,e,r){H(t),H(e),H(r);const s=n.length/3,a=m.generateTopUV(i,n,s-3,s-2,s-1);G(a[0]),G(a[1]),G(a[2])}function V(t,e,r,s){H(t),H(e),H(s),H(e),H(r),H(s);const a=n.length/3,o=m.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);G(o[0]),G(o[1]),G(o[3]),G(o[1]),G(o[2]),G(o[3])}function H(t){n.push(s[3*t+0]),n.push(s[3*t+1]),n.push(s[3*t+2])}function G(t){r.push(t.x),r.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=C*t;for(let t=0;t<O;t++){const i=N[t];k(i[2]+e,i[1]+e,i[0]+e)}t=o+2*p,e=C*t;for(let t=0;t<O;t++){const i=N[t];k(i[0]+e,i[1]+e,i[2]+e)}}else{for(let t=0;t<O;t++){const e=N[t];k(e[2],e[1],e[0])}for(let t=0;t<O;t++){const e=N[t];k(e[0]+C*o,e[1]+C*o,e[2]+C*o)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;z(A,e),e+=A.length;for(let t=0,i=E.length;t<i;t++){const i=E[t];z(i,e),e+=i.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new Gn(n,3)),this.setAttribute("uv",new Gn(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,i){if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){const n=t[e];i.shapes.push(n.uuid)}else i.shapes.push(t.uuid);i.options=Object.assign({},e),void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const i=[];for(let n=0,r=t.shapes.length;n<r;n++){const r=e[t.shapes[n]];i.push(r)}const n=t.options.extrudePath;return void 0!==n&&(t.options.extrudePath=(new Ws[n.type]).fromJSON(n)),new Ea(i,t.options)}}const Ta={generateTopUV:function(t,e,i,n,r){const s=e[3*i],a=e[3*i+1],o=e[3*n],l=e[3*n+1],h=e[3*r],c=e[3*r+1];return[new Je(s,a),new Je(o,l),new Je(h,c)]},generateSideWallUV:function(t,e,i,n,r,s){const a=e[3*i],o=e[3*i+1],l=e[3*i+2],h=e[3*n],c=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],_=e[3*s+2];return Math.abs(o-c)<Math.abs(a-h)?[new Je(a,1-l),new Je(h,1-u),new Je(d,1-f),new Je(m,1-_)]:[new Je(o,1-l),new Je(c,1-u),new Je(p,1-f),new Je(g,1-_)]}};class wa extends er{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,s=e/2,a=Math.floor(i),o=Math.floor(n),l=a+1,h=o+1,c=t/a,u=e/o,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let i=0;i<l;i++){const n=i*c-r;p.push(n,-e,0),f.push(0,0,1),m.push(i/a),m.push(1-t/o)}}for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=e+l*t,n=e+l*(t+1),r=e+1+l*(t+1),s=e+1+l*t;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Gn(p,3)),this.setAttribute("normal",new Gn(f,3)),this.setAttribute("uv",new Gn(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new wa(t.width,t.height,t.widthSegments,t.heightSegments)}}class Aa extends er{constructor(t=new qs([new Je(0,.5),new Je(-.5,-.5),new Je(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(t))l(t);else for(let e=0;e<t.length;e++)l(t[e]),this.addGroup(a,o,e),a+=o,o=0;function l(t){const a=n.length/3,l=t.extractPoints(e);let h=l.shape;const c=l.holes;!1===Ma.isClockWise(h)&&(h=h.reverse());for(let t=0,e=c.length;t<e;t++){const e=c[t];!0===Ma.isClockWise(e)&&(c[t]=e.reverse())}const u=Ma.triangulateShape(h,c);for(let t=0,e=c.length;t<e;t++){const e=c[t];h=h.concat(e)}for(let t=0,e=h.length;t<e;t++){const e=h[t];n.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],n=e[0]+a,r=e[1]+a,s=e[2]+a;i.push(n,r,s),o+=3}}this.setIndex(i),this.setAttribute("position",new Gn(n,3)),this.setAttribute("normal",new Gn(r,3)),this.setAttribute("uv",new Gn(s,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 i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}static fromJSON(t,e){const i=[];for(let n=0,r=t.shapes.length;n<r;n++){const r=e[t.shapes[n]];i.push(r)}return new Aa(i,t.curveSegments)}}class Ra extends er{constructor(t=1,e=32,i=16,n=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(s+a,Math.PI);let l=0;const h=[],c=new Qe,u=new Qe,d=[],p=[],f=[],m=[];for(let d=0;d<=i;d++){const g=[],_=d/i,v=s+_*a,x=t*Math.cos(v),y=Math.sqrt(t*t-x*x);let M=0;0===d&&0===s?M=.5/e:d===i&&o===Math.PI&&(M=-.5/e);for(let t=0;t<=e;t++){const i=t/e,s=n+i*r;c.x=-y*Math.cos(s),c.y=x,c.z=y*Math.sin(s),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(i+M,1-_),g.push(l++)}h.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=h[t][n+1],r=h[t][n],a=h[t+1][n],l=h[t+1][n+1];(0!==t||s>0)&&d.push(e,r,l),(t!==i-1||o<Math.PI)&&d.push(r,a,l)}this.setIndex(d),this.setAttribute("position",new Gn(p,3)),this.setAttribute("normal",new Gn(f,3)),this.setAttribute("uv",new Gn(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ra(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Ca extends er{constructor(t=1,e=.4,i=12,n=48,r=2*Math.PI,s=0,a=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:r,thetaStart:s,thetaLength:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],h=[],c=[],u=new Qe,d=new Qe,p=new Qe;for(let o=0;o<=i;o++){const f=s+o/i*a;for(let s=0;s<=n;s++){const a=s/n*r;d.x=(t+e*Math.cos(f))*Math.cos(a),d.y=(t+e*Math.cos(f))*Math.sin(a),d.z=e*Math.sin(f),l.push(d.x,d.y,d.z),u.x=t*Math.cos(a),u.y=t*Math.sin(a),p.subVectors(d,u).normalize(),h.push(p.x,p.y,p.z),c.push(s/n),c.push(o/i)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*t+e-1,r=(n+1)*(t-1)+e-1,s=(n+1)*(t-1)+e,a=(n+1)*t+e;o.push(i,r,a),o.push(r,s,a)}this.setIndex(o),this.setAttribute("position",new Gn(l,3)),this.setAttribute("normal",new Gn(h,3)),this.setAttribute("uv",new Gn(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ca(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class Pa extends er{constructor(t=new Hs(new Qe(-1,-1,0),new Qe(-1,1,0),new Qe(1,1,0)),e=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:n,closed:r};const s=t.computeFrenetFrames(e,r);this.tangents=s.tangents,this.normals=s.normals,this.binormals=s.binormals;const a=new Qe,o=new Qe,l=new Je;let h=new Qe;const c=[],u=[],d=[],p=[];function f(r){h=t.getPointAt(r/e,h);const l=s.normals[r],d=s.binormals[r];for(let t=0;t<=n;t++){const e=t/n*Math.PI*2,r=Math.sin(e),s=-Math.cos(e);o.x=s*l.x+r*d.x,o.y=s*l.y+r*d.y,o.z=s*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=h.x+i*o.x,a.y=h.y+i*o.y,a.z=h.z+i*o.z,c.push(a.x,a.y,a.z)}}!function(){for(let t=0;t<e;t++)f(t);f(!1===r?e:0),function(){for(let t=0;t<=e;t++)for(let i=0;i<=n;i++)l.x=t/e,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),r=(n+1)*t+(e-1),s=(n+1)*t+e,a=(n+1)*(t-1)+e;p.push(i,r,a),p.push(r,s,a)}}()}(),this.setIndex(p),this.setAttribute("position",new Gn(c,3)),this.setAttribute("normal",new Gn(u,3)),this.setAttribute("uv",new Gn(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 Pa((new Ws[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}function La(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];if(Ia(r))r.isRenderTargetTexture?(Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[i][n]=null):e[i][n]=r.clone();else if(Array.isArray(r))if(Ia(r[0])){const t=[];for(let e=0,i=r.length;e<i;e++)t[e]=r[e].clone();e[i][n]=t}else e[i][n]=r.slice();else e[i][n]=r}}return e}function Da(t){const e={};for(let i=0;i<t.length;i++){const n=La(t[i]);for(const t in n)e[t]=n[t]}return e}function Ia(t){return t&&(t.isColor||t.isMatrix3||t.isMatrix4||t.isVector2||t.isVector3||t.isVector4||t.isTexture||t.isQuaternion)}function Na(t){const e=t.getRenderTarget();return null===e?t.outputColorSpace:!0===e.isXRRenderTarget?e.texture.colorSpace:oi.workingColorSpace}const Ua={clone:La,merge:Da};class Oa extends or{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=La(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}fromJSON(t,e){if(super.fromJSON(t,e),void 0!==t.uniforms)for(const i in t.uniforms){const n=t.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=e[n.value]||null;break;case"c":this.uniforms[i].value=(new sn).setHex(n.value);break;case"v2":this.uniforms[i].value=(new Je).fromArray(n.value);break;case"v3":this.uniforms[i].value=(new Qe).fromArray(n.value);break;case"v4":this.uniforms[i].value=(new vi).fromArray(n.value);break;case"m3":this.uniforms[i].value=(new ii).fromArray(n.value);break;case"m4":this.uniforms[i].value=(new bi).fromArray(n.value);break;default:this.uniforms[i].value=n.value}}if(void 0!==t.defines&&(this.defines=t.defines),void 0!==t.vertexShader&&(this.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(this.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(this.glslVersion=t.glslVersion),void 0!==t.extensions)for(const e in t.extensions)this.extensions[e]=t.extensions[e];return void 0!==t.lights&&(this.lights=t.lights),void 0!==t.clipping&&(this.clipping=t.clipping),this}}class Fa extends Oa{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class za extends or{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new sn(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 sn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Je(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 Ii,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 Ba extends or{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new sn(16777215),this.specular=new sn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Je(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ii,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=t.envMapIntensity,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 ka extends or{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new sn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new sn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Je(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ii,this.combine=0,this.reflectivity=1,this.envMapIntensity=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.envMapIntensity=t.envMapIntensity,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 Va extends or{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 Ha extends or{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 Ga extends ts{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}}const Wa={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(Xa(t)||(this.files[t]=e))},get:function(t){if(!1!==this.enabled&&!Xa(t))return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function Xa(t){try{const e=t.slice(t.indexOf(":")+1);return"blob:"===new URL(e).protocol}catch(t){return!1}}class ja{constructor(t,e,i){const n=this;let r,s=!1,a=0,o=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(t){o++,!1===s&&void 0!==n.onStart&&n.onStart(t,a,o),s=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return t=t.normalize("NFC"),r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=l.length;e<i;e+=2){const i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const qa=new ja;class Ya{constructor(t){this.manager=void 0!==t?t:qa,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,r){i.load(t,n,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}}Ya.DEFAULT_MATERIAL_NAME="__DEFAULT";const Za=new WeakMap;class Ka extends Ya{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Wa.get(`image:${t}`);if(void 0!==s){if(!0===s.complete)r.manager.itemStart(t),setTimeout(function(){e&&e(s),r.manager.itemEnd(t)},0);else{let t=Za.get(s);void 0===t&&(t=[],Za.set(s,t)),t.push({onLoad:e,onError:n})}return s}const a=Pe("img");function o(){h(),e&&e(this);const i=Za.get(this)||[];for(let t=0;t<i.length;t++){const e=i[t];e.onLoad&&e.onLoad(this)}Za.delete(this),r.manager.itemEnd(t)}function l(e){h(),n&&n(e),Wa.remove(`image:${t}`);const i=Za.get(this)||[];for(let t=0;t<i.length;t++){const n=i[t];n.onError&&n.onError(e)}Za.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),Wa.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}}class Ja extends Ya{constructor(t){super(t)}load(t,e,i,n){const r=new ys;r.colorSpace=pe;const s=new Ka(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(t[i],function(t){r.images[i]=t,a++,6===a&&(r.needsUpdate=!0,e&&e(r))},void 0,n)}for(let e=0;e<t.length;++e)o(e);return r}}class $a extends Ki{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new sn(t),this.intensity=e}dispose(){this.dispatchEvent({type:"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,e}}class Qa extends $a{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ki.DEFAULT_UP),this.updateMatrix(),this.groundColor=new sn(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const to=new bi,eo=new Qe,io=new Qe;class no{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Je(512,512),this.mapType=ct,this.map=null,this.mapPass=null,this.matrix=new bi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Qr,this._frameExtents=new Je(1,1),this._viewportCount=1,this._viewports=[new vi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;eo.setFromMatrixPosition(t.matrixWorld),e.position.copy(eo),io.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(io),e.updateMatrixWorld(),to.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(to,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Ce||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(to)}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.biasNode=t.biasNode,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}}const ro=new Qe,so=new $e,ao=new Qe;class oo extends Ki{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new bi,this.projectionMatrix=new bi,this.projectionMatrixInverse=new bi,this.coordinateSystem=Re,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.matrixWorld.decompose(ro,so,ao),1===ao.x&&1===ao.y&&1===ao.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,so,ao.set(1,1,1)).invert()}updateWorldMatrix(t,e,i=!1){super.updateWorldMatrix(t,e,i),this.matrixWorld.decompose(ro,so,ao),1===ao.x&&1===ao.y&&1===ao.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ro,so,ao.set(1,1,1)).invert()}clone(){return(new this.constructor).copy(this)}}const lo=new Qe,ho=new Je,co=new Je;class uo extends oo{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Ge*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*He*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Ge*Math.atan(Math.tan(.5*He*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,i){lo.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(lo.x,lo.y).multiplyScalar(-t/lo.z),lo.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(lo.x,lo.y).multiplyScalar(-t/lo.z)}getViewSize(t,e){return this.getViewBounds(t,ho,co),e.subVectors(co,ho)}setViewOffset(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*He*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/a,n*=s.width/t,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far,this.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}}class po extends no{constructor(){super(new uo(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=2*Ge*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class fo extends $a{constructor(t,e,i=0,n=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ki.DEFAULT_UP),this.updateMatrix(),this.target=new Ki,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new po}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.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.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class mo extends no{constructor(){super(new uo(90,1,.5,500)),this.isPointLightShadow=!0}}class go extends $a{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new mo}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.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}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class _o extends oo{constructor(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.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 vo extends no{constructor(){super(new _o(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xo extends $a{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ki.DEFAULT_UP),this.updateMatrix(),this.target=new Ki,this.shadow=new vo}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class yo extends $a{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}const Mo=-90;class So extends Ki{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new uo(Mo,1,t,e);n.layers=this.layers,this.add(n);const r=new uo(Mo,1,t,e);r.layers=this.layers,this.add(r);const s=new uo(Mo,1,t,e);s.layers=this.layers,this.add(s);const a=new uo(Mo,1,t,e);a.layers=this.layers,this.add(a);const o=new uo(Mo,1,t,e);o.layers=this.layers,this.add(o);const l=new uo(Mo,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===Re)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.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!==Ce)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.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:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,h]=this.children,c=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const f=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;m=!0===t.isWebGLRenderer?t.state.buffers.depth.getReversed():t.reversedDepthBuffer,t.setRenderTarget(i,0,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,r),t.setRenderTarget(i,1,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,2,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,a),t.setRenderTarget(i,3,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,4,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=f,t.setRenderTarget(i,5,n),m&&!1===t.autoClear&&t.clearDepth(),t.render(e,h),t.setRenderTarget(c,u,d),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class bo extends uo{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Eo=new bi;class To{constructor(t,e,i=0,n=1/0){this.ray=new Pr(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new Ni,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.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Oe("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Eo.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Eo),this}intersectObject(t,e=!0,i=[]){return Ao(t,this,i,e),i.sort(wo),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;n<r;n++)Ao(t[n],this,i,e);return i.sort(wo),i}}function wo(t,e){return t.distance-e.distance}function Ao(t,e,i,n){let r=!0;if(t.layers.test(e.layers)){!1===t.raycast(e,i)&&(r=!1)}if(!0===r&&!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)Ao(n[t],e,i,!0)}}class Ro{constructor(t=1,e=0,i=0){this.radius=t,this.phi=e,this.theta=i}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,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=Xe(this.phi,t,Math.PI-t),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(Xe(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Co{static{Co.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],void 0!==t&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const r=this.elements;return r[0]=t,r[2]=e,r[1]=i,r[3]=n,this}}const Po=new Qe;class Lo extends Ki{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new er,n=[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,i=32;t<i;t++,e++){const r=t/i*Math.PI*2,s=e/i*Math.PI*2;n.push(Math.cos(r),Math.sin(r),1,Math.cos(s),Math.sin(s),1)}i.setAttribute("position",new Gn(n,3));const r=new ts({fog:!1,toneMapped:!1});this.cone=new ds(i,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.matrixWorldNeedsUpdate=!0;const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Po.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Po),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}class Do extends Gr{constructor(t,e,i){super(new Ra(e,4,2),new Lr({wireframe:!0,fog:!1,toneMapped:!1})),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const Io=new Qe,No=new Qe,Uo=new Qe;class Oo extends Ki{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===e&&(e=1);let n=new er;n.setAttribute("position",new Gn([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new ts({fog:!1,toneMapped:!1});this.lightPlane=new ls(n,r),this.add(this.lightPlane),n=new er,n.setAttribute("position",new Gn([0,0,0,0,0,1],3)),this.targetLine=new ls(n,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.matrixWorldNeedsUpdate=!0,this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Io.setFromMatrixPosition(this.light.matrixWorld),No.setFromMatrixPosition(this.light.target.matrixWorld),Uo.subVectors(No,Io),this.lightPlane.lookAt(No),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(No),this.targetLine.scale.z=Uo.length()}}class Fo extends Be{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):Ue("Controls: connect() now requires an element.")}disconnect(){}dispose(){}update(){}}function zo(t,e,i,n){const r=function(t){switch(t){case ct:case ut:return{byteLength:1,components:1};case pt:case dt:case _t:return{byteLength:2,components:1};case vt:case xt:return{byteLength:2,components:4};case mt:case ft:case gt:return{byteLength:4,components:1};case Mt:case St:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${t}.`)}(n);switch(i){case 1021:return t*e;case 1028:case wt:return t*e/r.components*r.byteLength;case At:case Rt:return t*e*2/r.components*r.byteLength;case 1022:return t*e*3/r.components*r.byteLength;case bt:case Ct:return t*e*4/r.components*r.byteLength;case Pt:case Lt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Dt:case It:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Ut:case Ft:return Math.max(t,16)*Math.max(e,8)/4;case Nt:case Ot:return Math.max(t,8)*Math.max(e,8)/2;case zt:case Bt:case Vt:case Ht:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case kt:case Gt:case Wt:case Xt:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case jt:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case qt:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Yt:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case Zt:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Kt:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case Jt:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case $t:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Qt:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case te:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case ee:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case ie:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case ne:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case re:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case se:case ae:case oe:return Math.ceil(t/4)*Math.ceil(e/4)*16;case le:case he:return Math.ceil(t/4)*Math.ceil(e/4)*8;case ce:case ue:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${i} format.`)}
21
+ /**
22
+ * @license
23
+ * Copyright 2010-2026 Three.js Authors
24
+ * SPDX-License-Identifier: MIT
25
+ */
26
+ function Bo(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&null!==t&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){null!==t&&t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function ko(t){const e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(i){i.isInterleavedBufferAttribute&&(i=i.data);const n=e.get(i);n&&(t.deleteBuffer(n.buffer),e.delete(i))},update:function(i,n){if(i.isInterleavedBufferAttribute&&(i=i.data),i.isGLBufferAttribute){const t=e.get(i);return void((!t||t.version<i.version)&&e.set(i,{buffer:i.buffer,type:i.type,bytesPerElement:i.elementSize,version:i.version}))}const r=e.get(i);if(void 0===r)e.set(i,function(e,i){const n=e.array,r=e.usage,s=n.byteLength,a=t.createBuffer();let o;if(t.bindBuffer(i,a),t.bufferData(i,n,r),e.onUploadCallback(),n instanceof Float32Array)o=t.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)o=t.HALF_FLOAT;else if(n instanceof Uint16Array)o=e.isFloat16BufferAttribute?t.HALF_FLOAT:t.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=t.SHORT;else if(n instanceof Uint32Array)o=t.UNSIGNED_INT;else if(n instanceof Int32Array)o=t.INT;else if(n instanceof Int8Array)o=t.BYTE;else if(n instanceof Uint8Array)o=t.UNSIGNED_BYTE;else{if(!(n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=t.UNSIGNED_BYTE}return{buffer:a,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,size:s}}(i,n));else if(r.version<i.version){if(r.size!==i.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(e,i,n){const r=i.array,s=i.updateRanges;if(t.bindBuffer(n,e),0===s.length)t.bufferSubData(n,0,r);else{s.sort((t,e)=>t.start-e.start);let e=0;for(let t=1;t<s.length;t++){const i=s[e],n=s[t];n.start<=i.start+i.count+1?i.count=Math.max(i.count,n.start+n.count-i.start):(++e,s[e]=n)}s.length=e+1;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.bufferSubData(n,i.start*r.BYTES_PER_ELEMENT,r,i.start,i.count)}i.clearUpdateRanges()}i.onUploadCallback()}(r.buffer,i,n),r.version=i.version}}}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:e}})),"undefined"!=typeof window&&(window.__THREE__?Ue("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=e);const Vo={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\tvec4 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 );\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 ) || defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec4 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n\tvColor *= color;\n#elif defined( USE_COLOR )\n\tvColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\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}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\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#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 = transformNormalByInverseViewMatrix( 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 * reflectVec );\n\t\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t\t#endif\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\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#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 = transformNormalByInverseViewMatrix( 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, pow4( roughness ) ) );\n\t\t\treflectVec = transformDirectionByInverseViewMatrix( 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 = transformNormalByInverseViewMatrix( 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 = transformNormalByInverseViewMatrix( 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\n#include <lightprobes_pars_fragment>",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;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = 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 = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n\tmaterial.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = vec3( 0.04 );\n\tmaterial.specularColorBlended = mix( material.specularColor, 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.0001, 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:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tvec3 diffuseContribution;\n\tvec3 specularColor;\n\tvec3 specularColorBlended;\n\tfloat roughness;\n\tfloat metalness;\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\tvec3 iridescenceFresnelDielectric;\n\t\tvec3 iridescenceFresnelMetallic;\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\treturn 0.5 / max( gv + gl, EPSILON );\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.specularColorBlended;\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 * transpose( 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 rInv = 1.0 / ( roughness + 0.1 );\n\tfloat a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n\tfloat b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n\tfloat DG = exp( a * dotNV + b );\n\treturn saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\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\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\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}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n\tvec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n\tvec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n\tvec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n\tfloat Ess_V = dfgV.x + dfgV.y;\n\tfloat Ess_L = dfgL.x + dfgL.y;\n\tfloat Ems_V = 1.0 - Ess_V;\n\tfloat Ems_L = 1.0 - Ess_L;\n\tvec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n\tvec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n\tfloat compensationFactor = Ems_V * Ems_L;\n\tvec3 multiScatter = Fms * compensationFactor;\n\treturn singleScatter + multiScatter;\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.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t\t#ifdef USE_CLEARCOAT\n\t\t\tvec3 Ncc = geometryClearcoatNormal;\n\t\t\tvec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n\t\t\tvec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n\t\t\tvec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n\t\t\tmat3 mInvClearcoat = mat3(\n\t\t\t\tvec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n\t\t\t\tvec3( 0, 1, 0 ),\n\t\t\t\tvec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n\t\t\t);\n\t\t\tvec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n\t\t\tclearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n\t\t#endif\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 \n \t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n \t\tfloat sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n \t\tfloat sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n \t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n \t\tirradiance *= sheenEnergyComp;\n \n \t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\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\tvec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tdiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectDiffuse += diffuse;\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 ) * RECIPROCAL_PI;\n \t#endif\n\tvec3 singleScatteringDielectric = vec3( 0.0 );\n\tvec3 multiScatteringDielectric = vec3( 0.0 );\n\tvec3 singleScatteringMetallic = vec3( 0.0 );\n\tvec3 multiScatteringMetallic = vec3( 0.0 );\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n\t#endif\n\tvec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n\tvec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n\tvec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n\tvec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tvec3 indirectSpecular = radiance * singleScattering;\n\tindirectSpecular += multiScattering * cosineWeightedIrradiance;\n\tvec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t\tfloat sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n\t\tindirectSpecular *= sheenEnergyComp;\n\t\tindirectDiffuse *= sheenEnergyComp;\n\t#endif\n\treflectedLight.indirectSpecular += indirectSpecular;\n\treflectedLight.indirectDiffuse += indirectDiffuse;\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.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n\t\tmaterial.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\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 ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\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\t#ifdef USE_LIGHT_PROBES_GRID\n\t\tvec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n\t\tvec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n\t\tirradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\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( ENVMAP_TYPE_CUBE_UV )\n\t\t#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n\t\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t\t#endif\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\t#if defined( LAMBERT ) || defined( PHONG )\n\t\tirradiance += iblIrradiance;\n\t#endif\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",lightprobes_pars_fragment:"#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probesResolution;\n\tvec3 gridRange = probesMax - probesMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\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#ifdef DOUBLE_SIDED\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#ifdef DOUBLE_SIDED\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\t#if defined( USE_PACKED_NORMALMAP )\n\t\tmapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n\t#endif\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\t#ifdef FLIP_SIDED\n\t\t\tvBitangent = - vBitangent;\n\t\t#endif\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\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\n\t\treturn depth * ( far - near ) - far;\n\t#else\n\t\treturn depth * ( near - far ) - near;\n\t#endif\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\t\n\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\treturn ( near * far ) / ( ( near - far ) * depth - near );\n\t#else\n\t\treturn ( near * far ) / ( ( far - near ) * depth - far );\n\t#endif\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\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\t#endif\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\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#else\n\t\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\t#endif\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\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tuniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\t\t\tuniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\t#endif\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\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat interleavedGradientNoise( vec2 position ) {\n\t\t\treturn fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n\t\t}\n\t\tvec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n\t\t\tconst float goldenAngle = 2.399963229728653;\n\t\t\tfloat r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n\t\t\tfloat theta = float( sampleIndex ) * goldenAngle + phi;\n\t\t\treturn vec2( cos( theta ), sin( theta ) ) * r;\n\t\t}\n\t#endif\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\tfloat getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\tshadowCoord.z += shadowBias;\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\t\tfloat radius = shadowRadius * texelSize.x;\n\t\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n\t\t\t\t\ttexture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n\t\t\t\t) * 0.2;\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tvec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n\t\t\t\tfloat mean = distribution.x;\n\t\t\t\tfloat variance = distribution.y * distribution.y;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tfloat hard_shadow = step( mean, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tfloat hard_shadow = step( shadowCoord.z, mean );\n\t\t\t\t#endif\n\t\t\t\t\n\t\t\t\tif ( hard_shadow == 1.0 ) {\n\t\t\t\t\tshadow = 1.0;\n\t\t\t\t} else {\n\t\t\t\t\tvariance = max( variance, 0.0000001 );\n\t\t\t\t\tfloat d = shadowCoord.z - mean;\n\t\t\t\t\tfloat p_max = variance / ( variance + d * d );\n\t\t\t\t\tp_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n\t\t\t\t\tshadow = max( hard_shadow, p_max );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#else\n\t\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\t\tfloat shadow = 1.0;\n\t\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tshadowCoord.z -= shadowBias;\n\t\t\t#else\n\t\t\t\tshadowCoord.z += shadowBias;\n\t\t\t#endif\n\t\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\t\tif ( frustumTest ) {\n\t\t\t\tfloat depth = texture2D( shadowMap, shadowCoord.xy ).r;\n\t\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\t\tshadow = step( depth, shadowCoord.z );\n\t\t\t\t#else\n\t\t\t\t\tshadow = step( shadowCoord.z, depth );\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#if defined( SHADOWMAP_TYPE_PCF )\n\tfloat getPointShadow( samplerCubeShadow 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\tvec3 bd3D = normalize( lightToPosition );\n\t\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tfloat dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp -= shadowBias;\n\t\t\t#else\n\t\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\t\tdp += shadowBias;\n\t\t\t#endif\n\t\t\tfloat texelSize = shadowRadius / shadowMapSize.x;\n\t\t\tvec3 absDir = abs( bd3D );\n\t\t\tvec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n\t\t\ttangent = normalize( cross( bd3D, tangent ) );\n\t\t\tvec3 bitangent = cross( bd3D, tangent );\n\t\t\tfloat phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n\t\t\tvec2 sample0 = vogelDiskSample( 0, 5, phi );\n\t\t\tvec2 sample1 = vogelDiskSample( 1, 5, phi );\n\t\t\tvec2 sample2 = vogelDiskSample( 2, 5, phi );\n\t\t\tvec2 sample3 = vogelDiskSample( 3, 5, phi );\n\t\t\tvec2 sample4 = vogelDiskSample( 4, 5, phi );\n\t\t\tshadow = (\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n\t\t\t\ttexture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n\t\t\t) * 0.2;\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#elif defined( SHADOWMAP_TYPE_BASIC )\n\tfloat getPointShadow( samplerCube 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\tvec3 absVec = abs( lightToPosition );\n\t\tfloat viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n\t\tif ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tfloat depth = textureCube( shadowMap, bd3D ).r;\n\t\t\t#ifdef USE_REVERSED_DEPTH_BUFFER\n\t\t\t\tdepth = 1.0 - depth;\n\t\t\t#endif\n\t\t\tshadow = step( dp, depth );\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\t#endif\n\t#endif\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\t#ifdef HAS_NORMAL\n\t\tvec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n\t#else\n\t\tvec3 shadowWorldNormal = vec3( 0.0 );\n\t#endif\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 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\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 = transformNormalByInverseViewMatrix( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseContribution, material.specularColorBlended, 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 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 * vWorldDirection );\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}",distance_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}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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 <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 = vec4( dist, 0.0, 0.0, 1.0 );\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 <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 <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_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 <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( normalize( normal ) * 0.5 + 0.5, 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 <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 <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_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 <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 \n\t\toutgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \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 <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 <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\t#include <premultiplied_alpha_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}"},Ho={common:{diffuse:{value:new sn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ii},alphaMap:{value:null},alphaMapTransform:{value:new ii},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ii}},envmap:{envMap:{value:null},envMapRotation:{value:new ii},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ii}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ii}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ii},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ii},normalScale:{value:new Je(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ii},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ii}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ii}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ii}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new sn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new Qe},probesMax:{value:new Qe},probesResolution:{value:new Qe}},points:{diffuse:{value:new sn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ii},alphaTest:{value:0},uvTransform:{value:new ii}},sprite:{diffuse:{value:new sn(16777215)},opacity:{value:1},center:{value:new Je(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ii},alphaMap:{value:null},alphaMapTransform:{value:new ii},alphaTest:{value:0}}},Go={basic:{uniforms:Da([Ho.common,Ho.specularmap,Ho.envmap,Ho.aomap,Ho.lightmap,Ho.fog]),vertexShader:Vo.meshbasic_vert,fragmentShader:Vo.meshbasic_frag},lambert:{uniforms:Da([Ho.common,Ho.specularmap,Ho.envmap,Ho.aomap,Ho.lightmap,Ho.emissivemap,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,Ho.fog,Ho.lights,{emissive:{value:new sn(0)},envMapIntensity:{value:1}}]),vertexShader:Vo.meshlambert_vert,fragmentShader:Vo.meshlambert_frag},phong:{uniforms:Da([Ho.common,Ho.specularmap,Ho.envmap,Ho.aomap,Ho.lightmap,Ho.emissivemap,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,Ho.fog,Ho.lights,{emissive:{value:new sn(0)},specular:{value:new sn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Vo.meshphong_vert,fragmentShader:Vo.meshphong_frag},standard:{uniforms:Da([Ho.common,Ho.envmap,Ho.aomap,Ho.lightmap,Ho.emissivemap,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,Ho.roughnessmap,Ho.metalnessmap,Ho.fog,Ho.lights,{emissive:{value:new sn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vo.meshphysical_vert,fragmentShader:Vo.meshphysical_frag},toon:{uniforms:Da([Ho.common,Ho.aomap,Ho.lightmap,Ho.emissivemap,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,Ho.gradientmap,Ho.fog,Ho.lights,{emissive:{value:new sn(0)}}]),vertexShader:Vo.meshtoon_vert,fragmentShader:Vo.meshtoon_frag},matcap:{uniforms:Da([Ho.common,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,Ho.fog,{matcap:{value:null}}]),vertexShader:Vo.meshmatcap_vert,fragmentShader:Vo.meshmatcap_frag},points:{uniforms:Da([Ho.points,Ho.fog]),vertexShader:Vo.points_vert,fragmentShader:Vo.points_frag},dashed:{uniforms:Da([Ho.common,Ho.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vo.linedashed_vert,fragmentShader:Vo.linedashed_frag},depth:{uniforms:Da([Ho.common,Ho.displacementmap]),vertexShader:Vo.depth_vert,fragmentShader:Vo.depth_frag},normal:{uniforms:Da([Ho.common,Ho.bumpmap,Ho.normalmap,Ho.displacementmap,{opacity:{value:1}}]),vertexShader:Vo.meshnormal_vert,fragmentShader:Vo.meshnormal_frag},sprite:{uniforms:Da([Ho.sprite,Ho.fog]),vertexShader:Vo.sprite_vert,fragmentShader:Vo.sprite_frag},background:{uniforms:{uvTransform:{value:new ii},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vo.background_vert,fragmentShader:Vo.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ii}},vertexShader:Vo.backgroundCube_vert,fragmentShader:Vo.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vo.cube_vert,fragmentShader:Vo.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vo.equirect_vert,fragmentShader:Vo.equirect_frag},distance:{uniforms:Da([Ho.common,Ho.displacementmap,{referencePosition:{value:new Qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vo.distance_vert,fragmentShader:Vo.distance_frag},shadow:{uniforms:Da([Ho.lights,Ho.fog,{color:{value:new sn(0)},opacity:{value:1}}]),vertexShader:Vo.shadow_vert,fragmentShader:Vo.shadow_frag}};Go.physical={uniforms:Da([Go.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ii},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ii},clearcoatNormalScale:{value:new Je(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ii},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ii},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ii},sheen:{value:0},sheenColor:{value:new sn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ii},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ii},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ii},transmissionSamplerSize:{value:new Je},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ii},attenuationDistance:{value:0},attenuationColor:{value:new sn(0)},specularColor:{value:new sn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ii},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ii},anisotropyVector:{value:new Je},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ii}}]),vertexShader:Vo.meshphysical_vert,fragmentShader:Vo.meshphysical_frag};const Wo={r:0,b:0,g:0},Xo=new bi,jo=new ii;function qo(t,e,i,n,r,s){const a=new sn(0);let o,l,h=!0===r?0:1,c=null,u=0,d=null;function p(t){let i=!0===t.isScene?t.background:null;if(i&&i.isTexture){const n=t.backgroundBlurriness>0;i=e.get(i,n)}return i}function f(e,n){e.getRGB(Wo,Na(t)),i.buffers.color.setClear(Wo.r,Wo.g,Wo.b,n,s)}return{getClearColor:function(){return a},setClearColor:function(t,e=1){a.set(t),h=e,f(a,h)},getClearAlpha:function(){return h},setClearAlpha:function(t){h=t,f(a,h)},render:function(e){let n=!1;const r=p(e);null===r?f(a,h):r&&r.isColor&&(f(r,1),n=!0);const o=t.xr.getEnvironmentBlendMode();"additive"===o?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===o&&i.buffers.color.setClear(0,0,0,0,s),(t.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))},addToRenderList:function(e,i){const r=p(i);r&&(r.isCubeTexture||r.mapping===tt)?(void 0===l&&(l=new Gr(new Ts(1,1,1),new Oa({name:"BackgroundCubeMaterial",uniforms:La(Go.backgroundCube.uniforms),vertexShader:Go.backgroundCube.vertexShader,fragmentShader:Go.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=r,l.material.uniforms.backgroundBlurriness.value=i.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Xo.makeRotationFromEuler(i.backgroundRotation)).transpose(),r.isCubeTexture&&!1===r.isRenderTargetTexture&&l.material.uniforms.backgroundRotation.value.premultiply(jo),l.material.toneMapped=oi.getTransfer(r.colorSpace)!==ge,c===r&&u===r.version&&d===t.toneMapping||(l.material.needsUpdate=!0,c=r,u=r.version,d=t.toneMapping),l.layers.enableAll(),e.unshift(l,l.geometry,l.material,0,0,null)):r&&r.isTexture&&(void 0===o&&(o=new Gr(new wa(2,2),new Oa({name:"BackgroundMaterial",uniforms:La(Go.background.uniforms),vertexShader:Go.background.vertexShader,fragmentShader:Go.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=r,o.material.uniforms.backgroundIntensity.value=i.backgroundIntensity,o.material.toneMapped=oi.getTransfer(r.colorSpace)!==ge,!0===r.matrixAutoUpdate&&r.updateMatrix(),o.material.uniforms.uvTransform.value.copy(r.matrix),c===r&&u===r.version&&d===t.toneMapping||(o.material.needsUpdate=!0,c=r,u=r.version,d=t.toneMapping),o.layers.enableAll(),e.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function Yo(t,e){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),n={},r=h(null);let s=r,a=!1;function o(e){return t.bindVertexArray(e)}function l(e){return t.deleteVertexArray(e)}function h(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function c(){const t=s.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function u(t){d(t,0)}function d(e,i){const n=s.newAttributes,r=s.enabledAttributes,a=s.attributeDivisors;n[e]=1,0===r[e]&&(t.enableVertexAttribArray(e),r[e]=1),a[e]!==i&&(t.vertexAttribDivisor(e,i),a[e]=i)}function p(){const e=s.newAttributes,i=s.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function f(e,i,n,r,s,a,o){!0===o?t.vertexAttribIPointer(e,i,n,s,a):t.vertexAttribPointer(e,i,n,r,s,a)}function m(){g(),a=!0,s!==r&&(s=r,o(s.object))}function g(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:function(i,r,l,m,g){let _=!1;const v=function(e,i,r,s){const a=!0===s.wireframe;let o=n[i.id];void 0===o&&(o={},n[i.id]=o);const l=!0===e.isInstancedMesh?e.id:0;let c=o[l];void 0===c&&(c={},o[l]=c);let u=c[r.id];void 0===u&&(u={},c[r.id]=u);let d=u[a];void 0===d&&(d=h(t.createVertexArray()),u[a]=d);return d}(i,m,l,r);s!==v&&(s=v,o(s.object)),_=function(t,e,i,n){const r=s.attributes,a=e.attributes;let o=0;const l=i.getAttributes();for(const e in l){if(l[e].location>=0){const i=r[e];let n=a[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return s.attributesNum!==o||s.index!==n}(i,m,l,g),_&&function(t,e,i,n){const r={},a=e.attributes;let o=0;const l=i.getAttributes();for(const e in l){if(l[e].location>=0){let i=a[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,o++}}s.attributes=r,s.attributesNum=o,s.index=n}(i,m,l,g),null!==g&&e.update(g,t.ELEMENT_ARRAY_BUFFER),(_||a)&&(a=!1,function(i,n,r,s){c();const a=s.attributes,o=r.getAttributes(),l=n.defaultAttributeValues;for(const n in o){const r=o[n];if(r.location>=0){let o=a[n];if(void 0===o&&("instanceMatrix"===n&&i.instanceMatrix&&(o=i.instanceMatrix),"instanceColor"===n&&i.instanceColor&&(o=i.instanceColor)),void 0!==o){const n=o.normalized,a=o.itemSize,l=e.get(o);if(void 0===l)continue;const h=l.buffer,c=l.type,p=l.bytesPerElement,m=c===t.INT||c===t.UNSIGNED_INT||o.gpuType===ft;if(o.isInterleavedBufferAttribute){const e=o.data,l=e.stride,g=o.offset;if(e.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)d(r.location+t,e.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=e.meshPerAttribute*e.count)}else for(let t=0;t<r.locationSize;t++)u(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,n,l*p,(g+a/r.locationSize*t)*p,m)}else{if(o.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)d(r.location+t,o.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let t=0;t<r.locationSize;t++)u(r.location+t);t.bindBuffer(t.ARRAY_BUFFER,h);for(let t=0;t<r.locationSize;t++)f(r.location+t,a/r.locationSize,c,n,a*p,a/r.locationSize*t*p,m)}}else if(void 0!==l){const e=l[n];if(void 0!==e)switch(e.length){case 2:t.vertexAttrib2fv(r.location,e);break;case 3:t.vertexAttrib3fv(r.location,e);break;case 4:t.vertexAttrib4fv(r.location,e);break;default:t.vertexAttrib1fv(r.location,e)}}}}p()}(i,r,l,m),null!==g&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(g).buffer))},reset:m,resetDefaultState:g,dispose:function(){m();for(const t in n){const e=n[t];for(const t in e){const i=e[t];for(const t in i){const e=i[t];for(const t in e)l(e[t].object),delete e[t];delete i[t]}}delete n[t]}},releaseStatesOfGeometry:function(t){if(void 0===n[t.id])return;const e=n[t.id];for(const t in e){const i=e[t];for(const t in i){const e=i[t];for(const t in e)l(e[t].object),delete e[t];delete i[t]}}delete n[t.id]},releaseStatesOfObject:function(t){for(const e in n){const i=n[e],r=!0===t.isInstancedMesh?t.id:0,s=i[r];if(void 0!==s){for(const t in s){const e=s[t];for(const t in e)l(e[t].object),delete e[t];delete s[t]}delete i[r],0===Object.keys(i).length&&delete n[e]}}},releaseStatesOfProgram:function(t){for(const e in n){const i=n[e];for(const e in i){const n=i[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)l(r[t].object),delete r[t];delete n[t.id]}}},initAttributes:c,enableAttribute:u,disableUnusedAttributes:p}}function Zo(t,e,i){let n;this.setMode=function(t){n=t},this.render=function(e,r){t.drawArrays(n,e,r),i.update(r,n,1)},this.renderInstances=function(e,r,s){0!==s&&(t.drawArraysInstanced(n,e,r,s),i.update(r,n,s))},this.renderMultiDraw=function(t,r,s){if(0===s)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,t,0,r,0,s);let a=0;for(let t=0;t<s;t++)a+=r[t];i.update(a,n,1)}}function Ko(t,e,i,n){let r;function s(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=void 0!==i.precision?i.precision:"highp";const o=s(a);o!==a&&(Ue("WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=!0===i.logarithmicDepthBuffer,h=!0===i.reversedDepthBuffer&&e.has("EXT_clip_control");!0===i.reversedDepthBuffer&&!1===h&&Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:s,textureFormatReadable:function(e){return e===bt||n.convert(e)===t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(i){const r=i===_t&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(i!==ct&&n.convert(i)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&i!==gt&&!r)},precision:a,logarithmicDepthBuffer:l,reversedDepthBuffer:h,maxTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxCubemapSize:t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:t.getParameter(t.MAX_VERTEX_ATTRIBS),maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:t.getParameter(t.MAX_VARYING_VECTORS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:t.getParameter(t.MAX_SAMPLES),samples:t.getParameter(t.SAMPLES)}}function Jo(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Zr,o=new ii,l={value:null,needsUpdate:!1};function h(t,i,n,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=l.value,!0!==r||null===h){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)a.copy(t[e]).applyMatrix4(r,o),a.normal.toArray(h,i),h[i+3]=a.constant}l.value=h,l.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e){const i=0!==t.length||e||0!==n||r;return r=e,n=t.length,i},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(t,e){i=h(t,e,0)},this.setState=function(a,o,c){const u=a.clippingPlanes,d=a.clipIntersection,p=a.clipShadows,f=t.get(a);if(!r||null===u||0===u.length||s&&!p)s?h(null):function(){l.value!==i&&(l.value=i,l.needsUpdate=n>0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=f.clippingState||null;l.value=r,r=h(u,o,e,c);for(let t=0;t!==e;++t)r[t]=i[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}jo.set(-1,0,0,0,1,0,0,0,1);const $o=[.125,.215,.35,.446,.526,.582],Qo=20,tl=new _o,el=new sn;let il=null,nl=0,rl=0,sl=!1;const al=new Qe;class ol{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,i=.1,n=100,r={}){const{size:s=256,position:a=al}=r;il=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),rl=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(t,i,n,o,a),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=ul(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=cl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(il,nl,rl),this._renderer.xr.enabled=sl,t.scissorTest=!1,hl(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===K||t.mapping===J?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),il=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),rl=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:ot,minFilter:ot,generateMipmaps:!1,type:_t,format:bt,colorSpace:fe,depthBuffer:!1},n=ll(t,e,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=ll(t,e,i);const{_lodMax:n}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(t){const e=[],i=[],n=[];let r=t;const s=t-4+1+$o.length;for(let a=0;a<s;a++){const s=Math.pow(2,r);e.push(s);let o=1/s;a>t-4?o=$o[a-t+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,f=3,m=2,g=1,_=new Float32Array(f*p*d),v=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let t=0;t<d;t++){const e=t%3*2/3-1,i=t>2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];_.set(n,f*p*t),v.set(u,m*p*t);const r=[t,t,t,t,t,t];x.set(r,g*p*t)}const y=new er;y.setAttribute("position",new kn(_,f)),y.setAttribute("uv",new kn(v,m)),y.setAttribute("faceIndex",new kn(x,g)),n.push(new Gr(y,null)),r>4&&r--}return{lodMeshes:n,sizeLods:e,sigmas:i}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(Qo),r=new Qe(0,1,0),s=new Oa({name:"SphericalGaussianBlur",defines:{n:Qo,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:dl(),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:0,depthTest:!1,depthWrite:!1});return s}(n,t,e),this._ggxMaterial=function(t,e,i){const n=new Oa({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:dl(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:0,depthTest:!1,depthWrite:!1});return n}(n,t,e)}return n}_compileMaterial(t){const e=new Gr(new er,t);this._renderer.compile(e,tl)}_sceneToCubeUV(t,e,i,n,r){const s=new uo(90,1,e,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,h=l.autoClear,c=l.toneMapping;l.getClearColor(el),l.toneMapping=0,l.autoClear=!1;l.state.buffers.depth.getReversed()&&(l.setRenderTarget(n),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new Gr(new Ts,new Lr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));const u=this._backgroundBox,d=u.material;let p=!1;const f=t.background;f?f.isColor&&(d.color.copy(f),t.background=null,p=!0):(d.color.copy(el),p=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x+o[e],r.y,r.z)):1===i?(s.up.set(0,0,a[e]),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y+o[e],r.z)):(s.up.set(0,a[e],0),s.position.set(r.x,r.y,r.z),s.lookAt(r.x,r.y,r.z+o[e]));const h=this._cubeSize;hl(n,i*h,e>2?h:0,h,h),l.setRenderTarget(n),p&&l.render(u,s),l.render(t,s)}l.toneMapping=c,l.autoClear=h,t.background=f}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===K||t.mapping===J;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=ul()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=cl());const r=n?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=r;r.uniforms.envMap.value=t;const a=this._cubeSize;hl(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,tl)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let e=1;e<n;e++)this._applyGGXFilter(t,e-1,e);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,r=this._pingPongRenderTarget,s=this._ggxMaterial,a=this._lodMeshes[i];a.material=s;const o=s.uniforms,l=i/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),c=Math.sqrt(l*l-h*h)*(0+1.25*l),{_lodMax:u}=this,d=this._sizeLods[i],p=3*d*(i>u-4?i-u+4:0),f=4*(this._cubeSize-d);o.envMap.value=t.texture,o.roughness.value=c,o.mipInt.value=u-e,hl(r,p,f,3*d,2*d),n.setRenderTarget(r),n.render(a,tl),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=u-i,hl(t,p,f,3*d,2*d),n.setRenderTarget(t),n.render(a,tl)}_blur(t,e,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(t,s,e,i,n,"latitudinal",r),this._halfBlur(s,t,i,i,n,"longitudinal",r)}_halfBlur(t,e,i,n,r,s,a){const o=this._renderer,l=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&Oe("blur direction must be either latitudinal or longitudinal!");const h=this._lodMeshes[n];h.material=l;const c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):Qo;f>Qo&&Ue(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t<Qo;++t){const e=t/p,i=Math.exp(-e*e/2);m.push(i),0===t?g+=i:t<f&&(g+=2*i)}for(let t=0;t<m.length;t++)m[t]=m[t]/g;c.envMap.value=t.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===s,a&&(c.poleAxis.value=a);const{_lodMax:_}=this;c.dTheta.value=d,c.mipInt.value=_-i;const v=this._sizeLods[n];hl(e,3*v*(n>_-4?n-_+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(h,tl)}}function ll(t,e,i){const n=new yi(t,e,i);return n.texture.mapping=tt,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function hl(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function cl(){return new Oa({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dl(),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:0,depthTest:!1,depthWrite:!1})}function ul(){return new Oa({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dl(),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:0,depthTest:!1,depthWrite:!1})}function dl(){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"}class pl extends yi{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];this.texture=new ys(n),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 i={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"},n=new Ts(5,5,5),r=new Oa({name:"CubemapFromEquirect",uniforms:La(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Gr(n,r),a=e.minFilter;e.minFilter===ht&&(e.minFilter=ot);return new So(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e=!0,i=!0,n=!0){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}function fl(t){let e=new WeakMap,i=new WeakMap,n=null;function r(t,e){return e===$?t.mapping=K:e===Q&&(t.mapping=J),t}function s(t){const i=t.target;i.removeEventListener("dispose",s);const n=e.get(i);void 0!==n&&(e.delete(i),n.dispose())}function a(t){const e=t.target;e.removeEventListener("dispose",a);const n=i.get(e);void 0!==n&&(i.delete(e),n.dispose())}return{get:function(o,l=!1){return null==o?null:l?function(e){if(e&&e.isTexture){const r=e.mapping,s=r===$||r===Q,o=r===K||r===J;if(s||o){let r=i.get(e);const l=void 0!==r?r.texture.pmremVersion:0;if(e.isRenderTargetTexture&&e.pmremVersion!==l)return null===n&&(n=new ol(t)),r=s?n.fromEquirectangular(e,r):n.fromCubemap(e,r),r.texture.pmremVersion=e.pmremVersion,i.set(e,r),r.texture;if(void 0!==r)return r.texture;{const l=e.image;return s&&l&&l.height>0||o&&l&&function(t){let e=0;const i=6;for(let n=0;n<i;n++)void 0!==t[n]&&e++;return e===i}(l)?(null===n&&(n=new ol(t)),r=s?n.fromEquirectangular(e):n.fromCubemap(e),r.texture.pmremVersion=e.pmremVersion,i.set(e,r),e.addEventListener("dispose",a),r.texture):null}}}return e}(o):function(i){if(i&&i.isTexture){const n=i.mapping;if(n===$||n===Q){if(e.has(i)){return r(e.get(i).texture,i.mapping)}{const n=i.image;if(n&&n.height>0){const a=new pl(n.height);return a.fromEquirectangularTexture(t,i),e.set(i,a),i.addEventListener("dispose",s),r(a.texture,i.mapping)}return null}}}return i}(o)},dispose:function(){e=new WeakMap,i=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function ml(t){const e={};function i(i){if(void 0!==e[i])return e[i];const n=t.getExtension(i);return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(){i("EXT_color_buffer_float"),i("WEBGL_clip_cull_distance"),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture"),i("WEBGL_render_shared_exponent")},get:function(t){const e=i(t);return null===e&&Fe("WebGLRenderer: "+t+" extension not supported."),e}}}function gl(t,e,i,n){const r={},s=new WeakMap;function a(t){const o=t.target;null!==o.index&&e.remove(o.index);for(const t in o.attributes)e.remove(o.attributes[t]);o.removeEventListener("dispose",a),delete r[o.id];const l=s.get(o);l&&(e.remove(l),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(t){const i=[],n=t.index,r=t.attributes.position;let a=0;if(void 0===r)return;if(null!==n){const t=n.array;a=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{const t=r.array;a=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const o=new(r.count>=65535?Hn:Vn)(i,1);o.version=a;const l=s.get(t);l&&e.remove(l),s.set(t,o)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",a),r[e.id]=!0,i.memory.geometries++),e},update:function(i){const n=i.attributes;for(const i in n)e.update(n[i],t.ARRAY_BUFFER)},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&o(t)}else o(t);return s.get(t)}}}function _l(t,e,i){let n,r,s;this.setMode=function(t){n=t},this.setIndex=function(t){r=t.type,s=t.bytesPerElement},this.render=function(e,a){t.drawElements(n,a,r,e*s),i.update(a,n,1)},this.renderInstances=function(e,a,o){0!==o&&(t.drawElementsInstanced(n,a,r,e*s,o),i.update(a,n,o))},this.renderMultiDraw=function(t,s,a){if(0===a)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,s,0,r,t,0,a);let o=0;for(let t=0;t<a;t++)o+=s[t];i.update(o,n,1)}}function vl(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(i,n,r){switch(e.calls++,n){case t.TRIANGLES:e.triangles+=r*(i/3);break;case t.LINES:e.lines+=r*(i/2);break;case t.LINE_STRIP:e.lines+=r*(i-1);break;case t.LINE_LOOP:e.lines+=r*i;break;case t.POINTS:e.points+=r*i;break;default:Oe("WebGLInfo: Unknown draw mode:",n)}}}}function xl(t,e,i){const n=new WeakMap,r=new vi;return{update:function(s,a,o){const l=s.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,c=void 0!==h?h.length:0;let u=n.get(a);if(void 0===u||u.count!==c){void 0!==u&&u.texture.dispose();const d=void 0!==a.morphAttributes.position,p=void 0!==a.morphAttributes.normal,f=void 0!==a.morphAttributes.color,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],_=a.morphAttributes.color||[];let v=0;!0===d&&(v=1),!0===p&&(v=2),!0===f&&(v=3);let x=a.attributes.position.count*v,y=1;x>e.maxTextureSize&&(y=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const M=new Float32Array(x*y*4*c),S=new Mi(M,x,y,c);S.type=gt,S.needsUpdate=!0;const b=4*v;for(let T=0;T<c;T++){const w=m[T],A=g[T],R=_[T],C=x*y*4*T;for(let P=0;P<w.count;P++){const L=P*b;!0===d&&(r.fromBufferAttribute(w,P),M[C+L+0]=r.x,M[C+L+1]=r.y,M[C+L+2]=r.z,M[C+L+3]=0),!0===p&&(r.fromBufferAttribute(A,P),M[C+L+4]=r.x,M[C+L+5]=r.y,M[C+L+6]=r.z,M[C+L+7]=0),!0===f&&(r.fromBufferAttribute(R,P),M[C+L+8]=r.x,M[C+L+9]=r.y,M[C+L+10]=r.z,M[C+L+11]=4===R.itemSize?r.w:1)}}function E(){S.dispose(),n.delete(a),a.removeEventListener("dispose",E)}u={count:c,texture:S,size:new Je(x,y)},n.set(a,u),a.addEventListener("dispose",E)}if(!0===s.isInstancedMesh&&null!==s.morphTexture)o.getUniforms().setValue(t,"morphTexture",s.morphTexture,i);else{let D=0;for(let N=0;N<l.length;N++)D+=l[N];const I=a.morphTargetsRelative?1:1-D;o.getUniforms().setValue(t,"morphTargetBaseInfluence",I),o.getUniforms().setValue(t,"morphTargetInfluences",l)}o.getUniforms().setValue(t,"morphTargetsTexture",u.texture,i),o.getUniforms().setValue(t,"morphTargetsTextureSize",u.size)}}}function yl(t,e,i,n,r){let s=new WeakMap;function a(t){const e=t.target;e.removeEventListener("dispose",a),n.releaseStatesOfObject(e),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(n){const o=r.render.frame,l=n.geometry,h=e.get(n,l);if(s.get(h)!==o&&(e.update(h),s.set(h,o)),n.isInstancedMesh&&(!1===n.hasEventListener("dispose",a)&&n.addEventListener("dispose",a),s.get(n)!==o&&(i.update(n.instanceMatrix,t.ARRAY_BUFFER),null!==n.instanceColor&&i.update(n.instanceColor,t.ARRAY_BUFFER),s.set(n,o))),n.isSkinnedMesh){const t=n.skeleton;s.get(t)!==o&&(t.update(),s.set(t,o))}return h},dispose:function(){s=new WeakMap}}}const Ml={[G]:"LINEAR_TONE_MAPPING",[W]:"REINHARD_TONE_MAPPING",[X]:"CINEON_TONE_MAPPING",[j]:"ACES_FILMIC_TONE_MAPPING",[Y]:"AGX_TONE_MAPPING",[Z]:"NEUTRAL_TONE_MAPPING",[q]:"CUSTOM_TONE_MAPPING"};function Sl(t,e,i,n,r,s){const a=new yi(e,i,{type:t,depthBuffer:r,stencilBuffer:s,samples:n?4:0,depthTexture:r?new Ss(e,i):void 0}),o=new yi(e,i,{type:_t,depthBuffer:!1,stencilBuffer:!1}),l=new er;l.setAttribute("position",new Gn([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Gn([0,2,0,0,2,0],2));const h=new Fa({uniforms:{tDiffuse:{value:null}},vertexShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform mat4 modelViewMatrix;\n\t\t\tuniform mat4 projectionMatrix;\n\n\t\t\tattribute vec3 position;\n\t\t\tattribute vec2 uv;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\tvoid main() {\n\t\t\t\tvUv = uv;\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t}",fragmentShader:"\n\t\t\tprecision highp float;\n\n\t\t\tuniform sampler2D tDiffuse;\n\n\t\t\tvarying vec2 vUv;\n\n\t\t\t#include <tonemapping_pars_fragment>\n\t\t\t#include <colorspace_pars_fragment>\n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:!1,depthWrite:!1}),c=new Gr(l,h),u=new _o(-1,1,1,-1,0,1);let d,p=null,f=null,m=!1,g=null,_=[],v=!1;this.setSize=function(t,e){a.setSize(t,e),o.setSize(t,e);for(let i=0;i<_.length;i++){const n=_[i];n.setSize&&n.setSize(t,e)}},this.setEffects=function(t){_=t,v=_.length>0&&!0===_[0].isRenderPass;const e=a.width,i=a.height;for(let t=0;t<_.length;t++){const n=_[t];n.setSize&&n.setSize(e,i)}},this.begin=function(t,e){if(m)return!1;if(0===t.toneMapping&&0===_.length)return!1;if(g=e,null!==e){const t=e.width,i=e.height;a.width===t&&a.height===i||this.setSize(t,i)}return!1===v&&t.setRenderTarget(a),d=t.toneMapping,t.toneMapping=0,!0},this.hasRenderPass=function(){return v},this.end=function(t,e){t.toneMapping=d,m=!0;let i=a,n=o;for(let r=0;r<_.length;r++){const s=_[r];if(!1!==s.enabled&&(s.render(t,n,i,e),!1!==s.needsSwap)){const t=i;i=n,n=t}}if(p!==t.outputColorSpace||f!==t.toneMapping){p=t.outputColorSpace,f=t.toneMapping,h.defines={},oi.getTransfer(p)===ge&&(h.defines.SRGB_TRANSFER="");const e=Ml[f];e&&(h.defines[e]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=i.texture,t.setRenderTarget(g),t.render(c,u),g=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),h.dispose()}}const bl=new _i,El=new Ss(1,1),Tl=new Mi,wl=new Si,Al=new ys,Rl=[],Cl=[],Pl=new Float32Array(16),Ll=new Float32Array(9),Dl=new Float32Array(4);function Il(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=Rl[r];if(void 0===s&&(s=new Float32Array(r),Rl[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Nl(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Ul(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function Ol(t,e){let i=Cl[e];void 0===i&&(i=new Int32Array(e),Cl[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Fl(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function zl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Nl(i,e))return;t.uniform2fv(this.addr,e),Ul(i,e)}}function Bl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(Nl(i,e))return;t.uniform3fv(this.addr,e),Ul(i,e)}}function kl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Nl(i,e))return;t.uniform4fv(this.addr,e),Ul(i,e)}}function Vl(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Nl(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ul(i,e)}else{if(Nl(i,n))return;Dl.set(n),t.uniformMatrix2fv(this.addr,!1,Dl),Ul(i,n)}}function Hl(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Nl(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ul(i,e)}else{if(Nl(i,n))return;Ll.set(n),t.uniformMatrix3fv(this.addr,!1,Ll),Ul(i,n)}}function Gl(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(Nl(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ul(i,e)}else{if(Nl(i,n))return;Pl.set(n),t.uniformMatrix4fv(this.addr,!1,Pl),Ul(i,n)}}function Wl(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function Xl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Nl(i,e))return;t.uniform2iv(this.addr,e),Ul(i,e)}}function jl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Nl(i,e))return;t.uniform3iv(this.addr,e),Ul(i,e)}}function ql(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Nl(i,e))return;t.uniform4iv(this.addr,e),Ul(i,e)}}function Yl(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Zl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(Nl(i,e))return;t.uniform2uiv(this.addr,e),Ul(i,e)}}function Kl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else{if(Nl(i,e))return;t.uniform3uiv(this.addr,e),Ul(i,e)}}function Jl(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(Nl(i,e))return;t.uniform4uiv(this.addr,e),Ul(i,e)}}function $l(t,e,i){const n=this.cache,r=i.allocateTextureUnit();let s;n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),this.type===t.SAMPLER_2D_SHADOW?(El.compareFunction=i.isReversedDepthBuffer()?518:515,s=El):s=bl,i.setTexture2D(e||s,r)}function Ql(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||wl,r)}function th(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(e||Al,r)}function eh(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||Tl,r)}function ih(t,e){t.uniform1fv(this.addr,e)}function nh(t,e){const i=Il(e,this.size,2);t.uniform2fv(this.addr,i)}function rh(t,e){const i=Il(e,this.size,3);t.uniform3fv(this.addr,i)}function sh(t,e){const i=Il(e,this.size,4);t.uniform4fv(this.addr,i)}function ah(t,e){const i=Il(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function oh(t,e){const i=Il(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function lh(t,e){const i=Il(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function hh(t,e){t.uniform1iv(this.addr,e)}function ch(t,e){t.uniform2iv(this.addr,e)}function uh(t,e){t.uniform3iv(this.addr,e)}function dh(t,e){t.uniform4iv(this.addr,e)}function ph(t,e){t.uniform1uiv(this.addr,e)}function fh(t,e){t.uniform2uiv(this.addr,e)}function mh(t,e){t.uniform3uiv(this.addr,e)}function gh(t,e){t.uniform4uiv(this.addr,e)}function _h(t,e,i){const n=this.cache,r=e.length,s=Ol(i,r);let a;Nl(n,s)||(t.uniform1iv(this.addr,s),Ul(n,s)),a=this.type===t.SAMPLER_2D_SHADOW?El:bl;for(let t=0;t!==r;++t)i.setTexture2D(e[t]||a,s[t])}function vh(t,e,i){const n=this.cache,r=e.length,s=Ol(i,r);Nl(n,s)||(t.uniform1iv(this.addr,s),Ul(n,s));for(let t=0;t!==r;++t)i.setTexture3D(e[t]||wl,s[t])}function xh(t,e,i){const n=this.cache,r=e.length,s=Ol(i,r);Nl(n,s)||(t.uniform1iv(this.addr,s),Ul(n,s));for(let t=0;t!==r;++t)i.setTextureCube(e[t]||Al,s[t])}function yh(t,e,i){const n=this.cache,r=e.length,s=Ol(i,r);Nl(n,s)||(t.uniform1iv(this.addr,s),Ul(n,s));for(let t=0;t!==r;++t)i.setTexture2DArray(e[t]||Tl,s[t])}class Mh{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.setValue=function(t){switch(t){case 5126:return Fl;case 35664:return zl;case 35665:return Bl;case 35666:return kl;case 35674:return Vl;case 35675:return Hl;case 35676:return Gl;case 5124:case 35670:return Wl;case 35667:case 35671:return Xl;case 35668:case 35672:return jl;case 35669:case 35673:return ql;case 5125:return Yl;case 36294:return Zl;case 36295:return Kl;case 36296:return Jl;case 35678:case 36198:case 36298:case 36306:case 35682:return $l;case 35679:case 36299:case 36307:return Ql;case 35680:case 36300:case 36308:case 36293:return th;case 36289:case 36303:case 36311:case 36292:return eh}}(e.type)}}class Sh{constructor(t,e,i){this.id=t,this.addr=i,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return ih;case 35664:return nh;case 35665:return rh;case 35666:return sh;case 35674:return ah;case 35675:return oh;case 35676:return lh;case 5124:case 35670:return hh;case 35667:case 35671:return ch;case 35668:case 35672:return uh;case 35669:case 35673:return dh;case 5125:return ph;case 36294:return fh;case 36295:return mh;case 36296:return gh;case 35678:case 36198:case 36298:case 36306:case 35682:return _h;case 35679:case 36299:case 36307:return vh;case 35680:case 36300:case 36308:case 36293:return xh;case 36289:case 36303:case 36311:case 36292:return yh}}(e.type)}}class bh{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}}}const Eh=/(\w+)(\])?(\[|\.)?/g;function Th(t,e){t.seq.push(e),t.map[e.id]=e}function wh(t,e,i){const n=t.name,r=n.length;for(Eh.lastIndex=0;;){const s=Eh.exec(n),a=Eh.lastIndex;let o=s[1];const l="]"===s[2],h=s[3];if(l&&(o|=0),void 0===h||"["===h&&a+2===r){Th(i,void 0===h?new Mh(o,t,e):new Sh(o,t,e));break}{let t=i.map[o];void 0===t&&(t=new bh(o),Th(i,t)),i=t}}}class Ah{constructor(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);wh(i,t.getUniformLocation(e,i.name),this)}const n=[],r=[];for(const e of this.seq)e.type===t.SAMPLER_2D_SHADOW||e.type===t.SAMPLER_CUBE_SHADOW||e.type===t.SAMPLER_2D_ARRAY_SHADOW?n.push(e):r.push(e);n.length>0&&(this.seq=n.concat(r))}setValue(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)}setOptional(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)}static upload(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(t,a.value,n)}}static seqWithValue(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i}}function Rh(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}let Ch=0;const Ph=new ii;function Lh(t,e,i){const n=t.getShaderParameter(e,t.COMPILE_STATUS),r=(t.getShaderInfoLog(e)||"").trim();if(n&&""===r)return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const n=parseInt(s[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function(t,e){const i=t.split("\n"),n=[],r=Math.max(e-6,0),s=Math.min(e+6,i.length);for(let t=r;t<s;t++){const r=t+1;n.push(`${r===e?">":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function Dh(t,e){const i=function(t){oi._getMatrix(Ph,oi.workingColorSpace,t);const e=`mat3( ${Ph.elements.map(t=>t.toFixed(4))} )`;switch(oi.getTransfer(t)){case me:return[e,"LinearTransferOETF"];case ge:return[e,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}(e);return[`vec4 ${t}( vec4 value ) {`,`\treturn ${i[1]}( vec4( value.rgb * ${i[0]}, value.a ) );`,"}"].join("\n")}const Ih={[G]:"Linear",[W]:"Reinhard",[X]:"Cineon",[j]:"ACESFilmic",[Y]:"AgX",[Z]:"Neutral",[q]:"Custom"};function Nh(t,e){const i=Ih[e];return void 0===i?(Ue("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}const Uh=new Qe;function Oh(){oi.getLuminanceCoefficients(Uh);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Uh.x.toFixed(4)}, ${Uh.y.toFixed(4)}, ${Uh.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function Fh(t){return""!==t}function zh(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Bh(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const kh=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vh(t){return t.replace(kh,Gh)}const Hh=new Map;function Gh(t,e){let i=Vo[e];if(void 0===i){const t=Hh.get(e);if(void 0===t)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");i=Vo[t],Ue('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Vh(i)}const Wh=/#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 Xh(t){return t.replace(Wh,jh)}function jh(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function qh(t){let e=`precision ${t.precision} float;\n\tprecision ${t.precision} int;\n\tprecision ${t.precision} sampler2D;\n\tprecision ${t.precision} samplerCube;\n\tprecision ${t.precision} sampler3D;\n\tprecision ${t.precision} sampler2DArray;\n\tprecision ${t.precision} sampler2DShadow;\n\tprecision ${t.precision} samplerCubeShadow;\n\tprecision ${t.precision} sampler2DArrayShadow;\n\tprecision ${t.precision} isampler2D;\n\tprecision ${t.precision} isampler3D;\n\tprecision ${t.precision} isamplerCube;\n\tprecision ${t.precision} isampler2DArray;\n\tprecision ${t.precision} usampler2D;\n\tprecision ${t.precision} usampler3D;\n\tprecision ${t.precision} usamplerCube;\n\tprecision ${t.precision} usampler2DArray;\n\t`;return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}const Yh={[h]:"SHADOWMAP_TYPE_PCF",[c]:"SHADOWMAP_TYPE_VSM"};const Zh={[K]:"ENVMAP_TYPE_CUBE",[J]:"ENVMAP_TYPE_CUBE",[tt]:"ENVMAP_TYPE_CUBE_UV"};const Kh={[J]:"ENVMAP_MODE_REFRACTION"};const Jh={[k]:"ENVMAP_BLENDING_MULTIPLY",[V]:"ENVMAP_BLENDING_MIX",[H]:"ENVMAP_BLENDING_ADD"};function $h(t,e,i,n){const r=t.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const l=function(t){return Yh[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}(i),h=function(t){return!1===t.envMap?"ENVMAP_TYPE_CUBE":Zh[t.envMapMode]||"ENVMAP_TYPE_CUBE"}(i),c=function(t){return!1===t.envMap?"ENVMAP_MODE_REFLECTION":Kh[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}(i),u=function(t){return!1===t.envMap?"ENVMAP_BLENDING_NONE":Jh[t.combine]||"ENVMAP_BLENDING_NONE"}(i),d=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const i=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),p=function(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fh).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),m=r.createProgram();let g,_,v=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(Fh).join("\n"),g.length>0&&(g+="\n"),_=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f].filter(Fh).join("\n"),_.length>0&&(_+="\n")):(g=[qh(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",i.batching?"#define USE_BATCHING":"",i.batchingColor?"#define USE_BATCHING_COLOR":"",i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.instancingMorph?"#define USE_INSTANCING_MORPH":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexNormals?"#define HAS_NORMAL":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.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(Fh).join("\n"),_=[qh(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,f,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+c:"",i.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.dispersion?"#define USE_DISPERSION":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas||i.batchingColor?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+l:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",i.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",i.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Vo.tonemapping_pars_fragment:"",0!==i.toneMapping?Nh("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Vo.colorspace_pars_fragment,Dh("linearToOutputTexel",i.outputColorSpace),Oh(),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Fh).join("\n")),a=Vh(a),a=zh(a,i),a=Bh(a,i),o=Vh(o),o=zh(o,i),o=Bh(o,i),a=Xh(a),o=Xh(o),!0!==i.isRawShaderMaterial&&(v="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Ae?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Ae?"":"#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"+_);const x=v+g+a,y=v+_+o,M=Rh(r,r.VERTEX_SHADER,x),S=Rh(r,r.FRAGMENT_SHADER,y);function b(e){if(t.debug.checkShaderErrors){const i=r.getProgramInfoLog(m)||"",n=r.getShaderInfoLog(M)||"",s=r.getShaderInfoLog(S)||"",a=i.trim(),o=n.trim(),l=s.trim();let h=!0,c=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(h=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(r,m,M,S);else{const t=Lh(r,M,"vertex"),i=Lh(r,S,"fragment");Oe("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+e.name+"\nMaterial Type: "+e.type+"\n\nProgram Info Log: "+a+"\n"+t+"\n"+i)}else""!==a?Ue("WebGLProgram: Program Info Log:",a):""!==o&&""!==l||(c=!1);c&&(e.diagnostics={runnable:h,programLog:a,vertexShader:{log:o,prefix:g},fragmentShader:{log:l,prefix:_}})}r.deleteShader(M),r.deleteShader(S),E=new Ah(r,m),T=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r),s=n.name;let a=1;n.type===t.FLOAT_MAT2&&(a=2),n.type===t.FLOAT_MAT3&&(a=3),n.type===t.FLOAT_MAT4&&(a=4),i[s]={type:n.type,location:t.getAttribLocation(e,s),locationSize:a}}return i}(r,m)}let E,T;r.attachShader(m,M),r.attachShader(m,S),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.hasPositionAttribute&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),this.getUniforms=function(){return void 0===E&&b(this),E},this.getAttributes=function(){return void 0===T&&b(this),T};let w=!1===i.rendererExtensionParallelShaderCompile;return this.isReady=function(){return!1===w&&(w=r.getProgramParameter(m,37297)),w},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Ch++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=M,this.fragmentShader=S,this}let Qh=0;class tc{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,i){const n=this._getShaderCacheForMaterial(t);return!1===n.has(e)&&(n.add(e),e.usedTimes++),!1===n.has(i)&&(n.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let i=e.get(t);return void 0===i&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return void 0===i&&(i=new ec(t),e.set(t,i)),i}}class ec{constructor(t){this.id=Qh++,this.code=t,this.usedTimes=0}}function ic(t,e,i,n,r,s){const a=new Ni,o=new tc,l=new Set,h=[],c=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function f(t){return l.add(t),0===t?"uv":`uv${t}`}return{getParameters:function(r,a,h,c,m,g){const _=c.fog,v=m.geometry,x=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?c.environment:null,y=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,M=e.get(r.envMap||x,y),S=M&&M.mapping===tt?M.image.height:null,b=p[r.type];null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&Ue("WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead."));const E=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=void 0!==E?E.length:0;let w,A,R,C,P=0;if(void 0!==v.morphAttributes.position&&(P=1),void 0!==v.morphAttributes.normal&&(P=2),void 0!==v.morphAttributes.color&&(P=3),b){const t=Go[b];w=t.vertexShader,A=t.fragmentShader}else{w=r.vertexShader,A=r.fragmentShader;const t=o.getVertexShaderStage(r),e=o.getFragmentShaderStage(r);o.update(r,t,e),R=t.id,C=e.id}const L=t.getRenderTarget(),D=t.state.buffers.depth.getReversed(),I=!0===m.isInstancedMesh,N=!0===m.isBatchedMesh,U=!!r.map,O=!!r.matcap,F=!!M,z=!!r.aoMap,B=!!r.lightMap,k=!!r.bumpMap&&!1===r.wireframe,V=!!r.normalMap,H=!!r.displacementMap,G=!!r.emissiveMap,W=!!r.metalnessMap,X=!!r.roughnessMap,j=r.anisotropy>0,q=r.clearcoat>0,Y=r.dispersion>0,Z=r.iridescence>0,K=r.sheen>0,J=r.transmission>0,$=j&&!!r.anisotropyMap,Q=q&&!!r.clearcoatMap,et=q&&!!r.clearcoatNormalMap,it=q&&!!r.clearcoatRoughnessMap,nt=Z&&!!r.iridescenceMap,rt=Z&&!!r.iridescenceThicknessMap,st=K&&!!r.sheenColorMap,at=K&&!!r.sheenRoughnessMap,ot=!!r.specularMap,lt=!!r.specularColorMap,ht=!!r.specularIntensityMap,ct=J&&!!r.transmissionMap,ut=J&&!!r.thicknessMap,dt=!!r.gradientMap,pt=!!r.alphaMap,ft=r.alphaTest>0,mt=!!r.alphaHash,gt=!!r.extensions;let _t=0;r.toneMapped&&(null!==L&&!0!==L.isXRRenderTarget||(_t=t.toneMapping));const vt={shaderID:b,shaderType:r.type,shaderName:r.name,vertexShader:w,fragmentShader:A,defines:r.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,batching:N,batchingColor:N&&null!==m._colorsTexture,instancing:I,instancingColor:I&&null!==m.instanceColor,instancingMorph:I&&null!==m.morphTexture,outputColorSpace:null===L?t.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:oi.workingColorSpace,alphaToCoverage:!!r.alphaToCoverage,map:U,matcap:O,envMap:F,envMapMode:F&&M.mapping,envMapCubeUVHeight:S,aoMap:z,lightMap:B,bumpMap:k,normalMap:V,displacementMap:H,emissiveMap:G,normalMapObjectSpace:V&&1===r.normalMapType,normalMapTangentSpace:V&&0===r.normalMapType,packedNormalMap:V&&0===r.normalMapType&&(xt=r.normalMap.format,xt===At||xt===Gt||xt===ce),metalnessMap:W,roughnessMap:X,anisotropy:j,anisotropyMap:$,clearcoat:q,clearcoatMap:Q,clearcoatNormalMap:et,clearcoatRoughnessMap:it,dispersion:Y,iridescence:Z,iridescenceMap:nt,iridescenceThicknessMap:rt,sheen:K,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:lt,specularIntensityMap:ht,transmission:J,transmissionMap:ct,thicknessMap:ut,gradientMap:dt,opaque:!1===r.transparent&&1===r.blending&&!1===r.alphaToCoverage,alphaMap:pt,alphaTest:ft,alphaHash:mt,combine:r.combine,mapUv:U&&f(r.map.channel),aoMapUv:z&&f(r.aoMap.channel),lightMapUv:B&&f(r.lightMap.channel),bumpMapUv:k&&f(r.bumpMap.channel),normalMapUv:V&&f(r.normalMap.channel),displacementMapUv:H&&f(r.displacementMap.channel),emissiveMapUv:G&&f(r.emissiveMap.channel),metalnessMapUv:W&&f(r.metalnessMap.channel),roughnessMapUv:X&&f(r.roughnessMap.channel),anisotropyMapUv:$&&f(r.anisotropyMap.channel),clearcoatMapUv:Q&&f(r.clearcoatMap.channel),clearcoatNormalMapUv:et&&f(r.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&f(r.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&f(r.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&f(r.iridescenceThicknessMap.channel),sheenColorMapUv:st&&f(r.sheenColorMap.channel),sheenRoughnessMapUv:at&&f(r.sheenRoughnessMap.channel),specularMapUv:ot&&f(r.specularMap.channel),specularColorMapUv:lt&&f(r.specularColorMap.channel),specularIntensityMapUv:ht&&f(r.specularIntensityMap.channel),transmissionMapUv:ct&&f(r.transmissionMap.channel),thicknessMapUv:ut&&f(r.thicknessMap.channel),alphaMapUv:pt&&f(r.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(V||j),vertexNormals:!!v.attributes.normal,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!v.attributes.color&&4===v.attributes.color.itemSize,pointsUvs:!0===m.isPoints&&!!v.attributes.uv&&(U||pt),fog:!!_,useFog:!0===r.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!1===r.wireframe&&(!0===r.flatShading||void 0===v.attributes.normal&&!1===V&&(r.isMeshLambertMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.isMeshPhysicalMaterial)),sizeAttenuation:!0===r.sizeAttenuation,logarithmicDepthBuffer:u,reversedDepthBuffer:D,skinning:!0===m.isSkinnedMesh,hasPositionAttribute:void 0!==v.attributes.position,morphTargets:void 0!==v.morphAttributes.position,morphNormals:void 0!==v.morphAttributes.normal,morphColors:void 0!==v.morphAttributes.color,morphTargetsCount:T,morphTextureStride:P,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numSpotLightMaps:a.spotLightMap.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numSpotLightShadowsWithMaps:a.numSpotLightShadowsWithMaps,numLightProbes:a.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,decodeVideoTexture:U&&!0===r.map.isVideoTexture&&oi.getTransfer(r.map.colorSpace)===ge,decodeVideoTextureEmissive:G&&!0===r.emissiveMap.isVideoTexture&&oi.getTransfer(r.emissiveMap.colorSpace)===ge,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,useDepthPacking:r.depthPacking>=0,depthPacking:r.depthPacking||0,index0AttributeName:r.index0AttributeName,extensionClipCullDistance:gt&&!0===r.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&!0===r.extensions.multiDraw||N)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:r.customProgramCacheKey()};var xt;return vt.vertexUv1s=l.has(1),vt.vertexUv2s=l.has(2),vt.vertexUv3s=l.has(3),l.clear(),vt},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){a.disableAll(),e.instancing&&a.enable(0);e.instancingColor&&a.enable(1);e.instancingMorph&&a.enable(2);e.matcap&&a.enable(3);e.envMap&&a.enable(4);e.normalMapObjectSpace&&a.enable(5);e.normalMapTangentSpace&&a.enable(6);e.clearcoat&&a.enable(7);e.iridescence&&a.enable(8);e.alphaTest&&a.enable(9);e.vertexColors&&a.enable(10);e.vertexAlphas&&a.enable(11);e.vertexUv1s&&a.enable(12);e.vertexUv2s&&a.enable(13);e.vertexUv3s&&a.enable(14);e.vertexTangents&&a.enable(15);e.anisotropy&&a.enable(16);e.alphaHash&&a.enable(17);e.batching&&a.enable(18);e.dispersion&&a.enable(19);e.batchingColor&&a.enable(20);e.gradientMap&&a.enable(21);e.packedNormalMap&&a.enable(22);e.vertexNormals&&a.enable(23);t.push(a.mask),a.disableAll(),e.fog&&a.enable(0);e.useFog&&a.enable(1);e.flatShading&&a.enable(2);e.logarithmicDepthBuffer&&a.enable(3);e.reversedDepthBuffer&&a.enable(4);e.skinning&&a.enable(5);e.morphTargets&&a.enable(6);e.morphNormals&&a.enable(7);e.morphColors&&a.enable(8);e.premultipliedAlpha&&a.enable(9);e.shadowMapEnabled&&a.enable(10);e.doubleSided&&a.enable(11);e.flipSided&&a.enable(12);e.useDepthPacking&&a.enable(13);e.dithering&&a.enable(14);e.transmission&&a.enable(15);e.sheen&&a.enable(16);e.opaque&&a.enable(17);e.pointsUvs&&a.enable(18);e.decodeVideoTexture&&a.enable(19);e.decodeVideoTextureEmissive&&a.enable(20);e.alphaToCoverage&&a.enable(21);e.numLightProbeGrids>0&&a.enable(22);e.hasPositionAttribute&&a.enable(23);t.push(a.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=p[t.type];let i;if(e){const t=Go[e];i=Ua.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n=c.get(i);return void 0!==n?++n.usedTimes:(n=new $h(t,i,e,r),h.push(n),c.set(i,n)),n},releaseProgram:function(t){if(0===--t.usedTimes){const e=h.indexOf(t);h[e]=h[h.length-1],h.pop(),c.delete(t.cacheKey),t.destroy()}},releaseShaderCache:function(t){o.remove(t)},programs:h,dispose:function(){o.dispose()}}}function nc(){let t=new WeakMap;return{has:function(e){return t.has(e)},get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function rc(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.materialVariant!==e.materialVariant?t.materialVariant-e.materialVariant:t.z!==e.z?t.z-e.z:t.id-e.id}function sc(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function ac(){const t=[];let e=0;const i=[],n=[],r=[];function s(t){let e=0;return t.isInstancedMesh&&(e+=2),t.isSkinnedMesh&&(e+=1),e}function a(i,n,r,a,o,l){let h=t[e];return void 0===h?(h={id:i.id,object:i,geometry:n,material:r,materialVariant:s(i),groupOrder:a,renderOrder:i.renderOrder,z:o,group:l},t[e]=h):(h.id=i.id,h.object=i,h.geometry=n,h.material=r,h.materialVariant=s(i),h.groupOrder=a,h.renderOrder=i.renderOrder,h.z=o,h.group=l),e++,h}return{opaque:i,transmissive:n,transparent:r,init:function(){e=0,i.length=0,n.length=0,r.length=0},push:function(t,e,s,o,l,h){const c=a(t,e,s,o,l,h);s.transmission>0?n.push(c):!0===s.transparent?r.push(c):i.push(c)},unshift:function(t,e,s,o,l,h){const c=a(t,e,s,o,l,h);s.transmission>0?n.unshift(c):!0===s.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=e,n=t.length;i<n;i++){const e=t[i];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e,s){i.length>1&&i.sort(t||rc),n.length>1&&n.sort(e||sc),r.length>1&&r.sort(e||sc),s&&(i.reverse(),n.reverse(),r.reverse())}}}function oc(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new ac,t.set(e,[r])):i>=n.length?(r=new ac,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function lc(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Qe,color:new sn};break;case"SpotLight":i={position:new Qe,direction:new Qe,color:new sn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Qe,color:new sn,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Qe,skyColor:new sn,groundColor:new sn};break;case"RectAreaLight":i={color:new sn,position:new Qe,halfWidth:new Qe,halfHeight:new Qe}}return t[e.id]=i,i}}}let hc=0;function cc(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function uc(t){const e=new lc,i=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je};break;case"PointLight":i={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Je,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),n={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 t=0;t<9;t++)n.probe.push(new Qe);const r=new Qe,s=new bi,a=new bi;return{setup:function(r){let s=0,a=0,o=0;for(let t=0;t<9;t++)n.probe[t].set(0,0,0);let l=0,h=0,c=0,u=0,d=0,p=0,f=0,m=0,g=0,_=0,v=0;r.sort(cc);for(let t=0,x=r.length;t<x;t++){const x=r[t],y=x.color,M=x.intensity,S=x.distance;let b=null;if(x.shadow&&x.shadow.map&&(b=x.shadow.map.texture.format===At?x.shadow.map.texture:x.shadow.map.depthTexture||x.shadow.map.texture),x.isAmbientLight)s+=y.r*M,a+=y.g*M,o+=y.b*M;else if(x.isLightProbe){for(let t=0;t<9;t++)n.probe[t].addScaledVector(x.sh.coefficients[t],M);v++}else if(x.isDirectionalLight){const t=e.get(x);if(t.color.copy(x.color).multiplyScalar(x.intensity),x.castShadow){const t=x.shadow,e=i.get(x);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,n.directionalShadow[l]=e,n.directionalShadowMap[l]=b,n.directionalShadowMatrix[l]=x.shadow.matrix,p++}n.directional[l]=t,l++}else if(x.isSpotLight){const t=e.get(x);t.position.setFromMatrixPosition(x.matrixWorld),t.color.copy(y).multiplyScalar(M),t.distance=S,t.coneCos=Math.cos(x.angle),t.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),t.decay=x.decay,n.spot[c]=t;const r=x.shadow;if(x.map&&(n.spotLightMap[g]=x.map,g++,r.updateMatrices(x),x.castShadow&&_++),n.spotLightMatrix[c]=r.matrix,x.castShadow){const t=i.get(x);t.shadowIntensity=r.intensity,t.shadowBias=r.bias,t.shadowNormalBias=r.normalBias,t.shadowRadius=r.radius,t.shadowMapSize=r.mapSize,n.spotShadow[c]=t,n.spotShadowMap[c]=b,m++}c++}else if(x.isRectAreaLight){const t=e.get(x);t.color.copy(y).multiplyScalar(M),t.halfWidth.set(.5*x.width,0,0),t.halfHeight.set(0,.5*x.height,0),n.rectArea[u]=t,u++}else if(x.isPointLight){const t=e.get(x);if(t.color.copy(x.color).multiplyScalar(x.intensity),t.distance=x.distance,t.decay=x.decay,x.castShadow){const t=x.shadow,e=i.get(x);e.shadowIntensity=t.intensity,e.shadowBias=t.bias,e.shadowNormalBias=t.normalBias,e.shadowRadius=t.radius,e.shadowMapSize=t.mapSize,e.shadowCameraNear=t.camera.near,e.shadowCameraFar=t.camera.far,n.pointShadow[h]=e,n.pointShadowMap[h]=b,n.pointShadowMatrix[h]=x.shadow.matrix,f++}n.point[h]=t,h++}else if(x.isHemisphereLight){const t=e.get(x);t.skyColor.copy(x.color).multiplyScalar(M),t.groundColor.copy(x.groundColor).multiplyScalar(M),n.hemi[d]=t,d++}}u>0&&(!0===t.has("OES_texture_float_linear")?(n.rectAreaLTC1=Ho.LTC_FLOAT_1,n.rectAreaLTC2=Ho.LTC_FLOAT_2):(n.rectAreaLTC1=Ho.LTC_HALF_1,n.rectAreaLTC2=Ho.LTC_HALF_2)),n.ambient[0]=s,n.ambient[1]=a,n.ambient[2]=o;const x=n.hash;x.directionalLength===l&&x.pointLength===h&&x.spotLength===c&&x.rectAreaLength===u&&x.hemiLength===d&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===v||(n.directional.length=l,n.spot.length=c,n.rectArea.length=u,n.point.length=h,n.hemi.length=d,n.directionalShadow.length=p,n.directionalShadowMap.length=p,n.pointShadow.length=f,n.pointShadowMap.length=f,n.spotShadow.length=m,n.spotShadowMap.length=m,n.directionalShadowMatrix.length=p,n.pointShadowMatrix.length=f,n.spotLightMatrix.length=m+g-_,n.spotLightMap.length=g,n.numSpotLightShadowsWithMaps=_,n.numLightProbes=v,x.directionalLength=l,x.pointLength=h,x.spotLength=c,x.rectAreaLength=u,x.hemiLength=d,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=v,n.version=hc++)},setupView:function(t,e){let i=0,o=0,l=0,h=0,c=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=n.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=n.spot[l];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),r.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(r),t.direction.transformDirection(u),l++}else if(d.isRectAreaLight){const t=n.rectArea[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),s.copy(d.matrixWorld),s.premultiply(u),a.extractRotation(s),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(d.isPointLight){const t=n.point[o];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),o++}else if(d.isHemisphereLight){const t=n.hemi[c];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),c++}}},state:n}}function dc(t){const e=new uc(t),i=[],n=[],r=[];const s={lightsArray:i,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:function(t){s.camera=t,i.length=0,n.length=0,r.length=0},state:s,setupLights:function(){e.setup(i)},setupLightsView:function(t){e.setupView(i,t)},pushLight:function(t){i.push(t)},pushShadow:function(t){n.push(t)},pushLightProbeGrid:function(t){r.push(t)}}}function pc(t){let e=new WeakMap;return{get:function(i,n=0){const r=e.get(i);let s;return void 0===r?(s=new dc(t),e.set(i,[s])):n>=r.length?(s=new dc(t),r.push(s)):s=r[n],s},dispose:function(){e=new WeakMap}}}const fc=[new Qe(1,0,0),new Qe(-1,0,0),new Qe(0,1,0),new Qe(0,-1,0),new Qe(0,0,1),new Qe(0,0,-1)],mc=[new Qe(0,-1,0),new Qe(0,-1,0),new Qe(0,0,1),new Qe(0,0,-1),new Qe(0,-1,0),new Qe(0,-1,0)],gc=new bi,_c=new Qe,vc=new Qe;function xc(t,e,i){let n=new Qr;const r=new Je,s=new Je,a=new vi,o=new Va,l=new Ha,h={},c=i.maxTextureSize,f={[u]:1,[d]:0,[p]:2},m=new Oa({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Je},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;\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 = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\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 = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\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( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const _=new er;_.setAttribute("position",new kn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Gr(_,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let y=this.type;function M(i,n){const s=e.update(v);m.defines.VSM_SAMPLES!==i.blurSamples&&(m.defines.VSM_SAMPLES=i.blurSamples,g.defines.VSM_SAMPLES=i.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new yi(r.x,r.y,{format:At,type:_t})),m.uniforms.shadow_pass.value=i.map.depthTexture,m.uniforms.resolution.value=i.mapSize,m.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,s,m,v,null),g.uniforms.shadow_pass.value=i.mapPass.texture,g.uniforms.resolution.value=i.mapSize,g.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,s,g,v,null)}function S(e,i,n,r){let s=null;const a=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===n.isPointLight?l:o,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0||!0===i.alphaToCoverage){const t=s.uuid,e=i.uuid;let n=h[t];void 0===n&&(n={},h[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r,i.addEventListener("dispose",E)),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:f[i.side],s.alphaMap=i.alphaMap,s.alphaTest=!0===i.alphaToCoverage?.5:i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function b(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),l=i.material;if(Array.isArray(l)){const e=n.groups;for(let h=0,c=e.length;h<c;h++){const c=e[h],u=l[c.materialIndex];if(u&&u.visible){const e=S(i,u,a,o);i.onBeforeShadow(t,i,r,s,n,e,c),t.renderBufferDirect(s,null,n,e,i,c),i.onAfterShadow(t,i,r,s,n,e,c)}}}else if(l.visible){const e=S(i,l,a,o);i.onBeforeShadow(t,i,r,s,n,e,null),t.renderBufferDirect(s,null,n,e,i,null),i.onAfterShadow(t,i,r,s,n,e,null)}}const l=i.children;for(let t=0,e=l.length;t<e;t++)b(l[t],r,s,a,o)}function E(t){t.target.removeEventListener("dispose",E);for(const e in h){const i=h[e],n=t.target.uuid;if(n in i){i[n].dispose(),delete i[n]}}}this.render=function(e,i,o){if(!1===x.enabled)return;if(!1===x.autoUpdate&&!1===x.needsUpdate)return;if(0===e.length)return;2===this.type&&(Ue("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=1);const l=t.getRenderTarget(),h=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),!0===d.buffers.depth.getReversed()?d.buffers.color.setClear(0,0,0,0):d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);const p=y!==this.type;p&&i.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(t=>t.needsUpdate=!0):t.material.needsUpdate=!0)});for(let l=0,h=e.length;l<h;l++){const h=e[l],u=h.shadow;if(void 0===u){Ue("WebGLShadowMap:",h,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const f=u.getFrameExtents();r.multiply(f),s.copy(u.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(s.x=Math.floor(c/f.x),r.x=s.x*f.x,u.mapSize.x=s.x),r.y>c&&(s.y=Math.floor(c/f.y),r.y=s.y*f.y,u.mapSize.y=s.y));const m=t.state.buffers.depth.getReversed();if(u.camera._reversedDepth=m,null===u.map||!0===p){if(null!==u.map&&(null!==u.map.depthTexture&&(u.map.depthTexture.dispose(),u.map.depthTexture=null),u.map.dispose()),3===this.type){if(h.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}u.map=new yi(r.x,r.y,{format:At,type:_t,minFilter:ot,magFilter:ot,generateMipmaps:!1}),u.map.texture.name=h.name+".shadowMap",u.map.depthTexture=new Ss(r.x,r.y,gt),u.map.depthTexture.name=h.name+".shadowMapDepth",u.map.depthTexture.format=Et,u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=rt,u.map.depthTexture.magFilter=rt}else h.isPointLight?(u.map=new pl(r.x),u.map.depthTexture=new bs(r.x,mt)):(u.map=new yi(r.x,r.y),u.map.depthTexture=new Ss(r.x,r.y,mt)),u.map.depthTexture.name=h.name+".shadowMap",u.map.depthTexture.format=Et,1===this.type?(u.map.depthTexture.compareFunction=m?518:515,u.map.depthTexture.minFilter=ot,u.map.depthTexture.magFilter=ot):(u.map.depthTexture.compareFunction=null,u.map.depthTexture.minFilter=rt,u.map.depthTexture.magFilter=rt);u.camera.updateProjectionMatrix()}const g=u.map.isWebGLCubeRenderTarget?6:1;for(let e=0;e<g;e++){if(u.map.isWebGLCubeRenderTarget)t.setRenderTarget(u.map,e),t.clear();else{0===e&&(t.setRenderTarget(u.map),t.clear());const i=u.getViewport(e);a.set(s.x*i.x,s.y*i.y,s.x*i.z,s.y*i.w),d.viewport(a)}if(h.isPointLight){const t=u.camera,i=u.matrix,n=h.distance||t.far;n!==t.far&&(t.far=n,t.updateProjectionMatrix()),_c.setFromMatrixPosition(h.matrixWorld),t.position.copy(_c),vc.copy(t.position),vc.add(fc[e]),t.up.copy(mc[e]),t.lookAt(vc),t.updateMatrixWorld(),i.makeTranslation(-_c.x,-_c.y,-_c.z),gc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),u._frustum.setFromProjectionMatrix(gc,t.coordinateSystem,t.reversedDepth)}else u.updateMatrices(h);n=u.getFrustum(),b(i,o,u.camera,h,this.type)}!0!==u.isPointLightShadow&&3===this.type&&M(u,o),u.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(l,h,u)}}function yc(t,e){const i=new function(){let e=!1;const i=new vi;let n=null;const r=new vi(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,a,o){!0===o&&(e*=a,n*=a,s*=a),i.set(e,n,s,a),!1===r.equals(i)&&(t.clearColor(e,n,s,a),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},n=new function(){let i=!1,n=!1,r=null,s=null,a=null;return{setReversed:function(t){if(n!==t){const i=e.get("EXT_clip_control");t?i.clipControlEXT(i.LOWER_LEFT_EXT,i.ZERO_TO_ONE_EXT):i.clipControlEXT(i.LOWER_LEFT_EXT,i.NEGATIVE_ONE_TO_ONE_EXT),n=t;const r=a;a=null,this.setClear(r)}},getReversed:function(){return n},setTest:function(e){e?st(t.DEPTH_TEST):at(t.DEPTH_TEST)},setMask:function(e){r===e||i||(t.depthMask(e),r=e)},setFunc:function(e){if(n&&(e=ze[e]),s!==e){switch(e){case 0:t.depthFunc(t.NEVER);break;case 1:t.depthFunc(t.ALWAYS);break;case 2:t.depthFunc(t.LESS);break;case 3:default:t.depthFunc(t.LEQUAL);break;case 4:t.depthFunc(t.EQUAL);break;case 5:t.depthFunc(t.GEQUAL);break;case 6:t.depthFunc(t.GREATER);break;case 7:t.depthFunc(t.NOTEQUAL)}s=e}},setLocked:function(t){i=t},setClear:function(e){a!==e&&(a=e,n&&(e=1-e),t.clearDepth(e))},reset:function(){i=!1,r=null,s=null,a=null,n=!1}}},r=new function(){let e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(i){e||(i?st(t.STENCIL_TEST):at(t.STENCIL_TEST))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,a){n===e&&r===i&&s===a||(t.stencilFunc(e,i,a),n=e,r=i,s=a)},setOp:function(e,i,n){a===e&&o===i&&l===n||(t.stencilOp(e,i,n),a=e,o=i,l=n)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,a=null,o=null,l=null,h=null}}},s=new WeakMap,a=new WeakMap;let o={},l={},h={},c=new WeakMap,u=[],d=null,p=!1,D=null,I=null,N=null,U=null,O=null,F=null,z=null,B=new sn(0,0,0),k=0,V=!1,H=null,G=null,W=null,X=null,j=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,Z=0;const K=t.getParameter(t.VERSION);-1!==K.indexOf("WebGL")?(Z=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=Z>=1):-1!==K.indexOf("OpenGL ES")&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=Z>=2);let J=null,$={};const Q=t.getParameter(t.SCISSOR_BOX),tt=t.getParameter(t.VIEWPORT),et=(new vi).fromArray(Q),it=(new vi).fromArray(tt);function nt(e,i,n,r){const s=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let a=0;a<n;a++)e===t.TEXTURE_3D||e===t.TEXTURE_2D_ARRAY?t.texImage3D(i,0,t.RGBA,1,1,r,0,t.RGBA,t.UNSIGNED_BYTE,s):t.texImage2D(i+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,s);return a}const rt={};function st(e){!0!==o[e]&&(t.enable(e),o[e]=!0)}function at(e){!1!==o[e]&&(t.disable(e),o[e]=!1)}rt[t.TEXTURE_2D]=nt(t.TEXTURE_2D,t.TEXTURE_2D,1),rt[t.TEXTURE_CUBE_MAP]=nt(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[t.TEXTURE_2D_ARRAY]=nt(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),rt[t.TEXTURE_3D]=nt(t.TEXTURE_3D,t.TEXTURE_3D,1,1),i.setClear(0,0,0,1),n.setClear(1),r.setClear(0),st(t.DEPTH_TEST),n.setFunc(3),ct(!1),ut(1),st(t.CULL_FACE),ht(0);const ot={[f]:t.FUNC_ADD,[m]:t.FUNC_SUBTRACT,[g]:t.FUNC_REVERSE_SUBTRACT};ot[103]=t.MIN,ot[104]=t.MAX;const lt={[_]:t.ZERO,[v]:t.ONE,[x]:t.SRC_COLOR,[M]:t.SRC_ALPHA,[A]:t.SRC_ALPHA_SATURATE,[T]:t.DST_COLOR,[b]:t.DST_ALPHA,[y]:t.ONE_MINUS_SRC_COLOR,[S]:t.ONE_MINUS_SRC_ALPHA,[w]:t.ONE_MINUS_DST_COLOR,[E]:t.ONE_MINUS_DST_ALPHA,[R]:t.CONSTANT_COLOR,[C]:t.ONE_MINUS_CONSTANT_COLOR,[P]:t.CONSTANT_ALPHA,[L]:t.ONE_MINUS_CONSTANT_ALPHA};function ht(e,i,n,r,s,a,o,l,h,c){if(0!==e){if(!1===p&&(st(t.BLEND),p=!0),5===e)s=s||i,a=a||n,o=o||r,i===I&&s===O||(t.blendEquationSeparate(ot[i],ot[s]),I=i,O=s),n===N&&r===U&&a===F&&o===z||(t.blendFuncSeparate(lt[n],lt[r],lt[a],lt[o]),N=n,U=r,F=a,z=o),!1!==l.equals(B)&&h===k||(t.blendColor(l.r,l.g,l.b,h),B.copy(l),k=h),D=e,V=!1;else if(e!==D||c!==V){if(I===f&&O===f||(t.blendEquation(t.FUNC_ADD),I=f,O=f),c)switch(e){case 1:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFunc(t.ONE,t.ONE);break;case 3:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case 4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Oe("WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case 2:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case 3:Oe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case 4:Oe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Oe("WebGLState: Invalid blending: ",e)}N=null,U=null,F=null,z=null,B.set(0,0,0),k=0,D=e,V=c}}else!0===p&&(at(t.BLEND),p=!1)}function ct(e){H!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),H=e)}function ut(e){0!==e?(st(t.CULL_FACE),e!==G&&(1===e?t.cullFace(t.BACK):2===e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):at(t.CULL_FACE),G=e}function dt(e,i,r){e?(st(t.POLYGON_OFFSET_FILL),X===i&&j===r||(X=i,j=r,n.getReversed()&&(i=-i),t.polygonOffset(i,r))):at(t.POLYGON_OFFSET_FILL)}return{buffers:{color:i,depth:n,stencil:r},enable:st,disable:at,bindFramebuffer:function(e,i){return h[e]!==i&&(t.bindFramebuffer(e,i),h[e]=i,e===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=i),e===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(e,i){let n=u,r=!1;if(e){n=c.get(i),void 0===n&&(n=[],c.set(i,n));const s=e.textures;if(n.length!==s.length||n[0]!==t.COLOR_ATTACHMENT0){for(let e=0,i=s.length;e<i;e++)n[e]=t.COLOR_ATTACHMENT0+e;n.length=s.length,r=!0}}else n[0]!==t.BACK&&(n[0]=t.BACK,r=!0);r&&t.drawBuffers(n)},useProgram:function(e){return d!==e&&(t.useProgram(e),d=e,!0)},setBlending:ht,setMaterial:function(e,s){2===e.side?at(t.CULL_FACE):st(t.CULL_FACE);let a=1===e.side;s&&(a=!a),ct(a),1===e.blending&&!1===e.transparent?ht(0):ht(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.blendColor,e.blendAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);const o=e.stencilWrite;r.setTest(o),o&&(r.setMask(e.stencilWriteMask),r.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),r.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),dt(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?st(t.SAMPLE_ALPHA_TO_COVERAGE):at(t.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:ct,setCullFace:ut,setLineWidth:function(e){e!==W&&(Y&&t.lineWidth(e),W=e)},setPolygonOffset:dt,setScissorTest:function(e){e?st(t.SCISSOR_TEST):at(t.SCISSOR_TEST)},activeTexture:function(e){void 0===e&&(e=t.TEXTURE0+q-1),J!==e&&(t.activeTexture(e),J=e)},bindTexture:function(e,i,n){void 0===n&&(n=null===J?t.TEXTURE0+q-1:J);let r=$[n];void 0===r&&(r={type:void 0,texture:void 0},$[n]=r),r.type===e&&r.texture===i||(J!==n&&(t.activeTexture(n),J=n),t.bindTexture(e,i||rt[e]),r.type=e,r.texture=i)},unbindTexture:function(){const e=$[J];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D(...arguments)}catch(t){Oe("WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D(...arguments)}catch(t){Oe("WebGLState:",t)}},texImage2D:function(){try{t.texImage2D(...arguments)}catch(t){Oe("WebGLState:",t)}},texImage3D:function(){try{t.texImage3D(...arguments)}catch(t){Oe("WebGLState:",t)}},pixelStorei:function(e,i){l[e]!==i&&(t.pixelStorei(e,i),l[e]=i)},getParameter:function(e){return void 0!==l[e]?l[e]:t.getParameter(e)},updateUBOMapping:function(e,i){let n=a.get(i);void 0===n&&(n=new WeakMap,a.set(i,n));let r=n.get(e);void 0===r&&(r=t.getUniformBlockIndex(i,e.name),n.set(e,r))},uniformBlockBinding:function(e,i){const n=a.get(i).get(e);s.get(i)!==n&&(t.uniformBlockBinding(i,n,e.__bindingPointIndex),s.set(i,n))},texStorage2D:function(){try{t.texStorage2D(...arguments)}catch(t){Oe("WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D(...arguments)}catch(t){Oe("WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D(...arguments)}catch(t){Oe("WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D(...arguments)}catch(t){Oe("WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D(...arguments)}catch(t){Oe("WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D(...arguments)}catch(t){Oe("WebGLState:",t)}},scissor:function(e){!1===et.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),et.copy(e))},viewport:function(e){!1===it.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),it.copy(e))},reset:function(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),n.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),t.pixelStorei(t.PACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_ALIGNMENT,4),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.BROWSER_DEFAULT_WEBGL),t.pixelStorei(t.PACK_ROW_LENGTH,0),t.pixelStorei(t.PACK_SKIP_PIXELS,0),t.pixelStorei(t.PACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),o={},l={},J=null,$={},h={},c=new WeakMap,u=[],d=null,p=!1,D=null,I=null,N=null,U=null,O=null,F=null,z=null,B=new sn(0,0,0),k=0,V=!1,H=null,G=null,W=null,X=null,j=null,et.set(0,0,t.canvas.width,t.canvas.height),it.set(0,0,t.canvas.width,t.canvas.height),i.reset(),n.reset(),r.reset()}}}function Mc(t,e,i,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),h=new Je,c=new WeakMap,u=new Set;let d;const p=new WeakMap;let f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):Pe("canvas")}function g(t,e,i){let n=1;const r=W(t);if((r.width>i||r.height>i)&&(n=i/Math.max(r.width,r.height)),n<1){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&t instanceof VideoFrame){const i=Math.floor(n*r.width),s=Math.floor(n*r.height);void 0===d&&(d=m(i,s));const a=e?m(i,s):d;a.width=i,a.height=s;return a.getContext("2d").drawImage(t,0,0,i,s),Ue("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+i+"x"+s+")."),a}return"data"in t&&Ue("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),t}return t}function _(t){return t.generateMipmaps}function v(e){t.generateMipmap(e)}function x(e){return e.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:e.isWebGL3DRenderTarget?t.TEXTURE_3D:e.isWebGLArrayRenderTarget||e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function y(i,n,r,s,a,o=!1){if(null!==i){if(void 0!==t[i])return t[i];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l;s&&(l=e.get("EXT_texture_norm16"),l||Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let h=n;if(n===t.RED&&(r===t.FLOAT&&(h=t.R32F),r===t.HALF_FLOAT&&(h=t.R16F),r===t.UNSIGNED_BYTE&&(h=t.R8),r===t.UNSIGNED_SHORT&&l&&(h=l.R16_EXT),r===t.SHORT&&l&&(h=l.R16_SNORM_EXT)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.R8UI),r===t.UNSIGNED_SHORT&&(h=t.R16UI),r===t.UNSIGNED_INT&&(h=t.R32UI),r===t.BYTE&&(h=t.R8I),r===t.SHORT&&(h=t.R16I),r===t.INT&&(h=t.R32I)),n===t.RG&&(r===t.FLOAT&&(h=t.RG32F),r===t.HALF_FLOAT&&(h=t.RG16F),r===t.UNSIGNED_BYTE&&(h=t.RG8),r===t.UNSIGNED_SHORT&&l&&(h=l.RG16_EXT),r===t.SHORT&&l&&(h=l.RG16_SNORM_EXT)),n===t.RG_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RG8UI),r===t.UNSIGNED_SHORT&&(h=t.RG16UI),r===t.UNSIGNED_INT&&(h=t.RG32UI),r===t.BYTE&&(h=t.RG8I),r===t.SHORT&&(h=t.RG16I),r===t.INT&&(h=t.RG32I)),n===t.RGB_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RGB8UI),r===t.UNSIGNED_SHORT&&(h=t.RGB16UI),r===t.UNSIGNED_INT&&(h=t.RGB32UI),r===t.BYTE&&(h=t.RGB8I),r===t.SHORT&&(h=t.RGB16I),r===t.INT&&(h=t.RGB32I)),n===t.RGBA_INTEGER&&(r===t.UNSIGNED_BYTE&&(h=t.RGBA8UI),r===t.UNSIGNED_SHORT&&(h=t.RGBA16UI),r===t.UNSIGNED_INT&&(h=t.RGBA32UI),r===t.BYTE&&(h=t.RGBA8I),r===t.SHORT&&(h=t.RGBA16I),r===t.INT&&(h=t.RGBA32I)),n===t.RGB&&(r===t.UNSIGNED_SHORT&&l&&(h=l.RGB16_EXT),r===t.SHORT&&l&&(h=l.RGB16_SNORM_EXT),r===t.UNSIGNED_INT_5_9_9_9_REV&&(h=t.RGB9_E5),r===t.UNSIGNED_INT_10F_11F_11F_REV&&(h=t.R11F_G11F_B10F)),n===t.RGBA){const e=o?me:oi.getTransfer(a);r===t.FLOAT&&(h=t.RGBA32F),r===t.HALF_FLOAT&&(h=t.RGBA16F),r===t.UNSIGNED_BYTE&&(h=e===ge?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT&&l&&(h=l.RGBA16_EXT),r===t.SHORT&&l&&(h=l.RGBA16_SNORM_EXT),r===t.UNSIGNED_SHORT_4_4_4_4&&(h=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(h=t.RGB5_A1)}return h!==t.R16F&&h!==t.R32F&&h!==t.RG16F&&h!==t.RG32F&&h!==t.RGBA16F&&h!==t.RGBA32F||e.get("EXT_color_buffer_float"),h}function M(e,i){let n;return e?null===i||i===mt||i===yt?n=t.DEPTH24_STENCIL8:i===gt?n=t.DEPTH32F_STENCIL8:i===pt&&(n=t.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===i||i===mt||i===yt?n=t.DEPTH_COMPONENT24:i===gt?n=t.DEPTH_COMPONENT32F:i===pt&&(n=t.DEPTH_COMPONENT16),n}function S(t,e){return!0===_(t)||t.isFramebufferTexture&&t.minFilter!==rt&&t.minFilter!==ot?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function b(t){const e=t.target;e.removeEventListener("dispose",b),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=p.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&T(t),0===Object.keys(r).length&&p.delete(i)}n.remove(t)}(e),e.isVideoTexture&&c.delete(e),e.isHTMLTexture&&u.delete(e)}function E(e){const i=e.target;i.removeEventListener("dispose",E),function(e){const i=n.get(e);e.depthTexture&&(e.depthTexture.dispose(),n.remove(e.depthTexture));if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(i.__webglFramebuffer[e]))for(let n=0;n<i.__webglFramebuffer[e].length;n++)t.deleteFramebuffer(i.__webglFramebuffer[e][n]);else t.deleteFramebuffer(i.__webglFramebuffer[e]);i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e])}else{if(Array.isArray(i.__webglFramebuffer))for(let e=0;e<i.__webglFramebuffer.length;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer);if(i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}const r=e.textures;for(let e=0,i=r.length;e<i;e++){const i=n.get(r[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),a.memory.textures--),n.remove(r[e])}n.remove(e)}(i)}function T(e){const i=n.get(e);t.deleteTexture(i.__webglTexture);const r=e.source;delete p.get(r)[i.__cacheKey],a.memory.textures--}let w=0;function A(e,r){const s=n.get(e);if(e.isVideoTexture&&function(t){const e=a.render.frame;c.get(t)!==e&&(c.set(t,e),t.update())}(e),!1===e.isRenderTargetTexture&&!0!==e.isExternalTexture&&e.version>0&&s.__version!==e.version){const t=e.image;if(null===t)Ue("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void N(s,e,r);Ue("WebGLRenderer: Texture marked for update but image is incomplete")}}else e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null);i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const R={[et]:t.REPEAT,[it]:t.CLAMP_TO_EDGE,[nt]:t.MIRRORED_REPEAT},C={[rt]:t.NEAREST,[st]:t.NEAREST_MIPMAP_NEAREST,[at]:t.NEAREST_MIPMAP_LINEAR,[ot]:t.LINEAR,[lt]:t.LINEAR_MIPMAP_NEAREST,[ht]:t.LINEAR_MIPMAP_LINEAR},P={[ve]:t.NEVER,[Te]:t.ALWAYS,[xe]:t.LESS,[Me]:t.LEQUAL,[ye]:t.EQUAL,[Ee]:t.GEQUAL,[Se]:t.GREATER,[be]:t.NOTEQUAL};function L(i,s){if(s.type!==gt||!1!==e.has("OES_texture_float_linear")||s.magFilter!==ot&&s.magFilter!==lt&&s.magFilter!==at&&s.magFilter!==ht&&s.minFilter!==ot&&s.minFilter!==lt&&s.minFilter!==at&&s.minFilter!==ht||Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(i,t.TEXTURE_WRAP_S,R[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,R[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,R[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,C[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,C[s.minFilter]),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,P[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){if(s.magFilter===rt)return;if(s.minFilter!==at&&s.minFilter!==ht)return;if(s.type===gt&&!1===e.has("OES_texture_float_linear"))return;if(s.anisotropy>1||n.get(s).__currentAnisotropy){const a=e.get("EXT_texture_filter_anisotropic");t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy}}}function D(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",b));const r=i.source;let s=p.get(r);void 0===s&&(s={},p.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&T(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function I(t,e,i){return Math.floor(Math.floor(t/i)/e)}function N(e,a,o){let l=t.TEXTURE_2D;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),a.isData3DTexture&&(l=t.TEXTURE_3D);const h=D(e,a),c=a.source;i.bindTexture(l,e.__webglTexture,t.TEXTURE0+o);const d=n.get(c);if(c.version!==d.__version||!0===h){i.activeTexture(t.TEXTURE0+o);if(!1===("undefined"!=typeof ImageBitmap&&a.image instanceof ImageBitmap)){const e=oi.getPrimaries(oi.workingColorSpace),n=a.colorSpace===de?null:oi.getPrimaries(a.colorSpace),r=a.colorSpace===de||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;i.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),i.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),i.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,r)}i.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment);let e=g(a.image,!1,r.maxTextureSize);e=G(a,e);const n=s.convert(a.format,a.colorSpace),p=s.convert(a.type);let f,m=y(a.internalFormat,n,p,a.normalized,a.colorSpace,a.isVideoTexture);L(l,a);const x=a.mipmaps,b=!0!==a.isVideoTexture,E=void 0===d.__version||!0===h,T=c.dataReady,w=S(a,e);if(a.isDepthTexture)m=M(a.format===Tt,a.type),E&&(b?i.texStorage2D(t.TEXTURE_2D,1,m,e.width,e.height):i.texImage2D(t.TEXTURE_2D,0,m,e.width,e.height,0,n,p,null));else if(a.isDataTexture)if(x.length>0){b&&E&&i.texStorage2D(t.TEXTURE_2D,w,m,x[0].width,x[0].height);for(let e=0,r=x.length;e<r;e++)f=x[e],b?T&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,f.width,f.height,n,p,f.data):i.texImage2D(t.TEXTURE_2D,e,m,f.width,f.height,0,n,p,f.data);a.generateMipmaps=!1}else b?(E&&i.texStorage2D(t.TEXTURE_2D,w,m,e.width,e.height),T&&function(e,n,r,s){const a=e.updateRanges;if(0===a.length)i.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,r,s,n.data);else{a.sort((t,e)=>t.start-e.start);let o=0;for(let t=1;t<a.length;t++){const e=a[o],i=a[t],r=e.start+e.count,s=I(i.start,n.width,4),l=I(e.start,n.width,4);i.start<=r+1&&s===l&&I(i.start+i.count-1,n.width,4)===s?e.count=Math.max(e.count,i.start+i.count-e.start):(++o,a[o]=i)}a.length=o+1;const l=i.getParameter(t.UNPACK_ROW_LENGTH),h=i.getParameter(t.UNPACK_SKIP_PIXELS),c=i.getParameter(t.UNPACK_SKIP_ROWS);i.pixelStorei(t.UNPACK_ROW_LENGTH,n.width);for(let e=0,o=a.length;e<o;e++){const o=a[e],l=Math.floor(o.start/4),h=Math.ceil(o.count/4),c=l%n.width,u=Math.floor(l/n.width),d=h,p=1;i.pixelStorei(t.UNPACK_SKIP_PIXELS,c),i.pixelStorei(t.UNPACK_SKIP_ROWS,u),i.texSubImage2D(t.TEXTURE_2D,0,c,u,d,p,r,s,n.data)}e.clearUpdateRanges(),i.pixelStorei(t.UNPACK_ROW_LENGTH,l),i.pixelStorei(t.UNPACK_SKIP_PIXELS,h),i.pixelStorei(t.UNPACK_SKIP_ROWS,c)}}(a,e,n,p)):i.texImage2D(t.TEXTURE_2D,0,m,e.width,e.height,0,n,p,e.data);else if(a.isCompressedTexture)if(a.isCompressedArrayTexture){b&&E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,w,m,x[0].width,x[0].height,e.depth);for(let r=0,s=x.length;r<s;r++)if(f=x[r],a.format!==bt)if(null!==n)if(b){if(T)if(a.layerUpdates.size>0){const e=zo(f.width,f.height,a.format,a.type);for(const s of a.layerUpdates){const a=f.data.subarray(s*e/f.data.BYTES_PER_ELEMENT,(s+1)*e/f.data.BYTES_PER_ELEMENT);i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,s,f.width,f.height,1,n,a)}a.clearLayerUpdates()}else i.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,f.width,f.height,e.depth,n,f.data)}else i.compressedTexImage3D(t.TEXTURE_2D_ARRAY,r,m,f.width,f.height,e.depth,0,f.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else b?T&&i.texSubImage3D(t.TEXTURE_2D_ARRAY,r,0,0,0,f.width,f.height,e.depth,n,p,f.data):i.texImage3D(t.TEXTURE_2D_ARRAY,r,m,f.width,f.height,e.depth,0,n,p,f.data)}else{b&&E&&i.texStorage2D(t.TEXTURE_2D,w,m,x[0].width,x[0].height);for(let e=0,r=x.length;e<r;e++)f=x[e],a.format!==bt?null!==n?b?T&&i.compressedTexSubImage2D(t.TEXTURE_2D,e,0,0,f.width,f.height,n,f.data):i.compressedTexImage2D(t.TEXTURE_2D,e,m,f.width,f.height,0,f.data):Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):b?T&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,f.width,f.height,n,p,f.data):i.texImage2D(t.TEXTURE_2D,e,m,f.width,f.height,0,n,p,f.data)}else if(a.isDataArrayTexture)if(b){if(E&&i.texStorage3D(t.TEXTURE_2D_ARRAY,w,m,e.width,e.height,e.depth),T)if(a.layerUpdates.size>0){const r=zo(e.width,e.height,a.format,a.type);for(const s of a.layerUpdates){const a=e.data.subarray(s*r/e.data.BYTES_PER_ELEMENT,(s+1)*r/e.data.BYTES_PER_ELEMENT);i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,s,e.width,e.height,1,n,p,a)}a.clearLayerUpdates()}else i.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,n,p,e.data)}else i.texImage3D(t.TEXTURE_2D_ARRAY,0,m,e.width,e.height,e.depth,0,n,p,e.data);else if(a.isData3DTexture)b?(E&&i.texStorage3D(t.TEXTURE_3D,w,m,e.width,e.height,e.depth),T&&i.texSubImage3D(t.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,n,p,e.data)):i.texImage3D(t.TEXTURE_3D,0,m,e.width,e.height,e.depth,0,n,p,e.data);else if(a.isFramebufferTexture){if(E)if(b)i.texStorage2D(t.TEXTURE_2D,w,m,e.width,e.height);else{let r=e.width,s=e.height;for(let e=0;e<w;e++)i.texImage2D(t.TEXTURE_2D,e,m,r,s,0,n,p,null),r>>=1,s>>=1}}else if(a.isHTMLTexture){if("texElementImage2D"in t){const i=t.canvas;if(i.hasAttribute("layoutsubtree")||i.setAttribute("layoutsubtree","true"),e.parentNode!==i)return i.appendChild(e),u.add(a),i.onpaint=t=>{const e=t.changedElements;for(const t of u)e.includes(t.image)&&(t.needsUpdate=!0)},void i.requestPaint();if(3===t.texElementImage2D.length)t.texElementImage2D(t.TEXTURE_2D,t.RGBA8,e);else{const i=0,n=t.RGBA,r=t.RGBA,s=t.UNSIGNED_BYTE;t.texElementImage2D(t.TEXTURE_2D,i,n,r,s,e)}t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}else if(x.length>0){if(b&&E){const e=W(x[0]);i.texStorage2D(t.TEXTURE_2D,w,m,e.width,e.height)}for(let e=0,r=x.length;e<r;e++)f=x[e],b?T&&i.texSubImage2D(t.TEXTURE_2D,e,0,0,n,p,f):i.texImage2D(t.TEXTURE_2D,e,m,n,p,f);a.generateMipmaps=!1}else if(b){if(E){const n=W(e);i.texStorage2D(t.TEXTURE_2D,w,m,n.width,n.height)}T&&i.texSubImage2D(t.TEXTURE_2D,0,0,0,n,p,e)}else i.texImage2D(t.TEXTURE_2D,0,m,n,p,e);_(a)&&v(l),d.__version=c.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}function U(e,r,a,l,h,c){const u=s.convert(a.format,a.colorSpace),d=s.convert(a.type),p=y(a.internalFormat,u,d,a.normalized,a.colorSpace),f=n.get(r),m=n.get(a);if(m.__renderTarget=r,!f.__hasExternalTextures){const e=Math.max(1,r.width>>c),n=Math.max(1,r.height>>c);h===t.TEXTURE_3D||h===t.TEXTURE_2D_ARRAY?i.texImage3D(h,c,p,e,n,r.depth,0,u,d,null):i.texImage2D(h,c,p,e,n,0,u,d,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),H(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,h,m.__webglTexture,0,V(r)):(h===t.TEXTURE_2D||h>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&h<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,l,h,m.__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function O(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer){const r=i.depthTexture,s=r&&r.isDepthTexture?r.type:null,a=M(i.stencilBuffer,s),l=i.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;H(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,V(i),a,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,V(i),a,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,a,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{const e=i.textures;for(let r=0;r<e.length;r++){const a=e[r],l=s.convert(a.format,a.colorSpace),h=s.convert(a.type),c=y(a.internalFormat,l,h,a.normalized,a.colorSpace);H(i)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,V(i),c,i.width,i.height):n?t.renderbufferStorageMultisample(t.RENDERBUFFER,V(i),c,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,c,i.width,i.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function F(e,r,a){const l=!0===r.isWebGLCubeRenderTarget;if(i.bindFramebuffer(t.FRAMEBUFFER,e),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const h=n.get(r.depthTexture);if(h.__renderTarget=r,h.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),l){if(void 0===h.__webglInit&&(h.__webglInit=!0,r.depthTexture.addEventListener("dispose",b)),void 0===h.__webglTexture){h.__webglTexture=t.createTexture(),i.bindTexture(t.TEXTURE_CUBE_MAP,h.__webglTexture),L(t.TEXTURE_CUBE_MAP,r.depthTexture);const e=s.convert(r.depthTexture.format),n=s.convert(r.depthTexture.type);let a;r.depthTexture.format===Et?a=t.DEPTH_COMPONENT24:r.depthTexture.format===Tt&&(a=t.DEPTH24_STENCIL8);for(let i=0;i<6;i++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,a,r.width,r.height,0,e,n,null)}}else A(r.depthTexture,0);const c=h.__webglTexture,u=V(r),d=l?t.TEXTURE_CUBE_MAP_POSITIVE_X+a:t.TEXTURE_2D,p=r.depthTexture.format===Tt?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(r.depthTexture.format===Et)H(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,c,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,c,0);else{if(r.depthTexture.format!==Tt)throw new Error("THREE.WebGLTextures: Unknown depthTexture format.");H(r)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,d,c,0,u):t.framebufferTexture2D(t.FRAMEBUFFER,p,d,c,0)}}function z(e){const r=n.get(e),s=!0===e.isWebGLCubeRenderTarget;if(r.__boundDepthTexture!==e.depthTexture){const t=e.depthTexture;if(r.__depthDisposeCallback&&r.__depthDisposeCallback(),t){const e=()=>{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,t.removeEventListener("dispose",e)};t.addEventListener("dispose",e),r.__depthDisposeCallback=e}r.__boundDepthTexture=t}if(e.depthTexture&&!r.__autoAllocateDepthBuffer)if(s)for(let t=0;t<6;t++)F(r.__webglFramebuffer[t],e,t);else{const t=e.texture.mipmaps;t&&t.length>0?F(r.__webglFramebuffer[0],e,0):F(r.__webglFramebuffer,e,0)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)if(i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[n]),void 0===r.__webglDepthbuffer[n])r.__webglDepthbuffer[n]=t.createRenderbuffer(),O(r.__webglDepthbuffer[n],e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,s=r.__webglDepthbuffer[n];t.bindRenderbuffer(t.RENDERBUFFER,s),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,s)}}else{const n=e.texture.mipmaps;if(n&&n.length>0?i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer[0]):i.bindFramebuffer(t.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=t.createRenderbuffer(),O(r.__webglDepthbuffer,e,!1);else{const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,n=r.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,n)}}i.bindFramebuffer(t.FRAMEBUFFER,null)}const B=[],k=[];function V(t){return Math.min(r.maxSamples,t.samples)}function H(t){const i=n.get(t);return t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function G(t,e){const i=t.colorSpace,n=t.format,r=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||i!==fe&&i!==de&&(oi.getTransfer(i)===ge?n===bt&&r===ct||Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Oe("WebGLTextures: Unsupported texture color space:",i)),e}function W(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement?(h.width=t.naturalWidth||t.width,h.height=t.naturalHeight||t.height):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?(h.width=t.displayWidth,h.height=t.displayHeight):(h.width=t.width,h.height=t.height),h}this.allocateTextureUnit=function(){const t=w;return t>=r.maxTextures&&Ue("WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+r.maxTextures),w+=1,t},this.resetTextureUnits=function(){w=0},this.getTextureUnits=function(){return w},this.setTextureUnits=function(t){w=t},this.setTexture2D=A,this.setTexture2DArray=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?N(s,e,r):(e.isExternalTexture&&(s.__webglTexture=e.sourceTexture?e.sourceTexture:null),i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r))},this.setTexture3D=function(e,r){const s=n.get(e);!1===e.isRenderTargetTexture&&e.version>0&&s.__version!==e.version?N(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,a){const o=n.get(e);!0!==e.isCubeDepthTexture&&e.version>0&&o.__version!==e.version?function(e,a,o){if(6!==a.image.length)return;const l=D(e,a),h=a.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+o);const c=n.get(h);if(h.version!==c.__version||!0===l){i.activeTexture(t.TEXTURE0+o);const e=oi.getPrimaries(oi.workingColorSpace),n=a.colorSpace===de?null:oi.getPrimaries(a.colorSpace),u=a.colorSpace===de||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;i.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,a.flipY),i.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),i.pixelStorei(t.UNPACK_ALIGNMENT,a.unpackAlignment),i.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const d=a.isCompressedTexture||a.image[0].isCompressedTexture,p=a.image[0]&&a.image[0].isDataTexture,f=[];for(let t=0;t<6;t++)f[t]=d||p?p?a.image[t].image:a.image[t]:g(a.image[t],!0,r.maxCubemapSize),f[t]=G(a,f[t]);const m=f[0],x=s.convert(a.format,a.colorSpace),M=s.convert(a.type),b=y(a.internalFormat,x,M,a.normalized,a.colorSpace),E=!0!==a.isVideoTexture,T=void 0===c.__version||!0===l,w=h.dataReady;let A,R=S(a,m);if(L(t.TEXTURE_CUBE_MAP,a),d){E&&T&&i.texStorage2D(t.TEXTURE_CUBE_MAP,R,b,m.width,m.height);for(let e=0;e<6;e++){A=f[e].mipmaps;for(let n=0;n<A.length;n++){const r=A[n];a.format!==bt?null!==x?E?w&&i.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,r.data):i.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,b,r.width,r.height,0,r.data):Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):E?w&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,0,0,r.width,r.height,x,M,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,b,r.width,r.height,0,x,M,r.data)}}}else{if(A=a.mipmaps,E&&T){A.length>0&&R++;const e=W(f[0]);i.texStorage2D(t.TEXTURE_CUBE_MAP,R,b,e.width,e.height)}for(let e=0;e<6;e++)if(p){E?w&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,f[e].width,f[e].height,x,M,f[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,b,f[e].width,f[e].height,0,x,M,f[e].data);for(let n=0;n<A.length;n++){const r=A[n].image[e].image;E?w&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,r.width,r.height,x,M,r.data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,b,r.width,r.height,0,x,M,r.data)}}else{E?w&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,x,M,f[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,b,x,M,f[e]);for(let n=0;n<A.length;n++){const r=A[n];E?w&&i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,0,0,x,M,r.image[e]):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,n+1,b,x,M,r.image[e])}}}_(a)&&v(t.TEXTURE_CUBE_MAP),c.__version=h.version,a.onUpdate&&a.onUpdate(a)}e.__version=a.version}(o,e,a):i.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture,t.TEXTURE0+a)},this.rebindTextures=function(e,i,r){const s=n.get(e);void 0!==i&&U(s.__webglFramebuffer,e,e.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),void 0!==r&&z(e)},this.setupRenderTarget=function(e){const r=e.texture,o=n.get(e),l=n.get(r);e.addEventListener("dispose",E);const h=e.textures,c=!0===e.isWebGLCubeRenderTarget,u=h.length>1;if(u||(void 0===l.__webglTexture&&(l.__webglTexture=t.createTexture()),l.__version=r.version,a.memory.textures++),c){o.__webglFramebuffer=[];for(let e=0;e<6;e++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[e]=[];for(let i=0;i<r.mipmaps.length;i++)o.__webglFramebuffer[e][i]=t.createFramebuffer()}else o.__webglFramebuffer[e]=t.createFramebuffer()}else{if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer=[];for(let e=0;e<r.mipmaps.length;e++)o.__webglFramebuffer[e]=t.createFramebuffer()}else o.__webglFramebuffer=t.createFramebuffer();if(u)for(let e=0,i=h.length;e<i;e++){const i=n.get(h[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),a.memory.textures++)}if(e.samples>0&&!1===H(e)){o.__webglMultisampledFramebuffer=t.createFramebuffer(),o.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let i=0;i<h.length;i++){const n=h[i];o.__webglColorRenderbuffer[i]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,o.__webglColorRenderbuffer[i]);const r=s.convert(n.format,n.colorSpace),a=s.convert(n.type),l=y(n.internalFormat,r,a,n.normalized,n.colorSpace,!0===e.isXRRenderTarget),c=V(e);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,l,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+i,t.RENDERBUFFER,o.__webglColorRenderbuffer[i])}t.bindRenderbuffer(t.RENDERBUFFER,null),e.depthBuffer&&(o.__webglDepthRenderbuffer=t.createRenderbuffer(),O(o.__webglDepthRenderbuffer,e,!0)),i.bindFramebuffer(t.FRAMEBUFFER,null)}}if(c){i.bindTexture(t.TEXTURE_CUBE_MAP,l.__webglTexture),L(t.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)if(r.mipmaps&&r.mipmaps.length>0)for(let n=0;n<r.mipmaps.length;n++)U(o.__webglFramebuffer[i][n],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else U(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);_(r)&&v(t.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(u){for(let r=0,s=h.length;r<s;r++){const s=h[r],a=n.get(s);let l=t.TEXTURE_2D;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(l=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(l,a.__webglTexture),L(l,s),U(o.__webglFramebuffer,e,s,t.COLOR_ATTACHMENT0+r,l,0),_(s)&&v(l)}i.unbindTexture()}else{let n=t.TEXTURE_2D;if((e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(n=e.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),i.bindTexture(n,l.__webglTexture),L(n,r),r.mipmaps&&r.mipmaps.length>0)for(let i=0;i<r.mipmaps.length;i++)U(o.__webglFramebuffer[i],e,r,t.COLOR_ATTACHMENT0,n,i);else U(o.__webglFramebuffer,e,r,t.COLOR_ATTACHMENT0,n,0);_(r)&&v(n),i.unbindTexture()}e.depthBuffer&&z(e)},this.updateRenderTargetMipmap=function(t){const e=t.textures;for(let r=0,s=e.length;r<s;r++){const s=e[r];if(_(s)){const e=x(t),r=n.get(s).__webglTexture;i.bindTexture(e,r),v(e),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(e.samples>0)if(!1===H(e)){const r=e.textures,s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const h=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,c=n.get(e),u=r.length>1;if(u)for(let e=0;e<r.length;e++)i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);i.bindFramebuffer(t.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer);const d=e.texture.mipmaps;d&&d.length>0?i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){if(e.resolveDepthBuffer&&(e.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),e.stencilBuffer&&e.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT)),u){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,c.__webglColorRenderbuffer[i]);const e=n.get(r[i]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}t.blitFramebuffer(0,0,s,a,0,0,s,a,o,t.NEAREST),!0===l&&(B.length=0,k.length=0,B.push(t.COLOR_ATTACHMENT0+i),e.depthBuffer&&!1===e.resolveDepthBuffer&&(B.push(h),k.push(h),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,k)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(i.bindFramebuffer(t.READ_FRAMEBUFFER,null),i.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),u)for(let e=0;e<r.length;e++){i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,c.__webglColorRenderbuffer[e]);const s=n.get(r[e]).__webglTexture;i.bindFramebuffer(t.FRAMEBUFFER,c.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,s,0)}i.bindFramebuffer(t.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}else if(e.depthBuffer&&!1===e.resolveDepthBuffer&&l){const i=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[i])}},this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=U,this.useMultisampledRTT=H,this.isReversedDepthBuffer=function(){return i.buffers.depth.getReversed()}}function Sc(t,e){return{convert:function(i,n=""){let r;const s=oi.getTransfer(n);if(i===ct)return t.UNSIGNED_BYTE;if(i===vt)return t.UNSIGNED_SHORT_4_4_4_4;if(i===xt)return t.UNSIGNED_SHORT_5_5_5_1;if(i===Mt)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===St)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===ut)return t.BYTE;if(i===dt)return t.SHORT;if(i===pt)return t.UNSIGNED_SHORT;if(i===ft)return t.INT;if(i===mt)return t.UNSIGNED_INT;if(i===gt)return t.FLOAT;if(i===_t)return t.HALF_FLOAT;if(1021===i)return t.ALPHA;if(1022===i)return t.RGB;if(i===bt)return t.RGBA;if(i===Et)return t.DEPTH_COMPONENT;if(i===Tt)return t.DEPTH_STENCIL;if(1028===i)return t.RED;if(i===wt)return t.RED_INTEGER;if(i===At)return t.RG;if(i===Rt)return t.RG_INTEGER;if(i===Ct)return t.RGBA_INTEGER;if(i===Pt||i===Lt||i===Dt||i===It)if(s===ge){if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(i===Pt)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Lt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Dt)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===It)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=e.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(i===Pt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Lt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Dt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===It)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Nt||i===Ut||i===Ot||i===Ft){if(r=e.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(i===Nt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ut)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Ot)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ft)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===zt||i===Bt||i===kt||i===Vt||i===Ht||i===Gt||i===Wt){if(r=e.get("WEBGL_compressed_texture_etc"),null===r)return null;if(i===zt||i===Bt)return s===ge?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===kt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Vt)return r.COMPRESSED_R11_EAC;if(i===Ht)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Gt)return r.COMPRESSED_RG11_EAC;if(i===Wt)return r.COMPRESSED_SIGNED_RG11_EAC}if(i===Xt||i===jt||i===qt||i===Yt||i===Zt||i===Kt||i===Jt||i===$t||i===Qt||i===te||i===ee||i===ie||i===ne||i===re){if(r=e.get("WEBGL_compressed_texture_astc"),null===r)return null;if(i===Xt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===jt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===qt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Yt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Zt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Kt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Jt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===$t)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Qt)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===te)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ee)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ie)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ne)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===re)return s===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===se||i===ae||i===oe){if(r=e.get("EXT_texture_compression_bptc"),null===r)return null;if(i===se)return s===ge?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ae)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===oe)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(i===le||i===he||i===ce||i===ue){if(r=e.get("EXT_texture_compression_rgtc"),null===r)return null;if(i===le)return r.COMPRESSED_RED_RGTC1_EXT;if(i===he)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===ce)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===ue)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===yt?t.UNSIGNED_INT_24_8:void 0!==t[i]?t[i]:null}}}class bc{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(null===this.texture){const i=new Es(t.texture);t.depthNear===e.depthNear&&t.depthFar===e.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(null!==this.texture&&null===this.mesh){const e=t.cameras[0].viewport,i=new Oa({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:e.z},depthHeight:{value:e.w}}});this.mesh=new Gr(new wa(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Ec extends Be{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null;const f="undefined"!=typeof XRWebGLBinding,m=new bc,g={},_=e.getContextAttributes();let v=null,x=null;const y=[],M=[],S=new Je;let b=null;const E=new uo;E.viewport=new vi;const T=new uo;T.viewport=new vi;const w=[E,T],A=new bo;let R=null,C=null;function P(t){const e=M.indexOf(t.inputSource);if(-1===e)return;const i=y[e];void 0!==i&&(i.update(t.inputSource,t.frame,l||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function L(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",L),n.removeEventListener("inputsourceschange",D);for(let t=0;t<y.length;t++){const e=M[t];null!==e&&(M[t]=null,y[t].disconnect(e))}R=null,C=null,m.reset();for(const t in g)delete g[t];t.setRenderTarget(v),d=null,u=null,c=null,n=null,x=null,F.stop(),i.isPresenting=!1,t.setPixelRatio(b),t.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}function D(t){for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=M.indexOf(i);n>=0&&(M[n]=null,y[n].disconnect(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e];let n=M.indexOf(i);if(-1===n){for(let t=0;t<y.length;t++){if(t>=M.length){M.push(i),n=t;break}if(null===M[t]){M[t]=i,n=t;break}}if(-1===n)break}const r=y[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=y[t];return void 0===e&&(e=new Qi,y[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=y[t];return void 0===e&&(e=new Qi,y[t]=e),e.getGripSpace()},this.getHand=function(t){let e=y[t];return void 0===e&&(e=new Qi,y[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return null===c&&f&&(c=new XRWebGLBinding(n,e)),c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(h){if(n=h,null!==n){v=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",L),n.addEventListener("inputsourceschange",D),!0!==_.xrCompatible&&await e.makeXRCompatible(),b=t.getPixelRatio(),t.getSize(S);if(f&&"createProjectionLayer"in XRWebGLBinding.prototype){let i=null,s=null,a=null;_.depth&&(a=_.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=_.stencil?Tt:Et,s=_.stencil?yt:mt);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};c=this.getBinding(),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),x=new yi(u.textureWidth,u.textureHeight,{format:bt,type:ct,depthTexture:new Ss(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:_.stencil,colorSpace:t.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:!1===u.ignoreDepthValues,resolveStencilBuffer:!1===u.ignoreDepthValues})}else{const i={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),t.setPixelRatio(1),t.setSize(d.framebufferWidth,d.framebufferHeight,!1),x=new yi(d.framebufferWidth,d.framebufferHeight,{format:bt,type:ct,colorSpace:t.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}x.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await n.requestReferenceSpace(a),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const I=new Qe,N=new Qe;function U(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;let e=t.near,i=t.far;null!==m.texture&&(m.depthNear>0&&(e=m.depthNear),m.depthFar>0&&(i=m.depthFar)),A.near=T.near=E.near=e,A.far=T.far=E.far=i,R===A.near&&C===A.far||(n.updateRenderState({depthNear:A.near,depthFar:A.far}),R=A.near,C=A.far),A.layers.mask=6|t.layers.mask,E.layers.mask=-5&A.layers.mask,T.layers.mask=-3&A.layers.mask;const r=t.parent,s=A.cameras;U(A,r);for(let t=0;t<s.length;t++)U(s[t],r);2===s.length?function(t,e,i){I.setFromMatrixPosition(e.matrixWorld),N.setFromMatrixPosition(i.matrixWorld);const n=I.distanceTo(N),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*c,p=a*u,f=n/(-c+u),m=f*-c;if(e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),-1===r[10])t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const e=a+f,i=o+f,r=d-m,s=p+(n-m),c=l*o/i*e,u=h*o/i*e;t.projectionMatrix.makePerspective(r,s,c,u,e,i),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()}}(A,E,T):A.projectionMatrix.copy(E.projectionMatrix),function(t,e,i){null===i?t.matrix.copy(e.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(e.matrixWorld));t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(e.projectionMatrix),t.projectionMatrixInverse.copy(e.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*Ge*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}(t,A,r)},this.getCamera=function(){return A},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(t){o=t,null!==u&&(u.fixedFoveation=t),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=t)},this.hasDepthSensing=function(){return null!==m.texture},this.getDepthSensingMesh=function(){return m.getMesh(A)},this.getCameraTexture=function(t){return g[t]};let O=null;const F=new Bo;F.setAnimationLoop(function(e,r){if(h=r.getViewerPose(l||s),p=r,null!==h){const e=h.views;null!==d&&(t.setRenderTargetFramebuffer(x,d.framebuffer),t.setRenderTarget(x));let r=!1;e.length!==A.cameras.length&&(A.cameras.length=0,r=!0);for(let i=0;i<e.length;i++){const n=e[i];let s=null;if(null!==d)s=d.getViewport(n);else{const e=c.getViewSubImage(u,n);s=e.viewport,0===i&&(t.setRenderTargetTextures(x,e.colorTexture,e.depthStencilTexture),t.setRenderTarget(x))}let a=w[i];void 0===a&&(a=new uo,a.layers.enable(i),a.viewport=new vi,w[i]=a),a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(n.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(s.x,s.y,s.width,s.height),0===i&&(A.matrix.copy(a.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),!0===r&&A.cameras.push(a)}const s=n.enabledFeatures;if(s&&s.includes("depth-sensing")&&"gpu-optimized"==n.depthUsage&&f){c=i.getBinding();const t=c.getDepthInformation(e[0]);t&&t.isValid&&t.texture&&m.init(t,n.renderState)}if(s&&s.includes("camera-access")&&f){t.state.unbindTexture(),c=i.getBinding();for(let t=0;t<e.length;t++){const i=e[t].camera;if(i){let t=g[i];t||(t=new Es,g[i]=t);const e=c.getCameraImage(i);t.sourceTexture=e}}}}for(let t=0;t<y.length;t++){const e=M[t],i=y[t];null!==e&&void 0!==i&&i.update(e,r,l||s)}O&&O(e,r),r.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:r}),p=null}),this.setAnimationLoop=function(t){O=t},this.dispose=function(){}}}const Tc=new bi,wc=new ii;function Ac(t,e){function i(t,e){!0===t.matrixAutoUpdate&&t.updateMatrix(),e.value.copy(t.matrix)}function n(t,n){t.opacity.value=n.opacity,n.color&&t.diffuse.value.copy(n.color),n.emissive&&t.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(t.map.value=n.map,i(n.map,t.mapTransform)),n.alphaMap&&(t.alphaMap.value=n.alphaMap,i(n.alphaMap,t.alphaMapTransform)),n.bumpMap&&(t.bumpMap.value=n.bumpMap,i(n.bumpMap,t.bumpMapTransform),t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,i(n.normalMap,t.normalMapTransform),t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,i(n.displacementMap,t.displacementMapTransform),t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,t.emissiveMapTransform)),n.specularMap&&(t.specularMap.value=n.specularMap,i(n.specularMap,t.specularMapTransform)),n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const r=e.get(n),s=r.envMap,a=r.envMapRotation;s&&(t.envMap.value=s,t.envMapRotation.value.setFromMatrix4(Tc.makeRotationFromEuler(a)).transpose(),s.isCubeTexture&&!1===s.isRenderTargetTexture&&t.envMapRotation.value.premultiply(wc),t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio),n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity,i(n.lightMap,t.lightMapTransform)),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,t.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,Na(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isNodeMaterial?r.uniformsNeedUpdate=!1:r.isMeshBasicMaterial?n(t,r):r.isMeshLambertMaterial?(n(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r),r.envMap&&(t.envMapIntensity.value=r.envMapIntensity)):r.isMeshStandardMaterial?(n(t,r),function(t,e){t.metalness.value=e.metalness,e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap,i(e.metalnessMap,t.metalnessMapTransform));t.roughness.value=e.roughness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap,i(e.roughnessMap,t.roughnessMapTransform));e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),1===e.side&&t.clearcoatNormalScale.value.negate()));e.dispersion>0&&(t.dispersion.value=e.dispersion);e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Rc(t,e,i,n){let r={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,i,n,r){if(!0===function(t,e,i,n){const r=t.value,s=e+"_"+i;if(void 0===n[s])return"number"==typeof r||"boolean"==typeof r?n[s]=r:ArrayBuffer.isView(r)?n[s]=r.slice():n[s]=r.clone(),!0;{const t=n[s];if("number"==typeof r||"boolean"==typeof r){if(t!==r)return n[s]=r,!0}else{if(ArrayBuffer.isView(r))return!0;if(!1===t.equals(r))return t.copy(r),!0}}return!1}(e,i,n,r)){const i=e.__offset,n=e.value;if(Array.isArray(n)){let t=0;for(let i=0;i<n.length;i++){const r=n[i],s=c(r);h(r,e.__data,t),"number"==typeof r||"boolean"==typeof r||r.isMatrix3||ArrayBuffer.isView(r)||(t+=s.storage/Float32Array.BYTES_PER_ELEMENT)}}else h(n,e.__data,0);t.bufferSubData(t.UNIFORM_BUFFER,i,e.__data)}}function h(t,e,i){"number"==typeof t||"boolean"==typeof t?e[0]=t:t.isMatrix3?(e[0]=t.elements[0],e[1]=t.elements[1],e[2]=t.elements[2],e[3]=0,e[4]=t.elements[3],e[5]=t.elements[4],e[6]=t.elements[5],e[7]=0,e[8]=t.elements[6],e[9]=t.elements[7],e[10]=t.elements[8],e[11]=0):ArrayBuffer.isView(t)?e.set(new t.constructor(t.buffer,t.byteOffset,e.length)):t.toArray(e,i)}function c(t){const e={boundary:0,storage:0};return"number"==typeof t||"boolean"==typeof t?(e.boundary=4,e.storage=4):t.isVector2?(e.boundary=8,e.storage=8):t.isVector3||t.isColor?(e.boundary=16,e.storage=12):t.isVector4?(e.boundary=16,e.storage=16):t.isMatrix3?(e.boundary=48,e.storage=48):t.isMatrix4?(e.boundary=64,e.storage=64):t.isTexture?Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(t)?(e.boundary=16,e.storage=t.byteLength):Ue("WebGLRenderer: Unsupported uniform value type.",t),e}function u(e){const i=e.target;i.removeEventListener("dispose",u);const n=a.indexOf(i.__bindingPointIndex);a.splice(n,1),t.deleteBuffer(r[i.id]),delete r[i.id],delete s[i.id]}return{bind:function(t,e){const i=e.program;n.uniformBlockBinding(t,i)},update:function(i,h){let d=r[i.id];void 0===d&&(!function(t){const e=t.uniforms;let i=0;const n=16;for(let t=0,r=e.length;t<r;t++){const r=Array.isArray(e[t])?e[t]:[e[t]];for(let t=0,e=r.length;t<e;t++){const e=r[t],s=Array.isArray(e.value)?e.value:[e.value];for(let t=0,r=s.length;t<r;t++){const r=c(s[t]),a=i%n,o=a%r.boundary,l=a+o;i+=o,0!==l&&n-l<r.storage&&(i+=n-l),e.__data=new Float32Array(r.storage/Float32Array.BYTES_PER_ELEMENT),e.__offset=i,i+=r.storage}}}const r=i%n;r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t<o;t++)if(-1===a.indexOf(t))return a.push(t),t;return Oe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=i;const n=t.createBuffer(),r=e.__size,s=e.usage;return t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,r,s),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=d,i.addEventListener("dispose",u));const p=h.program;n.updateUBOMapping(i,p);const f=e.render.frame;s[i.id]!==f&&(!function(e){const i=r[e.id],n=e.uniforms,s=e.__cache;t.bindBuffer(t.UNIFORM_BUFFER,i);for(let t=0,e=n.length;t<e;t++){const e=n[t];if(Array.isArray(e))for(let i=0,n=e.length;i<n;i++)l(e[i],t,i,s);else l(e,t,0,s)}t.bindBuffer(t.UNIFORM_BUFFER,null)}(i),s[i.id]=f)},dispose:function(){for(const e in r)t.deleteBuffer(r[e]);a=[],r={},s={}}}}wc.set(-1,0,0,0,1,0,0,0,1);const Cc=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Pc=null;class Lc{constructor(t={}){const{canvas:i=Le(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=ct}=t;let f;if(this.isWebGLRenderer=!0,null!==n){if("undefined"!=typeof WebGLRenderingContext&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;const m=p,g=new Set([Ct,Rt,wt]),_=new Set([ct,mt,pt,yt,vt,xt]),v=new Uint32Array(4),x=new Int32Array(4),y=new Qe;let M=null,S=null;const b=[],E=[];let T=null;this.domElement=i,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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const w=this;let A=!1,R=null,C=null,P=null,L=null;this._outputColorSpace=pe;let D=0,I=0,N=null,U=-1,O=null;const F=new vi,z=new vi;let B=null;const k=new sn(0);let V=0,H=i.width,G=i.height,W=1,X=null,j=null;const q=new vi(0,0,H,G),Y=new vi(0,0,H,G);let Z=!1;const K=new Qr;let J=!1,$=!1;const Q=new bi,tt=new Qe,et=new vi,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let rt=!1;function st(){return null===N?W:1}let at,lt,ut,dt,ft,gt,Mt,St,bt,Et,Tt,Pt,Lt,Dt,It,Nt,Ut,Ot,Ft,zt,Bt,kt,Vt,Ht=n;function Gt(t,e){return i.getContext(t,e)}try{const t={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${e}`),i.addEventListener("webglcontextlost",jt,!1),i.addEventListener("webglcontextrestored",qt,!1),i.addEventListener("webglcontextcreationerror",Yt,!1),null===Ht){const e="webgl2";if(Ht=Gt(e,t),null===Ht)throw Gt(e)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(t){throw Oe("WebGLRenderer: "+t.message),t}function Wt(){at=new ml(Ht),at.init(),Bt=new Sc(Ht,at),lt=new Ko(Ht,at,t,Bt),ut=new yc(Ht,at),lt.reversedDepthBuffer&&d&&ut.buffers.depth.setReversed(!0),C=Ht.createFramebuffer(),P=Ht.createFramebuffer(),L=Ht.createFramebuffer(),dt=new vl(Ht),ft=new nc,gt=new Mc(Ht,at,ut,ft,lt,Bt,dt),Mt=new fl(w),St=new ko(Ht),kt=new Yo(Ht,St),bt=new gl(Ht,St,dt,kt),Et=new yl(Ht,bt,St,kt,dt),Ot=new xl(Ht,lt,gt),It=new Jo(ft),Tt=new ic(w,Mt,at,lt,kt,It),Pt=new Ac(w,ft),Lt=new oc,Dt=new pc(at),Ut=new qo(w,Mt,ut,Et,f,l),Nt=new xc(w,Et,lt),Vt=new Rc(Ht,dt,lt,ut),Ft=new Zo(Ht,at,dt),zt=new _l(Ht,at,dt),dt.programs=Tt.programs,w.capabilities=lt,w.extensions=at,w.properties=ft,w.renderLists=Lt,w.shadowMap=Nt,w.state=ut,w.info=dt}Wt(),m!==ct&&(T=new Sl(m,i.width,i.height,o,r,s));const Xt=new Ec(w,Ht);function jt(t){t.preventDefault(),Ie("WebGLRenderer: Context Lost."),A=!0}function qt(){Ie("WebGLRenderer: Context Restored."),A=!1;const t=dt.autoReset,e=Nt.enabled,i=Nt.autoUpdate,n=Nt.needsUpdate,r=Nt.type;Wt(),dt.autoReset=t,Nt.enabled=e,Nt.autoUpdate=i,Nt.needsUpdate=n,Nt.type=r}function Yt(t){Oe("WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Zt(t){const e=t.target;e.removeEventListener("dispose",Zt),function(t){(function(t){const e=ft.get(t).programs;void 0!==e&&(e.forEach(function(t){Tt.releaseProgram(t)}),t.isShaderMaterial&&Tt.releaseShaderCache(t))})(t),ft.remove(t)}(e)}function Kt(t,e,i){!0===t.transparent&&2===t.side&&!1===t.forceSinglePass?(t.side=1,t.needsUpdate=!0,ae(t,e,i),t.side=0,t.needsUpdate=!0,ae(t,e,i),t.side=2):ae(t,e,i)}this.xr=Xt,this.getContext=function(){return Ht},this.getContextAttributes=function(){return Ht.getContextAttributes()},this.forceContextLoss=function(){const t=at.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=at.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(t){void 0!==t&&(W=t,this.setSize(H,G,!1))},this.getSize=function(t){return t.set(H,G)},this.setSize=function(t,e,n=!0){Xt.isPresenting?Ue("WebGLRenderer: Can't change size while VR device is presenting."):(H=t,G=e,i.width=Math.floor(t*W),i.height=Math.floor(e*W),!0===n&&(i.style.width=t+"px",i.style.height=e+"px"),null!==T&&T.setSize(i.width,i.height),this.setViewport(0,0,t,e))},this.getDrawingBufferSize=function(t){return t.set(H*W,G*W).floor()},this.setDrawingBufferSize=function(t,e,n){H=t,G=e,W=n,i.width=Math.floor(t*n),i.height=Math.floor(e*n),this.setViewport(0,0,t,e)},this.setEffects=function(t){if(m!==ct){if(t)for(let e=0;e<t.length;e++)if(!0===t[e].isOutputPass){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}T.setEffects(t||[])}else Oe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.")},this.getCurrentViewport=function(t){return t.copy(F)},this.getViewport=function(t){return t.copy(q)},this.setViewport=function(t,e,i,n){t.isVector4?q.set(t.x,t.y,t.z,t.w):q.set(t,e,i,n),ut.viewport(F.copy(q).multiplyScalar(W).round())},this.getScissor=function(t){return t.copy(Y)},this.setScissor=function(t,e,i,n){t.isVector4?Y.set(t.x,t.y,t.z,t.w):Y.set(t,e,i,n),ut.scissor(z.copy(Y).multiplyScalar(W).round())},this.getScissorTest=function(){return Z},this.setScissorTest=function(t){ut.setScissorTest(Z=t)},this.setOpaqueSort=function(t){X=t},this.setTransparentSort=function(t){j=t},this.getClearColor=function(t){return t.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor(...arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha(...arguments)},this.clear=function(t=!0,e=!0,i=!0){let n=0;if(t){let t=!1;if(null!==N){const e=N.texture.format;t=g.has(e)}if(t){const t=N.texture.type,e=_.has(t),i=Ut.getClearColor(),n=Ut.getClearAlpha(),r=i.r,s=i.g,a=i.b;e?(v[0]=r,v[1]=s,v[2]=a,v[3]=n,Ht.clearBufferuiv(Ht.COLOR,0,v)):(x[0]=r,x[1]=s,x[2]=a,x[3]=n,Ht.clearBufferiv(Ht.COLOR,0,x))}else n|=Ht.COLOR_BUFFER_BIT}e&&(n|=Ht.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),i&&(n|=Ht.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),0!==n&&Ht.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(t){t.setRenderer(this),R=t},this.dispose=function(){i.removeEventListener("webglcontextlost",jt,!1),i.removeEventListener("webglcontextrestored",qt,!1),i.removeEventListener("webglcontextcreationerror",Yt,!1),Ut.dispose(),Lt.dispose(),Dt.dispose(),ft.dispose(),Mt.dispose(),Et.dispose(),kt.dispose(),Vt.dispose(),Tt.dispose(),Xt.dispose(),Xt.removeEventListener("sessionstart",$t),Xt.removeEventListener("sessionend",Qt),te.stop()},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=nt);const a=r.isMesh&&r.matrixWorld.determinantAffine()<0,o=function(t,e,i,n,r){!0!==e.isScene&&(e=nt);gt.resetTextureUnits();const s=e.fog,a=n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial?e.environment:null,o=null===N?w.outputColorSpace:!0===N.isXRRenderTarget?N.texture.colorSpace:oi.workingColorSpace,l=n.isMeshStandardMaterial||n.isMeshLambertMaterial&&!n.envMap||n.isMeshPhongMaterial&&!n.envMap,h=Mt.get(n.envMap||a,l),c=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,u=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),d=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,f=!!i.morphAttributes.color;let m=0;n.toneMapped&&(null!==N&&!0!==N.isXRRenderTarget||(m=w.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,_=void 0!==g?g.length:0,v=ft.get(n),x=S.state.lights;if(!0===J&&(!0===$||t!==O)){const e=t===O&&n.id===U;It.setState(n,t,e)}let M=!1;n.version===v.__version?v.needsLights&&v.lightsStateVersion!==x.state.version||v.outputColorSpace!==o||r.isBatchedMesh&&!1===v.batching?M=!0:r.isBatchedMesh||!0!==v.batching?r.isBatchedMesh&&!0===v.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===v.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===v.instancing?M=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?M=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===v.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===v.instancingMorph&&null!==r.morphTexture||v.envMap!==h||!0===n.fog&&v.fog!==s?M=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===It.numPlanes&&v.numIntersection===It.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==u||v.morphTargets!==d||v.morphNormals!==p||v.morphColors!==f||v.toneMapping!==m||v.morphTargetsCount!==_||!!v.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(M=!0):M=!0:M=!0:M=!0:M=!0:(M=!0,v.__version=n.version);let b=v.currentProgram;!0===M&&(b=ae(n,e,r),R&&n.isNodeMaterial&&R.onUpdateProgram(n,b,v));let E=!1,T=!1,A=!1;const C=b.getUniforms(),P=v.uniforms;ut.useProgram(b.program)&&(E=!0,T=!0,A=!0);n.id!==U&&(U=n.id,T=!0);if(v.needsLights){const t=function(t,e){if(0===t.length)return null;if(1===t.length)return null!==t[0].texture?t[0]:null;y.setFromMatrixPosition(e.matrixWorld);for(let e=0,i=t.length;e<i;e++){const i=t[e];if(null!==i.texture&&i.boundingBox.containsPoint(y))return i}return null}(S.state.lightProbeGridArray,r);v.lightProbeGrid!==t&&(v.lightProbeGrid=t,T=!0)}if(E||O!==t){ut.buffers.depth.getReversed()&&!0!==t.reversedDepth&&(t._reversedDepth=!0,t.updateProjectionMatrix()),C.setValue(Ht,"projectionMatrix",t.projectionMatrix),C.setValue(Ht,"viewMatrix",t.matrixWorldInverse);const e=C.map.cameraPosition;void 0!==e&&e.setValue(Ht,tt.setFromMatrixPosition(t.matrixWorld)),lt.logarithmicDepthBuffer&&C.setValue(Ht,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&C.setValue(Ht,"isOrthographic",!0===t.isOrthographicCamera),O!==t&&(O=t,T=!0,A=!0)}v.needsLights&&(x.state.directionalShadowMap.length>0&&C.setValue(Ht,"directionalShadowMap",x.state.directionalShadowMap,gt),x.state.spotShadowMap.length>0&&C.setValue(Ht,"spotShadowMap",x.state.spotShadowMap,gt),x.state.pointShadowMap.length>0&&C.setValue(Ht,"pointShadowMap",x.state.pointShadowMap,gt));if(r.isSkinnedMesh){C.setOptional(Ht,r,"bindMatrix"),C.setOptional(Ht,r,"bindMatrixInverse");const t=r.skeleton;t&&(null===t.boneTexture&&t.computeBoneTexture(),C.setValue(Ht,"boneTexture",t.boneTexture,gt))}r.isBatchedMesh&&(C.setOptional(Ht,r,"batchingTexture"),C.setValue(Ht,"batchingTexture",r._matricesTexture,gt),C.setOptional(Ht,r,"batchingIdTexture"),C.setValue(Ht,"batchingIdTexture",r._indirectTexture,gt),C.setOptional(Ht,r,"batchingColorTexture"),null!==r._colorsTexture&&C.setValue(Ht,"batchingColorTexture",r._colorsTexture,gt));const L=i.morphAttributes;void 0===L.position&&void 0===L.normal&&void 0===L.color||Ot.update(r,i,b);(T||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,C.setValue(Ht,"receiveShadow",r.receiveShadow));(n.isMeshStandardMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial)&&null===n.envMap&&null!==e.environment&&(P.envMapIntensity.value=e.environmentIntensity);void 0!==P.dfgLUT&&(P.dfgLUT.value=(null===Pc&&(Pc=new Xr(Cc,16,16,At,_t),Pc.name="DFG_LUT",Pc.minFilter=ot,Pc.magFilter=ot,Pc.wrapS=it,Pc.wrapT=it,Pc.generateMipmaps=!1,Pc.needsUpdate=!0),Pc));if(T){if(C.setValue(Ht,"toneMappingExposure",w.toneMappingExposure),v.needsLights&&(I=A,(D=P).ambientLightColor.needsUpdate=I,D.lightProbe.needsUpdate=I,D.directionalLights.needsUpdate=I,D.directionalLightShadows.needsUpdate=I,D.pointLights.needsUpdate=I,D.pointLightShadows.needsUpdate=I,D.spotLights.needsUpdate=I,D.spotLightShadows.needsUpdate=I,D.rectAreaLights.needsUpdate=I,D.hemisphereLights.needsUpdate=I),s&&!0===n.fog&&Pt.refreshFogUniforms(P,s),Pt.refreshMaterialUniforms(P,n,W,G,S.state.transmissionRenderTarget[t.id]),v.needsLights&&v.lightProbeGrid){const t=v.lightProbeGrid;P.probesSH.value=t.texture,P.probesMin.value.copy(t.boundingBox.min),P.probesMax.value.copy(t.boundingBox.max),P.probesResolution.value.copy(t.resolution)}Ah.upload(Ht,oe(v),P,gt)}var D,I;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ah.upload(Ht,oe(v),P,gt),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&C.setValue(Ht,"center",r.center);if(C.setValue(Ht,"modelViewMatrix",r.modelViewMatrix),C.setValue(Ht,"normalMatrix",r.normalMatrix),C.setValue(Ht,"modelMatrix",r.matrixWorld),void 0!==n.uniformsGroups){const t=n.uniformsGroups;for(let e=0,i=t.length;e<i;e++){const i=t[e];Vt.update(i,b),Vt.bind(i,b)}}return b}(t,e,i,n,r);ut.setMaterial(n,a);let l=i.index,h=1;if(!0===n.wireframe){if(l=bt.getWireframeAttribute(i),void 0===l)return;h=2}const c=i.drawRange,u=i.attributes.position;let d=c.start*h,p=(c.start+c.count)*h;null!==s&&(d=Math.max(d,s.start*h),p=Math.min(p,(s.start+s.count)*h)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));const f=p-d;if(f<0||f===1/0)return;let m;kt.setup(r,n,o,i,l);let g=Ft;if(null!==l&&(m=St.get(l),g=zt,g.setIndex(m)),r.isMesh)!0===n.wireframe?(ut.setLineWidth(n.wireframeLinewidth*st()),g.setMode(Ht.LINES)):g.setMode(Ht.TRIANGLES);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),ut.setLineWidth(t*st()),r.isLineSegments?g.setMode(Ht.LINES):r.isLineLoop?g.setMode(Ht.LINE_LOOP):g.setMode(Ht.LINE_STRIP)}else r.isPoints?g.setMode(Ht.POINTS):r.isSprite&&g.setMode(Ht.TRIANGLES);if(r.isBatchedMesh)if(at.get("WEBGL_multi_draw"))g.renderMultiDraw(r._multiDrawStarts,r._multiDrawCounts,r._multiDrawCount);else{const t=r._multiDrawStarts,e=r._multiDrawCounts,i=r._multiDrawCount,s=l?St.get(l).bytesPerElement:1,a=ft.get(n).currentProgram.getUniforms();for(let n=0;n<i;n++)a.setValue(Ht,"_gl_DrawID",n),g.render(t[n]/s,e[n])}else if(r.isInstancedMesh)g.renderInstances(d,f,r.count);else if(i.isInstancedBufferGeometry){const t=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,t);g.renderInstances(d,f,e)}else g.render(d,f)},this.compile=function(t,e,i=null){null===i&&(i=t),S=Dt.get(i),S.init(e),E.push(S),i.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(S.pushLight(t),t.castShadow&&S.pushShadow(t))}),t!==i&&t.traverseVisible(function(t){t.isLight&&t.layers.test(e.layers)&&(S.pushLight(t),t.castShadow&&S.pushShadow(t))}),S.setupLights();const n=new Set;return t.traverse(function(t){if(!(t.isMesh||t.isPoints||t.isLine||t.isSprite))return;const e=t.material;if(e)if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=e[r];Kt(s,i,t),n.add(s)}else Kt(e,i,t),n.add(e)}),S=E.pop(),n},this.compileAsync=function(t,e,i=null){const n=this.compile(t,e,i);return new Promise(e=>{function i(){n.forEach(function(t){ft.get(t).currentProgram.isReady()&&n.delete(t)}),0!==n.size?setTimeout(i,10):e(t)}null!==at.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let Jt=null;function $t(){te.stop()}function Qt(){te.start()}const te=new Bo;function ee(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLightProbeGrid)S.pushLightProbeGrid(t);else if(t.isLight)S.pushLight(t),t.castShadow&&S.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||K.intersectsSprite(t)){n&&et.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Q);const e=Et.update(t),r=t.material;r.visible&&M.push(t,e,r,i,et.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||K.intersectsObject(t))){const e=Et.update(t),r=t.material;if(n&&(void 0!==t.boundingSphere?(null===t.boundingSphere&&t.computeBoundingSphere(),et.copy(t.boundingSphere.center)):(null===e.boundingSphere&&e.computeBoundingSphere(),et.copy(e.boundingSphere.center)),et.applyMatrix4(t.matrixWorld).applyMatrix4(Q)),Array.isArray(r)){const n=e.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&M.push(t,e,o,i,et.z,a)}}else r.visible&&M.push(t,e,r,i,et.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)ee(r[t],e,i,n)}function ie(t,e,i,n){const{opaque:r,transmissive:s,transparent:a}=t;S.setupLightsView(i),!0===J&&It.setGlobalState(w.clippingPlanes,i),n&&ut.viewport(F.copy(n)),r.length>0&&re(r,e,i),s.length>0&&re(s,e,i),a.length>0&&re(a,e,i),ut.buffers.depth.setTest(!0),ut.buffers.depth.setMask(!0),ut.buffers.color.setMask(!0),ut.setPolygonOffset(!1)}function ne(t,e,i,n){if(null!==(!0===i.isScene?i.overrideMaterial:null))return;if(void 0===S.state.transmissionRenderTarget[n.id]){const t=at.has("EXT_color_buffer_half_float")||at.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[n.id]=new yi(1,1,{generateMipmaps:!0,type:t?_t:ct,minFilter:ht,samples:Math.max(4,lt.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:oi.workingColorSpace})}const r=S.state.transmissionRenderTarget[n.id],a=n.viewport||F;r.setSize(a.z*w.transmissionResolutionScale,a.w*w.transmissionResolutionScale);const o=w.getRenderTarget(),l=w.getActiveCubeFace(),h=w.getActiveMipmapLevel();w.setRenderTarget(r),w.getClearColor(k),V=w.getClearAlpha(),V<1&&w.setClearColor(16777215,.5),w.clear(),rt&&Ut.render(i);const c=w.toneMapping;w.toneMapping=0;const u=n.viewport;if(void 0!==n.viewport&&(n.viewport=void 0),S.setupLightsView(n),!0===J&&It.setGlobalState(w.clippingPlanes,n),re(t,i,n),gt.updateMultisampleRenderTarget(r),gt.updateRenderTargetMipmap(r),!1===at.has("WEBGL_multisampled_render_to_texture")){let t=!1;for(let r=0,s=e.length;r<s;r++){const s=e[r],{object:a,geometry:o,material:l,group:h}=s;if(2===l.side&&a.layers.test(n.layers)){const e=l.side;l.side=1,l.needsUpdate=!0,se(a,i,n,o,l,h),l.side=e,l.needsUpdate=!0,t=!0}}!0===t&&(gt.updateMultisampleRenderTarget(r),gt.updateRenderTargetMipmap(r))}w.setRenderTarget(o,l,h),w.setClearColor(k,V),void 0!==u&&(n.viewport=u),w.toneMapping=c}function re(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],{object:a,geometry:o,group:l}=s;let h=s.material;!0===h.allowOverride&&null!==n&&(h=n),a.layers.test(i.layers)&&se(a,e,i,o,h,l)}}function se(t,e,i,n,r,s){t.onBeforeRender(w,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),r.onBeforeRender(w,e,i,n,t,s),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,w.renderBufferDirect(i,e,n,r,t,s),r.side=0,r.needsUpdate=!0,w.renderBufferDirect(i,e,n,r,t,s),r.side=2):w.renderBufferDirect(i,e,n,r,t,s),t.onAfterRender(w,e,i,n,r,s)}function ae(t,e,i){!0!==e.isScene&&(e=nt);const n=ft.get(t),r=S.state.lights,s=S.state.shadowsArray,a=r.state.version,o=Tt.getParameters(t,r.state,s,e,i,S.state.lightProbeGridArray),l=Tt.getProgramCacheKey(o);let h=n.programs;n.environment=t.isMeshStandardMaterial||t.isMeshLambertMaterial||t.isMeshPhongMaterial?e.environment:null,n.fog=e.fog;const c=t.isMeshStandardMaterial||t.isMeshLambertMaterial&&!t.envMap||t.isMeshPhongMaterial&&!t.envMap;n.envMap=Mt.get(t.envMap||n.environment,c),n.envMapRotation=null!==n.environment&&null===t.envMap?e.environmentRotation:t.envMapRotation,void 0===h&&(t.addEventListener("dispose",Zt),h=new Map,n.programs=h);let u=h.get(l);if(void 0!==u){if(n.currentProgram===u&&n.lightsStateVersion===a)return le(t,o),u}else o.uniforms=Tt.getUniforms(t),null!==R&&t.isNodeMaterial&&R.build(t,i,o),t.onBeforeCompile(o,w),u=Tt.acquireProgram(o,l),h.set(l,u),n.uniforms=o.uniforms;const d=n.uniforms;return(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(d.clippingPlanes=It.uniform),le(t,o),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=a,n.needsLights&&(d.ambientLightColor.value=r.state.ambient,d.lightProbe.value=r.state.probe,d.directionalLights.value=r.state.directional,d.directionalLightShadows.value=r.state.directionalShadow,d.spotLights.value=r.state.spot,d.spotLightShadows.value=r.state.spotShadow,d.rectAreaLights.value=r.state.rectArea,d.ltc_1.value=r.state.rectAreaLTC1,d.ltc_2.value=r.state.rectAreaLTC2,d.pointLights.value=r.state.point,d.pointLightShadows.value=r.state.pointShadow,d.hemisphereLights.value=r.state.hemi,d.directionalShadowMatrix.value=r.state.directionalShadowMatrix,d.spotLightMatrix.value=r.state.spotLightMatrix,d.spotLightMap.value=r.state.spotLightMap,d.pointShadowMatrix.value=r.state.pointShadowMatrix),n.lightProbeGrid=S.state.lightProbeGridArray.length>0,n.currentProgram=u,n.uniformsList=null,u}function oe(t){if(null===t.uniformsList){const e=t.currentProgram.getUniforms();t.uniformsList=Ah.seqWithValue(e.seq,t.uniforms)}return t.uniformsList}function le(t,e){const i=ft.get(t);i.outputColorSpace=e.outputColorSpace,i.batching=e.batching,i.batchingColor=e.batchingColor,i.instancing=e.instancing,i.instancingColor=e.instancingColor,i.instancingMorph=e.instancingMorph,i.skinning=e.skinning,i.morphTargets=e.morphTargets,i.morphNormals=e.morphNormals,i.morphColors=e.morphColors,i.morphTargetsCount=e.morphTargetsCount,i.numClippingPlanes=e.numClippingPlanes,i.numIntersection=e.numClipIntersection,i.vertexAlphas=e.vertexAlphas,i.vertexTangents=e.vertexTangents,i.toneMapping=e.toneMapping}te.setAnimationLoop(function(t){Jt&&Jt(t)}),"undefined"!=typeof self&&te.setContext(self),this.setAnimationLoop=function(t){Jt=t,Xt.setAnimationLoop(t),null===t?te.stop():te.start()},Xt.addEventListener("sessionstart",$t),Xt.addEventListener("sessionend",Qt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void Oe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===A)return;null!==R&&R.renderStart(t,e);const i=!0===Xt.enabled&&!0===Xt.isPresenting,n=null!==T&&(null===N||i)&&T.begin(w,N);if(!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0!==Xt.enabled||!0!==Xt.isPresenting||null!==T&&!1!==T.isCompositing()||(!0===Xt.cameraAutoUpdate&&Xt.updateCamera(e),e=Xt.getCamera()),!0===t.isScene&&t.onBeforeRender(w,t,e,N),S=Dt.get(t,E.length),S.init(e),S.state.textureUnits=gt.getTextureUnits(),E.push(S),Q.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromProjectionMatrix(Q,Re,e.reversedDepth),$=this.localClippingEnabled,J=It.init(this.clippingPlanes,$),M=Lt.get(t,b.length),M.init(),b.push(M),!0===Xt.enabled&&!0===Xt.isPresenting){const t=w.xr.getDepthSensingMesh();null!==t&&ee(t,e,-1/0,w.sortObjects)}ee(t,e,0,w.sortObjects),M.finish(),!0===w.sortObjects&&M.sort(X,j,e.reversedDepth),rt=!1===Xt.enabled||!1===Xt.isPresenting||!1===Xt.hasDepthSensing(),rt&&Ut.addToRenderList(M,t),this.info.render.frame++,!0===this.info.autoReset&&this.info.reset(),!0===J&&It.beginShadows();const r=S.state.shadowsArray;Nt.render(r,t,e),!0===J&&It.endShadows();if(!1===(n&&T.hasRenderPass())){const i=M.opaque,n=M.transmissive;if(S.setupLights(),e.isArrayCamera){const r=e.cameras;if(n.length>0)for(let e=0,s=r.length;e<s;e++){ne(i,n,t,r[e])}rt&&Ut.render(t);for(let e=0,i=r.length;e<i;e++){const i=r[e];ie(M,t,i,i.viewport)}}else n.length>0&&ne(i,n,t,e),rt&&Ut.render(t),ie(M,t,e)}null!==N&&0===I&&(gt.updateMultisampleRenderTarget(N),gt.updateRenderTargetMipmap(N)),n&&T.end(w),!0===t.isScene&&t.onAfterRender(w,t,e),kt.resetDefaultState(),U=-1,O=null,E.pop(),E.length>0?(S=E[E.length-1],gt.setTextureUnits(S.state.textureUnits),!0===J&&It.setGlobalState(w.clippingPlanes,S.state.camera)):S=null,b.pop(),M=b.length>0?b[b.length-1]:null,null!==R&&R.renderEnd()},this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return I},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(t,e,i){const n=ft.get(t);n.__autoAllocateDepthBuffer=!1===t.resolveDepthBuffer,!1===n.__autoAllocateDepthBuffer&&(n.__useRenderToTexture=!1),ft.get(t.texture).__webglTexture=e,ft.get(t.depthTexture).__webglTexture=n.__autoAllocateDepthBuffer?void 0:i,n.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(t,e){const i=ft.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){N=t,D=e,I=i;let n=null,r=!1,s=!1;if(t){const a=ft.get(t);if(void 0!==a.__useDefaultFramebuffer)return ut.bindFramebuffer(Ht.FRAMEBUFFER,a.__webglFramebuffer),F.copy(t.viewport),z.copy(t.scissor),B=t.scissorTest,ut.viewport(F),ut.scissor(z),ut.setScissorTest(B),void(U=-1);if(void 0===a.__webglFramebuffer)gt.setupRenderTarget(t);else if(a.__hasExternalTextures)gt.rebindTextures(t,ft.get(t.texture).__webglTexture,ft.get(t.depthTexture).__webglTexture);else if(t.depthBuffer){const e=t.depthTexture;if(a.__boundDepthTexture!==e){if(null!==e&&ft.has(e)&&(t.width!==e.image.width||t.height!==e.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");gt.setupDepthRenderbuffer(t)}}const o=t.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);const l=ft.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=Array.isArray(l[e])?l[e][i]:l[e],r=!0):n=t.samples>0&&!1===gt.useMultisampledRTT(t)?ft.get(t).__webglMultisampledFramebuffer:Array.isArray(l)?l[i]:l,F.copy(t.viewport),z.copy(t.scissor),B=t.scissorTest}else F.copy(q).multiplyScalar(W).floor(),z.copy(Y).multiplyScalar(W).floor(),B=Z;0!==i&&(n=C);if(ut.bindFramebuffer(Ht.FRAMEBUFFER,n)&&ut.drawBuffers(t,n),ut.viewport(F),ut.scissor(z),ut.setScissorTest(B),r){const n=ft.get(t.texture);Ht.framebufferTexture2D(Ht.FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,Ht.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(s){const n=e;for(let e=0;e<t.textures.length;e++){const r=ft.get(t.textures[e]);Ht.framebufferTextureLayer(Ht.FRAMEBUFFER,Ht.COLOR_ATTACHMENT0+e,r.__webglTexture,i,n)}}else if(null!==t&&0!==i){const e=ft.get(t.texture);Ht.framebufferTexture2D(Ht.FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,Ht.TEXTURE_2D,e.__webglTexture,i)}U=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)return void Oe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ft.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){ut.bindFramebuffer(Ht.FRAMEBUFFER,l);try{const a=t.textures[o],l=a.format,h=a.type;if(t.textures.length>1&&Ht.readBuffer(Ht.COLOR_ATTACHMENT0+o),!lt.textureFormatReadable(l))return void Oe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!lt.textureTypeReadable(h))return void Oe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&Ht.readPixels(e,i,n,r,Bt.convert(l),Bt.convert(h),s)}finally{const t=null!==N?ft.get(N).__webglFramebuffer:null;ut.bindFramebuffer(Ht.FRAMEBUFFER,t)}}},this.readRenderTargetPixelsAsync=async function(t,e,i,n,r,s,a,o=0){if(!t||!t.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ft.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(l=l[a]),l){if(e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r){ut.bindFramebuffer(Ht.FRAMEBUFFER,l);const a=t.textures[o],h=a.format,c=a.type;if(t.textures.length>1&&Ht.readBuffer(Ht.COLOR_ATTACHMENT0+o),!lt.textureFormatReadable(h))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!lt.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const u=Ht.createBuffer();Ht.bindBuffer(Ht.PIXEL_PACK_BUFFER,u),Ht.bufferData(Ht.PIXEL_PACK_BUFFER,s.byteLength,Ht.STREAM_READ),Ht.readPixels(e,i,n,r,Bt.convert(h),Bt.convert(c),0);const d=null!==N?ft.get(N).__webglFramebuffer:null;ut.bindFramebuffer(Ht.FRAMEBUFFER,d);const p=Ht.fenceSync(Ht.SYNC_GPU_COMMANDS_COMPLETE,0);return Ht.flush(),await function(t,e,i){return new Promise(function(n,r){setTimeout(function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(s,i);break;default:n()}},i)})}(Ht,p,4),Ht.bindBuffer(Ht.PIXEL_PACK_BUFFER,u),Ht.getBufferSubData(Ht.PIXEL_PACK_BUFFER,0,s),Ht.deleteBuffer(u),Ht.deleteSync(p),s}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(t,e=null,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n),a=null!==e?e.x:0,o=null!==e?e.y:0;gt.setTexture2D(t,0),Ht.copyTexSubImage2D(Ht.TEXTURE_2D,i,0,0,a,o,r,s),ut.unbindTexture()},this.copyTextureToTexture=function(t,e,i=null,n=null,r=0,s=0){let a,o,l,h,c,u,d,p,f;const m=t.isCompressedTexture?t.mipmaps[s]:t.image;if(null!==i)a=i.max.x-i.min.x,o=i.max.y-i.min.y,l=i.isBox3?i.max.z-i.min.z:1,h=i.min.x,c=i.min.y,u=i.isBox3?i.min.z:0;else{const e=Math.pow(2,-r);a=Math.floor(m.width*e),o=Math.floor(m.height*e),l=t.isDataArrayTexture?m.depth:t.isData3DTexture?Math.floor(m.depth*e):1,h=0,c=0,u=0}null!==n?(d=n.x,p=n.y,f=n.z):(d=0,p=0,f=0);const g=Bt.convert(e.format),_=Bt.convert(e.type);let v;e.isData3DTexture?(gt.setTexture3D(e,0),v=Ht.TEXTURE_3D):e.isDataArrayTexture||e.isCompressedArrayTexture?(gt.setTexture2DArray(e,0),v=Ht.TEXTURE_2D_ARRAY):(gt.setTexture2D(e,0),v=Ht.TEXTURE_2D),ut.activeTexture(Ht.TEXTURE0),ut.pixelStorei(Ht.UNPACK_FLIP_Y_WEBGL,e.flipY),ut.pixelStorei(Ht.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),ut.pixelStorei(Ht.UNPACK_ALIGNMENT,e.unpackAlignment);const x=ut.getParameter(Ht.UNPACK_ROW_LENGTH),y=ut.getParameter(Ht.UNPACK_IMAGE_HEIGHT),M=ut.getParameter(Ht.UNPACK_SKIP_PIXELS),S=ut.getParameter(Ht.UNPACK_SKIP_ROWS),b=ut.getParameter(Ht.UNPACK_SKIP_IMAGES);ut.pixelStorei(Ht.UNPACK_ROW_LENGTH,m.width),ut.pixelStorei(Ht.UNPACK_IMAGE_HEIGHT,m.height),ut.pixelStorei(Ht.UNPACK_SKIP_PIXELS,h),ut.pixelStorei(Ht.UNPACK_SKIP_ROWS,c),ut.pixelStorei(Ht.UNPACK_SKIP_IMAGES,u);const E=t.isDataArrayTexture||t.isData3DTexture,T=e.isDataArrayTexture||e.isData3DTexture;if(t.isDepthTexture){const i=ft.get(t),n=ft.get(e),m=ft.get(i.__renderTarget),g=ft.get(n.__renderTarget);ut.bindFramebuffer(Ht.READ_FRAMEBUFFER,m.__webglFramebuffer),ut.bindFramebuffer(Ht.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let i=0;i<l;i++)E&&(Ht.framebufferTextureLayer(Ht.READ_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,ft.get(t).__webglTexture,r,u+i),Ht.framebufferTextureLayer(Ht.DRAW_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,ft.get(e).__webglTexture,s,f+i)),Ht.blitFramebuffer(h,c,a,o,d,p,a,o,Ht.DEPTH_BUFFER_BIT,Ht.NEAREST);ut.bindFramebuffer(Ht.READ_FRAMEBUFFER,null),ut.bindFramebuffer(Ht.DRAW_FRAMEBUFFER,null)}else if(0!==r||t.isRenderTargetTexture||ft.has(t)){const i=ft.get(t),n=ft.get(e);ut.bindFramebuffer(Ht.READ_FRAMEBUFFER,P),ut.bindFramebuffer(Ht.DRAW_FRAMEBUFFER,L);for(let t=0;t<l;t++)E?Ht.framebufferTextureLayer(Ht.READ_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,i.__webglTexture,r,u+t):Ht.framebufferTexture2D(Ht.READ_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,Ht.TEXTURE_2D,i.__webglTexture,r),T?Ht.framebufferTextureLayer(Ht.DRAW_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,n.__webglTexture,s,f+t):Ht.framebufferTexture2D(Ht.DRAW_FRAMEBUFFER,Ht.COLOR_ATTACHMENT0,Ht.TEXTURE_2D,n.__webglTexture,s),0!==r?Ht.blitFramebuffer(h,c,a,o,d,p,a,o,Ht.COLOR_BUFFER_BIT,Ht.NEAREST):T?Ht.copyTexSubImage3D(v,s,d,p,f+t,h,c,a,o):Ht.copyTexSubImage2D(v,s,d,p,h,c,a,o);ut.bindFramebuffer(Ht.READ_FRAMEBUFFER,null),ut.bindFramebuffer(Ht.DRAW_FRAMEBUFFER,null)}else T?t.isDataTexture||t.isData3DTexture?Ht.texSubImage3D(v,s,d,p,f,a,o,l,g,_,m.data):e.isCompressedArrayTexture?Ht.compressedTexSubImage3D(v,s,d,p,f,a,o,l,g,m.data):Ht.texSubImage3D(v,s,d,p,f,a,o,l,g,_,m):t.isDataTexture?Ht.texSubImage2D(Ht.TEXTURE_2D,s,d,p,a,o,g,_,m.data):t.isCompressedTexture?Ht.compressedTexSubImage2D(Ht.TEXTURE_2D,s,d,p,m.width,m.height,g,m.data):Ht.texSubImage2D(Ht.TEXTURE_2D,s,d,p,a,o,g,_,m);ut.pixelStorei(Ht.UNPACK_ROW_LENGTH,x),ut.pixelStorei(Ht.UNPACK_IMAGE_HEIGHT,y),ut.pixelStorei(Ht.UNPACK_SKIP_PIXELS,M),ut.pixelStorei(Ht.UNPACK_SKIP_ROWS,S),ut.pixelStorei(Ht.UNPACK_SKIP_IMAGES,b),0===s&&e.generateMipmaps&&Ht.generateMipmap(v),ut.unbindTexture()},this.initRenderTarget=function(t){void 0===ft.get(t).__webglFramebuffer&&gt.setupRenderTarget(t)},this.initTexture=function(t){t.isCubeTexture?gt.setTextureCube(t,0):t.isData3DTexture?gt.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?gt.setTexture2DArray(t,0):gt.setTexture2D(t,0),ut.unbindTexture()},this.resetState=function(){D=0,I=0,N=null,ut.reset(),kt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Re}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=oi._getDrawingBufferColorSpace(t),e.unpackColorSpace=oi._getUnpackColorSpace()}}const Dc={type:"change"},Ic={type:"start"},Nc={type:"end"},Uc=1e-6,Oc=-1,Fc=0,zc=1,Bc=2,kc=3,Vc=4,Hc=new Je,Gc=new Je,Wc=new Qe,Xc=new Qe,jc=new Qe,qc=new $e,Yc=new Qe,Zc=new Qe,Kc=new Qe,Jc=new Qe;class $c extends Fo{constructor(t,e=null){super(t,e),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:i,MIDDLE:n,RIGHT:r},this.target=new Qe,this.state=Oc,this.keyState=Oc,this._lastPosition=new Qe,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new Qe,this._movePrev=new Je,this._moveCurr=new Je,this._lastAxis=new Qe,this._zoomStart=new Je,this._zoomEnd=new Je,this._panStart=new Je,this._panEnd=new Je,this._pointers=[],this._pointerPositions={},this._onPointerMove=tu.bind(this),this._onPointerDown=Qc.bind(this),this._onPointerUp=eu.bind(this),this._onPointerCancel=iu.bind(this),this._onContextMenu=hu.bind(this),this._onMouseWheel=lu.bind(this),this._onKeyDown=ru.bind(this),this._onKeyUp=nu.bind(this),this._onTouchStart=cu.bind(this),this._onTouchMove=uu.bind(this),this._onTouchEnd=du.bind(this),this._onMouseDown=su.bind(this),this._onMouseMove=au.bind(this),this._onMouseUp=ou.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,null!==e&&(this.connect(e),this.handleResize()),this.update()}connect(t){super.connect(t),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction=""}dispose(){this.disconnect()}handleResize(){const t=this.domElement.getBoundingClientRect(),e=this.domElement.ownerDocument.documentElement;this.screen.left=t.left+window.pageXOffset-e.clientLeft,this.screen.top=t.top+window.pageYOffset-e.clientTop,this.screen.width=t.width,this.screen.height=t.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>Uc&&(this.dispatchEvent(Dc),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>Uc||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(Dc),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Oc,this.keyState=Oc,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(Dc),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Gc.copy(this._panEnd).sub(this._panStart),Gc.lengthSq()){if(this.object.isOrthographicCamera){const t=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,e=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Gc.x*=t,Gc.y*=e}Gc.multiplyScalar(this._eye.length()*this.panSpeed),Xc.copy(this._eye).cross(this.object.up).setLength(Gc.x),Xc.add(Wc.copy(this.object.up).setLength(Gc.y)),this.object.position.add(Xc),this.target.add(Xc),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Gc.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Jc.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let t=Jc.length();t?(this._eye.copy(this.object.position).sub(this.target),Yc.copy(this._eye).normalize(),Zc.copy(this.object.up).normalize(),Kc.crossVectors(Zc,Yc).normalize(),Zc.setLength(this._moveCurr.y-this._movePrev.y),Kc.setLength(this._moveCurr.x-this._movePrev.x),Jc.copy(Zc.add(Kc)),jc.crossVectors(Jc,this._eye).normalize(),t*=this.rotateSpeed,qc.setFromAxisAngle(jc,t),this._eye.applyQuaternion(qc),this.object.up.applyQuaternion(qc),this._lastAxis.copy(jc),this._lastAngle=t):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),qc.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(qc),this.object.up.applyQuaternion(qc)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let t;this.state===Vc?(t=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom=Ke.clamp(this.object.zoom/t,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(t=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,1!==t&&t>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(t):this.object.isOrthographicCamera?(this.object.zoom=Ke.clamp(this.object.zoom/t,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(t,e){return Hc.set((t-this.screen.left)/this.screen.width,(e-this.screen.top)/this.screen.height),Hc}_getMouseOnCircle(t,e){return Hc.set((t-.5*this.screen.width-this.screen.left)/(.5*this.screen.width),(this.screen.height+2*(this.screen.top-e))/this.screen.width),Hc}_addPointer(t){this._pointers.push(t)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId==t.pointerId)return void this._pointers.splice(e,1)}_trackPointer(t){let e=this._pointerPositions[t.pointerId];void 0===e&&(e=new Je,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[e.pointerId]}_checkDistances(){this.noZoom&&this.noPan||(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}}function Qc(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t))}function tu(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function eu(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchEnd(t):this._onMouseUp(),this._removePointer(t),0===this._pointers.length&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp)))}function iu(t){this._removePointer(t)}function nu(){!1!==this.enabled&&(this.keyState=Oc,window.addEventListener("keydown",this._onKeyDown))}function ru(t){!1!==this.enabled&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===Oc&&(t.code!==this.keys[Fc]||this.noRotate?t.code!==this.keys[zc]||this.noZoom?t.code!==this.keys[Bc]||this.noPan||(this.keyState=Bc):this.keyState=zc:this.keyState=Fc))}function su(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case n:this.state=zc;break;case i:this.state=Fc;break;case r:this.state=Bc;break;default:this.state=Oc}const s=this.keyState!==Oc?this.keyState:this.state;s!==Fc||this.noRotate?s!==zc||this.noZoom?s!==Bc||this.noPan||(this._panStart.copy(this._getMouseOnScreen(t.pageX,t.pageY)),this._panEnd.copy(this._panStart)):(this._zoomStart.copy(this._getMouseOnScreen(t.pageX,t.pageY)),this._zoomEnd.copy(this._zoomStart)):(this._moveCurr.copy(this._getMouseOnCircle(t.pageX,t.pageY)),this._movePrev.copy(this._moveCurr)),this.dispatchEvent(Ic)}function au(t){const e=this.keyState!==Oc?this.keyState:this.state;e!==Fc||this.noRotate?e!==zc||this.noZoom?e!==Bc||this.noPan||this._panEnd.copy(this._getMouseOnScreen(t.pageX,t.pageY)):this._zoomEnd.copy(this._getMouseOnScreen(t.pageX,t.pageY)):(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(t.pageX,t.pageY)))}function ou(){this.state=Oc,this.dispatchEvent(Nc)}function lu(t){if(!1!==this.enabled&&!0!==this.noZoom){switch(t.preventDefault(),t.deltaMode){case 2:this._zoomStart.y-=.025*t.deltaY;break;case 1:this._zoomStart.y-=.01*t.deltaY;break;default:this._zoomStart.y-=25e-5*t.deltaY}this.dispatchEvent(Ic),this.dispatchEvent(Nc)}}function hu(t){!1!==this.enabled&&t.preventDefault()}function cu(t){if(this._trackPointer(t),1===this._pointers.length)this.state=kc,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);else{this.state=Vc;const t=this._pointers[0].pageX-this._pointers[1].pageX,e=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(t*t+e*e);const i=(this._pointers[0].pageX+this._pointers[1].pageX)/2,n=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(i,n)),this._panEnd.copy(this._panStart)}this.dispatchEvent(Ic)}function uu(t){if(this._trackPointer(t),1===this._pointers.length)this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(t.pageX,t.pageY));else{const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,n=t.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(i*i+n*n);const r=(t.pageX+e.x)/2,s=(t.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(r,s))}}function du(t){switch(this._pointers.length){case 0:this.state=Oc;break;case 1:this.state=kc,this._moveCurr.copy(this._getMouseOnCircle(t.pageX,t.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=Vc;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==t.pointerId){const t=this._pointerPositions[this._pointers[e].pointerId];this._moveCurr.copy(this._getMouseOnCircle(t.x,t.y)),this._movePrev.copy(this._moveCurr);break}}this.dispatchEvent(Nc)}class pu extends er{vertices;constructor(t,e,i,n=!1){super(),this.vertices=[];const r=e+1,s=1/e,a=1/r,o=1/i,l=1/(i+1),h=[],c=[],u=[];for(let n=0;n<=i;n++)for(let i=0;i<=e;i++){const e=new Qe(n*o-.5,t(n,i),.5-i*s);this.vertices.push(e),h.push(e.x,e.y,e.z),c.push(i*a,n*l)}for(let t=0;t<i;t++)for(let i=0;i<e;i++){const e=t*r+i,s=e+1,a=(t+1)*r+i,o=a+1;n?u.push(e,s,a,s,o,a):u.push(e,s,o,e,o,a)}const d=this;d.setAttribute("position",new Gn(h,3)),d.setAttribute("uv",new Gn(c,2)),d.setIndex(u),d.computeVertexNormals(),d.computeBoundingBox()}}function fu(){return"undefined"!=typeof HTMLCanvasElement}function mu(t,e){if(null==t)throw new Error(`The 3D ${e} is not available: enable the chart for 3D first`);return t}function gu(t){const e=new er;return t[0],e.setFromPoints(t),e}class _u{beginPath(){this.items=[],this.closedPath=!1}closePath(){this.closedPath=!0}moveTo(t,e,i){this.items.push({kind:0,x:t,y:e,z:i})}lineTo(t,e,i){this.items.push({kind:1,x:t,y:e,z:i})}lineZ(t,e,i,n){this.moveTo(t,e,i),this.lineTo(t,e,n)}bezierCurveTo(t,e,i,n,r,s){this.items.push({kind:11,a:t,b:e,c:i,d:n,e:r,f:s})}quadraticCurveTo(t,e,i,n){this.items.push({kind:7,x:t,y:e,width:i,height:n})}arc(t,e,i,n,r,s=!1){this.items.push({kind:4,x:t,y:e,radius:i,angle:n,endAngle:r,clockwise:s})}spline(t,e){if(this.items=[],this.path=0,e){const e=[];for(let i=0;i<t.length;i+=2)e.push(new Je(t[i],-t[i+1]));return void this.items.push({kind:12,p:e})}const i=new Us([]);for(let e=0;e<t.length;e+=2)i.points.push(new Qe(t[e],-t[e+1],0));this.items.push({kind:8,geo:i})}setLineDash(t){this.dash=t}constructor(t){function e(t,e,i,n){const r=(2-i)*n;return t.setHSL(e,i*n/r,.5*r)}function i(t,e,i,n,r,s,a,o){var l;if(t){const e=new Lr({vertexColors:!0});e.wireframe=t,l=e}else l=e;t||(l.side=2);var h=new Gr(r,l),u=o-a;o===a&&(u=1);var d=a+.5*u,f=n.height/u;h.position.set(n.x+.5*(n.width-T),n.y+.5*(n.height-w)-d*f,.5*-c),h.scale.set(n.width,f,c*s),M.showShadows&&(h.castShadow=!0),mu(p,"parent").add(h)}this.setEnabled=function(t,e){if(this.destroyed||!e)return;let i;if(!t||!Detector||Detector.webgl){if(this.__webgl=t,t&&e?._eventCleanups&&this._cleanupChart!==e&&(this._cleanupChart=e,e._eventCleanups.push(()=>this.destroy())),t)C&&(e.__webgl=!0,e.canvas.style.display="none",e.canvas=this,e.interactionCanvas=C.domElement,e.ctx=this,C?.domElement&&(C.domElement.style.display="block"));else{if(i=E,d||fu()&&(d=document.createElement("canvas"),i instanceof HTMLCanvasElement?(i.parentElement?.appendChild(d),d.style.background=i.style.background):i.appendChild(d)),!d)return;if(d.setAttribute("width",String(i.width)),d.setAttribute("height",String(i.height)),d.height=i.clientHeight,d.width=i.clientWidth,C?.domElement?C.domElement.style.display="none":fu()&&i instanceof HTMLCanvasElement&&(i.style.display="none"),d&&(d.style.display="block"),e.canvas=d,e.interactionCanvas=d,e.ctx=null,e.__webgl=!1,e.bounds.set(0,0,d.width,d.height),d){d.chart=e;const t=e.domousedown,i=e.domouseup,n=e.domousemove;d.onmousedown=t,d.ontouchstart=t,d.onmouseup=i,d.ontouchstop=i,d.onmousemove=n,d.ontouchmove=n,d.onmousewheel=e._doWheel}}N&&(N.enabled=t),e.aspect.view3d=t,e.draw()}},this.zPos=function(){return c*(1-this.z-.5*this.depth)},this.Gradient=function(){this.colors=[],this.stops=[],this.addColorStop=function(t,e){this.stops.push(t),this.colors.push(e)}},this.clearRect=function(){p&&mu(A,"scene").remove(p),p=new Ki,mu(A,"scene").add(p),this.needsRender=!0},this.surface=function(t,n,r,s,a,o){var l,h=new pu(n,t.x-1,t.y-1,!0);h.computeBoundingBox();var c,u,d=h.boundingBox,p=mu(d,"bou").min.y,f=mu(d,"bou").max.y,m=f-p||1,g=h.vertices,_=[];for(u=0;u<h.vertices.length;u++)e(c=new sn,.7*(f-g[u].y)/m,1,.9),_.push(c.r,c.g,c.b);h.setAttribute("color",new Gn(_,3)),i(!!s,new ka({color:16777215,opacity:this.globalAlpha,wireframe:this.wireframe,vertexColors:!0}),0,r,h,Number(o),p,f),a&&!s&&((l=new Lr({color:this.colorToInt(a),opacity:this.globalAlpha})).wireframe=!0,i(!1,l,0,r,h,Number(o),p,f))},this.slice=function(t,e,i,n,r,s,a,o){this.beveled=void 0!==o&&o,s>0?(this.path=8,this.p=t,this.torus=!!a,this.center=e,this.radius=i,this.angle0=n,this.angle1=r,this.donut=s,this.items=[]):(this.beginPath(),this.moveTo(t.x,t.y),this.arc(e.x,e.y,i,n,r,!1),this.closePath())},this.createLinearGradient=function(){return new this.Gradient},this.createRadialGradient=function(){return new this.Gradient};let n=null;function r(t){var e;M.extrudeOptions.amount=c*M.depth,e=0===M.depth?new Aa(t):new Ea(t,M.extrudeOptions);var i=new Gr(e,M.getMaterial());return M.showShadows&&(i.receiveShadow=!0,i.castShadow=!0),i}function s(t,e,i,n,r,s){t.moveTo(e,i+s),t.lineTo(e,i+r-s),t.quadraticCurveTo(e,i+r,e+s,i+r),t.lineTo(e+n-s,i+r),t.quadraticCurveTo(e+n,i+r,e+n,i+r-s),t.lineTo(e+n,i+s),t.quadraticCurveTo(e+n,i,e+n-s,i),t.lineTo(e+s,i),t.quadraticCurveTo(e,i,e,i+s)}function a(t,e){var i=E;i.width=t,i.height=e,mu(C,"renderer").setSize(t,e),R instanceof uo&&(R.aspect=t/e),mu(R,"camera").updateProjectionMatrix()}this.getMaterial=function(t){var e,i,r,s=this.fillStyle;return t?(n||(r=[`${e="textures/pisa/"}px${i=".png"}`,`${e}nx${i}`,`${e}py${i}`,`${e}ny${i}`,`${e}pz${i}`,`${e}nz${i}`],n=(new Ja).load(r,()=>{M.refresh()})),new Lr({color:16777215,envMap:n})):new Ba({color:this.colorToInt(s),opacity:this.globalAlpha,wireframe:this.wireframe,specular:5592405,map:null})},this.extrudeOptions={amount:1,bevelEnabled:!1,bevelSegments:16,steps:12,curveSegments:64,bevelThickness:10,bevelSize:8},this.getContext=function(){return this},this.beginParent=()=>(f=p,p=new Ki,mu(f,"oldParent").add(p),p),this.endParent=()=>{p=f},this.translate=(t,e)=>{p||(p=new Ji,mu(A,"scene").add(p)),p.matrixAutoUpdate=!1,p.matrix.multiply((new bi).makeTranslation(t,-e,0)),p.matrixWorldNeedsUpdate=!0},this.rotate=t=>{p||(p=new Ji,mu(A,"scene").add(p)),p.matrixAutoUpdate=!1,p.matrix.multiply((new bi).makeRotationZ(-t)),p.matrixWorldNeedsUpdate=!0},this.scale=(t,e)=>{p||(p=new Ji,mu(A,"scene").add(p)),p.matrixAutoUpdate=!1,p.matrix.multiply((new bi).makeScale(t,e,1)),p.matrixWorldNeedsUpdate=!0},this.fill=function(){var t,e,i,n,a,o,l,h,d,f,m,S,b,E,A,R,C,P,L,D=M.getMaterial(),I=this.items,N=I.length,U=this.r,O=Number.NaN,F=Number.NaN;if(N>0)if(8===I[0].kind)i=new Pa(I[0].geo,100,.05*c*this.depth,8,!1),(n=new Gr(i,D)).position.set(.5*-T,.5*w,this.zPos()),mu(p,"parent").add(n);else if(this.closedPath){for(e=new qs,o=0;o<N;o++)0===(a=I[o]).kind?0!==o&&O===a.x&&F===-a.y||(O=a.x,F=-a.y,e.moveTo(O,F)):1===a.kind?0!==o&&O===a.x&&F===-a.y||(O=a.x,F=-a.y,e.lineTo(O,F)):4===a.kind?e.absarc(O,F,a.radius,2*Math.PI-a.angle,2*Math.PI-a.endAngle,a.clockwise):7===a.kind?e.quadraticCurveTo(a.x,a.y,a.width,a.height):11===a.kind?e.bezierCurveTo(a.a,-a.b,a.c,-a.d,a.e,-a.f):12===a.kind&&(e.moveTo(a.p[0].x,a.p[0].y),e.splineThru(a.p));l=!!this.extrudeOptions.bevelEnabled,this.extrudeOptions.bevelEnabled=this.beveled,this.beveled&&(h=.02*Number(this.extrudeOptions.bevelSize),this.depth-=h,this.z+=.5*h),(n=r(e)).position.set(.5*-T,.5*w,this.zPos()-c*this.depth*.5),mu(p,"parent").add(n),this.extrudeOptions.bevelEnabled=l}else{const t=[];for(f=-c*this.depth,D.side=2,o=0;o<N;o++){const e=I[o];t.push(new Qe(e.x,-e.y,0))}d=function(t,e){const i=[],n=[];for(let r=0;r<t.length;r++){const s=t[r];if(i.push(s.x,s.y,0,s.x,s.y,e),r>0){const t=2*(r-1),e=2*r;n.push(t,t+1,e+1,t,e+1,e)}}const r=new er;return r.setAttribute("position",new Gn(i,3)),r.setIndex(n),r.computeVertexNormals(),r}(t,f),(m=new Gr(d,D)).position.set(.5*-T,.5*w,this.zPos()-.5*f),mu(p,"parent").add(m)}else 0===this.depth?this.rx>0?(s(e=new qs,U.x,-U.y,U.width,U.height,this.rx),(n=r(e)).position.set(.5*-T,-U.height+.5*w,this.zPos()),mu(p,"parent").add(n)):6===this.path?((e=new qs).absellipse(0,0,.5*U.width,.5*U.height,0,2*Math.PI,!0),(n=r(e)).position.set(this.cx-.5*T,-this.cy+.5*w,this.zPos()),mu(p,"parent").add(n)):(S=new wa(U.width,U.height),D.side=2,t=new Gr(S,D)):5===this.path?(1===this.topRadius?(g||(g=new ws(1,1,1,32,1)),b=g):(_||(_=new ws(0,1,1,32,1)),b=_),t=new Gr(b,D),E=.5*Math.min(this.vertical?U.width:U.height,c),t.scale.x=E,t.scale.z=E,t.scale.y=this.vertical?U.height:U.width,this.vertical||(t.rotation.z=.5*Math.PI,t.rotation.y=Math.PI)):7===this.path?(y||(y=new Ra(1,32,32)),(t=new Gr(y,D)).scale.set(.5*U.width,.5*U.height,c*this.depth)):6===this.path?((e=new qs).absellipse(0,0,.5*U.width,.5*U.height,0,2*Math.PI,!0),(n=r(e)).position.set(this.cx-.5*T,-this.cy+.5*w,this.zPos()),mu(p,"parent").add(n)):8===this.path?(this.angle0=2*Math.PI-this.angle0,this.angle1=2*Math.PI-this.angle1,this.torus?(A=Math.abs(this.angle1-this.angle0),R=Math.max(16,90*Math.PI/A|0),C=new Ca(this.radius-.5*this.donut,.5*this.donut,16,R,A),(P=new Gr(C,D)).position.set(this.center.x-.5*T,-this.center.y+.5*w,this.zPos()+this.donut),P.rotation.z=this.angle1,mu(p,"parent").add(P)):((e=new qs).moveTo(this.p.x,this.p.y),e.absarc(this.center.x,this.center.y,this.radius,this.angle0,this.angle1,!0),e.absarc(this.center.x,this.center.y,this.donut,this.angle0,this.angle1,!1),l=!!this.extrudeOptions.bevelEnabled,this.extrudeOptions.bevelEnabled=this.beveled,(n=r(e)).position.set(.5*-T,.5*-w,this.zPos()),mu(p,"parent").add(n),this.extrudeOptions.bevelEnabled=l)):(1===u?(v||(v=new Ts(1,1,1)),L=v):(x||(x=new Ts(1,1,1,u,u,u)),L=x),(t=new Gr(L,D)).scale.set(U.width,U.height,c*this.depth));t&&(t.position.set(U.x+.5*U.width-.5*T,-(U.y+.5*U.height)+.5*w,this.zPos()),this.showShadows&&(t.receiveShadow=!0,t.castShadow=!0),mu(p,"parent").add(t))},this.lineMaterial=function(){var t,e={color:this.colorToInt(this.strokeStyle),opacity:this.globalAlpha};if(this.dash&&this.dash.length>0){const i=new Ga(e);i.dashSize=3,i.gapSize=1,t=i}else(t=new ts(e)).linecap=this.cap,t.linejoin=this.join;return t.linewidth=this.lineWidth,t},this.polygon=function(t,e){var i,n,r,s,a,o,l,h=t.length,u=new qs;for(u.moveTo(t[0].x,-t[0].y),i=1;i<h;i++)n=t[i],u.lineTo(n.x,-n.y);if(u.lineTo(t[0].x,-t[0].y),""!==e.fill&&(r=new Aa(u),o=new Ba({color:this.colorToInt(e.fill),opacity:this.globalAlpha,transparent:this.globalAlpha<1}),a=new Gr(r,o),s=c*(1-this.z+this.depth),a.position.set(.5*-T,.5*w,s),this.showShadows&&(a.castShadow=!0),mu(p,"parent").add(a)),""!==e.stroke?.fill){const e=[];for(i=0;i<h;i++)n=t[i],e.push(new Qe(n.x,-n.y,0));r=gu(e),l=new ls(r,this.lineMaterial()),s=c*(1-this.z+this.depth),l.position.set(.5*-T,.5*w,s),mu(p,"parent").add(l)}},this.stroke=function(){var t,e,i,n,r,a,o,l=this.items.length,h=this.lineMaterial();if(l>0){let s=[];for(r=0;r<l;r++){const a=0===(e=this.items[r]).kind||1===e.kind?e.z:void 0;t=void 0===a?this.z:a,t=c*(1-t),0===e.kind?(s.length>0&&(n=gu(s),i=new ls(n,h),mu(p,"parent").add(i)),s=[new Qe(e.x-.5*T,-e.y+.5*w,t)]):1===e.kind&&s.push(new Qe(e.x-.5*T,-e.y+.5*w,t))}s.length>0&&(n=gu(s),i=new ls(n,h),mu(p,"parent").add(i))}else 0===this.depth&&(a=new js,o=this.r,0===this.path||1===this.path?this.rx>0?s(a,o.x,-o.y-o.height,o.width,o.height,this.rx):(a.moveTo(o.x,-o.y-o.height),a.lineTo(o.x+o.width,-o.y-o.height),a.lineTo(o.x+o.width,-o.y),a.lineTo(o.x,-o.y)):6===this.path&&a.absellipse(this.cx,-this.cy,.5*o.width,.5*o.height,0,2*Math.PI,!0),(i=new ls(gu(a.getPoints()),h)).position.set(.5*-T,.5*w,this.zPos()),mu(p,"parent").add(i))},this.measureText=t=>({width:1.4*mu(O,"privateCanvas").measureText(t).width}),this.roundRect=function(t,e,i,n,r,s){this.path=0,this.r={x:t,y:e,width:i,height:n},this.depth=0,this.rx=r,this.ry=s},this.rect=function(t,e,i,n){this.path=0,this.r={x:t,y:e,width:i,height:n},this.depth=0,this.rx=0,this.ry=0},this.fillRect=(t,e,i,n)=>{this.rect(t,e,i,n),this.fill()},this.strokeRect=(t,e,i,n)=>{this.rect(t,e,i,n),this.stroke()},this.cube=function(t,e){this.path=1,this.r=t,this.items=[],u=Number(e)>0?6:1},this.sphere=function(t,e,i,n){m||(m=new Ra(1,32,32));var r=new Gr(m,this.getMaterial());r.position.set(t-.5*T,.5*w-e,this.zPos()),r.scale.set(.5*i,.5*n,.5*Math.min(i,c)),mu(p,"parent").add(r)},this.save=()=>{b.push({parent:p,fillStyle:this.fillStyle,strokeStyle:this.strokeStyle,globalAlpha:this.globalAlpha,lineWidth:this.lineWidth,dash:[...this.dash],z:this.z,depth:this.depth,textDepth:this.textDepth,wireframe:this.wireframe,font:this.font,textAlign:this.textAlign,textBaseline:this.textBaseline,cap:this.cap,join:this.join,hitTest:this.hitTest,r:{...this.r}});const t=new Ji;p?p.add(t):mu(A,"scene").add(t),p=t},this.clip=()=>{const t=this.r;if(![t.x,t.y,t.width,t.height].every(Number.isFinite))return;const e=t.x-T/2,i=t.x+t.width-T/2,n=w/2-t.y,r=w/2-t.y-t.height,s=new Ji;s.userData.clippingPlanes=[new Zr(new Qe(1,0,0),-e),new Zr(new Qe(-1,0,0),i),new Zr(new Qe(0,-1,0),n),new Zr(new Qe(0,1,0),-r)],p?p.add(s):mu(A,"scene").add(s),p=s,C&&(C.localClippingEnabled=!0)},this.restore=()=>{const t=b.pop();t&&(p=t.parent,this.fillStyle=t.fillStyle,this.strokeStyle=t.strokeStyle,this.globalAlpha=t.globalAlpha,this.lineWidth=t.lineWidth,this.dash=t.dash,this.z=t.z,this.depth=t.depth,this.textDepth=t.textDepth,this.wireframe=t.wireframe,this.font=t.font,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline,this.cap=t.cap,this.join=t.join,this.hitTest=t.hitTest,this.r=t.r)},this.colorToInt=t=>{var e="string"==typeof t?t:t.colors[t.colors.length-1];return"#"===e.substr(0,1)?parseInt(e.substr(1),16):function(t){if("rgb("===t.substr(0,4)){const e=t.slice(4,t.length-1).split(",");return parseInt(e[2],10)|parseInt(e[1],10)<<8|parseInt(e[0],10)<<16}switch(t){case"white":default:return 16777215;case"silver":return 14737632;case"darkgray":case"darkgrey":return 8421504;case"black":return 0;case"red":return 16711680;case"green":return 65280;case"blue":return 255}}(e)},this.pyramid=(t,e)=>{},this.ellipsoid=function(t,e){this.path=7,this.r=t,this.vertical=e,this.items=[]},this.cylinder=function(t,e,i){this.path=5,this.r=t,this.topRadius=e,this.vertical=i,this.items=[]},this.ellipsePath=function(t,e,i,n){this.path=6,this.cx=t,this.cy=e,this.r={x:t,y:e,width:i,height:n},this.items=[]},this.addLight=function(t,e,i,n,r,s){var a=new t(e);return a.position.set(i,n,r),a.shadowsEnabled=s,this.showShadows&&s&&(a instanceof fo||a instanceof xo)&&(a.castShadow=!0),mu(A,"scene").add(a),this.lights.push(a),a},this.fillText=function(t,e,i){if(""!==t){var n=function(t){var e,i,n=t.split(" ");for(e=0;e<n.length;e++)if(i=parseFloat(n[e]))return i;return 20}(this.font),r=function(t,e){var i,n,r=S.length;for(i=0;i<r;i++)if((n=S[i]).text===t&&n.size===e)return n.obj;return null}(t,n),s=0;if(!r){const e=document.createElement("canvas"),i=e.getContext("2d");mu(i,"context").font=`${n}px sans-serif`;const s=mu(i,"context").measureText(t);e.width=Math.ceil(s.width+.5*n),e.height=Math.ceil(1.5*n),mu(i,"context").font=`${n}px sans-serif`,mu(i,"context").fillStyle=this.fillStyle,mu(i,"context").fillText(t,.25*n,n),(r=new Mr(new lr({map:new Ms(e),transparent:!0}))).userData.textWidth=s.width,r.userData.textHeight=n,S.push({text:t,obj:r,size:n})}var a=r.userData.textWidth,o=r.userData.textHeight;"center"===this.textAlign?s=-.5*a:"right"!==this.textAlign&&"end"!==this.textAlign||(s=-a);var l=r;l.scale.set(a,o,1);var h="top"===this.textBaseline?o:"middle"===this.textBaseline?.5*o:0;l.position.x=e+s-.5*T,l.position.y=.5*w-i-h+(o-n),l.position.z=1+c*(1-this.z),l.rotation.x=0,l.rotation.y=2*Math.PI,mu(p,"parent").add(l)}},this.update=function(){this.__webgl&&(N?.enabled&&N.update(),this.needsRender&&(this.hitTest&&this.doHitTest(),this.doRender()))},this.setCamera=function(t){R&&mu(A,"scene").remove(R);const e=Math.max(1,E.clientWidth),i=Math.max(1,E.clientHeight);R=t?new uo(45,e/i,.1,1e4):new _o(-e/2,e/2,i/2,-i/2,.1,1e4),this.camera=R,R.lookAt(mu(A,"scene").position),R.position.set(0,0,800),N&&(N.object=R),this.refresh()},this.refresh=function(){this.needsRender=!0,this.update()},this.createTrackball=function(){C&&(N=this.trackBall=new $c(mu(R,"camera"),C.domElement),N.enabled=!0,N.keys=["KeyA","KeyS","KeyD"],N.dynamicDampingFactor=.2,N.noZoom=!0,N.noPan=!0,("undefined"!=typeof navigator?navigator.userAgent.toLowerCase():"").indexOf("mac os x")>-1&&(N.zoomSpeed=.1),N instanceof $c&&N.addEventListener("change",()=>{M.needsRender=!0}))};var o,l={width:0,height:0};function h(){o?(a(l.width,l.height),o=!1):(l.width=E.width,l.height=E.height,a(window.innerWidth,window.innerHeight),o=!0),M.refresh()}document.addEventListener("fullscreenchange",h,!1),document.addEventListener("mozfullscreenchange",h,!1),document.addEventListener("webkitfullscreenchange",h,!1),this.fullScreen=()=>{var t=E,e=t.requestFullscreen||t.mozRequestFullscreen||t.webkitRequestFullscreen||t.msRequestFullScreen;e&&e.call(t)},this.onWindowResize=()=>{const t=Math.max(1,E.clientWidth),e=Math.max(1,E.clientHeight);T=this.width=t,w=this.height=e,R instanceof uo?R.aspect=t/e:R instanceof _o&&(R.left=-t/2,R.right=t/2,R.top=e/2,R.bottom=-e/2),R?.updateProjectionMatrix(),C&&C.setSize(t,e)},this.setShowShadows=function(t){var e,i;for(this.showShadows=t,e=0;e<this.lights.length;e++)((i=this.lights[e])instanceof fo||i instanceof xo)&&i.shadowsEnabled&&(i.castShadow=this.showShadows);mu(I,"floor").receiveShadow=this.showShadows,C&&(C.shadowMap.enabled=this.showShadows,C.shadowMap.type=2,this.showShadows&&(C.shadowMap.autoUpdate=!0))},this.setShowLights=function(t){this.showLights=t;var e,i=this.lights.length;for(e=0;e<i;e++){const i=this.lights[e];if(i.__helper)t=i.visible&&this.showLights,i.__helper.traverse(e=>{e.visible=t});else if(this.showLights){if(i instanceof fo)i.__helper=new Lo(i,16);else if(i instanceof go)i.__helper=new Do(i,16);else{if(!(i instanceof xo))continue;i.__helper=new Oo(i,16)}const t=i.__helper;t&&mu(A,"scene").add(t)}}this.needsRender||this.refresh()},this.showLight=function(t,e){var i=this.lights[t];i.visible=e;const n=i;n.__helper&&(e=e&&this.showLights,n.__helper.traverse(t=>{t.visible=e})),this.refresh()},this.doHitTest=()=>{},this.doRender=function(){C&&(mu(A,"scene").traverse(t=>{if(!(t instanceof Gr||t instanceof ls||t instanceof vs))return;let e=t.parent;for(;e&&!e.userData.clippingPlanes;)e=e.parent;const i=e?.userData.clippingPlanes;if(!i)return;if(t.userData.clippedMaterials)return;const n=(Array.isArray(t.material)?t.material:[t.material]).map(t=>{const e=t.clone();return e.clippingPlanes=i,e});t.material=Array.isArray(t.material)?n:n[0],t.userData.clippedMaterials=!0}),C.render(mu(A,"scene"),mu(R,"camera")),C.shadowMap.autoUpdate=!1,this.stats?.visible&&this.stats.update()),this.needsRender=!1},this.clearTextCache=()=>{S=[]},this.toogle=function(t,e){t.visible=e,t.visual?(t.visual.traverse(t=>{t.visible=e}),this.needsRender=!0):t.chart.draw(),this.update()},this.toggle=this.toogle,this.isEnabled=function(){return!!this.__webgl},this.destroy=function(){this.destroyed||(this.destroyed=!0,document.removeEventListener("fullscreenchange",h,!1),document.removeEventListener("mozfullscreenchange",h,!1),document.removeEventListener("webkitfullscreenchange",h,!1),N?.dispose?.(),d&&(d.onmousedown=d.ontouchstart=null,d.onmouseup=d.ontouchstop=null,d.onmousemove=d.ontouchmove=null,d.onmousewheel=null),A?.traverse?.(t=>{const e=t;if(e.geometry?.dispose?.(),Array.isArray(e.material))for(const t of e.material)t?.dispose?.();else e.material?.dispose?.()}),C?.dispose?.(),C?.domElement!==E&&C?.domElement?.remove?.(),A?.clear?.(),this.__webgl=!1,this.needsRender=!1,this.trackBall=null,this.renderer=null,this.scene=null,this.camera=null)},this.__webgl="undefined"==typeof Detector||!!Detector?.webgl,this.needsRender=!0;const c=200;this.showLights=!1,this.showShadows=!1,this.items=[],this.closedPath=!1,this.r={x:0,y:0,width:0,height:0},this.dash=[],this.fillStyle="#000000",this.strokeStyle="#000000",this.lineWidth=1,this.font="10px sans-serif",this.textAlign="start",this.textBaseline="alphabetic",this.cap="butt",this.join="miter",this.z=0,this.textDepth=0,this.beveled=!1;let u=1,d=null,p=null;this.wireframe=!1,this.globalAlpha=1;let f=null,m=null,g=null,_=null,v=null,x=null,y=null;const M=this;let S=[];const b=[],E="string"==typeof t?document.getElementById(t):t;if(!E)throw new Error("Three requires a valid container element.");let T=E.clientWidth,w=E.clientHeight,A=null,R=null,C=null,P=null,L=null,D=null,I=null,N=null,U=null;fu()&&E instanceof HTMLCanvasElement&&(U=E),this.__webgl&&(A=new on,C=new Lc({antialias:!0,canvas:U??void 0}));let O=null;if(fu()&&(O=document.createElement("canvas").getContext("2d")),this.width=T,this.height=w,this.camera=R,this.scene=A,this.renderer=C,C?C.sortObjects=!1:this.__webgl=!1,this.stats=null,"function"==typeof document.addEventListener&&"undefined"!=typeof Stats){this.stats=new Stats;const t=this.stats;t.visible=!0,t.setVisible=e=>{t.visible=e,t.domElement.style.display=e?"block":"none"}}C&&(C.setSize(T,w),this.showShadows&&(C.shadowMap.enabled=!0,C.shadowMap.type=2));let F="#AAAA77";window.getComputedStyle&&(F=window.getComputedStyle(E).backgroundColor),C&&(C.setClearColor(this.colorToInt(F)),E!==C.domElement&&E.appendChild(C.domElement)),this.lights=[],C&&(this.addLight(fo,12303291,-300,300,400,!0),this.addLight(xo,8947848,400,1800,1600,!1),this.addLight(go,8947848,500,120,-500,!1),this.setShowLights(this.showLights),this.ambientLight=new yo(2236962),P=this.ambientLight,P.visible=!1,mu(A,"scene").add(P),this.hemiLight=new Qa(16777215,16777215,.5),L=this.hemiLight,L.position.y=500,L.visible=!1,mu(A,"scene").add(L),D=null,this.floor=new Gr(new ws(4e3,4e3,50,32,1),new ka({color:this.colorToInt("white"),map:D,opacity:.9,transparent:!0})),I=this.floor,this.showShadows&&(I.receiveShadow=!0),I.position.y=-20-.5*w,mu(A,"scene").add(I),this.trackBall=null,N=this.trackBall,this.setCamera(!0),this.createTrackball()),this.needsRender=!0}}const vu={type:"change"},xu={type:"start"},yu={type:"end"},Mu=new Pr,Su=new Zr,bu=Math.cos(70*Ke.DEG2RAD),Eu=new Qe,Tu=2*Math.PI,wu=-1,Au=0,Ru=1,Cu=2,Pu=3,Lu=4,Du=5,Iu=6,Nu=1e-6;class Uu extends Fo{constructor(t,e=null){super(t,e),this.state=wu,this.target=new Qe,this.cursor=new Qe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:i,MIDDLE:n,RIGHT:r},this.touches={ONE:s,TWO:o},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new Qe,this._lastQuaternion=new $e,this._lastTargetPosition=new Qe,this._quat=(new $e).setFromUnitVectors(t.up,new Qe(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ro,this._sphericalDelta=new Ro,this._scale=1,this._panOffset=new Qe,this._rotateStart=new Je,this._rotateEnd=new Je,this._rotateDelta=new Je,this._panStart=new Je,this._panEnd=new Je,this._panDelta=new Je,this._dollyStart=new Je,this._dollyEnd=new Je,this._dollyDelta=new Je,this._dollyDirection=new Qe,this._mouse=new Je,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Fu.bind(this),this._onPointerDown=Ou.bind(this),this._onPointerUp=zu.bind(this),this._onContextMenu=Xu.bind(this),this._onMouseWheel=Vu.bind(this),this._onKeyDown=Hu.bind(this),this._onTouchStart=Gu.bind(this),this._onTouchMove=Wu.bind(this),this._onMouseDown=Bu.bind(this),this._onMouseMove=ku.bind(this),this._interceptControlDown=ju.bind(this),this._interceptControlUp=qu.bind(this),null!==this.domElement&&this.connect(this.domElement),this.update()}set cursorStyle(t){this._cursorStyle=t,this.domElement.style.cursor="grab"===t?"grab":"auto"}get cursorStyle(){return this._cursorStyle}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1});this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents();this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){null!==this._domElementKeyEvents&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(vu),this.update(),this.state=wu}pan(t,e){this._pan(t,e),this.update()}dollyIn(t){this._dollyIn(t),this.update()}dollyOut(t){this._dollyOut(t),this.update()}rotateLeft(t){this._rotateLeft(t),this.update()}rotateUp(t){this._rotateUp(t),this.update()}update(t=null){const e=this.object.position;Eu.copy(e).sub(this.target),Eu.applyQuaternion(this._quat),this._spherical.setFromVector3(Eu),this.autoRotate&&this.state===wu&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=Tu:i>Math.PI&&(i-=Tu),n<-Math.PI?n+=Tu:n>Math.PI&&(n-=Tu),this._spherical.theta=i<=n?Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const t=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=t!=this._spherical.radius}if(Eu.setFromSpherical(this._spherical),Eu.applyQuaternion(this._quatInverse),e.copy(this.target).add(Eu),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let t=null;if(this.object.isPerspectiveCamera){const e=Eu.length();t=this._clampDistance(e*this._scale);const i=e-t;this.object.position.addScaledVector(this._dollyDirection,i),this.object.updateMatrixWorld(),r=!!i}else if(this.object.isOrthographicCamera){const e=new Qe(this._mouse.x,this._mouse.y,0);e.unproject(this.object);const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=i!==this.object.zoom;const n=new Qe(this._mouse.x,this._mouse.y,0);n.unproject(this.object),this.object.position.sub(n).add(e),this.object.updateMatrixWorld(),t=Eu.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(Mu.origin.copy(this.object.position),Mu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mu.direction))<bu?this.object.lookAt(this.target):(Su.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mu.intersectPlane(Su,this.target))))}else if(this.object.isOrthographicCamera){const t=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),t!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,!!(r||this._lastPosition.distanceToSquared(this.object.position)>Nu||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Nu||this._lastTargetPosition.distanceToSquared(this.target)>Nu)&&(this.dispatchEvent(vu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(t){return null!==t?Tu/60*this.autoRotateSpeed*t:Tu/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Eu.setFromMatrixColumn(e,0),Eu.multiplyScalar(-t),this._panOffset.add(Eu)}_panUp(t,e){!0===this.screenSpacePanning?Eu.setFromMatrixColumn(e,1):(Eu.setFromMatrixColumn(e,0),Eu.crossVectors(this.object.up,Eu)),Eu.multiplyScalar(t),this._panOffset.add(Eu)}_pan(t,e){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Eu.copy(n).sub(this.target);let r=Eu.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/i.clientHeight,this.object.matrix),this._panUp(2*e*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),n=t-i.left,r=e-i.top,s=i.width,a=i.height;this._mouse.x=n/s*2-1,this._mouse.y=-r/a*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(Tu*this._rotateDelta.x/e.clientHeight),this._rotateUp(Tu*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(Tu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-Tu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(Tu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-Tu*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(1===this._pointers.length)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(t){if(1===this._pointers.length)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panStart.set(i,n)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(i*i+n*n);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(1==this._pointers.length)this._rotateEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._rotateEnd.set(i,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(Tu*this._rotateDelta.x/e.clientHeight),this._rotateUp(Tu*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(1===this._pointers.length)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),i=.5*(t.pageX+e.x),n=.5*(t.pageY+e.y);this._panEnd.set(i,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),i=t.pageX-e.x,n=t.pageY-e.y,r=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=.5*(t.pageX+e.x),a=.5*(t.pageY+e.y);this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return void this._pointers.splice(e,1)}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];void 0===e&&(e=new Je,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100}return t.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Ou(t){!1!==this.enabled&&(0===this._pointers.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._isTrackingPointer(t)||(this._addPointer(t),"touch"===t.pointerType?this._onTouchStart(t):this._onMouseDown(t),"grab"===this._cursorStyle&&(this.domElement.style.cursor="grabbing")))}function Fu(t){!1!==this.enabled&&("touch"===t.pointerType?this._onTouchMove(t):this._onMouseMove(t))}function zu(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(yu),this.state=wu,"grab"===this._cursorStyle&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],i=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:i.x,pageY:i.y})}}function Bu(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case n:if(!1===this.enableZoom)return;this._handleMouseDownDolly(t),this.state=Ru;break;case i:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=Cu}else{if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=Au}break;case r:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this._handleMouseDownRotate(t),this.state=Au}else{if(!1===this.enablePan)return;this._handleMouseDownPan(t),this.state=Cu}break;default:this.state=wu}this.state!==wu&&this.dispatchEvent(xu)}function ku(t){switch(this.state){case Au:if(!1===this.enableRotate)return;this._handleMouseMoveRotate(t);break;case Ru:if(!1===this.enableZoom)return;this._handleMouseMoveDolly(t);break;case Cu:if(!1===this.enablePan)return;this._handleMouseMovePan(t)}}function Vu(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===wu&&(t.preventDefault(),this.dispatchEvent(xu),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(yu))}function Hu(t){!1!==this.enabled&&this._handleKeyDown(t)}function Gu(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case s:if(!1===this.enableRotate)return;this._handleTouchStartRotate(t),this.state=Pu;break;case a:if(!1===this.enablePan)return;this._handleTouchStartPan(t),this.state=Lu;break;default:this.state=wu}break;case 2:switch(this.touches.TWO){case o:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchStartDollyPan(t),this.state=Du;break;case l:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchStartDollyRotate(t),this.state=Iu;break;default:this.state=wu}break;default:this.state=wu}this.state!==wu&&this.dispatchEvent(xu)}function Wu(t){switch(this._trackPointer(t),this.state){case Pu:if(!1===this.enableRotate)return;this._handleTouchMoveRotate(t),this.update();break;case Lu:if(!1===this.enablePan)return;this._handleTouchMovePan(t),this.update();break;case Du:if(!1===this.enableZoom&&!1===this.enablePan)return;this._handleTouchMoveDollyPan(t),this.update();break;case Iu:if(!1===this.enableZoom&&!1===this.enableRotate)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=wu}}function Xu(t){!1!==this.enabled&&t.preventDefault()}function ju(t){if("Control"===t.key){this._controlActive=!0;this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}function qu(t){if("Control"===t.key){this._controlActive=!1;this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0})}}function Yu(t,e,i="#222222"){const n=new Ki;if(n.userData.text=t,"undefined"==typeof document)return n;const r=document.createElement("canvas"),s=r.getContext("2d");if(!s)return n;s.font="32px sans-serif",r.width=Math.max(1,Math.ceil(s.measureText(t).width+8)),r.height=48,s.font="32px sans-serif",s.fillStyle=i,s.textBaseline="middle",s.fillText(t,4,24);const a=new Ms(r),o=new Mr(new lr({map:a,transparent:!0,depthWrite:!1}));return o.scale.set(e*r.width/r.height,e,1),o.userData.text=t,o}function Zu(t){const e=t.width??10,i=t.height??6,n=t.depth??4;if(![e,i,n].every(t=>Number.isFinite(t)&&t>0))throw new RangeError("Chart dimensions must be positive finite numbers");if(void 0!==t.axis?.increment&&(!Number.isFinite(t.axis.increment)||t.axis.increment<=0))throw new RangeError("Axis increment must be a positive finite number");if(void 0!==t.axis?.decimals&&(!Number.isInteger(t.axis.decimals)||t.axis.decimals<0||t.axis.decimals>20))throw new RangeError("Axis decimals must be an integer from 0 to 20");for(const e of t.series){if(e.x&&("surface"===e.type||"colorGrid"===e.type||"pie"===e.type||"donut"===e.type||"sliced"===e.type))throw new TypeError(`Explicit X values are not supported for ${e.type} series`);if(e.x&&(e.x.length!==e.values.length||!e.x.every(Number.isFinite)))throw new RangeError("Series X values must be finite and match the number of values");if(void 0!==e.transparency&&(!Number.isFinite(e.transparency)||e.transparency<0||e.transparency>1))throw new RangeError("Series transparency must be between 0 and 1");if(e.marks&&("pie"===e.type||"donut"===e.type||"sliced"===e.type||"surface"===e.type||"colorGrid"===e.type))throw new TypeError(`Marks are not yet supported for ${e.type} series`);if(e.stacked&&"bar"!==e.type)throw new TypeError("Stacking is currently supported only for bars");if("surface"===e.type||"colorGrid"===e.type){const t=e.columns??0,i=e.rows??e.values.length/t;if(!Number.isInteger(t)||t<2||!Number.isInteger(i)||i<2||e.values.length!==t*i)throw new RangeError(`A ${e.type} requires a rectangular grid with at least two rows and columns`)}}const r=new on;r.background=new sn(t.background??"#ffffff"),r.add(new yo(16777215,1.5));const s=new xo(16777215,2);if(s.position.set(4,8,6),r.add(s),t.walls){const t=new Gr(new wa(e,i),new za({color:"#f4f5f6",side:2}));t.name="back-wall",t.position.z=-n/2-.01,r.add(t)}if(t.floor){const t=new Gr(new wa(e,n),new za({color:"#eceef0",side:2}));t.name="floor",t.rotation.x=-Math.PI/2,t.position.y=-i/2-.01,r.add(t)}const a=t.series.map((t,e)=>({series:t,index:e})).filter(t=>!1!==t.series.visible),o=a.filter(({series:t})=>"bar"===t.type&&t.stacked);if(o.some(({series:t})=>"100"===t.stacked)&&o.some(({series:t})=>!0===t.stacked))throw new TypeError("Cannot mix percentage and absolute bar stacks");if(o.length>1){const t=o[0].series;for(const{series:e}of o.slice(1)){const i=Math.min(t.values.length,e.values.length);for(let n=0;n<i;n++)if((t.x?.[n]??n)!==(e.x?.[n]??n))throw new RangeError("Stacked bars must have matching X positions")}}let l=0,h=0,c=1;const u=[],d=[],p=[];for(const{series:t}of a)if("pie"!==t.type&&"donut"!==t.type&&"sliced"!==t.type&&"colorGrid"!==t.type){c=Math.max(c,"surface"===t.type?t.columns??0:t.values.length);for(const[e,i]of t.values.entries())if(Number.isFinite(i)){if("bar"===t.type&&"100"===t.stacked){p[e]=(p[e]??0)+Math.abs(i);continue}if("bar"===t.type&&t.stacked){const t=i>=0?u:d;t[e]=(t[e]??0)+i}l=Math.min(l,i),h=Math.max(h,i)}}for(const t of u)void 0!==t&&(h=Math.max(h,t));for(const t of d)void 0!==t&&(l=Math.min(l,t));const f=[];if(o.some(({series:t})=>"100"===t.stacked)){h=Math.max(h,100);for(const{series:t}of o)t.values.forEach((t,e)=>{if(!Number.isFinite(t))return;const i=p[e]?100*t/p[e]:0;f[e]=(f[e]??0)+i,l=Math.min(l,f[e])})}if(void 0!==t.axis?.minimum&&(l=t.axis.minimum),void 0!==t.axis?.maximum&&(h=t.axis.maximum),!Number.isFinite(l)||!Number.isFinite(h)||l>h)throw new RangeError("Axis minimum and maximum must be finite and ordered");if(l===h){if(void 0!==t.axis?.minimum||void 0!==t.axis?.maximum)throw new RangeError("Axis minimum must be less than maximum");h=l+1}const m=e=>{const n=(e-l)/(h-l);return(t.axis?.inverted?1-n:n)*i-i/2},g=t.axis?.increment??(h-l)/5,_=Math.floor((h-l)/g+1e-10)+1;if(!Number.isFinite(_)||_>1e3)throw new RangeError("Axis increment produces more than 1000 ticks");const v=Array.from({length:_},(t,e)=>l+g*e),x=m(Math.max(l,Math.min(h,0))),y=e/c,M=a.some(({series:t})=>void 0!==t.x);let S=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY;if(M)for(const{series:t}of a)"pie"!==t.type&&"donut"!==t.type&&"sliced"!==t.type&&"surface"!==t.type&&"colorGrid"!==t.type&&t.values.forEach((e,i)=>{const n=t.x?.[i]??i;S=Math.min(S,n),b=Math.max(b,n)});const E=(t,i)=>M?b<=S?0:-e/2+y/2+((t.x?.[i]??i)-S)*(e-y)/(b-S):-e/2+y*(i+.5),T=n/Math.max(1,a.length),w=["#2878b5","#e27c36","#59a868","#ba5b87"],A=[],R=[],C=[],P=(t,e,i)=>"100"===t.stacked?p[i]?100*e/p[i]:0:e;if(t.title){const e=Yu(t.title,.14*i);e.name="title",e.position.set(0,.65*i,0),r.add(e)}if(t.subtitle){const e=Yu(t.subtitle,.09*i,"#555555");e.name="subtitle",e.position.set(0,.52*i,0),r.add(e)}if(t.footer){const e=Yu(t.footer,.08*i,"#555555");e.name="footer",e.position.set(0,.68*-i,0),r.add(e)}if(!1!==t.axis?.visible&&(0===a.length||a.some(({series:t})=>"pie"!==t.type&&"donut"!==t.type&&"sliced"!==t.type))){const s=new Ji;s.name="axes";const o=new ts({color:t.axis?.color??"#444444"}),l=[new Qe(-e/2,-i/2,-n/2),new Qe(-e/2,i/2,-n/2),new Qe(-e/2,-i/2,-n/2),new Qe(e/2,-i/2,-n/2)];if(s.add(new ds((new er).setFromPoints(l),o)),!1!==t.axis?.gridVisible){const i=[];for(const t of v){const r=m(t);i.push(new Qe(-e/2,r,-n/2)),i.push(new Qe(e/2,r,-n/2))}s.add(new ds((new er).setFromPoints(i),new ts({color:t.axis?.gridColor??"#dddddd"})))}for(const r of!1===t.axis?.labelsVisible?[]:v){const a=void 0===t.axis?.decimals?Number(r.toPrecision(4)).toString():r.toFixed(t.axis.decimals),o=Yu(t.axis?.fixedDecimals||void 0===t.axis?.decimals?a:Number(a).toString(),.1*i);o.name="axis-label",o.position.set(.56*-e,m(r),-n/2),s.add(o)}if(t.axis?.title){const r=Yu(t.axis.title,.12*i);r.name="axis-title",r.position.set(.68*-e,0,-n/2),s.add(r)}const h=a.find(({series:t})=>"pie"!==t.type&&"donut"!==t.type&&"sliced"!==t.type&&"surface"!==t.type)?.series;t.labels?.forEach((t,r)=>{if(r>=c)return;const a=Yu(t,.1*i);a.name="category-label",a.position.set(h&&r<h.values.length?E(h,r):-e/2+y*(r+.5),.58*-i,-n/2),s.add(a)}),r.add(s)}return a.forEach(({series:s,index:a},o)=>{const c=new Ji;c.userData.seriesIndex=a,c.userData.seriesType=s.type,r.add(c);const u=s.color??w[o%w.length],d=1-(s.transparency??0),p={color:u,opacity:d,transparent:d<1};if(t.legend&&s.label){const t=Yu(s.label,.1*i,u);t.name="legend-label",t.position.set(.62*e,.45*i-o*i*.1,0),r.add(t)}const f="bar"===s.type&&s.stacked?0:-n/2+T*(o+.5),g=s.values.map((t,e)=>{if("bar"!==s.type||!s.stacked||!Number.isFinite(t))return 0;const i="100"===s.stacked?C:t>=0?A:R,n=i[e]??0;return i[e]=n+P(s,t,e),n});if(s.marks&&"pie"!==s.type&&"donut"!==s.type&&"sliced"!==s.type&&"surface"!==s.type&&"colorGrid"!==s.type&&s.values.forEach((t,e)=>{const n=P(s,t,e)+g[e];if(!Number.isFinite(t)||n<l||n>h)return;const r=Yu(String(t),.09*i,u);r.name="series-mark",r.position.set(E(s,e),m(n)+.07*i,f),c.add(r)}),"line"===s.type||"area"===s.type){const t=[],e=[];if(s.values.forEach((i,n)=>{!Number.isFinite(i)||i<l||i>h||(t.push(E(s,n),m(i),f),e.push(n))}),e.length>0){const i=new er;i.setAttribute("position",new Gn(t,3));const n=new vs(i,new ps({visible:!1}));n.name="point-targets",n.userData.pointIndices=e,n.userData.values=s.values,c.add(n)}}if("surface"===s.type||"colorGrid"===s.type){const t=s.columns??0,n=s.rows??s.values.length/t;if("colorGrid"===s.type){const r=Math.min(...s.values.filter(Number.isFinite)),a=Math.max(...s.values.filter(Number.isFinite)),o=e/t,l=T/n,h=new za({...p,side:2});s.values.forEach((n,s)=>{if(!Number.isFinite(n))return;const u=a===r?.5:(n-r)/(a-r),d=h.clone();d.color.setHSL(.68-.68*u,.78,.52);const p=Math.floor(s/t),m=s%t,g=new Gr(new Ts(.98*o,.012*i,.98*l),d);g.position.set(-e/2+o*(m+.5),.12*-i,f-T/2+l*(p+.5)),g.userData.pointIndex=s,g.userData.value=n,c.add(g)}),h.dispose()}else{const i=[],r=[];for(let r=0;r<n;r++)for(let a=0;a<t;a++){const o=s.values[r*t+a];i.push(-e/2+e*a/(t-1),m(Number.isFinite(o)?Math.max(l,Math.min(h,o)):l),f-T/2+T*r/(n-1))}for(let e=0;e<n-1;e++)for(let i=0;i<t-1;i++){const n=e*t+i,a=n+1,o=n+t,l=o+1;[n,a,o].every(t=>Number.isFinite(s.values[t]))&&r.push(n,o,a),[a,o,l].every(t=>Number.isFinite(s.values[t]))&&r.push(a,o,l)}if(r.length>0){const t=new er;t.setAttribute("position",new Gn(i,3)),t.setIndex(r),t.computeVertexNormals();const e=new Gr(t,new za({...p,side:2,wireframe:s.wireframe}));e.userData.surfaceValues=s.values,c.add(e)}}}else if("sliced"===s.type){const t=s.values.reduce((t,e)=>t+(Number.isFinite(e)?Math.abs(e):0),0);let n=-e/2;s.values.forEach((r,a)=>{if(!Number.isFinite(r)||0===r||0===t)return;const o=e*Math.abs(r)/t,l=new za({...p,color:s.color??w[a%w.length]}),h=new Gr(new Ts(.98*o,.72*i,.72*T),l);h.position.set(n+o/2,0,f),h.userData.pointIndex=a,h.userData.value=r,c.add(h),n+=o})}else if("pie"===s.type||"donut"===s.type){const t=s.values.reduce((t,e)=>t+(Number.isFinite(e)?Math.abs(e):0),0),n=.4*Math.min(e,i),r="donut"===s.type?.5*n:0;let a=0;s.values.forEach((e,i)=>{if(!Number.isFinite(e)||0===e||0===t)return;const o=a+Math.abs(e)/t*Math.PI*2,l=new qs;l.moveTo(r*Math.cos(a),r*Math.sin(a)),l.lineTo(n*Math.cos(a),n*Math.sin(a)),l.absarc(0,0,n,a,o,!1),l.lineTo(r*Math.cos(o),r*Math.sin(o)),r>0&&l.absarc(0,0,r,o,a,!0),l.closePath();const h=new za({...p,color:s.color??w[i%w.length]}),u=new Gr(new Ea(l,{depth:.5*T,bevelEnabled:!1}),h);u.position.z=f-.25*T,u.userData.pointIndex=i,u.userData.value=e,c.add(u),a=o})}else if("bar"===s.type||"volume"===s.type){const t=new za(p);s.values.forEach((e,i)=>{if(!Number.isFinite(e)||0===e)return;const n=m(Math.max(l,Math.min(h,g[i]))),r=m(Math.max(l,Math.min(h,g[i]+P(s,e,i))));if(r===n)return;const a=new Gr(new Ts(y*("volume"===s.type?.1:.7),Math.abs(r-n),T*("volume"===s.type?.1:.7)),t);a.position.set(E(s,i),(n+r)/2,f),a.userData.pointIndex=i,a.userData.value=e,c.add(a)}),c.children.some(t=>t instanceof Gr)||t.dispose()}else if("point"===s.type||"bubble"===s.type){const t=new za(p),e=Math.max(1,...(s.radii??[]).filter(t=>Number.isFinite(t)&&t>0));s.values.forEach((i,n)=>{if(!Number.isFinite(i)||i<l||i>h)return;const r="bubble"===s.type?Math.sqrt(Math.max(0,s.radii?.[n]??1)/e):1,a=new Gr(new Ra(.15*Math.min(y,T)*r,12,8),t);a.position.set(E(s,n),m(i),f),a.userData.pointIndex=n,a.userData.value=i,c.add(a)}),c.children.some(t=>t instanceof Gr)||t.dispose()}else if("area"===s.type){const t=[],e=(e,i,n,r)=>{t.push(e,x,f,e,i,f,n,r,f),t.push(e,x,f,n,r,f,n,x,f)};for(let t=1;t<s.values.length;t++){const i=s.values[t-1],n=s.values[t];if(!Number.isFinite(i)||!Number.isFinite(n))continue;const r=E(s,t-1),a=E(s,t),o=m(Math.max(l,Math.min(h,i))),c=m(Math.max(l,Math.min(h,n)));if((o-x)*(c-x)<0){const t=r+(a-r)*(x-o)/(c-o);e(r,o,t,x),e(t,x,a,c)}else e(r,o,a,c)}if(t.length>0){const e=new er;e.setAttribute("position",new Gn(t,3)),e.computeVertexNormals(),c.add(new Gr(e,new za({...p,side:2})))}}else{if("line"!==s.type)throw new TypeError(`Unsupported 3D series type: ${String(s.type)}`);{const t=new ts(p);let e=[];const i=()=>{e.length>1&&c.add(new ls((new er).setFromPoints(e),t)),e=[]};s.values.forEach((t,n)=>{Number.isFinite(t)?e.push(new Qe(E(s,n),m(t),f)):i()}),i(),c.children.some(t=>t instanceof ls)||t.dispose()}}}),r}class Ku{canvas;renderer;camera;controls;scene;observer;destroyed=!1;onPointClick;raycaster=new To;constructor(t,e){this.canvas=t,this.scene=Zu(e),this.onPointClick=e.onPointClick,this.raycaster.params.Points.threshold=.2,this.renderer=new Lc({canvas:t,antialias:!0}),this.renderer.setPixelRatio(window.devicePixelRatio||1);const i=Math.max(e.width??10,e.height??6,e.depth??4);this.camera="orthographic"===e.camera?.projection?new _o(-i,i,i,-i,.1,1e3):new uo(45,1,.1,1e3);const n=e.camera?.position??[i,.8*i,1.5*i];this.camera.position.set(...n),this.camera.lookAt(0,0,0),this.controls=new Uu(this.camera,t),this.controls.addEventListener("change",this.render),t.addEventListener("click",this.handleClick),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.resize()}setOptions(t){if(this.destroyed)return;const e=Zu(t);if(t.camera?.projection&&"orthographic"===t.camera.projection!=this.camera instanceof _o){const e=Math.max(t.width??10,t.height??6,t.depth??4),i="orthographic"===t.camera.projection?new _o(-e,e,e,-e,.1,1e3):new uo(45,1,.1,1e3);i.position.copy(this.camera.position),i.quaternion.copy(this.camera.quaternion),this.camera=i,this.controls.object=i}t.camera?.position&&(this.camera.position.set(...t.camera.position),this.camera.lookAt(this.controls.target)),Ju(this.scene),this.scene=e,this.onPointClick=t.onPointClick,this.resize()}handleClick=t=>{if(!this.onPointClick||this.destroyed)return;const e=this.canvas.getBoundingClientRect();if(!e.width||!e.height)return;const i=new Je((t.clientX-e.left)/e.width*2-1,-(t.clientY-e.top)/e.height*2+1);this.raycaster.setFromCamera(i,this.camera);for(const t of this.raycaster.intersectObjects(this.scene.children,!0)){const e=t.object;let i=e instanceof vs&&void 0!==t.index?e.userData.pointIndices?.[t.index]:e.userData.pointIndex;if(e instanceof Gr&&t.face&&Array.isArray(e.userData.surfaceValues)){const n=e.geometry.getAttribute("position");let r=Number.POSITIVE_INFINITY;for(const s of[t.face.a,t.face.b,t.face.c]){const a=e.localToWorld((new Qe).fromBufferAttribute(n,s)).distanceToSquared(t.point);a<r&&(r=a,i=s)}}const n=e instanceof vs?e.userData.values?.[i]:e.userData.surfaceValues?.[i]??e.userData.value;if("number"!=typeof i||"number"!=typeof n)continue;let r=e.parent;for(;r&&"number"!=typeof r.userData.seriesIndex;)r=r.parent;if(r){this.onPointClick({seriesIndex:r.userData.seriesIndex,pointIndex:i,value:n});break}}};resize(){if(this.destroyed)return;const t=Math.max(1,this.canvas.clientWidth),e=Math.max(1,this.canvas.clientHeight);if(this.renderer.setSize(t,e,!1),this.camera instanceof uo)this.camera.aspect=t/e;else{const i=(this.camera.top-this.camera.bottom)/2;this.camera.left=-i*t/e,this.camera.right=i*t/e}this.camera.updateProjectionMatrix(),this.render()}render=()=>{this.destroyed||this.renderer.render(this.scene,this.camera)};destroy(){this.destroyed||(this.destroyed=!0,this.observer?.disconnect(),this.controls.removeEventListener("change",this.render),this.canvas.removeEventListener("click",this.handleClick),this.controls.dispose(),Ju(this.scene),this.renderer.dispose())}}function Ju(t){const e=new Set;t.traverse(t=>{if(t instanceof Gr||t instanceof ls||t instanceof vs){t.geometry.dispose();for(const i of Array.isArray(t.material)?t.material:[t.material])e.add(i)}t instanceof Mr&&(t.material.map?.dispose(),e.add(t.material))});for(const t of e)t.dispose();t.clear()}function $u(t){const e=(t,e,i)=>{for(const n of Object.keys(t))if(!e.includes(n))throw new TypeError(`Unsupported 3D option: ${i}${n}`)};let i;e(t,["type","data","axes","panel","title","subtitle","footer","legend","walls"],""),"object"==typeof t.title?(e(t.title,["text","visible"],"title."),!1!==t.title.visible&&(i=t.title.text)):i=t.title,t.legend&&e(t.legend,["visible"],"legend."),t.data&&e(t.data,["series","labels"],"data."),t.axes&&e(t.axes,["left"],"axes."),t.axes?.left&&e(t.axes.left,["visible","minimum","maximum","lineColor","grid","labels","title","inverted","increment"],"axes.left."),t.axes?.left?.labels&&e(t.axes.left.labels,["visible","decimals","fixedDecimals"],"axes.left.labels."),t.axes?.left?.grid&&e(t.axes.left.grid,["visible","lineColor"],"axes.left.grid."),t.panel&&e(t.panel,["backgroundColor"],"panel."),t.walls&&e(t.walls,["visible"],"walls.");const n=(t.data?.series??[]).map((i,n)=>{e(i,["type","data","backgroundColor","visible","label","transparency","marks","stacked","x","xKey","yKey","wireFrame"],`data.series[${n}].`),i.marks&&e(i.marks,["visible"],`data.series[${n}].marks.`);const r=i.type??t.type??"line";if("bar"!==r&&"volume"!==r&&"line"!==r&&"area"!==r&&"point"!==r&&"bubble"!==r&&"pie"!==r&&"donut"!==r&&"sliced"!==r&&"surface"!==r&&"colorGrid"!==r)throw new TypeError(`Unsupported 3D series type: ${r}`);const s="stacked"in i?i.stacked:void 0;if(void 0!==s&&"no"!==s&&("yes"!==s&&"100"!==s||"bar"!==r))throw new TypeError(`Unsupported 3D stacking mode: ${s}`);if(!Array.isArray(i.data))throw new TypeError(`3D series ${n} requires an array of data`);const a="x"in i?i.x:void 0;let o,l=a?.map(t=>t instanceof Date?t.getTime():t);const h=[];let c,u;if("surface"!==r&&"colorGrid"!==r||!i.data.every(t=>Array.isArray(t)))if(i.data.every(t=>"number"==typeof t)){if("xKey"in i&&void 0!==i.xKey||"yKey"in i&&void 0!==i.yKey)throw new TypeError(`X and Y keys require object data for 3D series ${n}`);o=i.data,"bubble"===r&&h.push(...o.map(()=>1))}else{if(a||"pie"===r||"donut"===r||"sliced"===r)throw new TypeError(`Unsupported object data for 3D series ${n}`);const t="xKey"in i?i.xKey??"x":"x",e="yKey"in i?i.yKey??"y":"y";l=[],o=[];for(const s of i.data){if(null===s||"object"!=typeof s)throw new TypeError(`Invalid object data for 3D series ${n}`);const i=s,a=i[t],c=i[e];if(!("number"==typeof a||a instanceof Date)||"number"!=typeof c)throw new TypeError(`Invalid X or Y value for 3D series ${n}`);if(l.push(a instanceof Date?a.getTime():a),o.push(c),"bubble"===r){const t=i.radius;if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<0))throw new RangeError(`Invalid bubble radius for 3D series ${n}`);h.push("number"==typeof t?t:1)}}}else{const t=i.data;if(c=t[0]?.length??0,u=t.length,!t.every(t=>t.length===c&&t.every(t=>"number"==typeof t)))throw new RangeError(`3D ${r} series ${n} requires a rectangular numeric grid`);o=t.flat()}if(l&&("pie"===r||"donut"===r||"sliced"===r))throw new TypeError(`Unsupported X values for ${r} series`);if(("surface"===r||"colorGrid"===r)&&void 0===c)throw new TypeError(`3D ${r} series ${n} requires data as rows of numeric values`);return{type:r,values:o,radii:"bubble"===r?h:void 0,columns:c,rows:u,wireframe:"wireFrame"in i?i.wireFrame:void 0,x:l,color:i.backgroundColor,visible:i.visible,label:i.label,transparency:i.transparency,marks:i.marks?.visible,stacked:"100"===s?"100":"yes"===s}}),r=t.axes?.left;return{series:n,background:t.panel?.backgroundColor,title:i,subtitle:t.subtitle,footer:t.footer,legend:t.legend?.visible,labels:t.data?.labels,walls:t.walls?.visible,axis:r&&{minimum:r.minimum,maximum:r.maximum,visible:r.visible,color:r.lineColor,gridVisible:r.grid?.visible,gridColor:r.grid?.lineColor,labelsVisible:r.labels?.visible,inverted:r.inverted,increment:r.increment,decimals:r.labels?.decimals,fixedDecimals:r.labels?.fixedDecimals,title:r.title}}}class Qu{canvas;three;chart;observer;listeningForWindowResize=!1;responsive=!0;destroyed=!1;constructor(e,i={}){if(this.canvas=e,this.responsive=!1!==i.responsive,this.three=new _u(e),!this.three.isEnabled())throw this.three.destroy(),new Error("TeeChart3D requires WebGL support");let n;try{n=this.chart=new t(this.three,this.toThreeOptions(i)),this.resize(),this.configureResizeHandling()}catch(t){this.observer?.disconnect();try{n?.destroy()}catch{}throw this.three.destroy(),t}}setOptions(t){return this.destroyed||(void 0!==t.responsive&&(this.responsive=t.responsive,this.configureResizeHandling()),this.chart.setOptions(this.toThreeOptions(t)),this.resize()),this}configureResizeHandling(){this.observer?.disconnect(),this.observer=void 0,this.listeningForWindowResize&&window.removeEventListener("resize",this.resize),this.listeningForWindowResize=!1,this.responsive&&("undefined"!=typeof ResizeObserver?(this.observer=new ResizeObserver(this.resize),this.observer.observe(this.canvas)):"undefined"!=typeof window&&(window.addEventListener("resize",this.resize),this.listeningForWindowResize=!0))}toThreeOptions(t){return{...t,responsive:!1,aspect:{...t.aspect,view3d:!0},tools:t.tools?.cursor?{...t.tools,cursor:{...t.tools.cursor,render:"full"}}:t.tools}}resize=()=>{if(this.destroyed)return;const t=Math.max(1,this.canvas.clientWidth),e=Math.max(1,this.canvas.clientHeight);this.three.onWindowResize(),this.chart.bounds.set(0,0,t,e),this.chart.chartRect.setFrom(this.chart.bounds),this.chart.draw(),this.three.refresh()};destroy(){if(!this.destroyed){this.destroyed=!0,this.observer?.disconnect(),this.listeningForWindowResize&&window.removeEventListener("resize",this.resize);try{this.chart.destroy()}finally{this.three.destroy()}}}}export{Ku as Chart3D,pu as MyParametricGeometry,Qu as TeeChart3D,_u as Three,$u as chart3DOptionsFromChartOptions,Zu as createChart3DScene};
27
+ //# sourceMappingURL=teechart.3d.esm.js.map