mapicgc-gl-js 1.0.7 → 1.0.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 (52) hide show
  1. package/README.md +2 -4
  2. package/dist/array-utils-flat-DeB-J5jn.mjs +1523 -0
  3. package/dist/assets/maplibre-gl-worker-HMCkgiD4.js +10 -0
  4. package/dist/buffer-transform-CH0poqqn.mjs +941 -0
  5. package/dist/expression-CtaQKvTZ.mjs +3444 -0
  6. package/dist/get-attribute-from-layouts-DqvACIaG.mjs +936 -0
  7. package/dist/{html2canvas-DhrjCa5K-6_3CwS_m.mjs → html2canvas-Cgp0Hyhk-HIw4n-A9.mjs} +105 -109
  8. package/dist/{index.es-D_FsJY9H-CO3QIBGM.mjs → index.es-lgdlL0gw-Bl7I-U5B.mjs} +176 -176
  9. package/dist/mapicgc-gl-js.css +1 -1
  10. package/dist/mapicgc-gl.css +199 -0
  11. package/dist/mapicgc-gl.js +5079 -856
  12. package/dist/mapicgc-gl.mjs +85573 -61841
  13. package/dist/purify.es-DNpVkA56-DxzGf9c8.mjs +769 -0
  14. package/dist/{chunk-efA98nb6-Dfm7IivL.mjs → rolldown-runtime-3b4jIN3o-CmciV3xi.mjs} +2 -2
  15. package/dist/{typeof-CTd55yxz-BxqQpTq1.mjs → typeof-C3azmBUr-9LkZMuan.mjs} +1 -1
  16. package/dist/webgl-Cep-x0-T.mjs +784 -0
  17. package/package.json +20 -15
  18. package/public/mapicgc-gl.css +199 -0
  19. package/src/controls/ApiTerritorialControl.js +222 -0
  20. package/src/index.js +18 -1
  21. package/src/map/Map.js +245 -144
  22. package/src/mapicgc-config.json +1303 -8
  23. package/src/plugins/CompareMaps.js +2 -1
  24. package/src/territorial/ApiTerritorialControl.js +1 -0
  25. package/src/territorial/mostraPanellInfo.js +250 -0
  26. package/src/territorial/searchApiTerritorialICGC.js +250 -0
  27. package/test/exemples/addApiTerritorialICGC.html +113 -0
  28. package/test/exemples/addBasemap.html +4 -4
  29. package/test/exemples/addCompare.html +7 -6
  30. package/test/exemples/addControl.html +12 -6
  31. package/test/exemples/addFeatureQuery.html +5 -4
  32. package/test/exemples/addGeocoderICGC.html +5 -4
  33. package/test/exemples/addICGCTerrain.html +5 -4
  34. package/test/exemples/addICGCTerrainCustomStyle.html +5 -4
  35. package/test/exemples/addImageLayerICGC.html +5 -4
  36. package/test/exemples/addLayerGeojson.html +5 -4
  37. package/test/exemples/addLayerTree.html +5 -4
  38. package/test/exemples/addLogo.html +5 -3
  39. package/test/exemples/addMapStyle.html +5 -4
  40. package/test/exemples/addMarker.html +5 -4
  41. package/test/exemples/addMouseCoordinateControl.html +5 -4
  42. package/test/exemples/addReliefStyle.html +6 -5
  43. package/test/exemples/addVectorLayerICGC.html +5 -4
  44. package/test/exemples/advancedExemple.html +5 -4
  45. package/test/exemples/fetchData.html +6 -5
  46. package/test/exemples/fetchDataAndMenu.html +5 -4
  47. package/test/exemples/styleOrto3D.html +8 -4
  48. package/test/vitest/ApiTerritorialControl.test.js +76 -0
  49. package/vite.config.mjs +16 -5
  50. package/dist/purify.es-DVGU85zV-CJOZ7ABI.mjs +0 -549
  51. package/dist/webgl-device-B1jTrfKA.mjs +0 -6880
  52. package/dist/webgl-device-D8jkwRzb.mjs +0 -2
@@ -0,0 +1,941 @@
1
+ import { _ as e, b as t, c as n, f as r, p as i, u as a, v as o } from "./array-utils-flat-DeB-J5jn.mjs";
2
+ import { C as s, E as c, S as l, T as u, _ as d, b as f, d as p, f as ee, g as m, h, l as g, m as _, p as v, s as y, u as b, w as x } from "./expression-CtaQKvTZ.mjs";
3
+ import { c as te, i as ne, l as re, n as S, o as ie, r as C, s as w, t as ae } from "./get-attribute-from-layouts-DqvACIaG.mjs";
4
+ //#region node_modules/@luma.gl/core/dist/adapter/resources/external-texture.js
5
+ var T = class e extends o {
6
+ width;
7
+ height;
8
+ updateTimestamp;
9
+ get [Symbol.toStringTag]() {
10
+ return "ExternalTexture";
11
+ }
12
+ constructor(t, n) {
13
+ super(t, n, e.defaultProps);
14
+ let r = this.props.source ? t.getExternalImageSize(this.props.source) : null;
15
+ this.width = this.props.width || r?.width || 0, this.height = this.props.height || r?.height || 0, this.updateTimestamp = t.incrementTimestamp();
16
+ }
17
+ static defaultProps = {
18
+ ...o.defaultProps,
19
+ source: void 0,
20
+ width: 0,
21
+ height: 0,
22
+ colorSpace: "srgb",
23
+ sampler: {}
24
+ };
25
+ }, oe = "#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";
26
+ function se(e) {
27
+ let { input: t, inputChannels: n, output: r } = e || {};
28
+ if (!t) return oe;
29
+ if (!n) throw Error("inputChannels");
30
+ return `\
31
+ #version 300 es
32
+ in ${E(n)} ${t};
33
+ out vec4 ${r};
34
+ void main() {
35
+ ${r} = ${D(t, n)};
36
+ }`;
37
+ }
38
+ function E(e) {
39
+ switch (e) {
40
+ case 1: return "float";
41
+ case 2: return "vec2";
42
+ case 3: return "vec3";
43
+ case 4: return "vec4";
44
+ default: throw Error(`invalid channels: ${e}`);
45
+ }
46
+ }
47
+ function D(e, t) {
48
+ switch (t) {
49
+ case 1: return `vec4(${e}, 0.0, 0.0, 1.0)`;
50
+ case 2: return `vec4(${e}, 0.0, 1.0)`;
51
+ case 3: return `vec4(${e}, 1.0)`;
52
+ case 4: return e;
53
+ default: throw Error(`invalid channels: ${t}`);
54
+ }
55
+ }
56
+ //#endregion
57
+ //#region node_modules/@luma.gl/engine/dist/geometry/geometry.js
58
+ var O = class {
59
+ id;
60
+ topology;
61
+ vertexCount;
62
+ indices;
63
+ attributes;
64
+ bufferLayout;
65
+ userData = {};
66
+ constructor(e) {
67
+ let { attributes: t = {}, indices: n = null, vertexCount: r = null } = e;
68
+ this.id = e.id || d("geometry"), this.topology = e.topology, n && (this.indices = ArrayBuffer.isView(n) ? {
69
+ value: n,
70
+ size: 1
71
+ } : n), this.attributes = {};
72
+ for (let [e, n] of Object.entries(t)) {
73
+ let t = ArrayBuffer.isView(n) ? { value: n } : n;
74
+ if (!ArrayBuffer.isView(t.value)) throw Error(`${this._print(e)}: must be typed array or object with value as typed array`);
75
+ if ((e === "POSITION" || e === "positions") && !t.size && (t.size = 3), e === "indices") {
76
+ if (this.indices) throw Error("Multiple indices detected");
77
+ this.indices = t;
78
+ } else {
79
+ let n = k(e), r = Object.keys(this.attributes).find((e) => k(e) === n);
80
+ r && delete this.attributes[r], this.attributes[e] = t;
81
+ }
82
+ }
83
+ this.indices && this.indices.isIndexed !== void 0 && (this.indices = Object.assign({}, this.indices), delete this.indices.isIndexed), this.vertexCount = r || this._calculateVertexCount(this.attributes, this.indices), this.bufferLayout = e.bufferLayout || ce(this.attributes);
84
+ }
85
+ getVertexCount() {
86
+ return this.vertexCount;
87
+ }
88
+ getAttributes() {
89
+ return this.indices ? {
90
+ indices: this.indices,
91
+ ...this.attributes
92
+ } : this.attributes;
93
+ }
94
+ _print(e) {
95
+ return `Geometry ${this.id} attribute ${e}`;
96
+ }
97
+ _setAttributes(e, t) {
98
+ return this;
99
+ }
100
+ _calculateVertexCount(e, t) {
101
+ if (t) return t.value.length;
102
+ let n = Infinity;
103
+ for (let t of Object.values(e)) {
104
+ if (!t) continue;
105
+ let { value: e, size: r, constant: i } = t;
106
+ !i && e && r !== void 0 && r >= 1 && (n = Math.min(n, e.length / r));
107
+ }
108
+ return n;
109
+ }
110
+ };
111
+ function k(e) {
112
+ switch (e) {
113
+ case "POSITION": return "positions";
114
+ case "NORMAL": return "normals";
115
+ case "TEXCOORD_0": return "texCoords";
116
+ case "TEXCOORD_1": return "texCoords1";
117
+ case "COLOR_0": return "colors";
118
+ default: return e;
119
+ }
120
+ }
121
+ function ce(e) {
122
+ let t = [];
123
+ for (let [n, i] of Object.entries(e)) {
124
+ if (!i) continue;
125
+ let { value: e, size: a, normalized: o } = i;
126
+ if (a === void 0) throw Error(`Attribute ${n} is missing a size`);
127
+ t.push({
128
+ name: k(n),
129
+ format: r.getVertexFormatFromAttribute(e, a, o)
130
+ });
131
+ }
132
+ return t;
133
+ }
134
+ //#endregion
135
+ //#region node_modules/@luma.gl/engine/dist/geometry/geometry-utils.js
136
+ function A(e, t = {}) {
137
+ let n = t.bufferName || "geometry";
138
+ if (le(e, n)) return e;
139
+ let i = t.minAttributeAlignment || 4, a = ue(e, t.attributes), o = [], s = 0, c = Infinity;
140
+ for (let [e, t] of a) {
141
+ if (!t) continue;
142
+ if (t.constant) throw Error(`Attribute ${e} is constant`);
143
+ let { value: n, size: a, normalized: l } = t;
144
+ if (!ArrayBuffer.isView(n)) throw Error(`Attribute ${e} is missing typed array data`);
145
+ if (a === void 0) throw Error(`Attribute ${e} is missing a size`);
146
+ let u = r.getVertexFormatFromAttribute(n, a, l), d = r.getVertexFormatInfo(u);
147
+ s = M(s, i), o.push({
148
+ sourceName: e,
149
+ attributeName: k(e),
150
+ value: n,
151
+ size: a,
152
+ format: u,
153
+ byteOffset: s,
154
+ byteLength: d.byteLength
155
+ }), s += d.byteLength;
156
+ let f = n.length / a;
157
+ if (!Number.isInteger(f)) throw Error(`Attribute ${e} length is not divisible by size`);
158
+ c = Math.min(c, f);
159
+ }
160
+ if (o.length === 0 || !Number.isFinite(c)) throw Error(`Geometry ${e.id} has no interleavable attributes`);
161
+ let l = M(s, i), u = new ArrayBuffer(c * l);
162
+ for (let e of o) j(u, c, l, e);
163
+ return new O({
164
+ id: e.id,
165
+ topology: e.topology || "triangle-list",
166
+ vertexCount: e.vertexCount,
167
+ indices: e.indices,
168
+ attributes: { [n]: {
169
+ value: new Uint8Array(u),
170
+ size: l,
171
+ byteStride: l
172
+ } },
173
+ bufferLayout: [{
174
+ name: n,
175
+ stepMode: "vertex",
176
+ byteStride: l,
177
+ attributes: o.map((e) => ({
178
+ attribute: e.attributeName,
179
+ format: e.format,
180
+ byteOffset: e.byteOffset
181
+ }))
182
+ }]
183
+ });
184
+ }
185
+ function le(e, t) {
186
+ if (e.bufferLayout.length !== 1) return !1;
187
+ let n = e.bufferLayout[0];
188
+ return n.name === t && !!n.attributes?.length && !!e.attributes[t];
189
+ }
190
+ function ue(e, t) {
191
+ return t ? t.map((t) => [t, e.attributes[t]]) : Object.entries(e.attributes);
192
+ }
193
+ function j(e, t, n, r) {
194
+ let i = r.value.constructor, a = i.BYTES_PER_ELEMENT;
195
+ if (r.byteOffset % a !== 0 || n % a !== 0) throw Error(`Attribute ${r.sourceName} is not aligned to its component type`);
196
+ let o = new i(e), s = r.value, c = r.byteOffset / a, l = n / a;
197
+ for (let e = 0; e < t; e++) {
198
+ let t = e * r.size, n = e * l + c;
199
+ for (let e = 0; e < r.size; e++) o[n + e] = s[t + e];
200
+ }
201
+ }
202
+ function M(e, t) {
203
+ return Math.ceil(e / t) * t;
204
+ }
205
+ //#endregion
206
+ //#region node_modules/@luma.gl/engine/dist/geometry/gpu-geometry.js
207
+ var N = class {
208
+ id;
209
+ userData = {};
210
+ topology;
211
+ bufferLayout = [];
212
+ vertexCount;
213
+ indices;
214
+ attributes;
215
+ constructor(t) {
216
+ if (this.id = t.id || d("geometry"), this.topology = t.topology, this.indices = t.indices || null, this.attributes = t.attributes, this.vertexCount = t.vertexCount, this.bufferLayout = t.bufferLayout || [], this.indices && !(this.indices.usage & e.INDEX)) throw Error("Index buffer must have INDEX usage");
217
+ }
218
+ destroy() {
219
+ this.indices?.destroy();
220
+ for (let e of Object.values(this.attributes)) e.destroy();
221
+ }
222
+ getVertexCount() {
223
+ return this.vertexCount;
224
+ }
225
+ getAttributes() {
226
+ return this.attributes;
227
+ }
228
+ getIndexes() {
229
+ return this.indices || null;
230
+ }
231
+ _calculateVertexCount(e) {
232
+ return e.byteLength / 12;
233
+ }
234
+ };
235
+ function P(e, t) {
236
+ if (t instanceof N) return t;
237
+ let n = A(t), r = F(e, n), { attributes: i, bufferLayout: a } = I(e, n);
238
+ return new N({
239
+ topology: n.topology || "triangle-list",
240
+ bufferLayout: a,
241
+ vertexCount: n.vertexCount,
242
+ indices: r,
243
+ attributes: i
244
+ });
245
+ }
246
+ function F(t, n) {
247
+ if (!n.indices) return;
248
+ let r = n.indices.value;
249
+ return t.createBuffer({
250
+ usage: e.INDEX,
251
+ data: r
252
+ });
253
+ }
254
+ function I(e, t) {
255
+ let n = {};
256
+ for (let [r, i] of Object.entries(t.attributes)) {
257
+ let a = t.bufferLayout.find((e) => e.name === r)?.name || k(r);
258
+ i && (n[a] = e.createBuffer({
259
+ data: i.value,
260
+ id: `${r}-buffer`
261
+ }));
262
+ }
263
+ return {
264
+ attributes: n,
265
+ bufferLayout: t.bufferLayout,
266
+ vertexCount: t.vertexCount
267
+ };
268
+ }
269
+ //#endregion
270
+ //#region node_modules/@luma.gl/engine/dist/debug/debug-shader-layout.js
271
+ function L(e, t) {
272
+ let n = {}, r = "Values";
273
+ if (e.attributes.length === 0 && !e.varyings?.length) return { "No attributes or varyings": { [r]: "N/A" } };
274
+ for (let t of e.attributes) if (t) {
275
+ let e = `${t.location} ${t.name}: ${t.type}`;
276
+ n[`in ${e}`] = { [r]: t.stepMode || "vertex" };
277
+ }
278
+ for (let t of e.varyings || []) {
279
+ let e = `${t.location} ${t.name}`;
280
+ n[`out ${e}`] = { [r]: JSON.stringify(t) };
281
+ }
282
+ return n;
283
+ }
284
+ //#endregion
285
+ //#region node_modules/@luma.gl/engine/dist/debug/debug-framebuffer.js
286
+ var R = "__debugFramebufferState", z = 8;
287
+ function B(e, t, n) {
288
+ if (e.device.type !== "webgl") return;
289
+ let r = U(e.device);
290
+ if (!r.flushing) {
291
+ if (fe(e)) {
292
+ V(e, n, r);
293
+ return;
294
+ }
295
+ t && de(t) && t.handle !== null && (r.queuedFramebuffers.includes(t) || r.queuedFramebuffers.push(t));
296
+ }
297
+ }
298
+ function V(e, t, n) {
299
+ if (n.queuedFramebuffers.length === 0) return;
300
+ let { gl: r } = e.device, i = r.getParameter(36010), a = r.getParameter(36006), [o, s] = e.device.getDefaultCanvasContext().getDrawingBufferSize(), c = W(t.top, z), l = W(t.left, z);
301
+ n.flushing = !0;
302
+ try {
303
+ for (let e of n.queuedFramebuffers) {
304
+ let [n, i, a, u, d] = H({
305
+ framebuffer: e,
306
+ targetWidth: o,
307
+ targetHeight: s,
308
+ topPx: c,
309
+ leftPx: l,
310
+ minimap: t.minimap
311
+ });
312
+ r.bindFramebuffer(36008, e.handle), r.bindFramebuffer(36009, null), r.blitFramebuffer(0, 0, e.width, e.height, n, i, a, u, 16384, 9728), c += d + z;
313
+ }
314
+ } finally {
315
+ r.bindFramebuffer(36008, i), r.bindFramebuffer(36009, a), n.flushing = !1;
316
+ }
317
+ }
318
+ function H(e) {
319
+ let { framebuffer: t, targetWidth: n, targetHeight: r, topPx: i, leftPx: a, minimap: o } = e, s = o ? Math.max(Math.floor(n / 4), 1) : n, c = o ? Math.max(Math.floor(r / 4), 1) : r, l = Math.min(s / t.width, c / t.height), u = Math.max(Math.floor(t.width * l), 1), d = Math.max(Math.floor(t.height * l), 1), f = a, p = Math.max(r - i - d, 0);
320
+ return [
321
+ f,
322
+ p,
323
+ f + u,
324
+ p + d,
325
+ d
326
+ ];
327
+ }
328
+ function U(e) {
329
+ return e.userData[R] ||= {
330
+ flushing: !1,
331
+ queuedFramebuffers: []
332
+ }, e.userData[R];
333
+ }
334
+ function de(e) {
335
+ return "colorAttachments" in e;
336
+ }
337
+ function fe(e) {
338
+ let t = e.props.framebuffer;
339
+ return !t || t.handle === null;
340
+ }
341
+ function W(e, t) {
342
+ if (!e) return t;
343
+ let n = Number.parseInt(e, 10);
344
+ return Number.isFinite(n) ? n : t;
345
+ }
346
+ //#endregion
347
+ //#region node_modules/@luma.gl/engine/dist/utils/deep-equal.js
348
+ function G(e, t, n) {
349
+ if (e === t) return !0;
350
+ if (!n || !e || !t) return !1;
351
+ if (Array.isArray(e)) {
352
+ if (!Array.isArray(t) || e.length !== t.length) return !1;
353
+ for (let r = 0; r < e.length; r++) if (!G(e[r], t[r], n - 1)) return !1;
354
+ return !0;
355
+ }
356
+ if (Array.isArray(t)) return !1;
357
+ if (typeof e == "object" && typeof t == "object") {
358
+ let r = Object.keys(e), i = Object.keys(t);
359
+ if (r.length !== i.length) return !1;
360
+ for (let i of r) if (!t.hasOwnProperty(i) || !G(e[i], t[i], n - 1)) return !1;
361
+ return !0;
362
+ }
363
+ return !1;
364
+ }
365
+ //#endregion
366
+ //#region node_modules/@luma.gl/engine/dist/utils/buffer-layout-helper.js
367
+ var K = class {
368
+ bufferLayouts;
369
+ constructor(e) {
370
+ this.bufferLayouts = e;
371
+ }
372
+ getBufferLayout(e) {
373
+ return this.bufferLayouts.find((t) => t.name === e) || null;
374
+ }
375
+ getAttributeNamesForBuffer(e) {
376
+ return S(e);
377
+ }
378
+ mergeBufferLayouts(e, t) {
379
+ let n = [...e];
380
+ for (let e of t) {
381
+ let t = n.findIndex((t) => t.name === e.name);
382
+ t < 0 ? n.push(e) : n[t] = e;
383
+ }
384
+ return n;
385
+ }
386
+ };
387
+ //#endregion
388
+ //#region node_modules/@luma.gl/engine/dist/utils/buffer-layout-order.js
389
+ function pe(e, t) {
390
+ let n = ne(e), r = t.slice();
391
+ return r.sort((e, t) => C(S(e).map((e) => n[e])) - C(S(t).map((e) => n[e]))), r;
392
+ }
393
+ //#endregion
394
+ //#region node_modules/@luma.gl/engine/dist/dynamic-texture/texture-binding-source.js
395
+ function q(e) {
396
+ return typeof e == "object" && !!e && "resolveTextureBinding" in e && typeof e.resolveTextureBinding == "function";
397
+ }
398
+ function me(e) {
399
+ return e?.type === "texture" || e?.type === "external-texture";
400
+ }
401
+ function J(e, t, n) {
402
+ let r = ie(e, t, { ignoreWarnings: !0 });
403
+ return me(r) ? r : e.bindings.length === 0 && n?.fallbackGroup !== void 0 ? {
404
+ type: "texture",
405
+ name: t,
406
+ group: n.fallbackGroup,
407
+ location: 0
408
+ } : null;
409
+ }
410
+ //#endregion
411
+ //#region node_modules/@luma.gl/engine/dist/model/model.js
412
+ var Y = 2, he = 1e4, X = "render pipeline initialization failed", ge = [
413
+ "stencil8",
414
+ "depth16unorm",
415
+ "depth24plus",
416
+ "depth24plus-stencil8",
417
+ "depth32float",
418
+ "depth32float-stencil8"
419
+ ], Z = class r {
420
+ static defaultProps = {
421
+ ...n.defaultProps,
422
+ source: void 0,
423
+ vs: null,
424
+ fs: null,
425
+ id: "unnamed",
426
+ handle: void 0,
427
+ userData: {},
428
+ defines: {},
429
+ modules: [],
430
+ plugins: [],
431
+ geometry: null,
432
+ indexBuffer: null,
433
+ indexCount: void 0,
434
+ firstVertex: 0,
435
+ firstIndex: 0,
436
+ attributes: {},
437
+ constantAttributes: {},
438
+ bindings: {},
439
+ uniforms: {},
440
+ varyings: [],
441
+ isInstanced: void 0,
442
+ instanceCount: 0,
443
+ vertexCount: 0,
444
+ shaderInputs: void 0,
445
+ material: void 0,
446
+ pipelineFactory: void 0,
447
+ shaderFactory: void 0,
448
+ transformFeedback: void 0,
449
+ shaderAssembler: f.getDefaultShaderAssembler("glsl"),
450
+ debugShaders: void 0,
451
+ disableWarnings: void 0
452
+ };
453
+ device;
454
+ id;
455
+ source;
456
+ vs;
457
+ fs;
458
+ pipelineFactory;
459
+ shaderFactory;
460
+ userData = {};
461
+ parameters;
462
+ topology;
463
+ bufferLayout;
464
+ isInstanced = void 0;
465
+ instanceCount = 0;
466
+ vertexCount;
467
+ indexCount;
468
+ firstVertex;
469
+ firstIndex;
470
+ indexBuffer = null;
471
+ bufferAttributes = {};
472
+ constantAttributes = {};
473
+ bindings = {};
474
+ vertexArray;
475
+ transformFeedback = null;
476
+ pipeline;
477
+ shaderInputs;
478
+ material = null;
479
+ _uniformStore;
480
+ _attributeInfos = {};
481
+ _gpuGeometry = null;
482
+ props;
483
+ _dynamicIndexBufferSource = null;
484
+ _dynamicAttributeBufferSources = {};
485
+ _colorAttachmentFormats;
486
+ _depthStencilAttachmentFormat;
487
+ _pipelineNeedsUpdate = "newly created";
488
+ _needsRedraw = "initializing";
489
+ _drawBlockedReason = !1;
490
+ _destroyed = !1;
491
+ _lastDrawTimestamp = -1;
492
+ _bindingTable = [];
493
+ get [Symbol.toStringTag]() {
494
+ return "Model";
495
+ }
496
+ toString() {
497
+ return `Model(${this.id})`;
498
+ }
499
+ constructor(e, t) {
500
+ let n = r.defaultProps.shaderAssembler;
501
+ this.props = {
502
+ ...r.defaultProps,
503
+ ...t,
504
+ shaderAssembler: t.shaderAssembler ?? (Q(n, e.info.shadingLanguage) ? n : f.getDefaultShaderAssembler(e.info.shadingLanguage))
505
+ }, t = this.props, this.id = t.id || d("model"), this.device = e, Object.assign(this.userData, t.userData), this.material = t.material || null;
506
+ let i = xe(e), o = s(this.props.plugins, i.shaderLanguage), m = l(this.props.modules, o.modules), g = Object.fromEntries(m.map((e) => [e.name, e])), y = t.shaderInputs || new p(g, { disableWarnings: this.props.disableWarnings });
507
+ t.shaderInputs && o.modules.length > 0 && y.addModules(o.modules), this.setShaderInputs(y);
508
+ let b = h(this.props.modules, y.getModules()), x = {
509
+ ...o.defines,
510
+ ...this.props.defines
511
+ };
512
+ if (this.device.type === "webgl" && (this.props._uniformBlockLayouts = ee(b)), this.props.shaderLayout = _(this.props.shaderLayout, b) || null, this.device.type === "webgpu" && this.props.source) {
513
+ let t = this.props.shaderAssembler;
514
+ a(Q(t, "wgsl"));
515
+ let { source: n, getUniforms: r, bindingTable: s, shaderLayout: c } = t.assembleWGSLShader({
516
+ platformInfo: i,
517
+ ...this.props,
518
+ modules: b,
519
+ defines: x,
520
+ pluginInjections: o.injections,
521
+ pluginVertexInputs: o.vertexInputs,
522
+ pluginVaryings: o.varyings
523
+ });
524
+ this.source = n, this._getModuleUniforms = r, this._bindingTable = s;
525
+ let l = _e(c ?? e.getShaderLayout?.(this.source), o.vertexInputs), u = v(this.props.shaderLayout, l, Object.keys(o.vertexInputs));
526
+ this.props.shaderLayout = _(u || null, b) || null;
527
+ } else {
528
+ let e = this.props.shaderAssembler;
529
+ a(Q(e, "glsl"));
530
+ let { vs: t, fs: n, getUniforms: r } = e.assembleGLSLShaderPair({
531
+ platformInfo: i,
532
+ ...this.props,
533
+ modules: b,
534
+ defines: x,
535
+ pluginInjections: o.injections,
536
+ pluginVertexInputs: o.vertexInputs,
537
+ pluginVaryings: o.varyings
538
+ });
539
+ this.vs = t, this.fs = n, this._getModuleUniforms = r, this._bindingTable = [];
540
+ }
541
+ this.vertexCount = this.props.vertexCount, this.indexCount = this.props.indexCount, this.firstVertex = this.props.firstVertex, this.firstIndex = this.props.firstIndex, this.instanceCount = this.props.instanceCount, this.topology = this.props.topology, this.bufferLayout = this.props.bufferLayout, this.parameters = this.props.parameters, this._colorAttachmentFormats = this.props.colorAttachmentFormats, this._depthStencilAttachmentFormat = this.props.depthStencilAttachmentFormat, t.geometry && this.setGeometry(t.geometry), this.pipelineFactory = t.pipelineFactory || c.getDefaultPipelineFactory(this.device), this.shaderFactory = t.shaderFactory || u.getDefaultShaderFactory(this.device), this.pipeline = this._updatePipeline(), this.vertexArray = e.createVertexArray({
542
+ shaderLayout: this.pipeline.shaderLayout,
543
+ bufferLayout: this.pipeline.bufferLayout
544
+ }), this._gpuGeometry && this._setGeometryAttributes(this._gpuGeometry), "isInstanced" in t && (this.isInstanced = t.isInstanced), t.instanceCount && this.setInstanceCount(t.instanceCount), t.vertexCount && this.setVertexCount(t.vertexCount), t.indexBuffer && this.setIndexBuffer(t.indexBuffer), t.attributes && this.setAttributes(t.attributes), t.constantAttributes && this.setConstantAttributes(t.constantAttributes), t.bindings && this.setBindings(t.bindings), t.transformFeedback && (this.transformFeedback = t.transformFeedback);
545
+ }
546
+ destroy() {
547
+ this._destroyed ||= (this.pipelineFactory.release(this.pipeline), this.shaderFactory.release(this.pipeline.vs), this.pipeline.fs && this.pipeline.fs !== this.pipeline.vs && this.shaderFactory.release(this.pipeline.fs), this._uniformStore.destroy(), this._gpuGeometry?.destroy(), !0);
548
+ }
549
+ needsRedraw() {
550
+ this._getBindingsUpdateTimestamp() > this._lastDrawTimestamp && this.setNeedsRedraw("contents of bound textures or buffers updated");
551
+ let e = this._needsRedraw;
552
+ return this._needsRedraw = !1, e;
553
+ }
554
+ setNeedsRedraw(e) {
555
+ this._needsRedraw ||= e;
556
+ }
557
+ getBindingDebugTable() {
558
+ return this._bindingTable;
559
+ }
560
+ predraw(e) {
561
+ this._syncDynamicBuffers(), this.updateShaderInputs(e), this.material?.updateShaderInputs(e), this.pipeline = this._updatePipeline();
562
+ }
563
+ draw(e) {
564
+ if (this._drawBlockedReason && !this._pipelineNeedsUpdate) return t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(), !1;
565
+ let n = this._areBindingsLoading();
566
+ if (n) return t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${n} not loaded`)(), !1;
567
+ this._syncAttachmentFormats(e);
568
+ try {
569
+ e.pushDebugGroup(`${this}.predraw(${e})`), this.device.type === "webgpu" ? (this.updateShaderInputs(), this.material?.updateShaderInputs(), this._syncDynamicBuffers(), this.pipeline = this._updatePipeline()) : this.predraw(this.device.commandEncoder);
570
+ } finally {
571
+ e.popDebugGroup();
572
+ }
573
+ let r, i = this.pipeline.isErrored;
574
+ try {
575
+ if (e.pushDebugGroup(`${this}.draw(${e})`), this._logDrawCallStart(), this.pipeline = this._updatePipeline(), i = this.pipeline.isErrored, i) t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${X}`)(), r = !1;
576
+ else {
577
+ let n = this.vertexArray.getDrawValidationError();
578
+ if (n) t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${n}`)(), this._drawBlockedReason = n, r = !1;
579
+ else {
580
+ let t = this._getCurrentShaderLayout(), n = this._getBindings(t), i = this._getBindGroups(t, n), { indexBuffer: a } = this.vertexArray, o = a ? this.indexCount ?? a.byteLength / (a.indexType === "uint32" ? 4 : 2) : void 0;
581
+ e.setPipeline(this.pipeline), e.setBindings(i, { _bindGroupCacheKeys: this._getBindGroupCacheKeys() }), e.setVertexArray(this.vertexArray), r = this.isInstanced === !0 && this.instanceCount === 0 || e.draw({
582
+ isInstanced: this.isInstanced,
583
+ vertexCount: this.vertexCount,
584
+ instanceCount: this.isInstanced ? this.instanceCount : void 0,
585
+ indexCount: o,
586
+ firstVertex: this.firstVertex,
587
+ firstIndex: this.firstIndex,
588
+ transformFeedback: this.transformFeedback || void 0,
589
+ uniforms: this.props.uniforms,
590
+ parameters: this.parameters,
591
+ topology: this.topology
592
+ });
593
+ }
594
+ }
595
+ } finally {
596
+ e.popDebugGroup(), this._logDrawCallEnd();
597
+ }
598
+ return this._logFramebuffer(e), r ? (this._lastDrawTimestamp = this.device.timestamp, this._needsRedraw = !1) : i ? (this._needsRedraw = X, this._drawBlockedReason = X) : this._needsRedraw = this._drawBlockedReason ? this._drawBlockedReason : "waiting for resource initialization", r;
599
+ }
600
+ setGeometry(e) {
601
+ this._gpuGeometry?.destroy();
602
+ let t = e && P(this.device, e);
603
+ if (t) {
604
+ this.setTopology(t.topology || "triangle-list");
605
+ let e = new K(this.bufferLayout);
606
+ this.bufferLayout = e.mergeBufferLayouts(t.bufferLayout, this.bufferLayout), this.vertexArray && this._setGeometryAttributes(t);
607
+ }
608
+ this._gpuGeometry = t;
609
+ }
610
+ setTopology(e) {
611
+ e !== this.topology && (this.topology = e, this._setPipelineNeedsUpdate("topology"));
612
+ }
613
+ setBufferLayout(e) {
614
+ let t = new K(this.bufferLayout), n = this._gpuGeometry ? t.mergeBufferLayouts(e, this._gpuGeometry.bufferLayout) : e;
615
+ G(n, this.bufferLayout, -1) || (this.bufferLayout = n, this._setPipelineNeedsUpdate("bufferLayout"), this.pipeline = this._updatePipeline(), this.vertexArray = this.device.createVertexArray({
616
+ shaderLayout: this.pipeline.shaderLayout,
617
+ bufferLayout: this.pipeline.bufferLayout
618
+ }), this._gpuGeometry && this._setGeometryAttributes(this._gpuGeometry));
619
+ }
620
+ setParameters(e) {
621
+ G(e, this.parameters, 2) || (this.parameters = e, this._setPipelineNeedsUpdate("parameters"));
622
+ }
623
+ setInstanceCount(e) {
624
+ this.instanceCount = e, this.isInstanced === void 0 && e > 0 && (this.isInstanced = !0), this.setNeedsRedraw("instanceCount");
625
+ }
626
+ setVertexCount(e) {
627
+ this.vertexCount = e, this.setNeedsRedraw("vertexCount");
628
+ }
629
+ setIndexCount(e) {
630
+ this.indexCount = e, this.setNeedsRedraw("indexCount");
631
+ }
632
+ setDrawOffsets({ firstVertex: e, firstIndex: t }) {
633
+ this.firstVertex = e, this.firstIndex = t, this.setNeedsRedraw("drawOffsets");
634
+ }
635
+ setShaderInputs(e) {
636
+ this.shaderInputs = e, this._uniformStore = new x(this.device, this.shaderInputs.modules);
637
+ for (let [e, t] of Object.entries(this.shaderInputs.modules)) if (m(t) && !this.material?.ownsModule(e)) {
638
+ let t = this._uniformStore.getManagedUniformBuffer(e);
639
+ this.bindings[`${e}Uniforms`] = t;
640
+ }
641
+ this.setNeedsRedraw("shaderInputs");
642
+ }
643
+ setMaterial(e) {
644
+ this.material = e, this.setNeedsRedraw("material");
645
+ }
646
+ updateShaderInputs(e) {
647
+ this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(), e), this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())), this.setNeedsRedraw("shaderInputs");
648
+ }
649
+ setBindings(e) {
650
+ Object.assign(this.bindings, e), this.setNeedsRedraw("bindings");
651
+ }
652
+ setTransformFeedback(e) {
653
+ this.transformFeedback = e, this.setNeedsRedraw("transformFeedback");
654
+ }
655
+ setIndexBuffer(e) {
656
+ let t = e instanceof y ? e.buffer : e;
657
+ this.indexBuffer = t, this._dynamicIndexBufferSource = e instanceof y ? {
658
+ source: e,
659
+ generation: e.generation
660
+ } : null, this.vertexArray.setIndexBuffer(t), this.setNeedsRedraw("indexBuffer");
661
+ }
662
+ setAttributes(e, n) {
663
+ this._drawBlockedReason = !1;
664
+ let r = n?.disableWarnings ?? this.props.disableWarnings;
665
+ e.indices && t.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(), this.bufferLayout = pe(this.pipeline.shaderLayout, this.bufferLayout);
666
+ let i = new K(this.bufferLayout);
667
+ for (let [n, a] of Object.entries(e)) {
668
+ let e = a instanceof y ? a.buffer : a, o = i.getBufferLayout(n);
669
+ if (!o) {
670
+ r || t.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();
671
+ continue;
672
+ }
673
+ let s = i.getAttributeNamesForBuffer(o), c = !1;
674
+ for (let n of s) {
675
+ let i = this._attributeInfos[n];
676
+ if (i) {
677
+ let n = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(i.bufferName) : i.location;
678
+ if (n === null) {
679
+ r || t.warn(`Model(${this.id}): Missing vertex array slot for buffer "${i.bufferName}".`)();
680
+ continue;
681
+ }
682
+ this.vertexArray.setBuffer(n, e), a instanceof y ? this._dynamicAttributeBufferSources[n] = {
683
+ source: a,
684
+ generation: a.generation
685
+ } : delete this._dynamicAttributeBufferSources[n], c = !0;
686
+ }
687
+ }
688
+ !c && !r && t.warn(`Model(${this.id}): Ignoring buffer "${e.id}" for unknown attribute "${n}"`)();
689
+ }
690
+ this.setNeedsRedraw("attributes");
691
+ }
692
+ setConstantAttributes(e, n) {
693
+ for (let [r, i] of Object.entries(e)) {
694
+ let e = this._attributeInfos[r];
695
+ e ? this.vertexArray.setConstantWebGL(e.location, i) : (n?.disableWarnings ?? this.props.disableWarnings) || t.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)();
696
+ }
697
+ this.setNeedsRedraw("constants");
698
+ }
699
+ _areBindingsLoading() {
700
+ for (let e of Object.values(this.bindings)) if (q(e) && !e.isReady) return e.id;
701
+ for (let e of Object.values(this.material?.bindings || {})) if (q(e) && !e.isReady) return e.id;
702
+ return !1;
703
+ }
704
+ _getBindings(e = this._getCurrentShaderLayout()) {
705
+ let t = {};
706
+ for (let [n, r] of Object.entries(this.bindings)) {
707
+ let i = ve(n, r, e);
708
+ i && (t[n] = i);
709
+ }
710
+ return t;
711
+ }
712
+ _getBindGroups(e = this._getCurrentShaderLayout(), t = this._getBindings(e)) {
713
+ let n = e.bindings.length ? w(e, t) : { 0: t };
714
+ if (!this.material) return n;
715
+ for (let [t, r] of Object.entries(this.material.getBindingsByGroup(e))) {
716
+ let e = Number(t);
717
+ n[e] = {
718
+ ...n[e] || {},
719
+ ...r
720
+ };
721
+ }
722
+ return n;
723
+ }
724
+ _getBindGroupCacheKeys() {
725
+ let e = this.material?.getBindGroupCacheKey(3);
726
+ return e ? { 3: e } : {};
727
+ }
728
+ _getBindingsUpdateTimestamp() {
729
+ let t = 0;
730
+ this._dynamicIndexBufferSource && (t = Math.max(t, this._dynamicIndexBufferSource.source.updateTimestamp));
731
+ for (let e of Object.values(this._dynamicAttributeBufferSources)) t = Math.max(t, e.source.updateTimestamp);
732
+ for (let n of Object.values(this.bindings)) n instanceof te ? t = Math.max(t, n.texture.updateTimestamp) : n instanceof e || n instanceof re || n instanceof T || n instanceof y ? t = Math.max(t, n.updateTimestamp) : q(n) ? t = n.isReady ? Math.max(t, n.updateTimestamp) : Infinity : g(n) && (t = Math.max(t, (n.buffer instanceof y, n.buffer.updateTimestamp)));
733
+ return Math.max(t, this.material?.getBindingsUpdateTimestamp() || 0);
734
+ }
735
+ _setGeometryAttributes(e) {
736
+ let t = { ...e.attributes };
737
+ for (let [e] of Object.entries(t)) !this.pipeline.shaderLayout.attributes.find((t) => t.name === e) && e !== "positions" && delete t[e];
738
+ this.vertexCount = e.vertexCount, this.setIndexBuffer(e.indices || null), this.setAttributes(e.attributes, { disableWarnings: !0 }), this.setAttributes(t, { disableWarnings: this.props.disableWarnings }), this.setNeedsRedraw("geometry attributes");
739
+ }
740
+ _setPipelineNeedsUpdate(e) {
741
+ this._pipelineNeedsUpdate ||= e, this._drawBlockedReason = !1, this.setNeedsRedraw(e);
742
+ }
743
+ _updatePipeline() {
744
+ if (this._pipelineNeedsUpdate) {
745
+ let e = null, n = null;
746
+ this.pipeline && (t.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(), e = this.pipeline.vs, n = this.pipeline.fs), this._pipelineNeedsUpdate = !1;
747
+ let r = this.shaderFactory.createShader({
748
+ id: `${this.id}-vertex`,
749
+ stage: "vertex",
750
+ source: this.source || this.vs,
751
+ debugShaders: this.props.debugShaders
752
+ }), i = null;
753
+ this.source ? i = r : this.fs && (i = this.shaderFactory.createShader({
754
+ id: `${this.id}-fragment`,
755
+ stage: "fragment",
756
+ source: this.source || this.fs,
757
+ debugShaders: this.props.debugShaders
758
+ })), this.pipeline = this.pipelineFactory.createRenderPipeline({
759
+ ...this.props,
760
+ bindings: void 0,
761
+ bufferLayout: this.bufferLayout,
762
+ colorAttachmentFormats: this._colorAttachmentFormats,
763
+ depthStencilAttachmentFormat: this._depthStencilAttachmentFormat,
764
+ topology: this.topology,
765
+ parameters: this.parameters,
766
+ bindGroups: void 0,
767
+ vs: r,
768
+ fs: i
769
+ }), this._attributeInfos = ae(this.pipeline.shaderLayout, this.bufferLayout), e && this.shaderFactory.release(e), n && n !== e && this.shaderFactory.release(n);
770
+ }
771
+ return this.pipeline;
772
+ }
773
+ _lastLogTime = 0;
774
+ _logOpen = !1;
775
+ _logDrawCallStart() {
776
+ let e = t.level > 3 ? 0 : he;
777
+ t.level < 2 || Date.now() - this._lastLogTime < e || (this._lastLogTime = Date.now(), this._logOpen = !0, t.group(Y, `>>> DRAWING MODEL ${this.id}`, { collapsed: t.level <= 2 })());
778
+ }
779
+ _logDrawCallEnd() {
780
+ if (this._logOpen) {
781
+ let e = L(this.pipeline.shaderLayout, this.id);
782
+ t.table(Y, e)();
783
+ let n = this.shaderInputs.getDebugTable();
784
+ t.table(Y, n)();
785
+ let r = this._getAttributeDebugTable();
786
+ t.table(Y, this._attributeInfos)(), t.table(Y, r)(), t.groupEnd(Y)(), this._logOpen = !1;
787
+ }
788
+ }
789
+ _drawCount = 0;
790
+ _logFramebuffer(e) {
791
+ let t = this.device.props.debugFramebuffers;
792
+ if (this._drawCount++, !t) return;
793
+ let n = e.props.framebuffer;
794
+ B(e, n, {
795
+ id: n?.id || `${this.id}-framebuffer`,
796
+ minimap: !0
797
+ });
798
+ }
799
+ _getAttributeDebugTable() {
800
+ let e = {};
801
+ for (let [t, n] of Object.entries(this._attributeInfos)) {
802
+ let r = this.vertexArray.attributes[n.location];
803
+ e[n.location] = {
804
+ name: t,
805
+ type: n.shaderType,
806
+ values: r ? this._getBufferOrConstantValues(r, n.bufferDataType) : "null"
807
+ };
808
+ }
809
+ if (this.vertexArray.indexBuffer) {
810
+ let { indexBuffer: t } = this.vertexArray, n = t.indexType === "uint32" ? new Uint32Array(t.debugData) : new Uint16Array(t.debugData);
811
+ e.indices = {
812
+ name: "indices",
813
+ type: t.indexType,
814
+ values: n.toString()
815
+ };
816
+ }
817
+ return e;
818
+ }
819
+ _getBufferOrConstantValues(t, n) {
820
+ let r = i.getTypedArrayConstructor(n);
821
+ return (t instanceof e ? new r(t.debugData) : t).toString();
822
+ }
823
+ _getNonMaterialBindings(e) {
824
+ if (!this.material) return e;
825
+ let t = {};
826
+ for (let [n, r] of Object.entries(e)) this.material.ownsBinding(n) || (t[n] = r);
827
+ return t;
828
+ }
829
+ _getCurrentShaderLayout() {
830
+ return this.pipeline?.shaderLayout || this.props.shaderLayout || { bindings: [] };
831
+ }
832
+ _syncDynamicBuffers() {
833
+ if (this._dynamicIndexBufferSource && this._dynamicIndexBufferSource.generation !== this._dynamicIndexBufferSource.source.generation) {
834
+ let e = this._dynamicIndexBufferSource.source.buffer;
835
+ this.indexBuffer = e, this.vertexArray.setIndexBuffer(e), this._dynamicIndexBufferSource.generation = this._dynamicIndexBufferSource.source.generation, this.setNeedsRedraw("dynamic index buffer");
836
+ }
837
+ for (let [e, t] of Object.entries(this._dynamicAttributeBufferSources)) t.generation !== t.source.generation && (this.vertexArray.setBuffer(Number(e), t.source.buffer), t.generation = t.source.generation, this.setNeedsRedraw("dynamic attribute buffer"));
838
+ }
839
+ _syncAttachmentFormats(e) {
840
+ if (this.device.type !== "webgpu") return;
841
+ let t = e.framebuffer || e.props.framebuffer, n = e.props, r = n.colorAttachmentFormats ?? t?.colorAttachments?.map((e) => ye(e?.texture?.format)), i = n.depthStencilAttachmentFormat === !1 ? void 0 : n.depthStencilAttachmentFormat ?? be(t?.depthStencilAttachment?.texture?.format);
842
+ (!G(this._colorAttachmentFormats, r, 1) || this._depthStencilAttachmentFormat !== i) && (this._colorAttachmentFormats = r, this._depthStencilAttachmentFormat = i, this._setPipelineNeedsUpdate("attachment formats"));
843
+ }
844
+ };
845
+ function Q(e, t) {
846
+ return e.shaderLanguage !== void 0 && e.shaderLanguage !== t ? !1 : t === "glsl" ? "assembleGLSLShaderPair" in e && typeof e.assembleGLSLShaderPair == "function" : "assembleWGSLShader" in e && typeof e.assembleWGSLShader == "function";
847
+ }
848
+ function _e(e, t) {
849
+ return !e || Object.keys(t).length === 0 ? e : {
850
+ ...e,
851
+ attributes: e.attributes.map((e) => {
852
+ let n = e.name.startsWith("_luma_") ? e.name.slice(6) : null;
853
+ return n && t[n] ? {
854
+ ...e,
855
+ name: n
856
+ } : e;
857
+ })
858
+ };
859
+ }
860
+ function ve(e, t, n) {
861
+ if (q(t)) {
862
+ let r = J(n, e, { fallbackGroup: 0 });
863
+ return r ? t.resolveTextureBinding(r) : null;
864
+ }
865
+ return t instanceof y ? t.buffer : g(t) ? b(t) : t;
866
+ }
867
+ function ye(e) {
868
+ return e && !$(e) ? e : null;
869
+ }
870
+ function be(e) {
871
+ return e && $(e) ? e : void 0;
872
+ }
873
+ function $(e) {
874
+ return ge.includes(e);
875
+ }
876
+ function xe(e) {
877
+ return {
878
+ type: e.type,
879
+ shaderLanguage: e.info.shadingLanguage,
880
+ shaderLanguageVersion: e.info.shadingLanguageVersion,
881
+ gpu: e.info.gpu,
882
+ limits: e.limits,
883
+ features: e.features
884
+ };
885
+ }
886
+ //#endregion
887
+ //#region node_modules/@luma.gl/engine/dist/compute/buffer-transform.js
888
+ var Se = 35980, Ce = 35981, we = class t {
889
+ device;
890
+ model;
891
+ transformFeedback;
892
+ static defaultProps = {
893
+ ...Z.defaultProps,
894
+ feedbackBufferMode: "separate",
895
+ outputs: void 0,
896
+ feedbackBuffers: void 0
897
+ };
898
+ static isSupported(e) {
899
+ return e?.info?.type === "webgl";
900
+ }
901
+ constructor(e, n = t.defaultProps) {
902
+ if (!t.isSupported(e)) throw Error("BufferTransform not yet implemented on WebGPU");
903
+ this.device = e, this.model = new Z(this.device, {
904
+ id: n.id || "buffer-transform-model",
905
+ fs: n.fs || se(),
906
+ topology: n.topology || "point-list",
907
+ varyings: n.outputs || n.varyings,
908
+ ...n,
909
+ bufferMode: n.bufferMode || (n.feedbackBufferMode === "interleaved" ? Se : Ce)
910
+ }), this.transformFeedback = this.device.createTransformFeedback({
911
+ layout: this.model.pipeline.shaderLayout,
912
+ buffers: n.feedbackBuffers
913
+ }), this.model.setTransformFeedback(this.transformFeedback);
914
+ }
915
+ destroy() {
916
+ this.model && this.model.destroy();
917
+ }
918
+ delete() {
919
+ this.destroy();
920
+ }
921
+ run(e) {
922
+ e?.inputBuffers && this.model.setAttributes(e.inputBuffers), e?.outputBuffers && this.transformFeedback.setBuffers(e.outputBuffers);
923
+ let t = this.device.beginRenderPass({
924
+ discard: !0,
925
+ ...e
926
+ });
927
+ this.model.draw(t), t.end();
928
+ }
929
+ getBuffer(e) {
930
+ return this.transformFeedback.getBuffer(e);
931
+ }
932
+ readAsync(t) {
933
+ let n = this.getBuffer(t);
934
+ if (!n) throw Error("BufferTransform#getBuffer");
935
+ if (n instanceof e) return n.readAsync();
936
+ let { buffer: r, byteOffset: i = 0, byteLength: a = r.byteLength } = n;
937
+ return r.readAsync(i, a);
938
+ }
939
+ };
940
+ //#endregion
941
+ export { A as a, q as i, Z as n, O as o, J as r, T as s, we as t };