@darajs/ui-causal-graph-editor 0.4.8

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 (223) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/dist/CanvasPool.5cd3cdcd.js +30 -0
  4. package/dist/SharedSystems.140ebe02.js +1905 -0
  5. package/dist/WebGLRenderer.6ede660f.js +2241 -0
  6. package/dist/WebGPURenderer.f884c756.js +1544 -0
  7. package/dist/browserAll.2dcaa9f7.js +953 -0
  8. package/dist/colorToUniform.7c604fe6.js +76 -0
  9. package/dist/index.a01cfc5f.js +61895 -0
  10. package/dist/index.js +35 -0
  11. package/dist/index.umd.cjs +10287 -0
  12. package/dist/init.73e5c5e2.js +2602 -0
  13. package/dist/style.css +1 -0
  14. package/dist/types/graph-viewer/causal-graph-editor.d.ts +58 -0
  15. package/dist/types/graph-viewer/causal-graph-editor.d.ts.map +1 -0
  16. package/dist/types/graph-viewer/storybook/stories-utils.d.ts +1247 -0
  17. package/dist/types/graph-viewer/storybook/stories-utils.d.ts.map +1 -0
  18. package/dist/types/graph-viewer/utils/use-iterate-edges.d.ts +32 -0
  19. package/dist/types/graph-viewer/utils/use-iterate-edges.d.ts.map +1 -0
  20. package/dist/types/graph-viewer/utils/use-iterate-nodes.d.ts +32 -0
  21. package/dist/types/graph-viewer/utils/use-iterate-nodes.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +32 -0
  23. package/dist/types/index.d.ts.map +1 -0
  24. package/dist/types/jest-setup.d.ts +18 -0
  25. package/dist/types/jest-setup.d.ts.map +1 -0
  26. package/dist/types/node-hierarchy-builder/index.d.ts +19 -0
  27. package/dist/types/node-hierarchy-builder/index.d.ts.map +1 -0
  28. package/dist/types/node-hierarchy-builder/layer-divider.d.ts +15 -0
  29. package/dist/types/node-hierarchy-builder/layer-divider.d.ts.map +1 -0
  30. package/dist/types/node-hierarchy-builder/layer-label-editor.d.ts +24 -0
  31. package/dist/types/node-hierarchy-builder/layer-label-editor.d.ts.map +1 -0
  32. package/dist/types/node-hierarchy-builder/layer.d.ts +35 -0
  33. package/dist/types/node-hierarchy-builder/layer.d.ts.map +1 -0
  34. package/dist/types/node-hierarchy-builder/node-hierarchy-builder.d.ts +27 -0
  35. package/dist/types/node-hierarchy-builder/node-hierarchy-builder.d.ts.map +1 -0
  36. package/dist/types/node-hierarchy-builder/node.d.ts +21 -0
  37. package/dist/types/node-hierarchy-builder/node.d.ts.map +1 -0
  38. package/dist/types/node-hierarchy-builder/shared.d.ts +93 -0
  39. package/dist/types/node-hierarchy-builder/shared.d.ts.map +1 -0
  40. package/dist/types/shared/causal-graph-store.d.ts +118 -0
  41. package/dist/types/shared/causal-graph-store.d.ts.map +1 -0
  42. package/dist/types/shared/editor-overlay/buttons/add-node-button.d.ts +25 -0
  43. package/dist/types/shared/editor-overlay/buttons/add-node-button.d.ts.map +1 -0
  44. package/dist/types/shared/editor-overlay/buttons/center-graph-button.d.ts +7 -0
  45. package/dist/types/shared/editor-overlay/buttons/center-graph-button.d.ts.map +1 -0
  46. package/dist/types/shared/editor-overlay/buttons/collapse-all-button.d.ts +7 -0
  47. package/dist/types/shared/editor-overlay/buttons/collapse-all-button.d.ts.map +1 -0
  48. package/dist/types/shared/editor-overlay/buttons/collapse-expand-button.d.ts +26 -0
  49. package/dist/types/shared/editor-overlay/buttons/collapse-expand-button.d.ts.map +1 -0
  50. package/dist/types/shared/editor-overlay/buttons/drag-mode-button.d.ts +27 -0
  51. package/dist/types/shared/editor-overlay/buttons/drag-mode-button.d.ts.map +1 -0
  52. package/dist/types/shared/editor-overlay/buttons/index.d.ts +24 -0
  53. package/dist/types/shared/editor-overlay/buttons/index.d.ts.map +1 -0
  54. package/dist/types/shared/editor-overlay/buttons/recalculate-layout-button.d.ts +7 -0
  55. package/dist/types/shared/editor-overlay/buttons/recalculate-layout-button.d.ts.map +1 -0
  56. package/dist/types/shared/editor-overlay/buttons/save-image-button.d.ts +7 -0
  57. package/dist/types/shared/editor-overlay/buttons/save-image-button.d.ts.map +1 -0
  58. package/dist/types/shared/editor-overlay/buttons/soft-edge-arrow-button.d.ts +19 -0
  59. package/dist/types/shared/editor-overlay/buttons/soft-edge-arrow-button.d.ts.map +1 -0
  60. package/dist/types/shared/editor-overlay/floating-elements.d.ts +29 -0
  61. package/dist/types/shared/editor-overlay/floating-elements.d.ts.map +1 -0
  62. package/dist/types/shared/editor-overlay/index.d.ts +22 -0
  63. package/dist/types/shared/editor-overlay/index.d.ts.map +1 -0
  64. package/dist/types/shared/editor-overlay/legend/index.d.ts +19 -0
  65. package/dist/types/shared/editor-overlay/legend/index.d.ts.map +1 -0
  66. package/dist/types/shared/editor-overlay/legend/legend-data.d.ts +49 -0
  67. package/dist/types/shared/editor-overlay/legend/legend-data.d.ts.map +1 -0
  68. package/dist/types/shared/editor-overlay/legend/legend-list.d.ts +6 -0
  69. package/dist/types/shared/editor-overlay/legend/legend-list.d.ts.map +1 -0
  70. package/dist/types/shared/editor-overlay/legend/legend.d.ts +7 -0
  71. package/dist/types/shared/editor-overlay/legend/legend.d.ts.map +1 -0
  72. package/dist/types/shared/editor-overlay/overlay.d.ts +42 -0
  73. package/dist/types/shared/editor-overlay/overlay.d.ts.map +1 -0
  74. package/dist/types/shared/editor-overlay/panel-content/edge/edge-editor.d.ts +8 -0
  75. package/dist/types/shared/editor-overlay/panel-content/edge/edge-editor.d.ts.map +1 -0
  76. package/dist/types/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts +41 -0
  77. package/dist/types/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts.map +1 -0
  78. package/dist/types/shared/editor-overlay/panel-content/edge/editor-props.d.ts +35 -0
  79. package/dist/types/shared/editor-overlay/panel-content/edge/editor-props.d.ts.map +1 -0
  80. package/dist/types/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts +23 -0
  81. package/dist/types/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts.map +1 -0
  82. package/dist/types/shared/editor-overlay/panel-content/edge/index.d.ts +18 -0
  83. package/dist/types/shared/editor-overlay/panel-content/edge/index.d.ts.map +1 -0
  84. package/dist/types/shared/editor-overlay/panel-content/edge/pag-editor.d.ts +23 -0
  85. package/dist/types/shared/editor-overlay/panel-content/edge/pag-editor.d.ts.map +1 -0
  86. package/dist/types/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts +7 -0
  87. package/dist/types/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts.map +1 -0
  88. package/dist/types/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts +27 -0
  89. package/dist/types/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts.map +1 -0
  90. package/dist/types/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts +15 -0
  91. package/dist/types/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts.map +1 -0
  92. package/dist/types/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts +21 -0
  93. package/dist/types/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts.map +1 -0
  94. package/dist/types/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts +17 -0
  95. package/dist/types/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts.map +1 -0
  96. package/dist/types/shared/editor-overlay/panel-content/edge/sections/index.d.ts +19 -0
  97. package/dist/types/shared/editor-overlay/panel-content/edge/sections/index.d.ts.map +1 -0
  98. package/dist/types/shared/editor-overlay/panel-content/index.d.ts +20 -0
  99. package/dist/types/shared/editor-overlay/panel-content/index.d.ts.map +1 -0
  100. package/dist/types/shared/editor-overlay/panel-content/node/index.d.ts +18 -0
  101. package/dist/types/shared/editor-overlay/panel-content/node/index.d.ts.map +1 -0
  102. package/dist/types/shared/editor-overlay/panel-content/node/label-editor.d.ts +11 -0
  103. package/dist/types/shared/editor-overlay/panel-content/node/label-editor.d.ts.map +1 -0
  104. package/dist/types/shared/editor-overlay/panel-content/node/node-info-content.d.ts +34 -0
  105. package/dist/types/shared/editor-overlay/panel-content/node/node-info-content.d.ts.map +1 -0
  106. package/dist/types/shared/editor-overlay/panel-content/panel-content.d.ts +17 -0
  107. package/dist/types/shared/editor-overlay/panel-content/panel-content.d.ts.map +1 -0
  108. package/dist/types/shared/editor-overlay/panel-content/panel-title.d.ts +12 -0
  109. package/dist/types/shared/editor-overlay/panel-content/panel-title.d.ts.map +1 -0
  110. package/dist/types/shared/editor-overlay/panel-content/styled.d.ts +9 -0
  111. package/dist/types/shared/editor-overlay/panel-content/styled.d.ts.map +1 -0
  112. package/dist/types/shared/editor-overlay/positional-divs.d.ts +25 -0
  113. package/dist/types/shared/editor-overlay/positional-divs.d.ts.map +1 -0
  114. package/dist/types/shared/editor-overlay/search-bar/index.d.ts +19 -0
  115. package/dist/types/shared/editor-overlay/search-bar/index.d.ts.map +1 -0
  116. package/dist/types/shared/editor-overlay/search-bar/search-bar.d.ts +21 -0
  117. package/dist/types/shared/editor-overlay/search-bar/search-bar.d.ts.map +1 -0
  118. package/dist/types/shared/editor-overlay/search-bar/use-search.d.ts +32 -0
  119. package/dist/types/shared/editor-overlay/search-bar/use-search.d.ts.map +1 -0
  120. package/dist/types/shared/editor-overlay/zoom-prompt.d.ts +9 -0
  121. package/dist/types/shared/editor-overlay/zoom-prompt.d.ts.map +1 -0
  122. package/dist/types/shared/graph-context.d.ts +26 -0
  123. package/dist/types/shared/graph-context.d.ts.map +1 -0
  124. package/dist/types/shared/graph-layout/circular-layout.d.ts +32 -0
  125. package/dist/types/shared/graph-layout/circular-layout.d.ts.map +1 -0
  126. package/dist/types/shared/graph-layout/common.d.ts +96 -0
  127. package/dist/types/shared/graph-layout/common.d.ts.map +1 -0
  128. package/dist/types/shared/graph-layout/custom-layout.d.ts +36 -0
  129. package/dist/types/shared/graph-layout/custom-layout.d.ts.map +1 -0
  130. package/dist/types/shared/graph-layout/fcose-layout.d.ts +132 -0
  131. package/dist/types/shared/graph-layout/fcose-layout.d.ts.map +1 -0
  132. package/dist/types/shared/graph-layout/force-atlas-layout.d.ts +103 -0
  133. package/dist/types/shared/graph-layout/force-atlas-layout.d.ts.map +1 -0
  134. package/dist/types/shared/graph-layout/index.d.ts +25 -0
  135. package/dist/types/shared/graph-layout/index.d.ts.map +1 -0
  136. package/dist/types/shared/graph-layout/marketing-layout.d.ts +63 -0
  137. package/dist/types/shared/graph-layout/marketing-layout.d.ts.map +1 -0
  138. package/dist/types/shared/graph-layout/planar-layout.d.ts +67 -0
  139. package/dist/types/shared/graph-layout/planar-layout.d.ts.map +1 -0
  140. package/dist/types/shared/graph-layout/spring-layout.d.ts +101 -0
  141. package/dist/types/shared/graph-layout/spring-layout.d.ts.map +1 -0
  142. package/dist/types/shared/graph-layout/worker/circular.d.ts +5 -0
  143. package/dist/types/shared/graph-layout/worker/circular.d.ts.map +1 -0
  144. package/dist/types/shared/graph-layout/worker/client.d.ts +22 -0
  145. package/dist/types/shared/graph-layout/worker/client.d.ts.map +1 -0
  146. package/dist/types/shared/graph-layout/worker/fcose.d.ts +18 -0
  147. package/dist/types/shared/graph-layout/worker/fcose.d.ts.map +1 -0
  148. package/dist/types/shared/graph-layout/worker/force-atlas.d.ts +5 -0
  149. package/dist/types/shared/graph-layout/worker/force-atlas.d.ts.map +1 -0
  150. package/dist/types/shared/graph-layout/worker/marketing.d.ts +5 -0
  151. package/dist/types/shared/graph-layout/worker/marketing.d.ts.map +1 -0
  152. package/dist/types/shared/graph-layout/worker/planar.d.ts +5 -0
  153. package/dist/types/shared/graph-layout/worker/planar.d.ts.map +1 -0
  154. package/dist/types/shared/graph-layout/worker/spring.d.ts +19 -0
  155. package/dist/types/shared/graph-layout/worker/spring.d.ts.map +1 -0
  156. package/dist/types/shared/graph-layout/worker/worker.d.ts +27 -0
  157. package/dist/types/shared/graph-layout/worker/worker.d.ts.map +1 -0
  158. package/dist/types/shared/parsers.d.ts +43 -0
  159. package/dist/types/shared/parsers.d.ts.map +1 -0
  160. package/dist/types/shared/pointer-context.d.ts +20 -0
  161. package/dist/types/shared/pointer-context.d.ts.map +1 -0
  162. package/dist/types/shared/rendering/background.d.ts +48 -0
  163. package/dist/types/shared/rendering/background.d.ts.map +1 -0
  164. package/dist/types/shared/rendering/colors.d.ts +27 -0
  165. package/dist/types/shared/rendering/colors.d.ts.map +1 -0
  166. package/dist/types/shared/rendering/edge/curve.d.ts +51 -0
  167. package/dist/types/shared/rendering/edge/curve.d.ts.map +1 -0
  168. package/dist/types/shared/rendering/edge/definitions.d.ts +73 -0
  169. package/dist/types/shared/rendering/edge/definitions.d.ts.map +1 -0
  170. package/dist/types/shared/rendering/edge/edge-object.d.ts +93 -0
  171. package/dist/types/shared/rendering/edge/edge-object.d.ts.map +1 -0
  172. package/dist/types/shared/rendering/edge/index.d.ts +19 -0
  173. package/dist/types/shared/rendering/edge/index.d.ts.map +1 -0
  174. package/dist/types/shared/rendering/edge/symbols.d.ts +40 -0
  175. package/dist/types/shared/rendering/edge/symbols.d.ts.map +1 -0
  176. package/dist/types/shared/rendering/edge/utils.d.ts +27 -0
  177. package/dist/types/shared/rendering/edge/utils.d.ts.map +1 -0
  178. package/dist/types/shared/rendering/engine.d.ts +436 -0
  179. package/dist/types/shared/rendering/engine.d.ts.map +1 -0
  180. package/dist/types/shared/rendering/grouping/group-container-object.d.ts +56 -0
  181. package/dist/types/shared/rendering/grouping/group-container-object.d.ts.map +1 -0
  182. package/dist/types/shared/rendering/grouping/index.d.ts +2 -0
  183. package/dist/types/shared/rendering/grouping/index.d.ts.map +1 -0
  184. package/dist/types/shared/rendering/node/definitions.d.ts +59 -0
  185. package/dist/types/shared/rendering/node/definitions.d.ts.map +1 -0
  186. package/dist/types/shared/rendering/node/index.d.ts +20 -0
  187. package/dist/types/shared/rendering/node/index.d.ts.map +1 -0
  188. package/dist/types/shared/rendering/node/node-object.d.ts +78 -0
  189. package/dist/types/shared/rendering/node/node-object.d.ts.map +1 -0
  190. package/dist/types/shared/rendering/node/utils.d.ts +33 -0
  191. package/dist/types/shared/rendering/node/utils.d.ts.map +1 -0
  192. package/dist/types/shared/rendering/svg.d.ts +26 -0
  193. package/dist/types/shared/rendering/svg.d.ts.map +1 -0
  194. package/dist/types/shared/rendering/text.d.ts +33 -0
  195. package/dist/types/shared/rendering/text.d.ts.map +1 -0
  196. package/dist/types/shared/rendering/texture-cache.d.ts +47 -0
  197. package/dist/types/shared/rendering/texture-cache.d.ts.map +1 -0
  198. package/dist/types/shared/rendering/use-render-engine.d.ts +115 -0
  199. package/dist/types/shared/rendering/use-render-engine.d.ts.map +1 -0
  200. package/dist/types/shared/rendering/utils.d.ts +27 -0
  201. package/dist/types/shared/rendering/utils.d.ts.map +1 -0
  202. package/dist/types/shared/serializer.d.ts +39 -0
  203. package/dist/types/shared/serializer.d.ts.map +1 -0
  204. package/dist/types/shared/settings-context.d.ts +56 -0
  205. package/dist/types/shared/settings-context.d.ts.map +1 -0
  206. package/dist/types/shared/styles.d.ts +4 -0
  207. package/dist/types/shared/styles.d.ts.map +1 -0
  208. package/dist/types/shared/use-causal-graph-editor.d.ts +22 -0
  209. package/dist/types/shared/use-causal-graph-editor.d.ts.map +1 -0
  210. package/dist/types/shared/use-drag-mode.d.ts +33 -0
  211. package/dist/types/shared/use-drag-mode.d.ts.map +1 -0
  212. package/dist/types/shared/use-edge-encoder.d.ts +45 -0
  213. package/dist/types/shared/use-edge-encoder.d.ts.map +1 -0
  214. package/dist/types/shared/use-graph-tooltip.d.ts +15 -0
  215. package/dist/types/shared/use-graph-tooltip.d.ts.map +1 -0
  216. package/dist/types/shared/use-pane-visibility.d.ts +12 -0
  217. package/dist/types/shared/use-pane-visibility.d.ts.map +1 -0
  218. package/dist/types/shared/utils.d.ts +79 -0
  219. package/dist/types/shared/utils.d.ts.map +1 -0
  220. package/dist/types/types.d.ts +277 -0
  221. package/dist/types/types.d.ts.map +1 -0
  222. package/dist/webworkerAll.2e3715a5.js +7 -0
  223. package/package.json +120 -0
@@ -0,0 +1,2241 @@
1
+ import { S as U, E as l, q as B, w as m, a0 as S, y as K, G as Ae, A as Be, z as O, b as p, a9 as $, a5 as g, R as H, a7 as N, a8 as Ne, l as P, O as z, M as Y, L as q, X as Ie, Y as De, N as Z, Z as ye, e as x, aa as Ce, n as Ge } from "./index.a01cfc5f.js";
2
+ import { a as Q } from "./colorToUniform.7c604fe6.js";
3
+ import { e as Ue, G as Oe, c as Pe, b as Fe, U as Me, R as Le, B as J, d as I, f as He, S as we, a as Ve } from "./SharedSystems.140ebe02.js";
4
+ import "react";
5
+ import "styled-components";
6
+ import "react-dom";
7
+ class ee {
8
+ constructor() {
9
+ this._didUpload = !1, this._tempState = U.for2d();
10
+ }
11
+ init(e) {
12
+ e.renderer.runners.contextChange.add(this);
13
+ }
14
+ contextChange() {
15
+ this._didUpload = !1;
16
+ }
17
+ start(e, r, s) {
18
+ const n = e.renderer;
19
+ n.shader.bind(s, this._didUpload), n.shader.updateUniformGroup(n.globalUniforms.uniformGroup), n.geometry.bind(r, s.glProgram);
20
+ }
21
+ execute(e, r) {
22
+ const s = e.renderer;
23
+ this._didUpload = !0, this._tempState.blendMode = r.blendMode, s.state.set(this._tempState);
24
+ const n = r.textures.textures;
25
+ for (let i = 0; i < r.textures.count; i++)
26
+ s.texture.bind(n[i], i);
27
+ s.geometry.draw("triangle-list", r.size, r.start);
28
+ }
29
+ }
30
+ ee.extension = {
31
+ type: [
32
+ l.WebGLPipesAdaptor
33
+ ],
34
+ name: "batch"
35
+ };
36
+ var T = /* @__PURE__ */ ((t) => (t[t.ELEMENT_ARRAY_BUFFER = 34963] = "ELEMENT_ARRAY_BUFFER", t[t.ARRAY_BUFFER = 34962] = "ARRAY_BUFFER", t[t.UNIFORM_BUFFER = 35345] = "UNIFORM_BUFFER", t))(T || {});
37
+ class ke {
38
+ constructor(e, r) {
39
+ this.buffer = e || null, this.updateID = -1, this.byteLength = -1, this.type = r;
40
+ }
41
+ }
42
+ class te {
43
+ constructor(e) {
44
+ this._gpuBuffers = /* @__PURE__ */ Object.create(null), this._boundBufferBases = /* @__PURE__ */ Object.create(null), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_gpuBuffers");
45
+ }
46
+ destroy() {
47
+ this._renderer = null, this._gl = null, this._gpuBuffers = null, this._boundBufferBases = null;
48
+ }
49
+ contextChange() {
50
+ this._gpuBuffers = /* @__PURE__ */ Object.create(null), this._gl = this._renderer.gl;
51
+ }
52
+ getGlBuffer(e) {
53
+ return this._gpuBuffers[e.uid] || this.createGLBuffer(e);
54
+ }
55
+ bind(e) {
56
+ const { _gl: r } = this, s = this.getGlBuffer(e);
57
+ r.bindBuffer(s.type, s.buffer);
58
+ }
59
+ bindBufferBase(e, r) {
60
+ const { _gl: s } = this;
61
+ if (this._boundBufferBases[r] !== e) {
62
+ const n = this.getGlBuffer(e);
63
+ this._boundBufferBases[r] = e, s.bindBufferBase(s.UNIFORM_BUFFER, r, n.buffer);
64
+ }
65
+ }
66
+ bindBufferRange(e, r, s) {
67
+ const { _gl: n } = this;
68
+ s = s || 0;
69
+ const i = this.getGlBuffer(e);
70
+ n.bindBufferRange(n.UNIFORM_BUFFER, r || 0, i.buffer, s * 256, 256);
71
+ }
72
+ updateBuffer(e) {
73
+ const { _gl: r } = this, s = this.getGlBuffer(e);
74
+ if (e._updateID === s.updateID)
75
+ return s;
76
+ s.updateID = e._updateID, r.bindBuffer(s.type, s.buffer);
77
+ const n = e.data;
78
+ if (s.byteLength >= e.data.byteLength)
79
+ r.bufferSubData(s.type, 0, n, 0, e._updateSize / n.BYTES_PER_ELEMENT);
80
+ else {
81
+ const i = e.descriptor.usage & B.STATIC ? r.STATIC_DRAW : r.DYNAMIC_DRAW;
82
+ s.byteLength = n.byteLength, r.bufferData(s.type, n, i);
83
+ }
84
+ return s;
85
+ }
86
+ destroyAll() {
87
+ const e = this._gl;
88
+ for (const r in this._gpuBuffers)
89
+ e.deleteBuffer(this._gpuBuffers[r].buffer);
90
+ this._gpuBuffers = /* @__PURE__ */ Object.create(null);
91
+ }
92
+ onBufferDestroy(e, r) {
93
+ const s = this._gpuBuffers[e.uid], n = this._gl;
94
+ r || n.deleteBuffer(s.buffer), this._gpuBuffers[e.uid] = null;
95
+ }
96
+ createGLBuffer(e) {
97
+ const { _gl: r } = this;
98
+ let s = T.ARRAY_BUFFER;
99
+ e.descriptor.usage & B.INDEX ? s = T.ELEMENT_ARRAY_BUFFER : e.descriptor.usage & B.UNIFORM && (s = T.UNIFORM_BUFFER);
100
+ const n = new ke(r.createBuffer(), s);
101
+ return this._gpuBuffers[e.uid] = n, e.on("destroy", this.onBufferDestroy, this), n;
102
+ }
103
+ }
104
+ te.extension = {
105
+ type: [
106
+ l.WebGLSystem
107
+ ],
108
+ name: "buffer"
109
+ };
110
+ const F = class re {
111
+ constructor(e) {
112
+ this.supports = {
113
+ uint32Indices: !0,
114
+ uniformBufferObject: !0,
115
+ vertexArrayObject: !0,
116
+ srgbTextures: !0,
117
+ nonPowOf2wrapping: !0,
118
+ msaa: !0,
119
+ nonPowOf2mipmaps: !0
120
+ }, this._renderer = e, this.extensions = /* @__PURE__ */ Object.create(null), this.handleContextLost = this.handleContextLost.bind(this), this.handleContextRestored = this.handleContextRestored.bind(this);
121
+ }
122
+ get isLost() {
123
+ return !this.gl || this.gl.isContextLost();
124
+ }
125
+ contextChange(e) {
126
+ this.gl = e, this._renderer.gl = e;
127
+ }
128
+ init(e) {
129
+ var s, n;
130
+ e = { ...re.defaultOptions, ...e };
131
+ let r = this.multiView = e.multiView;
132
+ if (e.context && r && (m("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."), r = !1), r ? this.canvas = S.get().createCanvas(this._renderer.canvas.width, this._renderer.canvas.height) : this.canvas = this._renderer.view.canvas, e.context)
133
+ this.initFromContext(e.context);
134
+ else {
135
+ const i = this._renderer.background.alpha < 1, a = (s = e.premultipliedAlpha) != null ? s : !0, o = e.antialias && !this._renderer.backBuffer.useBackBuffer;
136
+ this.createContext(e.preferWebGLVersion, {
137
+ alpha: i,
138
+ premultipliedAlpha: a,
139
+ antialias: o,
140
+ stencil: !0,
141
+ preserveDrawingBuffer: e.preserveDrawingBuffer,
142
+ powerPreference: (n = e.powerPreference) != null ? n : "default"
143
+ });
144
+ }
145
+ }
146
+ ensureCanvasSize(e) {
147
+ if (!this.multiView) {
148
+ e !== this.canvas && m("multiView is disabled, but targetCanvas is not the main canvas");
149
+ return;
150
+ }
151
+ const { canvas: r } = this;
152
+ (r.width < e.width || r.height < e.height) && (r.width = Math.max(e.width, e.width), r.height = Math.max(e.height, e.height));
153
+ }
154
+ initFromContext(e) {
155
+ this.gl = e, this.webGLVersion = e instanceof S.get().getWebGLRenderingContext() ? 1 : 2, this.getExtensions(), this.validateContext(e), this._renderer.runners.contextChange.emit(e);
156
+ const r = this._renderer.view.canvas;
157
+ r.addEventListener("webglcontextlost", this.handleContextLost, !1), r.addEventListener("webglcontextrestored", this.handleContextRestored, !1);
158
+ }
159
+ createContext(e, r) {
160
+ let s;
161
+ const n = this.canvas;
162
+ if (e === 2 && (s = n.getContext("webgl2", r)), !s && (s = n.getContext("webgl", r), !s))
163
+ throw new Error("This browser does not support WebGL. Try using the canvas renderer");
164
+ this.gl = s, this.initFromContext(this.gl);
165
+ }
166
+ getExtensions() {
167
+ const { gl: e } = this, r = {
168
+ anisotropicFiltering: e.getExtension("EXT_texture_filter_anisotropic"),
169
+ floatTextureLinear: e.getExtension("OES_texture_float_linear"),
170
+ s3tc: e.getExtension("WEBGL_compressed_texture_s3tc"),
171
+ s3tc_sRGB: e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),
172
+ etc: e.getExtension("WEBGL_compressed_texture_etc"),
173
+ etc1: e.getExtension("WEBGL_compressed_texture_etc1"),
174
+ pvrtc: e.getExtension("WEBGL_compressed_texture_pvrtc") || e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
175
+ atc: e.getExtension("WEBGL_compressed_texture_atc"),
176
+ astc: e.getExtension("WEBGL_compressed_texture_astc"),
177
+ bptc: e.getExtension("EXT_texture_compression_bptc"),
178
+ rgtc: e.getExtension("EXT_texture_compression_rgtc"),
179
+ loseContext: e.getExtension("WEBGL_lose_context")
180
+ };
181
+ if (this.webGLVersion === 1)
182
+ this.extensions = {
183
+ ...r,
184
+ drawBuffers: e.getExtension("WEBGL_draw_buffers"),
185
+ depthTexture: e.getExtension("WEBGL_depth_texture"),
186
+ vertexArrayObject: e.getExtension("OES_vertex_array_object") || e.getExtension("MOZ_OES_vertex_array_object") || e.getExtension("WEBKIT_OES_vertex_array_object"),
187
+ uint32ElementIndex: e.getExtension("OES_element_index_uint"),
188
+ floatTexture: e.getExtension("OES_texture_float"),
189
+ floatTextureLinear: e.getExtension("OES_texture_float_linear"),
190
+ textureHalfFloat: e.getExtension("OES_texture_half_float"),
191
+ textureHalfFloatLinear: e.getExtension("OES_texture_half_float_linear"),
192
+ vertexAttribDivisorANGLE: e.getExtension("ANGLE_instanced_arrays"),
193
+ srgb: e.getExtension("EXT_sRGB")
194
+ };
195
+ else {
196
+ this.extensions = {
197
+ ...r,
198
+ colorBufferFloat: e.getExtension("EXT_color_buffer_float")
199
+ };
200
+ const s = e.getExtension("WEBGL_provoking_vertex");
201
+ s && s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL);
202
+ }
203
+ }
204
+ handleContextLost(e) {
205
+ e.preventDefault(), this._contextLossForced && (this._contextLossForced = !1, setTimeout(() => {
206
+ var r;
207
+ this.gl.isContextLost() && ((r = this.extensions.loseContext) == null || r.restoreContext());
208
+ }, 0));
209
+ }
210
+ handleContextRestored() {
211
+ this._renderer.runners.contextChange.emit(this.gl);
212
+ }
213
+ destroy() {
214
+ var r;
215
+ const e = this._renderer.view.canvas;
216
+ this._renderer = null, e.removeEventListener("webglcontextlost", this.handleContextLost), e.removeEventListener("webglcontextrestored", this.handleContextRestored), this.gl.useProgram(null), (r = this.extensions.loseContext) == null || r.loseContext();
217
+ }
218
+ forceContextLoss() {
219
+ var e;
220
+ (e = this.extensions.loseContext) == null || e.loseContext(), this._contextLossForced = !0;
221
+ }
222
+ validateContext(e) {
223
+ const r = e.getContextAttributes();
224
+ r && !r.stencil && m("Provided WebGL context does not have a stencil buffer, masks may not render correctly");
225
+ const s = this.supports, n = this.webGLVersion === 2, i = this.extensions;
226
+ s.uint32Indices = n || !!i.uint32ElementIndex, s.uniformBufferObject = n, s.vertexArrayObject = n || !!i.vertexArrayObject, s.srgbTextures = n || !!i.srgb, s.nonPowOf2wrapping = n, s.nonPowOf2mipmaps = n, s.msaa = n, s.uint32Indices || m("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly");
227
+ }
228
+ };
229
+ F.extension = {
230
+ type: [
231
+ l.WebGLSystem
232
+ ],
233
+ name: "context"
234
+ };
235
+ F.defaultOptions = {
236
+ context: null,
237
+ premultipliedAlpha: !0,
238
+ preserveDrawingBuffer: !1,
239
+ powerPreference: void 0,
240
+ preferWebGLVersion: 2,
241
+ multiView: !1
242
+ };
243
+ let Xe = F;
244
+ var C = /* @__PURE__ */ ((t) => (t[t.RGBA = 6408] = "RGBA", t[t.RGB = 6407] = "RGB", t[t.RG = 33319] = "RG", t[t.RED = 6403] = "RED", t[t.RGBA_INTEGER = 36249] = "RGBA_INTEGER", t[t.RGB_INTEGER = 36248] = "RGB_INTEGER", t[t.RG_INTEGER = 33320] = "RG_INTEGER", t[t.RED_INTEGER = 36244] = "RED_INTEGER", t[t.ALPHA = 6406] = "ALPHA", t[t.LUMINANCE = 6409] = "LUMINANCE", t[t.LUMINANCE_ALPHA = 6410] = "LUMINANCE_ALPHA", t[t.DEPTH_COMPONENT = 6402] = "DEPTH_COMPONENT", t[t.DEPTH_STENCIL = 34041] = "DEPTH_STENCIL", t))(C || {}), se = /* @__PURE__ */ ((t) => (t[t.TEXTURE_2D = 3553] = "TEXTURE_2D", t[t.TEXTURE_CUBE_MAP = 34067] = "TEXTURE_CUBE_MAP", t[t.TEXTURE_2D_ARRAY = 35866] = "TEXTURE_2D_ARRAY", t[t.TEXTURE_CUBE_MAP_POSITIVE_X = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X", t[t.TEXTURE_CUBE_MAP_NEGATIVE_X = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X", t[t.TEXTURE_CUBE_MAP_POSITIVE_Y = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y", t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y", t[t.TEXTURE_CUBE_MAP_POSITIVE_Z = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z", t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z", t))(se || {}), f = /* @__PURE__ */ ((t) => (t[t.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE", t[t.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT", t[t.UNSIGNED_SHORT_5_6_5 = 33635] = "UNSIGNED_SHORT_5_6_5", t[t.UNSIGNED_SHORT_4_4_4_4 = 32819] = "UNSIGNED_SHORT_4_4_4_4", t[t.UNSIGNED_SHORT_5_5_5_1 = 32820] = "UNSIGNED_SHORT_5_5_5_1", t[t.UNSIGNED_INT = 5125] = "UNSIGNED_INT", t[t.UNSIGNED_INT_10F_11F_11F_REV = 35899] = "UNSIGNED_INT_10F_11F_11F_REV", t[t.UNSIGNED_INT_2_10_10_10_REV = 33640] = "UNSIGNED_INT_2_10_10_10_REV", t[t.UNSIGNED_INT_24_8 = 34042] = "UNSIGNED_INT_24_8", t[t.UNSIGNED_INT_5_9_9_9_REV = 35902] = "UNSIGNED_INT_5_9_9_9_REV", t[t.BYTE = 5120] = "BYTE", t[t.SHORT = 5122] = "SHORT", t[t.INT = 5124] = "INT", t[t.FLOAT = 5126] = "FLOAT", t[t.FLOAT_32_UNSIGNED_INT_24_8_REV = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV", t[t.HALF_FLOAT = 36193] = "HALF_FLOAT", t))(f || {});
245
+ const w = {
246
+ uint8x2: f.UNSIGNED_BYTE,
247
+ uint8x4: f.UNSIGNED_BYTE,
248
+ sint8x2: f.BYTE,
249
+ sint8x4: f.BYTE,
250
+ unorm8x2: f.UNSIGNED_BYTE,
251
+ unorm8x4: f.UNSIGNED_BYTE,
252
+ snorm8x2: f.BYTE,
253
+ snorm8x4: f.BYTE,
254
+ uint16x2: f.UNSIGNED_SHORT,
255
+ uint16x4: f.UNSIGNED_SHORT,
256
+ sint16x2: f.SHORT,
257
+ sint16x4: f.SHORT,
258
+ unorm16x2: f.UNSIGNED_SHORT,
259
+ unorm16x4: f.UNSIGNED_SHORT,
260
+ snorm16x2: f.SHORT,
261
+ snorm16x4: f.SHORT,
262
+ float16x2: f.HALF_FLOAT,
263
+ float16x4: f.HALF_FLOAT,
264
+ float32: f.FLOAT,
265
+ float32x2: f.FLOAT,
266
+ float32x3: f.FLOAT,
267
+ float32x4: f.FLOAT,
268
+ uint32: f.UNSIGNED_INT,
269
+ uint32x2: f.UNSIGNED_INT,
270
+ uint32x3: f.UNSIGNED_INT,
271
+ uint32x4: f.UNSIGNED_INT,
272
+ sint32: f.INT,
273
+ sint32x2: f.INT,
274
+ sint32x3: f.INT,
275
+ sint32x4: f.INT
276
+ };
277
+ function We(t) {
278
+ var e;
279
+ return (e = w[t]) != null ? e : w.float32;
280
+ }
281
+ const je = {
282
+ "point-list": 0,
283
+ "line-list": 1,
284
+ "line-strip": 3,
285
+ "triangle-list": 4,
286
+ "triangle-strip": 5
287
+ };
288
+ class ne {
289
+ constructor(e) {
290
+ this._geometryVaoHash = /* @__PURE__ */ Object.create(null), this._renderer = e, this._activeGeometry = null, this._activeVao = null, this.hasVao = !0, this.hasInstance = !0, this._renderer.renderableGC.addManagedHash(this, "_geometryVaoHash");
291
+ }
292
+ contextChange() {
293
+ const e = this.gl = this._renderer.gl;
294
+ if (!this._renderer.context.supports.vertexArrayObject)
295
+ throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");
296
+ const r = this._renderer.context.extensions.vertexArrayObject;
297
+ r && (e.createVertexArray = () => r.createVertexArrayOES(), e.bindVertexArray = (n) => r.bindVertexArrayOES(n), e.deleteVertexArray = (n) => r.deleteVertexArrayOES(n));
298
+ const s = this._renderer.context.extensions.vertexAttribDivisorANGLE;
299
+ s && (e.drawArraysInstanced = (n, i, a, o) => {
300
+ s.drawArraysInstancedANGLE(n, i, a, o);
301
+ }, e.drawElementsInstanced = (n, i, a, o, c) => {
302
+ s.drawElementsInstancedANGLE(n, i, a, o, c);
303
+ }, e.vertexAttribDivisor = (n, i) => s.vertexAttribDivisorANGLE(n, i)), this._activeGeometry = null, this._activeVao = null, this._geometryVaoHash = /* @__PURE__ */ Object.create(null);
304
+ }
305
+ bind(e, r) {
306
+ const s = this.gl;
307
+ this._activeGeometry = e;
308
+ const n = this.getVao(e, r);
309
+ this._activeVao !== n && (this._activeVao = n, s.bindVertexArray(n)), this.updateBuffers();
310
+ }
311
+ reset() {
312
+ this.unbind();
313
+ }
314
+ updateBuffers() {
315
+ const e = this._activeGeometry, r = this._renderer.buffer;
316
+ for (let s = 0; s < e.buffers.length; s++) {
317
+ const n = e.buffers[s];
318
+ r.updateBuffer(n);
319
+ }
320
+ }
321
+ checkCompatibility(e, r) {
322
+ const s = e.attributes, n = r._attributeData;
323
+ for (const i in n)
324
+ if (!s[i])
325
+ throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`);
326
+ }
327
+ getSignature(e, r) {
328
+ const s = e.attributes, n = r._attributeData, i = ["g", e.uid];
329
+ for (const a in s)
330
+ n[a] && i.push(a, n[a].location);
331
+ return i.join("-");
332
+ }
333
+ getVao(e, r) {
334
+ var s;
335
+ return ((s = this._geometryVaoHash[e.uid]) == null ? void 0 : s[r._key]) || this.initGeometryVao(e, r);
336
+ }
337
+ initGeometryVao(e, r, s = !0) {
338
+ const n = this._renderer.gl, i = this._renderer.buffer;
339
+ this._renderer.shader._getProgramData(r), this.checkCompatibility(e, r);
340
+ const a = this.getSignature(e, r);
341
+ this._geometryVaoHash[e.uid] || (this._geometryVaoHash[e.uid] = /* @__PURE__ */ Object.create(null), e.on("destroy", this.onGeometryDestroy, this));
342
+ const o = this._geometryVaoHash[e.uid];
343
+ let c = o[a];
344
+ if (c)
345
+ return o[r._key] = c, c;
346
+ Ue(e, r._attributeData);
347
+ const u = e.buffers;
348
+ c = n.createVertexArray(), n.bindVertexArray(c);
349
+ for (let _ = 0; _ < u.length; _++) {
350
+ const h = u[_];
351
+ i.bind(h);
352
+ }
353
+ return this.activateVao(e, r), o[r._key] = c, o[a] = c, n.bindVertexArray(null), c;
354
+ }
355
+ onGeometryDestroy(e, r) {
356
+ const s = this._geometryVaoHash[e.uid], n = this.gl;
357
+ if (s) {
358
+ if (r)
359
+ for (const i in s)
360
+ this._activeVao !== s[i] && this.unbind(), n.deleteVertexArray(s[i]);
361
+ this._geometryVaoHash[e.uid] = null;
362
+ }
363
+ }
364
+ destroyAll(e = !1) {
365
+ const r = this.gl;
366
+ for (const s in this._geometryVaoHash) {
367
+ if (e)
368
+ for (const n in this._geometryVaoHash[s]) {
369
+ const i = this._geometryVaoHash[s];
370
+ this._activeVao !== i && this.unbind(), r.deleteVertexArray(i[n]);
371
+ }
372
+ this._geometryVaoHash[s] = null;
373
+ }
374
+ }
375
+ activateVao(e, r) {
376
+ var o, c;
377
+ const s = this._renderer.gl, n = this._renderer.buffer, i = e.attributes;
378
+ e.indexBuffer && n.bind(e.indexBuffer);
379
+ let a = null;
380
+ for (const u in i) {
381
+ const _ = i[u], h = _.buffer, d = n.getGlBuffer(h), b = r._attributeData[u];
382
+ if (b) {
383
+ a !== d && (n.bind(h), a = d);
384
+ const E = b.location;
385
+ s.enableVertexAttribArray(E);
386
+ const A = K(_.format), L = We(_.format);
387
+ if (((o = b.format) == null ? void 0 : o.substring(1, 4)) === "int" ? s.vertexAttribIPointer(
388
+ E,
389
+ A.size,
390
+ L,
391
+ _.stride,
392
+ _.offset
393
+ ) : s.vertexAttribPointer(
394
+ E,
395
+ A.size,
396
+ L,
397
+ A.normalised,
398
+ _.stride,
399
+ _.offset
400
+ ), _.instance)
401
+ if (this.hasInstance) {
402
+ const xe = (c = _.divisor) != null ? c : 1;
403
+ s.vertexAttribDivisor(E, xe);
404
+ } else
405
+ throw new Error("geometry error, GPU Instancing is not supported on this device");
406
+ }
407
+ }
408
+ }
409
+ draw(e, r, s, n) {
410
+ const { gl: i } = this._renderer, a = this._activeGeometry, o = je[a.topology || e];
411
+ if (n || (n = a.instanceCount), a.indexBuffer) {
412
+ const c = a.indexBuffer.data.BYTES_PER_ELEMENT, u = c === 2 ? i.UNSIGNED_SHORT : i.UNSIGNED_INT;
413
+ n > 1 ? i.drawElementsInstanced(o, r || a.indexBuffer.data.length, u, (s || 0) * c, n) : i.drawElements(o, r || a.indexBuffer.data.length, u, (s || 0) * c);
414
+ } else
415
+ n > 1 ? i.drawArraysInstanced(o, s || 0, r || a.getSize(), n) : i.drawArrays(o, s || 0, r || a.getSize());
416
+ return this;
417
+ }
418
+ unbind() {
419
+ this.gl.bindVertexArray(null), this._activeVao = null, this._activeGeometry = null;
420
+ }
421
+ destroy() {
422
+ this._renderer = null, this.gl = null, this._activeVao = null, this._activeGeometry = null;
423
+ }
424
+ }
425
+ ne.extension = {
426
+ type: [
427
+ l.WebGLSystem
428
+ ],
429
+ name: "geometry"
430
+ };
431
+ const Ke = new Ae({
432
+ attributes: {
433
+ aPosition: [
434
+ -1,
435
+ -1,
436
+ 3,
437
+ -1,
438
+ -1,
439
+ 3
440
+ ]
441
+ }
442
+ }), M = class ie {
443
+ constructor(e) {
444
+ this.useBackBuffer = !1, this._useBackBufferThisRender = !1, this._renderer = e;
445
+ }
446
+ init(e = {}) {
447
+ const { useBackBuffer: r, antialias: s } = { ...ie.defaultOptions, ...e };
448
+ this.useBackBuffer = r, this._antialias = s, this._renderer.context.supports.msaa || (m("antialiasing, is not supported on when using the back buffer"), this._antialias = !1), this._state = U.for2d();
449
+ const n = new Be({
450
+ vertex: `
451
+ attribute vec2 aPosition;
452
+ out vec2 vUv;
453
+
454
+ void main() {
455
+ gl_Position = vec4(aPosition, 0.0, 1.0);
456
+
457
+ vUv = (aPosition + 1.0) / 2.0;
458
+
459
+ // flip dem UVs
460
+ vUv.y = 1.0 - vUv.y;
461
+ }`,
462
+ fragment: `
463
+ in vec2 vUv;
464
+ out vec4 finalColor;
465
+
466
+ uniform sampler2D uTexture;
467
+
468
+ void main() {
469
+ finalColor = texture(uTexture, vUv);
470
+ }`,
471
+ name: "big-triangle"
472
+ });
473
+ this._bigTriangleShader = new O({
474
+ glProgram: n,
475
+ resources: {
476
+ uTexture: p.WHITE.source
477
+ }
478
+ });
479
+ }
480
+ renderStart(e) {
481
+ const r = this._renderer.renderTarget.getRenderTarget(e.target);
482
+ if (this._useBackBufferThisRender = this.useBackBuffer && !!r.isRoot, this._useBackBufferThisRender) {
483
+ const s = this._renderer.renderTarget.getRenderTarget(e.target);
484
+ this._targetTexture = s.colorTexture, e.target = this._getBackBufferTexture(s.colorTexture);
485
+ }
486
+ }
487
+ renderEnd() {
488
+ this._presentBackBuffer();
489
+ }
490
+ _presentBackBuffer() {
491
+ const e = this._renderer;
492
+ e.renderTarget.finishRenderPass(), this._useBackBufferThisRender && (e.renderTarget.bind(this._targetTexture, !1), this._bigTriangleShader.resources.uTexture = this._backBufferTexture.source, e.encoder.draw({
493
+ geometry: Ke,
494
+ shader: this._bigTriangleShader,
495
+ state: this._state
496
+ }));
497
+ }
498
+ _getBackBufferTexture(e) {
499
+ return this._backBufferTexture = this._backBufferTexture || new p({
500
+ source: new $({
501
+ width: e.width,
502
+ height: e.height,
503
+ resolution: e._resolution,
504
+ antialias: this._antialias
505
+ })
506
+ }), this._backBufferTexture.source.resize(
507
+ e.width,
508
+ e.height,
509
+ e._resolution
510
+ ), this._backBufferTexture;
511
+ }
512
+ destroy() {
513
+ this._backBufferTexture && (this._backBufferTexture.destroy(), this._backBufferTexture = null);
514
+ }
515
+ };
516
+ M.extension = {
517
+ type: [
518
+ l.WebGLSystem
519
+ ],
520
+ name: "backBuffer",
521
+ priority: 1
522
+ };
523
+ M.defaultOptions = {
524
+ useBackBuffer: !1
525
+ };
526
+ let $e = M;
527
+ class ae {
528
+ constructor(e) {
529
+ this._colorMaskCache = 15, this._renderer = e;
530
+ }
531
+ setMask(e) {
532
+ this._colorMaskCache !== e && (this._colorMaskCache = e, this._renderer.gl.colorMask(
533
+ !!(e & 8),
534
+ !!(e & 4),
535
+ !!(e & 2),
536
+ !!(e & 1)
537
+ ));
538
+ }
539
+ }
540
+ ae.extension = {
541
+ type: [
542
+ l.WebGLSystem
543
+ ],
544
+ name: "colorMask"
545
+ };
546
+ class oe {
547
+ constructor(e) {
548
+ this.commandFinished = Promise.resolve(), this._renderer = e;
549
+ }
550
+ setGeometry(e, r) {
551
+ this._renderer.geometry.bind(e, r.glProgram);
552
+ }
553
+ finishRenderPass() {
554
+ }
555
+ draw(e) {
556
+ const r = this._renderer, { geometry: s, shader: n, state: i, skipSync: a, topology: o, size: c, start: u, instanceCount: _ } = e;
557
+ r.shader.bind(n, a), r.geometry.bind(s, r.shader._activeProgram), i && r.state.set(i), r.geometry.draw(o, c, u, _ != null ? _ : s.instanceCount);
558
+ }
559
+ destroy() {
560
+ this._renderer = null;
561
+ }
562
+ }
563
+ oe.extension = {
564
+ type: [
565
+ l.WebGLSystem
566
+ ],
567
+ name: "encoder"
568
+ };
569
+ class ze {
570
+ constructor() {
571
+ this.width = -1, this.height = -1, this.msaa = !1, this.msaaRenderBuffer = [];
572
+ }
573
+ }
574
+ class ce {
575
+ constructor(e) {
576
+ this._stencilCache = {
577
+ enabled: !1,
578
+ stencilReference: 0,
579
+ stencilMode: g.NONE
580
+ }, this._renderTargetStencilState = /* @__PURE__ */ Object.create(null), e.renderTarget.onRenderTargetChange.add(this);
581
+ }
582
+ contextChange(e) {
583
+ this._gl = e, this._comparisonFuncMapping = {
584
+ always: e.ALWAYS,
585
+ never: e.NEVER,
586
+ equal: e.EQUAL,
587
+ "not-equal": e.NOTEQUAL,
588
+ less: e.LESS,
589
+ "less-equal": e.LEQUAL,
590
+ greater: e.GREATER,
591
+ "greater-equal": e.GEQUAL
592
+ }, this._stencilOpsMapping = {
593
+ keep: e.KEEP,
594
+ zero: e.ZERO,
595
+ replace: e.REPLACE,
596
+ invert: e.INVERT,
597
+ "increment-clamp": e.INCR,
598
+ "decrement-clamp": e.DECR,
599
+ "increment-wrap": e.INCR_WRAP,
600
+ "decrement-wrap": e.DECR_WRAP
601
+ }, this._stencilCache.enabled = !1, this._stencilCache.stencilMode = g.NONE, this._stencilCache.stencilReference = 0;
602
+ }
603
+ onRenderTargetChange(e) {
604
+ if (this._activeRenderTarget === e)
605
+ return;
606
+ this._activeRenderTarget = e;
607
+ let r = this._renderTargetStencilState[e.uid];
608
+ r || (r = this._renderTargetStencilState[e.uid] = {
609
+ stencilMode: g.DISABLED,
610
+ stencilReference: 0
611
+ }), this.setStencilMode(r.stencilMode, r.stencilReference);
612
+ }
613
+ setStencilMode(e, r) {
614
+ const s = this._renderTargetStencilState[this._activeRenderTarget.uid], n = this._gl, i = Oe[e], a = this._stencilCache;
615
+ if (s.stencilMode = e, s.stencilReference = r, e === g.DISABLED) {
616
+ this._stencilCache.enabled && (this._stencilCache.enabled = !1, n.disable(n.STENCIL_TEST));
617
+ return;
618
+ }
619
+ this._stencilCache.enabled || (this._stencilCache.enabled = !0, n.enable(n.STENCIL_TEST)), (e !== a.stencilMode || a.stencilReference !== r) && (a.stencilMode = e, a.stencilReference = r, n.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare], r, 255), n.stencilOp(n.KEEP, n.KEEP, this._stencilOpsMapping[i.stencilBack.passOp]));
620
+ }
621
+ }
622
+ ce.extension = {
623
+ type: [
624
+ l.WebGLSystem
625
+ ],
626
+ name: "stencil"
627
+ };
628
+ const ue = {
629
+ f32: 4,
630
+ "vec2<f32>": 8,
631
+ "vec3<f32>": 12,
632
+ "vec4<f32>": 16,
633
+ "mat2x2<f32>": 16 * 2,
634
+ "mat3x3<f32>": 16 * 3,
635
+ "mat4x4<f32>": 16 * 4
636
+ };
637
+ function Ye(t) {
638
+ const e = t.map((i) => ({
639
+ data: i,
640
+ offset: 0,
641
+ size: 0
642
+ }));
643
+ let r = 0, s = 0, n = 0;
644
+ for (let i = 0; i < e.length; i++) {
645
+ const a = e[i];
646
+ if (r = ue[a.data.type], !r)
647
+ throw new Error(`Unknown type ${a.data.type}`);
648
+ if (a.data.size > 1 && (r = Math.max(r, 16) * a.data.size), a.size = r, s % r !== 0 && s < 16) {
649
+ const o = s % r % 16;
650
+ s += o, n += o;
651
+ }
652
+ s + r > 16 ? (n = Math.ceil(n / 16) * 16, a.offset = n, n += r, s = r) : (a.offset = n, s += r, n += r);
653
+ }
654
+ return n = Math.ceil(n / 16) * 16, { uboElements: e, size: n };
655
+ }
656
+ function qe(t, e) {
657
+ const r = Math.max(ue[t.data.type] / 16, 1), s = t.data.value.length / t.data.size, n = (4 - s % 4) % 4;
658
+ return `
659
+ v = uv.${t.data.name};
660
+ offset += ${e};
661
+
662
+ arrayOffset = offset;
663
+
664
+ t = 0;
665
+
666
+ for(var i=0; i < ${t.data.size * r}; i++)
667
+ {
668
+ for(var j = 0; j < ${s}; j++)
669
+ {
670
+ data[arrayOffset++] = v[t++];
671
+ }
672
+ ${n !== 0 ? `arrayOffset += ${n};` : ""}
673
+ }
674
+ `;
675
+ }
676
+ function Ze(t) {
677
+ return Pe(
678
+ t,
679
+ "uboStd40",
680
+ qe,
681
+ Fe
682
+ );
683
+ }
684
+ class _e extends Me {
685
+ constructor() {
686
+ super({
687
+ createUboElements: Ye,
688
+ generateUboSync: Ze
689
+ });
690
+ }
691
+ }
692
+ _e.extension = {
693
+ type: [l.WebGLSystem],
694
+ name: "ubo"
695
+ };
696
+ class Qe {
697
+ constructor() {
698
+ this._clearColorCache = [0, 0, 0, 0], this._viewPortCache = new H();
699
+ }
700
+ init(e, r) {
701
+ this._renderer = e, this._renderTargetSystem = r, e.runners.contextChange.add(this);
702
+ }
703
+ contextChange() {
704
+ this._clearColorCache = [0, 0, 0, 0], this._viewPortCache = new H();
705
+ }
706
+ copyToTexture(e, r, s, n, i) {
707
+ const a = this._renderTargetSystem, o = this._renderer, c = a.getGpuRenderTarget(e), u = o.gl;
708
+ return this.finishRenderPass(e), u.bindFramebuffer(u.FRAMEBUFFER, c.resolveTargetFramebuffer), o.texture.bind(r, 0), u.copyTexSubImage2D(
709
+ u.TEXTURE_2D,
710
+ 0,
711
+ i.x,
712
+ i.y,
713
+ s.x,
714
+ s.y,
715
+ n.width,
716
+ n.height
717
+ ), r;
718
+ }
719
+ startRenderPass(e, r = !0, s, n) {
720
+ const i = this._renderTargetSystem, a = e.colorTexture, o = i.getGpuRenderTarget(e);
721
+ let c = n.y;
722
+ e.isRoot && (c = a.pixelHeight - n.height), e.colorTextures.forEach((h) => {
723
+ this._renderer.texture.unbind(h);
724
+ });
725
+ const u = this._renderer.gl;
726
+ u.bindFramebuffer(u.FRAMEBUFFER, o.framebuffer);
727
+ const _ = this._viewPortCache;
728
+ (_.x !== n.x || _.y !== c || _.width !== n.width || _.height !== n.height) && (_.x = n.x, _.y = c, _.width = n.width, _.height = n.height, u.viewport(
729
+ n.x,
730
+ c,
731
+ n.width,
732
+ n.height
733
+ )), !o.depthStencilRenderBuffer && (e.stencil || e.depth) && this._initStencil(o), this.clear(e, r, s);
734
+ }
735
+ finishRenderPass(e) {
736
+ const s = this._renderTargetSystem.getGpuRenderTarget(e);
737
+ if (!s.msaa)
738
+ return;
739
+ const n = this._renderer.gl;
740
+ n.bindFramebuffer(n.FRAMEBUFFER, s.resolveTargetFramebuffer), n.bindFramebuffer(n.READ_FRAMEBUFFER, s.framebuffer), n.blitFramebuffer(
741
+ 0,
742
+ 0,
743
+ s.width,
744
+ s.height,
745
+ 0,
746
+ 0,
747
+ s.width,
748
+ s.height,
749
+ n.COLOR_BUFFER_BIT,
750
+ n.NEAREST
751
+ ), n.bindFramebuffer(n.FRAMEBUFFER, s.framebuffer);
752
+ }
753
+ initGpuRenderTarget(e) {
754
+ const r = this._renderer, s = r.gl, n = new ze();
755
+ return e.colorTexture.resource === r.canvas ? (this._renderer.context.ensureCanvasSize(e.colorTexture.resource), n.framebuffer = null, n) : (this._initColor(e, n), s.bindFramebuffer(s.FRAMEBUFFER, null), n);
756
+ }
757
+ destroyGpuRenderTarget(e) {
758
+ const r = this._renderer.gl;
759
+ e.framebuffer && (r.deleteFramebuffer(e.framebuffer), e.framebuffer = null), e.resolveTargetFramebuffer && (r.deleteFramebuffer(e.resolveTargetFramebuffer), e.resolveTargetFramebuffer = null), e.depthStencilRenderBuffer && (r.deleteRenderbuffer(e.depthStencilRenderBuffer), e.depthStencilRenderBuffer = null), e.msaaRenderBuffer.forEach((s) => {
760
+ r.deleteRenderbuffer(s);
761
+ }), e.msaaRenderBuffer = null;
762
+ }
763
+ clear(e, r, s) {
764
+ if (!r)
765
+ return;
766
+ const n = this._renderTargetSystem;
767
+ typeof r == "boolean" && (r = r ? N.ALL : N.NONE);
768
+ const i = this._renderer.gl;
769
+ if (r & N.COLOR) {
770
+ s != null || (s = n.defaultClearColor);
771
+ const a = this._clearColorCache, o = s;
772
+ (a[0] !== o[0] || a[1] !== o[1] || a[2] !== o[2] || a[3] !== o[3]) && (a[0] = o[0], a[1] = o[1], a[2] = o[2], a[3] = o[3], i.clearColor(o[0], o[1], o[2], o[3]));
773
+ }
774
+ i.clear(r);
775
+ }
776
+ resizeGpuRenderTarget(e) {
777
+ if (e.isRoot)
778
+ return;
779
+ const s = this._renderTargetSystem.getGpuRenderTarget(e);
780
+ this._resizeColor(e, s), (e.stencil || e.depth) && this._resizeStencil(s);
781
+ }
782
+ _initColor(e, r) {
783
+ const s = this._renderer, n = s.gl, i = n.createFramebuffer();
784
+ if (r.resolveTargetFramebuffer = i, n.bindFramebuffer(n.FRAMEBUFFER, i), r.width = e.colorTexture.source.pixelWidth, r.height = e.colorTexture.source.pixelHeight, e.colorTextures.forEach((a, o) => {
785
+ const c = a.source;
786
+ c.antialias && (s.context.supports.msaa ? r.msaa = !0 : m("[RenderTexture] Antialiasing on textures is not supported in WebGL1")), s.texture.bindSource(c, 0);
787
+ const _ = s.texture.getGlSource(c).texture;
788
+ n.framebufferTexture2D(
789
+ n.FRAMEBUFFER,
790
+ n.COLOR_ATTACHMENT0 + o,
791
+ 3553,
792
+ _,
793
+ 0
794
+ );
795
+ }), r.msaa) {
796
+ const a = n.createFramebuffer();
797
+ r.framebuffer = a, n.bindFramebuffer(n.FRAMEBUFFER, a), e.colorTextures.forEach((o, c) => {
798
+ const u = n.createRenderbuffer();
799
+ r.msaaRenderBuffer[c] = u;
800
+ });
801
+ } else
802
+ r.framebuffer = i;
803
+ this._resizeColor(e, r);
804
+ }
805
+ _resizeColor(e, r) {
806
+ const s = e.colorTexture.source;
807
+ if (r.width = s.pixelWidth, r.height = s.pixelHeight, e.colorTextures.forEach((n, i) => {
808
+ i !== 0 && n.source.resize(s.width, s.height, s._resolution);
809
+ }), r.msaa) {
810
+ const n = this._renderer, i = n.gl, a = r.framebuffer;
811
+ i.bindFramebuffer(i.FRAMEBUFFER, a), e.colorTextures.forEach((o, c) => {
812
+ const u = o.source;
813
+ n.texture.bindSource(u, 0);
814
+ const h = n.texture.getGlSource(u).internalFormat, d = r.msaaRenderBuffer[c];
815
+ i.bindRenderbuffer(
816
+ i.RENDERBUFFER,
817
+ d
818
+ ), i.renderbufferStorageMultisample(
819
+ i.RENDERBUFFER,
820
+ 4,
821
+ h,
822
+ u.pixelWidth,
823
+ u.pixelHeight
824
+ ), i.framebufferRenderbuffer(
825
+ i.FRAMEBUFFER,
826
+ i.COLOR_ATTACHMENT0 + c,
827
+ i.RENDERBUFFER,
828
+ d
829
+ );
830
+ });
831
+ }
832
+ }
833
+ _initStencil(e) {
834
+ if (e.framebuffer === null)
835
+ return;
836
+ const r = this._renderer.gl, s = r.createRenderbuffer();
837
+ e.depthStencilRenderBuffer = s, r.bindRenderbuffer(
838
+ r.RENDERBUFFER,
839
+ s
840
+ ), r.framebufferRenderbuffer(
841
+ r.FRAMEBUFFER,
842
+ r.DEPTH_STENCIL_ATTACHMENT,
843
+ r.RENDERBUFFER,
844
+ s
845
+ ), this._resizeStencil(e);
846
+ }
847
+ _resizeStencil(e) {
848
+ const r = this._renderer.gl;
849
+ r.bindRenderbuffer(
850
+ r.RENDERBUFFER,
851
+ e.depthStencilRenderBuffer
852
+ ), e.msaa ? r.renderbufferStorageMultisample(
853
+ r.RENDERBUFFER,
854
+ 4,
855
+ r.DEPTH24_STENCIL8,
856
+ e.width,
857
+ e.height
858
+ ) : r.renderbufferStorage(
859
+ r.RENDERBUFFER,
860
+ this._renderer.context.webGLVersion === 2 ? r.DEPTH24_STENCIL8 : r.DEPTH_STENCIL,
861
+ e.width,
862
+ e.height
863
+ );
864
+ }
865
+ postrender(e) {
866
+ if (!!this._renderer.context.multiView && Ne.test(e.colorTexture.resource)) {
867
+ const r = this._renderer.context.canvas, s = e.colorTexture;
868
+ s.context2D.drawImage(
869
+ r,
870
+ 0,
871
+ s.pixelHeight - r.height
872
+ );
873
+ }
874
+ }
875
+ }
876
+ class fe extends Le {
877
+ constructor(e) {
878
+ super(e), this.adaptor = new Qe(), this.adaptor.init(e, this);
879
+ }
880
+ }
881
+ fe.extension = {
882
+ type: [l.WebGLSystem],
883
+ name: "renderTarget"
884
+ };
885
+ function Je(t, e) {
886
+ const r = [], s = [`
887
+ var g = s.groups;
888
+ var sS = r.shader;
889
+ var p = s.glProgram;
890
+ var ugS = r.uniformGroup;
891
+ var resources;
892
+ `];
893
+ let n = !1, i = 0, a = 0;
894
+ const o = e._getProgramData(t.glProgram);
895
+ for (const u in t.groups) {
896
+ const _ = t.groups[u];
897
+ r.push(`
898
+ resources = g[${u}].resources;
899
+ `);
900
+ for (const h in _.resources) {
901
+ const d = _.resources[h];
902
+ if (d instanceof P)
903
+ d.ubo ? r.push(`
904
+ sS.bindUniformBlock(
905
+ resources[${h}],
906
+ sS._uniformBindMap[${u}[${h}],
907
+ ${i++}
908
+ );
909
+ `) : r.push(`
910
+ ugS.updateUniformGroup(resources[${h}], p, sD);
911
+ `);
912
+ else if (d instanceof J)
913
+ r.push(`
914
+ sS.bindUniformBlock(
915
+ resources[${h}],
916
+ sS._uniformBindMap[${u}[${h}],
917
+ ${i++}
918
+ );
919
+ `);
920
+ else if (d instanceof $) {
921
+ const b = t._uniformBindMap[u][h], E = o.uniformData[b];
922
+ E && (n || (n = !0, s.push(`
923
+ var tS = r.texture;
924
+ `)), e._gl.uniform1i(E.location, a), r.push(`
925
+ tS.bind(resources[${h}], ${a});
926
+ `), a++);
927
+ }
928
+ }
929
+ }
930
+ const c = [...s, ...r].join(`
931
+ `);
932
+ return new Function("r", "s", "sD", c);
933
+ }
934
+ class et {
935
+ constructor(e, r) {
936
+ this.program = e, this.uniformData = r, this.uniformGroups = {}, this.uniformDirtyGroups = {}, this.uniformBlockBindings = {};
937
+ }
938
+ destroy() {
939
+ this.uniformData = null, this.uniformGroups = null, this.uniformDirtyGroups = null, this.uniformBlockBindings = null, this.program = null;
940
+ }
941
+ }
942
+ function V(t, e, r) {
943
+ const s = t.createShader(e);
944
+ return t.shaderSource(s, r), t.compileShader(s), s;
945
+ }
946
+ function D(t) {
947
+ const e = new Array(t);
948
+ for (let r = 0; r < e.length; r++)
949
+ e[r] = !1;
950
+ return e;
951
+ }
952
+ function he(t, e) {
953
+ switch (t) {
954
+ case "float":
955
+ return 0;
956
+ case "vec2":
957
+ return new Float32Array(2 * e);
958
+ case "vec3":
959
+ return new Float32Array(3 * e);
960
+ case "vec4":
961
+ return new Float32Array(4 * e);
962
+ case "int":
963
+ case "uint":
964
+ case "sampler2D":
965
+ case "sampler2DArray":
966
+ return 0;
967
+ case "ivec2":
968
+ return new Int32Array(2 * e);
969
+ case "ivec3":
970
+ return new Int32Array(3 * e);
971
+ case "ivec4":
972
+ return new Int32Array(4 * e);
973
+ case "uvec2":
974
+ return new Uint32Array(2 * e);
975
+ case "uvec3":
976
+ return new Uint32Array(3 * e);
977
+ case "uvec4":
978
+ return new Uint32Array(4 * e);
979
+ case "bool":
980
+ return !1;
981
+ case "bvec2":
982
+ return D(2 * e);
983
+ case "bvec3":
984
+ return D(3 * e);
985
+ case "bvec4":
986
+ return D(4 * e);
987
+ case "mat2":
988
+ return new Float32Array([
989
+ 1,
990
+ 0,
991
+ 0,
992
+ 1
993
+ ]);
994
+ case "mat3":
995
+ return new Float32Array([
996
+ 1,
997
+ 0,
998
+ 0,
999
+ 0,
1000
+ 1,
1001
+ 0,
1002
+ 0,
1003
+ 0,
1004
+ 1
1005
+ ]);
1006
+ case "mat4":
1007
+ return new Float32Array([
1008
+ 1,
1009
+ 0,
1010
+ 0,
1011
+ 0,
1012
+ 0,
1013
+ 1,
1014
+ 0,
1015
+ 0,
1016
+ 0,
1017
+ 0,
1018
+ 1,
1019
+ 0,
1020
+ 0,
1021
+ 0,
1022
+ 0,
1023
+ 1
1024
+ ]);
1025
+ }
1026
+ return null;
1027
+ }
1028
+ let R = null;
1029
+ const k = {
1030
+ FLOAT: "float",
1031
+ FLOAT_VEC2: "vec2",
1032
+ FLOAT_VEC3: "vec3",
1033
+ FLOAT_VEC4: "vec4",
1034
+ INT: "int",
1035
+ INT_VEC2: "ivec2",
1036
+ INT_VEC3: "ivec3",
1037
+ INT_VEC4: "ivec4",
1038
+ UNSIGNED_INT: "uint",
1039
+ UNSIGNED_INT_VEC2: "uvec2",
1040
+ UNSIGNED_INT_VEC3: "uvec3",
1041
+ UNSIGNED_INT_VEC4: "uvec4",
1042
+ BOOL: "bool",
1043
+ BOOL_VEC2: "bvec2",
1044
+ BOOL_VEC3: "bvec3",
1045
+ BOOL_VEC4: "bvec4",
1046
+ FLOAT_MAT2: "mat2",
1047
+ FLOAT_MAT3: "mat3",
1048
+ FLOAT_MAT4: "mat4",
1049
+ SAMPLER_2D: "sampler2D",
1050
+ INT_SAMPLER_2D: "sampler2D",
1051
+ UNSIGNED_INT_SAMPLER_2D: "sampler2D",
1052
+ SAMPLER_CUBE: "samplerCube",
1053
+ INT_SAMPLER_CUBE: "samplerCube",
1054
+ UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
1055
+ SAMPLER_2D_ARRAY: "sampler2DArray",
1056
+ INT_SAMPLER_2D_ARRAY: "sampler2DArray",
1057
+ UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
1058
+ }, tt = {
1059
+ float: "float32",
1060
+ vec2: "float32x2",
1061
+ vec3: "float32x3",
1062
+ vec4: "float32x4",
1063
+ int: "sint32",
1064
+ ivec2: "sint32x2",
1065
+ ivec3: "sint32x3",
1066
+ ivec4: "sint32x4",
1067
+ uint: "uint32",
1068
+ uvec2: "uint32x2",
1069
+ uvec3: "uint32x3",
1070
+ uvec4: "uint32x4",
1071
+ bool: "uint32",
1072
+ bvec2: "uint32x2",
1073
+ bvec3: "uint32x3",
1074
+ bvec4: "uint32x4"
1075
+ };
1076
+ function le(t, e) {
1077
+ if (!R) {
1078
+ const r = Object.keys(k);
1079
+ R = {};
1080
+ for (let s = 0; s < r.length; ++s) {
1081
+ const n = r[s];
1082
+ R[t[n]] = k[n];
1083
+ }
1084
+ }
1085
+ return R[e];
1086
+ }
1087
+ function rt(t, e) {
1088
+ const r = le(t, e);
1089
+ return tt[r] || "float32";
1090
+ }
1091
+ function st(t, e, r = !1) {
1092
+ const s = {}, n = e.getProgramParameter(t, e.ACTIVE_ATTRIBUTES);
1093
+ for (let a = 0; a < n; a++) {
1094
+ const o = e.getActiveAttrib(t, a);
1095
+ if (o.name.startsWith("gl_"))
1096
+ continue;
1097
+ const c = rt(e, o.type);
1098
+ s[o.name] = {
1099
+ location: 0,
1100
+ format: c,
1101
+ stride: K(c).stride,
1102
+ offset: 0,
1103
+ instance: !1,
1104
+ start: 0
1105
+ };
1106
+ }
1107
+ const i = Object.keys(s);
1108
+ if (r) {
1109
+ i.sort((a, o) => a > o ? 1 : -1);
1110
+ for (let a = 0; a < i.length; a++)
1111
+ s[i[a]].location = a, e.bindAttribLocation(t, a, i[a]);
1112
+ e.linkProgram(t);
1113
+ } else
1114
+ for (let a = 0; a < i.length; a++)
1115
+ s[i[a]].location = e.getAttribLocation(t, i[a]);
1116
+ return s;
1117
+ }
1118
+ function nt(t, e) {
1119
+ if (!e.ACTIVE_UNIFORM_BLOCKS)
1120
+ return {};
1121
+ const r = {}, s = e.getProgramParameter(t, e.ACTIVE_UNIFORM_BLOCKS);
1122
+ for (let n = 0; n < s; n++) {
1123
+ const i = e.getActiveUniformBlockName(t, n), a = e.getUniformBlockIndex(t, i), o = e.getActiveUniformBlockParameter(t, n, e.UNIFORM_BLOCK_DATA_SIZE);
1124
+ r[i] = {
1125
+ name: i,
1126
+ index: a,
1127
+ size: o
1128
+ };
1129
+ }
1130
+ return r;
1131
+ }
1132
+ function it(t, e) {
1133
+ const r = {}, s = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
1134
+ for (let n = 0; n < s; n++) {
1135
+ const i = e.getActiveUniform(t, n), a = i.name.replace(/\[.*?\]$/, ""), o = !!i.name.match(/\[.*?\]$/), c = le(e, i.type);
1136
+ r[a] = {
1137
+ name: a,
1138
+ index: n,
1139
+ type: c,
1140
+ size: i.size,
1141
+ isArray: o,
1142
+ value: he(c, i.size)
1143
+ };
1144
+ }
1145
+ return r;
1146
+ }
1147
+ function X(t, e) {
1148
+ const r = t.getShaderSource(e).split(`
1149
+ `).map((u, _) => `${_}: ${u}`), s = t.getShaderInfoLog(e), n = s.split(`
1150
+ `), i = {}, a = n.map((u) => parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/, "$1"))).filter((u) => u && !i[u] ? (i[u] = !0, !0) : !1), o = [""];
1151
+ a.forEach((u) => {
1152
+ r[u - 1] = `%c${r[u - 1]}%c`, o.push("background: #FF0000; color:#FFFFFF; font-size: 10px", "font-size: 10px");
1153
+ });
1154
+ const c = r.join(`
1155
+ `);
1156
+ o[0] = c, console.error(s), console.groupCollapsed("click to view full shader code"), console.warn(...o), console.groupEnd();
1157
+ }
1158
+ function at(t, e, r, s) {
1159
+ t.getProgramParameter(e, t.LINK_STATUS) || (t.getShaderParameter(r, t.COMPILE_STATUS) || X(t, r), t.getShaderParameter(s, t.COMPILE_STATUS) || X(t, s), console.error("PixiJS Error: Could not initialize shader."), t.getProgramInfoLog(e) !== "" && console.warn("PixiJS Warning: gl.getProgramInfoLog()", t.getProgramInfoLog(e)));
1160
+ }
1161
+ function ot(t, e) {
1162
+ const r = V(t, t.VERTEX_SHADER, e.vertex), s = V(t, t.FRAGMENT_SHADER, e.fragment), n = t.createProgram();
1163
+ t.attachShader(n, r), t.attachShader(n, s);
1164
+ const i = e.transformFeedbackVaryings;
1165
+ i && (typeof t.transformFeedbackVaryings != "function" ? m("TransformFeedback is not supported but TransformFeedbackVaryings are given.") : t.transformFeedbackVaryings(
1166
+ n,
1167
+ i.names,
1168
+ i.bufferMode === "separate" ? t.SEPARATE_ATTRIBS : t.INTERLEAVED_ATTRIBS
1169
+ )), t.linkProgram(n), t.getProgramParameter(n, t.LINK_STATUS) || at(t, n, r, s), e._attributeData = st(
1170
+ n,
1171
+ t,
1172
+ !/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)
1173
+ ), e._uniformData = it(n, t), e._uniformBlockData = nt(n, t), t.deleteShader(r), t.deleteShader(s);
1174
+ const a = {};
1175
+ for (const c in e._uniformData) {
1176
+ const u = e._uniformData[c];
1177
+ a[c] = {
1178
+ location: t.getUniformLocation(n, c),
1179
+ value: he(u.type, u.size)
1180
+ };
1181
+ }
1182
+ return new et(n, a);
1183
+ }
1184
+ const v = {
1185
+ textureCount: 0,
1186
+ blockIndex: 0
1187
+ };
1188
+ class de {
1189
+ constructor(e) {
1190
+ this._activeProgram = null, this._programDataHash = /* @__PURE__ */ Object.create(null), this._nextIndex = 0, this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null), this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null), this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null), this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_programDataHash");
1191
+ }
1192
+ contextChange(e) {
1193
+ this._gl = e, this._maxBindings = e.MAX_UNIFORM_BUFFER_BINDINGS ? e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS) : 0, this._programDataHash = /* @__PURE__ */ Object.create(null), this._boundUniformsIdsToIndexHash = /* @__PURE__ */ Object.create(null), this._boundIndexToUniformsHash = /* @__PURE__ */ Object.create(null), this._shaderSyncFunctions = /* @__PURE__ */ Object.create(null), this._activeProgram = null, this.maxTextures = z();
1194
+ }
1195
+ bind(e, r) {
1196
+ if (this._setProgram(e.glProgram), r)
1197
+ return;
1198
+ v.textureCount = 0, v.blockIndex = 0;
1199
+ let s = this._shaderSyncFunctions[e.glProgram._key];
1200
+ s || (s = this._shaderSyncFunctions[e.glProgram._key] = this._generateShaderSync(e, this)), s(this._renderer, e, v);
1201
+ }
1202
+ updateUniformGroup(e) {
1203
+ this._renderer.uniformGroup.updateUniformGroup(e, this._activeProgram, v);
1204
+ }
1205
+ bindUniformBlock(e, r, s = 0) {
1206
+ const n = this._renderer.buffer, i = this._getProgramData(this._activeProgram), a = e._bufferResource;
1207
+ a && this._renderer.ubo.updateUniformGroup(e), n.updateBuffer(e.buffer);
1208
+ let o = this._boundUniformsIdsToIndexHash[e.uid];
1209
+ if (o === void 0) {
1210
+ const _ = this._nextIndex++ % this._maxBindings, h = this._boundIndexToUniformsHash[_];
1211
+ h && (this._boundUniformsIdsToIndexHash[h.uid] = void 0), o = this._boundUniformsIdsToIndexHash[e.uid] = _, this._boundIndexToUniformsHash[_] = e, a ? n.bindBufferRange(e.buffer, _, e.offset) : n.bindBufferBase(e.buffer, _);
1212
+ }
1213
+ const c = this._gl, u = this._activeProgram._uniformBlockData[r].index;
1214
+ i.uniformBlockBindings[s] !== o && (i.uniformBlockBindings[s] = o, c.uniformBlockBinding(i.program, u, o));
1215
+ }
1216
+ _setProgram(e) {
1217
+ if (this._activeProgram === e)
1218
+ return;
1219
+ this._activeProgram = e;
1220
+ const r = this._getProgramData(e);
1221
+ this._gl.useProgram(r.program);
1222
+ }
1223
+ _getProgramData(e) {
1224
+ return this._programDataHash[e._key] || this._createProgramData(e);
1225
+ }
1226
+ _createProgramData(e) {
1227
+ const r = e._key;
1228
+ return this._programDataHash[r] = ot(this._gl, e), this._programDataHash[r];
1229
+ }
1230
+ destroy() {
1231
+ for (const e of Object.keys(this._programDataHash))
1232
+ this._programDataHash[e].destroy(), this._programDataHash[e] = null;
1233
+ this._programDataHash = null, this._boundUniformsIdsToIndexHash = null;
1234
+ }
1235
+ _generateShaderSync(e, r) {
1236
+ return Je(e, r);
1237
+ }
1238
+ }
1239
+ de.extension = {
1240
+ type: [
1241
+ l.WebGLSystem
1242
+ ],
1243
+ name: "shader"
1244
+ };
1245
+ const ct = {
1246
+ f32: `if (cv !== v) {
1247
+ cu.value = v;
1248
+ gl.uniform1f(location, v);
1249
+ }`,
1250
+ "vec2<f32>": `if (cv[0] !== v[0] || cv[1] !== v[1]) {
1251
+ cv[0] = v[0];
1252
+ cv[1] = v[1];
1253
+ gl.uniform2f(location, v[0], v[1]);
1254
+ }`,
1255
+ "vec3<f32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1256
+ cv[0] = v[0];
1257
+ cv[1] = v[1];
1258
+ cv[2] = v[2];
1259
+ gl.uniform3f(location, v[0], v[1], v[2]);
1260
+ }`,
1261
+ "vec4<f32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1262
+ cv[0] = v[0];
1263
+ cv[1] = v[1];
1264
+ cv[2] = v[2];
1265
+ cv[3] = v[3];
1266
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
1267
+ }`,
1268
+ i32: `if (cv !== v) {
1269
+ cu.value = v;
1270
+ gl.uniform1i(location, v);
1271
+ }`,
1272
+ "vec2<i32>": `if (cv[0] !== v[0] || cv[1] !== v[1]) {
1273
+ cv[0] = v[0];
1274
+ cv[1] = v[1];
1275
+ gl.uniform2i(location, v[0], v[1]);
1276
+ }`,
1277
+ "vec3<i32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1278
+ cv[0] = v[0];
1279
+ cv[1] = v[1];
1280
+ cv[2] = v[2];
1281
+ gl.uniform3i(location, v[0], v[1], v[2]);
1282
+ }`,
1283
+ "vec4<i32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1284
+ cv[0] = v[0];
1285
+ cv[1] = v[1];
1286
+ cv[2] = v[2];
1287
+ cv[3] = v[3];
1288
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
1289
+ }`,
1290
+ u32: `if (cv !== v) {
1291
+ cu.value = v;
1292
+ gl.uniform1ui(location, v);
1293
+ }`,
1294
+ "vec2<u32>": `if (cv[0] !== v[0] || cv[1] !== v[1]) {
1295
+ cv[0] = v[0];
1296
+ cv[1] = v[1];
1297
+ gl.uniform2ui(location, v[0], v[1]);
1298
+ }`,
1299
+ "vec3<u32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1300
+ cv[0] = v[0];
1301
+ cv[1] = v[1];
1302
+ cv[2] = v[2];
1303
+ gl.uniform3ui(location, v[0], v[1], v[2]);
1304
+ }`,
1305
+ "vec4<u32>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1306
+ cv[0] = v[0];
1307
+ cv[1] = v[1];
1308
+ cv[2] = v[2];
1309
+ cv[3] = v[3];
1310
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
1311
+ }`,
1312
+ bool: `if (cv !== v) {
1313
+ cu.value = v;
1314
+ gl.uniform1i(location, v);
1315
+ }`,
1316
+ "vec2<bool>": `if (cv[0] !== v[0] || cv[1] !== v[1]) {
1317
+ cv[0] = v[0];
1318
+ cv[1] = v[1];
1319
+ gl.uniform2i(location, v[0], v[1]);
1320
+ }`,
1321
+ "vec3<bool>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
1322
+ cv[0] = v[0];
1323
+ cv[1] = v[1];
1324
+ cv[2] = v[2];
1325
+ gl.uniform3i(location, v[0], v[1], v[2]);
1326
+ }`,
1327
+ "vec4<bool>": `if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
1328
+ cv[0] = v[0];
1329
+ cv[1] = v[1];
1330
+ cv[2] = v[2];
1331
+ cv[3] = v[3];
1332
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
1333
+ }`,
1334
+ "mat2x2<f32>": "gl.uniformMatrix2fv(location, false, v);",
1335
+ "mat3x3<f32>": "gl.uniformMatrix3fv(location, false, v);",
1336
+ "mat4x4<f32>": "gl.uniformMatrix4fv(location, false, v);"
1337
+ }, ut = {
1338
+ f32: "gl.uniform1fv(location, v);",
1339
+ "vec2<f32>": "gl.uniform2fv(location, v);",
1340
+ "vec3<f32>": "gl.uniform3fv(location, v);",
1341
+ "vec4<f32>": "gl.uniform4fv(location, v);",
1342
+ "mat2x2<f32>": "gl.uniformMatrix2fv(location, false, v);",
1343
+ "mat3x3<f32>": "gl.uniformMatrix3fv(location, false, v);",
1344
+ "mat4x4<f32>": "gl.uniformMatrix4fv(location, false, v);",
1345
+ i32: "gl.uniform1iv(location, v);",
1346
+ "vec2<i32>": "gl.uniform2iv(location, v);",
1347
+ "vec3<i32>": "gl.uniform3iv(location, v);",
1348
+ "vec4<i32>": "gl.uniform4iv(location, v);",
1349
+ u32: "gl.uniform1iv(location, v);",
1350
+ "vec2<u32>": "gl.uniform2iv(location, v);",
1351
+ "vec3<u32>": "gl.uniform3iv(location, v);",
1352
+ "vec4<u32>": "gl.uniform4iv(location, v);",
1353
+ bool: "gl.uniform1iv(location, v);",
1354
+ "vec2<bool>": "gl.uniform2iv(location, v);",
1355
+ "vec3<bool>": "gl.uniform3iv(location, v);",
1356
+ "vec4<bool>": "gl.uniform4iv(location, v);"
1357
+ };
1358
+ function _t(t, e) {
1359
+ const r = [`
1360
+ var v = null;
1361
+ var cv = null;
1362
+ var cu = null;
1363
+ var t = 0;
1364
+ var gl = renderer.gl;
1365
+ var name = null;
1366
+ `];
1367
+ for (const s in t.uniforms) {
1368
+ if (!e[s]) {
1369
+ t.uniforms[s] instanceof P ? t.uniforms[s].ubo ? r.push(`
1370
+ renderer.shader.bindUniformBlock(uv.${s}, "${s}");
1371
+ `) : r.push(`
1372
+ renderer.shader.updateUniformGroup(uv.${s});
1373
+ `) : t.uniforms[s] instanceof J && r.push(`
1374
+ renderer.shader.bindBufferResource(uv.${s}, "${s}");
1375
+ `);
1376
+ continue;
1377
+ }
1378
+ const n = t.uniformStructures[s];
1379
+ let i = !1;
1380
+ for (let a = 0; a < I.length; a++) {
1381
+ const o = I[a];
1382
+ if (n.type === o.type && o.test(n)) {
1383
+ r.push(`name = "${s}";`, I[a].uniform), i = !0;
1384
+ break;
1385
+ }
1386
+ }
1387
+ if (!i) {
1388
+ const o = (n.size === 1 ? ct : ut)[n.type].replace("location", `ud["${s}"].location`);
1389
+ r.push(`
1390
+ cu = ud["${s}"];
1391
+ cv = cu.value;
1392
+ v = uv["${s}"];
1393
+ ${o};`);
1394
+ }
1395
+ }
1396
+ return new Function("ud", "uv", "renderer", "syncData", r.join(`
1397
+ `));
1398
+ }
1399
+ class me {
1400
+ constructor(e) {
1401
+ this._cache = {}, this._uniformGroupSyncHash = {}, this._renderer = e, this.gl = null, this._cache = {};
1402
+ }
1403
+ contextChange(e) {
1404
+ this.gl = e;
1405
+ }
1406
+ updateUniformGroup(e, r, s) {
1407
+ const n = this._renderer.shader._getProgramData(r);
1408
+ (!e.isStatic || e._dirtyId !== n.uniformDirtyGroups[e.uid]) && (n.uniformDirtyGroups[e.uid] = e._dirtyId, this._getUniformSyncFunction(e, r)(n.uniformData, e.uniforms, this._renderer, s));
1409
+ }
1410
+ _getUniformSyncFunction(e, r) {
1411
+ var s;
1412
+ return ((s = this._uniformGroupSyncHash[e._signature]) == null ? void 0 : s[r._key]) || this._createUniformSyncFunction(e, r);
1413
+ }
1414
+ _createUniformSyncFunction(e, r) {
1415
+ const s = this._uniformGroupSyncHash[e._signature] || (this._uniformGroupSyncHash[e._signature] = {}), n = this._getSignature(e, r._uniformData, "u");
1416
+ return this._cache[n] || (this._cache[n] = this._generateUniformsSync(e, r._uniformData)), s[r._key] = this._cache[n], s[r._key];
1417
+ }
1418
+ _generateUniformsSync(e, r) {
1419
+ return _t(e, r);
1420
+ }
1421
+ _getSignature(e, r, s) {
1422
+ const n = e.uniforms, i = [`${s}-`];
1423
+ for (const a in n)
1424
+ i.push(a), r[a] && i.push(r[a].type);
1425
+ return i.join("-");
1426
+ }
1427
+ destroy() {
1428
+ this._renderer = null, this._cache = null;
1429
+ }
1430
+ }
1431
+ me.extension = {
1432
+ type: [
1433
+ l.WebGLSystem
1434
+ ],
1435
+ name: "uniformGroup"
1436
+ };
1437
+ function ft(t) {
1438
+ const e = {};
1439
+ if (e.normal = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e.add = [t.ONE, t.ONE], e.multiply = [t.DST_COLOR, t.ONE_MINUS_SRC_ALPHA, t.ONE, t.ONE_MINUS_SRC_ALPHA], e.screen = [t.ONE, t.ONE_MINUS_SRC_COLOR, t.ONE, t.ONE_MINUS_SRC_ALPHA], e.none = [0, 0], e["normal-npm"] = [t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA, t.ONE, t.ONE_MINUS_SRC_ALPHA], e["add-npm"] = [t.SRC_ALPHA, t.ONE, t.ONE, t.ONE], e["screen-npm"] = [t.SRC_ALPHA, t.ONE_MINUS_SRC_COLOR, t.ONE, t.ONE_MINUS_SRC_ALPHA], e.erase = [t.ZERO, t.ONE_MINUS_SRC_ALPHA], !(t instanceof S.get().getWebGLRenderingContext()))
1440
+ e.min = [t.ONE, t.ONE, t.ONE, t.ONE, t.MIN, t.MIN], e.max = [t.ONE, t.ONE, t.ONE, t.ONE, t.MAX, t.MAX];
1441
+ else {
1442
+ const s = t.getExtension("EXT_blend_minmax");
1443
+ s && (e.min = [t.ONE, t.ONE, t.ONE, t.ONE, s.MIN_EXT, s.MIN_EXT], e.max = [t.ONE, t.ONE, t.ONE, t.ONE, s.MAX_EXT, s.MAX_EXT]);
1444
+ }
1445
+ return e;
1446
+ }
1447
+ const ht = 0, lt = 1, dt = 2, mt = 3, Et = 4, bt = 5, Ee = class G {
1448
+ constructor() {
1449
+ this.gl = null, this.stateId = 0, this.polygonOffset = 0, this.blendMode = "none", this._blendEq = !1, this.map = [], this.map[ht] = this.setBlend, this.map[lt] = this.setOffset, this.map[dt] = this.setCullFace, this.map[mt] = this.setDepthTest, this.map[Et] = this.setFrontFace, this.map[bt] = this.setDepthMask, this.checks = [], this.defaultState = U.for2d();
1450
+ }
1451
+ contextChange(e) {
1452
+ this.gl = e, this.blendModesMap = ft(e), this.reset();
1453
+ }
1454
+ set(e) {
1455
+ if (e = e || this.defaultState, this.stateId !== e.data) {
1456
+ let r = this.stateId ^ e.data, s = 0;
1457
+ for (; r; )
1458
+ r & 1 && this.map[s].call(this, !!(e.data & 1 << s)), r = r >> 1, s++;
1459
+ this.stateId = e.data;
1460
+ }
1461
+ for (let r = 0; r < this.checks.length; r++)
1462
+ this.checks[r](this, e);
1463
+ }
1464
+ forceState(e) {
1465
+ e = e || this.defaultState;
1466
+ for (let r = 0; r < this.map.length; r++)
1467
+ this.map[r].call(this, !!(e.data & 1 << r));
1468
+ for (let r = 0; r < this.checks.length; r++)
1469
+ this.checks[r](this, e);
1470
+ this.stateId = e.data;
1471
+ }
1472
+ setBlend(e) {
1473
+ this._updateCheck(G._checkBlendMode, e), this.gl[e ? "enable" : "disable"](this.gl.BLEND);
1474
+ }
1475
+ setOffset(e) {
1476
+ this._updateCheck(G._checkPolygonOffset, e), this.gl[e ? "enable" : "disable"](this.gl.POLYGON_OFFSET_FILL);
1477
+ }
1478
+ setDepthTest(e) {
1479
+ this.gl[e ? "enable" : "disable"](this.gl.DEPTH_TEST);
1480
+ }
1481
+ setDepthMask(e) {
1482
+ this.gl.depthMask(e);
1483
+ }
1484
+ setCullFace(e) {
1485
+ this.gl[e ? "enable" : "disable"](this.gl.CULL_FACE);
1486
+ }
1487
+ setFrontFace(e) {
1488
+ this.gl.frontFace(this.gl[e ? "CW" : "CCW"]);
1489
+ }
1490
+ setBlendMode(e) {
1491
+ if (this.blendModesMap[e] || (e = "normal"), e === this.blendMode)
1492
+ return;
1493
+ this.blendMode = e;
1494
+ const r = this.blendModesMap[e], s = this.gl;
1495
+ r.length === 2 ? s.blendFunc(r[0], r[1]) : s.blendFuncSeparate(r[0], r[1], r[2], r[3]), r.length === 6 ? (this._blendEq = !0, s.blendEquationSeparate(r[4], r[5])) : this._blendEq && (this._blendEq = !1, s.blendEquationSeparate(s.FUNC_ADD, s.FUNC_ADD));
1496
+ }
1497
+ setPolygonOffset(e, r) {
1498
+ this.gl.polygonOffset(e, r);
1499
+ }
1500
+ reset() {
1501
+ this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, !1), this.forceState(this.defaultState), this._blendEq = !0, this.blendMode = "", this.setBlendMode("normal");
1502
+ }
1503
+ _updateCheck(e, r) {
1504
+ const s = this.checks.indexOf(e);
1505
+ r && s === -1 ? this.checks.push(e) : !r && s !== -1 && this.checks.splice(s, 1);
1506
+ }
1507
+ static _checkBlendMode(e, r) {
1508
+ e.setBlendMode(r.blendMode);
1509
+ }
1510
+ static _checkPolygonOffset(e, r) {
1511
+ e.setPolygonOffset(1, r.polygonOffset);
1512
+ }
1513
+ destroy() {
1514
+ this.gl = null, this.checks.length = 0;
1515
+ }
1516
+ };
1517
+ Ee.extension = {
1518
+ type: [
1519
+ l.WebGLSystem
1520
+ ],
1521
+ name: "state"
1522
+ };
1523
+ let St = Ee;
1524
+ class pt {
1525
+ constructor(e) {
1526
+ this.target = se.TEXTURE_2D, this.texture = e, this.width = -1, this.height = -1, this.type = f.UNSIGNED_BYTE, this.internalFormat = C.RGBA, this.format = C.RGBA, this.samplerType = 0;
1527
+ }
1528
+ }
1529
+ const gt = {
1530
+ id: "buffer",
1531
+ upload(t, e, r) {
1532
+ e.width === t.width || e.height === t.height ? r.texSubImage2D(
1533
+ r.TEXTURE_2D,
1534
+ 0,
1535
+ 0,
1536
+ 0,
1537
+ t.width,
1538
+ t.height,
1539
+ e.format,
1540
+ e.type,
1541
+ t.resource
1542
+ ) : r.texImage2D(
1543
+ e.target,
1544
+ 0,
1545
+ e.internalFormat,
1546
+ t.width,
1547
+ t.height,
1548
+ 0,
1549
+ e.format,
1550
+ e.type,
1551
+ t.resource
1552
+ ), e.width = t.width, e.height = t.height;
1553
+ }
1554
+ }, Rt = {
1555
+ "bc1-rgba-unorm": !0,
1556
+ "bc1-rgba-unorm-srgb": !0,
1557
+ "bc2-rgba-unorm": !0,
1558
+ "bc2-rgba-unorm-srgb": !0,
1559
+ "bc3-rgba-unorm": !0,
1560
+ "bc3-rgba-unorm-srgb": !0,
1561
+ "bc4-r-unorm": !0,
1562
+ "bc4-r-snorm": !0,
1563
+ "bc5-rg-unorm": !0,
1564
+ "bc5-rg-snorm": !0,
1565
+ "bc6h-rgb-ufloat": !0,
1566
+ "bc6h-rgb-float": !0,
1567
+ "bc7-rgba-unorm": !0,
1568
+ "bc7-rgba-unorm-srgb": !0,
1569
+ "etc2-rgb8unorm": !0,
1570
+ "etc2-rgb8unorm-srgb": !0,
1571
+ "etc2-rgb8a1unorm": !0,
1572
+ "etc2-rgb8a1unorm-srgb": !0,
1573
+ "etc2-rgba8unorm": !0,
1574
+ "etc2-rgba8unorm-srgb": !0,
1575
+ "eac-r11unorm": !0,
1576
+ "eac-r11snorm": !0,
1577
+ "eac-rg11unorm": !0,
1578
+ "eac-rg11snorm": !0,
1579
+ "astc-4x4-unorm": !0,
1580
+ "astc-4x4-unorm-srgb": !0,
1581
+ "astc-5x4-unorm": !0,
1582
+ "astc-5x4-unorm-srgb": !0,
1583
+ "astc-5x5-unorm": !0,
1584
+ "astc-5x5-unorm-srgb": !0,
1585
+ "astc-6x5-unorm": !0,
1586
+ "astc-6x5-unorm-srgb": !0,
1587
+ "astc-6x6-unorm": !0,
1588
+ "astc-6x6-unorm-srgb": !0,
1589
+ "astc-8x5-unorm": !0,
1590
+ "astc-8x5-unorm-srgb": !0,
1591
+ "astc-8x6-unorm": !0,
1592
+ "astc-8x6-unorm-srgb": !0,
1593
+ "astc-8x8-unorm": !0,
1594
+ "astc-8x8-unorm-srgb": !0,
1595
+ "astc-10x5-unorm": !0,
1596
+ "astc-10x5-unorm-srgb": !0,
1597
+ "astc-10x6-unorm": !0,
1598
+ "astc-10x6-unorm-srgb": !0,
1599
+ "astc-10x8-unorm": !0,
1600
+ "astc-10x8-unorm-srgb": !0,
1601
+ "astc-10x10-unorm": !0,
1602
+ "astc-10x10-unorm-srgb": !0,
1603
+ "astc-12x10-unorm": !0,
1604
+ "astc-12x10-unorm-srgb": !0,
1605
+ "astc-12x12-unorm": !0,
1606
+ "astc-12x12-unorm-srgb": !0
1607
+ }, vt = {
1608
+ id: "compressed",
1609
+ upload(t, e, r) {
1610
+ r.pixelStorei(r.UNPACK_ALIGNMENT, 4);
1611
+ let s = t.pixelWidth, n = t.pixelHeight;
1612
+ const i = !!Rt[t.format];
1613
+ for (let a = 0; a < t.resource.length; a++) {
1614
+ const o = t.resource[a];
1615
+ i ? r.compressedTexImage2D(
1616
+ r.TEXTURE_2D,
1617
+ a,
1618
+ e.internalFormat,
1619
+ s,
1620
+ n,
1621
+ 0,
1622
+ o
1623
+ ) : r.texImage2D(
1624
+ r.TEXTURE_2D,
1625
+ a,
1626
+ e.internalFormat,
1627
+ s,
1628
+ n,
1629
+ 0,
1630
+ e.format,
1631
+ e.type,
1632
+ o
1633
+ ), s = Math.max(s >> 1, 1), n = Math.max(n >> 1, 1);
1634
+ }
1635
+ }
1636
+ }, be = {
1637
+ id: "image",
1638
+ upload(t, e, r, s) {
1639
+ const n = t.alphaMode === "premultiply-alpha-on-upload";
1640
+ r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, n);
1641
+ const i = e.width, a = e.height, o = t.pixelWidth, c = t.pixelHeight, u = t.resourceWidth, _ = t.resourceHeight;
1642
+ u < o || _ < c ? ((i !== o || a !== c) && r.texImage2D(
1643
+ e.target,
1644
+ 0,
1645
+ e.internalFormat,
1646
+ o,
1647
+ c,
1648
+ 0,
1649
+ e.format,
1650
+ e.type,
1651
+ null
1652
+ ), s === 2 ? r.texSubImage2D(
1653
+ r.TEXTURE_2D,
1654
+ 0,
1655
+ 0,
1656
+ 0,
1657
+ u,
1658
+ _,
1659
+ e.format,
1660
+ e.type,
1661
+ t.resource
1662
+ ) : r.texSubImage2D(
1663
+ r.TEXTURE_2D,
1664
+ 0,
1665
+ 0,
1666
+ 0,
1667
+ e.format,
1668
+ e.type,
1669
+ t.resource
1670
+ )) : i === o || a === c ? r.texSubImage2D(
1671
+ r.TEXTURE_2D,
1672
+ 0,
1673
+ 0,
1674
+ 0,
1675
+ e.format,
1676
+ e.type,
1677
+ t.resource
1678
+ ) : s === 2 ? r.texImage2D(
1679
+ e.target,
1680
+ 0,
1681
+ e.internalFormat,
1682
+ o,
1683
+ c,
1684
+ 0,
1685
+ e.format,
1686
+ e.type,
1687
+ t.resource
1688
+ ) : r.texImage2D(
1689
+ e.target,
1690
+ 0,
1691
+ e.internalFormat,
1692
+ e.format,
1693
+ e.type,
1694
+ t.resource
1695
+ ), e.width = o, e.height = c;
1696
+ }
1697
+ }, Tt = {
1698
+ id: "video",
1699
+ upload(t, e, r, s) {
1700
+ if (!t.isValid) {
1701
+ r.texImage2D(
1702
+ e.target,
1703
+ 0,
1704
+ e.internalFormat,
1705
+ 1,
1706
+ 1,
1707
+ 0,
1708
+ e.format,
1709
+ e.type,
1710
+ null
1711
+ );
1712
+ return;
1713
+ }
1714
+ be.upload(t, e, r, s);
1715
+ }
1716
+ }, W = {
1717
+ linear: 9729,
1718
+ nearest: 9728
1719
+ }, xt = {
1720
+ linear: {
1721
+ linear: 9987,
1722
+ nearest: 9985
1723
+ },
1724
+ nearest: {
1725
+ linear: 9986,
1726
+ nearest: 9984
1727
+ }
1728
+ }, y = {
1729
+ "clamp-to-edge": 33071,
1730
+ repeat: 10497,
1731
+ "mirror-repeat": 33648
1732
+ }, At = {
1733
+ never: 512,
1734
+ less: 513,
1735
+ equal: 514,
1736
+ "less-equal": 515,
1737
+ greater: 516,
1738
+ "not-equal": 517,
1739
+ "greater-equal": 518,
1740
+ always: 519
1741
+ };
1742
+ function j(t, e, r, s, n, i, a, o) {
1743
+ const c = i;
1744
+ if (!o || t.addressModeU !== "repeat" || t.addressModeV !== "repeat" || t.addressModeW !== "repeat") {
1745
+ const u = y[a ? "clamp-to-edge" : t.addressModeU], _ = y[a ? "clamp-to-edge" : t.addressModeV], h = y[a ? "clamp-to-edge" : t.addressModeW];
1746
+ e[n](c, e.TEXTURE_WRAP_S, u), e[n](c, e.TEXTURE_WRAP_T, _), e.TEXTURE_WRAP_R && e[n](c, e.TEXTURE_WRAP_R, h);
1747
+ }
1748
+ if ((!o || t.magFilter !== "linear") && e[n](c, e.TEXTURE_MAG_FILTER, W[t.magFilter]), r) {
1749
+ if (!o || t.mipmapFilter !== "linear") {
1750
+ const u = xt[t.minFilter][t.mipmapFilter];
1751
+ e[n](c, e.TEXTURE_MIN_FILTER, u);
1752
+ }
1753
+ } else
1754
+ e[n](c, e.TEXTURE_MIN_FILTER, W[t.minFilter]);
1755
+ if (s && t.maxAnisotropy > 1) {
1756
+ const u = Math.min(t.maxAnisotropy, e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));
1757
+ e[n](c, s.TEXTURE_MAX_ANISOTROPY_EXT, u);
1758
+ }
1759
+ t.compare && e[n](c, e.TEXTURE_COMPARE_FUNC, At[t.compare]);
1760
+ }
1761
+ function Bt(t) {
1762
+ return {
1763
+ r8unorm: t.RED,
1764
+ r8snorm: t.RED,
1765
+ r8uint: t.RED,
1766
+ r8sint: t.RED,
1767
+ r16uint: t.RED,
1768
+ r16sint: t.RED,
1769
+ r16float: t.RED,
1770
+ rg8unorm: t.RG,
1771
+ rg8snorm: t.RG,
1772
+ rg8uint: t.RG,
1773
+ rg8sint: t.RG,
1774
+ r32uint: t.RED,
1775
+ r32sint: t.RED,
1776
+ r32float: t.RED,
1777
+ rg16uint: t.RG,
1778
+ rg16sint: t.RG,
1779
+ rg16float: t.RG,
1780
+ rgba8unorm: t.RGBA,
1781
+ "rgba8unorm-srgb": t.RGBA,
1782
+ rgba8snorm: t.RGBA,
1783
+ rgba8uint: t.RGBA,
1784
+ rgba8sint: t.RGBA,
1785
+ bgra8unorm: t.RGBA,
1786
+ "bgra8unorm-srgb": t.RGBA,
1787
+ rgb9e5ufloat: t.RGB,
1788
+ rgb10a2unorm: t.RGBA,
1789
+ rg11b10ufloat: t.RGB,
1790
+ rg32uint: t.RG,
1791
+ rg32sint: t.RG,
1792
+ rg32float: t.RG,
1793
+ rgba16uint: t.RGBA,
1794
+ rgba16sint: t.RGBA,
1795
+ rgba16float: t.RGBA,
1796
+ rgba32uint: t.RGBA,
1797
+ rgba32sint: t.RGBA,
1798
+ rgba32float: t.RGBA,
1799
+ stencil8: t.STENCIL_INDEX8,
1800
+ depth16unorm: t.DEPTH_COMPONENT,
1801
+ depth24plus: t.DEPTH_COMPONENT,
1802
+ "depth24plus-stencil8": t.DEPTH_STENCIL,
1803
+ depth32float: t.DEPTH_COMPONENT,
1804
+ "depth32float-stencil8": t.DEPTH_STENCIL
1805
+ };
1806
+ }
1807
+ function Nt(t, e) {
1808
+ let r = {}, s = t.RGBA;
1809
+ return t instanceof S.get().getWebGLRenderingContext() ? e.srgb && (r = {
1810
+ "rgba8unorm-srgb": e.srgb.SRGB8_ALPHA8_EXT,
1811
+ "bgra8unorm-srgb": e.srgb.SRGB8_ALPHA8_EXT
1812
+ }) : (r = {
1813
+ "rgba8unorm-srgb": t.SRGB8_ALPHA8,
1814
+ "bgra8unorm-srgb": t.SRGB8_ALPHA8
1815
+ }, s = t.RGBA8), {
1816
+ r8unorm: t.R8,
1817
+ r8snorm: t.R8_SNORM,
1818
+ r8uint: t.R8UI,
1819
+ r8sint: t.R8I,
1820
+ r16uint: t.R16UI,
1821
+ r16sint: t.R16I,
1822
+ r16float: t.R16F,
1823
+ rg8unorm: t.RG8,
1824
+ rg8snorm: t.RG8_SNORM,
1825
+ rg8uint: t.RG8UI,
1826
+ rg8sint: t.RG8I,
1827
+ r32uint: t.R32UI,
1828
+ r32sint: t.R32I,
1829
+ r32float: t.R32F,
1830
+ rg16uint: t.RG16UI,
1831
+ rg16sint: t.RG16I,
1832
+ rg16float: t.RG16F,
1833
+ rgba8unorm: t.RGBA,
1834
+ ...r,
1835
+ rgba8snorm: t.RGBA8_SNORM,
1836
+ rgba8uint: t.RGBA8UI,
1837
+ rgba8sint: t.RGBA8I,
1838
+ bgra8unorm: s,
1839
+ rgb9e5ufloat: t.RGB9_E5,
1840
+ rgb10a2unorm: t.RGB10_A2,
1841
+ rg11b10ufloat: t.R11F_G11F_B10F,
1842
+ rg32uint: t.RG32UI,
1843
+ rg32sint: t.RG32I,
1844
+ rg32float: t.RG32F,
1845
+ rgba16uint: t.RGBA16UI,
1846
+ rgba16sint: t.RGBA16I,
1847
+ rgba16float: t.RGBA16F,
1848
+ rgba32uint: t.RGBA32UI,
1849
+ rgba32sint: t.RGBA32I,
1850
+ rgba32float: t.RGBA32F,
1851
+ stencil8: t.STENCIL_INDEX8,
1852
+ depth16unorm: t.DEPTH_COMPONENT16,
1853
+ depth24plus: t.DEPTH_COMPONENT24,
1854
+ "depth24plus-stencil8": t.DEPTH24_STENCIL8,
1855
+ depth32float: t.DEPTH_COMPONENT32F,
1856
+ "depth32float-stencil8": t.DEPTH32F_STENCIL8,
1857
+ ...e.s3tc ? {
1858
+ "bc1-rgba-unorm": e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,
1859
+ "bc2-rgba-unorm": e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,
1860
+ "bc3-rgba-unorm": e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT
1861
+ } : {},
1862
+ ...e.s3tc_sRGB ? {
1863
+ "bc1-rgba-unorm-srgb": e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
1864
+ "bc2-rgba-unorm-srgb": e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
1865
+ "bc3-rgba-unorm-srgb": e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
1866
+ } : {},
1867
+ ...e.rgtc ? {
1868
+ "bc4-r-unorm": e.rgtc.COMPRESSED_RED_RGTC1_EXT,
1869
+ "bc4-r-snorm": e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,
1870
+ "bc5-rg-unorm": e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,
1871
+ "bc5-rg-snorm": e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT
1872
+ } : {},
1873
+ ...e.bptc ? {
1874
+ "bc6h-rgb-float": e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
1875
+ "bc6h-rgb-ufloat": e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
1876
+ "bc7-rgba-unorm": e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,
1877
+ "bc7-rgba-unorm-srgb": e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
1878
+ } : {},
1879
+ ...e.etc ? {
1880
+ "etc2-rgb8unorm": e.etc.COMPRESSED_RGB8_ETC2,
1881
+ "etc2-rgb8unorm-srgb": e.etc.COMPRESSED_SRGB8_ETC2,
1882
+ "etc2-rgb8a1unorm": e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1883
+ "etc2-rgb8a1unorm-srgb": e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1884
+ "etc2-rgba8unorm": e.etc.COMPRESSED_RGBA8_ETC2_EAC,
1885
+ "etc2-rgba8unorm-srgb": e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
1886
+ "eac-r11unorm": e.etc.COMPRESSED_R11_EAC,
1887
+ "eac-rg11unorm": e.etc.COMPRESSED_SIGNED_RG11_EAC
1888
+ } : {},
1889
+ ...e.astc ? {
1890
+ "astc-4x4-unorm": e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,
1891
+ "astc-4x4-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
1892
+ "astc-5x4-unorm": e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,
1893
+ "astc-5x4-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
1894
+ "astc-5x5-unorm": e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,
1895
+ "astc-5x5-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
1896
+ "astc-6x5-unorm": e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,
1897
+ "astc-6x5-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
1898
+ "astc-6x6-unorm": e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,
1899
+ "astc-6x6-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
1900
+ "astc-8x5-unorm": e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,
1901
+ "astc-8x5-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
1902
+ "astc-8x6-unorm": e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,
1903
+ "astc-8x6-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
1904
+ "astc-8x8-unorm": e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,
1905
+ "astc-8x8-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
1906
+ "astc-10x5-unorm": e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,
1907
+ "astc-10x5-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
1908
+ "astc-10x6-unorm": e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,
1909
+ "astc-10x6-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
1910
+ "astc-10x8-unorm": e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,
1911
+ "astc-10x8-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
1912
+ "astc-10x10-unorm": e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,
1913
+ "astc-10x10-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
1914
+ "astc-12x10-unorm": e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,
1915
+ "astc-12x10-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
1916
+ "astc-12x12-unorm": e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,
1917
+ "astc-12x12-unorm-srgb": e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
1918
+ } : {}
1919
+ };
1920
+ }
1921
+ function It(t) {
1922
+ return {
1923
+ r8unorm: t.UNSIGNED_BYTE,
1924
+ r8snorm: t.BYTE,
1925
+ r8uint: t.UNSIGNED_BYTE,
1926
+ r8sint: t.BYTE,
1927
+ r16uint: t.UNSIGNED_SHORT,
1928
+ r16sint: t.SHORT,
1929
+ r16float: t.HALF_FLOAT,
1930
+ rg8unorm: t.UNSIGNED_BYTE,
1931
+ rg8snorm: t.BYTE,
1932
+ rg8uint: t.UNSIGNED_BYTE,
1933
+ rg8sint: t.BYTE,
1934
+ r32uint: t.UNSIGNED_INT,
1935
+ r32sint: t.INT,
1936
+ r32float: t.FLOAT,
1937
+ rg16uint: t.UNSIGNED_SHORT,
1938
+ rg16sint: t.SHORT,
1939
+ rg16float: t.HALF_FLOAT,
1940
+ rgba8unorm: t.UNSIGNED_BYTE,
1941
+ "rgba8unorm-srgb": t.UNSIGNED_BYTE,
1942
+ rgba8snorm: t.BYTE,
1943
+ rgba8uint: t.UNSIGNED_BYTE,
1944
+ rgba8sint: t.BYTE,
1945
+ bgra8unorm: t.UNSIGNED_BYTE,
1946
+ "bgra8unorm-srgb": t.UNSIGNED_BYTE,
1947
+ rgb9e5ufloat: t.UNSIGNED_INT_5_9_9_9_REV,
1948
+ rgb10a2unorm: t.UNSIGNED_INT_2_10_10_10_REV,
1949
+ rg11b10ufloat: t.UNSIGNED_INT_10F_11F_11F_REV,
1950
+ rg32uint: t.UNSIGNED_INT,
1951
+ rg32sint: t.INT,
1952
+ rg32float: t.FLOAT,
1953
+ rgba16uint: t.UNSIGNED_SHORT,
1954
+ rgba16sint: t.SHORT,
1955
+ rgba16float: t.HALF_FLOAT,
1956
+ rgba32uint: t.UNSIGNED_INT,
1957
+ rgba32sint: t.INT,
1958
+ rgba32float: t.FLOAT,
1959
+ stencil8: t.UNSIGNED_BYTE,
1960
+ depth16unorm: t.UNSIGNED_SHORT,
1961
+ depth24plus: t.UNSIGNED_INT,
1962
+ "depth24plus-stencil8": t.UNSIGNED_INT_24_8,
1963
+ depth32float: t.FLOAT,
1964
+ "depth32float-stencil8": t.FLOAT_32_UNSIGNED_INT_24_8_REV
1965
+ };
1966
+ }
1967
+ const Dt = 4;
1968
+ class Se {
1969
+ constructor(e) {
1970
+ this.managedTextures = [], this._glTextures = /* @__PURE__ */ Object.create(null), this._glSamplers = /* @__PURE__ */ Object.create(null), this._boundTextures = [], this._activeTextureLocation = -1, this._boundSamplers = /* @__PURE__ */ Object.create(null), this._uploads = {
1971
+ image: be,
1972
+ buffer: gt,
1973
+ video: Tt,
1974
+ compressed: vt
1975
+ }, this._useSeparateSamplers = !1, this._renderer = e, this._renderer.renderableGC.addManagedHash(this, "_glTextures"), this._renderer.renderableGC.addManagedHash(this, "_glSamplers");
1976
+ }
1977
+ contextChange(e) {
1978
+ this._gl = e, this._mapFormatToInternalFormat || (this._mapFormatToInternalFormat = Nt(e, this._renderer.context.extensions), this._mapFormatToType = It(e), this._mapFormatToFormat = Bt(e)), this._glTextures = /* @__PURE__ */ Object.create(null), this._glSamplers = /* @__PURE__ */ Object.create(null), this._boundSamplers = /* @__PURE__ */ Object.create(null);
1979
+ for (let r = 0; r < 16; r++)
1980
+ this.bind(p.EMPTY, r);
1981
+ }
1982
+ initSource(e) {
1983
+ this.bind(e);
1984
+ }
1985
+ bind(e, r = 0) {
1986
+ const s = e.source;
1987
+ e ? (this.bindSource(s, r), this._useSeparateSamplers && this._bindSampler(s.style, r)) : (this.bindSource(null, r), this._useSeparateSamplers && this._bindSampler(null, r));
1988
+ }
1989
+ bindSource(e, r = 0) {
1990
+ const s = this._gl;
1991
+ if (e._touched = this._renderer.textureGC.count, this._boundTextures[r] !== e) {
1992
+ this._boundTextures[r] = e, this._activateLocation(r), e = e || p.EMPTY.source;
1993
+ const n = this.getGlSource(e);
1994
+ s.bindTexture(n.target, n.texture);
1995
+ }
1996
+ }
1997
+ _bindSampler(e, r = 0) {
1998
+ const s = this._gl;
1999
+ if (!e) {
2000
+ this._boundSamplers[r] = null, s.bindSampler(r, null);
2001
+ return;
2002
+ }
2003
+ const n = this._getGlSampler(e);
2004
+ this._boundSamplers[r] !== n && (this._boundSamplers[r] = n, s.bindSampler(r, n));
2005
+ }
2006
+ unbind(e) {
2007
+ const r = e.source, s = this._boundTextures, n = this._gl;
2008
+ for (let i = 0; i < s.length; i++)
2009
+ if (s[i] === r) {
2010
+ this._activateLocation(i);
2011
+ const a = this.getGlSource(r);
2012
+ n.bindTexture(a.target, null), s[i] = null;
2013
+ }
2014
+ }
2015
+ _activateLocation(e) {
2016
+ this._activeTextureLocation !== e && (this._activeTextureLocation = e, this._gl.activeTexture(this._gl.TEXTURE0 + e));
2017
+ }
2018
+ _initSource(e) {
2019
+ const r = this._gl, s = new pt(r.createTexture());
2020
+ if (s.type = this._mapFormatToType[e.format], s.internalFormat = this._mapFormatToInternalFormat[e.format], s.format = this._mapFormatToFormat[e.format], e.autoGenerateMipmaps && (this._renderer.context.supports.nonPowOf2mipmaps || e.isPowerOfTwo)) {
2021
+ const n = Math.max(e.width, e.height);
2022
+ e.mipLevelCount = Math.floor(Math.log2(n)) + 1;
2023
+ }
2024
+ return this._glTextures[e.uid] = s, this.managedTextures.includes(e) || (e.on("update", this.onSourceUpdate, this), e.on("resize", this.onSourceUpdate, this), e.on("styleChange", this.onStyleChange, this), e.on("destroy", this.onSourceDestroy, this), e.on("unload", this.onSourceUnload, this), e.on("updateMipmaps", this.onUpdateMipmaps, this), this.managedTextures.push(e)), this.onSourceUpdate(e), this.updateStyle(e, !1), s;
2025
+ }
2026
+ onStyleChange(e) {
2027
+ this.updateStyle(e, !1);
2028
+ }
2029
+ updateStyle(e, r) {
2030
+ const s = this._gl, n = this.getGlSource(e);
2031
+ s.bindTexture(s.TEXTURE_2D, n.texture), this._boundTextures[this._activeTextureLocation] = e, j(
2032
+ e.style,
2033
+ s,
2034
+ e.mipLevelCount > 1,
2035
+ this._renderer.context.extensions.anisotropicFiltering,
2036
+ "texParameteri",
2037
+ s.TEXTURE_2D,
2038
+ !this._renderer.context.supports.nonPowOf2wrapping && !e.isPowerOfTwo,
2039
+ r
2040
+ );
2041
+ }
2042
+ onSourceUnload(e) {
2043
+ const r = this._glTextures[e.uid];
2044
+ !r || (this.unbind(e), this._glTextures[e.uid] = null, this._gl.deleteTexture(r.texture));
2045
+ }
2046
+ onSourceUpdate(e) {
2047
+ const r = this._gl, s = this.getGlSource(e);
2048
+ r.bindTexture(r.TEXTURE_2D, s.texture), this._boundTextures[this._activeTextureLocation] = e, this._uploads[e.uploadMethodId] ? this._uploads[e.uploadMethodId].upload(e, s, r, this._renderer.context.webGLVersion) : r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, e.pixelWidth, e.pixelHeight, 0, r.RGBA, r.UNSIGNED_BYTE, null), e.autoGenerateMipmaps && e.mipLevelCount > 1 && this.onUpdateMipmaps(e, !1);
2049
+ }
2050
+ onUpdateMipmaps(e, r = !0) {
2051
+ r && this.bindSource(e, 0);
2052
+ const s = this.getGlSource(e);
2053
+ this._gl.generateMipmap(s.target);
2054
+ }
2055
+ onSourceDestroy(e) {
2056
+ e.off("destroy", this.onSourceDestroy, this), e.off("update", this.onSourceUpdate, this), e.off("resize", this.onSourceUpdate, this), e.off("unload", this.onSourceUnload, this), e.off("styleChange", this.onStyleChange, this), e.off("updateMipmaps", this.onUpdateMipmaps, this), this.managedTextures.splice(this.managedTextures.indexOf(e), 1), this.onSourceUnload(e);
2057
+ }
2058
+ _initSampler(e) {
2059
+ const r = this._gl, s = this._gl.createSampler();
2060
+ return this._glSamplers[e._resourceId] = s, j(
2061
+ e,
2062
+ r,
2063
+ this._boundTextures[this._activeTextureLocation].mipLevelCount > 1,
2064
+ this._renderer.context.extensions.anisotropicFiltering,
2065
+ "samplerParameteri",
2066
+ s,
2067
+ !1,
2068
+ !0
2069
+ ), this._glSamplers[e._resourceId];
2070
+ }
2071
+ _getGlSampler(e) {
2072
+ return this._glSamplers[e._resourceId] || this._initSampler(e);
2073
+ }
2074
+ getGlSource(e) {
2075
+ return this._glTextures[e.uid] || this._initSource(e);
2076
+ }
2077
+ generateCanvas(e) {
2078
+ const { pixels: r, width: s, height: n } = this.getPixels(e), i = S.get().createCanvas();
2079
+ i.width = s, i.height = n;
2080
+ const a = i.getContext("2d");
2081
+ if (a) {
2082
+ const o = a.createImageData(s, n);
2083
+ o.data.set(r), a.putImageData(o, 0, 0);
2084
+ }
2085
+ return i;
2086
+ }
2087
+ getPixels(e) {
2088
+ const r = e.source.resolution, s = e.frame, n = Math.max(Math.round(s.width * r), 1), i = Math.max(Math.round(s.height * r), 1), a = new Uint8Array(Dt * n * i), o = this._renderer, c = o.renderTarget.getRenderTarget(e), u = o.renderTarget.getGpuRenderTarget(c), _ = o.gl;
2089
+ return _.bindFramebuffer(_.FRAMEBUFFER, u.resolveTargetFramebuffer), _.readPixels(
2090
+ Math.round(s.x * r),
2091
+ Math.round(s.y * r),
2092
+ n,
2093
+ i,
2094
+ _.RGBA,
2095
+ _.UNSIGNED_BYTE,
2096
+ a
2097
+ ), { pixels: new Uint8ClampedArray(a.buffer), width: n, height: i };
2098
+ }
2099
+ destroy() {
2100
+ this.managedTextures.slice().forEach((e) => this.onSourceDestroy(e)), this.managedTextures = null, this._renderer = null;
2101
+ }
2102
+ }
2103
+ Se.extension = {
2104
+ type: [
2105
+ l.WebGLSystem
2106
+ ],
2107
+ name: "texture"
2108
+ };
2109
+ class pe {
2110
+ init() {
2111
+ const e = new P({
2112
+ uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
2113
+ uTransformMatrix: { value: new Y(), type: "mat3x3<f32>" },
2114
+ uRound: { value: 0, type: "f32" }
2115
+ }), r = z(), s = q({
2116
+ name: "graphics",
2117
+ bits: [
2118
+ Ie,
2119
+ De(r),
2120
+ Q,
2121
+ Z
2122
+ ]
2123
+ });
2124
+ this.shader = new O({
2125
+ glProgram: s,
2126
+ resources: {
2127
+ localUniforms: e,
2128
+ batchSamplers: ye(r)
2129
+ }
2130
+ });
2131
+ }
2132
+ execute(e, r) {
2133
+ const s = r.context, n = s.customShader || this.shader, i = e.renderer, a = i.graphicsContext, {
2134
+ batcher: o,
2135
+ instructions: c
2136
+ } = a.getContextRenderData(s);
2137
+ n.groups[0] = i.globalUniforms.bindGroup, i.state.set(e.state), i.shader.bind(n), i.geometry.bind(o.geometry, n.glProgram);
2138
+ const u = c.instructions;
2139
+ for (let _ = 0; _ < c.instructionSize; _++) {
2140
+ const h = u[_];
2141
+ if (h.size) {
2142
+ for (let d = 0; d < h.textures.count; d++)
2143
+ i.texture.bind(h.textures.textures[d], d);
2144
+ i.geometry.draw("triangle-list", h.size, h.start);
2145
+ }
2146
+ }
2147
+ }
2148
+ destroy() {
2149
+ this.shader.destroy(!0), this.shader = null;
2150
+ }
2151
+ }
2152
+ pe.extension = {
2153
+ type: [
2154
+ l.WebGLPipesAdaptor
2155
+ ],
2156
+ name: "graphics"
2157
+ };
2158
+ class ge {
2159
+ init() {
2160
+ const e = q({
2161
+ name: "mesh",
2162
+ bits: [
2163
+ Q,
2164
+ He,
2165
+ Z
2166
+ ]
2167
+ });
2168
+ this._shader = new O({
2169
+ glProgram: e,
2170
+ resources: {
2171
+ uTexture: p.EMPTY.source,
2172
+ textureUniforms: {
2173
+ uTextureMatrix: { type: "mat3x3<f32>", value: new Y() }
2174
+ }
2175
+ }
2176
+ });
2177
+ }
2178
+ execute(e, r) {
2179
+ const s = e.renderer;
2180
+ let n = r._shader;
2181
+ if (n) {
2182
+ if (!n.glProgram) {
2183
+ m("Mesh shader has no glProgram", r.shader);
2184
+ return;
2185
+ }
2186
+ } else {
2187
+ n = this._shader;
2188
+ const i = r.texture, a = i.source;
2189
+ n.resources.uTexture = a, n.resources.uSampler = a.style, n.resources.textureUniforms.uniforms.uTextureMatrix = i.textureMatrix.mapCoord;
2190
+ }
2191
+ n.groups[100] = s.globalUniforms.bindGroup, n.groups[101] = e.localUniformsBindGroup, s.encoder.draw({
2192
+ geometry: r._geometry,
2193
+ shader: n,
2194
+ state: r.state
2195
+ });
2196
+ }
2197
+ destroy() {
2198
+ this._shader.destroy(!0), this._shader = null;
2199
+ }
2200
+ }
2201
+ ge.extension = {
2202
+ type: [
2203
+ l.WebGLPipesAdaptor
2204
+ ],
2205
+ name: "mesh"
2206
+ };
2207
+ const yt = [
2208
+ ...we,
2209
+ _e,
2210
+ $e,
2211
+ Xe,
2212
+ te,
2213
+ Se,
2214
+ fe,
2215
+ ne,
2216
+ me,
2217
+ de,
2218
+ oe,
2219
+ St,
2220
+ ce,
2221
+ ae
2222
+ ], Ct = [...Ve], Gt = [ee, ge, pe], Re = [], ve = [], Te = [];
2223
+ x.handleByNamedList(l.WebGLSystem, Re);
2224
+ x.handleByNamedList(l.WebGLPipes, ve);
2225
+ x.handleByNamedList(l.WebGLPipesAdaptor, Te);
2226
+ x.add(...yt, ...Ct, ...Gt);
2227
+ class Ht extends Ce {
2228
+ constructor() {
2229
+ const e = {
2230
+ name: "webgl",
2231
+ type: Ge.WEBGL,
2232
+ systems: Re,
2233
+ renderPipes: ve,
2234
+ renderPipeAdaptors: Te
2235
+ };
2236
+ super(e);
2237
+ }
2238
+ }
2239
+ export {
2240
+ Ht as WebGLRenderer
2241
+ };