@footgun/cobalt 0.6.7 → 0.6.8

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