easycomponentstools 1.2.4 → 1.2.5

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.
@@ -0,0 +1,942 @@
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-BeGpfCVx.js";
2
+ import { c as s, i as c, l, n as u, o as d, r as f, s as p, t as ee } from "./get-attribute-from-layouts-CW53R-qj.js";
3
+ import { E as te, S as ne, T as re, c as m, d as ie, f as ae, g as h, h as oe, l as se, m as g, p as _, s as v, u as ce, w as y, x as b, y as x } from "./expression-DyJkfNa7.js";
4
+ //#region node_modules/@luma.gl/core/dist/adapter/resources/external-texture.js
5
+ var S = 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
+ }, C = "#version 300 es\nout vec4 transform_output;\nvoid main() {\n transform_output = vec4(0);\n}";
26
+ function w(e) {
27
+ let { input: t, inputChannels: n, output: r } = e || {};
28
+ if (!t) return C;
29
+ if (!n) throw Error("inputChannels");
30
+ return `\
31
+ #version 300 es
32
+ in ${T(n)} ${t};
33
+ out vec4 ${r};
34
+ void main() {
35
+ ${r} = ${le(t, n)};
36
+ }`;
37
+ }
38
+ function T(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 le(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 E = 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 || h("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 = D(e), r = Object.keys(this.attributes).find((e) => D(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 || O(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 D(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 O(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: D(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 k(e, t = {}) {
137
+ let n = t.bufferName || "geometry";
138
+ if (A(e, n)) return e;
139
+ let i = t.minAttributeAlignment || 4, a = j(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 = N(s, i), o.push({
148
+ sourceName: e,
149
+ attributeName: D(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 = N(s, i), u = new ArrayBuffer(c * l);
162
+ for (let e of o) M(u, c, l, e);
163
+ return new E({
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 A(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 j(e, t) {
191
+ return t ? t.map((t) => [t, e.attributes[t]]) : Object.entries(e.attributes);
192
+ }
193
+ function M(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 N(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 P = class {
208
+ id;
209
+ userData = {};
210
+ topology;
211
+ bufferLayout = [];
212
+ vertexCount;
213
+ indices;
214
+ attributes;
215
+ constructor(t) {
216
+ if (this.id = t.id || h("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 F(e, t) {
236
+ if (t instanceof P) return t;
237
+ let n = k(t), r = I(e, n), { attributes: i, bufferLayout: a } = L(e, n);
238
+ return new P({
239
+ topology: n.topology || "triangle-list",
240
+ bufferLayout: a,
241
+ vertexCount: n.vertexCount,
242
+ indices: r,
243
+ attributes: i
244
+ });
245
+ }
246
+ function I(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 L(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 || D(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 R(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 z = "__debugFramebufferState", B = 8;
287
+ function V(e, t, n) {
288
+ if (e.device.type !== "webgl") return;
289
+ let r = W(e.device);
290
+ if (!r.flushing) {
291
+ if (de(e)) {
292
+ H(e, n, r);
293
+ return;
294
+ }
295
+ t && ue(t) && t.handle !== null && (r.queuedFramebuffers.includes(t) || r.queuedFramebuffers.push(t));
296
+ }
297
+ }
298
+ function H(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 = G(t.top, B), l = G(t.left, B);
301
+ n.flushing = !0;
302
+ try {
303
+ for (let e of n.queuedFramebuffers) {
304
+ let [n, i, a, u, d] = U({
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 + B;
313
+ }
314
+ } finally {
315
+ r.bindFramebuffer(36008, i), r.bindFramebuffer(36009, a), n.flushing = !1;
316
+ }
317
+ }
318
+ function U(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 W(e) {
329
+ return e.userData[z] ||= {
330
+ flushing: !1,
331
+ queuedFramebuffers: []
332
+ }, e.userData[z];
333
+ }
334
+ function ue(e) {
335
+ return "colorAttachments" in e;
336
+ }
337
+ function de(e) {
338
+ let t = e.props.framebuffer;
339
+ return !t || t.handle === null;
340
+ }
341
+ function G(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 K(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 (!K(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) || !K(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 q = 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 u(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 fe(e, t) {
390
+ let n = c(e), r = t.slice();
391
+ return r.sort((e, t) => f(u(e).map((e) => n[e])) - f(u(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 J(e) {
396
+ return typeof e == "object" && !!e && "resolveTextureBinding" in e && typeof e.resolveTextureBinding == "function";
397
+ }
398
+ function pe(e) {
399
+ return e?.type === "texture" || e?.type === "external-texture";
400
+ }
401
+ function me(e, t, n) {
402
+ let r = d(e, t, { ignoreWarnings: !0 });
403
+ return pe(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: x.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
+ _vertexCountSet = !1;
492
+ _lastDrawTimestamp = -1;
493
+ _bindingTable = [];
494
+ get [Symbol.toStringTag]() {
495
+ return "Model";
496
+ }
497
+ toString() {
498
+ return `Model(${this.id})`;
499
+ }
500
+ constructor(e, t) {
501
+ let n = r.defaultProps.shaderAssembler, i = t.vertexCount !== void 0;
502
+ this.props = {
503
+ ...r.defaultProps,
504
+ ...t,
505
+ shaderAssembler: t.shaderAssembler ?? (Q(n, e.info.shadingLanguage) ? n : x.getDefaultShaderAssembler(e.info.shadingLanguage))
506
+ }, this._vertexCountSet = i, t = this.props, this.id = t.id || h("model"), this.device = e, Object.assign(this.userData, t.userData), this.material = t.material || null;
507
+ let o = xe(e), s = ne(this.props.plugins, o.shaderLanguage), c = b(this.props.modules, s.modules), l = Object.fromEntries(c.map((e) => [e.name, e])), u = t.shaderInputs || new ce(l, { disableWarnings: this.props.disableWarnings });
508
+ t.shaderInputs && s.modules.length > 0 && u.addModules(s.modules), this.setShaderInputs(u);
509
+ let d = g(this.props.modules, u.getModules()), f = {
510
+ ...s.defines,
511
+ ...this.props.defines
512
+ };
513
+ if (this.device.type === "webgl" && (this.props._uniformBlockLayouts = ie(d)), this.props.shaderLayout = _(this.props.shaderLayout, d) || null, this.device.type === "webgpu" && this.props.source) {
514
+ let t = this.props.shaderAssembler;
515
+ a(Q(t, "wgsl"));
516
+ let { source: n, getUniforms: r, bindingTable: i, shaderLayout: c } = t.assembleWGSLShader({
517
+ platformInfo: o,
518
+ ...this.props,
519
+ modules: d,
520
+ defines: f,
521
+ pluginInjections: s.injections,
522
+ pluginVertexInputs: s.vertexInputs,
523
+ pluginVaryings: s.varyings
524
+ });
525
+ this.source = n, this._getModuleUniforms = r, this._bindingTable = i;
526
+ let l = _e(c ?? e.getShaderLayout?.(this.source), s.vertexInputs), u = ae(this.props.shaderLayout, l, Object.keys(s.vertexInputs));
527
+ this.props.shaderLayout = _(u || null, d) || null;
528
+ } else {
529
+ let e = this.props.shaderAssembler;
530
+ a(Q(e, "glsl"));
531
+ let { vs: t, fs: n, getUniforms: r } = e.assembleGLSLShaderPair({
532
+ platformInfo: o,
533
+ ...this.props,
534
+ modules: d,
535
+ defines: f,
536
+ pluginInjections: s.injections,
537
+ pluginVertexInputs: s.vertexInputs,
538
+ pluginVaryings: s.varyings
539
+ });
540
+ this.vs = t, this.fs = n, this._getModuleUniforms = r, this._bindingTable = [];
541
+ }
542
+ 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 || te.getDefaultPipelineFactory(this.device), this.shaderFactory = t.shaderFactory || re.getDefaultShaderFactory(this.device), this.pipeline = this._updatePipeline(), this.vertexArray = e.createVertexArray({
543
+ shaderLayout: this.pipeline.shaderLayout,
544
+ bufferLayout: this.pipeline.bufferLayout
545
+ }), 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);
546
+ }
547
+ destroy() {
548
+ 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);
549
+ }
550
+ needsRedraw() {
551
+ this._getBindingsUpdateTimestamp() > this._lastDrawTimestamp && this.setNeedsRedraw("contents of bound textures or buffers updated");
552
+ let e = this._needsRedraw;
553
+ return this._needsRedraw = !1, e;
554
+ }
555
+ setNeedsRedraw(e) {
556
+ this._needsRedraw ||= e;
557
+ }
558
+ getBindingDebugTable() {
559
+ return this._bindingTable;
560
+ }
561
+ predraw(e) {
562
+ this._syncDynamicBuffers(), this.updateShaderInputs(e), this.material?.updateShaderInputs(e), this.pipeline = this._updatePipeline();
563
+ }
564
+ draw(e) {
565
+ if (this._drawBlockedReason && !this._pipelineNeedsUpdate) return t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)(), !1;
566
+ let n = this._areBindingsLoading();
567
+ if (n) return t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${n} not loaded`)(), !1;
568
+ this._syncAttachmentFormats(e);
569
+ try {
570
+ 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);
571
+ } finally {
572
+ e.popDebugGroup();
573
+ }
574
+ let r, i = this.pipeline.isErrored;
575
+ try {
576
+ 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;
577
+ else {
578
+ let n = this.vertexArray.getDrawValidationError();
579
+ if (n) t.info(Y, `>>> DRAWING ABORTED ${this.id}: ${n}`)(), this._drawBlockedReason = n, r = !1;
580
+ else {
581
+ let t = this._getCurrentShaderLayout(), n = this._getBindings(t), i = this._getBindGroups(t, n), { indexBuffer: a } = this.vertexArray, o = a ? this.indexCount ?? (this._vertexCountSet ? this.vertexCount : a.byteLength / (a.indexType === "uint32" ? 4 : 2)) : void 0;
582
+ e.setPipeline(this.pipeline), e.setBindings(i, { _bindGroupCacheKeys: this._getBindGroupCacheKeys() }), e.setVertexArray(this.vertexArray), r = this.isInstanced === !0 && this.instanceCount === 0 || e.draw({
583
+ isInstanced: this.isInstanced,
584
+ vertexCount: this.vertexCount,
585
+ instanceCount: this.isInstanced ? this.instanceCount : void 0,
586
+ indexCount: o,
587
+ firstVertex: this.firstVertex,
588
+ firstIndex: this.firstIndex,
589
+ transformFeedback: this.transformFeedback || void 0,
590
+ uniforms: this.props.uniforms,
591
+ parameters: this.parameters,
592
+ topology: this.topology
593
+ });
594
+ }
595
+ }
596
+ } finally {
597
+ e.popDebugGroup(), this._logDrawCallEnd();
598
+ }
599
+ 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;
600
+ }
601
+ setGeometry(e) {
602
+ this._gpuGeometry?.destroy();
603
+ let t = e && F(this.device, e);
604
+ if (t) {
605
+ this.setTopology(t.topology || "triangle-list");
606
+ let e = new q(this.bufferLayout);
607
+ this.bufferLayout = e.mergeBufferLayouts(t.bufferLayout, this.bufferLayout), this.vertexArray && this._setGeometryAttributes(t);
608
+ }
609
+ this._gpuGeometry = t;
610
+ }
611
+ setTopology(e) {
612
+ e !== this.topology && (this.topology = e, this._setPipelineNeedsUpdate("topology"));
613
+ }
614
+ setBufferLayout(e) {
615
+ let t = new q(this.bufferLayout), n = this._gpuGeometry ? t.mergeBufferLayouts(e, this._gpuGeometry.bufferLayout) : e;
616
+ K(n, this.bufferLayout, -1) || (this.bufferLayout = n, this._setPipelineNeedsUpdate("bufferLayout"), this.pipeline = this._updatePipeline(), this.vertexArray = this.device.createVertexArray({
617
+ shaderLayout: this.pipeline.shaderLayout,
618
+ bufferLayout: this.pipeline.bufferLayout
619
+ }), this._gpuGeometry && this._setGeometryAttributes(this._gpuGeometry));
620
+ }
621
+ setParameters(e) {
622
+ K(e, this.parameters, 2) || (this.parameters = e, this._setPipelineNeedsUpdate("parameters"));
623
+ }
624
+ setInstanceCount(e) {
625
+ this.instanceCount = e, this.isInstanced === void 0 && e > 0 && (this.isInstanced = !0), this.setNeedsRedraw("instanceCount");
626
+ }
627
+ setVertexCount(e) {
628
+ this.vertexCount = e, this._vertexCountSet = !0, this.setNeedsRedraw("vertexCount");
629
+ }
630
+ setIndexCount(e) {
631
+ this.indexCount = e, this.setNeedsRedraw("indexCount");
632
+ }
633
+ setDrawOffsets({ firstVertex: e, firstIndex: t }) {
634
+ this.firstVertex = e, this.firstIndex = t, this.setNeedsRedraw("drawOffsets");
635
+ }
636
+ setShaderInputs(e) {
637
+ this.shaderInputs = e, this._uniformStore = new y(this.device, this.shaderInputs.modules);
638
+ for (let [e, t] of Object.entries(this.shaderInputs.modules)) if (oe(t) && !this.material?.ownsModule(e)) {
639
+ let t = this._uniformStore.getManagedUniformBuffer(e);
640
+ this.bindings[`${e}Uniforms`] = t;
641
+ }
642
+ this.setNeedsRedraw("shaderInputs");
643
+ }
644
+ setMaterial(e) {
645
+ this.material = e, this.setNeedsRedraw("material");
646
+ }
647
+ updateShaderInputs(e) {
648
+ this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(), e), this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())), this.setNeedsRedraw("shaderInputs");
649
+ }
650
+ setBindings(e) {
651
+ Object.assign(this.bindings, e), this.setNeedsRedraw("bindings");
652
+ }
653
+ setTransformFeedback(e) {
654
+ this.transformFeedback = e, this.setNeedsRedraw("transformFeedback");
655
+ }
656
+ setIndexBuffer(e) {
657
+ let t = e instanceof v ? e.buffer : e;
658
+ this.indexBuffer = t, this._dynamicIndexBufferSource = e instanceof v ? {
659
+ source: e,
660
+ generation: e.generation
661
+ } : null, this.vertexArray.setIndexBuffer(t), this.setNeedsRedraw("indexBuffer");
662
+ }
663
+ setAttributes(e, n) {
664
+ this._drawBlockedReason = !1;
665
+ let r = n?.disableWarnings ?? this.props.disableWarnings;
666
+ e.indices && t.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(), this.bufferLayout = fe(this.pipeline.shaderLayout, this.bufferLayout);
667
+ let i = new q(this.bufferLayout);
668
+ for (let [n, a] of Object.entries(e)) {
669
+ let e = a instanceof v ? a.buffer : a, o = i.getBufferLayout(n);
670
+ if (!o) {
671
+ r || t.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();
672
+ continue;
673
+ }
674
+ let s = i.getAttributeNamesForBuffer(o), c = !1;
675
+ for (let n of s) {
676
+ let i = this._attributeInfos[n];
677
+ if (i) {
678
+ let n = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(i.bufferName) : i.location;
679
+ if (n === null) {
680
+ r || t.warn(`Model(${this.id}): Missing vertex array slot for buffer "${i.bufferName}".`)();
681
+ continue;
682
+ }
683
+ this.vertexArray.setBuffer(n, e), a instanceof v ? this._dynamicAttributeBufferSources[n] = {
684
+ source: a,
685
+ generation: a.generation
686
+ } : delete this._dynamicAttributeBufferSources[n], c = !0;
687
+ }
688
+ }
689
+ !c && !r && t.warn(`Model(${this.id}): Ignoring buffer "${e.id}" for unknown attribute "${n}"`)();
690
+ }
691
+ this.setNeedsRedraw("attributes");
692
+ }
693
+ setConstantAttributes(e, n) {
694
+ for (let [r, i] of Object.entries(e)) {
695
+ let e = this._attributeInfos[r];
696
+ e ? this.vertexArray.setConstantWebGL(e.location, i) : (n?.disableWarnings ?? this.props.disableWarnings) || t.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)();
697
+ }
698
+ this.setNeedsRedraw("constants");
699
+ }
700
+ _areBindingsLoading() {
701
+ for (let e of Object.values(this.bindings)) if (J(e) && !e.isReady) return e.id;
702
+ for (let e of Object.values(this.material?.bindings || {})) if (J(e) && !e.isReady) return e.id;
703
+ return !1;
704
+ }
705
+ _getBindings(e = this._getCurrentShaderLayout()) {
706
+ let t = {};
707
+ for (let [n, r] of Object.entries(this.bindings)) {
708
+ let i = ve(n, r, e);
709
+ i && (t[n] = i);
710
+ }
711
+ return t;
712
+ }
713
+ _getBindGroups(e = this._getCurrentShaderLayout(), t = this._getBindings(e)) {
714
+ let n = e.bindings.length ? p(e, t) : { 0: t };
715
+ if (!this.material) return n;
716
+ for (let [t, r] of Object.entries(this.material.getBindingsByGroup(e))) {
717
+ let e = Number(t);
718
+ n[e] = {
719
+ ...n[e] || {},
720
+ ...r
721
+ };
722
+ }
723
+ return n;
724
+ }
725
+ _getBindGroupCacheKeys() {
726
+ let e = this.material?.getBindGroupCacheKey(3);
727
+ return e ? { 3: e } : {};
728
+ }
729
+ _getBindingsUpdateTimestamp() {
730
+ let t = 0;
731
+ this._dynamicIndexBufferSource && (t = Math.max(t, this._dynamicIndexBufferSource.source.updateTimestamp));
732
+ for (let e of Object.values(this._dynamicAttributeBufferSources)) t = Math.max(t, e.source.updateTimestamp);
733
+ for (let n of Object.values(this.bindings)) n instanceof s ? t = Math.max(t, n.texture.updateTimestamp) : n instanceof e || n instanceof l || n instanceof S || n instanceof v ? t = Math.max(t, n.updateTimestamp) : J(n) ? t = n.isReady ? Math.max(t, n.updateTimestamp) : Infinity : m(n) && (t = Math.max(t, (n.buffer instanceof v, n.buffer.updateTimestamp)));
734
+ return Math.max(t, this.material?.getBindingsUpdateTimestamp() || 0);
735
+ }
736
+ _setGeometryAttributes(e) {
737
+ let t = { ...e.attributes };
738
+ for (let [e] of Object.entries(t)) !this.pipeline.shaderLayout.attributes.find((t) => t.name === e) && e !== "positions" && delete t[e];
739
+ this.vertexCount = e.vertexCount, this._vertexCountSet = !0, this.setIndexBuffer(e.indices || null), this.setAttributes(e.attributes, { disableWarnings: !0 }), this.setAttributes(t, { disableWarnings: this.props.disableWarnings }), this.setNeedsRedraw("geometry attributes");
740
+ }
741
+ _setPipelineNeedsUpdate(e) {
742
+ this._pipelineNeedsUpdate ||= e, this._drawBlockedReason = !1, this.setNeedsRedraw(e);
743
+ }
744
+ _updatePipeline() {
745
+ if (this._pipelineNeedsUpdate) {
746
+ let e = null, n = null;
747
+ this.pipeline && (t.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(), e = this.pipeline.vs, n = this.pipeline.fs), this._pipelineNeedsUpdate = !1;
748
+ let r = this.shaderFactory.createShader({
749
+ id: `${this.id}-vertex`,
750
+ stage: "vertex",
751
+ source: this.source || this.vs,
752
+ debugShaders: this.props.debugShaders
753
+ }), i = null;
754
+ this.source ? i = r : this.fs && (i = this.shaderFactory.createShader({
755
+ id: `${this.id}-fragment`,
756
+ stage: "fragment",
757
+ source: this.source || this.fs,
758
+ debugShaders: this.props.debugShaders
759
+ })), this.pipeline = this.pipelineFactory.createRenderPipeline({
760
+ ...this.props,
761
+ bindings: void 0,
762
+ bufferLayout: this.bufferLayout,
763
+ colorAttachmentFormats: this._colorAttachmentFormats,
764
+ depthStencilAttachmentFormat: this._depthStencilAttachmentFormat,
765
+ topology: this.topology,
766
+ parameters: this.parameters,
767
+ bindGroups: void 0,
768
+ vs: r,
769
+ fs: i
770
+ }), this._attributeInfos = ee(this.pipeline.shaderLayout, this.bufferLayout), e && this.shaderFactory.release(e), n && n !== e && this.shaderFactory.release(n);
771
+ }
772
+ return this.pipeline;
773
+ }
774
+ _lastLogTime = 0;
775
+ _logOpen = !1;
776
+ _logDrawCallStart() {
777
+ let e = t.level > 3 ? 0 : he;
778
+ 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 })());
779
+ }
780
+ _logDrawCallEnd() {
781
+ if (this._logOpen) {
782
+ let e = R(this.pipeline.shaderLayout, this.id);
783
+ t.table(Y, e)();
784
+ let n = this.shaderInputs.getDebugTable();
785
+ t.table(Y, n)();
786
+ let r = this._getAttributeDebugTable();
787
+ t.table(Y, this._attributeInfos)(), t.table(Y, r)(), t.groupEnd(Y)(), this._logOpen = !1;
788
+ }
789
+ }
790
+ _drawCount = 0;
791
+ _logFramebuffer(e) {
792
+ let t = this.device.props.debugFramebuffers;
793
+ if (this._drawCount++, !t) return;
794
+ let n = e.props.framebuffer;
795
+ V(e, n, {
796
+ id: n?.id || `${this.id}-framebuffer`,
797
+ minimap: !0
798
+ });
799
+ }
800
+ _getAttributeDebugTable() {
801
+ let e = {};
802
+ for (let [t, n] of Object.entries(this._attributeInfos)) {
803
+ let r = this.vertexArray.attributes[n.location];
804
+ e[n.location] = {
805
+ name: t,
806
+ type: n.shaderType,
807
+ values: r ? this._getBufferOrConstantValues(r, n.bufferDataType) : "null"
808
+ };
809
+ }
810
+ if (this.vertexArray.indexBuffer) {
811
+ let { indexBuffer: t } = this.vertexArray, n = t.indexType === "uint32" ? new Uint32Array(t.debugData) : new Uint16Array(t.debugData);
812
+ e.indices = {
813
+ name: "indices",
814
+ type: t.indexType,
815
+ values: n.toString()
816
+ };
817
+ }
818
+ return e;
819
+ }
820
+ _getBufferOrConstantValues(t, n) {
821
+ let r = i.getTypedArrayConstructor(n);
822
+ return (t instanceof e ? new r(t.debugData) : t).toString();
823
+ }
824
+ _getNonMaterialBindings(e) {
825
+ if (!this.material) return e;
826
+ let t = {};
827
+ for (let [n, r] of Object.entries(e)) this.material.ownsBinding(n) || (t[n] = r);
828
+ return t;
829
+ }
830
+ _getCurrentShaderLayout() {
831
+ return this.pipeline?.shaderLayout || this.props.shaderLayout || { bindings: [] };
832
+ }
833
+ _syncDynamicBuffers() {
834
+ if (this._dynamicIndexBufferSource && this._dynamicIndexBufferSource.generation !== this._dynamicIndexBufferSource.source.generation) {
835
+ let e = this._dynamicIndexBufferSource.source.buffer;
836
+ this.indexBuffer = e, this.vertexArray.setIndexBuffer(e), this._dynamicIndexBufferSource.generation = this._dynamicIndexBufferSource.source.generation, this.setNeedsRedraw("dynamic index buffer");
837
+ }
838
+ 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"));
839
+ }
840
+ _syncAttachmentFormats(e) {
841
+ if (this.device.type !== "webgpu") return;
842
+ 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);
843
+ (!K(this._colorAttachmentFormats, r, 1) || this._depthStencilAttachmentFormat !== i) && (this._colorAttachmentFormats = r, this._depthStencilAttachmentFormat = i, this._setPipelineNeedsUpdate("attachment formats"));
844
+ }
845
+ };
846
+ function Q(e, t) {
847
+ 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";
848
+ }
849
+ function _e(e, t) {
850
+ return !e || Object.keys(t).length === 0 ? e : {
851
+ ...e,
852
+ attributes: e.attributes.map((e) => {
853
+ let n = e.name.startsWith("_luma_") ? e.name.slice(6) : null;
854
+ return n && t[n] ? {
855
+ ...e,
856
+ name: n
857
+ } : e;
858
+ })
859
+ };
860
+ }
861
+ function ve(e, t, n) {
862
+ if (J(t)) {
863
+ let r = me(n, e, { fallbackGroup: 0 });
864
+ return r ? t.resolveTextureBinding(r) : null;
865
+ }
866
+ return t instanceof v ? t.buffer : m(t) ? se(t) : t;
867
+ }
868
+ function ye(e) {
869
+ return e && !$(e) ? e : null;
870
+ }
871
+ function be(e) {
872
+ return e && $(e) ? e : void 0;
873
+ }
874
+ function $(e) {
875
+ return ge.includes(e);
876
+ }
877
+ function xe(e) {
878
+ return {
879
+ type: e.type,
880
+ shaderLanguage: e.info.shadingLanguage,
881
+ shaderLanguageVersion: e.info.shadingLanguageVersion,
882
+ gpu: e.info.gpu,
883
+ limits: e.limits,
884
+ features: e.features
885
+ };
886
+ }
887
+ //#endregion
888
+ //#region node_modules/@luma.gl/engine/dist/compute/buffer-transform.js
889
+ var Se = 35980, Ce = 35981, we = class t {
890
+ device;
891
+ model;
892
+ transformFeedback;
893
+ static defaultProps = {
894
+ ...Z.defaultProps,
895
+ feedbackBufferMode: "separate",
896
+ outputs: void 0,
897
+ feedbackBuffers: void 0
898
+ };
899
+ static isSupported(e) {
900
+ return e?.info?.type === "webgl";
901
+ }
902
+ constructor(e, n = t.defaultProps) {
903
+ if (!t.isSupported(e)) throw Error("BufferTransform not yet implemented on WebGPU");
904
+ this.device = e, this.model = new Z(this.device, {
905
+ id: n.id || "buffer-transform-model",
906
+ fs: n.fs || w(),
907
+ topology: n.topology || "point-list",
908
+ varyings: n.outputs || n.varyings,
909
+ ...n,
910
+ bufferMode: n.bufferMode || (n.feedbackBufferMode === "interleaved" ? Se : Ce)
911
+ }), this.transformFeedback = this.device.createTransformFeedback({
912
+ layout: this.model.pipeline.shaderLayout,
913
+ buffers: n.feedbackBuffers
914
+ }), this.model.setTransformFeedback(this.transformFeedback);
915
+ }
916
+ destroy() {
917
+ this.model && this.model.destroy();
918
+ }
919
+ delete() {
920
+ this.destroy();
921
+ }
922
+ run(e) {
923
+ e?.inputBuffers && this.model.setAttributes(e.inputBuffers), e?.outputBuffers && this.transformFeedback.setBuffers(e.outputBuffers);
924
+ let t = this.device.beginRenderPass({
925
+ discard: !0,
926
+ ...e
927
+ });
928
+ this.model.draw(t), t.end();
929
+ }
930
+ getBuffer(e) {
931
+ return this.transformFeedback.getBuffer(e);
932
+ }
933
+ readAsync(t) {
934
+ let n = this.getBuffer(t);
935
+ if (!n) throw Error("BufferTransform#getBuffer");
936
+ if (n instanceof e) return n.readAsync();
937
+ let { buffer: r, byteOffset: i = 0, byteLength: a = r.byteLength } = n;
938
+ return r.readAsync(i, a);
939
+ }
940
+ };
941
+ //#endregion
942
+ export { w as a, E as i, Z as n, k as r, we as t };