@cazala/party 0.0.0

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.
Files changed (73) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +598 -0
  3. package/dist/engine.d.ts +113 -0
  4. package/dist/engine.d.ts.map +1 -0
  5. package/dist/index.d.ts +8 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +9628 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/interfaces.d.ts +223 -0
  10. package/dist/interfaces.d.ts.map +1 -0
  11. package/dist/module.d.ts +259 -0
  12. package/dist/module.d.ts.map +1 -0
  13. package/dist/modules/forces/behavior.d.ts +78 -0
  14. package/dist/modules/forces/behavior.d.ts.map +1 -0
  15. package/dist/modules/forces/boundary.d.ts +58 -0
  16. package/dist/modules/forces/boundary.d.ts.map +1 -0
  17. package/dist/modules/forces/collisions.d.ts +34 -0
  18. package/dist/modules/forces/collisions.d.ts.map +1 -0
  19. package/dist/modules/forces/environment.d.ts +62 -0
  20. package/dist/modules/forces/environment.d.ts.map +1 -0
  21. package/dist/modules/forces/fluids.d.ts +73 -0
  22. package/dist/modules/forces/fluids.d.ts.map +1 -0
  23. package/dist/modules/forces/grab.d.ts +56 -0
  24. package/dist/modules/forces/grab.d.ts.map +1 -0
  25. package/dist/modules/forces/interaction.d.ts +59 -0
  26. package/dist/modules/forces/interaction.d.ts.map +1 -0
  27. package/dist/modules/forces/joints.d.ts +87 -0
  28. package/dist/modules/forces/joints.d.ts.map +1 -0
  29. package/dist/modules/forces/sensors.d.ts +81 -0
  30. package/dist/modules/forces/sensors.d.ts.map +1 -0
  31. package/dist/modules/index.d.ts +13 -0
  32. package/dist/modules/index.d.ts.map +1 -0
  33. package/dist/modules/render/lines.d.ts +55 -0
  34. package/dist/modules/render/lines.d.ts.map +1 -0
  35. package/dist/modules/render/particles.d.ts +53 -0
  36. package/dist/modules/render/particles.d.ts.map +1 -0
  37. package/dist/modules/render/trails.d.ts +36 -0
  38. package/dist/modules/render/trails.d.ts.map +1 -0
  39. package/dist/oscillators.d.ts +66 -0
  40. package/dist/oscillators.d.ts.map +1 -0
  41. package/dist/particle.d.ts +19 -0
  42. package/dist/particle.d.ts.map +1 -0
  43. package/dist/runtimes/cpu/engine.d.ts +60 -0
  44. package/dist/runtimes/cpu/engine.d.ts.map +1 -0
  45. package/dist/runtimes/cpu/spatial-grid.d.ts +56 -0
  46. package/dist/runtimes/cpu/spatial-grid.d.ts.map +1 -0
  47. package/dist/runtimes/webgpu/builders/program.d.ts +56 -0
  48. package/dist/runtimes/webgpu/builders/program.d.ts.map +1 -0
  49. package/dist/runtimes/webgpu/builders/render-pass.d.ts +26 -0
  50. package/dist/runtimes/webgpu/builders/render-pass.d.ts.map +1 -0
  51. package/dist/runtimes/webgpu/engine.d.ts +73 -0
  52. package/dist/runtimes/webgpu/engine.d.ts.map +1 -0
  53. package/dist/runtimes/webgpu/gpu-resources.d.ts +141 -0
  54. package/dist/runtimes/webgpu/gpu-resources.d.ts.map +1 -0
  55. package/dist/runtimes/webgpu/module-registry.d.ts +53 -0
  56. package/dist/runtimes/webgpu/module-registry.d.ts.map +1 -0
  57. package/dist/runtimes/webgpu/particle-store.d.ts +43 -0
  58. package/dist/runtimes/webgpu/particle-store.d.ts.map +1 -0
  59. package/dist/runtimes/webgpu/render-pipeline.d.ts +49 -0
  60. package/dist/runtimes/webgpu/render-pipeline.d.ts.map +1 -0
  61. package/dist/runtimes/webgpu/shaders.d.ts +8 -0
  62. package/dist/runtimes/webgpu/shaders.d.ts.map +1 -0
  63. package/dist/runtimes/webgpu/simulation-pipeline.d.ts +22 -0
  64. package/dist/runtimes/webgpu/simulation-pipeline.d.ts.map +1 -0
  65. package/dist/runtimes/webgpu/spacial-grid.d.ts +27 -0
  66. package/dist/runtimes/webgpu/spacial-grid.d.ts.map +1 -0
  67. package/dist/spawner.d.ts +40 -0
  68. package/dist/spawner.d.ts.map +1 -0
  69. package/dist/vector.d.ts +61 -0
  70. package/dist/vector.d.ts.map +1 -0
  71. package/dist/view.d.ts +43 -0
  72. package/dist/view.d.ts.map +1 -0
  73. package/package.json +67 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ParticleStore
3
+ *
4
+ * CPU-side SoA-like packed Float32Array for particle attributes with helpers
5
+ * to set/add/read particles and to synchronize active slices to the GPU
6
+ * storage buffer owned by GPUResources.
7
+ *
8
+ * Layout (floatsPerParticle=12):
9
+ * [pos.x, pos.y, vel.x, vel.y, ax, ay, size, mass, color.r, color.g, color.b, color.a]
10
+ */
11
+ import { GPUResources } from "./gpu-resources";
12
+ import { IParticle } from "../../interfaces";
13
+ /**
14
+ * CPU-side particle storage and synchronization to GPU storage buffer.
15
+ */
16
+ export declare class ParticleStore {
17
+ private readonly maxParticles;
18
+ private readonly floatsPerParticle;
19
+ private readonly data;
20
+ private count;
21
+ constructor(maxParticles: number, floatsPerParticle?: number);
22
+ setParticles(list: IParticle[]): void;
23
+ addParticle(p: IParticle): void;
24
+ clear(): void;
25
+ getCount(): number;
26
+ getParticles(): IParticle[];
27
+ getParticle(index: number): IParticle;
28
+ /**
29
+ * Writes the currently active particle slice to the GPU particle buffer.
30
+ * Assumes the GPU storage buffer has already been created with matching capacity.
31
+ */
32
+ syncToGPU(resources: GPUResources): void;
33
+ /**
34
+ * Reads particle data back from GPU to CPU, updating the local data array.
35
+ * This ensures getParticles() returns current GPU simulation state.
36
+ */
37
+ syncFromGPU(resources: GPUResources): Promise<void>;
38
+ /**
39
+ * Internal: encode one particle into the CPU buffer at a given index.
40
+ */
41
+ private writeAtIndex;
42
+ }
43
+ //# sourceMappingURL=particle-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"particle-store.d.ts","sourceRoot":"","sources":["../../../src/runtimes/webgpu/particle-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAe;IACpC,OAAO,CAAC,KAAK,CAAa;gBAEd,YAAY,EAAE,MAAM,EAAE,iBAAiB,SAAK;IAMxD,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI;IAMrC,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI;IAM/B,KAAK,IAAI,IAAI;IAIb,QAAQ,IAAI,MAAM;IAIlB,YAAY,IAAI,SAAS,EAAE;IAQ3B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;IAgBrC;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;IAMxC;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAezD;;OAEG;IACH,OAAO,CAAC,YAAY;CAiBrB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * RenderPipeline
3
+ *
4
+ * Manages scene render targets (ping-pong textures) and executes a sequence of
5
+ * render module passes. Two pass types are supported:
6
+ * - Fullscreen (raster) passes: draw a screen-aligned quad, optionally instanced per particle
7
+ * - Compute image passes: read from a scene texture and write to the other scene texture
8
+ *
9
+ * The pipeline resolves each module's uniform layout, binds particle/render uniforms
10
+ * and module uniforms, and handles ping-pong view swapping when a pass writes the scene.
11
+ * Finally, it presents the last written scene view to the canvas using a cached copy pipeline.
12
+ */
13
+ import type { Program } from "./builders/program";
14
+ import type { GPUResources } from "./gpu-resources";
15
+ import { Module } from "../../module";
16
+ /**
17
+ * Run a fullscreen rasterization pass that draws a screen-aligned quad.
18
+ *
19
+ * Builds WGSL program via the render DSL, acquires (or creates) a cached
20
+ * pipeline, binds particle + render uniforms + module uniforms, and draws.
21
+ */
22
+ /**
23
+ * Run a compute image pass that reads from `currentView` and writes into `otherView`.
24
+ *
25
+ * This uses a compute pipeline generated from the DSL. If the pass is marked
26
+ * as writing the scene, the caller will swap the views afterwards.
27
+ */
28
+ export declare class RenderPipeline {
29
+ ensureTargets(resources: GPUResources, width: number, height: number): void;
30
+ clearTargets(resources: GPUResources, color?: {
31
+ r: number;
32
+ g: number;
33
+ b: number;
34
+ a: number;
35
+ }): void;
36
+ runPasses(encoder: GPUCommandEncoder, modules: Module[], program: Program, resources: GPUResources, viewSize: {
37
+ width: number;
38
+ height: number;
39
+ }, particleCount: number, clearColor: {
40
+ r: number;
41
+ g: number;
42
+ b: number;
43
+ a: number;
44
+ }): GPUTextureView;
45
+ present(encoder: GPUCommandEncoder, resources: GPUResources, sourceView?: GPUTextureView): void;
46
+ private runFullscreenPass;
47
+ private runComputePass;
48
+ }
49
+ //# sourceMappingURL=render-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/runtimes/webgpu/render-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAuB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,MAAM,EAMP,MAAM,cAAc,CAAC;AAMtB;;;;;GAKG;AAEH;;;;;GAKG;AAEH,qBAAa,cAAc;IACzB,aAAa,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3E,YAAY,CACV,SAAS,EAAE,YAAY,EACvB,KAAK,GAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAKlD,GACA,IAAI;IA+BP,SAAS,CACP,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,YAAY,EACvB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAC3C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GACzD,cAAc;IAgFjB,OAAO,CACL,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,YAAY,EACvB,UAAU,CAAC,EAAE,cAAc,GAC1B,IAAI;IA6BP,OAAO,CAAC,iBAAiB;IAmFzB,OAAO,CAAC,cAAc;CAoDvB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Presentation shader (copy)
3
+ *
4
+ * Minimal fullscreen copy shader used to present the rendered scene texture to the canvas.
5
+ * A small pipeline built with this WGSL is cached per canvas format.
6
+ */
7
+ export declare const copyShaderWGSL = "\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n}\n\n@group(0) @binding(0) var source_texture: texture_2d<f32>;\n@group(0) @binding(1) var source_sampler: sampler;\n\n@vertex\nfn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {\n var out: VertexOutput;\n let positions = array<vec2<f32>, 4>(\n vec2<f32>(-1.0, -1.0),\n vec2<f32>( 1.0, -1.0),\n vec2<f32>(-1.0, 1.0),\n vec2<f32>( 1.0, 1.0)\n );\n let uvs = array<vec2<f32>, 4>(\n vec2<f32>(0.0, 1.0),\n vec2<f32>(1.0, 1.0),\n vec2<f32>(0.0, 0.0),\n vec2<f32>(1.0, 0.0)\n );\n let index = vertex_index % 4u;\n out.position = vec4<f32>(positions[index], 0.0, 1.0);\n out.uv = uvs[index];\n return out;\n}\n\n@fragment\nfn fs_main(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(source_texture, source_sampler, uv);\n}";
8
+ //# sourceMappingURL=shaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaders.d.ts","sourceRoot":"","sources":["../../../src/runtimes/webgpu/shaders.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,04BAiCzB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * SimulationPipeline
3
+ *
4
+ * Wraps the compute side of the program. Builds compute layouts/pipelines from the
5
+ * generated WGSL and runs the available passes in sequence each frame:
6
+ * - grid_clear, grid_build (if present)
7
+ * - state_pass, apply_pass, integrate_pass, constrain_pass (N iterations), correct_pass
8
+ * If specialized passes are not present, falls back to `main`.
9
+ */
10
+ import type { Program } from "./builders/program";
11
+ import type { GPUResources } from "./gpu-resources";
12
+ export declare class SimulationPipeline {
13
+ private program;
14
+ initialize(resources: GPUResources, program: Program): void;
15
+ runPasses(encoder: GPUCommandEncoder, resources: GPUResources, params: {
16
+ particleCount: number;
17
+ gridCellCount: number;
18
+ workgroupSize: number;
19
+ constrainIterations?: number;
20
+ }): void;
21
+ }
22
+ //# sourceMappingURL=simulation-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulation-pipeline.d.ts","sourceRoot":"","sources":["../../../src/runtimes/webgpu/simulation-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAwB;IAEvC,UAAU,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAM3D,SAAS,CACP,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GACA,IAAI;CA0FR"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * GridSystem
3
+ *
4
+ * Maintains a world-aligned uniform grid based on the current view snapshot.
5
+ * Allocates GPU storage for per-cell counts/indices and writes grid uniforms
6
+ * into the `grid` system module's uniform buffer. Exposes resizeIfNeeded to
7
+ * keep grid state synchronized with camera/zoom/size changes.
8
+ */
9
+ import type { Program } from "./builders/program";
10
+ import type { GPUResources } from "./gpu-resources";
11
+ import type { ViewSnapshot } from "../../view";
12
+ export declare class SpacialGrid {
13
+ private cols;
14
+ private rows;
15
+ private cellSize;
16
+ private maxPerCell;
17
+ private lastView;
18
+ constructor(cellSize?: number);
19
+ configure(view: ViewSnapshot, resources: GPUResources, program: Program): void;
20
+ resizeIfNeeded(view: ViewSnapshot, resources: GPUResources, program: Program): void;
21
+ getCellCount(): number;
22
+ getCellSize(): number;
23
+ setCellSize(cellSize: number): void;
24
+ private computeGrid;
25
+ private writeUniforms;
26
+ }
27
+ //# sourceMappingURL=spacial-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacial-grid.d.ts","sourceRoot":"","sources":["../../../src/runtimes/webgpu/spacial-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,qBAAa,WAAW;IACtB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,QAAQ,CAA6B;gBAEjC,QAAQ,GAAE,MAAW;IAIjC,SAAS,CACP,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,OAAO,GACf,IAAI;IAoBP,cAAc,CACZ,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,OAAO,GACf,IAAI;IAcP,YAAY,IAAI,MAAM;IAItB,WAAW,IAAI,MAAM;IAIrB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASnC,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,aAAa;CA6BtB"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Spawner
3
+ *
4
+ * Utility for generating initial `IParticle[]` configurations for common
5
+ * shapes (grid, random, circle, donut, square) with optional initial velocity
6
+ * presets (random/in/out/clockwise/counter-clockwise/custom). Also includes
7
+ * lightweight color parsing helpers.
8
+ */
9
+ import { IParticle } from "./interfaces";
10
+ export type VelocityDirection = "random" | "in" | "out" | "custom" | "clockwise" | "counter-clockwise";
11
+ export interface VelocityConfig {
12
+ speed: number;
13
+ direction: VelocityDirection;
14
+ angle?: number;
15
+ }
16
+ export interface SpawnOptions {
17
+ count: number;
18
+ shape: "grid" | "random" | "circle" | "donut" | "square";
19
+ center: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ colors?: string[];
24
+ spacing?: number;
25
+ radius?: number;
26
+ innerRadius?: number;
27
+ squareSize?: number;
28
+ cornerRadius?: number;
29
+ size?: number;
30
+ mass?: number;
31
+ bounds?: {
32
+ width: number;
33
+ height: number;
34
+ };
35
+ velocity?: VelocityConfig;
36
+ }
37
+ export declare class Spawner {
38
+ initParticles(options: SpawnOptions): IParticle[];
39
+ }
40
+ //# sourceMappingURL=spawner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawner.d.ts","sourceRoot":"","sources":["../src/spawner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,IAAI,GACJ,KAAK,GACL,QAAQ,GACR,WAAW,GACX,mBAAmB,CAAC;AAExB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACzD,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAgDD,qBAAa,OAAO;IAClB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE;CAoUlD"}
@@ -0,0 +1,61 @@
1
+ export declare class Vector {
2
+ x: number;
3
+ y: number;
4
+ constructor(x?: number, y?: number);
5
+ add(vector: Vector): Vector;
6
+ subtract(vector: Vector): Vector;
7
+ multiply(scalar: number): Vector;
8
+ divide(scalar: number): Vector;
9
+ magnitude(): number;
10
+ normalize(): Vector;
11
+ limit(max: number): Vector;
12
+ dot(vector: Vector): number;
13
+ distance(vector: Vector): number;
14
+ direction(vector: Vector): Vector;
15
+ clone(): Vector;
16
+ set(x: number, y: number): Vector;
17
+ zero(): Vector;
18
+ static random(min?: number, max?: number): Vector;
19
+ static zero(): Vector;
20
+ /**
21
+ * Create a Vector2D from an angle in radians
22
+ * @param angle Angle in radians (0 = right, π/2 = down, π = left, 3π/2 = up)
23
+ * @param magnitude Length of the vector (default: 1)
24
+ */
25
+ static fromAngle(angle: number, magnitude?: number): Vector;
26
+ /**
27
+ * Create a Vector2D from an angle in degrees
28
+ * @param angle Angle in degrees (0° = right, 90° = down, 180° = left, 270° = up)
29
+ * @param magnitude Length of the vector (default: 1)
30
+ */
31
+ static fromAngleDegrees(angle: number, magnitude?: number): Vector;
32
+ /**
33
+ * Convert degrees to radians
34
+ * @param degrees Angle in degrees
35
+ * @returns Angle in radians
36
+ */
37
+ static degreesToRadians(degrees: number): number;
38
+ /**
39
+ * Convert radians to degrees
40
+ * @param radians Angle in radians
41
+ * @returns Angle in degrees
42
+ */
43
+ static radiansToDegrees(radians: number): number;
44
+ toJSON(): {
45
+ x: number;
46
+ y: number;
47
+ };
48
+ }
49
+ /**
50
+ * Convert degrees to radians
51
+ * @param degrees Angle in degrees
52
+ * @returns Angle in radians
53
+ */
54
+ export declare function degToRad(degrees: number): number;
55
+ /**
56
+ * Convert radians to degrees
57
+ * @param radians Angle in radians
58
+ * @returns Angle in degrees
59
+ */
60
+ export declare function radToDeg(radians: number): number;
61
+ //# sourceMappingURL=vector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IACE,CAAC,EAAE,MAAM;IAAa,CAAC,EAAE,MAAM;gBAA/B,CAAC,GAAE,MAAU,EAAS,CAAC,GAAE,MAAU;IAEtD,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAM3B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMhC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMhC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAO9B,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAYnB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAQ1B,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI3B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMhC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQjC,KAAK,IAAI,MAAM;IAIf,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAMjC,IAAI,IAAI,MAAM;IAMd,MAAM,CAAC,MAAM,CAAC,GAAG,GAAE,MAAW,EAAE,GAAG,GAAE,MAAU,GAAG,MAAM;IAOxD,MAAM,CAAC,IAAI,IAAI,MAAM;IAIrB;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM;IAI9D;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM;IAQrE;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIhD;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAIhD,MAAM,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;CAGnC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhD"}
package/dist/view.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ViewController
3
+ *
4
+ * Tracks canvas size, camera position, and zoom. Provides snapshot and writes
5
+ * render uniforms consumed by render passes (canvas size, camera, zoom).
6
+ * Also enforces simple zoom limits based on canvas size to avoid excessive
7
+ * grid allocation and texture usage.
8
+ */
9
+ export interface ViewSnapshot {
10
+ width: number;
11
+ height: number;
12
+ cx: number;
13
+ cy: number;
14
+ zoom: number;
15
+ }
16
+ export declare class View {
17
+ private width;
18
+ private height;
19
+ private cameraX;
20
+ private cameraY;
21
+ private zoom;
22
+ private minZoom;
23
+ private maxZoom;
24
+ constructor(width: number, height: number);
25
+ setSize(width: number, height: number): void;
26
+ getSize(): {
27
+ width: number;
28
+ height: number;
29
+ };
30
+ setCamera(x: number, y: number): void;
31
+ getCamera(): {
32
+ x: number;
33
+ y: number;
34
+ };
35
+ setZoom(zoom: number): void;
36
+ getZoom(): number;
37
+ /**
38
+ * Optional: allow external systems (e.g., GridSystem) to update zoom limits.
39
+ */
40
+ setZoomLimits(minZoom: number, maxZoom: number): void;
41
+ getSnapshot(): ViewSnapshot;
42
+ }
43
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,IAAI;IACf,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,OAAO,CAAa;gBAEhB,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKzC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAK5C,OAAO,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAI5C,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAKrC,SAAS,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAIrC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS3B,OAAO,IAAI,MAAM;IAIjB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAMrD,WAAW,IAAI,YAAY;CAS5B"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@cazala/party",
3
+ "version": "0.0.0",
4
+ "description": "High-performance TypeScript particle physics engine with dual runtime support (WebGPU compute + CPU fallback). Features modular architecture, real-time parameter oscillation, advanced physics modules, and comprehensive rendering capabilities.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "keywords": [
20
+ "particle-physics",
21
+ "physics-engine",
22
+ "webgpu",
23
+ "gpu-compute",
24
+ "dual-runtime",
25
+ "simulation",
26
+ "particles",
27
+ "forces",
28
+ "collision-detection",
29
+ "fluid-dynamics",
30
+ "sph",
31
+ "flocking",
32
+ "boids",
33
+ "spatial-grid",
34
+ "oscillators",
35
+ "modular-architecture",
36
+ "canvas-rendering",
37
+ "typescript",
38
+ "interactive",
39
+ "real-time"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/cazala/party.git",
44
+ "directory": "packages/core"
45
+ },
46
+ "homepage": "https://github.com/cazala/party#readme",
47
+ "bugs": {
48
+ "url": "https://github.com/cazala/party/issues"
49
+ },
50
+ "author": "cazala",
51
+ "license": "MIT",
52
+ "scripts": {
53
+ "build": "rollup -c",
54
+ "dev": "rollup -c --watch",
55
+ "prepublishOnly": "npm run build"
56
+ },
57
+ "devDependencies": {
58
+ "@rollup/plugin-typescript": "^11.1.0",
59
+ "@webgpu/types": "^0.1.64",
60
+ "rollup": "^4.0.0",
61
+ "tslib": "^2.6.0",
62
+ "typescript": "^5.0.0"
63
+ },
64
+ "engines": {
65
+ "node": ">=16.0.0"
66
+ }
67
+ }