@luma.gl/engine 10.0.0-alpha.1 → 10.0.0-alpha.3

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.
package/dist/dist.dev.js CHANGED
@@ -119,8 +119,11 @@ var __exports__ = (() => {
119
119
  loadImage: () => loadImage,
120
120
  loadImageBitmap: () => loadImageBitmap,
121
121
  makeAnimationLoop: () => makeAnimationLoop,
122
+ makeEdgeGeometry: () => makeEdgeGeometry,
123
+ makeEdgeGeometryFromGeometries: () => makeEdgeGeometryFromGeometries,
122
124
  makeInterleavedGeometry: () => makeInterleavedGeometry,
123
125
  makeRandomGenerator: () => makeRandomGenerator,
126
+ makeStrokeGeometry: () => makeStrokeGeometry,
124
127
  picking: () => picking4,
125
128
  requestAnimationFramePolyfill: () => requestAnimationFramePolyfill,
126
129
  resolvePickingBackend: () => resolvePickingBackend,
@@ -1117,10 +1120,6 @@ var __exports__ = (() => {
1117
1120
  toTarget(target) {
1118
1121
  return target ? this.to(target) : this;
1119
1122
  }
1120
- /** @deprecated */
1121
- toFloat32Array() {
1122
- return new Float32Array(this);
1123
- }
1124
1123
  toString() {
1125
1124
  return this.formatString(config);
1126
1125
  }
@@ -1247,51 +1246,6 @@ var __exports__ = (() => {
1247
1246
  }
1248
1247
  return valid;
1249
1248
  }
1250
- // three.js compatibility
1251
- /** @deprecated */
1252
- sub(a) {
1253
- return this.subtract(a);
1254
- }
1255
- /** @deprecated */
1256
- setScalar(a) {
1257
- for (let i = 0; i < this.ELEMENTS; ++i) {
1258
- this[i] = a;
1259
- }
1260
- return this.check();
1261
- }
1262
- /** @deprecated */
1263
- addScalar(a) {
1264
- for (let i = 0; i < this.ELEMENTS; ++i) {
1265
- this[i] += a;
1266
- }
1267
- return this.check();
1268
- }
1269
- /** @deprecated */
1270
- subScalar(a) {
1271
- return this.addScalar(-a);
1272
- }
1273
- /** @deprecated */
1274
- multiplyScalar(scalar) {
1275
- for (let i = 0; i < this.ELEMENTS; ++i) {
1276
- this[i] *= scalar;
1277
- }
1278
- return this.check();
1279
- }
1280
- /** @deprecated */
1281
- divideScalar(a) {
1282
- return this.multiplyByScalar(1 / a);
1283
- }
1284
- /** @deprecated */
1285
- clampScalar(min, max) {
1286
- for (let i = 0; i < this.ELEMENTS; ++i) {
1287
- this[i] = Math.min(Math.max(this[i], min), max);
1288
- }
1289
- return this.check();
1290
- }
1291
- /** @deprecated */
1292
- get elements() {
1293
- return this;
1294
- }
1295
1249
  };
1296
1250
 
1297
1251
  // ../../node_modules/@math.gl/core/dist/lib/validators.js
@@ -1319,6 +1273,64 @@ var __exports__ = (() => {
1319
1273
  return v;
1320
1274
  }
1321
1275
 
1276
+ // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
1277
+ var Matrix = class extends MathArray {
1278
+ // fromObject(object) {
1279
+ // const array = object.elements;
1280
+ // return this.fromRowMajor(array);
1281
+ // }
1282
+ // toObject(object) {
1283
+ // const array = object.elements;
1284
+ // this.toRowMajor(array);
1285
+ // return object;
1286
+ // }
1287
+ // TODO better override formatString?
1288
+ toString() {
1289
+ let string = "[";
1290
+ if (config.printRowMajor) {
1291
+ string += "row-major:";
1292
+ for (let row = 0; row < this.RANK; ++row) {
1293
+ for (let col = 0; col < this.RANK; ++col) {
1294
+ string += ` ${this[col * this.RANK + row]}`;
1295
+ }
1296
+ }
1297
+ } else {
1298
+ string += "column-major:";
1299
+ for (let i = 0; i < this.ELEMENTS; ++i) {
1300
+ string += ` ${this[i]}`;
1301
+ }
1302
+ }
1303
+ string += "]";
1304
+ return string;
1305
+ }
1306
+ getElementIndex(row, col) {
1307
+ return col * this.RANK + row;
1308
+ }
1309
+ // By default assumes row major indices
1310
+ getElement(row, col) {
1311
+ return this[col * this.RANK + row];
1312
+ }
1313
+ // By default assumes row major indices
1314
+ setElement(row, col, value) {
1315
+ this[col * this.RANK + row] = checkNumber(value);
1316
+ return this;
1317
+ }
1318
+ getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
1319
+ const firstIndex = columnIndex * this.RANK;
1320
+ for (let i = 0; i < this.RANK; ++i) {
1321
+ result[i] = this[firstIndex + i];
1322
+ }
1323
+ return result;
1324
+ }
1325
+ setColumn(columnIndex, columnVector) {
1326
+ const firstIndex = columnIndex * this.RANK;
1327
+ for (let i = 0; i < this.RANK; ++i) {
1328
+ this[firstIndex + i] = columnVector[i];
1329
+ }
1330
+ return this;
1331
+ }
1332
+ };
1333
+
1322
1334
  // ../../node_modules/@math.gl/core/dist/lib/assert.js
1323
1335
  function assert(condition, message) {
1324
1336
  if (!condition) {
@@ -1445,24 +1457,18 @@ var __exports__ = (() => {
1445
1457
  return this.copy(a).multiply(b);
1446
1458
  }
1447
1459
  addScaledVector(a, b) {
1448
- return this.add(new this.constructor(a).multiplyScalar(b));
1460
+ for (let i = 0; i < this.ELEMENTS; ++i) {
1461
+ this[i] += a[i] * b;
1462
+ }
1463
+ return this.check();
1449
1464
  }
1450
1465
  };
1451
1466
 
1452
1467
  // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
1453
1468
  var EPSILON = 1e-6;
1454
- var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
1455
1469
  var degree = Math.PI / 180;
1456
1470
 
1457
1471
  // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
1458
- function create() {
1459
- const out = new ARRAY_TYPE(2);
1460
- if (ARRAY_TYPE != Float32Array) {
1461
- out[0] = 0;
1462
- out[1] = 0;
1463
- }
1464
- return out;
1465
- }
1466
1472
  function transformMat4(out, a, m) {
1467
1473
  const x = a[0];
1468
1474
  const y = a[1];
@@ -1470,32 +1476,6 @@ var __exports__ = (() => {
1470
1476
  out[1] = m[1] * x + m[5] * y + m[13];
1471
1477
  return out;
1472
1478
  }
1473
- var forEach = (function() {
1474
- const vec = create();
1475
- return function(a, stride, offset, count, fn, arg) {
1476
- let i;
1477
- let l;
1478
- if (!stride) {
1479
- stride = 2;
1480
- }
1481
- if (!offset) {
1482
- offset = 0;
1483
- }
1484
- if (count) {
1485
- l = Math.min(count * stride + offset, a.length);
1486
- } else {
1487
- l = a.length;
1488
- }
1489
- for (i = offset; i < l; i += stride) {
1490
- vec[0] = a[i];
1491
- vec[1] = a[i + 1];
1492
- fn(vec, vec, arg);
1493
- a[i] = vec[0];
1494
- a[i + 1] = vec[1];
1495
- }
1496
- return a;
1497
- };
1498
- })();
1499
1479
 
1500
1480
  // ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js
1501
1481
  function vec2_transformMat4AsVector(out, a, m) {
@@ -1526,15 +1506,6 @@ var __exports__ = (() => {
1526
1506
  }
1527
1507
 
1528
1508
  // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
1529
- function create2() {
1530
- const out = new ARRAY_TYPE(3);
1531
- if (ARRAY_TYPE != Float32Array) {
1532
- out[0] = 0;
1533
- out[1] = 0;
1534
- out[2] = 0;
1535
- }
1536
- return out;
1537
- }
1538
1509
  function dot(a, b) {
1539
1510
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
1540
1511
  }
@@ -1649,34 +1620,6 @@ var __exports__ = (() => {
1649
1620
  const cosine = mag && dot(a, b) / mag;
1650
1621
  return Math.acos(Math.min(Math.max(cosine, -1), 1));
1651
1622
  }
1652
- var forEach2 = (function() {
1653
- const vec = create2();
1654
- return function(a, stride, offset, count, fn, arg) {
1655
- let i;
1656
- let l;
1657
- if (!stride) {
1658
- stride = 3;
1659
- }
1660
- if (!offset) {
1661
- offset = 0;
1662
- }
1663
- if (count) {
1664
- l = Math.min(count * stride + offset, a.length);
1665
- } else {
1666
- l = a.length;
1667
- }
1668
- for (i = offset; i < l; i += stride) {
1669
- vec[0] = a[i];
1670
- vec[1] = a[i + 1];
1671
- vec[2] = a[i + 2];
1672
- fn(vec, vec, arg);
1673
- a[i] = vec[0];
1674
- a[i + 1] = vec[1];
1675
- a[i + 2] = vec[2];
1676
- }
1677
- return a;
1678
- };
1679
- })();
1680
1623
 
1681
1624
  // ../../node_modules/@math.gl/core/dist/classes/vector3.js
1682
1625
  var ORIGIN = [0, 0, 0];
@@ -1799,64 +1742,6 @@ var __exports__ = (() => {
1799
1742
  }
1800
1743
  };
1801
1744
 
1802
- // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
1803
- var Matrix = class extends MathArray {
1804
- // fromObject(object) {
1805
- // const array = object.elements;
1806
- // return this.fromRowMajor(array);
1807
- // }
1808
- // toObject(object) {
1809
- // const array = object.elements;
1810
- // this.toRowMajor(array);
1811
- // return object;
1812
- // }
1813
- // TODO better override formatString?
1814
- toString() {
1815
- let string = "[";
1816
- if (config.printRowMajor) {
1817
- string += "row-major:";
1818
- for (let row = 0; row < this.RANK; ++row) {
1819
- for (let col = 0; col < this.RANK; ++col) {
1820
- string += ` ${this[col * this.RANK + row]}`;
1821
- }
1822
- }
1823
- } else {
1824
- string += "column-major:";
1825
- for (let i = 0; i < this.ELEMENTS; ++i) {
1826
- string += ` ${this[i]}`;
1827
- }
1828
- }
1829
- string += "]";
1830
- return string;
1831
- }
1832
- getElementIndex(row, col) {
1833
- return col * this.RANK + row;
1834
- }
1835
- // By default assumes row major indices
1836
- getElement(row, col) {
1837
- return this[col * this.RANK + row];
1838
- }
1839
- // By default assumes row major indices
1840
- setElement(row, col, value) {
1841
- this[col * this.RANK + row] = checkNumber(value);
1842
- return this;
1843
- }
1844
- getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
1845
- const firstIndex = columnIndex * this.RANK;
1846
- for (let i = 0; i < this.RANK; ++i) {
1847
- result[i] = this[firstIndex + i];
1848
- }
1849
- return result;
1850
- }
1851
- setColumn(columnIndex, columnVector) {
1852
- const firstIndex = columnIndex * this.RANK;
1853
- for (let i = 0; i < this.RANK; ++i) {
1854
- this[firstIndex + i] = columnVector[i];
1855
- }
1856
- return this;
1857
- }
1858
- };
1859
-
1860
1745
  // ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
1861
1746
  function identity(out) {
1862
1747
  out[0] = 1;
@@ -2482,16 +2367,6 @@ var __exports__ = (() => {
2482
2367
  }
2483
2368
 
2484
2369
  // ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
2485
- function create3() {
2486
- const out = new ARRAY_TYPE(4);
2487
- if (ARRAY_TYPE != Float32Array) {
2488
- out[0] = 0;
2489
- out[1] = 0;
2490
- out[2] = 0;
2491
- out[3] = 0;
2492
- }
2493
- return out;
2494
- }
2495
2370
  function transformMat43(out, a, m) {
2496
2371
  const x = a[0];
2497
2372
  const y = a[1];
@@ -2503,36 +2378,6 @@ var __exports__ = (() => {
2503
2378
  out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
2504
2379
  return out;
2505
2380
  }
2506
- var forEach3 = (function() {
2507
- const vec = create3();
2508
- return function(a, stride, offset, count, fn, arg) {
2509
- let i;
2510
- let l;
2511
- if (!stride) {
2512
- stride = 4;
2513
- }
2514
- if (!offset) {
2515
- offset = 0;
2516
- }
2517
- if (count) {
2518
- l = Math.min(count * stride + offset, a.length);
2519
- } else {
2520
- l = a.length;
2521
- }
2522
- for (i = offset; i < l; i += stride) {
2523
- vec[0] = a[i];
2524
- vec[1] = a[i + 1];
2525
- vec[2] = a[i + 2];
2526
- vec[3] = a[i + 3];
2527
- fn(vec, vec, arg);
2528
- a[i] = vec[0];
2529
- a[i + 1] = vec[1];
2530
- a[i + 2] = vec[2];
2531
- a[i + 3] = vec[3];
2532
- }
2533
- return a;
2534
- };
2535
- })();
2536
2381
 
2537
2382
  // ../../node_modules/@math.gl/core/dist/classes/matrix4.js
2538
2383
  var INDICES;
@@ -2685,6 +2530,14 @@ var __exports__ = (() => {
2685
2530
  fromQuat(this, quaternion);
2686
2531
  return this.check();
2687
2532
  }
2533
+ /**
2534
+ * Sets this matrix from a 3x3 matrix, with zero translation.
2535
+ * @param matrix3 - 3x3 matrix in column-major order.
2536
+ * @returns This matrix.
2537
+ */
2538
+ fromMatrix3(matrix3) {
2539
+ return this.set(matrix3[0], matrix3[1], matrix3[2], 0, matrix3[3], matrix3[4], matrix3[5], 0, matrix3[6], matrix3[7], matrix3[8], 0, 0, 0, 0, 1);
2540
+ }
2688
2541
  /**
2689
2542
  * Generates a frustum matrix with the given bounds
2690
2543
  * @param view.left - Left bound of the frustum
@@ -2985,18 +2838,6 @@ var __exports__ = (() => {
2985
2838
  checkVector(out, vector.length);
2986
2839
  return out;
2987
2840
  }
2988
- /** @deprecated */
2989
- transformPoint(vector, result) {
2990
- return this.transformAsPoint(vector, result);
2991
- }
2992
- /** @deprecated */
2993
- transformVector(vector, result) {
2994
- return this.transformAsPoint(vector, result);
2995
- }
2996
- /** @deprecated */
2997
- transformDirection(vector, result) {
2998
- return this.transformAsVector(vector, result);
2999
- }
3000
2841
  // three.js math API compatibility
3001
2842
  makeRotationX(radians) {
3002
2843
  return this.identity().rotateX(radians);
@@ -5346,6 +5187,7 @@ var __exports__ = (() => {
5346
5187
  static defaultProps = {
5347
5188
  ...import_core13.RenderPipeline.defaultProps,
5348
5189
  source: void 0,
5190
+ sourceLanguage: void 0,
5349
5191
  vs: null,
5350
5192
  fs: null,
5351
5193
  id: "unnamed",
@@ -5501,6 +5343,7 @@ var __exports__ = (() => {
5501
5343
  source: source4,
5502
5344
  getUniforms: getUniforms2,
5503
5345
  bindingTable,
5346
+ entryPoints = {},
5504
5347
  shaderLayout: assembledShaderLayout
5505
5348
  } = shaderAssembler.assembleWGSLShader({
5506
5349
  platformInfo,
@@ -5512,6 +5355,8 @@ var __exports__ = (() => {
5512
5355
  pluginVaryings: resolvedPlugins.varyings
5513
5356
  });
5514
5357
  this.source = source4;
5358
+ this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
5359
+ this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
5515
5360
  this._getModuleUniforms = getUniforms2;
5516
5361
  this._bindingTable = bindingTable;
5517
5362
  const scannedOrReflectedShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(
@@ -5877,6 +5722,8 @@ var __exports__ = (() => {
5877
5722
  }
5878
5723
  /**
5879
5724
  * Sets attributes (buffers)
5725
+ * @param options.byteOffsets Optional byte offsets, keyed by buffer name, where each buffer's
5726
+ * vertex data starts. Buffers without an entry are bound at offset 0.
5880
5727
  * @note Overrides any attributes previously set with the same name
5881
5728
  */
5882
5729
  setAttributes(buffers, options) {
@@ -5915,11 +5762,13 @@ var __exports__ = (() => {
5915
5762
  }
5916
5763
  continue;
5917
5764
  }
5918
- this.vertexArray.setBuffer(bufferSlot, resolvedBuffer);
5765
+ const byteOffset = options?.byteOffsets?.[bufferName] ?? 0;
5766
+ this.vertexArray.setBuffer(bufferSlot, resolvedBuffer, byteOffset);
5919
5767
  if (buffer instanceof DynamicBuffer) {
5920
5768
  this._dynamicAttributeBufferSources[bufferSlot] = {
5921
5769
  source: buffer,
5922
- generation: buffer.generation
5770
+ generation: buffer.generation,
5771
+ byteOffset
5923
5772
  };
5924
5773
  } else {
5925
5774
  delete this._dynamicAttributeBufferSources[bufferSlot];
@@ -6237,7 +6086,7 @@ var __exports__ = (() => {
6237
6086
  }
6238
6087
  for (const [locationKey, entry] of Object.entries(this._dynamicAttributeBufferSources)) {
6239
6088
  if (entry.generation !== entry.source.generation) {
6240
- this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer);
6089
+ this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer, entry.byteOffset);
6241
6090
  entry.generation = entry.source.generation;
6242
6091
  this.setNeedsRedraw("dynamic attribute buffer");
6243
6092
  }
@@ -8673,13 +8522,332 @@ void main(void) {
8673
8522
  return areScenegraphBoundsDefined(instancedBounds) ? instancedBounds : null;
8674
8523
  }
8675
8524
 
8676
- // src/geometry/mesh-simplification.ts
8525
+ // src/geometry/edge-geometry.ts
8677
8526
  var import_core23 = __toESM(require_core(), 1);
8527
+ function makeEdgeGeometry(geometry, options = {}) {
8528
+ const { angleThreshold = 30, weldTolerance = 0, positionAttribute = "POSITION" } = options;
8529
+ const positions = getTrianglePositions(geometry, positionAttribute);
8530
+ (0, import_core23.assert)(Number.isFinite(weldTolerance) && weldTolerance >= 0);
8531
+ (0, import_core23.assert)(Number.isFinite(angleThreshold) && angleThreshold >= 0 && angleThreshold <= 180);
8532
+ const sourceIndices = geometry.indices?.value;
8533
+ const sourceCount = positions.value.length / 3;
8534
+ const representatives = /* @__PURE__ */ new Map();
8535
+ const buckets = /* @__PURE__ */ new Map();
8536
+ const faces = /* @__PURE__ */ new Set();
8537
+ const edges = /* @__PURE__ */ new Map();
8538
+ const cosineThreshold = Math.cos(angleThreshold * Math.PI / 180);
8539
+ const toleranceSquared = weldTolerance * weldTolerance;
8540
+ function readPosition(index) {
8541
+ return [
8542
+ positions.value[index * 3],
8543
+ positions.value[index * 3 + 1],
8544
+ positions.value[index * 3 + 2]
8545
+ ];
8546
+ }
8547
+ function weldPosition(index) {
8548
+ const cached = representatives.get(index);
8549
+ if (cached !== void 0) return cached;
8550
+ (0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < sourceCount);
8551
+ const position = readPosition(index);
8552
+ (0, import_core23.assert)(position.every(Number.isFinite));
8553
+ const cell = weldTolerance > 0 ? position.map((value) => Math.floor(value / weldTolerance)) : position;
8554
+ const radius = weldTolerance > 0 ? 1 : 0;
8555
+ for (let east = -radius; east <= radius; east++) {
8556
+ for (let north = -radius; north <= radius; north++) {
8557
+ for (let up = -radius; up <= radius; up++) {
8558
+ const candidates = buckets.get(`${cell[0] + east},${cell[1] + north},${cell[2] + up}`);
8559
+ for (const candidate of candidates || []) {
8560
+ const other = readPosition(candidate);
8561
+ const distanceSquared = (position[0] - other[0]) ** 2 + (position[1] - other[1]) ** 2 + (position[2] - other[2]) ** 2;
8562
+ if (distanceSquared <= toleranceSquared) {
8563
+ representatives.set(index, candidate);
8564
+ return candidate;
8565
+ }
8566
+ }
8567
+ }
8568
+ }
8569
+ }
8570
+ const key = cell.join(",");
8571
+ const bucket = buckets.get(key) || [];
8572
+ bucket.push(index);
8573
+ buckets.set(key, bucket);
8574
+ representatives.set(index, index);
8575
+ return index;
8576
+ }
8577
+ function addEdge(first, second, normal) {
8578
+ const start = Math.min(first, second);
8579
+ const end = Math.max(first, second);
8580
+ const key = `${start},${end}`;
8581
+ const edge = edges.get(key);
8582
+ if (edge) {
8583
+ edge.faceCount++;
8584
+ const cosine = normal[0] * edge.normal[0] + normal[1] * edge.normal[1] + normal[2] * edge.normal[2];
8585
+ edge.crease ||= cosine < 1 - 1e-7 && cosine <= cosineThreshold + 1e-7;
8586
+ } else {
8587
+ edges.set(key, { start, end, normal, faceCount: 1, crease: false });
8588
+ }
8589
+ }
8590
+ for (let offset = 0; offset < geometry.vertexCount; offset += 3) {
8591
+ const first = weldPosition(sourceIndices?.[offset] ?? offset);
8592
+ const second = weldPosition(sourceIndices?.[offset + 1] ?? offset + 1);
8593
+ const third = weldPosition(sourceIndices?.[offset + 2] ?? offset + 2);
8594
+ if (first === second || second === third || third === first) continue;
8595
+ const faceKey = [first, second, third].sort((left, right) => left - right).join(",");
8596
+ if (faces.has(faceKey)) continue;
8597
+ faces.add(faceKey);
8598
+ const start = readPosition(first);
8599
+ const end = readPosition(second);
8600
+ const corner = readPosition(third);
8601
+ const firstDirection = end.map((value, axis) => value - start[axis]);
8602
+ const secondDirection = corner.map((value, axis) => value - start[axis]);
8603
+ const normal = [
8604
+ firstDirection[1] * secondDirection[2] - firstDirection[2] * secondDirection[1],
8605
+ firstDirection[2] * secondDirection[0] - firstDirection[0] * secondDirection[2],
8606
+ firstDirection[0] * secondDirection[1] - firstDirection[1] * secondDirection[0]
8607
+ ];
8608
+ const magnitude = Math.hypot(...normal);
8609
+ if (magnitude === 0) continue;
8610
+ normal[0] /= magnitude;
8611
+ normal[1] /= magnitude;
8612
+ normal[2] /= magnitude;
8613
+ addEdge(first, second, normal);
8614
+ addEdge(second, third, normal);
8615
+ addEdge(third, first, normal);
8616
+ }
8617
+ const selected = [...edges.values()].filter((edge) => options.includeCoplanarEdges || edge.faceCount !== 2 || edge.crease).sort((left, right) => left.start - right.start || left.end - right.end);
8618
+ return new Geometry({
8619
+ id: `${geometry.id}-edges`,
8620
+ topology: "line-list",
8621
+ attributes: { [positionAttribute]: positions },
8622
+ indices: new Uint32Array(selected.flatMap((edge) => [edge.start, edge.end]))
8623
+ });
8624
+ }
8625
+ function makeEdgeGeometryFromGeometries(geometries, options = {}) {
8626
+ (0, import_core23.assert)(geometries.length > 0);
8627
+ const positionAttribute = options.positionAttribute ?? "POSITION";
8628
+ const attributes = geometries.map((geometry) => getTrianglePositions(geometry, positionAttribute));
8629
+ const firstAttribute = attributes[0];
8630
+ (0, import_core23.assert)(
8631
+ attributes.every(
8632
+ (attribute) => attribute.value.constructor === firstAttribute.value.constructor && Boolean(attribute["normalized"]) === Boolean(firstAttribute["normalized"])
8633
+ )
8634
+ );
8635
+ const PositionArray = firstAttribute.value.constructor;
8636
+ const positions = new PositionArray(
8637
+ attributes.reduce((count, attribute) => count + attribute.value.length, 0)
8638
+ );
8639
+ const indices = new Uint32Array(
8640
+ geometries.reduce((count, geometry) => count + geometry.vertexCount, 0)
8641
+ );
8642
+ let positionOffset = 0;
8643
+ let indexOffset = 0;
8644
+ for (const [geometryIndex, geometry] of geometries.entries()) {
8645
+ const attribute = attributes[geometryIndex];
8646
+ positions.set(attribute.value, positionOffset);
8647
+ for (let offset = 0; offset < geometry.vertexCount; offset++) {
8648
+ const index = geometry.indices?.value[offset] ?? offset;
8649
+ (0, import_core23.assert)(Number.isInteger(index) && index >= 0 && index < attribute.value.length / 3);
8650
+ indices[indexOffset++] = index + positionOffset / 3;
8651
+ }
8652
+ positionOffset += attribute.value.length;
8653
+ }
8654
+ return makeEdgeGeometry(
8655
+ new Geometry({
8656
+ id: `${geometries[0].id}-batch`,
8657
+ topology: "triangle-list",
8658
+ attributes: { [positionAttribute]: { ...firstAttribute, value: positions } },
8659
+ indices
8660
+ }),
8661
+ options
8662
+ );
8663
+ }
8664
+ function getTrianglePositions(geometry, positionAttribute) {
8665
+ const positions = geometry.attributes[positionAttribute];
8666
+ (0, import_core23.assert)(geometry.topology === "triangle-list" && positions?.size === 3);
8667
+ (0, import_core23.assert)(positions.value.length % 3 === 0 && geometry.vertexCount % 3 === 0);
8668
+ (0, import_core23.assert)(
8669
+ !positions["byteStride"] || positions["byteStride"] === positions.value.BYTES_PER_ELEMENT * 3
8670
+ );
8671
+ (0, import_core23.assert)(
8672
+ geometry.vertexCount >= 0 && geometry.vertexCount <= (geometry.indices?.value.length ?? positions.value.length / 3)
8673
+ );
8674
+ return positions;
8675
+ }
8676
+
8677
+ // src/geometry/stroke-geometry.ts
8678
+ var import_core24 = __toESM(require_core(), 1);
8679
+ function makeStrokeGeometry(path, options = {}) {
8680
+ const { width = 1, cap = "butt", join = "miter", miterLimit = 4, roundSegments = 16 } = options;
8681
+ (0, import_core24.assert)(Number.isFinite(width) && width >= 0 && Number.isFinite(miterLimit) && miterLimit >= 1);
8682
+ (0, import_core24.assert)(Number.isInteger(roundSegments) && roundSegments >= 2 && roundSegments <= 256);
8683
+ const points = [];
8684
+ for (const position of path) {
8685
+ (0, import_core24.assert)(
8686
+ Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2] ?? 0)
8687
+ );
8688
+ const previous = points.at(-1);
8689
+ if (!previous || previous[0] !== position[0] || previous[1] !== position[1])
8690
+ points.push([position[0], position[1], position[2] ?? 0]);
8691
+ }
8692
+ if (options.closed && points.length > 1 && points[0][0] === points.at(-1)[0] && points[0][1] === points.at(-1)[1])
8693
+ points.pop();
8694
+ const closed = Boolean(options.closed && points.length > 2);
8695
+ const positions = [];
8696
+ const coordinates = [];
8697
+ const halfWidth = width / 2;
8698
+ if (points.length > 1 && width > 0) {
8699
+ const segments = [];
8700
+ const distances = [0];
8701
+ for (let index = 0; index < points.length - (closed ? 0 : 1); index++) {
8702
+ const start = points[index];
8703
+ const end = points[(index + 1) % points.length];
8704
+ const horizontal = end[0] - start[0];
8705
+ const vertical = end[1] - start[1];
8706
+ const length = Math.hypot(horizontal, vertical);
8707
+ segments.push({ direction: [horizontal / length, vertical / length], length });
8708
+ distances.push(distances.at(-1) + length);
8709
+ }
8710
+ const corners = points.map((point, index) => {
8711
+ const previous = segments[(index - 1 + segments.length) % segments.length];
8712
+ const next = segments[index % segments.length];
8713
+ const distance = distances[index];
8714
+ if (!closed && (index === 0 || index === points.length - 1)) {
8715
+ const direction = index === 0 ? next.direction : previous.direction;
8716
+ const extension = cap === "square" ? index === 0 ? -halfWidth : halfWidth : 0;
8717
+ const left = createVertex(point, direction, halfWidth, extension, distance + extension);
8718
+ const right = createVertex(point, direction, -halfWidth, extension, distance + extension);
8719
+ if (cap === "round") appendCap(point, direction, distance, index === 0);
8720
+ return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
8721
+ }
8722
+ const incoming = previous.direction;
8723
+ const outgoing = next.direction;
8724
+ const turn = incoming[0] * outgoing[1] - incoming[1] * outgoing[0];
8725
+ const cosine = incoming[0] * outgoing[0] + incoming[1] * outgoing[1];
8726
+ const result = {
8727
+ incomingLeft: createVertex(point, incoming, halfWidth, 0, distance),
8728
+ incomingRight: createVertex(point, incoming, -halfWidth, 0, distance),
8729
+ outgoingLeft: createVertex(point, outgoing, halfWidth, 0, distance),
8730
+ outgoingRight: createVertex(point, outgoing, -halfWidth, 0, distance)
8731
+ };
8732
+ if (1 + cosine < 1e-8) {
8733
+ if (join === "round") {
8734
+ appendCap(point, incoming, distance, false);
8735
+ appendCap(point, outgoing, distance, true);
8736
+ }
8737
+ return result;
8738
+ }
8739
+ const miter = [
8740
+ -(incoming[1] + outgoing[1]) * halfWidth / (1 + cosine),
8741
+ (incoming[0] + outgoing[0]) * halfWidth / (1 + cosine)
8742
+ ];
8743
+ const miterLength = Math.hypot(...miter);
8744
+ if (Math.abs(turn) < 1e-8 || join === "miter" && miterLength <= miterLimit * halfWidth) {
8745
+ const left = offsetVertex(point, miter, distance, halfWidth);
8746
+ const right = offsetVertex(point, [-miter[0], -miter[1]], distance, -halfWidth);
8747
+ return { incomingLeft: left, outgoingLeft: left, incomingRight: right, outgoingRight: right };
8748
+ }
8749
+ const innerSide = Math.sign(turn);
8750
+ const innerScale = Math.min(1, Math.min(previous.length, next.length) / (2 * miterLength));
8751
+ const inner = offsetVertex(
8752
+ point,
8753
+ [miter[0] * innerSide * innerScale, miter[1] * innerSide * innerScale],
8754
+ distance,
8755
+ halfWidth * innerSide
8756
+ );
8757
+ if (innerSide > 0) {
8758
+ result.incomingLeft = inner;
8759
+ result.outgoingLeft = inner;
8760
+ } else {
8761
+ result.incomingRight = inner;
8762
+ result.outgoingRight = inner;
8763
+ }
8764
+ const outerStart = innerSide > 0 ? result.incomingRight : result.incomingLeft;
8765
+ const outerEnd = innerSide > 0 ? result.outgoingRight : result.outgoingLeft;
8766
+ if (join === "round") {
8767
+ const sweep = Math.atan2(turn, cosine);
8768
+ const startAngle = Math.atan2(
8769
+ outerStart.position[1] - point[1],
8770
+ outerStart.position[0] - point[0]
8771
+ );
8772
+ const steps = Math.max(1, Math.ceil(Math.abs(sweep) / Math.PI * roundSegments));
8773
+ let previousOuter = outerStart;
8774
+ for (let step = 1; step <= steps; step++) {
8775
+ const angle2 = startAngle + sweep * step / steps;
8776
+ const currentOuter = step === steps ? outerEnd : offsetVertex(
8777
+ point,
8778
+ [Math.cos(angle2) * halfWidth, Math.sin(angle2) * halfWidth],
8779
+ distance,
8780
+ -halfWidth * innerSide
8781
+ );
8782
+ appendTriangle(inner, previousOuter, currentOuter);
8783
+ previousOuter = currentOuter;
8784
+ }
8785
+ } else appendTriangle(inner, outerStart, outerEnd);
8786
+ return result;
8787
+ });
8788
+ segments.forEach((_segment, index) => {
8789
+ const start = corners[index];
8790
+ const end = corners[(index + 1) % corners.length];
8791
+ const closing = closed && index === segments.length - 1;
8792
+ const endLeft = closing ? { ...end.incomingLeft, distance: distances.at(-1) } : end.incomingLeft;
8793
+ const endRight = closing ? { ...end.incomingRight, distance: distances.at(-1) } : end.incomingRight;
8794
+ appendTriangle(start.outgoingLeft, start.outgoingRight, endLeft);
8795
+ appendTriangle(start.outgoingRight, endRight, endLeft);
8796
+ });
8797
+ }
8798
+ return new Geometry({
8799
+ id: options.id,
8800
+ topology: "triangle-list",
8801
+ attributes: {
8802
+ POSITION: { size: 3, value: new Float32Array(positions) },
8803
+ TEXCOORD_0: { size: 2, value: new Float32Array(coordinates) }
8804
+ }
8805
+ });
8806
+ function appendTriangle(first, second, third) {
8807
+ const area = (second.position[0] - first.position[0]) * (third.position[1] - first.position[1]) - (second.position[1] - first.position[1]) * (third.position[0] - first.position[0]);
8808
+ if (area === 0) return;
8809
+ for (const vertex of area > 0 ? [first, second, third] : [first, third, second]) {
8810
+ positions.push(...vertex.position);
8811
+ coordinates.push(vertex.distance, vertex.across);
8812
+ }
8813
+ }
8814
+ function offsetVertex(point, offset, distance, across) {
8815
+ return { position: [point[0] + offset[0], point[1] + offset[1], point[2]], distance, across };
8816
+ }
8817
+ function createVertex(point, direction, across, along, distance) {
8818
+ return offsetVertex(
8819
+ point,
8820
+ [-direction[1] * across + direction[0] * along, direction[0] * across + direction[1] * along],
8821
+ distance,
8822
+ across
8823
+ );
8824
+ }
8825
+ function appendCap(point, direction, distance, start) {
8826
+ const center = { position: point, distance, across: 0 };
8827
+ const startAngle = Math.atan2(direction[1], direction[0]) + (start ? -Math.PI / 2 : Math.PI / 2);
8828
+ let previous;
8829
+ for (let step = 0; step <= roundSegments; step++) {
8830
+ const angle2 = startAngle - Math.PI * step / roundSegments;
8831
+ const offset = [Math.cos(angle2) * halfWidth, Math.sin(angle2) * halfWidth];
8832
+ const current = offsetVertex(
8833
+ point,
8834
+ offset,
8835
+ distance + offset[0] * direction[0] + offset[1] * direction[1],
8836
+ -offset[0] * direction[1] + offset[1] * direction[0]
8837
+ );
8838
+ if (previous) appendTriangle(center, previous, current);
8839
+ previous = current;
8840
+ }
8841
+ }
8842
+ }
8843
+
8844
+ // src/geometry/mesh-simplification.ts
8845
+ var import_core25 = __toESM(require_core(), 1);
8678
8846
  var QUADRIC_COMPONENTS = 10;
8679
8847
  var BOUNDARY_COLLINEAR_TOLERANCE = 1e-10;
8680
8848
  function simplifyMesh(options) {
8681
8849
  const { positions, indices, attributes = [], preserveBoundary = true } = options;
8682
- (0, import_core23.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
8850
+ (0, import_core25.assert)(indices.length % 3 === 0 && positions.length % 3 === 0);
8683
8851
  const targetIndexCount = Math.max(
8684
8852
  0,
8685
8853
  Math.min(
@@ -8772,7 +8940,7 @@ void main(void) {
8772
8940
  const firstVertex = indices[indexOffset2];
8773
8941
  const secondVertex = indices[indexOffset2 + 1];
8774
8942
  const thirdVertex = indices[indexOffset2 + 2];
8775
- (0, import_core23.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
8943
+ (0, import_core25.assert)(firstVertex < vertexCount && secondVertex < vertexCount && thirdVertex < vertexCount);
8776
8944
  const triangle = {
8777
8945
  vertices: [firstVertex, secondVertex, thirdVertex],
8778
8946
  active: false
@@ -10037,7 +10205,7 @@ void main(void) {
10037
10205
  }
10038
10206
 
10039
10207
  // src/dynamic-texture/video-texture.ts
10040
- var import_core25 = __toESM(require_core(), 1);
10208
+ var import_core27 = __toESM(require_core(), 1);
10041
10209
  var VideoTexture = class {
10042
10210
  /** Device used to create copied and native external texture bindings. */
10043
10211
  device;
@@ -10086,7 +10254,7 @@ void main(void) {
10086
10254
  * @param props Live video source and copied texture options.
10087
10255
  */
10088
10256
  constructor(device, props) {
10089
- (0, import_core25.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
10257
+ (0, import_core27.assert)(isHTMLVideoElementSource(props?.source) || isVideoFrameSource(props?.source));
10090
10258
  this.device = device;
10091
10259
  this.id = props.id || uid("video-texture");
10092
10260
  this._source = props.source;
@@ -10100,7 +10268,7 @@ void main(void) {
10100
10268
  * @param source Next caller-owned video source to follow.
10101
10269
  */
10102
10270
  setSource(source4) {
10103
- (0, import_core25.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
10271
+ (0, import_core27.assert)(isHTMLVideoElementSource(source4) || isVideoFrameSource(source4));
10104
10272
  this._destroyExternalTexture();
10105
10273
  this._source = source4;
10106
10274
  this._sourceVersion++;
@@ -10178,7 +10346,7 @@ void main(void) {
10178
10346
  width: size.width,
10179
10347
  height: size.height,
10180
10348
  format: "rgba8unorm",
10181
- usage: import_core25.Texture.SAMPLE | import_core25.Texture.COPY_DST,
10349
+ usage: import_core27.Texture.SAMPLE | import_core27.Texture.COPY_DST,
10182
10350
  mipLevels: 1,
10183
10351
  sampler: this._sampler
10184
10352
  });
@@ -10213,7 +10381,7 @@ void main(void) {
10213
10381
  */
10214
10382
  _getResolvedSize() {
10215
10383
  const size = getVideoTextureSourceSize(this._source);
10216
- (0, import_core25.assert)(size.width > 0 && size.height > 0);
10384
+ (0, import_core27.assert)(size.width > 0 && size.height > 0);
10217
10385
  return size;
10218
10386
  }
10219
10387
  /** Observes current source readiness and frame identity before binding resolution. */
@@ -10278,11 +10446,11 @@ void main(void) {
10278
10446
  }
10279
10447
 
10280
10448
  // src/passes/shader-pass-renderer.ts
10281
- var import_core28 = __toESM(require_core(), 1);
10449
+ var import_core30 = __toESM(require_core(), 1);
10282
10450
  var import_shadertools7 = __toESM(require_shadertools(), 1);
10283
10451
 
10284
10452
  // src/compute/swap.ts
10285
- var import_core26 = __toESM(require_core(), 1);
10453
+ var import_core28 = __toESM(require_core(), 1);
10286
10454
  var Swap = class {
10287
10455
  id;
10288
10456
  /** The current resource - usually the source for renders or computations */
@@ -10314,7 +10482,7 @@ void main(void) {
10314
10482
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
10315
10483
  id: `${props.id}-texture-0`,
10316
10484
  format: colorAttachment,
10317
- usage: import_core26.Texture.SAMPLE | import_core26.Texture.RENDER | import_core26.Texture.COPY_SRC | import_core26.Texture.COPY_DST,
10485
+ usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
10318
10486
  width,
10319
10487
  height
10320
10488
  })
@@ -10324,7 +10492,7 @@ void main(void) {
10324
10492
  (colorAttachment) => typeof colorAttachment !== "string" ? colorAttachment : device.createTexture({
10325
10493
  id: `${props.id}-texture-1`,
10326
10494
  format: colorAttachment,
10327
- usage: import_core26.Texture.SAMPLE | import_core26.Texture.RENDER | import_core26.Texture.COPY_SRC | import_core26.Texture.COPY_DST,
10495
+ usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST,
10328
10496
  width,
10329
10497
  height
10330
10498
  })
@@ -10388,7 +10556,7 @@ void main(void) {
10388
10556
  };
10389
10557
 
10390
10558
  // src/compute/computation.ts
10391
- var import_core27 = __toESM(require_core(), 1);
10559
+ var import_core29 = __toESM(require_core(), 1);
10392
10560
  var import_shadertools6 = __toESM(require_shadertools(), 1);
10393
10561
  var LOG_DRAW_PRIORITY2 = 2;
10394
10562
  var LOG_DRAW_TIMEOUT2 = 1e4;
@@ -10400,13 +10568,13 @@ void main(void) {
10400
10568
  * constructor remains the synchronous compatibility path.
10401
10569
  */
10402
10570
  static async createAsync(device, props) {
10403
- const ownsCompilation = !import_core27.PipelineFactory.getAsyncCompilation(device);
10404
- const asyncCompilation = ownsCompilation ? import_core27.PipelineFactory.beginAsyncCompilation(device) : import_core27.PipelineFactory.getAsyncCompilation(device);
10571
+ const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
10572
+ const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
10405
10573
  let computation;
10406
10574
  try {
10407
10575
  computation = new _Computation(device, props);
10408
10576
  } finally {
10409
- if (ownsCompilation) import_core27.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
10577
+ if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
10410
10578
  }
10411
10579
  try {
10412
10580
  if (ownsCompilation) {
@@ -10421,11 +10589,12 @@ void main(void) {
10421
10589
  }
10422
10590
  }
10423
10591
  static defaultProps = {
10424
- ...import_core27.ComputePipeline.defaultProps,
10592
+ ...import_core29.ComputePipeline.defaultProps,
10425
10593
  id: "unnamed",
10426
10594
  handle: void 0,
10427
10595
  userData: {},
10428
10596
  source: "",
10597
+ sourceLanguage: void 0,
10429
10598
  modules: [],
10430
10599
  defines: {},
10431
10600
  plugins: [],
@@ -10486,30 +10655,34 @@ void main(void) {
10486
10655
  const modules = mergeShaderModules(this.props.modules, this.shaderInputs?.getModules());
10487
10656
  const defines = { ...resolvedPlugins.defines, ...this.props.defines };
10488
10657
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
10489
- this.pipelineFactory = props.pipelineFactory || import_core27.PipelineFactory.getDefaultPipelineFactory(this.device);
10490
- this.shaderFactory = props.shaderFactory || import_core27.ShaderFactory.getDefaultShaderFactory(this.device);
10658
+ this.pipelineFactory = props.pipelineFactory || import_core29.PipelineFactory.getDefaultPipelineFactory(this.device);
10659
+ this.shaderFactory = props.shaderFactory || import_core29.ShaderFactory.getDefaultShaderFactory(this.device);
10491
10660
  const shaderAssembler = this.props.shaderAssembler;
10492
- (0, import_core27.assert)(shaderAssembler instanceof import_shadertools6.WGSLShaderAssembler);
10661
+ (0, import_core29.assert)(shaderAssembler instanceof import_shadertools6.WGSLShaderAssembler);
10493
10662
  const {
10494
10663
  source: source4,
10495
10664
  getUniforms: getUniforms2,
10665
+ entryPoints = {},
10496
10666
  shaderLayout: assembledShaderLayout
10497
10667
  } = shaderAssembler.assembleWGSLShader({
10498
10668
  platformInfo,
10499
10669
  ...this.props,
10500
10670
  modules,
10501
10671
  defines,
10672
+ shaderStage: "compute",
10673
+ computeEntryPoint: this.props.entryPoint,
10502
10674
  scanVertexAttributes: false,
10503
10675
  pluginInjections: resolvedPlugins.injections
10504
10676
  });
10505
10677
  this.source = source4;
10678
+ this.props.entryPoint = entryPoints.compute || this.props.entryPoint;
10506
10679
  this._getModuleUniforms = getUniforms2;
10507
10680
  const inferredShaderLayout = assembledShaderLayout ?? device.getShaderLayout?.(this.source, { scanVertexAttributes: false });
10508
10681
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(
10509
10682
  this.props.shaderLayout || inferredShaderLayout || null,
10510
10683
  modules
10511
10684
  ) || null;
10512
- const asyncCompilation = import_core27.PipelineFactory.getAsyncCompilation(this.device);
10685
+ const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(this.device);
10513
10686
  if (asyncCompilation) {
10514
10687
  this._pipelineInitialization = this._updatePipelineAsync();
10515
10688
  asyncCompilation.push(this._pipelineInitialization);
@@ -10576,7 +10749,7 @@ void main(void) {
10576
10749
  }
10577
10750
  setShaderInputs(shaderInputs) {
10578
10751
  this.shaderInputs = shaderInputs;
10579
- this._uniformStore = new import_core27.UniformStore(this.device, this.shaderInputs.modules);
10752
+ this._uniformStore = new import_core29.UniformStore(this.device, this.shaderInputs.modules);
10580
10753
  for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
10581
10754
  if (shaderModuleHasUniforms(module)) {
10582
10755
  const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
@@ -10645,7 +10818,7 @@ void main(void) {
10645
10818
  if (!this._pipelineNeedsUpdate) return null;
10646
10819
  const previousShader = this.pipeline ? this.shader : null;
10647
10820
  if (this.pipeline) {
10648
- import_core27.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
10821
+ import_core29.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
10649
10822
  }
10650
10823
  this._pipelineNeedsUpdate = false;
10651
10824
  this.shader = this.shaderFactory.createShader({
@@ -10663,27 +10836,27 @@ void main(void) {
10663
10836
  _lastLogTime = 0;
10664
10837
  _logOpen = false;
10665
10838
  _logDrawCallStart() {
10666
- const logDrawTimeout = import_core27.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
10667
- if (import_core27.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
10839
+ const logDrawTimeout = import_core29.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT2;
10840
+ if (import_core29.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
10668
10841
  return;
10669
10842
  }
10670
10843
  this._lastLogTime = Date.now();
10671
10844
  this._logOpen = true;
10672
- import_core27.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core27.log.level <= 2 })();
10845
+ import_core29.log.group(LOG_DRAW_PRIORITY2, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core29.log.level <= 2 })();
10673
10846
  }
10674
10847
  _logDrawCallEnd() {
10675
10848
  if (this._logOpen) {
10676
10849
  const uniformTable = this.shaderInputs.getDebugTable();
10677
- import_core27.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
10678
- import_core27.log.groupEnd(LOG_DRAW_PRIORITY2)();
10850
+ import_core29.log.table(LOG_DRAW_PRIORITY2, uniformTable)();
10851
+ import_core29.log.groupEnd(LOG_DRAW_PRIORITY2)();
10679
10852
  this._logOpen = false;
10680
10853
  }
10681
10854
  }
10682
10855
  _drawCount = 0;
10683
10856
  // TODO - fix typing of luma data types
10684
10857
  _getBufferOrConstantValues(attribute, dataType) {
10685
- const TypedArrayConstructor = import_core27.dataTypeDecoder.getTypedArrayConstructor(dataType);
10686
- const typedArray = attribute instanceof import_core27.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
10858
+ const TypedArrayConstructor = import_core29.dataTypeDecoder.getTypedArrayConstructor(dataType);
10859
+ const typedArray = attribute instanceof import_core29.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
10687
10860
  return typedArray.toString();
10688
10861
  }
10689
10862
  };
@@ -11251,7 +11424,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11251
11424
  this.parameterBuffer = device.createBuffer({
11252
11425
  id: `${optimization.name}-parameters`,
11253
11426
  byteLength: Math.max(Math.ceil(optimization.uniformNames.length / 4) * 16, 16),
11254
- usage: import_core28.Buffer.UNIFORM | import_core28.Buffer.COPY_DST
11427
+ usage: import_core30.Buffer.UNIFORM | import_core30.Buffer.COPY_DST
11255
11428
  });
11256
11429
  const outputBindings = Object.entries(optimization.outputs).map(
11257
11430
  ([bindingName, targetName], outputIndex) => ({
@@ -11536,7 +11709,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11536
11709
  width: targetSize[0],
11537
11710
  height: targetSize[1],
11538
11711
  format: spec.format || device.preferredColorFormat,
11539
- usage: import_core28.Texture.SAMPLE | import_core28.Texture.RENDER | import_core28.Texture.COPY_SRC | import_core28.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core28.Texture.STORAGE : 0),
11712
+ usage: import_core30.Texture.SAMPLE | import_core30.Texture.RENDER | import_core30.Texture.COPY_SRC | import_core30.Texture.COPY_DST | (spec.storage && device.type === "webgpu" && device.getTextureFormatCapabilities(spec.format || device.preferredColorFormat).store ? import_core30.Texture.STORAGE : 0),
11540
11713
  ...spec.sampler ? { sampler: spec.sampler } : {}
11541
11714
  });
11542
11715
  const framebuffer = device.createFramebuffer({
@@ -11591,17 +11764,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11591
11764
  }
11592
11765
 
11593
11766
  // src/compute/kernel.ts
11594
- var import_core29 = __toESM(require_core(), 1);
11767
+ var import_core31 = __toESM(require_core(), 1);
11595
11768
  var Kernel = class _Kernel {
11596
11769
  /** Creates a kernel while allowing the backend to compile its pipeline asynchronously. */
11597
11770
  static async createAsync(device, props) {
11598
- const ownsCompilation = !import_core29.PipelineFactory.getAsyncCompilation(device);
11599
- const asyncCompilation = ownsCompilation ? import_core29.PipelineFactory.beginAsyncCompilation(device) : import_core29.PipelineFactory.getAsyncCompilation(device);
11771
+ const ownsCompilation = !import_core31.PipelineFactory.getAsyncCompilation(device);
11772
+ const asyncCompilation = ownsCompilation ? import_core31.PipelineFactory.beginAsyncCompilation(device) : import_core31.PipelineFactory.getAsyncCompilation(device);
11600
11773
  let kernel;
11601
11774
  try {
11602
11775
  kernel = new _Kernel(device, props);
11603
11776
  } finally {
11604
- if (ownsCompilation) import_core29.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
11777
+ if (ownsCompilation) import_core31.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
11605
11778
  }
11606
11779
  try {
11607
11780
  if (ownsCompilation) {
@@ -11632,8 +11805,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11632
11805
  this.device = device;
11633
11806
  this.id = props.id ?? "kernel";
11634
11807
  this.source = source4;
11635
- this.pipelineFactory = pipelineFactory ?? import_core29.PipelineFactory.getDefaultPipelineFactory(device);
11636
- this.shaderFactory = shaderFactory ?? import_core29.ShaderFactory.getDefaultShaderFactory(device);
11808
+ this.pipelineFactory = pipelineFactory ?? import_core31.PipelineFactory.getDefaultPipelineFactory(device);
11809
+ this.shaderFactory = shaderFactory ?? import_core31.ShaderFactory.getDefaultShaderFactory(device);
11637
11810
  this.shader = this.shaderFactory.createShader({
11638
11811
  id: `${this.id}-compute`,
11639
11812
  stage: "compute",
@@ -11641,7 +11814,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11641
11814
  debugShaders
11642
11815
  });
11643
11816
  const computePipelineProps = { ...pipelineProps, shader: this.shader };
11644
- const asyncCompilation = import_core29.PipelineFactory.getAsyncCompilation(device);
11817
+ const asyncCompilation = import_core31.PipelineFactory.getAsyncCompilation(device);
11645
11818
  if (asyncCompilation) {
11646
11819
  const pipelineInitialization = this.pipelineFactory.createComputePipelineAsync(computePipelineProps);
11647
11820
  this._pipelineInitialization = pipelineInitialization;
@@ -11678,17 +11851,17 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11678
11851
  };
11679
11852
 
11680
11853
  // src/compute/render-kernel.ts
11681
- var import_core30 = __toESM(require_core(), 1);
11854
+ var import_core32 = __toESM(require_core(), 1);
11682
11855
  var RenderKernel = class _RenderKernel {
11683
11856
  /** Creates a render kernel while allowing the backend to compile its pipeline asynchronously. */
11684
11857
  static async createAsync(device, props) {
11685
- const ownsCompilation = !import_core30.PipelineFactory.getAsyncCompilation(device);
11686
- const asyncCompilation = ownsCompilation ? import_core30.PipelineFactory.beginAsyncCompilation(device) : import_core30.PipelineFactory.getAsyncCompilation(device);
11858
+ const ownsCompilation = !import_core32.PipelineFactory.getAsyncCompilation(device);
11859
+ const asyncCompilation = ownsCompilation ? import_core32.PipelineFactory.beginAsyncCompilation(device) : import_core32.PipelineFactory.getAsyncCompilation(device);
11687
11860
  let kernel;
11688
11861
  try {
11689
11862
  kernel = new _RenderKernel(device, props);
11690
11863
  } finally {
11691
- if (ownsCompilation) import_core30.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
11864
+ if (ownsCompilation) import_core32.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
11692
11865
  }
11693
11866
  try {
11694
11867
  if (ownsCompilation) {
@@ -11729,8 +11902,8 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11729
11902
  this.id = props.id ?? "render-kernel";
11730
11903
  this.vertexSource = vertexSource;
11731
11904
  this.fragmentSource = fragmentSource;
11732
- this.pipelineFactory = pipelineFactory ?? import_core30.PipelineFactory.getDefaultPipelineFactory(device);
11733
- this.shaderFactory = shaderFactory ?? import_core30.ShaderFactory.getDefaultShaderFactory(device);
11905
+ this.pipelineFactory = pipelineFactory ?? import_core32.PipelineFactory.getDefaultPipelineFactory(device);
11906
+ this.shaderFactory = shaderFactory ?? import_core32.ShaderFactory.getDefaultShaderFactory(device);
11734
11907
  this.vertexShader = this.shaderFactory.createShader({
11735
11908
  id: `${this.id}-vertex`,
11736
11909
  stage: "vertex",
@@ -11748,7 +11921,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11748
11921
  vs: this.vertexShader,
11749
11922
  fs: this.fragmentShader
11750
11923
  };
11751
- const asyncCompilation = import_core30.PipelineFactory.getAsyncCompilation(device);
11924
+ const asyncCompilation = import_core32.PipelineFactory.getAsyncCompilation(device);
11752
11925
  if (asyncCompilation) {
11753
11926
  const pipelineInitialization = this.pipelineFactory.createRenderPipelineAsync(renderPipelineProps);
11754
11927
  this._pipelineInitialization = pipelineInitialization;
@@ -11795,7 +11968,7 @@ vec2 shaderPassRenderer_getRenderTargetUV(vec2 textureUV) {
11795
11968
  };
11796
11969
 
11797
11970
  // src/modules/picking/picking-manager.ts
11798
- var import_core31 = __toESM(require_core(), 1);
11971
+ var import_core33 = __toESM(require_core(), 1);
11799
11972
 
11800
11973
  // src/modules/picking/picking-uniforms.ts
11801
11974
  var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
@@ -12059,13 +12232,13 @@ layout(std140) uniform pickingUniforms {
12059
12232
  format: "rgba8unorm",
12060
12233
  width: 1,
12061
12234
  height: 1,
12062
- usage: import_core31.Texture.RENDER_ATTACHMENT
12235
+ usage: import_core33.Texture.RENDER_ATTACHMENT
12063
12236
  });
12064
12237
  const pickingTexture = this.device.createTexture({
12065
12238
  format: "rg32sint",
12066
12239
  width: 1,
12067
12240
  height: 1,
12068
- usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
12241
+ usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
12069
12242
  });
12070
12243
  return this.device.createFramebuffer({
12071
12244
  colorAttachments: [colorTexture, pickingTexture],
@@ -12077,7 +12250,7 @@ layout(std140) uniform pickingUniforms {
12077
12250
  format: "rgba8unorm",
12078
12251
  width: 1,
12079
12252
  height: 1,
12080
- usage: import_core31.Texture.RENDER_ATTACHMENT | import_core31.Texture.COPY_SRC
12253
+ usage: import_core33.Texture.RENDER_ATTACHMENT | import_core33.Texture.COPY_SRC
12081
12254
  });
12082
12255
  return this.device.createFramebuffer({
12083
12256
  colorAttachments: [pickingTexture],
@@ -12099,7 +12272,7 @@ layout(std140) uniform pickingUniforms {
12099
12272
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
12100
12273
  const readBuffer = this.device.createBuffer({
12101
12274
  byteLength: layout.byteLength,
12102
- usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
12275
+ usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
12103
12276
  });
12104
12277
  try {
12105
12278
  pickTexture.readBuffer(
@@ -12135,7 +12308,7 @@ layout(std140) uniform pickingUniforms {
12135
12308
  const layout = pickTexture.computeMemoryLayout({ width: 1, height: 1 });
12136
12309
  const readBuffer = this.device.createBuffer({
12137
12310
  byteLength: layout.byteLength,
12138
- usage: import_core31.Buffer.COPY_DST | import_core31.Buffer.MAP_READ
12311
+ usage: import_core33.Buffer.COPY_DST | import_core33.Buffer.MAP_READ
12139
12312
  });
12140
12313
  try {
12141
12314
  pickTexture.readBuffer(