@woosh/meep-engine 3.78.1 → 3.78.3

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 (47) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +1 -1
  3. package/src/engine/asset/loaders/GroomAssetLoader.d.ts.map +1 -1
  4. package/src/engine/asset/loaders/GroomAssetLoader.js +2 -1
  5. package/src/engine/graphics/hair/Groom.d.ts +30 -0
  6. package/src/engine/graphics/hair/Groom.d.ts.map +1 -1
  7. package/src/engine/graphics/hair/Groom.js +35 -0
  8. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts +18 -2
  9. package/src/engine/graphics/hair/GroomSerializationAdapter.d.ts.map +1 -1
  10. package/src/engine/graphics/hair/GroomSerializationAdapter.js +36 -6
  11. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts +8 -0
  12. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.d.ts.map +1 -0
  13. package/src/engine/graphics/hair/GroomSerializationUpgrader_1_2.js +44 -0
  14. package/src/engine/graphics/hair/groom_bake_shelter.d.ts +33 -0
  15. package/src/engine/graphics/hair/groom_bake_shelter.d.ts.map +1 -0
  16. package/src/engine/graphics/hair/groom_bake_shelter.js +288 -0
  17. package/src/engine/graphics/hair/groom_build_group.d.ts +10 -2
  18. package/src/engine/graphics/hair/groom_build_group.d.ts.map +1 -1
  19. package/src/engine/graphics/hair/groom_build_group.js +8 -2
  20. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts +119 -0
  21. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts.map +1 -0
  22. package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js +563 -0
  23. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.d.ts +11 -0
  24. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.d.ts.map +1 -0
  25. package/src/generation/wfc/GRID_WFC_PIECE_SOCKET_PREFIX.js +10 -0
  26. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts +123 -0
  27. package/src/generation/wfc/GridWFCCompiledTileSet.d.ts.map +1 -0
  28. package/src/generation/wfc/GridWFCCompiledTileSet.js +355 -0
  29. package/src/generation/wfc/GridWFCEdge.d.ts +13 -0
  30. package/src/generation/wfc/GridWFCEdge.d.ts.map +1 -0
  31. package/src/generation/wfc/GridWFCEdge.js +14 -0
  32. package/src/generation/wfc/GridWFCTileSet.d.ts +120 -0
  33. package/src/generation/wfc/GridWFCTileSet.d.ts.map +1 -0
  34. package/src/generation/wfc/GridWFCTileSet.js +275 -0
  35. package/src/shade/renderer/hair/GPUHairSystem.d.ts.map +1 -1
  36. package/src/shade/renderer/hair/GPUHairSystem.js +55 -11
  37. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.d.ts.map +1 -1
  38. package/src/shade/renderer/hair/HAIR_DATABASE_SPEC.js +4 -0
  39. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts +77 -15
  40. package/src/shade/renderer/hair/HAIR_SIMULATION.d.ts.map +1 -1
  41. package/src/shade/renderer/hair/HAIR_SIMULATION.js +104 -17
  42. package/src/shade/renderer/hair/chunk_hair_guide.d.ts +9 -2
  43. package/src/shade/renderer/hair/chunk_hair_guide.d.ts.map +1 -1
  44. package/src/shade/renderer/hair/chunk_hair_guide.js +30 -2
  45. package/src/shade/renderer/hair/shader_hair_simulate.d.ts +27 -18
  46. package/src/shade/renderer/hair/shader_hair_simulate.d.ts.map +1 -1
  47. package/src/shade/renderer/hair/shader_hair_simulate.js +174 -83
@@ -14,6 +14,8 @@
14
14
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
15
15
  * @property {number} [width] metres, for curves that carry no widths
16
16
  * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
17
+ * @property {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air
18
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
17
19
  */
18
20
  /**
19
21
  * Whether `n` is `2^k + 1` for some `k ≥ 0`, within what a group may hold.
@@ -42,13 +44,14 @@ export function groom_point_count_for(curves: GroomCurves, tolerance: number): n
42
44
  /**
43
45
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
44
46
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
45
- * from what was quantized, and the guides chosen from it (`groom_build_guides`).
47
+ * from what was quantized, the guides chosen from it (`groom_build_guides`), and how the hair shelters itself from
48
+ * the air worked out for them (`groom_bake_shelter`).
46
49
  *
47
50
  * @param {GroomCurves} curves
48
51
  * @param {GroomBuildOptions} options
49
52
  * @returns {GroomGroup}
50
53
  */
51
- export function groom_build_group(curves: GroomCurves, { name, point_count, width, guide_tolerance }: GroomBuildOptions): GroomGroup;
54
+ export function groom_build_group(curves: GroomCurves, { name, point_count, width, guide_tolerance, solid }: GroomBuildOptions): GroomGroup;
52
55
  /**
53
56
  * Curves as an importer or a generator hands them over: any number of points a curve.
54
57
  */
@@ -85,6 +88,11 @@ export type GroomBuildOptions = {
85
88
  * metres: how far a strand strays from the guide it follows (`groom_build_guides`)
86
89
  */
87
90
  guide_tolerance?: number;
91
+ /**
92
+ * what the air
93
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
94
+ */
95
+ solid?: import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D | null;
88
96
  };
89
97
  import { GroomGroup } from "./Groom.js";
90
98
  //# sourceMappingURL=groom_build_group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;GAQG;AACH,0CAJW,WAAW,iDACX,iBAAiB,GACf,UAAU,CAwItB;;;;;;;;eApZa,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;sBACN,MAAM;;2BArBb,YAAY"}
1
+ {"version":3,"file":"groom_build_group.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/hair/groom_build_group.js"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,8CAHW,MAAM,GACJ,OAAO,CAUnB;AA6ED;;;;;;GAMG;AACH,+CAHW,UAAU,GACR,YAAY,CA6CxB;AAED;;;;;;;GAOG;AACH,8CAJW,WAAW,aACX,MAAM,GACJ,MAAM,CA+ClB;AAkDD;;;;;;;;;GASG;AACH,0CAJW,WAAW,wDACX,iBAAiB,GACf,UAAU,CA0ItB;;;;;;;;eAzZa,YAAY,GAAC,YAAY;;;;YACzB,WAAW,GAAC,MAAM,EAAE;;;;;YACpB,YAAY,GAAC,YAAY,GAAC,IAAI;;;;gBAE9B,UAAU,GAAC,IAAI;;;WAKf,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;sBACN,MAAM;;;;;YACN,OAAO,gDAAgD,EAAE,eAAe,GAAC,IAAI;;2BAvBpF,YAAY"}
@@ -6,6 +6,7 @@ import {
6
6
  GROOM_POINT_WORDS,
7
7
  GroomGroup
8
8
  } from "./Groom.js";
9
+ import { groom_bake_shelter } from "./groom_bake_shelter.js";
9
10
  import { groom_build_guides, GROOM_GUIDE_DEFAULT_TOLERANCE } from "./groom_build_guides.js";
10
11
  import { groom_rank_order } from "./groom_rank_order.js";
11
12
  import { groom_root_spacing } from "./groom_root_spacing.js";
@@ -27,6 +28,8 @@ import { groom_root_spacing } from "./groom_root_spacing.js";
27
28
  * @property {number} point_count points a strand is resampled to, `2^k + 1`
28
29
  * @property {number} [width] metres, for curves that carry no widths
29
30
  * @property {number} [guide_tolerance] metres: how far a strand strays from the guide it follows (`groom_build_guides`)
31
+ * @property {import("../../../core/geom/3d/shape/AbstractShape3D.js").AbstractShape3D|null} [solid] what the air
32
+ * does not pass, in the curves' metres, such as the head the hair grows on (`groom_bake_shelter`)
30
33
  */
31
34
 
32
35
  /**
@@ -278,7 +281,8 @@ function sample_at(positions, lengths, first, count, s, out, out_offset) {
278
281
  /**
279
282
  * Make a group from curves: each resampled to `point_count` points evenly along its arc length, the strands put in
280
283
  * rank order (`groom_rank_order`), the points quantized inside the group's bounds, and the decimation table taken
281
- * from what was quantized, and the guides chosen from it (`groom_build_guides`).
284
+ * from what was quantized, the guides chosen from it (`groom_build_guides`), and how the hair shelters itself from
285
+ * the air worked out for them (`groom_bake_shelter`).
282
286
  *
283
287
  * @param {GroomCurves} curves
284
288
  * @param {GroomBuildOptions} options
@@ -288,7 +292,8 @@ export function groom_build_group(curves, {
288
292
  name = "",
289
293
  point_count,
290
294
  width = 70e-6,
291
- guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE
295
+ guide_tolerance = GROOM_GUIDE_DEFAULT_TOLERANCE,
296
+ solid = null
292
297
  }) {
293
298
  assert.ok(groom_point_count_is_valid(point_count), `point_count ${point_count} is not 2^k + 1 within ${GROOM_POINT_COUNT_MAX}`);
294
299
 
@@ -416,6 +421,7 @@ export function groom_build_group(curves, {
416
421
  group.root_spacing = groom_root_spacing(group);
417
422
 
418
423
  groom_build_guides(group, guide_tolerance);
424
+ groom_bake_shelter(group, solid);
419
425
 
420
426
  return group;
421
427
  }
@@ -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"}