bg2e-js 2.3.12 → 2.3.14

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 (148) hide show
  1. package/dist/bg2e-js.js +460 -427
  2. package/dist/bg2e-js.js.map +1 -1
  3. package/package.json +56 -56
  4. package/src/app/AppController.ts +39 -39
  5. package/src/app/Bg2KeyboardEvent.ts +54 -54
  6. package/src/app/Bg2MouseEvent.ts +82 -82
  7. package/src/app/Bg2TouchEvent.ts +18 -18
  8. package/src/app/Canvas.ts +108 -108
  9. package/src/app/EventBase.ts +10 -10
  10. package/src/app/MainLoop.ts +273 -273
  11. package/src/app/index.ts +24 -24
  12. package/src/base/Color.ts +134 -134
  13. package/src/base/Environment.ts +183 -183
  14. package/src/base/Light.ts +192 -192
  15. package/src/base/Material.ts +620 -620
  16. package/src/base/PolyList.ts +378 -365
  17. package/src/base/Texture.ts +620 -620
  18. package/src/base/index.ts +81 -81
  19. package/src/db/Bg2LoaderPlugin.ts +143 -143
  20. package/src/db/DBPluginApi.ts +48 -48
  21. package/src/db/Loader.ts +116 -116
  22. package/src/db/LoaderPlugin.ts +34 -34
  23. package/src/db/MtlParser.ts +7 -7
  24. package/src/db/ObjLoaderPlugin.ts +54 -54
  25. package/src/db/ObjParser.ts +252 -252
  26. package/src/db/ObjWriterPlugin.ts +18 -18
  27. package/src/db/VitscnjLoaderPlugin.ts +112 -112
  28. package/src/db/Writer.ts +52 -52
  29. package/src/db/WriterPlugin.ts +22 -22
  30. package/src/db/index.ts +44 -44
  31. package/src/debug/DebugRenderer.ts +173 -173
  32. package/src/debug/WebGLTextureViewer.ts +75 -75
  33. package/src/debug/index.ts +6 -6
  34. package/src/index.html +11 -11
  35. package/src/index.ts +33 -33
  36. package/src/manipulation/SelectionBuffer.ts +81 -81
  37. package/src/manipulation/SelectionHighlight.ts +104 -84
  38. package/src/manipulation/SelectionIdAssignVisitor.ts +103 -96
  39. package/src/manipulation/SelectionManager.ts +200 -196
  40. package/src/manipulation/SelectionMode.ts +6 -6
  41. package/src/math/Mat3.ts +259 -259
  42. package/src/math/Mat4.ts +710 -710
  43. package/src/math/MatrixStrategy.ts +25 -25
  44. package/src/math/Quat.ts +65 -65
  45. package/src/math/Vec.ts +753 -753
  46. package/src/math/constants.ts +46 -46
  47. package/src/math/functions.ts +103 -103
  48. package/src/math/index.ts +74 -74
  49. package/src/phsics/joint.ts +137 -137
  50. package/src/primitives/arrow.ts +57 -57
  51. package/src/primitives/cone.ts +138 -138
  52. package/src/primitives/cube.ts +60 -60
  53. package/src/primitives/cylinder.ts +216 -216
  54. package/src/primitives/index.ts +13 -13
  55. package/src/primitives/plane.ts +31 -31
  56. package/src/primitives/sphere.ts +809 -809
  57. package/src/react/useBg2e.ts +69 -69
  58. package/src/render/BRDFIntegrationMap.ts +4 -4
  59. package/src/render/Environment.ts +135 -135
  60. package/src/render/FrameBuffer.ts +35 -35
  61. package/src/render/MaterialRenderer.ts +34 -34
  62. package/src/render/Pipeline.ts +108 -108
  63. package/src/render/PolyListRenderer.ts +47 -47
  64. package/src/render/RenderBuffer.ts +197 -197
  65. package/src/render/RenderQueue.ts +198 -198
  66. package/src/render/RenderState.ts +116 -116
  67. package/src/render/Renderer.ts +248 -248
  68. package/src/render/SceneAppController.ts +250 -250
  69. package/src/render/SceneRenderer.ts +387 -387
  70. package/src/render/Shader.ts +32 -32
  71. package/src/render/ShadowRenderer.ts +176 -176
  72. package/src/render/SkyCube.ts +105 -105
  73. package/src/render/SkySphere.ts +117 -117
  74. package/src/render/TextureMergerRenderer.ts +70 -70
  75. package/src/render/TextureRenderer.ts +34 -34
  76. package/src/render/index.ts +67 -67
  77. package/src/render/webgl/FrameBuffer.ts +9 -9
  78. package/src/render/webgl/MaterialRenderer.ts +112 -112
  79. package/src/render/webgl/Pipeline.ts +88 -88
  80. package/src/render/webgl/PolyListRenderer.ts +260 -260
  81. package/src/render/webgl/RenderBuffer.ts +226 -226
  82. package/src/render/webgl/Renderer.ts +262 -262
  83. package/src/render/webgl/SceneRenderer.ts +67 -67
  84. package/src/render/webgl/ShaderProgram.ts +424 -424
  85. package/src/render/webgl/ShadowRenderer.ts +6 -6
  86. package/src/render/webgl/SkyCube.ts +15 -15
  87. package/src/render/webgl/SkySphere.ts +15 -15
  88. package/src/render/webgl/State.ts +152 -152
  89. package/src/render/webgl/TextureRenderer.ts +167 -167
  90. package/src/render/webgl/VertexBuffer.ts +137 -137
  91. package/src/render/webgl/index.ts +35 -35
  92. package/src/scene/Camera.ts +458 -458
  93. package/src/scene/Chain.ts +44 -44
  94. package/src/scene/ChainJoint.ts +58 -58
  95. package/src/scene/Component.ts +177 -177
  96. package/src/scene/ComponentMap.ts +106 -106
  97. package/src/scene/Drawable.ts +158 -154
  98. package/src/scene/EnvironmentComponent.ts +141 -141
  99. package/src/scene/FindNodeVisitor.ts +59 -59
  100. package/src/scene/LightComponent.ts +154 -154
  101. package/src/scene/MatrixState.ts +46 -46
  102. package/src/scene/Node.ts +328 -328
  103. package/src/scene/NodeVisitor.ts +15 -15
  104. package/src/scene/OrbitCameraController.ts +450 -450
  105. package/src/scene/SmoothOrbitCameraController.ts +99 -99
  106. package/src/scene/Transform.ts +73 -73
  107. package/src/scene/index.ts +60 -60
  108. package/src/shaders/BasicDiffuseColorShader.ts +111 -111
  109. package/src/shaders/BasicPBRLightShader.ts +276 -276
  110. package/src/shaders/DebugRenderShader.ts +97 -97
  111. package/src/shaders/DepthRenderShader.ts +127 -127
  112. package/src/shaders/IrradianceMapCubeShader.ts +115 -115
  113. package/src/shaders/PBRLightIBLShader.ts +486 -486
  114. package/src/shaders/PickSelectionShader.ts +101 -101
  115. package/src/shaders/PresentDebugFramebufferShader.ts +118 -118
  116. package/src/shaders/PresentTextureShader.ts +99 -99
  117. package/src/shaders/SelectionHighlightShader.ts +143 -127
  118. package/src/shaders/ShaderFunction.ts +318 -318
  119. package/src/shaders/SkyCubeShader.ts +93 -93
  120. package/src/shaders/SkySphereShader.ts +102 -102
  121. package/src/shaders/SpecularMapCubeShader.ts +164 -164
  122. package/src/shaders/TextureMergerShader.ts +171 -171
  123. package/src/shaders/index.ts +36 -36
  124. package/src/shaders/webgl/color_correction.glsl +47 -47
  125. package/src/shaders/webgl/constants.glsl +6 -6
  126. package/src/shaders/webgl/index.ts +70 -70
  127. package/src/shaders/webgl/normal_map.glsl +9 -9
  128. package/src/shaders/webgl/pbr.glsl +173 -173
  129. package/src/shaders/webgl/uniforms.glsl +91 -91
  130. package/src/shaders/webgl_shader_lib.ts +213 -213
  131. package/src/tools/BinaryResourceProvider.ts +14 -14
  132. package/src/tools/ImageResourceProvider.ts +66 -66
  133. package/src/tools/MaterialModifier.ts +446 -446
  134. package/src/tools/Resource.ts +203 -203
  135. package/src/tools/ResourceProvider.ts +69 -69
  136. package/src/tools/TextResourceProvider.ts +24 -24
  137. package/src/tools/TextureCache.ts +51 -51
  138. package/src/tools/TextureResourceDatabase.ts +100 -100
  139. package/src/tools/UserAgent.ts +362 -362
  140. package/src/tools/VideoResourceProvider.ts +50 -50
  141. package/src/tools/WriteStrategy.ts +22 -22
  142. package/src/tools/base64.ts +11 -11
  143. package/src/tools/crypto.ts +19 -19
  144. package/src/tools/endiantess.ts +13 -13
  145. package/src/tools/image.ts +18 -18
  146. package/src/tools/index.ts +41 -41
  147. package/src/tools/processType.ts +39 -39
  148. package/src/vite-env.d.ts +12 -12
package/dist/bg2e-js.js CHANGED
@@ -1,4 +1,4 @@
1
- var ct = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.Y = 2] = "Y", t[t.Z = 3] = "Z", t[t.W = 4] = "W", t))(ct || {});
1
+ var gt = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.Y = 2] = "Y", t[t.Z = 3] = "Z", t[t.W = 4] = "W", t))(gt || {});
2
2
  ((t) => {
3
3
  function e(r) {
4
4
  switch (r) {
@@ -17,11 +17,11 @@ var ct = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.X = 1] = "X", t[t.
17
17
  }
18
18
  }
19
19
  t.name = e;
20
- })(ct || (ct = {}));
21
- const _r = 3.141592653589793, $r = 0.01745329251994, ei = 57.29577951308233, qn = 1.5707963267948966, _n = 0.785398163397448, $n = 0.392699081698724, es = 6.283185307179586, gt = 1e-7, Le = Float32Array, ts = Float64Array, rs = 3402823e32, Ge = (t, e) => t.length >= e;
20
+ })(gt || (gt = {}));
21
+ const _r = 3.141592653589793, $r = 0.01745329251994, ei = 57.29577951308233, qn = 1.5707963267948966, _n = 0.785398163397448, $n = 0.392699081698724, es = 6.283185307179586, ut = 1e-7, Le = Float32Array, ts = Float64Array, rs = 3402823e32, Ge = (t, e) => t.length >= e;
22
22
  let Ft = Date.now();
23
- const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, le = (t) => t > -gt && t < gt ? 0 : t, b = (t) => le(t) === 0, E = (t, e) => Math.abs(t - e) < gt, We = (t) => Math.fround(le(t * $r)), ti = (t) => Math.fround(le(t * ei)), ns = (t) => Math.fround(le(Math.sin(t))), ss = (t) => Math.fround(le(Math.cos(t))), ri = (t) => Math.fround(le(Math.tan(t))), os = (t) => Math.fround(le(1 / ri(t))), as = (t) => Math.fround(le(Math.atan(t))), hs = (t, e) => Math.fround(le(Math.atan2(t, e))), As = () => Math.random(), fs = () => (Ft = (Ft * 9301 + 49297) % 233280, 0 + Ft / 233280 * 1), ls = (t, e) => Math.fround(Math.max(t, e)), cs = (t, e) => Math.fround(Math.min(t, e)), gs = (t) => Math.fround(Math.abs(t)), us = (t) => Math.fround(Math.sqrt(t)), J = (t, e, r) => (r = r > 1 ? 1 : r, Math.fround((1 - r) * t + r * e)), ds = (t) => Math.fround(t * t), Z = (t, e, r) => Math.fround(Math.max(e, Math.min(t, r))), ws = {
24
- Axis: ct,
23
+ const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, le = (t) => t > -ut && t < ut ? 0 : t, b = (t) => le(t) === 0, E = (t, e) => Math.abs(t - e) < ut, We = (t) => Math.fround(le(t * $r)), ti = (t) => Math.fround(le(t * ei)), ns = (t) => Math.fround(le(Math.sin(t))), ss = (t) => Math.fround(le(Math.cos(t))), ri = (t) => Math.fround(le(Math.tan(t))), os = (t) => Math.fround(le(1 / ri(t))), as = (t) => Math.fround(le(Math.atan(t))), hs = (t, e) => Math.fround(le(Math.atan2(t, e))), As = () => Math.random(), fs = () => (Ft = (Ft * 9301 + 49297) % 233280, 0 + Ft / 233280 * 1), ls = (t, e) => Math.fround(Math.max(t, e)), cs = (t, e) => Math.fround(Math.min(t, e)), gs = (t) => Math.fround(Math.abs(t)), us = (t) => Math.fround(Math.sqrt(t)), J = (t, e, r) => (r = r > 1 ? 1 : r, Math.fround((1 - r) * t + r * e)), ds = (t) => Math.fround(t * t), Z = (t, e, r) => Math.fround(Math.max(e, Math.min(t, r))), ws = {
24
+ Axis: gt,
25
25
  PI: _r,
26
26
  DEG_TO_RAD: $r,
27
27
  RAD_TO_DEG: ei,
@@ -29,7 +29,7 @@ const is = (t) => typeof t != "number" ? !1 : t !== 0 && (t & t - 1) === 0, le =
29
29
  PI_4: _n,
30
30
  PI_8: $n,
31
31
  TWO_PI: es,
32
- EPSILON: gt,
32
+ EPSILON: ut,
33
33
  NumericArray: Le,
34
34
  NumericArrayHighP: ts,
35
35
  FLOAT_MAX: rs,
@@ -1447,7 +1447,7 @@ const Cs = (t) => {
1447
1447
  return "Browser";
1448
1448
  }
1449
1449
  }, ar = () => 0, ps = () => ar() === 0, Ds = () => ar() === 1, bs = async (t) => new Uint8Array(atob(t).split("").map((e) => e.charCodeAt(0)));
1450
- class Ze {
1450
+ class qe {
1451
1451
  set writeStrategy(e) {
1452
1452
  this._writeStrategy = e;
1453
1453
  }
@@ -1494,7 +1494,7 @@ const Gt = (t) => {
1494
1494
  Gt(s.target), i(new Error(`Image load aborted '${t}'.`));
1495
1495
  }), n.src = t + (e ? `?${Pt()}` : "");
1496
1496
  });
1497
- class ai extends Ze {
1497
+ class ai extends qe {
1498
1498
  async load(e) {
1499
1499
  return await Es(e, !1);
1500
1500
  }
@@ -1513,7 +1513,7 @@ const Ut = (t) => {
1513
1513
  Ut(n.target), r(new Error(`Video load aborted '${t}'`));
1514
1514
  }), i.src = t;
1515
1515
  });
1516
- class hi extends Ze {
1516
+ class hi extends qe {
1517
1517
  async load(e) {
1518
1518
  return await xs(e);
1519
1519
  }
@@ -1521,7 +1521,7 @@ class hi extends Ze {
1521
1521
  throw new Error("VideoResourceProvider.write(): not supported");
1522
1522
  }
1523
1523
  }
1524
- class Ai extends Ze {
1524
+ class Ai extends qe {
1525
1525
  async load(e) {
1526
1526
  const r = await fetch(e);
1527
1527
  if (r.ok)
@@ -1529,7 +1529,7 @@ class Ai extends Ze {
1529
1529
  throw new Error(`Resource not found at '${e}'`);
1530
1530
  }
1531
1531
  }
1532
- class fi extends Ze {
1532
+ class fi extends qe {
1533
1533
  async load(e) {
1534
1534
  const r = await fetch(e);
1535
1535
  if (r.ok) {
@@ -1581,7 +1581,7 @@ const Qs = (t) => {
1581
1581
  ], di = (t) => Bt(t, cr), zs = (t) => {
1582
1582
  Ct(t, cr);
1583
1583
  }, Ls = () => cr;
1584
- class qe {
1584
+ class _e {
1585
1585
  constructor({
1586
1586
  imageProvider: e = null,
1587
1587
  videoProvider: r = null,
@@ -1622,7 +1622,7 @@ const Is = {
1622
1622
  isBigEndian: ms,
1623
1623
  isLittleEndian: Ps,
1624
1624
  UserAgent: Bs,
1625
- Resource: qe,
1625
+ Resource: _e,
1626
1626
  isFormat: Bt,
1627
1627
  addFormats: Ct,
1628
1628
  isValidImage: gi,
@@ -1634,7 +1634,7 @@ const Is = {
1634
1634
  isValidBinary: di,
1635
1635
  addBinaryFormats: zs,
1636
1636
  getValidBinaryFormats: Ls,
1637
- ResourceProvider: Ze,
1637
+ ResourceProvider: qe,
1638
1638
  ImageResourceProvider: ai,
1639
1639
  VideoResourceProvider: hi,
1640
1640
  BinaryResourceProvider: Ai,
@@ -1804,7 +1804,7 @@ class p extends h {
1804
1804
  }
1805
1805
  var wi = /* @__PURE__ */ ((t) => (t[t.VERTEX = 1] = "VERTEX", t[t.NORMAL = 2] = "NORMAL", t[t.TEX_COORD_0 = 4] = "TEX_COORD_0", t[t.TEX_COORD_1 = 8] = "TEX_COORD_1", t[t.TEX_COORD_2 = 16] = "TEX_COORD_2", t[t.COLOR = 32] = "COLOR", t[t.TANGENT = 64] = "TANGENT", t[t.INDEX = 128] = "INDEX", t))(wi || {}), ae = /* @__PURE__ */ ((t) => (t[t.POINTS = 0] = "POINTS", t[t.TRIANGLES = 1] = "TRIANGLES", t[t.TRIANGLE_FAN = 2] = "TRIANGLE_FAN", t[t.TRIANGLE_STRIP = 3] = "TRIANGLE_STRIP", t[t.LINES = 4] = "LINES", t[t.LINE_STRIP = 5] = "LINE_STRIP", t))(ae || {}), k = /* @__PURE__ */ ((t) => (t[t.LAYER_0 = 1] = "LAYER_0", t[t.OPAQUE_DEFAULT = 1] = "OPAQUE_DEFAULT", t[t.LAYER_1 = 2] = "LAYER_1", t[t.LAYER_2 = 4] = "LAYER_2", t[t.LAYER_3 = 8] = "LAYER_3", t[t.LAYER_4 = 16] = "LAYER_4", t[t.LAYER_5 = 32] = "LAYER_5", t[t.LAYER_6 = 64] = "LAYER_6", t[t.LAYER_7 = 128] = "LAYER_7", t[t.LAYER_8 = 256] = "LAYER_8", t[t.LAYER_9 = 512] = "LAYER_9", t[t.LAYER_10 = 1024] = "LAYER_10", t[t.LAYER_11 = 2048] = "LAYER_11", t[t.LAYER_12 = 4096] = "LAYER_12", t[t.LAYER_13 = 8192] = "LAYER_13", t[t.LAYER_14 = 16384] = "LAYER_14", t[t.LAYER_15 = 32768] = "LAYER_15", t[t.TRANSPARENT_DEFAULT = 32768] = "TRANSPARENT_DEFAULT", t[t.LAYER_16 = 65536] = "LAYER_16", t[t.LAYER_17 = 131072] = "LAYER_17", t[t.LAYER_18 = 262144] = "LAYER_18", t[t.LAYER_19 = 524288] = "LAYER_19", t[t.LAYER_20 = 1048576] = "LAYER_20", t[t.LAYER_21 = 2097152] = "LAYER_21", t[t.LAYER_22 = 4194304] = "LAYER_22", t[t.LAYER_23 = 8388608] = "LAYER_23", t[t.LAYER_24 = 16777216] = "LAYER_24", t[t.LAYER_25 = 33554432] = "LAYER_25", t[t.LAYER_26 = 67108864] = "LAYER_26", t[t.LAYER_27 = 134217728] = "LAYER_27", t[t.LAYER_28 = 268435456] = "LAYER_28", t[t.LAYER_29 = 536870912] = "LAYER_29", t[t.LAYER_30 = 1073741824] = "LAYER_30", t[t.LAYER_31 = -2147483648] = "LAYER_31", t[t.SELECTION_DEFAULT = -2147483648] = "SELECTION_DEFAULT", t[t.ALL = 4294967295] = "ALL", t[t.AUTO = 0] = "AUTO", t))(k || {});
1806
1806
  const vi = (t, e) => t.renderLayers === 0 ? (e.isTransparent ? 32768 : 1) | -2147483648 : t.renderLayers;
1807
- var ut = /* @__PURE__ */ ((t) => (t[t.CW = 0] = "CW", t[t.CCW = 1] = "CCW", t))(ut || {}), De = /* @__PURE__ */ ((t) => (t[t.FRONT = 0] = "FRONT", t[t.BACK = 1] = "BACK", t[t.FRONT_AND_BACK = 2] = "FRONT_AND_BACK", t))(De || {});
1807
+ var dt = /* @__PURE__ */ ((t) => (t[t.CW = 0] = "CW", t[t.CCW = 1] = "CCW", t))(dt || {}), De = /* @__PURE__ */ ((t) => (t[t.FRONT = 0] = "FRONT", t[t.BACK = 1] = "BACK", t[t.FRONT_AND_BACK = 2] = "FRONT_AND_BACK", t))(De || {});
1808
1808
  function yr(t) {
1809
1809
  const e = [], r = (s) => ({
1810
1810
  pos: new h(t.vertex[s] * 3, t.vertex[s + 1] * 3, t.vertex[s + 2] * 3),
@@ -1967,6 +1967,15 @@ class de {
1967
1967
  set selectable(e) {
1968
1968
  this._selectable = e;
1969
1969
  }
1970
+ // The mainDrawable is a reference to the las Drawable object that contains this polyList. Note that
1971
+ // in some circunstances a polyList can be shared by several Drawable objects, but the mainDrawable
1972
+ // will be the last one that was assigned.
1973
+ get mainDrawable() {
1974
+ return this._mainDrawable;
1975
+ }
1976
+ set mainDrawable(e) {
1977
+ this._mainDrawable = e;
1978
+ }
1970
1979
  // The this._renderer variable is initialized by the polyListRenderer factory
1971
1980
  get renderer() {
1972
1981
  return this._renderer;
@@ -2022,15 +2031,15 @@ const Ss = (t, e = "image/jpeg") => {
2022
2031
  radiusY: n.radiusY
2023
2032
  }));
2024
2033
  };
2025
- let rt = null;
2026
- class _e {
2034
+ let it = null;
2035
+ class $e {
2027
2036
  static FirstCanvas() {
2028
- if (!rt)
2037
+ if (!it)
2029
2038
  throw new Error("No Canvas instance has been created yet.");
2030
- return rt;
2039
+ return it;
2031
2040
  }
2032
2041
  constructor(e, r) {
2033
- this._renderer = r, this._domElement = e, this._domElement._bg2e_id = Pt(), rt = rt || this, this._mainLoop = null;
2042
+ this._renderer = r, this._domElement = e, this._domElement._bg2e_id = Pt(), it = it || this, this._mainLoop = null;
2034
2043
  }
2035
2044
  get id() {
2036
2045
  return this._domElement._bg2e_id;
@@ -2128,9 +2137,9 @@ const Ci = Object.freeze({
2128
2137
  2: "G",
2129
2138
  3: "B",
2130
2139
  4: "A"
2131
- }), it = {};
2140
+ }), nt = {};
2132
2141
  let Xt = null;
2133
- const kt = {}, Rs = async (t) => (Xt || (Xt = new qe()), kt[t] ? console.log(`Image already loaded or loading: ${t}`) : (console.log(`Loading image: ${t}`), kt[t] = new Promise(async (e, r) => {
2142
+ const kt = {}, Rs = async (t) => (Xt || (Xt = new _e()), kt[t] ? console.log(`Image already loaded or loading: ${t}`) : (console.log(`Loading image: ${t}`), kt[t] = new Promise(async (e, r) => {
2134
2143
  const i = await Xt?.load(t), n = document.createElement("canvas");
2135
2144
  n.width = i.naturalWidth, n.height = i.naturalHeight;
2136
2145
  const s = n.getContext("2d");
@@ -2184,7 +2193,7 @@ function ks(t) {
2184
2193
  }
2185
2194
  class x {
2186
2195
  constructor(e = null) {
2187
- const r = e || _e.FirstCanvas();
2196
+ const r = e || $e.FirstCanvas();
2188
2197
  if (!r)
2189
2198
  throw new Error("Error creating Texture: no Canvas available.");
2190
2199
  this._canvas = r, this._dirty = !0, this._dataType = 0, this._wrapModeX = 0, this._wrapModeY = 0, this._magFilter = 5, this._minFilter = 5, this._target = 0, this._size = new h(64, 64), this._fileName = "", this._proceduralFunction = 0, this._proceduralParameters = {}, this._renderTargetAttachment = 0, this._componentFormat = 0, this._imageData = null, this._references = 0, this._name = "";
@@ -2325,9 +2334,9 @@ class x {
2325
2334
  }
2326
2335
  async loadImageData(e = !1) {
2327
2336
  if (this.fileName) {
2328
- it[this.fileName] && e && delete it[this.fileName];
2329
- let r = it[this.fileName];
2330
- r ? console.debug(`Texture: loadImageData(): image already loaded or is loading: ${this.fileName}`) : (r = Rs(this.fileName), it[this.fileName] = r), this._imageData = await r, this._size = new h(this._imageData.width, this._imageData.height), this._dirty = !0;
2337
+ nt[this.fileName] && e && delete nt[this.fileName];
2338
+ let r = nt[this.fileName];
2339
+ r ? console.debug(`Texture: loadImageData(): image already loaded or is loading: ${this.fileName}`) : (r = Rs(this.fileName), nt[this.fileName] = r), this._imageData = await r, this._size = new h(this._imageData.width, this._imageData.height), this._dirty = !0;
2331
2340
  } else if (this.dataType === 7)
2332
2341
  this._imageData = {
2333
2342
  currentSize: new h(this.size)
@@ -2367,9 +2376,9 @@ class x {
2367
2376
  }
2368
2377
  }
2369
2378
  const ye = {};
2370
- class dt {
2379
+ class wt {
2371
2380
  static Get(e = null) {
2372
- return e = e || _e.FirstCanvas(), !e && !ye.__no_canvas__ && console.warn("TextureCache.Get() No canvas available. If your application uses a canvas, ensure that it has been created before using TexturCache. If your application does not use a canvas, you may disregard this message."), e && !ye[e.id] ? ye[e.id] = new dt(e) : !e && !ye.__no_canvas__ && (ye.__no_canvas__ = new dt(null)), ye[e ? e.id : "__no_canvas__"];
2381
+ return e = e || $e.FirstCanvas(), !e && !ye.__no_canvas__ && console.warn("TextureCache.Get() No canvas available. If your application uses a canvas, ensure that it has been created before using TexturCache. If your application does not use a canvas, you may disregard this message."), e && !ye[e.id] ? ye[e.id] = new wt(e) : !e && !ye.__no_canvas__ && (ye.__no_canvas__ = new wt(null)), ye[e ? e.id : "__no_canvas__"];
2373
2382
  }
2374
2383
  constructor(e) {
2375
2384
  this._canvas = e, this._cache = {};
@@ -2405,7 +2414,7 @@ const Ce = {
2405
2414
  if (t === "ambientOcclussion" && typeof e == "number")
2406
2415
  return null;
2407
2416
  if (typeof e == "string") {
2408
- const n = r + e, s = dt.Get(i);
2417
+ const n = r + e, s = wt.Get(i);
2409
2418
  if (s.findTexture(n))
2410
2419
  return console.debug(`Texture '${n}' already loaded. Reusing texture.`), s.getTexture(n);
2411
2420
  {
@@ -2417,7 +2426,7 @@ const Ce = {
2417
2426
  throw new Error("Invalid parameter found in material deserialization. The required parameter type is string (file path)");
2418
2427
  } else return null;
2419
2428
  }
2420
- }, nt = {
2429
+ }, st = {
2421
2430
  serialize: (t, e) => {
2422
2431
  if (!e)
2423
2432
  return null;
@@ -2456,11 +2465,11 @@ const Ce = {
2456
2465
  }, S = {
2457
2466
  serialize: (t, e) => e || null,
2458
2467
  deserialize: (t, e) => e
2459
- }, st = {
2468
+ }, ot = {
2460
2469
  type: { loader: S },
2461
2470
  alphaCutoff: { loader: S },
2462
2471
  isTransparent: { loader: S },
2463
- albedo: { loader: nt },
2472
+ albedo: { loader: st },
2464
2473
  albedoTexture: { loader: Ce },
2465
2474
  albedoScale: { loader: Me },
2466
2475
  albedoUV: { loader: S },
@@ -2477,10 +2486,10 @@ const Ce = {
2477
2486
  roughnessChannel: { loader: S },
2478
2487
  roughnessScale: { loader: Me },
2479
2488
  roughnessUV: { loader: S },
2480
- fresnelTint: { loader: nt },
2489
+ fresnelTint: { loader: st },
2481
2490
  sheenIntensity: { loader: S },
2482
- sheenColor: { loader: nt },
2483
- lightEmission: { loader: nt },
2491
+ sheenColor: { loader: st },
2492
+ lightEmission: { loader: st },
2484
2493
  lightEmissionTexture: { loader: Ce },
2485
2494
  lightEmissionChannel: { loader: S },
2486
2495
  lightEmissionScale: { loader: Me },
@@ -2511,7 +2520,7 @@ class ne {
2511
2520
  return await n.deserialize(e, r, i), n;
2512
2521
  }
2513
2522
  constructor(e = null) {
2514
- this._canvas = e || _e.FirstCanvas(), this._type = "pbr", this._renderer = null, this._alphaCutoff = 0.5, this._isTransparent = !1, this._albedo = p.White(), this._albedoTexture = null, this._albedoScale = new h(1, 1), this._albedoUV = 0, this._normalTexture = null, this._normalScale = new h(1, 1), this._normalUV = 0, this._normalChannel = 0, this._metalness = 0, this._metalnessTexture = null, this._metalnessChannel = 0, this._metalnessScale = new h(1, 1), this._metalnessUV = 0, this._roughness = 1, this._roughnessTexture = null, this._roughnessChannel = 0, this._roughnessScale = new h(1, 1), this._roughnessUV = 0, this._fresnelTint = p.White(), this._sheenIntensity = 0, this._sheenColor = p.White(), this._lightEmission = 0, this._lightEmissionTexture = null, this._lightEmissionChannel = 0, this._lightEmissionScale = new h(1, 1), this._lightEmissionUV = 0, this._ambientOcclussion = null, this._ambientOcclussionChannel = 0, this._ambientOcclussionUV = 1, this._heightTexture = null, this._heightChannel = 0, this._heightScale = new h(1, 1), this._heightUV = 0, this._heightIntensity = 1, this._castShadows = !0, this._unlit = !1, this._dirty = !0;
2523
+ this._canvas = e || $e.FirstCanvas(), this._type = "pbr", this._renderer = null, this._alphaCutoff = 0.5, this._isTransparent = !1, this._albedo = p.White(), this._albedoTexture = null, this._albedoScale = new h(1, 1), this._albedoUV = 0, this._normalTexture = null, this._normalScale = new h(1, 1), this._normalUV = 0, this._normalChannel = 0, this._metalness = 0, this._metalnessTexture = null, this._metalnessChannel = 0, this._metalnessScale = new h(1, 1), this._metalnessUV = 0, this._roughness = 1, this._roughnessTexture = null, this._roughnessChannel = 0, this._roughnessScale = new h(1, 1), this._roughnessUV = 0, this._fresnelTint = p.White(), this._sheenIntensity = 0, this._sheenColor = p.White(), this._lightEmission = 0, this._lightEmissionTexture = null, this._lightEmissionChannel = 0, this._lightEmissionScale = new h(1, 1), this._lightEmissionUV = 0, this._ambientOcclussion = null, this._ambientOcclussionChannel = 0, this._ambientOcclussionUV = 1, this._heightTexture = null, this._heightChannel = 0, this._heightScale = new h(1, 1), this._heightUV = 0, this._heightIntensity = 1, this._castShadows = !0, this._unlit = !1, this._dirty = !0;
2515
2524
  }
2516
2525
  get canvas() {
2517
2526
  return this._canvas;
@@ -2767,16 +2776,16 @@ class ne {
2767
2776
  this._unlit = e, this._dirty = !0;
2768
2777
  }
2769
2778
  async serialize(e) {
2770
- for (const r in st) {
2771
- const i = st[r].loader.serialize(r, this[r]);
2779
+ for (const r in ot) {
2780
+ const i = ot[r].loader.serialize(r, this[r]);
2772
2781
  i && (e[r] = i);
2773
2782
  }
2774
2783
  }
2775
2784
  async deserialize(e, r, i) {
2776
2785
  const n = [];
2777
2786
  this.type = e.type || "pbr", this.alphaCutoff = e.alphaCutoff || 0.5, this.isTransparent = e.isTransparent || !1;
2778
- for (const s in st) {
2779
- const o = st[s]?.loader;
2787
+ for (const s in ot) {
2788
+ const o = ot[s]?.loader;
2780
2789
  if (o) {
2781
2790
  const a = o.deserialize(s, e[s], r, this.canvas);
2782
2791
  a instanceof x && n.push(a.loadImageData()), a != null && (this[s] = a);
@@ -3281,7 +3290,7 @@ function qs(t) {
3281
3290
  let e = /s\s+(.*)/.exec(t);
3282
3291
  e && this._currentPlist?.name == "" && (this._currentPlist.name = e[1]);
3283
3292
  }
3284
- function ot() {
3293
+ function at() {
3285
3294
  this._addPlist && (this._currentPlist && this._plistArray.push(this._currentPlist), this._currentPlist = new de(), this._addPlist = !1);
3286
3295
  }
3287
3296
  function _s() {
@@ -3306,13 +3315,13 @@ function _s() {
3306
3315
  ) : console.warn("Error parsing line " + r);
3307
3316
  break;
3308
3317
  case "m":
3309
- ot.apply(this), js.apply(this, [r]);
3318
+ at.apply(this), js.apply(this, [r]);
3310
3319
  break;
3311
3320
  case "g":
3312
- ot.apply(this), Vs.apply(this, [r]);
3321
+ at.apply(this), Vs.apply(this, [r]);
3313
3322
  break;
3314
3323
  case "u":
3315
- ot.apply(this), Ks.apply(this, [r]);
3324
+ at.apply(this), Ks.apply(this, [r]);
3316
3325
  break;
3317
3326
  case "s":
3318
3327
  Ws.apply(this, [r]);
@@ -3321,7 +3330,7 @@ function _s() {
3321
3330
  Zs.apply(this, [r]);
3322
3331
  break;
3323
3332
  case "o":
3324
- ot.apply(this), qs.apply(this, [r]);
3333
+ at.apply(this), qs.apply(this, [r]);
3325
3334
  break;
3326
3335
  }
3327
3336
  }), this._currentPlist && this._addPlist && this._plistArray.push(this._currentPlist);
@@ -4929,10 +4938,10 @@ const Ir = {
4929
4938
  gl_FragColor = result;
4930
4939
  }`
4931
4940
  }
4932
- }, at = {};
4941
+ }, ht = {};
4933
4942
  class bt extends V {
4934
4943
  static GetUnique(e) {
4935
- return at[e.uniqueId] || (at[e.uniqueId] = new bt(e), at[e.uniqueId].load()), at[e.uniqueId];
4944
+ return ht[e.uniqueId] || (ht[e.uniqueId] = new bt(e), ht[e.uniqueId].load()), ht[e.uniqueId];
4936
4945
  }
4937
4946
  constructor(e) {
4938
4947
  if (super(e), e.typeId !== "WebGL")
@@ -5648,7 +5657,7 @@ class Ui extends pt {
5648
5657
  throw new Error(`VitscnjLoaderPlugin.load() unexpected resource type received: ${r}`);
5649
5658
  const n = i.currentPath;
5650
5659
  i.currentPath = li(e);
5651
- const s = new qe(), o = new fe("Scene Root"), { scene: a } = await s.load(e);
5660
+ const s = new _e(), o = new fe("Scene Root"), { scene: a } = await s.load(e);
5652
5661
  for (const f of a) {
5653
5662
  const c = await Gi(f, i);
5654
5663
  o.addChild(c);
@@ -5695,10 +5704,10 @@ class Oe extends se {
5695
5704
  throw new Error("Error adding polyList to drawable object: material is not an instance of Material");
5696
5705
  if (!(i instanceof w))
5697
5706
  throw new Error("Error adding polyList to drawable object: transform is not an instance of Mat4");
5698
- this._items.push({ polyList: e, material: r, transform: i });
5707
+ this._items.push({ polyList: e, material: r, transform: i }), e.mainDrawable = this;
5699
5708
  }
5700
5709
  removePolyList(e) {
5701
- this._items = this._items.filter((r) => r.polyList != e);
5710
+ this._items = this._items.filter((r) => r.polyList != e), e.mainDrawable === this && (e.mainDrawable = void 0);
5702
5711
  }
5703
5712
  destroy() {
5704
5713
  }
@@ -5905,11 +5914,11 @@ var mo = async ({ debug: t = !1, wasmPath: e = "" } = {}) => {
5905
5914
  const r = await Bg2ioModule();
5906
5915
  return new wo({ instance: r, debug: t });
5907
5916
  };
5908
- let ht = null;
5917
+ let At = null;
5909
5918
  const Po = async (t) => {
5910
- if (ht === null && (ht = await mo(t ? { wasmPath: t } : {}), !ht))
5919
+ if (At === null && (At = await mo(t ? { wasmPath: t } : {}), !At))
5911
5920
  throw new Error("Bg2LoaderPlugin: unable to initialize bg2io library");
5912
- return ht;
5921
+ return At;
5913
5922
  }, Xi = (t, e) => t.polyLists.map((i) => {
5914
5923
  const n = new de(), s = t.materials.find((o) => o.name === i.matName);
5915
5924
  return n.name = i.name, n.visible = i.visible, s && (n.groupName = s.groupName || "", n.enableCullFace = s.cullFace), n.vertex = i.vertex, n.normal = i.normal, n.texCoord0 = i.texCoord0, n.texCoord1 = i.texCoord1, n.texCoord2 = i.texCoord2, n.index = i.index, { plist: n, materialData: s };
@@ -5937,7 +5946,7 @@ class Yi extends pt {
5937
5946
  bg2ioPath: e = null,
5938
5947
  materialImportCallback: r
5939
5948
  } = {}) {
5940
- super(), this._bg2ioPath = e, this._materialImportCallback = r, this._resource = new qe();
5949
+ super(), this._bg2ioPath = e, this._materialImportCallback = r, this._resource = new _e();
5941
5950
  }
5942
5951
  get supportedExtensions() {
5943
5952
  return ["bg2", "vwglb"];
@@ -5971,7 +5980,7 @@ const vr = {
5971
5980
  }, mr = (t) => ({
5972
5981
  operationType: t,
5973
5982
  plugins: {}
5974
- }), wt = (t, e) => {
5983
+ }), vt = (t, e) => {
5975
5984
  t.resourceTypes.forEach((r) => {
5976
5985
  e.plugins[r] = e.plugins[r] || [], e.plugins[r].push(t);
5977
5986
  });
@@ -5985,7 +5994,7 @@ const vr = {
5985
5994
  } else
5986
5995
  throw new Error(s);
5987
5996
  }, ir = mr(vr.Read), Co = (t) => {
5988
- t.dependencies.forEach((e) => wt(e, ir)), wt(t, ir);
5997
+ t.dependencies.forEach((e) => vt(e, ir)), vt(t, ir);
5989
5998
  }, nr = (t, e) => Pr(t, e, ir), Or = () => ({
5990
5999
  [M.PolyList]: {},
5991
6000
  [M.Drawable]: {},
@@ -5995,7 +6004,7 @@ const vr = {
5995
6004
  });
5996
6005
  class po {
5997
6006
  constructor(e) {
5998
- this._canvas = e || _e.FirstCanvas(), this._cache = Or(), this._currentPath = "";
6007
+ this._canvas = e || $e.FirstCanvas(), this._cache = Or(), this._currentPath = "";
5999
6008
  }
6000
6009
  get canvas() {
6001
6010
  return this._canvas;
@@ -6052,7 +6061,7 @@ const bo = (t, e, r) => {
6052
6061
  };
6053
6062
  class Eo extends pt {
6054
6063
  constructor() {
6055
- super(), this._resource = new qe();
6064
+ super(), this._resource = new _e();
6056
6065
  }
6057
6066
  get supportedExtensions() {
6058
6067
  return ["obj"];
@@ -6104,7 +6113,7 @@ class xo extends ji {
6104
6113
  }
6105
6114
  }
6106
6115
  const Vi = mr(vr.Write), Qo = (t) => {
6107
- wt(t, Vi);
6116
+ vt(t, Vi);
6108
6117
  }, Ki = (t, e) => Pr(t, e, Vi);
6109
6118
  class To {
6110
6119
  constructor() {
@@ -6132,7 +6141,7 @@ const yo = {
6132
6141
  Bg2LoaderPlugin: Yi,
6133
6142
  PluginOperationType: vr,
6134
6143
  createPluginDatabase: mr,
6135
- registerPluginInDatabase: wt,
6144
+ registerPluginInDatabase: vt,
6136
6145
  getPluginFromDatabase: Pr,
6137
6146
  Loader: po,
6138
6147
  registerLoaderPlugin: Co,
@@ -6395,7 +6404,7 @@ const Mo = {
6395
6404
  DrawMode: ae,
6396
6405
  RenderLayer: k,
6397
6406
  getLayers: vi,
6398
- PolyListFrontFace: ut,
6407
+ PolyListFrontFace: dt,
6399
6408
  PolyListCullFace: De,
6400
6409
  Texture: x,
6401
6410
  TextureDataType: Qe,
@@ -6744,7 +6753,7 @@ class he extends se {
6744
6753
  e.addLight(this.light, r);
6745
6754
  }
6746
6755
  }
6747
- class $e extends ii {
6756
+ class et extends ii {
6748
6757
  static Factory(e) {
6749
6758
  if (!e)
6750
6759
  return null;
@@ -6796,7 +6805,7 @@ class $e extends ii {
6796
6805
  this.near = e.near ?? this.near, this.far = e.far ?? this.far, Array.isArray(e.viewport) ? this.viewport = new h(e.viewport) : e.viewport instanceof h && (this.viewport = new h(e.viewport));
6797
6806
  }
6798
6807
  }
6799
- class Mt extends $e {
6808
+ class Mt extends et {
6800
6809
  constructor(e = null) {
6801
6810
  super(e), this._fov = 60;
6802
6811
  }
@@ -6823,7 +6832,7 @@ class Mt extends $e {
6823
6832
  super.deserialize(e), this.fov = e.fov ?? this.fov;
6824
6833
  }
6825
6834
  }
6826
- class Nt extends $e {
6835
+ class Nt extends et {
6827
6836
  constructor(e = null) {
6828
6837
  super(e), this._focalLength = 50, this._frameSize = 35;
6829
6838
  }
@@ -6862,7 +6871,7 @@ class Nt extends $e {
6862
6871
  super.deserialize(e), this.frameSize = e.frameSize ?? this.frameSize, this.focalLength = e.focalLength ?? this.focalLength;
6863
6872
  }
6864
6873
  }
6865
- class Ie extends $e {
6874
+ class Ie extends et {
6866
6875
  constructor(e = null) {
6867
6876
  super(e), this._viewWidth = 100;
6868
6877
  }
@@ -6987,7 +6996,7 @@ class j extends se {
6987
6996
  }
6988
6997
  async deserialize(e = {}, r) {
6989
6998
  if (await super.deserialize(e, r), this.focusDistance = e.focusDistance ?? this._focusDistance, e.projectionMethod) {
6990
- const i = $e.Factory(e.projectionMethod);
6999
+ const i = et.Factory(e.projectionMethod);
6991
7000
  i && (this.projectionStrategy = i);
6992
7001
  }
6993
7002
  }
@@ -7026,7 +7035,7 @@ class zt extends Ht {
7026
7035
  }
7027
7036
  }
7028
7037
  var Fe = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.UP = 1] = "UP", t[t.DOWN = 2] = "DOWN", t))(Fe || {});
7029
- const et = (t, e, r) => {
7038
+ const tt = (t, e, r) => {
7030
7039
  if (e.mouseStatus.pos = Pi(t, e.canvas), r !== 0) {
7031
7040
  const i = r === 2;
7032
7041
  t.button === 0 ? e.mouseStatus.leftButton = i : t.button === 1 ? e.mouseStatus.middleButton = i : t.button === 2 && (e.mouseStatus.rightButton = i);
@@ -7069,12 +7078,12 @@ function Oo(t) {
7069
7078
  return Ee.ZOOM;
7070
7079
  }
7071
7080
  }
7072
- class tt extends se {
7081
+ class rt extends se {
7073
7082
  constructor(e = null) {
7074
7083
  super(e ?? "OrbitCameraController"), this._rotateButtons = { left: !0, middle: !1, right: !1 }, this._panButtons = { left: !1, middle: !1, right: !0 }, this._zoomButtons = { left: !1, middle: !0, right: !1 }, this._rotation = new h([0, 0]), this._distance = 5, this._center = new h([0, 0, 0]), this._rotationSpeed = 0.2, this._forward = 0, this._left = 0, this._wheelSpeed = 1, this._minFocus = 2, this._minPitch = -85, this._maxPitch = 85, this._minDistance = 0.4, this._maxDistance = 24, this._maxX = 45, this._minX = -45, this._minY = -45, this._maxY = 45, this._maxZ = 45, this._minZ = -45, this._displacementSpeed = 0.1, this._enabled = !0, this._keys = {}, this._lastTouch = [];
7075
7084
  }
7076
7085
  clone() {
7077
- const e = new tt();
7086
+ const e = new rt();
7078
7087
  return e.assign(this), e;
7079
7088
  }
7080
7089
  assign(e) {
@@ -7292,7 +7301,7 @@ class tt extends se {
7292
7301
  this.enabled && (this._keys[e.key] = !1);
7293
7302
  }
7294
7303
  }
7295
- class Lt extends tt {
7304
+ class Lt extends rt {
7296
7305
  constructor() {
7297
7306
  super("SmoothOrbitCameraController"), this._smoothFactor = 9e-3, this._action = Ee.NONE;
7298
7307
  }
@@ -7391,7 +7400,7 @@ class It extends se {
7391
7400
  }
7392
7401
  }
7393
7402
  const $i = () => {
7394
- _("Drawable", Oe), _("Transform", oe), _("Light", he), _("LightComponent", he), _("Chain", Qt), _("InputChainJoint", Tt), _("OutputChainJoint", yt), _("Camera", j), _("OrbitCameraController", tt), _("SmoothOrbitCameraController", Lt), _("Environment", It);
7403
+ _("Drawable", Oe), _("Transform", oe), _("Light", he), _("LightComponent", he), _("Chain", Qt), _("InputChainJoint", Tt), _("OutputChainJoint", yt), _("Camera", j), _("OrbitCameraController", rt), _("SmoothOrbitCameraController", Lt), _("Environment", It);
7395
7404
  }, Fo = {
7396
7405
  Component: se,
7397
7406
  DrawableComponent: Oe,
@@ -7403,8 +7412,8 @@ const $i = () => {
7403
7412
  CameraComponent: j,
7404
7413
  OpticalProjectionStrategy: Nt,
7405
7414
  PerspectiveProjectionStrategy: Mt,
7406
- ProjectionStrategy: $e,
7407
- OrbitCameraControllerComponent: tt,
7415
+ ProjectionStrategy: et,
7416
+ OrbitCameraControllerComponent: rt,
7408
7417
  SmoothOrbitCameraControllerComponent: Lt,
7409
7418
  EnvironmentComponent: It,
7410
7419
  registerComponents: $i,
@@ -7555,26 +7564,26 @@ async function ko(t, e) {
7555
7564
  t.redisplay && (t.updateMode === 0 ? t._redisplayFrames = 1 : t._redisplayFrames--, (t._redisplayFrames > 0 || !t._firstFrameRendered) && (await t.appController.frame(e), t.appController.display(), t._firstFrameRendered = !0));
7556
7565
  }
7557
7566
  function Yo(t, e) {
7558
- const r = et(t, e, Fe.DOWN);
7567
+ const r = tt(t, e, Fe.DOWN);
7559
7568
  return qi(r, !0), e.appController.mouseDown(r), r;
7560
7569
  }
7561
7570
  function sn(t, e) {
7562
- const r = et(t, e, Fe.NONE);
7571
+ const r = tt(t, e, Fe.NONE);
7563
7572
  return e.appController.mouseMove(r), e.mouseStatus.anyButton && e.appController.mouseDrag(r), r;
7564
7573
  }
7565
7574
  function jo(t, e) {
7566
- const r = et(t, e, Fe.NONE);
7575
+ const r = tt(t, e, Fe.NONE);
7567
7576
  return Ro(), e.appController.mouseOut(r), r;
7568
7577
  }
7569
7578
  function Vo(t, e) {
7570
7579
  return sn(t, e);
7571
7580
  }
7572
7581
  function Ko(t, e) {
7573
- const r = et(t, e, Fe.UP);
7582
+ const r = tt(t, e, Fe.UP);
7574
7583
  return qi(r, !1), e.appController.mouseUp(r), r;
7575
7584
  }
7576
7585
  function Wo(t, e) {
7577
- const r = et(t, e, Fe.NONE);
7586
+ const r = tt(t, e, Fe.NONE);
7578
7587
  return r.delta = t.wheelDelta ? t.wheelDelta * -1 : t.detail * 10, e.appController.mouseWheel(r), r;
7579
7588
  }
7580
7589
  function Jo(t, e) {
@@ -7600,7 +7609,7 @@ function $o(t, e) {
7600
7609
  const e0 = {
7601
7610
  AppController: en,
7602
7611
  FrameUpdate: rn,
7603
- Canvas: _e,
7612
+ Canvas: $e,
7604
7613
  getMouseEventOffset: Pi,
7605
7614
  getEventTouches: Bi,
7606
7615
  EventBase: Ht,
@@ -7732,7 +7741,7 @@ const fn = {
7732
7741
  1: "TEXTURE",
7733
7742
  2: "CUBE_MAP"
7734
7743
  };
7735
- var vt = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.POSITIVE_X = 1] = "POSITIVE_X", t[t.NEGATIVE_X = 2] = "NEGATIVE_X", t[t.POSITIVE_Y = 3] = "POSITIVE_Y", t[t.NEGATIVE_Y = 4] = "NEGATIVE_Y", t[t.POSITIVE_Z = 5] = "POSITIVE_Z", t[t.NEGATIVE_Z = 6] = "NEGATIVE_Z", t))(vt || {});
7744
+ var mt = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.POSITIVE_X = 1] = "POSITIVE_X", t[t.NEGATIVE_X = 2] = "NEGATIVE_X", t[t.POSITIVE_Y = 3] = "POSITIVE_Y", t[t.NEGATIVE_Y = 4] = "NEGATIVE_Y", t[t.POSITIVE_Z = 5] = "POSITIVE_Z", t[t.NEGATIVE_Z = 6] = "NEGATIVE_Z", t))(mt || {});
7736
7745
  function Fr(t) {
7737
7746
  if (t.target === ee.TEXTURE_2D)
7738
7747
  return 1;
@@ -8593,6 +8602,18 @@ class Cn extends V {
8593
8602
  if (super(e), this._program = null, e.typeId !== "WebGL")
8594
8603
  throw Error("SelectionHighlightShader is only compatible with WebGL renderer");
8595
8604
  }
8605
+ get borderColor() {
8606
+ return this._borderColor;
8607
+ }
8608
+ set borderColor(e) {
8609
+ this._borderColor = e;
8610
+ }
8611
+ get borderWidth() {
8612
+ return this._borderWidth;
8613
+ }
8614
+ set borderWidth(e) {
8615
+ this._borderWidth = e;
8616
+ }
8596
8617
  async load() {
8597
8618
  const { gl: e } = this.renderer;
8598
8619
  this._program = new T(e, "SelectionHighlightShader"), this._program.attachVertexSource(Xr.webgl.vertex), this._program.attachFragmentSource(Xr.webgl.fragment), this._program.link(), this._borderWidth = 3, this._borderColor = new h([0, 0.7, 1, 1]), this._convMatrix = [
@@ -8628,6 +8649,18 @@ class u0 {
8628
8649
  constructor(e) {
8629
8650
  this._targetTexture = null, this._renderBuffer = null, this._shader = null, this._renderQueue = null, this._frameVisitor = null, this._selectionDrawShader = null, this._renderer = e;
8630
8651
  }
8652
+ get borderColor() {
8653
+ return this._selectionDrawShader?.borderColor || new h(1, 0, 0, 1);
8654
+ }
8655
+ set borderColor(e) {
8656
+ this._selectionDrawShader && (this._selectionDrawShader.borderColor = e);
8657
+ }
8658
+ get borderWidth() {
8659
+ return this._selectionDrawShader?.borderWidth || 3;
8660
+ }
8661
+ set borderWidth(e) {
8662
+ this._selectionDrawShader && (this._selectionDrawShader.borderWidth = e);
8663
+ }
8631
8664
  async init() {
8632
8665
  const e = this._renderer;
8633
8666
  this._targetTexture = new x(), this._targetTexture.renderTargetAttachment = Y.COLOR_ATTACHMENT_0, this._targetTexture.componentFormat = ie.UNSIGNED_BYTE, this._targetTexture.wrapModeXY = U.CLAMP, this._renderBuffer = e.factory.renderBuffer(), await this._renderBuffer.attachTexture(this._targetTexture), this._shader = new Dr(e), await this._shader.load(), this._shader.forceDraw = !1, this._renderQueue = new St(e), this._renderQueue.enableQueue(k.SELECTION_DEFAULT, this._shader), this._frameVisitor = new Rt(this._renderQueue), this._selectionDrawShader = new Cn(e), await this._selectionDrawShader.load();
@@ -8674,11 +8707,11 @@ class d0 {
8674
8707
  this._renderBuffer?.destroy(), this._targetTexture?.destroy(), this._renderBuffer = null, this._targetTexture = null;
8675
8708
  }
8676
8709
  }
8677
- var mt = /* @__PURE__ */ ((t) => (t[t.OBJECT = 0] = "OBJECT", t[t.POLY_LIST = 1] = "POLY_LIST", t))(mt || {});
8678
- const At = (t) => "" + t[0] + t[1] + t[2];
8710
+ var Ze = /* @__PURE__ */ ((t) => (t[t.OBJECT = 0] = "OBJECT", t[t.POLY_LIST = 1] = "POLY_LIST", t))(Ze || {});
8711
+ const ft = (t) => "" + t[0] + t[1] + t[2];
8679
8712
  class w0 extends ce {
8680
8713
  constructor() {
8681
- super(), this._r = 0, this._g = 0, this._b = 0, this._selectionMode = mt.POLY_LIST, this._elements = {};
8714
+ super(), this._r = 0, this._g = 0, this._b = 0, this._selectionMode = Ze.POLY_LIST, this._elements = {};
8682
8715
  }
8683
8716
  set selectionMode(e) {
8684
8717
  this._selectionMode = e, this.clear();
@@ -8695,9 +8728,9 @@ class w0 extends ce {
8695
8728
  Math.round(Math.random() * 255),
8696
8729
  Math.round(Math.random() * 255)
8697
8730
  ];
8698
- let r = e(), i = At(r);
8731
+ let r = e(), i = ft(r);
8699
8732
  for (; this._elements[i]; )
8700
- r = e(), i = At(r);
8733
+ r = e(), i = ft(r);
8701
8734
  return this._r = r[0], this._g = r[1], this._b = r[2], new p([r[0] / 255, r[1] / 255, r[2] / 255, 1]);
8702
8735
  }
8703
8736
  findElement(e) {
@@ -8708,7 +8741,7 @@ class w0 extends ce {
8708
8741
  e[1],
8709
8742
  e[2]
8710
8743
  ];
8711
- return this._elements[At(r)];
8744
+ return this._elements[ft(r)] || null;
8712
8745
  }
8713
8746
  visit(e) {
8714
8747
  const { drawable: r } = e;
@@ -8717,21 +8750,21 @@ class w0 extends ce {
8717
8750
  r.items.forEach(({ polyList: n }, s, o) => {
8718
8751
  if (n.isSelectable) {
8719
8752
  n.colorCode = i, n.selected = !1;
8720
- const a = At([
8753
+ const a = ft([
8721
8754
  Math.round(i[0] * 255),
8722
8755
  Math.round(i[1] * 255),
8723
8756
  Math.round(i[2] * 255)
8724
8757
  ]);
8725
8758
  this._elements[a] = { polyList: n, drawable: r };
8726
8759
  }
8727
- s < o.length - 1 && this._selectionMode == mt.POLY_LIST && (i = this.getNextColor());
8760
+ s < o.length - 1 && this._selectionMode == Ze.POLY_LIST && (i = this.getNextColor());
8728
8761
  });
8729
8762
  }
8730
8763
  }
8731
8764
  }
8732
8765
  class v0 {
8733
8766
  constructor(e) {
8734
- this._selectionBuffer = null, this._selectionIdVisitor = null, this._downPosition = new h(), this._viewportSize = [1, 1], this._enabled = !0, this._renderer = e, this._sceneRoot = null, this._camera = null, this._selectionMode = mt.POLY_LIST, this._multiSelect = !1, this._selection = [], this._selectionChangedCallbacks = {};
8767
+ this._selectionBuffer = null, this._selectionIdVisitor = null, this._downPosition = new h(), this._viewportSize = [1, 1], this._enabled = !0, this._renderer = e, this._sceneRoot = null, this._camera = null, this._selectionMode = Ze.POLY_LIST, this._multiSelect = !1, this._selection = [], this._selectionChangedCallbacks = {};
8735
8768
  }
8736
8769
  async init() {
8737
8770
  this._selectionBuffer = new d0(this._renderer), await this._selectionBuffer.init(), this._selectionIdVisitor = new w0();
@@ -8802,8 +8835,8 @@ class v0 {
8802
8835
  this._selectionIdVisitor && this.sceneRoot && (this._selectionIdVisitor.selectionMode = this.selectionMode, this.sceneRoot.accept(this._selectionIdVisitor));
8803
8836
  const i = window.devicePixelRatio || 1;
8804
8837
  this._selectionBuffer?.reshape(this._viewportSize[0], this._viewportSize[1]);
8805
- const n = this._selectionBuffer.draw(this.sceneRoot, this.camera, e.x * i, e.y * i), s = this._selectionIdVisitor.findElement(n), o = () => this._selection.find((a) => a.polyList === s.polyList && a.drawable === s.drawable);
8806
- s && this._multiSelect && !o() ? (this._selection.push(s), this.triggerSelectionChanged()) : s && !o() ? (this._selection = [s], this.triggerSelectionChanged()) : !s && !this._multiSelect && this._selection.length > 0 && (this._selection = [], this.triggerSelectionChanged()), this._selection.forEach((a) => a.polyList.selected = !0);
8838
+ const n = this._selectionBuffer.draw(this.sceneRoot, this.camera, e.x * i, e.y * i), s = this._selectionIdVisitor.findElement(n), o = () => this._selection.find((a) => s && a.polyList === s.polyList && a.drawable === s.drawable);
8839
+ s && this.selectionMode === Ze.OBJECT && s.drawable.items.forEach((a) => a.polyList.selected = !0), s && this._multiSelect && !o() ? (this._selection.push(s), this.triggerSelectionChanged()) : s && !o() ? (this._selection = [s], this.triggerSelectionChanged()) : !s && !this._multiSelect && this._selection.length > 0 && (this._selection = [], this.triggerSelectionChanged()), this._selection.forEach((a) => a.polyList.selected = !0);
8807
8840
  }
8808
8841
  }
8809
8842
  mouseDown(e) {
@@ -9098,332 +9131,332 @@ class m0 extends en {
9098
9131
  this.sceneRoot && this.sceneRenderer?.touchEnd(this.sceneRoot, e), this.selectionManager?.touchEnd(e), this.updateOnInputEvents && this.mainLoop.postRedisplay({ frames: this._updateInputEventsFrameCount });
9099
9132
  }
9100
9133
  }
9101
- const bn = `#ifndef COLOR_CORRECTION_GLSL\r
9102
- #define COLOR_CORRECTION_GLSL\r
9103
- \r
9104
- // Convert lineal color to SRGB for shader output\r
9105
- vec4 lineal2SRGB(vec4 color, float gamma)\r
9106
- {\r
9107
- color = color / (color + vec4(1.0));\r
9108
- return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a);\r
9109
- }\r
9110
- \r
9111
- vec3 lineal2SRGB(vec3 color, float gamma)\r
9112
- {\r
9113
- color = color / (color + vec3(1.0));\r
9114
- return pow(color.rgb, vec3(1.0 / gamma));\r
9115
- }\r
9116
- \r
9117
- // Convert SRGB textures to lineal color\r
9118
- vec4 SRGB2Lineal(vec4 color, float gamma)\r
9119
- {\r
9120
- return vec4(pow(color.rgb, vec3(gamma)), color.a);\r
9121
- }\r
9122
- \r
9123
- vec3 SRGB2lLineal(vec3 color, float gamma)\r
9124
- {\r
9125
- return pow(color, vec3(gamma));\r
9126
- }\r
9127
- \r
9128
- vec4 brightnessContrast(vec4 color, float brightness, float contrast)\r
9129
- {\r
9130
- mat4 brightnessMat = mat4(\r
9131
- 1.0, 0.0, 0.0, 0.0,\r
9132
- 0.0, 1.0, 0.0, 0.0,\r
9133
- 0.0, 0.0, 1.0, 0.0,\r
9134
- brightness, brightness, brightness, 1.0\r
9135
- );\r
9136
- float t = (1.0 - contrast) / 2.0;\r
9137
- mat4 contrastMat = mat4(\r
9138
- contrast, 0.0, 0.0, 0.0,\r
9139
- 0.0, contrast, 0.0, 0.0,\r
9140
- 0.0, 0.0, contrast, 0.0,\r
9141
- t, t, t, 1.0\r
9142
- );\r
9143
- return contrastMat * brightnessMat * color;\r
9144
- }\r
9145
- \r
9146
- #endif // COLOR_CORRECTION_GLSL\r
9147
- \r
9148
- `, P0 = `\r
9149
- #define PI 3.14159265359\r
9150
- #define LIGHT_TYPE_POINT 5\r
9151
- #define LIGHT_TYPE_DIRECTIONAL 4\r
9152
- #define LIGHT_TYPE_SPOT 1\r
9153
- #define LIGHT_TYPE_DISABLED 10\r
9154
- `, En = `\r
9155
- mat3 TBNMatrix(mat4 model, vec3 normal, vec3 tangent)\r
9156
- {\r
9157
- vec3 T = normalize(vec3(model * vec4(tangent, 0.0)));\r
9158
- vec3 B = normalize(vec3(model * vec4(cross(tangent, normal), 0.0)));\r
9159
- vec3 N = normalize(vec3(model * vec4(normal, 0.0)));\r
9160
- return mat3(T, B, N);\r
9161
- }\r
9162
- \r
9163
- `, xn = `\r
9164
- #include "lib/constants.glsl"\r
9165
- \r
9166
- vec3 fresnelSchlick(float cosTheta, vec3 F0)\r
9167
- {\r
9168
- return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);\r
9169
- }\r
9170
- \r
9171
- vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)\r
9172
- {\r
9173
- // Use the Schlick approximation for fresnel with roughness\r
9174
- return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);\r
9175
- }\r
9176
- \r
9177
- float distributionGGX(vec3 normal, vec3 halfVector, float roughness)\r
9178
- {\r
9179
- float a = roughness * roughness;\r
9180
- float a2 = a * a;\r
9181
- \r
9182
- float NdotH = max(dot(normal, halfVector), 0.0);\r
9183
- float NdotH2 = NdotH * NdotH;\r
9184
- \r
9185
- float denom = NdotH2 * (a2 - 1.0) + 1.0;\r
9186
- \r
9187
- return a2 / (PI * denom * denom);\r
9188
- }\r
9189
- \r
9190
- float geometrySchlickGGX(float NdotV, float roughness)\r
9191
- {\r
9192
- float r = (roughness + 1.0);\r
9193
- float k = (r * r) / 8.0;\r
9194
- \r
9195
- float num = NdotV;\r
9196
- float denom = NdotV * (1.0 - k) + k;\r
9197
- \r
9198
- return num / denom;\r
9199
- }\r
9200
- \r
9201
- float geometrySmith(vec3 normal, vec3 viewDir, vec3 lightDir, float roughness)\r
9202
- {\r
9203
- float NdotV = max(dot(normal, viewDir), 0.0);\r
9204
- float NdotL = max(dot(normal, lightDir), 0.0);\r
9205
- float ggx2 = geometrySchlickGGX(NdotV, roughness);\r
9206
- float ggx1 = geometrySchlickGGX(NdotL, roughness);\r
9207
- return ggx1 * ggx2;\r
9208
- }\r
9209
- \r
9210
- float calcAttenuation(vec3 lightPosition, vec3 fragPosition)\r
9211
- {\r
9212
- float distance = length(lightPosition - fragPosition);\r
9213
- return 1.0 / (distance * distance);\r
9214
- }\r
9215
- \r
9216
- vec3 calcRadiancePoint( Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion) {\r
9217
- // calculate per-light radiance\r
9218
- vec3 L = normalize(light.position - fragPos);\r
9219
- vec3 H = normalize(viewDir + L);\r
9220
- float attenuation = calcAttenuation(light.position, fragPos);\r
9221
- vec3 radiance = light.color.rgb * light.intensity * attenuation;\r
9222
- \r
9223
- // cook-torrance brdf\r
9224
- float NDF = distributionGGX(normal, H, roughness);\r
9225
- float G = geometrySmith(normal, viewDir, L, roughness);\r
9226
- vec3 F = fresnelSchlick(max(dot(H, viewDir), 0.0), F0);\r
9227
- \r
9228
- vec3 kS = F;\r
9229
- vec3 kD = vec3(1.0) - kS;\r
9230
- kD *= 1.0 - metallic;\r
9231
- \r
9232
- vec3 numerator = NDF * G * F;\r
9233
- float denominator = 4.0 * max(dot(normal, viewDir), 0.0) * max(dot(normal, L), 0.0) + 0.0001;\r
9234
- vec3 specular = numerator / denominator;\r
9235
- \r
9236
- // add to outgoing radiance Lo\r
9237
- float NdotL = max(dot(normal, L), 0.0);\r
9238
- vec3 base = (kD * albedo / PI + specular) * radiance * NdotL;\r
9239
- vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion;\r
9240
- return base + sheen;\r
9241
- }\r
9242
- \r
9243
- vec3 calcRadianceDirectional(Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion)\r
9244
- {\r
9245
- vec3 L = normalize(-light.direction);\r
9246
- vec3 H = normalize(viewDir + L);\r
9247
- vec3 radiance = light.color.rgb * light.intensity;\r
9248
- \r
9249
- // cook-torrance brdf\r
9250
- float NDF = distributionGGX(normal, H, roughness);\r
9251
- float G = geometrySmith(normal, viewDir, L, roughness);\r
9252
- vec3 F = fresnelSchlick(max(dot(H, viewDir), 0.0), F0);\r
9253
- \r
9254
- vec3 kS = F;\r
9255
- vec3 kD = vec3(1.0) - kS;\r
9256
- kD *= 1.0 - metallic;\r
9257
- \r
9258
- vec3 numerator = NDF * G * F;\r
9259
- float denominator = 4.0 * max(dot(normal, viewDir), 0.0) * max(dot(normal, L), 0.0) + 0.0001;\r
9260
- vec3 specular = numerator / denominator;\r
9261
- \r
9262
- // add to outgoing radiance Lo\r
9263
- float NdotL = max(dot(normal, L), 0.0);\r
9264
- vec3 base = (kD * albedo / PI + specular) * radiance * NdotL;\r
9265
- vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion;\r
9266
- return base + sheen;\r
9267
- }\r
9268
- \r
9269
- vec3 calcRadiance( Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion) {\r
9270
- if (light.type == LIGHT_TYPE_POINT)\r
9271
- {\r
9272
- return calcRadiancePoint(light, viewDir, fragPos, metallic, roughness, F0, normal, albedo, sheenIntensity, sheenColor, ambientOcclussion);\r
9273
- }\r
9274
- else if (light.type == LIGHT_TYPE_DIRECTIONAL)\r
9275
- {\r
9276
- return calcRadianceDirectional(light, viewDir, fragPos, metallic, roughness, F0, normal, albedo, sheenIntensity, sheenColor, ambientOcclussion);\r
9277
- }\r
9278
- return vec3(0.0);\r
9279
- }\r
9280
- \r
9281
- vec3 getPrefilteredColor(float roughness,vec3 refVec,samplerCube irrMap,samplerCube specMap,samplerCube envMap) {\r
9282
- vec3 specMap0 = textureCube(envMap, refVec).rgb;\r
9283
- vec3 specMap1 = textureCube(specMap, refVec).rgb;\r
9284
- vec3 specMap2 = textureCube(irrMap, refVec).rgb;\r
9285
- \r
9286
- if (roughness < 0.4) {\r
9287
- return mix(specMap0, specMap1, roughness / 0.4);\r
9288
- }\r
9289
- return mix(specMap1, specMap2, (roughness - 0.4) / 0.6);\r
9290
- }\r
9291
- \r
9292
- vec3 calcAmbientLight( vec3 viewDir, vec3 normal, vec3 F0, vec3 albedo, float metallic, float roughness, samplerCube irradianceMap, samplerCube prefilteredEnvMap, samplerCube envMap, sampler2D brdfLUT, float ambientOcclussion, float sheenIntensity, vec3 sheenColor, vec3 shadowColor, float ambientIntensity) {\r
9293
- vec3 R = reflect(-viewDir, normal);\r
9294
- \r
9295
- vec3 F = fresnelSchlickRoughness(max(dot(normal, viewDir), 0.0), F0, roughness) * max(shadowColor, vec3(0.8));\r
9296
- \r
9297
- vec3 Ks = F;\r
9298
- vec3 Kd = 1.0 - Ks;\r
9299
- Kd *= 1.0 - metallic;\r
9300
- \r
9301
- vec3 irradiance = textureCube(irradianceMap, normal).rgb * ambientIntensity;\r
9302
- vec3 diffuse = irradiance * albedo;\r
9303
- \r
9304
- vec3 prefilteredColor = getPrefilteredColor(roughness, R, irradianceMap, prefilteredEnvMap, envMap);\r
9305
- \r
9306
- vec2 brdfUV = vec2(clamp(max(dot(normal, viewDir), 0.0), 0.01, 0.99), roughness);\r
9307
- vec2 envBRDF = texture2D(brdfLUT, brdfUV).rg;\r
9308
- vec3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);\r
9309
- \r
9310
- vec3 base = (Kd * diffuse + specular) * ambientOcclussion;\r
9311
- vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion * shadowColor;\r
9312
- return base + sheen;\r
9313
- }\r
9314
- \r
9315
- // TODO: Extract this function to a shadow map shader function\r
9316
- vec3 getShadowColor(vec4 positionFromLightPov, sampler2D shadowMap, float shadowBias, float shadowStrength) {\r
9317
- // The vertex location rendered from the light source is almost in\r
9318
- // normalized device coordinates (NDC), but the perspective division\r
9319
- // has not been performed yet. We need to divide by w to get the\r
9320
- // vertex location in range [-1, +1]\r
9321
- vec3 shadowCoord = positionFromLightPov.xyz / positionFromLightPov.w;\r
9322
- \r
9323
- // Convert from NDC to texture coordinates\r
9324
- shadowCoord = shadowCoord * 0.5 + 0.5;\r
9325
- \r
9326
- if (shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 &&\r
9327
- shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0)\r
9328
- {\r
9329
- float shadowDepth = texture2D(shadowMap, shadowCoord.xy).r;\r
9330
- if (shadowCoord.z > shadowDepth + shadowBias) {\r
9331
- return vec3(1.0 - shadowStrength);\r
9332
- }\r
9333
- }\r
9334
- return vec3(1.0);\r
9335
- }\r
9336
- `, Qn = `\r
9337
- struct PBRMaterialData\r
9338
- {\r
9339
- vec4 albedo;\r
9340
- \r
9341
- vec2 albedoScale;\r
9342
- vec2 normalScale;\r
9343
- vec2 metalnessScale;\r
9344
- vec2 roughnessScale;\r
9345
- vec2 lightEmissionScale;\r
9346
- \r
9347
- float metalness;\r
9348
- float roughness;\r
9349
- float lightEmission;\r
9350
- \r
9351
- int albedoUVSet;\r
9352
- int normalUVSet;\r
9353
- int metalnessUVSet;\r
9354
- int roughnessUVSet;\r
9355
- int lightEmissionUVSet;\r
9356
- int aoUVSet;\r
9357
- \r
9358
- vec4 fresnelTint;\r
9359
- vec4 sheenColor;\r
9360
- float sheenIntensity;\r
9361
- };\r
9362
- \r
9363
- struct Light\r
9364
- {\r
9365
- vec3 position;\r
9366
- float intensity;\r
9367
- vec4 color;\r
9368
- vec3 direction;\r
9369
- int type;\r
9370
- };\r
9371
- \r
9372
- vec4 sampleAlbedo(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat, float gamma)\r
9373
- {\r
9374
- vec2 uv = mat.albedoUVSet == 0 ? uv0 : uv1;\r
9375
- vec4 texColor = texture2D(tex, uv * mat.albedoScale);\r
9376
- return vec4(SRGB2Lineal(texColor, gamma).rgb * mat.albedo.rgb, texColor.a * mat.albedo.a);\r
9377
- }\r
9378
- \r
9379
- float sampleMetallic(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)\r
9380
- {\r
9381
- vec2 uv = mat.metalnessUVSet == 0 ? uv0 : uv1;\r
9382
- return texture2D(tex, uv * mat.metalnessScale).r * mat.metalness;\r
9383
- }\r
9384
- \r
9385
- float sampleRoughness(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)\r
9386
- {\r
9387
- const float minRoughness = 0.05; // Minimum roughness value: even a mirror have some roughness\r
9388
- const float maxRoughness = 0.98; // Maximum roughness value: avoid completely diffuse surfaces\r
9389
- vec2 uv = mat.roughnessUVSet == 0 ? uv0 : uv1;\r
9390
- return min(max(texture2D(tex, uv * mat.roughnessScale).g * mat.roughness, minRoughness), maxRoughness);\r
9391
- }\r
9392
- \r
9393
- \r
9394
- float sampleLightEmission(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)\r
9395
- {\r
9396
- vec2 uv = mat.lightEmissionUVSet == 0 ? uv0 : uv1;\r
9397
- return texture2D(tex, uv * mat.lightEmissionScale).b * mat.lightEmission;\r
9398
- }\r
9399
- \r
9400
- vec3 sampleNormal(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat, mat3 TBN)\r
9401
- {\r
9402
- vec2 uv = mat.normalUVSet == 0 ? uv0 : uv1;\r
9403
- vec3 normal = texture2D(tex, uv * mat.normalScale).xyz * 2.0 - 1.0;\r
9404
- return normalize(TBN * normal);\r
9405
- }\r
9406
- \r
9407
- float sampleAmbientOcclussion(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)\r
9408
- {\r
9409
- vec2 uv = mat.aoUVSet == 0 ? uv0 : uv1;\r
9410
- return texture2D(tex, uv).a;\r
9411
- }\r
9412
- \r
9413
- vec3 calcF0(vec3 albedo, PBRMaterialData mat)\r
9414
- {\r
9415
- return mix(vec3(0.04), albedo, mat.metalness) * mat.fresnelTint.rgb;\r
9416
- }\r
9417
- \r
9418
- vec3 calcSheen(vec3 normal, vec3 viewDir, vec3 sheenColor, float sheenIntensity)\r
9419
- {\r
9420
- float NdotV = max(dot(normal, viewDir), 0.0);\r
9421
- float facing = 1.0 - NdotV;\r
9422
- \r
9423
- // Adjustable power: controls how concentrated the brightness is\r
9424
- float falloff = pow(facing, 5.0);\r
9425
- return sheenColor * falloff * sheenIntensity;\r
9426
- }\r
9134
+ const bn = `#ifndef COLOR_CORRECTION_GLSL
9135
+ #define COLOR_CORRECTION_GLSL
9136
+
9137
+ // Convert lineal color to SRGB for shader output
9138
+ vec4 lineal2SRGB(vec4 color, float gamma)
9139
+ {
9140
+ color = color / (color + vec4(1.0));
9141
+ return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a);
9142
+ }
9143
+
9144
+ vec3 lineal2SRGB(vec3 color, float gamma)
9145
+ {
9146
+ color = color / (color + vec3(1.0));
9147
+ return pow(color.rgb, vec3(1.0 / gamma));
9148
+ }
9149
+
9150
+ // Convert SRGB textures to lineal color
9151
+ vec4 SRGB2Lineal(vec4 color, float gamma)
9152
+ {
9153
+ return vec4(pow(color.rgb, vec3(gamma)), color.a);
9154
+ }
9155
+
9156
+ vec3 SRGB2lLineal(vec3 color, float gamma)
9157
+ {
9158
+ return pow(color, vec3(gamma));
9159
+ }
9160
+
9161
+ vec4 brightnessContrast(vec4 color, float brightness, float contrast)
9162
+ {
9163
+ mat4 brightnessMat = mat4(
9164
+ 1.0, 0.0, 0.0, 0.0,
9165
+ 0.0, 1.0, 0.0, 0.0,
9166
+ 0.0, 0.0, 1.0, 0.0,
9167
+ brightness, brightness, brightness, 1.0
9168
+ );
9169
+ float t = (1.0 - contrast) / 2.0;
9170
+ mat4 contrastMat = mat4(
9171
+ contrast, 0.0, 0.0, 0.0,
9172
+ 0.0, contrast, 0.0, 0.0,
9173
+ 0.0, 0.0, contrast, 0.0,
9174
+ t, t, t, 1.0
9175
+ );
9176
+ return contrastMat * brightnessMat * color;
9177
+ }
9178
+
9179
+ #endif // COLOR_CORRECTION_GLSL
9180
+
9181
+ `, P0 = `
9182
+ #define PI 3.14159265359
9183
+ #define LIGHT_TYPE_POINT 5
9184
+ #define LIGHT_TYPE_DIRECTIONAL 4
9185
+ #define LIGHT_TYPE_SPOT 1
9186
+ #define LIGHT_TYPE_DISABLED 10
9187
+ `, En = `
9188
+ mat3 TBNMatrix(mat4 model, vec3 normal, vec3 tangent)
9189
+ {
9190
+ vec3 T = normalize(vec3(model * vec4(tangent, 0.0)));
9191
+ vec3 B = normalize(vec3(model * vec4(cross(tangent, normal), 0.0)));
9192
+ vec3 N = normalize(vec3(model * vec4(normal, 0.0)));
9193
+ return mat3(T, B, N);
9194
+ }
9195
+
9196
+ `, xn = `
9197
+ #include "lib/constants.glsl"
9198
+
9199
+ vec3 fresnelSchlick(float cosTheta, vec3 F0)
9200
+ {
9201
+ return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
9202
+ }
9203
+
9204
+ vec3 fresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
9205
+ {
9206
+ // Use the Schlick approximation for fresnel with roughness
9207
+ return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
9208
+ }
9209
+
9210
+ float distributionGGX(vec3 normal, vec3 halfVector, float roughness)
9211
+ {
9212
+ float a = roughness * roughness;
9213
+ float a2 = a * a;
9214
+
9215
+ float NdotH = max(dot(normal, halfVector), 0.0);
9216
+ float NdotH2 = NdotH * NdotH;
9217
+
9218
+ float denom = NdotH2 * (a2 - 1.0) + 1.0;
9219
+
9220
+ return a2 / (PI * denom * denom);
9221
+ }
9222
+
9223
+ float geometrySchlickGGX(float NdotV, float roughness)
9224
+ {
9225
+ float r = (roughness + 1.0);
9226
+ float k = (r * r) / 8.0;
9227
+
9228
+ float num = NdotV;
9229
+ float denom = NdotV * (1.0 - k) + k;
9230
+
9231
+ return num / denom;
9232
+ }
9233
+
9234
+ float geometrySmith(vec3 normal, vec3 viewDir, vec3 lightDir, float roughness)
9235
+ {
9236
+ float NdotV = max(dot(normal, viewDir), 0.0);
9237
+ float NdotL = max(dot(normal, lightDir), 0.0);
9238
+ float ggx2 = geometrySchlickGGX(NdotV, roughness);
9239
+ float ggx1 = geometrySchlickGGX(NdotL, roughness);
9240
+ return ggx1 * ggx2;
9241
+ }
9242
+
9243
+ float calcAttenuation(vec3 lightPosition, vec3 fragPosition)
9244
+ {
9245
+ float distance = length(lightPosition - fragPosition);
9246
+ return 1.0 / (distance * distance);
9247
+ }
9248
+
9249
+ vec3 calcRadiancePoint( Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion) {
9250
+ // calculate per-light radiance
9251
+ vec3 L = normalize(light.position - fragPos);
9252
+ vec3 H = normalize(viewDir + L);
9253
+ float attenuation = calcAttenuation(light.position, fragPos);
9254
+ vec3 radiance = light.color.rgb * light.intensity * attenuation;
9255
+
9256
+ // cook-torrance brdf
9257
+ float NDF = distributionGGX(normal, H, roughness);
9258
+ float G = geometrySmith(normal, viewDir, L, roughness);
9259
+ vec3 F = fresnelSchlick(max(dot(H, viewDir), 0.0), F0);
9260
+
9261
+ vec3 kS = F;
9262
+ vec3 kD = vec3(1.0) - kS;
9263
+ kD *= 1.0 - metallic;
9264
+
9265
+ vec3 numerator = NDF * G * F;
9266
+ float denominator = 4.0 * max(dot(normal, viewDir), 0.0) * max(dot(normal, L), 0.0) + 0.0001;
9267
+ vec3 specular = numerator / denominator;
9268
+
9269
+ // add to outgoing radiance Lo
9270
+ float NdotL = max(dot(normal, L), 0.0);
9271
+ vec3 base = (kD * albedo / PI + specular) * radiance * NdotL;
9272
+ vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion;
9273
+ return base + sheen;
9274
+ }
9275
+
9276
+ vec3 calcRadianceDirectional(Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion)
9277
+ {
9278
+ vec3 L = normalize(-light.direction);
9279
+ vec3 H = normalize(viewDir + L);
9280
+ vec3 radiance = light.color.rgb * light.intensity;
9281
+
9282
+ // cook-torrance brdf
9283
+ float NDF = distributionGGX(normal, H, roughness);
9284
+ float G = geometrySmith(normal, viewDir, L, roughness);
9285
+ vec3 F = fresnelSchlick(max(dot(H, viewDir), 0.0), F0);
9286
+
9287
+ vec3 kS = F;
9288
+ vec3 kD = vec3(1.0) - kS;
9289
+ kD *= 1.0 - metallic;
9290
+
9291
+ vec3 numerator = NDF * G * F;
9292
+ float denominator = 4.0 * max(dot(normal, viewDir), 0.0) * max(dot(normal, L), 0.0) + 0.0001;
9293
+ vec3 specular = numerator / denominator;
9294
+
9295
+ // add to outgoing radiance Lo
9296
+ float NdotL = max(dot(normal, L), 0.0);
9297
+ vec3 base = (kD * albedo / PI + specular) * radiance * NdotL;
9298
+ vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion;
9299
+ return base + sheen;
9300
+ }
9301
+
9302
+ vec3 calcRadiance( Light light, vec3 viewDir, vec3 fragPos, float metallic, float roughness, vec3 F0, vec3 normal, vec3 albedo, float sheenIntensity, vec3 sheenColor, float ambientOcclussion) {
9303
+ if (light.type == LIGHT_TYPE_POINT)
9304
+ {
9305
+ return calcRadiancePoint(light, viewDir, fragPos, metallic, roughness, F0, normal, albedo, sheenIntensity, sheenColor, ambientOcclussion);
9306
+ }
9307
+ else if (light.type == LIGHT_TYPE_DIRECTIONAL)
9308
+ {
9309
+ return calcRadianceDirectional(light, viewDir, fragPos, metallic, roughness, F0, normal, albedo, sheenIntensity, sheenColor, ambientOcclussion);
9310
+ }
9311
+ return vec3(0.0);
9312
+ }
9313
+
9314
+ vec3 getPrefilteredColor(float roughness,vec3 refVec,samplerCube irrMap,samplerCube specMap,samplerCube envMap) {
9315
+ vec3 specMap0 = textureCube(envMap, refVec).rgb;
9316
+ vec3 specMap1 = textureCube(specMap, refVec).rgb;
9317
+ vec3 specMap2 = textureCube(irrMap, refVec).rgb;
9318
+
9319
+ if (roughness < 0.4) {
9320
+ return mix(specMap0, specMap1, roughness / 0.4);
9321
+ }
9322
+ return mix(specMap1, specMap2, (roughness - 0.4) / 0.6);
9323
+ }
9324
+
9325
+ vec3 calcAmbientLight( vec3 viewDir, vec3 normal, vec3 F0, vec3 albedo, float metallic, float roughness, samplerCube irradianceMap, samplerCube prefilteredEnvMap, samplerCube envMap, sampler2D brdfLUT, float ambientOcclussion, float sheenIntensity, vec3 sheenColor, vec3 shadowColor, float ambientIntensity) {
9326
+ vec3 R = reflect(-viewDir, normal);
9327
+
9328
+ vec3 F = fresnelSchlickRoughness(max(dot(normal, viewDir), 0.0), F0, roughness) * max(shadowColor, vec3(0.8));
9329
+
9330
+ vec3 Ks = F;
9331
+ vec3 Kd = 1.0 - Ks;
9332
+ Kd *= 1.0 - metallic;
9333
+
9334
+ vec3 irradiance = textureCube(irradianceMap, normal).rgb * ambientIntensity;
9335
+ vec3 diffuse = irradiance * albedo;
9336
+
9337
+ vec3 prefilteredColor = getPrefilteredColor(roughness, R, irradianceMap, prefilteredEnvMap, envMap);
9338
+
9339
+ vec2 brdfUV = vec2(clamp(max(dot(normal, viewDir), 0.0), 0.01, 0.99), roughness);
9340
+ vec2 envBRDF = texture2D(brdfLUT, brdfUV).rg;
9341
+ vec3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);
9342
+
9343
+ vec3 base = (Kd * diffuse + specular) * ambientOcclussion;
9344
+ vec3 sheen = calcSheen(normal, viewDir, sheenColor, sheenIntensity) * ambientOcclussion * shadowColor;
9345
+ return base + sheen;
9346
+ }
9347
+
9348
+ // TODO: Extract this function to a shadow map shader function
9349
+ vec3 getShadowColor(vec4 positionFromLightPov, sampler2D shadowMap, float shadowBias, float shadowStrength) {
9350
+ // The vertex location rendered from the light source is almost in
9351
+ // normalized device coordinates (NDC), but the perspective division
9352
+ // has not been performed yet. We need to divide by w to get the
9353
+ // vertex location in range [-1, +1]
9354
+ vec3 shadowCoord = positionFromLightPov.xyz / positionFromLightPov.w;
9355
+
9356
+ // Convert from NDC to texture coordinates
9357
+ shadowCoord = shadowCoord * 0.5 + 0.5;
9358
+
9359
+ if (shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 &&
9360
+ shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0)
9361
+ {
9362
+ float shadowDepth = texture2D(shadowMap, shadowCoord.xy).r;
9363
+ if (shadowCoord.z > shadowDepth + shadowBias) {
9364
+ return vec3(1.0 - shadowStrength);
9365
+ }
9366
+ }
9367
+ return vec3(1.0);
9368
+ }
9369
+ `, Qn = `
9370
+ struct PBRMaterialData
9371
+ {
9372
+ vec4 albedo;
9373
+
9374
+ vec2 albedoScale;
9375
+ vec2 normalScale;
9376
+ vec2 metalnessScale;
9377
+ vec2 roughnessScale;
9378
+ vec2 lightEmissionScale;
9379
+
9380
+ float metalness;
9381
+ float roughness;
9382
+ float lightEmission;
9383
+
9384
+ int albedoUVSet;
9385
+ int normalUVSet;
9386
+ int metalnessUVSet;
9387
+ int roughnessUVSet;
9388
+ int lightEmissionUVSet;
9389
+ int aoUVSet;
9390
+
9391
+ vec4 fresnelTint;
9392
+ vec4 sheenColor;
9393
+ float sheenIntensity;
9394
+ };
9395
+
9396
+ struct Light
9397
+ {
9398
+ vec3 position;
9399
+ float intensity;
9400
+ vec4 color;
9401
+ vec3 direction;
9402
+ int type;
9403
+ };
9404
+
9405
+ vec4 sampleAlbedo(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat, float gamma)
9406
+ {
9407
+ vec2 uv = mat.albedoUVSet == 0 ? uv0 : uv1;
9408
+ vec4 texColor = texture2D(tex, uv * mat.albedoScale);
9409
+ return vec4(SRGB2Lineal(texColor, gamma).rgb * mat.albedo.rgb, texColor.a * mat.albedo.a);
9410
+ }
9411
+
9412
+ float sampleMetallic(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)
9413
+ {
9414
+ vec2 uv = mat.metalnessUVSet == 0 ? uv0 : uv1;
9415
+ return texture2D(tex, uv * mat.metalnessScale).r * mat.metalness;
9416
+ }
9417
+
9418
+ float sampleRoughness(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)
9419
+ {
9420
+ const float minRoughness = 0.05; // Minimum roughness value: even a mirror have some roughness
9421
+ const float maxRoughness = 0.98; // Maximum roughness value: avoid completely diffuse surfaces
9422
+ vec2 uv = mat.roughnessUVSet == 0 ? uv0 : uv1;
9423
+ return min(max(texture2D(tex, uv * mat.roughnessScale).g * mat.roughness, minRoughness), maxRoughness);
9424
+ }
9425
+
9426
+
9427
+ float sampleLightEmission(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)
9428
+ {
9429
+ vec2 uv = mat.lightEmissionUVSet == 0 ? uv0 : uv1;
9430
+ return texture2D(tex, uv * mat.lightEmissionScale).b * mat.lightEmission;
9431
+ }
9432
+
9433
+ vec3 sampleNormal(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat, mat3 TBN)
9434
+ {
9435
+ vec2 uv = mat.normalUVSet == 0 ? uv0 : uv1;
9436
+ vec3 normal = texture2D(tex, uv * mat.normalScale).xyz * 2.0 - 1.0;
9437
+ return normalize(TBN * normal);
9438
+ }
9439
+
9440
+ float sampleAmbientOcclussion(sampler2D tex, vec2 uv0, vec2 uv1, PBRMaterialData mat)
9441
+ {
9442
+ vec2 uv = mat.aoUVSet == 0 ? uv0 : uv1;
9443
+ return texture2D(tex, uv).a;
9444
+ }
9445
+
9446
+ vec3 calcF0(vec3 albedo, PBRMaterialData mat)
9447
+ {
9448
+ return mix(vec3(0.04), albedo, mat.metalness) * mat.fresnelTint.rgb;
9449
+ }
9450
+
9451
+ vec3 calcSheen(vec3 normal, vec3 viewDir, vec3 sheenColor, float sheenIntensity)
9452
+ {
9453
+ float NdotV = max(dot(normal, viewDir), 0.0);
9454
+ float facing = 1.0 - NdotV;
9455
+
9456
+ // Adjustable power: controls how concentrated the brightness is
9457
+ float falloff = pow(facing, 5.0);
9458
+ return sheenColor * falloff * sheenIntensity;
9459
+ }
9427
9460
  `;
9428
9461
  let _t = null;
9429
9462
  function B0() {
@@ -9799,7 +9832,7 @@ const y0 = (t, e) => {
9799
9832
  return t.FUNC_REVERSE_SUBTRACT;
9800
9833
  }
9801
9834
  throw new Error(`Invalid blend equation specified in WebGLPipeline: ${e}`);
9802
- }, ft = (t, e) => {
9835
+ }, lt = (t, e) => {
9803
9836
  switch (e) {
9804
9837
  case R.NULL:
9805
9838
  return null;
@@ -9829,7 +9862,7 @@ const y0 = (t, e) => {
9829
9862
  class On extends hn {
9830
9863
  create() {
9831
9864
  const { gl: e } = this.renderer;
9832
- if (this._blendEquation = y0(e, this.blendState.blendEquation), this._blendFuncSrcColor = ft(e, this.blendState.blendFuncSrc), this._blendFuncSrcAlpha = ft(e, this.blendState.blendFuncSrcAlpha), this._blendFuncDstColor = ft(e, this.blendState.blendFuncDst), this._blendFuncDstAlpha = ft(e, this.blendState.blendFuncDstAlpha), this._blendFuncDstAlpha === null && this._blendFuncSrcAlpha !== null || this._blendFuncDstAlpha !== null && this._blendFuncSrcAlpha === null)
9865
+ if (this._blendEquation = y0(e, this.blendState.blendEquation), this._blendFuncSrcColor = lt(e, this.blendState.blendFuncSrc), this._blendFuncSrcAlpha = lt(e, this.blendState.blendFuncSrcAlpha), this._blendFuncDstColor = lt(e, this.blendState.blendFuncDst), this._blendFuncDstAlpha = lt(e, this.blendState.blendFuncDstAlpha), this._blendFuncDstAlpha === null && this._blendFuncSrcAlpha !== null || this._blendFuncDstAlpha !== null && this._blendFuncSrcAlpha === null)
9833
9866
  throw new Error("WebGLPipeline.create(): Invalid values of blendFuncDstAlpha and blendFuncSrcAlpha");
9834
9867
  this._blendFunc = this._blendFuncDstAlpha !== null ? (r, i) => e.blendFunc(r, i) : (r, i, n, s) => e.blendFuncSeparate(r, i, n, s);
9835
9868
  }
@@ -9977,10 +10010,10 @@ class Gn extends An {
9977
10010
  draw() {
9978
10011
  const { gl: e, state: r } = this.renderer;
9979
10012
  switch (r.cullFaceEnabled = this.polyList.enableCullFace, this.polyList.frontFace) {
9980
- case ut.CCW:
10013
+ case dt.CCW:
9981
10014
  r.frontFace = r.CCW;
9982
10015
  break;
9983
- case ut.CW:
10016
+ case dt.CW:
9984
10017
  r.frontFace = r.CW;
9985
10018
  break;
9986
10019
  }
@@ -10058,7 +10091,7 @@ class Un extends ln {
10058
10091
  const { gl: e } = this.renderer;
10059
10092
  e.bindBuffer(e.ARRAY_BUFFER, this._prevArrayBufferBinding), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._prevElementBufferBinding);
10060
10093
  }
10061
- beginUpdate(e = vt.NONE) {
10094
+ beginUpdate(e = mt.NONE) {
10062
10095
  if (this.type === ve.TEXTURE)
10063
10096
  this.beginUpdateTexture();
10064
10097
  else if (this.type === ve.CUBE_MAP)
@@ -10066,7 +10099,7 @@ class Un extends ln {
10066
10099
  else
10067
10100
  throw new Error("The render buffer is not initialized");
10068
10101
  }
10069
- endUpdate(e = vt.NONE) {
10102
+ endUpdate(e = mt.NONE) {
10070
10103
  if (this.type === ve.TEXTURE)
10071
10104
  this.endUpdateTexture();
10072
10105
  else if (this.type === ve.CUBE_MAP)
@@ -10602,7 +10635,7 @@ const L0 = (t, e) => {
10602
10635
  default:
10603
10636
  throw new Error("Error creating WebGL Texture: invalid target");
10604
10637
  }
10605
- }, lt = (t, e) => {
10638
+ }, ct = (t, e) => {
10606
10639
  if (e === 1)
10607
10640
  return t.CLAMP_TO_EDGE;
10608
10641
  {
@@ -10636,14 +10669,14 @@ const L0 = (t, e) => {
10636
10669
  const { width: n, height: s } = e.size, o = e.renderTargetAttachment === Y.DEPTH_ATTACHMENT, a = o ? t.DEPTH_COMPONENT : t.RGBA;
10637
10670
  let f = o ? t.DEPTH_COMPONENT : t.RGBA;
10638
10671
  const c = o ? t.UNSIGNED_SHORT : i;
10639
- if (t.texParameteri(r, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_WRAP_S, lt(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, lt(t, e.wrapModeY)), r === t.TEXTURE_CUBE_MAP)
10672
+ if (t.texParameteri(r, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(r, t.TEXTURE_WRAP_S, ct(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, ct(t, e.wrapModeY)), r === t.TEXTURE_CUBE_MAP)
10640
10673
  for (let d = 0; d < 6; ++d)
10641
10674
  t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X + d, 0, a, n, s, 0, f, c, null);
10642
10675
  else
10643
10676
  t.texImage2D(r, 0, a, n, s, 0, f, c, null);
10644
10677
  e.imageData.currentSize = new h(e.size);
10645
10678
  } else
10646
- t.texImage2D(r, 0, t.RGBA, t.RGBA, i, e._imageData), t.texParameteri(r, t.TEXTURE_WRAP_S, lt(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, lt(t, e.wrapModeY)), t.texParameteri(r, t.TEXTURE_MAG_FILTER, Zr(t, e.magFilter)), t.texParameteri(r, t.TEXTURE_MIN_FILTER, Zr(t, e.minFilter)), e.mipmapRequired && t.generateMipmap(r);
10679
+ t.texImage2D(r, 0, t.RGBA, t.RGBA, i, e._imageData), t.texParameteri(r, t.TEXTURE_WRAP_S, ct(t, e.wrapModeX)), t.texParameteri(r, t.TEXTURE_WRAP_T, ct(t, e.wrapModeY)), t.texParameteri(r, t.TEXTURE_MAG_FILTER, Zr(t, e.magFilter)), t.texParameteri(r, t.TEXTURE_MIN_FILTER, Zr(t, e.minFilter)), e.mipmapRequired && t.generateMipmap(r);
10647
10680
  };
10648
10681
  class Jn extends Ln {
10649
10682
  static ListTextures(e) {
@@ -10822,7 +10855,7 @@ const U0 = {
10822
10855
  RenderBuffer: ln,
10823
10856
  RenderBufferType: ve,
10824
10857
  RenderBufferTypeName: fn,
10825
- CubeMapFace: vt,
10858
+ CubeMapFace: mt,
10826
10859
  Renderer: Et,
10827
10860
  EngineFeatures: Ve,
10828
10861
  RenderQueue: St,