holostaff-widget 3.0.0-alpha.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{BufferResource-DXhnw-dI.js → BufferResource-DeLlYxf8.js} +58 -56
  2. package/dist/{BufferResource-DXhnw-dI.js.map → BufferResource-DeLlYxf8.js.map} +1 -1
  3. package/dist/CanvasRenderer-BgLtSh22.js +5933 -0
  4. package/dist/CanvasRenderer-BgLtSh22.js.map +1 -0
  5. package/dist/Geometry-Bdq2tsB3.js +1017 -0
  6. package/dist/Geometry-Bdq2tsB3.js.map +1 -0
  7. package/dist/{RenderTargetSystem-CzB0gbGa.js → RenderTargetSystem-BCBByEgg.js} +1543 -501
  8. package/dist/RenderTargetSystem-BCBByEgg.js.map +1 -0
  9. package/dist/{WebGLRenderer-DtR6kMFT.js → WebGLRenderer-3x7mgYt9.js} +55 -54
  10. package/dist/{WebGLRenderer-DtR6kMFT.js.map → WebGLRenderer-3x7mgYt9.js.map} +1 -1
  11. package/dist/{WebGPURenderer-dabwtEl1.js → WebGPURenderer-CdbjQMqs.js} +242 -197
  12. package/dist/WebGPURenderer-CdbjQMqs.js.map +1 -0
  13. package/dist/{browserAll-BVcYDudp.js → browserAll-DejMU3y7.js} +3 -3
  14. package/dist/{browserAll-BVcYDudp.js.map → browserAll-DejMU3y7.js.map} +1 -1
  15. package/dist/getTextureBatchBindGroup-CHJWR-eE.js +23 -0
  16. package/dist/getTextureBatchBindGroup-CHJWR-eE.js.map +1 -0
  17. package/dist/hs-widget.es.js +2 -2
  18. package/dist/hs-widget.umd.js +210 -122
  19. package/dist/hs-widget.umd.js.map +1 -1
  20. package/dist/index-C1ZbqCjI.js +17937 -0
  21. package/dist/index-C1ZbqCjI.js.map +1 -0
  22. package/dist/{webworkerAll-7qf_N1bC.js → webworkerAll-D5g5Ds7S.js} +12 -12
  23. package/dist/{webworkerAll-7qf_N1bC.js.map → webworkerAll-D5g5Ds7S.js.map} +1 -1
  24. package/package.json +2 -1
  25. package/dist/CanvasRenderer-JN1g1jcS.js +0 -976
  26. package/dist/CanvasRenderer-JN1g1jcS.js.map +0 -1
  27. package/dist/Filter-CD8NI4d3.js +0 -57
  28. package/dist/Filter-CD8NI4d3.js.map +0 -1
  29. package/dist/RenderTargetSystem-CzB0gbGa.js.map +0 -1
  30. package/dist/WebGPURenderer-dabwtEl1.js.map +0 -1
  31. package/dist/index-X9A71QD8.js +0 -25701
  32. package/dist/index-X9A71QD8.js.map +0 -1
@@ -0,0 +1,1017 @@
1
+ import { D as rt, a as y, E as N, B as nt } from "./index-C1ZbqCjI.js";
2
+ const P = /* @__PURE__ */ Object.create(null), Y = /* @__PURE__ */ Object.create(null);
3
+ function L(s, t) {
4
+ let e = Y[s];
5
+ return e === void 0 && (P[t] === void 0 && (P[t] = 1), Y[s] = e = P[t]++), e;
6
+ }
7
+ let b;
8
+ function ot() {
9
+ return (!b || b != null && b.isContextLost()) && (b = rt.get().createCanvas().getContext("webgl", {})), b;
10
+ }
11
+ let E;
12
+ function at() {
13
+ if (!E) {
14
+ E = "mediump";
15
+ const s = ot();
16
+ s && s.getShaderPrecisionFormat && (E = s.getShaderPrecisionFormat(s.FRAGMENT_SHADER, s.HIGH_FLOAT).precision ? "highp" : "mediump");
17
+ }
18
+ return E;
19
+ }
20
+ function ut(s, t, e) {
21
+ return t ? s : e ? (s = s.replace("out vec4 finalColor;", ""), `
22
+
23
+ #ifdef GL_ES // This checks if it is WebGL1
24
+ #define in varying
25
+ #define finalColor gl_FragColor
26
+ #define texture texture2D
27
+ #endif
28
+ ${s}
29
+ `) : `
30
+
31
+ #ifdef GL_ES // This checks if it is WebGL1
32
+ #define in attribute
33
+ #define out varying
34
+ #endif
35
+ ${s}
36
+ `;
37
+ }
38
+ function ct(s, t, e) {
39
+ const i = e ? t.maxSupportedFragmentPrecision : t.maxSupportedVertexPrecision;
40
+ if (s.substring(0, 9) !== "precision") {
41
+ let r = e ? t.requestedFragmentPrecision : t.requestedVertexPrecision;
42
+ return r === "highp" && i !== "highp" && (r = "mediump"), `precision ${r} float;
43
+ ${s}`;
44
+ } else if (i !== "highp" && s.substring(0, 15) === "precision highp")
45
+ return s.replace("precision highp", "precision mediump");
46
+ return s;
47
+ }
48
+ function lt(s, t) {
49
+ return t ? `#version 300 es
50
+ ${s}` : s;
51
+ }
52
+ const dt = {}, ht = {};
53
+ function ft(s, { name: t = "pixi-program" }, e = !0) {
54
+ t = t.replace(/\s+/g, "-"), t += e ? "-fragment" : "-vertex";
55
+ const i = e ? dt : ht;
56
+ return i[t] ? (i[t]++, t += `-${i[t]}`) : i[t] = 1, s.indexOf("#define SHADER_NAME") !== -1 ? s : `${`#define SHADER_NAME ${t}`}
57
+ ${s}`;
58
+ }
59
+ function mt(s, t) {
60
+ return t ? s.replace("#version 300 es", "") : s;
61
+ }
62
+ const v = {
63
+ // strips any version headers..
64
+ stripVersion: mt,
65
+ // adds precision string if not already present
66
+ ensurePrecision: ct,
67
+ // add some defines if WebGL1 to make it more compatible with WebGL2 shaders
68
+ addProgramDefines: ut,
69
+ // add the program name to the shader
70
+ setProgramName: ft,
71
+ // add the version string to the shader header
72
+ insertVersion: lt
73
+ }, _ = /* @__PURE__ */ Object.create(null), K = class R {
74
+ /**
75
+ * Creates a shiny new GlProgram. Used by WebGL renderer.
76
+ * @param options - The options for the program.
77
+ */
78
+ constructor(t) {
79
+ t = { ...R.defaultOptions, ...t };
80
+ const e = t.fragment.indexOf("#version 300 es") !== -1, i = {
81
+ stripVersion: e,
82
+ ensurePrecision: {
83
+ requestedFragmentPrecision: t.preferredFragmentPrecision,
84
+ requestedVertexPrecision: t.preferredVertexPrecision,
85
+ maxSupportedVertexPrecision: "highp",
86
+ maxSupportedFragmentPrecision: at()
87
+ },
88
+ setProgramName: {
89
+ name: t.name
90
+ },
91
+ addProgramDefines: e,
92
+ insertVersion: e
93
+ };
94
+ let r = t.fragment, n = t.vertex;
95
+ Object.keys(v).forEach((a) => {
96
+ const o = i[a];
97
+ r = v[a](r, o, !0), n = v[a](n, o, !1);
98
+ }), this.fragment = r, this.vertex = n, this.transformFeedbackVaryings = t.transformFeedbackVaryings, this._key = L(`${this.vertex}:${this.fragment}`, "gl-program");
99
+ }
100
+ /** destroys the program */
101
+ destroy() {
102
+ this.fragment = null, this.vertex = null, this._attributeData = null, this._uniformData = null, this._uniformBlockData = null, this.transformFeedbackVaryings = null, _[this._cacheKey] = null;
103
+ }
104
+ /**
105
+ * Helper function that creates a program for a given source.
106
+ * It will check the program cache if the program has already been created.
107
+ * If it has that one will be returned, if not a new one will be created and cached.
108
+ * @param options - The options for the program.
109
+ * @returns A program using the same source
110
+ */
111
+ static from(t) {
112
+ const e = `${t.vertex}:${t.fragment}`;
113
+ return _[e] || (_[e] = new R(t), _[e]._cacheKey = e), _[e];
114
+ }
115
+ };
116
+ K.defaultOptions = {
117
+ preferredVertexPrecision: "highp",
118
+ preferredFragmentPrecision: "mediump"
119
+ };
120
+ let U = K;
121
+ const j = {
122
+ uint8x2: { size: 2, stride: 2, normalised: !1 },
123
+ uint8x4: { size: 4, stride: 4, normalised: !1 },
124
+ sint8x2: { size: 2, stride: 2, normalised: !1 },
125
+ sint8x4: { size: 4, stride: 4, normalised: !1 },
126
+ unorm8x2: { size: 2, stride: 2, normalised: !0 },
127
+ unorm8x4: { size: 4, stride: 4, normalised: !0 },
128
+ snorm8x2: { size: 2, stride: 2, normalised: !0 },
129
+ snorm8x4: { size: 4, stride: 4, normalised: !0 },
130
+ uint16x2: { size: 2, stride: 4, normalised: !1 },
131
+ uint16x4: { size: 4, stride: 8, normalised: !1 },
132
+ sint16x2: { size: 2, stride: 4, normalised: !1 },
133
+ sint16x4: { size: 4, stride: 8, normalised: !1 },
134
+ unorm16x2: { size: 2, stride: 4, normalised: !0 },
135
+ unorm16x4: { size: 4, stride: 8, normalised: !0 },
136
+ snorm16x2: { size: 2, stride: 4, normalised: !0 },
137
+ snorm16x4: { size: 4, stride: 8, normalised: !0 },
138
+ float16x2: { size: 2, stride: 4, normalised: !1 },
139
+ float16x4: { size: 4, stride: 8, normalised: !1 },
140
+ float32: { size: 1, stride: 4, normalised: !1 },
141
+ float32x2: { size: 2, stride: 8, normalised: !1 },
142
+ float32x3: { size: 3, stride: 12, normalised: !1 },
143
+ float32x4: { size: 4, stride: 16, normalised: !1 },
144
+ uint32: { size: 1, stride: 4, normalised: !1 },
145
+ uint32x2: { size: 2, stride: 8, normalised: !1 },
146
+ uint32x3: { size: 3, stride: 12, normalised: !1 },
147
+ uint32x4: { size: 4, stride: 16, normalised: !1 },
148
+ sint32: { size: 1, stride: 4, normalised: !1 },
149
+ sint32x2: { size: 2, stride: 8, normalised: !1 },
150
+ sint32x3: { size: 3, stride: 12, normalised: !1 },
151
+ sint32x4: { size: 4, stride: 16, normalised: !1 }
152
+ };
153
+ function pt(s) {
154
+ return j[s] ?? j.float32;
155
+ }
156
+ const gt = {
157
+ f32: "float32",
158
+ "vec2<f32>": "float32x2",
159
+ "vec3<f32>": "float32x3",
160
+ "vec4<f32>": "float32x4",
161
+ vec2f: "float32x2",
162
+ vec3f: "float32x3",
163
+ vec4f: "float32x4",
164
+ i32: "sint32",
165
+ "vec2<i32>": "sint32x2",
166
+ "vec3<i32>": "sint32x3",
167
+ "vec4<i32>": "sint32x4",
168
+ vec2i: "sint32x2",
169
+ vec3i: "sint32x3",
170
+ vec4i: "sint32x4",
171
+ u32: "uint32",
172
+ "vec2<u32>": "uint32x2",
173
+ "vec3<u32>": "uint32x3",
174
+ "vec4<u32>": "uint32x4",
175
+ vec2u: "uint32x2",
176
+ vec3u: "uint32x3",
177
+ vec4u: "uint32x4",
178
+ bool: "uint32",
179
+ "vec2<bool>": "uint32x2",
180
+ "vec3<bool>": "uint32x3",
181
+ "vec4<bool>": "uint32x4"
182
+ }, X = /@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;
183
+ function W(s, t) {
184
+ let e;
185
+ for (; (e = X.exec(s)) !== null; ) {
186
+ const i = gt[e[3]] ?? "float32";
187
+ t[e[2]] = {
188
+ location: parseInt(e[1], 10),
189
+ format: i,
190
+ stride: pt(i).stride,
191
+ offset: 0,
192
+ instance: !1,
193
+ start: 0
194
+ };
195
+ }
196
+ X.lastIndex = 0;
197
+ }
198
+ function yt(s) {
199
+ return s.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
200
+ }
201
+ function bt({ source: s, entryPoint: t }) {
202
+ const e = {}, i = yt(s), r = i.indexOf(`fn ${t}(`);
203
+ if (r === -1)
204
+ return e;
205
+ const n = i.indexOf("->", r);
206
+ if (n === -1)
207
+ return e;
208
+ const a = i.substring(r, n);
209
+ if (W(a, e), Object.keys(e).length === 0) {
210
+ const o = a.match(/\(\s*\w+\s*:\s*(\w+)/);
211
+ if (o) {
212
+ const d = o[1], l = new RegExp(`struct\\s+${d}\\s*\\{([^}]+)\\}`, "s"), u = i.match(l);
213
+ u && W(u[1], e);
214
+ }
215
+ }
216
+ return e;
217
+ }
218
+ function T(s) {
219
+ var h, f;
220
+ const t = /(^|[^/])@(group|binding)\(\d+\)[^;]+;/g, e = /@group\((\d+)\)/, i = /@binding\((\d+)\)/, r = /var(<[^>]+>)? (\w+)/, n = /:\s*([\w<>]+)/, a = /struct\s+(\w+)\s*{([^}]+)}/g, o = /(\w+)\s*:\s*([\w\<\>]+)/g, d = /struct\s+(\w+)/, l = (h = s.match(t)) == null ? void 0 : h.map((c) => ({
221
+ group: parseInt(c.match(e)[1], 10),
222
+ binding: parseInt(c.match(i)[1], 10),
223
+ name: c.match(r)[2],
224
+ isUniform: c.match(r)[1] === "<uniform>",
225
+ type: c.match(n)[1]
226
+ }));
227
+ if (!l)
228
+ return {
229
+ groups: [],
230
+ structs: []
231
+ };
232
+ const u = ((f = s.match(a)) == null ? void 0 : f.map((c) => {
233
+ const p = c.match(d)[1], V = c.match(o).reduce((B, et) => {
234
+ const [st, it] = et.split(":");
235
+ return B[st.trim()] = it.trim(), B;
236
+ }, {});
237
+ return V ? { name: p, members: V } : null;
238
+ }).filter(({ name: c }) => l.some(
239
+ (p) => (
240
+ // Handle both direct type matches and generic types like array<StructName>
241
+ p.type === c || p.type.includes(`<${c}>`)
242
+ )
243
+ ))) ?? [];
244
+ return {
245
+ groups: l,
246
+ structs: u
247
+ };
248
+ }
249
+ var g = /* @__PURE__ */ ((s) => (s[s.VERTEX = 1] = "VERTEX", s[s.FRAGMENT = 2] = "FRAGMENT", s[s.COMPUTE = 4] = "COMPUTE", s))(g || {});
250
+ function _t({ groups: s }) {
251
+ const t = [];
252
+ for (let e = 0; e < s.length; e++) {
253
+ const i = s[e];
254
+ t[i.group] || (t[i.group] = []), i.isUniform ? t[i.group].push({
255
+ binding: i.binding,
256
+ visibility: g.VERTEX | g.FRAGMENT,
257
+ buffer: {
258
+ type: "uniform"
259
+ }
260
+ }) : i.type === "sampler" ? t[i.group].push({
261
+ binding: i.binding,
262
+ visibility: g.FRAGMENT,
263
+ sampler: {
264
+ type: "filtering"
265
+ }
266
+ }) : i.type === "texture_2d" || i.type.startsWith("texture_2d<") ? t[i.group].push({
267
+ binding: i.binding,
268
+ visibility: g.FRAGMENT,
269
+ texture: {
270
+ sampleType: "float",
271
+ viewDimension: "2d",
272
+ multisampled: !1
273
+ }
274
+ }) : i.type === "texture_2d_array" || i.type.startsWith("texture_2d_array<") ? t[i.group].push({
275
+ binding: i.binding,
276
+ visibility: g.FRAGMENT,
277
+ texture: {
278
+ sampleType: "float",
279
+ viewDimension: "2d-array",
280
+ multisampled: !1
281
+ }
282
+ }) : (i.type === "texture_cube" || i.type.startsWith("texture_cube<")) && t[i.group].push({
283
+ binding: i.binding,
284
+ visibility: g.FRAGMENT,
285
+ texture: {
286
+ sampleType: "float",
287
+ viewDimension: "cube",
288
+ multisampled: !1
289
+ }
290
+ });
291
+ }
292
+ for (let e = 0; e < t.length; e++)
293
+ t[e] || (t[e] = []);
294
+ return t;
295
+ }
296
+ function xt({ groups: s }) {
297
+ const t = [];
298
+ for (let e = 0; e < s.length; e++) {
299
+ const i = s[e];
300
+ t[i.group] || (t[i.group] = {}), t[i.group][i.name] = i.binding;
301
+ }
302
+ return t;
303
+ }
304
+ function Et(s, t) {
305
+ const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), r = [...s.structs, ...t.structs].filter((a) => e.has(a.name) ? !1 : (e.add(a.name), !0)), n = [...s.groups, ...t.groups].filter((a) => {
306
+ const o = `${a.name}-${a.binding}`;
307
+ return i.has(o) ? !1 : (i.add(o), !0);
308
+ });
309
+ return { structs: r, groups: n };
310
+ }
311
+ const x = /* @__PURE__ */ Object.create(null);
312
+ class A {
313
+ /**
314
+ * Create a new GpuProgram
315
+ * @param options - The options for the gpu program
316
+ */
317
+ constructor(t) {
318
+ var o, d;
319
+ this._layoutKey = 0, this._attributeLocationsKey = 0;
320
+ const { fragment: e, vertex: i, layout: r, gpuLayout: n, name: a } = t;
321
+ if (this.name = a, this.fragment = e, this.vertex = i, e.source === i.source) {
322
+ const l = T(e.source);
323
+ this.structsAndGroups = l;
324
+ } else {
325
+ const l = T(i.source), u = T(e.source);
326
+ this.structsAndGroups = Et(l, u);
327
+ }
328
+ this.layout = r ?? xt(this.structsAndGroups), this.gpuLayout = n ?? _t(this.structsAndGroups), this.autoAssignGlobalUniforms = ((o = this.layout[0]) == null ? void 0 : o.globalUniforms) !== void 0, this.autoAssignLocalUniforms = ((d = this.layout[1]) == null ? void 0 : d.localUniforms) !== void 0, this._generateProgramKey();
329
+ }
330
+ // TODO maker this pure
331
+ _generateProgramKey() {
332
+ const { vertex: t, fragment: e } = this, i = t.source + e.source + t.entryPoint + e.entryPoint;
333
+ this._layoutKey = L(i, "program");
334
+ }
335
+ get attributeData() {
336
+ return this._attributeData ?? (this._attributeData = bt(this.vertex)), this._attributeData;
337
+ }
338
+ /** destroys the program */
339
+ destroy() {
340
+ this.gpuLayout = null, this.layout = null, this.structsAndGroups = null, this.fragment = null, this.vertex = null, x[this._cacheKey] = null;
341
+ }
342
+ /**
343
+ * Helper function that creates a program for a given source.
344
+ * It will check the program cache if the program has already been created.
345
+ * If it has that one will be returned, if not a new one will be created and cached.
346
+ * @param options - The options for the program.
347
+ * @returns A program using the same source
348
+ */
349
+ static from(t) {
350
+ const e = `${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;
351
+ return x[e] || (x[e] = new A(t), x[e]._cacheKey = e), x[e];
352
+ }
353
+ }
354
+ const H = [
355
+ "f32",
356
+ "i32",
357
+ "vec2<f32>",
358
+ "vec3<f32>",
359
+ "vec4<f32>",
360
+ "mat2x2<f32>",
361
+ "mat3x3<f32>",
362
+ "mat4x4<f32>",
363
+ "mat3x2<f32>",
364
+ "mat4x2<f32>",
365
+ "mat2x3<f32>",
366
+ "mat4x3<f32>",
367
+ "mat2x4<f32>",
368
+ "mat3x4<f32>",
369
+ "vec2<i32>",
370
+ "vec3<i32>",
371
+ "vec4<i32>"
372
+ ], At = H.reduce((s, t) => (s[t] = !0, s), {});
373
+ function Pt(s, t) {
374
+ switch (s) {
375
+ case "f32":
376
+ return 0;
377
+ case "vec2<f32>":
378
+ return new Float32Array(2 * t);
379
+ case "vec3<f32>":
380
+ return new Float32Array(3 * t);
381
+ case "vec4<f32>":
382
+ return new Float32Array(4 * t);
383
+ case "mat2x2<f32>":
384
+ return new Float32Array([
385
+ 1,
386
+ 0,
387
+ 0,
388
+ 1
389
+ ]);
390
+ case "mat3x3<f32>":
391
+ return new Float32Array([
392
+ 1,
393
+ 0,
394
+ 0,
395
+ 0,
396
+ 1,
397
+ 0,
398
+ 0,
399
+ 0,
400
+ 1
401
+ ]);
402
+ case "mat4x4<f32>":
403
+ return new Float32Array([
404
+ 1,
405
+ 0,
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 1,
410
+ 0,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 1,
415
+ 0,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 1
420
+ ]);
421
+ }
422
+ return null;
423
+ }
424
+ const q = class Q {
425
+ /**
426
+ * Create a new Uniform group
427
+ * @param uniformStructures - The structures of the uniform group
428
+ * @param options - The optional parameters of this uniform group
429
+ */
430
+ constructor(t, e) {
431
+ this._touched = 0, this.uid = y("uniform"), this._resourceType = "uniformGroup", this._resourceId = y("resource"), this.isUniformGroup = !0, this._dirtyId = 0, this.destroyed = !1, e = { ...Q.defaultOptions, ...e }, this.uniformStructures = t;
432
+ const i = {};
433
+ for (const r in t) {
434
+ const n = t[r];
435
+ if (n.name = r, n.size = n.size ?? 1, !At[n.type]) {
436
+ const a = n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);
437
+ if (a) {
438
+ const [, o, d] = a;
439
+ throw new Error(
440
+ `Uniform type ${n.type} is not supported. Use type: '${o}', size: ${d} instead.`
441
+ );
442
+ }
443
+ throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${H.join(", ")}`);
444
+ }
445
+ n.value ?? (n.value = Pt(n.type, n.size)), i[r] = n.value;
446
+ }
447
+ this.uniforms = i, this._dirtyId = 1, this.ubo = e.ubo, this.isStatic = e.isStatic, this._signature = L(Object.keys(i).map(
448
+ (r) => `${r}-${t[r].type}`
449
+ ).join("-"), "uniform-group");
450
+ }
451
+ /** Call this if you want the uniform groups data to be uploaded to the GPU only useful if `isStatic` is true. */
452
+ update() {
453
+ this._dirtyId++;
454
+ }
455
+ };
456
+ q.defaultOptions = {
457
+ /** if true the UniformGroup is handled as an Uniform buffer object. */
458
+ ubo: !1,
459
+ /** if true, then you are responsible for when the data is uploaded to the GPU by calling `update()` */
460
+ isStatic: !1
461
+ };
462
+ let vt = q;
463
+ class F {
464
+ /**
465
+ * Create a new instance eof the Bind Group.
466
+ * @param resources - The resources that are bound together for use by a shader.
467
+ */
468
+ constructor(t) {
469
+ this.resources = /* @__PURE__ */ Object.create(null), this._dirty = !0;
470
+ let e = 0;
471
+ for (const i in t) {
472
+ const r = t[i];
473
+ this.setResource(r, e++);
474
+ }
475
+ this._updateKey();
476
+ }
477
+ /**
478
+ * Updates the key if its flagged as dirty. This is used internally to
479
+ * match this bind group to a WebGPU BindGroup.
480
+ * @internal
481
+ */
482
+ _updateKey() {
483
+ if (!this._dirty) return;
484
+ this._dirty = !1;
485
+ const t = [];
486
+ let e = 0;
487
+ for (const i in this.resources)
488
+ t[e++] = this.resources[i]._resourceId;
489
+ this._key = t.join("|");
490
+ }
491
+ /**
492
+ * Set a resource at a given index. this function will
493
+ * ensure that listeners will be removed from the current resource
494
+ * and added to the new resource.
495
+ * @param resource - The resource to set.
496
+ * @param index - The index to set the resource at.
497
+ */
498
+ setResource(t, e) {
499
+ var r, n;
500
+ const i = this.resources[e];
501
+ t !== i && ((r = i == null ? void 0 : i.off) == null || r.call(i, "change", this.onResourceChange, this), (n = t.on) == null || n.call(t, "change", this.onResourceChange, this), this.resources[e] = t, this._dirty = !0);
502
+ }
503
+ /**
504
+ * Returns the resource at the current specified index.
505
+ * @param index - The index of the resource to get.
506
+ * @returns - The resource at the specified index.
507
+ */
508
+ getResource(t) {
509
+ return this.resources[t];
510
+ }
511
+ /**
512
+ * Used internally to 'touch' each resource, to ensure that the GC
513
+ * knows that all resources in this bind group are still being used.
514
+ * @param now - The current time in milliseconds.
515
+ * @param tick - The current tick.
516
+ * @internal
517
+ */
518
+ _touch(t, e) {
519
+ const i = this.resources;
520
+ for (const r in i)
521
+ i[r]._gcLastUsed = t, i[r]._touched = e;
522
+ }
523
+ /** Destroys this bind group and removes all listeners. */
524
+ destroy() {
525
+ var e;
526
+ const t = this.resources;
527
+ for (const i in t) {
528
+ const r = t[i];
529
+ (e = r == null ? void 0 : r.off) == null || e.call(r, "change", this.onResourceChange, this);
530
+ }
531
+ this.resources = null;
532
+ }
533
+ onResourceChange(t) {
534
+ this._dirty = !0, t.destroyed ? this.destroy() : this._updateKey();
535
+ }
536
+ }
537
+ var I = /* @__PURE__ */ ((s) => (s[s.WEBGL = 1] = "WEBGL", s[s.WEBGPU = 2] = "WEBGPU", s[s.CANVAS = 4] = "CANVAS", s[s.BOTH = 3] = "BOTH", s))(I || {});
538
+ class k extends N {
539
+ constructor(t) {
540
+ super(), this.uid = y("shader"), this._uniformBindMap = /* @__PURE__ */ Object.create(null), this._ownedBindGroups = [], this._destroyed = !1;
541
+ let {
542
+ gpuProgram: e,
543
+ glProgram: i,
544
+ groups: r,
545
+ resources: n,
546
+ compatibleRenderers: a,
547
+ groupMap: o
548
+ } = t;
549
+ this.gpuProgram = e, this.glProgram = i, a === void 0 && (a = 0, e && (a |= I.WEBGPU), i && (a |= I.WEBGL)), this.compatibleRenderers = a;
550
+ const d = {};
551
+ if (!n && !r && (n = {}), n && r)
552
+ throw new Error("[Shader] Cannot have both resources and groups");
553
+ if (!e && r && !o)
554
+ throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");
555
+ if (!e && r && o)
556
+ for (const l in o)
557
+ for (const u in o[l]) {
558
+ const h = o[l][u];
559
+ d[h] = {
560
+ group: l,
561
+ binding: u,
562
+ name: h
563
+ };
564
+ }
565
+ else if (e && r && !o) {
566
+ const l = e.structsAndGroups.groups;
567
+ o = {}, l.forEach((u) => {
568
+ o[u.group] = o[u.group] || {}, o[u.group][u.binding] = u.name, d[u.name] = u;
569
+ });
570
+ } else if (n) {
571
+ r = {}, o = {}, e && e.structsAndGroups.groups.forEach((h) => {
572
+ o[h.group] = o[h.group] || {}, o[h.group][h.binding] = h.name, d[h.name] = h;
573
+ });
574
+ let l = 0;
575
+ for (const u in n)
576
+ d[u] || (r[99] || (r[99] = new F(), this._ownedBindGroups.push(r[99])), d[u] = { group: 99, binding: l, name: u }, o[99] = o[99] || {}, o[99][l] = u, l++);
577
+ for (const u in n) {
578
+ const h = u;
579
+ let f = n[u];
580
+ !f.source && !f._resourceType && (f = new vt(f));
581
+ const c = d[h];
582
+ c && (r[c.group] || (r[c.group] = new F(), this._ownedBindGroups.push(r[c.group])), r[c.group].setResource(f, c.binding));
583
+ }
584
+ }
585
+ this.groups = r, this._uniformBindMap = o, this.resources = this._buildResourceAccessor(r, d);
586
+ }
587
+ /**
588
+ * Sometimes a resource group will be provided later (for example global uniforms)
589
+ * In such cases, this method can be used to let the shader know about the group.
590
+ * @param name - the name of the resource group
591
+ * @param groupIndex - the index of the group (should match the webGPU shader group location)
592
+ * @param bindIndex - the index of the bind point (should match the webGPU shader bind point)
593
+ */
594
+ addResource(t, e, i) {
595
+ var r, n;
596
+ (r = this._uniformBindMap)[e] || (r[e] = {}), (n = this._uniformBindMap[e])[i] || (n[i] = t), this.groups[e] || (this.groups[e] = new F(), this._ownedBindGroups.push(this.groups[e]));
597
+ }
598
+ _buildResourceAccessor(t, e) {
599
+ const i = {};
600
+ for (const r in e) {
601
+ const n = e[r];
602
+ Object.defineProperty(i, n.name, {
603
+ get() {
604
+ return t[n.group].getResource(n.binding);
605
+ },
606
+ set(a) {
607
+ t[n.group].setResource(a, n.binding);
608
+ }
609
+ });
610
+ }
611
+ return i;
612
+ }
613
+ /**
614
+ * Use to destroy the shader when its not longer needed.
615
+ * It will destroy the resources and remove listeners.
616
+ * @param destroyPrograms - if the programs should be destroyed as well.
617
+ * Make sure its not being used by other shaders!
618
+ */
619
+ destroy(t = !1) {
620
+ var e, i;
621
+ this._destroyed || (this._destroyed = !0, this.emit("destroy", this), t && ((e = this.gpuProgram) == null || e.destroy(), (i = this.glProgram) == null || i.destroy()), this.gpuProgram = null, this.glProgram = null, this.removeAllListeners(), this._uniformBindMap = null, this._ownedBindGroups.forEach((r) => {
622
+ r.destroy();
623
+ }), this._ownedBindGroups = null, this.resources = null, this.groups = null);
624
+ }
625
+ static from(t) {
626
+ const { gpu: e, gl: i, ...r } = t;
627
+ let n, a;
628
+ return e && (n = A.from(e)), i && (a = U.from(i)), new k({
629
+ gpuProgram: n,
630
+ glProgram: a,
631
+ ...r
632
+ });
633
+ }
634
+ }
635
+ const Tt = {
636
+ normal: 0,
637
+ add: 1,
638
+ multiply: 2,
639
+ screen: 3,
640
+ overlay: 4,
641
+ erase: 5,
642
+ "normal-npm": 6,
643
+ "add-npm": 7,
644
+ "screen-npm": 8,
645
+ min: 9,
646
+ max: 10
647
+ }, w = 0, S = 1, D = 2, G = 3, M = 4, O = 5, C = class Z {
648
+ constructor() {
649
+ this.data = 0, this.blendMode = "normal", this.polygonOffset = 0, this.blend = !0, this.depthMask = !0;
650
+ }
651
+ /**
652
+ * Activates blending of the computed fragment color values.
653
+ * @default true
654
+ */
655
+ get blend() {
656
+ return !!(this.data & 1 << w);
657
+ }
658
+ set blend(t) {
659
+ !!(this.data & 1 << w) !== t && (this.data ^= 1 << w);
660
+ }
661
+ /**
662
+ * Activates adding an offset to depth values of polygon's fragments
663
+ * @default false
664
+ */
665
+ get offsets() {
666
+ return !!(this.data & 1 << S);
667
+ }
668
+ set offsets(t) {
669
+ !!(this.data & 1 << S) !== t && (this.data ^= 1 << S);
670
+ }
671
+ /** The culling settings for this state none - No culling back - Back face culling front - Front face culling */
672
+ set cullMode(t) {
673
+ if (t === "none") {
674
+ this.culling = !1;
675
+ return;
676
+ }
677
+ this.culling = !0, this.clockwiseFrontFace = t === "front";
678
+ }
679
+ get cullMode() {
680
+ return this.culling ? this.clockwiseFrontFace ? "front" : "back" : "none";
681
+ }
682
+ /**
683
+ * Activates culling of polygons.
684
+ * @default false
685
+ */
686
+ get culling() {
687
+ return !!(this.data & 1 << D);
688
+ }
689
+ set culling(t) {
690
+ !!(this.data & 1 << D) !== t && (this.data ^= 1 << D);
691
+ }
692
+ /**
693
+ * Activates depth comparisons and updates to the depth buffer.
694
+ * @default false
695
+ */
696
+ get depthTest() {
697
+ return !!(this.data & 1 << G);
698
+ }
699
+ set depthTest(t) {
700
+ !!(this.data & 1 << G) !== t && (this.data ^= 1 << G);
701
+ }
702
+ /**
703
+ * Enables or disables writing to the depth buffer.
704
+ * @default true
705
+ */
706
+ get depthMask() {
707
+ return !!(this.data & 1 << O);
708
+ }
709
+ set depthMask(t) {
710
+ !!(this.data & 1 << O) !== t && (this.data ^= 1 << O);
711
+ }
712
+ /**
713
+ * Specifies whether or not front or back-facing polygons can be culled.
714
+ * @default false
715
+ */
716
+ get clockwiseFrontFace() {
717
+ return !!(this.data & 1 << M);
718
+ }
719
+ set clockwiseFrontFace(t) {
720
+ !!(this.data & 1 << M) !== t && (this.data ^= 1 << M);
721
+ }
722
+ /**
723
+ * The blend mode to be applied when this state is set. Apply a value of `normal` to reset the blend mode.
724
+ * Setting this mode to anything other than NO_BLEND will automatically switch blending on.
725
+ * @default 'normal'
726
+ */
727
+ get blendMode() {
728
+ return this._blendMode;
729
+ }
730
+ set blendMode(t) {
731
+ this.blend = t !== "none", this._blendMode = t, this._blendModeId = Tt[t] || 0;
732
+ }
733
+ /**
734
+ * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.
735
+ * @default 0
736
+ */
737
+ get polygonOffset() {
738
+ return this._polygonOffset;
739
+ }
740
+ set polygonOffset(t) {
741
+ this.offsets = !!t, this._polygonOffset = t;
742
+ }
743
+ toString() {
744
+ return `[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
745
+ }
746
+ /**
747
+ * A quickly getting an instance of a State that is configured for 2d rendering.
748
+ * @returns a new State with values set for 2d rendering
749
+ */
750
+ static for2d() {
751
+ const t = new Z();
752
+ return t.depthTest = !1, t.blend = !0, t;
753
+ }
754
+ };
755
+ C.default2d = C.for2d();
756
+ let Ft = C;
757
+ const J = class z extends k {
758
+ /**
759
+ * @param options - The optional parameters of this filter.
760
+ */
761
+ constructor(t) {
762
+ t = { ...z.defaultOptions, ...t }, super(t), this.enabled = !0, this._state = Ft.for2d(), this.blendMode = t.blendMode, this.padding = t.padding, typeof t.antialias == "boolean" ? this.antialias = t.antialias ? "on" : "off" : this.antialias = t.antialias, this.resolution = t.resolution, this.blendRequired = t.blendRequired, this.clipToViewport = t.clipToViewport, this.addResource("uTexture", 0, 1), t.blendRequired && this.addResource("uBackTexture", 0, 3);
763
+ }
764
+ /**
765
+ * Applies the filter
766
+ * @param filterManager - The renderer to retrieve the filter from
767
+ * @param input - The input render target.
768
+ * @param output - The target to output to.
769
+ * @param clearMode - Should the output be cleared before rendering to it
770
+ */
771
+ apply(t, e, i, r) {
772
+ t.applyFilter(this, e, i, r);
773
+ }
774
+ /**
775
+ * Get the blend mode of the filter.
776
+ * @default "normal"
777
+ */
778
+ get blendMode() {
779
+ return this._state.blendMode;
780
+ }
781
+ /** Sets the blend mode of the filter. */
782
+ set blendMode(t) {
783
+ this._state.blendMode = t;
784
+ }
785
+ /**
786
+ * A short hand function to create a filter based of a vertex and fragment shader src.
787
+ * @param options
788
+ * @returns A shiny new PixiJS filter!
789
+ */
790
+ static from(t) {
791
+ const { gpu: e, gl: i, ...r } = t;
792
+ let n, a;
793
+ return e && (n = A.from(e)), i && (a = U.from(i)), new z({
794
+ gpuProgram: n,
795
+ glProgram: a,
796
+ ...r
797
+ });
798
+ }
799
+ };
800
+ J.defaultOptions = {
801
+ blendMode: "normal",
802
+ resolution: 1,
803
+ padding: 0,
804
+ antialias: "off",
805
+ blendRequired: !1,
806
+ clipToViewport: !0
807
+ };
808
+ let Gt = J;
809
+ var m = /* @__PURE__ */ ((s) => (s[s.MAP_READ = 1] = "MAP_READ", s[s.MAP_WRITE = 2] = "MAP_WRITE", s[s.COPY_SRC = 4] = "COPY_SRC", s[s.COPY_DST = 8] = "COPY_DST", s[s.INDEX = 16] = "INDEX", s[s.VERTEX = 32] = "VERTEX", s[s.UNIFORM = 64] = "UNIFORM", s[s.STORAGE = 128] = "STORAGE", s[s.INDIRECT = 256] = "INDIRECT", s[s.QUERY_RESOLVE = 512] = "QUERY_RESOLVE", s[s.STATIC = 1024] = "STATIC", s))(m || {});
810
+ let $ = class extends N {
811
+ /**
812
+ * Creates a new Buffer with the given options
813
+ * @param options - the options for the buffer
814
+ */
815
+ constructor(t) {
816
+ let { data: e, size: i } = t;
817
+ const { usage: r, label: n, shrinkToFit: a } = t;
818
+ super(), this._gpuData = /* @__PURE__ */ Object.create(null), this._gcLastUsed = -1, this.autoGarbageCollect = !0, this.uid = y("buffer"), this._resourceType = "buffer", this._resourceId = y("resource"), this._touched = 0, this._updateID = 1, this._dataInt32 = null, this.shrinkToFit = !0, this.destroyed = !1, e instanceof Array && (e = new Float32Array(e)), this._data = e, i ?? (i = e == null ? void 0 : e.byteLength);
819
+ const o = !!e;
820
+ this.descriptor = {
821
+ size: i,
822
+ usage: r,
823
+ mappedAtCreation: o,
824
+ label: n
825
+ }, this.shrinkToFit = a ?? !0;
826
+ }
827
+ /** the data in the buffer */
828
+ get data() {
829
+ return this._data;
830
+ }
831
+ set data(t) {
832
+ this.setDataWithSize(t, t.length, !0);
833
+ }
834
+ get dataInt32() {
835
+ return this._dataInt32 || (this._dataInt32 = new Int32Array(this.data.buffer)), this._dataInt32;
836
+ }
837
+ /** whether the buffer is static or not */
838
+ get static() {
839
+ return !!(this.descriptor.usage & m.STATIC);
840
+ }
841
+ set static(t) {
842
+ t ? this.descriptor.usage |= m.STATIC : this.descriptor.usage &= ~m.STATIC;
843
+ }
844
+ /**
845
+ * Sets the data in the buffer to the given value. This will immediately update the buffer on the GPU.
846
+ * If you only want to update a subset of the buffer, you can pass in the size of the data.
847
+ * @param value - the data to set
848
+ * @param size - the size of the data in bytes
849
+ * @param syncGPU - should the buffer be updated on the GPU immediately?
850
+ */
851
+ setDataWithSize(t, e, i) {
852
+ if (this._updateID++, this._updateSize = e * t.BYTES_PER_ELEMENT, this._data === t) {
853
+ i && this.emit("update", this);
854
+ return;
855
+ }
856
+ const r = this._data;
857
+ if (this._data = t, this._dataInt32 = null, !r || r.length !== t.length) {
858
+ !this.shrinkToFit && r && t.byteLength < r.byteLength ? i && this.emit("update", this) : (this.descriptor.size = t.byteLength, this._resourceId = y("resource"), this.emit("change", this));
859
+ return;
860
+ }
861
+ i && this.emit("update", this);
862
+ }
863
+ /**
864
+ * updates the buffer on the GPU to reflect the data in the buffer.
865
+ * By default it will update the entire buffer. If you only want to update a subset of the buffer,
866
+ * you can pass in the size of the buffer to update.
867
+ * @param sizeInBytes - the new size of the buffer in bytes
868
+ */
869
+ update(t) {
870
+ this._updateSize = t ?? this._updateSize, this._updateID++, this.emit("update", this);
871
+ }
872
+ /** Unloads the buffer from the GPU */
873
+ unload() {
874
+ var t;
875
+ this.emit("unload", this);
876
+ for (const e in this._gpuData)
877
+ (t = this._gpuData[e]) == null || t.destroy();
878
+ this._gpuData = /* @__PURE__ */ Object.create(null);
879
+ }
880
+ /** Destroys the buffer */
881
+ destroy() {
882
+ this.destroyed = !0, this.unload(), this.emit("destroy", this), this.emit("change", this), this._data = null, this.descriptor = null, this.removeAllListeners();
883
+ }
884
+ };
885
+ function tt(s, t) {
886
+ if (!(s instanceof $)) {
887
+ let e = t ? m.INDEX : m.VERTEX;
888
+ s instanceof Array && (t ? (s = new Uint32Array(s), e = m.INDEX | m.COPY_DST) : (s = new Float32Array(s), e = m.VERTEX | m.COPY_DST)), s = new $({
889
+ data: s,
890
+ label: t ? "index-mesh-buffer" : "vertex-mesh-buffer",
891
+ usage: e
892
+ });
893
+ }
894
+ return s;
895
+ }
896
+ function wt(s, t, e) {
897
+ const i = s.getAttribute(t);
898
+ if (!i)
899
+ return e.minX = 0, e.minY = 0, e.maxX = 0, e.maxY = 0, e;
900
+ const r = i.buffer.data;
901
+ let n = 1 / 0, a = 1 / 0, o = -1 / 0, d = -1 / 0;
902
+ const l = r.BYTES_PER_ELEMENT, u = (i.offset || 0) / l, h = (i.stride || 8) / l;
903
+ for (let f = u; f < r.length; f += h) {
904
+ const c = r[f], p = r[f + 1];
905
+ c > o && (o = c), p > d && (d = p), c < n && (n = c), p < a && (a = p);
906
+ }
907
+ return e.minX = n, e.minY = a, e.maxX = o, e.maxY = d, e;
908
+ }
909
+ function St(s) {
910
+ return (s instanceof $ || Array.isArray(s) || s.BYTES_PER_ELEMENT) && (s = {
911
+ buffer: s
912
+ }), s.buffer = tt(s.buffer, !1), s;
913
+ }
914
+ class Ot extends N {
915
+ /**
916
+ * Create a new instance of a geometry
917
+ * @param options - The options for the geometry.
918
+ */
919
+ constructor(t = {}) {
920
+ super(), this._gpuData = /* @__PURE__ */ Object.create(null), this.autoGarbageCollect = !0, this._gcLastUsed = -1, this.uid = y("geometry"), this._layoutKey = 0, this.instanceCount = 1, this._bounds = new nt(), this._boundsDirty = !0;
921
+ const { attributes: e, indexBuffer: i, topology: r } = t;
922
+ if (this.buffers = [], this.attributes = {}, e)
923
+ for (const n in e)
924
+ this.addAttribute(n, e[n]);
925
+ this.instanceCount = t.instanceCount ?? 1, i && this.addIndex(i), this.topology = r || "triangle-list";
926
+ }
927
+ onBufferUpdate() {
928
+ this._boundsDirty = !0, this.emit("update", this);
929
+ }
930
+ /**
931
+ * Returns the requested attribute.
932
+ * @param id - The name of the attribute required
933
+ * @returns - The attribute requested.
934
+ */
935
+ getAttribute(t) {
936
+ return this.attributes[t];
937
+ }
938
+ /**
939
+ * Returns the index buffer
940
+ * @returns - The index buffer.
941
+ */
942
+ getIndex() {
943
+ return this.indexBuffer;
944
+ }
945
+ /**
946
+ * Returns the requested buffer.
947
+ * @param id - The name of the buffer required.
948
+ * @returns - The buffer requested.
949
+ */
950
+ getBuffer(t) {
951
+ return this.getAttribute(t).buffer;
952
+ }
953
+ /**
954
+ * Used to figure out how many vertices there are in this geometry
955
+ * @returns the number of vertices in the geometry
956
+ */
957
+ getSize() {
958
+ for (const t in this.attributes) {
959
+ const e = this.attributes[t];
960
+ return e.buffer.data.length / (e.stride / 4 || e.size);
961
+ }
962
+ return 0;
963
+ }
964
+ /**
965
+ * Adds an attribute to the geometry.
966
+ * @param name - The name of the attribute to add.
967
+ * @param attributeOption - The attribute option to add.
968
+ */
969
+ addAttribute(t, e) {
970
+ const i = St(e);
971
+ this.buffers.indexOf(i.buffer) === -1 && (this.buffers.push(i.buffer), i.buffer.on("update", this.onBufferUpdate, this), i.buffer.on("change", this.onBufferUpdate, this)), this.attributes[t] = i;
972
+ }
973
+ /**
974
+ * Adds an index buffer to the geometry.
975
+ * @param indexBuffer - The index buffer to add. Can be a Buffer, TypedArray, or an array of numbers.
976
+ */
977
+ addIndex(t) {
978
+ this.indexBuffer = tt(t, !0), this.buffers.push(this.indexBuffer);
979
+ }
980
+ /** Returns the bounds of the geometry. */
981
+ get bounds() {
982
+ return this._boundsDirty ? (this._boundsDirty = !1, wt(this, "aPosition", this._bounds)) : this._bounds;
983
+ }
984
+ /** Unloads the geometry from the GPU. */
985
+ unload() {
986
+ var t;
987
+ this.emit("unload", this);
988
+ for (const e in this._gpuData)
989
+ (t = this._gpuData[e]) == null || t.destroy();
990
+ this._gpuData = /* @__PURE__ */ Object.create(null);
991
+ }
992
+ /**
993
+ * destroys the geometry.
994
+ * @param destroyBuffers - destroy the buffers associated with this geometry
995
+ */
996
+ destroy(t = !1) {
997
+ var e;
998
+ this.emit("destroy", this), this.removeAllListeners(), t && this.buffers.forEach((i) => i.destroy()), this.unload(), (e = this.indexBuffer) == null || e.destroy(), this.attributes = null, this.buffers = null, this.indexBuffer = null, this._bounds = null;
999
+ }
1000
+ }
1001
+ export {
1002
+ F as B,
1003
+ Gt as F,
1004
+ U as G,
1005
+ I as R,
1006
+ Ft as S,
1007
+ vt as U,
1008
+ $ as a,
1009
+ m as b,
1010
+ L as c,
1011
+ k as d,
1012
+ Ot as e,
1013
+ ot as f,
1014
+ pt as g,
1015
+ A as h
1016
+ };
1017
+ //# sourceMappingURL=Geometry-Bdq2tsB3.js.map