@woosh/meep-engine 3.78.1 → 3.78.2

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 (25) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +1 -1
  3. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts +119 -0
  4. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts.map +1 -0
  5. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js +563 -0
  6. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.d.ts +11 -0
  7. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.d.ts.map +1 -0
  8. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.js +10 -0
  9. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts +123 -0
  10. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts.map +1 -0
  11. package/src/generation/wfc/GridWFCCompiledTileSet.js +355 -0
  12. package/src/generation/wfc/GridWFCEdge.d.ts +13 -0
  13. package/src/generation/wfc/GridWFCEdge.d.ts.map +1 -0
  14. package/src/generation/wfc/GridWFCEdge.js +14 -0
  15. package/src/generation/wfc/GridWFCTileSet.d.ts +120 -0
  16. package/src/generation/wfc/GridWFCTileSet.d.ts.map +1 -0
  17. package/src/generation/wfc/GridWFCTileSet.js +275 -0
  18. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  19. package/src/shade/renderer/hair/GPUHairSystem.js +28 -9
  20. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +50 -9
  21. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -1
  22. package/src/shade/renderer/hair/HAIR_SIMULATION.js +71 -11
  23. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +22 -16
  24. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -1
  25. package/src/shade/renderer/hair/shader_hair_simulate.js +151 -78
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Generation: wave function collapse over a grid
6
+
7
+ - **Added:** `GridTaskWaveFunctionCollapse`, a grid task that lays the tiles of a `GridWFCTileSet` over the whole
8
+ grid with the `core/wfc` solver and runs each tile's `GridCellAction` on its cell, turned as the tile is. Cells a
9
+ `CellMatcher` names can be restricted to tiles carrying a tag, the edge of the grid likewise, and the tiles of one
10
+ tag can be required to form one region — by swapping in a tile with the same sockets that carries the tag where
11
+ one keeps two regions apart, and by drawing again where none can. A `fallback` tile covers the grid when every draw
12
+ failed.
13
+ - **Added:** `generation/wfc/GridWFCTileSet`: tiles described by a socket on each edge, expanded into their quarter
14
+ turns and compiled to a `WFCRuleTable`. `add_piece` makes a piece of several cells, joined edge to edge, that only
15
+ ever appears whole; `compile().lint()` names a tile showing a socket nothing answers and tiles that can never share
16
+ a result (`WFC_DESIGN.md` §13).
17
+
5
18
  ### Cloth: a cloth that slides is not pulled back to where it landed
6
19
 
7
20
  - **Fixed:** cloth friction pulled a sliding particle towards the point where its contact began, for as long as
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Advanced 3D game engine",
7
7
  "type": "module",
8
8
  "author": "Alexander Goldring",
9
- "version": "3.78.1",
9
+ "version": "3.78.2",
10
10
  "exports": {
11
11
  "./build/*": "./build/*",
12
12
  "./src/*": "./src/*",
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Lays tiles over the whole grid by wave function collapse: every cell gets one tile of a
3
+ * {@link GridWFCTileSet}, and every pair of neighbours shows the same socket on the edge they
4
+ * share. Each tile's {@link GridCellAction} is then run on its cell, turned the way the tile is.
5
+ *
6
+ * What adjacency alone cannot say is said around the solve:
7
+ * - {@link restrictions} narrow what a cell may hold before it starts — keep these cells open,
8
+ * let paving stand only where that field is high;
9
+ * - {@link boundary} says what may stand against the edge of the grid;
10
+ * - {@link connected} makes the tiles of one kind hang together — by opening what keeps them
11
+ * apart where the set has a tile for it, and by drawing again, up to {@link attempts} times,
12
+ * where it has not;
13
+ * - {@link fallback} covers the grid when every attempt failed, so a generator that must always
14
+ * produce a map does.
15
+ *
16
+ * The same grid, tile set and seed always give the same result.
17
+ */
18
+ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
19
+ /**
20
+ * @param {Object} options
21
+ * @param {string} [options.name]
22
+ * @param {GridWFCTileSet} options.tiles
23
+ * @param {{matcher: CellMatcher, tag: string}[]} [options.restrictions]
24
+ * @param {string|null} [options.boundary]
25
+ * @param {string|null} [options.connected]
26
+ * @param {WFCCellChoice} [options.cell_choice]
27
+ * @param {number} [options.attempts]
28
+ * @param {string|null} [options.fallback]
29
+ * @returns {GridTaskWaveFunctionCollapse}
30
+ */
31
+ static from({ name, tiles, restrictions, boundary, connected, cell_choice, attempts, fallback }: {
32
+ name?: string;
33
+ tiles: GridWFCTileSet;
34
+ restrictions?: {
35
+ matcher: CellMatcher;
36
+ tag: string;
37
+ }[];
38
+ boundary?: string | null;
39
+ connected?: string | null;
40
+ cell_choice?: WFCCellChoice;
41
+ attempts?: number;
42
+ fallback?: string | null;
43
+ }): GridTaskWaveFunctionCollapse;
44
+ /**
45
+ * @type {GridWFCTileSet}
46
+ */
47
+ tiles: GridWFCTileSet;
48
+ /**
49
+ * A cell that `matcher` matches may only hold tiles carrying `tag`. A cell matched by several
50
+ * may only hold tiles carrying all their tags.
51
+ *
52
+ * @type {{matcher: CellMatcher, tag: string}[]}
53
+ */
54
+ restrictions: {
55
+ matcher: CellMatcher;
56
+ tag: string;
57
+ }[];
58
+ /**
59
+ * Tag of the tiles allowed in the cells along the edge of the grid; `null` allows any.
60
+ *
61
+ * A tile set whose walls must close on themselves wants its open tile here: a wall could
62
+ * otherwise run off the edge and never have to turn back.
63
+ *
64
+ * @type {string|null}
65
+ */
66
+ boundary: string | null;
67
+ /**
68
+ * Tag of the tiles that must form one region, joined edge to edge; `null` skips the check.
69
+ *
70
+ * Adjacency rules cannot express this — a ring of wall with no gate in it is locally perfect —
71
+ * so it is seen to on the finished result. Where a tile keeping two regions apart has a
72
+ * **twin** carrying the tag (a tile with the same four sockets: the gap in a wall, for a
73
+ * stretch of that wall), the twin is swapped in and nothing around it has to change. Give the
74
+ * set such twins and one draw nearly always does; a result no swap can join (a pocket walled
75
+ * by tiles with no twin, or by two walls back to back) is thrown away and drawn again — which
76
+ * is all a set without twins can do, and a large grid can rarely afford.
77
+ *
78
+ * @type {string|null}
79
+ */
80
+ connected: string | null;
81
+ /**
82
+ * @type {WFCCellChoice}
83
+ */
84
+ cell_choice: WFCCellChoice;
85
+ /**
86
+ * How many draws are tried before giving up. A draw is abandoned when the search runs out of
87
+ * backtracks, or when its result cannot be made {@link connected}.
88
+ *
89
+ * @type {number}
90
+ */
91
+ attempts: number;
92
+ /**
93
+ * Name of the tile laid over the whole grid when every attempt failed; `null` fails the task
94
+ * instead. It has to be a tile that may neighbour itself, which {@link build} checks, and that
95
+ * may stand in every restricted cell and against the edge of the grid, which nothing checks:
96
+ * the fallback is laid over restrictions and boundary alike — the set's open tile, usually.
97
+ *
98
+ * @type {string|null}
99
+ */
100
+ fallback: string | null;
101
+ /**
102
+ * How the most recent build went, for tuning a tile set. Not an input. `backtracks` and
103
+ * `openings` are summed over every draw of the build, the ones thrown away included.
104
+ *
105
+ * @type {{attempts: number, backtracks: number, openings: number, solved: boolean, fallback: boolean}}
106
+ */
107
+ statistics: {
108
+ attempts: number;
109
+ backtracks: number;
110
+ openings: number;
111
+ solved: boolean;
112
+ fallback: boolean;
113
+ };
114
+ build(grid: any, ecd: any, seed: any): TaskGroup;
115
+ }
116
+ import { GridTaskGenerator } from "../../GridTaskGenerator.js";
117
+ import { WFCCellChoice } from "../../../../core/wfc/WFCCellChoice.js";
118
+ import TaskGroup from "../../../../core/process/task/TaskGroup.js";
119
+ //# sourceMappingURL=GridTaskWaveFunctionCollapse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridTaskWaveFunctionCollapse.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;GAgBG;AACH;IAuEI;;;;;;;;;;;OAWG;IACH;QAV4B,IAAI,GAArB,MAAM;QACkB,KAAK;QACmB,YAAY,GAA5D;YAAC,OAAO,cAAc;YAAC,GAAG,EAAE,MAAM,CAAA;SAAC,EAAE;QACf,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACW,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,WAAW,GAAnC,aAAa;QACI,QAAQ,GAAzB,MAAM;QACgB,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACT,4BAA4B,CAiCxC;IAhHD;;OAEG;IACH,sBAAa;IAEb;;;;;OAKG;IACH,cAFU;QAAC,OAAO,cAAc;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAE7B;IAElB;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;;;;;;;;OAYG;IACH,WAFU,MAAM,GAAC,IAAI,CAEJ;IAEjB;;OAEG;IACH,aAFU,aAAa,CAEc;IAErC;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;OAKG;IACH,YAFU;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAEb;IAmDzF,iDA0YC;CACJ;kCA/hBiC,4BAA4B;8BAThC,uCAAuC;sBAJ/C,4CAA4C"}