@footgun/cobalt 0.6.6 → 0.6.7

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/bundle.js CHANGED
@@ -7358,16 +7358,16 @@ var bloom_default2 = {
7358
7358
  onInit: async function(cobalt, options = {}) {
7359
7359
  return init(cobalt, options);
7360
7360
  },
7361
- onRun: function(cobalt, node, webGpuCommandEncoder) {
7362
- draw(cobalt, node.data, webGpuCommandEncoder);
7361
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
7362
+ draw(cobalt, node2.data, webGpuCommandEncoder);
7363
7363
  },
7364
- onDestroy: function(cobalt, node) {
7365
- destroy(node);
7364
+ onDestroy: function(cobalt, node2) {
7365
+ destroy(node2);
7366
7366
  },
7367
- onResize: function(cobalt, node) {
7368
- resize(cobalt, node);
7367
+ onResize: function(cobalt, node2) {
7368
+ resize(cobalt, node2);
7369
7369
  },
7370
- onViewportPosition: function(cobalt, node) {
7370
+ onViewportPosition: function(cobalt, node2) {
7371
7371
  }
7372
7372
  };
7373
7373
  function init(cobalt, nodeData) {
@@ -7468,12 +7468,12 @@ function init(cobalt, nodeData) {
7468
7468
  bloom_mat.compute_pipeline = compute_pipeline;
7469
7469
  return bloom_mat;
7470
7470
  }
7471
- function set_all_bind_group(cobalt, bloom_mat, node) {
7472
- const { refs } = node;
7471
+ function set_all_bind_group(cobalt, bloom_mat, node2) {
7472
+ const { refs } = node2;
7473
7473
  const { device } = cobalt;
7474
- const bloom_threshold = node.options.bloom_threshold ?? 0.1;
7475
- const bloom_knee = node.options.bloom_knee ?? 0.2;
7476
- const combine_constant = node.options.bloom_combine_constant ?? 0.68;
7474
+ const bloom_threshold = node2.options.bloom_threshold ?? 0.1;
7475
+ const bloom_knee = node2.options.bloom_knee ?? 0.2;
7476
+ const combine_constant = node2.options.bloom_combine_constant ?? 0.68;
7477
7477
  const dat = new Float32Array([
7478
7478
  bloom_threshold,
7479
7479
  bloom_threshold - bloom_knee,
@@ -7713,19 +7713,19 @@ var scene_composite_default2 = {
7713
7713
  onInit: async function(cobalt, options = {}) {
7714
7714
  return init2(cobalt, options);
7715
7715
  },
7716
- onRun: function(cobalt, node, webGpuCommandEncoder) {
7717
- draw2(cobalt, node, webGpuCommandEncoder);
7716
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
7717
+ draw2(cobalt, node2, webGpuCommandEncoder);
7718
7718
  },
7719
- onDestroy: function(cobalt, node) {
7719
+ onDestroy: function(cobalt, node2) {
7720
7720
  },
7721
- onResize: function(cobalt, node) {
7722
- resize2(cobalt, node);
7721
+ onResize: function(cobalt, node2) {
7722
+ resize2(cobalt, node2);
7723
7723
  },
7724
- onViewportPosition: function(cobalt, node) {
7724
+ onViewportPosition: function(cobalt, node2) {
7725
7725
  }
7726
7726
  };
7727
- function init2(cobalt, node) {
7728
- const { options, refs } = node;
7727
+ function init2(cobalt, node2) {
7728
+ const { options, refs } = node2;
7729
7729
  const { device } = cobalt;
7730
7730
  const format = getPreferredFormat(cobalt);
7731
7731
  const bloom_intensity = options.bloom_intensity ?? 40;
@@ -7795,12 +7795,12 @@ function init2(cobalt, node) {
7795
7795
  params_buf
7796
7796
  };
7797
7797
  }
7798
- function draw2(cobalt, node, commandEncoder) {
7798
+ function draw2(cobalt, node2, commandEncoder) {
7799
7799
  const passEncoder = commandEncoder.beginRenderPass({
7800
7800
  label: "scene-composite",
7801
7801
  colorAttachments: [
7802
7802
  {
7803
- view: node.refs.combined.data.view,
7803
+ view: node2.refs.combined.data.view,
7804
7804
  //getCurrentTextureView(cobalt)
7805
7805
  clearValue: { r: 0, g: 0, b: 0, a: 1 },
7806
7806
  loadOp: "clear",
@@ -7808,31 +7808,31 @@ function draw2(cobalt, node, commandEncoder) {
7808
7808
  }
7809
7809
  ]
7810
7810
  });
7811
- const { pipeline, bindGroup } = node.data;
7811
+ const { pipeline, bindGroup } = node2.data;
7812
7812
  passEncoder.setPipeline(pipeline);
7813
7813
  passEncoder.setBindGroup(0, bindGroup);
7814
7814
  passEncoder.draw(3);
7815
7815
  passEncoder.end();
7816
7816
  }
7817
- function resize2(cobalt, node) {
7818
- const { pipeline, params_buf } = node.data;
7817
+ function resize2(cobalt, node2) {
7818
+ const { pipeline, params_buf } = node2.data;
7819
7819
  const { device } = cobalt;
7820
- node.data.bindGroup = device.createBindGroup({
7820
+ node2.data.bindGroup = device.createBindGroup({
7821
7821
  layout: pipeline.getBindGroupLayout(0),
7822
7822
  entries: [
7823
7823
  {
7824
7824
  binding: 0,
7825
- resource: node.refs.hdr.data.sampler
7825
+ resource: node2.refs.hdr.data.sampler
7826
7826
  },
7827
7827
  // color
7828
7828
  {
7829
7829
  binding: 1,
7830
- resource: node.refs.hdr.data.view
7830
+ resource: node2.refs.hdr.data.view
7831
7831
  },
7832
7832
  // emissive
7833
7833
  {
7834
7834
  binding: 2,
7835
- resource: node.refs.bloom.data.mip_view[0]
7835
+ resource: node2.refs.bloom.data.mip_view[0]
7836
7836
  //bloom_mat.bind_groups_textures[2].mip_view[0],
7837
7837
  },
7838
7838
  {
@@ -8037,15 +8037,15 @@ var sprite_default = {
8037
8037
  onInit: async function(cobalt, options = {}) {
8038
8038
  return init3(cobalt, options);
8039
8039
  },
8040
- onRun: function(cobalt, node, webGpuCommandEncoder) {
8041
- draw3(cobalt, node, webGpuCommandEncoder);
8040
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
8041
+ draw3(cobalt, node2, webGpuCommandEncoder);
8042
8042
  },
8043
- onDestroy: function(cobalt, node) {
8044
- destroy2(node);
8043
+ onDestroy: function(cobalt, node2) {
8044
+ destroy2(node2);
8045
8045
  },
8046
- onResize: function(cobalt, node) {
8046
+ onResize: function(cobalt, node2) {
8047
8047
  },
8048
- onViewportPosition: function(cobalt, node) {
8048
+ onViewportPosition: function(cobalt, node2) {
8049
8049
  },
8050
8050
  // optional
8051
8051
  customFunctions: {
@@ -8122,44 +8122,44 @@ async function init3(cobalt, nodeData) {
8122
8122
  dirty: false
8123
8123
  };
8124
8124
  }
8125
- function draw3(cobalt, node, commandEncoder) {
8125
+ function draw3(cobalt, node2, commandEncoder) {
8126
8126
  const { device } = cobalt;
8127
- const loadOp = node.options.loadOp || "load";
8128
- if (node.data.dirty) {
8129
- _rebuildSpriteDrawCalls(node.data);
8130
- node.data.dirty = false;
8127
+ const loadOp = node2.options.loadOp || "load";
8128
+ if (node2.data.dirty) {
8129
+ _rebuildSpriteDrawCalls(node2.data);
8130
+ node2.data.dirty = false;
8131
8131
  }
8132
- if (node.data.spriteCount > 0) {
8133
- const writeLength = node.data.spriteCount * FLOAT32S_PER_SPRITE * Float32Array.BYTES_PER_ELEMENT;
8134
- device.queue.writeBuffer(node.data.spriteBuffer, 0, node.data.spriteData.buffer, 0, writeLength);
8132
+ if (node2.data.spriteCount > 0) {
8133
+ const writeLength = node2.data.spriteCount * FLOAT32S_PER_SPRITE * Float32Array.BYTES_PER_ELEMENT;
8134
+ device.queue.writeBuffer(node2.data.spriteBuffer, 0, node2.data.spriteData.buffer, 0, writeLength);
8135
8135
  }
8136
8136
  const renderpass = commandEncoder.beginRenderPass({
8137
8137
  label: "sprite",
8138
8138
  colorAttachments: [
8139
8139
  // color
8140
8140
  {
8141
- view: node.refs.hdr.data.view,
8141
+ view: node2.refs.hdr.data.view,
8142
8142
  clearValue: cobalt.clearValue,
8143
8143
  loadOp,
8144
8144
  storeOp: "store"
8145
8145
  },
8146
8146
  // emissive
8147
8147
  {
8148
- view: node.refs.emissive.data.view,
8148
+ view: node2.refs.emissive.data.view,
8149
8149
  clearValue: cobalt.clearValue,
8150
8150
  loadOp: "clear",
8151
8151
  storeOp: "store"
8152
8152
  }
8153
8153
  ]
8154
8154
  });
8155
- renderpass.setPipeline(node.refs.spritesheet.data.pipeline);
8156
- renderpass.setBindGroup(0, node.data.bindGroup);
8157
- renderpass.setVertexBuffer(0, node.refs.spritesheet.data.quads.buffer);
8155
+ renderpass.setPipeline(node2.refs.spritesheet.data.pipeline);
8156
+ renderpass.setBindGroup(0, node2.data.bindGroup);
8157
+ renderpass.setVertexBuffer(0, node2.refs.spritesheet.data.quads.buffer);
8158
8158
  const vertexCount = 6;
8159
8159
  let baseInstanceIdx = 0;
8160
- for (let i = 0; i < node.data.instancedDrawCallCount; i++) {
8161
- const baseVertexIdx = node.data.instancedDrawCalls[i * 2] * vertexCount;
8162
- const instanceCount = node.data.instancedDrawCalls[i * 2 + 1];
8160
+ for (let i = 0; i < node2.data.instancedDrawCallCount; i++) {
8161
+ const baseVertexIdx = node2.data.instancedDrawCalls[i * 2] * vertexCount;
8162
+ const instanceCount = node2.data.instancedDrawCalls[i * 2 + 1];
8163
8163
  renderpass.draw(vertexCount, instanceCount, baseVertexIdx, baseInstanceIdx);
8164
8164
  baseInstanceIdx += instanceCount;
8165
8165
  }
@@ -8188,14 +8188,14 @@ function _rebuildSpriteDrawCalls(renderPass) {
8188
8188
  renderPass.instancedDrawCallCount++;
8189
8189
  }
8190
8190
  }
8191
- function destroy2(node) {
8192
- node.data.instancedDrawCalls = null;
8193
- node.data.bindGroup = null;
8194
- node.data.spriteBuffer.destroy();
8195
- node.data.spriteBuffer = null;
8196
- node.data.spriteData = null;
8197
- node.data.spriteIndices.clear();
8198
- node.data.spriteIndices = null;
8191
+ function destroy2(node2) {
8192
+ node2.data.instancedDrawCalls = null;
8193
+ node2.data.bindGroup = null;
8194
+ node2.data.spriteBuffer.destroy();
8195
+ node2.data.spriteBuffer = null;
8196
+ node2.data.spriteData = null;
8197
+ node2.data.spriteIndices.clear();
8198
+ node2.data.spriteIndices = null;
8199
8199
  }
8200
8200
 
8201
8201
  // src/tile/tile.js
@@ -8209,36 +8209,36 @@ var tile_default = {
8209
8209
  onInit: async function(cobalt, options = {}) {
8210
8210
  return init4(cobalt, options);
8211
8211
  },
8212
- onRun: function(cobalt, node, webGpuCommandEncoder) {
8213
- draw4(cobalt, node, webGpuCommandEncoder);
8212
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
8213
+ draw4(cobalt, node2, webGpuCommandEncoder);
8214
8214
  },
8215
- onDestroy: function(cobalt, node) {
8216
- destroy3(node);
8215
+ onDestroy: function(cobalt, node2) {
8216
+ destroy3(node2);
8217
8217
  },
8218
- onResize: function(cobalt, node) {
8218
+ onResize: function(cobalt, node2) {
8219
8219
  },
8220
- onViewportPosition: function(cobalt, node) {
8220
+ onViewportPosition: function(cobalt, node2) {
8221
8221
  },
8222
8222
  // optional
8223
8223
  customFunctions: {
8224
- setTexture: async function(cobalt, node, textureUrl) {
8224
+ setTexture: async function(cobalt, node2, textureUrl) {
8225
8225
  const { canvas, device } = cobalt;
8226
- destroy3(node);
8226
+ destroy3(node2);
8227
8227
  const format = getPreferredFormat(cobalt);
8228
8228
  let material;
8229
8229
  if (canvas) {
8230
- node.options.textureUrl = textureUrl;
8231
- material = await createTextureFromUrl(cobalt, "tile map", node.options.textureUrl, format);
8230
+ node2.options.textureUrl = textureUrl;
8231
+ material = await createTextureFromUrl(cobalt, "tile map", node2.options.textureUrl, format);
8232
8232
  } else {
8233
- material = await createTextureFromBuffer(cobalt, "tile map", node.options.texture, format);
8233
+ material = await createTextureFromBuffer(cobalt, "tile map", node2.options.texture, format);
8234
8234
  }
8235
8235
  const bindGroup = device.createBindGroup({
8236
- layout: node.refs.tileAtlas.data.tileBindGroupLayout,
8236
+ layout: node2.refs.tileAtlas.data.tileBindGroupLayout,
8237
8237
  entries: [
8238
8238
  {
8239
8239
  binding: 0,
8240
8240
  resource: {
8241
- buffer: node.data.uniformBuffer
8241
+ buffer: node2.data.uniformBuffer
8242
8242
  }
8243
8243
  },
8244
8244
  {
@@ -8251,14 +8251,20 @@ var tile_default = {
8251
8251
  }
8252
8252
  ]
8253
8253
  });
8254
- node.data.bindGroup = bindGroup;
8255
- node.data.material = material;
8254
+ node2.data.bindGroup = bindGroup;
8255
+ node2.data.material = material;
8256
8256
  }
8257
8257
  }
8258
8258
  };
8259
8259
  async function init4(cobalt, nodeData) {
8260
- const { device } = cobalt;
8261
- const material = await createTextureFromUrl(cobalt, "tile map", nodeData.options.textureUrl);
8260
+ const { canvas, device } = cobalt;
8261
+ let material;
8262
+ const format = getPreferredFormat(cobalt);
8263
+ if (canvas) {
8264
+ material = await createTextureFromUrl(cobalt, "tile map", nodeData.options.textureUrl, format);
8265
+ } else {
8266
+ material = await createTextureFromBuffer(cobalt, "tile map", node.options.texture, format);
8267
+ }
8262
8268
  const dat = new Float32Array([nodeData.options.scrollScale, nodeData.options.scrollScale]);
8263
8269
  const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
8264
8270
  const descriptor = {
@@ -12220,42 +12226,42 @@ var displacement_default2 = {
12220
12226
  onInit: async function(cobalt, options = {}) {
12221
12227
  return init5(cobalt, options);
12222
12228
  },
12223
- onRun: function(cobalt, node, webGpuCommandEncoder) {
12224
- draw5(cobalt, node, webGpuCommandEncoder);
12229
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
12230
+ draw5(cobalt, node2, webGpuCommandEncoder);
12225
12231
  },
12226
- onDestroy: function(cobalt, node) {
12227
- destroy4(node);
12232
+ onDestroy: function(cobalt, node2) {
12233
+ destroy4(node2);
12228
12234
  },
12229
- onResize: function(cobalt, node) {
12230
- node.data.displacementTexture.resize(cobalt.viewport.width, cobalt.viewport.height);
12231
- node.data.displacementComposition.setColorTextureView(node.refs.color.data.view);
12232
- node.data.displacementComposition.setNoiseMapTextureView(node.refs.map.view);
12233
- node.data.displacementComposition.setDisplacementTextureView(node.data.displacementTexture.getView());
12235
+ onResize: function(cobalt, node2) {
12236
+ node2.data.displacementTexture.resize(cobalt.viewport.width, cobalt.viewport.height);
12237
+ node2.data.displacementComposition.setColorTextureView(node2.refs.color.data.view);
12238
+ node2.data.displacementComposition.setNoiseMapTextureView(node2.refs.map.view);
12239
+ node2.data.displacementComposition.setDisplacementTextureView(node2.data.displacementTexture.getView());
12234
12240
  },
12235
- onViewportPosition: function(cobalt, node) {
12236
- node.data.displacementTexture.setViewport(cobalt.viewport);
12241
+ onViewportPosition: function(cobalt, node2) {
12242
+ node2.data.displacementTexture.setViewport(cobalt.viewport);
12237
12243
  },
12238
12244
  // optional
12239
12245
  customFunctions: {
12240
- addTriangle: function(cobalt, node, triangleVertices) {
12241
- return node.data.trianglesBuffer.addTriangle(triangleVertices);
12246
+ addTriangle: function(cobalt, node2, triangleVertices) {
12247
+ return node2.data.trianglesBuffer.addTriangle(triangleVertices);
12242
12248
  },
12243
- removeTriangle: function(cobalt, node, triangleId) {
12244
- node.data.trianglesBuffer.removeTriangle(triangleId);
12249
+ removeTriangle: function(cobalt, node2, triangleId) {
12250
+ node2.data.trianglesBuffer.removeTriangle(triangleId);
12245
12251
  },
12246
- setPosition: function(cobalt, node, triangleId, triangleVertices) {
12247
- node.data.trianglesBuffer.setTriangle(triangleId, triangleVertices);
12252
+ setPosition: function(cobalt, node2, triangleId, triangleVertices) {
12253
+ node2.data.trianglesBuffer.setTriangle(triangleId, triangleVertices);
12248
12254
  }
12249
12255
  }
12250
12256
  };
12251
- async function init5(cobalt, node) {
12257
+ async function init5(cobalt, node2) {
12252
12258
  const { device } = cobalt;
12253
12259
  const displacementParameters = new DisplacementParametersBuffer({
12254
12260
  device,
12255
12261
  initialParameters: {
12256
- offsetX: node.options.offseyX ?? 0,
12257
- offsetY: node.options.offseyY ?? 0,
12258
- scale: node.options.scale ?? 20
12262
+ offsetX: node2.options.offseyX ?? 0,
12263
+ offsetY: node2.options.offseyY ?? 0,
12264
+ scale: node2.options.scale ?? 20
12259
12265
  }
12260
12266
  });
12261
12267
  const MAX_SPRITE_COUNT = 256;
@@ -12273,8 +12279,8 @@ async function init5(cobalt, node) {
12273
12279
  const displacementComposition = new DisplacementComposition({
12274
12280
  device,
12275
12281
  targetFormat: getPreferredFormat(cobalt),
12276
- colorTextureView: node.refs.color.data.view,
12277
- noiseMapTextureView: node.refs.map.view,
12282
+ colorTextureView: node2.refs.color.data.view,
12283
+ noiseMapTextureView: node2.refs.map.view,
12278
12284
  displacementTextureView: displacementTexture.getView(),
12279
12285
  displacementParametersBuffer: displacementParameters
12280
12286
  });
@@ -12285,35 +12291,35 @@ async function init5(cobalt, node) {
12285
12291
  trianglesBuffer
12286
12292
  };
12287
12293
  }
12288
- function draw5(cobalt, node, commandEncoder) {
12289
- const spriteCount = node.data.trianglesBuffer.spriteCount;
12294
+ function draw5(cobalt, node2, commandEncoder) {
12295
+ const spriteCount = node2.data.trianglesBuffer.spriteCount;
12290
12296
  if (spriteCount === 0)
12291
12297
  return;
12292
- node.data.trianglesBuffer.update();
12293
- node.data.displacementTexture.update(commandEncoder);
12298
+ node2.data.trianglesBuffer.update();
12299
+ node2.data.displacementTexture.update(commandEncoder);
12294
12300
  const renderpass = commandEncoder.beginRenderPass({
12295
12301
  label: "displacement",
12296
12302
  colorAttachments: [
12297
12303
  {
12298
- view: node.refs.out,
12304
+ view: node2.refs.out,
12299
12305
  clearValue: cobalt.clearValue,
12300
12306
  loadOp: "load",
12301
12307
  storeOp: "store"
12302
12308
  }
12303
12309
  ]
12304
12310
  });
12305
- renderpass.executeBundles([node.data.displacementComposition.getRenderBundle()]);
12311
+ renderpass.executeBundles([node2.data.displacementComposition.getRenderBundle()]);
12306
12312
  renderpass.end();
12307
12313
  }
12308
- function destroy4(node) {
12309
- node.data.trianglesBuffer.destroy();
12310
- node.data.trianglesBuffer = null;
12311
- node.data.displacementParameters.destroy();
12312
- node.data.displacementParameters = null;
12313
- node.data.displacementTexture.destroy();
12314
- node.data.displacementTexture = null;
12315
- node.data.displacementComposition.destroy();
12316
- node.data.displacementComposition = null;
12314
+ function destroy4(node2) {
12315
+ node2.data.trianglesBuffer.destroy();
12316
+ node2.data.trianglesBuffer = null;
12317
+ node2.data.displacementParameters.destroy();
12318
+ node2.data.displacementParameters = null;
12319
+ node2.data.displacementTexture.destroy();
12320
+ node2.data.displacementTexture = null;
12321
+ node2.data.displacementComposition.destroy();
12322
+ node2.data.displacementComposition = null;
12317
12323
  }
12318
12324
 
12319
12325
  // src/sprite/create-sprite-quads.js
@@ -12374,17 +12380,17 @@ var overlay_default2 = {
12374
12380
  onInit: async function(cobalt, options = {}) {
12375
12381
  return init6(cobalt, options);
12376
12382
  },
12377
- onRun: function(cobalt, node, webGpuCommandEncoder) {
12378
- draw6(cobalt, node, webGpuCommandEncoder);
12383
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
12384
+ draw6(cobalt, node2, webGpuCommandEncoder);
12379
12385
  },
12380
- onDestroy: function(cobalt, node) {
12381
- destroy5(node);
12386
+ onDestroy: function(cobalt, node2) {
12387
+ destroy5(node2);
12382
12388
  },
12383
- onResize: function(cobalt, node) {
12384
- _writeOverlayBuffer(cobalt, node);
12389
+ onResize: function(cobalt, node2) {
12390
+ _writeOverlayBuffer(cobalt, node2);
12385
12391
  },
12386
- onViewportPosition: function(cobalt, node) {
12387
- _writeOverlayBuffer(cobalt, node);
12392
+ onViewportPosition: function(cobalt, node2) {
12393
+ _writeOverlayBuffer(cobalt, node2);
12388
12394
  },
12389
12395
  // optional
12390
12396
  customFunctions: { ...public_api_exports }
@@ -12526,37 +12532,37 @@ async function init6(cobalt, nodeData) {
12526
12532
  dirty: false
12527
12533
  };
12528
12534
  }
12529
- function draw6(cobalt, node, commandEncoder) {
12535
+ function draw6(cobalt, node2, commandEncoder) {
12530
12536
  const { device } = cobalt;
12531
- const loadOp = node.options.loadOp || "load";
12532
- if (node.data.dirty) {
12533
- _rebuildSpriteDrawCalls2(node.data);
12534
- node.data.dirty = false;
12537
+ const loadOp = node2.options.loadOp || "load";
12538
+ if (node2.data.dirty) {
12539
+ _rebuildSpriteDrawCalls2(node2.data);
12540
+ node2.data.dirty = false;
12535
12541
  }
12536
- if (node.data.spriteCount > 0) {
12537
- const writeLength = node.data.spriteCount * FLOAT32S_PER_SPRITE2 * Float32Array.BYTES_PER_ELEMENT;
12538
- device.queue.writeBuffer(node.data.spriteBuffer, 0, node.data.spriteData.buffer, 0, writeLength);
12542
+ if (node2.data.spriteCount > 0) {
12543
+ const writeLength = node2.data.spriteCount * FLOAT32S_PER_SPRITE2 * Float32Array.BYTES_PER_ELEMENT;
12544
+ device.queue.writeBuffer(node2.data.spriteBuffer, 0, node2.data.spriteData.buffer, 0, writeLength);
12539
12545
  }
12540
12546
  const renderpass = commandEncoder.beginRenderPass({
12541
12547
  label: "overlay",
12542
12548
  colorAttachments: [
12543
12549
  // color
12544
12550
  {
12545
- view: node.refs.color,
12551
+ view: node2.refs.color,
12546
12552
  clearValue: cobalt.clearValue,
12547
12553
  loadOp,
12548
12554
  storeOp: "store"
12549
12555
  }
12550
12556
  ]
12551
12557
  });
12552
- renderpass.setPipeline(node.data.pipeline);
12553
- renderpass.setBindGroup(0, node.data.bindGroup);
12554
- renderpass.setVertexBuffer(0, node.refs.spritesheet.data.quads.buffer);
12558
+ renderpass.setPipeline(node2.data.pipeline);
12559
+ renderpass.setBindGroup(0, node2.data.bindGroup);
12560
+ renderpass.setVertexBuffer(0, node2.refs.spritesheet.data.quads.buffer);
12555
12561
  const vertexCount = 6;
12556
12562
  let baseInstanceIdx = 0;
12557
- for (let i = 0; i < node.data.instancedDrawCallCount; i++) {
12558
- const baseVertexIdx = node.data.instancedDrawCalls[i * 2] * vertexCount;
12559
- const instanceCount = node.data.instancedDrawCalls[i * 2 + 1];
12563
+ for (let i = 0; i < node2.data.instancedDrawCallCount; i++) {
12564
+ const baseVertexIdx = node2.data.instancedDrawCalls[i * 2] * vertexCount;
12565
+ const instanceCount = node2.data.instancedDrawCalls[i * 2 + 1];
12560
12566
  renderpass.draw(vertexCount, instanceCount, baseVertexIdx, baseInstanceIdx);
12561
12567
  baseInstanceIdx += instanceCount;
12562
12568
  }
@@ -12622,18 +12628,18 @@ var fb_blit_default2 = {
12622
12628
  onInit: async function(cobalt, options = {}) {
12623
12629
  return init7(cobalt, options);
12624
12630
  },
12625
- onRun: function(cobalt, node, webGpuCommandEncoder) {
12626
- draw7(cobalt, node, webGpuCommandEncoder);
12631
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
12632
+ draw7(cobalt, node2, webGpuCommandEncoder);
12627
12633
  },
12628
- onDestroy: function(cobalt, node) {
12634
+ onDestroy: function(cobalt, node2) {
12629
12635
  },
12630
- onResize: function(cobalt, node) {
12631
- resize3(cobalt, node);
12636
+ onResize: function(cobalt, node2) {
12637
+ resize3(cobalt, node2);
12632
12638
  },
12633
- onViewportPosition: function(cobalt, node) {
12639
+ onViewportPosition: function(cobalt, node2) {
12634
12640
  }
12635
12641
  };
12636
- async function init7(cobalt, node) {
12642
+ async function init7(cobalt, node2) {
12637
12643
  const { device } = cobalt;
12638
12644
  const bindGroupLayout = device.createBindGroupLayout({
12639
12645
  entries: [
@@ -12654,11 +12660,11 @@ async function init7(cobalt, node) {
12654
12660
  entries: [
12655
12661
  {
12656
12662
  binding: 0,
12657
- resource: node.refs.in.data.view
12663
+ resource: node2.refs.in.data.view
12658
12664
  },
12659
12665
  {
12660
12666
  binding: 1,
12661
- resource: node.refs.in.data.sampler
12667
+ resource: node2.refs.in.data.sampler
12662
12668
  }
12663
12669
  ]
12664
12670
  });
@@ -12708,36 +12714,36 @@ async function init7(cobalt, node) {
12708
12714
  pipeline
12709
12715
  };
12710
12716
  }
12711
- function draw7(cobalt, node, commandEncoder) {
12717
+ function draw7(cobalt, node2, commandEncoder) {
12712
12718
  const { device } = cobalt;
12713
12719
  const renderpass = commandEncoder.beginRenderPass({
12714
12720
  label: "fb-blit",
12715
12721
  colorAttachments: [
12716
12722
  {
12717
- view: node.refs.out,
12723
+ view: node2.refs.out,
12718
12724
  clearValue: cobalt.clearValue,
12719
12725
  loadOp: "load",
12720
12726
  storeOp: "store"
12721
12727
  }
12722
12728
  ]
12723
12729
  });
12724
- renderpass.setPipeline(node.data.pipeline);
12725
- renderpass.setBindGroup(0, node.data.bindGroup);
12730
+ renderpass.setPipeline(node2.data.pipeline);
12731
+ renderpass.setBindGroup(0, node2.data.bindGroup);
12726
12732
  renderpass.draw(3);
12727
12733
  renderpass.end();
12728
12734
  }
12729
- function resize3(cobalt, node) {
12735
+ function resize3(cobalt, node2) {
12730
12736
  const { device } = cobalt;
12731
- node.data.bindGroup = device.createBindGroup({
12732
- layout: node.data.bindGroupLayout,
12737
+ node2.data.bindGroup = device.createBindGroup({
12738
+ layout: node2.data.bindGroupLayout,
12733
12739
  entries: [
12734
12740
  {
12735
12741
  binding: 0,
12736
- resource: node.refs.in.data.view
12742
+ resource: node2.refs.in.data.view
12737
12743
  },
12738
12744
  {
12739
12745
  binding: 1,
12740
- resource: node.refs.in.data.sampler
12746
+ resource: node2.refs.in.data.sampler
12741
12747
  }
12742
12748
  ]
12743
12749
  });
@@ -12794,66 +12800,66 @@ function polygonToPSLG(loops, options) {
12794
12800
  // src/primitives/public-api.js
12795
12801
  var public_api_default = {
12796
12802
  line,
12797
- save: function(cobalt, node) {
12798
- node.data.transforms.push(mat3.clone(node.data.transforms.at(-1)));
12803
+ save: function(cobalt, node2) {
12804
+ node2.data.transforms.push(mat3.clone(node2.data.transforms.at(-1)));
12799
12805
  },
12800
- restore: function(cobalt, node) {
12801
- if (node.data.transforms.length > 1)
12802
- node.data.transforms.pop();
12806
+ restore: function(cobalt, node2) {
12807
+ if (node2.data.transforms.length > 1)
12808
+ node2.data.transforms.pop();
12803
12809
  },
12804
- translate: function(cobalt, node, translation) {
12805
- const m = node.data.transforms.at(-1);
12810
+ translate: function(cobalt, node2, translation) {
12811
+ const m = node2.data.transforms.at(-1);
12806
12812
  mat3.translate(m, translation, m);
12807
12813
  },
12808
- rotate: function(cobalt, node, radians) {
12809
- const m = node.data.transforms.at(-1);
12814
+ rotate: function(cobalt, node2, radians) {
12815
+ const m = node2.data.transforms.at(-1);
12810
12816
  mat3.rotate(m, radians, m);
12811
12817
  },
12812
- scale: function(cobalt, node, scale) {
12813
- const m = node.data.transforms.at(-1);
12818
+ scale: function(cobalt, node2, scale) {
12819
+ const m = node2.data.transforms.at(-1);
12814
12820
  mat3.scale(m, scale, m);
12815
12821
  },
12816
- strokePath: function(cobalt, node, segments, color, lineWidth = 1) {
12822
+ strokePath: function(cobalt, node2, segments, color, lineWidth = 1) {
12817
12823
  for (const s of segments)
12818
- line(cobalt, node, s[0], s[1], color, lineWidth);
12824
+ line(cobalt, node2, s[0], s[1], color, lineWidth);
12819
12825
  },
12820
- filledPath: function(cobalt, node, points, color) {
12826
+ filledPath: function(cobalt, node2, points, color) {
12821
12827
  const pslg = polygonToPSLG(points);
12822
12828
  const triangles = (0, import_cdt2d.default)(pslg.points, pslg.edges, { exterior: false });
12823
- const m = node.data.transforms.at(-1);
12824
- let i = node.data.vertexCount * 6;
12825
- const currentElementCount = node.data.vertexCount * 6;
12829
+ const m = node2.data.transforms.at(-1);
12830
+ let i = node2.data.vertexCount * 6;
12831
+ const currentElementCount = node2.data.vertexCount * 6;
12826
12832
  const floatsToAdd = triangles.length * 3 * 6;
12827
- node.data.vertices = handleArrayResize(Float32Array, node.data.vertices, currentElementCount, floatsToAdd);
12833
+ node2.data.vertices = handleArrayResize(Float32Array, node2.data.vertices, currentElementCount, floatsToAdd);
12828
12834
  const pos = vec2.create();
12829
12835
  for (const tri of triangles) {
12830
12836
  vec2.transformMat3(points[tri[0]], m, pos);
12831
- node.data.vertices[i + 0] = pos[0];
12832
- node.data.vertices[i + 1] = pos[1];
12833
- node.data.vertices[i + 2] = color[0];
12834
- node.data.vertices[i + 3] = color[1];
12835
- node.data.vertices[i + 4] = color[2];
12836
- node.data.vertices[i + 5] = color[3];
12837
+ node2.data.vertices[i + 0] = pos[0];
12838
+ node2.data.vertices[i + 1] = pos[1];
12839
+ node2.data.vertices[i + 2] = color[0];
12840
+ node2.data.vertices[i + 3] = color[1];
12841
+ node2.data.vertices[i + 4] = color[2];
12842
+ node2.data.vertices[i + 5] = color[3];
12837
12843
  vec2.transformMat3(points[tri[1]], m, pos);
12838
- node.data.vertices[i + 6] = pos[0];
12839
- node.data.vertices[i + 7] = pos[1];
12840
- node.data.vertices[i + 8] = color[0];
12841
- node.data.vertices[i + 9] = color[1];
12842
- node.data.vertices[i + 10] = color[2];
12843
- node.data.vertices[i + 11] = color[3];
12844
+ node2.data.vertices[i + 6] = pos[0];
12845
+ node2.data.vertices[i + 7] = pos[1];
12846
+ node2.data.vertices[i + 8] = color[0];
12847
+ node2.data.vertices[i + 9] = color[1];
12848
+ node2.data.vertices[i + 10] = color[2];
12849
+ node2.data.vertices[i + 11] = color[3];
12844
12850
  vec2.transformMat3(points[tri[2]], m, pos);
12845
- node.data.vertices[i + 12] = pos[0];
12846
- node.data.vertices[i + 13] = pos[1];
12847
- node.data.vertices[i + 14] = color[0];
12848
- node.data.vertices[i + 15] = color[1];
12849
- node.data.vertices[i + 16] = color[2];
12850
- node.data.vertices[i + 17] = color[3];
12851
+ node2.data.vertices[i + 12] = pos[0];
12852
+ node2.data.vertices[i + 13] = pos[1];
12853
+ node2.data.vertices[i + 14] = color[0];
12854
+ node2.data.vertices[i + 15] = color[1];
12855
+ node2.data.vertices[i + 16] = color[2];
12856
+ node2.data.vertices[i + 17] = color[3];
12851
12857
  i += 18;
12852
12858
  }
12853
- node.data.vertexCount += 3 * triangles.length;
12854
- node.data.dirty = true;
12859
+ node2.data.vertexCount += 3 * triangles.length;
12860
+ node2.data.dirty = true;
12855
12861
  },
12856
- ellipse: function(cobalt, node, center, halfWidth, halfHeight, numSegments, color, lineWidth = 1) {
12862
+ ellipse: function(cobalt, node2, center, halfWidth, halfHeight, numSegments, color, lineWidth = 1) {
12857
12863
  const [x, y] = center;
12858
12864
  const deltaAngle = 2 * Math.PI / numSegments;
12859
12865
  for (let i = 0; i < numSegments; i++) {
@@ -12863,16 +12869,16 @@ var public_api_default = {
12863
12869
  const currY = y + halfHeight * Math.sin(angle);
12864
12870
  const nextX = x + halfWidth * Math.cos(nextAngle);
12865
12871
  const nextY = y + halfHeight * Math.sin(nextAngle);
12866
- line(cobalt, node, [currX, currY], [nextX, nextY], color, lineWidth);
12872
+ line(cobalt, node2, [currX, currY], [nextX, nextY], color, lineWidth);
12867
12873
  }
12868
12874
  },
12869
- filledEllipse: function(cobalt, node, center, halfWidth, halfHeight, numSegments, color) {
12875
+ filledEllipse: function(cobalt, node2, center, halfWidth, halfHeight, numSegments, color) {
12870
12876
  const [x, y] = center;
12871
12877
  const deltaAngle = 2 * Math.PI / numSegments;
12872
- const currentElementCount = node.data.vertexCount * 6;
12878
+ const currentElementCount = node2.data.vertexCount * 6;
12873
12879
  const floatsToAdd = numSegments * 3 * 6;
12874
- node.data.vertices = handleArrayResize(Float32Array, node.data.vertices, currentElementCount, floatsToAdd);
12875
- const m = node.data.transforms.at(-1);
12880
+ node2.data.vertices = handleArrayResize(Float32Array, node2.data.vertices, currentElementCount, floatsToAdd);
12881
+ const m = node2.data.transforms.at(-1);
12876
12882
  for (let i = 0; i < numSegments; i++) {
12877
12883
  const angle = i * deltaAngle;
12878
12884
  const nextAngle = (i + 1) * deltaAngle;
@@ -12881,33 +12887,33 @@ var public_api_default = {
12881
12887
  const nextX = x + halfWidth * Math.cos(nextAngle);
12882
12888
  const nextY = y + halfHeight * Math.sin(nextAngle);
12883
12889
  const stride = 18;
12884
- const vi = node.data.vertexCount * 6 + i * stride;
12890
+ const vi = node2.data.vertexCount * 6 + i * stride;
12885
12891
  const pos = vec2.transformMat3([x, y], m);
12886
- node.data.vertices[vi + 0] = pos[0];
12887
- node.data.vertices[vi + 1] = pos[1];
12888
- node.data.vertices[vi + 2] = color[0];
12889
- node.data.vertices[vi + 3] = color[1];
12890
- node.data.vertices[vi + 4] = color[2];
12891
- node.data.vertices[vi + 5] = color[3];
12892
+ node2.data.vertices[vi + 0] = pos[0];
12893
+ node2.data.vertices[vi + 1] = pos[1];
12894
+ node2.data.vertices[vi + 2] = color[0];
12895
+ node2.data.vertices[vi + 3] = color[1];
12896
+ node2.data.vertices[vi + 4] = color[2];
12897
+ node2.data.vertices[vi + 5] = color[3];
12892
12898
  vec2.transformMat3([currX, currY], m, pos);
12893
- node.data.vertices[vi + 6] = pos[0];
12894
- node.data.vertices[vi + 7] = pos[1];
12895
- node.data.vertices[vi + 8] = color[0];
12896
- node.data.vertices[vi + 9] = color[1];
12897
- node.data.vertices[vi + 10] = color[2];
12898
- node.data.vertices[vi + 11] = color[3];
12899
+ node2.data.vertices[vi + 6] = pos[0];
12900
+ node2.data.vertices[vi + 7] = pos[1];
12901
+ node2.data.vertices[vi + 8] = color[0];
12902
+ node2.data.vertices[vi + 9] = color[1];
12903
+ node2.data.vertices[vi + 10] = color[2];
12904
+ node2.data.vertices[vi + 11] = color[3];
12899
12905
  vec2.transformMat3([nextX, nextY], m, pos);
12900
- node.data.vertices[vi + 12] = pos[0];
12901
- node.data.vertices[vi + 13] = pos[1];
12902
- node.data.vertices[vi + 14] = color[0];
12903
- node.data.vertices[vi + 15] = color[1];
12904
- node.data.vertices[vi + 16] = color[2];
12905
- node.data.vertices[vi + 17] = color[3];
12906
- }
12907
- node.data.vertexCount += 3 * numSegments;
12908
- node.data.dirty = true;
12906
+ node2.data.vertices[vi + 12] = pos[0];
12907
+ node2.data.vertices[vi + 13] = pos[1];
12908
+ node2.data.vertices[vi + 14] = color[0];
12909
+ node2.data.vertices[vi + 15] = color[1];
12910
+ node2.data.vertices[vi + 16] = color[2];
12911
+ node2.data.vertices[vi + 17] = color[3];
12912
+ }
12913
+ node2.data.vertexCount += 3 * numSegments;
12914
+ node2.data.dirty = true;
12909
12915
  },
12910
- box: function(cobalt, node, center, width, height, color, lineWidth = 1) {
12916
+ box: function(cobalt, node2, center, width, height, color, lineWidth = 1) {
12911
12917
  const [x, y] = center;
12912
12918
  const halfWidth = width / 2;
12913
12919
  const halfHeight = height / 2;
@@ -12915,120 +12921,120 @@ var public_api_default = {
12915
12921
  const topRight = [x + halfWidth, y - halfHeight];
12916
12922
  const bottomLeft = [x - halfWidth, y + halfHeight];
12917
12923
  const bottomRight = [x + halfWidth, y + halfHeight];
12918
- line(cobalt, node, topLeft, topRight, color, lineWidth);
12919
- line(cobalt, node, bottomLeft, bottomRight, color, lineWidth);
12920
- line(cobalt, node, topLeft, bottomLeft, color, lineWidth);
12921
- line(cobalt, node, topRight, bottomRight, color, lineWidth);
12924
+ line(cobalt, node2, topLeft, topRight, color, lineWidth);
12925
+ line(cobalt, node2, bottomLeft, bottomRight, color, lineWidth);
12926
+ line(cobalt, node2, topLeft, bottomLeft, color, lineWidth);
12927
+ line(cobalt, node2, topRight, bottomRight, color, lineWidth);
12922
12928
  },
12923
- filledBox: function(cobalt, node, center, width, height, color) {
12929
+ filledBox: function(cobalt, node2, center, width, height, color) {
12924
12930
  const [x, y] = center;
12925
12931
  const halfWidth = width / 2;
12926
12932
  const halfHeight = height / 2;
12927
- const m = node.data.transforms.at(-1);
12933
+ const m = node2.data.transforms.at(-1);
12928
12934
  const topLeft = vec2.transformMat3([x - halfWidth, y - halfHeight], m);
12929
12935
  const topRight = vec2.transformMat3([x + halfWidth, y - halfHeight], m);
12930
12936
  const bottomLeft = vec2.transformMat3([x - halfWidth, y + halfHeight], m);
12931
12937
  const bottomRight = vec2.transformMat3([x + halfWidth, y + halfHeight], m);
12932
- const currentElementCount = node.data.vertexCount * 6;
12938
+ const currentElementCount = node2.data.vertexCount * 6;
12933
12939
  const floatsToAdd = 6 * 6;
12934
- node.data.vertices = handleArrayResize(Float32Array, node.data.vertices, currentElementCount, floatsToAdd);
12935
- let i = node.data.vertexCount * 6;
12936
- node.data.vertices[i + 0] = topLeft[0];
12937
- node.data.vertices[i + 1] = topLeft[1];
12938
- node.data.vertices[i + 2] = color[0];
12939
- node.data.vertices[i + 3] = color[1];
12940
- node.data.vertices[i + 4] = color[2];
12941
- node.data.vertices[i + 5] = color[3];
12942
- node.data.vertices[i + 6] = bottomLeft[0];
12943
- node.data.vertices[i + 7] = bottomLeft[1];
12944
- node.data.vertices[i + 8] = color[0];
12945
- node.data.vertices[i + 9] = color[1];
12946
- node.data.vertices[i + 10] = color[2];
12947
- node.data.vertices[i + 11] = color[3];
12948
- node.data.vertices[i + 12] = topRight[0];
12949
- node.data.vertices[i + 13] = topRight[1];
12950
- node.data.vertices[i + 14] = color[0];
12951
- node.data.vertices[i + 15] = color[1];
12952
- node.data.vertices[i + 16] = color[2];
12953
- node.data.vertices[i + 17] = color[3];
12954
- node.data.vertices[i + 18] = bottomLeft[0];
12955
- node.data.vertices[i + 19] = bottomLeft[1];
12956
- node.data.vertices[i + 20] = color[0];
12957
- node.data.vertices[i + 21] = color[1];
12958
- node.data.vertices[i + 22] = color[2];
12959
- node.data.vertices[i + 23] = color[3];
12960
- node.data.vertices[i + 24] = bottomRight[0];
12961
- node.data.vertices[i + 25] = bottomRight[1];
12962
- node.data.vertices[i + 26] = color[0];
12963
- node.data.vertices[i + 27] = color[1];
12964
- node.data.vertices[i + 28] = color[2];
12965
- node.data.vertices[i + 29] = color[3];
12966
- node.data.vertices[i + 30] = topRight[0];
12967
- node.data.vertices[i + 31] = topRight[1];
12968
- node.data.vertices[i + 32] = color[0];
12969
- node.data.vertices[i + 33] = color[1];
12970
- node.data.vertices[i + 34] = color[2];
12971
- node.data.vertices[i + 35] = color[3];
12972
- node.data.vertexCount += 6;
12973
- node.data.dirty = true;
12940
+ node2.data.vertices = handleArrayResize(Float32Array, node2.data.vertices, currentElementCount, floatsToAdd);
12941
+ let i = node2.data.vertexCount * 6;
12942
+ node2.data.vertices[i + 0] = topLeft[0];
12943
+ node2.data.vertices[i + 1] = topLeft[1];
12944
+ node2.data.vertices[i + 2] = color[0];
12945
+ node2.data.vertices[i + 3] = color[1];
12946
+ node2.data.vertices[i + 4] = color[2];
12947
+ node2.data.vertices[i + 5] = color[3];
12948
+ node2.data.vertices[i + 6] = bottomLeft[0];
12949
+ node2.data.vertices[i + 7] = bottomLeft[1];
12950
+ node2.data.vertices[i + 8] = color[0];
12951
+ node2.data.vertices[i + 9] = color[1];
12952
+ node2.data.vertices[i + 10] = color[2];
12953
+ node2.data.vertices[i + 11] = color[3];
12954
+ node2.data.vertices[i + 12] = topRight[0];
12955
+ node2.data.vertices[i + 13] = topRight[1];
12956
+ node2.data.vertices[i + 14] = color[0];
12957
+ node2.data.vertices[i + 15] = color[1];
12958
+ node2.data.vertices[i + 16] = color[2];
12959
+ node2.data.vertices[i + 17] = color[3];
12960
+ node2.data.vertices[i + 18] = bottomLeft[0];
12961
+ node2.data.vertices[i + 19] = bottomLeft[1];
12962
+ node2.data.vertices[i + 20] = color[0];
12963
+ node2.data.vertices[i + 21] = color[1];
12964
+ node2.data.vertices[i + 22] = color[2];
12965
+ node2.data.vertices[i + 23] = color[3];
12966
+ node2.data.vertices[i + 24] = bottomRight[0];
12967
+ node2.data.vertices[i + 25] = bottomRight[1];
12968
+ node2.data.vertices[i + 26] = color[0];
12969
+ node2.data.vertices[i + 27] = color[1];
12970
+ node2.data.vertices[i + 28] = color[2];
12971
+ node2.data.vertices[i + 29] = color[3];
12972
+ node2.data.vertices[i + 30] = topRight[0];
12973
+ node2.data.vertices[i + 31] = topRight[1];
12974
+ node2.data.vertices[i + 32] = color[0];
12975
+ node2.data.vertices[i + 33] = color[1];
12976
+ node2.data.vertices[i + 34] = color[2];
12977
+ node2.data.vertices[i + 35] = color[3];
12978
+ node2.data.vertexCount += 6;
12979
+ node2.data.dirty = true;
12974
12980
  },
12975
- clear: function(cobalt, node) {
12976
- node.data.vertexCount = 0;
12977
- node.data.transforms.length = 1;
12978
- mat3.identity(node.data.transforms[0]);
12979
- node.data.dirty = true;
12981
+ clear: function(cobalt, node2) {
12982
+ node2.data.vertexCount = 0;
12983
+ node2.data.transforms.length = 1;
12984
+ mat3.identity(node2.data.transforms[0]);
12985
+ node2.data.dirty = true;
12980
12986
  }
12981
12987
  };
12982
- function line(cobalt, node, start, end, color, lineWidth = 1) {
12983
- const m = node.data.transforms.at(-1);
12988
+ function line(cobalt, node2, start, end, color, lineWidth = 1) {
12989
+ const m = node2.data.transforms.at(-1);
12984
12990
  start = vec2.transformMat3(start, m);
12985
12991
  end = vec2.transformMat3(end, m);
12986
12992
  const delta = vec2.sub(end, start);
12987
12993
  const unitBasis = vec2.normalize(delta);
12988
12994
  const perp = perpendicularComponent(unitBasis);
12989
12995
  const halfLineWidth = lineWidth / 2;
12990
- let i = node.data.vertexCount * 6;
12991
- const currentElementCount = node.data.vertexCount * 6;
12996
+ let i = node2.data.vertexCount * 6;
12997
+ const currentElementCount = node2.data.vertexCount * 6;
12992
12998
  const floatsToAdd = 6 * 6;
12993
- node.data.vertices = handleArrayResize(Float32Array, node.data.vertices, currentElementCount, floatsToAdd);
12994
- node.data.vertices[i + 0] = start[0] + perp[0] * halfLineWidth;
12995
- node.data.vertices[i + 1] = start[1] + perp[1] * halfLineWidth;
12996
- node.data.vertices[i + 2] = color[0];
12997
- node.data.vertices[i + 3] = color[1];
12998
- node.data.vertices[i + 4] = color[2];
12999
- node.data.vertices[i + 5] = color[3];
13000
- node.data.vertices[i + 6] = start[0] - perp[0] * halfLineWidth;
13001
- node.data.vertices[i + 7] = start[1] - perp[1] * halfLineWidth;
13002
- node.data.vertices[i + 8] = color[0];
13003
- node.data.vertices[i + 9] = color[1];
13004
- node.data.vertices[i + 10] = color[2];
13005
- node.data.vertices[i + 11] = color[3];
13006
- node.data.vertices[i + 12] = end[0] + perp[0] * halfLineWidth;
13007
- node.data.vertices[i + 13] = end[1] + perp[1] * halfLineWidth;
13008
- node.data.vertices[i + 14] = color[0];
13009
- node.data.vertices[i + 15] = color[1];
13010
- node.data.vertices[i + 16] = color[2];
13011
- node.data.vertices[i + 17] = color[3];
13012
- node.data.vertices[i + 18] = start[0] - perp[0] * halfLineWidth;
13013
- node.data.vertices[i + 19] = start[1] - perp[1] * halfLineWidth;
13014
- node.data.vertices[i + 20] = color[0];
13015
- node.data.vertices[i + 21] = color[1];
13016
- node.data.vertices[i + 22] = color[2];
13017
- node.data.vertices[i + 23] = color[3];
13018
- node.data.vertices[i + 24] = end[0] + perp[0] * halfLineWidth;
13019
- node.data.vertices[i + 25] = end[1] + perp[1] * halfLineWidth;
13020
- node.data.vertices[i + 26] = color[0];
13021
- node.data.vertices[i + 27] = color[1];
13022
- node.data.vertices[i + 28] = color[2];
13023
- node.data.vertices[i + 29] = color[3];
13024
- node.data.vertices[i + 30] = end[0] - perp[0] * halfLineWidth;
13025
- node.data.vertices[i + 31] = end[1] - perp[1] * halfLineWidth;
13026
- node.data.vertices[i + 32] = color[0];
13027
- node.data.vertices[i + 33] = color[1];
13028
- node.data.vertices[i + 34] = color[2];
13029
- node.data.vertices[i + 35] = color[3];
13030
- node.data.vertexCount += 6;
13031
- node.data.dirty = true;
12999
+ node2.data.vertices = handleArrayResize(Float32Array, node2.data.vertices, currentElementCount, floatsToAdd);
13000
+ node2.data.vertices[i + 0] = start[0] + perp[0] * halfLineWidth;
13001
+ node2.data.vertices[i + 1] = start[1] + perp[1] * halfLineWidth;
13002
+ node2.data.vertices[i + 2] = color[0];
13003
+ node2.data.vertices[i + 3] = color[1];
13004
+ node2.data.vertices[i + 4] = color[2];
13005
+ node2.data.vertices[i + 5] = color[3];
13006
+ node2.data.vertices[i + 6] = start[0] - perp[0] * halfLineWidth;
13007
+ node2.data.vertices[i + 7] = start[1] - perp[1] * halfLineWidth;
13008
+ node2.data.vertices[i + 8] = color[0];
13009
+ node2.data.vertices[i + 9] = color[1];
13010
+ node2.data.vertices[i + 10] = color[2];
13011
+ node2.data.vertices[i + 11] = color[3];
13012
+ node2.data.vertices[i + 12] = end[0] + perp[0] * halfLineWidth;
13013
+ node2.data.vertices[i + 13] = end[1] + perp[1] * halfLineWidth;
13014
+ node2.data.vertices[i + 14] = color[0];
13015
+ node2.data.vertices[i + 15] = color[1];
13016
+ node2.data.vertices[i + 16] = color[2];
13017
+ node2.data.vertices[i + 17] = color[3];
13018
+ node2.data.vertices[i + 18] = start[0] - perp[0] * halfLineWidth;
13019
+ node2.data.vertices[i + 19] = start[1] - perp[1] * halfLineWidth;
13020
+ node2.data.vertices[i + 20] = color[0];
13021
+ node2.data.vertices[i + 21] = color[1];
13022
+ node2.data.vertices[i + 22] = color[2];
13023
+ node2.data.vertices[i + 23] = color[3];
13024
+ node2.data.vertices[i + 24] = end[0] + perp[0] * halfLineWidth;
13025
+ node2.data.vertices[i + 25] = end[1] + perp[1] * halfLineWidth;
13026
+ node2.data.vertices[i + 26] = color[0];
13027
+ node2.data.vertices[i + 27] = color[1];
13028
+ node2.data.vertices[i + 28] = color[2];
13029
+ node2.data.vertices[i + 29] = color[3];
13030
+ node2.data.vertices[i + 30] = end[0] - perp[0] * halfLineWidth;
13031
+ node2.data.vertices[i + 31] = end[1] - perp[1] * halfLineWidth;
13032
+ node2.data.vertices[i + 32] = color[0];
13033
+ node2.data.vertices[i + 33] = color[1];
13034
+ node2.data.vertices[i + 34] = color[2];
13035
+ node2.data.vertices[i + 35] = color[3];
13036
+ node2.data.vertexCount += 6;
13037
+ node2.data.dirty = true;
13032
13038
  }
13033
13039
  function handleArrayResize(ArrayType, arr, currentElementCount, elementsToAdd) {
13034
13040
  if (currentElementCount + elementsToAdd <= arr.length)
@@ -13058,22 +13064,22 @@ var primitives_default2 = {
13058
13064
  onInit: async function(cobalt, options = {}) {
13059
13065
  return init8(cobalt, options);
13060
13066
  },
13061
- onRun: function(cobalt, node, webGpuCommandEncoder) {
13062
- draw8(cobalt, node, webGpuCommandEncoder);
13067
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
13068
+ draw8(cobalt, node2, webGpuCommandEncoder);
13063
13069
  },
13064
- onDestroy: function(cobalt, node) {
13065
- destroy6(node);
13070
+ onDestroy: function(cobalt, node2) {
13071
+ destroy6(node2);
13066
13072
  },
13067
- onResize: function(cobalt, node) {
13068
- _writeMatricesBuffer(cobalt, node);
13073
+ onResize: function(cobalt, node2) {
13074
+ _writeMatricesBuffer(cobalt, node2);
13069
13075
  },
13070
- onViewportPosition: function(cobalt, node) {
13071
- _writeMatricesBuffer(cobalt, node);
13076
+ onViewportPosition: function(cobalt, node2) {
13077
+ _writeMatricesBuffer(cobalt, node2);
13072
13078
  },
13073
13079
  // optional
13074
13080
  customFunctions: public_api_default
13075
13081
  };
13076
- async function init8(cobalt, node) {
13082
+ async function init8(cobalt, node2) {
13077
13083
  const { device } = cobalt;
13078
13084
  const vertices = new Float32Array(1024);
13079
13085
  const vertexBuffer = device.createBuffer({
@@ -13179,34 +13185,34 @@ async function init8(cobalt, node) {
13179
13185
  transforms: [mat3.identity()]
13180
13186
  };
13181
13187
  }
13182
- function draw8(cobalt, node, commandEncoder) {
13183
- if (node.data.vertexCount === 0)
13188
+ function draw8(cobalt, node2, commandEncoder) {
13189
+ if (node2.data.vertexCount === 0)
13184
13190
  return;
13185
13191
  const { device } = cobalt;
13186
- if (node.data.dirty) {
13187
- node.data.dirty = false;
13192
+ if (node2.data.dirty) {
13193
+ node2.data.dirty = false;
13188
13194
  const stride = 6 * Float32Array.BYTES_PER_ELEMENT;
13189
- if (node.data.vertices.buffer.byteLength > node.data.vertexBuffer.size) {
13190
- node.data.vertexBuffer.destroy();
13191
- node.data.vertexBuffer = device.createBuffer({
13192
- size: node.data.vertices.byteLength,
13195
+ if (node2.data.vertices.buffer.byteLength > node2.data.vertexBuffer.size) {
13196
+ node2.data.vertexBuffer.destroy();
13197
+ node2.data.vertexBuffer = device.createBuffer({
13198
+ size: node2.data.vertices.byteLength,
13193
13199
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
13194
13200
  });
13195
13201
  }
13196
- let byteCount = node.data.vertexCount * stride;
13197
- if (byteCount > node.data.vertexBuffer.size) {
13202
+ let byteCount = node2.data.vertexCount * stride;
13203
+ if (byteCount > node2.data.vertexBuffer.size) {
13198
13204
  console.error("too many primitives, bailing");
13199
13205
  return;
13200
13206
  }
13201
- cobalt.device.queue.writeBuffer(node.data.vertexBuffer, 0, node.data.vertices.buffer, 0, byteCount);
13207
+ cobalt.device.queue.writeBuffer(node2.data.vertexBuffer, 0, node2.data.vertices.buffer, 0, byteCount);
13202
13208
  }
13203
- const loadOp = node.options.loadOp || "load";
13209
+ const loadOp = node2.options.loadOp || "load";
13204
13210
  const renderpass = commandEncoder.beginRenderPass({
13205
13211
  label: "primitives",
13206
13212
  colorAttachments: [
13207
13213
  // color
13208
13214
  {
13209
- view: node.refs.color,
13215
+ view: node2.refs.color,
13210
13216
  //node.refs.color.data.view,
13211
13217
  clearValue: cobalt.clearValue,
13212
13218
  loadOp,
@@ -13214,28 +13220,28 @@ function draw8(cobalt, node, commandEncoder) {
13214
13220
  }
13215
13221
  ]
13216
13222
  });
13217
- renderpass.setPipeline(node.data.pipeline);
13218
- renderpass.setBindGroup(0, node.data.bindGroup);
13219
- renderpass.setVertexBuffer(0, node.data.vertexBuffer);
13220
- renderpass.draw(node.data.vertexCount);
13223
+ renderpass.setPipeline(node2.data.pipeline);
13224
+ renderpass.setBindGroup(0, node2.data.bindGroup);
13225
+ renderpass.setVertexBuffer(0, node2.data.vertexBuffer);
13226
+ renderpass.draw(node2.data.vertexCount);
13221
13227
  renderpass.end();
13222
13228
  }
13223
- function destroy6(node) {
13224
- node.data.vertexBuffer.destroy();
13225
- node.data.vertexBuffer = null;
13226
- node.data.uniformBuffer.destroy();
13227
- node.data.uniformBuffer = null;
13228
- node.data.transforms.length = 0;
13229
+ function destroy6(node2) {
13230
+ node2.data.vertexBuffer.destroy();
13231
+ node2.data.vertexBuffer = null;
13232
+ node2.data.uniformBuffer.destroy();
13233
+ node2.data.uniformBuffer = null;
13234
+ node2.data.transforms.length = 0;
13229
13235
  }
13230
- function _writeMatricesBuffer(cobalt, node) {
13236
+ function _writeMatricesBuffer(cobalt, node2) {
13231
13237
  const { device } = cobalt;
13232
13238
  const GAME_WIDTH = cobalt.viewport.width / cobalt.viewport.zoom;
13233
13239
  const GAME_HEIGHT = cobalt.viewport.height / cobalt.viewport.zoom;
13234
13240
  const projection = mat4.ortho(0, GAME_WIDTH, GAME_HEIGHT, 0, -10, 10);
13235
13241
  vec3.set(-cobalt.viewport.position[0] - 1, -cobalt.viewport.position[1] - 1, 0, _tmpVec32);
13236
13242
  const view = mat4.translation(_tmpVec32);
13237
- device.queue.writeBuffer(node.data.uniformBuffer, 0, view.buffer);
13238
- device.queue.writeBuffer(node.data.uniformBuffer, 64, projection.buffer);
13243
+ device.queue.writeBuffer(node2.data.uniformBuffer, 0, view.buffer);
13244
+ device.queue.writeBuffer(node2.data.uniformBuffer, 64, projection.buffer);
13239
13245
  }
13240
13246
 
13241
13247
  // src/light/public-api.js
@@ -13245,16 +13251,16 @@ __export(public_api_exports2, {
13245
13251
  setLights: () => setLights,
13246
13252
  setOccluders: () => setOccluders
13247
13253
  });
13248
- function setLights(cobalt, node, lights) {
13249
- node.data.lights = lights;
13250
- node.data.lightsBufferNeedsUpdate = true;
13254
+ function setLights(cobalt, node2, lights) {
13255
+ node2.data.lights = lights;
13256
+ node2.data.lightsBufferNeedsUpdate = true;
13251
13257
  }
13252
- function setAmbientLight(cobalt, node, color) {
13253
- node.data.lightsRenderer.setAmbientLight(color);
13258
+ function setAmbientLight(cobalt, node2, color) {
13259
+ node2.data.lightsRenderer.setAmbientLight(color);
13254
13260
  }
13255
- function setOccluders(cobalt, node, segmentsList) {
13256
- node.data.lightsRenderer.setObstacles(segmentsList);
13257
- node.data.lightsTextureNeedsUpdate = true;
13261
+ function setOccluders(cobalt, node2, segmentsList) {
13262
+ node2.data.lightsRenderer.setObstacles(segmentsList);
13263
+ node2.data.lightsTextureNeedsUpdate = true;
13258
13264
  }
13259
13265
 
13260
13266
  // src/light/viewport.ts
@@ -14120,24 +14126,24 @@ var light_default = {
14120
14126
  onInit: async function(cobalt, options = {}) {
14121
14127
  return init9(cobalt, options);
14122
14128
  },
14123
- onRun: function(cobalt, node, webGpuCommandEncoder) {
14124
- draw9(cobalt, node, webGpuCommandEncoder);
14129
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
14130
+ draw9(cobalt, node2, webGpuCommandEncoder);
14125
14131
  },
14126
- onDestroy: function(cobalt, node) {
14127
- destroy7(node);
14132
+ onDestroy: function(cobalt, node2) {
14133
+ destroy7(node2);
14128
14134
  },
14129
- onResize: function(cobalt, node) {
14130
- resize4(cobalt, node);
14135
+ onResize: function(cobalt, node2) {
14136
+ resize4(cobalt, node2);
14131
14137
  },
14132
- onViewportPosition: function(cobalt, node) {
14133
- node.data.viewport.setTopLeft(...cobalt.viewport.position);
14138
+ onViewportPosition: function(cobalt, node2) {
14139
+ node2.data.viewport.setTopLeft(...cobalt.viewport.position);
14134
14140
  },
14135
14141
  // optional
14136
14142
  customFunctions: {
14137
14143
  ...public_api_exports2
14138
14144
  }
14139
14145
  };
14140
- async function init9(cobalt, node) {
14146
+ async function init9(cobalt, node2) {
14141
14147
  const { device } = cobalt;
14142
14148
  const MAX_LIGHT_COUNT = 256;
14143
14149
  const MAX_LIGHT_SIZE = 256;
@@ -14153,10 +14159,10 @@ async function init9(cobalt, node) {
14153
14159
  const lightsRenderer = new LightsRenderer({
14154
14160
  device,
14155
14161
  albedo: {
14156
- view: node.refs.in.data.view,
14157
- sampler: node.refs.in.data.sampler
14162
+ view: node2.refs.in.data.view,
14163
+ sampler: node2.refs.in.data.sampler
14158
14164
  },
14159
- targetTexture: node.refs.out.data.texture,
14165
+ targetTexture: node2.refs.out.data.texture,
14160
14166
  lightsBuffer,
14161
14167
  lightsTextureProperties: {
14162
14168
  resolutionPerLight: MAX_LIGHT_SIZE,
@@ -14175,44 +14181,44 @@ async function init9(cobalt, node) {
14175
14181
  lights: []
14176
14182
  };
14177
14183
  }
14178
- function draw9(cobalt, node, commandEncoder) {
14179
- if (node.data.lightsBufferNeedsUpdate) {
14180
- const lightsBuffer = node.data.lightsBuffer;
14181
- lightsBuffer.setLights(node.data.lights);
14182
- node.data.lightsBufferNeedsUpdate = false;
14183
- node.data.lightsTextureNeedsUpdate = true;
14184
- }
14185
- const lightsRenderer = node.data.lightsRenderer;
14186
- if (node.data.lightsTextureNeedsUpdate) {
14184
+ function draw9(cobalt, node2, commandEncoder) {
14185
+ if (node2.data.lightsBufferNeedsUpdate) {
14186
+ const lightsBuffer = node2.data.lightsBuffer;
14187
+ lightsBuffer.setLights(node2.data.lights);
14188
+ node2.data.lightsBufferNeedsUpdate = false;
14189
+ node2.data.lightsTextureNeedsUpdate = true;
14190
+ }
14191
+ const lightsRenderer = node2.data.lightsRenderer;
14192
+ if (node2.data.lightsTextureNeedsUpdate) {
14187
14193
  lightsRenderer.computeLightsTexture(commandEncoder);
14188
- node.data.lightsTextureNeedsUpdate = false;
14194
+ node2.data.lightsTextureNeedsUpdate = false;
14189
14195
  }
14190
14196
  const renderpass = commandEncoder.beginRenderPass({
14191
14197
  label: "light",
14192
14198
  colorAttachments: [
14193
14199
  {
14194
- view: node.refs.out.data.view,
14200
+ view: node2.refs.out.data.view,
14195
14201
  clearValue: cobalt.clearValue,
14196
14202
  loadOp: "load",
14197
14203
  storeOp: "store"
14198
14204
  }
14199
14205
  ]
14200
14206
  });
14201
- node.data.viewport.setZoom(cobalt.viewport.zoom);
14202
- const invertVpMatrix = node.data.viewport.invertViewProjectionMatrix;
14207
+ node2.data.viewport.setZoom(cobalt.viewport.zoom);
14208
+ const invertVpMatrix = node2.data.viewport.invertViewProjectionMatrix;
14203
14209
  lightsRenderer.render(renderpass, invertVpMatrix);
14204
14210
  renderpass.end();
14205
14211
  }
14206
- function destroy7(node) {
14207
- node.data.lightsBuffer.destroy();
14208
- node.data.lightsRenderer.destroy();
14212
+ function destroy7(node2) {
14213
+ node2.data.lightsBuffer.destroy();
14214
+ node2.data.lightsRenderer.destroy();
14209
14215
  }
14210
- function resize4(cobalt, node) {
14211
- node.data.lightsRenderer.setAlbedo({
14212
- view: node.refs.in.data.view,
14213
- sampler: node.refs.in.data.sampler
14216
+ function resize4(cobalt, node2) {
14217
+ node2.data.lightsRenderer.setAlbedo({
14218
+ view: node2.refs.in.data.view,
14219
+ sampler: node2.refs.in.data.sampler
14214
14220
  });
14215
- node.data.viewport.setViewportSize(cobalt.viewport.width, cobalt.viewport.height);
14221
+ node2.data.viewport.setViewportSize(cobalt.viewport.width, cobalt.viewport.height);
14216
14222
  }
14217
14223
 
14218
14224
  // src/tile/tile.wgsl
@@ -14228,16 +14234,16 @@ var atlas_default = {
14228
14234
  onInit: async function(cobalt, options = {}) {
14229
14235
  return init10(cobalt, options);
14230
14236
  },
14231
- onRun: function(cobalt, node, webGpuCommandEncoder) {
14237
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
14232
14238
  },
14233
- onDestroy: function(cobalt, node) {
14239
+ onDestroy: function(cobalt, node2) {
14234
14240
  destroy8(data);
14235
14241
  },
14236
- onResize: function(cobalt, node) {
14237
- _writeTileBuffer(cobalt, node);
14242
+ onResize: function(cobalt, node2) {
14243
+ _writeTileBuffer(cobalt, node2);
14238
14244
  },
14239
- onViewportPosition: function(cobalt, node) {
14240
- _writeTileBuffer(cobalt, node);
14245
+ onViewportPosition: function(cobalt, node2) {
14246
+ _writeTileBuffer(cobalt, node2);
14241
14247
  }
14242
14248
  };
14243
14249
  async function init10(cobalt, nodeData) {
@@ -14443,32 +14449,32 @@ var spritesheet_default = {
14443
14449
  onInit: async function(cobalt, options = {}) {
14444
14450
  return init11(cobalt, options);
14445
14451
  },
14446
- onRun: function(cobalt, node, webGpuCommandEncoder) {
14452
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
14447
14453
  },
14448
- onDestroy: function(cobalt, node) {
14449
- destroy9(node);
14454
+ onDestroy: function(cobalt, node2) {
14455
+ destroy9(node2);
14450
14456
  },
14451
- onResize: function(cobalt, node) {
14452
- _writeSpriteBuffer(cobalt, node);
14457
+ onResize: function(cobalt, node2) {
14458
+ _writeSpriteBuffer(cobalt, node2);
14453
14459
  },
14454
- onViewportPosition: function(cobalt, node) {
14455
- _writeSpriteBuffer(cobalt, node);
14460
+ onViewportPosition: function(cobalt, node2) {
14461
+ _writeSpriteBuffer(cobalt, node2);
14456
14462
  }
14457
14463
  };
14458
- async function init11(cobalt, node) {
14464
+ async function init11(cobalt, node2) {
14459
14465
  const { canvas, device } = cobalt;
14460
14466
  let spritesheet, colorTexture, emissiveTexture;
14461
14467
  const format = getPreferredFormat(cobalt);
14462
14468
  if (canvas) {
14463
- spritesheet = await fetchJson(node.options.spriteSheetJsonUrl);
14469
+ spritesheet = await fetchJson(node2.options.spriteSheetJsonUrl);
14464
14470
  spritesheet = readSpriteSheet(spritesheet);
14465
- colorTexture = await createTextureFromUrl(cobalt, "sprite", node.options.colorTextureUrl, format);
14466
- emissiveTexture = await createTextureFromUrl(cobalt, "emissive sprite", node.options.emissiveTextureUrl, format);
14471
+ colorTexture = await createTextureFromUrl(cobalt, "sprite", node2.options.colorTextureUrl, format);
14472
+ emissiveTexture = await createTextureFromUrl(cobalt, "emissive sprite", node2.options.emissiveTextureUrl, format);
14467
14473
  canvas.style.imageRendering = "pixelated";
14468
14474
  } else {
14469
- spritesheet = readSpriteSheet(node.options.spriteSheetJson);
14470
- colorTexture = await createTextureFromBuffer(cobalt, "sprite", node.options.colorTexture, format);
14471
- emissiveTexture = await createTextureFromBuffer(cobalt, "emissive sprite", node.options.emissiveTexture, format);
14475
+ spritesheet = readSpriteSheet(node2.options.spriteSheetJson);
14476
+ colorTexture = await createTextureFromBuffer(cobalt, "sprite", node2.options.colorTexture, format);
14477
+ emissiveTexture = await createTextureFromBuffer(cobalt, "emissive sprite", node2.options.emissiveTexture, format);
14472
14478
  }
14473
14479
  const quads = createSpriteQuads(device, spritesheet);
14474
14480
  const uniformBuffer = device.createBuffer({
@@ -14561,25 +14567,25 @@ async function init11(cobalt, node) {
14561
14567
  spritesheet
14562
14568
  };
14563
14569
  }
14564
- function destroy9(node) {
14565
- node.data.quads.buffer.destroy();
14566
- node.data.colorTexture.buffer.destroy();
14567
- node.data.uniformBuffer.destroy();
14568
- node.data.emissiveTexture.texture.destroy();
14570
+ function destroy9(node2) {
14571
+ node2.data.quads.buffer.destroy();
14572
+ node2.data.colorTexture.buffer.destroy();
14573
+ node2.data.uniformBuffer.destroy();
14574
+ node2.data.emissiveTexture.texture.destroy();
14569
14575
  }
14570
14576
  async function fetchJson(url) {
14571
14577
  const raw = await fetch(url);
14572
14578
  return raw.json();
14573
14579
  }
14574
- function _writeSpriteBuffer(cobalt, node) {
14580
+ function _writeSpriteBuffer(cobalt, node2) {
14575
14581
  const { device, viewport } = cobalt;
14576
14582
  const GAME_WIDTH = viewport.width / viewport.zoom;
14577
14583
  const GAME_HEIGHT = viewport.height / viewport.zoom;
14578
14584
  const projection = mat4.ortho(0, GAME_WIDTH, GAME_HEIGHT, 0, -10, 10);
14579
14585
  vec3.set(-viewport.position[0], -viewport.position[1], 0, _tmpVec33);
14580
14586
  const view = mat4.translation(_tmpVec33);
14581
- device.queue.writeBuffer(node.data.uniformBuffer, 0, view.buffer);
14582
- device.queue.writeBuffer(node.data.uniformBuffer, 64, projection.buffer);
14587
+ device.queue.writeBuffer(node2.data.uniformBuffer, 0, view.buffer);
14588
+ device.queue.writeBuffer(node2.data.uniformBuffer, 64, projection.buffer);
14583
14589
  }
14584
14590
 
14585
14591
  // src/fb-texture/fb-texture.js
@@ -14591,33 +14597,33 @@ var fb_texture_default = {
14591
14597
  onInit: async function(cobalt, options = {}) {
14592
14598
  return init12(cobalt, options);
14593
14599
  },
14594
- onRun: function(cobalt, node, webGpuCommandEncoder) {
14600
+ onRun: function(cobalt, node2, webGpuCommandEncoder) {
14595
14601
  },
14596
- onDestroy: function(cobalt, node) {
14602
+ onDestroy: function(cobalt, node2) {
14597
14603
  destroy10(data);
14598
14604
  },
14599
- onResize: function(cobalt, node) {
14600
- resize5(cobalt, node);
14605
+ onResize: function(cobalt, node2) {
14606
+ resize5(cobalt, node2);
14601
14607
  },
14602
- onViewportPosition: function(cobalt, node) {
14608
+ onViewportPosition: function(cobalt, node2) {
14603
14609
  }
14604
14610
  };
14605
- async function init12(cobalt, node) {
14611
+ async function init12(cobalt, node2) {
14606
14612
  const { device } = cobalt;
14607
- node.options.format = node.options.format === "PREFERRED_TEXTURE_FORMAT" ? getPreferredFormat(cobalt) : node.options.format;
14608
- const { format, label, mip_count, usage, viewportScale } = node.options;
14613
+ node2.options.format = node2.options.format === "PREFERRED_TEXTURE_FORMAT" ? getPreferredFormat(cobalt) : node2.options.format;
14614
+ const { format, label, mip_count, usage, viewportScale } = node2.options;
14609
14615
  return createTexture(device, label, cobalt.viewport.width * viewportScale, cobalt.viewport.height * viewportScale, mip_count, format, usage);
14610
14616
  }
14611
- function destroy10(node) {
14612
- node.data.texture.destroy();
14617
+ function destroy10(node2) {
14618
+ node2.data.texture.destroy();
14613
14619
  }
14614
- function resize5(cobalt, node) {
14620
+ function resize5(cobalt, node2) {
14615
14621
  const { device } = cobalt;
14616
- destroy10(node);
14622
+ destroy10(node2);
14617
14623
  const { width, height } = cobalt.viewport;
14618
- const { options } = node;
14619
- const scale = node.options.viewportScale;
14620
- node.data = createTexture(device, options.label, width * scale, height * scale, options.mip_count, options.format, options.usage);
14624
+ const { options } = node2;
14625
+ const scale = node2.options.viewportScale;
14626
+ node2.data = createTexture(device, options.label, width * scale, height * scale, options.mip_count, options.format, options.usage);
14621
14627
  }
14622
14628
 
14623
14629
  // src/cobalt.js
@@ -14694,7 +14700,7 @@ async function initNode(c, nodeData) {
14694
14700
  const nodeDef = c.nodeDefs[nodeData?.type];
14695
14701
  if (!nodeDef)
14696
14702
  throw new Error(`Can't initialize a new node missing a type.`);
14697
- const node = {
14703
+ const node2 = {
14698
14704
  type: nodeData.type,
14699
14705
  refs: nodeData.refs || {},
14700
14706
  options: nodeData.options || {},
@@ -14702,21 +14708,21 @@ async function initNode(c, nodeData) {
14702
14708
  enabled: true
14703
14709
  // when disabled, the node won't be run
14704
14710
  };
14705
- for (const refName in node.refs) {
14706
- if (node.refs[refName] === "FRAME_TEXTURE_VIEW") {
14707
- c.defaultTextureViewRefs.push({ node, refName });
14708
- node.refs[refName] = getCurrentTextureView(c);
14711
+ for (const refName in node2.refs) {
14712
+ if (node2.refs[refName] === "FRAME_TEXTURE_VIEW") {
14713
+ c.defaultTextureViewRefs.push({ node: node2, refName });
14714
+ node2.refs[refName] = getCurrentTextureView(c);
14709
14715
  }
14710
14716
  }
14711
- node.data = await nodeDef.onInit(c, node);
14717
+ node2.data = await nodeDef.onInit(c, node2);
14712
14718
  const customFunctions = nodeDef.customFunctions || {};
14713
14719
  for (const fnName in customFunctions) {
14714
- node[fnName] = function(...args) {
14715
- return customFunctions[fnName](c, node, ...args);
14720
+ node2[fnName] = function(...args) {
14721
+ return customFunctions[fnName](c, node2, ...args);
14716
14722
  };
14717
14723
  }
14718
- c.nodes.push(node);
14719
- return node;
14724
+ c.nodes.push(node2);
14725
+ return node2;
14720
14726
  }
14721
14727
  function draw10(c) {
14722
14728
  const { device, context } = c;
@@ -14724,11 +14730,11 @@ function draw10(c) {
14724
14730
  const v = getCurrentTextureView(c);
14725
14731
  for (const r of c.defaultTextureViewRefs)
14726
14732
  r.node.refs[r.refName] = v;
14727
- for (const node of c.nodes) {
14728
- if (!node.enabled)
14733
+ for (const node2 of c.nodes) {
14734
+ if (!node2.enabled)
14729
14735
  continue;
14730
- const nodeDef = c.nodeDefs[node.type];
14731
- nodeDef.onRun(c, node, commandEncoder);
14736
+ const nodeDef = c.nodeDefs[node2.type];
14737
+ nodeDef.onRun(c, node2, commandEncoder);
14732
14738
  }
14733
14739
  device.queue.submit([commandEncoder.finish()]);
14734
14740
  if (!c.canvas)