@gisfun/maplibre-gl-components 0.15.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1960 -0
  3. package/dist/ControlGrid-DN5md8hp.cjs +19636 -0
  4. package/dist/ControlGrid-rVNG7B9O.js +170422 -0
  5. package/dist/DuckDBConverter-B98M0DFs.cjs +23 -0
  6. package/dist/DuckDBConverter-RPq48-t0.js +434 -0
  7. package/dist/ShapefileConverter-AjbEjEyq.cjs +1 -0
  8. package/dist/ShapefileConverter-trvt8J3z.js +125 -0
  9. package/dist/decoder-CLokFc0V.js +8 -0
  10. package/dist/decoder-D9LU4bUo.cjs +1 -0
  11. package/dist/deflate-BA1jZeSX.js +10 -0
  12. package/dist/deflate-DEdCz12a.cjs +1 -0
  13. package/dist/geojson-BQSVgKFt.cjs +1 -0
  14. package/dist/geojson-BSUuDj5k.js +2551 -0
  15. package/dist/geotiff-De1w1lBy.cjs +8 -0
  16. package/dist/geotiff-o_Fq1Na4.js +3108 -0
  17. package/dist/index-8ZZtuDTp.js +705 -0
  18. package/dist/index-B-Nr9y7J.cjs +84 -0
  19. package/dist/index-B5NoFrpY.js +8892 -0
  20. package/dist/index-Bi1MMPUx.js +4163 -0
  21. package/dist/index-C9fk_HKR.js +167 -0
  22. package/dist/index-CBBRBJvR.cjs +274 -0
  23. package/dist/index-CZxPF1qt.js +4 -0
  24. package/dist/index-CiDPSJ9T.cjs +1 -0
  25. package/dist/index-CjM_nbxd.cjs +107 -0
  26. package/dist/index-DQXdX5y1.js +4666 -0
  27. package/dist/index-Dh1kpCb6.cjs +1 -0
  28. package/dist/index-IrsIiQNM.cjs +4 -0
  29. package/dist/index.cjs +3819 -0
  30. package/dist/index.mjs +19580 -0
  31. package/dist/jpeg-CF9OGQg_.js +533 -0
  32. package/dist/jpeg-JSQOxGHy.cjs +1 -0
  33. package/dist/lerc-7LlQoT6u.js +1032 -0
  34. package/dist/lerc-BIsodce9.cjs +1 -0
  35. package/dist/lzw-BZniWIYG.js +84 -0
  36. package/dist/lzw-BhML-BvT.cjs +1 -0
  37. package/dist/main-dist-Bymiy5aM.cjs +2 -0
  38. package/dist/main-dist-Cv8AKwrY.js +629 -0
  39. package/dist/maplibre-geoman.es-Bxdg-2EU.cjs +129 -0
  40. package/dist/maplibre-geoman.es-CFgM2ajb.js +22827 -0
  41. package/dist/maplibre-gl-components.css +1 -0
  42. package/dist/packbits-B9b7gX2c.cjs +1 -0
  43. package/dist/packbits-DWY5O-FG.js +24 -0
  44. package/dist/pako.esm-Bx5X36Wo.js +1074 -0
  45. package/dist/pako.esm-DZC2QrbJ.cjs +1 -0
  46. package/dist/raw-C3ARbSFo.cjs +1 -0
  47. package/dist/raw-DUslI1gr.js +9 -0
  48. package/dist/react.cjs +1 -0
  49. package/dist/react.mjs +1306 -0
  50. package/dist/types/index.d.ts +44 -0
  51. package/dist/types/index.d.ts.map +1 -0
  52. package/dist/types/lib/adapters/AddVectorAdapter.d.ts +66 -0
  53. package/dist/types/lib/adapters/AddVectorAdapter.d.ts.map +1 -0
  54. package/dist/types/lib/adapters/CogLayerAdapter.d.ts +126 -0
  55. package/dist/types/lib/adapters/CogLayerAdapter.d.ts.map +1 -0
  56. package/dist/types/lib/adapters/PMTilesLayerAdapter.d.ts +78 -0
  57. package/dist/types/lib/adapters/PMTilesLayerAdapter.d.ts.map +1 -0
  58. package/dist/types/lib/adapters/StacLayerAdapter.d.ts +71 -0
  59. package/dist/types/lib/adapters/StacLayerAdapter.d.ts.map +1 -0
  60. package/dist/types/lib/adapters/ZarrLayerAdapter.d.ts +72 -0
  61. package/dist/types/lib/adapters/ZarrLayerAdapter.d.ts.map +1 -0
  62. package/dist/types/lib/adapters/index.d.ts +7 -0
  63. package/dist/types/lib/adapters/index.d.ts.map +1 -0
  64. package/dist/types/lib/addControlGrid.d.ts +80 -0
  65. package/dist/types/lib/addControlGrid.d.ts.map +1 -0
  66. package/dist/types/lib/colormaps/diverging.d.ts +30 -0
  67. package/dist/types/lib/colormaps/diverging.d.ts.map +1 -0
  68. package/dist/types/lib/colormaps/index.d.ts +32 -0
  69. package/dist/types/lib/colormaps/index.d.ts.map +1 -0
  70. package/dist/types/lib/colormaps/misc.d.ts +38 -0
  71. package/dist/types/lib/colormaps/misc.d.ts.map +1 -0
  72. package/dist/types/lib/colormaps/sequential.d.ts +22 -0
  73. package/dist/types/lib/colormaps/sequential.d.ts.map +1 -0
  74. package/dist/types/lib/converters/DuckDBConverter.d.ts +112 -0
  75. package/dist/types/lib/converters/DuckDBConverter.d.ts.map +1 -0
  76. package/dist/types/lib/converters/ShapefileConverter.d.ts +56 -0
  77. package/dist/types/lib/converters/ShapefileConverter.d.ts.map +1 -0
  78. package/dist/types/lib/converters/index.d.ts +8 -0
  79. package/dist/types/lib/converters/index.d.ts.map +1 -0
  80. package/dist/types/lib/converters/types.d.ts +75 -0
  81. package/dist/types/lib/converters/types.d.ts.map +1 -0
  82. package/dist/types/lib/core/AddVector.d.ts +116 -0
  83. package/dist/types/lib/core/AddVector.d.ts.map +1 -0
  84. package/dist/types/lib/core/Basemap.d.ts +206 -0
  85. package/dist/types/lib/core/Basemap.d.ts.map +1 -0
  86. package/dist/types/lib/core/BasemapReact.d.ts +32 -0
  87. package/dist/types/lib/core/BasemapReact.d.ts.map +1 -0
  88. package/dist/types/lib/core/BookmarkControl.d.ts +180 -0
  89. package/dist/types/lib/core/BookmarkControl.d.ts.map +1 -0
  90. package/dist/types/lib/core/ChoroplethControl.d.ts +105 -0
  91. package/dist/types/lib/core/ChoroplethControl.d.ts.map +1 -0
  92. package/dist/types/lib/core/CogLayer.d.ts +139 -0
  93. package/dist/types/lib/core/CogLayer.d.ts.map +1 -0
  94. package/dist/types/lib/core/CogLayerReact.d.ts +32 -0
  95. package/dist/types/lib/core/CogLayerReact.d.ts.map +1 -0
  96. package/dist/types/lib/core/Colorbar.d.ts +133 -0
  97. package/dist/types/lib/core/Colorbar.d.ts.map +1 -0
  98. package/dist/types/lib/core/ColorbarGuiControl.d.ts +79 -0
  99. package/dist/types/lib/core/ColorbarGuiControl.d.ts.map +1 -0
  100. package/dist/types/lib/core/ColorbarReact.d.ts +34 -0
  101. package/dist/types/lib/core/ColorbarReact.d.ts.map +1 -0
  102. package/dist/types/lib/core/ControlGrid.d.ts +125 -0
  103. package/dist/types/lib/core/ControlGrid.d.ts.map +1 -0
  104. package/dist/types/lib/core/ControlGridReact.d.ts +32 -0
  105. package/dist/types/lib/core/ControlGridReact.d.ts.map +1 -0
  106. package/dist/types/lib/core/HtmlControl.d.ts +140 -0
  107. package/dist/types/lib/core/HtmlControl.d.ts.map +1 -0
  108. package/dist/types/lib/core/HtmlControlReact.d.ts +32 -0
  109. package/dist/types/lib/core/HtmlControlReact.d.ts.map +1 -0
  110. package/dist/types/lib/core/HtmlGuiControl.d.ts +68 -0
  111. package/dist/types/lib/core/HtmlGuiControl.d.ts.map +1 -0
  112. package/dist/types/lib/core/InspectControl.d.ts +202 -0
  113. package/dist/types/lib/core/InspectControl.d.ts.map +1 -0
  114. package/dist/types/lib/core/InspectControlReact.d.ts +32 -0
  115. package/dist/types/lib/core/InspectControlReact.d.ts.map +1 -0
  116. package/dist/types/lib/core/Legend.d.ts +142 -0
  117. package/dist/types/lib/core/Legend.d.ts.map +1 -0
  118. package/dist/types/lib/core/LegendGuiControl.d.ts +69 -0
  119. package/dist/types/lib/core/LegendGuiControl.d.ts.map +1 -0
  120. package/dist/types/lib/core/LegendReact.d.ts +34 -0
  121. package/dist/types/lib/core/LegendReact.d.ts.map +1 -0
  122. package/dist/types/lib/core/MeasureControl.d.ts +211 -0
  123. package/dist/types/lib/core/MeasureControl.d.ts.map +1 -0
  124. package/dist/types/lib/core/MinimapControl.d.ts +77 -0
  125. package/dist/types/lib/core/MinimapControl.d.ts.map +1 -0
  126. package/dist/types/lib/core/MinimapControlReact.d.ts +32 -0
  127. package/dist/types/lib/core/MinimapControlReact.d.ts.map +1 -0
  128. package/dist/types/lib/core/PMTilesLayer.d.ts +119 -0
  129. package/dist/types/lib/core/PMTilesLayer.d.ts.map +1 -0
  130. package/dist/types/lib/core/PrintControl.d.ts +226 -0
  131. package/dist/types/lib/core/PrintControl.d.ts.map +1 -0
  132. package/dist/types/lib/core/SearchControl.d.ts +172 -0
  133. package/dist/types/lib/core/SearchControl.d.ts.map +1 -0
  134. package/dist/types/lib/core/SearchControlReact.d.ts +32 -0
  135. package/dist/types/lib/core/SearchControlReact.d.ts.map +1 -0
  136. package/dist/types/lib/core/StacLayer.d.ts +107 -0
  137. package/dist/types/lib/core/StacLayer.d.ts.map +1 -0
  138. package/dist/types/lib/core/StacSearch.d.ts +109 -0
  139. package/dist/types/lib/core/StacSearch.d.ts.map +1 -0
  140. package/dist/types/lib/core/Terrain.d.ts +165 -0
  141. package/dist/types/lib/core/Terrain.d.ts.map +1 -0
  142. package/dist/types/lib/core/TerrainReact.d.ts +32 -0
  143. package/dist/types/lib/core/TerrainReact.d.ts.map +1 -0
  144. package/dist/types/lib/core/VectorDataset.d.ts +228 -0
  145. package/dist/types/lib/core/VectorDataset.d.ts.map +1 -0
  146. package/dist/types/lib/core/VectorDatasetReact.d.ts +31 -0
  147. package/dist/types/lib/core/VectorDatasetReact.d.ts.map +1 -0
  148. package/dist/types/lib/core/ViewStateControl.d.ts +205 -0
  149. package/dist/types/lib/core/ViewStateControl.d.ts.map +1 -0
  150. package/dist/types/lib/core/ViewStateControlReact.d.ts +32 -0
  151. package/dist/types/lib/core/ViewStateControlReact.d.ts.map +1 -0
  152. package/dist/types/lib/core/ZarrLayer.d.ts +110 -0
  153. package/dist/types/lib/core/ZarrLayer.d.ts.map +1 -0
  154. package/dist/types/lib/core/types.d.ts +2793 -0
  155. package/dist/types/lib/core/types.d.ts.map +1 -0
  156. package/dist/types/lib/hooks/index.d.ts +13 -0
  157. package/dist/types/lib/hooks/index.d.ts.map +1 -0
  158. package/dist/types/lib/hooks/useBasemap.d.ts +43 -0
  159. package/dist/types/lib/hooks/useBasemap.d.ts.map +1 -0
  160. package/dist/types/lib/hooks/useCogLayer.d.ts +44 -0
  161. package/dist/types/lib/hooks/useCogLayer.d.ts.map +1 -0
  162. package/dist/types/lib/hooks/useColorbar.d.ts +36 -0
  163. package/dist/types/lib/hooks/useColorbar.d.ts.map +1 -0
  164. package/dist/types/lib/hooks/useControlGrid.d.ts +41 -0
  165. package/dist/types/lib/hooks/useControlGrid.d.ts.map +1 -0
  166. package/dist/types/lib/hooks/useHtmlControl.d.ts +39 -0
  167. package/dist/types/lib/hooks/useHtmlControl.d.ts.map +1 -0
  168. package/dist/types/lib/hooks/useInspectControl.d.ts +49 -0
  169. package/dist/types/lib/hooks/useInspectControl.d.ts.map +1 -0
  170. package/dist/types/lib/hooks/useLegend.d.ts +41 -0
  171. package/dist/types/lib/hooks/useLegend.d.ts.map +1 -0
  172. package/dist/types/lib/hooks/useMinimapControl.d.ts +35 -0
  173. package/dist/types/lib/hooks/useMinimapControl.d.ts.map +1 -0
  174. package/dist/types/lib/hooks/useSearchControl.d.ts +43 -0
  175. package/dist/types/lib/hooks/useSearchControl.d.ts.map +1 -0
  176. package/dist/types/lib/hooks/useTerrain.d.ts +43 -0
  177. package/dist/types/lib/hooks/useTerrain.d.ts.map +1 -0
  178. package/dist/types/lib/hooks/useVectorDataset.d.ts +35 -0
  179. package/dist/types/lib/hooks/useVectorDataset.d.ts.map +1 -0
  180. package/dist/types/lib/hooks/useViewState.d.ts +43 -0
  181. package/dist/types/lib/hooks/useViewState.d.ts.map +1 -0
  182. package/dist/types/lib/utils/color.d.ts +47 -0
  183. package/dist/types/lib/utils/color.d.ts.map +1 -0
  184. package/dist/types/lib/utils/fileHelpers.d.ts +207 -0
  185. package/dist/types/lib/utils/fileHelpers.d.ts.map +1 -0
  186. package/dist/types/lib/utils/helpers.d.ts +48 -0
  187. package/dist/types/lib/utils/helpers.d.ts.map +1 -0
  188. package/dist/types/lib/utils/index.d.ts +4 -0
  189. package/dist/types/lib/utils/index.d.ts.map +1 -0
  190. package/dist/types/lib/utils/providers.d.ts +46 -0
  191. package/dist/types/lib/utils/providers.d.ts.map +1 -0
  192. package/dist/types/react.d.ts +15 -0
  193. package/dist/types/react.d.ts.map +1 -0
  194. package/dist/webimage-CBRffWZD.cjs +1 -0
  195. package/dist/webimage-ibSPOLHJ.js +19 -0
  196. package/package.json +137 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,3819 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("./ControlGrid-DN5md8hp.cjs"),hl=require("maplibre-gl"),lo=require("./DuckDBConverter-B98M0DFs.cjs"),co=require("./ShapefileConverter-AjbEjEyq.cjs"),uo=["globe","fullscreen","north","terrain","search","viewState","inspect","vectorDataset","basemap","measure","geoEditor","bookmark","print","minimap","swipe","colorbarGui","legendGui","htmlGui","streetView","addVector","choropleth","cogLayer","zarrLayer","pmtilesLayer","stacLayer","stacSearch","planetaryComputer","gaussianSplat","lidar","usgsLidar"],ho=["usgs-lidar-*","lidar-*","mapbox-gl-draw-*","gl-draw-*","gm_*","inspect-highlight-*","measure-*"];function dl(i){if(i<=0)return{rows:1,columns:1};const e=Math.ceil(Math.sqrt(i));return{rows:Math.ceil(i/e),columns:e}}function fo(i,e){const{exclude:t,...n}=e??{};if(n.defaultControls===void 0){const a=new Set(t??[]);n.defaultControls=uo.filter(o=>!a.has(o))}const r=n.defaultControls.length;if(n.rows===void 0&&n.columns===void 0){const a=dl(r);n.rows=a.rows,n.columns=a.columns}else n.rows===void 0&&n.columns!==void 0?n.rows=Math.ceil(r/n.columns):n.columns===void 0&&n.rows!==void 0&&(n.columns=Math.ceil(r/n.rows));n.position??="top-right",n.collapsible??=!0,n.collapsed??=!0,n.showRowColumnControls??=!0,n.gap??=2,n.excludeLayers??=[...ho];const s=new W.ControlGrid(n);return i.addControl(s,n.position),s}function fl(i){i.prototype.addControlGrid||(i.prototype.addControlGrid=function(e){return fo(this,e)})}const Gs="178",pl=0,la=1,ml=2,po=1,_l=2,tn=3,vn=0,At=1,nn=2,_n=0,si=1,ca=2,ua=3,ha=4,gl=5,Ln=100,vl=101,xl=102,Sl=103,Ml=104,El=200,Tl=201,yl=202,Al=203,Qr=204,es=205,bl=206,wl=207,Rl=208,Cl=209,Pl=210,Ll=211,Dl=212,Ul=213,Il=214,ts=0,ns=1,is=2,li=3,rs=4,ss=5,as=6,os=7,mo=0,Nl=1,Fl=2,gn=0,Ol=1,Bl=2,zl=3,Hl=4,Gl=5,Vl=6,kl=7,_o=300,ci=301,ui=302,ls=303,cs=304,mr=306,us=1e3,In=1001,hs=1002,kt=1003,Wl=1004,Fi=1005,Xt=1006,Mr=1007,Nn=1008,Kt=1009,go=1010,vo=1011,Ti=1012,Vs=1013,Bn=1014,rn=1015,Ri=1016,ks=1017,Ws=1018,yi=1020,xo=35902,So=1021,Mo=1022,Gt=1023,Ai=1026,bi=1027,Eo=1028,Xs=1029,To=1030,qs=1031,Ys=1033,sr=33776,ar=33777,or=33778,lr=33779,ds=35840,fs=35841,ps=35842,ms=35843,_s=36196,gs=37492,vs=37496,xs=37808,Ss=37809,Ms=37810,Es=37811,Ts=37812,ys=37813,As=37814,bs=37815,ws=37816,Rs=37817,Cs=37818,Ps=37819,Ls=37820,Ds=37821,cr=36492,Us=36494,Is=36495,yo=36283,Ns=36284,Fs=36285,Os=36286,Xl=3200,ql=3201,Yl=0,Kl=1,pn="",It="srgb",hi="srgb-linear",hr="linear",$e="srgb",kn=7680,da=519,Zl=512,$l=513,jl=514,Ao=515,Jl=516,Ql=517,ec=518,tc=519,fa=35044,pa="300 es",sn=2e3,dr=2001;class Hn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const vt=["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"],Er=Math.PI/180,Bs=180/Math.PI;function Ci(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(vt[i&255]+vt[i>>8&255]+vt[i>>16&255]+vt[i>>24&255]+"-"+vt[e&255]+vt[e>>8&255]+"-"+vt[e>>16&15|64]+vt[e>>24&255]+"-"+vt[t&63|128]+vt[t>>8&255]+"-"+vt[t>>16&255]+vt[t>>24&255]+vt[n&255]+vt[n>>8&255]+vt[n>>16&255]+vt[n>>24&255]).toLowerCase()}function Be(i,e,t){return Math.max(e,Math.min(t,i))}function nc(i,e){return(i%e+e)%e}function Tr(i,e,t){return(1-t)*i+t*e}function _i(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function yt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}class Ye{constructor(e=0,t=0){Ye.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Pi{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3];const f=s[a+0],m=s[a+1],v=s[a+2],S=s[a+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d;return}if(o===1){e[t+0]=f,e[t+1]=m,e[t+2]=v,e[t+3]=S;return}if(d!==S||l!==f||c!==m||h!==v){let p=1-o;const u=l*f+c*m+h*v+d*S,A=u>=0?1:-1,y=1-u*u;if(y>Number.EPSILON){const U=Math.sqrt(y),R=Math.atan2(U,u*A);p=Math.sin(p*R)/U,o=Math.sin(o*R)/U}const M=o*A;if(l=l*p+f*M,c=c*p+m*M,h=h*p+v*M,d=d*p+S*M,p===1-o){const U=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=U,c*=U,h*=U,d*=U}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[a],f=s[a+1],m=s[a+2],v=s[a+3];return e[t]=o*v+h*d+l*m-c*f,e[t+1]=l*v+h*f+c*d-o*m,e[t+2]=c*v+h*m+o*f-l*d,e[t+3]=h*v-o*d-l*f-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),d=o(s/2),f=l(n/2),m=l(r/2),v=l(s/2);switch(a){case"XYZ":this._x=f*h*d+c*m*v,this._y=c*m*d-f*h*v,this._z=c*h*v+f*m*d,this._w=c*h*d-f*m*v;break;case"YXZ":this._x=f*h*d+c*m*v,this._y=c*m*d-f*h*v,this._z=c*h*v-f*m*d,this._w=c*h*d+f*m*v;break;case"ZXY":this._x=f*h*d-c*m*v,this._y=c*m*d+f*h*v,this._z=c*h*v+f*m*d,this._w=c*h*d-f*m*v;break;case"ZYX":this._x=f*h*d-c*m*v,this._y=c*m*d+f*h*v,this._z=c*h*v-f*m*d,this._w=c*h*d+f*m*v;break;case"YZX":this._x=f*h*d+c*m*v,this._y=c*m*d+f*h*v,this._z=c*h*v-f*m*d,this._w=c*h*d-f*m*v;break;case"XZY":this._x=f*h*d-c*m*v,this._y=c*m*d-f*h*v,this._z=c*h*v+f*m*d,this._w=c*h*d+f*m*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],f=n+o+d;if(f>0){const m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(h-l)*m,this._y=(s-c)*m,this._z=(a-r)*m}else if(n>o&&n>d){const m=2*Math.sqrt(1+n-o-d);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+c)/m}else if(o>d){const m=2*Math.sqrt(1+o-n-d);this._w=(s-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+d-n-o);this._w=(a-r)/m,this._x=(s+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Be(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),d=Math.sin((1-t)*h)/c,f=Math.sin(t*h)/c;return this._w=a*d+this._w*f,this._x=n*d+this._x*f,this._y=r*d+this._y*f,this._z=s*d+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{constructor(e=0,t=0,n=0){F.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ma.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ma.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),d=2*(s*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-s*d,this.z=r+l*d+s*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return yr.copy(this).projectOnVector(e),this.sub(yr)}reflect(e){return this.sub(yr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const yr=new F,ma=new Pi;class Ue{constructor(e,t,n,r,s,a,o,l,c){Ue.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],f=n[2],m=n[5],v=n[8],S=r[0],p=r[3],u=r[6],A=r[1],y=r[4],M=r[7],U=r[2],R=r[5],C=r[8];return s[0]=a*S+o*A+l*U,s[3]=a*p+o*y+l*R,s[6]=a*u+o*M+l*C,s[1]=c*S+h*A+d*U,s[4]=c*p+h*y+d*R,s[7]=c*u+h*M+d*C,s[2]=f*S+m*A+v*U,s[5]=f*p+m*y+v*R,s[8]=f*u+m*M+v*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,f=o*l-h*s,m=c*s-a*l,v=t*d+n*f+r*m;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=d*S,e[1]=(r*c-h*n)*S,e[2]=(o*n-r*a)*S,e[3]=f*S,e[4]=(h*t-r*l)*S,e[5]=(r*s-o*t)*S,e[6]=m*S,e[7]=(n*l-c*t)*S,e[8]=(a*t-n*s)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ar.makeScale(e,t)),this}rotate(e){return this.premultiply(Ar.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ar.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Ar=new Ue;function bo(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function fr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ic(){const i=fr("canvas");return i.style.display="block",i}const _a={};function ai(i){i in _a||(_a[i]=!0,console.warn(i))}function rc(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function sc(i){const e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function ac(i){const e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const ga=new Ue().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),va=new Ue().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function oc(){const i={enabled:!0,workingColorSpace:hi,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===$e&&(r.r=an(r.r),r.g=an(r.g),r.b=an(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$e&&(r.r=oi(r.r),r.g=oi(r.g),r.b=oi(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===pn?hr:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return ai("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return ai("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[hi]:{primaries:e,whitePoint:n,transfer:hr,toXYZ:ga,fromXYZ:va,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:It},outputColorSpaceConfig:{drawingBufferColorSpace:It}},[It]:{primaries:e,whitePoint:n,transfer:$e,toXYZ:ga,fromXYZ:va,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:It}}}),i}const Ve=oc();function an(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function oi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Wn;class lc{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Wn===void 0&&(Wn=fr("canvas")),Wn.width=e.width,Wn.height=e.height;const r=Wn.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Wn}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=fr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=an(s[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(an(t[n]/255)*255):t[n]=an(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cc=0;class Ks{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cc++}),this.uuid=Ci(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(br(r[a].image)):s.push(br(r[a]))}else s=br(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function br(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?lc.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let uc=0;const wr=new F;class bt extends Hn{constructor(e=bt.DEFAULT_IMAGE,t=bt.DEFAULT_MAPPING,n=In,r=In,s=Xt,a=Nn,o=Gt,l=Kt,c=bt.DEFAULT_ANISOTROPY,h=pn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:uc++}),this.uuid=Ci(),this.name="",this.source=new Ks(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Ye(0,0),this.repeat=new Ye(1,1),this.center=new Ye(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ue,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=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(wr).x}get height(){return this.source.getSize(wr).y}get depth(){return this.source.getSize(wr).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==_o)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case us:e.x=e.x-Math.floor(e.x);break;case In:e.x=e.x<0?0:1;break;case hs:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case us:e.y=e.y-Math.floor(e.y);break;case In:e.y=e.y<0?0:1;break;case hs:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}bt.DEFAULT_IMAGE=null;bt.DEFAULT_MAPPING=_o;bt.DEFAULT_ANISOTROPY=1;class ct{constructor(e=0,t=0,n=0,r=1){ct.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const l=e.elements,c=l[0],h=l[4],d=l[8],f=l[1],m=l[5],v=l[9],S=l[2],p=l[6],u=l[10];if(Math.abs(h-f)<.01&&Math.abs(d-S)<.01&&Math.abs(v-p)<.01){if(Math.abs(h+f)<.1&&Math.abs(d+S)<.1&&Math.abs(v+p)<.1&&Math.abs(c+m+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const y=(c+1)/2,M=(m+1)/2,U=(u+1)/2,R=(h+f)/4,C=(d+S)/4,I=(v+p)/4;return y>M&&y>U?y<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(y),r=R/n,s=C/n):M>U?M<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),n=R/r,s=I/r):U<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(U),n=C/s,r=I/s),this.set(n,r,s,t),this}let A=Math.sqrt((p-v)*(p-v)+(d-S)*(d-S)+(f-h)*(f-h));return Math.abs(A)<.001&&(A=1),this.x=(p-v)/A,this.y=(d-S)/A,this.z=(f-h)/A,this.w=Math.acos((c+m+u-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class hc extends Hn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ct(0,0,e,t),this.scissorTest=!1,this.viewport=new ct(0,0,e,t);const r={width:e,height:t,depth:n.depth},s=new bt(r);this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Xt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ks(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class zn extends hc{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class wo extends bt{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=kt,this.minFilter=kt,this.wrapR=In,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class dc extends bt{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=kt,this.minFilter=kt,this.wrapR=In,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class fi{constructor(e=new F(1/0,1/0,1/0),t=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ot.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ot.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Ot.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Ot):Ot.fromBufferAttribute(s,a),Ot.applyMatrix4(e.matrixWorld),this.expandByPoint(Ot);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Oi.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Oi.copy(n.boundingBox)),Oi.applyMatrix4(e.matrixWorld),this.union(Oi)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ot),Ot.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(gi),Bi.subVectors(this.max,gi),Xn.subVectors(e.a,gi),qn.subVectors(e.b,gi),Yn.subVectors(e.c,gi),ln.subVectors(qn,Xn),cn.subVectors(Yn,qn),En.subVectors(Xn,Yn);let t=[0,-ln.z,ln.y,0,-cn.z,cn.y,0,-En.z,En.y,ln.z,0,-ln.x,cn.z,0,-cn.x,En.z,0,-En.x,-ln.y,ln.x,0,-cn.y,cn.x,0,-En.y,En.x,0];return!Rr(t,Xn,qn,Yn,Bi)||(t=[1,0,0,0,1,0,0,0,1],!Rr(t,Xn,qn,Yn,Bi))?!1:(zi.crossVectors(ln,cn),t=[zi.x,zi.y,zi.z],Rr(t,Xn,qn,Yn,Bi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ot).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ot).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:($t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($t),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const $t=[new F,new F,new F,new F,new F,new F,new F,new F],Ot=new F,Oi=new fi,Xn=new F,qn=new F,Yn=new F,ln=new F,cn=new F,En=new F,gi=new F,Bi=new F,zi=new F,Tn=new F;function Rr(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Tn.fromArray(i,s);const o=r.x*Math.abs(Tn.x)+r.y*Math.abs(Tn.y)+r.z*Math.abs(Tn.z),l=e.dot(Tn),c=t.dot(Tn),h=n.dot(Tn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const fc=new fi,vi=new F,Cr=new F;class Zs{constructor(e=new F,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):fc.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vi.subVectors(e,this.center);const t=vi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(vi,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Cr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vi.copy(e.center).add(Cr)),this.expandByPoint(vi.copy(e.center).sub(Cr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const jt=new F,Pr=new F,Hi=new F,un=new F,Lr=new F,Gi=new F,Dr=new F;class pc{constructor(e=new F,t=new F(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,jt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=jt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(jt.copy(this.origin).addScaledVector(this.direction,t),jt.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Pr.copy(e).add(t).multiplyScalar(.5),Hi.copy(t).sub(e).normalize(),un.copy(this.origin).sub(Pr);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Hi),o=un.dot(this.direction),l=-un.dot(Hi),c=un.lengthSq(),h=Math.abs(1-a*a);let d,f,m,v;if(h>0)if(d=a*l-o,f=a*o-l,v=s*h,d>=0)if(f>=-v)if(f<=v){const S=1/h;d*=S,f*=S,m=d*(d+a*f+2*o)+f*(a*d+f+2*l)+c}else f=s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*l)+c;else f=-s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*l)+c;else f<=-v?(d=Math.max(0,-(-a*s+o)),f=d>0?-s:Math.min(Math.max(-s,-l),s),m=-d*d+f*(f+2*l)+c):f<=v?(d=0,f=Math.min(Math.max(-s,-l),s),m=f*(f+2*l)+c):(d=Math.max(0,-(a*s+o)),f=d>0?s:Math.min(Math.max(-s,-l),s),m=-d*d+f*(f+2*l)+c);else f=a>0?-s:s,d=Math.max(0,-(a*f+o)),m=-d*d+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),r&&r.copy(Pr).addScaledVector(Hi,f),m}intersectSphere(e,t){jt.subVectors(e.center,this.origin);const n=jt.dot(this.direction),r=jt.dot(jt)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),h>=0?(s=(e.min.y-f.y)*h,a=(e.max.y-f.y)*h):(s=(e.max.y-f.y)*h,a=(e.min.y-f.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),d>=0?(o=(e.min.z-f.z)*d,l=(e.max.z-f.z)*d):(o=(e.max.z-f.z)*d,l=(e.min.z-f.z)*d),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,jt)!==null}intersectTriangle(e,t,n,r,s){Lr.subVectors(t,e),Gi.subVectors(n,e),Dr.crossVectors(Lr,Gi);let a=this.direction.dot(Dr),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;un.subVectors(this.origin,e);const l=o*this.direction.dot(Gi.crossVectors(un,Gi));if(l<0)return null;const c=o*this.direction.dot(Lr.cross(un));if(c<0||l+c>a)return null;const h=-o*un.dot(Dr);return h<0?null:this.at(h/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ke{constructor(e,t,n,r,s,a,o,l,c,h,d,f,m,v,S,p){ke.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c,h,d,f,m,v,S,p)}set(e,t,n,r,s,a,o,l,c,h,d,f,m,v,S,p){const u=this.elements;return u[0]=e,u[4]=t,u[8]=n,u[12]=r,u[1]=s,u[5]=a,u[9]=o,u[13]=l,u[2]=c,u[6]=h,u[10]=d,u[14]=f,u[3]=m,u[7]=v,u[11]=S,u[15]=p,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 ke().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Kn.setFromMatrixColumn(e,0).length(),s=1/Kn.setFromMatrixColumn(e,1).length(),a=1/Kn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(e.order==="XYZ"){const f=a*h,m=a*d,v=o*h,S=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=m+v*c,t[5]=f-S*c,t[9]=-o*l,t[2]=S-f*c,t[6]=v+m*c,t[10]=a*l}else if(e.order==="YXZ"){const f=l*h,m=l*d,v=c*h,S=c*d;t[0]=f+S*o,t[4]=v*o-m,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=m*o-v,t[6]=S+f*o,t[10]=a*l}else if(e.order==="ZXY"){const f=l*h,m=l*d,v=c*h,S=c*d;t[0]=f-S*o,t[4]=-a*d,t[8]=v+m*o,t[1]=m+v*o,t[5]=a*h,t[9]=S-f*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const f=a*h,m=a*d,v=o*h,S=o*d;t[0]=l*h,t[4]=v*c-m,t[8]=f*c+S,t[1]=l*d,t[5]=S*c+f,t[9]=m*c-v,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const f=a*l,m=a*c,v=o*l,S=o*c;t[0]=l*h,t[4]=S-f*d,t[8]=v*d+m,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*d+v,t[10]=f-S*d}else if(e.order==="XZY"){const f=a*l,m=a*c,v=o*l,S=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=f*d+S,t[5]=a*h,t[9]=m*d-v,t[2]=v*d-m,t[6]=o*h,t[10]=S*d+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mc,e,_c)}lookAt(e,t,n){const r=this.elements;return Ct.subVectors(e,t),Ct.lengthSq()===0&&(Ct.z=1),Ct.normalize(),hn.crossVectors(n,Ct),hn.lengthSq()===0&&(Math.abs(n.z)===1?Ct.x+=1e-4:Ct.z+=1e-4,Ct.normalize(),hn.crossVectors(n,Ct)),hn.normalize(),Vi.crossVectors(Ct,hn),r[0]=hn.x,r[4]=Vi.x,r[8]=Ct.x,r[1]=hn.y,r[5]=Vi.y,r[9]=Ct.y,r[2]=hn.z,r[6]=Vi.z,r[10]=Ct.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],f=n[9],m=n[13],v=n[2],S=n[6],p=n[10],u=n[14],A=n[3],y=n[7],M=n[11],U=n[15],R=r[0],C=r[4],I=r[8],E=r[12],x=r[1],P=r[5],Y=r[9],z=r[13],X=r[2],J=r[6],V=r[10],te=r[14],H=r[3],le=r[7],de=r[11],Ee=r[15];return s[0]=a*R+o*x+l*X+c*H,s[4]=a*C+o*P+l*J+c*le,s[8]=a*I+o*Y+l*V+c*de,s[12]=a*E+o*z+l*te+c*Ee,s[1]=h*R+d*x+f*X+m*H,s[5]=h*C+d*P+f*J+m*le,s[9]=h*I+d*Y+f*V+m*de,s[13]=h*E+d*z+f*te+m*Ee,s[2]=v*R+S*x+p*X+u*H,s[6]=v*C+S*P+p*J+u*le,s[10]=v*I+S*Y+p*V+u*de,s[14]=v*E+S*z+p*te+u*Ee,s[3]=A*R+y*x+M*X+U*H,s[7]=A*C+y*P+M*J+U*le,s[11]=A*I+y*Y+M*V+U*de,s[15]=A*E+y*z+M*te+U*Ee,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],f=e[10],m=e[14],v=e[3],S=e[7],p=e[11],u=e[15];return v*(+s*l*d-r*c*d-s*o*f+n*c*f+r*o*m-n*l*m)+S*(+t*l*m-t*c*f+s*a*f-r*a*m+r*c*h-s*l*h)+p*(+t*c*d-t*o*m-s*a*d+n*a*m+s*o*h-n*c*h)+u*(-r*o*h-t*l*d+t*o*f+r*a*d-n*a*f+n*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],f=e[10],m=e[11],v=e[12],S=e[13],p=e[14],u=e[15],A=d*p*c-S*f*c+S*l*m-o*p*m-d*l*u+o*f*u,y=v*f*c-h*p*c-v*l*m+a*p*m+h*l*u-a*f*u,M=h*S*c-v*d*c+v*o*m-a*S*m-h*o*u+a*d*u,U=v*d*l-h*S*l-v*o*f+a*S*f+h*o*p-a*d*p,R=t*A+n*y+r*M+s*U;if(R===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/R;return e[0]=A*C,e[1]=(S*f*s-d*p*s-S*r*m+n*p*m+d*r*u-n*f*u)*C,e[2]=(o*p*s-S*l*s+S*r*c-n*p*c-o*r*u+n*l*u)*C,e[3]=(d*l*s-o*f*s-d*r*c+n*f*c+o*r*m-n*l*m)*C,e[4]=y*C,e[5]=(h*p*s-v*f*s+v*r*m-t*p*m-h*r*u+t*f*u)*C,e[6]=(v*l*s-a*p*s-v*r*c+t*p*c+a*r*u-t*l*u)*C,e[7]=(a*f*s-h*l*s+h*r*c-t*f*c-a*r*m+t*l*m)*C,e[8]=M*C,e[9]=(v*d*s-h*S*s-v*n*m+t*S*m+h*n*u-t*d*u)*C,e[10]=(a*S*s-v*o*s+v*n*c-t*S*c-a*n*u+t*o*u)*C,e[11]=(h*o*s-a*d*s-h*n*c+t*d*c+a*n*m-t*o*m)*C,e[12]=U*C,e[13]=(h*S*r-v*d*r+v*n*f-t*S*f-h*n*p+t*d*p)*C,e[14]=(v*o*r-a*S*r-v*n*l+t*S*l+a*n*p-t*o*p)*C,e[15]=(a*d*r-h*o*r+h*n*l-t*d*l-a*n*f+t*o*f)*C,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,d=o+o,f=s*c,m=s*h,v=s*d,S=a*h,p=a*d,u=o*d,A=l*c,y=l*h,M=l*d,U=n.x,R=n.y,C=n.z;return r[0]=(1-(S+u))*U,r[1]=(m+M)*U,r[2]=(v-y)*U,r[3]=0,r[4]=(m-M)*R,r[5]=(1-(f+u))*R,r[6]=(p+A)*R,r[7]=0,r[8]=(v+y)*C,r[9]=(p-A)*C,r[10]=(1-(f+S))*C,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let s=Kn.set(r[0],r[1],r[2]).length();const a=Kn.set(r[4],r[5],r[6]).length(),o=Kn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],Bt.copy(this);const c=1/s,h=1/a,d=1/o;return Bt.elements[0]*=c,Bt.elements[1]*=c,Bt.elements[2]*=c,Bt.elements[4]*=h,Bt.elements[5]*=h,Bt.elements[6]*=h,Bt.elements[8]*=d,Bt.elements[9]*=d,Bt.elements[10]*=d,t.setFromRotationMatrix(Bt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,r,s,a,o=sn){const l=this.elements,c=2*s/(t-e),h=2*s/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r);let m,v;if(o===sn)m=-(a+s)/(a-s),v=-2*a*s/(a-s);else if(o===dr)m=-a/(a-s),v=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=sn){const l=this.elements,c=1/(t-e),h=1/(n-r),d=1/(a-s),f=(t+e)*c,m=(n+r)*h;let v,S;if(o===sn)v=(a+s)*d,S=-2*d;else if(o===dr)v=s*d,S=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-f,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=S,l[14]=-v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Kn=new F,Bt=new ke,mc=new F(0,0,0),_c=new F(1,1,1),hn=new F,Vi=new F,Ct=new F,xa=new ke,Sa=new Pi;class on{constructor(e=0,t=0,n=0,r=on.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],d=r[2],f=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,s),this._z=0);break;case"ZXY":this._x=Math.asin(Be(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Be(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Be(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return xa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xa,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Sa.setFromEuler(this),this.setFromQuaternion(Sa,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}on.DEFAULT_ORDER="XYZ";class Ro{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let gc=0;const Ma=new F,Zn=new Pi,Jt=new ke,ki=new F,xi=new F,vc=new F,xc=new Pi,Ea=new F(1,0,0),Ta=new F(0,1,0),ya=new F(0,0,1),Aa={type:"added"},Sc={type:"removed"},$n={type:"childadded",child:null},Ur={type:"childremoved",child:null};class gt extends Hn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gc++}),this.uuid=Ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();const e=new F,t=new on,n=new Pi,r=new F(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ke},normalMatrix:{value:new Ue}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ro,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Zn.setFromAxisAngle(e,t),this.quaternion.multiply(Zn),this}rotateOnWorldAxis(e,t){return Zn.setFromAxisAngle(e,t),this.quaternion.premultiply(Zn),this}rotateX(e){return this.rotateOnAxis(Ea,e)}rotateY(e){return this.rotateOnAxis(Ta,e)}rotateZ(e){return this.rotateOnAxis(ya,e)}translateOnAxis(e,t){return Ma.copy(e).applyQuaternion(this.quaternion),this.position.add(Ma.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ea,e)}translateY(e){return this.translateOnAxis(Ta,e)}translateZ(e){return this.translateOnAxis(ya,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ki.copy(e):ki.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),xi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jt.lookAt(xi,ki,this.up):Jt.lookAt(ki,xi,this.up),this.quaternion.setFromRotationMatrix(Jt),r&&(Jt.extractRotation(r.matrixWorld),Zn.setFromRotationMatrix(Jt),this.quaternion.premultiply(Zn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Aa),$n.child=e,this.dispatchEvent($n),$n.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Sc),Ur.child=e,this.dispatchEvent(Ur),Ur.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Jt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jt),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Aa),$n.child=e,this.dispatchEvent($n),$n.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xi,e,vc),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xi,xc,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];s(e.shapes,d)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),f=a(e.skeletons),m=a(e.animations),v=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),f.length>0&&(n.skeletons=f),m.length>0&&(n.animations=m),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}gt.DEFAULT_UP=new F(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zt=new F,Qt=new F,Ir=new F,en=new F,jn=new F,Jn=new F,ba=new F,Nr=new F,Fr=new F,Or=new F,Br=new ct,zr=new ct,Hr=new ct;class Ht{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),zt.subVectors(e,t),r.cross(zt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){zt.subVectors(r,t),Qt.subVectors(n,t),Ir.subVectors(e,t);const a=zt.dot(zt),o=zt.dot(Qt),l=zt.dot(Ir),c=Qt.dot(Qt),h=Qt.dot(Ir),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const f=1/d,m=(c*l-o*h)*f,v=(a*h-o*l)*f;return s.set(1-m-v,v,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,en)===null?!1:en.x>=0&&en.y>=0&&en.x+en.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,en)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,en.x),l.addScaledVector(a,en.y),l.addScaledVector(o,en.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return Br.setScalar(0),zr.setScalar(0),Hr.setScalar(0),Br.fromBufferAttribute(e,t),zr.fromBufferAttribute(e,n),Hr.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Br,s.x),a.addScaledVector(zr,s.y),a.addScaledVector(Hr,s.z),a}static isFrontFacing(e,t,n,r){return zt.subVectors(n,t),Qt.subVectors(e,t),zt.cross(Qt).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return zt.subVectors(this.c,this.b),Qt.subVectors(this.a,this.b),zt.cross(Qt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ht.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Ht.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Ht.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Ht.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ht.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;jn.subVectors(r,n),Jn.subVectors(s,n),Nr.subVectors(e,n);const l=jn.dot(Nr),c=Jn.dot(Nr);if(l<=0&&c<=0)return t.copy(n);Fr.subVectors(e,r);const h=jn.dot(Fr),d=Jn.dot(Fr);if(h>=0&&d<=h)return t.copy(r);const f=l*d-h*c;if(f<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(jn,a);Or.subVectors(e,s);const m=jn.dot(Or),v=Jn.dot(Or);if(v>=0&&m<=v)return t.copy(s);const S=m*c-l*v;if(S<=0&&c>=0&&v<=0)return o=c/(c-v),t.copy(n).addScaledVector(Jn,o);const p=h*v-m*d;if(p<=0&&d-h>=0&&m-v>=0)return ba.subVectors(s,r),o=(d-h)/(d-h+(m-v)),t.copy(r).addScaledVector(ba,o);const u=1/(p+S+f);return a=S*u,o=f*u,t.copy(n).addScaledVector(jn,a).addScaledVector(Jn,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Co={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},dn={h:0,s:0,l:0},Wi={h:0,s:0,l:0};function Gr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class ze{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=It){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ve.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=Ve.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ve.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=Ve.workingColorSpace){if(e=nc(e,1),t=Be(t,0,1),n=Be(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Gr(a,s,e+1/3),this.g=Gr(a,s,e),this.b=Gr(a,s,e-1/3)}return Ve.colorSpaceToWorking(this,r),this}setStyle(e,t=It){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=It){const n=Co[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=an(e.r),this.g=an(e.g),this.b=an(e.b),this}copyLinearToSRGB(e){return this.r=oi(e.r),this.g=oi(e.g),this.b=oi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=It){return Ve.workingToColorSpace(xt.copy(this),e),Math.round(Be(xt.r*255,0,255))*65536+Math.round(Be(xt.g*255,0,255))*256+Math.round(Be(xt.b*255,0,255))}getHexString(e=It){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ve.workingColorSpace){Ve.workingToColorSpace(xt.copy(this),t);const n=xt.r,r=xt.g,s=xt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ve.workingColorSpace){return Ve.workingToColorSpace(xt.copy(this),t),e.r=xt.r,e.g=xt.g,e.b=xt.b,e}getStyle(e=It){Ve.workingToColorSpace(xt.copy(this),e);const t=xt.r,n=xt.g,r=xt.b;return e!==It?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(dn),this.setHSL(dn.h+e,dn.s+t,dn.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(dn),e.getHSL(Wi);const n=Tr(dn.h,Wi.h,t),r=Tr(dn.s,Wi.s,t),s=Tr(dn.l,Wi.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const xt=new ze;ze.NAMES=Co;let Mc=0;class Li extends Hn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Mc++}),this.uuid=Ci(),this.name="",this.type="Material",this.blending=si,this.side=vn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Qr,this.blendDst=es,this.blendEquation=Ln,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=li,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=da,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=kn,this.stencilZFail=kn,this.stencilZPass=kn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==si&&(n.blending=this.blending),this.side!==vn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Qr&&(n.blendSrc=this.blendSrc),this.blendDst!==es&&(n.blendDst=this.blendDst),this.blendEquation!==Ln&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==li&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==da&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==kn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==kn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==kn&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Po extends Li{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 on,this.combine=mo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ut=new F,Xi=new Ye;let Ec=0;class Yt{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Ec++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=fa,this.updateRanges=[],this.gpuType=rn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Xi.fromBufferAttribute(this,t),Xi.applyMatrix3(e),this.setXY(t,Xi.x,Xi.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix3(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyMatrix4(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.applyNormalMatrix(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ut.fromBufferAttribute(this,t),ut.transformDirection(e),this.setXYZ(t,ut.x,ut.y,ut.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=_i(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=yt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=_i(t,this.array)),t}setX(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=_i(t,this.array)),t}setY(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=_i(t,this.array)),t}setZ(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=_i(t,this.array)),t}setW(e,t){return this.normalized&&(t=yt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=yt(t,this.array),n=yt(n,this.array),r=yt(r,this.array),s=yt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==fa&&(e.usage=this.usage),e}}class Lo extends Yt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Do extends Yt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class On extends Yt{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Tc=0;const Ut=new ke,Vr=new gt,Qn=new F,Pt=new fi,Si=new fi,pt=new F;class Gn extends Hn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Tc++}),this.uuid=Ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(bo(e)?Do:Lo)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ue().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ut.makeRotationFromQuaternion(e),this.applyMatrix4(Ut),this}rotateX(e){return Ut.makeRotationX(e),this.applyMatrix4(Ut),this}rotateY(e){return Ut.makeRotationY(e),this.applyMatrix4(Ut),this}rotateZ(e){return Ut.makeRotationZ(e),this.applyMatrix4(Ut),this}translate(e,t,n){return Ut.makeTranslation(e,t,n),this.applyMatrix4(Ut),this}scale(e,t,n){return Ut.makeScale(e,t,n),this.applyMatrix4(Ut),this}lookAt(e){return Vr.lookAt(e),Vr.updateMatrix(),this.applyMatrix4(Vr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qn).negate(),this.translate(Qn.x,Qn.y,Qn.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new On(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Pt.setFromBufferAttribute(s),this.morphTargetsRelative?(pt.addVectors(this.boundingBox.min,Pt.min),this.boundingBox.expandByPoint(pt),pt.addVectors(this.boundingBox.max,Pt.max),this.boundingBox.expandByPoint(pt)):(this.boundingBox.expandByPoint(Pt.min),this.boundingBox.expandByPoint(Pt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Zs);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){const n=this.boundingSphere.center;if(Pt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Si.setFromBufferAttribute(o),this.morphTargetsRelative?(pt.addVectors(Pt.min,Si.min),Pt.expandByPoint(pt),pt.addVectors(Pt.max,Si.max),Pt.expandByPoint(pt)):(Pt.expandByPoint(Si.min),Pt.expandByPoint(Si.max))}Pt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)pt.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(pt));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)pt.fromBufferAttribute(o,c),l&&(Qn.fromBufferAttribute(e,c),pt.add(Qn)),r=Math.max(r,n.distanceToSquared(pt))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yt(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<n.count;I++)o[I]=new F,l[I]=new F;const c=new F,h=new F,d=new F,f=new Ye,m=new Ye,v=new Ye,S=new F,p=new F;function u(I,E,x){c.fromBufferAttribute(n,I),h.fromBufferAttribute(n,E),d.fromBufferAttribute(n,x),f.fromBufferAttribute(s,I),m.fromBufferAttribute(s,E),v.fromBufferAttribute(s,x),h.sub(c),d.sub(c),m.sub(f),v.sub(f);const P=1/(m.x*v.y-v.x*m.y);isFinite(P)&&(S.copy(h).multiplyScalar(v.y).addScaledVector(d,-m.y).multiplyScalar(P),p.copy(d).multiplyScalar(m.x).addScaledVector(h,-v.x).multiplyScalar(P),o[I].add(S),o[E].add(S),o[x].add(S),l[I].add(p),l[E].add(p),l[x].add(p))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let I=0,E=A.length;I<E;++I){const x=A[I],P=x.start,Y=x.count;for(let z=P,X=P+Y;z<X;z+=3)u(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const y=new F,M=new F,U=new F,R=new F;function C(I){U.fromBufferAttribute(r,I),R.copy(U);const E=o[I];y.copy(E),y.sub(U.multiplyScalar(U.dot(E))).normalize(),M.crossVectors(R,E);const P=M.dot(l[I])<0?-1:1;a.setXYZW(I,y.x,y.y,y.z,P)}for(let I=0,E=A.length;I<E;++I){const x=A[I],P=x.start,Y=x.count;for(let z=P,X=P+Y;z<X;z+=3)C(e.getX(z+0)),C(e.getX(z+1)),C(e.getX(z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Yt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,m=n.count;f<m;f++)n.setXYZ(f,0,0,0);const r=new F,s=new F,a=new F,o=new F,l=new F,c=new F,h=new F,d=new F;if(e)for(let f=0,m=e.count;f<m;f+=3){const v=e.getX(f+0),S=e.getX(f+1),p=e.getX(f+2);r.fromBufferAttribute(t,v),s.fromBufferAttribute(t,S),a.fromBufferAttribute(t,p),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),o.fromBufferAttribute(n,v),l.fromBufferAttribute(n,S),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(v,o.x,o.y,o.z),n.setXYZ(S,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let f=0,m=t.count;f<m;f+=3)r.fromBufferAttribute(t,f+0),s.fromBufferAttribute(t,f+1),a.fromBufferAttribute(t,f+2),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)pt.fromBufferAttribute(e,t),pt.normalize(),e.setXYZ(t,pt.x,pt.y,pt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,f=new c.constructor(l.length*h);let m=0,v=0;for(let S=0,p=l.length;S<p;S++){o.isInterleavedBufferAttribute?m=l[S]*o.data.stride+o.offset:m=l[S]*h;for(let u=0;u<h;u++)f[v++]=c[m++]}return new Yt(f,h,d)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Gn,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,d=c.length;h<d;h++){const f=c[h],m=e(f,n);l.push(m)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,f=c.length;d<f;d++){const m=c[d];h.push(m.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],d=s[c];for(let f=0,m=d.length;f<m;f++)h.push(d[f].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const wa=new ke,yn=new pc,qi=new Zs,Ra=new F,Yi=new F,Ki=new F,Zi=new F,kr=new F,$i=new F,Ca=new F,ji=new F;class qt extends gt{constructor(e=new Gn,t=new Po){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){$i.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(kr.fromBufferAttribute(d,e),a?$i.addScaledVector(kr,h):$i.addScaledVector(kr.sub(t),h))}t.add($i)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),qi.copy(n.boundingSphere),qi.applyMatrix4(s),yn.copy(e.ray).recast(e.near),!(qi.containsPoint(yn.origin)===!1&&(yn.intersectSphere(qi,Ra)===null||yn.origin.distanceToSquared(Ra)>(e.far-e.near)**2))&&(wa.copy(s).invert(),yn.copy(e.ray).applyMatrix4(wa),!(n.boundingBox!==null&&yn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,yn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,f=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,S=f.length;v<S;v++){const p=f[v],u=a[p.materialIndex],A=Math.max(p.start,m.start),y=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let M=A,U=y;M<U;M+=3){const R=o.getX(M),C=o.getX(M+1),I=o.getX(M+2);r=Ji(this,u,e,n,c,h,d,R,C,I),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),S=Math.min(o.count,m.start+m.count);for(let p=v,u=S;p<u;p+=3){const A=o.getX(p),y=o.getX(p+1),M=o.getX(p+2);r=Ji(this,a,e,n,c,h,d,A,y,M),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let v=0,S=f.length;v<S;v++){const p=f[v],u=a[p.materialIndex],A=Math.max(p.start,m.start),y=Math.min(l.count,Math.min(p.start+p.count,m.start+m.count));for(let M=A,U=y;M<U;M+=3){const R=M,C=M+1,I=M+2;r=Ji(this,u,e,n,c,h,d,R,C,I),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const v=Math.max(0,m.start),S=Math.min(l.count,m.start+m.count);for(let p=v,u=S;p<u;p+=3){const A=p,y=p+1,M=p+2;r=Ji(this,a,e,n,c,h,d,A,y,M),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function yc(i,e,t,n,r,s,a,o){let l;if(e.side===At?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===vn,o),l===null)return null;ji.copy(o),ji.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(ji);return c<t.near||c>t.far?null:{distance:c,point:ji.clone(),object:i}}function Ji(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,Yi),i.getVertexPosition(l,Ki),i.getVertexPosition(c,Zi);const h=yc(i,e,t,n,Yi,Ki,Zi,Ca);if(h){const d=new F;Ht.getBarycoord(Ca,Yi,Ki,Zi,d),r&&(h.uv=Ht.getInterpolatedAttribute(r,o,l,c,d,new Ye)),s&&(h.uv1=Ht.getInterpolatedAttribute(s,o,l,c,d,new Ye)),a&&(h.normal=Ht.getInterpolatedAttribute(a,o,l,c,d,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new F,materialIndex:0};Ht.getNormal(Yi,Ki,Zi,f.normal),h.face=f,h.barycoord=d}return h}class Di extends Gn{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let f=0,m=0;v("z","y","x",-1,-1,n,t,e,a,s,0),v("z","y","x",1,-1,n,t,-e,a,s,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,s,4),v("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new On(c,3)),this.setAttribute("normal",new On(h,3)),this.setAttribute("uv",new On(d,2));function v(S,p,u,A,y,M,U,R,C,I,E){const x=M/C,P=U/I,Y=M/2,z=U/2,X=R/2,J=C+1,V=I+1;let te=0,H=0;const le=new F;for(let de=0;de<V;de++){const Ee=de*P-z;for(let Fe=0;Fe<J;Fe++){const je=Fe*x-Y;le[S]=je*A,le[p]=Ee*y,le[u]=X,c.push(le.x,le.y,le.z),le[S]=0,le[p]=0,le[u]=R>0?1:-1,h.push(le.x,le.y,le.z),d.push(Fe/C),d.push(1-de/I),te+=1}}for(let de=0;de<I;de++)for(let Ee=0;Ee<C;Ee++){const Fe=f+Ee+J*de,je=f+Ee+J*(de+1),q=f+(Ee+1)+J*(de+1),ne=f+(Ee+1)+J*de;l.push(Fe,je,ne),l.push(je,q,ne),H+=6}o.addGroup(m,H,E),m+=H,f+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Di(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function di(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function Et(i){const e={};for(let t=0;t<i.length;t++){const n=di(i[t]);for(const r in n)e[r]=n[r]}return e}function Ac(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Uo(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ve.workingColorSpace}const bc={clone:di,merge:Et};var wc=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,Rc=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`;class xn extends Li{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=wc,this.fragmentShader=Rc,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=di(e.uniforms),this.uniformsGroups=Ac(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Io extends gt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke,this.coordinateSystem=sn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const fn=new F,Pa=new Ye,La=new Ye;class Nt extends Io{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Bs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Er*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Bs*2*Math.atan(Math.tan(Er*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){fn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(fn.x,fn.y).multiplyScalar(-e/fn.z),fn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(fn.x,fn.y).multiplyScalar(-e/fn.z)}getViewSize(e,t){return this.getViewBounds(e,Pa,La),t.subVectors(La,Pa)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Er*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ei=-90,ti=1;class Cc extends gt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Nt(ei,ti,e,t);r.layers=this.layers,this.add(r);const s=new Nt(ei,ti,e,t);s.layers=this.layers,this.add(s);const a=new Nt(ei,ti,e,t);a.layers=this.layers,this.add(a);const o=new Nt(ei,ti,e,t);o.layers=this.layers,this.add(o);const l=new Nt(ei,ti,e,t);l.layers=this.layers,this.add(l);const c=new Nt(ei,ti,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===sn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===dr)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=e.getRenderTarget(),f=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const S=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,l),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,r),e.render(t,h),e.setRenderTarget(d,f,m),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class No extends bt{constructor(e=[],t=ci,n,r,s,a,o,l,c,h){super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Pc extends zn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new No(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},r=new Di(5,5,5),s=new xn({name:"CubemapFromEquirect",uniforms:di(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:At,blending:_n});s.uniforms.tEquirect.value=t;const a=new qt(r,s),o=t.minFilter;return t.minFilter===Nn&&(t.minFilter=Xt),new Cc(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(s)}}class mn extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Lc={type:"move"};class Wr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new mn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new mn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new mn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const S of e.hand.values()){const p=t.getJointPose(S,n),u=this._getHandJoint(c,S);p!==null&&(u.matrix.fromArray(p.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=p.radius),u.visible=p!==null}const h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],f=h.position.distanceTo(d.position),m=.02,v=.005;c.inputState.pinching&&f>m+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=m-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(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,this.dispatchEvent(Lc)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new mn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Dc extends gt{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 on,this.environmentIntensity=1,this.environmentRotation=new on,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Xr=new F,Uc=new F,Ic=new Ue;class Rn{constructor(e=new F(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Xr.subVectors(n,t).cross(Uc.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Xr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Ic.getNormalMatrix(e),r=this.coplanarPoint(Xr).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const An=new Zs,Nc=new Ye(.5,.5),Qi=new F;class $s{constructor(e=new Rn,t=new Rn,n=new Rn,r=new Rn,s=new Rn,a=new Rn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=sn){const n=this.planes,r=e.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],h=r[5],d=r[6],f=r[7],m=r[8],v=r[9],S=r[10],p=r[11],u=r[12],A=r[13],y=r[14],M=r[15];if(n[0].setComponents(l-s,f-c,p-m,M-u).normalize(),n[1].setComponents(l+s,f+c,p+m,M+u).normalize(),n[2].setComponents(l+a,f+h,p+v,M+A).normalize(),n[3].setComponents(l-a,f-h,p-v,M-A).normalize(),n[4].setComponents(l-o,f-d,p-S,M-y).normalize(),t===sn)n[5].setComponents(l+o,f+d,p+S,M+y).normalize();else if(t===dr)n[5].setComponents(o,d,S,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),An.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),An.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(An)}intersectsSprite(e){An.center.set(0,0,0);const t=Nc.distanceTo(e.center);return An.radius=.7071067811865476+t,An.applyMatrix4(e.matrixWorld),this.intersectsSphere(An)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Qi.x=r.normal.x>0?e.max.x:e.min.x,Qi.y=r.normal.y>0?e.max.y:e.min.y,Qi.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Qi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Fo extends bt{constructor(e,t,n=Bn,r,s,a,o=kt,l=kt,c,h=Ai,d=1){if(h!==Ai&&h!==bi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const f={width:e,height:t,depth:d};super(f,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ks(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Ui extends Gn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,d=e/o,f=t/l,m=[],v=[],S=[],p=[];for(let u=0;u<h;u++){const A=u*f-a;for(let y=0;y<c;y++){const M=y*d-s;v.push(M,-A,0),S.push(0,0,1),p.push(y/o),p.push(1-u/l)}}for(let u=0;u<l;u++)for(let A=0;A<o;A++){const y=A+c*u,M=A+c*(u+1),U=A+1+c*(u+1),R=A+1+c*u;m.push(y,M,R),m.push(M,U,R)}this.setIndex(m),this.setAttribute("position",new On(v,3)),this.setAttribute("normal",new On(S,3)),this.setAttribute("uv",new On(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ui(e.width,e.height,e.widthSegments,e.heightSegments)}}class Fc extends Li{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ze(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class Oc extends Li{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Xl,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Bc extends Li{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Oo extends gt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class zc extends Oo{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const qr=new ke,Da=new F,Ua=new F;class Hc{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ye(512,512),this.mapType=Kt,this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $s,this._frameExtents=new Ye(1,1),this._viewportCount=1,this._viewports=[new ct(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Da.setFromMatrixPosition(e.matrixWorld),t.position.copy(Da),Ua.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ua),t.updateMatrixWorld(),qr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(qr),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(qr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Bo extends Io{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Gc extends Hc{constructor(){super(new Bo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Vc extends Oo{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new Gc}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class kc extends Nt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}function Ia(i,e,t,n){const r=Wc(n);switch(t){case So:return i*e;case Eo:return i*e/r.components*r.byteLength;case Xs:return i*e/r.components*r.byteLength;case To:return i*e*2/r.components*r.byteLength;case qs:return i*e*2/r.components*r.byteLength;case Mo:return i*e*3/r.components*r.byteLength;case Gt:return i*e*4/r.components*r.byteLength;case Ys:return i*e*4/r.components*r.byteLength;case sr:case ar:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case or:case lr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case fs:case ms:return Math.max(i,16)*Math.max(e,8)/4;case ds:case ps:return Math.max(i,8)*Math.max(e,8)/2;case _s:case gs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case vs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case xs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ss:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ms:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Es:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ts:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case ys:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case As:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case bs:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ws:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Rs:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Cs:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ps:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ls:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ds:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case cr:case Us:case Is:return Math.ceil(i/4)*Math.ceil(e/4)*16;case yo:case Ns:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Fs:case Os:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Wc(i){switch(i){case Kt:case go:return{byteLength:1,components:1};case Ti:case vo:case Ri:return{byteLength:2,components:1};case ks:case Ws:return{byteLength:2,components:4};case Bn:case Vs:case rn:return{byteLength:4,components:1};case xo:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Gs}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Gs);function zo(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Xc(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,f=i.createBuffer();i.bindBuffer(l,f),i.bufferData(l,c,h),o.onUploadCallback();let m;if(c instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=i.SHORT;else if(c instanceof Uint32Array)m=i.UNSIGNED_INT;else if(c instanceof Int32Array)m=i.INT;else if(c instanceof Int8Array)m=i.BYTE;else if(c instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:f,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,l,c){const h=l.array,d=l.updateRanges;if(i.bindBuffer(c,o),d.length===0)i.bufferSubData(c,0,h);else{d.sort((m,v)=>m.start-v.start);let f=0;for(let m=1;m<d.length;m++){const v=d[f],S=d[m];S.start<=v.start+v.count+1?v.count=Math.max(v.count,S.start+S.count-v.start):(++f,d[f]=S)}d.length=f+1;for(let m=0,v=d.length;m<v;m++){const S=d[m];i.bufferSubData(c,S.start*h.BYTES_PER_ELEMENT,h,S.start,S.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.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.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var qc=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,Yc=`#ifdef USE_ALPHAHASH
43
+ const float ALPHA_HASH_SCALE = 0.05;
44
+ float hash2D( vec2 value ) {
45
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
+ }
47
+ float hash3D( vec3 value ) {
48
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
+ }
50
+ float getAlphaHashThreshold( vec3 position ) {
51
+ float maxDeriv = max(
52
+ length( dFdx( position.xyz ) ),
53
+ length( dFdy( position.xyz ) )
54
+ );
55
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
+ vec2 pixScales = vec2(
57
+ exp2( floor( log2( pixScale ) ) ),
58
+ exp2( ceil( log2( pixScale ) ) )
59
+ );
60
+ vec2 alpha = vec2(
61
+ hash3D( floor( pixScales.x * position.xyz ) ),
62
+ hash3D( floor( pixScales.y * position.xyz ) )
63
+ );
64
+ float lerpFactor = fract( log2( pixScale ) );
65
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
+ float a = min( lerpFactor, 1.0 - lerpFactor );
67
+ vec3 cases = vec3(
68
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
+ ( x - 0.5 * a ) / ( 1.0 - a ),
70
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
+ );
72
+ float threshold = ( x < ( 1.0 - a ) )
73
+ ? ( ( x < a ) ? cases.x : cases.y )
74
+ : cases.z;
75
+ return clamp( threshold , 1.0e-6, 1.0 );
76
+ }
77
+ #endif`,Kc=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,Zc=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,$c=`#ifdef USE_ALPHATEST
82
+ #ifdef ALPHA_TO_COVERAGE
83
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
+ if ( diffuseColor.a == 0.0 ) discard;
85
+ #else
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif
88
+ #endif`,jc=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,Jc=`#ifdef USE_AOMAP
91
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
93
+ #if defined( USE_CLEARCOAT )
94
+ clearcoatSpecularIndirect *= ambientOcclusion;
95
+ #endif
96
+ #if defined( USE_SHEEN )
97
+ sheenSpecularIndirect *= ambientOcclusion;
98
+ #endif
99
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
100
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
+ #endif
103
+ #endif`,Qc=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,eu=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,tu=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,nu=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,iu=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,ru=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,su=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,au=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,ou=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,lu=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,cu=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,uu=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,hu=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,du=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,fu=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,pu=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,mu=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ mat3 transposeMat3( const in mat3 m ) {
375
+ mat3 tmp;
376
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
377
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
378
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
379
+ return tmp;
380
+ }
381
+ bool isPerspectiveMatrix( mat4 m ) {
382
+ return m[ 2 ][ 3 ] == - 1.0;
383
+ }
384
+ vec2 equirectUv( in vec3 dir ) {
385
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
386
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
387
+ return vec2( u, v );
388
+ }
389
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
390
+ return RECIPROCAL_PI * diffuseColor;
391
+ }
392
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
393
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
394
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
395
+ }
396
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
+ } // validated`,_u=`#ifdef ENVMAP_TYPE_CUBE_UV
400
+ #define cubeUV_minMipLevel 4.0
401
+ #define cubeUV_minTileSize 16.0
402
+ float getFace( vec3 direction ) {
403
+ vec3 absDirection = abs( direction );
404
+ float face = - 1.0;
405
+ if ( absDirection.x > absDirection.z ) {
406
+ if ( absDirection.x > absDirection.y )
407
+ face = direction.x > 0.0 ? 0.0 : 3.0;
408
+ else
409
+ face = direction.y > 0.0 ? 1.0 : 4.0;
410
+ } else {
411
+ if ( absDirection.z > absDirection.y )
412
+ face = direction.z > 0.0 ? 2.0 : 5.0;
413
+ else
414
+ face = direction.y > 0.0 ? 1.0 : 4.0;
415
+ }
416
+ return face;
417
+ }
418
+ vec2 getUV( vec3 direction, float face ) {
419
+ vec2 uv;
420
+ if ( face == 0.0 ) {
421
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
422
+ } else if ( face == 1.0 ) {
423
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
424
+ } else if ( face == 2.0 ) {
425
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
426
+ } else if ( face == 3.0 ) {
427
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
428
+ } else if ( face == 4.0 ) {
429
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
430
+ } else {
431
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
432
+ }
433
+ return 0.5 * ( uv + 1.0 );
434
+ }
435
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
436
+ float face = getFace( direction );
437
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
438
+ mipInt = max( mipInt, cubeUV_minMipLevel );
439
+ float faceSize = exp2( mipInt );
440
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
441
+ if ( face > 2.0 ) {
442
+ uv.y += faceSize;
443
+ face -= 3.0;
444
+ }
445
+ uv.x += face * faceSize;
446
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
447
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
448
+ uv.x *= CUBEUV_TEXEL_WIDTH;
449
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
450
+ #ifdef texture2DGradEXT
451
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
452
+ #else
453
+ return texture2D( envMap, uv ).rgb;
454
+ #endif
455
+ }
456
+ #define cubeUV_r0 1.0
457
+ #define cubeUV_m0 - 2.0
458
+ #define cubeUV_r1 0.8
459
+ #define cubeUV_m1 - 1.0
460
+ #define cubeUV_r4 0.4
461
+ #define cubeUV_m4 2.0
462
+ #define cubeUV_r5 0.305
463
+ #define cubeUV_m5 3.0
464
+ #define cubeUV_r6 0.21
465
+ #define cubeUV_m6 4.0
466
+ float roughnessToMip( float roughness ) {
467
+ float mip = 0.0;
468
+ if ( roughness >= cubeUV_r1 ) {
469
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
470
+ } else if ( roughness >= cubeUV_r4 ) {
471
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
472
+ } else if ( roughness >= cubeUV_r5 ) {
473
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
474
+ } else if ( roughness >= cubeUV_r6 ) {
475
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
476
+ } else {
477
+ mip = - 2.0 * log2( 1.16 * roughness ); }
478
+ return mip;
479
+ }
480
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
481
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
482
+ float mipF = fract( mip );
483
+ float mipInt = floor( mip );
484
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
485
+ if ( mipF == 0.0 ) {
486
+ return vec4( color0, 1.0 );
487
+ } else {
488
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
489
+ return vec4( mix( color0, color1, mipF ), 1.0 );
490
+ }
491
+ }
492
+ #endif`,gu=`vec3 transformedNormal = objectNormal;
493
+ #ifdef USE_TANGENT
494
+ vec3 transformedTangent = objectTangent;
495
+ #endif
496
+ #ifdef USE_BATCHING
497
+ mat3 bm = mat3( batchingMatrix );
498
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
499
+ transformedNormal = bm * transformedNormal;
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = bm * transformedTangent;
502
+ #endif
503
+ #endif
504
+ #ifdef USE_INSTANCING
505
+ mat3 im = mat3( instanceMatrix );
506
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
507
+ transformedNormal = im * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = im * transformedTangent;
510
+ #endif
511
+ #endif
512
+ transformedNormal = normalMatrix * transformedNormal;
513
+ #ifdef FLIP_SIDED
514
+ transformedNormal = - transformedNormal;
515
+ #endif
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
518
+ #ifdef FLIP_SIDED
519
+ transformedTangent = - transformedTangent;
520
+ #endif
521
+ #endif`,vu=`#ifdef USE_DISPLACEMENTMAP
522
+ uniform sampler2D displacementMap;
523
+ uniform float displacementScale;
524
+ uniform float displacementBias;
525
+ #endif`,xu=`#ifdef USE_DISPLACEMENTMAP
526
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
+ #endif`,Su=`#ifdef USE_EMISSIVEMAP
528
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
530
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
531
+ #endif
532
+ totalEmissiveRadiance *= emissiveColor.rgb;
533
+ #endif`,Mu=`#ifdef USE_EMISSIVEMAP
534
+ uniform sampler2D emissiveMap;
535
+ #endif`,Eu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Tu=`vec4 LinearTransferOETF( in vec4 value ) {
536
+ return value;
537
+ }
538
+ vec4 sRGBTransferEOTF( in vec4 value ) {
539
+ return 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 );
540
+ }
541
+ vec4 sRGBTransferOETF( in vec4 value ) {
542
+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
543
+ }`,yu=`#ifdef USE_ENVMAP
544
+ #ifdef ENV_WORLDPOS
545
+ vec3 cameraToFrag;
546
+ if ( isOrthographic ) {
547
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
548
+ } else {
549
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
550
+ }
551
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
552
+ #ifdef ENVMAP_MODE_REFLECTION
553
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
554
+ #else
555
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
556
+ #endif
557
+ #else
558
+ vec3 reflectVec = vReflect;
559
+ #endif
560
+ #ifdef ENVMAP_TYPE_CUBE
561
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
562
+ #else
563
+ vec4 envColor = vec4( 0.0 );
564
+ #endif
565
+ #ifdef ENVMAP_BLENDING_MULTIPLY
566
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
567
+ #elif defined( ENVMAP_BLENDING_MIX )
568
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
569
+ #elif defined( ENVMAP_BLENDING_ADD )
570
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
571
+ #endif
572
+ #endif`,Au=`#ifdef USE_ENVMAP
573
+ uniform float envMapIntensity;
574
+ uniform float flipEnvMap;
575
+ uniform mat3 envMapRotation;
576
+ #ifdef ENVMAP_TYPE_CUBE
577
+ uniform samplerCube envMap;
578
+ #else
579
+ uniform sampler2D envMap;
580
+ #endif
581
+
582
+ #endif`,bu=`#ifdef USE_ENVMAP
583
+ uniform float reflectivity;
584
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
585
+ #define ENV_WORLDPOS
586
+ #endif
587
+ #ifdef ENV_WORLDPOS
588
+ varying vec3 vWorldPosition;
589
+ uniform float refractionRatio;
590
+ #else
591
+ varying vec3 vReflect;
592
+ #endif
593
+ #endif`,wu=`#ifdef USE_ENVMAP
594
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
595
+ #define ENV_WORLDPOS
596
+ #endif
597
+ #ifdef ENV_WORLDPOS
598
+
599
+ varying vec3 vWorldPosition;
600
+ #else
601
+ varying vec3 vReflect;
602
+ uniform float refractionRatio;
603
+ #endif
604
+ #endif`,Ru=`#ifdef USE_ENVMAP
605
+ #ifdef ENV_WORLDPOS
606
+ vWorldPosition = worldPosition.xyz;
607
+ #else
608
+ vec3 cameraToVertex;
609
+ if ( isOrthographic ) {
610
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
611
+ } else {
612
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
613
+ }
614
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
615
+ #ifdef ENVMAP_MODE_REFLECTION
616
+ vReflect = reflect( cameraToVertex, worldNormal );
617
+ #else
618
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
619
+ #endif
620
+ #endif
621
+ #endif`,Cu=`#ifdef USE_FOG
622
+ vFogDepth = - mvPosition.z;
623
+ #endif`,Pu=`#ifdef USE_FOG
624
+ varying float vFogDepth;
625
+ #endif`,Lu=`#ifdef USE_FOG
626
+ #ifdef FOG_EXP2
627
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
628
+ #else
629
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
630
+ #endif
631
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
632
+ #endif`,Du=`#ifdef USE_FOG
633
+ uniform vec3 fogColor;
634
+ varying float vFogDepth;
635
+ #ifdef FOG_EXP2
636
+ uniform float fogDensity;
637
+ #else
638
+ uniform float fogNear;
639
+ uniform float fogFar;
640
+ #endif
641
+ #endif`,Uu=`#ifdef USE_GRADIENTMAP
642
+ uniform sampler2D gradientMap;
643
+ #endif
644
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
645
+ float dotNL = dot( normal, lightDirection );
646
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
647
+ #ifdef USE_GRADIENTMAP
648
+ return vec3( texture2D( gradientMap, coord ).r );
649
+ #else
650
+ vec2 fw = fwidth( coord ) * 0.5;
651
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
652
+ #endif
653
+ }`,Iu=`#ifdef USE_LIGHTMAP
654
+ uniform sampler2D lightMap;
655
+ uniform float lightMapIntensity;
656
+ #endif`,Nu=`LambertMaterial material;
657
+ material.diffuseColor = diffuseColor.rgb;
658
+ material.specularStrength = specularStrength;`,Fu=`varying vec3 vViewPosition;
659
+ struct LambertMaterial {
660
+ vec3 diffuseColor;
661
+ float specularStrength;
662
+ };
663
+ void 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 ) {
664
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
665
+ vec3 irradiance = dotNL * directLight.color;
666
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
667
+ }
668
+ void 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 ) {
669
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
670
+ }
671
+ #define RE_Direct RE_Direct_Lambert
672
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ou=`uniform bool receiveShadow;
673
+ uniform vec3 ambientLightColor;
674
+ #if defined( USE_LIGHT_PROBES )
675
+ uniform vec3 lightProbe[ 9 ];
676
+ #endif
677
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
678
+ float x = normal.x, y = normal.y, z = normal.z;
679
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
680
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
681
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
682
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
683
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
684
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
685
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
686
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
687
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
688
+ return result;
689
+ }
690
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
691
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
692
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
693
+ return irradiance;
694
+ }
695
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
696
+ vec3 irradiance = ambientLightColor;
697
+ return irradiance;
698
+ }
699
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
700
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
701
+ if ( cutoffDistance > 0.0 ) {
702
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
703
+ }
704
+ return distanceFalloff;
705
+ }
706
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
707
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
708
+ }
709
+ #if NUM_DIR_LIGHTS > 0
710
+ struct DirectionalLight {
711
+ vec3 direction;
712
+ vec3 color;
713
+ };
714
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
715
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
716
+ light.color = directionalLight.color;
717
+ light.direction = directionalLight.direction;
718
+ light.visible = true;
719
+ }
720
+ #endif
721
+ #if NUM_POINT_LIGHTS > 0
722
+ struct PointLight {
723
+ vec3 position;
724
+ vec3 color;
725
+ float distance;
726
+ float decay;
727
+ };
728
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
729
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
730
+ vec3 lVector = pointLight.position - geometryPosition;
731
+ light.direction = normalize( lVector );
732
+ float lightDistance = length( lVector );
733
+ light.color = pointLight.color;
734
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
735
+ light.visible = ( light.color != vec3( 0.0 ) );
736
+ }
737
+ #endif
738
+ #if NUM_SPOT_LIGHTS > 0
739
+ struct SpotLight {
740
+ vec3 position;
741
+ vec3 direction;
742
+ vec3 color;
743
+ float distance;
744
+ float decay;
745
+ float coneCos;
746
+ float penumbraCos;
747
+ };
748
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
749
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
750
+ vec3 lVector = spotLight.position - geometryPosition;
751
+ light.direction = normalize( lVector );
752
+ float angleCos = dot( light.direction, spotLight.direction );
753
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
754
+ if ( spotAttenuation > 0.0 ) {
755
+ float lightDistance = length( lVector );
756
+ light.color = spotLight.color * spotAttenuation;
757
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
758
+ light.visible = ( light.color != vec3( 0.0 ) );
759
+ } else {
760
+ light.color = vec3( 0.0 );
761
+ light.visible = false;
762
+ }
763
+ }
764
+ #endif
765
+ #if NUM_RECT_AREA_LIGHTS > 0
766
+ struct RectAreaLight {
767
+ vec3 color;
768
+ vec3 position;
769
+ vec3 halfWidth;
770
+ vec3 halfHeight;
771
+ };
772
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
773
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
774
+ #endif
775
+ #if NUM_HEMI_LIGHTS > 0
776
+ struct HemisphereLight {
777
+ vec3 direction;
778
+ vec3 skyColor;
779
+ vec3 groundColor;
780
+ };
781
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
782
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
783
+ float dotNL = dot( normal, hemiLight.direction );
784
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
785
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
786
+ return irradiance;
787
+ }
788
+ #endif`,Bu=`#ifdef USE_ENVMAP
789
+ vec3 getIBLIrradiance( const in vec3 normal ) {
790
+ #ifdef ENVMAP_TYPE_CUBE_UV
791
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
792
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
793
+ return PI * envMapColor.rgb * envMapIntensity;
794
+ #else
795
+ return vec3( 0.0 );
796
+ #endif
797
+ }
798
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
799
+ #ifdef ENVMAP_TYPE_CUBE_UV
800
+ vec3 reflectVec = reflect( - viewDir, normal );
801
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
802
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
803
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
804
+ return envMapColor.rgb * envMapIntensity;
805
+ #else
806
+ return vec3( 0.0 );
807
+ #endif
808
+ }
809
+ #ifdef USE_ANISOTROPY
810
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
811
+ #ifdef ENVMAP_TYPE_CUBE_UV
812
+ vec3 bentNormal = cross( bitangent, viewDir );
813
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
814
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
815
+ return getIBLRadiance( viewDir, bentNormal, roughness );
816
+ #else
817
+ return vec3( 0.0 );
818
+ #endif
819
+ }
820
+ #endif
821
+ #endif`,zu=`ToonMaterial material;
822
+ material.diffuseColor = diffuseColor.rgb;`,Hu=`varying vec3 vViewPosition;
823
+ struct ToonMaterial {
824
+ vec3 diffuseColor;
825
+ };
826
+ void 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 ) {
827
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
828
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
829
+ }
830
+ void 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 ) {
831
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
832
+ }
833
+ #define RE_Direct RE_Direct_Toon
834
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Gu=`BlinnPhongMaterial material;
835
+ material.diffuseColor = diffuseColor.rgb;
836
+ material.specularColor = specular;
837
+ material.specularShininess = shininess;
838
+ material.specularStrength = specularStrength;`,Vu=`varying vec3 vViewPosition;
839
+ struct BlinnPhongMaterial {
840
+ vec3 diffuseColor;
841
+ vec3 specularColor;
842
+ float specularShininess;
843
+ float specularStrength;
844
+ };
845
+ void 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 ) {
846
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
847
+ vec3 irradiance = dotNL * directLight.color;
848
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
849
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
850
+ }
851
+ void 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 ) {
852
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
+ }
854
+ #define RE_Direct RE_Direct_BlinnPhong
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ku=`PhysicalMaterial material;
856
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
857
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
858
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
859
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
860
+ material.roughness = min( material.roughness, 1.0 );
861
+ #ifdef IOR
862
+ material.ior = ior;
863
+ #ifdef USE_SPECULAR
864
+ float specularIntensityFactor = specularIntensity;
865
+ vec3 specularColorFactor = specularColor;
866
+ #ifdef USE_SPECULAR_COLORMAP
867
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
868
+ #endif
869
+ #ifdef USE_SPECULAR_INTENSITYMAP
870
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
871
+ #endif
872
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
873
+ #else
874
+ float specularIntensityFactor = 1.0;
875
+ vec3 specularColorFactor = vec3( 1.0 );
876
+ material.specularF90 = 1.0;
877
+ #endif
878
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
879
+ #else
880
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
881
+ material.specularF90 = 1.0;
882
+ #endif
883
+ #ifdef USE_CLEARCOAT
884
+ material.clearcoat = clearcoat;
885
+ material.clearcoatRoughness = clearcoatRoughness;
886
+ material.clearcoatF0 = vec3( 0.04 );
887
+ material.clearcoatF90 = 1.0;
888
+ #ifdef USE_CLEARCOATMAP
889
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
890
+ #endif
891
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
892
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
893
+ #endif
894
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
895
+ material.clearcoatRoughness += geometryRoughness;
896
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
897
+ #endif
898
+ #ifdef USE_DISPERSION
899
+ material.dispersion = dispersion;
900
+ #endif
901
+ #ifdef USE_IRIDESCENCE
902
+ material.iridescence = iridescence;
903
+ material.iridescenceIOR = iridescenceIOR;
904
+ #ifdef USE_IRIDESCENCEMAP
905
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
906
+ #endif
907
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
908
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
909
+ #else
910
+ material.iridescenceThickness = iridescenceThicknessMaximum;
911
+ #endif
912
+ #endif
913
+ #ifdef USE_SHEEN
914
+ material.sheenColor = sheenColor;
915
+ #ifdef USE_SHEEN_COLORMAP
916
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
917
+ #endif
918
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
919
+ #ifdef USE_SHEEN_ROUGHNESSMAP
920
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
921
+ #endif
922
+ #endif
923
+ #ifdef USE_ANISOTROPY
924
+ #ifdef USE_ANISOTROPYMAP
925
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
926
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
927
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
928
+ #else
929
+ vec2 anisotropyV = anisotropyVector;
930
+ #endif
931
+ material.anisotropy = length( anisotropyV );
932
+ if( material.anisotropy == 0.0 ) {
933
+ anisotropyV = vec2( 1.0, 0.0 );
934
+ } else {
935
+ anisotropyV /= material.anisotropy;
936
+ material.anisotropy = saturate( material.anisotropy );
937
+ }
938
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
939
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
940
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
941
+ #endif`,Wu=`struct PhysicalMaterial {
942
+ vec3 diffuseColor;
943
+ float roughness;
944
+ vec3 specularColor;
945
+ float specularF90;
946
+ float dispersion;
947
+ #ifdef USE_CLEARCOAT
948
+ float clearcoat;
949
+ float clearcoatRoughness;
950
+ vec3 clearcoatF0;
951
+ float clearcoatF90;
952
+ #endif
953
+ #ifdef USE_IRIDESCENCE
954
+ float iridescence;
955
+ float iridescenceIOR;
956
+ float iridescenceThickness;
957
+ vec3 iridescenceFresnel;
958
+ vec3 iridescenceF0;
959
+ #endif
960
+ #ifdef USE_SHEEN
961
+ vec3 sheenColor;
962
+ float sheenRoughness;
963
+ #endif
964
+ #ifdef IOR
965
+ float ior;
966
+ #endif
967
+ #ifdef USE_TRANSMISSION
968
+ float transmission;
969
+ float transmissionAlpha;
970
+ float thickness;
971
+ float attenuationDistance;
972
+ vec3 attenuationColor;
973
+ #endif
974
+ #ifdef USE_ANISOTROPY
975
+ float anisotropy;
976
+ float alphaT;
977
+ vec3 anisotropyT;
978
+ vec3 anisotropyB;
979
+ #endif
980
+ };
981
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
982
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
983
+ vec3 sheenSpecularDirect = vec3( 0.0 );
984
+ vec3 sheenSpecularIndirect = vec3(0.0 );
985
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
986
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
987
+ float x2 = x * x;
988
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
989
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
990
+ }
991
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
992
+ float a2 = pow2( alpha );
993
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
994
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
995
+ return 0.5 / max( gv + gl, EPSILON );
996
+ }
997
+ float D_GGX( const in float alpha, const in float dotNH ) {
998
+ float a2 = pow2( alpha );
999
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1000
+ return RECIPROCAL_PI * a2 / pow2( denom );
1001
+ }
1002
+ #ifdef USE_ANISOTROPY
1003
+ float 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 ) {
1004
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1005
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1006
+ float v = 0.5 / ( gv + gl );
1007
+ return saturate(v);
1008
+ }
1009
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1010
+ float a2 = alphaT * alphaB;
1011
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1012
+ highp float v2 = dot( v, v );
1013
+ float w2 = a2 / v2;
1014
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1015
+ }
1016
+ #endif
1017
+ #ifdef USE_CLEARCOAT
1018
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1019
+ vec3 f0 = material.clearcoatF0;
1020
+ float f90 = material.clearcoatF90;
1021
+ float roughness = material.clearcoatRoughness;
1022
+ float alpha = pow2( roughness );
1023
+ vec3 halfDir = normalize( lightDir + viewDir );
1024
+ float dotNL = saturate( dot( normal, lightDir ) );
1025
+ float dotNV = saturate( dot( normal, viewDir ) );
1026
+ float dotNH = saturate( dot( normal, halfDir ) );
1027
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1028
+ vec3 F = F_Schlick( f0, f90, dotVH );
1029
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1030
+ float D = D_GGX( alpha, dotNH );
1031
+ return F * ( V * D );
1032
+ }
1033
+ #endif
1034
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1035
+ vec3 f0 = material.specularColor;
1036
+ float f90 = material.specularF90;
1037
+ float roughness = material.roughness;
1038
+ float alpha = pow2( roughness );
1039
+ vec3 halfDir = normalize( lightDir + viewDir );
1040
+ float dotNL = saturate( dot( normal, lightDir ) );
1041
+ float dotNV = saturate( dot( normal, viewDir ) );
1042
+ float dotNH = saturate( dot( normal, halfDir ) );
1043
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1044
+ vec3 F = F_Schlick( f0, f90, dotVH );
1045
+ #ifdef USE_IRIDESCENCE
1046
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1047
+ #endif
1048
+ #ifdef USE_ANISOTROPY
1049
+ float dotTL = dot( material.anisotropyT, lightDir );
1050
+ float dotTV = dot( material.anisotropyT, viewDir );
1051
+ float dotTH = dot( material.anisotropyT, halfDir );
1052
+ float dotBL = dot( material.anisotropyB, lightDir );
1053
+ float dotBV = dot( material.anisotropyB, viewDir );
1054
+ float dotBH = dot( material.anisotropyB, halfDir );
1055
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1056
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1057
+ #else
1058
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1059
+ float D = D_GGX( alpha, dotNH );
1060
+ #endif
1061
+ return F * ( V * D );
1062
+ }
1063
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1064
+ const float LUT_SIZE = 64.0;
1065
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1066
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1067
+ float dotNV = saturate( dot( N, V ) );
1068
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1069
+ uv = uv * LUT_SCALE + LUT_BIAS;
1070
+ return uv;
1071
+ }
1072
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1073
+ float l = length( f );
1074
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1075
+ }
1076
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1077
+ float x = dot( v1, v2 );
1078
+ float y = abs( x );
1079
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1080
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1081
+ float v = a / b;
1082
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1083
+ return cross( v1, v2 ) * theta_sintheta;
1084
+ }
1085
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1086
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1087
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1088
+ vec3 lightNormal = cross( v1, v2 );
1089
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1090
+ vec3 T1, T2;
1091
+ T1 = normalize( V - N * dot( V, N ) );
1092
+ T2 = - cross( N, T1 );
1093
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1094
+ vec3 coords[ 4 ];
1095
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1096
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1097
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1098
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1099
+ coords[ 0 ] = normalize( coords[ 0 ] );
1100
+ coords[ 1 ] = normalize( coords[ 1 ] );
1101
+ coords[ 2 ] = normalize( coords[ 2 ] );
1102
+ coords[ 3 ] = normalize( coords[ 3 ] );
1103
+ vec3 vectorFormFactor = vec3( 0.0 );
1104
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1105
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1106
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1107
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1108
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1109
+ return vec3( result );
1110
+ }
1111
+ #if defined( USE_SHEEN )
1112
+ float D_Charlie( float roughness, float dotNH ) {
1113
+ float alpha = pow2( roughness );
1114
+ float invAlpha = 1.0 / alpha;
1115
+ float cos2h = dotNH * dotNH;
1116
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1117
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1118
+ }
1119
+ float V_Neubelt( float dotNV, float dotNL ) {
1120
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1121
+ }
1122
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1123
+ vec3 halfDir = normalize( lightDir + viewDir );
1124
+ float dotNL = saturate( dot( normal, lightDir ) );
1125
+ float dotNV = saturate( dot( normal, viewDir ) );
1126
+ float dotNH = saturate( dot( normal, halfDir ) );
1127
+ float D = D_Charlie( sheenRoughness, dotNH );
1128
+ float V = V_Neubelt( dotNV, dotNL );
1129
+ return sheenColor * ( D * V );
1130
+ }
1131
+ #endif
1132
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float r2 = roughness * roughness;
1135
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1136
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1137
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1138
+ return saturate( DG * RECIPROCAL_PI );
1139
+ }
1140
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1143
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1144
+ vec4 r = roughness * c0 + c1;
1145
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1146
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1147
+ return fab;
1148
+ }
1149
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1150
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1151
+ return specularColor * fab.x + specularF90 * fab.y;
1152
+ }
1153
+ #ifdef USE_IRIDESCENCE
1154
+ void 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 ) {
1155
+ #else
1156
+ void 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 ) {
1157
+ #endif
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ #ifdef USE_IRIDESCENCE
1160
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1161
+ #else
1162
+ vec3 Fr = specularColor;
1163
+ #endif
1164
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1165
+ float Ess = fab.x + fab.y;
1166
+ float Ems = 1.0 - Ess;
1167
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1168
+ singleScatter += FssEss;
1169
+ multiScatter += Fms * Ems;
1170
+ }
1171
+ #if NUM_RECT_AREA_LIGHTS > 0
1172
+ void 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 ) {
1173
+ vec3 normal = geometryNormal;
1174
+ vec3 viewDir = geometryViewDir;
1175
+ vec3 position = geometryPosition;
1176
+ vec3 lightPos = rectAreaLight.position;
1177
+ vec3 halfWidth = rectAreaLight.halfWidth;
1178
+ vec3 halfHeight = rectAreaLight.halfHeight;
1179
+ vec3 lightColor = rectAreaLight.color;
1180
+ float roughness = material.roughness;
1181
+ vec3 rectCoords[ 4 ];
1182
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1183
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1184
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1185
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1186
+ vec4 t1 = texture2D( ltc_1, uv );
1187
+ vec4 t2 = texture2D( ltc_2, uv );
1188
+ mat3 mInv = mat3(
1189
+ vec3( t1.x, 0, t1.y ),
1190
+ vec3( 0, 1, 0 ),
1191
+ vec3( t1.z, 0, t1.w )
1192
+ );
1193
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1194
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1195
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1196
+ }
1197
+ #endif
1198
+ void 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 ) {
1199
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1200
+ vec3 irradiance = dotNL * directLight.color;
1201
+ #ifdef USE_CLEARCOAT
1202
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1203
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1204
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1205
+ #endif
1206
+ #ifdef USE_SHEEN
1207
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1208
+ #endif
1209
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1210
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1211
+ }
1212
+ void 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 ) {
1213
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1214
+ }
1215
+ void 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) {
1216
+ #ifdef USE_CLEARCOAT
1217
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1218
+ #endif
1219
+ #ifdef USE_SHEEN
1220
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1221
+ #endif
1222
+ vec3 singleScattering = vec3( 0.0 );
1223
+ vec3 multiScattering = vec3( 0.0 );
1224
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1225
+ #ifdef USE_IRIDESCENCE
1226
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1227
+ #else
1228
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1229
+ #endif
1230
+ vec3 totalScattering = singleScattering + multiScattering;
1231
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1232
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1233
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1234
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1235
+ }
1236
+ #define RE_Direct RE_Direct_Physical
1237
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1238
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1239
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1240
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1241
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1242
+ }`,Xu=`
1243
+ vec3 geometryPosition = - vViewPosition;
1244
+ vec3 geometryNormal = normal;
1245
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1246
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1247
+ #ifdef USE_CLEARCOAT
1248
+ geometryClearcoatNormal = clearcoatNormal;
1249
+ #endif
1250
+ #ifdef USE_IRIDESCENCE
1251
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1252
+ if ( material.iridescenceThickness == 0.0 ) {
1253
+ material.iridescence = 0.0;
1254
+ } else {
1255
+ material.iridescence = saturate( material.iridescence );
1256
+ }
1257
+ if ( material.iridescence > 0.0 ) {
1258
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1259
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1260
+ }
1261
+ #endif
1262
+ IncidentLight directLight;
1263
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1264
+ PointLight pointLight;
1265
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1266
+ PointLightShadow pointLightShadow;
1267
+ #endif
1268
+ #pragma unroll_loop_start
1269
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1270
+ pointLight = pointLights[ i ];
1271
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1272
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1273
+ pointLightShadow = pointLightShadows[ i ];
1274
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1275
+ #endif
1276
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1277
+ }
1278
+ #pragma unroll_loop_end
1279
+ #endif
1280
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1281
+ SpotLight spotLight;
1282
+ vec4 spotColor;
1283
+ vec3 spotLightCoord;
1284
+ bool inSpotLightMap;
1285
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1286
+ SpotLightShadow spotLightShadow;
1287
+ #endif
1288
+ #pragma unroll_loop_start
1289
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1290
+ spotLight = spotLights[ i ];
1291
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1292
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1293
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1294
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1295
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1296
+ #else
1297
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1298
+ #endif
1299
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1300
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1301
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1302
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1303
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1304
+ #endif
1305
+ #undef SPOT_LIGHT_MAP_INDEX
1306
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1307
+ spotLightShadow = spotLightShadows[ i ];
1308
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1309
+ #endif
1310
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1311
+ }
1312
+ #pragma unroll_loop_end
1313
+ #endif
1314
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1315
+ DirectionalLight directionalLight;
1316
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1317
+ DirectionalLightShadow directionalLightShadow;
1318
+ #endif
1319
+ #pragma unroll_loop_start
1320
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1321
+ directionalLight = directionalLights[ i ];
1322
+ getDirectionalLightInfo( directionalLight, directLight );
1323
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1324
+ directionalLightShadow = directionalLightShadows[ i ];
1325
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1326
+ #endif
1327
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1328
+ }
1329
+ #pragma unroll_loop_end
1330
+ #endif
1331
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1332
+ RectAreaLight rectAreaLight;
1333
+ #pragma unroll_loop_start
1334
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1335
+ rectAreaLight = rectAreaLights[ i ];
1336
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1337
+ }
1338
+ #pragma unroll_loop_end
1339
+ #endif
1340
+ #if defined( RE_IndirectDiffuse )
1341
+ vec3 iblIrradiance = vec3( 0.0 );
1342
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1343
+ #if defined( USE_LIGHT_PROBES )
1344
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1345
+ #endif
1346
+ #if ( NUM_HEMI_LIGHTS > 0 )
1347
+ #pragma unroll_loop_start
1348
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1349
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1350
+ }
1351
+ #pragma unroll_loop_end
1352
+ #endif
1353
+ #endif
1354
+ #if defined( RE_IndirectSpecular )
1355
+ vec3 radiance = vec3( 0.0 );
1356
+ vec3 clearcoatRadiance = vec3( 0.0 );
1357
+ #endif`,qu=`#if defined( RE_IndirectDiffuse )
1358
+ #ifdef USE_LIGHTMAP
1359
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1360
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1361
+ irradiance += lightMapIrradiance;
1362
+ #endif
1363
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1364
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1365
+ #endif
1366
+ #endif
1367
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1368
+ #ifdef USE_ANISOTROPY
1369
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1370
+ #else
1371
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1372
+ #endif
1373
+ #ifdef USE_CLEARCOAT
1374
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1375
+ #endif
1376
+ #endif`,Yu=`#if defined( RE_IndirectDiffuse )
1377
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1378
+ #endif
1379
+ #if defined( RE_IndirectSpecular )
1380
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1381
+ #endif`,Ku=`#if defined( USE_LOGDEPTHBUF )
1382
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1383
+ #endif`,Zu=`#if defined( USE_LOGDEPTHBUF )
1384
+ uniform float logDepthBufFC;
1385
+ varying float vFragDepth;
1386
+ varying float vIsPerspective;
1387
+ #endif`,$u=`#ifdef USE_LOGDEPTHBUF
1388
+ varying float vFragDepth;
1389
+ varying float vIsPerspective;
1390
+ #endif`,ju=`#ifdef USE_LOGDEPTHBUF
1391
+ vFragDepth = 1.0 + gl_Position.w;
1392
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1393
+ #endif`,Ju=`#ifdef USE_MAP
1394
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1395
+ #ifdef DECODE_VIDEO_TEXTURE
1396
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1397
+ #endif
1398
+ diffuseColor *= sampledDiffuseColor;
1399
+ #endif`,Qu=`#ifdef USE_MAP
1400
+ uniform sampler2D map;
1401
+ #endif`,eh=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1402
+ #if defined( USE_POINTS_UV )
1403
+ vec2 uv = vUv;
1404
+ #else
1405
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1406
+ #endif
1407
+ #endif
1408
+ #ifdef USE_MAP
1409
+ diffuseColor *= texture2D( map, uv );
1410
+ #endif
1411
+ #ifdef USE_ALPHAMAP
1412
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1413
+ #endif`,th=`#if defined( USE_POINTS_UV )
1414
+ varying vec2 vUv;
1415
+ #else
1416
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1417
+ uniform mat3 uvTransform;
1418
+ #endif
1419
+ #endif
1420
+ #ifdef USE_MAP
1421
+ uniform sampler2D map;
1422
+ #endif
1423
+ #ifdef USE_ALPHAMAP
1424
+ uniform sampler2D alphaMap;
1425
+ #endif`,nh=`float metalnessFactor = metalness;
1426
+ #ifdef USE_METALNESSMAP
1427
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1428
+ metalnessFactor *= texelMetalness.b;
1429
+ #endif`,ih=`#ifdef USE_METALNESSMAP
1430
+ uniform sampler2D metalnessMap;
1431
+ #endif`,rh=`#ifdef USE_INSTANCING_MORPH
1432
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1433
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1434
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1435
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1436
+ }
1437
+ #endif`,sh=`#if defined( USE_MORPHCOLORS )
1438
+ vColor *= morphTargetBaseInfluence;
1439
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1440
+ #if defined( USE_COLOR_ALPHA )
1441
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1442
+ #elif defined( USE_COLOR )
1443
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1444
+ #endif
1445
+ }
1446
+ #endif`,ah=`#ifdef USE_MORPHNORMALS
1447
+ objectNormal *= morphTargetBaseInfluence;
1448
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1449
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1450
+ }
1451
+ #endif`,oh=`#ifdef USE_MORPHTARGETS
1452
+ #ifndef USE_INSTANCING_MORPH
1453
+ uniform float morphTargetBaseInfluence;
1454
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1455
+ #endif
1456
+ uniform sampler2DArray morphTargetsTexture;
1457
+ uniform ivec2 morphTargetsTextureSize;
1458
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1459
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1460
+ int y = texelIndex / morphTargetsTextureSize.x;
1461
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1462
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1463
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1464
+ }
1465
+ #endif`,lh=`#ifdef USE_MORPHTARGETS
1466
+ transformed *= morphTargetBaseInfluence;
1467
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1469
+ }
1470
+ #endif`,ch=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1471
+ #ifdef FLAT_SHADED
1472
+ vec3 fdx = dFdx( vViewPosition );
1473
+ vec3 fdy = dFdy( vViewPosition );
1474
+ vec3 normal = normalize( cross( fdx, fdy ) );
1475
+ #else
1476
+ vec3 normal = normalize( vNormal );
1477
+ #ifdef DOUBLE_SIDED
1478
+ normal *= faceDirection;
1479
+ #endif
1480
+ #endif
1481
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1482
+ #ifdef USE_TANGENT
1483
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1484
+ #else
1485
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1486
+ #if defined( USE_NORMALMAP )
1487
+ vNormalMapUv
1488
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1489
+ vClearcoatNormalMapUv
1490
+ #else
1491
+ vUv
1492
+ #endif
1493
+ );
1494
+ #endif
1495
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1496
+ tbn[0] *= faceDirection;
1497
+ tbn[1] *= faceDirection;
1498
+ #endif
1499
+ #endif
1500
+ #ifdef USE_CLEARCOAT_NORMALMAP
1501
+ #ifdef USE_TANGENT
1502
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1503
+ #else
1504
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1505
+ #endif
1506
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1507
+ tbn2[0] *= faceDirection;
1508
+ tbn2[1] *= faceDirection;
1509
+ #endif
1510
+ #endif
1511
+ vec3 nonPerturbedNormal = normal;`,uh=`#ifdef USE_NORMALMAP_OBJECTSPACE
1512
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1513
+ #ifdef FLIP_SIDED
1514
+ normal = - normal;
1515
+ #endif
1516
+ #ifdef DOUBLE_SIDED
1517
+ normal = normal * faceDirection;
1518
+ #endif
1519
+ normal = normalize( normalMatrix * normal );
1520
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1521
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1522
+ mapN.xy *= normalScale;
1523
+ normal = normalize( tbn * mapN );
1524
+ #elif defined( USE_BUMPMAP )
1525
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1526
+ #endif`,hh=`#ifndef FLAT_SHADED
1527
+ varying vec3 vNormal;
1528
+ #ifdef USE_TANGENT
1529
+ varying vec3 vTangent;
1530
+ varying vec3 vBitangent;
1531
+ #endif
1532
+ #endif`,dh=`#ifndef FLAT_SHADED
1533
+ varying vec3 vNormal;
1534
+ #ifdef USE_TANGENT
1535
+ varying vec3 vTangent;
1536
+ varying vec3 vBitangent;
1537
+ #endif
1538
+ #endif`,fh=`#ifndef FLAT_SHADED
1539
+ vNormal = normalize( transformedNormal );
1540
+ #ifdef USE_TANGENT
1541
+ vTangent = normalize( transformedTangent );
1542
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1543
+ #endif
1544
+ #endif`,ph=`#ifdef USE_NORMALMAP
1545
+ uniform sampler2D normalMap;
1546
+ uniform vec2 normalScale;
1547
+ #endif
1548
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1549
+ uniform mat3 normalMatrix;
1550
+ #endif
1551
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1552
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1553
+ vec3 q0 = dFdx( eye_pos.xyz );
1554
+ vec3 q1 = dFdy( eye_pos.xyz );
1555
+ vec2 st0 = dFdx( uv.st );
1556
+ vec2 st1 = dFdy( uv.st );
1557
+ vec3 N = surf_norm;
1558
+ vec3 q1perp = cross( q1, N );
1559
+ vec3 q0perp = cross( N, q0 );
1560
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1561
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1562
+ float det = max( dot( T, T ), dot( B, B ) );
1563
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1564
+ return mat3( T * scale, B * scale, N );
1565
+ }
1566
+ #endif`,mh=`#ifdef USE_CLEARCOAT
1567
+ vec3 clearcoatNormal = nonPerturbedNormal;
1568
+ #endif`,_h=`#ifdef USE_CLEARCOAT_NORMALMAP
1569
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1570
+ clearcoatMapN.xy *= clearcoatNormalScale;
1571
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1572
+ #endif`,gh=`#ifdef USE_CLEARCOATMAP
1573
+ uniform sampler2D clearcoatMap;
1574
+ #endif
1575
+ #ifdef USE_CLEARCOAT_NORMALMAP
1576
+ uniform sampler2D clearcoatNormalMap;
1577
+ uniform vec2 clearcoatNormalScale;
1578
+ #endif
1579
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1580
+ uniform sampler2D clearcoatRoughnessMap;
1581
+ #endif`,vh=`#ifdef USE_IRIDESCENCEMAP
1582
+ uniform sampler2D iridescenceMap;
1583
+ #endif
1584
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1585
+ uniform sampler2D iridescenceThicknessMap;
1586
+ #endif`,xh=`#ifdef OPAQUE
1587
+ diffuseColor.a = 1.0;
1588
+ #endif
1589
+ #ifdef USE_TRANSMISSION
1590
+ diffuseColor.a *= material.transmissionAlpha;
1591
+ #endif
1592
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Sh=`vec3 packNormalToRGB( const in vec3 normal ) {
1593
+ return normalize( normal ) * 0.5 + 0.5;
1594
+ }
1595
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1596
+ return 2.0 * rgb.xyz - 1.0;
1597
+ }
1598
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1599
+ const float Inv255 = 1. / 255.;
1600
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1601
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1602
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1603
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1604
+ vec4 packDepthToRGBA( const in float v ) {
1605
+ if( v <= 0.0 )
1606
+ return vec4( 0., 0., 0., 0. );
1607
+ if( v >= 1.0 )
1608
+ return vec4( 1., 1., 1., 1. );
1609
+ float vuf;
1610
+ float af = modf( v * PackFactors.a, vuf );
1611
+ float bf = modf( vuf * ShiftRight8, vuf );
1612
+ float gf = modf( vuf * ShiftRight8, vuf );
1613
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1614
+ }
1615
+ vec3 packDepthToRGB( const in float v ) {
1616
+ if( v <= 0.0 )
1617
+ return vec3( 0., 0., 0. );
1618
+ if( v >= 1.0 )
1619
+ return vec3( 1., 1., 1. );
1620
+ float vuf;
1621
+ float bf = modf( v * PackFactors.b, vuf );
1622
+ float gf = modf( vuf * ShiftRight8, vuf );
1623
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1624
+ }
1625
+ vec2 packDepthToRG( const in float v ) {
1626
+ if( v <= 0.0 )
1627
+ return vec2( 0., 0. );
1628
+ if( v >= 1.0 )
1629
+ return vec2( 1., 1. );
1630
+ float vuf;
1631
+ float gf = modf( v * 256., vuf );
1632
+ return vec2( vuf * Inv255, gf );
1633
+ }
1634
+ float unpackRGBAToDepth( const in vec4 v ) {
1635
+ return dot( v, UnpackFactors4 );
1636
+ }
1637
+ float unpackRGBToDepth( const in vec3 v ) {
1638
+ return dot( v, UnpackFactors3 );
1639
+ }
1640
+ float unpackRGToDepth( const in vec2 v ) {
1641
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1642
+ }
1643
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1644
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1645
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1646
+ }
1647
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1648
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1649
+ }
1650
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1651
+ return ( viewZ + near ) / ( near - far );
1652
+ }
1653
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1654
+ return depth * ( near - far ) - near;
1655
+ }
1656
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1657
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1658
+ }
1659
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1660
+ return ( near * far ) / ( ( far - near ) * depth - far );
1661
+ }`,Mh=`#ifdef PREMULTIPLIED_ALPHA
1662
+ gl_FragColor.rgb *= gl_FragColor.a;
1663
+ #endif`,Eh=`vec4 mvPosition = vec4( transformed, 1.0 );
1664
+ #ifdef USE_BATCHING
1665
+ mvPosition = batchingMatrix * mvPosition;
1666
+ #endif
1667
+ #ifdef USE_INSTANCING
1668
+ mvPosition = instanceMatrix * mvPosition;
1669
+ #endif
1670
+ mvPosition = modelViewMatrix * mvPosition;
1671
+ gl_Position = projectionMatrix * mvPosition;`,Th=`#ifdef DITHERING
1672
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1673
+ #endif`,yh=`#ifdef DITHERING
1674
+ vec3 dithering( vec3 color ) {
1675
+ float grid_position = rand( gl_FragCoord.xy );
1676
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1677
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1678
+ return color + dither_shift_RGB;
1679
+ }
1680
+ #endif`,Ah=`float roughnessFactor = roughness;
1681
+ #ifdef USE_ROUGHNESSMAP
1682
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1683
+ roughnessFactor *= texelRoughness.g;
1684
+ #endif`,bh=`#ifdef USE_ROUGHNESSMAP
1685
+ uniform sampler2D roughnessMap;
1686
+ #endif`,wh=`#if NUM_SPOT_LIGHT_COORDS > 0
1687
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1688
+ #endif
1689
+ #if NUM_SPOT_LIGHT_MAPS > 0
1690
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1691
+ #endif
1692
+ #ifdef USE_SHADOWMAP
1693
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1694
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1695
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1696
+ struct DirectionalLightShadow {
1697
+ float shadowIntensity;
1698
+ float shadowBias;
1699
+ float shadowNormalBias;
1700
+ float shadowRadius;
1701
+ vec2 shadowMapSize;
1702
+ };
1703
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1704
+ #endif
1705
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1706
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1707
+ struct SpotLightShadow {
1708
+ float shadowIntensity;
1709
+ float shadowBias;
1710
+ float shadowNormalBias;
1711
+ float shadowRadius;
1712
+ vec2 shadowMapSize;
1713
+ };
1714
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1715
+ #endif
1716
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1717
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1718
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1719
+ struct PointLightShadow {
1720
+ float shadowIntensity;
1721
+ float shadowBias;
1722
+ float shadowNormalBias;
1723
+ float shadowRadius;
1724
+ vec2 shadowMapSize;
1725
+ float shadowCameraNear;
1726
+ float shadowCameraFar;
1727
+ };
1728
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1729
+ #endif
1730
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1731
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1732
+ }
1733
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1734
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1735
+ }
1736
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1737
+ float occlusion = 1.0;
1738
+ vec2 distribution = texture2DDistribution( shadow, uv );
1739
+ float hard_shadow = step( compare , distribution.x );
1740
+ if (hard_shadow != 1.0 ) {
1741
+ float distance = compare - distribution.x ;
1742
+ float variance = max( 0.00000, distribution.y * distribution.y );
1743
+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1744
+ }
1745
+ return occlusion;
1746
+ }
1747
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1748
+ float shadow = 1.0;
1749
+ shadowCoord.xyz /= shadowCoord.w;
1750
+ shadowCoord.z += shadowBias;
1751
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1752
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1753
+ if ( frustumTest ) {
1754
+ #if defined( SHADOWMAP_TYPE_PCF )
1755
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1756
+ float dx0 = - texelSize.x * shadowRadius;
1757
+ float dy0 = - texelSize.y * shadowRadius;
1758
+ float dx1 = + texelSize.x * shadowRadius;
1759
+ float dy1 = + texelSize.y * shadowRadius;
1760
+ float dx2 = dx0 / 2.0;
1761
+ float dy2 = dy0 / 2.0;
1762
+ float dx3 = dx1 / 2.0;
1763
+ float dy3 = dy1 / 2.0;
1764
+ shadow = (
1765
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1766
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1767
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1768
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1769
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1770
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1771
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1772
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1773
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1774
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1775
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1776
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1782
+ ) * ( 1.0 / 17.0 );
1783
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1784
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1785
+ float dx = texelSize.x;
1786
+ float dy = texelSize.y;
1787
+ vec2 uv = shadowCoord.xy;
1788
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1789
+ uv -= f * texelSize;
1790
+ shadow = (
1791
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1794
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1795
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1796
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1797
+ f.x ) +
1798
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1799
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1800
+ f.x ) +
1801
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1802
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1803
+ f.y ) +
1804
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1805
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1806
+ f.y ) +
1807
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1808
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1809
+ f.x ),
1810
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1811
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1812
+ f.x ),
1813
+ f.y )
1814
+ ) * ( 1.0 / 9.0 );
1815
+ #elif defined( SHADOWMAP_TYPE_VSM )
1816
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1817
+ #else
1818
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1819
+ #endif
1820
+ }
1821
+ return mix( 1.0, shadow, shadowIntensity );
1822
+ }
1823
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1824
+ vec3 absV = abs( v );
1825
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1826
+ absV *= scaleToCube;
1827
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1828
+ vec2 planar = v.xy;
1829
+ float almostATexel = 1.5 * texelSizeY;
1830
+ float almostOne = 1.0 - almostATexel;
1831
+ if ( absV.z >= almostOne ) {
1832
+ if ( v.z > 0.0 )
1833
+ planar.x = 4.0 - v.x;
1834
+ } else if ( absV.x >= almostOne ) {
1835
+ float signX = sign( v.x );
1836
+ planar.x = v.z * signX + 2.0 * signX;
1837
+ } else if ( absV.y >= almostOne ) {
1838
+ float signY = sign( v.y );
1839
+ planar.x = v.x + 2.0 * signY + 2.0;
1840
+ planar.y = v.z * signY - 2.0;
1841
+ }
1842
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1843
+ }
1844
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1845
+ float shadow = 1.0;
1846
+ vec3 lightToPosition = shadowCoord.xyz;
1847
+
1848
+ float lightToPositionLength = length( lightToPosition );
1849
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1850
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1851
+ vec3 bd3D = normalize( lightToPosition );
1852
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1853
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1854
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1855
+ shadow = (
1856
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1857
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1858
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1859
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1860
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1861
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1862
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1863
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1864
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1865
+ ) * ( 1.0 / 9.0 );
1866
+ #else
1867
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1868
+ #endif
1869
+ }
1870
+ return mix( 1.0, shadow, shadowIntensity );
1871
+ }
1872
+ #endif`,Rh=`#if NUM_SPOT_LIGHT_COORDS > 0
1873
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1874
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1875
+ #endif
1876
+ #ifdef USE_SHADOWMAP
1877
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1878
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1879
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1880
+ struct DirectionalLightShadow {
1881
+ float shadowIntensity;
1882
+ float shadowBias;
1883
+ float shadowNormalBias;
1884
+ float shadowRadius;
1885
+ vec2 shadowMapSize;
1886
+ };
1887
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1888
+ #endif
1889
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1890
+ struct SpotLightShadow {
1891
+ float shadowIntensity;
1892
+ float shadowBias;
1893
+ float shadowNormalBias;
1894
+ float shadowRadius;
1895
+ vec2 shadowMapSize;
1896
+ };
1897
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1898
+ #endif
1899
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1900
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1901
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1902
+ struct PointLightShadow {
1903
+ float shadowIntensity;
1904
+ float shadowBias;
1905
+ float shadowNormalBias;
1906
+ float shadowRadius;
1907
+ vec2 shadowMapSize;
1908
+ float shadowCameraNear;
1909
+ float shadowCameraFar;
1910
+ };
1911
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1912
+ #endif
1913
+ #endif`,Ch=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1914
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1915
+ vec4 shadowWorldPosition;
1916
+ #endif
1917
+ #if defined( USE_SHADOWMAP )
1918
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1919
+ #pragma unroll_loop_start
1920
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1921
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1922
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1923
+ }
1924
+ #pragma unroll_loop_end
1925
+ #endif
1926
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1927
+ #pragma unroll_loop_start
1928
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1929
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1930
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1931
+ }
1932
+ #pragma unroll_loop_end
1933
+ #endif
1934
+ #endif
1935
+ #if NUM_SPOT_LIGHT_COORDS > 0
1936
+ #pragma unroll_loop_start
1937
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1938
+ shadowWorldPosition = worldPosition;
1939
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1940
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1941
+ #endif
1942
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1943
+ }
1944
+ #pragma unroll_loop_end
1945
+ #endif`,Ph=`float getShadowMask() {
1946
+ float shadow = 1.0;
1947
+ #ifdef USE_SHADOWMAP
1948
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1949
+ DirectionalLightShadow directionalLight;
1950
+ #pragma unroll_loop_start
1951
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1952
+ directionalLight = directionalLightShadows[ i ];
1953
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1954
+ }
1955
+ #pragma unroll_loop_end
1956
+ #endif
1957
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1958
+ SpotLightShadow spotLight;
1959
+ #pragma unroll_loop_start
1960
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1961
+ spotLight = spotLightShadows[ i ];
1962
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1963
+ }
1964
+ #pragma unroll_loop_end
1965
+ #endif
1966
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1967
+ PointLightShadow pointLight;
1968
+ #pragma unroll_loop_start
1969
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1970
+ pointLight = pointLightShadows[ i ];
1971
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1972
+ }
1973
+ #pragma unroll_loop_end
1974
+ #endif
1975
+ #endif
1976
+ return shadow;
1977
+ }`,Lh=`#ifdef USE_SKINNING
1978
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1979
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1980
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1981
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1982
+ #endif`,Dh=`#ifdef USE_SKINNING
1983
+ uniform mat4 bindMatrix;
1984
+ uniform mat4 bindMatrixInverse;
1985
+ uniform highp sampler2D boneTexture;
1986
+ mat4 getBoneMatrix( const in float i ) {
1987
+ int size = textureSize( boneTexture, 0 ).x;
1988
+ int j = int( i ) * 4;
1989
+ int x = j % size;
1990
+ int y = j / size;
1991
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1992
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1993
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
1994
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
1995
+ return mat4( v1, v2, v3, v4 );
1996
+ }
1997
+ #endif`,Uh=`#ifdef USE_SKINNING
1998
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
1999
+ vec4 skinned = vec4( 0.0 );
2000
+ skinned += boneMatX * skinVertex * skinWeight.x;
2001
+ skinned += boneMatY * skinVertex * skinWeight.y;
2002
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2003
+ skinned += boneMatW * skinVertex * skinWeight.w;
2004
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2005
+ #endif`,Ih=`#ifdef USE_SKINNING
2006
+ mat4 skinMatrix = mat4( 0.0 );
2007
+ skinMatrix += skinWeight.x * boneMatX;
2008
+ skinMatrix += skinWeight.y * boneMatY;
2009
+ skinMatrix += skinWeight.z * boneMatZ;
2010
+ skinMatrix += skinWeight.w * boneMatW;
2011
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2012
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2013
+ #ifdef USE_TANGENT
2014
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2015
+ #endif
2016
+ #endif`,Nh=`float specularStrength;
2017
+ #ifdef USE_SPECULARMAP
2018
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2019
+ specularStrength = texelSpecular.r;
2020
+ #else
2021
+ specularStrength = 1.0;
2022
+ #endif`,Fh=`#ifdef USE_SPECULARMAP
2023
+ uniform sampler2D specularMap;
2024
+ #endif`,Oh=`#if defined( TONE_MAPPING )
2025
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2026
+ #endif`,Bh=`#ifndef saturate
2027
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2028
+ #endif
2029
+ uniform float toneMappingExposure;
2030
+ vec3 LinearToneMapping( vec3 color ) {
2031
+ return saturate( toneMappingExposure * color );
2032
+ }
2033
+ vec3 ReinhardToneMapping( vec3 color ) {
2034
+ color *= toneMappingExposure;
2035
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2036
+ }
2037
+ vec3 CineonToneMapping( vec3 color ) {
2038
+ color *= toneMappingExposure;
2039
+ color = max( vec3( 0.0 ), color - 0.004 );
2040
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2041
+ }
2042
+ vec3 RRTAndODTFit( vec3 v ) {
2043
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2044
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2045
+ return a / b;
2046
+ }
2047
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2048
+ const mat3 ACESInputMat = mat3(
2049
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2050
+ vec3( 0.04823, 0.01566, 0.83777 )
2051
+ );
2052
+ const mat3 ACESOutputMat = mat3(
2053
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2054
+ vec3( -0.07367, -0.00605, 1.07602 )
2055
+ );
2056
+ color *= toneMappingExposure / 0.6;
2057
+ color = ACESInputMat * color;
2058
+ color = RRTAndODTFit( color );
2059
+ color = ACESOutputMat * color;
2060
+ return saturate( color );
2061
+ }
2062
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2063
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2064
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2065
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2066
+ );
2067
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2068
+ vec3( 0.6274, 0.0691, 0.0164 ),
2069
+ vec3( 0.3293, 0.9195, 0.0880 ),
2070
+ vec3( 0.0433, 0.0113, 0.8956 )
2071
+ );
2072
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2073
+ vec3 x2 = x * x;
2074
+ vec3 x4 = x2 * x2;
2075
+ return + 15.5 * x4 * x2
2076
+ - 40.14 * x4 * x
2077
+ + 31.96 * x4
2078
+ - 6.868 * x2 * x
2079
+ + 0.4298 * x2
2080
+ + 0.1191 * x
2081
+ - 0.00232;
2082
+ }
2083
+ vec3 AgXToneMapping( vec3 color ) {
2084
+ const mat3 AgXInsetMatrix = mat3(
2085
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2086
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2087
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2088
+ );
2089
+ const mat3 AgXOutsetMatrix = mat3(
2090
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2091
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2092
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2093
+ );
2094
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2095
+ color *= toneMappingExposure;
2096
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2097
+ color = AgXInsetMatrix * color;
2098
+ color = max( color, 1e-10 ); color = log2( color );
2099
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2100
+ color = clamp( color, 0.0, 1.0 );
2101
+ color = agxDefaultContrastApprox( color );
2102
+ color = AgXOutsetMatrix * color;
2103
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2104
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2105
+ color = clamp( color, 0.0, 1.0 );
2106
+ return color;
2107
+ }
2108
+ vec3 NeutralToneMapping( vec3 color ) {
2109
+ const float StartCompression = 0.8 - 0.04;
2110
+ const float Desaturation = 0.15;
2111
+ color *= toneMappingExposure;
2112
+ float x = min( color.r, min( color.g, color.b ) );
2113
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2114
+ color -= offset;
2115
+ float peak = max( color.r, max( color.g, color.b ) );
2116
+ if ( peak < StartCompression ) return color;
2117
+ float d = 1. - StartCompression;
2118
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2119
+ color *= newPeak / peak;
2120
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2121
+ return mix( color, vec3( newPeak ), g );
2122
+ }
2123
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,zh=`#ifdef USE_TRANSMISSION
2124
+ material.transmission = transmission;
2125
+ material.transmissionAlpha = 1.0;
2126
+ material.thickness = thickness;
2127
+ material.attenuationDistance = attenuationDistance;
2128
+ material.attenuationColor = attenuationColor;
2129
+ #ifdef USE_TRANSMISSIONMAP
2130
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2131
+ #endif
2132
+ #ifdef USE_THICKNESSMAP
2133
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2134
+ #endif
2135
+ vec3 pos = vWorldPosition;
2136
+ vec3 v = normalize( cameraPosition - pos );
2137
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2138
+ vec4 transmitted = getIBLVolumeRefraction(
2139
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2140
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2141
+ material.attenuationColor, material.attenuationDistance );
2142
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2143
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2144
+ #endif`,Hh=`#ifdef USE_TRANSMISSION
2145
+ uniform float transmission;
2146
+ uniform float thickness;
2147
+ uniform float attenuationDistance;
2148
+ uniform vec3 attenuationColor;
2149
+ #ifdef USE_TRANSMISSIONMAP
2150
+ uniform sampler2D transmissionMap;
2151
+ #endif
2152
+ #ifdef USE_THICKNESSMAP
2153
+ uniform sampler2D thicknessMap;
2154
+ #endif
2155
+ uniform vec2 transmissionSamplerSize;
2156
+ uniform sampler2D transmissionSamplerMap;
2157
+ uniform mat4 modelMatrix;
2158
+ uniform mat4 projectionMatrix;
2159
+ varying vec3 vWorldPosition;
2160
+ float w0( float a ) {
2161
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2162
+ }
2163
+ float w1( float a ) {
2164
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2165
+ }
2166
+ float w2( float a ){
2167
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2168
+ }
2169
+ float w3( float a ) {
2170
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2171
+ }
2172
+ float g0( float a ) {
2173
+ return w0( a ) + w1( a );
2174
+ }
2175
+ float g1( float a ) {
2176
+ return w2( a ) + w3( a );
2177
+ }
2178
+ float h0( float a ) {
2179
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2180
+ }
2181
+ float h1( float a ) {
2182
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2183
+ }
2184
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2185
+ uv = uv * texelSize.zw + 0.5;
2186
+ vec2 iuv = floor( uv );
2187
+ vec2 fuv = fract( uv );
2188
+ float g0x = g0( fuv.x );
2189
+ float g1x = g1( fuv.x );
2190
+ float h0x = h0( fuv.x );
2191
+ float h1x = h1( fuv.x );
2192
+ float h0y = h0( fuv.y );
2193
+ float h1y = h1( fuv.y );
2194
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2195
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2196
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2197
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2198
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2199
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2200
+ }
2201
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2202
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2203
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2204
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2205
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2206
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2207
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2208
+ return mix( fSample, cSample, fract( lod ) );
2209
+ }
2210
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2211
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2212
+ vec3 modelScale;
2213
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2214
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2215
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2216
+ return normalize( refractionVector ) * thickness * modelScale;
2217
+ }
2218
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2219
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2220
+ }
2221
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2222
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2223
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2224
+ }
2225
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2226
+ if ( isinf( attenuationDistance ) ) {
2227
+ return vec3( 1.0 );
2228
+ } else {
2229
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2230
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2231
+ }
2232
+ }
2233
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2234
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2235
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2236
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2237
+ vec4 transmittedLight;
2238
+ vec3 transmittance;
2239
+ #ifdef USE_DISPERSION
2240
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2241
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2242
+ for ( int i = 0; i < 3; i ++ ) {
2243
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2244
+ vec3 refractedRayExit = position + transmissionRay;
2245
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2246
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2247
+ refractionCoords += 1.0;
2248
+ refractionCoords /= 2.0;
2249
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2250
+ transmittedLight[ i ] = transmissionSample[ i ];
2251
+ transmittedLight.a += transmissionSample.a;
2252
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2253
+ }
2254
+ transmittedLight.a /= 3.0;
2255
+ #else
2256
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2257
+ vec3 refractedRayExit = position + transmissionRay;
2258
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2259
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2260
+ refractionCoords += 1.0;
2261
+ refractionCoords /= 2.0;
2262
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2263
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2264
+ #endif
2265
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2266
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2267
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2268
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2269
+ }
2270
+ #endif`,Gh=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2271
+ varying vec2 vUv;
2272
+ #endif
2273
+ #ifdef USE_MAP
2274
+ varying vec2 vMapUv;
2275
+ #endif
2276
+ #ifdef USE_ALPHAMAP
2277
+ varying vec2 vAlphaMapUv;
2278
+ #endif
2279
+ #ifdef USE_LIGHTMAP
2280
+ varying vec2 vLightMapUv;
2281
+ #endif
2282
+ #ifdef USE_AOMAP
2283
+ varying vec2 vAoMapUv;
2284
+ #endif
2285
+ #ifdef USE_BUMPMAP
2286
+ varying vec2 vBumpMapUv;
2287
+ #endif
2288
+ #ifdef USE_NORMALMAP
2289
+ varying vec2 vNormalMapUv;
2290
+ #endif
2291
+ #ifdef USE_EMISSIVEMAP
2292
+ varying vec2 vEmissiveMapUv;
2293
+ #endif
2294
+ #ifdef USE_METALNESSMAP
2295
+ varying vec2 vMetalnessMapUv;
2296
+ #endif
2297
+ #ifdef USE_ROUGHNESSMAP
2298
+ varying vec2 vRoughnessMapUv;
2299
+ #endif
2300
+ #ifdef USE_ANISOTROPYMAP
2301
+ varying vec2 vAnisotropyMapUv;
2302
+ #endif
2303
+ #ifdef USE_CLEARCOATMAP
2304
+ varying vec2 vClearcoatMapUv;
2305
+ #endif
2306
+ #ifdef USE_CLEARCOAT_NORMALMAP
2307
+ varying vec2 vClearcoatNormalMapUv;
2308
+ #endif
2309
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2310
+ varying vec2 vClearcoatRoughnessMapUv;
2311
+ #endif
2312
+ #ifdef USE_IRIDESCENCEMAP
2313
+ varying vec2 vIridescenceMapUv;
2314
+ #endif
2315
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2316
+ varying vec2 vIridescenceThicknessMapUv;
2317
+ #endif
2318
+ #ifdef USE_SHEEN_COLORMAP
2319
+ varying vec2 vSheenColorMapUv;
2320
+ #endif
2321
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2322
+ varying vec2 vSheenRoughnessMapUv;
2323
+ #endif
2324
+ #ifdef USE_SPECULARMAP
2325
+ varying vec2 vSpecularMapUv;
2326
+ #endif
2327
+ #ifdef USE_SPECULAR_COLORMAP
2328
+ varying vec2 vSpecularColorMapUv;
2329
+ #endif
2330
+ #ifdef USE_SPECULAR_INTENSITYMAP
2331
+ varying vec2 vSpecularIntensityMapUv;
2332
+ #endif
2333
+ #ifdef USE_TRANSMISSIONMAP
2334
+ uniform mat3 transmissionMapTransform;
2335
+ varying vec2 vTransmissionMapUv;
2336
+ #endif
2337
+ #ifdef USE_THICKNESSMAP
2338
+ uniform mat3 thicknessMapTransform;
2339
+ varying vec2 vThicknessMapUv;
2340
+ #endif`,Vh=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2341
+ varying vec2 vUv;
2342
+ #endif
2343
+ #ifdef USE_MAP
2344
+ uniform mat3 mapTransform;
2345
+ varying vec2 vMapUv;
2346
+ #endif
2347
+ #ifdef USE_ALPHAMAP
2348
+ uniform mat3 alphaMapTransform;
2349
+ varying vec2 vAlphaMapUv;
2350
+ #endif
2351
+ #ifdef USE_LIGHTMAP
2352
+ uniform mat3 lightMapTransform;
2353
+ varying vec2 vLightMapUv;
2354
+ #endif
2355
+ #ifdef USE_AOMAP
2356
+ uniform mat3 aoMapTransform;
2357
+ varying vec2 vAoMapUv;
2358
+ #endif
2359
+ #ifdef USE_BUMPMAP
2360
+ uniform mat3 bumpMapTransform;
2361
+ varying vec2 vBumpMapUv;
2362
+ #endif
2363
+ #ifdef USE_NORMALMAP
2364
+ uniform mat3 normalMapTransform;
2365
+ varying vec2 vNormalMapUv;
2366
+ #endif
2367
+ #ifdef USE_DISPLACEMENTMAP
2368
+ uniform mat3 displacementMapTransform;
2369
+ varying vec2 vDisplacementMapUv;
2370
+ #endif
2371
+ #ifdef USE_EMISSIVEMAP
2372
+ uniform mat3 emissiveMapTransform;
2373
+ varying vec2 vEmissiveMapUv;
2374
+ #endif
2375
+ #ifdef USE_METALNESSMAP
2376
+ uniform mat3 metalnessMapTransform;
2377
+ varying vec2 vMetalnessMapUv;
2378
+ #endif
2379
+ #ifdef USE_ROUGHNESSMAP
2380
+ uniform mat3 roughnessMapTransform;
2381
+ varying vec2 vRoughnessMapUv;
2382
+ #endif
2383
+ #ifdef USE_ANISOTROPYMAP
2384
+ uniform mat3 anisotropyMapTransform;
2385
+ varying vec2 vAnisotropyMapUv;
2386
+ #endif
2387
+ #ifdef USE_CLEARCOATMAP
2388
+ uniform mat3 clearcoatMapTransform;
2389
+ varying vec2 vClearcoatMapUv;
2390
+ #endif
2391
+ #ifdef USE_CLEARCOAT_NORMALMAP
2392
+ uniform mat3 clearcoatNormalMapTransform;
2393
+ varying vec2 vClearcoatNormalMapUv;
2394
+ #endif
2395
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2396
+ uniform mat3 clearcoatRoughnessMapTransform;
2397
+ varying vec2 vClearcoatRoughnessMapUv;
2398
+ #endif
2399
+ #ifdef USE_SHEEN_COLORMAP
2400
+ uniform mat3 sheenColorMapTransform;
2401
+ varying vec2 vSheenColorMapUv;
2402
+ #endif
2403
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2404
+ uniform mat3 sheenRoughnessMapTransform;
2405
+ varying vec2 vSheenRoughnessMapUv;
2406
+ #endif
2407
+ #ifdef USE_IRIDESCENCEMAP
2408
+ uniform mat3 iridescenceMapTransform;
2409
+ varying vec2 vIridescenceMapUv;
2410
+ #endif
2411
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2412
+ uniform mat3 iridescenceThicknessMapTransform;
2413
+ varying vec2 vIridescenceThicknessMapUv;
2414
+ #endif
2415
+ #ifdef USE_SPECULARMAP
2416
+ uniform mat3 specularMapTransform;
2417
+ varying vec2 vSpecularMapUv;
2418
+ #endif
2419
+ #ifdef USE_SPECULAR_COLORMAP
2420
+ uniform mat3 specularColorMapTransform;
2421
+ varying vec2 vSpecularColorMapUv;
2422
+ #endif
2423
+ #ifdef USE_SPECULAR_INTENSITYMAP
2424
+ uniform mat3 specularIntensityMapTransform;
2425
+ varying vec2 vSpecularIntensityMapUv;
2426
+ #endif
2427
+ #ifdef USE_TRANSMISSIONMAP
2428
+ uniform mat3 transmissionMapTransform;
2429
+ varying vec2 vTransmissionMapUv;
2430
+ #endif
2431
+ #ifdef USE_THICKNESSMAP
2432
+ uniform mat3 thicknessMapTransform;
2433
+ varying vec2 vThicknessMapUv;
2434
+ #endif`,kh=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2435
+ vUv = vec3( uv, 1 ).xy;
2436
+ #endif
2437
+ #ifdef USE_MAP
2438
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2439
+ #endif
2440
+ #ifdef USE_ALPHAMAP
2441
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2442
+ #endif
2443
+ #ifdef USE_LIGHTMAP
2444
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2445
+ #endif
2446
+ #ifdef USE_AOMAP
2447
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2448
+ #endif
2449
+ #ifdef USE_BUMPMAP
2450
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2451
+ #endif
2452
+ #ifdef USE_NORMALMAP
2453
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2454
+ #endif
2455
+ #ifdef USE_DISPLACEMENTMAP
2456
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2457
+ #endif
2458
+ #ifdef USE_EMISSIVEMAP
2459
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2460
+ #endif
2461
+ #ifdef USE_METALNESSMAP
2462
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2463
+ #endif
2464
+ #ifdef USE_ROUGHNESSMAP
2465
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2466
+ #endif
2467
+ #ifdef USE_ANISOTROPYMAP
2468
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2469
+ #endif
2470
+ #ifdef USE_CLEARCOATMAP
2471
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2472
+ #endif
2473
+ #ifdef USE_CLEARCOAT_NORMALMAP
2474
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2475
+ #endif
2476
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2477
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2478
+ #endif
2479
+ #ifdef USE_IRIDESCENCEMAP
2480
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2481
+ #endif
2482
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2483
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2484
+ #endif
2485
+ #ifdef USE_SHEEN_COLORMAP
2486
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2487
+ #endif
2488
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2489
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2490
+ #endif
2491
+ #ifdef USE_SPECULARMAP
2492
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2493
+ #endif
2494
+ #ifdef USE_SPECULAR_COLORMAP
2495
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2496
+ #endif
2497
+ #ifdef USE_SPECULAR_INTENSITYMAP
2498
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2499
+ #endif
2500
+ #ifdef USE_TRANSMISSIONMAP
2501
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2502
+ #endif
2503
+ #ifdef USE_THICKNESSMAP
2504
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2505
+ #endif`,Wh=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2506
+ vec4 worldPosition = vec4( transformed, 1.0 );
2507
+ #ifdef USE_BATCHING
2508
+ worldPosition = batchingMatrix * worldPosition;
2509
+ #endif
2510
+ #ifdef USE_INSTANCING
2511
+ worldPosition = instanceMatrix * worldPosition;
2512
+ #endif
2513
+ worldPosition = modelMatrix * worldPosition;
2514
+ #endif`;const Xh=`varying vec2 vUv;
2515
+ uniform mat3 uvTransform;
2516
+ void main() {
2517
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2518
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2519
+ }`,qh=`uniform sampler2D t2D;
2520
+ uniform float backgroundIntensity;
2521
+ varying vec2 vUv;
2522
+ void main() {
2523
+ vec4 texColor = texture2D( t2D, vUv );
2524
+ #ifdef DECODE_VIDEO_TEXTURE
2525
+ texColor = 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 );
2526
+ #endif
2527
+ texColor.rgb *= backgroundIntensity;
2528
+ gl_FragColor = texColor;
2529
+ #include <tonemapping_fragment>
2530
+ #include <colorspace_fragment>
2531
+ }`,Yh=`varying vec3 vWorldDirection;
2532
+ #include <common>
2533
+ void main() {
2534
+ vWorldDirection = transformDirection( position, modelMatrix );
2535
+ #include <begin_vertex>
2536
+ #include <project_vertex>
2537
+ gl_Position.z = gl_Position.w;
2538
+ }`,Kh=`#ifdef ENVMAP_TYPE_CUBE
2539
+ uniform samplerCube envMap;
2540
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2541
+ uniform sampler2D envMap;
2542
+ #endif
2543
+ uniform float flipEnvMap;
2544
+ uniform float backgroundBlurriness;
2545
+ uniform float backgroundIntensity;
2546
+ uniform mat3 backgroundRotation;
2547
+ varying vec3 vWorldDirection;
2548
+ #include <cube_uv_reflection_fragment>
2549
+ void main() {
2550
+ #ifdef ENVMAP_TYPE_CUBE
2551
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2552
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2553
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2554
+ #else
2555
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2556
+ #endif
2557
+ texColor.rgb *= backgroundIntensity;
2558
+ gl_FragColor = texColor;
2559
+ #include <tonemapping_fragment>
2560
+ #include <colorspace_fragment>
2561
+ }`,Zh=`varying vec3 vWorldDirection;
2562
+ #include <common>
2563
+ void main() {
2564
+ vWorldDirection = transformDirection( position, modelMatrix );
2565
+ #include <begin_vertex>
2566
+ #include <project_vertex>
2567
+ gl_Position.z = gl_Position.w;
2568
+ }`,$h=`uniform samplerCube tCube;
2569
+ uniform float tFlip;
2570
+ uniform float opacity;
2571
+ varying vec3 vWorldDirection;
2572
+ void main() {
2573
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2574
+ gl_FragColor = texColor;
2575
+ gl_FragColor.a *= opacity;
2576
+ #include <tonemapping_fragment>
2577
+ #include <colorspace_fragment>
2578
+ }`,jh=`#include <common>
2579
+ #include <batching_pars_vertex>
2580
+ #include <uv_pars_vertex>
2581
+ #include <displacementmap_pars_vertex>
2582
+ #include <morphtarget_pars_vertex>
2583
+ #include <skinning_pars_vertex>
2584
+ #include <logdepthbuf_pars_vertex>
2585
+ #include <clipping_planes_pars_vertex>
2586
+ varying vec2 vHighPrecisionZW;
2587
+ void main() {
2588
+ #include <uv_vertex>
2589
+ #include <batching_vertex>
2590
+ #include <skinbase_vertex>
2591
+ #include <morphinstance_vertex>
2592
+ #ifdef USE_DISPLACEMENTMAP
2593
+ #include <beginnormal_vertex>
2594
+ #include <morphnormal_vertex>
2595
+ #include <skinnormal_vertex>
2596
+ #endif
2597
+ #include <begin_vertex>
2598
+ #include <morphtarget_vertex>
2599
+ #include <skinning_vertex>
2600
+ #include <displacementmap_vertex>
2601
+ #include <project_vertex>
2602
+ #include <logdepthbuf_vertex>
2603
+ #include <clipping_planes_vertex>
2604
+ vHighPrecisionZW = gl_Position.zw;
2605
+ }`,Jh=`#if DEPTH_PACKING == 3200
2606
+ uniform float opacity;
2607
+ #endif
2608
+ #include <common>
2609
+ #include <packing>
2610
+ #include <uv_pars_fragment>
2611
+ #include <map_pars_fragment>
2612
+ #include <alphamap_pars_fragment>
2613
+ #include <alphatest_pars_fragment>
2614
+ #include <alphahash_pars_fragment>
2615
+ #include <logdepthbuf_pars_fragment>
2616
+ #include <clipping_planes_pars_fragment>
2617
+ varying vec2 vHighPrecisionZW;
2618
+ void main() {
2619
+ vec4 diffuseColor = vec4( 1.0 );
2620
+ #include <clipping_planes_fragment>
2621
+ #if DEPTH_PACKING == 3200
2622
+ diffuseColor.a = opacity;
2623
+ #endif
2624
+ #include <map_fragment>
2625
+ #include <alphamap_fragment>
2626
+ #include <alphatest_fragment>
2627
+ #include <alphahash_fragment>
2628
+ #include <logdepthbuf_fragment>
2629
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2630
+ #if DEPTH_PACKING == 3200
2631
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2632
+ #elif DEPTH_PACKING == 3201
2633
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2634
+ #elif DEPTH_PACKING == 3202
2635
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2636
+ #elif DEPTH_PACKING == 3203
2637
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2638
+ #endif
2639
+ }`,Qh=`#define DISTANCE
2640
+ varying vec3 vWorldPosition;
2641
+ #include <common>
2642
+ #include <batching_pars_vertex>
2643
+ #include <uv_pars_vertex>
2644
+ #include <displacementmap_pars_vertex>
2645
+ #include <morphtarget_pars_vertex>
2646
+ #include <skinning_pars_vertex>
2647
+ #include <clipping_planes_pars_vertex>
2648
+ void main() {
2649
+ #include <uv_vertex>
2650
+ #include <batching_vertex>
2651
+ #include <skinbase_vertex>
2652
+ #include <morphinstance_vertex>
2653
+ #ifdef USE_DISPLACEMENTMAP
2654
+ #include <beginnormal_vertex>
2655
+ #include <morphnormal_vertex>
2656
+ #include <skinnormal_vertex>
2657
+ #endif
2658
+ #include <begin_vertex>
2659
+ #include <morphtarget_vertex>
2660
+ #include <skinning_vertex>
2661
+ #include <displacementmap_vertex>
2662
+ #include <project_vertex>
2663
+ #include <worldpos_vertex>
2664
+ #include <clipping_planes_vertex>
2665
+ vWorldPosition = worldPosition.xyz;
2666
+ }`,ed=`#define DISTANCE
2667
+ uniform vec3 referencePosition;
2668
+ uniform float nearDistance;
2669
+ uniform float farDistance;
2670
+ varying vec3 vWorldPosition;
2671
+ #include <common>
2672
+ #include <packing>
2673
+ #include <uv_pars_fragment>
2674
+ #include <map_pars_fragment>
2675
+ #include <alphamap_pars_fragment>
2676
+ #include <alphatest_pars_fragment>
2677
+ #include <alphahash_pars_fragment>
2678
+ #include <clipping_planes_pars_fragment>
2679
+ void main () {
2680
+ vec4 diffuseColor = vec4( 1.0 );
2681
+ #include <clipping_planes_fragment>
2682
+ #include <map_fragment>
2683
+ #include <alphamap_fragment>
2684
+ #include <alphatest_fragment>
2685
+ #include <alphahash_fragment>
2686
+ float dist = length( vWorldPosition - referencePosition );
2687
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2688
+ dist = saturate( dist );
2689
+ gl_FragColor = packDepthToRGBA( dist );
2690
+ }`,td=`varying vec3 vWorldDirection;
2691
+ #include <common>
2692
+ void main() {
2693
+ vWorldDirection = transformDirection( position, modelMatrix );
2694
+ #include <begin_vertex>
2695
+ #include <project_vertex>
2696
+ }`,nd=`uniform sampler2D tEquirect;
2697
+ varying vec3 vWorldDirection;
2698
+ #include <common>
2699
+ void main() {
2700
+ vec3 direction = normalize( vWorldDirection );
2701
+ vec2 sampleUV = equirectUv( direction );
2702
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2703
+ #include <tonemapping_fragment>
2704
+ #include <colorspace_fragment>
2705
+ }`,id=`uniform float scale;
2706
+ attribute float lineDistance;
2707
+ varying float vLineDistance;
2708
+ #include <common>
2709
+ #include <uv_pars_vertex>
2710
+ #include <color_pars_vertex>
2711
+ #include <fog_pars_vertex>
2712
+ #include <morphtarget_pars_vertex>
2713
+ #include <logdepthbuf_pars_vertex>
2714
+ #include <clipping_planes_pars_vertex>
2715
+ void main() {
2716
+ vLineDistance = scale * lineDistance;
2717
+ #include <uv_vertex>
2718
+ #include <color_vertex>
2719
+ #include <morphinstance_vertex>
2720
+ #include <morphcolor_vertex>
2721
+ #include <begin_vertex>
2722
+ #include <morphtarget_vertex>
2723
+ #include <project_vertex>
2724
+ #include <logdepthbuf_vertex>
2725
+ #include <clipping_planes_vertex>
2726
+ #include <fog_vertex>
2727
+ }`,rd=`uniform vec3 diffuse;
2728
+ uniform float opacity;
2729
+ uniform float dashSize;
2730
+ uniform float totalSize;
2731
+ varying float vLineDistance;
2732
+ #include <common>
2733
+ #include <color_pars_fragment>
2734
+ #include <uv_pars_fragment>
2735
+ #include <map_pars_fragment>
2736
+ #include <fog_pars_fragment>
2737
+ #include <logdepthbuf_pars_fragment>
2738
+ #include <clipping_planes_pars_fragment>
2739
+ void main() {
2740
+ vec4 diffuseColor = vec4( diffuse, opacity );
2741
+ #include <clipping_planes_fragment>
2742
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2743
+ discard;
2744
+ }
2745
+ vec3 outgoingLight = vec3( 0.0 );
2746
+ #include <logdepthbuf_fragment>
2747
+ #include <map_fragment>
2748
+ #include <color_fragment>
2749
+ outgoingLight = diffuseColor.rgb;
2750
+ #include <opaque_fragment>
2751
+ #include <tonemapping_fragment>
2752
+ #include <colorspace_fragment>
2753
+ #include <fog_fragment>
2754
+ #include <premultiplied_alpha_fragment>
2755
+ }`,sd=`#include <common>
2756
+ #include <batching_pars_vertex>
2757
+ #include <uv_pars_vertex>
2758
+ #include <envmap_pars_vertex>
2759
+ #include <color_pars_vertex>
2760
+ #include <fog_pars_vertex>
2761
+ #include <morphtarget_pars_vertex>
2762
+ #include <skinning_pars_vertex>
2763
+ #include <logdepthbuf_pars_vertex>
2764
+ #include <clipping_planes_pars_vertex>
2765
+ void main() {
2766
+ #include <uv_vertex>
2767
+ #include <color_vertex>
2768
+ #include <morphinstance_vertex>
2769
+ #include <morphcolor_vertex>
2770
+ #include <batching_vertex>
2771
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2772
+ #include <beginnormal_vertex>
2773
+ #include <morphnormal_vertex>
2774
+ #include <skinbase_vertex>
2775
+ #include <skinnormal_vertex>
2776
+ #include <defaultnormal_vertex>
2777
+ #endif
2778
+ #include <begin_vertex>
2779
+ #include <morphtarget_vertex>
2780
+ #include <skinning_vertex>
2781
+ #include <project_vertex>
2782
+ #include <logdepthbuf_vertex>
2783
+ #include <clipping_planes_vertex>
2784
+ #include <worldpos_vertex>
2785
+ #include <envmap_vertex>
2786
+ #include <fog_vertex>
2787
+ }`,ad=`uniform vec3 diffuse;
2788
+ uniform float opacity;
2789
+ #ifndef FLAT_SHADED
2790
+ varying vec3 vNormal;
2791
+ #endif
2792
+ #include <common>
2793
+ #include <dithering_pars_fragment>
2794
+ #include <color_pars_fragment>
2795
+ #include <uv_pars_fragment>
2796
+ #include <map_pars_fragment>
2797
+ #include <alphamap_pars_fragment>
2798
+ #include <alphatest_pars_fragment>
2799
+ #include <alphahash_pars_fragment>
2800
+ #include <aomap_pars_fragment>
2801
+ #include <lightmap_pars_fragment>
2802
+ #include <envmap_common_pars_fragment>
2803
+ #include <envmap_pars_fragment>
2804
+ #include <fog_pars_fragment>
2805
+ #include <specularmap_pars_fragment>
2806
+ #include <logdepthbuf_pars_fragment>
2807
+ #include <clipping_planes_pars_fragment>
2808
+ void main() {
2809
+ vec4 diffuseColor = vec4( diffuse, opacity );
2810
+ #include <clipping_planes_fragment>
2811
+ #include <logdepthbuf_fragment>
2812
+ #include <map_fragment>
2813
+ #include <color_fragment>
2814
+ #include <alphamap_fragment>
2815
+ #include <alphatest_fragment>
2816
+ #include <alphahash_fragment>
2817
+ #include <specularmap_fragment>
2818
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2819
+ #ifdef USE_LIGHTMAP
2820
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2821
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2822
+ #else
2823
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2824
+ #endif
2825
+ #include <aomap_fragment>
2826
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2827
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2828
+ #include <envmap_fragment>
2829
+ #include <opaque_fragment>
2830
+ #include <tonemapping_fragment>
2831
+ #include <colorspace_fragment>
2832
+ #include <fog_fragment>
2833
+ #include <premultiplied_alpha_fragment>
2834
+ #include <dithering_fragment>
2835
+ }`,od=`#define LAMBERT
2836
+ varying vec3 vViewPosition;
2837
+ #include <common>
2838
+ #include <batching_pars_vertex>
2839
+ #include <uv_pars_vertex>
2840
+ #include <displacementmap_pars_vertex>
2841
+ #include <envmap_pars_vertex>
2842
+ #include <color_pars_vertex>
2843
+ #include <fog_pars_vertex>
2844
+ #include <normal_pars_vertex>
2845
+ #include <morphtarget_pars_vertex>
2846
+ #include <skinning_pars_vertex>
2847
+ #include <shadowmap_pars_vertex>
2848
+ #include <logdepthbuf_pars_vertex>
2849
+ #include <clipping_planes_pars_vertex>
2850
+ void main() {
2851
+ #include <uv_vertex>
2852
+ #include <color_vertex>
2853
+ #include <morphinstance_vertex>
2854
+ #include <morphcolor_vertex>
2855
+ #include <batching_vertex>
2856
+ #include <beginnormal_vertex>
2857
+ #include <morphnormal_vertex>
2858
+ #include <skinbase_vertex>
2859
+ #include <skinnormal_vertex>
2860
+ #include <defaultnormal_vertex>
2861
+ #include <normal_vertex>
2862
+ #include <begin_vertex>
2863
+ #include <morphtarget_vertex>
2864
+ #include <skinning_vertex>
2865
+ #include <displacementmap_vertex>
2866
+ #include <project_vertex>
2867
+ #include <logdepthbuf_vertex>
2868
+ #include <clipping_planes_vertex>
2869
+ vViewPosition = - mvPosition.xyz;
2870
+ #include <worldpos_vertex>
2871
+ #include <envmap_vertex>
2872
+ #include <shadowmap_vertex>
2873
+ #include <fog_vertex>
2874
+ }`,ld=`#define LAMBERT
2875
+ uniform vec3 diffuse;
2876
+ uniform vec3 emissive;
2877
+ uniform float opacity;
2878
+ #include <common>
2879
+ #include <packing>
2880
+ #include <dithering_pars_fragment>
2881
+ #include <color_pars_fragment>
2882
+ #include <uv_pars_fragment>
2883
+ #include <map_pars_fragment>
2884
+ #include <alphamap_pars_fragment>
2885
+ #include <alphatest_pars_fragment>
2886
+ #include <alphahash_pars_fragment>
2887
+ #include <aomap_pars_fragment>
2888
+ #include <lightmap_pars_fragment>
2889
+ #include <emissivemap_pars_fragment>
2890
+ #include <envmap_common_pars_fragment>
2891
+ #include <envmap_pars_fragment>
2892
+ #include <fog_pars_fragment>
2893
+ #include <bsdfs>
2894
+ #include <lights_pars_begin>
2895
+ #include <normal_pars_fragment>
2896
+ #include <lights_lambert_pars_fragment>
2897
+ #include <shadowmap_pars_fragment>
2898
+ #include <bumpmap_pars_fragment>
2899
+ #include <normalmap_pars_fragment>
2900
+ #include <specularmap_pars_fragment>
2901
+ #include <logdepthbuf_pars_fragment>
2902
+ #include <clipping_planes_pars_fragment>
2903
+ void main() {
2904
+ vec4 diffuseColor = vec4( diffuse, opacity );
2905
+ #include <clipping_planes_fragment>
2906
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2907
+ vec3 totalEmissiveRadiance = emissive;
2908
+ #include <logdepthbuf_fragment>
2909
+ #include <map_fragment>
2910
+ #include <color_fragment>
2911
+ #include <alphamap_fragment>
2912
+ #include <alphatest_fragment>
2913
+ #include <alphahash_fragment>
2914
+ #include <specularmap_fragment>
2915
+ #include <normal_fragment_begin>
2916
+ #include <normal_fragment_maps>
2917
+ #include <emissivemap_fragment>
2918
+ #include <lights_lambert_fragment>
2919
+ #include <lights_fragment_begin>
2920
+ #include <lights_fragment_maps>
2921
+ #include <lights_fragment_end>
2922
+ #include <aomap_fragment>
2923
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2924
+ #include <envmap_fragment>
2925
+ #include <opaque_fragment>
2926
+ #include <tonemapping_fragment>
2927
+ #include <colorspace_fragment>
2928
+ #include <fog_fragment>
2929
+ #include <premultiplied_alpha_fragment>
2930
+ #include <dithering_fragment>
2931
+ }`,cd=`#define MATCAP
2932
+ varying vec3 vViewPosition;
2933
+ #include <common>
2934
+ #include <batching_pars_vertex>
2935
+ #include <uv_pars_vertex>
2936
+ #include <color_pars_vertex>
2937
+ #include <displacementmap_pars_vertex>
2938
+ #include <fog_pars_vertex>
2939
+ #include <normal_pars_vertex>
2940
+ #include <morphtarget_pars_vertex>
2941
+ #include <skinning_pars_vertex>
2942
+ #include <logdepthbuf_pars_vertex>
2943
+ #include <clipping_planes_pars_vertex>
2944
+ void main() {
2945
+ #include <uv_vertex>
2946
+ #include <color_vertex>
2947
+ #include <morphinstance_vertex>
2948
+ #include <morphcolor_vertex>
2949
+ #include <batching_vertex>
2950
+ #include <beginnormal_vertex>
2951
+ #include <morphnormal_vertex>
2952
+ #include <skinbase_vertex>
2953
+ #include <skinnormal_vertex>
2954
+ #include <defaultnormal_vertex>
2955
+ #include <normal_vertex>
2956
+ #include <begin_vertex>
2957
+ #include <morphtarget_vertex>
2958
+ #include <skinning_vertex>
2959
+ #include <displacementmap_vertex>
2960
+ #include <project_vertex>
2961
+ #include <logdepthbuf_vertex>
2962
+ #include <clipping_planes_vertex>
2963
+ #include <fog_vertex>
2964
+ vViewPosition = - mvPosition.xyz;
2965
+ }`,ud=`#define MATCAP
2966
+ uniform vec3 diffuse;
2967
+ uniform float opacity;
2968
+ uniform sampler2D matcap;
2969
+ varying vec3 vViewPosition;
2970
+ #include <common>
2971
+ #include <dithering_pars_fragment>
2972
+ #include <color_pars_fragment>
2973
+ #include <uv_pars_fragment>
2974
+ #include <map_pars_fragment>
2975
+ #include <alphamap_pars_fragment>
2976
+ #include <alphatest_pars_fragment>
2977
+ #include <alphahash_pars_fragment>
2978
+ #include <fog_pars_fragment>
2979
+ #include <normal_pars_fragment>
2980
+ #include <bumpmap_pars_fragment>
2981
+ #include <normalmap_pars_fragment>
2982
+ #include <logdepthbuf_pars_fragment>
2983
+ #include <clipping_planes_pars_fragment>
2984
+ void main() {
2985
+ vec4 diffuseColor = vec4( diffuse, opacity );
2986
+ #include <clipping_planes_fragment>
2987
+ #include <logdepthbuf_fragment>
2988
+ #include <map_fragment>
2989
+ #include <color_fragment>
2990
+ #include <alphamap_fragment>
2991
+ #include <alphatest_fragment>
2992
+ #include <alphahash_fragment>
2993
+ #include <normal_fragment_begin>
2994
+ #include <normal_fragment_maps>
2995
+ vec3 viewDir = normalize( vViewPosition );
2996
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
2997
+ vec3 y = cross( viewDir, x );
2998
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
2999
+ #ifdef USE_MATCAP
3000
+ vec4 matcapColor = texture2D( matcap, uv );
3001
+ #else
3002
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3003
+ #endif
3004
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3005
+ #include <opaque_fragment>
3006
+ #include <tonemapping_fragment>
3007
+ #include <colorspace_fragment>
3008
+ #include <fog_fragment>
3009
+ #include <premultiplied_alpha_fragment>
3010
+ #include <dithering_fragment>
3011
+ }`,hd=`#define NORMAL
3012
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3013
+ varying vec3 vViewPosition;
3014
+ #endif
3015
+ #include <common>
3016
+ #include <batching_pars_vertex>
3017
+ #include <uv_pars_vertex>
3018
+ #include <displacementmap_pars_vertex>
3019
+ #include <normal_pars_vertex>
3020
+ #include <morphtarget_pars_vertex>
3021
+ #include <skinning_pars_vertex>
3022
+ #include <logdepthbuf_pars_vertex>
3023
+ #include <clipping_planes_pars_vertex>
3024
+ void main() {
3025
+ #include <uv_vertex>
3026
+ #include <batching_vertex>
3027
+ #include <beginnormal_vertex>
3028
+ #include <morphinstance_vertex>
3029
+ #include <morphnormal_vertex>
3030
+ #include <skinbase_vertex>
3031
+ #include <skinnormal_vertex>
3032
+ #include <defaultnormal_vertex>
3033
+ #include <normal_vertex>
3034
+ #include <begin_vertex>
3035
+ #include <morphtarget_vertex>
3036
+ #include <skinning_vertex>
3037
+ #include <displacementmap_vertex>
3038
+ #include <project_vertex>
3039
+ #include <logdepthbuf_vertex>
3040
+ #include <clipping_planes_vertex>
3041
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3042
+ vViewPosition = - mvPosition.xyz;
3043
+ #endif
3044
+ }`,dd=`#define NORMAL
3045
+ uniform float opacity;
3046
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
+ varying vec3 vViewPosition;
3048
+ #endif
3049
+ #include <packing>
3050
+ #include <uv_pars_fragment>
3051
+ #include <normal_pars_fragment>
3052
+ #include <bumpmap_pars_fragment>
3053
+ #include <normalmap_pars_fragment>
3054
+ #include <logdepthbuf_pars_fragment>
3055
+ #include <clipping_planes_pars_fragment>
3056
+ void main() {
3057
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3058
+ #include <clipping_planes_fragment>
3059
+ #include <logdepthbuf_fragment>
3060
+ #include <normal_fragment_begin>
3061
+ #include <normal_fragment_maps>
3062
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3063
+ #ifdef OPAQUE
3064
+ gl_FragColor.a = 1.0;
3065
+ #endif
3066
+ }`,fd=`#define PHONG
3067
+ varying vec3 vViewPosition;
3068
+ #include <common>
3069
+ #include <batching_pars_vertex>
3070
+ #include <uv_pars_vertex>
3071
+ #include <displacementmap_pars_vertex>
3072
+ #include <envmap_pars_vertex>
3073
+ #include <color_pars_vertex>
3074
+ #include <fog_pars_vertex>
3075
+ #include <normal_pars_vertex>
3076
+ #include <morphtarget_pars_vertex>
3077
+ #include <skinning_pars_vertex>
3078
+ #include <shadowmap_pars_vertex>
3079
+ #include <logdepthbuf_pars_vertex>
3080
+ #include <clipping_planes_pars_vertex>
3081
+ void main() {
3082
+ #include <uv_vertex>
3083
+ #include <color_vertex>
3084
+ #include <morphcolor_vertex>
3085
+ #include <batching_vertex>
3086
+ #include <beginnormal_vertex>
3087
+ #include <morphinstance_vertex>
3088
+ #include <morphnormal_vertex>
3089
+ #include <skinbase_vertex>
3090
+ #include <skinnormal_vertex>
3091
+ #include <defaultnormal_vertex>
3092
+ #include <normal_vertex>
3093
+ #include <begin_vertex>
3094
+ #include <morphtarget_vertex>
3095
+ #include <skinning_vertex>
3096
+ #include <displacementmap_vertex>
3097
+ #include <project_vertex>
3098
+ #include <logdepthbuf_vertex>
3099
+ #include <clipping_planes_vertex>
3100
+ vViewPosition = - mvPosition.xyz;
3101
+ #include <worldpos_vertex>
3102
+ #include <envmap_vertex>
3103
+ #include <shadowmap_vertex>
3104
+ #include <fog_vertex>
3105
+ }`,pd=`#define PHONG
3106
+ uniform vec3 diffuse;
3107
+ uniform vec3 emissive;
3108
+ uniform vec3 specular;
3109
+ uniform float shininess;
3110
+ uniform float opacity;
3111
+ #include <common>
3112
+ #include <packing>
3113
+ #include <dithering_pars_fragment>
3114
+ #include <color_pars_fragment>
3115
+ #include <uv_pars_fragment>
3116
+ #include <map_pars_fragment>
3117
+ #include <alphamap_pars_fragment>
3118
+ #include <alphatest_pars_fragment>
3119
+ #include <alphahash_pars_fragment>
3120
+ #include <aomap_pars_fragment>
3121
+ #include <lightmap_pars_fragment>
3122
+ #include <emissivemap_pars_fragment>
3123
+ #include <envmap_common_pars_fragment>
3124
+ #include <envmap_pars_fragment>
3125
+ #include <fog_pars_fragment>
3126
+ #include <bsdfs>
3127
+ #include <lights_pars_begin>
3128
+ #include <normal_pars_fragment>
3129
+ #include <lights_phong_pars_fragment>
3130
+ #include <shadowmap_pars_fragment>
3131
+ #include <bumpmap_pars_fragment>
3132
+ #include <normalmap_pars_fragment>
3133
+ #include <specularmap_pars_fragment>
3134
+ #include <logdepthbuf_pars_fragment>
3135
+ #include <clipping_planes_pars_fragment>
3136
+ void main() {
3137
+ vec4 diffuseColor = vec4( diffuse, opacity );
3138
+ #include <clipping_planes_fragment>
3139
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3140
+ vec3 totalEmissiveRadiance = emissive;
3141
+ #include <logdepthbuf_fragment>
3142
+ #include <map_fragment>
3143
+ #include <color_fragment>
3144
+ #include <alphamap_fragment>
3145
+ #include <alphatest_fragment>
3146
+ #include <alphahash_fragment>
3147
+ #include <specularmap_fragment>
3148
+ #include <normal_fragment_begin>
3149
+ #include <normal_fragment_maps>
3150
+ #include <emissivemap_fragment>
3151
+ #include <lights_phong_fragment>
3152
+ #include <lights_fragment_begin>
3153
+ #include <lights_fragment_maps>
3154
+ #include <lights_fragment_end>
3155
+ #include <aomap_fragment>
3156
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3157
+ #include <envmap_fragment>
3158
+ #include <opaque_fragment>
3159
+ #include <tonemapping_fragment>
3160
+ #include <colorspace_fragment>
3161
+ #include <fog_fragment>
3162
+ #include <premultiplied_alpha_fragment>
3163
+ #include <dithering_fragment>
3164
+ }`,md=`#define STANDARD
3165
+ varying vec3 vViewPosition;
3166
+ #ifdef USE_TRANSMISSION
3167
+ varying vec3 vWorldPosition;
3168
+ #endif
3169
+ #include <common>
3170
+ #include <batching_pars_vertex>
3171
+ #include <uv_pars_vertex>
3172
+ #include <displacementmap_pars_vertex>
3173
+ #include <color_pars_vertex>
3174
+ #include <fog_pars_vertex>
3175
+ #include <normal_pars_vertex>
3176
+ #include <morphtarget_pars_vertex>
3177
+ #include <skinning_pars_vertex>
3178
+ #include <shadowmap_pars_vertex>
3179
+ #include <logdepthbuf_pars_vertex>
3180
+ #include <clipping_planes_pars_vertex>
3181
+ void main() {
3182
+ #include <uv_vertex>
3183
+ #include <color_vertex>
3184
+ #include <morphinstance_vertex>
3185
+ #include <morphcolor_vertex>
3186
+ #include <batching_vertex>
3187
+ #include <beginnormal_vertex>
3188
+ #include <morphnormal_vertex>
3189
+ #include <skinbase_vertex>
3190
+ #include <skinnormal_vertex>
3191
+ #include <defaultnormal_vertex>
3192
+ #include <normal_vertex>
3193
+ #include <begin_vertex>
3194
+ #include <morphtarget_vertex>
3195
+ #include <skinning_vertex>
3196
+ #include <displacementmap_vertex>
3197
+ #include <project_vertex>
3198
+ #include <logdepthbuf_vertex>
3199
+ #include <clipping_planes_vertex>
3200
+ vViewPosition = - mvPosition.xyz;
3201
+ #include <worldpos_vertex>
3202
+ #include <shadowmap_vertex>
3203
+ #include <fog_vertex>
3204
+ #ifdef USE_TRANSMISSION
3205
+ vWorldPosition = worldPosition.xyz;
3206
+ #endif
3207
+ }`,_d=`#define STANDARD
3208
+ #ifdef PHYSICAL
3209
+ #define IOR
3210
+ #define USE_SPECULAR
3211
+ #endif
3212
+ uniform vec3 diffuse;
3213
+ uniform vec3 emissive;
3214
+ uniform float roughness;
3215
+ uniform float metalness;
3216
+ uniform float opacity;
3217
+ #ifdef IOR
3218
+ uniform float ior;
3219
+ #endif
3220
+ #ifdef USE_SPECULAR
3221
+ uniform float specularIntensity;
3222
+ uniform vec3 specularColor;
3223
+ #ifdef USE_SPECULAR_COLORMAP
3224
+ uniform sampler2D specularColorMap;
3225
+ #endif
3226
+ #ifdef USE_SPECULAR_INTENSITYMAP
3227
+ uniform sampler2D specularIntensityMap;
3228
+ #endif
3229
+ #endif
3230
+ #ifdef USE_CLEARCOAT
3231
+ uniform float clearcoat;
3232
+ uniform float clearcoatRoughness;
3233
+ #endif
3234
+ #ifdef USE_DISPERSION
3235
+ uniform float dispersion;
3236
+ #endif
3237
+ #ifdef USE_IRIDESCENCE
3238
+ uniform float iridescence;
3239
+ uniform float iridescenceIOR;
3240
+ uniform float iridescenceThicknessMinimum;
3241
+ uniform float iridescenceThicknessMaximum;
3242
+ #endif
3243
+ #ifdef USE_SHEEN
3244
+ uniform vec3 sheenColor;
3245
+ uniform float sheenRoughness;
3246
+ #ifdef USE_SHEEN_COLORMAP
3247
+ uniform sampler2D sheenColorMap;
3248
+ #endif
3249
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3250
+ uniform sampler2D sheenRoughnessMap;
3251
+ #endif
3252
+ #endif
3253
+ #ifdef USE_ANISOTROPY
3254
+ uniform vec2 anisotropyVector;
3255
+ #ifdef USE_ANISOTROPYMAP
3256
+ uniform sampler2D anisotropyMap;
3257
+ #endif
3258
+ #endif
3259
+ varying vec3 vViewPosition;
3260
+ #include <common>
3261
+ #include <packing>
3262
+ #include <dithering_pars_fragment>
3263
+ #include <color_pars_fragment>
3264
+ #include <uv_pars_fragment>
3265
+ #include <map_pars_fragment>
3266
+ #include <alphamap_pars_fragment>
3267
+ #include <alphatest_pars_fragment>
3268
+ #include <alphahash_pars_fragment>
3269
+ #include <aomap_pars_fragment>
3270
+ #include <lightmap_pars_fragment>
3271
+ #include <emissivemap_pars_fragment>
3272
+ #include <iridescence_fragment>
3273
+ #include <cube_uv_reflection_fragment>
3274
+ #include <envmap_common_pars_fragment>
3275
+ #include <envmap_physical_pars_fragment>
3276
+ #include <fog_pars_fragment>
3277
+ #include <lights_pars_begin>
3278
+ #include <normal_pars_fragment>
3279
+ #include <lights_physical_pars_fragment>
3280
+ #include <transmission_pars_fragment>
3281
+ #include <shadowmap_pars_fragment>
3282
+ #include <bumpmap_pars_fragment>
3283
+ #include <normalmap_pars_fragment>
3284
+ #include <clearcoat_pars_fragment>
3285
+ #include <iridescence_pars_fragment>
3286
+ #include <roughnessmap_pars_fragment>
3287
+ #include <metalnessmap_pars_fragment>
3288
+ #include <logdepthbuf_pars_fragment>
3289
+ #include <clipping_planes_pars_fragment>
3290
+ void main() {
3291
+ vec4 diffuseColor = vec4( diffuse, opacity );
3292
+ #include <clipping_planes_fragment>
3293
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3294
+ vec3 totalEmissiveRadiance = emissive;
3295
+ #include <logdepthbuf_fragment>
3296
+ #include <map_fragment>
3297
+ #include <color_fragment>
3298
+ #include <alphamap_fragment>
3299
+ #include <alphatest_fragment>
3300
+ #include <alphahash_fragment>
3301
+ #include <roughnessmap_fragment>
3302
+ #include <metalnessmap_fragment>
3303
+ #include <normal_fragment_begin>
3304
+ #include <normal_fragment_maps>
3305
+ #include <clearcoat_normal_fragment_begin>
3306
+ #include <clearcoat_normal_fragment_maps>
3307
+ #include <emissivemap_fragment>
3308
+ #include <lights_physical_fragment>
3309
+ #include <lights_fragment_begin>
3310
+ #include <lights_fragment_maps>
3311
+ #include <lights_fragment_end>
3312
+ #include <aomap_fragment>
3313
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3314
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3315
+ #include <transmission_fragment>
3316
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3317
+ #ifdef USE_SHEEN
3318
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3319
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3320
+ #endif
3321
+ #ifdef USE_CLEARCOAT
3322
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3323
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3324
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3325
+ #endif
3326
+ #include <opaque_fragment>
3327
+ #include <tonemapping_fragment>
3328
+ #include <colorspace_fragment>
3329
+ #include <fog_fragment>
3330
+ #include <premultiplied_alpha_fragment>
3331
+ #include <dithering_fragment>
3332
+ }`,gd=`#define TOON
3333
+ varying vec3 vViewPosition;
3334
+ #include <common>
3335
+ #include <batching_pars_vertex>
3336
+ #include <uv_pars_vertex>
3337
+ #include <displacementmap_pars_vertex>
3338
+ #include <color_pars_vertex>
3339
+ #include <fog_pars_vertex>
3340
+ #include <normal_pars_vertex>
3341
+ #include <morphtarget_pars_vertex>
3342
+ #include <skinning_pars_vertex>
3343
+ #include <shadowmap_pars_vertex>
3344
+ #include <logdepthbuf_pars_vertex>
3345
+ #include <clipping_planes_pars_vertex>
3346
+ void main() {
3347
+ #include <uv_vertex>
3348
+ #include <color_vertex>
3349
+ #include <morphinstance_vertex>
3350
+ #include <morphcolor_vertex>
3351
+ #include <batching_vertex>
3352
+ #include <beginnormal_vertex>
3353
+ #include <morphnormal_vertex>
3354
+ #include <skinbase_vertex>
3355
+ #include <skinnormal_vertex>
3356
+ #include <defaultnormal_vertex>
3357
+ #include <normal_vertex>
3358
+ #include <begin_vertex>
3359
+ #include <morphtarget_vertex>
3360
+ #include <skinning_vertex>
3361
+ #include <displacementmap_vertex>
3362
+ #include <project_vertex>
3363
+ #include <logdepthbuf_vertex>
3364
+ #include <clipping_planes_vertex>
3365
+ vViewPosition = - mvPosition.xyz;
3366
+ #include <worldpos_vertex>
3367
+ #include <shadowmap_vertex>
3368
+ #include <fog_vertex>
3369
+ }`,vd=`#define TOON
3370
+ uniform vec3 diffuse;
3371
+ uniform vec3 emissive;
3372
+ uniform float opacity;
3373
+ #include <common>
3374
+ #include <packing>
3375
+ #include <dithering_pars_fragment>
3376
+ #include <color_pars_fragment>
3377
+ #include <uv_pars_fragment>
3378
+ #include <map_pars_fragment>
3379
+ #include <alphamap_pars_fragment>
3380
+ #include <alphatest_pars_fragment>
3381
+ #include <alphahash_pars_fragment>
3382
+ #include <aomap_pars_fragment>
3383
+ #include <lightmap_pars_fragment>
3384
+ #include <emissivemap_pars_fragment>
3385
+ #include <gradientmap_pars_fragment>
3386
+ #include <fog_pars_fragment>
3387
+ #include <bsdfs>
3388
+ #include <lights_pars_begin>
3389
+ #include <normal_pars_fragment>
3390
+ #include <lights_toon_pars_fragment>
3391
+ #include <shadowmap_pars_fragment>
3392
+ #include <bumpmap_pars_fragment>
3393
+ #include <normalmap_pars_fragment>
3394
+ #include <logdepthbuf_pars_fragment>
3395
+ #include <clipping_planes_pars_fragment>
3396
+ void main() {
3397
+ vec4 diffuseColor = vec4( diffuse, opacity );
3398
+ #include <clipping_planes_fragment>
3399
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3400
+ vec3 totalEmissiveRadiance = emissive;
3401
+ #include <logdepthbuf_fragment>
3402
+ #include <map_fragment>
3403
+ #include <color_fragment>
3404
+ #include <alphamap_fragment>
3405
+ #include <alphatest_fragment>
3406
+ #include <alphahash_fragment>
3407
+ #include <normal_fragment_begin>
3408
+ #include <normal_fragment_maps>
3409
+ #include <emissivemap_fragment>
3410
+ #include <lights_toon_fragment>
3411
+ #include <lights_fragment_begin>
3412
+ #include <lights_fragment_maps>
3413
+ #include <lights_fragment_end>
3414
+ #include <aomap_fragment>
3415
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3416
+ #include <opaque_fragment>
3417
+ #include <tonemapping_fragment>
3418
+ #include <colorspace_fragment>
3419
+ #include <fog_fragment>
3420
+ #include <premultiplied_alpha_fragment>
3421
+ #include <dithering_fragment>
3422
+ }`,xd=`uniform float size;
3423
+ uniform float scale;
3424
+ #include <common>
3425
+ #include <color_pars_vertex>
3426
+ #include <fog_pars_vertex>
3427
+ #include <morphtarget_pars_vertex>
3428
+ #include <logdepthbuf_pars_vertex>
3429
+ #include <clipping_planes_pars_vertex>
3430
+ #ifdef USE_POINTS_UV
3431
+ varying vec2 vUv;
3432
+ uniform mat3 uvTransform;
3433
+ #endif
3434
+ void main() {
3435
+ #ifdef USE_POINTS_UV
3436
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3437
+ #endif
3438
+ #include <color_vertex>
3439
+ #include <morphinstance_vertex>
3440
+ #include <morphcolor_vertex>
3441
+ #include <begin_vertex>
3442
+ #include <morphtarget_vertex>
3443
+ #include <project_vertex>
3444
+ gl_PointSize = size;
3445
+ #ifdef USE_SIZEATTENUATION
3446
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3447
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3448
+ #endif
3449
+ #include <logdepthbuf_vertex>
3450
+ #include <clipping_planes_vertex>
3451
+ #include <worldpos_vertex>
3452
+ #include <fog_vertex>
3453
+ }`,Sd=`uniform vec3 diffuse;
3454
+ uniform float opacity;
3455
+ #include <common>
3456
+ #include <color_pars_fragment>
3457
+ #include <map_particle_pars_fragment>
3458
+ #include <alphatest_pars_fragment>
3459
+ #include <alphahash_pars_fragment>
3460
+ #include <fog_pars_fragment>
3461
+ #include <logdepthbuf_pars_fragment>
3462
+ #include <clipping_planes_pars_fragment>
3463
+ void main() {
3464
+ vec4 diffuseColor = vec4( diffuse, opacity );
3465
+ #include <clipping_planes_fragment>
3466
+ vec3 outgoingLight = vec3( 0.0 );
3467
+ #include <logdepthbuf_fragment>
3468
+ #include <map_particle_fragment>
3469
+ #include <color_fragment>
3470
+ #include <alphatest_fragment>
3471
+ #include <alphahash_fragment>
3472
+ outgoingLight = diffuseColor.rgb;
3473
+ #include <opaque_fragment>
3474
+ #include <tonemapping_fragment>
3475
+ #include <colorspace_fragment>
3476
+ #include <fog_fragment>
3477
+ #include <premultiplied_alpha_fragment>
3478
+ }`,Md=`#include <common>
3479
+ #include <batching_pars_vertex>
3480
+ #include <fog_pars_vertex>
3481
+ #include <morphtarget_pars_vertex>
3482
+ #include <skinning_pars_vertex>
3483
+ #include <logdepthbuf_pars_vertex>
3484
+ #include <shadowmap_pars_vertex>
3485
+ void main() {
3486
+ #include <batching_vertex>
3487
+ #include <beginnormal_vertex>
3488
+ #include <morphinstance_vertex>
3489
+ #include <morphnormal_vertex>
3490
+ #include <skinbase_vertex>
3491
+ #include <skinnormal_vertex>
3492
+ #include <defaultnormal_vertex>
3493
+ #include <begin_vertex>
3494
+ #include <morphtarget_vertex>
3495
+ #include <skinning_vertex>
3496
+ #include <project_vertex>
3497
+ #include <logdepthbuf_vertex>
3498
+ #include <worldpos_vertex>
3499
+ #include <shadowmap_vertex>
3500
+ #include <fog_vertex>
3501
+ }`,Ed=`uniform vec3 color;
3502
+ uniform float opacity;
3503
+ #include <common>
3504
+ #include <packing>
3505
+ #include <fog_pars_fragment>
3506
+ #include <bsdfs>
3507
+ #include <lights_pars_begin>
3508
+ #include <logdepthbuf_pars_fragment>
3509
+ #include <shadowmap_pars_fragment>
3510
+ #include <shadowmask_pars_fragment>
3511
+ void main() {
3512
+ #include <logdepthbuf_fragment>
3513
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3514
+ #include <tonemapping_fragment>
3515
+ #include <colorspace_fragment>
3516
+ #include <fog_fragment>
3517
+ }`,Td=`uniform float rotation;
3518
+ uniform vec2 center;
3519
+ #include <common>
3520
+ #include <uv_pars_vertex>
3521
+ #include <fog_pars_vertex>
3522
+ #include <logdepthbuf_pars_vertex>
3523
+ #include <clipping_planes_pars_vertex>
3524
+ void main() {
3525
+ #include <uv_vertex>
3526
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3527
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3528
+ #ifndef USE_SIZEATTENUATION
3529
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3530
+ if ( isPerspective ) scale *= - mvPosition.z;
3531
+ #endif
3532
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3533
+ vec2 rotatedPosition;
3534
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3535
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3536
+ mvPosition.xy += rotatedPosition;
3537
+ gl_Position = projectionMatrix * mvPosition;
3538
+ #include <logdepthbuf_vertex>
3539
+ #include <clipping_planes_vertex>
3540
+ #include <fog_vertex>
3541
+ }`,yd=`uniform vec3 diffuse;
3542
+ uniform float opacity;
3543
+ #include <common>
3544
+ #include <uv_pars_fragment>
3545
+ #include <map_pars_fragment>
3546
+ #include <alphamap_pars_fragment>
3547
+ #include <alphatest_pars_fragment>
3548
+ #include <alphahash_pars_fragment>
3549
+ #include <fog_pars_fragment>
3550
+ #include <logdepthbuf_pars_fragment>
3551
+ #include <clipping_planes_pars_fragment>
3552
+ void main() {
3553
+ vec4 diffuseColor = vec4( diffuse, opacity );
3554
+ #include <clipping_planes_fragment>
3555
+ vec3 outgoingLight = vec3( 0.0 );
3556
+ #include <logdepthbuf_fragment>
3557
+ #include <map_fragment>
3558
+ #include <alphamap_fragment>
3559
+ #include <alphatest_fragment>
3560
+ #include <alphahash_fragment>
3561
+ outgoingLight = diffuseColor.rgb;
3562
+ #include <opaque_fragment>
3563
+ #include <tonemapping_fragment>
3564
+ #include <colorspace_fragment>
3565
+ #include <fog_fragment>
3566
+ }`,Ne={alphahash_fragment:qc,alphahash_pars_fragment:Yc,alphamap_fragment:Kc,alphamap_pars_fragment:Zc,alphatest_fragment:$c,alphatest_pars_fragment:jc,aomap_fragment:Jc,aomap_pars_fragment:Qc,batching_pars_vertex:eu,batching_vertex:tu,begin_vertex:nu,beginnormal_vertex:iu,bsdfs:ru,iridescence_fragment:su,bumpmap_pars_fragment:au,clipping_planes_fragment:ou,clipping_planes_pars_fragment:lu,clipping_planes_pars_vertex:cu,clipping_planes_vertex:uu,color_fragment:hu,color_pars_fragment:du,color_pars_vertex:fu,color_vertex:pu,common:mu,cube_uv_reflection_fragment:_u,defaultnormal_vertex:gu,displacementmap_pars_vertex:vu,displacementmap_vertex:xu,emissivemap_fragment:Su,emissivemap_pars_fragment:Mu,colorspace_fragment:Eu,colorspace_pars_fragment:Tu,envmap_fragment:yu,envmap_common_pars_fragment:Au,envmap_pars_fragment:bu,envmap_pars_vertex:wu,envmap_physical_pars_fragment:Bu,envmap_vertex:Ru,fog_vertex:Cu,fog_pars_vertex:Pu,fog_fragment:Lu,fog_pars_fragment:Du,gradientmap_pars_fragment:Uu,lightmap_pars_fragment:Iu,lights_lambert_fragment:Nu,lights_lambert_pars_fragment:Fu,lights_pars_begin:Ou,lights_toon_fragment:zu,lights_toon_pars_fragment:Hu,lights_phong_fragment:Gu,lights_phong_pars_fragment:Vu,lights_physical_fragment:ku,lights_physical_pars_fragment:Wu,lights_fragment_begin:Xu,lights_fragment_maps:qu,lights_fragment_end:Yu,logdepthbuf_fragment:Ku,logdepthbuf_pars_fragment:Zu,logdepthbuf_pars_vertex:$u,logdepthbuf_vertex:ju,map_fragment:Ju,map_pars_fragment:Qu,map_particle_fragment:eh,map_particle_pars_fragment:th,metalnessmap_fragment:nh,metalnessmap_pars_fragment:ih,morphinstance_vertex:rh,morphcolor_vertex:sh,morphnormal_vertex:ah,morphtarget_pars_vertex:oh,morphtarget_vertex:lh,normal_fragment_begin:ch,normal_fragment_maps:uh,normal_pars_fragment:hh,normal_pars_vertex:dh,normal_vertex:fh,normalmap_pars_fragment:ph,clearcoat_normal_fragment_begin:mh,clearcoat_normal_fragment_maps:_h,clearcoat_pars_fragment:gh,iridescence_pars_fragment:vh,opaque_fragment:xh,packing:Sh,premultiplied_alpha_fragment:Mh,project_vertex:Eh,dithering_fragment:Th,dithering_pars_fragment:yh,roughnessmap_fragment:Ah,roughnessmap_pars_fragment:bh,shadowmap_pars_fragment:wh,shadowmap_pars_vertex:Rh,shadowmap_vertex:Ch,shadowmask_pars_fragment:Ph,skinbase_vertex:Lh,skinning_pars_vertex:Dh,skinning_vertex:Uh,skinnormal_vertex:Ih,specularmap_fragment:Nh,specularmap_pars_fragment:Fh,tonemapping_fragment:Oh,tonemapping_pars_fragment:Bh,transmission_fragment:zh,transmission_pars_fragment:Hh,uv_pars_fragment:Gh,uv_pars_vertex:Vh,uv_vertex:kh,worldpos_vertex:Wh,background_vert:Xh,background_frag:qh,backgroundCube_vert:Yh,backgroundCube_frag:Kh,cube_vert:Zh,cube_frag:$h,depth_vert:jh,depth_frag:Jh,distanceRGBA_vert:Qh,distanceRGBA_frag:ed,equirect_vert:td,equirect_frag:nd,linedashed_vert:id,linedashed_frag:rd,meshbasic_vert:sd,meshbasic_frag:ad,meshlambert_vert:od,meshlambert_frag:ld,meshmatcap_vert:cd,meshmatcap_frag:ud,meshnormal_vert:hd,meshnormal_frag:dd,meshphong_vert:fd,meshphong_frag:pd,meshphysical_vert:md,meshphysical_frag:_d,meshtoon_vert:gd,meshtoon_frag:vd,points_vert:xd,points_frag:Sd,shadow_vert:Md,shadow_frag:Ed,sprite_vert:Td,sprite_frag:yd},re={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ue}},envmap:{envMap:{value:null},envMapRotation:{value:new Ue},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ue}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ue}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ue},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ue},normalScale:{value:new Ye(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ue},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ue}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ue}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ue}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0},uvTransform:{value:new Ue}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ye(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ue},alphaMap:{value:null},alphaMapTransform:{value:new Ue},alphaTest:{value:0}}},Wt={basic:{uniforms:Et([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Et([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.fog,re.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Et([re.common,re.specularmap,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.fog,re.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Et([re.common,re.envmap,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.roughnessmap,re.metalnessmap,re.fog,re.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Et([re.common,re.aomap,re.lightmap,re.emissivemap,re.bumpmap,re.normalmap,re.displacementmap,re.gradientmap,re.fog,re.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Et([re.common,re.bumpmap,re.normalmap,re.displacementmap,re.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Et([re.points,re.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Et([re.common,re.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Et([re.common,re.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Et([re.common,re.bumpmap,re.normalmap,re.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Et([re.sprite,re.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new Ue},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ue}},vertexShader:Ne.backgroundCube_vert,fragmentShader:Ne.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distanceRGBA:{uniforms:Et([re.common,re.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distanceRGBA_vert,fragmentShader:Ne.distanceRGBA_frag},shadow:{uniforms:Et([re.lights,re.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};Wt.physical={uniforms:Et([Wt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ue},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ue},clearcoatNormalScale:{value:new Ye(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ue},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ue},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ue},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ue},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ue},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ue},transmissionSamplerSize:{value:new Ye},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ue},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ue},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ue},anisotropyVector:{value:new Ye},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ue}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};const er={r:0,b:0,g:0},bn=new on,Ad=new ke;function bd(i,e,t,n,r,s,a){const o=new ze(0);let l=s===!0?0:1,c,h,d=null,f=0,m=null;function v(y){let M=y.isScene===!0?y.background:null;return M&&M.isTexture&&(M=(y.backgroundBlurriness>0?t:e).get(M)),M}function S(y){let M=!1;const U=v(y);U===null?u(o,l):U&&U.isColor&&(u(U,1),M=!0);const R=i.xr.getEnvironmentBlendMode();R==="additive"?n.buffers.color.setClear(0,0,0,1,a):R==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||M)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(y,M){const U=v(M);U&&(U.isCubeTexture||U.mapping===mr)?(h===void 0&&(h=new qt(new Di(1,1,1),new xn({name:"BackgroundCubeMaterial",uniforms:di(Wt.backgroundCube.uniforms),vertexShader:Wt.backgroundCube.vertexShader,fragmentShader:Wt.backgroundCube.fragmentShader,side:At,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(R,C,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),bn.copy(M.backgroundRotation),bn.x*=-1,bn.y*=-1,bn.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(bn.y*=-1,bn.z*=-1),h.material.uniforms.envMap.value=U,h.material.uniforms.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Ad.makeRotationFromEuler(bn)),h.material.toneMapped=Ve.getTransfer(U.colorSpace)!==$e,(d!==U||f!==U.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,d=U,f=U.version,m=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):U&&U.isTexture&&(c===void 0&&(c=new qt(new Ui(2,2),new xn({name:"BackgroundMaterial",uniforms:di(Wt.background.uniforms),vertexShader:Wt.background.vertexShader,fragmentShader:Wt.background.fragmentShader,side:vn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=U,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.toneMapped=Ve.getTransfer(U.colorSpace)!==$e,U.matrixAutoUpdate===!0&&U.updateMatrix(),c.material.uniforms.uvTransform.value.copy(U.matrix),(d!==U||f!==U.version||m!==i.toneMapping)&&(c.material.needsUpdate=!0,d=U,f=U.version,m=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function u(y,M){y.getRGB(er,Uo(i)),n.buffers.color.setClear(er.r,er.g,er.b,M,a)}function A(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,M=1){o.set(y),l=M,u(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,u(o,l)},render:S,addToRenderList:p,dispose:A}}function wd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null);let s=r,a=!1;function o(x,P,Y,z,X){let J=!1;const V=d(z,Y,P);s!==V&&(s=V,c(s.object)),J=m(x,z,Y,X),J&&v(x,z,Y,X),X!==null&&e.update(X,i.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,M(x,P,Y,z),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(X).buffer))}function l(){return i.createVertexArray()}function c(x){return i.bindVertexArray(x)}function h(x){return i.deleteVertexArray(x)}function d(x,P,Y){const z=Y.wireframe===!0;let X=n[x.id];X===void 0&&(X={},n[x.id]=X);let J=X[P.id];J===void 0&&(J={},X[P.id]=J);let V=J[z];return V===void 0&&(V=f(l()),J[z]=V),V}function f(x){const P=[],Y=[],z=[];for(let X=0;X<t;X++)P[X]=0,Y[X]=0,z[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:Y,attributeDivisors:z,object:x,attributes:{},index:null}}function m(x,P,Y,z){const X=s.attributes,J=P.attributes;let V=0;const te=Y.getAttributes();for(const H in te)if(te[H].location>=0){const de=X[H];let Ee=J[H];if(Ee===void 0&&(H==="instanceMatrix"&&x.instanceMatrix&&(Ee=x.instanceMatrix),H==="instanceColor"&&x.instanceColor&&(Ee=x.instanceColor)),de===void 0||de.attribute!==Ee||Ee&&de.data!==Ee.data)return!0;V++}return s.attributesNum!==V||s.index!==z}function v(x,P,Y,z){const X={},J=P.attributes;let V=0;const te=Y.getAttributes();for(const H in te)if(te[H].location>=0){let de=J[H];de===void 0&&(H==="instanceMatrix"&&x.instanceMatrix&&(de=x.instanceMatrix),H==="instanceColor"&&x.instanceColor&&(de=x.instanceColor));const Ee={};Ee.attribute=de,de&&de.data&&(Ee.data=de.data),X[H]=Ee,V++}s.attributes=X,s.attributesNum=V,s.index=z}function S(){const x=s.newAttributes;for(let P=0,Y=x.length;P<Y;P++)x[P]=0}function p(x){u(x,0)}function u(x,P){const Y=s.newAttributes,z=s.enabledAttributes,X=s.attributeDivisors;Y[x]=1,z[x]===0&&(i.enableVertexAttribArray(x),z[x]=1),X[x]!==P&&(i.vertexAttribDivisor(x,P),X[x]=P)}function A(){const x=s.newAttributes,P=s.enabledAttributes;for(let Y=0,z=P.length;Y<z;Y++)P[Y]!==x[Y]&&(i.disableVertexAttribArray(Y),P[Y]=0)}function y(x,P,Y,z,X,J,V){V===!0?i.vertexAttribIPointer(x,P,Y,X,J):i.vertexAttribPointer(x,P,Y,z,X,J)}function M(x,P,Y,z){S();const X=z.attributes,J=Y.getAttributes(),V=P.defaultAttributeValues;for(const te in J){const H=J[te];if(H.location>=0){let le=X[te];if(le===void 0&&(te==="instanceMatrix"&&x.instanceMatrix&&(le=x.instanceMatrix),te==="instanceColor"&&x.instanceColor&&(le=x.instanceColor)),le!==void 0){const de=le.normalized,Ee=le.itemSize,Fe=e.get(le);if(Fe===void 0)continue;const je=Fe.buffer,q=Fe.type,ne=Fe.bytesPerElement,Se=q===i.INT||q===i.UNSIGNED_INT||le.gpuType===Vs;if(le.isInterleavedBufferAttribute){const ce=le.data,Me=ce.stride,We=le.offset;if(ce.isInstancedInterleavedBuffer){for(let Re=0;Re<H.locationSize;Re++)u(H.location+Re,ce.meshPerAttribute);x.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ce.meshPerAttribute*ce.count)}else for(let Re=0;Re<H.locationSize;Re++)p(H.location+Re);i.bindBuffer(i.ARRAY_BUFFER,je);for(let Re=0;Re<H.locationSize;Re++)y(H.location+Re,Ee/H.locationSize,q,de,Me*ne,(We+Ee/H.locationSize*Re)*ne,Se)}else{if(le.isInstancedBufferAttribute){for(let ce=0;ce<H.locationSize;ce++)u(H.location+ce,le.meshPerAttribute);x.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ce=0;ce<H.locationSize;ce++)p(H.location+ce);i.bindBuffer(i.ARRAY_BUFFER,je);for(let ce=0;ce<H.locationSize;ce++)y(H.location+ce,Ee/H.locationSize,q,de,Ee*ne,Ee/H.locationSize*ce*ne,Se)}}else if(V!==void 0){const de=V[te];if(de!==void 0)switch(de.length){case 2:i.vertexAttrib2fv(H.location,de);break;case 3:i.vertexAttrib3fv(H.location,de);break;case 4:i.vertexAttrib4fv(H.location,de);break;default:i.vertexAttrib1fv(H.location,de)}}}}A()}function U(){I();for(const x in n){const P=n[x];for(const Y in P){const z=P[Y];for(const X in z)h(z[X].object),delete z[X];delete P[Y]}delete n[x]}}function R(x){if(n[x.id]===void 0)return;const P=n[x.id];for(const Y in P){const z=P[Y];for(const X in z)h(z[X].object),delete z[X];delete P[Y]}delete n[x.id]}function C(x){for(const P in n){const Y=n[P];if(Y[x.id]===void 0)continue;const z=Y[x.id];for(const X in z)h(z[X].object),delete z[X];delete Y[x.id]}}function I(){E(),a=!0,s!==r&&(s=r,c(s.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:E,dispose:U,releaseStatesOfGeometry:R,releaseStatesOfProgram:C,initAttributes:S,enableAttribute:p,disableUnusedAttributes:A}}function Rd(i,e,t){let n;function r(c){n=c}function s(c,h){i.drawArrays(n,c,h),t.update(h,n,1)}function a(c,h,d){d!==0&&(i.drawArraysInstanced(n,c,h,d),t.update(h,n,d))}function o(c,h,d){if(d===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,d);let m=0;for(let v=0;v<d;v++)m+=h[v];t.update(m,n,1)}function l(c,h,d,f){if(d===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let v=0;v<c.length;v++)a(c[v],h[v],f[v]);else{m.multiDrawArraysInstancedWEBGL(n,c,0,h,0,f,0,d);let v=0;for(let S=0;S<d;S++)v+=h[S]*f[S];t.update(v,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Cd(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(C){return!(C!==Gt&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const I=C===Ri&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==Kt&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==rn&&!I)}function l(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=t.logarithmicDepthBuffer===!0,f=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),u=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),y=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),U=v>0,R=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reverseDepthBuffer:f,maxTextures:m,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:p,maxAttributes:u,maxVertexUniforms:A,maxVaryings:y,maxFragmentUniforms:M,vertexTextures:U,maxSamples:R}}function Pd(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Rn,o=new Ue,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,f){const m=d.length!==0||f||n!==0||r;return r=f,n=d.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,f){t=h(d,f,0)},this.setState=function(d,f,m){const v=d.clippingPlanes,S=d.clipIntersection,p=d.clipShadows,u=i.get(d);if(!r||v===null||v.length===0||s&&!p)s?h(null):c();else{const A=s?0:n,y=A*4;let M=u.clippingState||null;l.value=M,M=h(v,f,y,m);for(let U=0;U!==y;++U)M[U]=t[U];u.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,f,m,v){const S=d!==null?d.length:0;let p=null;if(S!==0){if(p=l.value,v!==!0||p===null){const u=m+S*4,A=f.matrixWorldInverse;o.getNormalMatrix(A),(p===null||p.length<u)&&(p=new Float32Array(u));for(let y=0,M=m;y!==S;++y,M+=4)a.copy(d[y]).applyMatrix4(A,o),a.normal.toArray(p,M),p[M+3]=a.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,p}}function Ld(i){let e=new WeakMap;function t(a,o){return o===ls?a.mapping=ci:o===cs&&(a.mapping=ui),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===ls||o===cs)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Pc(l.height);return c.fromEquirectangularTexture(i,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}const ri=4,Na=[.125,.215,.35,.446,.526,.582],Dn=20,Yr=new Bo,Fa=new ze;let Kr=null,Zr=0,$r=0,jr=!1;const Cn=(1+Math.sqrt(5))/2,ni=1/Cn,Oa=[new F(-Cn,ni,0),new F(Cn,ni,0),new F(-ni,0,Cn),new F(ni,0,Cn),new F(0,Cn,-ni),new F(0,Cn,ni),new F(-1,1,-1),new F(1,1,-1),new F(-1,1,1),new F(1,1,1)],Dd=new F;class Ba{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=Dd}=s;Kr=this._renderer.getRenderTarget(),Zr=this._renderer.getActiveCubeFace(),$r=this._renderer.getActiveMipmapLevel(),jr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ga(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ha(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Kr,Zr,$r),this._renderer.xr.enabled=jr,e.scissorTest=!1,tr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ci||e.mapping===ui?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Kr=this._renderer.getRenderTarget(),Zr=this._renderer.getActiveCubeFace(),$r=this._renderer.getActiveMipmapLevel(),jr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Xt,minFilter:Xt,generateMipmaps:!1,type:Ri,format:Gt,colorSpace:hi,depthBuffer:!1},r=za(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=za(e,t,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ud(s)),this._blurMaterial=Id(s,e,t)}return r}_compileMaterial(e){const t=new qt(this._lodPlanes[0],e);this._renderer.compile(t,Yr)}_sceneToCubeUV(e,t,n,r,s){const l=new Nt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(Fa),d.toneMapping=gn,d.autoClear=!1;const v=new Po({name:"PMREM.Background",side:At,depthWrite:!1,depthTest:!1}),S=new qt(new Di,v);let p=!1;const u=e.background;u?u.isColor&&(v.color.copy(u),e.background=null,p=!0):(v.color.copy(Fa),p=!0);for(let A=0;A<6;A++){const y=A%3;y===0?(l.up.set(0,c[A],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[A],s.y,s.z)):y===1?(l.up.set(0,0,c[A]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[A],s.z)):(l.up.set(0,c[A],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[A]));const M=this._cubeSize;tr(r,y*M,A>2?M:0,M,M),d.setRenderTarget(r),p&&d.render(S,l),d.render(e,l)}S.geometry.dispose(),S.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=u}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===ci||e.mapping===ui;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ga()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ha());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new qt(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;tr(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Yr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Oa[(r-s-1)%Oa.length];this._blur(e,s-1,s,a,o)}t.autoClear=n}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,d=new qt(this._lodPlanes[r],c),f=c.uniforms,m=this._sizeLods[n]-1,v=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Dn-1),S=s/v,p=isFinite(s)?1+Math.floor(h*S):Dn;p>Dn&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Dn}`);const u=[];let A=0;for(let C=0;C<Dn;++C){const I=C/S,E=Math.exp(-I*I/2);u.push(E),C===0?A+=E:C<p&&(A+=2*E)}for(let C=0;C<u.length;C++)u[C]=u[C]/A;f.envMap.value=e.texture,f.samples.value=p,f.weights.value=u,f.latitudinal.value=a==="latitudinal",o&&(f.poleAxis.value=o);const{_lodMax:y}=this;f.dTheta.value=v,f.mipInt.value=y-n;const M=this._sizeLods[r],U=3*M*(r>y-ri?r-y+ri:0),R=4*(this._cubeSize-M);tr(t,U,R,3*M,2*M),l.setRenderTarget(t),l.render(d,Yr)}}function Ud(i){const e=[],t=[],n=[];let r=i;const s=i-ri+1+Na.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>i-ri?l=Na[a-i+ri-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,d=1+c,f=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,S=3,p=2,u=1,A=new Float32Array(S*v*m),y=new Float32Array(p*v*m),M=new Float32Array(u*v*m);for(let R=0;R<m;R++){const C=R%3*2/3-1,I=R>2?0:-1,E=[C,I,0,C+2/3,I,0,C+2/3,I+1,0,C,I,0,C+2/3,I+1,0,C,I+1,0];A.set(E,S*v*R),y.set(f,p*v*R);const x=[R,R,R,R,R,R];M.set(x,u*v*R)}const U=new Gn;U.setAttribute("position",new Yt(A,S)),U.setAttribute("uv",new Yt(y,p)),U.setAttribute("faceIndex",new Yt(M,u)),e.push(U),r>ri&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function za(i,e,t){const n=new zn(i,e,t);return n.texture.mapping=mr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function tr(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Id(i,e,t){const n=new Float32Array(Dn),r=new F(0,1,0);return new xn({name:"SphericalGaussianBlur",defines:{n:Dn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:js(),fragmentShader:`
3567
+
3568
+ precision mediump float;
3569
+ precision mediump int;
3570
+
3571
+ varying vec3 vOutputDirection;
3572
+
3573
+ uniform sampler2D envMap;
3574
+ uniform int samples;
3575
+ uniform float weights[ n ];
3576
+ uniform bool latitudinal;
3577
+ uniform float dTheta;
3578
+ uniform float mipInt;
3579
+ uniform vec3 poleAxis;
3580
+
3581
+ #define ENVMAP_TYPE_CUBE_UV
3582
+ #include <cube_uv_reflection_fragment>
3583
+
3584
+ vec3 getSample( float theta, vec3 axis ) {
3585
+
3586
+ float cosTheta = cos( theta );
3587
+ // Rodrigues' axis-angle rotation
3588
+ vec3 sampleDirection = vOutputDirection * cosTheta
3589
+ + cross( axis, vOutputDirection ) * sin( theta )
3590
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3591
+
3592
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3593
+
3594
+ }
3595
+
3596
+ void main() {
3597
+
3598
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3599
+
3600
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3601
+
3602
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3603
+
3604
+ }
3605
+
3606
+ axis = normalize( axis );
3607
+
3608
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3609
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3610
+
3611
+ for ( int i = 1; i < n; i++ ) {
3612
+
3613
+ if ( i >= samples ) {
3614
+
3615
+ break;
3616
+
3617
+ }
3618
+
3619
+ float theta = dTheta * float( i );
3620
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3621
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3622
+
3623
+ }
3624
+
3625
+ }
3626
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function Ha(){return new xn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:js(),fragmentShader:`
3627
+
3628
+ precision mediump float;
3629
+ precision mediump int;
3630
+
3631
+ varying vec3 vOutputDirection;
3632
+
3633
+ uniform sampler2D envMap;
3634
+
3635
+ #include <common>
3636
+
3637
+ void main() {
3638
+
3639
+ vec3 outputDirection = normalize( vOutputDirection );
3640
+ vec2 uv = equirectUv( outputDirection );
3641
+
3642
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3643
+
3644
+ }
3645
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function Ga(){return new xn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:js(),fragmentShader:`
3646
+
3647
+ precision mediump float;
3648
+ precision mediump int;
3649
+
3650
+ uniform float flipEnvMap;
3651
+
3652
+ varying vec3 vOutputDirection;
3653
+
3654
+ uniform samplerCube envMap;
3655
+
3656
+ void main() {
3657
+
3658
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3659
+
3660
+ }
3661
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function js(){return`
3662
+
3663
+ precision mediump float;
3664
+ precision mediump int;
3665
+
3666
+ attribute float faceIndex;
3667
+
3668
+ varying vec3 vOutputDirection;
3669
+
3670
+ // RH coordinate system; PMREM face-indexing convention
3671
+ vec3 getDirection( vec2 uv, float face ) {
3672
+
3673
+ uv = 2.0 * uv - 1.0;
3674
+
3675
+ vec3 direction = vec3( uv, 1.0 );
3676
+
3677
+ if ( face == 0.0 ) {
3678
+
3679
+ direction = direction.zyx; // ( 1, v, u ) pos x
3680
+
3681
+ } else if ( face == 1.0 ) {
3682
+
3683
+ direction = direction.xzy;
3684
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3685
+
3686
+ } else if ( face == 2.0 ) {
3687
+
3688
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3689
+
3690
+ } else if ( face == 3.0 ) {
3691
+
3692
+ direction = direction.zyx;
3693
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3694
+
3695
+ } else if ( face == 4.0 ) {
3696
+
3697
+ direction = direction.xzy;
3698
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3699
+
3700
+ } else if ( face == 5.0 ) {
3701
+
3702
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3703
+
3704
+ }
3705
+
3706
+ return direction;
3707
+
3708
+ }
3709
+
3710
+ void main() {
3711
+
3712
+ vOutputDirection = getDirection( uv, faceIndex );
3713
+ gl_Position = vec4( position, 1.0 );
3714
+
3715
+ }
3716
+ `}function Nd(i){let e=new WeakMap,t=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===ls||l===cs,h=l===ci||l===ui;if(c||h){let d=e.get(o);const f=d!==void 0?d.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==f)return t===null&&(t=new Ba(i)),d=c?t.fromEquirectangular(o,d):t.fromCubemap(o,d),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),d.texture;if(d!==void 0)return d.texture;{const m=o.image;return c&&m&&m.height>0||h&&m&&r(m)?(t===null&&(t=new Ba(i)),d=c?t.fromEquirectangular(o):t.fromCubemap(o),d.texture.pmremVersion=o.pmremVersion,e.set(o,d),o.addEventListener("dispose",s),d.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function Fd(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const r=t(n);return r===null&&ai("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function Od(i,e,t,n){const r={},s=new WeakMap;function a(d){const f=d.target;f.index!==null&&e.remove(f.index);for(const v in f.attributes)e.remove(f.attributes[v]);f.removeEventListener("dispose",a),delete r[f.id];const m=s.get(f);m&&(e.remove(m),s.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(d,f){return r[f.id]===!0||(f.addEventListener("dispose",a),r[f.id]=!0,t.memory.geometries++),f}function l(d){const f=d.attributes;for(const m in f)e.update(f[m],i.ARRAY_BUFFER)}function c(d){const f=[],m=d.index,v=d.attributes.position;let S=0;if(m!==null){const A=m.array;S=m.version;for(let y=0,M=A.length;y<M;y+=3){const U=A[y+0],R=A[y+1],C=A[y+2];f.push(U,R,R,C,C,U)}}else if(v!==void 0){const A=v.array;S=v.version;for(let y=0,M=A.length/3-1;y<M;y+=3){const U=y+0,R=y+1,C=y+2;f.push(U,R,R,C,C,U)}}else return;const p=new(bo(f)?Do:Lo)(f,1);p.version=S;const u=s.get(d);u&&e.remove(u),s.set(d,p)}function h(d){const f=s.get(d);if(f){const m=d.index;m!==null&&f.version<m.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function Bd(i,e,t){let n;function r(f){n=f}let s,a;function o(f){s=f.type,a=f.bytesPerElement}function l(f,m){i.drawElements(n,m,s,f*a),t.update(m,n,1)}function c(f,m,v){v!==0&&(i.drawElementsInstanced(n,m,s,f*a,v),t.update(m,n,v))}function h(f,m,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,f,0,v);let p=0;for(let u=0;u<v;u++)p+=m[u];t.update(p,n,1)}function d(f,m,v,S){if(v===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let u=0;u<f.length;u++)c(f[u]/a,m[u],S[u]);else{p.multiDrawElementsInstancedWEBGL(n,m,0,s,f,0,S,0,v);let u=0;for(let A=0;A<v;A++)u+=m[A]*S[A];t.update(u,n,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=d}function zd(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(s/3);break;case i.LINES:t.lines+=o*(s/2);break;case i.LINE_STRIP:t.lines+=o*(s-1);break;case i.LINE_LOOP:t.lines+=o*s;break;case i.POINTS:t.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function Hd(i,e,t){const n=new WeakMap,r=new ct;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let f=n.get(o);if(f===void 0||f.count!==d){let E=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",E)};f!==void 0&&f.texture.dispose();const m=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,S=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let y=0;m===!0&&(y=1),v===!0&&(y=2),S===!0&&(y=3);let M=o.attributes.position.count*y,U=1;M>e.maxTextureSize&&(U=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const R=new Float32Array(M*U*4*d),C=new wo(R,M,U,d);C.type=rn,C.needsUpdate=!0;const I=y*4;for(let x=0;x<d;x++){const P=p[x],Y=u[x],z=A[x],X=M*U*4*x;for(let J=0;J<P.count;J++){const V=J*I;m===!0&&(r.fromBufferAttribute(P,J),R[X+V+0]=r.x,R[X+V+1]=r.y,R[X+V+2]=r.z,R[X+V+3]=0),v===!0&&(r.fromBufferAttribute(Y,J),R[X+V+4]=r.x,R[X+V+5]=r.y,R[X+V+6]=r.z,R[X+V+7]=0),S===!0&&(r.fromBufferAttribute(z,J),R[X+V+8]=r.x,R[X+V+9]=r.y,R[X+V+10]=r.z,R[X+V+11]=z.itemSize===4?r.w:1)}}f={count:d,texture:C,size:new Ye(M,U)},n.set(o,f),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let m=0;for(let S=0;S<c.length;S++)m+=c[S];const v=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(i,"morphTargetBaseInfluence",v),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",f.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",f.size)}return{update:s}}function Gd(i,e,t,n){let r=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,d=e.get(l,h);if(r.get(d)!==c&&(e.update(d),r.set(d,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const f=l.skeleton;r.get(f)!==c&&(f.update(),r.set(f,c))}return d}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Ho=new bt,Va=new Fo(1,1),Go=new wo,Vo=new dc,ko=new No,ka=[],Wa=[],Xa=new Float32Array(16),qa=new Float32Array(9),Ya=new Float32Array(4);function pi(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=ka[r];if(s===void 0&&(s=new Float32Array(r),ka[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function dt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function ft(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function _r(i,e){let t=Wa[e];t===void 0&&(t=new Int32Array(e),Wa[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Vd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function kd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2fv(this.addr,e),ft(t,e)}}function Wd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dt(t,e))return;i.uniform3fv(this.addr,e),ft(t,e)}}function Xd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4fv(this.addr,e),ft(t,e)}}function qd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;Ya.set(n),i.uniformMatrix2fv(this.addr,!1,Ya),ft(t,n)}}function Yd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;qa.set(n),i.uniformMatrix3fv(this.addr,!1,qa),ft(t,n)}}function Kd(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;Xa.set(n),i.uniformMatrix4fv(this.addr,!1,Xa),ft(t,n)}}function Zd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function $d(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2iv(this.addr,e),ft(t,e)}}function jd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;i.uniform3iv(this.addr,e),ft(t,e)}}function Jd(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4iv(this.addr,e),ft(t,e)}}function Qd(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function ef(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;i.uniform2uiv(this.addr,e),ft(t,e)}}function tf(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;i.uniform3uiv(this.addr,e),ft(t,e)}}function nf(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;i.uniform4uiv(this.addr,e),ft(t,e)}}function rf(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Va.compareFunction=Ao,s=Va):s=Ho,t.setTexture2D(e||s,r)}function sf(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||Vo,r)}function af(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||ko,r)}function of(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Go,r)}function lf(i){switch(i){case 5126:return Vd;case 35664:return kd;case 35665:return Wd;case 35666:return Xd;case 35674:return qd;case 35675:return Yd;case 35676:return Kd;case 5124:case 35670:return Zd;case 35667:case 35671:return $d;case 35668:case 35672:return jd;case 35669:case 35673:return Jd;case 5125:return Qd;case 36294:return ef;case 36295:return tf;case 36296:return nf;case 35678:case 36198:case 36298:case 36306:case 35682:return rf;case 35679:case 36299:case 36307:return sf;case 35680:case 36300:case 36308:case 36293:return af;case 36289:case 36303:case 36311:case 36292:return of}}function cf(i,e){i.uniform1fv(this.addr,e)}function uf(i,e){const t=pi(e,this.size,2);i.uniform2fv(this.addr,t)}function hf(i,e){const t=pi(e,this.size,3);i.uniform3fv(this.addr,t)}function df(i,e){const t=pi(e,this.size,4);i.uniform4fv(this.addr,t)}function ff(i,e){const t=pi(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function pf(i,e){const t=pi(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function mf(i,e){const t=pi(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function _f(i,e){i.uniform1iv(this.addr,e)}function gf(i,e){i.uniform2iv(this.addr,e)}function vf(i,e){i.uniform3iv(this.addr,e)}function xf(i,e){i.uniform4iv(this.addr,e)}function Sf(i,e){i.uniform1uiv(this.addr,e)}function Mf(i,e){i.uniform2uiv(this.addr,e)}function Ef(i,e){i.uniform3uiv(this.addr,e)}function Tf(i,e){i.uniform4uiv(this.addr,e)}function yf(i,e,t){const n=this.cache,r=e.length,s=_r(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),ft(n,s));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||Ho,s[a])}function Af(i,e,t){const n=this.cache,r=e.length,s=_r(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),ft(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Vo,s[a])}function bf(i,e,t){const n=this.cache,r=e.length,s=_r(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),ft(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||ko,s[a])}function wf(i,e,t){const n=this.cache,r=e.length,s=_r(t,r);dt(n,s)||(i.uniform1iv(this.addr,s),ft(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Go,s[a])}function Rf(i){switch(i){case 5126:return cf;case 35664:return uf;case 35665:return hf;case 35666:return df;case 35674:return ff;case 35675:return pf;case 35676:return mf;case 5124:case 35670:return _f;case 35667:case 35671:return gf;case 35668:case 35672:return vf;case 35669:case 35673:return xf;case 5125:return Sf;case 36294:return Mf;case 36295:return Ef;case 36296:return Tf;case 35678:case 36198:case 36298:case 36306:case 35682:return yf;case 35679:case 36299:case 36307:return Af;case 35680:case 36300:case 36308:case 36293:return bf;case 36289:case 36303:case 36311:case 36292:return wf}}class Cf{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=lf(t.type)}}class Pf{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Rf(t.type)}}class Lf{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Jr=/(\w+)(\])?(\[|\.)?/g;function Ka(i,e){i.seq.push(e),i.map[e.id]=e}function Df(i,e,t){const n=i.name,r=n.length;for(Jr.lastIndex=0;;){const s=Jr.exec(n),a=Jr.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Ka(t,c===void 0?new Cf(o,i,e):new Pf(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new Lf(o),Ka(t,d)),t=d}}}class ur{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=e.getActiveUniform(t,r),a=e.getUniformLocation(t,s.name);Df(s,a,this)}}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function Za(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Uf=37297;let If=0;function Nf(i,e){const t=i.split(`
3717
+ `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
3718
+ `)}const $a=new Ue;function Ff(i){Ve._getMatrix($a,Ve.workingColorSpace,i);const e=`mat3( ${$a.elements.map(t=>t.toFixed(4))} )`;switch(Ve.getTransfer(i)){case hr:return[e,"LinearTransferOETF"];case $e:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ja(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return t.toUpperCase()+`
3719
+
3720
+ `+r+`
3721
+
3722
+ `+Nf(i.getShaderSource(e),a)}else return r}function Of(i,e){const t=Ff(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
3723
+ `)}function Bf(i,e){let t;switch(e){case Ol:t="Linear";break;case Bl:t="Reinhard";break;case zl:t="Cineon";break;case Hl:t="ACESFilmic";break;case Vl:t="AgX";break;case kl:t="Neutral";break;case Gl:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const nr=new F;function zf(){Ve.getLuminanceCoefficients(nr);const i=nr.x.toFixed(4),e=nr.y.toFixed(4),t=nr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
3724
+ `)}function Hf(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Mi).join(`
3725
+ `)}function Gf(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
3726
+ `)}function Vf(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Mi(i){return i!==""}function Ja(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.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,t).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 Qa(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const kf=/^[ \t]*#include +<([\w\d./]+)>/gm;function zs(i){return i.replace(kf,Xf)}const Wf=new Map;function Xf(i,e){let t=Ne[e];if(t===void 0){const n=Wf.get(e);if(n!==void 0)t=Ne[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return zs(t)}const qf=/#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 eo(i){return i.replace(qf,Yf)}function Yf(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function to(i){let e=`precision ${i.precision} float;
3727
+ precision ${i.precision} int;
3728
+ precision ${i.precision} sampler2D;
3729
+ precision ${i.precision} samplerCube;
3730
+ precision ${i.precision} sampler3D;
3731
+ precision ${i.precision} sampler2DArray;
3732
+ precision ${i.precision} sampler2DShadow;
3733
+ precision ${i.precision} samplerCubeShadow;
3734
+ precision ${i.precision} sampler2DArrayShadow;
3735
+ precision ${i.precision} isampler2D;
3736
+ precision ${i.precision} isampler3D;
3737
+ precision ${i.precision} isamplerCube;
3738
+ precision ${i.precision} isampler2DArray;
3739
+ precision ${i.precision} usampler2D;
3740
+ precision ${i.precision} usampler3D;
3741
+ precision ${i.precision} usamplerCube;
3742
+ precision ${i.precision} usampler2DArray;
3743
+ `;return i.precision==="highp"?e+=`
3744
+ #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
3745
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
3746
+ #define LOW_PRECISION`),e}function Kf(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===po?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===_l?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===tn&&(e="SHADOWMAP_TYPE_VSM"),e}function Zf(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case ci:case ui:e="ENVMAP_TYPE_CUBE";break;case mr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function $f(i){let e="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===ui&&(e="ENVMAP_MODE_REFRACTION"),e}function jf(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case mo:e="ENVMAP_BLENDING_MULTIPLY";break;case Nl:e="ENVMAP_BLENDING_MIX";break;case Fl:e="ENVMAP_BLENDING_ADD";break}return e}function Jf(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Qf(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=Kf(t),c=Zf(t),h=$f(t),d=jf(t),f=Jf(t),m=Hf(t),v=Gf(s),S=r.createProgram();let p,u,A=t.glslVersion?"#version "+t.glslVersion+`
3747
+ `:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Mi).join(`
3748
+ `),p.length>0&&(p+=`
3749
+ `),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Mi).join(`
3750
+ `),u.length>0&&(u+=`
3751
+ `)):(p=[to(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3752
+ `].filter(Mi).join(`
3753
+ `),u=[to(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==gn?"#define TONE_MAPPING":"",t.toneMapping!==gn?Ne.tonemapping_pars_fragment:"",t.toneMapping!==gn?Bf("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ne.colorspace_pars_fragment,Of("linearToOutputTexel",t.outputColorSpace),zf(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
3754
+ `].filter(Mi).join(`
3755
+ `)),a=zs(a),a=Ja(a,t),a=Qa(a,t),o=zs(o),o=Ja(o,t),o=Qa(o,t),a=eo(a),o=eo(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
3756
+ `,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3757
+ `)+`
3758
+ `+p,u=["#define varying in",t.glslVersion===pa?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pa?"":"#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(`
3759
+ `)+`
3760
+ `+u);const y=A+p+a,M=A+u+o,U=Za(r,r.VERTEX_SHADER,y),R=Za(r,r.FRAGMENT_SHADER,M);r.attachShader(S,U),r.attachShader(S,R),t.index0AttributeName!==void 0?r.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S);function C(P){if(i.debug.checkShaderErrors){const Y=r.getProgramInfoLog(S).trim(),z=r.getShaderInfoLog(U).trim(),X=r.getShaderInfoLog(R).trim();let J=!0,V=!0;if(r.getProgramParameter(S,r.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,S,U,R);else{const te=ja(r,U,"vertex"),H=ja(r,R,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,r.VALIDATE_STATUS)+`
3761
+
3762
+ Material Name: `+P.name+`
3763
+ Material Type: `+P.type+`
3764
+
3765
+ Program Info Log: `+Y+`
3766
+ `+te+`
3767
+ `+H)}else Y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Y):(z===""||X==="")&&(V=!1);V&&(P.diagnostics={runnable:J,programLog:Y,vertexShader:{log:z,prefix:p},fragmentShader:{log:X,prefix:u}})}r.deleteShader(U),r.deleteShader(R),I=new ur(r,S),E=Vf(r,S)}let I;this.getUniforms=function(){return I===void 0&&C(this),I};let E;this.getAttributes=function(){return E===void 0&&C(this),E};let x=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return x===!1&&(x=r.getProgramParameter(S,Uf)),x},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=If++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=U,this.fragmentShader=R,this}let ep=0;class tp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new np(e),t.set(e,n)),n}}class np{constructor(e){this.id=ep++,this.code=e,this.usedTimes=0}}function ip(i,e,t,n,r,s,a){const o=new Ro,l=new tp,c=new Set,h=[],d=r.logarithmicDepthBuffer,f=r.vertexTextures;let m=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function S(E){return c.add(E),E===0?"uv":`uv${E}`}function p(E,x,P,Y,z){const X=Y.fog,J=z.geometry,V=E.isMeshStandardMaterial?Y.environment:null,te=(E.isMeshStandardMaterial?t:e).get(E.envMap||V),H=te&&te.mapping===mr?te.image.height:null,le=v[E.type];E.precision!==null&&(m=r.getMaxPrecision(E.precision),m!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",m,"instead."));const de=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Ee=de!==void 0?de.length:0;let Fe=0;J.morphAttributes.position!==void 0&&(Fe=1),J.morphAttributes.normal!==void 0&&(Fe=2),J.morphAttributes.color!==void 0&&(Fe=3);let je,q,ne,Se;if(le){const Ke=Wt[le];je=Ke.vertexShader,q=Ke.fragmentShader}else je=E.vertexShader,q=E.fragmentShader,l.update(E),ne=l.getVertexShaderID(E),Se=l.getFragmentShaderID(E);const ce=i.getRenderTarget(),Me=i.state.buffers.depth.getReversed(),We=z.isInstancedMesh===!0,Re=z.isBatchedMesh===!0,rt=!!E.map,st=!!E.matcap,Xe=!!te,b=!!E.aoMap,St=!!E.lightMap,qe=!!E.bumpMap,et=!!E.normalMap,ge=!!E.displacementMap,He=!!E.emissiveMap,ye=!!E.metalnessMap,Ie=!!E.roughnessMap,ht=E.anisotropy>0,T=E.clearcoat>0,_=E.dispersion>0,N=E.iridescence>0,k=E.sheen>0,Z=E.transmission>0,G=ht&&!!E.anisotropyMap,ve=T&&!!E.clearcoatMap,se=T&&!!E.clearcoatNormalMap,_e=T&&!!E.clearcoatRoughnessMap,xe=N&&!!E.iridescenceMap,$=N&&!!E.iridescenceThicknessMap,ue=k&&!!E.sheenColorMap,we=k&&!!E.sheenRoughnessMap,be=!!E.specularMap,ie=!!E.specularColorMap,Le=!!E.specularIntensityMap,w=Z&&!!E.transmissionMap,ae=Z&&!!E.thicknessMap,j=!!E.gradientMap,fe=!!E.alphaMap,Q=E.alphaTest>0,K=!!E.alphaHash,pe=!!E.extensions;let De=gn;E.toneMapped&&(ce===null||ce.isXRRenderTarget===!0)&&(De=i.toneMapping);const tt={shaderID:le,shaderType:E.type,shaderName:E.name,vertexShader:je,fragmentShader:q,defines:E.defines,customVertexShaderID:ne,customFragmentShaderID:Se,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:m,batching:Re,batchingColor:Re&&z._colorsTexture!==null,instancing:We,instancingColor:We&&z.instanceColor!==null,instancingMorph:We&&z.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:ce===null?i.outputColorSpace:ce.isXRRenderTarget===!0?ce.texture.colorSpace:hi,alphaToCoverage:!!E.alphaToCoverage,map:rt,matcap:st,envMap:Xe,envMapMode:Xe&&te.mapping,envMapCubeUVHeight:H,aoMap:b,lightMap:St,bumpMap:qe,normalMap:et,displacementMap:f&&ge,emissiveMap:He,normalMapObjectSpace:et&&E.normalMapType===Kl,normalMapTangentSpace:et&&E.normalMapType===Yl,metalnessMap:ye,roughnessMap:Ie,anisotropy:ht,anisotropyMap:G,clearcoat:T,clearcoatMap:ve,clearcoatNormalMap:se,clearcoatRoughnessMap:_e,dispersion:_,iridescence:N,iridescenceMap:xe,iridescenceThicknessMap:$,sheen:k,sheenColorMap:ue,sheenRoughnessMap:we,specularMap:be,specularColorMap:ie,specularIntensityMap:Le,transmission:Z,transmissionMap:w,thicknessMap:ae,gradientMap:j,opaque:E.transparent===!1&&E.blending===si&&E.alphaToCoverage===!1,alphaMap:fe,alphaTest:Q,alphaHash:K,combine:E.combine,mapUv:rt&&S(E.map.channel),aoMapUv:b&&S(E.aoMap.channel),lightMapUv:St&&S(E.lightMap.channel),bumpMapUv:qe&&S(E.bumpMap.channel),normalMapUv:et&&S(E.normalMap.channel),displacementMapUv:ge&&S(E.displacementMap.channel),emissiveMapUv:He&&S(E.emissiveMap.channel),metalnessMapUv:ye&&S(E.metalnessMap.channel),roughnessMapUv:Ie&&S(E.roughnessMap.channel),anisotropyMapUv:G&&S(E.anisotropyMap.channel),clearcoatMapUv:ve&&S(E.clearcoatMap.channel),clearcoatNormalMapUv:se&&S(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_e&&S(E.clearcoatRoughnessMap.channel),iridescenceMapUv:xe&&S(E.iridescenceMap.channel),iridescenceThicknessMapUv:$&&S(E.iridescenceThicknessMap.channel),sheenColorMapUv:ue&&S(E.sheenColorMap.channel),sheenRoughnessMapUv:we&&S(E.sheenRoughnessMap.channel),specularMapUv:be&&S(E.specularMap.channel),specularColorMapUv:ie&&S(E.specularColorMap.channel),specularIntensityMapUv:Le&&S(E.specularIntensityMap.channel),transmissionMapUv:w&&S(E.transmissionMap.channel),thicknessMapUv:ae&&S(E.thicknessMap.channel),alphaMapUv:fe&&S(E.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(et||ht),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!J.attributes.uv&&(rt||fe),fog:!!X,useFog:E.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:E.flatShading===!0&&E.wireframe===!1,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:d,reverseDepthBuffer:Me,skinning:z.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:Ee,morphTextureStride:Fe,numDirLights:x.directional.length,numPointLights:x.point.length,numSpotLights:x.spot.length,numSpotLightMaps:x.spotLightMap.length,numRectAreaLights:x.rectArea.length,numHemiLights:x.hemi.length,numDirLightShadows:x.directionalShadowMap.length,numPointLightShadows:x.pointShadowMap.length,numSpotLightShadows:x.spotShadowMap.length,numSpotLightShadowsWithMaps:x.numSpotLightShadowsWithMaps,numLightProbes:x.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:De,decodeVideoTexture:rt&&E.map.isVideoTexture===!0&&Ve.getTransfer(E.map.colorSpace)===$e,decodeVideoTextureEmissive:He&&E.emissiveMap.isVideoTexture===!0&&Ve.getTransfer(E.emissiveMap.colorSpace)===$e,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===nn,flipSided:E.side===At,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:pe&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pe&&E.extensions.multiDraw===!0||Re)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return tt.vertexUv1s=c.has(1),tt.vertexUv2s=c.has(2),tt.vertexUv3s=c.has(3),c.clear(),tt}function u(E){const x=[];if(E.shaderID?x.push(E.shaderID):(x.push(E.customVertexShaderID),x.push(E.customFragmentShaderID)),E.defines!==void 0)for(const P in E.defines)x.push(P),x.push(E.defines[P]);return E.isRawShaderMaterial===!1&&(A(x,E),y(x,E),x.push(i.outputColorSpace)),x.push(E.customProgramCacheKey),x.join()}function A(E,x){E.push(x.precision),E.push(x.outputColorSpace),E.push(x.envMapMode),E.push(x.envMapCubeUVHeight),E.push(x.mapUv),E.push(x.alphaMapUv),E.push(x.lightMapUv),E.push(x.aoMapUv),E.push(x.bumpMapUv),E.push(x.normalMapUv),E.push(x.displacementMapUv),E.push(x.emissiveMapUv),E.push(x.metalnessMapUv),E.push(x.roughnessMapUv),E.push(x.anisotropyMapUv),E.push(x.clearcoatMapUv),E.push(x.clearcoatNormalMapUv),E.push(x.clearcoatRoughnessMapUv),E.push(x.iridescenceMapUv),E.push(x.iridescenceThicknessMapUv),E.push(x.sheenColorMapUv),E.push(x.sheenRoughnessMapUv),E.push(x.specularMapUv),E.push(x.specularColorMapUv),E.push(x.specularIntensityMapUv),E.push(x.transmissionMapUv),E.push(x.thicknessMapUv),E.push(x.combine),E.push(x.fogExp2),E.push(x.sizeAttenuation),E.push(x.morphTargetsCount),E.push(x.morphAttributeCount),E.push(x.numDirLights),E.push(x.numPointLights),E.push(x.numSpotLights),E.push(x.numSpotLightMaps),E.push(x.numHemiLights),E.push(x.numRectAreaLights),E.push(x.numDirLightShadows),E.push(x.numPointLightShadows),E.push(x.numSpotLightShadows),E.push(x.numSpotLightShadowsWithMaps),E.push(x.numLightProbes),E.push(x.shadowMapType),E.push(x.toneMapping),E.push(x.numClippingPlanes),E.push(x.numClipIntersection),E.push(x.depthPacking)}function y(E,x){o.disableAll(),x.supportsVertexTextures&&o.enable(0),x.instancing&&o.enable(1),x.instancingColor&&o.enable(2),x.instancingMorph&&o.enable(3),x.matcap&&o.enable(4),x.envMap&&o.enable(5),x.normalMapObjectSpace&&o.enable(6),x.normalMapTangentSpace&&o.enable(7),x.clearcoat&&o.enable(8),x.iridescence&&o.enable(9),x.alphaTest&&o.enable(10),x.vertexColors&&o.enable(11),x.vertexAlphas&&o.enable(12),x.vertexUv1s&&o.enable(13),x.vertexUv2s&&o.enable(14),x.vertexUv3s&&o.enable(15),x.vertexTangents&&o.enable(16),x.anisotropy&&o.enable(17),x.alphaHash&&o.enable(18),x.batching&&o.enable(19),x.dispersion&&o.enable(20),x.batchingColor&&o.enable(21),x.gradientMap&&o.enable(22),E.push(o.mask),o.disableAll(),x.fog&&o.enable(0),x.useFog&&o.enable(1),x.flatShading&&o.enable(2),x.logarithmicDepthBuffer&&o.enable(3),x.reverseDepthBuffer&&o.enable(4),x.skinning&&o.enable(5),x.morphTargets&&o.enable(6),x.morphNormals&&o.enable(7),x.morphColors&&o.enable(8),x.premultipliedAlpha&&o.enable(9),x.shadowMapEnabled&&o.enable(10),x.doubleSided&&o.enable(11),x.flipSided&&o.enable(12),x.useDepthPacking&&o.enable(13),x.dithering&&o.enable(14),x.transmission&&o.enable(15),x.sheen&&o.enable(16),x.opaque&&o.enable(17),x.pointsUvs&&o.enable(18),x.decodeVideoTexture&&o.enable(19),x.decodeVideoTextureEmissive&&o.enable(20),x.alphaToCoverage&&o.enable(21),E.push(o.mask)}function M(E){const x=v[E.type];let P;if(x){const Y=Wt[x];P=bc.clone(Y.uniforms)}else P=E.uniforms;return P}function U(E,x){let P;for(let Y=0,z=h.length;Y<z;Y++){const X=h[Y];if(X.cacheKey===x){P=X,++P.usedTimes;break}}return P===void 0&&(P=new Qf(i,x,E,s),h.push(P)),P}function R(E){if(--E.usedTimes===0){const x=h.indexOf(E);h[x]=h[h.length-1],h.pop(),E.destroy()}}function C(E){l.remove(E)}function I(){l.dispose()}return{getParameters:p,getProgramCacheKey:u,getUniforms:M,acquireProgram:U,releaseProgram:R,releaseShaderCache:C,programs:h,dispose:I}}function rp(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function sp(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function no(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function io(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(d,f,m,v,S,p){let u=i[e];return u===void 0?(u={id:d.id,object:d,geometry:f,material:m,groupOrder:v,renderOrder:d.renderOrder,z:S,group:p},i[e]=u):(u.id=d.id,u.object=d,u.geometry=f,u.material=m,u.groupOrder=v,u.renderOrder=d.renderOrder,u.z=S,u.group=p),e++,u}function o(d,f,m,v,S,p){const u=a(d,f,m,v,S,p);m.transmission>0?n.push(u):m.transparent===!0?r.push(u):t.push(u)}function l(d,f,m,v,S,p){const u=a(d,f,m,v,S,p);m.transmission>0?n.unshift(u):m.transparent===!0?r.unshift(u):t.unshift(u)}function c(d,f){t.length>1&&t.sort(d||sp),n.length>1&&n.sort(f||no),r.length>1&&r.sort(f||no)}function h(){for(let d=e,f=i.length;d<f;d++){const m=i[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function ap(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new io,i.set(n,[a])):r>=s.length?(a=new io,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function op(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new F,color:new ze};break;case"SpotLight":t={position:new F,direction:new F,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function lp(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ye,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let cp=0;function up(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function hp(i){const e=new op,t=lp(),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 c=0;c<9;c++)n.probe.push(new F);const r=new F,s=new ke,a=new ke;function o(c){let h=0,d=0,f=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let m=0,v=0,S=0,p=0,u=0,A=0,y=0,M=0,U=0,R=0,C=0;c.sort(up);for(let E=0,x=c.length;E<x;E++){const P=c[E],Y=P.color,z=P.intensity,X=P.distance,J=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=Y.r*z,d+=Y.g*z,f+=Y.b*z;else if(P.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(P.sh.coefficients[V],z);C++}else if(P.isDirectionalLight){const V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const te=P.shadow,H=t.get(P);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,n.directionalShadow[m]=H,n.directionalShadowMap[m]=J,n.directionalShadowMatrix[m]=P.shadow.matrix,A++}n.directional[m]=V,m++}else if(P.isSpotLight){const V=e.get(P);V.position.setFromMatrixPosition(P.matrixWorld),V.color.copy(Y).multiplyScalar(z),V.distance=X,V.coneCos=Math.cos(P.angle),V.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),V.decay=P.decay,n.spot[S]=V;const te=P.shadow;if(P.map&&(n.spotLightMap[U]=P.map,U++,te.updateMatrices(P),P.castShadow&&R++),n.spotLightMatrix[S]=te.matrix,P.castShadow){const H=t.get(P);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,n.spotShadow[S]=H,n.spotShadowMap[S]=J,M++}S++}else if(P.isRectAreaLight){const V=e.get(P);V.color.copy(Y).multiplyScalar(z),V.halfWidth.set(P.width*.5,0,0),V.halfHeight.set(0,P.height*.5,0),n.rectArea[p]=V,p++}else if(P.isPointLight){const V=e.get(P);if(V.color.copy(P.color).multiplyScalar(P.intensity),V.distance=P.distance,V.decay=P.decay,P.castShadow){const te=P.shadow,H=t.get(P);H.shadowIntensity=te.intensity,H.shadowBias=te.bias,H.shadowNormalBias=te.normalBias,H.shadowRadius=te.radius,H.shadowMapSize=te.mapSize,H.shadowCameraNear=te.camera.near,H.shadowCameraFar=te.camera.far,n.pointShadow[v]=H,n.pointShadowMap[v]=J,n.pointShadowMatrix[v]=P.shadow.matrix,y++}n.point[v]=V,v++}else if(P.isHemisphereLight){const V=e.get(P);V.skyColor.copy(P.color).multiplyScalar(z),V.groundColor.copy(P.groundColor).multiplyScalar(z),n.hemi[u]=V,u++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=re.LTC_FLOAT_1,n.rectAreaLTC2=re.LTC_FLOAT_2):(n.rectAreaLTC1=re.LTC_HALF_1,n.rectAreaLTC2=re.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=f;const I=n.hash;(I.directionalLength!==m||I.pointLength!==v||I.spotLength!==S||I.rectAreaLength!==p||I.hemiLength!==u||I.numDirectionalShadows!==A||I.numPointShadows!==y||I.numSpotShadows!==M||I.numSpotMaps!==U||I.numLightProbes!==C)&&(n.directional.length=m,n.spot.length=S,n.rectArea.length=p,n.point.length=v,n.hemi.length=u,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=y,n.pointShadowMap.length=y,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=y,n.spotLightMatrix.length=M+U-R,n.spotLightMap.length=U,n.numSpotLightShadowsWithMaps=R,n.numLightProbes=C,I.directionalLength=m,I.pointLength=v,I.spotLength=S,I.rectAreaLength=p,I.hemiLength=u,I.numDirectionalShadows=A,I.numPointShadows=y,I.numSpotShadows=M,I.numSpotMaps=U,I.numLightProbes=C,n.version=cp++)}function l(c,h){let d=0,f=0,m=0,v=0,S=0;const p=h.matrixWorldInverse;for(let u=0,A=c.length;u<A;u++){const y=c[u];if(y.isDirectionalLight){const M=n.directional[d];M.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(p),d++}else if(y.isSpotLight){const M=n.spot[m];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(p),M.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(p),m++}else if(y.isRectAreaLight){const M=n.rectArea[v];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(p),a.identity(),s.copy(y.matrixWorld),s.premultiply(p),a.extractRotation(s),M.halfWidth.set(y.width*.5,0,0),M.halfHeight.set(0,y.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),v++}else if(y.isPointLight){const M=n.point[f];M.position.setFromMatrixPosition(y.matrixWorld),M.position.applyMatrix4(p),f++}else if(y.isHemisphereLight){const M=n.hemi[S];M.direction.setFromMatrixPosition(y.matrixWorld),M.direction.transformDirection(p),S++}}}return{setup:o,setupView:l,state:n}}function ro(i){const e=new hp(i),t=[],n=[];function r(h){c.camera=h,t.length=0,n.length=0}function s(h){t.push(h)}function a(h){n.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function dp(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ro(i),e.set(r,[o])):s>=a.length?(o=new ro(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const fp=`void main() {
3768
+ gl_Position = vec4( position, 1.0 );
3769
+ }`,pp=`uniform sampler2D shadow_pass;
3770
+ uniform vec2 resolution;
3771
+ uniform float radius;
3772
+ #include <packing>
3773
+ void main() {
3774
+ const float samples = float( VSM_SAMPLES );
3775
+ float mean = 0.0;
3776
+ float squared_mean = 0.0;
3777
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3778
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3779
+ for ( float i = 0.0; i < samples; i ++ ) {
3780
+ float uvOffset = uvStart + i * uvStride;
3781
+ #ifdef HORIZONTAL_PASS
3782
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3783
+ mean += distribution.x;
3784
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3785
+ #else
3786
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3787
+ mean += depth;
3788
+ squared_mean += depth * depth;
3789
+ #endif
3790
+ }
3791
+ mean = mean / samples;
3792
+ squared_mean = squared_mean / samples;
3793
+ float std_dev = sqrt( squared_mean - mean * mean );
3794
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3795
+ }`;function mp(i,e,t){let n=new $s;const r=new Ye,s=new Ye,a=new ct,o=new Oc({depthPacking:ql}),l=new Bc,c={},h=t.maxTextureSize,d={[vn]:At,[At]:vn,[nn]:nn},f=new xn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ye},radius:{value:4}},vertexShader:fp,fragmentShader:pp}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const v=new Gn;v.setAttribute("position",new Yt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new qt(v,f),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=po;let u=this.type;this.render=function(R,C,I){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||R.length===0)return;const E=i.getRenderTarget(),x=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),Y=i.state;Y.setBlending(_n),Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);const z=u!==tn&&this.type===tn,X=u===tn&&this.type!==tn;for(let J=0,V=R.length;J<V;J++){const te=R[J],H=te.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",te,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const le=H.getFrameExtents();if(r.multiply(le),s.copy(H.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/le.x),r.x=s.x*le.x,H.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/le.y),r.y=s.y*le.y,H.mapSize.y=s.y)),H.map===null||z===!0||X===!0){const Ee=this.type!==tn?{minFilter:kt,magFilter:kt}:{};H.map!==null&&H.map.dispose(),H.map=new zn(r.x,r.y,Ee),H.map.texture.name=te.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const de=H.getViewportCount();for(let Ee=0;Ee<de;Ee++){const Fe=H.getViewport(Ee);a.set(s.x*Fe.x,s.y*Fe.y,s.x*Fe.z,s.y*Fe.w),Y.viewport(a),H.updateMatrices(te,Ee),n=H.getFrustum(),M(C,I,H.camera,te,this.type)}H.isPointLightShadow!==!0&&this.type===tn&&A(H,I),H.needsUpdate=!1}u=this.type,p.needsUpdate=!1,i.setRenderTarget(E,x,P)};function A(R,C){const I=e.update(S);f.defines.VSM_SAMPLES!==R.blurSamples&&(f.defines.VSM_SAMPLES=R.blurSamples,m.defines.VSM_SAMPLES=R.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new zn(r.x,r.y)),f.uniforms.shadow_pass.value=R.map.texture,f.uniforms.resolution.value=R.mapSize,f.uniforms.radius.value=R.radius,i.setRenderTarget(R.mapPass),i.clear(),i.renderBufferDirect(C,null,I,f,S,null),m.uniforms.shadow_pass.value=R.mapPass.texture,m.uniforms.resolution.value=R.mapSize,m.uniforms.radius.value=R.radius,i.setRenderTarget(R.map),i.clear(),i.renderBufferDirect(C,null,I,m,S,null)}function y(R,C,I,E){let x=null;const P=I.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(P!==void 0)x=P;else if(x=I.isPointLight===!0?l:o,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const Y=x.uuid,z=C.uuid;let X=c[Y];X===void 0&&(X={},c[Y]=X);let J=X[z];J===void 0&&(J=x.clone(),X[z]=J,C.addEventListener("dispose",U)),x=J}if(x.visible=C.visible,x.wireframe=C.wireframe,E===tn?x.side=C.shadowSide!==null?C.shadowSide:C.side:x.side=C.shadowSide!==null?C.shadowSide:d[C.side],x.alphaMap=C.alphaMap,x.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,x.map=C.map,x.clipShadows=C.clipShadows,x.clippingPlanes=C.clippingPlanes,x.clipIntersection=C.clipIntersection,x.displacementMap=C.displacementMap,x.displacementScale=C.displacementScale,x.displacementBias=C.displacementBias,x.wireframeLinewidth=C.wireframeLinewidth,x.linewidth=C.linewidth,I.isPointLight===!0&&x.isMeshDistanceMaterial===!0){const Y=i.properties.get(x);Y.light=I}return x}function M(R,C,I,E,x){if(R.visible===!1)return;if(R.layers.test(C.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&x===tn)&&(!R.frustumCulled||n.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,R.matrixWorld);const z=e.update(R),X=R.material;if(Array.isArray(X)){const J=z.groups;for(let V=0,te=J.length;V<te;V++){const H=J[V],le=X[H.materialIndex];if(le&&le.visible){const de=y(R,le,E,x);R.onBeforeShadow(i,R,C,I,z,de,H),i.renderBufferDirect(I,null,z,de,R,H),R.onAfterShadow(i,R,C,I,z,de,H)}}}else if(X.visible){const J=y(R,X,E,x);R.onBeforeShadow(i,R,C,I,z,J,null),i.renderBufferDirect(I,null,z,J,R,null),R.onAfterShadow(i,R,C,I,z,J,null)}}const Y=R.children;for(let z=0,X=Y.length;z<X;z++)M(Y[z],C,I,E,x)}function U(R){R.target.removeEventListener("dispose",U);for(const I in c){const E=c[I],x=R.target.uuid;x in E&&(E[x].dispose(),delete E[x])}}}const _p={[ts]:ns,[is]:as,[rs]:os,[li]:ss,[ns]:ts,[as]:is,[os]:rs,[ss]:li};function gp(i,e){function t(){let w=!1;const ae=new ct;let j=null;const fe=new ct(0,0,0,0);return{setMask:function(Q){j!==Q&&!w&&(i.colorMask(Q,Q,Q,Q),j=Q)},setLocked:function(Q){w=Q},setClear:function(Q,K,pe,De,tt){tt===!0&&(Q*=De,K*=De,pe*=De),ae.set(Q,K,pe,De),fe.equals(ae)===!1&&(i.clearColor(Q,K,pe,De),fe.copy(ae))},reset:function(){w=!1,j=null,fe.set(-1,0,0,0)}}}function n(){let w=!1,ae=!1,j=null,fe=null,Q=null;return{setReversed:function(K){if(ae!==K){const pe=e.get("EXT_clip_control");K?pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.ZERO_TO_ONE_EXT):pe.clipControlEXT(pe.LOWER_LEFT_EXT,pe.NEGATIVE_ONE_TO_ONE_EXT),ae=K;const De=Q;Q=null,this.setClear(De)}},getReversed:function(){return ae},setTest:function(K){K?ce(i.DEPTH_TEST):Me(i.DEPTH_TEST)},setMask:function(K){j!==K&&!w&&(i.depthMask(K),j=K)},setFunc:function(K){if(ae&&(K=_p[K]),fe!==K){switch(K){case ts:i.depthFunc(i.NEVER);break;case ns:i.depthFunc(i.ALWAYS);break;case is:i.depthFunc(i.LESS);break;case li:i.depthFunc(i.LEQUAL);break;case rs:i.depthFunc(i.EQUAL);break;case ss:i.depthFunc(i.GEQUAL);break;case as:i.depthFunc(i.GREATER);break;case os:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}fe=K}},setLocked:function(K){w=K},setClear:function(K){Q!==K&&(ae&&(K=1-K),i.clearDepth(K),Q=K)},reset:function(){w=!1,j=null,fe=null,Q=null,ae=!1}}}function r(){let w=!1,ae=null,j=null,fe=null,Q=null,K=null,pe=null,De=null,tt=null;return{setTest:function(Ke){w||(Ke?ce(i.STENCIL_TEST):Me(i.STENCIL_TEST))},setMask:function(Ke){ae!==Ke&&!w&&(i.stencilMask(Ke),ae=Ke)},setFunc:function(Ke,Ft,Zt){(j!==Ke||fe!==Ft||Q!==Zt)&&(i.stencilFunc(Ke,Ft,Zt),j=Ke,fe=Ft,Q=Zt)},setOp:function(Ke,Ft,Zt){(K!==Ke||pe!==Ft||De!==Zt)&&(i.stencilOp(Ke,Ft,Zt),K=Ke,pe=Ft,De=Zt)},setLocked:function(Ke){w=Ke},setClear:function(Ke){tt!==Ke&&(i.clearStencil(Ke),tt=Ke)},reset:function(){w=!1,ae=null,j=null,fe=null,Q=null,K=null,pe=null,De=null,tt=null}}}const s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},d={},f=new WeakMap,m=[],v=null,S=!1,p=null,u=null,A=null,y=null,M=null,U=null,R=null,C=new ze(0,0,0),I=0,E=!1,x=null,P=null,Y=null,z=null,X=null;const J=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let V=!1,te=0;const H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(H)[1]),V=te>=1):H.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),V=te>=2);let le=null,de={};const Ee=i.getParameter(i.SCISSOR_BOX),Fe=i.getParameter(i.VIEWPORT),je=new ct().fromArray(Ee),q=new ct().fromArray(Fe);function ne(w,ae,j,fe){const Q=new Uint8Array(4),K=i.createTexture();i.bindTexture(w,K),i.texParameteri(w,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(w,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pe=0;pe<j;pe++)w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,fe,0,i.RGBA,i.UNSIGNED_BYTE,Q):i.texImage2D(ae+pe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Q);return K}const Se={};Se[i.TEXTURE_2D]=ne(i.TEXTURE_2D,i.TEXTURE_2D,1),Se[i.TEXTURE_CUBE_MAP]=ne(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Se[i.TEXTURE_2D_ARRAY]=ne(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Se[i.TEXTURE_3D]=ne(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ce(i.DEPTH_TEST),a.setFunc(li),qe(!1),et(la),ce(i.CULL_FACE),b(_n);function ce(w){h[w]!==!0&&(i.enable(w),h[w]=!0)}function Me(w){h[w]!==!1&&(i.disable(w),h[w]=!1)}function We(w,ae){return d[w]!==ae?(i.bindFramebuffer(w,ae),d[w]=ae,w===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=ae),w===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Re(w,ae){let j=m,fe=!1;if(w){j=f.get(ae),j===void 0&&(j=[],f.set(ae,j));const Q=w.textures;if(j.length!==Q.length||j[0]!==i.COLOR_ATTACHMENT0){for(let K=0,pe=Q.length;K<pe;K++)j[K]=i.COLOR_ATTACHMENT0+K;j.length=Q.length,fe=!0}}else j[0]!==i.BACK&&(j[0]=i.BACK,fe=!0);fe&&i.drawBuffers(j)}function rt(w){return v!==w?(i.useProgram(w),v=w,!0):!1}const st={[Ln]:i.FUNC_ADD,[vl]:i.FUNC_SUBTRACT,[xl]:i.FUNC_REVERSE_SUBTRACT};st[Sl]=i.MIN,st[Ml]=i.MAX;const Xe={[El]:i.ZERO,[Tl]:i.ONE,[yl]:i.SRC_COLOR,[Qr]:i.SRC_ALPHA,[Pl]:i.SRC_ALPHA_SATURATE,[Rl]:i.DST_COLOR,[bl]:i.DST_ALPHA,[Al]:i.ONE_MINUS_SRC_COLOR,[es]:i.ONE_MINUS_SRC_ALPHA,[Cl]:i.ONE_MINUS_DST_COLOR,[wl]:i.ONE_MINUS_DST_ALPHA,[Ll]:i.CONSTANT_COLOR,[Dl]:i.ONE_MINUS_CONSTANT_COLOR,[Ul]:i.CONSTANT_ALPHA,[Il]:i.ONE_MINUS_CONSTANT_ALPHA};function b(w,ae,j,fe,Q,K,pe,De,tt,Ke){if(w===_n){S===!0&&(Me(i.BLEND),S=!1);return}if(S===!1&&(ce(i.BLEND),S=!0),w!==gl){if(w!==p||Ke!==E){if((u!==Ln||M!==Ln)&&(i.blendEquation(i.FUNC_ADD),u=Ln,M=Ln),Ke)switch(w){case si:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ca:i.blendFunc(i.ONE,i.ONE);break;case ua:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case ha:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}else switch(w){case si:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ca:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ua:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ha:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}A=null,y=null,U=null,R=null,C.set(0,0,0),I=0,p=w,E=Ke}return}Q=Q||ae,K=K||j,pe=pe||fe,(ae!==u||Q!==M)&&(i.blendEquationSeparate(st[ae],st[Q]),u=ae,M=Q),(j!==A||fe!==y||K!==U||pe!==R)&&(i.blendFuncSeparate(Xe[j],Xe[fe],Xe[K],Xe[pe]),A=j,y=fe,U=K,R=pe),(De.equals(C)===!1||tt!==I)&&(i.blendColor(De.r,De.g,De.b,tt),C.copy(De),I=tt),p=w,E=!1}function St(w,ae){w.side===nn?Me(i.CULL_FACE):ce(i.CULL_FACE);let j=w.side===At;ae&&(j=!j),qe(j),w.blending===si&&w.transparent===!1?b(_n):b(w.blending,w.blendEquation,w.blendSrc,w.blendDst,w.blendEquationAlpha,w.blendSrcAlpha,w.blendDstAlpha,w.blendColor,w.blendAlpha,w.premultipliedAlpha),a.setFunc(w.depthFunc),a.setTest(w.depthTest),a.setMask(w.depthWrite),s.setMask(w.colorWrite);const fe=w.stencilWrite;o.setTest(fe),fe&&(o.setMask(w.stencilWriteMask),o.setFunc(w.stencilFunc,w.stencilRef,w.stencilFuncMask),o.setOp(w.stencilFail,w.stencilZFail,w.stencilZPass)),He(w.polygonOffset,w.polygonOffsetFactor,w.polygonOffsetUnits),w.alphaToCoverage===!0?ce(i.SAMPLE_ALPHA_TO_COVERAGE):Me(i.SAMPLE_ALPHA_TO_COVERAGE)}function qe(w){x!==w&&(w?i.frontFace(i.CW):i.frontFace(i.CCW),x=w)}function et(w){w!==pl?(ce(i.CULL_FACE),w!==P&&(w===la?i.cullFace(i.BACK):w===ml?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Me(i.CULL_FACE),P=w}function ge(w){w!==Y&&(V&&i.lineWidth(w),Y=w)}function He(w,ae,j){w?(ce(i.POLYGON_OFFSET_FILL),(z!==ae||X!==j)&&(i.polygonOffset(ae,j),z=ae,X=j)):Me(i.POLYGON_OFFSET_FILL)}function ye(w){w?ce(i.SCISSOR_TEST):Me(i.SCISSOR_TEST)}function Ie(w){w===void 0&&(w=i.TEXTURE0+J-1),le!==w&&(i.activeTexture(w),le=w)}function ht(w,ae,j){j===void 0&&(le===null?j=i.TEXTURE0+J-1:j=le);let fe=de[j];fe===void 0&&(fe={type:void 0,texture:void 0},de[j]=fe),(fe.type!==w||fe.texture!==ae)&&(le!==j&&(i.activeTexture(j),le=j),i.bindTexture(w,ae||Se[w]),fe.type=w,fe.texture=ae)}function T(){const w=de[le];w!==void 0&&w.type!==void 0&&(i.bindTexture(w.type,null),w.type=void 0,w.texture=void 0)}function _(){try{i.compressedTexImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function N(){try{i.compressedTexImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function k(){try{i.texSubImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Z(){try{i.texSubImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function ve(){try{i.compressedTexSubImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function se(){try{i.texStorage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function _e(){try{i.texStorage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function xe(){try{i.texImage2D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function $(){try{i.texImage3D(...arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function ue(w){je.equals(w)===!1&&(i.scissor(w.x,w.y,w.z,w.w),je.copy(w))}function we(w){q.equals(w)===!1&&(i.viewport(w.x,w.y,w.z,w.w),q.copy(w))}function be(w,ae){let j=c.get(ae);j===void 0&&(j=new WeakMap,c.set(ae,j));let fe=j.get(w);fe===void 0&&(fe=i.getUniformBlockIndex(ae,w.name),j.set(w,fe))}function ie(w,ae){const fe=c.get(ae).get(w);l.get(ae)!==fe&&(i.uniformBlockBinding(ae,fe,w.__bindingPointIndex),l.set(ae,fe))}function Le(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),h={},le=null,de={},d={},f=new WeakMap,m=[],v=null,S=!1,p=null,u=null,A=null,y=null,M=null,U=null,R=null,C=new ze(0,0,0),I=0,E=!1,x=null,P=null,Y=null,z=null,X=null,je.set(0,0,i.canvas.width,i.canvas.height),q.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ce,disable:Me,bindFramebuffer:We,drawBuffers:Re,useProgram:rt,setBlending:b,setMaterial:St,setFlipSided:qe,setCullFace:et,setLineWidth:ge,setPolygonOffset:He,setScissorTest:ye,activeTexture:Ie,bindTexture:ht,unbindTexture:T,compressedTexImage2D:_,compressedTexImage3D:N,texImage2D:xe,texImage3D:$,updateUBOMapping:be,uniformBlockBinding:ie,texStorage2D:se,texStorage3D:_e,texSubImage2D:k,texSubImage3D:Z,compressedTexSubImage2D:G,compressedTexSubImage3D:ve,scissor:ue,viewport:we,reset:Le}}function vp(i,e,t,n,r,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ye,h=new WeakMap;let d;const f=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,_){return m?new OffscreenCanvas(T,_):fr("canvas")}function S(T,_,N){let k=1;const Z=ht(T);if((Z.width>N||Z.height>N)&&(k=N/Math.max(Z.width,Z.height)),k<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const G=Math.floor(k*Z.width),ve=Math.floor(k*Z.height);d===void 0&&(d=v(G,ve));const se=_?v(G,ve):d;return se.width=G,se.height=ve,se.getContext("2d").drawImage(T,0,0,G,ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+G+"x"+ve+")."),se}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),T;return T}function p(T){return T.generateMipmaps}function u(T){i.generateMipmap(T)}function A(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function y(T,_,N,k,Z=!1){if(T!==null){if(i[T]!==void 0)return i[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let G=_;if(_===i.RED&&(N===i.FLOAT&&(G=i.R32F),N===i.HALF_FLOAT&&(G=i.R16F),N===i.UNSIGNED_BYTE&&(G=i.R8)),_===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.R8UI),N===i.UNSIGNED_SHORT&&(G=i.R16UI),N===i.UNSIGNED_INT&&(G=i.R32UI),N===i.BYTE&&(G=i.R8I),N===i.SHORT&&(G=i.R16I),N===i.INT&&(G=i.R32I)),_===i.RG&&(N===i.FLOAT&&(G=i.RG32F),N===i.HALF_FLOAT&&(G=i.RG16F),N===i.UNSIGNED_BYTE&&(G=i.RG8)),_===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RG8UI),N===i.UNSIGNED_SHORT&&(G=i.RG16UI),N===i.UNSIGNED_INT&&(G=i.RG32UI),N===i.BYTE&&(G=i.RG8I),N===i.SHORT&&(G=i.RG16I),N===i.INT&&(G=i.RG32I)),_===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RGB8UI),N===i.UNSIGNED_SHORT&&(G=i.RGB16UI),N===i.UNSIGNED_INT&&(G=i.RGB32UI),N===i.BYTE&&(G=i.RGB8I),N===i.SHORT&&(G=i.RGB16I),N===i.INT&&(G=i.RGB32I)),_===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(G=i.RGBA16UI),N===i.UNSIGNED_INT&&(G=i.RGBA32UI),N===i.BYTE&&(G=i.RGBA8I),N===i.SHORT&&(G=i.RGBA16I),N===i.INT&&(G=i.RGBA32I)),_===i.RGB&&N===i.UNSIGNED_INT_5_9_9_9_REV&&(G=i.RGB9_E5),_===i.RGBA){const ve=Z?hr:Ve.getTransfer(k);N===i.FLOAT&&(G=i.RGBA32F),N===i.HALF_FLOAT&&(G=i.RGBA16F),N===i.UNSIGNED_BYTE&&(G=ve===$e?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT_4_4_4_4&&(G=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(G=i.RGB5_A1)}return(G===i.R16F||G===i.R32F||G===i.RG16F||G===i.RG32F||G===i.RGBA16F||G===i.RGBA32F)&&e.get("EXT_color_buffer_float"),G}function M(T,_){let N;return T?_===null||_===Bn||_===yi?N=i.DEPTH24_STENCIL8:_===rn?N=i.DEPTH32F_STENCIL8:_===Ti&&(N=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Bn||_===yi?N=i.DEPTH_COMPONENT24:_===rn?N=i.DEPTH_COMPONENT32F:_===Ti&&(N=i.DEPTH_COMPONENT16),N}function U(T,_){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==kt&&T.minFilter!==Xt?Math.log2(Math.max(_.width,_.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?_.mipmaps.length:1}function R(T){const _=T.target;_.removeEventListener("dispose",R),I(_),_.isVideoTexture&&h.delete(_)}function C(T){const _=T.target;_.removeEventListener("dispose",C),x(_)}function I(T){const _=n.get(T);if(_.__webglInit===void 0)return;const N=T.source,k=f.get(N);if(k){const Z=k[_.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&E(T),Object.keys(k).length===0&&f.delete(N)}n.remove(T)}function E(T){const _=n.get(T);i.deleteTexture(_.__webglTexture);const N=T.source,k=f.get(N);delete k[_.__cacheKey],a.memory.textures--}function x(T){const _=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(_.__webglFramebuffer[k]))for(let Z=0;Z<_.__webglFramebuffer[k].length;Z++)i.deleteFramebuffer(_.__webglFramebuffer[k][Z]);else i.deleteFramebuffer(_.__webglFramebuffer[k]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[k])}else{if(Array.isArray(_.__webglFramebuffer))for(let k=0;k<_.__webglFramebuffer.length;k++)i.deleteFramebuffer(_.__webglFramebuffer[k]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let k=0;k<_.__webglColorRenderbuffer.length;k++)_.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[k]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const N=T.textures;for(let k=0,Z=N.length;k<Z;k++){const G=n.get(N[k]);G.__webglTexture&&(i.deleteTexture(G.__webglTexture),a.memory.textures--),n.remove(N[k])}n.remove(T)}let P=0;function Y(){P=0}function z(){const T=P;return T>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),P+=1,T}function X(T){const _=[];return _.push(T.wrapS),_.push(T.wrapT),_.push(T.wrapR||0),_.push(T.magFilter),_.push(T.minFilter),_.push(T.anisotropy),_.push(T.internalFormat),_.push(T.format),_.push(T.type),_.push(T.generateMipmaps),_.push(T.premultiplyAlpha),_.push(T.flipY),_.push(T.unpackAlignment),_.push(T.colorSpace),_.join()}function J(T,_){const N=n.get(T);if(T.isVideoTexture&&ye(T),T.isRenderTargetTexture===!1&&T.version>0&&N.__version!==T.version){const k=T.image;if(k===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Se(N,T,_);return}}t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+_)}function V(T,_){const N=n.get(T);if(T.version>0&&N.__version!==T.version){Se(N,T,_);return}t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+_)}function te(T,_){const N=n.get(T);if(T.version>0&&N.__version!==T.version){Se(N,T,_);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+_)}function H(T,_){const N=n.get(T);if(T.version>0&&N.__version!==T.version){ce(N,T,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+_)}const le={[us]:i.REPEAT,[In]:i.CLAMP_TO_EDGE,[hs]:i.MIRRORED_REPEAT},de={[kt]:i.NEAREST,[Wl]:i.NEAREST_MIPMAP_NEAREST,[Fi]:i.NEAREST_MIPMAP_LINEAR,[Xt]:i.LINEAR,[Mr]:i.LINEAR_MIPMAP_NEAREST,[Nn]:i.LINEAR_MIPMAP_LINEAR},Ee={[Zl]:i.NEVER,[tc]:i.ALWAYS,[$l]:i.LESS,[Ao]:i.LEQUAL,[jl]:i.EQUAL,[ec]:i.GEQUAL,[Jl]:i.GREATER,[Ql]:i.NOTEQUAL};function Fe(T,_){if(_.type===rn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Xt||_.magFilter===Mr||_.magFilter===Fi||_.magFilter===Nn||_.minFilter===Xt||_.minFilter===Mr||_.minFilter===Fi||_.minFilter===Nn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,le[_.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,le[_.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,le[_.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,de[_.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,de[_.minFilter]),_.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Ee[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===kt||_.minFilter!==Fi&&_.minFilter!==Nn||_.type===rn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function je(T,_){let N=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",R));const k=_.source;let Z=f.get(k);Z===void 0&&(Z={},f.set(k,Z));const G=X(_);if(G!==T.__cacheKey){Z[G]===void 0&&(Z[G]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),Z[G].usedTimes++;const ve=Z[T.__cacheKey];ve!==void 0&&(Z[T.__cacheKey].usedTimes--,ve.usedTimes===0&&E(_)),T.__cacheKey=G,T.__webglTexture=Z[G].texture}return N}function q(T,_,N){return Math.floor(Math.floor(T/N)/_)}function ne(T,_,N,k){const G=T.updateRanges;if(G.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,N,k,_.data);else{G.sort(($,ue)=>$.start-ue.start);let ve=0;for(let $=1;$<G.length;$++){const ue=G[ve],we=G[$],be=ue.start+ue.count,ie=q(we.start,_.width,4),Le=q(ue.start,_.width,4);we.start<=be+1&&ie===Le&&q(we.start+we.count-1,_.width,4)===ie?ue.count=Math.max(ue.count,we.start+we.count-ue.start):(++ve,G[ve]=we)}G.length=ve+1;const se=i.getParameter(i.UNPACK_ROW_LENGTH),_e=i.getParameter(i.UNPACK_SKIP_PIXELS),xe=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let $=0,ue=G.length;$<ue;$++){const we=G[$],be=Math.floor(we.start/4),ie=Math.ceil(we.count/4),Le=be%_.width,w=Math.floor(be/_.width),ae=ie,j=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Le),i.pixelStorei(i.UNPACK_SKIP_ROWS,w),t.texSubImage2D(i.TEXTURE_2D,0,Le,w,ae,j,N,k,_.data)}T.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,se),i.pixelStorei(i.UNPACK_SKIP_PIXELS,_e),i.pixelStorei(i.UNPACK_SKIP_ROWS,xe)}}function Se(T,_,N){let k=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(k=i.TEXTURE_3D);const Z=je(T,_),G=_.source;t.bindTexture(k,T.__webglTexture,i.TEXTURE0+N);const ve=n.get(G);if(G.version!==ve.__version||Z===!0){t.activeTexture(i.TEXTURE0+N);const se=Ve.getPrimaries(Ve.workingColorSpace),_e=_.colorSpace===pn?null:Ve.getPrimaries(_.colorSpace),xe=_.colorSpace===pn||se===_e?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xe);let $=S(_.image,!1,r.maxTextureSize);$=Ie(_,$);const ue=s.convert(_.format,_.colorSpace),we=s.convert(_.type);let be=y(_.internalFormat,ue,we,_.colorSpace,_.isVideoTexture);Fe(k,_);let ie;const Le=_.mipmaps,w=_.isVideoTexture!==!0,ae=ve.__version===void 0||Z===!0,j=G.dataReady,fe=U(_,$);if(_.isDepthTexture)be=M(_.format===bi,_.type),ae&&(w?t.texStorage2D(i.TEXTURE_2D,1,be,$.width,$.height):t.texImage2D(i.TEXTURE_2D,0,be,$.width,$.height,0,ue,we,null));else if(_.isDataTexture)if(Le.length>0){w&&ae&&t.texStorage2D(i.TEXTURE_2D,fe,be,Le[0].width,Le[0].height);for(let Q=0,K=Le.length;Q<K;Q++)ie=Le[Q],w?j&&t.texSubImage2D(i.TEXTURE_2D,Q,0,0,ie.width,ie.height,ue,we,ie.data):t.texImage2D(i.TEXTURE_2D,Q,be,ie.width,ie.height,0,ue,we,ie.data);_.generateMipmaps=!1}else w?(ae&&t.texStorage2D(i.TEXTURE_2D,fe,be,$.width,$.height),j&&ne(_,$,ue,we)):t.texImage2D(i.TEXTURE_2D,0,be,$.width,$.height,0,ue,we,$.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){w&&ae&&t.texStorage3D(i.TEXTURE_2D_ARRAY,fe,be,Le[0].width,Le[0].height,$.depth);for(let Q=0,K=Le.length;Q<K;Q++)if(ie=Le[Q],_.format!==Gt)if(ue!==null)if(w){if(j)if(_.layerUpdates.size>0){const pe=Ia(ie.width,ie.height,_.format,_.type);for(const De of _.layerUpdates){const tt=ie.data.subarray(De*pe/ie.data.BYTES_PER_ELEMENT,(De+1)*pe/ie.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Q,0,0,De,ie.width,ie.height,1,ue,tt)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Q,0,0,0,ie.width,ie.height,$.depth,ue,ie.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Q,be,ie.width,ie.height,$.depth,0,ie.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?j&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Q,0,0,0,ie.width,ie.height,$.depth,ue,we,ie.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Q,be,ie.width,ie.height,$.depth,0,ue,we,ie.data)}else{w&&ae&&t.texStorage2D(i.TEXTURE_2D,fe,be,Le[0].width,Le[0].height);for(let Q=0,K=Le.length;Q<K;Q++)ie=Le[Q],_.format!==Gt?ue!==null?w?j&&t.compressedTexSubImage2D(i.TEXTURE_2D,Q,0,0,ie.width,ie.height,ue,ie.data):t.compressedTexImage2D(i.TEXTURE_2D,Q,be,ie.width,ie.height,0,ie.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):w?j&&t.texSubImage2D(i.TEXTURE_2D,Q,0,0,ie.width,ie.height,ue,we,ie.data):t.texImage2D(i.TEXTURE_2D,Q,be,ie.width,ie.height,0,ue,we,ie.data)}else if(_.isDataArrayTexture)if(w){if(ae&&t.texStorage3D(i.TEXTURE_2D_ARRAY,fe,be,$.width,$.height,$.depth),j)if(_.layerUpdates.size>0){const Q=Ia($.width,$.height,_.format,_.type);for(const K of _.layerUpdates){const pe=$.data.subarray(K*Q/$.data.BYTES_PER_ELEMENT,(K+1)*Q/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,K,$.width,$.height,1,ue,we,pe)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ue,we,$.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,be,$.width,$.height,$.depth,0,ue,we,$.data);else if(_.isData3DTexture)w?(ae&&t.texStorage3D(i.TEXTURE_3D,fe,be,$.width,$.height,$.depth),j&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ue,we,$.data)):t.texImage3D(i.TEXTURE_3D,0,be,$.width,$.height,$.depth,0,ue,we,$.data);else if(_.isFramebufferTexture){if(ae)if(w)t.texStorage2D(i.TEXTURE_2D,fe,be,$.width,$.height);else{let Q=$.width,K=$.height;for(let pe=0;pe<fe;pe++)t.texImage2D(i.TEXTURE_2D,pe,be,Q,K,0,ue,we,null),Q>>=1,K>>=1}}else if(Le.length>0){if(w&&ae){const Q=ht(Le[0]);t.texStorage2D(i.TEXTURE_2D,fe,be,Q.width,Q.height)}for(let Q=0,K=Le.length;Q<K;Q++)ie=Le[Q],w?j&&t.texSubImage2D(i.TEXTURE_2D,Q,0,0,ue,we,ie):t.texImage2D(i.TEXTURE_2D,Q,be,ue,we,ie);_.generateMipmaps=!1}else if(w){if(ae){const Q=ht($);t.texStorage2D(i.TEXTURE_2D,fe,be,Q.width,Q.height)}j&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ue,we,$)}else t.texImage2D(i.TEXTURE_2D,0,be,ue,we,$);p(_)&&u(k),ve.__version=G.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function ce(T,_,N){if(_.image.length!==6)return;const k=je(T,_),Z=_.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+N);const G=n.get(Z);if(Z.version!==G.__version||k===!0){t.activeTexture(i.TEXTURE0+N);const ve=Ve.getPrimaries(Ve.workingColorSpace),se=_.colorSpace===pn?null:Ve.getPrimaries(_.colorSpace),_e=_.colorSpace===pn||ve===se?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);const xe=_.isCompressedTexture||_.image[0].isCompressedTexture,$=_.image[0]&&_.image[0].isDataTexture,ue=[];for(let K=0;K<6;K++)!xe&&!$?ue[K]=S(_.image[K],!0,r.maxCubemapSize):ue[K]=$?_.image[K].image:_.image[K],ue[K]=Ie(_,ue[K]);const we=ue[0],be=s.convert(_.format,_.colorSpace),ie=s.convert(_.type),Le=y(_.internalFormat,be,ie,_.colorSpace),w=_.isVideoTexture!==!0,ae=G.__version===void 0||k===!0,j=Z.dataReady;let fe=U(_,we);Fe(i.TEXTURE_CUBE_MAP,_);let Q;if(xe){w&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,fe,Le,we.width,we.height);for(let K=0;K<6;K++){Q=ue[K].mipmaps;for(let pe=0;pe<Q.length;pe++){const De=Q[pe];_.format!==Gt?be!==null?w?j&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe,0,0,De.width,De.height,be,De.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe,Le,De.width,De.height,0,De.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):w?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe,0,0,De.width,De.height,be,ie,De.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe,Le,De.width,De.height,0,be,ie,De.data)}}}else{if(Q=_.mipmaps,w&&ae){Q.length>0&&fe++;const K=ht(ue[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,fe,Le,K.width,K.height)}for(let K=0;K<6;K++)if($){w?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,ue[K].width,ue[K].height,be,ie,ue[K].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Le,ue[K].width,ue[K].height,0,be,ie,ue[K].data);for(let pe=0;pe<Q.length;pe++){const tt=Q[pe].image[K].image;w?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe+1,0,0,tt.width,tt.height,be,ie,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe+1,Le,tt.width,tt.height,0,be,ie,tt.data)}}else{w?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,be,ie,ue[K]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Le,be,ie,ue[K]);for(let pe=0;pe<Q.length;pe++){const De=Q[pe];w?j&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe+1,0,0,be,ie,De.image[K]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,pe+1,Le,be,ie,De.image[K])}}}p(_)&&u(i.TEXTURE_CUBE_MAP),G.__version=Z.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function Me(T,_,N,k,Z,G){const ve=s.convert(N.format,N.colorSpace),se=s.convert(N.type),_e=y(N.internalFormat,ve,se,N.colorSpace),xe=n.get(_),$=n.get(N);if($.__renderTarget=_,!xe.__hasExternalTextures){const ue=Math.max(1,_.width>>G),we=Math.max(1,_.height>>G);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?t.texImage3D(Z,G,_e,ue,we,_.depth,0,ve,se,null):t.texImage2D(Z,G,_e,ue,we,0,ve,se,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),He(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,Z,$.__webglTexture,0,ge(_)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,Z,$.__webglTexture,G),t.bindFramebuffer(i.FRAMEBUFFER,null)}function We(T,_,N){if(i.bindRenderbuffer(i.RENDERBUFFER,T),_.depthBuffer){const k=_.depthTexture,Z=k&&k.isDepthTexture?k.type:null,G=M(_.stencilBuffer,Z),ve=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=ge(_);He(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,se,G,_.width,_.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,se,G,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,G,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ve,i.RENDERBUFFER,T)}else{const k=_.textures;for(let Z=0;Z<k.length;Z++){const G=k[Z],ve=s.convert(G.format,G.colorSpace),se=s.convert(G.type),_e=y(G.internalFormat,ve,se,G.colorSpace),xe=ge(_);N&&He(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,xe,_e,_.width,_.height):He(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xe,_e,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,_e,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Re(T,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const k=n.get(_.depthTexture);k.__renderTarget=_,(!k.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),J(_.depthTexture,0);const Z=k.__webglTexture,G=ge(_);if(_.depthTexture.format===Ai)He(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,G):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(_.depthTexture.format===bi)He(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,G):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function rt(T){const _=n.get(T),N=T.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==T.depthTexture){const k=T.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),k){const Z=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,k.removeEventListener("dispose",Z)};k.addEventListener("dispose",Z),_.__depthDisposeCallback=Z}_.__boundDepthTexture=k}if(T.depthTexture&&!_.__autoAllocateDepthBuffer){if(N)throw new Error("target.depthTexture not supported in Cube render targets");const k=T.texture.mipmaps;k&&k.length>0?Re(_.__webglFramebuffer[0],T):Re(_.__webglFramebuffer,T)}else if(N){_.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[k]),_.__webglDepthbuffer[k]===void 0)_.__webglDepthbuffer[k]=i.createRenderbuffer(),We(_.__webglDepthbuffer[k],T,!1);else{const Z=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,G=_.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,G),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,G)}}else{const k=T.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),We(_.__webglDepthbuffer,T,!1);else{const Z=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,G=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,G),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,G)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function st(T,_,N){const k=n.get(T);_!==void 0&&Me(k.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&rt(T)}function Xe(T){const _=T.texture,N=n.get(T),k=n.get(_);T.addEventListener("dispose",C);const Z=T.textures,G=T.isWebGLCubeRenderTarget===!0,ve=Z.length>1;if(ve||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=_.version,a.memory.textures++),G){N.__webglFramebuffer=[];for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0){N.__webglFramebuffer[se]=[];for(let _e=0;_e<_.mipmaps.length;_e++)N.__webglFramebuffer[se][_e]=i.createFramebuffer()}else N.__webglFramebuffer[se]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){N.__webglFramebuffer=[];for(let se=0;se<_.mipmaps.length;se++)N.__webglFramebuffer[se]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(ve)for(let se=0,_e=Z.length;se<_e;se++){const xe=n.get(Z[se]);xe.__webglTexture===void 0&&(xe.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&He(T)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let se=0;se<Z.length;se++){const _e=Z[se];N.__webglColorRenderbuffer[se]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[se]);const xe=s.convert(_e.format,_e.colorSpace),$=s.convert(_e.type),ue=y(_e.internalFormat,xe,$,_e.colorSpace,T.isXRRenderTarget===!0),we=ge(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,we,ue,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+se,i.RENDERBUFFER,N.__webglColorRenderbuffer[se])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),We(N.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(G){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Fe(i.TEXTURE_CUBE_MAP,_);for(let se=0;se<6;se++)if(_.mipmaps&&_.mipmaps.length>0)for(let _e=0;_e<_.mipmaps.length;_e++)Me(N.__webglFramebuffer[se][_e],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+se,_e);else Me(N.__webglFramebuffer[se],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+se,0);p(_)&&u(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ve){for(let se=0,_e=Z.length;se<_e;se++){const xe=Z[se],$=n.get(xe);t.bindTexture(i.TEXTURE_2D,$.__webglTexture),Fe(i.TEXTURE_2D,xe),Me(N.__webglFramebuffer,T,xe,i.COLOR_ATTACHMENT0+se,i.TEXTURE_2D,0),p(xe)&&u(i.TEXTURE_2D)}t.unbindTexture()}else{let se=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(se=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(se,k.__webglTexture),Fe(se,_),_.mipmaps&&_.mipmaps.length>0)for(let _e=0;_e<_.mipmaps.length;_e++)Me(N.__webglFramebuffer[_e],T,_,i.COLOR_ATTACHMENT0,se,_e);else Me(N.__webglFramebuffer,T,_,i.COLOR_ATTACHMENT0,se,0);p(_)&&u(se),t.unbindTexture()}T.depthBuffer&&rt(T)}function b(T){const _=T.textures;for(let N=0,k=_.length;N<k;N++){const Z=_[N];if(p(Z)){const G=A(T),ve=n.get(Z).__webglTexture;t.bindTexture(G,ve),u(G),t.unbindTexture()}}}const St=[],qe=[];function et(T){if(T.samples>0){if(He(T)===!1){const _=T.textures,N=T.width,k=T.height;let Z=i.COLOR_BUFFER_BIT;const G=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ve=n.get(T),se=_.length>1;if(se)for(let xe=0;xe<_.length;xe++)t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ve.__webglMultisampledFramebuffer);const _e=T.texture.mipmaps;_e&&_e.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ve.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ve.__webglFramebuffer);for(let xe=0;xe<_.length;xe++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),se){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ve.__webglColorRenderbuffer[xe]);const $=n.get(_[xe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,$,0)}i.blitFramebuffer(0,0,N,k,0,0,N,k,Z,i.NEAREST),l===!0&&(St.length=0,qe.length=0,St.push(i.COLOR_ATTACHMENT0+xe),T.depthBuffer&&T.resolveDepthBuffer===!1&&(St.push(G),qe.push(G),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,qe)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,St))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),se)for(let xe=0;xe<_.length;xe++){t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.RENDERBUFFER,ve.__webglColorRenderbuffer[xe]);const $=n.get(_[xe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ve.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xe,i.TEXTURE_2D,$,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ve.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const _=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ge(T){return Math.min(r.maxSamples,T.samples)}function He(T){const _=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function ye(T){const _=a.render.frame;h.get(T)!==_&&(h.set(T,_),T.update())}function Ie(T,_){const N=T.colorSpace,k=T.format,Z=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||N!==hi&&N!==pn&&(Ve.getTransfer(N)===$e?(k!==Gt||Z!==Kt)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",N)),_}function ht(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=Y,this.setTexture2D=J,this.setTexture2DArray=V,this.setTexture3D=te,this.setTextureCube=H,this.rebindTextures=st,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=b,this.updateMultisampleRenderTarget=et,this.setupDepthRenderbuffer=rt,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=He}function xp(i,e){function t(n,r=pn){let s;const a=Ve.getTransfer(r);if(n===Kt)return i.UNSIGNED_BYTE;if(n===ks)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ws)return i.UNSIGNED_SHORT_5_5_5_1;if(n===xo)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===go)return i.BYTE;if(n===vo)return i.SHORT;if(n===Ti)return i.UNSIGNED_SHORT;if(n===Vs)return i.INT;if(n===Bn)return i.UNSIGNED_INT;if(n===rn)return i.FLOAT;if(n===Ri)return i.HALF_FLOAT;if(n===So)return i.ALPHA;if(n===Mo)return i.RGB;if(n===Gt)return i.RGBA;if(n===Ai)return i.DEPTH_COMPONENT;if(n===bi)return i.DEPTH_STENCIL;if(n===Eo)return i.RED;if(n===Xs)return i.RED_INTEGER;if(n===To)return i.RG;if(n===qs)return i.RG_INTEGER;if(n===Ys)return i.RGBA_INTEGER;if(n===sr||n===ar||n===or||n===lr)if(a===$e)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===sr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ar)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===or)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===lr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===sr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ar)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===or)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===lr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ds||n===fs||n===ps||n===ms)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ds)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===fs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ps)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ms)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===_s||n===gs||n===vs)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===_s||n===gs)return a===$e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===vs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xs||n===Ss||n===Ms||n===Es||n===Ts||n===ys||n===As||n===bs||n===ws||n===Rs||n===Cs||n===Ps||n===Ls||n===Ds)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===xs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ss)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ms)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Es)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ts)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ys)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===As)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===bs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ws)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Rs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Cs)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ps)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ls)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ds)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===cr||n===Us||n===Is)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===cr)return a===$e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Us)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Is)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===yo||n===Ns||n===Fs||n===Os)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===cr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ns)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fs)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Os)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===yi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Sp=`
3796
+ void main() {
3797
+
3798
+ gl_Position = vec4( position, 1.0 );
3799
+
3800
+ }`,Mp=`
3801
+ uniform sampler2DArray depthColor;
3802
+ uniform float depthWidth;
3803
+ uniform float depthHeight;
3804
+
3805
+ void main() {
3806
+
3807
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3808
+
3809
+ if ( coord.x >= 1.0 ) {
3810
+
3811
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3812
+
3813
+ } else {
3814
+
3815
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3816
+
3817
+ }
3818
+
3819
+ }`;class Ep{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const r=new bt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new xn({vertexShader:Sp,fragmentShader:Mp,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new qt(new Ui(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Tp extends Hn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,f=null,m=null,v=null;const S=new Ep,p=t.getContextAttributes();let u=null,A=null;const y=[],M=[],U=new Ye;let R=null;const C=new Nt;C.viewport=new ct;const I=new Nt;I.viewport=new ct;const E=[C,I],x=new kc;let P=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let ne=y[q];return ne===void 0&&(ne=new Wr,y[q]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(q){let ne=y[q];return ne===void 0&&(ne=new Wr,y[q]=ne),ne.getGripSpace()},this.getHand=function(q){let ne=y[q];return ne===void 0&&(ne=new Wr,y[q]=ne),ne.getHandSpace()};function z(q){const ne=M.indexOf(q.inputSource);if(ne===-1)return;const Se=y[ne];Se!==void 0&&(Se.update(q.inputSource,q.frame,c||a),Se.dispatchEvent({type:q.type,data:q.inputSource}))}function X(){r.removeEventListener("select",z),r.removeEventListener("selectstart",z),r.removeEventListener("selectend",z),r.removeEventListener("squeeze",z),r.removeEventListener("squeezestart",z),r.removeEventListener("squeezeend",z),r.removeEventListener("end",X),r.removeEventListener("inputsourceschange",J);for(let q=0;q<y.length;q++){const ne=M[q];ne!==null&&(M[q]=null,y[q].disconnect(ne))}P=null,Y=null,S.reset(),e.setRenderTarget(u),m=null,f=null,d=null,r=null,A=null,je.stop(),n.isPresenting=!1,e.setPixelRatio(R),e.setSize(U.width,U.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){s=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(q){c=q},this.getBaseLayer=function(){return f!==null?f:m},this.getBinding=function(){return d},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=async function(q){if(r=q,r!==null){if(u=e.getRenderTarget(),r.addEventListener("select",z),r.addEventListener("selectstart",z),r.addEventListener("selectend",z),r.addEventListener("squeeze",z),r.addEventListener("squeezestart",z),r.addEventListener("squeezeend",z),r.addEventListener("end",X),r.addEventListener("inputsourceschange",J),p.xrCompatible!==!0&&await t.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(U),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let Se=null,ce=null,Me=null;p.depth&&(Me=p.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Se=p.stencil?bi:Ai,ce=p.stencil?yi:Bn);const We={colorFormat:t.RGBA8,depthFormat:Me,scaleFactor:s};d=new XRWebGLBinding(r,t),f=d.createProjectionLayer(We),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),A=new zn(f.textureWidth,f.textureHeight,{format:Gt,type:Kt,depthTexture:new Fo(f.textureWidth,f.textureHeight,ce,void 0,void 0,void 0,void 0,void 0,void 0,Se),stencilBuffer:p.stencil,colorSpace:e.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{const Se={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,Se),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new zn(m.framebufferWidth,m.framebufferHeight,{format:Gt,type:Kt,colorSpace:e.outputColorSpace,stencilBuffer:p.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),je.setContext(r),je.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return S.getDepthTexture()};function J(q){for(let ne=0;ne<q.removed.length;ne++){const Se=q.removed[ne],ce=M.indexOf(Se);ce>=0&&(M[ce]=null,y[ce].disconnect(Se))}for(let ne=0;ne<q.added.length;ne++){const Se=q.added[ne];let ce=M.indexOf(Se);if(ce===-1){for(let We=0;We<y.length;We++)if(We>=M.length){M.push(Se),ce=We;break}else if(M[We]===null){M[We]=Se,ce=We;break}if(ce===-1)break}const Me=y[ce];Me&&Me.connect(Se)}}const V=new F,te=new F;function H(q,ne,Se){V.setFromMatrixPosition(ne.matrixWorld),te.setFromMatrixPosition(Se.matrixWorld);const ce=V.distanceTo(te),Me=ne.projectionMatrix.elements,We=Se.projectionMatrix.elements,Re=Me[14]/(Me[10]-1),rt=Me[14]/(Me[10]+1),st=(Me[9]+1)/Me[5],Xe=(Me[9]-1)/Me[5],b=(Me[8]-1)/Me[0],St=(We[8]+1)/We[0],qe=Re*b,et=Re*St,ge=ce/(-b+St),He=ge*-b;if(ne.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(He),q.translateZ(ge),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Me[10]===-1)q.projectionMatrix.copy(ne.projectionMatrix),q.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ye=Re+ge,Ie=rt+ge,ht=qe-He,T=et+(ce-He),_=st*rt/Ie*ye,N=Xe*rt/Ie*ye;q.projectionMatrix.makePerspective(ht,T,_,N,ye,Ie),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function le(q,ne){ne===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(ne.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(r===null)return;let ne=q.near,Se=q.far;S.texture!==null&&(S.depthNear>0&&(ne=S.depthNear),S.depthFar>0&&(Se=S.depthFar)),x.near=I.near=C.near=ne,x.far=I.far=C.far=Se,(P!==x.near||Y!==x.far)&&(r.updateRenderState({depthNear:x.near,depthFar:x.far}),P=x.near,Y=x.far),C.layers.mask=q.layers.mask|2,I.layers.mask=q.layers.mask|4,x.layers.mask=C.layers.mask|I.layers.mask;const ce=q.parent,Me=x.cameras;le(x,ce);for(let We=0;We<Me.length;We++)le(Me[We],ce);Me.length===2?H(x,C,I):x.projectionMatrix.copy(C.projectionMatrix),de(q,x,ce)};function de(q,ne,Se){Se===null?q.matrix.copy(ne.matrixWorld):(q.matrix.copy(Se.matrixWorld),q.matrix.invert(),q.matrix.multiply(ne.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(ne.projectionMatrix),q.projectionMatrixInverse.copy(ne.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=Bs*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return x},this.getFoveation=function(){if(!(f===null&&m===null))return l},this.setFoveation=function(q){l=q,f!==null&&(f.fixedFoveation=q),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=q)},this.hasDepthSensing=function(){return S.texture!==null},this.getDepthSensingMesh=function(){return S.getMesh(x)};let Ee=null;function Fe(q,ne){if(h=ne.getViewerPose(c||a),v=ne,h!==null){const Se=h.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let ce=!1;Se.length!==x.cameras.length&&(x.cameras.length=0,ce=!0);for(let Re=0;Re<Se.length;Re++){const rt=Se[Re];let st=null;if(m!==null)st=m.getViewport(rt);else{const b=d.getViewSubImage(f,rt);st=b.viewport,Re===0&&(e.setRenderTargetTextures(A,b.colorTexture,b.depthStencilTexture),e.setRenderTarget(A))}let Xe=E[Re];Xe===void 0&&(Xe=new Nt,Xe.layers.enable(Re),Xe.viewport=new ct,E[Re]=Xe),Xe.matrix.fromArray(rt.transform.matrix),Xe.matrix.decompose(Xe.position,Xe.quaternion,Xe.scale),Xe.projectionMatrix.fromArray(rt.projectionMatrix),Xe.projectionMatrixInverse.copy(Xe.projectionMatrix).invert(),Xe.viewport.set(st.x,st.y,st.width,st.height),Re===0&&(x.matrix.copy(Xe.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale)),ce===!0&&x.cameras.push(Xe)}const Me=r.enabledFeatures;if(Me&&Me.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&d){const Re=d.getDepthInformation(Se[0]);Re&&Re.isValid&&Re.texture&&S.init(e,Re,r.renderState)}}for(let Se=0;Se<y.length;Se++){const ce=M[Se],Me=y[Se];ce!==null&&Me!==void 0&&Me.update(ce,ne,c||a)}Ee&&Ee(q,ne),ne.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ne}),v=null}const je=new zo;je.setAnimationLoop(Fe),this.setAnimationLoop=function(q){Ee=q},this.dispose=function(){}}}const wn=new on,yp=new ke;function Ap(i,e){function t(p,u){p.matrixAutoUpdate===!0&&p.updateMatrix(),u.value.copy(p.matrix)}function n(p,u){u.color.getRGB(p.fogColor.value,Uo(i)),u.isFog?(p.fogNear.value=u.near,p.fogFar.value=u.far):u.isFogExp2&&(p.fogDensity.value=u.density)}function r(p,u,A,y,M){u.isMeshBasicMaterial||u.isMeshLambertMaterial?s(p,u):u.isMeshToonMaterial?(s(p,u),d(p,u)):u.isMeshPhongMaterial?(s(p,u),h(p,u)):u.isMeshStandardMaterial?(s(p,u),f(p,u),u.isMeshPhysicalMaterial&&m(p,u,M)):u.isMeshMatcapMaterial?(s(p,u),v(p,u)):u.isMeshDepthMaterial?s(p,u):u.isMeshDistanceMaterial?(s(p,u),S(p,u)):u.isMeshNormalMaterial?s(p,u):u.isLineBasicMaterial?(a(p,u),u.isLineDashedMaterial&&o(p,u)):u.isPointsMaterial?l(p,u,A,y):u.isSpriteMaterial?c(p,u):u.isShadowMaterial?(p.color.value.copy(u.color),p.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function s(p,u){p.opacity.value=u.opacity,u.color&&p.diffuse.value.copy(u.color),u.emissive&&p.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.bumpMap&&(p.bumpMap.value=u.bumpMap,t(u.bumpMap,p.bumpMapTransform),p.bumpScale.value=u.bumpScale,u.side===At&&(p.bumpScale.value*=-1)),u.normalMap&&(p.normalMap.value=u.normalMap,t(u.normalMap,p.normalMapTransform),p.normalScale.value.copy(u.normalScale),u.side===At&&p.normalScale.value.negate()),u.displacementMap&&(p.displacementMap.value=u.displacementMap,t(u.displacementMap,p.displacementMapTransform),p.displacementScale.value=u.displacementScale,p.displacementBias.value=u.displacementBias),u.emissiveMap&&(p.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,p.emissiveMapTransform)),u.specularMap&&(p.specularMap.value=u.specularMap,t(u.specularMap,p.specularMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest);const A=e.get(u),y=A.envMap,M=A.envMapRotation;y&&(p.envMap.value=y,wn.copy(M),wn.x*=-1,wn.y*=-1,wn.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(wn.y*=-1,wn.z*=-1),p.envMapRotation.value.setFromMatrix4(yp.makeRotationFromEuler(wn)),p.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap&&(p.lightMap.value=u.lightMap,p.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,p.lightMapTransform)),u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function l(p,u,A,y){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*A,p.scale.value=y*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function c(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function h(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function d(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function f(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),u.envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function m(p,u,A){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===At&&p.clearcoatNormalScale.value.negate())),u.dispersion>0&&(p.dispersion.value=u.dispersion),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=A.texture,p.transmissionSamplerSize.value.set(A.width,A.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function v(p,u){u.matcap&&(p.matcap.value=u.matcap)}function S(p,u){const A=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(A.matrixWorld),p.nearDistance.value=A.shadow.camera.near,p.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function bp(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(A,y){const M=y.program;n.uniformBlockBinding(A,M)}function c(A,y){let M=r[A.id];M===void 0&&(v(A),M=h(A),r[A.id]=M,A.addEventListener("dispose",p));const U=y.program;n.updateUBOMapping(A,U);const R=e.render.frame;s[A.id]!==R&&(f(A),s[A.id]=R)}function h(A){const y=d();A.__bindingPointIndex=y;const M=i.createBuffer(),U=A.__size,R=A.usage;return i.bindBuffer(i.UNIFORM_BUFFER,M),i.bufferData(i.UNIFORM_BUFFER,U,R),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,M),M}function d(){for(let A=0;A<o;A++)if(a.indexOf(A)===-1)return a.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(A){const y=r[A.id],M=A.uniforms,U=A.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let R=0,C=M.length;R<C;R++){const I=Array.isArray(M[R])?M[R]:[M[R]];for(let E=0,x=I.length;E<x;E++){const P=I[E];if(m(P,R,E,U)===!0){const Y=P.__offset,z=Array.isArray(P.value)?P.value:[P.value];let X=0;for(let J=0;J<z.length;J++){const V=z[J],te=S(V);typeof V=="number"||typeof V=="boolean"?(P.__data[0]=V,i.bufferSubData(i.UNIFORM_BUFFER,Y+X,P.__data)):V.isMatrix3?(P.__data[0]=V.elements[0],P.__data[1]=V.elements[1],P.__data[2]=V.elements[2],P.__data[3]=0,P.__data[4]=V.elements[3],P.__data[5]=V.elements[4],P.__data[6]=V.elements[5],P.__data[7]=0,P.__data[8]=V.elements[6],P.__data[9]=V.elements[7],P.__data[10]=V.elements[8],P.__data[11]=0):(V.toArray(P.__data,X),X+=te.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,Y,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(A,y,M,U){const R=A.value,C=y+"_"+M;if(U[C]===void 0)return typeof R=="number"||typeof R=="boolean"?U[C]=R:U[C]=R.clone(),!0;{const I=U[C];if(typeof R=="number"||typeof R=="boolean"){if(I!==R)return U[C]=R,!0}else if(I.equals(R)===!1)return I.copy(R),!0}return!1}function v(A){const y=A.uniforms;let M=0;const U=16;for(let C=0,I=y.length;C<I;C++){const E=Array.isArray(y[C])?y[C]:[y[C]];for(let x=0,P=E.length;x<P;x++){const Y=E[x],z=Array.isArray(Y.value)?Y.value:[Y.value];for(let X=0,J=z.length;X<J;X++){const V=z[X],te=S(V),H=M%U,le=H%te.boundary,de=H+le;M+=le,de!==0&&U-de<te.storage&&(M+=U-de),Y.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),Y.__offset=M,M+=te.storage}}}const R=M%U;return R>0&&(M+=U-R),A.__size=M,A.__cache={},this}function S(A){const y={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(y.boundary=4,y.storage=4):A.isVector2?(y.boundary=8,y.storage=8):A.isVector3||A.isColor?(y.boundary=16,y.storage=12):A.isVector4?(y.boundary=16,y.storage=16):A.isMatrix3?(y.boundary=48,y.storage=48):A.isMatrix4?(y.boundary=64,y.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),y}function p(A){const y=A.target;y.removeEventListener("dispose",p);const M=a.indexOf(y.__bindingPointIndex);a.splice(M,1),i.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function u(){for(const A in r)i.deleteBuffer(r[A]);a=[],r={},s={}}return{bind:l,update:c,dispose:u}}class wp{constructor(e={}){const{canvas:t=ic(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reverseDepthBuffer:f=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=a;const v=new Uint32Array(4),S=new Int32Array(4);let p=null,u=null;const A=[],y=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=gn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const M=this;let U=!1;this._outputColorSpace=It;let R=0,C=0,I=null,E=-1,x=null;const P=new ct,Y=new ct;let z=null;const X=new ze(0);let J=0,V=t.width,te=t.height,H=1,le=null,de=null;const Ee=new ct(0,0,V,te),Fe=new ct(0,0,V,te);let je=!1;const q=new $s;let ne=!1,Se=!1;const ce=new ke,Me=new ke,We=new F,Re=new ct,rt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let st=!1;function Xe(){return I===null?H:1}let b=n;function St(g,L){return t.getContext(g,L)}try{const g={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Gs}`),t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",Q,!1),t.addEventListener("webglcontextcreationerror",K,!1),b===null){const L="webgl2";if(b=St(L,g),b===null)throw St(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(g){throw console.error("THREE.WebGLRenderer: "+g.message),g}let qe,et,ge,He,ye,Ie,ht,T,_,N,k,Z,G,ve,se,_e,xe,$,ue,we,be,ie,Le,w;function ae(){qe=new Fd(b),qe.init(),ie=new xp(b,qe),et=new Cd(b,qe,e,ie),ge=new gp(b,qe),et.reverseDepthBuffer&&f&&ge.buffers.depth.setReversed(!0),He=new zd(b),ye=new rp,Ie=new vp(b,qe,ge,ye,et,ie,He),ht=new Ld(M),T=new Nd(M),_=new Xc(b),Le=new wd(b,_),N=new Od(b,_,He,Le),k=new Gd(b,N,_,He),ue=new Hd(b,et,Ie),_e=new Pd(ye),Z=new ip(M,ht,T,qe,et,Le,_e),G=new Ap(M,ye),ve=new ap,se=new dp(qe),$=new bd(M,ht,T,ge,k,m,l),xe=new mp(M,k,et),w=new bp(b,He,et,ge),we=new Rd(b,qe,He),be=new Bd(b,qe,He),He.programs=Z.programs,M.capabilities=et,M.extensions=qe,M.properties=ye,M.renderLists=ve,M.shadowMap=xe,M.state=ge,M.info=He}ae();const j=new Tp(M,b);this.xr=j,this.getContext=function(){return b},this.getContextAttributes=function(){return b.getContextAttributes()},this.forceContextLoss=function(){const g=qe.get("WEBGL_lose_context");g&&g.loseContext()},this.forceContextRestore=function(){const g=qe.get("WEBGL_lose_context");g&&g.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(g){g!==void 0&&(H=g,this.setSize(V,te,!1))},this.getSize=function(g){return g.set(V,te)},this.setSize=function(g,L,O=!0){if(j.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=g,te=L,t.width=Math.floor(g*H),t.height=Math.floor(L*H),O===!0&&(t.style.width=g+"px",t.style.height=L+"px"),this.setViewport(0,0,g,L)},this.getDrawingBufferSize=function(g){return g.set(V*H,te*H).floor()},this.setDrawingBufferSize=function(g,L,O){V=g,te=L,H=O,t.width=Math.floor(g*O),t.height=Math.floor(L*O),this.setViewport(0,0,g,L)},this.getCurrentViewport=function(g){return g.copy(P)},this.getViewport=function(g){return g.copy(Ee)},this.setViewport=function(g,L,O,B){g.isVector4?Ee.set(g.x,g.y,g.z,g.w):Ee.set(g,L,O,B),ge.viewport(P.copy(Ee).multiplyScalar(H).round())},this.getScissor=function(g){return g.copy(Fe)},this.setScissor=function(g,L,O,B){g.isVector4?Fe.set(g.x,g.y,g.z,g.w):Fe.set(g,L,O,B),ge.scissor(Y.copy(Fe).multiplyScalar(H).round())},this.getScissorTest=function(){return je},this.setScissorTest=function(g){ge.setScissorTest(je=g)},this.setOpaqueSort=function(g){le=g},this.setTransparentSort=function(g){de=g},this.getClearColor=function(g){return g.copy($.getClearColor())},this.setClearColor=function(){$.setClearColor(...arguments)},this.getClearAlpha=function(){return $.getClearAlpha()},this.setClearAlpha=function(){$.setClearAlpha(...arguments)},this.clear=function(g=!0,L=!0,O=!0){let B=0;if(g){let D=!1;if(I!==null){const ee=I.texture.format;D=ee===Ys||ee===qs||ee===Xs}if(D){const ee=I.texture.type,oe=ee===Kt||ee===Bn||ee===Ti||ee===yi||ee===ks||ee===Ws,me=$.getClearColor(),he=$.getClearAlpha(),Ce=me.r,Pe=me.g,Te=me.b;oe?(v[0]=Ce,v[1]=Pe,v[2]=Te,v[3]=he,b.clearBufferuiv(b.COLOR,0,v)):(S[0]=Ce,S[1]=Pe,S[2]=Te,S[3]=he,b.clearBufferiv(b.COLOR,0,S))}else B|=b.COLOR_BUFFER_BIT}L&&(B|=b.DEPTH_BUFFER_BIT),O&&(B|=b.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),b.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",Q,!1),t.removeEventListener("webglcontextcreationerror",K,!1),$.dispose(),ve.dispose(),se.dispose(),ye.dispose(),ht.dispose(),T.dispose(),k.dispose(),Le.dispose(),w.dispose(),Z.dispose(),j.dispose(),j.removeEventListener("sessionstart",ta),j.removeEventListener("sessionend",na),Sn.stop()};function fe(g){g.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),U=!0}function Q(){console.log("THREE.WebGLRenderer: Context Restored."),U=!1;const g=He.autoReset,L=xe.enabled,O=xe.autoUpdate,B=xe.needsUpdate,D=xe.type;ae(),He.autoReset=g,xe.enabled=L,xe.autoUpdate=O,xe.needsUpdate=B,xe.type=D}function K(g){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",g.statusMessage)}function pe(g){const L=g.target;L.removeEventListener("dispose",pe),De(L)}function De(g){tt(g),ye.remove(g)}function tt(g){const L=ye.get(g).programs;L!==void 0&&(L.forEach(function(O){Z.releaseProgram(O)}),g.isShaderMaterial&&Z.releaseShaderCache(g))}this.renderBufferDirect=function(g,L,O,B,D,ee){L===null&&(L=rt);const oe=D.isMesh&&D.matrixWorld.determinant()<0,me=sl(g,L,O,B,D);ge.setMaterial(B,oe);let he=O.index,Ce=1;if(B.wireframe===!0){if(he=N.getWireframeAttribute(O),he===void 0)return;Ce=2}const Pe=O.drawRange,Te=O.attributes.position;let Oe=Pe.start*Ce,Ze=(Pe.start+Pe.count)*Ce;ee!==null&&(Oe=Math.max(Oe,ee.start*Ce),Ze=Math.min(Ze,(ee.start+ee.count)*Ce)),he!==null?(Oe=Math.max(Oe,0),Ze=Math.min(Ze,he.count)):Te!=null&&(Oe=Math.max(Oe,0),Ze=Math.min(Ze,Te.count));const lt=Ze-Oe;if(lt<0||lt===1/0)return;Le.setup(D,B,me,O,he);let nt,Je=we;if(he!==null&&(nt=_.get(he),Je=be,Je.setIndex(nt)),D.isMesh)B.wireframe===!0?(ge.setLineWidth(B.wireframeLinewidth*Xe()),Je.setMode(b.LINES)):Je.setMode(b.TRIANGLES);else if(D.isLine){let Ae=B.linewidth;Ae===void 0&&(Ae=1),ge.setLineWidth(Ae*Xe()),D.isLineSegments?Je.setMode(b.LINES):D.isLineLoop?Je.setMode(b.LINE_LOOP):Je.setMode(b.LINE_STRIP)}else D.isPoints?Je.setMode(b.POINTS):D.isSprite&&Je.setMode(b.TRIANGLES);if(D.isBatchedMesh)if(D._multiDrawInstances!==null)ai("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Je.renderMultiDrawInstances(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount,D._multiDrawInstances);else if(qe.get("WEBGL_multi_draw"))Je.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else{const Ae=D._multiDrawStarts,at=D._multiDrawCounts,Ge=D._multiDrawCount,wt=he?_.get(he).bytesPerElement:1,Vn=ye.get(B).currentProgram.getUniforms();for(let Rt=0;Rt<Ge;Rt++)Vn.setValue(b,"_gl_DrawID",Rt),Je.render(Ae[Rt]/wt,at[Rt])}else if(D.isInstancedMesh)Je.renderInstances(Oe,lt,D.count);else if(O.isInstancedBufferGeometry){const Ae=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,at=Math.min(O.instanceCount,Ae);Je.renderInstances(Oe,lt,at)}else Je.render(Oe,lt)};function Ke(g,L,O){g.transparent===!0&&g.side===nn&&g.forceSinglePass===!1?(g.side=At,g.needsUpdate=!0,Ni(g,L,O),g.side=vn,g.needsUpdate=!0,Ni(g,L,O),g.side=nn):Ni(g,L,O)}this.compile=function(g,L,O=null){O===null&&(O=g),u=se.get(O),u.init(L),y.push(u),O.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(u.pushLight(D),D.castShadow&&u.pushShadow(D))}),g!==O&&g.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(u.pushLight(D),D.castShadow&&u.pushShadow(D))}),u.setupLights();const B=new Set;return g.traverse(function(D){if(!(D.isMesh||D.isPoints||D.isLine||D.isSprite))return;const ee=D.material;if(ee)if(Array.isArray(ee))for(let oe=0;oe<ee.length;oe++){const me=ee[oe];Ke(me,O,D),B.add(me)}else Ke(ee,O,D),B.add(ee)}),u=y.pop(),B},this.compileAsync=function(g,L,O=null){const B=this.compile(g,L,O);return new Promise(D=>{function ee(){if(B.forEach(function(oe){ye.get(oe).currentProgram.isReady()&&B.delete(oe)}),B.size===0){D(g);return}setTimeout(ee,10)}qe.get("KHR_parallel_shader_compile")!==null?ee():setTimeout(ee,10)})};let Ft=null;function Zt(g){Ft&&Ft(g)}function ta(){Sn.stop()}function na(){Sn.start()}const Sn=new zo;Sn.setAnimationLoop(Zt),typeof self<"u"&&Sn.setContext(self),this.setAnimationLoop=function(g){Ft=g,j.setAnimationLoop(g),g===null?Sn.stop():Sn.start()},j.addEventListener("sessionstart",ta),j.addEventListener("sessionend",na),this.render=function(g,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;if(g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),j.enabled===!0&&j.isPresenting===!0&&(j.cameraAutoUpdate===!0&&j.updateCamera(L),L=j.getCamera()),g.isScene===!0&&g.onBeforeRender(M,g,L,I),u=se.get(g,y.length),u.init(L),y.push(u),Me.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),q.setFromProjectionMatrix(Me),Se=this.localClippingEnabled,ne=_e.init(this.clippingPlanes,Se),p=ve.get(g,A.length),p.init(),A.push(p),j.enabled===!0&&j.isPresenting===!0){const ee=M.xr.getDepthSensingMesh();ee!==null&&xr(ee,L,-1/0,M.sortObjects)}xr(g,L,0,M.sortObjects),p.finish(),M.sortObjects===!0&&p.sort(le,de),st=j.enabled===!1||j.isPresenting===!1||j.hasDepthSensing()===!1,st&&$.addToRenderList(p,g),this.info.render.frame++,ne===!0&&_e.beginShadows();const O=u.state.shadowsArray;xe.render(O,g,L),ne===!0&&_e.endShadows(),this.info.autoReset===!0&&this.info.reset();const B=p.opaque,D=p.transmissive;if(u.setupLights(),L.isArrayCamera){const ee=L.cameras;if(D.length>0)for(let oe=0,me=ee.length;oe<me;oe++){const he=ee[oe];ra(B,D,g,he)}st&&$.render(g);for(let oe=0,me=ee.length;oe<me;oe++){const he=ee[oe];ia(p,g,he,he.viewport)}}else D.length>0&&ra(B,D,g,L),st&&$.render(g),ia(p,g,L);I!==null&&C===0&&(Ie.updateMultisampleRenderTarget(I),Ie.updateRenderTargetMipmap(I)),g.isScene===!0&&g.onAfterRender(M,g,L),Le.resetDefaultState(),E=-1,x=null,y.pop(),y.length>0?(u=y[y.length-1],ne===!0&&_e.setGlobalState(M.clippingPlanes,u.state.camera)):u=null,A.pop(),A.length>0?p=A[A.length-1]:p=null};function xr(g,L,O,B){if(g.visible===!1)return;if(g.layers.test(L.layers)){if(g.isGroup)O=g.renderOrder;else if(g.isLOD)g.autoUpdate===!0&&g.update(L);else if(g.isLight)u.pushLight(g),g.castShadow&&u.pushShadow(g);else if(g.isSprite){if(!g.frustumCulled||q.intersectsSprite(g)){B&&Re.setFromMatrixPosition(g.matrixWorld).applyMatrix4(Me);const oe=k.update(g),me=g.material;me.visible&&p.push(g,oe,me,O,Re.z,null)}}else if((g.isMesh||g.isLine||g.isPoints)&&(!g.frustumCulled||q.intersectsObject(g))){const oe=k.update(g),me=g.material;if(B&&(g.boundingSphere!==void 0?(g.boundingSphere===null&&g.computeBoundingSphere(),Re.copy(g.boundingSphere.center)):(oe.boundingSphere===null&&oe.computeBoundingSphere(),Re.copy(oe.boundingSphere.center)),Re.applyMatrix4(g.matrixWorld).applyMatrix4(Me)),Array.isArray(me)){const he=oe.groups;for(let Ce=0,Pe=he.length;Ce<Pe;Ce++){const Te=he[Ce],Oe=me[Te.materialIndex];Oe&&Oe.visible&&p.push(g,oe,Oe,O,Re.z,Te)}}else me.visible&&p.push(g,oe,me,O,Re.z,null)}}const ee=g.children;for(let oe=0,me=ee.length;oe<me;oe++)xr(ee[oe],L,O,B)}function ia(g,L,O,B){const D=g.opaque,ee=g.transmissive,oe=g.transparent;u.setupLightsView(O),ne===!0&&_e.setGlobalState(M.clippingPlanes,O),B&&ge.viewport(P.copy(B)),D.length>0&&Ii(D,L,O),ee.length>0&&Ii(ee,L,O),oe.length>0&&Ii(oe,L,O),ge.buffers.depth.setTest(!0),ge.buffers.depth.setMask(!0),ge.buffers.color.setMask(!0),ge.setPolygonOffset(!1)}function ra(g,L,O,B){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;u.state.transmissionRenderTarget[B.id]===void 0&&(u.state.transmissionRenderTarget[B.id]=new zn(1,1,{generateMipmaps:!0,type:qe.has("EXT_color_buffer_half_float")||qe.has("EXT_color_buffer_float")?Ri:Kt,minFilter:Nn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ve.workingColorSpace}));const ee=u.state.transmissionRenderTarget[B.id],oe=B.viewport||P;ee.setSize(oe.z*M.transmissionResolutionScale,oe.w*M.transmissionResolutionScale);const me=M.getRenderTarget(),he=M.getActiveCubeFace(),Ce=M.getActiveMipmapLevel();M.setRenderTarget(ee),M.getClearColor(X),J=M.getClearAlpha(),J<1&&M.setClearColor(16777215,.5),M.clear(),st&&$.render(O);const Pe=M.toneMapping;M.toneMapping=gn;const Te=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),u.setupLightsView(B),ne===!0&&_e.setGlobalState(M.clippingPlanes,B),Ii(g,O,B),Ie.updateMultisampleRenderTarget(ee),Ie.updateRenderTargetMipmap(ee),qe.has("WEBGL_multisampled_render_to_texture")===!1){let Oe=!1;for(let Ze=0,lt=L.length;Ze<lt;Ze++){const nt=L[Ze],Je=nt.object,Ae=nt.geometry,at=nt.material,Ge=nt.group;if(at.side===nn&&Je.layers.test(B.layers)){const wt=at.side;at.side=At,at.needsUpdate=!0,sa(Je,O,B,Ae,at,Ge),at.side=wt,at.needsUpdate=!0,Oe=!0}}Oe===!0&&(Ie.updateMultisampleRenderTarget(ee),Ie.updateRenderTargetMipmap(ee))}M.setRenderTarget(me,he,Ce),M.setClearColor(X,J),Te!==void 0&&(B.viewport=Te),M.toneMapping=Pe}function Ii(g,L,O){const B=L.isScene===!0?L.overrideMaterial:null;for(let D=0,ee=g.length;D<ee;D++){const oe=g[D],me=oe.object,he=oe.geometry,Ce=oe.group;let Pe=oe.material;Pe.allowOverride===!0&&B!==null&&(Pe=B),me.layers.test(O.layers)&&sa(me,L,O,he,Pe,Ce)}}function sa(g,L,O,B,D,ee){g.onBeforeRender(M,L,O,B,D,ee),g.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,g.matrixWorld),g.normalMatrix.getNormalMatrix(g.modelViewMatrix),D.onBeforeRender(M,L,O,B,g,ee),D.transparent===!0&&D.side===nn&&D.forceSinglePass===!1?(D.side=At,D.needsUpdate=!0,M.renderBufferDirect(O,L,B,D,g,ee),D.side=vn,D.needsUpdate=!0,M.renderBufferDirect(O,L,B,D,g,ee),D.side=nn):M.renderBufferDirect(O,L,B,D,g,ee),g.onAfterRender(M,L,O,B,D,ee)}function Ni(g,L,O){L.isScene!==!0&&(L=rt);const B=ye.get(g),D=u.state.lights,ee=u.state.shadowsArray,oe=D.state.version,me=Z.getParameters(g,D.state,ee,L,O),he=Z.getProgramCacheKey(me);let Ce=B.programs;B.environment=g.isMeshStandardMaterial?L.environment:null,B.fog=L.fog,B.envMap=(g.isMeshStandardMaterial?T:ht).get(g.envMap||B.environment),B.envMapRotation=B.environment!==null&&g.envMap===null?L.environmentRotation:g.envMapRotation,Ce===void 0&&(g.addEventListener("dispose",pe),Ce=new Map,B.programs=Ce);let Pe=Ce.get(he);if(Pe!==void 0){if(B.currentProgram===Pe&&B.lightsStateVersion===oe)return oa(g,me),Pe}else me.uniforms=Z.getUniforms(g),g.onBeforeCompile(me,M),Pe=Z.acquireProgram(me,he),Ce.set(he,Pe),B.uniforms=me.uniforms;const Te=B.uniforms;return(!g.isShaderMaterial&&!g.isRawShaderMaterial||g.clipping===!0)&&(Te.clippingPlanes=_e.uniform),oa(g,me),B.needsLights=ol(g),B.lightsStateVersion=oe,B.needsLights&&(Te.ambientLightColor.value=D.state.ambient,Te.lightProbe.value=D.state.probe,Te.directionalLights.value=D.state.directional,Te.directionalLightShadows.value=D.state.directionalShadow,Te.spotLights.value=D.state.spot,Te.spotLightShadows.value=D.state.spotShadow,Te.rectAreaLights.value=D.state.rectArea,Te.ltc_1.value=D.state.rectAreaLTC1,Te.ltc_2.value=D.state.rectAreaLTC2,Te.pointLights.value=D.state.point,Te.pointLightShadows.value=D.state.pointShadow,Te.hemisphereLights.value=D.state.hemi,Te.directionalShadowMap.value=D.state.directionalShadowMap,Te.directionalShadowMatrix.value=D.state.directionalShadowMatrix,Te.spotShadowMap.value=D.state.spotShadowMap,Te.spotLightMatrix.value=D.state.spotLightMatrix,Te.spotLightMap.value=D.state.spotLightMap,Te.pointShadowMap.value=D.state.pointShadowMap,Te.pointShadowMatrix.value=D.state.pointShadowMatrix),B.currentProgram=Pe,B.uniformsList=null,Pe}function aa(g){if(g.uniformsList===null){const L=g.currentProgram.getUniforms();g.uniformsList=ur.seqWithValue(L.seq,g.uniforms)}return g.uniformsList}function oa(g,L){const O=ye.get(g);O.outputColorSpace=L.outputColorSpace,O.batching=L.batching,O.batchingColor=L.batchingColor,O.instancing=L.instancing,O.instancingColor=L.instancingColor,O.instancingMorph=L.instancingMorph,O.skinning=L.skinning,O.morphTargets=L.morphTargets,O.morphNormals=L.morphNormals,O.morphColors=L.morphColors,O.morphTargetsCount=L.morphTargetsCount,O.numClippingPlanes=L.numClippingPlanes,O.numIntersection=L.numClipIntersection,O.vertexAlphas=L.vertexAlphas,O.vertexTangents=L.vertexTangents,O.toneMapping=L.toneMapping}function sl(g,L,O,B,D){L.isScene!==!0&&(L=rt),Ie.resetTextureUnits();const ee=L.fog,oe=B.isMeshStandardMaterial?L.environment:null,me=I===null?M.outputColorSpace:I.isXRRenderTarget===!0?I.texture.colorSpace:hi,he=(B.isMeshStandardMaterial?T:ht).get(B.envMap||oe),Ce=B.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,Pe=!!O.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Te=!!O.morphAttributes.position,Oe=!!O.morphAttributes.normal,Ze=!!O.morphAttributes.color;let lt=gn;B.toneMapped&&(I===null||I.isXRRenderTarget===!0)&&(lt=M.toneMapping);const nt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,Je=nt!==void 0?nt.length:0,Ae=ye.get(B),at=u.state.lights;if(ne===!0&&(Se===!0||g!==x)){const Mt=g===x&&B.id===E;_e.setState(B,g,Mt)}let Ge=!1;B.version===Ae.__version?(Ae.needsLights&&Ae.lightsStateVersion!==at.state.version||Ae.outputColorSpace!==me||D.isBatchedMesh&&Ae.batching===!1||!D.isBatchedMesh&&Ae.batching===!0||D.isBatchedMesh&&Ae.batchingColor===!0&&D.colorTexture===null||D.isBatchedMesh&&Ae.batchingColor===!1&&D.colorTexture!==null||D.isInstancedMesh&&Ae.instancing===!1||!D.isInstancedMesh&&Ae.instancing===!0||D.isSkinnedMesh&&Ae.skinning===!1||!D.isSkinnedMesh&&Ae.skinning===!0||D.isInstancedMesh&&Ae.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&Ae.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&Ae.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&Ae.instancingMorph===!1&&D.morphTexture!==null||Ae.envMap!==he||B.fog===!0&&Ae.fog!==ee||Ae.numClippingPlanes!==void 0&&(Ae.numClippingPlanes!==_e.numPlanes||Ae.numIntersection!==_e.numIntersection)||Ae.vertexAlphas!==Ce||Ae.vertexTangents!==Pe||Ae.morphTargets!==Te||Ae.morphNormals!==Oe||Ae.morphColors!==Ze||Ae.toneMapping!==lt||Ae.morphTargetsCount!==Je)&&(Ge=!0):(Ge=!0,Ae.__version=B.version);let wt=Ae.currentProgram;Ge===!0&&(wt=Ni(B,L,D));let Vn=!1,Rt=!1,mi=!1;const it=wt.getUniforms(),Lt=Ae.uniforms;if(ge.useProgram(wt.program)&&(Vn=!0,Rt=!0,mi=!0),B.id!==E&&(E=B.id,Rt=!0),Vn||x!==g){ge.buffers.depth.getReversed()?(ce.copy(g.projectionMatrix),sc(ce),ac(ce),it.setValue(b,"projectionMatrix",ce)):it.setValue(b,"projectionMatrix",g.projectionMatrix),it.setValue(b,"viewMatrix",g.matrixWorldInverse);const Tt=it.map.cameraPosition;Tt!==void 0&&Tt.setValue(b,We.setFromMatrixPosition(g.matrixWorld)),et.logarithmicDepthBuffer&&it.setValue(b,"logDepthBufFC",2/(Math.log(g.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&it.setValue(b,"isOrthographic",g.isOrthographicCamera===!0),x!==g&&(x=g,Rt=!0,mi=!0)}if(D.isSkinnedMesh){it.setOptional(b,D,"bindMatrix"),it.setOptional(b,D,"bindMatrixInverse");const Mt=D.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),it.setValue(b,"boneTexture",Mt.boneTexture,Ie))}D.isBatchedMesh&&(it.setOptional(b,D,"batchingTexture"),it.setValue(b,"batchingTexture",D._matricesTexture,Ie),it.setOptional(b,D,"batchingIdTexture"),it.setValue(b,"batchingIdTexture",D._indirectTexture,Ie),it.setOptional(b,D,"batchingColorTexture"),D._colorsTexture!==null&&it.setValue(b,"batchingColorTexture",D._colorsTexture,Ie));const Dt=O.morphAttributes;if((Dt.position!==void 0||Dt.normal!==void 0||Dt.color!==void 0)&&ue.update(D,O,wt),(Rt||Ae.receiveShadow!==D.receiveShadow)&&(Ae.receiveShadow=D.receiveShadow,it.setValue(b,"receiveShadow",D.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(Lt.envMap.value=he,Lt.flipEnvMap.value=he.isCubeTexture&&he.isRenderTargetTexture===!1?-1:1),B.isMeshStandardMaterial&&B.envMap===null&&L.environment!==null&&(Lt.envMapIntensity.value=L.environmentIntensity),Rt&&(it.setValue(b,"toneMappingExposure",M.toneMappingExposure),Ae.needsLights&&al(Lt,mi),ee&&B.fog===!0&&G.refreshFogUniforms(Lt,ee),G.refreshMaterialUniforms(Lt,B,H,te,u.state.transmissionRenderTarget[g.id]),ur.upload(b,aa(Ae),Lt,Ie)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(ur.upload(b,aa(Ae),Lt,Ie),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&it.setValue(b,"center",D.center),it.setValue(b,"modelViewMatrix",D.modelViewMatrix),it.setValue(b,"normalMatrix",D.normalMatrix),it.setValue(b,"modelMatrix",D.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){const Mt=B.uniformsGroups;for(let Tt=0,Sr=Mt.length;Tt<Sr;Tt++){const Mn=Mt[Tt];w.update(Mn,wt),w.bind(Mn,wt)}}return wt}function al(g,L){g.ambientLightColor.needsUpdate=L,g.lightProbe.needsUpdate=L,g.directionalLights.needsUpdate=L,g.directionalLightShadows.needsUpdate=L,g.pointLights.needsUpdate=L,g.pointLightShadows.needsUpdate=L,g.spotLights.needsUpdate=L,g.spotLightShadows.needsUpdate=L,g.rectAreaLights.needsUpdate=L,g.hemisphereLights.needsUpdate=L}function ol(g){return g.isMeshLambertMaterial||g.isMeshToonMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isShadowMaterial||g.isShaderMaterial&&g.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(g,L,O){const B=ye.get(g);B.__autoAllocateDepthBuffer=g.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),ye.get(g.texture).__webglTexture=L,ye.get(g.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:O,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(g,L){const O=ye.get(g);O.__webglFramebuffer=L,O.__useDefaultFramebuffer=L===void 0};const ll=b.createFramebuffer();this.setRenderTarget=function(g,L=0,O=0){I=g,R=L,C=O;let B=!0,D=null,ee=!1,oe=!1;if(g){const he=ye.get(g);if(he.__useDefaultFramebuffer!==void 0)ge.bindFramebuffer(b.FRAMEBUFFER,null),B=!1;else if(he.__webglFramebuffer===void 0)Ie.setupRenderTarget(g);else if(he.__hasExternalTextures)Ie.rebindTextures(g,ye.get(g.texture).__webglTexture,ye.get(g.depthTexture).__webglTexture);else if(g.depthBuffer){const Te=g.depthTexture;if(he.__boundDepthTexture!==Te){if(Te!==null&&ye.has(Te)&&(g.width!==Te.image.width||g.height!==Te.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ie.setupDepthRenderbuffer(g)}}const Ce=g.texture;(Ce.isData3DTexture||Ce.isDataArrayTexture||Ce.isCompressedArrayTexture)&&(oe=!0);const Pe=ye.get(g).__webglFramebuffer;g.isWebGLCubeRenderTarget?(Array.isArray(Pe[L])?D=Pe[L][O]:D=Pe[L],ee=!0):g.samples>0&&Ie.useMultisampledRTT(g)===!1?D=ye.get(g).__webglMultisampledFramebuffer:Array.isArray(Pe)?D=Pe[O]:D=Pe,P.copy(g.viewport),Y.copy(g.scissor),z=g.scissorTest}else P.copy(Ee).multiplyScalar(H).floor(),Y.copy(Fe).multiplyScalar(H).floor(),z=je;if(O!==0&&(D=ll),ge.bindFramebuffer(b.FRAMEBUFFER,D)&&B&&ge.drawBuffers(g,D),ge.viewport(P),ge.scissor(Y),ge.setScissorTest(z),ee){const he=ye.get(g.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_CUBE_MAP_POSITIVE_X+L,he.__webglTexture,O)}else if(oe){const he=ye.get(g.texture),Ce=L;b.framebufferTextureLayer(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,he.__webglTexture,O,Ce)}else if(g!==null&&O!==0){const he=ye.get(g.texture);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,he.__webglTexture,O)}E=-1},this.readRenderTargetPixels=function(g,L,O,B,D,ee,oe,me=0){if(!(g&&g.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let he=ye.get(g).__webglFramebuffer;if(g.isWebGLCubeRenderTarget&&oe!==void 0&&(he=he[oe]),he){ge.bindFramebuffer(b.FRAMEBUFFER,he);try{const Ce=g.textures[me],Pe=Ce.format,Te=Ce.type;if(!et.textureFormatReadable(Pe)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!et.textureTypeReadable(Te)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=g.width-B&&O>=0&&O<=g.height-D&&(g.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+me),b.readPixels(L,O,B,D,ie.convert(Pe),ie.convert(Te),ee))}finally{const Ce=I!==null?ye.get(I).__webglFramebuffer:null;ge.bindFramebuffer(b.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(g,L,O,B,D,ee,oe,me=0){if(!(g&&g.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let he=ye.get(g).__webglFramebuffer;if(g.isWebGLCubeRenderTarget&&oe!==void 0&&(he=he[oe]),he)if(L>=0&&L<=g.width-B&&O>=0&&O<=g.height-D){ge.bindFramebuffer(b.FRAMEBUFFER,he);const Ce=g.textures[me],Pe=Ce.format,Te=Ce.type;if(!et.textureFormatReadable(Pe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!et.textureTypeReadable(Te))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Oe=b.createBuffer();b.bindBuffer(b.PIXEL_PACK_BUFFER,Oe),b.bufferData(b.PIXEL_PACK_BUFFER,ee.byteLength,b.STREAM_READ),g.textures.length>1&&b.readBuffer(b.COLOR_ATTACHMENT0+me),b.readPixels(L,O,B,D,ie.convert(Pe),ie.convert(Te),0);const Ze=I!==null?ye.get(I).__webglFramebuffer:null;ge.bindFramebuffer(b.FRAMEBUFFER,Ze);const lt=b.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);return b.flush(),await rc(b,lt,4),b.bindBuffer(b.PIXEL_PACK_BUFFER,Oe),b.getBufferSubData(b.PIXEL_PACK_BUFFER,0,ee),b.deleteBuffer(Oe),b.deleteSync(lt),ee}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(g,L=null,O=0){const B=Math.pow(2,-O),D=Math.floor(g.image.width*B),ee=Math.floor(g.image.height*B),oe=L!==null?L.x:0,me=L!==null?L.y:0;Ie.setTexture2D(g,0),b.copyTexSubImage2D(b.TEXTURE_2D,O,0,0,oe,me,D,ee),ge.unbindTexture()};const cl=b.createFramebuffer(),ul=b.createFramebuffer();this.copyTextureToTexture=function(g,L,O=null,B=null,D=0,ee=null){ee===null&&(D!==0?(ai("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ee=D,D=0):ee=0);let oe,me,he,Ce,Pe,Te,Oe,Ze,lt;const nt=g.isCompressedTexture?g.mipmaps[ee]:g.image;if(O!==null)oe=O.max.x-O.min.x,me=O.max.y-O.min.y,he=O.isBox3?O.max.z-O.min.z:1,Ce=O.min.x,Pe=O.min.y,Te=O.isBox3?O.min.z:0;else{const Dt=Math.pow(2,-D);oe=Math.floor(nt.width*Dt),me=Math.floor(nt.height*Dt),g.isDataArrayTexture?he=nt.depth:g.isData3DTexture?he=Math.floor(nt.depth*Dt):he=1,Ce=0,Pe=0,Te=0}B!==null?(Oe=B.x,Ze=B.y,lt=B.z):(Oe=0,Ze=0,lt=0);const Je=ie.convert(L.format),Ae=ie.convert(L.type);let at;L.isData3DTexture?(Ie.setTexture3D(L,0),at=b.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Ie.setTexture2DArray(L,0),at=b.TEXTURE_2D_ARRAY):(Ie.setTexture2D(L,0),at=b.TEXTURE_2D),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,L.flipY),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),b.pixelStorei(b.UNPACK_ALIGNMENT,L.unpackAlignment);const Ge=b.getParameter(b.UNPACK_ROW_LENGTH),wt=b.getParameter(b.UNPACK_IMAGE_HEIGHT),Vn=b.getParameter(b.UNPACK_SKIP_PIXELS),Rt=b.getParameter(b.UNPACK_SKIP_ROWS),mi=b.getParameter(b.UNPACK_SKIP_IMAGES);b.pixelStorei(b.UNPACK_ROW_LENGTH,nt.width),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,nt.height),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Ce),b.pixelStorei(b.UNPACK_SKIP_ROWS,Pe),b.pixelStorei(b.UNPACK_SKIP_IMAGES,Te);const it=g.isDataArrayTexture||g.isData3DTexture,Lt=L.isDataArrayTexture||L.isData3DTexture;if(g.isDepthTexture){const Dt=ye.get(g),Mt=ye.get(L),Tt=ye.get(Dt.__renderTarget),Sr=ye.get(Mt.__renderTarget);ge.bindFramebuffer(b.READ_FRAMEBUFFER,Tt.__webglFramebuffer),ge.bindFramebuffer(b.DRAW_FRAMEBUFFER,Sr.__webglFramebuffer);for(let Mn=0;Mn<he;Mn++)it&&(b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ye.get(g).__webglTexture,D,Te+Mn),b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,ye.get(L).__webglTexture,ee,lt+Mn)),b.blitFramebuffer(Ce,Pe,oe,me,Oe,Ze,oe,me,b.DEPTH_BUFFER_BIT,b.NEAREST);ge.bindFramebuffer(b.READ_FRAMEBUFFER,null),ge.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else if(D!==0||g.isRenderTargetTexture||ye.has(g)){const Dt=ye.get(g),Mt=ye.get(L);ge.bindFramebuffer(b.READ_FRAMEBUFFER,cl),ge.bindFramebuffer(b.DRAW_FRAMEBUFFER,ul);for(let Tt=0;Tt<he;Tt++)it?b.framebufferTextureLayer(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Dt.__webglTexture,D,Te+Tt):b.framebufferTexture2D(b.READ_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Dt.__webglTexture,D),Lt?b.framebufferTextureLayer(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,Mt.__webglTexture,ee,lt+Tt):b.framebufferTexture2D(b.DRAW_FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,Mt.__webglTexture,ee),D!==0?b.blitFramebuffer(Ce,Pe,oe,me,Oe,Ze,oe,me,b.COLOR_BUFFER_BIT,b.NEAREST):Lt?b.copyTexSubImage3D(at,ee,Oe,Ze,lt+Tt,Ce,Pe,oe,me):b.copyTexSubImage2D(at,ee,Oe,Ze,Ce,Pe,oe,me);ge.bindFramebuffer(b.READ_FRAMEBUFFER,null),ge.bindFramebuffer(b.DRAW_FRAMEBUFFER,null)}else Lt?g.isDataTexture||g.isData3DTexture?b.texSubImage3D(at,ee,Oe,Ze,lt,oe,me,he,Je,Ae,nt.data):L.isCompressedArrayTexture?b.compressedTexSubImage3D(at,ee,Oe,Ze,lt,oe,me,he,Je,nt.data):b.texSubImage3D(at,ee,Oe,Ze,lt,oe,me,he,Je,Ae,nt):g.isDataTexture?b.texSubImage2D(b.TEXTURE_2D,ee,Oe,Ze,oe,me,Je,Ae,nt.data):g.isCompressedTexture?b.compressedTexSubImage2D(b.TEXTURE_2D,ee,Oe,Ze,nt.width,nt.height,Je,nt.data):b.texSubImage2D(b.TEXTURE_2D,ee,Oe,Ze,oe,me,Je,Ae,nt);b.pixelStorei(b.UNPACK_ROW_LENGTH,Ge),b.pixelStorei(b.UNPACK_IMAGE_HEIGHT,wt),b.pixelStorei(b.UNPACK_SKIP_PIXELS,Vn),b.pixelStorei(b.UNPACK_SKIP_ROWS,Rt),b.pixelStorei(b.UNPACK_SKIP_IMAGES,mi),ee===0&&L.generateMipmaps&&b.generateMipmap(at),ge.unbindTexture()},this.copyTextureToTexture3D=function(g,L,O=null,B=null,D=0){return ai('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(g,L,O,B,D)},this.initRenderTarget=function(g){ye.get(g).__webglFramebuffer===void 0&&Ie.setupRenderTarget(g)},this.initTexture=function(g){g.isCubeTexture?Ie.setTextureCube(g,0):g.isData3DTexture?Ie.setTexture3D(g,0):g.isDataArrayTexture||g.isCompressedArrayTexture?Ie.setTexture2DArray(g,0):Ie.setTexture2D(g,0),ge.unbindTexture()},this.resetState=function(){R=0,C=0,I=null,ge.reset(),Le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ve._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ve._getUnpackColorSpace()}}var Pn=63710088e-1,Ei=2*Math.PI*Pn,_t=Math.PI/180,ii=1024e3/Ei,Rp=512,Cp=class{static clamp(i,e,t){return Math.min(t,Math.max(e,i))}static makePerspectiveMatrix(i,e,t,n){let r=1/Math.tan(i/2),s=1/(t-n);return[r/e,0,0,0,0,r,0,0,0,0,(n+t)*s,-1,0,0,2*n*t*s,0]}static mercatorXFromLng(i){return(180+i)/360}static mercatorYFromLat(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}static getViewInfo(i,e,t){let n=i.fov*_t,r=i.pitch*_t,s=null;if(Array.isArray(e)&&(s={lng:e[0],lat:e[1],alt:e[2]||0}),typeof e=="string"){let d=e.split(",");s={lng:+d[0],lat:+d[1],alt:+d[2]||0}}let a=Math.max(t.x,t.y,t.z)/(2*Math.tan(n/2))*Math.cos(r)+s.alt,o=Math.abs(Math.cos(r)*i.cameraToCenterDistance),l=Ei*Math.abs(Math.cos(s.lat*_t)),c=o/a*l,h=Math.round(Math.log2(c/i.tileSize));return{center:[s.lng,s.lat],cameraHeight:a,zoom:h}}static getHeightByZoom(i,e,t,n){let r=Math.abs(Math.cos(n*_t)*i.cameraToCenterDistance),s=Ei*Math.abs(Math.cos(t*_t)),a=Math.pow(2,e)*i.tileSize;return r*s/a}static getZoomByHeight(i,e,t,n){let r=Math.abs(Math.cos(n*_t)*i.cameraToCenterDistance),s=Ei*Math.abs(Math.cos(t*_t)),a=r/e*s;return Math.round(Math.log2(a/i.tileSize))}},Fn=Cp,so=new ke,ao=new ke,oo=85.051129,Pp=class{_map;_world;_camera;_translateCenter;_worldSizeRatio;constructor(i,e,t){this._map=i,this._world=e,this._camera=t,this._translateCenter=new ke().makeTranslation(1024e3/2,-1024e3/2,0),this._worldSizeRatio=Rp/1024e3,this._map.on("move",()=>{this.syncCamera(!1)}),this._map.on("resize",()=>{this.syncCamera(!0)})}syncCamera(i){let e=this._map.transform,t=e.pitch*_t,n=e.bearing*_t;if(i){let d=e.fov*_t,f=e.centerOffset||new F;this._camera.aspect=e.width/e.height,so.elements=Fn.makePerspectiveMatrix(d,this._camera.aspect,e.height/50,e.farZ),this._camera.projectionMatrix=so,this._camera.projectionMatrix.elements[8]=-f.x*2/e.width,this._camera.projectionMatrix.elements[9]=f.y*2/e.height}ao.makeTranslation(0,0,e.cameraToCenterDistance);let r=new ke().premultiply(ao).premultiply(new ke().makeRotationX(t)).premultiply(new ke().makeRotationZ(-n));e.elevation&&(r.elements[14]=e.cameraToCenterDistance*Math.cos(t)),this._camera.matrixWorld.copy(r);let s=e.scale*this._worldSizeRatio,a=new ke().makeScale(s,s,s),o=e.x,l=e.y;if(!o||!l){let d=e.center,f=Fn.clamp(d.lat,-oo,oo);o=Fn.mercatorXFromLng(d.lng)*e.worldSize,l=Fn.mercatorYFromLat(f)*e.worldSize}let c=new ke().makeTranslation(-o,l,0),h=new ke().makeRotationZ(Math.PI);this._world.matrix=new ke().premultiply(h).premultiply(this._translateCenter).premultiply(a).premultiply(c)}},Lp=Pp,Dp=class{_id;_mapScene;_cameraSync;constructor(i,e){this._id=i,this._mapScene=e,this._cameraSync=new Lp(this._mapScene.map,this._mapScene.world,this._mapScene.camera)}get id(){return this._id}get type(){return"custom"}get renderingMode(){return"3d"}onAdd(){this._cameraSync.syncCamera(!0)}render(){this._mapScene.render()}onRemove(){this._cameraSync=null,this._mapScene=null}},Up=Dp,Ip=class{static projectedMercatorUnitsPerMeter(){return this.projectedUnitsPerMeter(0)}static projectedUnitsPerMeter(i){return Math.abs(1024e3/Math.cos(_t*i)/Ei)}static lngLatToVector3(i,e,t){let n=[0,0,0];return Array.isArray(i)?(n=[-Pn*_t*i[0]*ii,-Pn*Math.log(Math.tan(Math.PI*.25+.5*_t*i[1]))*ii],i[2]?n.push(i[2]*this.projectedUnitsPerMeter(i[1])):n.push(0)):(n=[-Pn*_t*i*ii,-Pn*Math.log(Math.tan(Math.PI*.25+.5*_t*(e||0)))*ii],t?n.push(t*this.projectedUnitsPerMeter(e||0)):n.push(0)),new F(n[0],n[1],n[2])}static vector3ToLngLat(i){let e=[0,0,0];return i&&(e[0]=-i.x/(Pn*_t*ii),e[1]=2*(Math.atan(Math.exp(i.y/(ii*-Pn)))-Math.PI/4)/_t,e[2]=i.z/this.projectedUnitsPerMeter(e[1])),e}},Un=Ip,Np={scene:null,camera:null,renderer:null,renderLoop:null,preserveDrawingBuffer:!1},Fp=class{_map;_options;_canvas;_scene;_camera;_renderer;_lights;_world;_event;constructor(i,e={}){if(!i)throw"missing map";this._map=i,this._options={...Np,...e},this._canvas=i.getCanvas(),this._scene=this._options.scene||new Dc,this._camera=this._options.camera||new Nt(this._map.transform.fov,this._map.transform.width/this._map.transform.height,.001,1e21),this._camera.matrixAutoUpdate=!1,this._renderer=this._options.renderer||new wp({alpha:!0,antialias:!0,preserveDrawingBuffer:this._options.preserveDrawingBuffer,canvas:this._canvas,context:this._canvas.getContext("webgl2")}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._canvas.clientWidth,this._canvas.clientHeight),this._renderer.autoClear=!1,this._lights=new mn,this._lights.name="lights",this._scene.add(this._lights),this._world=new mn,this._world.name="world",this._world.userData={isWorld:!0,name:"world"},this._world.position.set(1024e3/2,1024e3/2,0),this._world.matrixAutoUpdate=!1,this._scene.add(this._world),this._map.on("render",this._onMapRender.bind(this)),this._event=new Hn}get map(){return this._map}get canvas(){return this._canvas}get camera(){return this._camera}get scene(){return this._scene}get lights(){return this._lights}get world(){return this._world}get renderer(){return this._renderer}_onMapRender(){this._map.getLayer("map_scene_layer")||this._map.addLayer(new Up("map_scene_layer",this))}render(){if(this._options.renderLoop)this._options.renderLoop(this);else{let i={center:this._map.getCenter(),scene:this._scene,camera:this._camera,renderer:this._renderer};this._event.dispatchEvent({type:"preReset",frameState:i}),this.renderer.resetState(),this._event.dispatchEvent({type:"postReset",frameState:i}),this._event.dispatchEvent({type:"preRender",frameState:i}),this.renderer.render(this._scene,this._camera),this._event.dispatchEvent({type:"postRender",frameState:i})}return this}addLight(i){return this._lights.add(i.delegate||i),this}removeLight(i){return this._lights.remove(i.delegate||i),this}addObject(i){let e="delegate"in i?i.delegate:i;return this._world.add(e),this}removeObject(i){let e="delegate"in i?i.delegate:i;return this._world.remove(e),e.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose()),t.texture&&t.texture.dispose()}),this}getViewPosition(){let i=this._map.transform,e=i.center;return{position:[e.lng,e.lat,Fn.getHeightByZoom(i,i.zoom,e.lat,i.pitch)],heading:i.bearing,pitch:i.pitch}}flyTo(i,e,t){if(i&&i.position){t&&this._map.once("moveend",t);let n=i.size;n||(n=new F,new fi().setFromObject(i.delegate||i,!0).getSize(n));let r=Fn.getViewInfo(this._map.transform,Un.vector3ToLngLat(i.position),n);this._map.flyTo({center:r.center,zoom:r.zoom,duration:(e||3)*1e3})}return this}zoomTo(i,e){return this.flyTo(i,0,e)}flyToPosition(i,e=[0,0,0],t,n=3){return t&&this._map.once("moveend",t),this._map.flyTo({center:[i[0],i[1]],zoom:Fn.getZoomByHeight(this._map.transform,i[2],i[1],e[1]||0),bearing:e[0],pitch:e[1],duration:n*1e3}),this}zoomToPosition(i,e=[0,0,0],t){return this.flyToPosition(i,e,t,0)}on(i,e){return this._event.addEventListener(i,e),this}off(i,e){return this._event.removeEventListener(i,e),this}},gr=Math.PI,Qe=Math.sin,ot=Math.cos,Js=Math.tan,Wo=Math.asin,wi=Math.atan2,Xo=Math.acos,mt=gr/180,Qs=1e3*60*60*24,qo=2440588,Yo=2451545;function Op(i){return i.valueOf()/Qs-.5+qo}function ir(i){return new Date((i+.5-qo)*Qs)}function vr(i){return Op(i)-Yo}var pr=mt*23.4397;function Ko(i,e){return wi(Qe(i)*ot(pr)-Js(e)*Qe(pr),ot(i))}function ea(i,e){return Wo(Qe(e)*ot(pr)+ot(e)*Qe(pr)*Qe(i))}function Zo(i,e,t){return wi(Qe(i),ot(i)*Qe(e)-Js(t)*ot(e))}function $o(i,e,t){return Wo(Qe(e)*Qe(t)+ot(e)*ot(t)*ot(i))}function jo(i,e){return mt*(280.16+360.9856235*i)-e}function Bp(i){return i<0&&(i=0),2967e-7/Math.tan(i+.00312536/(i+.08901179))}function Jo(i){return mt*(357.5291+.98560028*i)}function Qo(i){let e=mt*(1.9148*Qe(i)+.02*Qe(2*i)+3e-4*Qe(3*i)),t=mt*102.9372;return i+e+t+gr}function el(i){let e=Jo(i),t=Qo(e);return{dec:ea(t,0),ra:Ko(t,0)}}var Vt={};Vt.getPosition=function(i,e,t){let n=mt*-t,r=mt*e,s=vr(i),a=el(s),o=jo(s,n)-a.ra;return{azimuth:Zo(o,r,a.dec),altitude:$o(o,r,a.dec)}};var Hs=Vt.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];Vt.addTime=function(i,e,t){Hs.push([i,e,t])};var tl=9e-4;function zp(i,e){return Math.round(i-tl-e/(2*gr))}function nl(i,e,t){return tl+(i+e)/(2*gr)+t}function il(i,e,t){return Yo+i+.0053*Qe(e)-.0069*Qe(2*t)}function Hp(i,e,t){return Xo((Qe(i)-Qe(e)*Qe(t))/(ot(e)*ot(t)))}function Gp(i){return-2.076*Math.sqrt(i)/60}function Vp(i,e,t,n,r,s,a){let o=Hp(i,t,n),l=nl(o,e,r);return il(l,s,a)}Vt.getTimes=function(i,e,t,n=0){let r=mt*-t,s=mt*e,a=Gp(n),o=vr(i),l=zp(o,r),c=nl(0,r,l),h=Jo(c),d=Qo(h),f=ea(d,0),m=il(c,h,d),v,S,p,u,A,y,M={solarNoon:ir(m),nadir:ir(m-.5)};for(v=0,S=Hs.length;v<S;v+=1)p=Hs[v],u=(p[0]+a)*mt,A=Vp(u,r,s,f,l,h,d),y=m-(A-m),M[p[1]]=ir(y),M[p[2]]=ir(A);return M};function rl(i){let e=mt*(218.316+13.176396*i),t=mt*(134.963+13.064993*i),n=mt*(93.272+13.22935*i),r=e+mt*6.289*Qe(t),s=mt*5.128*Qe(n),a=385001-20905*ot(t);return{ra:Ko(r,s),dec:ea(r,s),dist:a}}Vt.getMoonPosition=function(i,e,t){let n=mt*-t,r=mt*e,s=vr(i),a=rl(s),o=jo(s,n)-a.ra,l=$o(o,r,a.dec),c=wi(Qe(o),Js(r)*ot(a.dec)-Qe(a.dec)*ot(o));return l=l+Bp(l),{azimuth:Zo(o,r,a.dec),altitude:l,distance:a.dist,parallacticAngle:c}};Vt.getMoonIllumination=function(i){let e=vr(i||new Date),t=el(e),n=rl(e),r=149598e3,s=Xo(Qe(t.dec)*Qe(n.dec)+ot(t.dec)*ot(n.dec)*ot(t.ra-n.ra)),a=wi(r*Qe(s),n.dist-r*ot(s)),o=wi(ot(t.dec)*Qe(t.ra-n.ra),Qe(t.dec)*ot(n.dec)-ot(t.dec)*Qe(n.dec)*ot(t.ra-n.ra));return{fraction:(1+ot(a))/2,phase:.5+.5*a*(o<0?-1:1)/Math.PI,angle:o}};function rr(i,e){return new Date(i.valueOf()+e*Qs/24)}Vt.getMoonTimes=function(i,e,t,n=!1){let r=new Date(i);n?r.setUTCHours(0,0,0,0):r.setHours(0,0,0,0);let s=.133*mt,a=Vt.getMoonPosition(r,e,t).altitude-s,o,l,c,h,d,f,m,v,S,p,u,A,y;for(let U=1;U<=24&&(o=Vt.getMoonPosition(rr(r,U),e,t).altitude-s,l=Vt.getMoonPosition(rr(r,U+1),e,t).altitude-s,d=(a+l)/2-o,f=(l-a)/2,m=-f/(2*d),v=(d*m+f)*m+o,S=f*f-4*d*o,p=0,S>=0&&(y=Math.sqrt(S)/(Math.abs(d)*2),u=m-y,A=m+y,Math.abs(u)<=1&&p++,Math.abs(A)<=1&&p++,u<-1&&(u=A)),p===1?a<0?c=U+u:h=U+u:p===2&&(c=U+(v<0?A:u),h=U+(v<0?u:A)),!(c&&h));U+=2)a=l;let M={};return c&&(M.rise=rr(r,c)),h&&(M.set=rr(r,h)),!c&&!h&&(M[v>0?"alwaysUp":"alwaysDown"]=!0),M};var kp=Vt,Wp=class{_delegate;_sunLight;_hemiLight;_currentTime;constructor(){this._delegate=new mn,this._delegate.name="Sun",this._sunLight=new Vc(16777215,1),this._hemiLight=new zc(new ze(16777215),new ze(16777215),.6),this._hemiLight.color.setHSL(.661,.96,.12),this._hemiLight.groundColor.setHSL(.11,.96,.14),this._hemiLight.position.set(0,0,50),this._delegate.add(this._sunLight),this._delegate.add(this._hemiLight),this._currentTime=new Date().getTime()}get delegate(){return this._delegate}set castShadow(i){this._sunLight.castShadow=i}get castShadow(){return this._sunLight.castShadow}set currentTime(i){this._currentTime=i}get currentTime(){return this._currentTime}get sunLight(){return this._sunLight}get hemiLight(){return this._hemiLight}setShadow(i={}){return this._sunLight.shadow.radius=i.radius||2,this._sunLight.shadow.mapSize.width=i.mapSize?i.mapSize[0]:8192,this._sunLight.shadow.mapSize.height=i.mapSize?i.mapSize[1]:8192,this._sunLight.shadow.camera.top=this._sunLight.shadow.camera.right=i.topRight||1e3,this._sunLight.shadow.camera.bottom=this._sunLight.shadow.camera.left=i.bottomLeft||-1e3,this._sunLight.shadow.camera.near=i.near||1,this._sunLight.shadow.camera.far=i.far||1e8,this._sunLight.shadow.camera.visible=!0,this}update(i){let e=new Date(this._currentTime||new Date().getTime()),t=i.center,n=kp.getPosition(e,t.lat,t.lng),r=n.altitude,s=Math.PI+n.azimuth,a=1024e3/2,o=Math.sin(r),l=Math.cos(r),c=Math.cos(s)*l,h=Math.sin(s)*l;this._sunLight.position.set(h,c,o),this._sunLight.position.multiplyScalar(a),this._sunLight.intensity=Math.max(o,0),this._hemiLight.intensity=Math.max(o*1,.1),this._sunLight.updateMatrixWorld()}},Xp=Wp,qp=class{static createRTCGroup(i,e,t){let n=new mn;if(n.name="rtc",n.position.copy(Un.lngLatToVector3(i)),e?(n.rotateX(e[0]||0),n.rotateY(e[1]||0),n.rotateZ(e[2]||0)):(n.rotateX(Math.PI/2),n.rotateY(Math.PI)),t)n.scale.set(t[0]||1,t[1]||1,t[2]||1);else{let r=1;Array.isArray(i)&&(r=Un.projectedUnitsPerMeter(i[1])),n.scale.set(r,r,r)}return n}static createMercatorRTCGroup(i,e,t){let n=this.createRTCGroup(i,e,t);if(!t){let r=1,s=Un.projectedMercatorUnitsPerMeter();Array.isArray(i)&&(r=Un.projectedUnitsPerMeter(i[1])),n.scale.set(s,s,r)}return n}static createShadowGround(i,e,t){let n=new Ui(e||100,t||100),r=new Fc({opacity:.5,transparent:!0}),s=new qt(n,r);return s.position.copy(Un.lngLatToVector3(i)),s.receiveShadow=!0,s.name="shadow-ground",s}},Yp=qp;fl(hl.Map);exports.ADVANCED_EXTENSIONS=W.ADVANCED_EXTENSIONS;exports.ALL_EXTENSIONS=W.ALL_EXTENSIONS;exports.AddVectorAdapter=W.AddVectorAdapter;exports.AddVectorControl=W.AddVectorControl;exports.BasemapControl=W.BasemapControl;exports.BookmarkControl=W.BookmarkControl;exports.COLORMAPS=W.COLORMAPS;exports.CSV_EXTENSIONS=W.CSV_EXTENSIONS;exports.ChoroplethControl=W.ChoroplethControl;exports.CogLayerAdapter=W.CogLayerAdapter;exports.CogLayerControl=W.CogLayerControl;exports.Colorbar=W.Colorbar;exports.ColorbarGuiControl=W.ColorbarGuiControl;exports.ControlGrid=W.ControlGrid;exports.DUCKDB_EXTENSIONS=W.DUCKDB_EXTENSIONS;exports.DXF_EXTENSIONS=W.DXF_EXTENSIONS;exports.FLATGEOBUF_EXTENSIONS=W.FLATGEOBUF_EXTENSIONS;exports.GEOJSON_EXTENSIONS=W.GEOJSON_EXTENSIONS;exports.GEOPACKAGE_EXTENSIONS=W.GEOPACKAGE_EXTENSIONS;exports.GEOPARQUET_EXTENSIONS=W.GEOPARQUET_EXTENSIONS;exports.GML_EXTENSIONS=W.GML_EXTENSIONS;exports.GOOGLE_BASEMAPS=W.GOOGLE_BASEMAPS;exports.GPX_EXTENSIONS=W.GPX_EXTENSIONS;exports.GaussianSplatControl=W.GaussianSplatControl;exports.GaussianSplatLayerAdapter=W.GaussianSplatLayerAdapter;exports.GeoEditor=W.GeoEditor;exports.GeoEditorLayerAdapter=W.GeoEditorLayerAdapter;exports.HtmlControl=W.HtmlControl;exports.HtmlGuiControl=W.HtmlGuiControl;exports.InspectControl=W.InspectControl;exports.KML_EXTENSIONS=W.KML_EXTENSIONS;exports.KMZ_EXTENSIONS=W.KMZ_EXTENSIONS;exports.Legend=W.Legend;exports.LegendGuiControl=W.LegendGuiControl;exports.LidarControl=W.LidarControl;exports.LidarLayerAdapter=W.LidarLayerAdapter;exports.MeasureControl=W.MeasureControl;exports.MinimapControl=W.MinimapControl;exports.PMTilesLayerAdapter=W.PMTilesLayerAdapter;exports.PMTilesLayerControl=W.PMTilesLayerControl;exports.PlanetaryComputerControl=W.PlanetaryComputerControl;exports.PlanetaryComputerLayerAdapter=W.PlanetaryComputerLayerAdapter;exports.PrintControl=W.PrintControl;exports.RdBu=W.RdBu;exports.RdYlBu=W.RdYlBu;exports.RdYlGn=W.RdYlGn;exports.SHAPEFILE_EXTENSIONS=W.SHAPEFILE_EXTENSIONS;exports.SHPJS_EXTENSIONS=W.SHPJS_EXTENSIONS;exports.SearchControl=W.SearchControl;exports.StacLayerAdapter=W.StacLayerAdapter;exports.StacLayerControl=W.StacLayerControl;exports.StacSearchControl=W.StacSearchControl;exports.StreetViewControl=W.StreetViewControl;exports.SwipeControl=W.SwipeControl;exports.TOPOJSON_EXTENSIONS=W.TOPOJSON_EXTENSIONS;exports.TerrainControl=W.TerrainControl;exports.UsgsLidarControl=W.UsgsLidarControl;exports.UsgsLidarLayerAdapter=W.UsgsLidarLayerAdapter;exports.VectorDatasetControl=W.VectorDatasetControl;exports.ViewStateControl=W.ViewStateControl;exports.XLSX_EXTENSIONS=W.XLSX_EXTENSIONS;exports.XYZSERVICES_URL=W.XYZSERVICES_URL;exports.ZarrLayerAdapter=W.ZarrLayerAdapter;exports.ZarrLayerControl=W.ZarrLayerControl;exports.bone=W.bone;exports.buildTileUrl=W.buildTileUrl;exports.bwr=W.bwr;exports.cividis=W.cividis;exports.clamp=W.clamp;exports.classNames=W.classNames;exports.cool=W.cool;exports.coolwarm=W.coolwarm;exports.debounce=W.debounce;exports.detectFormat=W.detectFormat;exports.fetchProviders=W.fetchProviders;exports.filterBasemaps=W.filterBasemaps;exports.formatNumericValue=W.formatNumericValue;exports.generateGradientCSS=W.generateGradientCSS;exports.generateId=W.generateId;exports.generateThumbnailUrl=W.generateThumbnailUrl;exports.getAcceptedExtensions=W.getAcceptedExtensions;exports.getColorAtPosition=W.getColorAtPosition;exports.getColormap=W.getColormap;exports.getColormapNames=W.getColormapNames;exports.getFileExtension=W.getFileExtension;exports.getFormatDescription=W.getFormatDescription;exports.getFormatDisplayName=W.getFormatDisplayName;exports.gray=W.gray;exports.groupBasemaps=W.groupBasemaps;exports.hexToRgb=W.hexToRgb;exports.hot=W.hot;exports.inferno=W.inferno;exports.interpolateColor=W.interpolateColor;exports.isValidColormap=W.isValidColormap;exports.isValidExtension=W.isValidExtension;exports.jet=W.jet;exports.magma=W.magma;exports.ocean=W.ocean;exports.parseProviders=W.parseProviders;exports.plasma=W.plasma;exports.rainbow=W.rainbow;exports.readFileAsBuffer=W.readFileAsBuffer;exports.requiresConversion=W.requiresConversion;exports.requiresDuckDB=W.requiresDuckDB;exports.rgbToHex=W.rgbToHex;exports.seismic=W.seismic;exports.spectral=W.spectral;exports.terrain=W.terrain;exports.throttle=W.throttle;exports.turbo=W.turbo;exports.viridis=W.viridis;exports.DuckDBConverter=lo.DuckDBConverter;exports.getDuckDBConverter=lo.getDuckDBConverter;exports.ShapefileConverter=co.ShapefileConverter;exports.getShapefileConverter=co.getShapefileConverter;exports.ALL_DEFAULT_CONTROLS=uo;exports.Creator=Yp;exports.DEFAULT_EXCLUDE_LAYERS=ho;exports.MapScene=Fp;exports.SceneTransform=Un;exports.Sun=Xp;exports.addControlGrid=fo;