@footgun/cobalt 0.6.11 → 0.6.12

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/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ # 0.6.12
2
+ * fix mistype in tile node
3
+
4
+
1
5
  # 0.6.11
2
6
  * make tile, tileAtlas, spriteSheet nodes default to input textures with rgba8unorm
3
7
 
8
+
4
9
  # 0.6.10
5
10
  * bugfix in tile node setTexture function
6
11
 
package/bundle.js CHANGED
@@ -7370,7 +7370,7 @@ var bloom_default2 = {
7370
7370
  onViewportPosition: function(cobalt, node) {
7371
7371
  }
7372
7372
  };
7373
- function init(cobalt, nodeData2) {
7373
+ function init(cobalt, nodeData) {
7374
7374
  const { device } = cobalt;
7375
7375
  const viewportWidth = cobalt.viewport.width;
7376
7376
  const viewportHeight = cobalt.viewport.height;
@@ -7451,7 +7451,7 @@ function init(cobalt, nodeData2) {
7451
7451
  "rgba16float",
7452
7452
  GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING
7453
7453
  ));
7454
- bloom_mat.bind_groups_textures.push(nodeData2.refs.bloom.data);
7454
+ bloom_mat.bind_groups_textures.push(nodeData.refs.bloom.data);
7455
7455
  const compute_pipeline_layout = device.createPipelineLayout({
7456
7456
  bindGroupLayouts: bloom_mat.bind_group_layout
7457
7457
  });
@@ -7464,7 +7464,7 @@ function init(cobalt, nodeData2) {
7464
7464
  entryPoint: "cs_main"
7465
7465
  }
7466
7466
  });
7467
- set_all_bind_group(cobalt, bloom_mat, nodeData2);
7467
+ set_all_bind_group(cobalt, bloom_mat, nodeData);
7468
7468
  bloom_mat.compute_pipeline = compute_pipeline;
7469
7469
  return bloom_mat;
7470
7470
  }
@@ -7666,9 +7666,9 @@ function get_mip_size(current_mip, texture) {
7666
7666
  }
7667
7667
  return { width, height, depthOrArrayLayers: 1 };
7668
7668
  }
7669
- function resize(cobalt, nodeData2) {
7669
+ function resize(cobalt, nodeData) {
7670
7670
  const { device } = cobalt;
7671
- const bloom_mat = nodeData2.data;
7671
+ const bloom_mat = nodeData.data;
7672
7672
  destroy(bloom_mat);
7673
7673
  bloom_mat.bind_groups_textures.push(createTexture(
7674
7674
  device,
@@ -7688,8 +7688,8 @@ function resize(cobalt, nodeData2) {
7688
7688
  "rgba16float",
7689
7689
  GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING
7690
7690
  ));
7691
- bloom_mat.bind_groups_textures.push(nodeData2.refs.bloom.data);
7692
- set_all_bind_group(cobalt, bloom_mat, nodeData2);
7691
+ bloom_mat.bind_groups_textures.push(nodeData.refs.bloom.data);
7692
+ set_all_bind_group(cobalt, bloom_mat, nodeData);
7693
7693
  }
7694
7694
  function destroy(bloom_mat) {
7695
7695
  for (const t of bloom_mat.bind_groups_textures)
@@ -8052,7 +8052,7 @@ var sprite_default = {
8052
8052
  ...public_api_exports
8053
8053
  }
8054
8054
  };
8055
- async function init3(cobalt, nodeData2) {
8055
+ async function init3(cobalt, nodeData) {
8056
8056
  const { device } = cobalt;
8057
8057
  const MAX_SPRITE_COUNT = 16192;
8058
8058
  const numInstances = MAX_SPRITE_COUNT;
@@ -8070,9 +8070,9 @@ async function init3(cobalt, nodeData2) {
8070
8070
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
8071
8071
  //mappedAtCreation: true,
8072
8072
  });
8073
- const spritesheet = nodeData2.refs.spritesheet.data;
8073
+ const spritesheet = nodeData.refs.spritesheet.data;
8074
8074
  const bindGroup = device.createBindGroup({
8075
- layout: nodeData2.refs.spritesheet.data.bindGroupLayout,
8075
+ layout: nodeData.refs.spritesheet.data.bindGroupLayout,
8076
8076
  entries: [
8077
8077
  {
8078
8078
  binding: 0,
@@ -8224,7 +8224,7 @@ var tile_default = {
8224
8224
  setTexture: async function(cobalt, node, texture) {
8225
8225
  const { canvas, device } = cobalt;
8226
8226
  destroy3(node);
8227
- const format = nodeData.options.format || "rgba8unorm";
8227
+ const format = node.options.format || "rgba8unorm";
8228
8228
  let material;
8229
8229
  if (canvas) {
8230
8230
  node.options.textureUrl = texture;
@@ -8256,16 +8256,16 @@ var tile_default = {
8256
8256
  }
8257
8257
  }
8258
8258
  };
8259
- async function init4(cobalt, nodeData2) {
8259
+ async function init4(cobalt, nodeData) {
8260
8260
  const { canvas, device } = cobalt;
8261
8261
  let material;
8262
- const format = nodeData2.options.format || "rgba8unorm";
8262
+ const format = nodeData.options.format || "rgba8unorm";
8263
8263
  if (canvas) {
8264
- material = await createTextureFromUrl(cobalt, "tile map", nodeData2.options.textureUrl, format);
8264
+ material = await createTextureFromUrl(cobalt, "tile map", nodeData.options.textureUrl, format);
8265
8265
  } else {
8266
- material = await createTextureFromBuffer(cobalt, "tile map", nodeData2.options.texture, format);
8266
+ material = await createTextureFromBuffer(cobalt, "tile map", nodeData.options.texture, format);
8267
8267
  }
8268
- const dat = new Float32Array([nodeData2.options.scrollScale, nodeData2.options.scrollScale]);
8268
+ const dat = new Float32Array([nodeData.options.scrollScale, nodeData.options.scrollScale]);
8269
8269
  const usage = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
8270
8270
  const descriptor = {
8271
8271
  size: dat.byteLength,
@@ -8277,7 +8277,7 @@ async function init4(cobalt, nodeData2) {
8277
8277
  new Float32Array(uniformBuffer.getMappedRange()).set(dat);
8278
8278
  uniformBuffer.unmap();
8279
8279
  const bindGroup = device.createBindGroup({
8280
- layout: nodeData2.refs.tileAtlas.data.tileBindGroupLayout,
8280
+ layout: nodeData.refs.tileAtlas.data.tileBindGroupLayout,
8281
8281
  entries: [
8282
8282
  {
8283
8283
  binding: 0,
@@ -8299,33 +8299,33 @@ async function init4(cobalt, nodeData2) {
8299
8299
  bindGroup,
8300
8300
  material,
8301
8301
  uniformBuffer,
8302
- scrollScale: nodeData2.options.scrollScale
8302
+ scrollScale: nodeData.options.scrollScale
8303
8303
  };
8304
8304
  }
8305
- function draw4(cobalt, nodeData2, commandEncoder) {
8305
+ function draw4(cobalt, nodeData, commandEncoder) {
8306
8306
  const { device } = cobalt;
8307
- const loadOp = nodeData2.options.loadOp || "load";
8307
+ const loadOp = nodeData.options.loadOp || "load";
8308
8308
  const renderpass = commandEncoder.beginRenderPass({
8309
8309
  label: "tile",
8310
8310
  colorAttachments: [
8311
8311
  {
8312
- view: nodeData2.refs.hdr.data.view,
8312
+ view: nodeData.refs.hdr.data.view,
8313
8313
  clearValue: cobalt.clearValue,
8314
8314
  loadOp,
8315
8315
  storeOp: "store"
8316
8316
  }
8317
8317
  ]
8318
8318
  });
8319
- const tileAtlas = nodeData2.refs.tileAtlas.data;
8319
+ const tileAtlas = nodeData.refs.tileAtlas.data;
8320
8320
  renderpass.setPipeline(tileAtlas.pipeline);
8321
- renderpass.setBindGroup(0, nodeData2.data.bindGroup);
8321
+ renderpass.setBindGroup(0, nodeData.data.bindGroup);
8322
8322
  renderpass.setBindGroup(1, tileAtlas.atlasBindGroup);
8323
8323
  renderpass.draw(3);
8324
8324
  renderpass.end();
8325
8325
  }
8326
- function destroy3(nodeData2) {
8327
- nodeData2.data.material.texture.destroy();
8328
- nodeData2.data.material.texture = void 0;
8326
+ function destroy3(nodeData) {
8327
+ nodeData.data.material.texture.destroy();
8328
+ nodeData.data.material.texture = void 0;
8329
8329
  }
8330
8330
 
8331
8331
  // src/displacement/triangles-buffer.ts
@@ -12395,7 +12395,7 @@ var overlay_default2 = {
12395
12395
  // optional
12396
12396
  customFunctions: { ...public_api_exports }
12397
12397
  };
12398
- async function init6(cobalt, nodeData2) {
12398
+ async function init6(cobalt, nodeData) {
12399
12399
  const { device } = cobalt;
12400
12400
  const MAX_SPRITE_COUNT = 16192;
12401
12401
  const numInstances = MAX_SPRITE_COUNT;
@@ -12454,11 +12454,11 @@ async function init6(cobalt, nodeData2) {
12454
12454
  },
12455
12455
  {
12456
12456
  binding: 1,
12457
- resource: nodeData2.refs.spritesheet.data.colorTexture.view
12457
+ resource: nodeData.refs.spritesheet.data.colorTexture.view
12458
12458
  },
12459
12459
  {
12460
12460
  binding: 2,
12461
- resource: nodeData2.refs.spritesheet.data.colorTexture.sampler
12461
+ resource: nodeData.refs.spritesheet.data.colorTexture.sampler
12462
12462
  },
12463
12463
  {
12464
12464
  binding: 3,
@@ -12478,7 +12478,7 @@ async function init6(cobalt, nodeData2) {
12478
12478
  code: overlay_default
12479
12479
  }),
12480
12480
  entryPoint: "vs_main",
12481
- buffers: [nodeData2.refs.spritesheet.data.quads.bufferLayout]
12481
+ buffers: [nodeData.refs.spritesheet.data.quads.bufferLayout]
12482
12482
  },
12483
12483
  fragment: {
12484
12484
  module: device.createShaderModule({
@@ -12591,26 +12591,26 @@ function _rebuildSpriteDrawCalls2(renderPass) {
12591
12591
  renderPass.instancedDrawCallCount++;
12592
12592
  }
12593
12593
  }
12594
- function _writeOverlayBuffer(cobalt, nodeData2) {
12594
+ function _writeOverlayBuffer(cobalt, nodeData) {
12595
12595
  const zoom = 1;
12596
12596
  const GAME_WIDTH = Math.round(cobalt.viewport.width / zoom);
12597
12597
  const GAME_HEIGHT = Math.round(cobalt.viewport.height / zoom);
12598
12598
  const projection = mat4.ortho(0, GAME_WIDTH, GAME_HEIGHT, 0, -10, 10);
12599
12599
  vec3.set(0, 0, 0, _tmpVec3);
12600
12600
  const view = mat4.translation(_tmpVec3);
12601
- cobalt.device.queue.writeBuffer(nodeData2.data.uniformBuffer, 0, view.buffer);
12602
- cobalt.device.queue.writeBuffer(nodeData2.data.uniformBuffer, 64, projection.buffer);
12601
+ cobalt.device.queue.writeBuffer(nodeData.data.uniformBuffer, 0, view.buffer);
12602
+ cobalt.device.queue.writeBuffer(nodeData.data.uniformBuffer, 64, projection.buffer);
12603
12603
  }
12604
- function destroy5(nodeData2) {
12605
- nodeData2.data.instancedDrawCalls = null;
12606
- nodeData2.data.bindGroup = null;
12607
- nodeData2.data.spriteBuffer.destroy();
12608
- nodeData2.data.spriteBuffer = null;
12609
- nodeData2.data.uniformBuffer.destroy();
12610
- nodeData2.data.uniformBuffer = null;
12611
- nodeData2.data.spriteData = null;
12612
- nodeData2.data.spriteIndices.clear();
12613
- nodeData2.data.spriteIndices = null;
12604
+ function destroy5(nodeData) {
12605
+ nodeData.data.instancedDrawCalls = null;
12606
+ nodeData.data.bindGroup = null;
12607
+ nodeData.data.spriteBuffer.destroy();
12608
+ nodeData.data.spriteBuffer = null;
12609
+ nodeData.data.uniformBuffer.destroy();
12610
+ nodeData.data.uniformBuffer = null;
12611
+ nodeData.data.spriteData = null;
12612
+ nodeData.data.spriteIndices.clear();
12613
+ nodeData.data.spriteIndices = null;
12614
12614
  }
12615
12615
 
12616
12616
  // src/fb-blit/fb-blit.wgsl
@@ -14246,14 +14246,14 @@ var atlas_default = {
14246
14246
  _writeTileBuffer(cobalt, node);
14247
14247
  }
14248
14248
  };
14249
- async function init10(cobalt, nodeData2) {
14249
+ async function init10(cobalt, nodeData) {
14250
14250
  const { canvas, device } = cobalt;
14251
- const format = nodeData2.options.format || "rgba8unorm";
14251
+ const format = nodeData.options.format || "rgba8unorm";
14252
14252
  let atlasMaterial;
14253
14253
  if (canvas) {
14254
- atlasMaterial = await createTextureFromUrl(cobalt, "tile atlas", nodeData2.options.textureUrl, format);
14254
+ atlasMaterial = await createTextureFromUrl(cobalt, "tile atlas", nodeData.options.textureUrl, format);
14255
14255
  } else {
14256
- atlasMaterial = await createTextureFromBuffer(cobalt, "tile atlas", nodeData2.options.texture, format);
14256
+ atlasMaterial = await createTextureFromBuffer(cobalt, "tile atlas", nodeData.options.texture, format);
14257
14257
  }
14258
14258
  const uniformBuffer = device.createBuffer({
14259
14259
  size: 32,
@@ -14362,18 +14362,18 @@ async function init10(cobalt, nodeData2) {
14362
14362
  // tile atlas texture, transform UBO
14363
14363
  atlasMaterial,
14364
14364
  tileBindGroupLayout,
14365
- tileSize: nodeData2.options.tileSize,
14366
- tileScale: nodeData2.options.tileScale
14365
+ tileSize: nodeData.options.tileSize,
14366
+ tileScale: nodeData.options.tileScale
14367
14367
  };
14368
14368
  }
14369
14369
  function destroy8(data2) {
14370
14370
  data2.atlasMaterial.texture.destroy();
14371
14371
  data2.atlasMaterial.texture = void 0;
14372
14372
  }
14373
- function _writeTileBuffer(c, nodeData2) {
14373
+ function _writeTileBuffer(c, nodeData) {
14374
14374
  _buf[0] = c.viewport.position[0];
14375
14375
  _buf[1] = c.viewport.position[1];
14376
- const tile = nodeData2.data;
14376
+ const tile = nodeData.data;
14377
14377
  const { tileScale, tileSize } = tile;
14378
14378
  const GAME_WIDTH = c.viewport.width / c.viewport.zoom;
14379
14379
  const GAME_HEIGHT = c.viewport.height / c.viewport.zoom;
@@ -14696,14 +14696,14 @@ function defineNode(c, nodeDefinition) {
14696
14696
  throw new Error(`Can't define a new node missing a type.`);
14697
14697
  c.nodeDefs[nodeDefinition.type] = nodeDefinition;
14698
14698
  }
14699
- async function initNode(c, nodeData2) {
14700
- const nodeDef = c.nodeDefs[nodeData2?.type];
14699
+ async function initNode(c, nodeData) {
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
14703
  const node = {
14704
- type: nodeData2.type,
14705
- refs: nodeData2.refs || {},
14706
- options: nodeData2.options || {},
14704
+ type: nodeData.type,
14705
+ refs: nodeData.refs || {},
14706
+ options: nodeData.options || {},
14707
14707
  data: {},
14708
14708
  enabled: true
14709
14709
  // when disabled, the node won't be run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@footgun/cobalt",
3
- "version": "0.6.11",
3
+ "version": "0.6.12",
4
4
  "type": "module",
5
5
  "main": "bundle.js",
6
6
  "description": "A 2D WebGpu renderer",
package/src/tile/tile.js CHANGED
@@ -52,7 +52,7 @@ export default {
52
52
 
53
53
  destroy(node)
54
54
 
55
- const format = nodeData.options.format || 'rgba8unorm'
55
+ const format = node.options.format || 'rgba8unorm'
56
56
 
57
57
  let material
58
58