@roomle/web-sdk 3.7.0 → 3.8.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 (132) hide show
  1. package/lib/{BufferGeometry-BzmfTBQt.mjs → BufferGeometry-ltw0XkYt.mjs} +7 -4
  2. package/lib/BufferGeometry-ltw0XkYt.mjs.map +1 -0
  3. package/lib/ConfiguratorKernel.js +6 -6
  4. package/lib/ConfiguratorKernel.wasm +0 -0
  5. package/lib/{GLTFExporter-CyhgWPq0.mjs → GLTFExporter-BqjC9LhS.mjs} +9 -14
  6. package/lib/GLTFExporter-BqjC9LhS.mjs.map +1 -0
  7. package/lib/{Object3D-C3wqWk6O.mjs → Object3D-BZaiqQIE.mjs} +24 -12
  8. package/lib/Object3D-BZaiqQIE.mjs.map +1 -0
  9. package/lib/{PointLightHelper-DwIXACyT.mjs → PointLightHelper-AxCe6I00.mjs} +4 -4
  10. package/lib/PointLightHelper-AxCe6I00.mjs.map +1 -0
  11. package/lib/RoomleCore.js +8 -8
  12. package/lib/RoomleCore.wasm +0 -0
  13. package/lib/RoomleToolsCore.wasm +0 -0
  14. package/lib/{SpotLightHelper-CfLHM7LU.mjs → SpotLightHelper-DpMerFPv.mjs} +3 -3
  15. package/lib/{SpotLightHelper-CfLHM7LU.mjs.map → SpotLightHelper-DpMerFPv.mjs.map} +1 -1
  16. package/lib/{USDZExporter-kmxcTvnQ.mjs → USDZExporter-qUD2VgwK.mjs} +2 -2
  17. package/lib/{USDZExporter-kmxcTvnQ.mjs.map → USDZExporter-qUD2VgwK.mjs.map} +1 -1
  18. package/lib/{Vector4-DUqY3Egg.mjs → Vector4-BfZH1ecw.mjs} +7 -4
  19. package/lib/Vector4-BfZH1ecw.mjs.map +1 -0
  20. package/lib/{api-X1dDTDvL.mjs → api-CbHAzwVm.mjs} +2 -2
  21. package/lib/{api-X1dDTDvL.mjs.map → api-CbHAzwVm.mjs.map} +1 -1
  22. package/lib/asset-loader.worker-A7nEeQB4.mjs.map +1 -1
  23. package/lib/{banana-for-scale-Bpf8RfLi.mjs → banana-for-scale-DiBCpVNM.mjs} +3 -3
  24. package/lib/{banana-for-scale-Bpf8RfLi.mjs.map → banana-for-scale-DiBCpVNM.mjs.map} +1 -1
  25. package/lib/budgeteer.sw-CQWYbQSc.mjs.map +1 -1
  26. package/lib/{common-utils-DMI8Yuhe.mjs → common-utils-AB4Lnet3.mjs} +2 -2
  27. package/lib/{common-utils-DMI8Yuhe.mjs.map → common-utils-AB4Lnet3.mjs.map} +1 -1
  28. package/lib/{component-dimensioning-MtS9xiY-.mjs → component-dimensioning-LUnZnpqG.mjs} +5 -5
  29. package/lib/{component-dimensioning-MtS9xiY-.mjs.map → component-dimensioning-LUnZnpqG.mjs.map} +1 -1
  30. package/lib/{component-raycast-helper-C1qWqpRH.mjs → component-raycast-helper-Bl0mWPcj.mjs} +4 -4
  31. package/lib/{component-raycast-helper-C1qWqpRH.mjs.map → component-raycast-helper-Bl0mWPcj.mjs.map} +1 -1
  32. package/lib/configurator-BmJX0gB5.mjs +2 -0
  33. package/lib/configurator-CP80d0HI.mjs +45 -0
  34. package/lib/{configurator-Cg1a9XSL.mjs.map → configurator-CP80d0HI.mjs.map} +1 -1
  35. package/lib/{continuous-drawing-helper-CQx5Sbns.mjs → continuous-drawing-helper-BlRy7u2t.mjs} +3 -3
  36. package/lib/{continuous-drawing-helper-CQx5Sbns.mjs.map → continuous-drawing-helper-BlRy7u2t.mjs.map} +1 -1
  37. package/lib/dimensioning-helper-5xsc6I7Y.mjs +2 -0
  38. package/lib/{dimensioning-helper-GPn7Z8GE.mjs → dimensioning-helper-vPhGfHd-.mjs} +3 -3
  39. package/lib/{dimensioning-helper-GPn7Z8GE.mjs.map → dimensioning-helper-vPhGfHd-.mjs.map} +1 -1
  40. package/lib/{glb-viewer-tgKOPCaI.mjs → glb-viewer-B7pA8K_w.mjs} +71 -54
  41. package/lib/glb-viewer-B7pA8K_w.mjs.map +1 -0
  42. package/lib/glb-viewer-XFEP993c.mjs +2 -0
  43. package/lib/{highlight-coordinator-DRHeEU-E.mjs → highlight-coordinator-DeB46jQq.mjs} +9 -3
  44. package/lib/highlight-coordinator-DeB46jQq.mjs.map +1 -0
  45. package/lib/{homag-intelligence-D5mCTWgG.mjs → homag-intelligence-f1JD0An1.mjs} +3 -3
  46. package/lib/homag-intelligence-f1JD0An1.mjs.map +1 -0
  47. package/lib/{imos-ix-poc-export-helper-BKFs_Yhm.mjs → imos-ix-poc-export-helper-Vyv-uuNs.mjs} +3 -3
  48. package/lib/{imos-ix-poc-export-helper-BKFs_Yhm.mjs.map → imos-ix-poc-export-helper-Vyv-uuNs.mjs.map} +1 -1
  49. package/lib/kernel-C7YDLxq8.mjs.map +1 -1
  50. package/lib/{kernel-utils-B80amC-l.mjs → kernel-utils-BG1uqfT_.mjs} +2 -2
  51. package/lib/{kernel-utils-B80amC-l.mjs.map → kernel-utils-BG1uqfT_.mjs.map} +1 -1
  52. package/lib/{main-CJ5TNhBt.mjs → main-CuqGqemT.mjs} +2916 -2605
  53. package/lib/main-CuqGqemT.mjs.map +1 -0
  54. package/lib/{material-viewer-DCqZzMZN.mjs → material-viewer-Cij9aWpI.mjs} +23 -23
  55. package/lib/{material-viewer-DCqZzMZN.mjs.map → material-viewer-Cij9aWpI.mjs.map} +1 -1
  56. package/lib/packages-DALvuVA_.mjs +4 -0
  57. package/lib/planner-CVn2Lls0.mjs +2 -0
  58. package/lib/planner-DKbmQVSf.mjs +44 -0
  59. package/lib/{planner-CSboZram.mjs.map → planner-DKbmQVSf.mjs.map} +1 -1
  60. package/lib/{plugin-system-DD0Z9Jvt.mjs → plugin-system-BEZnFUyT.mjs} +2 -2
  61. package/lib/{plugin-system-DD0Z9Jvt.mjs.map → plugin-system-BEZnFUyT.mjs.map} +1 -1
  62. package/lib/{roomle-headless-setup-nsoGENQV.mjs → roomle-headless-setup-CMK-quZI.mjs} +131 -77
  63. package/lib/roomle-headless-setup-CMK-quZI.mjs.map +1 -0
  64. package/lib/roomle-headless.d.ts +333 -44
  65. package/lib/roomle-headless.js +196 -80
  66. package/lib/roomle-headless.js.map +1 -1
  67. package/lib/{roomle-renderer-BEJNPCKx.mjs → roomle-renderer-BgT28pfp.mjs} +2 -2
  68. package/lib/{roomle-renderer-BEJNPCKx.mjs.map → roomle-renderer-BgT28pfp.mjs.map} +1 -1
  69. package/lib/roomle-sdk.d.ts +168 -37
  70. package/lib/roomle-sdk.js +7 -7
  71. package/lib/roomle-webgpu-renderer-BdCItfH1.mjs +2243 -0
  72. package/lib/roomle-webgpu-renderer-BdCItfH1.mjs.map +1 -0
  73. package/lib/{scene-renderer-Dm1kij1z.mjs → scene-renderer-Bdl7umAf.mjs} +6 -6
  74. package/lib/{scene-renderer-Dm1kij1z.mjs.map → scene-renderer-Bdl7umAf.mjs.map} +1 -1
  75. package/lib/{script-loader-DqaDm1FG.mjs → script-loader-BtWHegD-.mjs} +2 -2
  76. package/lib/{script-loader-DqaDm1FG.mjs.map → script-loader-BtWHegD-.mjs.map} +1 -1
  77. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  78. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCallback.d.ts +2 -2
  79. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCallback.js +2 -2
  80. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCallback.js.map +1 -1
  81. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +12 -3
  82. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js +1 -0
  83. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js.map +1 -1
  84. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +43 -2
  85. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js +20 -1
  86. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
  87. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurationLoader.d.ts +1 -1
  88. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurationLoader.js +1 -1
  89. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/loader/configurationLoader.js.map +1 -1
  90. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.js +6 -6
  91. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  92. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.js +8 -8
  93. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  94. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  95. package/lib/{stats-helper-D7a7oxnj.mjs → stats-helper-BvDfWWfq.mjs} +2 -2
  96. package/lib/{stats-helper-D7a7oxnj.mjs.map → stats-helper-BvDfWWfq.mjs.map} +1 -1
  97. package/lib/{three.core-BmQnspOL.mjs → three.core-K1JzUaep.mjs} +748 -706
  98. package/lib/three.core-K1JzUaep.mjs.map +1 -0
  99. package/lib/{three.module-DkrZwaid.mjs → three.module-Q2K9uyhi.mjs} +1022 -965
  100. package/lib/three.module-Q2K9uyhi.mjs.map +1 -0
  101. package/lib/{three.webgpu-DLZjhIYv.mjs → three.webgpu-7v7o6Pxs.mjs} +3804 -3481
  102. package/lib/three.webgpu-7v7o6Pxs.mjs.map +1 -0
  103. package/lib/three.webgpu-ChguPx4k.mjs +3 -0
  104. package/lib/{threejs-utils-CrK_gp1x.mjs → threejs-utils-BzXU2M3w.mjs} +67 -47
  105. package/lib/threejs-utils-BzXU2M3w.mjs.map +1 -0
  106. package/lib/{tools-core-CZWgXTFV.mjs → tools-core-BoxckhTR.mjs} +6 -6
  107. package/lib/{tools-core-CZWgXTFV.mjs.map → tools-core-BoxckhTR.mjs.map} +1 -1
  108. package/package.json +4 -4
  109. package/lib/BufferGeometry-BzmfTBQt.mjs.map +0 -1
  110. package/lib/GLTFExporter-CyhgWPq0.mjs.map +0 -1
  111. package/lib/Object3D-C3wqWk6O.mjs.map +0 -1
  112. package/lib/PointLightHelper-DwIXACyT.mjs.map +0 -1
  113. package/lib/Vector4-DUqY3Egg.mjs.map +0 -1
  114. package/lib/configurator-C5t3clCx.mjs +0 -2
  115. package/lib/configurator-Cg1a9XSL.mjs +0 -45
  116. package/lib/dimensioning-helper-Bfe0fImX.mjs +0 -2
  117. package/lib/glb-viewer-DIEpkrvY.mjs +0 -2
  118. package/lib/glb-viewer-tgKOPCaI.mjs.map +0 -1
  119. package/lib/highlight-coordinator-DRHeEU-E.mjs.map +0 -1
  120. package/lib/homag-intelligence-D5mCTWgG.mjs.map +0 -1
  121. package/lib/main-CJ5TNhBt.mjs.map +0 -1
  122. package/lib/packages-DuOz6rk6.mjs +0 -4
  123. package/lib/planner-CSboZram.mjs +0 -44
  124. package/lib/planner-CWPqJktz.mjs +0 -2
  125. package/lib/roomle-headless-setup-nsoGENQV.mjs.map +0 -1
  126. package/lib/roomle-webgpu-renderer-D5flithq.mjs +0 -1502
  127. package/lib/roomle-webgpu-renderer-D5flithq.mjs.map +0 -1
  128. package/lib/three.core-BmQnspOL.mjs.map +0 -1
  129. package/lib/three.module-DkrZwaid.mjs.map +0 -1
  130. package/lib/three.webgpu-DLZjhIYv.mjs.map +0 -1
  131. package/lib/three.webgpu-RkQxSIwG.mjs +0 -3
  132. package/lib/threejs-utils-CrK_gp1x.mjs.map +0 -1
@@ -1,16 +1,16 @@
1
- import { A as e, B as t, Bi as n, Bn as r, Br as i, C as a, Cr as o, Di as s, Dn as c, Fi as l, Ft as u, Gn as d, Hi as f, Hr as p, Ii as m, J as h, K as g, Kt as _, Mi as v, Ni as y, Nr as b, On as x, Pi as S, Qt as C, R as w, Ri as T, Si as E, Sr as D, T as O, Ti as k, Tn as A, Ui as j, Wn as M, Xt as ee, Yt as te, Zt as ne, _i as N, a as P, ai as F, an as I, bi as L, bn as R, cn as re, di as z, f as ie, fi as ae, gi as oe, j as B, ji as V, jr as se, k as ce, kn as le, kr as ue, li as de, ln as fe, m as pe, mi as me, mt as he, nt as H, on as ge, ot as _e, p as ve, q as ye, rt as be, sn as U, st as xe, tt as Se, ui as Ce, un as we, ut as Te, vi as Ee, vn as De, wi as Oe, wr as ke, x as Ae, xi as W, xn as je, yi as Me, yn as Ne, z as G, zi as Pe, zr as Fe } from "./three.core-BmQnspOL.mjs";
1
+ import { A as e, B as t, Bi as n, Bn as r, Br as i, C as a, Cr as o, Di as s, Dn as c, Fi as l, Ft as u, Gn as d, Hi as f, Hr as p, Ii as m, J as h, K as g, Kt as _, Mi as v, Ni as y, Nr as b, On as x, Pi as S, Qt as C, R as w, Ri as T, Si as E, Sr as D, T as O, Ti as ee, Tn as k, Ui as A, Wn as j, Xt as M, Yt as te, Zt as ne, _i as N, a as P, ai as F, an as I, bi as L, bn as R, cn as re, di as z, f as ie, fi as ae, gi as oe, j as se, ji as B, jr as V, k as ce, kn as le, kr as ue, li as H, ln as de, m as U, mi as fe, mt as pe, nt as me, on as he, ot as ge, p as _e, q as ve, rt as ye, sn as be, st as xe, ui as Se, un as Ce, ut as we, vi as Te, vn as Ee, wi as De, wr as Oe, x as ke, xi as W, xn as Ae, yi as je, yn as Me, z as Ne, zi as G, zr as Pe } from "./three.core-K1JzUaep.mjs";
2
2
  //#region ../../node_modules/three/build/three.module.js
3
- function Ie() {
3
+ function Fe() {
4
4
  let e = null, t = !1, n = null, r = null;
5
5
  function i(t, a) {
6
6
  n(t, a), r = e.requestAnimationFrame(i);
7
7
  }
8
8
  return {
9
9
  start: function() {
10
- t !== !0 && n !== null && (r = e.requestAnimationFrame(i), t = !0);
10
+ t !== !0 && n !== null && e !== null && (r = e.requestAnimationFrame(i), t = !0);
11
11
  },
12
12
  stop: function() {
13
- e.cancelAnimationFrame(r), t = !1;
13
+ e !== null && e.cancelAnimationFrame(r), t = !1;
14
14
  },
15
15
  setAnimationLoop: function(e) {
16
16
  n = e;
@@ -20,7 +20,7 @@ function Ie() {
20
20
  }
21
21
  };
22
22
  }
23
- function Le(e) {
23
+ function Ie(e) {
24
24
  let t = /* @__PURE__ */ new WeakMap();
25
25
  function n(t, n) {
26
26
  let r = t.array, i = t.usage, a = r.byteLength, o = e.createBuffer();
@@ -128,8 +128,8 @@ var K = {
128
128
  emissivemap_pars_fragment: "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",
129
129
  colorspace_fragment: "gl_FragColor = linearToOutputTexel( gl_FragColor );",
130
130
  colorspace_pars_fragment: "vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n 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 );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n 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 );\n}",
131
- envmap_fragment: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif",
132
- envmap_common_pars_fragment: "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",
131
+ envmap_fragment: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif",
132
+ envmap_common_pars_fragment: "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",
133
133
  envmap_pars_fragment: "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",
134
134
  envmap_pars_vertex: "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",
135
135
  envmap_physical_pars_fragment: "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",
@@ -142,16 +142,17 @@ var K = {
142
142
  lightmap_pars_fragment: "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",
143
143
  lights_lambert_fragment: "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",
144
144
  lights_lambert_pars_fragment: "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",
145
- lights_pars_begin: "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",
145
+ lights_pars_begin: "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>",
146
146
  lights_toon_fragment: "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",
147
147
  lights_toon_pars_fragment: "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",
148
148
  lights_phong_fragment: "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",
149
149
  lights_phong_pars_fragment: "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",
150
150
  lights_physical_fragment: "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",
151
- lights_physical_pars_fragment: "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n 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 ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",
152
- lights_fragment_begin: "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
151
+ lights_physical_pars_fragment: "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n 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 ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",
152
+ lights_fragment_begin: "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
153
153
  lights_fragment_maps: "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",
154
154
  lights_fragment_end: "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",
155
+ lightprobes_pars_fragment: "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif",
155
156
  logdepthbuf_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",
156
157
  logdepthbuf_pars_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",
157
158
  logdepthbuf_pars_vertex: "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",
@@ -168,7 +169,7 @@ var K = {
168
169
  morphtarget_pars_vertex: "#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",
169
170
  morphtarget_vertex: "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",
170
171
  normal_fragment_begin: "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",
171
- normal_fragment_maps: "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",
172
+ normal_fragment_maps: "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",
172
173
  normal_pars_fragment: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",
173
174
  normal_pars_vertex: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",
174
175
  normal_vertex: "#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",
@@ -187,7 +188,7 @@ var K = {
187
188
  roughnessmap_pars_fragment: "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",
188
189
  shadowmap_pars_fragment: "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",
189
190
  shadowmap_pars_vertex: "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",
190
- shadowmap_vertex: "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",
191
+ shadowmap_vertex: "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",
191
192
  shadowmask_pars_fragment: "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",
192
193
  skinbase_vertex: "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",
193
194
  skinning_pars_vertex: "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",
@@ -206,7 +207,7 @@ var K = {
206
207
  background_vert: "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",
207
208
  background_frag: "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n 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 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
208
209
  backgroundCube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",
209
- backgroundCube_frag: "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
210
+ backgroundCube_frag: "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
210
211
  cube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}",
211
212
  cube_frag: "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}",
212
213
  depth_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}",
@@ -254,7 +255,6 @@ var K = {
254
255
  envmap: {
255
256
  envMap: { value: null },
256
257
  envMapRotation: { value: /* @__PURE__ */ new I() },
257
- flipEnvMap: { value: -1 },
258
258
  reflectivity: { value: 1 },
259
259
  ior: { value: 1.5 },
260
260
  refractionRatio: { value: .98 },
@@ -390,7 +390,11 @@ var K = {
390
390
  }
391
391
  },
392
392
  ltc_1: { value: null },
393
- ltc_2: { value: null }
393
+ ltc_2: { value: null },
394
+ probesSH: { value: null },
395
+ probesMin: { value: /* @__PURE__ */ new W() },
396
+ probesMax: { value: /* @__PURE__ */ new W() },
397
+ probesResolution: { value: /* @__PURE__ */ new W() }
394
398
  },
395
399
  points: {
396
400
  diffuse: { value: /* @__PURE__ */ new a(16777215) },
@@ -416,7 +420,7 @@ var K = {
416
420
  }
417
421
  }, J = {
418
422
  basic: {
419
- uniforms: /* @__PURE__ */ Pe([
423
+ uniforms: /* @__PURE__ */ G([
420
424
  q.common,
421
425
  q.specularmap,
422
426
  q.envmap,
@@ -428,7 +432,7 @@ var K = {
428
432
  fragmentShader: K.meshbasic_frag
429
433
  },
430
434
  lambert: {
431
- uniforms: /* @__PURE__ */ Pe([
435
+ uniforms: /* @__PURE__ */ G([
432
436
  q.common,
433
437
  q.specularmap,
434
438
  q.envmap,
@@ -449,7 +453,7 @@ var K = {
449
453
  fragmentShader: K.meshlambert_frag
450
454
  },
451
455
  phong: {
452
- uniforms: /* @__PURE__ */ Pe([
456
+ uniforms: /* @__PURE__ */ G([
453
457
  q.common,
454
458
  q.specularmap,
455
459
  q.envmap,
@@ -472,7 +476,7 @@ var K = {
472
476
  fragmentShader: K.meshphong_frag
473
477
  },
474
478
  standard: {
475
- uniforms: /* @__PURE__ */ Pe([
479
+ uniforms: /* @__PURE__ */ G([
476
480
  q.common,
477
481
  q.envmap,
478
482
  q.aomap,
@@ -496,7 +500,7 @@ var K = {
496
500
  fragmentShader: K.meshphysical_frag
497
501
  },
498
502
  toon: {
499
- uniforms: /* @__PURE__ */ Pe([
503
+ uniforms: /* @__PURE__ */ G([
500
504
  q.common,
501
505
  q.aomap,
502
506
  q.lightmap,
@@ -513,7 +517,7 @@ var K = {
513
517
  fragmentShader: K.meshtoon_frag
514
518
  },
515
519
  matcap: {
516
- uniforms: /* @__PURE__ */ Pe([
520
+ uniforms: /* @__PURE__ */ G([
517
521
  q.common,
518
522
  q.bumpmap,
519
523
  q.normalmap,
@@ -525,12 +529,12 @@ var K = {
525
529
  fragmentShader: K.meshmatcap_frag
526
530
  },
527
531
  points: {
528
- uniforms: /* @__PURE__ */ Pe([q.points, q.fog]),
532
+ uniforms: /* @__PURE__ */ G([q.points, q.fog]),
529
533
  vertexShader: K.points_vert,
530
534
  fragmentShader: K.points_frag
531
535
  },
532
536
  dashed: {
533
- uniforms: /* @__PURE__ */ Pe([
537
+ uniforms: /* @__PURE__ */ G([
534
538
  q.common,
535
539
  q.fog,
536
540
  {
@@ -543,12 +547,12 @@ var K = {
543
547
  fragmentShader: K.linedashed_frag
544
548
  },
545
549
  depth: {
546
- uniforms: /* @__PURE__ */ Pe([q.common, q.displacementmap]),
550
+ uniforms: /* @__PURE__ */ G([q.common, q.displacementmap]),
547
551
  vertexShader: K.depth_vert,
548
552
  fragmentShader: K.depth_frag
549
553
  },
550
554
  normal: {
551
- uniforms: /* @__PURE__ */ Pe([
555
+ uniforms: /* @__PURE__ */ G([
552
556
  q.common,
553
557
  q.bumpmap,
554
558
  q.normalmap,
@@ -559,7 +563,7 @@ var K = {
559
563
  fragmentShader: K.meshnormal_frag
560
564
  },
561
565
  sprite: {
562
- uniforms: /* @__PURE__ */ Pe([q.sprite, q.fog]),
566
+ uniforms: /* @__PURE__ */ G([q.sprite, q.fog]),
563
567
  vertexShader: K.sprite_vert,
564
568
  fragmentShader: K.sprite_frag
565
569
  },
@@ -575,7 +579,6 @@ var K = {
575
579
  backgroundCube: {
576
580
  uniforms: {
577
581
  envMap: { value: null },
578
- flipEnvMap: { value: -1 },
579
582
  backgroundBlurriness: { value: 0 },
580
583
  backgroundIntensity: { value: 1 },
581
584
  backgroundRotation: { value: /* @__PURE__ */ new I() }
@@ -598,7 +601,7 @@ var K = {
598
601
  fragmentShader: K.equirect_frag
599
602
  },
600
603
  distance: {
601
- uniforms: /* @__PURE__ */ Pe([
604
+ uniforms: /* @__PURE__ */ G([
602
605
  q.common,
603
606
  q.displacementmap,
604
607
  {
@@ -611,7 +614,7 @@ var K = {
611
614
  fragmentShader: K.distance_frag
612
615
  },
613
616
  shadow: {
614
- uniforms: /* @__PURE__ */ Pe([
617
+ uniforms: /* @__PURE__ */ G([
615
618
  q.lights,
616
619
  q.fog,
617
620
  {
@@ -624,7 +627,7 @@ var K = {
624
627
  }
625
628
  };
626
629
  J.physical = {
627
- uniforms: /* @__PURE__ */ Pe([J.standard.uniforms, {
630
+ uniforms: /* @__PURE__ */ G([J.standard.uniforms, {
628
631
  clearcoat: { value: 0 },
629
632
  clearcoatMap: { value: null },
630
633
  clearcoatMapTransform: { value: /* @__PURE__ */ new I() },
@@ -673,12 +676,13 @@ J.physical = {
673
676
  vertexShader: K.meshphysical_vert,
674
677
  fragmentShader: K.meshphysical_frag
675
678
  };
676
- var Re = {
679
+ var Y = {
677
680
  r: 0,
678
681
  b: 0,
679
682
  g: 0
680
- }, Y = /* @__PURE__ */ new Se(), X = /* @__PURE__ */ new ge();
681
- function ze(e, t, n, r, o, s) {
683
+ }, Le = /* @__PURE__ */ new he(), X = /* @__PURE__ */ new I();
684
+ X.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
685
+ function Re(e, t, n, r, o, s) {
682
686
  let c = new a(0), l = o === !0 ? 0 : 1, u, d, f = null, h = 0, g = null;
683
687
  function _(e) {
684
688
  let n = e.isScene === !0 ? e.background : null;
@@ -696,9 +700,9 @@ function ze(e, t, n, r, o, s) {
696
700
  }
697
701
  function y(t, n) {
698
702
  let a = _(n);
699
- a && (a.isCubeTexture || a.mapping === 306) ? (d === void 0 && (d = new U(new ie(1, 1, 1), new p({
703
+ a && (a.isCubeTexture || a.mapping === 306) ? (d === void 0 && (d = new be(new ie(1, 1, 1), new p({
700
704
  name: "BackgroundCubeMaterial",
701
- uniforms: V(J.backgroundCube.uniforms),
705
+ uniforms: B(J.backgroundCube.uniforms),
702
706
  vertexShader: J.backgroundCube.vertexShader,
703
707
  fragmentShader: J.backgroundCube.fragmentShader,
704
708
  side: 1,
@@ -710,9 +714,9 @@ function ze(e, t, n, r, o, s) {
710
714
  this.matrixWorld.copyPosition(n.matrixWorld);
711
715
  }, Object.defineProperty(d.material, "envMap", { get: function() {
712
716
  return this.uniforms.envMap.value;
713
- } }), r.update(d)), Y.copy(n.backgroundRotation), Y.x *= -1, Y.y *= -1, Y.z *= -1, a.isCubeTexture && a.isRenderTargetTexture === !1 && (Y.y *= -1, Y.z *= -1), d.material.uniforms.envMap.value = a, d.material.uniforms.flipEnvMap.value = a.isCubeTexture && a.isRenderTargetTexture === !1 ? -1 : 1, d.material.uniforms.backgroundBlurriness.value = n.backgroundBlurriness, d.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, d.material.uniforms.backgroundRotation.value.setFromMatrix4(X.makeRotationFromEuler(Y)), d.material.toneMapped = O.getTransfer(a.colorSpace) !== i, (f !== a || h !== a.version || g !== e.toneMapping) && (d.material.needsUpdate = !0, f = a, h = a.version, g = e.toneMapping), d.layers.enableAll(), t.unshift(d, d.geometry, d.material, 0, 0, null)) : a && a.isTexture && (u === void 0 && (u = new U(new le(2, 2), new p({
717
+ } }), r.update(d)), d.material.uniforms.envMap.value = a, d.material.uniforms.backgroundBlurriness.value = n.backgroundBlurriness, d.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, d.material.uniforms.backgroundRotation.value.setFromMatrix4(Le.makeRotationFromEuler(n.backgroundRotation)).transpose(), a.isCubeTexture && a.isRenderTargetTexture === !1 && d.material.uniforms.backgroundRotation.value.premultiply(X), d.material.toneMapped = O.getTransfer(a.colorSpace) !== i, (f !== a || h !== a.version || g !== e.toneMapping) && (d.material.needsUpdate = !0, f = a, h = a.version, g = e.toneMapping), d.layers.enableAll(), t.unshift(d, d.geometry, d.material, 0, 0, null)) : a && a.isTexture && (u === void 0 && (u = new be(new le(2, 2), new p({
714
718
  name: "BackgroundMaterial",
715
- uniforms: V(J.background.uniforms),
719
+ uniforms: B(J.background.uniforms),
716
720
  vertexShader: J.background.vertexShader,
717
721
  fragmentShader: J.background.fragmentShader,
718
722
  side: 0,
@@ -725,7 +729,7 @@ function ze(e, t, n, r, o, s) {
725
729
  } }), r.update(u)), u.material.uniforms.t2D.value = a, u.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, u.material.toneMapped = O.getTransfer(a.colorSpace) !== i, a.matrixAutoUpdate === !0 && a.updateMatrix(), u.material.uniforms.uvTransform.value.copy(a.matrix), (f !== a || h !== a.version || g !== e.toneMapping) && (u.material.needsUpdate = !0, f = a, h = a.version, g = e.toneMapping), u.layers.enableAll(), t.unshift(u, u.geometry, u.material, 0, 0, null));
726
730
  }
727
731
  function b(t, r) {
728
- t.getRGB(Re, m(e)), n.buffers.color.setClear(Re.r, Re.g, Re.b, r, s);
732
+ t.getRGB(Y, m(e)), n.buffers.color.setClear(Y.r, Y.g, Y.b, r, s);
729
733
  }
730
734
  function x() {
731
735
  d !== void 0 && (d.geometry.dispose(), d.material.dispose(), d = void 0), u !== void 0 && (u.geometry.dispose(), u.material.dispose(), u = void 0);
@@ -748,7 +752,7 @@ function ze(e, t, n, r, o, s) {
748
752
  dispose: x
749
753
  };
750
754
  }
751
- function Be(e, t) {
755
+ function ze(e, t) {
752
756
  let n = e.getParameter(e.MAX_VERTEX_ATTRIBS), r = {}, i = f(null), a = i, o = !1;
753
757
  function s(n, r, i, s, c) {
754
758
  let u = !1, f = d(n, s, i, r);
@@ -943,7 +947,7 @@ function Be(e, t) {
943
947
  disableUnusedAttributes: v
944
948
  };
945
949
  }
946
- function Ve(e, t, n) {
950
+ function Be(e, t, n) {
947
951
  let r;
948
952
  function i(e) {
949
953
  r = e;
@@ -961,20 +965,9 @@ function Ve(e, t, n) {
961
965
  for (let e = 0; e < a; e++) o += i[e];
962
966
  n.update(o, r, 1);
963
967
  }
964
- function c(e, i, a, s) {
965
- if (a === 0) return;
966
- let c = t.get("WEBGL_multi_draw");
967
- if (c === null) for (let t = 0; t < e.length; t++) o(e[t], i[t], s[t]);
968
- else {
969
- c.multiDrawArraysInstancedWEBGL(r, e, 0, i, 0, s, 0, a);
970
- let t = 0;
971
- for (let e = 0; e < a; e++) t += i[e] * s[e];
972
- n.update(t, r, 1);
973
- }
974
- }
975
- this.setMode = i, this.render = a, this.renderInstances = o, this.renderMultiDraw = s, this.renderMultiDrawInstances = c;
968
+ this.setMode = i, this.render = a, this.renderInstances = o, this.renderMultiDraw = s;
976
969
  }
977
- function He(e, t, n, r) {
970
+ function Ve(e, t, n, r) {
978
971
  let i;
979
972
  function a() {
980
973
  if (i !== void 0) return i;
@@ -1000,7 +993,9 @@ function He(e, t, n, r) {
1000
993
  }
1001
994
  let l = n.precision === void 0 ? "highp" : n.precision, u = c(l);
1002
995
  u !== l && (f("WebGLRenderer:", l, "not supported, using", u, "instead."), l = u);
1003
- let d = n.logarithmicDepthBuffer === !0, p = n.reversedDepthBuffer === !0 && t.has("EXT_clip_control"), m = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), h = e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS), g = e.getParameter(e.MAX_TEXTURE_SIZE), _ = e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE), v = e.getParameter(e.MAX_VERTEX_ATTRIBS), y = e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS), b = e.getParameter(e.MAX_VARYING_VECTORS), x = e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS), S = e.getParameter(e.MAX_SAMPLES), C = e.getParameter(e.SAMPLES);
996
+ let d = n.logarithmicDepthBuffer === !0, p = n.reversedDepthBuffer === !0 && t.has("EXT_clip_control");
997
+ n.reversedDepthBuffer === !0 && p === !1 && f("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
998
+ let m = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), h = e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS), g = e.getParameter(e.MAX_TEXTURE_SIZE), _ = e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE), v = e.getParameter(e.MAX_VERTEX_ATTRIBS), y = e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS), b = e.getParameter(e.MAX_VARYING_VECTORS), x = e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS), S = e.getParameter(e.MAX_SAMPLES), C = e.getParameter(e.SAMPLES);
1004
999
  return {
1005
1000
  isWebGL2: !0,
1006
1001
  getMaxAnisotropy: a,
@@ -1022,7 +1017,7 @@ function He(e, t, n, r) {
1022
1017
  samples: C
1023
1018
  };
1024
1019
  }
1025
- function Ue(e) {
1020
+ function He(e) {
1026
1021
  let t = this, n = null, r = 0, i = !1, a = !1, o = new x(), s = new I(), c = {
1027
1022
  value: null,
1028
1023
  needsUpdate: !1
@@ -1062,20 +1057,20 @@ function Ue(e) {
1062
1057
  return t.numPlanes = a, t.numIntersection = 0, l;
1063
1058
  }
1064
1059
  }
1065
- var We = 4, Ge = [
1060
+ var Z = 4, Ue = [
1066
1061
  .125,
1067
1062
  .215,
1068
1063
  .35,
1069
1064
  .446,
1070
1065
  .526,
1071
1066
  .582
1072
- ], Ke = 20, qe = 256, Je = /* @__PURE__ */ new A(), Ye = /* @__PURE__ */ new a(), Xe = null, Ze = 0, Qe = 0, $e = !1, et = /* @__PURE__ */ new W(), tt = class {
1067
+ ], We = 20, Ge = 256, Ke = /* @__PURE__ */ new k(), qe = /* @__PURE__ */ new a(), Je = null, Ye = 0, Xe = 0, Ze = !1, Qe = /* @__PURE__ */ new W(), $e = class {
1073
1068
  constructor(e) {
1074
1069
  this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._sizeLods = [], this._sigmas = [], this._lodMeshes = [], this._backgroundBox = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._blurMaterial = null, this._ggxMaterial = null;
1075
1070
  }
1076
1071
  fromScene(e, t = 0, n = .1, r = 100, i = {}) {
1077
- let { size: a = 256, position: o = et } = i;
1078
- Xe = this._renderer.getRenderTarget(), Ze = this._renderer.getActiveCubeFace(), Qe = this._renderer.getActiveMipmapLevel(), $e = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a);
1072
+ let { size: a = 256, position: o = Qe } = i;
1073
+ Je = this._renderer.getRenderTarget(), Ye = this._renderer.getActiveCubeFace(), Xe = this._renderer.getActiveMipmapLevel(), Ze = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a);
1079
1074
  let s = this._allocateTargets();
1080
1075
  return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s, o), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s;
1081
1076
  }
@@ -1086,10 +1081,10 @@ var We = 4, Ge = [
1086
1081
  return this._fromTexture(e, t);
1087
1082
  }
1088
1083
  compileCubemapShader() {
1089
- this._cubemapMaterial === null && (this._cubemapMaterial = Z(), this._compileMaterial(this._cubemapMaterial));
1084
+ this._cubemapMaterial === null && (this._cubemapMaterial = ot(), this._compileMaterial(this._cubemapMaterial));
1090
1085
  }
1091
1086
  compileEquirectangularShader() {
1092
- this._equirectMaterial === null && (this._equirectMaterial = st(), this._compileMaterial(this._equirectMaterial));
1087
+ this._equirectMaterial === null && (this._equirectMaterial = at(), this._compileMaterial(this._equirectMaterial));
1093
1088
  }
1094
1089
  dispose() {
1095
1090
  this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(), this._backgroundBox !== null && (this._backgroundBox.geometry.dispose(), this._backgroundBox.material.dispose());
@@ -1102,10 +1097,10 @@ var We = 4, Ge = [
1102
1097
  for (let e = 0; e < this._lodMeshes.length; e++) this._lodMeshes[e].geometry.dispose();
1103
1098
  }
1104
1099
  _cleanup(e) {
1105
- this._renderer.setRenderTarget(Xe, Ze, Qe), this._renderer.xr.enabled = $e, e.scissorTest = !1, it(e, 0, 0, e.width, e.height);
1100
+ this._renderer.setRenderTarget(Je, Ye, Xe), this._renderer.xr.enabled = Ze, e.scissorTest = !1, nt(e, 0, 0, e.width, e.height);
1106
1101
  }
1107
1102
  _fromTexture(e, t) {
1108
- e.mapping === 301 || e.mapping === 302 ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), Xe = this._renderer.getRenderTarget(), Ze = this._renderer.getActiveCubeFace(), Qe = this._renderer.getActiveMipmapLevel(), $e = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
1103
+ e.mapping === 301 || e.mapping === 302 ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), Je = this._renderer.getRenderTarget(), Ye = this._renderer.getActiveCubeFace(), Xe = this._renderer.getActiveMipmapLevel(), Ze = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
1109
1104
  let n = t || this._allocateTargets();
1110
1105
  return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n;
1111
1106
  }
@@ -1114,21 +1109,21 @@ var We = 4, Ge = [
1114
1109
  magFilter: _,
1115
1110
  minFilter: _,
1116
1111
  generateMipmaps: !1,
1117
- type: he,
1118
- format: M,
1112
+ type: pe,
1113
+ format: j,
1119
1114
  colorSpace: ne,
1120
1115
  depthBuffer: !1
1121
- }, r = rt(e, t, n);
1116
+ }, r = tt(e, t, n);
1122
1117
  if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
1123
- this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = rt(e, t, n);
1118
+ this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = tt(e, t, n);
1124
1119
  let { _lodMax: r } = this;
1125
- ({lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas} = nt(r)), this._blurMaterial = ot(r, e, t), this._ggxMaterial = at(r, e, t);
1120
+ ({lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas} = et(r)), this._blurMaterial = it(r, e, t), this._ggxMaterial = rt(r, e, t);
1126
1121
  }
1127
1122
  return r;
1128
1123
  }
1129
1124
  _compileMaterial(e) {
1130
- let t = new U(new pe(), e);
1131
- this._renderer.compile(t, Je);
1125
+ let t = new be(new U(), e);
1126
+ this._renderer.compile(t, Ke);
1132
1127
  }
1133
1128
  _sceneToCubeUV(e, t, n, r, i) {
1134
1129
  let a = new c(90, 1, t, n), o = [
@@ -1146,31 +1141,31 @@ var We = 4, Ge = [
1146
1141
  -1,
1147
1142
  -1
1148
1143
  ], l = this._renderer, u = l.autoClear, d = l.toneMapping;
1149
- l.getClearColor(Ye), l.toneMapping = 0, l.autoClear = !1, l.state.buffers.depth.getReversed() && (l.setRenderTarget(r), l.clearDepth(), l.setRenderTarget(null)), this._backgroundBox === null && (this._backgroundBox = new U(new ie(), new re({
1144
+ l.getClearColor(qe), l.toneMapping = 0, l.autoClear = !1, l.state.buffers.depth.getReversed() && (l.setRenderTarget(r), l.clearDepth(), l.setRenderTarget(null)), this._backgroundBox === null && (this._backgroundBox = new be(new ie(), new re({
1150
1145
  name: "PMREM.Background",
1151
1146
  side: 1,
1152
1147
  depthWrite: !1,
1153
1148
  depthTest: !1
1154
1149
  })));
1155
1150
  let f = this._backgroundBox, p = f.material, m = !1, h = e.background;
1156
- h ? h.isColor && (p.color.copy(h), e.background = null, m = !0) : (p.color.copy(Ye), m = !0);
1151
+ h ? h.isColor && (p.color.copy(h), e.background = null, m = !0) : (p.color.copy(qe), m = !0);
1157
1152
  for (let t = 0; t < 6; t++) {
1158
1153
  let n = t % 3;
1159
1154
  n === 0 ? (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x + s[t], i.y, i.z)) : n === 1 ? (a.up.set(0, 0, o[t]), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y + s[t], i.z)) : (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y, i.z + s[t]));
1160
1155
  let c = this._cubeSize;
1161
- it(r, n * c, t > 2 ? c : 0, c, c), l.setRenderTarget(r), m && l.render(f, a), l.render(e, a);
1156
+ nt(r, n * c, t > 2 ? c : 0, c, c), l.setRenderTarget(r), m && l.render(f, a), l.render(e, a);
1162
1157
  }
1163
1158
  l.toneMapping = d, l.autoClear = u, e.background = h;
1164
1159
  }
1165
1160
  _textureToCubeUV(e, t) {
1166
1161
  let n = this._renderer, r = e.mapping === 301 || e.mapping === 302;
1167
- r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Z()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = st());
1162
+ r ? (this._cubemapMaterial === null && (this._cubemapMaterial = ot()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = at());
1168
1163
  let i = r ? this._cubemapMaterial : this._equirectMaterial, a = this._lodMeshes[0];
1169
1164
  a.material = i;
1170
1165
  let o = i.uniforms;
1171
1166
  o.envMap.value = e;
1172
1167
  let s = this._cubeSize;
1173
- it(t, 0, 0, 3 * s, 2 * s), n.setRenderTarget(t), n.render(a, Je);
1168
+ nt(t, 0, 0, 3 * s, 2 * s), n.setRenderTarget(t), n.render(a, Ke);
1174
1169
  }
1175
1170
  _applyPMREM(e) {
1176
1171
  let t = this._renderer, n = t.autoClear;
@@ -1182,8 +1177,8 @@ var We = 4, Ge = [
1182
1177
  _applyGGXFilter(e, t, n) {
1183
1178
  let r = this._renderer, i = this._pingPongRenderTarget, a = this._ggxMaterial, o = this._lodMeshes[n];
1184
1179
  o.material = a;
1185
- let s = a.uniforms, c = n / (this._lodMeshes.length - 1), l = t / (this._lodMeshes.length - 1), u = Math.sqrt(c * c - l * l) * (0 + c * 1.25), { _lodMax: d } = this, f = this._sizeLods[n], p = 3 * f * (n > d - We ? n - d + We : 0), m = 4 * (this._cubeSize - f);
1186
- s.envMap.value = e.texture, s.roughness.value = u, s.mipInt.value = d - t, it(i, p, m, 3 * f, 2 * f), r.setRenderTarget(i), r.render(o, Je), s.envMap.value = i.texture, s.roughness.value = 0, s.mipInt.value = d - n, it(e, p, m, 3 * f, 2 * f), r.setRenderTarget(e), r.render(o, Je);
1180
+ let s = a.uniforms, c = n / (this._lodMeshes.length - 1), l = t / (this._lodMeshes.length - 1), u = Math.sqrt(c * c - l * l) * (0 + c * 1.25), { _lodMax: d } = this, f = this._sizeLods[n], p = 3 * f * (n > d - Z ? n - d + Z : 0), m = 4 * (this._cubeSize - f);
1181
+ s.envMap.value = e.texture, s.roughness.value = u, s.mipInt.value = d - t, nt(i, p, m, 3 * f, 2 * f), r.setRenderTarget(i), r.render(o, Ke), s.envMap.value = i.texture, s.roughness.value = 0, s.mipInt.value = d - n, nt(e, p, m, 3 * f, 2 * f), r.setRenderTarget(e), r.render(o, Ke);
1187
1182
  }
1188
1183
  _blur(e, t, n, r, i) {
1189
1184
  let a = this._pingPongRenderTarget;
@@ -1194,10 +1189,10 @@ var We = 4, Ge = [
1194
1189
  a !== "latitudinal" && a !== "longitudinal" && S("blur direction must be either latitudinal or longitudinal!");
1195
1190
  let l = this._lodMeshes[r];
1196
1191
  l.material = c;
1197
- let u = c.uniforms, d = this._sizeLods[n] - 1, p = isFinite(i) ? Math.PI / (2 * d) : 2 * Math.PI / (2 * Ke - 1), m = i / p, h = isFinite(i) ? 1 + Math.floor(3 * m) : Ke;
1198
- h > Ke && f(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${Ke}`);
1192
+ let u = c.uniforms, d = this._sizeLods[n] - 1, p = isFinite(i) ? Math.PI / (2 * d) : 2 * Math.PI / (2 * We - 1), m = i / p, h = isFinite(i) ? 1 + Math.floor(3 * m) : We;
1193
+ h > We && f(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${We}`);
1199
1194
  let g = [], _ = 0;
1200
- for (let e = 0; e < Ke; ++e) {
1195
+ for (let e = 0; e < We; ++e) {
1201
1196
  let t = e / m, n = Math.exp(-t * t / 2);
1202
1197
  g.push(n), e === 0 ? _ += n : e < h && (_ += 2 * n);
1203
1198
  }
@@ -1206,16 +1201,16 @@ var We = 4, Ge = [
1206
1201
  let { _lodMax: v } = this;
1207
1202
  u.dTheta.value = p, u.mipInt.value = v - n;
1208
1203
  let y = this._sizeLods[r];
1209
- it(t, 3 * y * (r > v - We ? r - v + We : 0), 4 * (this._cubeSize - y), 3 * y, 2 * y), s.setRenderTarget(t), s.render(l, Je);
1204
+ nt(t, 3 * y * (r > v - Z ? r - v + Z : 0), 4 * (this._cubeSize - y), 3 * y, 2 * y), s.setRenderTarget(t), s.render(l, Ke);
1210
1205
  }
1211
1206
  };
1212
- function nt(e) {
1213
- let t = [], n = [], r = [], i = e, a = e - We + 1 + Ge.length;
1207
+ function et(e) {
1208
+ let t = [], n = [], r = [], i = e, a = e - Z + 1 + Ue.length;
1214
1209
  for (let o = 0; o < a; o++) {
1215
1210
  let a = 2 ** i;
1216
1211
  t.push(a);
1217
1212
  let s = 1 / a;
1218
- o > e - We ? s = Ge[o - e + We - 1] : o === 0 && (s = 0), n.push(s);
1213
+ o > e - Z ? s = Ue[o - e + Z - 1] : o === 0 && (s = 0), n.push(s);
1219
1214
  let c = 1 / (a - 2), l = -c, u = 1 + c, d = [
1220
1215
  l,
1221
1216
  l,
@@ -1262,8 +1257,8 @@ function nt(e) {
1262
1257
  ];
1263
1258
  m.set(i, 6 * e);
1264
1259
  }
1265
- let h = new pe();
1266
- h.setAttribute("position", new ve(f, 3)), h.setAttribute("uv", new ve(p, 2)), h.setAttribute("faceIndex", new ve(m, 1)), r.push(new U(h, null)), i > We && i--;
1260
+ let h = new U();
1261
+ h.setAttribute("position", new _e(f, 3)), h.setAttribute("uv", new _e(p, 2)), h.setAttribute("faceIndex", new _e(m, 1)), r.push(new be(h, null)), i > Z && i--;
1267
1262
  }
1268
1263
  return {
1269
1264
  lodMeshes: r,
@@ -1271,18 +1266,18 @@ function nt(e) {
1271
1266
  sigmas: n
1272
1267
  };
1273
1268
  }
1274
- function rt(e, t, n) {
1275
- let r = new k(e, t, n);
1269
+ function tt(e, t, n) {
1270
+ let r = new ee(e, t, n);
1276
1271
  return r.texture.mapping = 306, r.texture.name = "PMREM.cubeUv", r.scissorTest = !0, r;
1277
1272
  }
1278
- function it(e, t, n, r, i) {
1273
+ function nt(e, t, n, r, i) {
1279
1274
  e.viewport.set(t, n, r, i), e.scissor.set(t, n, r, i);
1280
1275
  }
1281
- function at(e, t, n) {
1276
+ function rt(e, t, n) {
1282
1277
  return new p({
1283
1278
  name: "PMREMGGXConvolution",
1284
1279
  defines: {
1285
- GGX_SAMPLES: qe,
1280
+ GGX_SAMPLES: Ge,
1286
1281
  CUBEUV_TEXEL_WIDTH: 1 / t,
1287
1282
  CUBEUV_TEXEL_HEIGHT: 1 / n,
1288
1283
  CUBEUV_MAX_MIP: `${e}.0`
@@ -1292,19 +1287,19 @@ function at(e, t, n) {
1292
1287
  roughness: { value: 0 },
1293
1288
  mipInt: { value: 0 }
1294
1289
  },
1295
- vertexShader: ct(),
1290
+ vertexShader: Q(),
1296
1291
  fragmentShader: "\n\n precision highp float;\n precision highp int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform float roughness;\n uniform float mipInt;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n #define PI 3.14159265359\n\n // Van der Corput radical inverse\n float radicalInverse_VdC(uint bits) {\n bits = (bits << 16u) | (bits >> 16u);\n bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n return float(bits) * 2.3283064365386963e-10; // / 0x100000000\n }\n\n // Hammersley sequence\n vec2 hammersley(uint i, uint N) {\n return vec2(float(i) / float(N), radicalInverse_VdC(i));\n }\n\n // GGX VNDF importance sampling (Eric Heitz 2018)\n // \"Sampling the GGX Distribution of Visible Normals\"\n // https://jcgt.org/published/0007/04/01/\n vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n float alpha = roughness * roughness;\n\n // Section 4.1: Orthonormal basis\n vec3 T1 = vec3(1.0, 0.0, 0.0);\n vec3 T2 = cross(V, T1);\n\n // Section 4.2: Parameterization of projected area\n float r = sqrt(Xi.x);\n float phi = 2.0 * PI * Xi.y;\n float t1 = r * cos(phi);\n float t2 = r * sin(phi);\n float s = 0.5 * (1.0 + V.z);\n t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n // Section 4.3: Reprojection onto hemisphere\n vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n // Section 3.4: Transform back to ellipsoid configuration\n return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n }\n\n void main() {\n vec3 N = normalize(vOutputDirection);\n vec3 V = N; // Assume view direction equals normal for pre-filtering\n\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n\n // For very low roughness, just sample the environment directly\n if (roughness < 0.001) {\n gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n return;\n }\n\n // Tangent space basis for VNDF sampling\n vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangent = normalize(cross(up, N));\n vec3 bitangent = cross(N, tangent);\n\n for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n vec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n // For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n // Transform H back to world space\n vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n vec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n float NdotL = max(dot(N, L), 0.0);\n\n if(NdotL > 0.0) {\n // Sample environment at fixed mip level\n // VNDF importance sampling handles the distribution filtering\n vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n // Weight by NdotL for the split-sum approximation\n // VNDF PDF naturally accounts for the visible microfacet distribution\n prefilteredColor += sampleColor * NdotL;\n totalWeight += NdotL;\n }\n }\n\n if (totalWeight > 0.0) {\n prefilteredColor = prefilteredColor / totalWeight;\n }\n\n gl_FragColor = vec4(prefilteredColor, 1.0);\n }\n ",
1297
1292
  blending: 0,
1298
1293
  depthTest: !1,
1299
1294
  depthWrite: !1
1300
1295
  });
1301
1296
  }
1302
- function ot(e, t, n) {
1303
- let r = new Float32Array(Ke), i = new W(0, 1, 0);
1297
+ function it(e, t, n) {
1298
+ let r = new Float32Array(We), i = new W(0, 1, 0);
1304
1299
  return new p({
1305
1300
  name: "SphericalGaussianBlur",
1306
1301
  defines: {
1307
- n: Ke,
1302
+ n: We,
1308
1303
  CUBEUV_TEXEL_WIDTH: 1 / t,
1309
1304
  CUBEUV_TEXEL_HEIGHT: 1 / n,
1310
1305
  CUBEUV_MAX_MIP: `${e}.0`
@@ -1318,42 +1313,42 @@ function ot(e, t, n) {
1318
1313
  mipInt: { value: 0 },
1319
1314
  poleAxis: { value: i }
1320
1315
  },
1321
- vertexShader: ct(),
1316
+ vertexShader: Q(),
1322
1317
  fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform float mipInt;\n uniform vec3 poleAxis;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n vec3 getSample( float theta, vec3 axis ) {\n\n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n return bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n }\n\n void main() {\n\n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n }\n\n axis = normalize( axis );\n\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n for ( int i = 1; i < n; i++ ) {\n\n if ( i >= samples ) {\n\n break;\n\n }\n\n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n }\n\n }\n ",
1323
1318
  blending: 0,
1324
1319
  depthTest: !1,
1325
1320
  depthWrite: !1
1326
1321
  });
1327
1322
  }
1328
- function st() {
1323
+ function at() {
1329
1324
  return new p({
1330
1325
  name: "EquirectangularToCubeUV",
1331
1326
  uniforms: { envMap: { value: null } },
1332
- vertexShader: ct(),
1327
+ vertexShader: Q(),
1333
1328
  fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n\n #include <common>\n\n void main() {\n\n vec3 outputDirection = normalize( vOutputDirection );\n vec2 uv = equirectUv( outputDirection );\n\n gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n }\n ",
1334
1329
  blending: 0,
1335
1330
  depthTest: !1,
1336
1331
  depthWrite: !1
1337
1332
  });
1338
1333
  }
1339
- function Z() {
1334
+ function ot() {
1340
1335
  return new p({
1341
1336
  name: "CubemapToCubeUV",
1342
1337
  uniforms: {
1343
1338
  envMap: { value: null },
1344
1339
  flipEnvMap: { value: -1 }
1345
1340
  },
1346
- vertexShader: ct(),
1341
+ vertexShader: Q(),
1347
1342
  fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n uniform float flipEnvMap;\n\n varying vec3 vOutputDirection;\n\n uniform samplerCube envMap;\n\n void main() {\n\n gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n }\n ",
1348
1343
  blending: 0,
1349
1344
  depthTest: !1,
1350
1345
  depthWrite: !1
1351
1346
  });
1352
1347
  }
1353
- function ct() {
1348
+ function Q() {
1354
1349
  return "\n\n precision mediump float;\n precision mediump int;\n\n attribute float faceIndex;\n\n varying vec3 vOutputDirection;\n\n // RH coordinate system; PMREM face-indexing convention\n vec3 getDirection( vec2 uv, float face ) {\n\n uv = 2.0 * uv - 1.0;\n\n vec3 direction = vec3( uv, 1.0 );\n\n if ( face == 0.0 ) {\n\n direction = direction.zyx; // ( 1, v, u ) pos x\n\n } else if ( face == 1.0 ) {\n\n direction = direction.xzy;\n direction.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n } else if ( face == 2.0 ) {\n\n direction.x *= -1.0; // ( -u, v, 1 ) pos z\n\n } else if ( face == 3.0 ) {\n\n direction = direction.zyx;\n direction.xz *= -1.0; // ( -1, v, -u ) neg x\n\n } else if ( face == 4.0 ) {\n\n direction = direction.xzy;\n direction.xy *= -1.0; // ( -u, -1, v ) neg y\n\n } else if ( face == 5.0 ) {\n\n direction.z *= -1.0; // ( u, v, -1 ) neg z\n\n }\n\n return direction;\n\n }\n\n void main() {\n\n vOutputDirection = getDirection( uv, faceIndex );\n gl_Position = vec4( position, 1.0 );\n\n }\n ";
1355
1350
  }
1356
- var lt = class extends k {
1351
+ var st = class extends ee {
1357
1352
  constructor(e = 1, t = {}) {
1358
1353
  super(e, e, t), this.isWebGLCubeRenderTarget = !0;
1359
1354
  let n = {
@@ -1361,7 +1356,7 @@ var lt = class extends k {
1361
1356
  height: e,
1362
1357
  depth: 1
1363
1358
  };
1364
- this.texture = new B([
1359
+ this.texture = new se([
1365
1360
  n,
1366
1361
  n,
1367
1362
  n,
@@ -1378,14 +1373,14 @@ var lt = class extends k {
1378
1373
  fragmentShader: "\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include <common>\n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n "
1379
1374
  }, r = new ie(5, 5, 5), i = new p({
1380
1375
  name: "CubemapFromEquirect",
1381
- uniforms: V(n.uniforms),
1376
+ uniforms: B(n.uniforms),
1382
1377
  vertexShader: n.vertexShader,
1383
1378
  fragmentShader: n.fragmentShader,
1384
1379
  side: 1,
1385
1380
  blending: 0
1386
1381
  });
1387
1382
  i.uniforms.tEquirect.value = t;
1388
- let a = new U(r, i), o = t.minFilter;
1383
+ let a = new be(r, i), o = t.minFilter;
1389
1384
  return t.minFilter === 1008 && (t.minFilter = _), new ce(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this;
1390
1385
  }
1391
1386
  clear(e, t = !0, n = !0, r = !0) {
@@ -1394,7 +1389,7 @@ var lt = class extends k {
1394
1389
  e.setRenderTarget(i);
1395
1390
  }
1396
1391
  };
1397
- function ut(e) {
1392
+ function ct(e) {
1398
1393
  let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = null;
1399
1394
  function i(e, t = !1) {
1400
1395
  return e == null ? null : t ? o(e) : a(e);
@@ -1408,7 +1403,7 @@ function ut(e) {
1408
1403
  } else {
1409
1404
  let r = n.image;
1410
1405
  if (r && r.height > 0) {
1411
- let i = new lt(r.height);
1406
+ let i = new st(r.height);
1412
1407
  return i.fromEquirectangularTexture(e, n), t.set(n, i), n.addEventListener("dispose", l), s(i.texture, n.mapping);
1413
1408
  } else return null;
1414
1409
  }
@@ -1420,11 +1415,11 @@ function ut(e) {
1420
1415
  let i = t.mapping, a = i === 303 || i === 304, o = i === 301 || i === 302;
1421
1416
  if (a || o) {
1422
1417
  let i = n.get(t), s = i === void 0 ? 0 : i.texture.pmremVersion;
1423
- if (t.isRenderTargetTexture && t.pmremVersion !== s) return r === null && (r = new tt(e)), i = a ? r.fromEquirectangular(t, i) : r.fromCubemap(t, i), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), i.texture;
1418
+ if (t.isRenderTargetTexture && t.pmremVersion !== s) return r === null && (r = new $e(e)), i = a ? r.fromEquirectangular(t, i) : r.fromCubemap(t, i), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), i.texture;
1424
1419
  if (i !== void 0) return i.texture;
1425
1420
  {
1426
1421
  let s = t.image;
1427
- return a && s && s.height > 0 || o && s && c(s) ? (r === null && (r = new tt(e)), i = a ? r.fromEquirectangular(t) : r.fromCubemap(t), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), t.addEventListener("dispose", u), i.texture) : null;
1422
+ return a && s && s.height > 0 || o && s && c(s) ? (r === null && (r = new $e(e)), i = a ? r.fromEquirectangular(t) : r.fromCubemap(t), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), t.addEventListener("dispose", u), i.texture) : null;
1428
1423
  }
1429
1424
  }
1430
1425
  }
@@ -1458,7 +1453,7 @@ function ut(e) {
1458
1453
  dispose: d
1459
1454
  };
1460
1455
  }
1461
- function dt(e) {
1456
+ function lt(e) {
1462
1457
  let t = {};
1463
1458
  function n(n) {
1464
1459
  if (t[n] !== void 0) return t[n];
@@ -1474,11 +1469,11 @@ function dt(e) {
1474
1469
  },
1475
1470
  get: function(e) {
1476
1471
  let t = n(e);
1477
- return t === null && j("WebGLRenderer: " + e + " extension not supported."), t;
1472
+ return t === null && A("WebGLRenderer: " + e + " extension not supported."), t;
1478
1473
  }
1479
1474
  };
1480
1475
  }
1481
- function ft(e, t, n, r) {
1476
+ function ut(e, t, n, r) {
1482
1477
  let i = {}, a = /* @__PURE__ */ new WeakMap();
1483
1478
  function o(e) {
1484
1479
  let s = e.target;
@@ -1513,7 +1508,7 @@ function ft(e, t, n, r) {
1513
1508
  n.push(e, r, r, i, i, e);
1514
1509
  }
1515
1510
  }
1516
- let s = new (i.count >= 65535 ? Ce : de)(n, 1);
1511
+ let s = new (i.count >= 65535 ? Se : H)(n, 1);
1517
1512
  s.version = o;
1518
1513
  let c = a.get(e);
1519
1514
  c && t.remove(c), a.set(e, s);
@@ -1532,7 +1527,7 @@ function ft(e, t, n, r) {
1532
1527
  getWireframeAttribute: u
1533
1528
  };
1534
1529
  }
1535
- function pt(e, t, n) {
1530
+ function dt(e, t, n) {
1536
1531
  let r;
1537
1532
  function i(e) {
1538
1533
  r = e;
@@ -1554,20 +1549,9 @@ function pt(e, t, n) {
1554
1549
  for (let e = 0; e < o; e++) s += i[e];
1555
1550
  n.update(s, r, 1);
1556
1551
  }
1557
- function d(e, i, s, c) {
1558
- if (s === 0) return;
1559
- let u = t.get("WEBGL_multi_draw");
1560
- if (u === null) for (let t = 0; t < e.length; t++) l(e[t] / o, i[t], c[t]);
1561
- else {
1562
- u.multiDrawElementsInstancedWEBGL(r, i, 0, a, e, 0, c, 0, s);
1563
- let t = 0;
1564
- for (let e = 0; e < s; e++) t += i[e] * c[e];
1565
- n.update(t, r, 1);
1566
- }
1567
- }
1568
- this.setMode = i, this.setIndex = s, this.render = c, this.renderInstances = l, this.renderMultiDraw = u, this.renderMultiDrawInstances = d;
1552
+ this.setMode = i, this.setIndex = s, this.render = c, this.renderInstances = l, this.renderMultiDraw = u;
1569
1553
  }
1570
- function mt(e) {
1554
+ function ft(e) {
1571
1555
  let t = {
1572
1556
  geometries: 0,
1573
1557
  textures: 0
@@ -1612,7 +1596,7 @@ function mt(e) {
1612
1596
  update: r
1613
1597
  };
1614
1598
  }
1615
- function ht(e, t, n) {
1599
+ function pt(e, t, n) {
1616
1600
  let r = /* @__PURE__ */ new WeakMap(), i = new E();
1617
1601
  function a(a, o, s) {
1618
1602
  let c = a.morphTargetInfluences, l = o.morphAttributes.position || o.morphAttributes.normal || o.morphAttributes.color, u = l === void 0 ? 0 : l.length, d = r.get(o);
@@ -1622,7 +1606,7 @@ function ht(e, t, n) {
1622
1606
  e === !0 && (f = 1), n === !0 && (f = 2), a === !0 && (f = 3);
1623
1607
  let p = o.attributes.position.count * f, m = 1;
1624
1608
  p > t.maxTextureSize && (m = Math.ceil(p / t.maxTextureSize), p = t.maxTextureSize);
1625
- let h = new Float32Array(p * m * 4 * u), g = new G(h, p, m, u);
1609
+ let h = new Float32Array(p * m * 4 * u), g = new Ne(h, p, m, u);
1626
1610
  g.type = xe, g.needsUpdate = !0;
1627
1611
  let _ = f * 4;
1628
1612
  for (let t = 0; t < u; t++) {
@@ -1653,7 +1637,7 @@ function ht(e, t, n) {
1653
1637
  }
1654
1638
  return { update: a };
1655
1639
  }
1656
- function gt(e, t, n, r, i) {
1640
+ function mt(e, t, n, r, i) {
1657
1641
  let a = /* @__PURE__ */ new WeakMap();
1658
1642
  function o(r) {
1659
1643
  let o = i.render.frame, s = r.geometry, l = t.get(r, s);
@@ -1675,7 +1659,7 @@ function gt(e, t, n, r, i) {
1675
1659
  dispose: s
1676
1660
  };
1677
1661
  }
1678
- var _t = {
1662
+ var ht = {
1679
1663
  1: "LINEAR_TONE_MAPPING",
1680
1664
  2: "REINHARD_TONE_MAPPING",
1681
1665
  3: "CINEON_TONE_MAPPING",
@@ -1684,17 +1668,18 @@ var _t = {
1684
1668
  7: "NEUTRAL_TONE_MAPPING",
1685
1669
  5: "CUSTOM_TONE_MAPPING"
1686
1670
  };
1687
- function vt(e, t, n, r, i) {
1688
- let a = new k(t, n, {
1671
+ function gt(e, t, n, r, i) {
1672
+ let a = new ee(t, n, {
1689
1673
  type: e,
1690
1674
  depthBuffer: r,
1691
- stencilBuffer: i
1692
- }), o = new k(t, n, {
1693
- type: he,
1675
+ stencilBuffer: i,
1676
+ depthTexture: r ? new h(t, n) : void 0
1677
+ }), o = new ee(t, n, {
1678
+ type: pe,
1694
1679
  depthBuffer: !1,
1695
1680
  stencilBuffer: !1
1696
- }), s = new pe();
1697
- s.setAttribute("position", new _e([
1681
+ }), s = new U();
1682
+ s.setAttribute("position", new ge([
1698
1683
  -1,
1699
1684
  3,
1700
1685
  0,
@@ -1704,7 +1689,7 @@ function vt(e, t, n, r, i) {
1704
1689
  3,
1705
1690
  -1,
1706
1691
  0
1707
- ], 3)), s.setAttribute("uv", new _e([
1692
+ ], 3)), s.setAttribute("uv", new ge([
1708
1693
  0,
1709
1694
  2,
1710
1695
  0,
@@ -1712,40 +1697,40 @@ function vt(e, t, n, r, i) {
1712
1697
  2,
1713
1698
  0
1714
1699
  ], 2));
1715
- let c = new ke({
1700
+ let c = new Oe({
1716
1701
  uniforms: { tDiffuse: { value: null } },
1717
1702
  vertexShader: "\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
1718
1703
  fragmentShader: "\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n #ifdef LINEAR_TONE_MAPPING\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n #elif defined( REINHARD_TONE_MAPPING )\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n #elif defined( CINEON_TONE_MAPPING )\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n #elif defined( AGX_TONE_MAPPING )\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n #elif defined( NEUTRAL_TONE_MAPPING )\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n #elif defined( CUSTOM_TONE_MAPPING )\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n #endif\n\n #ifdef SRGB_TRANSFER\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n #endif\n }",
1719
1704
  depthTest: !1,
1720
1705
  depthWrite: !1
1721
- }), l = new U(s, c), u = new A(-1, 1, 1, -1, 0, 1), d = null, f = null, p = !1, m, h = null, g = [], _ = !1;
1706
+ }), l = new be(s, c), u = new k(-1, 1, 1, -1, 0, 1), d = null, f = null, p = !1, m, g = null, _ = [], v = !1;
1722
1707
  this.setSize = function(e, t) {
1723
1708
  a.setSize(e, t), o.setSize(e, t);
1724
- for (let n = 0; n < g.length; n++) {
1725
- let r = g[n];
1709
+ for (let n = 0; n < _.length; n++) {
1710
+ let r = _[n];
1726
1711
  r.setSize && r.setSize(e, t);
1727
1712
  }
1728
1713
  }, this.setEffects = function(e) {
1729
- g = e, _ = g.length > 0 && g[0].isRenderPass === !0;
1714
+ _ = e, v = _.length > 0 && _[0].isRenderPass === !0;
1730
1715
  let t = a.width, n = a.height;
1731
- for (let e = 0; e < g.length; e++) {
1732
- let r = g[e];
1716
+ for (let e = 0; e < _.length; e++) {
1717
+ let r = _[e];
1733
1718
  r.setSize && r.setSize(t, n);
1734
1719
  }
1735
1720
  }, this.begin = function(e, t) {
1736
- if (p || e.toneMapping === 0 && g.length === 0) return !1;
1737
- if (h = t, t !== null) {
1721
+ if (p || e.toneMapping === 0 && _.length === 0) return !1;
1722
+ if (g = t, t !== null) {
1738
1723
  let e = t.width, n = t.height;
1739
1724
  (a.width !== e || a.height !== n) && this.setSize(e, n);
1740
1725
  }
1741
- return _ === !1 && e.setRenderTarget(a), m = e.toneMapping, e.toneMapping = 0, !0;
1726
+ return v === !1 && e.setRenderTarget(a), m = e.toneMapping, e.toneMapping = 0, !0;
1742
1727
  }, this.hasRenderPass = function() {
1743
- return _;
1728
+ return v;
1744
1729
  }, this.end = function(e, t) {
1745
1730
  e.toneMapping = m, p = !0;
1746
1731
  let n = a, r = o;
1747
- for (let i = 0; i < g.length; i++) {
1748
- let a = g[i];
1732
+ for (let i = 0; i < _.length; i++) {
1733
+ let a = _[i];
1749
1734
  if (a.enabled !== !1 && (a.render(e, r, n, t), a.needsSwap !== !1)) {
1750
1735
  let e = n;
1751
1736
  n = r, r = e;
@@ -1753,28 +1738,28 @@ function vt(e, t, n, r, i) {
1753
1738
  }
1754
1739
  if (d !== e.outputColorSpace || f !== e.toneMapping) {
1755
1740
  d = e.outputColorSpace, f = e.toneMapping, c.defines = {}, O.getTransfer(d) === "srgb" && (c.defines.SRGB_TRANSFER = "");
1756
- let t = _t[f];
1741
+ let t = ht[f];
1757
1742
  t && (c.defines[t] = ""), c.needsUpdate = !0;
1758
1743
  }
1759
- c.uniforms.tDiffuse.value = n.texture, e.setRenderTarget(h), e.render(l, u), h = null, p = !1;
1744
+ c.uniforms.tDiffuse.value = n.texture, e.setRenderTarget(g), e.render(l, u), g = null, p = !1;
1760
1745
  }, this.isCompositing = function() {
1761
1746
  return p;
1762
1747
  }, this.dispose = function() {
1763
- a.dispose(), o.dispose(), s.dispose(), c.dispose();
1748
+ a.depthTexture && a.depthTexture.dispose(), a.dispose(), o.dispose(), s.dispose(), c.dispose();
1764
1749
  };
1765
1750
  }
1766
- var yt = /* @__PURE__ */ new F(), bt = /* @__PURE__ */ new h(1, 1), xt = /* @__PURE__ */ new G(), St = /* @__PURE__ */ new w(), Ct = /* @__PURE__ */ new B(), wt = [], Tt = [], Et = new Float32Array(16), Dt = new Float32Array(9), Ot = new Float32Array(4);
1767
- function kt(e, t, n) {
1751
+ var _t = /* @__PURE__ */ new F(), vt = /* @__PURE__ */ new h(1, 1), yt = /* @__PURE__ */ new Ne(), bt = /* @__PURE__ */ new w(), xt = /* @__PURE__ */ new se(), St = [], Ct = [], wt = new Float32Array(16), Tt = new Float32Array(9), Et = new Float32Array(4);
1752
+ function Dt(e, t, n) {
1768
1753
  let r = e[0];
1769
1754
  if (r <= 0 || r > 0) return e;
1770
- let i = t * n, a = wt[i];
1771
- if (a === void 0 && (a = new Float32Array(i), wt[i] = a), t !== 0) {
1755
+ let i = t * n, a = St[i];
1756
+ if (a === void 0 && (a = new Float32Array(i), St[i] = a), t !== 0) {
1772
1757
  r.toArray(a, 0);
1773
1758
  for (let r = 1, i = 0; r !== t; ++r) i += n, e[r].toArray(a, i);
1774
1759
  }
1775
1760
  return a;
1776
1761
  }
1777
- function Q(e, t) {
1762
+ function Ot(e, t) {
1778
1763
  if (e.length !== t.length) return !1;
1779
1764
  for (let n = 0, r = e.length; n < r; n++) if (e[n] !== t[n]) return !1;
1780
1765
  return !0;
@@ -1782,305 +1767,305 @@ function Q(e, t) {
1782
1767
  function $(e, t) {
1783
1768
  for (let n = 0, r = t.length; n < r; n++) e[n] = t[n];
1784
1769
  }
1785
- function At(e, t) {
1786
- let n = Tt[t];
1787
- n === void 0 && (n = new Int32Array(t), Tt[t] = n);
1770
+ function kt(e, t) {
1771
+ let n = Ct[t];
1772
+ n === void 0 && (n = new Int32Array(t), Ct[t] = n);
1788
1773
  for (let r = 0; r !== t; ++r) n[r] = e.allocateTextureUnit();
1789
1774
  return n;
1790
1775
  }
1791
- function jt(e, t) {
1776
+ function At(e, t) {
1792
1777
  let n = this.cache;
1793
1778
  n[0] !== t && (e.uniform1f(this.addr, t), n[0] = t);
1794
1779
  }
1795
- function Mt(e, t) {
1780
+ function jt(e, t) {
1796
1781
  let n = this.cache;
1797
1782
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2f(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y);
1798
1783
  else {
1799
- if (Q(n, t)) return;
1784
+ if (Ot(n, t)) return;
1800
1785
  e.uniform2fv(this.addr, t), $(n, t);
1801
1786
  }
1802
1787
  }
1803
- function Nt(e, t) {
1788
+ function Mt(e, t) {
1804
1789
  let n = this.cache;
1805
1790
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3f(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z);
1806
1791
  else if (t.r !== void 0) (n[0] !== t.r || n[1] !== t.g || n[2] !== t.b) && (e.uniform3f(this.addr, t.r, t.g, t.b), n[0] = t.r, n[1] = t.g, n[2] = t.b);
1807
1792
  else {
1808
- if (Q(n, t)) return;
1793
+ if (Ot(n, t)) return;
1809
1794
  e.uniform3fv(this.addr, t), $(n, t);
1810
1795
  }
1811
1796
  }
1812
- function Pt(e, t) {
1797
+ function Nt(e, t) {
1813
1798
  let n = this.cache;
1814
1799
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4f(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w);
1815
1800
  else {
1816
- if (Q(n, t)) return;
1801
+ if (Ot(n, t)) return;
1817
1802
  e.uniform4fv(this.addr, t), $(n, t);
1818
1803
  }
1819
1804
  }
1820
- function Ft(e, t) {
1805
+ function Pt(e, t) {
1821
1806
  let n = this.cache, r = t.elements;
1822
1807
  if (r === void 0) {
1823
- if (Q(n, t)) return;
1808
+ if (Ot(n, t)) return;
1824
1809
  e.uniformMatrix2fv(this.addr, !1, t), $(n, t);
1825
1810
  } else {
1826
- if (Q(n, r)) return;
1827
- Ot.set(r), e.uniformMatrix2fv(this.addr, !1, Ot), $(n, r);
1811
+ if (Ot(n, r)) return;
1812
+ Et.set(r), e.uniformMatrix2fv(this.addr, !1, Et), $(n, r);
1828
1813
  }
1829
1814
  }
1830
- function It(e, t) {
1815
+ function Ft(e, t) {
1831
1816
  let n = this.cache, r = t.elements;
1832
1817
  if (r === void 0) {
1833
- if (Q(n, t)) return;
1818
+ if (Ot(n, t)) return;
1834
1819
  e.uniformMatrix3fv(this.addr, !1, t), $(n, t);
1835
1820
  } else {
1836
- if (Q(n, r)) return;
1837
- Dt.set(r), e.uniformMatrix3fv(this.addr, !1, Dt), $(n, r);
1821
+ if (Ot(n, r)) return;
1822
+ Tt.set(r), e.uniformMatrix3fv(this.addr, !1, Tt), $(n, r);
1838
1823
  }
1839
1824
  }
1840
- function Lt(e, t) {
1825
+ function It(e, t) {
1841
1826
  let n = this.cache, r = t.elements;
1842
1827
  if (r === void 0) {
1843
- if (Q(n, t)) return;
1828
+ if (Ot(n, t)) return;
1844
1829
  e.uniformMatrix4fv(this.addr, !1, t), $(n, t);
1845
1830
  } else {
1846
- if (Q(n, r)) return;
1847
- Et.set(r), e.uniformMatrix4fv(this.addr, !1, Et), $(n, r);
1831
+ if (Ot(n, r)) return;
1832
+ wt.set(r), e.uniformMatrix4fv(this.addr, !1, wt), $(n, r);
1848
1833
  }
1849
1834
  }
1850
- function Rt(e, t) {
1835
+ function Lt(e, t) {
1851
1836
  let n = this.cache;
1852
1837
  n[0] !== t && (e.uniform1i(this.addr, t), n[0] = t);
1853
1838
  }
1854
- function zt(e, t) {
1839
+ function Rt(e, t) {
1855
1840
  let n = this.cache;
1856
1841
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2i(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y);
1857
1842
  else {
1858
- if (Q(n, t)) return;
1843
+ if (Ot(n, t)) return;
1859
1844
  e.uniform2iv(this.addr, t), $(n, t);
1860
1845
  }
1861
1846
  }
1862
- function Bt(e, t) {
1847
+ function zt(e, t) {
1863
1848
  let n = this.cache;
1864
1849
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3i(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z);
1865
1850
  else {
1866
- if (Q(n, t)) return;
1851
+ if (Ot(n, t)) return;
1867
1852
  e.uniform3iv(this.addr, t), $(n, t);
1868
1853
  }
1869
1854
  }
1870
- function Vt(e, t) {
1855
+ function Bt(e, t) {
1871
1856
  let n = this.cache;
1872
1857
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4i(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w);
1873
1858
  else {
1874
- if (Q(n, t)) return;
1859
+ if (Ot(n, t)) return;
1875
1860
  e.uniform4iv(this.addr, t), $(n, t);
1876
1861
  }
1877
1862
  }
1878
- function Ht(e, t) {
1863
+ function Vt(e, t) {
1879
1864
  let n = this.cache;
1880
1865
  n[0] !== t && (e.uniform1ui(this.addr, t), n[0] = t);
1881
1866
  }
1882
- function Ut(e, t) {
1867
+ function Ht(e, t) {
1883
1868
  let n = this.cache;
1884
1869
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2ui(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y);
1885
1870
  else {
1886
- if (Q(n, t)) return;
1871
+ if (Ot(n, t)) return;
1887
1872
  e.uniform2uiv(this.addr, t), $(n, t);
1888
1873
  }
1889
1874
  }
1890
- function Wt(e, t) {
1875
+ function Ut(e, t) {
1891
1876
  let n = this.cache;
1892
1877
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3ui(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z);
1893
1878
  else {
1894
- if (Q(n, t)) return;
1879
+ if (Ot(n, t)) return;
1895
1880
  e.uniform3uiv(this.addr, t), $(n, t);
1896
1881
  }
1897
1882
  }
1898
- function Gt(e, t) {
1883
+ function Wt(e, t) {
1899
1884
  let n = this.cache;
1900
1885
  if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4ui(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w);
1901
1886
  else {
1902
- if (Q(n, t)) return;
1887
+ if (Ot(n, t)) return;
1903
1888
  e.uniform4uiv(this.addr, t), $(n, t);
1904
1889
  }
1905
1890
  }
1906
- function Kt(e, t, n) {
1891
+ function Gt(e, t, n) {
1907
1892
  let r = this.cache, i = n.allocateTextureUnit();
1908
1893
  r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i);
1909
1894
  let a;
1910
- this.type === e.SAMPLER_2D_SHADOW ? (bt.compareFunction = n.isReversedDepthBuffer() ? 518 : 515, a = bt) : a = yt, n.setTexture2D(t || a, i);
1895
+ this.type === e.SAMPLER_2D_SHADOW ? (vt.compareFunction = n.isReversedDepthBuffer() ? 518 : 515, a = vt) : a = _t, n.setTexture2D(t || a, i);
1911
1896
  }
1912
- function qt(e, t, n) {
1897
+ function Kt(e, t, n) {
1913
1898
  let r = this.cache, i = n.allocateTextureUnit();
1914
- r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture3D(t || St, i);
1899
+ r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture3D(t || bt, i);
1915
1900
  }
1916
- function Jt(e, t, n) {
1901
+ function qt(e, t, n) {
1917
1902
  let r = this.cache, i = n.allocateTextureUnit();
1918
- r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTextureCube(t || Ct, i);
1903
+ r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTextureCube(t || xt, i);
1919
1904
  }
1920
- function Yt(e, t, n) {
1905
+ function Jt(e, t, n) {
1921
1906
  let r = this.cache, i = n.allocateTextureUnit();
1922
- r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture2DArray(t || xt, i);
1907
+ r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture2DArray(t || yt, i);
1923
1908
  }
1924
- function Xt(e) {
1909
+ function Yt(e) {
1925
1910
  switch (e) {
1926
- case 5126: return jt;
1927
- case 35664: return Mt;
1928
- case 35665: return Nt;
1929
- case 35666: return Pt;
1930
- case 35674: return Ft;
1931
- case 35675: return It;
1932
- case 35676: return Lt;
1911
+ case 5126: return At;
1912
+ case 35664: return jt;
1913
+ case 35665: return Mt;
1914
+ case 35666: return Nt;
1915
+ case 35674: return Pt;
1916
+ case 35675: return Ft;
1917
+ case 35676: return It;
1933
1918
  case 5124:
1934
- case 35670: return Rt;
1919
+ case 35670: return Lt;
1935
1920
  case 35667:
1936
- case 35671: return zt;
1921
+ case 35671: return Rt;
1937
1922
  case 35668:
1938
- case 35672: return Bt;
1923
+ case 35672: return zt;
1939
1924
  case 35669:
1940
- case 35673: return Vt;
1941
- case 5125: return Ht;
1942
- case 36294: return Ut;
1943
- case 36295: return Wt;
1944
- case 36296: return Gt;
1925
+ case 35673: return Bt;
1926
+ case 5125: return Vt;
1927
+ case 36294: return Ht;
1928
+ case 36295: return Ut;
1929
+ case 36296: return Wt;
1945
1930
  case 35678:
1946
1931
  case 36198:
1947
1932
  case 36298:
1948
1933
  case 36306:
1949
- case 35682: return Kt;
1934
+ case 35682: return Gt;
1950
1935
  case 35679:
1951
1936
  case 36299:
1952
- case 36307: return qt;
1937
+ case 36307: return Kt;
1953
1938
  case 35680:
1954
1939
  case 36300:
1955
1940
  case 36308:
1956
- case 36293: return Jt;
1941
+ case 36293: return qt;
1957
1942
  case 36289:
1958
1943
  case 36303:
1959
1944
  case 36311:
1960
- case 36292: return Yt;
1945
+ case 36292: return Jt;
1961
1946
  }
1962
1947
  }
1963
- function Zt(e, t) {
1948
+ function Xt(e, t) {
1964
1949
  e.uniform1fv(this.addr, t);
1965
1950
  }
1966
- function Qt(e, t) {
1967
- let n = kt(t, this.size, 2);
1951
+ function Zt(e, t) {
1952
+ let n = Dt(t, this.size, 2);
1968
1953
  e.uniform2fv(this.addr, n);
1969
1954
  }
1970
- function $t(e, t) {
1971
- let n = kt(t, this.size, 3);
1955
+ function Qt(e, t) {
1956
+ let n = Dt(t, this.size, 3);
1972
1957
  e.uniform3fv(this.addr, n);
1973
1958
  }
1974
- function en(e, t) {
1975
- let n = kt(t, this.size, 4);
1959
+ function $t(e, t) {
1960
+ let n = Dt(t, this.size, 4);
1976
1961
  e.uniform4fv(this.addr, n);
1977
1962
  }
1978
- function tn(e, t) {
1979
- let n = kt(t, this.size, 4);
1963
+ function en(e, t) {
1964
+ let n = Dt(t, this.size, 4);
1980
1965
  e.uniformMatrix2fv(this.addr, !1, n);
1981
1966
  }
1982
- function nn(e, t) {
1983
- let n = kt(t, this.size, 9);
1967
+ function tn(e, t) {
1968
+ let n = Dt(t, this.size, 9);
1984
1969
  e.uniformMatrix3fv(this.addr, !1, n);
1985
1970
  }
1986
- function rn(e, t) {
1987
- let n = kt(t, this.size, 16);
1971
+ function nn(e, t) {
1972
+ let n = Dt(t, this.size, 16);
1988
1973
  e.uniformMatrix4fv(this.addr, !1, n);
1989
1974
  }
1990
- function an(e, t) {
1975
+ function rn(e, t) {
1991
1976
  e.uniform1iv(this.addr, t);
1992
1977
  }
1993
- function on(e, t) {
1978
+ function an(e, t) {
1994
1979
  e.uniform2iv(this.addr, t);
1995
1980
  }
1996
- function sn(e, t) {
1981
+ function on(e, t) {
1997
1982
  e.uniform3iv(this.addr, t);
1998
1983
  }
1999
- function cn(e, t) {
1984
+ function sn(e, t) {
2000
1985
  e.uniform4iv(this.addr, t);
2001
1986
  }
2002
- function ln(e, t) {
1987
+ function cn(e, t) {
2003
1988
  e.uniform1uiv(this.addr, t);
2004
1989
  }
2005
- function un(e, t) {
1990
+ function ln(e, t) {
2006
1991
  e.uniform2uiv(this.addr, t);
2007
1992
  }
2008
- function dn(e, t) {
1993
+ function un(e, t) {
2009
1994
  e.uniform3uiv(this.addr, t);
2010
1995
  }
2011
- function fn(e, t) {
1996
+ function dn(e, t) {
2012
1997
  e.uniform4uiv(this.addr, t);
2013
1998
  }
2014
- function pn(e, t, n) {
2015
- let r = this.cache, i = t.length, a = At(n, i);
2016
- Q(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
1999
+ function fn(e, t, n) {
2000
+ let r = this.cache, i = t.length, a = kt(n, i);
2001
+ Ot(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2017
2002
  let o;
2018
- o = this.type === e.SAMPLER_2D_SHADOW ? bt : yt;
2003
+ o = this.type === e.SAMPLER_2D_SHADOW ? vt : _t;
2019
2004
  for (let e = 0; e !== i; ++e) n.setTexture2D(t[e] || o, a[e]);
2020
2005
  }
2006
+ function pn(e, t, n) {
2007
+ let r = this.cache, i = t.length, a = kt(n, i);
2008
+ Ot(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2009
+ for (let e = 0; e !== i; ++e) n.setTexture3D(t[e] || bt, a[e]);
2010
+ }
2021
2011
  function mn(e, t, n) {
2022
- let r = this.cache, i = t.length, a = At(n, i);
2023
- Q(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2024
- for (let e = 0; e !== i; ++e) n.setTexture3D(t[e] || St, a[e]);
2012
+ let r = this.cache, i = t.length, a = kt(n, i);
2013
+ Ot(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2014
+ for (let e = 0; e !== i; ++e) n.setTextureCube(t[e] || xt, a[e]);
2025
2015
  }
2026
2016
  function hn(e, t, n) {
2027
- let r = this.cache, i = t.length, a = At(n, i);
2028
- Q(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2029
- for (let e = 0; e !== i; ++e) n.setTextureCube(t[e] || Ct, a[e]);
2017
+ let r = this.cache, i = t.length, a = kt(n, i);
2018
+ Ot(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2019
+ for (let e = 0; e !== i; ++e) n.setTexture2DArray(t[e] || yt, a[e]);
2030
2020
  }
2031
- function gn(e, t, n) {
2032
- let r = this.cache, i = t.length, a = At(n, i);
2033
- Q(r, a) || (e.uniform1iv(this.addr, a), $(r, a));
2034
- for (let e = 0; e !== i; ++e) n.setTexture2DArray(t[e] || xt, a[e]);
2035
- }
2036
- function _n(e) {
2021
+ function gn(e) {
2037
2022
  switch (e) {
2038
- case 5126: return Zt;
2039
- case 35664: return Qt;
2040
- case 35665: return $t;
2041
- case 35666: return en;
2042
- case 35674: return tn;
2043
- case 35675: return nn;
2044
- case 35676: return rn;
2023
+ case 5126: return Xt;
2024
+ case 35664: return Zt;
2025
+ case 35665: return Qt;
2026
+ case 35666: return $t;
2027
+ case 35674: return en;
2028
+ case 35675: return tn;
2029
+ case 35676: return nn;
2045
2030
  case 5124:
2046
- case 35670: return an;
2031
+ case 35670: return rn;
2047
2032
  case 35667:
2048
- case 35671: return on;
2033
+ case 35671: return an;
2049
2034
  case 35668:
2050
- case 35672: return sn;
2035
+ case 35672: return on;
2051
2036
  case 35669:
2052
- case 35673: return cn;
2053
- case 5125: return ln;
2054
- case 36294: return un;
2055
- case 36295: return dn;
2056
- case 36296: return fn;
2037
+ case 35673: return sn;
2038
+ case 5125: return cn;
2039
+ case 36294: return ln;
2040
+ case 36295: return un;
2041
+ case 36296: return dn;
2057
2042
  case 35678:
2058
2043
  case 36198:
2059
2044
  case 36298:
2060
2045
  case 36306:
2061
- case 35682: return pn;
2046
+ case 35682: return fn;
2062
2047
  case 35679:
2063
2048
  case 36299:
2064
- case 36307: return mn;
2049
+ case 36307: return pn;
2065
2050
  case 35680:
2066
2051
  case 36300:
2067
2052
  case 36308:
2068
- case 36293: return hn;
2053
+ case 36293: return mn;
2069
2054
  case 36289:
2070
2055
  case 36303:
2071
2056
  case 36311:
2072
- case 36292: return gn;
2057
+ case 36292: return hn;
2073
2058
  }
2074
2059
  }
2075
- var vn = class {
2060
+ var _n = class {
2076
2061
  constructor(e, t, n) {
2077
- this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = Xt(t.type);
2062
+ this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = Yt(t.type);
2078
2063
  }
2079
- }, yn = class {
2064
+ }, vn = class {
2080
2065
  constructor(e, t, n) {
2081
- this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = _n(t.type);
2066
+ this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = gn(t.type);
2082
2067
  }
2083
- }, bn = class {
2068
+ }, yn = class {
2084
2069
  constructor(e) {
2085
2070
  this.id = e, this.seq = [], this.map = {};
2086
2071
  }
@@ -2091,30 +2076,30 @@ var vn = class {
2091
2076
  a.setValue(e, t[a.id], n);
2092
2077
  }
2093
2078
  }
2094
- }, xn = /(\w+)(\])?(\[|\.)?/g;
2095
- function Sn(e, t) {
2079
+ }, bn = /(\w+)(\])?(\[|\.)?/g;
2080
+ function xn(e, t) {
2096
2081
  e.seq.push(t), e.map[t.id] = t;
2097
2082
  }
2098
- function Cn(e, t, n) {
2083
+ function Sn(e, t, n) {
2099
2084
  let r = e.name, i = r.length;
2100
- for (xn.lastIndex = 0;;) {
2101
- let a = xn.exec(r), o = xn.lastIndex, s = a[1], c = a[2] === "]", l = a[3];
2085
+ for (bn.lastIndex = 0;;) {
2086
+ let a = bn.exec(r), o = bn.lastIndex, s = a[1], c = a[2] === "]", l = a[3];
2102
2087
  if (c && (s |= 0), l === void 0 || l === "[" && o + 2 === i) {
2103
- Sn(n, l === void 0 ? new vn(s, e, t) : new yn(s, e, t));
2088
+ xn(n, l === void 0 ? new _n(s, e, t) : new vn(s, e, t));
2104
2089
  break;
2105
2090
  } else {
2106
2091
  let e = n.map[s];
2107
- e === void 0 && (e = new bn(s), Sn(n, e)), n = e;
2092
+ e === void 0 && (e = new yn(s), xn(n, e)), n = e;
2108
2093
  }
2109
2094
  }
2110
2095
  }
2111
- var wn = class {
2096
+ var Cn = class {
2112
2097
  constructor(e, t) {
2113
2098
  this.seq = [], this.map = {};
2114
2099
  let n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
2115
2100
  for (let r = 0; r < n; ++r) {
2116
2101
  let n = e.getActiveUniform(t, r);
2117
- Cn(n, e.getUniformLocation(t, n.name), this);
2102
+ Sn(n, e.getUniformLocation(t, n.name), this);
2118
2103
  }
2119
2104
  let r = [], i = [];
2120
2105
  for (let t of this.seq) t.type === e.SAMPLER_2D_SHADOW || t.type === e.SAMPLER_CUBE_SHADOW || t.type === e.SAMPLER_2D_ARRAY_SHADOW ? r.push(t) : i.push(t);
@@ -2143,12 +2128,12 @@ var wn = class {
2143
2128
  return n;
2144
2129
  }
2145
2130
  };
2146
- function Tn(e, t, n) {
2131
+ function wn(e, t, n) {
2147
2132
  let r = e.createShader(t);
2148
2133
  return e.shaderSource(r, n), e.compileShader(r), r;
2149
2134
  }
2150
- var En = 37297, Dn = 0;
2151
- function On(e, t) {
2135
+ var Tn = 37297, En = 0;
2136
+ function Dn(e, t) {
2152
2137
  let n = e.split("\n"), r = [], i = Math.max(t - 6, 0), a = Math.min(t + 6, n.length);
2153
2138
  for (let e = i; e < a; e++) {
2154
2139
  let i = e + 1;
@@ -2156,34 +2141,34 @@ function On(e, t) {
2156
2141
  }
2157
2142
  return r.join("\n");
2158
2143
  }
2159
- var kn = /* @__PURE__ */ new I();
2160
- function An(e) {
2161
- O._getMatrix(kn, O.workingColorSpace, e);
2162
- let t = `mat3( ${kn.elements.map((e) => e.toFixed(4))} )`;
2144
+ var On = /* @__PURE__ */ new I();
2145
+ function kn(e) {
2146
+ O._getMatrix(On, O.workingColorSpace, e);
2147
+ let t = `mat3( ${On.elements.map((e) => e.toFixed(4))} )`;
2163
2148
  switch (O.getTransfer(e)) {
2164
2149
  case C: return [t, "LinearTransferOETF"];
2165
2150
  case i: return [t, "sRGBTransferOETF"];
2166
2151
  default: return f("WebGLProgram: Unsupported color space: ", e), [t, "LinearTransferOETF"];
2167
2152
  }
2168
2153
  }
2169
- function jn(e, t, n) {
2154
+ function An(e, t, n) {
2170
2155
  let r = e.getShaderParameter(t, e.COMPILE_STATUS), i = (e.getShaderInfoLog(t) || "").trim();
2171
2156
  if (r && i === "") return "";
2172
2157
  let a = /ERROR: 0:(\d+)/.exec(i);
2173
2158
  if (a) {
2174
2159
  let r = parseInt(a[1]);
2175
- return n.toUpperCase() + "\n\n" + i + "\n\n" + On(e.getShaderSource(t), r);
2160
+ return n.toUpperCase() + "\n\n" + i + "\n\n" + Dn(e.getShaderSource(t), r);
2176
2161
  } else return i;
2177
2162
  }
2178
- function Mn(e, t) {
2179
- let n = An(t);
2163
+ function jn(e, t) {
2164
+ let n = kn(t);
2180
2165
  return [
2181
2166
  `vec4 ${e}( vec4 value ) {`,
2182
2167
  ` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,
2183
2168
  "}"
2184
2169
  ].join("\n");
2185
2170
  }
2186
- var Nn = {
2171
+ var Mn = {
2187
2172
  1: "Linear",
2188
2173
  2: "Reinhard",
2189
2174
  3: "Cineon",
@@ -2192,23 +2177,23 @@ var Nn = {
2192
2177
  7: "Neutral",
2193
2178
  5: "Custom"
2194
2179
  };
2195
- function Pn(e, t) {
2196
- let n = Nn[t];
2180
+ function Nn(e, t) {
2181
+ let n = Mn[t];
2197
2182
  return n === void 0 ? (f("WebGLProgram: Unsupported toneMapping:", t), "vec3 " + e + "( vec3 color ) { return LinearToneMapping( color ); }") : "vec3 " + e + "( vec3 color ) { return " + n + "ToneMapping( color ); }";
2198
2183
  }
2199
- var Fn = /* @__PURE__ */ new W();
2200
- function In() {
2201
- return O.getLuminanceCoefficients(Fn), [
2184
+ var Pn = /* @__PURE__ */ new W();
2185
+ function Fn() {
2186
+ return O.getLuminanceCoefficients(Pn), [
2202
2187
  "float luminance( const in vec3 rgb ) {",
2203
- ` const vec3 weights = vec3( ${Fn.x.toFixed(4)}, ${Fn.y.toFixed(4)}, ${Fn.z.toFixed(4)} );`,
2188
+ ` const vec3 weights = vec3( ${Pn.x.toFixed(4)}, ${Pn.y.toFixed(4)}, ${Pn.z.toFixed(4)} );`,
2204
2189
  " return dot( weights, rgb );",
2205
2190
  "}"
2206
2191
  ].join("\n");
2207
2192
  }
2208
- function Ln(e) {
2209
- return [e.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", e.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""].filter(Bn).join("\n");
2193
+ function In(e) {
2194
+ return [e.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", e.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""].filter(zn).join("\n");
2210
2195
  }
2211
- function Rn(e) {
2196
+ function Ln(e) {
2212
2197
  let t = [];
2213
2198
  for (let n in e) {
2214
2199
  let r = e[n];
@@ -2216,7 +2201,7 @@ function Rn(e) {
2216
2201
  }
2217
2202
  return t.join("\n");
2218
2203
  }
2219
- function zn(e, t) {
2204
+ function Rn(e, t) {
2220
2205
  let n = {}, r = e.getProgramParameter(t, e.ACTIVE_ATTRIBUTES);
2221
2206
  for (let i = 0; i < r; i++) {
2222
2207
  let r = e.getActiveAttrib(t, i), a = r.name, o = 1;
@@ -2228,40 +2213,40 @@ function zn(e, t) {
2228
2213
  }
2229
2214
  return n;
2230
2215
  }
2231
- function Bn(e) {
2216
+ function zn(e) {
2232
2217
  return e !== "";
2233
2218
  }
2234
- function Vn(e, t) {
2219
+ function Bn(e, t) {
2235
2220
  let n = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps;
2236
2221
  return e.replace(/NUM_DIR_LIGHTS/g, t.numDirLights).replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, n).replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, t.numPointLights).replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows);
2237
2222
  }
2238
- function Hn(e, t) {
2223
+ function Vn(e, t) {
2239
2224
  return e.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection);
2240
2225
  }
2241
- var Un = /^[ \t]*#include +<([\w\d./]+)>/gm;
2242
- function Wn(e) {
2243
- return e.replace(Un, Kn);
2226
+ var Hn = /^[ \t]*#include +<([\w\d./]+)>/gm;
2227
+ function Un(e) {
2228
+ return e.replace(Hn, Gn);
2244
2229
  }
2245
- var Gn = /* @__PURE__ */ new Map();
2246
- function Kn(e, t) {
2230
+ var Wn = /* @__PURE__ */ new Map();
2231
+ function Gn(e, t) {
2247
2232
  let n = K[t];
2248
2233
  if (n === void 0) {
2249
- let e = Gn.get(t);
2234
+ let e = Wn.get(t);
2250
2235
  if (e !== void 0) n = K[e], f("WebGLRenderer: Shader chunk \"%s\" has been deprecated. Use \"%s\" instead.", t, e);
2251
2236
  else throw Error("Can not resolve #include <" + t + ">");
2252
2237
  }
2253
- return Wn(n);
2238
+ return Un(n);
2254
2239
  }
2255
- var qn = /#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;
2256
- function Jn(e) {
2257
- return e.replace(qn, Yn);
2240
+ var Kn = /#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;
2241
+ function qn(e) {
2242
+ return e.replace(Kn, Jn);
2258
2243
  }
2259
- function Yn(e, t, n, r) {
2244
+ function Jn(e, t, n, r) {
2260
2245
  let i = "";
2261
2246
  for (let e = parseInt(t); e < parseInt(n); e++) i += r.replace(/\[\s*i\s*\]/g, "[ " + e + " ]").replace(/UNROLLED_LOOP_INDEX/g, e);
2262
2247
  return i;
2263
2248
  }
2264
- function Xn(e) {
2249
+ function Yn(e) {
2265
2250
  let t = `precision ${e.precision} float;
2266
2251
  precision ${e.precision} int;
2267
2252
  precision ${e.precision} sampler2D;
@@ -2282,34 +2267,34 @@ function Xn(e) {
2282
2267
  `;
2283
2268
  return e.precision === "highp" ? t += "\n#define HIGH_PRECISION" : e.precision === "mediump" ? t += "\n#define MEDIUM_PRECISION" : e.precision === "lowp" && (t += "\n#define LOW_PRECISION"), t;
2284
2269
  }
2285
- var Zn = {
2270
+ var Xn = {
2286
2271
  1: "SHADOWMAP_TYPE_PCF",
2287
2272
  3: "SHADOWMAP_TYPE_VSM"
2288
2273
  };
2289
- function Qn(e) {
2290
- return Zn[e.shadowMapType] || "SHADOWMAP_TYPE_BASIC";
2274
+ function Zn(e) {
2275
+ return Xn[e.shadowMapType] || "SHADOWMAP_TYPE_BASIC";
2291
2276
  }
2292
- var $n = {
2277
+ var Qn = {
2293
2278
  301: "ENVMAP_TYPE_CUBE",
2294
2279
  302: "ENVMAP_TYPE_CUBE",
2295
2280
  306: "ENVMAP_TYPE_CUBE_UV"
2296
2281
  };
2297
- function er(e) {
2298
- return e.envMap === !1 ? "ENVMAP_TYPE_CUBE" : $n[e.envMapMode] || "ENVMAP_TYPE_CUBE";
2282
+ function $n(e) {
2283
+ return e.envMap === !1 ? "ENVMAP_TYPE_CUBE" : Qn[e.envMapMode] || "ENVMAP_TYPE_CUBE";
2299
2284
  }
2300
- var tr = { 302: "ENVMAP_MODE_REFRACTION" };
2301
- function nr(e) {
2302
- return e.envMap === !1 ? "ENVMAP_MODE_REFLECTION" : tr[e.envMapMode] || "ENVMAP_MODE_REFLECTION";
2285
+ var er = { 302: "ENVMAP_MODE_REFRACTION" };
2286
+ function tr(e) {
2287
+ return e.envMap === !1 ? "ENVMAP_MODE_REFLECTION" : er[e.envMapMode] || "ENVMAP_MODE_REFLECTION";
2303
2288
  }
2304
- var rr = {
2289
+ var nr = {
2305
2290
  0: "ENVMAP_BLENDING_MULTIPLY",
2306
2291
  1: "ENVMAP_BLENDING_MIX",
2307
2292
  2: "ENVMAP_BLENDING_ADD"
2308
2293
  };
2309
- function ir(e) {
2310
- return e.envMap === !1 ? "ENVMAP_BLENDING_NONE" : rr[e.combine] || "ENVMAP_BLENDING_NONE";
2294
+ function rr(e) {
2295
+ return e.envMap === !1 ? "ENVMAP_BLENDING_NONE" : nr[e.combine] || "ENVMAP_BLENDING_NONE";
2311
2296
  }
2312
- function ar(e) {
2297
+ function ir(e) {
2313
2298
  let t = e.envMapCubeUVHeight;
2314
2299
  if (t === null) return null;
2315
2300
  let n = Math.log2(t) - 2, r = 1 / t;
@@ -2319,18 +2304,18 @@ function ar(e) {
2319
2304
  maxMip: n
2320
2305
  };
2321
2306
  }
2322
- function or(e, t, n, r) {
2323
- let i = e.getContext(), a = n.defines, o = n.vertexShader, s = n.fragmentShader, c = Qn(n), l = er(n), u = nr(n), d = ir(n), p = ar(n), m = Ln(n), h = Rn(a), g = i.createProgram(), _, v, y = n.glslVersion ? "#version " + n.glslVersion + "\n" : "";
2307
+ function ar(e, t, n, r) {
2308
+ let i = e.getContext(), a = n.defines, o = n.vertexShader, s = n.fragmentShader, c = Zn(n), l = $n(n), u = tr(n), d = rr(n), p = ir(n), m = In(n), h = Ln(a), g = i.createProgram(), _, v, y = n.glslVersion ? "#version " + n.glslVersion + "\n" : "";
2324
2309
  n.isRawShaderMaterial ? (_ = [
2325
2310
  "#define SHADER_TYPE " + n.shaderType,
2326
2311
  "#define SHADER_NAME " + n.shaderName,
2327
2312
  h
2328
- ].filter(Bn).join("\n"), _.length > 0 && (_ += "\n"), v = [
2313
+ ].filter(zn).join("\n"), _.length > 0 && (_ += "\n"), v = [
2329
2314
  "#define SHADER_TYPE " + n.shaderType,
2330
2315
  "#define SHADER_NAME " + n.shaderName,
2331
2316
  h
2332
- ].filter(Bn).join("\n"), v.length > 0 && (v += "\n")) : (_ = [
2333
- Xn(n),
2317
+ ].filter(zn).join("\n"), v.length > 0 && (v += "\n")) : (_ = [
2318
+ Yn(n),
2334
2319
  "#define SHADER_TYPE " + n.shaderType,
2335
2320
  "#define SHADER_NAME " + n.shaderName,
2336
2321
  h,
@@ -2396,6 +2381,7 @@ function or(e, t, n, r) {
2396
2381
  n.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + n.transmissionMapUv : "",
2397
2382
  n.thicknessMapUv ? "#define THICKNESSMAP_UV " + n.thicknessMapUv : "",
2398
2383
  n.vertexTangents && n.flatShading === !1 ? "#define USE_TANGENT" : "",
2384
+ n.vertexNormals ? "#define HAS_NORMAL" : "",
2399
2385
  n.vertexColors ? "#define USE_COLOR" : "",
2400
2386
  n.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
2401
2387
  n.vertexUv1s ? "#define USE_UV1" : "",
@@ -2458,8 +2444,8 @@ function or(e, t, n, r) {
2458
2444
  " attribute vec4 skinWeight;",
2459
2445
  "#endif",
2460
2446
  "\n"
2461
- ].filter(Bn).join("\n"), v = [
2462
- Xn(n),
2447
+ ].filter(zn).join("\n"), v = [
2448
+ Yn(n),
2463
2449
  "#define SHADER_TYPE " + n.shaderType,
2464
2450
  "#define SHADER_NAME " + n.shaderName,
2465
2451
  h,
@@ -2481,6 +2467,7 @@ function or(e, t, n, r) {
2481
2467
  n.normalMap ? "#define USE_NORMALMAP" : "",
2482
2468
  n.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
2483
2469
  n.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
2470
+ n.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
2484
2471
  n.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
2485
2472
  n.anisotropy ? "#define USE_ANISOTROPY" : "",
2486
2473
  n.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
@@ -2521,6 +2508,7 @@ function or(e, t, n, r) {
2521
2508
  n.shadowMapEnabled ? "#define " + c : "",
2522
2509
  n.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
2523
2510
  n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
2511
+ n.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
2524
2512
  n.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
2525
2513
  n.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
2526
2514
  n.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
@@ -2530,15 +2518,15 @@ function or(e, t, n, r) {
2530
2518
  "uniform bool isOrthographic;",
2531
2519
  n.toneMapping === 0 ? "" : "#define TONE_MAPPING",
2532
2520
  n.toneMapping === 0 ? "" : K.tonemapping_pars_fragment,
2533
- n.toneMapping === 0 ? "" : Pn("toneMapping", n.toneMapping),
2521
+ n.toneMapping === 0 ? "" : Nn("toneMapping", n.toneMapping),
2534
2522
  n.dithering ? "#define DITHERING" : "",
2535
2523
  n.opaque ? "#define OPAQUE" : "",
2536
2524
  K.colorspace_pars_fragment,
2537
- Mn("linearToOutputTexel", n.outputColorSpace),
2538
- In(),
2525
+ jn("linearToOutputTexel", n.outputColorSpace),
2526
+ Fn(),
2539
2527
  n.useDepthPacking ? "#define DEPTH_PACKING " + n.depthPacking : "",
2540
2528
  "\n"
2541
- ].filter(Bn).join("\n")), o = Wn(o), o = Vn(o, n), o = Hn(o, n), s = Wn(s), s = Vn(s, n), s = Hn(s, n), o = Jn(o), s = Jn(s), n.isRawShaderMaterial !== !0 && (y = "#version 300 es\n", _ = [
2529
+ ].filter(zn).join("\n")), o = Un(o), o = Bn(o, n), o = Vn(o, n), s = Un(s), s = Bn(s, n), s = Vn(s, n), o = qn(o), s = qn(s), n.isRawShaderMaterial !== !0 && (y = "#version 300 es\n", _ = [
2542
2530
  m,
2543
2531
  "#define attribute in",
2544
2532
  "#define varying out",
@@ -2558,14 +2546,14 @@ function or(e, t, n, r) {
2558
2546
  "#define texture2DProjGradEXT textureProjGrad",
2559
2547
  "#define textureCubeGradEXT textureGrad"
2560
2548
  ].join("\n") + "\n" + v);
2561
- let b = y + _ + o, x = y + v + s, C = Tn(i, i.VERTEX_SHADER, b), w = Tn(i, i.FRAGMENT_SHADER, x);
2549
+ let b = y + _ + o, x = y + v + s, C = wn(i, i.VERTEX_SHADER, b), w = wn(i, i.FRAGMENT_SHADER, x);
2562
2550
  i.attachShader(g, C), i.attachShader(g, w), n.index0AttributeName === void 0 ? n.morphTargets === !0 && i.bindAttribLocation(g, 0, "position") : i.bindAttribLocation(g, 0, n.index0AttributeName), i.linkProgram(g);
2563
2551
  function T(t) {
2564
2552
  if (e.debug.checkShaderErrors) {
2565
2553
  let n = i.getProgramInfoLog(g) || "", r = i.getShaderInfoLog(C) || "", a = i.getShaderInfoLog(w) || "", o = n.trim(), s = r.trim(), c = a.trim(), l = !0, u = !0;
2566
2554
  if (i.getProgramParameter(g, i.LINK_STATUS) === !1) if (l = !1, typeof e.debug.onShaderError == "function") e.debug.onShaderError(i, g, C, w);
2567
2555
  else {
2568
- let e = jn(i, C, "vertex"), n = jn(i, w, "fragment");
2556
+ let e = An(i, C, "vertex"), n = An(i, w, "fragment");
2569
2557
  S("THREE.WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(g, i.VALIDATE_STATUS) + "\n\nMaterial Name: " + t.name + "\nMaterial Type: " + t.type + "\n\nProgram Info Log: " + o + "\n" + e + "\n" + n);
2570
2558
  }
2571
2559
  else o === "" ? (s === "" || c === "") && (u = !1) : f("WebGLProgram: Program Info Log:", o);
@@ -2582,7 +2570,7 @@ function or(e, t, n, r) {
2582
2570
  }
2583
2571
  });
2584
2572
  }
2585
- i.deleteShader(C), i.deleteShader(w), E = new wn(i, g), D = zn(i, g);
2573
+ i.deleteShader(C), i.deleteShader(w), E = new Cn(i, g), D = Rn(i, g);
2586
2574
  }
2587
2575
  let E;
2588
2576
  this.getUniforms = function() {
@@ -2594,12 +2582,12 @@ function or(e, t, n, r) {
2594
2582
  };
2595
2583
  let O = n.rendererExtensionParallelShaderCompile === !1;
2596
2584
  return this.isReady = function() {
2597
- return O === !1 && (O = i.getProgramParameter(g, En)), O;
2585
+ return O === !1 && (O = i.getProgramParameter(g, Tn)), O;
2598
2586
  }, this.destroy = function() {
2599
2587
  r.releaseStatesOfProgram(this), i.deleteProgram(g), this.program = void 0;
2600
- }, this.type = n.shaderType, this.name = n.shaderName, this.id = Dn++, this.cacheKey = t, this.usedTimes = 1, this.program = g, this.vertexShader = C, this.fragmentShader = w, this;
2588
+ }, this.type = n.shaderType, this.name = n.shaderName, this.id = En++, this.cacheKey = t, this.usedTimes = 1, this.program = g, this.vertexShader = C, this.fragmentShader = w, this;
2601
2589
  }
2602
- var sr = 0, cr = class {
2590
+ var or = 0, sr = class {
2603
2591
  constructor() {
2604
2592
  this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
2605
2593
  }
@@ -2627,15 +2615,18 @@ var sr = 0, cr = class {
2627
2615
  }
2628
2616
  _getShaderStage(e) {
2629
2617
  let t = this.shaderCache, n = t.get(e);
2630
- return n === void 0 && (n = new lr(e), t.set(e, n)), n;
2618
+ return n === void 0 && (n = new cr(e), t.set(e, n)), n;
2631
2619
  }
2632
- }, lr = class {
2620
+ }, cr = class {
2633
2621
  constructor(e) {
2634
- this.id = sr++, this.code = e, this.usedTimes = 0;
2622
+ this.id = or++, this.code = e, this.usedTimes = 0;
2635
2623
  }
2636
2624
  };
2625
+ function lr(e) {
2626
+ return e === 1030 || e === 37490 || e === 36285;
2627
+ }
2637
2628
  function ur(e, t, n, r, i, a) {
2638
- let o = new u(), s = new cr(), c = /* @__PURE__ */ new Set(), l = [], d = /* @__PURE__ */ new Map(), p = r.logarithmicDepthBuffer, m = r.precision, h = {
2629
+ let o = new u(), s = new sr(), c = /* @__PURE__ */ new Set(), l = [], d = /* @__PURE__ */ new Map(), p = r.logarithmicDepthBuffer, m = r.precision, h = {
2639
2630
  MeshDepthMaterial: "depth",
2640
2631
  MeshDistanceMaterial: "distance",
2641
2632
  MeshNormalMaterial: "normal",
@@ -2655,23 +2646,23 @@ function ur(e, t, n, r, i, a) {
2655
2646
  function g(e) {
2656
2647
  return c.add(e), e === 0 ? "uv" : `uv${e}`;
2657
2648
  }
2658
- function _(i, o, l, u, d) {
2659
- let _ = u.fog, v = d.geometry, y = i.isMeshStandardMaterial || i.isMeshLambertMaterial || i.isMeshPhongMaterial ? u.environment : null, b = i.isMeshStandardMaterial || i.isMeshLambertMaterial && !i.envMap || i.isMeshPhongMaterial && !i.envMap, x = t.get(i.envMap || y, b), S = x && x.mapping === 306 ? x.image.height : null, C = h[i.type];
2649
+ function _(i, o, l, u, d, _) {
2650
+ let v = u.fog, y = d.geometry, b = i.isMeshStandardMaterial || i.isMeshLambertMaterial || i.isMeshPhongMaterial ? u.environment : null, x = i.isMeshStandardMaterial || i.isMeshLambertMaterial && !i.envMap || i.isMeshPhongMaterial && !i.envMap, S = t.get(i.envMap || b, x), C = S && S.mapping === 306 ? S.image.height : null, w = h[i.type];
2660
2651
  i.precision !== null && (m = r.getMaxPrecision(i.precision), m !== i.precision && f("WebGLProgram.getParameters:", i.precision, "not supported, using", m, "instead."));
2661
- let w = v.morphAttributes.position || v.morphAttributes.normal || v.morphAttributes.color, T = w === void 0 ? 0 : w.length, E = 0;
2662
- v.morphAttributes.position !== void 0 && (E = 1), v.morphAttributes.normal !== void 0 && (E = 2), v.morphAttributes.color !== void 0 && (E = 3);
2663
- let D, k, A, j;
2664
- if (C) {
2665
- let e = J[C];
2666
- D = e.vertexShader, k = e.fragmentShader;
2667
- } else D = i.vertexShader, k = i.fragmentShader, s.update(i), A = s.getVertexShaderID(i), j = s.getFragmentShaderID(i);
2668
- let M = e.getRenderTarget(), ee = e.state.buffers.depth.getReversed(), te = d.isInstancedMesh === !0, N = d.isBatchedMesh === !0, P = !!i.map, F = !!i.matcap, I = !!x, L = !!i.aoMap, R = !!i.lightMap, re = !!i.bumpMap, z = !!i.normalMap, ie = !!i.displacementMap, ae = !!i.emissiveMap, oe = !!i.metalnessMap, B = !!i.roughnessMap, V = i.anisotropy > 0, se = i.clearcoat > 0, ce = i.dispersion > 0, le = i.iridescence > 0, ue = i.sheen > 0, de = i.transmission > 0, fe = V && !!i.anisotropyMap, pe = se && !!i.clearcoatMap, me = se && !!i.clearcoatNormalMap, he = se && !!i.clearcoatRoughnessMap, H = le && !!i.iridescenceMap, ge = le && !!i.iridescenceThicknessMap, _e = ue && !!i.sheenColorMap, ve = ue && !!i.sheenRoughnessMap, ye = !!i.specularMap, be = !!i.specularColorMap, U = !!i.specularIntensityMap, xe = de && !!i.transmissionMap, Se = de && !!i.thicknessMap, Ce = !!i.gradientMap, we = !!i.alphaMap, Te = i.alphaTest > 0, Ee = !!i.alphaHash, De = !!i.extensions, Oe = 0;
2652
+ let T = y.morphAttributes.position || y.morphAttributes.normal || y.morphAttributes.color, E = T === void 0 ? 0 : T.length, D = 0;
2653
+ y.morphAttributes.position !== void 0 && (D = 1), y.morphAttributes.normal !== void 0 && (D = 2), y.morphAttributes.color !== void 0 && (D = 3);
2654
+ let ee, k, A, j;
2655
+ if (w) {
2656
+ let e = J[w];
2657
+ ee = e.vertexShader, k = e.fragmentShader;
2658
+ } else ee = i.vertexShader, k = i.fragmentShader, s.update(i), A = s.getVertexShaderID(i), j = s.getFragmentShaderID(i);
2659
+ let M = e.getRenderTarget(), te = e.state.buffers.depth.getReversed(), ne = d.isInstancedMesh === !0, N = d.isBatchedMesh === !0, P = !!i.map, F = !!i.matcap, I = !!S, L = !!i.aoMap, R = !!i.lightMap, re = !!i.bumpMap, z = !!i.normalMap, ie = !!i.displacementMap, ae = !!i.emissiveMap, oe = !!i.metalnessMap, se = !!i.roughnessMap, B = i.anisotropy > 0, V = i.clearcoat > 0, ce = i.dispersion > 0, le = i.iridescence > 0, ue = i.sheen > 0, H = i.transmission > 0, de = B && !!i.anisotropyMap, U = V && !!i.clearcoatMap, fe = V && !!i.clearcoatNormalMap, pe = V && !!i.clearcoatRoughnessMap, me = le && !!i.iridescenceMap, he = le && !!i.iridescenceThicknessMap, ge = ue && !!i.sheenColorMap, _e = ue && !!i.sheenRoughnessMap, ve = !!i.specularMap, ye = !!i.specularColorMap, be = !!i.specularIntensityMap, xe = H && !!i.transmissionMap, Se = H && !!i.thicknessMap, Ce = !!i.gradientMap, we = !!i.alphaMap, Te = i.alphaTest > 0, Ee = !!i.alphaHash, De = !!i.extensions, Oe = 0;
2669
2660
  i.toneMapped && (M === null || M.isXRRenderTarget === !0) && (Oe = e.toneMapping);
2670
2661
  let ke = {
2671
- shaderID: C,
2662
+ shaderID: w,
2672
2663
  shaderType: i.type,
2673
2664
  shaderName: i.name,
2674
- vertexShader: D,
2665
+ vertexShader: ee,
2675
2666
  fragmentShader: k,
2676
2667
  defines: i.defines,
2677
2668
  customVertexShaderID: A,
@@ -2681,16 +2672,16 @@ function ur(e, t, n, r, i, a) {
2681
2672
  precision: m,
2682
2673
  batching: N,
2683
2674
  batchingColor: N && d._colorsTexture !== null,
2684
- instancing: te,
2685
- instancingColor: te && d.instanceColor !== null,
2686
- instancingMorph: te && d.morphTexture !== null,
2687
- outputColorSpace: M === null ? e.outputColorSpace : M.isXRRenderTarget === !0 ? M.texture.colorSpace : ne,
2675
+ instancing: ne,
2676
+ instancingColor: ne && d.instanceColor !== null,
2677
+ instancingMorph: ne && d.morphTexture !== null,
2678
+ outputColorSpace: M === null ? e.outputColorSpace : M.isXRRenderTarget === !0 ? M.texture.colorSpace : O.workingColorSpace,
2688
2679
  alphaToCoverage: !!i.alphaToCoverage,
2689
2680
  map: P,
2690
2681
  matcap: F,
2691
2682
  envMap: I,
2692
- envMapMode: I && x.mapping,
2693
- envMapCubeUVHeight: S,
2683
+ envMapMode: I && S.mapping,
2684
+ envMapCubeUVHeight: C,
2694
2685
  aoMap: L,
2695
2686
  lightMap: R,
2696
2687
  bumpMap: re,
@@ -2699,25 +2690,26 @@ function ur(e, t, n, r, i, a) {
2699
2690
  emissiveMap: ae,
2700
2691
  normalMapObjectSpace: z && i.normalMapType === 1,
2701
2692
  normalMapTangentSpace: z && i.normalMapType === 0,
2693
+ packedNormalMap: z && i.normalMapType === 0 && lr(i.normalMap.format),
2702
2694
  metalnessMap: oe,
2703
- roughnessMap: B,
2704
- anisotropy: V,
2705
- anisotropyMap: fe,
2706
- clearcoat: se,
2707
- clearcoatMap: pe,
2708
- clearcoatNormalMap: me,
2709
- clearcoatRoughnessMap: he,
2695
+ roughnessMap: se,
2696
+ anisotropy: B,
2697
+ anisotropyMap: de,
2698
+ clearcoat: V,
2699
+ clearcoatMap: U,
2700
+ clearcoatNormalMap: fe,
2701
+ clearcoatRoughnessMap: pe,
2710
2702
  dispersion: ce,
2711
2703
  iridescence: le,
2712
- iridescenceMap: H,
2713
- iridescenceThicknessMap: ge,
2704
+ iridescenceMap: me,
2705
+ iridescenceThicknessMap: he,
2714
2706
  sheen: ue,
2715
- sheenColorMap: _e,
2716
- sheenRoughnessMap: ve,
2717
- specularMap: ye,
2718
- specularColorMap: be,
2719
- specularIntensityMap: U,
2720
- transmission: de,
2707
+ sheenColorMap: ge,
2708
+ sheenRoughnessMap: _e,
2709
+ specularMap: ve,
2710
+ specularColorMap: ye,
2711
+ specularIntensityMap: be,
2712
+ transmission: H,
2721
2713
  transmissionMap: xe,
2722
2714
  thicknessMap: Se,
2723
2715
  gradientMap: Ce,
@@ -2734,38 +2726,39 @@ function ur(e, t, n, r, i, a) {
2734
2726
  displacementMapUv: ie && g(i.displacementMap.channel),
2735
2727
  emissiveMapUv: ae && g(i.emissiveMap.channel),
2736
2728
  metalnessMapUv: oe && g(i.metalnessMap.channel),
2737
- roughnessMapUv: B && g(i.roughnessMap.channel),
2738
- anisotropyMapUv: fe && g(i.anisotropyMap.channel),
2739
- clearcoatMapUv: pe && g(i.clearcoatMap.channel),
2740
- clearcoatNormalMapUv: me && g(i.clearcoatNormalMap.channel),
2741
- clearcoatRoughnessMapUv: he && g(i.clearcoatRoughnessMap.channel),
2742
- iridescenceMapUv: H && g(i.iridescenceMap.channel),
2743
- iridescenceThicknessMapUv: ge && g(i.iridescenceThicknessMap.channel),
2744
- sheenColorMapUv: _e && g(i.sheenColorMap.channel),
2745
- sheenRoughnessMapUv: ve && g(i.sheenRoughnessMap.channel),
2746
- specularMapUv: ye && g(i.specularMap.channel),
2747
- specularColorMapUv: be && g(i.specularColorMap.channel),
2748
- specularIntensityMapUv: U && g(i.specularIntensityMap.channel),
2729
+ roughnessMapUv: se && g(i.roughnessMap.channel),
2730
+ anisotropyMapUv: de && g(i.anisotropyMap.channel),
2731
+ clearcoatMapUv: U && g(i.clearcoatMap.channel),
2732
+ clearcoatNormalMapUv: fe && g(i.clearcoatNormalMap.channel),
2733
+ clearcoatRoughnessMapUv: pe && g(i.clearcoatRoughnessMap.channel),
2734
+ iridescenceMapUv: me && g(i.iridescenceMap.channel),
2735
+ iridescenceThicknessMapUv: he && g(i.iridescenceThicknessMap.channel),
2736
+ sheenColorMapUv: ge && g(i.sheenColorMap.channel),
2737
+ sheenRoughnessMapUv: _e && g(i.sheenRoughnessMap.channel),
2738
+ specularMapUv: ve && g(i.specularMap.channel),
2739
+ specularColorMapUv: ye && g(i.specularColorMap.channel),
2740
+ specularIntensityMapUv: be && g(i.specularIntensityMap.channel),
2749
2741
  transmissionMapUv: xe && g(i.transmissionMap.channel),
2750
2742
  thicknessMapUv: Se && g(i.thicknessMap.channel),
2751
2743
  alphaMapUv: we && g(i.alphaMap.channel),
2752
- vertexTangents: !!v.attributes.tangent && (z || V),
2744
+ vertexTangents: !!y.attributes.tangent && (z || B),
2745
+ vertexNormals: !!y.attributes.normal,
2753
2746
  vertexColors: i.vertexColors,
2754
- vertexAlphas: i.vertexColors === !0 && !!v.attributes.color && v.attributes.color.itemSize === 4,
2755
- pointsUvs: d.isPoints === !0 && !!v.attributes.uv && (P || we),
2756
- fog: !!_,
2747
+ vertexAlphas: i.vertexColors === !0 && !!y.attributes.color && y.attributes.color.itemSize === 4,
2748
+ pointsUvs: d.isPoints === !0 && !!y.attributes.uv && (P || we),
2749
+ fog: !!v,
2757
2750
  useFog: i.fog === !0,
2758
- fogExp2: !!_ && _.isFogExp2,
2759
- flatShading: i.wireframe === !1 && (i.flatShading === !0 || v.attributes.normal === void 0 && z === !1 && (i.isMeshLambertMaterial || i.isMeshPhongMaterial || i.isMeshStandardMaterial || i.isMeshPhysicalMaterial)),
2751
+ fogExp2: !!v && v.isFogExp2,
2752
+ flatShading: i.wireframe === !1 && (i.flatShading === !0 || y.attributes.normal === void 0 && z === !1 && (i.isMeshLambertMaterial || i.isMeshPhongMaterial || i.isMeshStandardMaterial || i.isMeshPhysicalMaterial)),
2760
2753
  sizeAttenuation: i.sizeAttenuation === !0,
2761
2754
  logarithmicDepthBuffer: p,
2762
- reversedDepthBuffer: ee,
2755
+ reversedDepthBuffer: te,
2763
2756
  skinning: d.isSkinnedMesh === !0,
2764
- morphTargets: v.morphAttributes.position !== void 0,
2765
- morphNormals: v.morphAttributes.normal !== void 0,
2766
- morphColors: v.morphAttributes.color !== void 0,
2767
- morphTargetsCount: T,
2768
- morphTextureStride: E,
2757
+ morphTargets: y.morphAttributes.position !== void 0,
2758
+ morphNormals: y.morphAttributes.normal !== void 0,
2759
+ morphColors: y.morphAttributes.color !== void 0,
2760
+ morphTargetsCount: E,
2761
+ morphTextureStride: D,
2769
2762
  numDirLights: o.directional.length,
2770
2763
  numPointLights: o.point.length,
2771
2764
  numSpotLights: o.spot.length,
@@ -2777,6 +2770,7 @@ function ur(e, t, n, r, i, a) {
2777
2770
  numSpotLightShadows: o.spotShadowMap.length,
2778
2771
  numSpotLightShadowsWithMaps: o.numSpotLightShadowsWithMaps,
2779
2772
  numLightProbes: o.numLightProbes,
2773
+ numLightProbeGrids: _.length,
2780
2774
  numClippingPlanes: a.numPlanes,
2781
2775
  numClipIntersection: a.numIntersection,
2782
2776
  dithering: i.dithering,
@@ -2807,7 +2801,7 @@ function ur(e, t, n, r, i, a) {
2807
2801
  e.push(t.precision), e.push(t.outputColorSpace), e.push(t.envMapMode), e.push(t.envMapCubeUVHeight), e.push(t.mapUv), e.push(t.alphaMapUv), e.push(t.lightMapUv), e.push(t.aoMapUv), e.push(t.bumpMapUv), e.push(t.normalMapUv), e.push(t.displacementMapUv), e.push(t.emissiveMapUv), e.push(t.metalnessMapUv), e.push(t.roughnessMapUv), e.push(t.anisotropyMapUv), e.push(t.clearcoatMapUv), e.push(t.clearcoatNormalMapUv), e.push(t.clearcoatRoughnessMapUv), e.push(t.iridescenceMapUv), e.push(t.iridescenceThicknessMapUv), e.push(t.sheenColorMapUv), e.push(t.sheenRoughnessMapUv), e.push(t.specularMapUv), e.push(t.specularColorMapUv), e.push(t.specularIntensityMapUv), e.push(t.transmissionMapUv), e.push(t.thicknessMapUv), e.push(t.combine), e.push(t.fogExp2), e.push(t.sizeAttenuation), e.push(t.morphTargetsCount), e.push(t.morphAttributeCount), e.push(t.numDirLights), e.push(t.numPointLights), e.push(t.numSpotLights), e.push(t.numSpotLightMaps), e.push(t.numHemiLights), e.push(t.numRectAreaLights), e.push(t.numDirLightShadows), e.push(t.numPointLightShadows), e.push(t.numSpotLightShadows), e.push(t.numSpotLightShadowsWithMaps), e.push(t.numLightProbes), e.push(t.shadowMapType), e.push(t.toneMapping), e.push(t.numClippingPlanes), e.push(t.numClipIntersection), e.push(t.depthPacking);
2808
2802
  }
2809
2803
  function b(e, t) {
2810
- o.disableAll(), t.instancing && o.enable(0), t.instancingColor && o.enable(1), t.instancingMorph && o.enable(2), t.matcap && o.enable(3), t.envMap && o.enable(4), t.normalMapObjectSpace && o.enable(5), t.normalMapTangentSpace && o.enable(6), t.clearcoat && o.enable(7), t.iridescence && o.enable(8), t.alphaTest && o.enable(9), t.vertexColors && o.enable(10), t.vertexAlphas && o.enable(11), t.vertexUv1s && o.enable(12), t.vertexUv2s && o.enable(13), t.vertexUv3s && o.enable(14), t.vertexTangents && o.enable(15), t.anisotropy && o.enable(16), t.alphaHash && o.enable(17), t.batching && o.enable(18), t.dispersion && o.enable(19), t.batchingColor && o.enable(20), t.gradientMap && o.enable(21), e.push(o.mask), o.disableAll(), t.fog && o.enable(0), t.useFog && o.enable(1), t.flatShading && o.enable(2), t.logarithmicDepthBuffer && o.enable(3), t.reversedDepthBuffer && o.enable(4), t.skinning && o.enable(5), t.morphTargets && o.enable(6), t.morphNormals && o.enable(7), t.morphColors && o.enable(8), t.premultipliedAlpha && o.enable(9), t.shadowMapEnabled && o.enable(10), t.doubleSided && o.enable(11), t.flipSided && o.enable(12), t.useDepthPacking && o.enable(13), t.dithering && o.enable(14), t.transmission && o.enable(15), t.sheen && o.enable(16), t.opaque && o.enable(17), t.pointsUvs && o.enable(18), t.decodeVideoTexture && o.enable(19), t.decodeVideoTextureEmissive && o.enable(20), t.alphaToCoverage && o.enable(21), e.push(o.mask);
2804
+ o.disableAll(), t.instancing && o.enable(0), t.instancingColor && o.enable(1), t.instancingMorph && o.enable(2), t.matcap && o.enable(3), t.envMap && o.enable(4), t.normalMapObjectSpace && o.enable(5), t.normalMapTangentSpace && o.enable(6), t.clearcoat && o.enable(7), t.iridescence && o.enable(8), t.alphaTest && o.enable(9), t.vertexColors && o.enable(10), t.vertexAlphas && o.enable(11), t.vertexUv1s && o.enable(12), t.vertexUv2s && o.enable(13), t.vertexUv3s && o.enable(14), t.vertexTangents && o.enable(15), t.anisotropy && o.enable(16), t.alphaHash && o.enable(17), t.batching && o.enable(18), t.dispersion && o.enable(19), t.batchingColor && o.enable(20), t.gradientMap && o.enable(21), t.packedNormalMap && o.enable(22), t.vertexNormals && o.enable(23), e.push(o.mask), o.disableAll(), t.fog && o.enable(0), t.useFog && o.enable(1), t.flatShading && o.enable(2), t.logarithmicDepthBuffer && o.enable(3), t.reversedDepthBuffer && o.enable(4), t.skinning && o.enable(5), t.morphTargets && o.enable(6), t.morphNormals && o.enable(7), t.morphColors && o.enable(8), t.premultipliedAlpha && o.enable(9), t.shadowMapEnabled && o.enable(10), t.doubleSided && o.enable(11), t.flipSided && o.enable(12), t.useDepthPacking && o.enable(13), t.dithering && o.enable(14), t.transmission && o.enable(15), t.sheen && o.enable(16), t.opaque && o.enable(17), t.pointsUvs && o.enable(18), t.decodeVideoTexture && o.enable(19), t.decodeVideoTextureEmissive && o.enable(20), t.alphaToCoverage && o.enable(21), t.numLightProbeGrids > 0 && o.enable(22), e.push(o.mask);
2811
2805
  }
2812
2806
  function x(e) {
2813
2807
  let t = h[e.type], n;
@@ -2819,7 +2813,7 @@ function ur(e, t, n, r, i, a) {
2819
2813
  }
2820
2814
  function S(t, n) {
2821
2815
  let r = d.get(n);
2822
- return r === void 0 ? (r = new or(e, n, t, i), l.push(r), d.set(n, r)) : ++r.usedTimes, r;
2816
+ return r === void 0 ? (r = new ar(e, n, t, i), l.push(r), d.set(n, r)) : ++r.usedTimes, r;
2823
2817
  }
2824
2818
  function C(e) {
2825
2819
  if (--e.usedTimes === 0) {
@@ -3077,7 +3071,7 @@ function br(e) {
3077
3071
  numLightProbes: 0
3078
3072
  };
3079
3073
  for (let e = 0; e < 9; e++) r.probe.push(new W());
3080
- let i = new W(), a = new ge(), o = new ge();
3074
+ let i = new W(), a = new he(), o = new he();
3081
3075
  function s(i) {
3082
3076
  let a = 0, o = 0, s = 0;
3083
3077
  for (let e = 0; e < 9; e++) r.probe[e].set(0, 0, 0);
@@ -3153,36 +3147,42 @@ function br(e) {
3153
3147
  };
3154
3148
  }
3155
3149
  function xr(e) {
3156
- let t = new br(e), n = [], r = [];
3157
- function i(e) {
3158
- l.camera = e, n.length = 0, r.length = 0;
3159
- }
3150
+ let t = new br(e), n = [], r = [], i = [];
3160
3151
  function a(e) {
3161
- n.push(e);
3152
+ d.camera = e, n.length = 0, r.length = 0, i.length = 0;
3162
3153
  }
3163
3154
  function o(e) {
3155
+ n.push(e);
3156
+ }
3157
+ function s(e) {
3164
3158
  r.push(e);
3165
3159
  }
3166
- function s() {
3160
+ function c(e) {
3161
+ i.push(e);
3162
+ }
3163
+ function l() {
3167
3164
  t.setup(n);
3168
3165
  }
3169
- function c(e) {
3166
+ function u(e) {
3170
3167
  t.setupView(n, e);
3171
3168
  }
3172
- let l = {
3169
+ let d = {
3173
3170
  lightsArray: n,
3174
3171
  shadowsArray: r,
3172
+ lightProbeGridArray: i,
3175
3173
  camera: null,
3176
3174
  lights: t,
3177
- transmissionRenderTarget: {}
3175
+ transmissionRenderTarget: {},
3176
+ textureUnits: 0
3178
3177
  };
3179
3178
  return {
3180
- init: i,
3181
- state: l,
3182
- setupLights: s,
3183
- setupLightsView: c,
3184
- pushLight: a,
3185
- pushShadow: o
3179
+ init: a,
3180
+ state: d,
3181
+ setupLights: l,
3182
+ setupLightsView: u,
3183
+ pushLight: o,
3184
+ pushShadow: s,
3185
+ pushLightProbeGrid: c
3186
3186
  };
3187
3187
  }
3188
3188
  function Sr(e) {
@@ -3213,9 +3213,9 @@ var Cr = "void main() {\n gl_Position = vec4( position, 1.0 );\n}", wr = "unifor
3213
3213
  /* @__PURE__ */ new W(0, 0, -1),
3214
3214
  /* @__PURE__ */ new W(0, -1, 0),
3215
3215
  /* @__PURE__ */ new W(0, -1, 0)
3216
- ], Dr = /* @__PURE__ */ new ge(), Or = /* @__PURE__ */ new W(), kr = /* @__PURE__ */ new W();
3216
+ ], Dr = /* @__PURE__ */ new he(), Or = /* @__PURE__ */ new W(), kr = /* @__PURE__ */ new W();
3217
3217
  function Ar(t, n, r) {
3218
- let i = new Te(), a = new L(), o = new L(), s = new E(), c = new fe(), l = new we(), u = {}, d = r.maxTextureSize, m = {
3218
+ let i = new we(), a = new L(), o = new L(), s = new E(), c = new de(), l = new Ce(), u = {}, d = r.maxTextureSize, m = {
3219
3219
  0: 1,
3220
3220
  1: 0,
3221
3221
  2: 2
@@ -3230,8 +3230,8 @@ function Ar(t, n, r) {
3230
3230
  fragmentShader: wr
3231
3231
  }), y = v.clone();
3232
3232
  y.defines.HORIZONTAL_PASS = 1;
3233
- let b = new pe();
3234
- b.setAttribute("position", new ve(new Float32Array([
3233
+ let b = new U();
3234
+ b.setAttribute("position", new _e(new Float32Array([
3235
3235
  -1,
3236
3236
  -1,
3237
3237
  .5,
@@ -3242,7 +3242,7 @@ function Ar(t, n, r) {
3242
3242
  3,
3243
3243
  .5
3244
3244
  ]), 3));
3245
- let x = new U(b, v), S = this;
3245
+ let x = new be(b, v), S = this;
3246
3246
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = 1;
3247
3247
  let C = this.type;
3248
3248
  this.render = function(n, r, c) {
@@ -3271,14 +3271,14 @@ function Ar(t, n, r) {
3271
3271
  f("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");
3272
3272
  continue;
3273
3273
  }
3274
- p.map = new k(a.x, a.y, {
3274
+ p.map = new ee(a.x, a.y, {
3275
3275
  format: D,
3276
- type: he,
3276
+ type: pe,
3277
3277
  minFilter: _,
3278
3278
  magFilter: _,
3279
3279
  generateMipmaps: !1
3280
- }), p.map.texture.name = u.name + ".shadowMap", p.map.depthTexture = new h(a.x, a.y, xe), p.map.depthTexture.name = u.name + ".shadowMapDepth", p.map.depthTexture.format = g, p.map.depthTexture.compareFunction = null, p.map.depthTexture.minFilter = Ne, p.map.depthTexture.magFilter = Ne;
3281
- } else u.isPointLight ? (p.map = new lt(a.x), p.map.depthTexture = new e(a.x, oe)) : (p.map = new k(a.x, a.y), p.map.depthTexture = new h(a.x, a.y, oe)), p.map.depthTexture.name = u.name + ".shadowMap", p.map.depthTexture.format = g, this.type === 1 ? (p.map.depthTexture.compareFunction = b ? 518 : 515, p.map.depthTexture.minFilter = _, p.map.depthTexture.magFilter = _) : (p.map.depthTexture.compareFunction = null, p.map.depthTexture.minFilter = Ne, p.map.depthTexture.magFilter = Ne);
3280
+ }), p.map.texture.name = u.name + ".shadowMap", p.map.depthTexture = new h(a.x, a.y, xe), p.map.depthTexture.name = u.name + ".shadowMapDepth", p.map.depthTexture.format = g, p.map.depthTexture.compareFunction = null, p.map.depthTexture.minFilter = Me, p.map.depthTexture.magFilter = Me;
3281
+ } else u.isPointLight ? (p.map = new st(a.x), p.map.depthTexture = new e(a.x, oe)) : (p.map = new ee(a.x, a.y), p.map.depthTexture = new h(a.x, a.y, oe)), p.map.depthTexture.name = u.name + ".shadowMap", p.map.depthTexture.format = g, this.type === 1 ? (p.map.depthTexture.compareFunction = b ? 518 : 515, p.map.depthTexture.minFilter = _, p.map.depthTexture.magFilter = _) : (p.map.depthTexture.compareFunction = null, p.map.depthTexture.minFilter = Me, p.map.depthTexture.magFilter = Me);
3282
3282
  p.camera.updateProjectionMatrix();
3283
3283
  }
3284
3284
  let x = p.map.isWebGLCubeRenderTarget ? 6 : 1;
@@ -3301,9 +3301,9 @@ function Ar(t, n, r) {
3301
3301
  };
3302
3302
  function w(e, r) {
3303
3303
  let i = n.update(x);
3304
- v.defines.VSM_SAMPLES !== e.blurSamples && (v.defines.VSM_SAMPLES = e.blurSamples, y.defines.VSM_SAMPLES = e.blurSamples, v.needsUpdate = !0, y.needsUpdate = !0), e.mapPass === null && (e.mapPass = new k(a.x, a.y, {
3304
+ v.defines.VSM_SAMPLES !== e.blurSamples && (v.defines.VSM_SAMPLES = e.blurSamples, y.defines.VSM_SAMPLES = e.blurSamples, v.needsUpdate = !0, y.needsUpdate = !0), e.mapPass === null && (e.mapPass = new ee(a.x, a.y, {
3305
3305
  format: D,
3306
- type: he
3306
+ type: pe
3307
3307
  })), v.uniforms.shadow_pass.value = e.map.depthTexture, v.uniforms.resolution.value = e.mapSize, v.uniforms.radius.value = e.radius, t.setRenderTarget(e.mapPass), t.clear(), t.renderBufferDirect(r, null, i, v, x, null), y.uniforms.shadow_pass.value = e.mapPass.texture, y.uniforms.resolution.value = e.mapSize, y.uniforms.radius.value = e.radius, t.setRenderTarget(e.map), t.clear(), t.renderBufferDirect(r, null, i, y, x, null);
3308
3308
  }
3309
3309
  function T(e, n, r, i) {
@@ -3313,7 +3313,7 @@ function Ar(t, n, r) {
3313
3313
  let e = a.uuid, t = n.uuid, r = u[e];
3314
3314
  r === void 0 && (r = {}, u[e] = r);
3315
3315
  let i = r[t];
3316
- i === void 0 && (i = a.clone(), r[t] = i, n.addEventListener("dispose", A)), a = i;
3316
+ i === void 0 && (i = a.clone(), r[t] = i, n.addEventListener("dispose", k)), a = i;
3317
3317
  }
3318
3318
  if (a.visible = n.visible, a.wireframe = n.wireframe, i === 3 ? a.side = n.shadowSide === null ? n.side : n.shadowSide : a.side = n.shadowSide === null ? m[n.side] : n.shadowSide, a.alphaMap = n.alphaMap, a.alphaTest = n.alphaToCoverage === !0 ? .5 : n.alphaTest, a.map = n.map, a.clipShadows = n.clipShadows, a.clippingPlanes = n.clippingPlanes, a.clipIntersection = n.clipIntersection, a.displacementMap = n.displacementMap, a.displacementScale = n.displacementScale, a.displacementBias = n.displacementBias, a.wireframeLinewidth = n.wireframeLinewidth, a.linewidth = n.linewidth, r.isPointLight === !0 && a.isMeshDistanceMaterial === !0) {
3319
3319
  let e = t.properties.get(a);
@@ -3343,8 +3343,8 @@ function Ar(t, n, r) {
3343
3343
  let c = e.children;
3344
3344
  for (let e = 0, t = c.length; e < t; e++) O(c[e], r, a, o, s);
3345
3345
  }
3346
- function A(e) {
3347
- e.target.removeEventListener("dispose", A);
3346
+ function k(e) {
3347
+ e.target.removeEventListener("dispose", k);
3348
3348
  for (let t in u) {
3349
3349
  let n = u[t], r = e.target.uuid;
3350
3350
  r in n && (n[r].dispose(), delete n[r]);
@@ -3458,30 +3458,30 @@ function jr(e, t) {
3458
3458
  }
3459
3459
  };
3460
3460
  }
3461
- let o = new n(), s = new r(), c = new i(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), d = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, x = null, C = null, w = null, T = null, D = new a(0, 0, 0), O = 0, k = !1, A = null, j = null, M = null, ee = null, te = null, ne = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), N = !1, P = 0, F = e.getParameter(e.VERSION);
3462
- F.indexOf("WebGL") === -1 ? F.indexOf("OpenGL ES") !== -1 && (P = parseFloat(/^OpenGL ES (\d)/.exec(F)[1]), N = P >= 2) : (P = parseFloat(/^WebGL (\d)/.exec(F)[1]), N = P >= 1);
3463
- let I = null, L = {}, R = e.getParameter(e.SCISSOR_BOX), re = e.getParameter(e.VIEWPORT), z = new E().fromArray(R), ie = new E().fromArray(re);
3464
- function ae(t, n, r, i) {
3461
+ let o = new n(), s = new r(), c = new i(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), d = {}, f = {}, p = {}, m = /* @__PURE__ */ new WeakMap(), h = [], g = null, _ = !1, v = null, y = null, x = null, C = null, w = null, T = null, D = null, O = new a(0, 0, 0), ee = 0, k = !1, A = null, j = null, M = null, te = null, ne = null, N = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), P = !1, F = 0, I = e.getParameter(e.VERSION);
3462
+ I.indexOf("WebGL") === -1 ? I.indexOf("OpenGL ES") !== -1 && (F = parseFloat(/^OpenGL ES (\d)/.exec(I)[1]), P = F >= 2) : (F = parseFloat(/^WebGL (\d)/.exec(I)[1]), P = F >= 1);
3463
+ let L = null, R = {}, re = e.getParameter(e.SCISSOR_BOX), z = e.getParameter(e.VIEWPORT), ie = new E().fromArray(re), ae = new E().fromArray(z);
3464
+ function oe(t, n, r, i) {
3465
3465
  let a = new Uint8Array(4), o = e.createTexture();
3466
3466
  e.bindTexture(t, o), e.texParameteri(t, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(t, e.TEXTURE_MAG_FILTER, e.NEAREST);
3467
3467
  for (let o = 0; o < r; o++) t === e.TEXTURE_3D || t === e.TEXTURE_2D_ARRAY ? e.texImage3D(n, 0, e.RGBA, 1, 1, i, 0, e.RGBA, e.UNSIGNED_BYTE, a) : e.texImage2D(n + o, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, a);
3468
3468
  return o;
3469
3469
  }
3470
- let oe = {};
3471
- oe[e.TEXTURE_2D] = ae(e.TEXTURE_2D, e.TEXTURE_2D, 1), oe[e.TEXTURE_CUBE_MAP] = ae(e.TEXTURE_CUBE_MAP, e.TEXTURE_CUBE_MAP_POSITIVE_X, 6), oe[e.TEXTURE_2D_ARRAY] = ae(e.TEXTURE_2D_ARRAY, e.TEXTURE_2D_ARRAY, 1, 1), oe[e.TEXTURE_3D] = ae(e.TEXTURE_3D, e.TEXTURE_3D, 1, 1), o.setClear(0, 0, 0, 1), s.setClear(1), c.setClear(0), B(e.DEPTH_TEST), s.setFunc(3), me(!1), he(1), B(e.CULL_FACE), fe(0);
3470
+ let se = {};
3471
+ se[e.TEXTURE_2D] = oe(e.TEXTURE_2D, e.TEXTURE_2D, 1), se[e.TEXTURE_CUBE_MAP] = oe(e.TEXTURE_CUBE_MAP, e.TEXTURE_CUBE_MAP_POSITIVE_X, 6), se[e.TEXTURE_2D_ARRAY] = oe(e.TEXTURE_2D_ARRAY, e.TEXTURE_2D_ARRAY, 1, 1), se[e.TEXTURE_3D] = oe(e.TEXTURE_3D, e.TEXTURE_3D, 1, 1), o.setClear(0, 0, 0, 1), s.setClear(1), c.setClear(0), B(e.DEPTH_TEST), s.setFunc(3), pe(!1), me(1), B(e.CULL_FACE), U(0);
3472
3472
  function B(t) {
3473
3473
  d[t] !== !0 && (e.enable(t), d[t] = !0);
3474
3474
  }
3475
3475
  function V(t) {
3476
3476
  d[t] !== !1 && (e.disable(t), d[t] = !1);
3477
3477
  }
3478
- function se(t, n) {
3479
- return f[t] === n ? !1 : (e.bindFramebuffer(t, n), f[t] = n, t === e.DRAW_FRAMEBUFFER && (f[e.FRAMEBUFFER] = n), t === e.FRAMEBUFFER && (f[e.DRAW_FRAMEBUFFER] = n), !0);
3480
- }
3481
3478
  function ce(t, n) {
3482
- let r = m, i = !1;
3479
+ return p[t] === n ? !1 : (e.bindFramebuffer(t, n), p[t] = n, t === e.DRAW_FRAMEBUFFER && (p[e.FRAMEBUFFER] = n), t === e.FRAMEBUFFER && (p[e.DRAW_FRAMEBUFFER] = n), !0);
3480
+ }
3481
+ function le(t, n) {
3482
+ let r = h, i = !1;
3483
3483
  if (t) {
3484
- r = p.get(n), r === void 0 && (r = [], p.set(n, r));
3484
+ r = m.get(n), r === void 0 && (r = [], m.set(n, r));
3485
3485
  let a = t.textures;
3486
3486
  if (r.length !== a.length || r[0] !== e.COLOR_ATTACHMENT0) {
3487
3487
  for (let t = 0, n = a.length; t < n; t++) r[t] = e.COLOR_ATTACHMENT0 + t;
@@ -3490,15 +3490,15 @@ function jr(e, t) {
3490
3490
  } else r[0] !== e.BACK && (r[0] = e.BACK, i = !0);
3491
3491
  i && e.drawBuffers(r);
3492
3492
  }
3493
- function le(t) {
3494
- return h === t ? !1 : (e.useProgram(t), h = t, !0);
3493
+ function ue(t) {
3494
+ return g === t ? !1 : (e.useProgram(t), g = t, !0);
3495
3495
  }
3496
- let ue = {
3496
+ let H = {
3497
3497
  100: e.FUNC_ADD,
3498
3498
  101: e.FUNC_SUBTRACT,
3499
3499
  102: e.FUNC_REVERSE_SUBTRACT
3500
3500
  };
3501
- ue[103] = e.MIN, ue[104] = e.MAX;
3501
+ H[103] = e.MIN, H[104] = e.MAX;
3502
3502
  let de = {
3503
3503
  200: e.ZERO,
3504
3504
  201: e.ONE,
@@ -3516,14 +3516,14 @@ function jr(e, t) {
3516
3516
  213: e.CONSTANT_ALPHA,
3517
3517
  214: e.ONE_MINUS_CONSTANT_ALPHA
3518
3518
  };
3519
- function fe(t, n, r, i, a, o, s, c, l, u) {
3519
+ function U(t, n, r, i, a, o, s, c, l, u) {
3520
3520
  if (t === 0) {
3521
- g === !0 && (V(e.BLEND), g = !1);
3521
+ _ === !0 && (V(e.BLEND), _ = !1);
3522
3522
  return;
3523
3523
  }
3524
- if (g === !1 && (B(e.BLEND), g = !0), t !== 5) {
3525
- if (t !== _ || u !== k) {
3526
- if ((v !== 100 || C !== 100) && (e.blendEquation(e.FUNC_ADD), v = 100, C = 100), u) switch (t) {
3524
+ if (_ === !1 && (B(e.BLEND), _ = !0), t !== 5) {
3525
+ if (t !== v || u !== k) {
3526
+ if ((y !== 100 || w !== 100) && (e.blendEquation(e.FUNC_ADD), y = 100, w = 100), u) switch (t) {
3527
3527
  case 1:
3528
3528
  e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA);
3529
3529
  break;
@@ -3557,113 +3557,113 @@ function jr(e, t) {
3557
3557
  S("WebGLState: Invalid blending: ", t);
3558
3558
  break;
3559
3559
  }
3560
- y = null, x = null, w = null, T = null, D.set(0, 0, 0), O = 0, _ = t, k = u;
3560
+ x = null, C = null, T = null, D = null, O.set(0, 0, 0), ee = 0, v = t, k = u;
3561
3561
  }
3562
3562
  return;
3563
3563
  }
3564
- a ||= n, o ||= r, s ||= i, (n !== v || a !== C) && (e.blendEquationSeparate(ue[n], ue[a]), v = n, C = a), (r !== y || i !== x || o !== w || s !== T) && (e.blendFuncSeparate(de[r], de[i], de[o], de[s]), y = r, x = i, w = o, T = s), (c.equals(D) === !1 || l !== O) && (e.blendColor(c.r, c.g, c.b, l), D.copy(c), O = l), _ = t, k = !1;
3564
+ a ||= n, o ||= r, s ||= i, (n !== y || a !== w) && (e.blendEquationSeparate(H[n], H[a]), y = n, w = a), (r !== x || i !== C || o !== T || s !== D) && (e.blendFuncSeparate(de[r], de[i], de[o], de[s]), x = r, C = i, T = o, D = s), (c.equals(O) === !1 || l !== ee) && (e.blendColor(c.r, c.g, c.b, l), O.copy(c), ee = l), v = t, k = !1;
3565
3565
  }
3566
- function pe(t, n) {
3566
+ function fe(t, n) {
3567
3567
  t.side === 2 ? V(e.CULL_FACE) : B(e.CULL_FACE);
3568
3568
  let r = t.side === 1;
3569
- n && (r = !r), me(r), t.blending === 1 && t.transparent === !1 ? fe(0) : fe(t.blending, t.blendEquation, t.blendSrc, t.blendDst, t.blendEquationAlpha, t.blendSrcAlpha, t.blendDstAlpha, t.blendColor, t.blendAlpha, t.premultipliedAlpha), s.setFunc(t.depthFunc), s.setTest(t.depthTest), s.setMask(t.depthWrite), o.setMask(t.colorWrite);
3569
+ n && (r = !r), pe(r), t.blending === 1 && t.transparent === !1 ? U(0) : U(t.blending, t.blendEquation, t.blendSrc, t.blendDst, t.blendEquationAlpha, t.blendSrcAlpha, t.blendDstAlpha, t.blendColor, t.blendAlpha, t.premultipliedAlpha), s.setFunc(t.depthFunc), s.setTest(t.depthTest), s.setMask(t.depthWrite), o.setMask(t.colorWrite);
3570
3570
  let i = t.stencilWrite;
3571
3571
  c.setTest(i), i && (c.setMask(t.stencilWriteMask), c.setFunc(t.stencilFunc, t.stencilRef, t.stencilFuncMask), c.setOp(t.stencilFail, t.stencilZFail, t.stencilZPass)), ge(t.polygonOffset, t.polygonOffsetFactor, t.polygonOffsetUnits), t.alphaToCoverage === !0 ? B(e.SAMPLE_ALPHA_TO_COVERAGE) : V(e.SAMPLE_ALPHA_TO_COVERAGE);
3572
3572
  }
3573
- function me(t) {
3573
+ function pe(t) {
3574
3574
  A !== t && (t ? e.frontFace(e.CW) : e.frontFace(e.CCW), A = t);
3575
3575
  }
3576
- function he(t) {
3576
+ function me(t) {
3577
3577
  t === 0 ? V(e.CULL_FACE) : (B(e.CULL_FACE), t !== j && (t === 1 ? e.cullFace(e.BACK) : t === 2 ? e.cullFace(e.FRONT) : e.cullFace(e.FRONT_AND_BACK))), j = t;
3578
3578
  }
3579
- function H(t) {
3580
- t !== M && (N && e.lineWidth(t), M = t);
3579
+ function he(t) {
3580
+ t !== M && (P && e.lineWidth(t), M = t);
3581
3581
  }
3582
3582
  function ge(t, n, r) {
3583
- t ? (B(e.POLYGON_OFFSET_FILL), (ee !== n || te !== r) && (ee = n, te = r, s.getReversed() && (n = -n), e.polygonOffset(n, r))) : V(e.POLYGON_OFFSET_FILL);
3583
+ t ? (B(e.POLYGON_OFFSET_FILL), (te !== n || ne !== r) && (te = n, ne = r, s.getReversed() && (n = -n), e.polygonOffset(n, r))) : V(e.POLYGON_OFFSET_FILL);
3584
3584
  }
3585
3585
  function _e(t) {
3586
3586
  t ? B(e.SCISSOR_TEST) : V(e.SCISSOR_TEST);
3587
3587
  }
3588
3588
  function ve(t) {
3589
- t === void 0 && (t = e.TEXTURE0 + ne - 1), I !== t && (e.activeTexture(t), I = t);
3589
+ t === void 0 && (t = e.TEXTURE0 + N - 1), L !== t && (e.activeTexture(t), L = t);
3590
3590
  }
3591
3591
  function ye(t, n, r) {
3592
- r === void 0 && (r = I === null ? e.TEXTURE0 + ne - 1 : I);
3593
- let i = L[r];
3592
+ r === void 0 && (r = L === null ? e.TEXTURE0 + N - 1 : L);
3593
+ let i = R[r];
3594
3594
  i === void 0 && (i = {
3595
3595
  type: void 0,
3596
3596
  texture: void 0
3597
- }, L[r] = i), (i.type !== t || i.texture !== n) && (I !== r && (e.activeTexture(r), I = r), e.bindTexture(t, n || oe[t]), i.type = t, i.texture = n);
3597
+ }, R[r] = i), (i.type !== t || i.texture !== n) && (L !== r && (e.activeTexture(r), L = r), e.bindTexture(t, n || se[t]), i.type = t, i.texture = n);
3598
3598
  }
3599
3599
  function be() {
3600
- let t = L[I];
3600
+ let t = R[L];
3601
3601
  t !== void 0 && t.type !== void 0 && (e.bindTexture(t.type, null), t.type = void 0, t.texture = void 0);
3602
3602
  }
3603
- function U() {
3603
+ function xe() {
3604
3604
  try {
3605
3605
  e.compressedTexImage2D(...arguments);
3606
3606
  } catch (e) {
3607
3607
  S("WebGLState:", e);
3608
3608
  }
3609
3609
  }
3610
- function xe() {
3610
+ function Se() {
3611
3611
  try {
3612
3612
  e.compressedTexImage3D(...arguments);
3613
3613
  } catch (e) {
3614
3614
  S("WebGLState:", e);
3615
3615
  }
3616
3616
  }
3617
- function Se() {
3617
+ function Ce() {
3618
3618
  try {
3619
3619
  e.texSubImage2D(...arguments);
3620
3620
  } catch (e) {
3621
3621
  S("WebGLState:", e);
3622
3622
  }
3623
3623
  }
3624
- function Ce() {
3624
+ function we() {
3625
3625
  try {
3626
3626
  e.texSubImage3D(...arguments);
3627
3627
  } catch (e) {
3628
3628
  S("WebGLState:", e);
3629
3629
  }
3630
3630
  }
3631
- function we() {
3631
+ function Te() {
3632
3632
  try {
3633
3633
  e.compressedTexSubImage2D(...arguments);
3634
3634
  } catch (e) {
3635
3635
  S("WebGLState:", e);
3636
3636
  }
3637
3637
  }
3638
- function Te() {
3638
+ function Ee() {
3639
3639
  try {
3640
3640
  e.compressedTexSubImage3D(...arguments);
3641
3641
  } catch (e) {
3642
3642
  S("WebGLState:", e);
3643
3643
  }
3644
3644
  }
3645
- function Ee() {
3645
+ function De() {
3646
3646
  try {
3647
3647
  e.texStorage2D(...arguments);
3648
3648
  } catch (e) {
3649
3649
  S("WebGLState:", e);
3650
3650
  }
3651
3651
  }
3652
- function De() {
3652
+ function Oe() {
3653
3653
  try {
3654
3654
  e.texStorage3D(...arguments);
3655
3655
  } catch (e) {
3656
3656
  S("WebGLState:", e);
3657
3657
  }
3658
3658
  }
3659
- function Oe() {
3659
+ function ke() {
3660
3660
  try {
3661
3661
  e.texImage2D(...arguments);
3662
3662
  } catch (e) {
3663
3663
  S("WebGLState:", e);
3664
3664
  }
3665
3665
  }
3666
- function ke() {
3666
+ function W() {
3667
3667
  try {
3668
3668
  e.texImage3D(...arguments);
3669
3669
  } catch (e) {
@@ -3671,23 +3671,29 @@ function jr(e, t) {
3671
3671
  }
3672
3672
  }
3673
3673
  function Ae(t) {
3674
- z.equals(t) === !1 && (e.scissor(t.x, t.y, t.z, t.w), z.copy(t));
3675
- }
3676
- function W(t) {
3677
- ie.equals(t) === !1 && (e.viewport(t.x, t.y, t.z, t.w), ie.copy(t));
3674
+ return f[t] === void 0 ? e.getParameter(t) : f[t];
3678
3675
  }
3679
3676
  function je(t, n) {
3677
+ f[t] !== n && (e.pixelStorei(t, n), f[t] = n);
3678
+ }
3679
+ function Me(t) {
3680
+ ie.equals(t) === !1 && (e.scissor(t.x, t.y, t.z, t.w), ie.copy(t));
3681
+ }
3682
+ function Ne(t) {
3683
+ ae.equals(t) === !1 && (e.viewport(t.x, t.y, t.z, t.w), ae.copy(t));
3684
+ }
3685
+ function G(t, n) {
3680
3686
  let r = u.get(n);
3681
3687
  r === void 0 && (r = /* @__PURE__ */ new WeakMap(), u.set(n, r));
3682
3688
  let i = r.get(t);
3683
3689
  i === void 0 && (i = e.getUniformBlockIndex(n, t.name), r.set(t, i));
3684
3690
  }
3685
- function Me(t, n) {
3691
+ function Pe(t, n) {
3686
3692
  let r = u.get(n).get(t);
3687
3693
  l.get(n) !== r && (e.uniformBlockBinding(n, r, t.__bindingPointIndex), l.set(n, r));
3688
3694
  }
3689
- function Ne() {
3690
- e.disable(e.BLEND), e.disable(e.CULL_FACE), e.disable(e.DEPTH_TEST), e.disable(e.POLYGON_OFFSET_FILL), e.disable(e.SCISSOR_TEST), e.disable(e.STENCIL_TEST), e.disable(e.SAMPLE_ALPHA_TO_COVERAGE), e.blendEquation(e.FUNC_ADD), e.blendFunc(e.ONE, e.ZERO), e.blendFuncSeparate(e.ONE, e.ZERO, e.ONE, e.ZERO), e.blendColor(0, 0, 0, 0), e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.depthMask(!0), e.depthFunc(e.LESS), s.setReversed(!1), e.clearDepth(1), e.stencilMask(4294967295), e.stencilFunc(e.ALWAYS, 0, 4294967295), e.stencilOp(e.KEEP, e.KEEP, e.KEEP), e.clearStencil(0), e.cullFace(e.BACK), e.frontFace(e.CCW), e.polygonOffset(0, 0), e.activeTexture(e.TEXTURE0), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), e.bindFramebuffer(e.READ_FRAMEBUFFER, null), e.useProgram(null), e.lineWidth(1), e.scissor(0, 0, e.canvas.width, e.canvas.height), e.viewport(0, 0, e.canvas.width, e.canvas.height), d = {}, I = null, L = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, x = null, C = null, w = null, T = null, D = new a(0, 0, 0), O = 0, k = !1, A = null, j = null, M = null, ee = null, te = null, z.set(0, 0, e.canvas.width, e.canvas.height), ie.set(0, 0, e.canvas.width, e.canvas.height), o.reset(), s.reset(), c.reset();
3695
+ function Fe() {
3696
+ e.disable(e.BLEND), e.disable(e.CULL_FACE), e.disable(e.DEPTH_TEST), e.disable(e.POLYGON_OFFSET_FILL), e.disable(e.SCISSOR_TEST), e.disable(e.STENCIL_TEST), e.disable(e.SAMPLE_ALPHA_TO_COVERAGE), e.blendEquation(e.FUNC_ADD), e.blendFunc(e.ONE, e.ZERO), e.blendFuncSeparate(e.ONE, e.ZERO, e.ONE, e.ZERO), e.blendColor(0, 0, 0, 0), e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.depthMask(!0), e.depthFunc(e.LESS), s.setReversed(!1), e.clearDepth(1), e.stencilMask(4294967295), e.stencilFunc(e.ALWAYS, 0, 4294967295), e.stencilOp(e.KEEP, e.KEEP, e.KEEP), e.clearStencil(0), e.cullFace(e.BACK), e.frontFace(e.CCW), e.polygonOffset(0, 0), e.activeTexture(e.TEXTURE0), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), e.bindFramebuffer(e.READ_FRAMEBUFFER, null), e.useProgram(null), e.lineWidth(1), e.scissor(0, 0, e.canvas.width, e.canvas.height), e.viewport(0, 0, e.canvas.width, e.canvas.height), e.pixelStorei(e.PACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.BROWSER_DEFAULT_WEBGL), e.pixelStorei(e.PACK_ROW_LENGTH, 0), e.pixelStorei(e.PACK_SKIP_PIXELS, 0), e.pixelStorei(e.PACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_ROW_LENGTH, 0), e.pixelStorei(e.UNPACK_IMAGE_HEIGHT, 0), e.pixelStorei(e.UNPACK_SKIP_PIXELS, 0), e.pixelStorei(e.UNPACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_SKIP_IMAGES, 0), d = {}, f = {}, L = null, R = {}, p = {}, m = /* @__PURE__ */ new WeakMap(), h = [], g = null, _ = !1, v = null, y = null, x = null, C = null, w = null, T = null, D = null, O = new a(0, 0, 0), ee = 0, k = !1, A = null, j = null, M = null, te = null, ne = null, ie.set(0, 0, e.canvas.width, e.canvas.height), ae.set(0, 0, e.canvas.width, e.canvas.height), o.reset(), s.reset(), c.reset();
3691
3697
  }
3692
3698
  return {
3693
3699
  buffers: {
@@ -3697,107 +3703,111 @@ function jr(e, t) {
3697
3703
  },
3698
3704
  enable: B,
3699
3705
  disable: V,
3700
- bindFramebuffer: se,
3701
- drawBuffers: ce,
3702
- useProgram: le,
3703
- setBlending: fe,
3704
- setMaterial: pe,
3705
- setFlipSided: me,
3706
- setCullFace: he,
3707
- setLineWidth: H,
3706
+ bindFramebuffer: ce,
3707
+ drawBuffers: le,
3708
+ useProgram: ue,
3709
+ setBlending: U,
3710
+ setMaterial: fe,
3711
+ setFlipSided: pe,
3712
+ setCullFace: me,
3713
+ setLineWidth: he,
3708
3714
  setPolygonOffset: ge,
3709
3715
  setScissorTest: _e,
3710
3716
  activeTexture: ve,
3711
3717
  bindTexture: ye,
3712
3718
  unbindTexture: be,
3713
- compressedTexImage2D: U,
3714
- compressedTexImage3D: xe,
3715
- texImage2D: Oe,
3716
- texImage3D: ke,
3717
- updateUBOMapping: je,
3718
- uniformBlockBinding: Me,
3719
- texStorage2D: Ee,
3720
- texStorage3D: De,
3721
- texSubImage2D: Se,
3722
- texSubImage3D: Ce,
3723
- compressedTexSubImage2D: we,
3724
- compressedTexSubImage3D: Te,
3725
- scissor: Ae,
3726
- viewport: W,
3727
- reset: Ne
3719
+ compressedTexImage2D: xe,
3720
+ compressedTexImage3D: Se,
3721
+ texImage2D: ke,
3722
+ texImage3D: W,
3723
+ pixelStorei: je,
3724
+ getParameter: Ae,
3725
+ updateUBOMapping: G,
3726
+ uniformBlockBinding: Pe,
3727
+ texStorage2D: De,
3728
+ texStorage3D: Oe,
3729
+ texSubImage2D: Ce,
3730
+ texSubImage3D: we,
3731
+ compressedTexSubImage2D: Te,
3732
+ compressedTexSubImage3D: Ee,
3733
+ scissor: Me,
3734
+ viewport: Ne,
3735
+ reset: Fe
3728
3736
  };
3729
3737
  }
3730
3738
  function Mr(e, t, n, r, i, a, o) {
3731
- let s = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), u = new L(), d = /* @__PURE__ */ new WeakMap(), p, m = /* @__PURE__ */ new WeakMap(), h = !1;
3739
+ let s = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), u = new L(), d = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new Set(), m, h = /* @__PURE__ */ new WeakMap(), g = !1;
3732
3740
  try {
3733
- h = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
3741
+ g = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
3734
3742
  } catch {}
3735
- function g(e, t) {
3736
- return h ? new OffscreenCanvas(e, t) : y("canvas");
3743
+ function v(e, t) {
3744
+ return g ? new OffscreenCanvas(e, t) : y("canvas");
3737
3745
  }
3738
- function v(e, t, n) {
3739
- let r = 1, i = Oe(e);
3746
+ function b(e, t, n) {
3747
+ let r = 1, i = Ne(e);
3740
3748
  if ((i.width > n || i.height > n) && (r = n / Math.max(i.width, i.height)), r < 1) if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof VideoFrame < "u" && e instanceof VideoFrame) {
3741
3749
  let n = Math.floor(r * i.width), a = Math.floor(r * i.height);
3742
- p === void 0 && (p = g(n, a));
3743
- let o = t ? g(n, a) : p;
3750
+ m === void 0 && (m = v(n, a));
3751
+ let o = t ? v(n, a) : m;
3744
3752
  return o.width = n, o.height = a, o.getContext("2d").drawImage(e, 0, 0, n, a), f("WebGLRenderer: Texture has been resized from (" + i.width + "x" + i.height + ") to (" + n + "x" + a + ")."), o;
3745
3753
  } else return "data" in e && f("WebGLRenderer: Image in DataTexture is too big (" + i.width + "x" + i.height + ")."), e;
3746
3754
  return e;
3747
3755
  }
3748
- function b(e) {
3756
+ function x(e) {
3749
3757
  return e.generateMipmaps;
3750
3758
  }
3751
- function x(t) {
3759
+ function w(t) {
3752
3760
  e.generateMipmap(t);
3753
3761
  }
3754
- function w(t) {
3762
+ function T(t) {
3755
3763
  return t.isWebGLCubeRenderTarget ? e.TEXTURE_CUBE_MAP : t.isWebGL3DRenderTarget ? e.TEXTURE_3D : t.isWebGLArrayRenderTarget || t.isCompressedArrayTexture ? e.TEXTURE_2D_ARRAY : e.TEXTURE_2D;
3756
3764
  }
3757
- function T(n, r, i, a, o = !1) {
3765
+ function E(n, r, i, a, o, s = !1) {
3758
3766
  if (n !== null) {
3759
3767
  if (e[n] !== void 0) return e[n];
3760
3768
  f("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + n + "'");
3761
3769
  }
3762
- let s = r;
3763
- if (r === e.RED && (i === e.FLOAT && (s = e.R32F), i === e.HALF_FLOAT && (s = e.R16F), i === e.UNSIGNED_BYTE && (s = e.R8)), r === e.RED_INTEGER && (i === e.UNSIGNED_BYTE && (s = e.R8UI), i === e.UNSIGNED_SHORT && (s = e.R16UI), i === e.UNSIGNED_INT && (s = e.R32UI), i === e.BYTE && (s = e.R8I), i === e.SHORT && (s = e.R16I), i === e.INT && (s = e.R32I)), r === e.RG && (i === e.FLOAT && (s = e.RG32F), i === e.HALF_FLOAT && (s = e.RG16F), i === e.UNSIGNED_BYTE && (s = e.RG8)), r === e.RG_INTEGER && (i === e.UNSIGNED_BYTE && (s = e.RG8UI), i === e.UNSIGNED_SHORT && (s = e.RG16UI), i === e.UNSIGNED_INT && (s = e.RG32UI), i === e.BYTE && (s = e.RG8I), i === e.SHORT && (s = e.RG16I), i === e.INT && (s = e.RG32I)), r === e.RGB_INTEGER && (i === e.UNSIGNED_BYTE && (s = e.RGB8UI), i === e.UNSIGNED_SHORT && (s = e.RGB16UI), i === e.UNSIGNED_INT && (s = e.RGB32UI), i === e.BYTE && (s = e.RGB8I), i === e.SHORT && (s = e.RGB16I), i === e.INT && (s = e.RGB32I)), r === e.RGBA_INTEGER && (i === e.UNSIGNED_BYTE && (s = e.RGBA8UI), i === e.UNSIGNED_SHORT && (s = e.RGBA16UI), i === e.UNSIGNED_INT && (s = e.RGBA32UI), i === e.BYTE && (s = e.RGBA8I), i === e.SHORT && (s = e.RGBA16I), i === e.INT && (s = e.RGBA32I)), r === e.RGB && (i === e.UNSIGNED_INT_5_9_9_9_REV && (s = e.RGB9_E5), i === e.UNSIGNED_INT_10F_11F_11F_REV && (s = e.R11F_G11F_B10F)), r === e.RGBA) {
3764
- let t = o ? C : O.getTransfer(a);
3765
- i === e.FLOAT && (s = e.RGBA32F), i === e.HALF_FLOAT && (s = e.RGBA16F), i === e.UNSIGNED_BYTE && (s = t === "srgb" ? e.SRGB8_ALPHA8 : e.RGBA8), i === e.UNSIGNED_SHORT_4_4_4_4 && (s = e.RGBA4), i === e.UNSIGNED_SHORT_5_5_5_1 && (s = e.RGB5_A1);
3770
+ let c;
3771
+ a && (c = t.get("EXT_texture_norm16"), c || f("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));
3772
+ let l = r;
3773
+ if (r === e.RED && (i === e.FLOAT && (l = e.R32F), i === e.HALF_FLOAT && (l = e.R16F), i === e.UNSIGNED_BYTE && (l = e.R8), i === e.UNSIGNED_SHORT && c && (l = c.R16_EXT), i === e.SHORT && c && (l = c.R16_SNORM_EXT)), r === e.RED_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.R8UI), i === e.UNSIGNED_SHORT && (l = e.R16UI), i === e.UNSIGNED_INT && (l = e.R32UI), i === e.BYTE && (l = e.R8I), i === e.SHORT && (l = e.R16I), i === e.INT && (l = e.R32I)), r === e.RG && (i === e.FLOAT && (l = e.RG32F), i === e.HALF_FLOAT && (l = e.RG16F), i === e.UNSIGNED_BYTE && (l = e.RG8), i === e.UNSIGNED_SHORT && c && (l = c.RG16_EXT), i === e.SHORT && c && (l = c.RG16_SNORM_EXT)), r === e.RG_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RG8UI), i === e.UNSIGNED_SHORT && (l = e.RG16UI), i === e.UNSIGNED_INT && (l = e.RG32UI), i === e.BYTE && (l = e.RG8I), i === e.SHORT && (l = e.RG16I), i === e.INT && (l = e.RG32I)), r === e.RGB_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGB8UI), i === e.UNSIGNED_SHORT && (l = e.RGB16UI), i === e.UNSIGNED_INT && (l = e.RGB32UI), i === e.BYTE && (l = e.RGB8I), i === e.SHORT && (l = e.RGB16I), i === e.INT && (l = e.RGB32I)), r === e.RGBA_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGBA8UI), i === e.UNSIGNED_SHORT && (l = e.RGBA16UI), i === e.UNSIGNED_INT && (l = e.RGBA32UI), i === e.BYTE && (l = e.RGBA8I), i === e.SHORT && (l = e.RGBA16I), i === e.INT && (l = e.RGBA32I)), r === e.RGB && (i === e.UNSIGNED_SHORT && c && (l = c.RGB16_EXT), i === e.SHORT && c && (l = c.RGB16_SNORM_EXT), i === e.UNSIGNED_INT_5_9_9_9_REV && (l = e.RGB9_E5), i === e.UNSIGNED_INT_10F_11F_11F_REV && (l = e.R11F_G11F_B10F)), r === e.RGBA) {
3774
+ let t = s ? C : O.getTransfer(o);
3775
+ i === e.FLOAT && (l = e.RGBA32F), i === e.HALF_FLOAT && (l = e.RGBA16F), i === e.UNSIGNED_BYTE && (l = t === "srgb" ? e.SRGB8_ALPHA8 : e.RGBA8), i === e.UNSIGNED_SHORT && c && (l = c.RGBA16_EXT), i === e.SHORT && c && (l = c.RGBA16_SNORM_EXT), i === e.UNSIGNED_SHORT_4_4_4_4 && (l = e.RGBA4), i === e.UNSIGNED_SHORT_5_5_5_1 && (l = e.RGB5_A1);
3766
3776
  }
3767
- return (s === e.R16F || s === e.R32F || s === e.RG16F || s === e.RG32F || s === e.RGBA16F || s === e.RGBA32F) && t.get("EXT_color_buffer_float"), s;
3777
+ return (l === e.R16F || l === e.R32F || l === e.RG16F || l === e.RG32F || l === e.RGBA16F || l === e.RGBA32F) && t.get("EXT_color_buffer_float"), l;
3768
3778
  }
3769
- function E(t, n) {
3779
+ function D(t, n) {
3770
3780
  let r;
3771
3781
  return t ? n === null || n === 1014 || n === 1020 ? r = e.DEPTH24_STENCIL8 : n === 1015 ? r = e.DEPTH32F_STENCIL8 : n === 1012 && (r = e.DEPTH24_STENCIL8, f("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : n === null || n === 1014 || n === 1020 ? r = e.DEPTH_COMPONENT24 : n === 1015 ? r = e.DEPTH_COMPONENT32F : n === 1012 && (r = e.DEPTH_COMPONENT16), r;
3772
3782
  }
3773
- function D(e, t) {
3774
- return b(e) === !0 || e.isFramebufferTexture && e.minFilter !== 1003 && e.minFilter !== 1006 ? Math.log2(Math.max(t.width, t.height)) + 1 : e.mipmaps !== void 0 && e.mipmaps.length > 0 ? e.mipmaps.length : e.isCompressedTexture && Array.isArray(e.image) ? t.mipmaps.length : 1;
3783
+ function ee(e, t) {
3784
+ return x(e) === !0 || e.isFramebufferTexture && e.minFilter !== 1003 && e.minFilter !== 1006 ? Math.log2(Math.max(t.width, t.height)) + 1 : e.mipmaps !== void 0 && e.mipmaps.length > 0 ? e.mipmaps.length : e.isCompressedTexture && Array.isArray(e.image) ? t.mipmaps.length : 1;
3775
3785
  }
3776
3786
  function k(e) {
3777
3787
  let t = e.target;
3778
- t.removeEventListener("dispose", k), j(t), t.isVideoTexture && d.delete(t);
3788
+ t.removeEventListener("dispose", k), j(t), t.isVideoTexture && d.delete(t), t.isHTMLTexture && p.delete(t);
3779
3789
  }
3780
3790
  function A(e) {
3781
3791
  let t = e.target;
3782
- t.removeEventListener("dispose", A), ne(t);
3792
+ t.removeEventListener("dispose", A), N(t);
3783
3793
  }
3784
3794
  function j(e) {
3785
3795
  let t = r.get(e);
3786
3796
  if (t.__webglInit === void 0) return;
3787
- let n = e.source, i = m.get(n);
3797
+ let n = e.source, i = h.get(n);
3788
3798
  if (i) {
3789
3799
  let r = i[t.__cacheKey];
3790
- r.usedTimes--, r.usedTimes === 0 && M(e), Object.keys(i).length === 0 && m.delete(n);
3800
+ r.usedTimes--, r.usedTimes === 0 && ne(e), Object.keys(i).length === 0 && h.delete(n);
3791
3801
  }
3792
3802
  r.remove(e);
3793
3803
  }
3794
- function M(t) {
3804
+ function ne(t) {
3795
3805
  let n = r.get(t);
3796
3806
  e.deleteTexture(n.__webglTexture);
3797
- let i = t.source, a = m.get(i);
3807
+ let i = t.source, a = h.get(i);
3798
3808
  delete a[n.__cacheKey], o.memory.textures--;
3799
3809
  }
3800
- function ne(t) {
3810
+ function N(t) {
3801
3811
  let n = r.get(t);
3802
3812
  if (t.depthTexture && (t.depthTexture.dispose(), r.remove(t.depthTexture)), t.isWebGLCubeRenderTarget) for (let t = 0; t < 6; t++) {
3803
3813
  if (Array.isArray(n.__webglFramebuffer[t])) for (let r = 0; r < n.__webglFramebuffer[t].length; r++) e.deleteFramebuffer(n.__webglFramebuffer[t][r]);
@@ -3817,67 +3827,73 @@ function Mr(e, t, n, r, i, a, o) {
3817
3827
  }
3818
3828
  r.remove(t);
3819
3829
  }
3820
- let N = 0;
3821
- function P() {
3822
- N = 0;
3823
- }
3830
+ let P = 0;
3824
3831
  function F() {
3825
- let e = N;
3826
- return e >= i.maxTextures && f("WebGLTextures: Trying to use " + e + " texture units while this GPU supports only " + i.maxTextures), N += 1, e;
3832
+ P = 0;
3833
+ }
3834
+ function I() {
3835
+ return P;
3827
3836
  }
3828
- function I(e) {
3837
+ function re(e) {
3838
+ P = e;
3839
+ }
3840
+ function z() {
3841
+ let e = P;
3842
+ return e >= i.maxTextures && f("WebGLTextures: Trying to use " + e + " texture units while this GPU supports only " + i.maxTextures), P += 1, e;
3843
+ }
3844
+ function ie(e) {
3829
3845
  let t = [];
3830
3846
  return t.push(e.wrapS), t.push(e.wrapT), t.push(e.wrapR || 0), t.push(e.magFilter), t.push(e.minFilter), t.push(e.anisotropy), t.push(e.internalFormat), t.push(e.format), t.push(e.type), t.push(e.generateMipmaps), t.push(e.premultiplyAlpha), t.push(e.flipY), t.push(e.unpackAlignment), t.push(e.colorSpace), t.join();
3831
3847
  }
3832
- function re(t, i) {
3848
+ function ae(t, i) {
3833
3849
  let a = r.get(t);
3834
- if (t.isVideoTexture && Te(t), t.isRenderTargetTexture === !1 && t.isExternalTexture !== !0 && t.version > 0 && a.__version !== t.version) {
3850
+ if (t.isVideoTexture && W(t), t.isRenderTargetTexture === !1 && t.isExternalTexture !== !0 && t.version > 0 && a.__version !== t.version) {
3835
3851
  let e = t.image;
3836
3852
  if (e === null) f("WebGLRenderer: Texture marked for update but no image data found.");
3837
3853
  else if (e.complete === !1) f("WebGLRenderer: Texture marked for update but image is incomplete");
3838
3854
  else {
3839
- fe(a, t, i);
3855
+ pe(a, t, i);
3840
3856
  return;
3841
3857
  }
3842
3858
  } else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null);
3843
3859
  n.bindTexture(e.TEXTURE_2D, a.__webglTexture, e.TEXTURE0 + i);
3844
3860
  }
3845
- function z(t, i) {
3861
+ function oe(t, i) {
3846
3862
  let a = r.get(t);
3847
3863
  if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) {
3848
- fe(a, t, i);
3864
+ pe(a, t, i);
3849
3865
  return;
3850
3866
  } else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null);
3851
3867
  n.bindTexture(e.TEXTURE_2D_ARRAY, a.__webglTexture, e.TEXTURE0 + i);
3852
3868
  }
3853
- function ie(t, i) {
3869
+ function se(t, i) {
3854
3870
  let a = r.get(t);
3855
3871
  if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) {
3856
- fe(a, t, i);
3872
+ pe(a, t, i);
3857
3873
  return;
3858
3874
  }
3859
3875
  n.bindTexture(e.TEXTURE_3D, a.__webglTexture, e.TEXTURE0 + i);
3860
3876
  }
3861
- function ae(t, i) {
3877
+ function B(t, i) {
3862
3878
  let a = r.get(t);
3863
3879
  if (t.isCubeDepthTexture !== !0 && t.version > 0 && a.__version !== t.version) {
3864
- pe(a, t, i);
3880
+ me(a, t, i);
3865
3881
  return;
3866
3882
  }
3867
3883
  n.bindTexture(e.TEXTURE_CUBE_MAP, a.__webglTexture, e.TEXTURE0 + i);
3868
3884
  }
3869
- let oe = {
3870
- [se]: e.REPEAT,
3871
- [Ae]: e.CLAMP_TO_EDGE,
3872
- [De]: e.MIRRORED_REPEAT
3873
- }, B = {
3874
- [Ne]: e.NEAREST,
3875
- [je]: e.NEAREST_MIPMAP_NEAREST,
3885
+ let ce = {
3886
+ [V]: e.REPEAT,
3887
+ [ke]: e.CLAMP_TO_EDGE,
3888
+ [Ee]: e.MIRRORED_REPEAT
3889
+ }, le = {
3890
+ [Me]: e.NEAREST,
3891
+ [Ae]: e.NEAREST_MIPMAP_NEAREST,
3876
3892
  [R]: e.NEAREST_MIPMAP_LINEAR,
3877
3893
  [_]: e.LINEAR,
3878
- [ee]: e.LINEAR_MIPMAP_NEAREST,
3894
+ [M]: e.LINEAR_MIPMAP_NEAREST,
3879
3895
  [te]: e.LINEAR_MIPMAP_LINEAR
3880
- }, V = {
3896
+ }, ue = {
3881
3897
  512: e.NEVER,
3882
3898
  519: e.ALWAYS,
3883
3899
  513: e.LESS,
@@ -3887,8 +3903,8 @@ function Mr(e, t, n, r, i, a, o) {
3887
3903
  516: e.GREATER,
3888
3904
  517: e.NOTEQUAL
3889
3905
  };
3890
- function ce(n, a) {
3891
- if (a.type === 1015 && t.has("OES_texture_float_linear") === !1 && (a.magFilter === 1006 || a.magFilter === 1007 || a.magFilter === 1005 || a.magFilter === 1008 || a.minFilter === 1006 || a.minFilter === 1007 || a.minFilter === 1005 || a.minFilter === 1008) && f("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), e.texParameteri(n, e.TEXTURE_WRAP_S, oe[a.wrapS]), e.texParameteri(n, e.TEXTURE_WRAP_T, oe[a.wrapT]), (n === e.TEXTURE_3D || n === e.TEXTURE_2D_ARRAY) && e.texParameteri(n, e.TEXTURE_WRAP_R, oe[a.wrapR]), e.texParameteri(n, e.TEXTURE_MAG_FILTER, B[a.magFilter]), e.texParameteri(n, e.TEXTURE_MIN_FILTER, B[a.minFilter]), a.compareFunction && (e.texParameteri(n, e.TEXTURE_COMPARE_MODE, e.COMPARE_REF_TO_TEXTURE), e.texParameteri(n, e.TEXTURE_COMPARE_FUNC, V[a.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
3906
+ function H(n, a) {
3907
+ if (a.type === 1015 && t.has("OES_texture_float_linear") === !1 && (a.magFilter === 1006 || a.magFilter === 1007 || a.magFilter === 1005 || a.magFilter === 1008 || a.minFilter === 1006 || a.minFilter === 1007 || a.minFilter === 1005 || a.minFilter === 1008) && f("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), e.texParameteri(n, e.TEXTURE_WRAP_S, ce[a.wrapS]), e.texParameteri(n, e.TEXTURE_WRAP_T, ce[a.wrapT]), (n === e.TEXTURE_3D || n === e.TEXTURE_2D_ARRAY) && e.texParameteri(n, e.TEXTURE_WRAP_R, ce[a.wrapR]), e.texParameteri(n, e.TEXTURE_MAG_FILTER, le[a.magFilter]), e.texParameteri(n, e.TEXTURE_MIN_FILTER, le[a.minFilter]), a.compareFunction && (e.texParameteri(n, e.TEXTURE_COMPARE_MODE, e.COMPARE_REF_TO_TEXTURE), e.texParameteri(n, e.TEXTURE_COMPARE_FUNC, ue[a.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) {
3892
3908
  if (a.magFilter === 1003 || a.minFilter !== 1005 && a.minFilter !== 1008 || a.type === 1015 && t.has("OES_texture_float_linear") === !1) return;
3893
3909
  if (a.anisotropy > 1 || r.get(a).__currentAnisotropy) {
3894
3910
  let o = t.get("EXT_texture_filter_anisotropic");
@@ -3896,205 +3912,220 @@ function Mr(e, t, n, r, i, a, o) {
3896
3912
  }
3897
3913
  }
3898
3914
  }
3899
- function le(t, n) {
3915
+ function de(t, n) {
3900
3916
  let r = !1;
3901
3917
  t.__webglInit === void 0 && (t.__webglInit = !0, n.addEventListener("dispose", k));
3902
- let i = n.source, a = m.get(i);
3903
- a === void 0 && (a = {}, m.set(i, a));
3904
- let s = I(n);
3918
+ let i = n.source, a = h.get(i);
3919
+ a === void 0 && (a = {}, h.set(i, a));
3920
+ let s = ie(n);
3905
3921
  if (s !== t.__cacheKey) {
3906
3922
  a[s] === void 0 && (a[s] = {
3907
3923
  texture: e.createTexture(),
3908
3924
  usedTimes: 0
3909
3925
  }, o.memory.textures++, r = !0), a[s].usedTimes++;
3910
3926
  let i = a[t.__cacheKey];
3911
- i !== void 0 && (a[t.__cacheKey].usedTimes--, i.usedTimes === 0 && M(n)), t.__cacheKey = s, t.__webglTexture = a[s].texture;
3927
+ i !== void 0 && (a[t.__cacheKey].usedTimes--, i.usedTimes === 0 && ne(n)), t.__cacheKey = s, t.__webglTexture = a[s].texture;
3912
3928
  }
3913
3929
  return r;
3914
3930
  }
3915
- function ue(e, t, n) {
3931
+ function U(e, t, n) {
3916
3932
  return Math.floor(Math.floor(e / n) / t);
3917
3933
  }
3918
- function de(t, r, i, a) {
3934
+ function fe(t, r, i, a) {
3919
3935
  let o = t.updateRanges;
3920
3936
  if (o.length === 0) n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r.width, r.height, i, a, r.data);
3921
3937
  else {
3922
3938
  o.sort((e, t) => e.start - t.start);
3923
3939
  let s = 0;
3924
3940
  for (let e = 1; e < o.length; e++) {
3925
- let t = o[s], n = o[e], i = t.start + t.count, a = ue(n.start, r.width, 4), c = ue(t.start, r.width, 4);
3926
- n.start <= i + 1 && a === c && ue(n.start + n.count - 1, r.width, 4) === a ? t.count = Math.max(t.count, n.start + n.count - t.start) : (++s, o[s] = n);
3941
+ let t = o[s], n = o[e], i = t.start + t.count, a = U(n.start, r.width, 4), c = U(t.start, r.width, 4);
3942
+ n.start <= i + 1 && a === c && U(n.start + n.count - 1, r.width, 4) === a ? t.count = Math.max(t.count, n.start + n.count - t.start) : (++s, o[s] = n);
3927
3943
  }
3928
3944
  o.length = s + 1;
3929
- let c = e.getParameter(e.UNPACK_ROW_LENGTH), l = e.getParameter(e.UNPACK_SKIP_PIXELS), u = e.getParameter(e.UNPACK_SKIP_ROWS);
3930
- e.pixelStorei(e.UNPACK_ROW_LENGTH, r.width);
3945
+ let c = n.getParameter(e.UNPACK_ROW_LENGTH), l = n.getParameter(e.UNPACK_SKIP_PIXELS), u = n.getParameter(e.UNPACK_SKIP_ROWS);
3946
+ n.pixelStorei(e.UNPACK_ROW_LENGTH, r.width);
3931
3947
  for (let t = 0, s = o.length; t < s; t++) {
3932
3948
  let s = o[t], c = Math.floor(s.start / 4), l = Math.ceil(s.count / 4), u = c % r.width, d = Math.floor(c / r.width), f = l;
3933
- e.pixelStorei(e.UNPACK_SKIP_PIXELS, u), e.pixelStorei(e.UNPACK_SKIP_ROWS, d), n.texSubImage2D(e.TEXTURE_2D, 0, u, d, f, 1, i, a, r.data);
3949
+ n.pixelStorei(e.UNPACK_SKIP_PIXELS, u), n.pixelStorei(e.UNPACK_SKIP_ROWS, d), n.texSubImage2D(e.TEXTURE_2D, 0, u, d, f, 1, i, a, r.data);
3934
3950
  }
3935
- t.clearUpdateRanges(), e.pixelStorei(e.UNPACK_ROW_LENGTH, c), e.pixelStorei(e.UNPACK_SKIP_PIXELS, l), e.pixelStorei(e.UNPACK_SKIP_ROWS, u);
3951
+ t.clearUpdateRanges(), n.pixelStorei(e.UNPACK_ROW_LENGTH, c), n.pixelStorei(e.UNPACK_SKIP_PIXELS, l), n.pixelStorei(e.UNPACK_SKIP_ROWS, u);
3936
3952
  }
3937
3953
  }
3938
- function fe(t, o, s) {
3954
+ function pe(t, o, s) {
3939
3955
  let c = e.TEXTURE_2D;
3940
3956
  (o.isDataArrayTexture || o.isCompressedArrayTexture) && (c = e.TEXTURE_2D_ARRAY), o.isData3DTexture && (c = e.TEXTURE_3D);
3941
- let u = le(t, o), d = o.source;
3957
+ let u = de(t, o), d = o.source;
3942
3958
  n.bindTexture(c, t.__webglTexture, e.TEXTURE0 + s);
3943
- let p = r.get(d);
3944
- if (d.version !== p.__version || u === !0) {
3945
- n.activeTexture(e.TEXTURE0 + s);
3946
- let t = O.getPrimaries(O.workingColorSpace), r = o.colorSpace === "" ? null : O.getPrimaries(o.colorSpace), m = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL;
3947
- e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), e.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, m);
3948
- let h = v(o.image, !1, i.maxTextureSize);
3949
- h = Ee(o, h);
3950
- let g = a.convert(o.format, o.colorSpace), _ = a.convert(o.type), y = T(o.internalFormat, g, _, o.colorSpace, o.isVideoTexture);
3951
- ce(c, o);
3952
- let S, C = o.mipmaps, w = o.isVideoTexture !== !0, k = p.__version === void 0 || u === !0, A = d.dataReady, j = D(o, h);
3953
- if (o.isDepthTexture) y = E(o.format === ye, o.type), k && (w ? n.texStorage2D(e.TEXTURE_2D, 1, y, h.width, h.height) : n.texImage2D(e.TEXTURE_2D, 0, y, h.width, h.height, 0, g, _, null));
3954
- else if (o.isDataTexture) if (C.length > 0) {
3955
- w && k && n.texStorage2D(e.TEXTURE_2D, j, y, C[0].width, C[0].height);
3956
- for (let t = 0, r = C.length; t < r; t++) S = C[t], w ? A && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, S.width, S.height, g, _, S.data) : n.texImage2D(e.TEXTURE_2D, t, y, S.width, S.height, 0, g, _, S.data);
3959
+ let m = r.get(d);
3960
+ if (d.version !== m.__version || u === !0) {
3961
+ if (n.activeTexture(e.TEXTURE0 + s), !(typeof ImageBitmap < "u" && o.image instanceof ImageBitmap)) {
3962
+ let t = O.getPrimaries(O.workingColorSpace), r = o.colorSpace === "" ? null : O.getPrimaries(o.colorSpace), i = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL;
3963
+ n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, i);
3964
+ }
3965
+ n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment);
3966
+ let t = b(o.image, !1, i.maxTextureSize);
3967
+ t = je(o, t);
3968
+ let r = a.convert(o.format, o.colorSpace), h = a.convert(o.type), g = E(o.internalFormat, r, h, o.normalized, o.colorSpace, o.isVideoTexture);
3969
+ H(c, o);
3970
+ let _, v = o.mipmaps, y = o.isVideoTexture !== !0, S = m.__version === void 0 || u === !0, C = d.dataReady, T = ee(o, t);
3971
+ if (o.isDepthTexture) g = D(o.format === ve, o.type), S && (y ? n.texStorage2D(e.TEXTURE_2D, 1, g, t.width, t.height) : n.texImage2D(e.TEXTURE_2D, 0, g, t.width, t.height, 0, r, h, null));
3972
+ else if (o.isDataTexture) if (v.length > 0) {
3973
+ y && S && n.texStorage2D(e.TEXTURE_2D, T, g, v[0].width, v[0].height);
3974
+ for (let t = 0, i = v.length; t < i; t++) _ = v[t], y ? C && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, _.width, _.height, r, h, _.data) : n.texImage2D(e.TEXTURE_2D, t, g, _.width, _.height, 0, r, h, _.data);
3957
3975
  o.generateMipmaps = !1;
3958
- } else w ? (k && n.texStorage2D(e.TEXTURE_2D, j, y, h.width, h.height), A && de(o, h, g, _)) : n.texImage2D(e.TEXTURE_2D, 0, y, h.width, h.height, 0, g, _, h.data);
3976
+ } else y ? (S && n.texStorage2D(e.TEXTURE_2D, T, g, t.width, t.height), C && fe(o, t, r, h)) : n.texImage2D(e.TEXTURE_2D, 0, g, t.width, t.height, 0, r, h, t.data);
3959
3977
  else if (o.isCompressedTexture) if (o.isCompressedArrayTexture) {
3960
- w && k && n.texStorage3D(e.TEXTURE_2D_ARRAY, j, y, C[0].width, C[0].height, h.depth);
3961
- for (let t = 0, r = C.length; t < r; t++) if (S = C[t], o.format !== 1023) if (g !== null) if (w) {
3962
- if (A) if (o.layerUpdates.size > 0) {
3963
- let r = l(S.width, S.height, o.format, o.type);
3964
- for (let i of o.layerUpdates) {
3965
- let a = S.data.subarray(i * r / S.data.BYTES_PER_ELEMENT, (i + 1) * r / S.data.BYTES_PER_ELEMENT);
3966
- n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, t, 0, 0, i, S.width, S.height, 1, g, a);
3978
+ y && S && n.texStorage3D(e.TEXTURE_2D_ARRAY, T, g, v[0].width, v[0].height, t.depth);
3979
+ for (let i = 0, a = v.length; i < a; i++) if (_ = v[i], o.format !== 1023) if (r !== null) if (y) {
3980
+ if (C) if (o.layerUpdates.size > 0) {
3981
+ let t = l(_.width, _.height, o.format, o.type);
3982
+ for (let a of o.layerUpdates) {
3983
+ let o = _.data.subarray(a * t / _.data.BYTES_PER_ELEMENT, (a + 1) * t / _.data.BYTES_PER_ELEMENT);
3984
+ n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, a, _.width, _.height, 1, r, o);
3967
3985
  }
3968
3986
  o.clearLayerUpdates();
3969
- } else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, t, 0, 0, 0, S.width, S.height, h.depth, g, S.data);
3970
- } else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY, t, y, S.width, S.height, h.depth, 0, S.data, 0, 0);
3987
+ } else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, _.width, _.height, t.depth, r, _.data);
3988
+ } else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY, i, g, _.width, _.height, t.depth, 0, _.data, 0, 0);
3971
3989
  else f("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");
3972
- else w ? A && n.texSubImage3D(e.TEXTURE_2D_ARRAY, t, 0, 0, 0, S.width, S.height, h.depth, g, _, S.data) : n.texImage3D(e.TEXTURE_2D_ARRAY, t, y, S.width, S.height, h.depth, 0, g, _, S.data);
3990
+ else y ? C && n.texSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, _.width, _.height, t.depth, r, h, _.data) : n.texImage3D(e.TEXTURE_2D_ARRAY, i, g, _.width, _.height, t.depth, 0, r, h, _.data);
3973
3991
  } else {
3974
- w && k && n.texStorage2D(e.TEXTURE_2D, j, y, C[0].width, C[0].height);
3975
- for (let t = 0, r = C.length; t < r; t++) S = C[t], o.format === 1023 ? w ? A && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, S.width, S.height, g, _, S.data) : n.texImage2D(e.TEXTURE_2D, t, y, S.width, S.height, 0, g, _, S.data) : g === null ? f("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : w ? A && n.compressedTexSubImage2D(e.TEXTURE_2D, t, 0, 0, S.width, S.height, g, S.data) : n.compressedTexImage2D(e.TEXTURE_2D, t, y, S.width, S.height, 0, S.data);
3992
+ y && S && n.texStorage2D(e.TEXTURE_2D, T, g, v[0].width, v[0].height);
3993
+ for (let t = 0, i = v.length; t < i; t++) _ = v[t], o.format === 1023 ? y ? C && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, _.width, _.height, r, h, _.data) : n.texImage2D(e.TEXTURE_2D, t, g, _.width, _.height, 0, r, h, _.data) : r === null ? f("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : y ? C && n.compressedTexSubImage2D(e.TEXTURE_2D, t, 0, 0, _.width, _.height, r, _.data) : n.compressedTexImage2D(e.TEXTURE_2D, t, g, _.width, _.height, 0, _.data);
3976
3994
  }
3977
- else if (o.isDataArrayTexture) if (w) {
3978
- if (k && n.texStorage3D(e.TEXTURE_2D_ARRAY, j, y, h.width, h.height, h.depth), A) if (o.layerUpdates.size > 0) {
3979
- let t = l(h.width, h.height, o.format, o.type);
3980
- for (let r of o.layerUpdates) {
3981
- let i = h.data.subarray(r * t / h.data.BYTES_PER_ELEMENT, (r + 1) * t / h.data.BYTES_PER_ELEMENT);
3982
- n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, r, h.width, h.height, 1, g, _, i);
3995
+ else if (o.isDataArrayTexture) if (y) {
3996
+ if (S && n.texStorage3D(e.TEXTURE_2D_ARRAY, T, g, t.width, t.height, t.depth), C) if (o.layerUpdates.size > 0) {
3997
+ let i = l(t.width, t.height, o.format, o.type);
3998
+ for (let a of o.layerUpdates) {
3999
+ let o = t.data.subarray(a * i / t.data.BYTES_PER_ELEMENT, (a + 1) * i / t.data.BYTES_PER_ELEMENT);
4000
+ n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, a, t.width, t.height, 1, r, h, o);
3983
4001
  }
3984
4002
  o.clearLayerUpdates();
3985
- } else n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, 0, h.width, h.height, h.depth, g, _, h.data);
3986
- } else n.texImage3D(e.TEXTURE_2D_ARRAY, 0, y, h.width, h.height, h.depth, 0, g, _, h.data);
3987
- else if (o.isData3DTexture) w ? (k && n.texStorage3D(e.TEXTURE_3D, j, y, h.width, h.height, h.depth), A && n.texSubImage3D(e.TEXTURE_3D, 0, 0, 0, 0, h.width, h.height, h.depth, g, _, h.data)) : n.texImage3D(e.TEXTURE_3D, 0, y, h.width, h.height, h.depth, 0, g, _, h.data);
4003
+ } else n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, 0, t.width, t.height, t.depth, r, h, t.data);
4004
+ } else n.texImage3D(e.TEXTURE_2D_ARRAY, 0, g, t.width, t.height, t.depth, 0, r, h, t.data);
4005
+ else if (o.isData3DTexture) y ? (S && n.texStorage3D(e.TEXTURE_3D, T, g, t.width, t.height, t.depth), C && n.texSubImage3D(e.TEXTURE_3D, 0, 0, 0, 0, t.width, t.height, t.depth, r, h, t.data)) : n.texImage3D(e.TEXTURE_3D, 0, g, t.width, t.height, t.depth, 0, r, h, t.data);
3988
4006
  else if (o.isFramebufferTexture) {
3989
- if (k) if (w) n.texStorage2D(e.TEXTURE_2D, j, y, h.width, h.height);
4007
+ if (S) if (y) n.texStorage2D(e.TEXTURE_2D, T, g, t.width, t.height);
3990
4008
  else {
3991
- let t = h.width, r = h.height;
3992
- for (let i = 0; i < j; i++) n.texImage2D(e.TEXTURE_2D, i, y, t, r, 0, g, _, null), t >>= 1, r >>= 1;
4009
+ let i = t.width, a = t.height;
4010
+ for (let t = 0; t < T; t++) n.texImage2D(e.TEXTURE_2D, t, g, i, a, 0, r, h, null), i >>= 1, a >>= 1;
4011
+ }
4012
+ } else if (o.isHTMLTexture) {
4013
+ if ("texElementImage2D" in e) {
4014
+ let n = e.canvas;
4015
+ if (n.hasAttribute("layoutsubtree") || n.setAttribute("layoutsubtree", "true"), t.parentNode !== n) {
4016
+ n.appendChild(t), p.add(o), n.onpaint = (e) => {
4017
+ let t = e.changedElements;
4018
+ for (let e of p) t.includes(e.image) && (e.needsUpdate = !0);
4019
+ }, n.requestPaint();
4020
+ return;
4021
+ }
4022
+ let r = e.RGBA, i = e.RGBA, a = e.UNSIGNED_BYTE;
4023
+ e.texElementImage2D(e.TEXTURE_2D, 0, r, i, a, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE);
3993
4024
  }
3994
- } else if (C.length > 0) {
3995
- if (w && k) {
3996
- let t = Oe(C[0]);
3997
- n.texStorage2D(e.TEXTURE_2D, j, y, t.width, t.height);
4025
+ } else if (v.length > 0) {
4026
+ if (y && S) {
4027
+ let t = Ne(v[0]);
4028
+ n.texStorage2D(e.TEXTURE_2D, T, g, t.width, t.height);
3998
4029
  }
3999
- for (let t = 0, r = C.length; t < r; t++) S = C[t], w ? A && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, g, _, S) : n.texImage2D(e.TEXTURE_2D, t, y, g, _, S);
4030
+ for (let t = 0, i = v.length; t < i; t++) _ = v[t], y ? C && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, r, h, _) : n.texImage2D(e.TEXTURE_2D, t, g, r, h, _);
4000
4031
  o.generateMipmaps = !1;
4001
- } else if (w) {
4002
- if (k) {
4003
- let t = Oe(h);
4004
- n.texStorage2D(e.TEXTURE_2D, j, y, t.width, t.height);
4032
+ } else if (y) {
4033
+ if (S) {
4034
+ let r = Ne(t);
4035
+ n.texStorage2D(e.TEXTURE_2D, T, g, r.width, r.height);
4005
4036
  }
4006
- A && n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, g, _, h);
4007
- } else n.texImage2D(e.TEXTURE_2D, 0, y, g, _, h);
4008
- b(o) && x(c), p.__version = d.version, o.onUpdate && o.onUpdate(o);
4037
+ C && n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r, h, t);
4038
+ } else n.texImage2D(e.TEXTURE_2D, 0, g, r, h, t);
4039
+ x(o) && w(c), m.__version = d.version, o.onUpdate && o.onUpdate(o);
4009
4040
  }
4010
4041
  t.__version = o.version;
4011
4042
  }
4012
- function pe(t, o, s) {
4043
+ function me(t, o, s) {
4013
4044
  if (o.image.length !== 6) return;
4014
- let c = le(t, o), l = o.source;
4045
+ let c = de(t, o), l = o.source;
4015
4046
  n.bindTexture(e.TEXTURE_CUBE_MAP, t.__webglTexture, e.TEXTURE0 + s);
4016
4047
  let u = r.get(l);
4017
4048
  if (l.version !== u.__version || c === !0) {
4018
4049
  n.activeTexture(e.TEXTURE0 + s);
4019
4050
  let t = O.getPrimaries(O.workingColorSpace), r = o.colorSpace === "" ? null : O.getPrimaries(o.colorSpace), d = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL;
4020
- e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), e.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, d);
4051
+ n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, d);
4021
4052
  let p = o.isCompressedTexture || o.image[0].isCompressedTexture, m = o.image[0] && o.image[0].isDataTexture, h = [];
4022
- for (let e = 0; e < 6; e++) !p && !m ? h[e] = v(o.image[e], !0, i.maxCubemapSize) : h[e] = m ? o.image[e].image : o.image[e], h[e] = Ee(o, h[e]);
4023
- let g = h[0], _ = a.convert(o.format, o.colorSpace), y = a.convert(o.type), S = T(o.internalFormat, _, y, o.colorSpace), C = o.isVideoTexture !== !0, w = u.__version === void 0 || c === !0, E = l.dataReady, k = D(o, g);
4024
- ce(e.TEXTURE_CUBE_MAP, o);
4025
- let A;
4053
+ for (let e = 0; e < 6; e++) !p && !m ? h[e] = b(o.image[e], !0, i.maxCubemapSize) : h[e] = m ? o.image[e].image : o.image[e], h[e] = je(o, h[e]);
4054
+ let g = h[0], _ = a.convert(o.format, o.colorSpace), v = a.convert(o.type), y = E(o.internalFormat, _, v, o.normalized, o.colorSpace), S = o.isVideoTexture !== !0, C = u.__version === void 0 || c === !0, T = l.dataReady, D = ee(o, g);
4055
+ H(e.TEXTURE_CUBE_MAP, o);
4056
+ let k;
4026
4057
  if (p) {
4027
- C && w && n.texStorage2D(e.TEXTURE_CUBE_MAP, k, S, g.width, g.height);
4058
+ S && C && n.texStorage2D(e.TEXTURE_CUBE_MAP, D, y, g.width, g.height);
4028
4059
  for (let t = 0; t < 6; t++) {
4029
- A = h[t].mipmaps;
4030
- for (let r = 0; r < A.length; r++) {
4031
- let i = A[r];
4032
- o.format === 1023 ? C ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, _, y, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, S, i.width, i.height, 0, _, y, i.data) : _ === null ? f("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : C ? E && n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, _, i.data) : n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, S, i.width, i.height, 0, i.data);
4060
+ k = h[t].mipmaps;
4061
+ for (let r = 0; r < k.length; r++) {
4062
+ let i = k[r];
4063
+ o.format === 1023 ? S ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, _, v, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, y, i.width, i.height, 0, _, v, i.data) : _ === null ? f("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : S ? T && n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, _, i.data) : n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, y, i.width, i.height, 0, i.data);
4033
4064
  }
4034
4065
  }
4035
4066
  } else {
4036
- if (A = o.mipmaps, C && w) {
4037
- A.length > 0 && k++;
4038
- let t = Oe(h[0]);
4039
- n.texStorage2D(e.TEXTURE_CUBE_MAP, k, S, t.width, t.height);
4067
+ if (k = o.mipmaps, S && C) {
4068
+ k.length > 0 && D++;
4069
+ let t = Ne(h[0]);
4070
+ n.texStorage2D(e.TEXTURE_CUBE_MAP, D, y, t.width, t.height);
4040
4071
  }
4041
4072
  for (let t = 0; t < 6; t++) if (m) {
4042
- C ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, h[t].width, h[t].height, _, y, h[t].data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, S, h[t].width, h[t].height, 0, _, y, h[t].data);
4043
- for (let r = 0; r < A.length; r++) {
4044
- let i = A[r].image[t].image;
4045
- C ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, i.width, i.height, _, y, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, S, i.width, i.height, 0, _, y, i.data);
4073
+ S ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, h[t].width, h[t].height, _, v, h[t].data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, y, h[t].width, h[t].height, 0, _, v, h[t].data);
4074
+ for (let r = 0; r < k.length; r++) {
4075
+ let i = k[r].image[t].image;
4076
+ S ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, i.width, i.height, _, v, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, y, i.width, i.height, 0, _, v, i.data);
4046
4077
  }
4047
4078
  } else {
4048
- C ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, _, y, h[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, S, _, y, h[t]);
4049
- for (let r = 0; r < A.length; r++) {
4050
- let i = A[r];
4051
- C ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, _, y, i.image[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, S, _, y, i.image[t]);
4079
+ S ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, _, v, h[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, y, _, v, h[t]);
4080
+ for (let r = 0; r < k.length; r++) {
4081
+ let i = k[r];
4082
+ S ? T && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, _, v, i.image[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, y, _, v, i.image[t]);
4052
4083
  }
4053
4084
  }
4054
4085
  }
4055
- b(o) && x(e.TEXTURE_CUBE_MAP), u.__version = l.version, o.onUpdate && o.onUpdate(o);
4086
+ x(o) && w(e.TEXTURE_CUBE_MAP), u.__version = l.version, o.onUpdate && o.onUpdate(o);
4056
4087
  }
4057
4088
  t.__version = o.version;
4058
4089
  }
4059
- function me(t, i, o, c, l, u) {
4060
- let d = a.convert(o.format, o.colorSpace), f = a.convert(o.type), p = T(o.internalFormat, d, f, o.colorSpace), m = r.get(i), h = r.get(o);
4090
+ function he(t, i, o, c, l, u) {
4091
+ let d = a.convert(o.format, o.colorSpace), f = a.convert(o.type), p = E(o.internalFormat, d, f, o.normalized, o.colorSpace), m = r.get(i), h = r.get(o);
4061
4092
  if (h.__renderTarget = i, !m.__hasExternalTextures) {
4062
4093
  let t = Math.max(1, i.width >> u), r = Math.max(1, i.height >> u);
4063
4094
  l === e.TEXTURE_3D || l === e.TEXTURE_2D_ARRAY ? n.texImage3D(l, u, p, t, r, i.depth, 0, d, f, null) : n.texImage2D(l, u, p, t, r, 0, d, f, null);
4064
4095
  }
4065
- n.bindFramebuffer(e.FRAMEBUFFER, t), we(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, c, l, h.__webglTexture, 0, Ce(i)) : (l === e.TEXTURE_2D || l >= e.TEXTURE_CUBE_MAP_POSITIVE_X && l <= e.TEXTURE_CUBE_MAP_NEGATIVE_Z) && e.framebufferTexture2D(e.FRAMEBUFFER, c, l, h.__webglTexture, u), n.bindFramebuffer(e.FRAMEBUFFER, null);
4096
+ n.bindFramebuffer(e.FRAMEBUFFER, t), Oe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, c, l, h.__webglTexture, 0, De(i)) : (l === e.TEXTURE_2D || l >= e.TEXTURE_CUBE_MAP_POSITIVE_X && l <= e.TEXTURE_CUBE_MAP_NEGATIVE_Z) && e.framebufferTexture2D(e.FRAMEBUFFER, c, l, h.__webglTexture, u), n.bindFramebuffer(e.FRAMEBUFFER, null);
4066
4097
  }
4067
- function he(t, n, r) {
4098
+ function ge(t, n, r) {
4068
4099
  if (e.bindRenderbuffer(e.RENDERBUFFER, t), n.depthBuffer) {
4069
- let i = n.depthTexture, a = i && i.isDepthTexture ? i.type : null, o = E(n.stencilBuffer, a), c = n.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
4070
- we(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, Ce(n), o, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, Ce(n), o, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, o, n.width, n.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, c, e.RENDERBUFFER, t);
4100
+ let i = n.depthTexture, a = i && i.isDepthTexture ? i.type : null, o = D(n.stencilBuffer, a), c = n.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
4101
+ Oe(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, De(n), o, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, De(n), o, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, o, n.width, n.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, c, e.RENDERBUFFER, t);
4071
4102
  } else {
4072
4103
  let t = n.textures;
4073
4104
  for (let i = 0; i < t.length; i++) {
4074
- let o = t[i], c = a.convert(o.format, o.colorSpace), l = a.convert(o.type), u = T(o.internalFormat, c, l, o.colorSpace);
4075
- we(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, Ce(n), u, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, Ce(n), u, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, u, n.width, n.height);
4105
+ let o = t[i], c = a.convert(o.format, o.colorSpace), l = a.convert(o.type), u = E(o.internalFormat, c, l, o.normalized, o.colorSpace);
4106
+ Oe(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, De(n), u, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, De(n), u, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, u, n.width, n.height);
4076
4107
  }
4077
4108
  }
4078
4109
  e.bindRenderbuffer(e.RENDERBUFFER, null);
4079
4110
  }
4080
- function H(t, i, o) {
4111
+ function _e(t, i, o) {
4081
4112
  let c = i.isWebGLCubeRenderTarget === !0;
4082
4113
  if (n.bindFramebuffer(e.FRAMEBUFFER, t), !(i.depthTexture && i.depthTexture.isDepthTexture)) throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
4083
4114
  let l = r.get(i.depthTexture);
4084
4115
  if (l.__renderTarget = i, (!l.__webglTexture || i.depthTexture.image.width !== i.width || i.depthTexture.image.height !== i.height) && (i.depthTexture.image.width = i.width, i.depthTexture.image.height = i.height, i.depthTexture.needsUpdate = !0), c) {
4085
4116
  if (l.__webglInit === void 0 && (l.__webglInit = !0, i.depthTexture.addEventListener("dispose", k)), l.__webglTexture === void 0) {
4086
- l.__webglTexture = e.createTexture(), n.bindTexture(e.TEXTURE_CUBE_MAP, l.__webglTexture), ce(e.TEXTURE_CUBE_MAP, i.depthTexture);
4117
+ l.__webglTexture = e.createTexture(), n.bindTexture(e.TEXTURE_CUBE_MAP, l.__webglTexture), H(e.TEXTURE_CUBE_MAP, i.depthTexture);
4087
4118
  let t = a.convert(i.depthTexture.format), r = a.convert(i.depthTexture.type), o;
4088
4119
  i.depthTexture.format === 1026 ? o = e.DEPTH_COMPONENT24 : i.depthTexture.format === 1027 && (o = e.DEPTH24_STENCIL8);
4089
4120
  for (let n = 0; n < 6; n++) e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0, o, i.width, i.height, 0, t, r, null);
4090
4121
  }
4091
- } else re(i.depthTexture, 0);
4092
- let u = l.__webglTexture, d = Ce(i), f = c ? e.TEXTURE_CUBE_MAP_POSITIVE_X + o : e.TEXTURE_2D, p = i.depthTexture.format === 1027 ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
4093
- if (i.depthTexture.format === 1026) we(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
4094
- else if (i.depthTexture.format === 1027) we(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
4122
+ } else ae(i.depthTexture, 0);
4123
+ let u = l.__webglTexture, d = De(i), f = c ? e.TEXTURE_CUBE_MAP_POSITIVE_X + o : e.TEXTURE_2D, p = i.depthTexture.format === 1027 ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT;
4124
+ if (i.depthTexture.format === 1026) Oe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
4125
+ else if (i.depthTexture.format === 1027) Oe(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0);
4095
4126
  else throw Error("Unknown depthTexture format");
4096
4127
  }
4097
- function ge(t) {
4128
+ function ye(t) {
4098
4129
  let i = r.get(t), a = t.isWebGLCubeRenderTarget === !0;
4099
4130
  if (i.__boundDepthTexture !== t.depthTexture) {
4100
4131
  let e = t.depthTexture;
@@ -4106,21 +4137,21 @@ function Mr(e, t, n, r, i, a, o) {
4106
4137
  }
4107
4138
  i.__boundDepthTexture = e;
4108
4139
  }
4109
- if (t.depthTexture && !i.__autoAllocateDepthBuffer) if (a) for (let e = 0; e < 6; e++) H(i.__webglFramebuffer[e], t, e);
4140
+ if (t.depthTexture && !i.__autoAllocateDepthBuffer) if (a) for (let e = 0; e < 6; e++) _e(i.__webglFramebuffer[e], t, e);
4110
4141
  else {
4111
4142
  let e = t.texture.mipmaps;
4112
- e && e.length > 0 ? H(i.__webglFramebuffer[0], t, 0) : H(i.__webglFramebuffer, t, 0);
4143
+ e && e.length > 0 ? _e(i.__webglFramebuffer[0], t, 0) : _e(i.__webglFramebuffer, t, 0);
4113
4144
  }
4114
4145
  else if (a) {
4115
4146
  i.__webglDepthbuffer = [];
4116
- for (let r = 0; r < 6; r++) if (n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[r]), i.__webglDepthbuffer[r] === void 0) i.__webglDepthbuffer[r] = e.createRenderbuffer(), he(i.__webglDepthbuffer[r], t, !1);
4147
+ for (let r = 0; r < 6; r++) if (n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[r]), i.__webglDepthbuffer[r] === void 0) i.__webglDepthbuffer[r] = e.createRenderbuffer(), ge(i.__webglDepthbuffer[r], t, !1);
4117
4148
  else {
4118
4149
  let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, a = i.__webglDepthbuffer[r];
4119
4150
  e.bindRenderbuffer(e.RENDERBUFFER, a), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, a);
4120
4151
  }
4121
4152
  } else {
4122
4153
  let r = t.texture.mipmaps;
4123
- if (r && r.length > 0 ? n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[0]) : n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer), i.__webglDepthbuffer === void 0) i.__webglDepthbuffer = e.createRenderbuffer(), he(i.__webglDepthbuffer, t, !1);
4154
+ if (r && r.length > 0 ? n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[0]) : n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer), i.__webglDepthbuffer === void 0) i.__webglDepthbuffer = e.createRenderbuffer(), ge(i.__webglDepthbuffer, t, !1);
4124
4155
  else {
4125
4156
  let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, r = i.__webglDepthbuffer;
4126
4157
  e.bindRenderbuffer(e.RENDERBUFFER, r), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, r);
@@ -4128,11 +4159,11 @@ function Mr(e, t, n, r, i, a, o) {
4128
4159
  }
4129
4160
  n.bindFramebuffer(e.FRAMEBUFFER, null);
4130
4161
  }
4131
- function _e(t, n, i) {
4162
+ function be(t, n, i) {
4132
4163
  let a = r.get(t);
4133
- n !== void 0 && me(a.__webglFramebuffer, t, t.texture, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, 0), i !== void 0 && ge(t);
4164
+ n !== void 0 && he(a.__webglFramebuffer, t, t.texture, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, 0), i !== void 0 && ye(t);
4134
4165
  }
4135
- function ve(t) {
4166
+ function xe(t) {
4136
4167
  let i = t.texture, s = r.get(t), c = r.get(i);
4137
4168
  t.addEventListener("dispose", A);
4138
4169
  let l = t.textures, u = t.isWebGLCubeRenderTarget === !0, d = l.length > 1;
@@ -4151,50 +4182,50 @@ function Mr(e, t, n, r, i, a, o) {
4151
4182
  let n = r.get(l[t]);
4152
4183
  n.__webglTexture === void 0 && (n.__webglTexture = e.createTexture(), o.memory.textures++);
4153
4184
  }
4154
- if (t.samples > 0 && we(t) === !1) {
4185
+ if (t.samples > 0 && Oe(t) === !1) {
4155
4186
  s.__webglMultisampledFramebuffer = e.createFramebuffer(), s.__webglColorRenderbuffer = [], n.bindFramebuffer(e.FRAMEBUFFER, s.__webglMultisampledFramebuffer);
4156
4187
  for (let n = 0; n < l.length; n++) {
4157
4188
  let r = l[n];
4158
4189
  s.__webglColorRenderbuffer[n] = e.createRenderbuffer(), e.bindRenderbuffer(e.RENDERBUFFER, s.__webglColorRenderbuffer[n]);
4159
- let i = a.convert(r.format, r.colorSpace), o = a.convert(r.type), c = T(r.internalFormat, i, o, r.colorSpace, t.isXRRenderTarget === !0), u = Ce(t);
4190
+ let i = a.convert(r.format, r.colorSpace), o = a.convert(r.type), c = E(r.internalFormat, i, o, r.normalized, r.colorSpace, t.isXRRenderTarget === !0), u = De(t);
4160
4191
  e.renderbufferStorageMultisample(e.RENDERBUFFER, u, c, t.width, t.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + n, e.RENDERBUFFER, s.__webglColorRenderbuffer[n]);
4161
4192
  }
4162
- e.bindRenderbuffer(e.RENDERBUFFER, null), t.depthBuffer && (s.__webglDepthRenderbuffer = e.createRenderbuffer(), he(s.__webglDepthRenderbuffer, t, !0)), n.bindFramebuffer(e.FRAMEBUFFER, null);
4193
+ e.bindRenderbuffer(e.RENDERBUFFER, null), t.depthBuffer && (s.__webglDepthRenderbuffer = e.createRenderbuffer(), ge(s.__webglDepthRenderbuffer, t, !0)), n.bindFramebuffer(e.FRAMEBUFFER, null);
4163
4194
  }
4164
4195
  }
4165
4196
  if (u) {
4166
- n.bindTexture(e.TEXTURE_CUBE_MAP, c.__webglTexture), ce(e.TEXTURE_CUBE_MAP, i);
4167
- for (let n = 0; n < 6; n++) if (i.mipmaps && i.mipmaps.length > 0) for (let r = 0; r < i.mipmaps.length; r++) me(s.__webglFramebuffer[n][r], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, r);
4168
- else me(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0);
4169
- b(i) && x(e.TEXTURE_CUBE_MAP), n.unbindTexture();
4197
+ n.bindTexture(e.TEXTURE_CUBE_MAP, c.__webglTexture), H(e.TEXTURE_CUBE_MAP, i);
4198
+ for (let n = 0; n < 6; n++) if (i.mipmaps && i.mipmaps.length > 0) for (let r = 0; r < i.mipmaps.length; r++) he(s.__webglFramebuffer[n][r], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, r);
4199
+ else he(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0);
4200
+ x(i) && w(e.TEXTURE_CUBE_MAP), n.unbindTexture();
4170
4201
  } else if (d) {
4171
4202
  for (let i = 0, a = l.length; i < a; i++) {
4172
4203
  let a = l[i], o = r.get(a), c = e.TEXTURE_2D;
4173
- (t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (c = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(c, o.__webglTexture), ce(c, a), me(s.__webglFramebuffer, t, a, e.COLOR_ATTACHMENT0 + i, c, 0), b(a) && x(c);
4204
+ (t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (c = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(c, o.__webglTexture), H(c, a), he(s.__webglFramebuffer, t, a, e.COLOR_ATTACHMENT0 + i, c, 0), x(a) && w(c);
4174
4205
  }
4175
4206
  n.unbindTexture();
4176
4207
  } else {
4177
4208
  let r = e.TEXTURE_2D;
4178
- if ((t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (r = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(r, c.__webglTexture), ce(r, i), i.mipmaps && i.mipmaps.length > 0) for (let n = 0; n < i.mipmaps.length; n++) me(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, r, n);
4179
- else me(s.__webglFramebuffer, t, i, e.COLOR_ATTACHMENT0, r, 0);
4180
- b(i) && x(r), n.unbindTexture();
4209
+ if ((t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (r = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(r, c.__webglTexture), H(r, i), i.mipmaps && i.mipmaps.length > 0) for (let n = 0; n < i.mipmaps.length; n++) he(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, r, n);
4210
+ else he(s.__webglFramebuffer, t, i, e.COLOR_ATTACHMENT0, r, 0);
4211
+ x(i) && w(r), n.unbindTexture();
4181
4212
  }
4182
- t.depthBuffer && ge(t);
4213
+ t.depthBuffer && ye(t);
4183
4214
  }
4184
- function be(e) {
4215
+ function Se(e) {
4185
4216
  let t = e.textures;
4186
4217
  for (let i = 0, a = t.length; i < a; i++) {
4187
4218
  let a = t[i];
4188
- if (b(a)) {
4189
- let t = w(e), i = r.get(a).__webglTexture;
4190
- n.bindTexture(t, i), x(t), n.unbindTexture();
4219
+ if (x(a)) {
4220
+ let t = T(e), i = r.get(a).__webglTexture;
4221
+ n.bindTexture(t, i), w(t), n.unbindTexture();
4191
4222
  }
4192
4223
  }
4193
4224
  }
4194
- let U = [], xe = [];
4195
- function Se(t) {
4225
+ let Ce = [], we = [];
4226
+ function Te(t) {
4196
4227
  if (t.samples > 0) {
4197
- if (we(t) === !1) {
4228
+ if (Oe(t) === !1) {
4198
4229
  let i = t.textures, a = t.width, o = t.height, s = e.COLOR_BUFFER_BIT, l = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, u = r.get(t), d = i.length > 1;
4199
4230
  if (d) for (let t = 0; t < i.length; t++) n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, null), n.bindFramebuffer(e.FRAMEBUFFER, u.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.TEXTURE_2D, null, 0);
4200
4231
  n.bindFramebuffer(e.READ_FRAMEBUFFER, u.__webglMultisampledFramebuffer);
@@ -4206,7 +4237,7 @@ function Mr(e, t, n, r, i, a, o) {
4206
4237
  let t = r.get(i[n]).__webglTexture;
4207
4238
  e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0);
4208
4239
  }
4209
- e.blitFramebuffer(0, 0, a, o, 0, 0, a, o, s, e.NEAREST), c === !0 && (U.length = 0, xe.length = 0, U.push(e.COLOR_ATTACHMENT0 + n), t.depthBuffer && t.resolveDepthBuffer === !1 && (U.push(l), xe.push(l), e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, xe)), e.invalidateFramebuffer(e.READ_FRAMEBUFFER, U));
4240
+ e.blitFramebuffer(0, 0, a, o, 0, 0, a, o, s, e.NEAREST), c === !0 && (Ce.length = 0, we.length = 0, Ce.push(e.COLOR_ATTACHMENT0 + n), t.depthBuffer && t.resolveDepthBuffer === !1 && (Ce.push(l), we.push(l), e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, we)), e.invalidateFramebuffer(e.READ_FRAMEBUFFER, Ce));
4210
4241
  }
4211
4242
  if (n.bindFramebuffer(e.READ_FRAMEBUFFER, null), n.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), d) for (let t = 0; t < i.length; t++) {
4212
4243
  n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, u.__webglColorRenderbuffer[t]);
@@ -4220,25 +4251,25 @@ function Mr(e, t, n, r, i, a, o) {
4220
4251
  }
4221
4252
  }
4222
4253
  }
4223
- function Ce(e) {
4254
+ function De(e) {
4224
4255
  return Math.min(i.maxSamples, e.samples);
4225
4256
  }
4226
- function we(e) {
4257
+ function Oe(e) {
4227
4258
  let n = r.get(e);
4228
4259
  return e.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && n.__useRenderToTexture !== !1;
4229
4260
  }
4230
- function Te(e) {
4261
+ function W(e) {
4231
4262
  let t = o.render.frame;
4232
4263
  d.get(e) !== t && (d.set(e, t), e.update());
4233
4264
  }
4234
- function Ee(e, t) {
4265
+ function je(e, t) {
4235
4266
  let n = e.colorSpace, r = e.format, i = e.type;
4236
4267
  return e.isCompressedTexture === !0 || e.isVideoTexture === !0 || n !== "srgb-linear" && n !== "" && (O.getTransfer(n) === "srgb" ? (r !== 1023 || i !== 1009) && f("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : S("WebGLTextures: Unsupported texture color space:", n)), t;
4237
4268
  }
4238
- function Oe(e) {
4269
+ function Ne(e) {
4239
4270
  return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement ? (u.width = e.naturalWidth || e.width, u.height = e.naturalHeight || e.height) : typeof VideoFrame < "u" && e instanceof VideoFrame ? (u.width = e.displayWidth, u.height = e.displayHeight) : (u.width = e.width, u.height = e.height), u;
4240
4271
  }
4241
- this.allocateTextureUnit = F, this.resetTextureUnits = P, this.setTexture2D = re, this.setTexture2DArray = z, this.setTexture3D = ie, this.setTextureCube = ae, this.rebindTextures = _e, this.setupRenderTarget = ve, this.updateRenderTargetMipmap = be, this.updateMultisampleRenderTarget = Se, this.setupDepthRenderbuffer = ge, this.setupFrameBufferTexture = me, this.useMultisampledRTT = we, this.isReversedDepthBuffer = function() {
4272
+ this.allocateTextureUnit = z, this.resetTextureUnits = F, this.getTextureUnits = I, this.setTextureUnits = re, this.setTexture2D = ae, this.setTexture2DArray = oe, this.setTexture3D = se, this.setTextureCube = B, this.rebindTextures = be, this.setupRenderTarget = xe, this.updateRenderTargetMipmap = Se, this.updateMultisampleRenderTarget = Te, this.setupDepthRenderbuffer = ye, this.setupFrameBufferTexture = he, this.useMultisampledRTT = Oe, this.isReversedDepthBuffer = function() {
4242
4273
  return n.buffers.depth.getReversed();
4243
4274
  };
4244
4275
  }
@@ -4330,7 +4361,7 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4330
4361
  }
4331
4362
  init(e, t) {
4332
4363
  if (this.texture === null) {
4333
- let n = new be(e.texture);
4364
+ let n = new ye(e.texture);
4334
4365
  (e.depthNear !== t.depthNear || e.depthFar !== t.depthFar) && (this.depthNear = e.depthNear, this.depthFar = e.depthFar), this.texture = n;
4335
4366
  }
4336
4367
  }
@@ -4345,7 +4376,7 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4345
4376
  depthHeight: { value: t.w }
4346
4377
  }
4347
4378
  });
4348
- this.mesh = new U(new le(20, 20), n);
4379
+ this.mesh = new be(new le(20, 20), n);
4349
4380
  }
4350
4381
  return this.mesh;
4351
4382
  }
@@ -4355,14 +4386,14 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4355
4386
  getDepthTexture() {
4356
4387
  return this.texture;
4357
4388
  }
4358
- }, Lr = class extends H {
4389
+ }, Lr = class extends me {
4359
4390
  constructor(e, t) {
4360
4391
  super();
4361
- let n = this, i = null, a = 1, o = null, l = "local-floor", u = 1, d = null, p = null, m = null, _ = null, v = null, y = null, b = typeof XRWebGLBinding < "u", x = new Ir(), S = {}, C = t.getContextAttributes(), w = null, T = null, D = [], O = [], A = new L(), j = null, ee = new c();
4362
- ee.viewport = new E();
4392
+ let n = this, i = null, a = 1, o = null, l = "local-floor", u = 1, d = null, p = null, m = null, _ = null, v = null, y = null, b = typeof XRWebGLBinding < "u", x = new Ir(), S = {}, C = t.getContextAttributes(), w = null, T = null, D = [], O = [], k = new L(), A = null, M = new c();
4393
+ M.viewport = new E();
4363
4394
  let te = new c();
4364
4395
  te.viewport = new E();
4365
- let ne = [ee, te], N = new P(), F = null, I = null;
4396
+ let ne = [M, te], N = new P(), F = null, I = null;
4366
4397
  this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(e) {
4367
4398
  let t = D[e];
4368
4399
  return t === void 0 && (t = new s(), D[e] = t), t.getTargetRaySpace();
@@ -4390,7 +4421,7 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4390
4421
  }
4391
4422
  F = null, I = null, x.reset();
4392
4423
  for (let e in S) delete S[e];
4393
- e.setRenderTarget(w), v = null, _ = null, m = null, i = null, T = null, de.stop(), n.isPresenting = !1, e.setPixelRatio(j), e.setSize(A.width, A.height, !1), n.dispatchEvent({ type: "sessionend" });
4424
+ e.setRenderTarget(w), v = null, _ = null, m = null, i = null, T = null, H.stop(), n.isPresenting = !1, e.setPixelRatio(A), e.setSize(k.width, k.height, !1), n.dispatchEvent({ type: "sessionend" });
4394
4425
  }
4395
4426
  this.setFramebufferScaleFactor = function(e) {
4396
4427
  a = e, n.isPresenting === !0 && f("WebXRManager: Cannot change framebuffer scale while presenting.");
@@ -4410,16 +4441,16 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4410
4441
  return i;
4411
4442
  }, this.setSession = async function(r) {
4412
4443
  if (i = r, i !== null) {
4413
- if (w = e.getRenderTarget(), i.addEventListener("select", R), i.addEventListener("selectstart", R), i.addEventListener("selectend", R), i.addEventListener("squeeze", R), i.addEventListener("squeezestart", R), i.addEventListener("squeezeend", R), i.addEventListener("end", re), i.addEventListener("inputsourceschange", z), C.xrCompatible !== !0 && await t.makeXRCompatible(), j = e.getPixelRatio(), e.getSize(A), b && "createProjectionLayer" in XRWebGLBinding.prototype) {
4444
+ if (w = e.getRenderTarget(), i.addEventListener("select", R), i.addEventListener("selectstart", R), i.addEventListener("selectend", R), i.addEventListener("squeeze", R), i.addEventListener("squeezestart", R), i.addEventListener("squeezeend", R), i.addEventListener("end", re), i.addEventListener("inputsourceschange", z), C.xrCompatible !== !0 && await t.makeXRCompatible(), A = e.getPixelRatio(), e.getSize(k), b && "createProjectionLayer" in XRWebGLBinding.prototype) {
4414
4445
  let n = null, r = null, o = null;
4415
- C.depth && (o = C.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, n = C.stencil ? ye : g, r = C.stencil ? me : oe);
4446
+ C.depth && (o = C.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, n = C.stencil ? ve : g, r = C.stencil ? fe : oe);
4416
4447
  let s = {
4417
4448
  colorFormat: t.RGBA8,
4418
4449
  depthFormat: o,
4419
4450
  scaleFactor: a
4420
4451
  };
4421
- m = this.getBinding(), _ = m.createProjectionLayer(s), i.updateRenderState({ layers: [_] }), e.setPixelRatio(1), e.setSize(_.textureWidth, _.textureHeight, !1), T = new k(_.textureWidth, _.textureHeight, {
4422
- format: M,
4452
+ m = this.getBinding(), _ = m.createProjectionLayer(s), i.updateRenderState({ layers: [_] }), e.setPixelRatio(1), e.setSize(_.textureWidth, _.textureHeight, !1), T = new ee(_.textureWidth, _.textureHeight, {
4453
+ format: j,
4423
4454
  type: ae,
4424
4455
  depthTexture: new h(_.textureWidth, _.textureHeight, r, void 0, void 0, void 0, void 0, void 0, void 0, n),
4425
4456
  stencilBuffer: C.stencil,
@@ -4436,8 +4467,8 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4436
4467
  stencil: C.stencil,
4437
4468
  framebufferScaleFactor: a
4438
4469
  };
4439
- v = new XRWebGLLayer(i, t, n), i.updateRenderState({ baseLayer: v }), e.setPixelRatio(1), e.setSize(v.framebufferWidth, v.framebufferHeight, !1), T = new k(v.framebufferWidth, v.framebufferHeight, {
4440
- format: M,
4470
+ v = new XRWebGLLayer(i, t, n), i.updateRenderState({ baseLayer: v }), e.setPixelRatio(1), e.setSize(v.framebufferWidth, v.framebufferHeight, !1), T = new ee(v.framebufferWidth, v.framebufferHeight, {
4471
+ format: j,
4441
4472
  type: ae,
4442
4473
  colorSpace: e.outputColorSpace,
4443
4474
  stencilBuffer: C.stencil,
@@ -4445,7 +4476,7 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4445
4476
  resolveStencilBuffer: v.ignoreDepthValues === !1
4446
4477
  });
4447
4478
  }
4448
- T.isXRRenderTarget = !0, this.setFoveation(u), d = null, o = await i.requestReferenceSpace(l), de.setContext(i), de.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });
4479
+ T.isXRRenderTarget = !0, this.setFoveation(u), d = null, o = await i.requestReferenceSpace(l), H.setContext(i), H.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });
4449
4480
  }
4450
4481
  }, this.getEnvironmentBlendMode = function() {
4451
4482
  if (i !== null) return i.environmentBlendMode;
@@ -4473,30 +4504,30 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4473
4504
  i && i.connect(n);
4474
4505
  }
4475
4506
  }
4476
- let ie = new W(), B = new W();
4477
- function V(e, t, n) {
4478
- ie.setFromMatrixPosition(t.matrixWorld), B.setFromMatrixPosition(n.matrixWorld);
4479
- let r = ie.distanceTo(B), i = t.projectionMatrix.elements, a = n.projectionMatrix.elements, o = i[14] / (i[10] - 1), s = i[14] / (i[10] + 1), c = (i[9] + 1) / i[5], l = (i[9] - 1) / i[5], u = (i[8] - 1) / i[0], d = (a[8] + 1) / a[0], f = o * u, p = o * d, m = r / (-u + d), h = m * -u;
4507
+ let ie = new W(), se = new W();
4508
+ function B(e, t, n) {
4509
+ ie.setFromMatrixPosition(t.matrixWorld), se.setFromMatrixPosition(n.matrixWorld);
4510
+ let r = ie.distanceTo(se), i = t.projectionMatrix.elements, a = n.projectionMatrix.elements, o = i[14] / (i[10] - 1), s = i[14] / (i[10] + 1), c = (i[9] + 1) / i[5], l = (i[9] - 1) / i[5], u = (i[8] - 1) / i[0], d = (a[8] + 1) / a[0], f = o * u, p = o * d, m = r / (-u + d), h = m * -u;
4480
4511
  if (t.matrixWorld.decompose(e.position, e.quaternion, e.scale), e.translateX(h), e.translateZ(m), e.matrixWorld.compose(e.position, e.quaternion, e.scale), e.matrixWorldInverse.copy(e.matrixWorld).invert(), i[10] === -1) e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse);
4481
4512
  else {
4482
4513
  let t = o + m, n = s + m, i = f - h, a = p + (r - h), u = c * s / n * t, d = l * s / n * t;
4483
4514
  e.projectionMatrix.makePerspective(i, a, u, d, t, n), e.projectionMatrixInverse.copy(e.projectionMatrix).invert();
4484
4515
  }
4485
4516
  }
4486
- function se(e, t) {
4517
+ function V(e, t) {
4487
4518
  t === null ? e.matrixWorld.copy(e.matrix) : e.matrixWorld.multiplyMatrices(t.matrixWorld, e.matrix), e.matrixWorldInverse.copy(e.matrixWorld).invert();
4488
4519
  }
4489
4520
  this.updateCamera = function(e) {
4490
4521
  if (i === null) return;
4491
4522
  let t = e.near, n = e.far;
4492
- x.texture !== null && (x.depthNear > 0 && (t = x.depthNear), x.depthFar > 0 && (n = x.depthFar)), N.near = te.near = ee.near = t, N.far = te.far = ee.far = n, (F !== N.near || I !== N.far) && (i.updateRenderState({
4523
+ x.texture !== null && (x.depthNear > 0 && (t = x.depthNear), x.depthFar > 0 && (n = x.depthFar)), N.near = te.near = M.near = t, N.far = te.far = M.far = n, (F !== N.near || I !== N.far) && (i.updateRenderState({
4493
4524
  depthNear: N.near,
4494
4525
  depthFar: N.far
4495
- }), F = N.near, I = N.far), N.layers.mask = e.layers.mask | 6, ee.layers.mask = N.layers.mask & -5, te.layers.mask = N.layers.mask & -3;
4526
+ }), F = N.near, I = N.far), N.layers.mask = e.layers.mask | 6, M.layers.mask = N.layers.mask & -5, te.layers.mask = N.layers.mask & -3;
4496
4527
  let r = e.parent, a = N.cameras;
4497
- se(N, r);
4498
- for (let e = 0; e < a.length; e++) se(a[e], r);
4499
- a.length === 2 ? V(N, ee, te) : N.projectionMatrix.copy(ee.projectionMatrix), ce(e, N, r);
4528
+ V(N, r);
4529
+ for (let e = 0; e < a.length; e++) V(a[e], r);
4530
+ a.length === 2 ? B(N, M, te) : N.projectionMatrix.copy(M.projectionMatrix), ce(e, N, r);
4500
4531
  };
4501
4532
  function ce(e, t, n) {
4502
4533
  n === null ? e.matrix.copy(t.matrixWorld) : (e.matrix.copy(n.matrixWorld), e.matrix.invert(), e.matrix.multiply(t.matrixWorld)), e.matrix.decompose(e.position, e.quaternion, e.scale), e.updateMatrixWorld(!0), e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse), e.isPerspectiveCamera && (e.fov = r * 2 * Math.atan(1 / e.projectionMatrix.elements[5]), e.zoom = 1);
@@ -4543,7 +4574,7 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4543
4574
  let n = t[e].camera;
4544
4575
  if (n) {
4545
4576
  let e = S[n];
4546
- e || (e = new be(), S[n] = e);
4577
+ e || (e = new ye(), S[n] = e);
4547
4578
  let t = m.getCameraImage(n);
4548
4579
  e.sourceTexture = t;
4549
4580
  }
@@ -4559,12 +4590,13 @@ var Pr = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Fr = "
4559
4590
  data: r
4560
4591
  }), y = null;
4561
4592
  }
4562
- let de = new Ie();
4563
- de.setAnimationLoop(ue), this.setAnimationLoop = function(e) {
4593
+ let H = new Fe();
4594
+ H.setAnimationLoop(ue), this.setAnimationLoop = function(e) {
4564
4595
  le = e;
4565
4596
  }, this.dispose = function() {};
4566
4597
  }
4567
- }, Rr = /* @__PURE__ */ new Se(), zr = /* @__PURE__ */ new ge();
4598
+ }, Rr = /* @__PURE__ */ new he(), zr = /* @__PURE__ */ new I();
4599
+ zr.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
4568
4600
  function Br(e, t) {
4569
4601
  function n(e, t) {
4570
4602
  e.matrixAutoUpdate === !0 && e.updateMatrix(), t.value.copy(e.matrix);
@@ -4573,12 +4605,12 @@ function Br(e, t) {
4573
4605
  n.color.getRGB(t.fogColor.value, m(e)), n.isFog ? (t.fogNear.value = n.near, t.fogFar.value = n.far) : n.isFogExp2 && (t.fogDensity.value = n.density);
4574
4606
  }
4575
4607
  function i(e, t, n, r, i) {
4576
- t.isMeshBasicMaterial ? a(e, t) : t.isMeshLambertMaterial ? (a(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshToonMaterial ? (a(e, t), d(e, t)) : t.isMeshPhongMaterial ? (a(e, t), u(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshStandardMaterial ? (a(e, t), f(e, t), t.isMeshPhysicalMaterial && p(e, t, i)) : t.isMeshMatcapMaterial ? (a(e, t), h(e, t)) : t.isMeshDepthMaterial ? a(e, t) : t.isMeshDistanceMaterial ? (a(e, t), g(e, t)) : t.isMeshNormalMaterial ? a(e, t) : t.isLineBasicMaterial ? (o(e, t), t.isLineDashedMaterial && s(e, t)) : t.isPointsMaterial ? c(e, t, n, r) : t.isSpriteMaterial ? l(e, t) : t.isShadowMaterial ? (e.color.value.copy(t.color), e.opacity.value = t.opacity) : t.isShaderMaterial && (t.uniformsNeedUpdate = !1);
4608
+ t.isNodeMaterial ? t.uniformsNeedUpdate = !1 : t.isMeshBasicMaterial ? a(e, t) : t.isMeshLambertMaterial ? (a(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshToonMaterial ? (a(e, t), d(e, t)) : t.isMeshPhongMaterial ? (a(e, t), u(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshStandardMaterial ? (a(e, t), f(e, t), t.isMeshPhysicalMaterial && p(e, t, i)) : t.isMeshMatcapMaterial ? (a(e, t), h(e, t)) : t.isMeshDepthMaterial ? a(e, t) : t.isMeshDistanceMaterial ? (a(e, t), g(e, t)) : t.isMeshNormalMaterial ? a(e, t) : t.isLineBasicMaterial ? (o(e, t), t.isLineDashedMaterial && s(e, t)) : t.isPointsMaterial ? c(e, t, n, r) : t.isSpriteMaterial ? l(e, t) : t.isShadowMaterial ? (e.color.value.copy(t.color), e.opacity.value = t.opacity) : t.isShaderMaterial && (t.uniformsNeedUpdate = !1);
4577
4609
  }
4578
4610
  function a(e, r) {
4579
4611
  e.opacity.value = r.opacity, r.color && e.diffuse.value.copy(r.color), r.emissive && e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity), r.map && (e.map.value = r.map, n(r.map, e.mapTransform)), r.alphaMap && (e.alphaMap.value = r.alphaMap, n(r.alphaMap, e.alphaMapTransform)), r.bumpMap && (e.bumpMap.value = r.bumpMap, n(r.bumpMap, e.bumpMapTransform), e.bumpScale.value = r.bumpScale, r.side === 1 && (e.bumpScale.value *= -1)), r.normalMap && (e.normalMap.value = r.normalMap, n(r.normalMap, e.normalMapTransform), e.normalScale.value.copy(r.normalScale), r.side === 1 && e.normalScale.value.negate()), r.displacementMap && (e.displacementMap.value = r.displacementMap, n(r.displacementMap, e.displacementMapTransform), e.displacementScale.value = r.displacementScale, e.displacementBias.value = r.displacementBias), r.emissiveMap && (e.emissiveMap.value = r.emissiveMap, n(r.emissiveMap, e.emissiveMapTransform)), r.specularMap && (e.specularMap.value = r.specularMap, n(r.specularMap, e.specularMapTransform)), r.alphaTest > 0 && (e.alphaTest.value = r.alphaTest);
4580
4612
  let i = t.get(r), a = i.envMap, o = i.envMapRotation;
4581
- a && (e.envMap.value = a, Rr.copy(o), Rr.x *= -1, Rr.y *= -1, Rr.z *= -1, a.isCubeTexture && a.isRenderTargetTexture === !1 && (Rr.y *= -1, Rr.z *= -1), e.envMapRotation.value.setFromMatrix4(zr.makeRotationFromEuler(Rr)), e.flipEnvMap.value = a.isCubeTexture && a.isRenderTargetTexture === !1 ? -1 : 1, e.reflectivity.value = r.reflectivity, e.ior.value = r.ior, e.refractionRatio.value = r.refractionRatio), r.lightMap && (e.lightMap.value = r.lightMap, e.lightMapIntensity.value = r.lightMapIntensity, n(r.lightMap, e.lightMapTransform)), r.aoMap && (e.aoMap.value = r.aoMap, e.aoMapIntensity.value = r.aoMapIntensity, n(r.aoMap, e.aoMapTransform));
4613
+ a && (e.envMap.value = a, e.envMapRotation.value.setFromMatrix4(Rr.makeRotationFromEuler(o)).transpose(), a.isCubeTexture && a.isRenderTargetTexture === !1 && e.envMapRotation.value.premultiply(zr), e.reflectivity.value = r.reflectivity, e.ior.value = r.ior, e.refractionRatio.value = r.refractionRatio), r.lightMap && (e.lightMap.value = r.lightMap, e.lightMapIntensity.value = r.lightMapIntensity, n(r.lightMap, e.lightMapTransform)), r.aoMap && (e.aoMap.value = r.aoMap, e.aoMapIntensity.value = r.aoMapIntensity, n(r.aoMap, e.aoMapTransform));
4582
4614
  }
4583
4615
  function o(e, t) {
4584
4616
  e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, t.map && (e.map.value = t.map, n(t.map, e.mapTransform));
@@ -4651,7 +4683,7 @@ function Vr(e, t, n, r) {
4651
4683
  let t = i.__offset, n = Array.isArray(i.value) ? i.value : [i.value], r = 0;
4652
4684
  for (let a = 0; a < n.length; a++) {
4653
4685
  let o = n[a], s = g(o);
4654
- typeof o == "number" || typeof o == "boolean" ? (i.__data[0] = o, e.bufferSubData(e.UNIFORM_BUFFER, t + r, i.__data)) : o.isMatrix3 ? (i.__data[0] = o.elements[0], i.__data[1] = o.elements[1], i.__data[2] = o.elements[2], i.__data[3] = 0, i.__data[4] = o.elements[3], i.__data[5] = o.elements[4], i.__data[6] = o.elements[5], i.__data[7] = 0, i.__data[8] = o.elements[6], i.__data[9] = o.elements[7], i.__data[10] = o.elements[8], i.__data[11] = 0) : (o.toArray(i.__data, r), r += s.storage / Float32Array.BYTES_PER_ELEMENT);
4686
+ typeof o == "number" || typeof o == "boolean" ? (i.__data[0] = o, e.bufferSubData(e.UNIFORM_BUFFER, t + r, i.__data)) : o.isMatrix3 ? (i.__data[0] = o.elements[0], i.__data[1] = o.elements[1], i.__data[2] = o.elements[2], i.__data[3] = 0, i.__data[4] = o.elements[3], i.__data[5] = o.elements[4], i.__data[6] = o.elements[5], i.__data[7] = 0, i.__data[8] = o.elements[6], i.__data[9] = o.elements[7], i.__data[10] = o.elements[8], i.__data[11] = 0) : ArrayBuffer.isView(o) ? i.__data.set(new o.constructor(o.buffer, o.byteOffset, i.__data.length)) : (o.toArray(i.__data, r), r += s.storage / Float32Array.BYTES_PER_ELEMENT);
4655
4687
  }
4656
4688
  e.bufferSubData(e.UNIFORM_BUFFER, t, i.__data);
4657
4689
  }
@@ -4661,12 +4693,13 @@ function Vr(e, t, n, r) {
4661
4693
  }
4662
4694
  function m(e, t, n, r) {
4663
4695
  let i = e.value, a = t + "_" + n;
4664
- if (r[a] === void 0) return typeof i == "number" || typeof i == "boolean" ? r[a] = i : r[a] = i.clone(), !0;
4696
+ if (r[a] === void 0) return typeof i == "number" || typeof i == "boolean" ? r[a] = i : ArrayBuffer.isView(i) ? r[a] = i.slice() : r[a] = i.clone(), !0;
4665
4697
  {
4666
4698
  let e = r[a];
4667
4699
  if (typeof i == "number" || typeof i == "boolean") {
4668
4700
  if (e !== i) return r[a] = i, !0;
4669
- } else if (e.equals(i) === !1) return e.copy(i), !0;
4701
+ } else if (ArrayBuffer.isView(i)) return !0;
4702
+ else if (e.equals(i) === !1) return e.copy(i), !0;
4670
4703
  }
4671
4704
  return !1;
4672
4705
  }
@@ -4690,7 +4723,7 @@ function Vr(e, t, n, r) {
4690
4723
  boundary: 0,
4691
4724
  storage: 0
4692
4725
  };
4693
- return typeof e == "number" || typeof e == "boolean" ? (t.boundary = 4, t.storage = 4) : e.isVector2 ? (t.boundary = 8, t.storage = 8) : e.isVector3 || e.isColor ? (t.boundary = 16, t.storage = 12) : e.isVector4 ? (t.boundary = 16, t.storage = 16) : e.isMatrix3 ? (t.boundary = 48, t.storage = 48) : e.isMatrix4 ? (t.boundary = 64, t.storage = 64) : e.isTexture ? f("WebGLRenderer: Texture samplers can not be part of an uniforms group.") : f("WebGLRenderer: Unsupported uniform value type.", e), t;
4726
+ return typeof e == "number" || typeof e == "boolean" ? (t.boundary = 4, t.storage = 4) : e.isVector2 ? (t.boundary = 8, t.storage = 8) : e.isVector3 || e.isColor ? (t.boundary = 16, t.storage = 12) : e.isVector4 ? (t.boundary = 16, t.storage = 16) : e.isMatrix3 ? (t.boundary = 48, t.storage = 48) : e.isMatrix4 ? (t.boundary = 64, t.storage = 64) : e.isTexture ? f("WebGLRenderer: Texture samplers can not be part of an uniforms group.") : ArrayBuffer.isView(e) ? (t.boundary = 16, t.storage = e.byteLength) : f("WebGLRenderer: Unsupported uniform value type.", e), t;
4694
4727
  }
4695
4728
  function _(t) {
4696
4729
  let n = t.target;
@@ -5223,7 +5256,7 @@ var Hr = new Uint16Array([
5223
5256
  1183
5224
5257
  ]), Ur = null;
5225
5258
  function Wr() {
5226
- return Ur === null && (Ur = new t(Hr, 16, 16, D, he), Ur.name = "DFG_LUT", Ur.minFilter = _, Ur.magFilter = _, Ur.wrapS = Ae, Ur.wrapT = Ae, Ur.generateMipmaps = !1, Ur.needsUpdate = !0), Ur;
5259
+ return Ur === null && (Ur = new t(Hr, 16, 16, D, pe), Ur.name = "DFG_LUT", Ur.minFilter = _, Ur.magFilter = _, Ur.wrapS = ke, Ur.wrapT = ke, Ur.generateMipmaps = !1, Ur.needsUpdate = !0), Ur;
5227
5260
  }
5228
5261
  var Gr = class {
5229
5262
  constructor(e = {}) {
@@ -5241,29 +5274,29 @@ var Gr = class {
5241
5274
  ]), C = new Set([
5242
5275
  ae,
5243
5276
  oe,
5244
- Me,
5245
- me,
5277
+ je,
5278
+ fe,
5246
5279
  N,
5247
- Ee
5248
- ]), w = new Uint32Array(4), D = new Int32Array(4), A = null, M = null, ee = [], P = [], F = null;
5280
+ Te
5281
+ ]), w = new Uint32Array(4), D = new Int32Array(4), k = new W(), A = null, j = null, M = [], ne = [], P = null;
5249
5282
  this.domElement = t, this.debug = {
5250
5283
  checkShaderErrors: !0,
5251
5284
  onShaderError: null
5252
5285
  }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.toneMapping = 0, this.toneMappingExposure = 1, this.transmissionResolutionScale = 1;
5253
- let I = this, L = !1;
5254
- this._outputColorSpace = Fe;
5255
- let R = 0, re = 0, z = null, ie = -1, B = null, V = new E(), se = new E(), ce = null, le = new a(0), de = 0, fe = t.width, pe = t.height, H = 1, _e = null, ve = null, ye = new E(0, 0, fe, pe), be = new E(0, 0, fe, pe), U = !1, xe = new Te(), Se = !1, Ce = !1, we = new ge(), De = new W(), ke = new E(), Ae = {
5286
+ let F = this, I = !1, L = null;
5287
+ this._outputColorSpace = Pe;
5288
+ let R = 0, re = 0, z = null, ie = -1, se = null, B = new E(), V = new E(), ce = null, le = new a(0), H = 0, de = t.width, U = t.height, me = 1, ge = null, _e = null, ve = new E(0, 0, de, U), ye = new E(0, 0, de, U), be = !1, xe = new we(), Se = !1, Ce = !1, Ee = new he(), Oe = new W(), ke = new E(), Ae = {
5256
5289
  background: null,
5257
5290
  fog: null,
5258
5291
  environment: null,
5259
5292
  overrideMaterial: null,
5260
5293
  isScene: !0
5261
- }, je = !1;
5294
+ }, Me = !1;
5262
5295
  function Ne() {
5263
- return z === null ? H : 1;
5296
+ return z === null ? me : 1;
5264
5297
  }
5265
5298
  let G = r;
5266
- function Pe(e, n) {
5299
+ function K(e, n) {
5267
5300
  return t.getContext(e, n);
5268
5301
  }
5269
5302
  try {
@@ -5277,83 +5310,83 @@ var Gr = class {
5277
5310
  powerPreference: m,
5278
5311
  failIfMajorPerformanceCaveat: h
5279
5312
  };
5280
- if ("setAttribute" in t && t.setAttribute("data-engine", "three.js r183"), t.addEventListener("webglcontextlost", ct, !1), t.addEventListener("webglcontextrestored", lt, !1), t.addEventListener("webglcontextcreationerror", _t, !1), G === null) {
5313
+ if ("setAttribute" in t && t.setAttribute("data-engine", "three.js r184"), t.addEventListener("webglcontextlost", st, !1), t.addEventListener("webglcontextrestored", ht, !1), t.addEventListener("webglcontextcreationerror", _t, !1), G === null) {
5281
5314
  let t = "webgl2";
5282
- if (G = Pe(t, e), G === null) throw Pe(t) ? Error("Error creating WebGL context with your selected attributes.") : Error("Error creating WebGL context.");
5315
+ if (G = K(t, e), G === null) throw K(t) ? Error("Error creating WebGL context with your selected attributes.") : Error("Error creating WebGL context.");
5283
5316
  }
5284
5317
  } catch (e) {
5285
5318
  throw S("WebGLRenderer: " + e.message), e;
5286
5319
  }
5287
- let K, q, J, Re, Y, X, We, Ge, Ke, qe, Je, Ye, Xe, Ze, Qe, $e, et, tt, nt, rt, it, at, ot;
5288
- function st() {
5289
- K = new dt(G), K.init(), it = new Nr(G, K), q = new He(G, K, e, it), J = new jr(G, K), q.reversedDepthBuffer && g && J.buffers.depth.setReversed(!0), Re = new mt(G), Y = new dr(), X = new Mr(G, K, J, Y, q, it, Re), We = new ut(I), Ge = new Le(G), at = new Be(G, Ge), Ke = new ft(G, Ge, Re, at), qe = new gt(G, Ke, Ge, at, Re), tt = new ht(G, q, X), Qe = new Ue(Y), Je = new ur(I, We, K, q, at, Qe), Ye = new Br(I, Y), Xe = new hr(), Ze = new Sr(K), et = new ze(I, We, J, qe, y, u), $e = new Ar(I, qe, q), ot = new Vr(G, Re, q, J), nt = new Ve(G, K, Re), rt = new pt(G, K, Re), Re.programs = Je.programs, I.capabilities = q, I.extensions = K, I.properties = Y, I.renderLists = Xe, I.shadowMap = $e, I.state = J, I.info = Re;
5320
+ let q, J, Y, Le, X, Z, Ue, We, Ge, Ke, qe, Je, Ye, Xe, Ze, Qe, $e, et, tt, nt, rt, it, at;
5321
+ function ot() {
5322
+ q = new lt(G), q.init(), rt = new Nr(G, q), J = new Ve(G, q, e, rt), Y = new jr(G, q), J.reversedDepthBuffer && g && Y.buffers.depth.setReversed(!0), Le = new ft(G), X = new dr(), Z = new Mr(G, q, Y, X, J, rt, Le), Ue = new ct(F), We = new Ie(G), it = new ze(G, We), Ge = new ut(G, We, Le, it), Ke = new mt(G, Ge, We, it, Le), et = new pt(G, J, Z), Ze = new He(X), qe = new ur(F, Ue, q, J, it, Ze), Je = new Br(F, X), Ye = new hr(), Xe = new Sr(q), $e = new Re(F, Ue, Y, Ke, y, u), Qe = new Ar(F, Ke, J), at = new Vr(G, Le, J, Y), tt = new Be(G, q, Le), nt = new dt(G, q, Le), Le.programs = qe.programs, F.capabilities = J, F.extensions = q, F.properties = X, F.renderLists = Ye, F.shadowMap = Qe, F.state = Y, F.info = Le;
5290
5323
  }
5291
- st(), b !== 1009 && (F = new vt(b, t.width, t.height, i, s));
5292
- let Z = new Lr(I, G);
5293
- this.xr = Z, this.getContext = function() {
5324
+ ot(), b !== 1009 && (P = new gt(b, t.width, t.height, i, s));
5325
+ let Q = new Lr(F, G);
5326
+ this.xr = Q, this.getContext = function() {
5294
5327
  return G;
5295
5328
  }, this.getContextAttributes = function() {
5296
5329
  return G.getContextAttributes();
5297
5330
  }, this.forceContextLoss = function() {
5298
- let e = K.get("WEBGL_lose_context");
5331
+ let e = q.get("WEBGL_lose_context");
5299
5332
  e && e.loseContext();
5300
5333
  }, this.forceContextRestore = function() {
5301
- let e = K.get("WEBGL_lose_context");
5334
+ let e = q.get("WEBGL_lose_context");
5302
5335
  e && e.restoreContext();
5303
5336
  }, this.getPixelRatio = function() {
5304
- return H;
5337
+ return me;
5305
5338
  }, this.setPixelRatio = function(e) {
5306
- e !== void 0 && (H = e, this.setSize(fe, pe, !1));
5339
+ e !== void 0 && (me = e, this.setSize(de, U, !1));
5307
5340
  }, this.getSize = function(e) {
5308
- return e.set(fe, pe);
5341
+ return e.set(de, U);
5309
5342
  }, this.setSize = function(e, n, r = !0) {
5310
- if (Z.isPresenting) {
5343
+ if (Q.isPresenting) {
5311
5344
  f("WebGLRenderer: Can't change size while VR device is presenting.");
5312
5345
  return;
5313
5346
  }
5314
- fe = e, pe = n, t.width = Math.floor(e * H), t.height = Math.floor(n * H), r === !0 && (t.style.width = e + "px", t.style.height = n + "px"), F !== null && F.setSize(t.width, t.height), this.setViewport(0, 0, e, n);
5347
+ de = e, U = n, t.width = Math.floor(e * me), t.height = Math.floor(n * me), r === !0 && (t.style.width = e + "px", t.style.height = n + "px"), P !== null && P.setSize(t.width, t.height), this.setViewport(0, 0, e, n);
5315
5348
  }, this.getDrawingBufferSize = function(e) {
5316
- return e.set(fe * H, pe * H).floor();
5349
+ return e.set(de * me, U * me).floor();
5317
5350
  }, this.setDrawingBufferSize = function(e, n, r) {
5318
- fe = e, pe = n, H = r, t.width = Math.floor(e * r), t.height = Math.floor(n * r), this.setViewport(0, 0, e, n);
5351
+ de = e, U = n, me = r, t.width = Math.floor(e * r), t.height = Math.floor(n * r), this.setViewport(0, 0, e, n);
5319
5352
  }, this.setEffects = function(e) {
5320
5353
  if (b === 1009) {
5321
- console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
5354
+ S("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
5322
5355
  return;
5323
5356
  }
5324
5357
  if (e) {
5325
5358
  for (let t = 0; t < e.length; t++) if (e[t].isOutputPass === !0) {
5326
- console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
5359
+ f("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
5327
5360
  break;
5328
5361
  }
5329
5362
  }
5330
- F.setEffects(e || []);
5363
+ P.setEffects(e || []);
5331
5364
  }, this.getCurrentViewport = function(e) {
5332
- return e.copy(V);
5365
+ return e.copy(B);
5333
5366
  }, this.getViewport = function(e) {
5334
- return e.copy(ye);
5367
+ return e.copy(ve);
5335
5368
  }, this.setViewport = function(e, t, n, r) {
5336
- e.isVector4 ? ye.set(e.x, e.y, e.z, e.w) : ye.set(e, t, n, r), J.viewport(V.copy(ye).multiplyScalar(H).round());
5369
+ e.isVector4 ? ve.set(e.x, e.y, e.z, e.w) : ve.set(e, t, n, r), Y.viewport(B.copy(ve).multiplyScalar(me).round());
5337
5370
  }, this.getScissor = function(e) {
5338
- return e.copy(be);
5371
+ return e.copy(ye);
5339
5372
  }, this.setScissor = function(e, t, n, r) {
5340
- e.isVector4 ? be.set(e.x, e.y, e.z, e.w) : be.set(e, t, n, r), J.scissor(se.copy(be).multiplyScalar(H).round());
5373
+ e.isVector4 ? ye.set(e.x, e.y, e.z, e.w) : ye.set(e, t, n, r), Y.scissor(V.copy(ye).multiplyScalar(me).round());
5341
5374
  }, this.getScissorTest = function() {
5342
- return U;
5375
+ return be;
5343
5376
  }, this.setScissorTest = function(e) {
5344
- J.setScissorTest(U = e);
5377
+ Y.setScissorTest(be = e);
5345
5378
  }, this.setOpaqueSort = function(e) {
5346
- _e = e;
5379
+ ge = e;
5347
5380
  }, this.setTransparentSort = function(e) {
5348
- ve = e;
5381
+ _e = e;
5349
5382
  }, this.getClearColor = function(e) {
5350
- return e.copy(et.getClearColor());
5383
+ return e.copy($e.getClearColor());
5351
5384
  }, this.setClearColor = function() {
5352
- et.setClearColor(...arguments);
5385
+ $e.setClearColor(...arguments);
5353
5386
  }, this.getClearAlpha = function() {
5354
- return et.getClearAlpha();
5387
+ return $e.getClearAlpha();
5355
5388
  }, this.setClearAlpha = function() {
5356
- et.setClearAlpha(...arguments);
5389
+ $e.setClearAlpha(...arguments);
5357
5390
  }, this.clear = function(e = !0, t = !0, n = !0) {
5358
5391
  let r = 0;
5359
5392
  if (e) {
@@ -5363,68 +5396,69 @@ var Gr = class {
5363
5396
  e = x.has(t);
5364
5397
  }
5365
5398
  if (e) {
5366
- let e = z.texture.type, t = C.has(e), n = et.getClearColor(), r = et.getClearAlpha(), i = n.r, a = n.g, o = n.b;
5399
+ let e = z.texture.type, t = C.has(e), n = $e.getClearColor(), r = $e.getClearAlpha(), i = n.r, a = n.g, o = n.b;
5367
5400
  t ? (w[0] = i, w[1] = a, w[2] = o, w[3] = r, G.clearBufferuiv(G.COLOR, 0, w)) : (D[0] = i, D[1] = a, D[2] = o, D[3] = r, G.clearBufferiv(G.COLOR, 0, D));
5368
5401
  } else r |= G.COLOR_BUFFER_BIT;
5369
5402
  }
5370
- t && (r |= G.DEPTH_BUFFER_BIT), n && (r |= G.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), r !== 0 && G.clear(r);
5403
+ t && (r |= G.DEPTH_BUFFER_BIT, this.state.buffers.depth.setMask(!0)), n && (r |= G.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), r !== 0 && G.clear(r);
5371
5404
  }, this.clearColor = function() {
5372
5405
  this.clear(!0, !1, !1);
5373
5406
  }, this.clearDepth = function() {
5374
5407
  this.clear(!1, !0, !1);
5375
5408
  }, this.clearStencil = function() {
5376
5409
  this.clear(!1, !1, !0);
5410
+ }, this.setNodesHandler = function(e) {
5411
+ e.setRenderer(this), L = e;
5377
5412
  }, this.dispose = function() {
5378
- t.removeEventListener("webglcontextlost", ct, !1), t.removeEventListener("webglcontextrestored", lt, !1), t.removeEventListener("webglcontextcreationerror", _t, !1), et.dispose(), Xe.dispose(), Ze.dispose(), Y.dispose(), We.dispose(), qe.dispose(), at.dispose(), ot.dispose(), Je.dispose(), Z.dispose(), Z.removeEventListener("sessionstart", Tt), Z.removeEventListener("sessionend", Et), Dt.stop();
5413
+ t.removeEventListener("webglcontextlost", st, !1), t.removeEventListener("webglcontextrestored", ht, !1), t.removeEventListener("webglcontextcreationerror", _t, !1), $e.dispose(), Ye.dispose(), Xe.dispose(), X.dispose(), Ue.dispose(), Ke.dispose(), it.dispose(), at.dispose(), qe.dispose(), Q.dispose(), Q.removeEventListener("sessionstart", wt), Q.removeEventListener("sessionend", Tt), Et.stop();
5379
5414
  };
5380
- function ct(e) {
5381
- e.preventDefault(), T("WebGLRenderer: Context Lost."), L = !0;
5415
+ function st(e) {
5416
+ e.preventDefault(), T("WebGLRenderer: Context Lost."), I = !0;
5382
5417
  }
5383
- function lt() {
5384
- T("WebGLRenderer: Context Restored."), L = !1;
5385
- let e = Re.autoReset, t = $e.enabled, n = $e.autoUpdate, r = $e.needsUpdate, i = $e.type;
5386
- st(), Re.autoReset = e, $e.enabled = t, $e.autoUpdate = n, $e.needsUpdate = r, $e.type = i;
5418
+ function ht() {
5419
+ T("WebGLRenderer: Context Restored."), I = !1;
5420
+ let e = Le.autoReset, t = Qe.enabled, n = Qe.autoUpdate, r = Qe.needsUpdate, i = Qe.type;
5421
+ ot(), Le.autoReset = e, Qe.enabled = t, Qe.autoUpdate = n, Qe.needsUpdate = r, Qe.type = i;
5387
5422
  }
5388
5423
  function _t(e) {
5389
5424
  S("WebGLRenderer: A WebGL context could not be created. Reason: ", e.statusMessage);
5390
5425
  }
5391
- function yt(e) {
5426
+ function vt(e) {
5392
5427
  let t = e.target;
5393
- t.removeEventListener("dispose", yt), bt(t);
5428
+ t.removeEventListener("dispose", vt), yt(t);
5394
5429
  }
5395
- function bt(e) {
5396
- xt(e), Y.remove(e);
5430
+ function yt(e) {
5431
+ bt(e), X.remove(e);
5397
5432
  }
5398
- function xt(e) {
5399
- let t = Y.get(e).programs;
5433
+ function bt(e) {
5434
+ let t = X.get(e).programs;
5400
5435
  t !== void 0 && (t.forEach(function(e) {
5401
- Je.releaseProgram(e);
5402
- }), e.isShaderMaterial && Je.releaseShaderCache(e));
5436
+ qe.releaseProgram(e);
5437
+ }), e.isShaderMaterial && qe.releaseShaderCache(e));
5403
5438
  }
5404
5439
  this.renderBufferDirect = function(e, t, n, r, i, a) {
5405
5440
  t === null && (t = Ae);
5406
- let o = i.isMesh && i.matrixWorld.determinant() < 0, s = Pt(e, t, n, r, i);
5407
- J.setMaterial(r, o);
5441
+ let o = i.isMesh && i.matrixWorld.determinant() < 0, s = Ft(e, t, n, r, i);
5442
+ Y.setMaterial(r, o);
5408
5443
  let c = n.index, l = 1;
5409
5444
  if (r.wireframe === !0) {
5410
- if (c = Ke.getWireframeAttribute(n), c === void 0) return;
5445
+ if (c = Ge.getWireframeAttribute(n), c === void 0) return;
5411
5446
  l = 2;
5412
5447
  }
5413
5448
  let u = n.drawRange, d = n.attributes.position, f = u.start * l, p = (u.start + u.count) * l;
5414
5449
  a !== null && (f = Math.max(f, a.start * l), p = Math.min(p, (a.start + a.count) * l)), c === null ? d != null && (f = Math.max(f, 0), p = Math.min(p, d.count)) : (f = Math.max(f, 0), p = Math.min(p, c.count));
5415
5450
  let m = p - f;
5416
5451
  if (m < 0 || m === Infinity) return;
5417
- at.setup(i, r, s, n, c);
5418
- let h, g = nt;
5419
- if (c !== null && (h = Ge.get(c), g = rt, g.setIndex(h)), i.isMesh) r.wireframe === !0 ? (J.setLineWidth(r.wireframeLinewidth * Ne()), g.setMode(G.LINES)) : g.setMode(G.TRIANGLES);
5452
+ it.setup(i, r, s, n, c);
5453
+ let h, g = tt;
5454
+ if (c !== null && (h = We.get(c), g = nt, g.setIndex(h)), i.isMesh) r.wireframe === !0 ? (Y.setLineWidth(r.wireframeLinewidth * Ne()), g.setMode(G.LINES)) : g.setMode(G.TRIANGLES);
5420
5455
  else if (i.isLine) {
5421
5456
  let e = r.linewidth;
5422
- e === void 0 && (e = 1), J.setLineWidth(e * Ne()), i.isLineSegments ? g.setMode(G.LINES) : i.isLineLoop ? g.setMode(G.LINE_LOOP) : g.setMode(G.LINE_STRIP);
5457
+ e === void 0 && (e = 1), Y.setLineWidth(e * Ne()), i.isLineSegments ? g.setMode(G.LINES) : i.isLineLoop ? g.setMode(G.LINE_LOOP) : g.setMode(G.LINE_STRIP);
5423
5458
  } else i.isPoints ? g.setMode(G.POINTS) : i.isSprite && g.setMode(G.TRIANGLES);
5424
- if (i.isBatchedMesh) if (i._multiDrawInstances !== null) j("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."), g.renderMultiDrawInstances(i._multiDrawStarts, i._multiDrawCounts, i._multiDrawCount, i._multiDrawInstances);
5425
- else if (K.get("WEBGL_multi_draw")) g.renderMultiDraw(i._multiDrawStarts, i._multiDrawCounts, i._multiDrawCount);
5459
+ if (i.isBatchedMesh) if (q.get("WEBGL_multi_draw")) g.renderMultiDraw(i._multiDrawStarts, i._multiDrawCounts, i._multiDrawCount);
5426
5460
  else {
5427
- let e = i._multiDrawStarts, t = i._multiDrawCounts, n = i._multiDrawCount, a = c ? Ge.get(c).bytesPerElement : 1, o = Y.get(r).currentProgram.getUniforms();
5461
+ let e = i._multiDrawStarts, t = i._multiDrawCounts, n = i._multiDrawCount, a = c ? We.get(c).bytesPerElement : 1, o = X.get(r).currentProgram.getUniforms();
5428
5462
  for (let r = 0; r < n; r++) o.setValue(G, "_gl_DrawID", r), g.render(e[r] / a, t[r]);
5429
5463
  }
5430
5464
  else if (i.isInstancedMesh) g.renderInstances(f, m, i.count);
@@ -5433,98 +5467,100 @@ var Gr = class {
5433
5467
  g.renderInstances(f, m, t);
5434
5468
  } else g.render(f, m);
5435
5469
  };
5436
- function St(e, t, n) {
5470
+ function xt(e, t, n) {
5437
5471
  e.transparent === !0 && e.side === 2 && e.forceSinglePass === !1 ? (e.side = 1, e.needsUpdate = !0, jt(e, t, n), e.side = 0, e.needsUpdate = !0, jt(e, t, n), e.side = 2) : jt(e, t, n);
5438
5472
  }
5439
5473
  this.compile = function(e, t, n = null) {
5440
- n === null && (n = e), M = Ze.get(n), M.init(t), P.push(M), n.traverseVisible(function(e) {
5441
- e.isLight && e.layers.test(t.layers) && (M.pushLight(e), e.castShadow && M.pushShadow(e));
5474
+ n === null && (n = e), j = Xe.get(n), j.init(t), ne.push(j), n.traverseVisible(function(e) {
5475
+ e.isLight && e.layers.test(t.layers) && (j.pushLight(e), e.castShadow && j.pushShadow(e));
5442
5476
  }), e !== n && e.traverseVisible(function(e) {
5443
- e.isLight && e.layers.test(t.layers) && (M.pushLight(e), e.castShadow && M.pushShadow(e));
5444
- }), M.setupLights();
5477
+ e.isLight && e.layers.test(t.layers) && (j.pushLight(e), e.castShadow && j.pushShadow(e));
5478
+ }), j.setupLights();
5445
5479
  let r = /* @__PURE__ */ new Set();
5446
5480
  return e.traverse(function(e) {
5447
5481
  if (!(e.isMesh || e.isPoints || e.isLine || e.isSprite)) return;
5448
5482
  let t = e.material;
5449
5483
  if (t) if (Array.isArray(t)) for (let i = 0; i < t.length; i++) {
5450
5484
  let a = t[i];
5451
- St(a, n, e), r.add(a);
5485
+ xt(a, n, e), r.add(a);
5452
5486
  }
5453
- else St(t, n, e), r.add(t);
5454
- }), M = P.pop(), r;
5487
+ else xt(t, n, e), r.add(t);
5488
+ }), j = ne.pop(), r;
5455
5489
  }, this.compileAsync = function(e, t, n = null) {
5456
5490
  let r = this.compile(e, t, n);
5457
5491
  return new Promise((t) => {
5458
5492
  function n() {
5459
5493
  if (r.forEach(function(e) {
5460
- Y.get(e).currentProgram.isReady() && r.delete(e);
5494
+ X.get(e).currentProgram.isReady() && r.delete(e);
5461
5495
  }), r.size === 0) {
5462
5496
  t(e);
5463
5497
  return;
5464
5498
  }
5465
5499
  setTimeout(n, 10);
5466
5500
  }
5467
- K.get("KHR_parallel_shader_compile") === null ? setTimeout(n, 10) : n();
5501
+ q.get("KHR_parallel_shader_compile") === null ? setTimeout(n, 10) : n();
5468
5502
  });
5469
5503
  };
5470
- let Ct = null;
5471
- function wt(e) {
5472
- Ct && Ct(e);
5504
+ let St = null;
5505
+ function Ct(e) {
5506
+ St && St(e);
5473
5507
  }
5474
- function Tt() {
5475
- Dt.stop();
5508
+ function wt() {
5509
+ Et.stop();
5476
5510
  }
5477
- function Et() {
5478
- Dt.start();
5511
+ function Tt() {
5512
+ Et.start();
5479
5513
  }
5480
- let Dt = new Ie();
5481
- Dt.setAnimationLoop(wt), typeof self < "u" && Dt.setContext(self), this.setAnimationLoop = function(e) {
5482
- Ct = e, Z.setAnimationLoop(e), e === null ? Dt.stop() : Dt.start();
5483
- }, Z.addEventListener("sessionstart", Tt), Z.addEventListener("sessionend", Et), this.render = function(e, t) {
5514
+ let Et = new Fe();
5515
+ Et.setAnimationLoop(Ct), typeof self < "u" && Et.setContext(self), this.setAnimationLoop = function(e) {
5516
+ St = e, Q.setAnimationLoop(e), e === null ? Et.stop() : Et.start();
5517
+ }, Q.addEventListener("sessionstart", wt), Q.addEventListener("sessionend", Tt), this.render = function(e, t) {
5484
5518
  if (t !== void 0 && t.isCamera !== !0) {
5485
5519
  S("WebGLRenderer.render: camera is not an instance of THREE.Camera.");
5486
5520
  return;
5487
5521
  }
5488
- if (L === !0) return;
5489
- let n = Z.enabled === !0 && Z.isPresenting === !0, r = F !== null && (z === null || n) && F.begin(I, z);
5490
- if (e.matrixWorldAutoUpdate === !0 && e.updateMatrixWorld(), t.parent === null && t.matrixWorldAutoUpdate === !0 && t.updateMatrixWorld(), Z.enabled === !0 && Z.isPresenting === !0 && (F === null || F.isCompositing() === !1) && (Z.cameraAutoUpdate === !0 && Z.updateCamera(t), t = Z.getCamera()), e.isScene === !0 && e.onBeforeRender(I, e, t, z), M = Ze.get(e, P.length), M.init(t), P.push(M), we.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), xe.setFromProjectionMatrix(we, Oe, t.reversedDepth), Ce = this.localClippingEnabled, Se = Qe.init(this.clippingPlanes, Ce), A = Xe.get(e, ee.length), A.init(), ee.push(A), Z.enabled === !0 && Z.isPresenting === !0) {
5491
- let e = I.xr.getDepthSensingMesh();
5492
- e !== null && Ot(e, t, -Infinity, I.sortObjects);
5522
+ if (I === !0) return;
5523
+ L !== null && L.renderStart(e, t);
5524
+ let n = Q.enabled === !0 && Q.isPresenting === !0, r = P !== null && (z === null || n) && P.begin(F, z);
5525
+ if (e.matrixWorldAutoUpdate === !0 && e.updateMatrixWorld(), t.parent === null && t.matrixWorldAutoUpdate === !0 && t.updateMatrixWorld(), Q.enabled === !0 && Q.isPresenting === !0 && (P === null || P.isCompositing() === !1) && (Q.cameraAutoUpdate === !0 && Q.updateCamera(t), t = Q.getCamera()), e.isScene === !0 && e.onBeforeRender(F, e, t, z), j = Xe.get(e, ne.length), j.init(t), j.state.textureUnits = Z.getTextureUnits(), ne.push(j), Ee.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), xe.setFromProjectionMatrix(Ee, De, t.reversedDepth), Ce = this.localClippingEnabled, Se = Ze.init(this.clippingPlanes, Ce), A = Ye.get(e, M.length), A.init(), M.push(A), Q.enabled === !0 && Q.isPresenting === !0) {
5526
+ let e = F.xr.getDepthSensingMesh();
5527
+ e !== null && Dt(e, t, -Infinity, F.sortObjects);
5493
5528
  }
5494
- Ot(e, t, 0, I.sortObjects), A.finish(), I.sortObjects === !0 && A.sort(_e, ve), je = Z.enabled === !1 || Z.isPresenting === !1 || Z.hasDepthSensing() === !1, je && et.addToRenderList(A, e), this.info.render.frame++, Se === !0 && Qe.beginShadows();
5495
- let i = M.state.shadowsArray;
5496
- if ($e.render(i, e, t), Se === !0 && Qe.endShadows(), this.info.autoReset === !0 && this.info.reset(), (r && F.hasRenderPass()) === !1) {
5529
+ Dt(e, t, 0, F.sortObjects), A.finish(), F.sortObjects === !0 && A.sort(ge, _e), Me = Q.enabled === !1 || Q.isPresenting === !1 || Q.hasDepthSensing() === !1, Me && $e.addToRenderList(A, e), this.info.render.frame++, Se === !0 && Ze.beginShadows();
5530
+ let i = j.state.shadowsArray;
5531
+ if (Qe.render(i, e, t), Se === !0 && Ze.endShadows(), this.info.autoReset === !0 && this.info.reset(), (r && P.hasRenderPass()) === !1) {
5497
5532
  let n = A.opaque, r = A.transmissive;
5498
- if (M.setupLights(), t.isArrayCamera) {
5533
+ if (j.setupLights(), t.isArrayCamera) {
5499
5534
  let i = t.cameras;
5500
5535
  if (r.length > 0) for (let t = 0, a = i.length; t < a; t++) {
5501
5536
  let a = i[t];
5502
- Q(n, r, e, a);
5537
+ $(n, r, e, a);
5503
5538
  }
5504
- je && et.render(e);
5539
+ Me && $e.render(e);
5505
5540
  for (let t = 0, n = i.length; t < n; t++) {
5506
5541
  let n = i[t];
5507
- kt(A, e, n, n.viewport);
5542
+ Ot(A, e, n, n.viewport);
5508
5543
  }
5509
- } else r.length > 0 && Q(n, r, e, t), je && et.render(e), kt(A, e, t);
5544
+ } else r.length > 0 && $(n, r, e, t), Me && $e.render(e), Ot(A, e, t);
5510
5545
  }
5511
- z !== null && re === 0 && (X.updateMultisampleRenderTarget(z), X.updateRenderTargetMipmap(z)), r && F.end(I), e.isScene === !0 && e.onAfterRender(I, e, t), at.resetDefaultState(), ie = -1, B = null, P.pop(), P.length > 0 ? (M = P[P.length - 1], Se === !0 && Qe.setGlobalState(I.clippingPlanes, M.state.camera)) : M = null, ee.pop(), A = ee.length > 0 ? ee[ee.length - 1] : null;
5546
+ z !== null && re === 0 && (Z.updateMultisampleRenderTarget(z), Z.updateRenderTargetMipmap(z)), r && P.end(F), e.isScene === !0 && e.onAfterRender(F, e, t), it.resetDefaultState(), ie = -1, se = null, ne.pop(), ne.length > 0 ? (j = ne[ne.length - 1], Z.setTextureUnits(j.state.textureUnits), Se === !0 && Ze.setGlobalState(F.clippingPlanes, j.state.camera)) : j = null, M.pop(), A = M.length > 0 ? M[M.length - 1] : null, L !== null && L.renderEnd();
5512
5547
  };
5513
- function Ot(e, t, n, r) {
5548
+ function Dt(e, t, n, r) {
5514
5549
  if (e.visible === !1) return;
5515
5550
  if (e.layers.test(t.layers)) {
5516
5551
  if (e.isGroup) n = e.renderOrder;
5517
5552
  else if (e.isLOD) e.autoUpdate === !0 && e.update(t);
5518
- else if (e.isLight) M.pushLight(e), e.castShadow && M.pushShadow(e);
5553
+ else if (e.isLightProbeGrid) j.pushLightProbeGrid(e);
5554
+ else if (e.isLight) j.pushLight(e), e.castShadow && j.pushShadow(e);
5519
5555
  else if (e.isSprite) {
5520
5556
  if (!e.frustumCulled || xe.intersectsSprite(e)) {
5521
- r && ke.setFromMatrixPosition(e.matrixWorld).applyMatrix4(we);
5522
- let t = qe.update(e), i = e.material;
5557
+ r && ke.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Ee);
5558
+ let t = Ke.update(e), i = e.material;
5523
5559
  i.visible && A.push(e, t, i, n, ke.z, null);
5524
5560
  }
5525
5561
  } else if ((e.isMesh || e.isLine || e.isPoints) && (!e.frustumCulled || xe.intersectsObject(e))) {
5526
- let t = qe.update(e), i = e.material;
5527
- if (r && (e.boundingSphere === void 0 ? (t.boundingSphere === null && t.computeBoundingSphere(), ke.copy(t.boundingSphere.center)) : (e.boundingSphere === null && e.computeBoundingSphere(), ke.copy(e.boundingSphere.center)), ke.applyMatrix4(e.matrixWorld).applyMatrix4(we)), Array.isArray(i)) {
5562
+ let t = Ke.update(e), i = e.material;
5563
+ if (r && (e.boundingSphere === void 0 ? (t.boundingSphere === null && t.computeBoundingSphere(), ke.copy(t.boundingSphere.center)) : (e.boundingSphere === null && e.computeBoundingSphere(), ke.copy(e.boundingSphere.center)), ke.applyMatrix4(e.matrixWorld).applyMatrix4(Ee)), Array.isArray(i)) {
5528
5564
  let r = t.groups;
5529
5565
  for (let a = 0, o = r.length; a < o; a++) {
5530
5566
  let o = r[a], s = i[o.materialIndex];
@@ -5534,35 +5570,35 @@ var Gr = class {
5534
5570
  }
5535
5571
  }
5536
5572
  let i = e.children;
5537
- for (let e = 0, a = i.length; e < a; e++) Ot(i[e], t, n, r);
5573
+ for (let e = 0, a = i.length; e < a; e++) Dt(i[e], t, n, r);
5538
5574
  }
5539
- function kt(e, t, n, r) {
5575
+ function Ot(e, t, n, r) {
5540
5576
  let { opaque: i, transmissive: a, transparent: o } = e;
5541
- M.setupLightsView(n), Se === !0 && Qe.setGlobalState(I.clippingPlanes, n), r && J.viewport(V.copy(r)), i.length > 0 && $(i, t, n), a.length > 0 && $(a, t, n), o.length > 0 && $(o, t, n), J.buffers.depth.setTest(!0), J.buffers.depth.setMask(!0), J.buffers.color.setMask(!0), J.setPolygonOffset(!1);
5577
+ j.setupLightsView(n), Se === !0 && Ze.setGlobalState(F.clippingPlanes, n), r && Y.viewport(B.copy(r)), i.length > 0 && kt(i, t, n), a.length > 0 && kt(a, t, n), o.length > 0 && kt(o, t, n), Y.buffers.depth.setTest(!0), Y.buffers.depth.setMask(!0), Y.buffers.color.setMask(!0), Y.setPolygonOffset(!1);
5542
5578
  }
5543
- function Q(e, t, n, r) {
5579
+ function $(e, t, n, r) {
5544
5580
  if ((n.isScene === !0 ? n.overrideMaterial : null) !== null) return;
5545
- if (M.state.transmissionRenderTarget[r.id] === void 0) {
5546
- let e = K.has("EXT_color_buffer_half_float") || K.has("EXT_color_buffer_float");
5547
- M.state.transmissionRenderTarget[r.id] = new k(1, 1, {
5581
+ if (j.state.transmissionRenderTarget[r.id] === void 0) {
5582
+ let e = q.has("EXT_color_buffer_half_float") || q.has("EXT_color_buffer_float");
5583
+ j.state.transmissionRenderTarget[r.id] = new ee(1, 1, {
5548
5584
  generateMipmaps: !0,
5549
- type: e ? he : ae,
5585
+ type: e ? pe : ae,
5550
5586
  minFilter: te,
5551
- samples: q.samples,
5587
+ samples: Math.max(4, J.samples),
5552
5588
  stencilBuffer: s,
5553
5589
  resolveDepthBuffer: !1,
5554
5590
  resolveStencilBuffer: !1,
5555
5591
  colorSpace: O.workingColorSpace
5556
5592
  });
5557
5593
  }
5558
- let i = M.state.transmissionRenderTarget[r.id], a = r.viewport || V;
5559
- i.setSize(a.z * I.transmissionResolutionScale, a.w * I.transmissionResolutionScale);
5560
- let o = I.getRenderTarget(), c = I.getActiveCubeFace(), l = I.getActiveMipmapLevel();
5561
- I.setRenderTarget(i), I.getClearColor(le), de = I.getClearAlpha(), de < 1 && I.setClearColor(16777215, .5), I.clear(), je && et.render(n);
5562
- let u = I.toneMapping;
5563
- I.toneMapping = 0;
5594
+ let i = j.state.transmissionRenderTarget[r.id], a = r.viewport || B;
5595
+ i.setSize(a.z * F.transmissionResolutionScale, a.w * F.transmissionResolutionScale);
5596
+ let o = F.getRenderTarget(), c = F.getActiveCubeFace(), l = F.getActiveMipmapLevel();
5597
+ F.setRenderTarget(i), F.getClearColor(le), H = F.getClearAlpha(), H < 1 && F.setClearColor(16777215, .5), F.clear(), Me && $e.render(n);
5598
+ let u = F.toneMapping;
5599
+ F.toneMapping = 0;
5564
5600
  let d = r.viewport;
5565
- if (r.viewport !== void 0 && (r.viewport = void 0), M.setupLightsView(r), Se === !0 && Qe.setGlobalState(I.clippingPlanes, r), $(e, n, r), X.updateMultisampleRenderTarget(i), X.updateRenderTargetMipmap(i), K.has("WEBGL_multisampled_render_to_texture") === !1) {
5601
+ if (r.viewport !== void 0 && (r.viewport = void 0), j.setupLightsView(r), Se === !0 && Ze.setGlobalState(F.clippingPlanes, r), kt(e, n, r), Z.updateMultisampleRenderTarget(i), Z.updateRenderTargetMipmap(i), q.has("WEBGL_multisampled_render_to_texture") === !1) {
5566
5602
  let e = !1;
5567
5603
  for (let i = 0, a = t.length; i < a; i++) {
5568
5604
  let { object: a, geometry: o, material: s, group: c } = t[i];
@@ -5571,11 +5607,11 @@ var Gr = class {
5571
5607
  s.side = 1, s.needsUpdate = !0, At(a, n, r, o, s, c), s.side = t, s.needsUpdate = !0, e = !0;
5572
5608
  }
5573
5609
  }
5574
- e === !0 && (X.updateMultisampleRenderTarget(i), X.updateRenderTargetMipmap(i));
5610
+ e === !0 && (Z.updateMultisampleRenderTarget(i), Z.updateRenderTargetMipmap(i));
5575
5611
  }
5576
- I.setRenderTarget(o, c, l), I.setClearColor(le, de), d !== void 0 && (r.viewport = d), I.toneMapping = u;
5612
+ F.setRenderTarget(o, c, l), F.setClearColor(le, H), d !== void 0 && (r.viewport = d), F.toneMapping = u;
5577
5613
  }
5578
- function $(e, t, n) {
5614
+ function kt(e, t, n) {
5579
5615
  let r = t.isScene === !0 ? t.overrideMaterial : null;
5580
5616
  for (let i = 0, a = e.length; i < a; i++) {
5581
5617
  let a = e[i], { object: o, geometry: s, group: c } = a, l = a.material;
@@ -5583,71 +5619,92 @@ var Gr = class {
5583
5619
  }
5584
5620
  }
5585
5621
  function At(e, t, n, r, i, a) {
5586
- e.onBeforeRender(I, t, n, r, i, a), e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse, e.matrixWorld), e.normalMatrix.getNormalMatrix(e.modelViewMatrix), i.onBeforeRender(I, t, n, r, e, a), i.transparent === !0 && i.side === 2 && i.forceSinglePass === !1 ? (i.side = 1, i.needsUpdate = !0, I.renderBufferDirect(n, t, r, i, e, a), i.side = 0, i.needsUpdate = !0, I.renderBufferDirect(n, t, r, i, e, a), i.side = 2) : I.renderBufferDirect(n, t, r, i, e, a), e.onAfterRender(I, t, n, r, i, a);
5622
+ e.onBeforeRender(F, t, n, r, i, a), e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse, e.matrixWorld), e.normalMatrix.getNormalMatrix(e.modelViewMatrix), i.onBeforeRender(F, t, n, r, e, a), i.transparent === !0 && i.side === 2 && i.forceSinglePass === !1 ? (i.side = 1, i.needsUpdate = !0, F.renderBufferDirect(n, t, r, i, e, a), i.side = 0, i.needsUpdate = !0, F.renderBufferDirect(n, t, r, i, e, a), i.side = 2) : F.renderBufferDirect(n, t, r, i, e, a), e.onAfterRender(F, t, n, r, i, a);
5587
5623
  }
5588
5624
  function jt(e, t, n) {
5589
5625
  t.isScene !== !0 && (t = Ae);
5590
- let r = Y.get(e), i = M.state.lights, a = M.state.shadowsArray, o = i.state.version, s = Je.getParameters(e, i.state, a, t, n), c = Je.getProgramCacheKey(s), l = r.programs;
5626
+ let r = X.get(e), i = j.state.lights, a = j.state.shadowsArray, o = i.state.version, s = qe.getParameters(e, i.state, a, t, n, j.state.lightProbeGridArray), c = qe.getProgramCacheKey(s), l = r.programs;
5591
5627
  r.environment = e.isMeshStandardMaterial || e.isMeshLambertMaterial || e.isMeshPhongMaterial ? t.environment : null, r.fog = t.fog;
5592
5628
  let u = e.isMeshStandardMaterial || e.isMeshLambertMaterial && !e.envMap || e.isMeshPhongMaterial && !e.envMap;
5593
- r.envMap = We.get(e.envMap || r.environment, u), r.envMapRotation = r.environment !== null && e.envMap === null ? t.environmentRotation : e.envMapRotation, l === void 0 && (e.addEventListener("dispose", yt), l = /* @__PURE__ */ new Map(), r.programs = l);
5629
+ r.envMap = Ue.get(e.envMap || r.environment, u), r.envMapRotation = r.environment !== null && e.envMap === null ? t.environmentRotation : e.envMapRotation, l === void 0 && (e.addEventListener("dispose", vt), l = /* @__PURE__ */ new Map(), r.programs = l);
5594
5630
  let d = l.get(c);
5595
5631
  if (d !== void 0) {
5596
5632
  if (r.currentProgram === d && r.lightsStateVersion === o) return Nt(e, s), d;
5597
- } else s.uniforms = Je.getUniforms(e), e.onBeforeCompile(s, I), d = Je.acquireProgram(s, c), l.set(c, d), r.uniforms = s.uniforms;
5633
+ } else s.uniforms = qe.getUniforms(e), L !== null && e.isNodeMaterial && L.build(e, n, s), e.onBeforeCompile(s, F), d = qe.acquireProgram(s, c), l.set(c, d), r.uniforms = s.uniforms;
5598
5634
  let f = r.uniforms;
5599
- return (!e.isShaderMaterial && !e.isRawShaderMaterial || e.clipping === !0) && (f.clippingPlanes = Qe.uniform), Nt(e, s), r.needsLights = It(e), r.lightsStateVersion = o, r.needsLights && (f.ambientLightColor.value = i.state.ambient, f.lightProbe.value = i.state.probe, f.directionalLights.value = i.state.directional, f.directionalLightShadows.value = i.state.directionalShadow, f.spotLights.value = i.state.spot, f.spotLightShadows.value = i.state.spotShadow, f.rectAreaLights.value = i.state.rectArea, f.ltc_1.value = i.state.rectAreaLTC1, f.ltc_2.value = i.state.rectAreaLTC2, f.pointLights.value = i.state.point, f.pointLightShadows.value = i.state.pointShadow, f.hemisphereLights.value = i.state.hemi, f.directionalShadowMatrix.value = i.state.directionalShadowMatrix, f.spotLightMatrix.value = i.state.spotLightMatrix, f.spotLightMap.value = i.state.spotLightMap, f.pointShadowMatrix.value = i.state.pointShadowMatrix), r.currentProgram = d, r.uniformsList = null, d;
5635
+ return (!e.isShaderMaterial && !e.isRawShaderMaterial || e.clipping === !0) && (f.clippingPlanes = Ze.uniform), Nt(e, s), r.needsLights = Lt(e), r.lightsStateVersion = o, r.needsLights && (f.ambientLightColor.value = i.state.ambient, f.lightProbe.value = i.state.probe, f.directionalLights.value = i.state.directional, f.directionalLightShadows.value = i.state.directionalShadow, f.spotLights.value = i.state.spot, f.spotLightShadows.value = i.state.spotShadow, f.rectAreaLights.value = i.state.rectArea, f.ltc_1.value = i.state.rectAreaLTC1, f.ltc_2.value = i.state.rectAreaLTC2, f.pointLights.value = i.state.point, f.pointLightShadows.value = i.state.pointShadow, f.hemisphereLights.value = i.state.hemi, f.directionalShadowMatrix.value = i.state.directionalShadowMatrix, f.spotLightMatrix.value = i.state.spotLightMatrix, f.spotLightMap.value = i.state.spotLightMap, f.pointShadowMatrix.value = i.state.pointShadowMatrix), r.lightProbeGrid = j.state.lightProbeGridArray.length > 0, r.currentProgram = d, r.uniformsList = null, d;
5600
5636
  }
5601
5637
  function Mt(e) {
5602
5638
  if (e.uniformsList === null) {
5603
5639
  let t = e.currentProgram.getUniforms();
5604
- e.uniformsList = wn.seqWithValue(t.seq, e.uniforms);
5640
+ e.uniformsList = Cn.seqWithValue(t.seq, e.uniforms);
5605
5641
  }
5606
5642
  return e.uniformsList;
5607
5643
  }
5608
5644
  function Nt(e, t) {
5609
- let n = Y.get(e);
5645
+ let n = X.get(e);
5610
5646
  n.outputColorSpace = t.outputColorSpace, n.batching = t.batching, n.batchingColor = t.batchingColor, n.instancing = t.instancing, n.instancingColor = t.instancingColor, n.instancingMorph = t.instancingMorph, n.skinning = t.skinning, n.morphTargets = t.morphTargets, n.morphNormals = t.morphNormals, n.morphColors = t.morphColors, n.morphTargetsCount = t.morphTargetsCount, n.numClippingPlanes = t.numClippingPlanes, n.numIntersection = t.numClipIntersection, n.vertexAlphas = t.vertexAlphas, n.vertexTangents = t.vertexTangents, n.toneMapping = t.toneMapping;
5611
5647
  }
5612
- function Pt(e, t, n, r, i) {
5613
- t.isScene !== !0 && (t = Ae), X.resetTextureUnits();
5614
- let a = t.fog, o = r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial ? t.environment : null, s = z === null ? I.outputColorSpace : z.isXRRenderTarget === !0 ? z.texture.colorSpace : ne, c = r.isMeshStandardMaterial || r.isMeshLambertMaterial && !r.envMap || r.isMeshPhongMaterial && !r.envMap, l = We.get(r.envMap || o, c), u = r.vertexColors === !0 && !!n.attributes.color && n.attributes.color.itemSize === 4, d = !!n.attributes.tangent && (!!r.normalMap || r.anisotropy > 0), f = !!n.morphAttributes.position, p = !!n.morphAttributes.normal, m = !!n.morphAttributes.color, h = 0;
5615
- r.toneMapped && (z === null || z.isXRRenderTarget === !0) && (h = I.toneMapping);
5616
- let g = n.morphAttributes.position || n.morphAttributes.normal || n.morphAttributes.color, _ = g === void 0 ? 0 : g.length, v = Y.get(r), y = M.state.lights;
5617
- if (Se === !0 && (Ce === !0 || e !== B)) {
5618
- let t = e === B && r.id === ie;
5619
- Qe.setState(r, e, t);
5648
+ function Pt(e, t) {
5649
+ if (e.length === 0) return null;
5650
+ if (e.length === 1) return e[0].texture === null ? null : e[0];
5651
+ k.setFromMatrixPosition(t.matrixWorld);
5652
+ for (let t = 0, n = e.length; t < n; t++) {
5653
+ let n = e[t];
5654
+ if (n.texture !== null && n.boundingBox.containsPoint(k)) return n;
5655
+ }
5656
+ return null;
5657
+ }
5658
+ function Ft(e, t, n, r, i) {
5659
+ t.isScene !== !0 && (t = Ae), Z.resetTextureUnits();
5660
+ let a = t.fog, o = r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial ? t.environment : null, s = z === null ? F.outputColorSpace : z.isXRRenderTarget === !0 ? z.texture.colorSpace : O.workingColorSpace, c = r.isMeshStandardMaterial || r.isMeshLambertMaterial && !r.envMap || r.isMeshPhongMaterial && !r.envMap, l = Ue.get(r.envMap || o, c), u = r.vertexColors === !0 && !!n.attributes.color && n.attributes.color.itemSize === 4, d = !!n.attributes.tangent && (!!r.normalMap || r.anisotropy > 0), f = !!n.morphAttributes.position, p = !!n.morphAttributes.normal, m = !!n.morphAttributes.color, h = 0;
5661
+ r.toneMapped && (z === null || z.isXRRenderTarget === !0) && (h = F.toneMapping);
5662
+ let g = n.morphAttributes.position || n.morphAttributes.normal || n.morphAttributes.color, _ = g === void 0 ? 0 : g.length, v = X.get(r), y = j.state.lights;
5663
+ if (Se === !0 && (Ce === !0 || e !== se)) {
5664
+ let t = e === se && r.id === ie;
5665
+ Ze.setState(r, e, t);
5620
5666
  }
5621
5667
  let b = !1;
5622
- r.version === v.__version ? v.needsLights && v.lightsStateVersion !== y.state.version ? b = !0 : v.outputColorSpace === s ? i.isBatchedMesh && v.batching === !1 || !i.isBatchedMesh && v.batching === !0 || i.isBatchedMesh && v.batchingColor === !0 && i.colorTexture === null || i.isBatchedMesh && v.batchingColor === !1 && i.colorTexture !== null || i.isInstancedMesh && v.instancing === !1 || !i.isInstancedMesh && v.instancing === !0 || i.isSkinnedMesh && v.skinning === !1 || !i.isSkinnedMesh && v.skinning === !0 || i.isInstancedMesh && v.instancingColor === !0 && i.instanceColor === null || i.isInstancedMesh && v.instancingColor === !1 && i.instanceColor !== null || i.isInstancedMesh && v.instancingMorph === !0 && i.morphTexture === null || i.isInstancedMesh && v.instancingMorph === !1 && i.morphTexture !== null ? b = !0 : v.envMap === l ? r.fog === !0 && v.fog !== a || v.numClippingPlanes !== void 0 && (v.numClippingPlanes !== Qe.numPlanes || v.numIntersection !== Qe.numIntersection) ? b = !0 : v.vertexAlphas === u && v.vertexTangents === d && v.morphTargets === f && v.morphNormals === p && v.morphColors === m && v.toneMapping === h ? v.morphTargetsCount !== _ && (b = !0) : b = !0 : b = !0 : b = !0 : (b = !0, v.__version = r.version);
5668
+ r.version === v.__version ? v.needsLights && v.lightsStateVersion !== y.state.version ? b = !0 : v.outputColorSpace === s ? i.isBatchedMesh && v.batching === !1 || !i.isBatchedMesh && v.batching === !0 || i.isBatchedMesh && v.batchingColor === !0 && i.colorTexture === null || i.isBatchedMesh && v.batchingColor === !1 && i.colorTexture !== null || i.isInstancedMesh && v.instancing === !1 || !i.isInstancedMesh && v.instancing === !0 || i.isSkinnedMesh && v.skinning === !1 || !i.isSkinnedMesh && v.skinning === !0 || i.isInstancedMesh && v.instancingColor === !0 && i.instanceColor === null || i.isInstancedMesh && v.instancingColor === !1 && i.instanceColor !== null || i.isInstancedMesh && v.instancingMorph === !0 && i.morphTexture === null || i.isInstancedMesh && v.instancingMorph === !1 && i.morphTexture !== null ? b = !0 : v.envMap === l ? r.fog === !0 && v.fog !== a || v.numClippingPlanes !== void 0 && (v.numClippingPlanes !== Ze.numPlanes || v.numIntersection !== Ze.numIntersection) ? b = !0 : v.vertexAlphas === u && v.vertexTangents === d && v.morphTargets === f && v.morphNormals === p && v.morphColors === m && v.toneMapping === h && v.morphTargetsCount === _ ? !!v.lightProbeGrid != j.state.lightProbeGridArray.length > 0 && (b = !0) : b = !0 : b = !0 : b = !0 : (b = !0, v.__version = r.version);
5623
5669
  let x = v.currentProgram;
5624
- b === !0 && (x = jt(r, t, i));
5670
+ b === !0 && (x = jt(r, t, i), L && r.isNodeMaterial && L.onUpdateProgram(r, x, v));
5625
5671
  let S = !1, C = !1, w = !1, T = x.getUniforms(), E = v.uniforms;
5626
- if (J.useProgram(x.program) && (S = !0, C = !0, w = !0), r.id !== ie && (ie = r.id, C = !0), S || B !== e) {
5627
- J.buffers.depth.getReversed() && e.reversedDepth !== !0 && (e._reversedDepth = !0, e.updateProjectionMatrix()), T.setValue(G, "projectionMatrix", e.projectionMatrix), T.setValue(G, "viewMatrix", e.matrixWorldInverse);
5672
+ if (Y.useProgram(x.program) && (S = !0, C = !0, w = !0), r.id !== ie && (ie = r.id, C = !0), v.needsLights) {
5673
+ let e = Pt(j.state.lightProbeGridArray, i);
5674
+ v.lightProbeGrid !== e && (v.lightProbeGrid = e, C = !0);
5675
+ }
5676
+ if (S || se !== e) {
5677
+ Y.buffers.depth.getReversed() && e.reversedDepth !== !0 && (e._reversedDepth = !0, e.updateProjectionMatrix()), T.setValue(G, "projectionMatrix", e.projectionMatrix), T.setValue(G, "viewMatrix", e.matrixWorldInverse);
5628
5678
  let t = T.map.cameraPosition;
5629
- t !== void 0 && t.setValue(G, De.setFromMatrixPosition(e.matrixWorld)), q.logarithmicDepthBuffer && T.setValue(G, "logDepthBufFC", 2 / (Math.log(e.far + 1) / Math.LN2)), (r.isMeshPhongMaterial || r.isMeshToonMaterial || r.isMeshLambertMaterial || r.isMeshBasicMaterial || r.isMeshStandardMaterial || r.isShaderMaterial) && T.setValue(G, "isOrthographic", e.isOrthographicCamera === !0), B !== e && (B = e, C = !0, w = !0);
5679
+ t !== void 0 && t.setValue(G, Oe.setFromMatrixPosition(e.matrixWorld)), J.logarithmicDepthBuffer && T.setValue(G, "logDepthBufFC", 2 / (Math.log(e.far + 1) / Math.LN2)), (r.isMeshPhongMaterial || r.isMeshToonMaterial || r.isMeshLambertMaterial || r.isMeshBasicMaterial || r.isMeshStandardMaterial || r.isShaderMaterial) && T.setValue(G, "isOrthographic", e.isOrthographicCamera === !0), se !== e && (se = e, C = !0, w = !0);
5630
5680
  }
5631
- if (v.needsLights && (y.state.directionalShadowMap.length > 0 && T.setValue(G, "directionalShadowMap", y.state.directionalShadowMap, X), y.state.spotShadowMap.length > 0 && T.setValue(G, "spotShadowMap", y.state.spotShadowMap, X), y.state.pointShadowMap.length > 0 && T.setValue(G, "pointShadowMap", y.state.pointShadowMap, X)), i.isSkinnedMesh) {
5681
+ if (v.needsLights && (y.state.directionalShadowMap.length > 0 && T.setValue(G, "directionalShadowMap", y.state.directionalShadowMap, Z), y.state.spotShadowMap.length > 0 && T.setValue(G, "spotShadowMap", y.state.spotShadowMap, Z), y.state.pointShadowMap.length > 0 && T.setValue(G, "pointShadowMap", y.state.pointShadowMap, Z)), i.isSkinnedMesh) {
5632
5682
  T.setOptional(G, i, "bindMatrix"), T.setOptional(G, i, "bindMatrixInverse");
5633
5683
  let e = i.skeleton;
5634
- e && (e.boneTexture === null && e.computeBoneTexture(), T.setValue(G, "boneTexture", e.boneTexture, X));
5684
+ e && (e.boneTexture === null && e.computeBoneTexture(), T.setValue(G, "boneTexture", e.boneTexture, Z));
5635
5685
  }
5636
- i.isBatchedMesh && (T.setOptional(G, i, "batchingTexture"), T.setValue(G, "batchingTexture", i._matricesTexture, X), T.setOptional(G, i, "batchingIdTexture"), T.setValue(G, "batchingIdTexture", i._indirectTexture, X), T.setOptional(G, i, "batchingColorTexture"), i._colorsTexture !== null && T.setValue(G, "batchingColorTexture", i._colorsTexture, X));
5686
+ i.isBatchedMesh && (T.setOptional(G, i, "batchingTexture"), T.setValue(G, "batchingTexture", i._matricesTexture, Z), T.setOptional(G, i, "batchingIdTexture"), T.setValue(G, "batchingIdTexture", i._indirectTexture, Z), T.setOptional(G, i, "batchingColorTexture"), i._colorsTexture !== null && T.setValue(G, "batchingColorTexture", i._colorsTexture, Z));
5637
5687
  let D = n.morphAttributes;
5638
- if ((D.position !== void 0 || D.normal !== void 0 || D.color !== void 0) && tt.update(i, n, x), (C || v.receiveShadow !== i.receiveShadow) && (v.receiveShadow = i.receiveShadow, T.setValue(G, "receiveShadow", i.receiveShadow)), (r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial) && r.envMap === null && t.environment !== null && (E.envMapIntensity.value = t.environmentIntensity), E.dfgLUT !== void 0 && (E.dfgLUT.value = Wr()), C && (T.setValue(G, "toneMappingExposure", I.toneMappingExposure), v.needsLights && Ft(E, w), a && r.fog === !0 && Ye.refreshFogUniforms(E, a), Ye.refreshMaterialUniforms(E, r, H, pe, M.state.transmissionRenderTarget[e.id]), wn.upload(G, Mt(v), E, X)), r.isShaderMaterial && r.uniformsNeedUpdate === !0 && (wn.upload(G, Mt(v), E, X), r.uniformsNeedUpdate = !1), r.isSpriteMaterial && T.setValue(G, "center", i.center), T.setValue(G, "modelViewMatrix", i.modelViewMatrix), T.setValue(G, "normalMatrix", i.normalMatrix), T.setValue(G, "modelMatrix", i.matrixWorld), r.isShaderMaterial || r.isRawShaderMaterial) {
5688
+ if ((D.position !== void 0 || D.normal !== void 0 || D.color !== void 0) && et.update(i, n, x), (C || v.receiveShadow !== i.receiveShadow) && (v.receiveShadow = i.receiveShadow, T.setValue(G, "receiveShadow", i.receiveShadow)), (r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial) && r.envMap === null && t.environment !== null && (E.envMapIntensity.value = t.environmentIntensity), E.dfgLUT !== void 0 && (E.dfgLUT.value = Wr()), C) {
5689
+ if (T.setValue(G, "toneMappingExposure", F.toneMappingExposure), v.needsLights && It(E, w), a && r.fog === !0 && Je.refreshFogUniforms(E, a), Je.refreshMaterialUniforms(E, r, me, U, j.state.transmissionRenderTarget[e.id]), v.needsLights && v.lightProbeGrid) {
5690
+ let e = v.lightProbeGrid;
5691
+ E.probesSH.value = e.texture, E.probesMin.value.copy(e.boundingBox.min), E.probesMax.value.copy(e.boundingBox.max), E.probesResolution.value.copy(e.resolution);
5692
+ }
5693
+ Cn.upload(G, Mt(v), E, Z);
5694
+ }
5695
+ if (r.isShaderMaterial && r.uniformsNeedUpdate === !0 && (Cn.upload(G, Mt(v), E, Z), r.uniformsNeedUpdate = !1), r.isSpriteMaterial && T.setValue(G, "center", i.center), T.setValue(G, "modelViewMatrix", i.modelViewMatrix), T.setValue(G, "normalMatrix", i.normalMatrix), T.setValue(G, "modelMatrix", i.matrixWorld), r.uniformsGroups !== void 0) {
5639
5696
  let e = r.uniformsGroups;
5640
5697
  for (let t = 0, n = e.length; t < n; t++) {
5641
5698
  let n = e[t];
5642
- ot.update(n, x), ot.bind(n, x);
5699
+ at.update(n, x), at.bind(n, x);
5643
5700
  }
5644
5701
  }
5645
5702
  return x;
5646
5703
  }
5647
- function Ft(e, t) {
5704
+ function It(e, t) {
5648
5705
  e.ambientLightColor.needsUpdate = t, e.lightProbe.needsUpdate = t, e.directionalLights.needsUpdate = t, e.directionalLightShadows.needsUpdate = t, e.pointLights.needsUpdate = t, e.pointLightShadows.needsUpdate = t, e.spotLights.needsUpdate = t, e.spotLightShadows.needsUpdate = t, e.rectAreaLights.needsUpdate = t, e.hemisphereLights.needsUpdate = t;
5649
5706
  }
5650
- function It(e) {
5707
+ function Lt(e) {
5651
5708
  return e.isMeshLambertMaterial || e.isMeshToonMaterial || e.isMeshPhongMaterial || e.isMeshStandardMaterial || e.isShadowMaterial || e.isShaderMaterial && e.lights === !0;
5652
5709
  }
5653
5710
  this.getActiveCubeFace = function() {
@@ -5657,46 +5714,46 @@ var Gr = class {
5657
5714
  }, this.getRenderTarget = function() {
5658
5715
  return z;
5659
5716
  }, this.setRenderTargetTextures = function(e, t, n) {
5660
- let r = Y.get(e);
5661
- r.__autoAllocateDepthBuffer = e.resolveDepthBuffer === !1, r.__autoAllocateDepthBuffer === !1 && (r.__useRenderToTexture = !1), Y.get(e.texture).__webglTexture = t, Y.get(e.depthTexture).__webglTexture = r.__autoAllocateDepthBuffer ? void 0 : n, r.__hasExternalTextures = !0;
5717
+ let r = X.get(e);
5718
+ r.__autoAllocateDepthBuffer = e.resolveDepthBuffer === !1, r.__autoAllocateDepthBuffer === !1 && (r.__useRenderToTexture = !1), X.get(e.texture).__webglTexture = t, X.get(e.depthTexture).__webglTexture = r.__autoAllocateDepthBuffer ? void 0 : n, r.__hasExternalTextures = !0;
5662
5719
  }, this.setRenderTargetFramebuffer = function(e, t) {
5663
- let n = Y.get(e);
5720
+ let n = X.get(e);
5664
5721
  n.__webglFramebuffer = t, n.__useDefaultFramebuffer = t === void 0;
5665
5722
  };
5666
- let Lt = G.createFramebuffer();
5723
+ let Rt = G.createFramebuffer();
5667
5724
  this.setRenderTarget = function(e, t = 0, n = 0) {
5668
5725
  z = e, R = t, re = n;
5669
5726
  let r = null, i = !1, a = !1;
5670
5727
  if (e) {
5671
- let o = Y.get(e);
5728
+ let o = X.get(e);
5672
5729
  if (o.__useDefaultFramebuffer !== void 0) {
5673
- J.bindFramebuffer(G.FRAMEBUFFER, o.__webglFramebuffer), V.copy(e.viewport), se.copy(e.scissor), ce = e.scissorTest, J.viewport(V), J.scissor(se), J.setScissorTest(ce), ie = -1;
5730
+ Y.bindFramebuffer(G.FRAMEBUFFER, o.__webglFramebuffer), B.copy(e.viewport), V.copy(e.scissor), ce = e.scissorTest, Y.viewport(B), Y.scissor(V), Y.setScissorTest(ce), ie = -1;
5674
5731
  return;
5675
- } else if (o.__webglFramebuffer === void 0) X.setupRenderTarget(e);
5676
- else if (o.__hasExternalTextures) X.rebindTextures(e, Y.get(e.texture).__webglTexture, Y.get(e.depthTexture).__webglTexture);
5732
+ } else if (o.__webglFramebuffer === void 0) Z.setupRenderTarget(e);
5733
+ else if (o.__hasExternalTextures) Z.rebindTextures(e, X.get(e.texture).__webglTexture, X.get(e.depthTexture).__webglTexture);
5677
5734
  else if (e.depthBuffer) {
5678
5735
  let t = e.depthTexture;
5679
5736
  if (o.__boundDepthTexture !== t) {
5680
- if (t !== null && Y.has(t) && (e.width !== t.image.width || e.height !== t.image.height)) throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
5681
- X.setupDepthRenderbuffer(e);
5737
+ if (t !== null && X.has(t) && (e.width !== t.image.width || e.height !== t.image.height)) throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");
5738
+ Z.setupDepthRenderbuffer(e);
5682
5739
  }
5683
5740
  }
5684
5741
  let s = e.texture;
5685
5742
  (s.isData3DTexture || s.isDataArrayTexture || s.isCompressedArrayTexture) && (a = !0);
5686
- let c = Y.get(e).__webglFramebuffer;
5687
- e.isWebGLCubeRenderTarget ? (r = Array.isArray(c[t]) ? c[t][n] : c[t], i = !0) : r = e.samples > 0 && X.useMultisampledRTT(e) === !1 ? Y.get(e).__webglMultisampledFramebuffer : Array.isArray(c) ? c[n] : c, V.copy(e.viewport), se.copy(e.scissor), ce = e.scissorTest;
5688
- } else V.copy(ye).multiplyScalar(H).floor(), se.copy(be).multiplyScalar(H).floor(), ce = U;
5689
- if (n !== 0 && (r = Lt), J.bindFramebuffer(G.FRAMEBUFFER, r) && J.drawBuffers(e, r), J.viewport(V), J.scissor(se), J.setScissorTest(ce), i) {
5690
- let r = Y.get(e.texture);
5743
+ let c = X.get(e).__webglFramebuffer;
5744
+ e.isWebGLCubeRenderTarget ? (r = Array.isArray(c[t]) ? c[t][n] : c[t], i = !0) : r = e.samples > 0 && Z.useMultisampledRTT(e) === !1 ? X.get(e).__webglMultisampledFramebuffer : Array.isArray(c) ? c[n] : c, B.copy(e.viewport), V.copy(e.scissor), ce = e.scissorTest;
5745
+ } else B.copy(ve).multiplyScalar(me).floor(), V.copy(ye).multiplyScalar(me).floor(), ce = be;
5746
+ if (n !== 0 && (r = Rt), Y.bindFramebuffer(G.FRAMEBUFFER, r) && Y.drawBuffers(e, r), Y.viewport(B), Y.scissor(V), Y.setScissorTest(ce), i) {
5747
+ let r = X.get(e.texture);
5691
5748
  G.framebufferTexture2D(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_CUBE_MAP_POSITIVE_X + t, r.__webglTexture, n);
5692
5749
  } else if (a) {
5693
5750
  let r = t;
5694
5751
  for (let t = 0; t < e.textures.length; t++) {
5695
- let i = Y.get(e.textures[t]);
5752
+ let i = X.get(e.textures[t]);
5696
5753
  G.framebufferTextureLayer(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0 + t, i.__webglTexture, n, r);
5697
5754
  }
5698
5755
  } else if (e !== null && n !== 0) {
5699
- let t = Y.get(e.texture);
5756
+ let t = X.get(e.texture);
5700
5757
  G.framebufferTexture2D(G.FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, t.__webglTexture, n);
5701
5758
  }
5702
5759
  ie = -1;
@@ -5705,45 +5762,45 @@ var Gr = class {
5705
5762
  S("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
5706
5763
  return;
5707
5764
  }
5708
- let c = Y.get(e).__webglFramebuffer;
5765
+ let c = X.get(e).__webglFramebuffer;
5709
5766
  if (e.isWebGLCubeRenderTarget && o !== void 0 && (c = c[o]), c) {
5710
- J.bindFramebuffer(G.FRAMEBUFFER, c);
5767
+ Y.bindFramebuffer(G.FRAMEBUFFER, c);
5711
5768
  try {
5712
5769
  let o = e.textures[s], c = o.format, l = o.type;
5713
- if (e.textures.length > 1 && G.readBuffer(G.COLOR_ATTACHMENT0 + s), !q.textureFormatReadable(c)) {
5770
+ if (e.textures.length > 1 && G.readBuffer(G.COLOR_ATTACHMENT0 + s), !J.textureFormatReadable(c)) {
5714
5771
  S("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
5715
5772
  return;
5716
5773
  }
5717
- if (!q.textureTypeReadable(l)) {
5774
+ if (!J.textureTypeReadable(l)) {
5718
5775
  S("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
5719
5776
  return;
5720
5777
  }
5721
- t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i && G.readPixels(t, n, r, i, it.convert(c), it.convert(l), a);
5778
+ t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i && G.readPixels(t, n, r, i, rt.convert(c), rt.convert(l), a);
5722
5779
  } finally {
5723
- let e = z === null ? null : Y.get(z).__webglFramebuffer;
5724
- J.bindFramebuffer(G.FRAMEBUFFER, e);
5780
+ let e = z === null ? null : X.get(z).__webglFramebuffer;
5781
+ Y.bindFramebuffer(G.FRAMEBUFFER, e);
5725
5782
  }
5726
5783
  }
5727
5784
  }, this.readRenderTargetPixelsAsync = async function(e, t, r, i, a, o, s, c = 0) {
5728
5785
  if (!(e && e.isWebGLRenderTarget)) throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
5729
- let l = Y.get(e).__webglFramebuffer;
5786
+ let l = X.get(e).__webglFramebuffer;
5730
5787
  if (e.isWebGLCubeRenderTarget && s !== void 0 && (l = l[s]), l) if (t >= 0 && t <= e.width - i && r >= 0 && r <= e.height - a) {
5731
- J.bindFramebuffer(G.FRAMEBUFFER, l);
5788
+ Y.bindFramebuffer(G.FRAMEBUFFER, l);
5732
5789
  let s = e.textures[c], u = s.format, d = s.type;
5733
- if (e.textures.length > 1 && G.readBuffer(G.COLOR_ATTACHMENT0 + c), !q.textureFormatReadable(u)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
5734
- if (!q.textureTypeReadable(d)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
5790
+ if (e.textures.length > 1 && G.readBuffer(G.COLOR_ATTACHMENT0 + c), !J.textureFormatReadable(u)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");
5791
+ if (!J.textureTypeReadable(d)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");
5735
5792
  let f = G.createBuffer();
5736
- G.bindBuffer(G.PIXEL_PACK_BUFFER, f), G.bufferData(G.PIXEL_PACK_BUFFER, o.byteLength, G.STREAM_READ), G.readPixels(t, r, i, a, it.convert(u), it.convert(d), 0);
5737
- let p = z === null ? null : Y.get(z).__webglFramebuffer;
5738
- J.bindFramebuffer(G.FRAMEBUFFER, p);
5793
+ G.bindBuffer(G.PIXEL_PACK_BUFFER, f), G.bufferData(G.PIXEL_PACK_BUFFER, o.byteLength, G.STREAM_READ), G.readPixels(t, r, i, a, rt.convert(u), rt.convert(d), 0);
5794
+ let p = z === null ? null : X.get(z).__webglFramebuffer;
5795
+ Y.bindFramebuffer(G.FRAMEBUFFER, p);
5739
5796
  let m = G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE, 0);
5740
5797
  return G.flush(), await n(G, m, 4), G.bindBuffer(G.PIXEL_PACK_BUFFER, f), G.getBufferSubData(G.PIXEL_PACK_BUFFER, 0, o), G.deleteBuffer(f), G.deleteSync(m), o;
5741
5798
  } else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.");
5742
5799
  }, this.copyFramebufferToTexture = function(e, t = null, n = 0) {
5743
5800
  let r = 2 ** -n, i = Math.floor(e.image.width * r), a = Math.floor(e.image.height * r), o = t === null ? 0 : t.x, s = t === null ? 0 : t.y;
5744
- X.setTexture2D(e, 0), G.copyTexSubImage2D(G.TEXTURE_2D, n, 0, 0, o, s, i, a), J.unbindTexture();
5801
+ Z.setTexture2D(e, 0), G.copyTexSubImage2D(G.TEXTURE_2D, n, 0, 0, o, s, i, a), Y.unbindTexture();
5745
5802
  };
5746
- let Rt = G.createFramebuffer(), zt = G.createFramebuffer();
5803
+ let zt = G.createFramebuffer(), Bt = G.createFramebuffer();
5747
5804
  this.copyTextureToTexture = function(e, t, n = null, r = null, i = 0, a = 0) {
5748
5805
  let o, s, c, l, u, d, f, p, m, h = e.isCompressedTexture ? e.mipmaps[a] : e.image;
5749
5806
  if (n !== null) o = n.max.x - n.min.x, s = n.max.y - n.min.y, c = n.isBox3 ? n.max.z - n.min.z : 1, l = n.min.x, u = n.min.y, d = n.isBox3 ? n.min.z : 0;
@@ -5752,33 +5809,33 @@ var Gr = class {
5752
5809
  o = Math.floor(h.width * t), s = Math.floor(h.height * t), c = e.isDataArrayTexture ? h.depth : e.isData3DTexture ? Math.floor(h.depth * t) : 1, l = 0, u = 0, d = 0;
5753
5810
  }
5754
5811
  r === null ? (f = 0, p = 0, m = 0) : (f = r.x, p = r.y, m = r.z);
5755
- let g = it.convert(t.format), _ = it.convert(t.type), v;
5756
- t.isData3DTexture ? (X.setTexture3D(t, 0), v = G.TEXTURE_3D) : t.isDataArrayTexture || t.isCompressedArrayTexture ? (X.setTexture2DArray(t, 0), v = G.TEXTURE_2D_ARRAY) : (X.setTexture2D(t, 0), v = G.TEXTURE_2D), G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL, t.flipY), G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultiplyAlpha), G.pixelStorei(G.UNPACK_ALIGNMENT, t.unpackAlignment);
5757
- let y = G.getParameter(G.UNPACK_ROW_LENGTH), b = G.getParameter(G.UNPACK_IMAGE_HEIGHT), x = G.getParameter(G.UNPACK_SKIP_PIXELS), S = G.getParameter(G.UNPACK_SKIP_ROWS), C = G.getParameter(G.UNPACK_SKIP_IMAGES);
5758
- G.pixelStorei(G.UNPACK_ROW_LENGTH, h.width), G.pixelStorei(G.UNPACK_IMAGE_HEIGHT, h.height), G.pixelStorei(G.UNPACK_SKIP_PIXELS, l), G.pixelStorei(G.UNPACK_SKIP_ROWS, u), G.pixelStorei(G.UNPACK_SKIP_IMAGES, d);
5812
+ let g = rt.convert(t.format), _ = rt.convert(t.type), v;
5813
+ t.isData3DTexture ? (Z.setTexture3D(t, 0), v = G.TEXTURE_3D) : t.isDataArrayTexture || t.isCompressedArrayTexture ? (Z.setTexture2DArray(t, 0), v = G.TEXTURE_2D_ARRAY) : (Z.setTexture2D(t, 0), v = G.TEXTURE_2D), Y.activeTexture(G.TEXTURE0), Y.pixelStorei(G.UNPACK_FLIP_Y_WEBGL, t.flipY), Y.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultiplyAlpha), Y.pixelStorei(G.UNPACK_ALIGNMENT, t.unpackAlignment);
5814
+ let y = Y.getParameter(G.UNPACK_ROW_LENGTH), b = Y.getParameter(G.UNPACK_IMAGE_HEIGHT), x = Y.getParameter(G.UNPACK_SKIP_PIXELS), S = Y.getParameter(G.UNPACK_SKIP_ROWS), C = Y.getParameter(G.UNPACK_SKIP_IMAGES);
5815
+ Y.pixelStorei(G.UNPACK_ROW_LENGTH, h.width), Y.pixelStorei(G.UNPACK_IMAGE_HEIGHT, h.height), Y.pixelStorei(G.UNPACK_SKIP_PIXELS, l), Y.pixelStorei(G.UNPACK_SKIP_ROWS, u), Y.pixelStorei(G.UNPACK_SKIP_IMAGES, d);
5759
5816
  let w = e.isDataArrayTexture || e.isData3DTexture, T = t.isDataArrayTexture || t.isData3DTexture;
5760
5817
  if (e.isDepthTexture) {
5761
- let n = Y.get(e), r = Y.get(t), h = Y.get(n.__renderTarget), g = Y.get(r.__renderTarget);
5762
- J.bindFramebuffer(G.READ_FRAMEBUFFER, h.__webglFramebuffer), J.bindFramebuffer(G.DRAW_FRAMEBUFFER, g.__webglFramebuffer);
5763
- for (let n = 0; n < c; n++) w && (G.framebufferTextureLayer(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, Y.get(e).__webglTexture, i, d + n), G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, Y.get(t).__webglTexture, a, m + n)), G.blitFramebuffer(l, u, o, s, f, p, o, s, G.DEPTH_BUFFER_BIT, G.NEAREST);
5764
- J.bindFramebuffer(G.READ_FRAMEBUFFER, null), J.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);
5765
- } else if (i !== 0 || e.isRenderTargetTexture || Y.has(e)) {
5766
- let n = Y.get(e), r = Y.get(t);
5767
- J.bindFramebuffer(G.READ_FRAMEBUFFER, Rt), J.bindFramebuffer(G.DRAW_FRAMEBUFFER, zt);
5818
+ let n = X.get(e), r = X.get(t), h = X.get(n.__renderTarget), g = X.get(r.__renderTarget);
5819
+ Y.bindFramebuffer(G.READ_FRAMEBUFFER, h.__webglFramebuffer), Y.bindFramebuffer(G.DRAW_FRAMEBUFFER, g.__webglFramebuffer);
5820
+ for (let n = 0; n < c; n++) w && (G.framebufferTextureLayer(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, X.get(e).__webglTexture, i, d + n), G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, X.get(t).__webglTexture, a, m + n)), G.blitFramebuffer(l, u, o, s, f, p, o, s, G.DEPTH_BUFFER_BIT, G.NEAREST);
5821
+ Y.bindFramebuffer(G.READ_FRAMEBUFFER, null), Y.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);
5822
+ } else if (i !== 0 || e.isRenderTargetTexture || X.has(e)) {
5823
+ let n = X.get(e), r = X.get(t);
5824
+ Y.bindFramebuffer(G.READ_FRAMEBUFFER, zt), Y.bindFramebuffer(G.DRAW_FRAMEBUFFER, Bt);
5768
5825
  for (let e = 0; e < c; e++) w ? G.framebufferTextureLayer(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, n.__webglTexture, i, d + e) : G.framebufferTexture2D(G.READ_FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, n.__webglTexture, i), T ? G.framebufferTextureLayer(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, r.__webglTexture, a, m + e) : G.framebufferTexture2D(G.DRAW_FRAMEBUFFER, G.COLOR_ATTACHMENT0, G.TEXTURE_2D, r.__webglTexture, a), i === 0 ? T ? G.copyTexSubImage3D(v, a, f, p, m + e, l, u, o, s) : G.copyTexSubImage2D(v, a, f, p, l, u, o, s) : G.blitFramebuffer(l, u, o, s, f, p, o, s, G.COLOR_BUFFER_BIT, G.NEAREST);
5769
- J.bindFramebuffer(G.READ_FRAMEBUFFER, null), J.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);
5826
+ Y.bindFramebuffer(G.READ_FRAMEBUFFER, null), Y.bindFramebuffer(G.DRAW_FRAMEBUFFER, null);
5770
5827
  } else T ? e.isDataTexture || e.isData3DTexture ? G.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h.data) : t.isCompressedArrayTexture ? G.compressedTexSubImage3D(v, a, f, p, m, o, s, c, g, h.data) : G.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h) : e.isDataTexture ? G.texSubImage2D(G.TEXTURE_2D, a, f, p, o, s, g, _, h.data) : e.isCompressedTexture ? G.compressedTexSubImage2D(G.TEXTURE_2D, a, f, p, h.width, h.height, g, h.data) : G.texSubImage2D(G.TEXTURE_2D, a, f, p, o, s, g, _, h);
5771
- G.pixelStorei(G.UNPACK_ROW_LENGTH, y), G.pixelStorei(G.UNPACK_IMAGE_HEIGHT, b), G.pixelStorei(G.UNPACK_SKIP_PIXELS, x), G.pixelStorei(G.UNPACK_SKIP_ROWS, S), G.pixelStorei(G.UNPACK_SKIP_IMAGES, C), a === 0 && t.generateMipmaps && G.generateMipmap(v), J.unbindTexture();
5828
+ Y.pixelStorei(G.UNPACK_ROW_LENGTH, y), Y.pixelStorei(G.UNPACK_IMAGE_HEIGHT, b), Y.pixelStorei(G.UNPACK_SKIP_PIXELS, x), Y.pixelStorei(G.UNPACK_SKIP_ROWS, S), Y.pixelStorei(G.UNPACK_SKIP_IMAGES, C), a === 0 && t.generateMipmaps && G.generateMipmap(v), Y.unbindTexture();
5772
5829
  }, this.initRenderTarget = function(e) {
5773
- Y.get(e).__webglFramebuffer === void 0 && X.setupRenderTarget(e);
5830
+ X.get(e).__webglFramebuffer === void 0 && Z.setupRenderTarget(e);
5774
5831
  }, this.initTexture = function(e) {
5775
- e.isCubeTexture ? X.setTextureCube(e, 0) : e.isData3DTexture ? X.setTexture3D(e, 0) : e.isDataArrayTexture || e.isCompressedArrayTexture ? X.setTexture2DArray(e, 0) : X.setTexture2D(e, 0), J.unbindTexture();
5832
+ e.isCubeTexture ? Z.setTextureCube(e, 0) : e.isData3DTexture ? Z.setTexture3D(e, 0) : e.isDataArrayTexture || e.isCompressedArrayTexture ? Z.setTexture2DArray(e, 0) : Z.setTexture2D(e, 0), Y.unbindTexture();
5776
5833
  }, this.resetState = function() {
5777
- R = 0, re = 0, z = null, J.reset(), at.reset();
5834
+ R = 0, re = 0, z = null, Y.reset(), it.reset();
5778
5835
  }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
5779
5836
  }
5780
5837
  get coordinateSystem() {
5781
- return Oe;
5838
+ return De;
5782
5839
  }
5783
5840
  get outputColorSpace() {
5784
5841
  return this._outputColorSpace;
@@ -5790,6 +5847,6 @@ var Gr = class {
5790
5847
  }
5791
5848
  };
5792
5849
  //#endregion
5793
- export { K as n, Gr as r, tt as t };
5850
+ export { K as n, Gr as r, $e as t };
5794
5851
 
5795
- //# sourceMappingURL=three.module-DkrZwaid.mjs.map
5852
+ //# sourceMappingURL=three.module-Q2K9uyhi.mjs.map