@multiplekex/shallot 0.1.9 → 0.1.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@multiplekex/shallot",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
package/src/core/state.ts CHANGED
@@ -37,6 +37,7 @@ export class State {
37
37
  readonly world: World;
38
38
  readonly scheduler = new Scheduler();
39
39
  readonly canvas: HTMLCanvasElement | null;
40
+ maxEid = 0;
40
41
 
41
42
  private _resources = new Map<symbol, unknown>();
42
43
  private _disposed = false;
@@ -140,6 +141,7 @@ export class State {
140
141
  if (eid >= MAX_ENTITIES) {
141
142
  throw new Error(`Entity limit exceeded: ${eid} >= ${MAX_ENTITIES}`);
142
143
  }
144
+ if (eid > this.maxEid) this.maxEid = eid;
143
145
  return eid;
144
146
  }
145
147
 
@@ -5,9 +5,10 @@ import {
5
5
  Render,
6
6
  RenderPlugin,
7
7
  DEPTH_FORMAT,
8
- registerDrawContributor,
9
- type DrawContributor,
10
- type DrawContext,
8
+ Pass,
9
+ registerDraw,
10
+ type Draw,
11
+ type SharedPassContext,
11
12
  } from "../../standard/render";
12
13
  import { Transform } from "../../standard/transforms";
13
14
  import { Line, Lines, LinesPlugin } from "../lines";
@@ -245,15 +246,18 @@ export function createArrowsPipeline(
245
246
  });
246
247
  }
247
248
 
248
- function createArrowsContributor(config: ArrowsConfig): DrawContributor {
249
+ function createArrowsDraw(config: ArrowsConfig): Draw {
249
250
  let pipeline: GPURenderPipeline | null = null;
250
251
  let bindGroup: GPUBindGroup | null = null;
251
252
 
252
253
  return {
253
254
  id: "arrows",
255
+ pass: Pass.Transparent,
254
256
  order: 1,
255
257
 
256
- draw(pass: GPURenderPassEncoder, ctx: DrawContext) {
258
+ execute() {},
259
+
260
+ draw(pass: GPURenderPassEncoder, ctx: SharedPassContext) {
257
261
  const count = config.getCount();
258
262
  if (count === 0) return;
259
263
 
@@ -314,7 +318,8 @@ const ArrowsSystem: System = {
314
318
  }
315
319
  }
316
320
 
317
- device.queue.writeBuffer(arrows.buffer, 0, ArrowData.data);
321
+ const uploadCount = state.maxEid + 1;
322
+ device.queue.writeBuffer(arrows.buffer, 0, ArrowData.data, 0, uploadCount * 4);
318
323
  device.queue.writeBuffer(arrows.entityIds, 0, arrowEntityIdArray, 0, count);
319
324
  arrows.count = count;
320
325
  },
@@ -345,9 +350,9 @@ export const ArrowsPlugin: Plugin = {
345
350
 
346
351
  state.setResource(Arrows, arrowsState);
347
352
 
348
- registerDrawContributor(
353
+ registerDraw(
349
354
  state,
350
- createArrowsContributor({
355
+ createArrowsDraw({
351
356
  scene: render.scene,
352
357
  arrows: arrowsState.buffer,
353
358
  lines: lines.buffer,