@woosh/meep-engine 2.85.18 → 2.85.20
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
|
@@ -16,6 +16,16 @@ export class ThemeEngine {
|
|
|
16
16
|
*/
|
|
17
17
|
private __assetManager;
|
|
18
18
|
set assetManager(arg: any);
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {number} v
|
|
22
|
+
*/
|
|
23
|
+
set seed(arg: number);
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @returns {number}
|
|
27
|
+
*/
|
|
28
|
+
get seed(): number;
|
|
19
29
|
/**
|
|
20
30
|
*
|
|
21
31
|
* @param {AreaTheme} theme
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeEngine.d.ts","sourceRoot":"","sources":["../../../../src/generation/theme/ThemeEngine.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThemeEngine.d.ts","sourceRoot":"","sources":["../../../../src/generation/theme/ThemeEngine.js"],"names":[],"mappings":"AAsFA;IAEI;;;OAGG;IACH,OAFU,uBAAuB,CAEN;IAE3B;;;OAGG;IACH,cAFqB,MAAM,CAEF;IAEzB;;;;OAIG;IACH,uBAAsB;IAEtB,2BAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,4BAUC;IAED;;;;;;OAMG;IACH,4BALW,WAAW,KACX,MAAM,KACN,MAAM,GACJ,MAAM,CA8BlB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,gDAGJ,IAAI,CAmChB;IAED;;;;;OAKG;IACH,sDAFa,SAAS,CAiLrB;IAED;;;;;;OAMG;IACH,+DAHW,MAAM,GACJ,IAAI,GAAC,SAAS,CAoG1B;IAED;;;;OAIG;IACH,kEAqCC;IAED;;;;OAIG;IACH,iCAFa,IAAI,CAIhB;IAED;;;;OAIG;IACH,uCAHa,SAAS,CAYrB;IAED;;;;;OAKG;IACH,oDAFa,SAAS,CA2DrB;CACJ;6BAloB4B,8CAA8C;iBAK1D,iCAAiC;sBAC5B,sCAAsC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {assert} from "../../core/assert.js";
|
|
2
|
-
import {binarySearchLowIndex} from "../../core/collection/array/binarySearchLowIndex.js";
|
|
3
|
-
import {HashMap} from "../../core/collection/map/HashMap.js";
|
|
4
|
-
import {QuadTreeNode} from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
5
|
-
import {randomFloatBetween} from "../../core/math/random/randomFloatBetween.js";
|
|
6
|
-
import {seededRandom} from "../../core/math/random/seededRandom.js";
|
|
7
|
-
import {number_compare_ascending} from "../../core/primitives/numbers/number_compare_ascending.js";
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
import { binarySearchLowIndex } from "../../core/collection/array/binarySearchLowIndex.js";
|
|
3
|
+
import { HashMap } from "../../core/collection/map/HashMap.js";
|
|
4
|
+
import { QuadTreeNode } from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
5
|
+
import { randomFloatBetween } from "../../core/math/random/randomFloatBetween.js";
|
|
6
|
+
import { seededRandom } from "../../core/math/random/seededRandom.js";
|
|
7
|
+
import { number_compare_ascending } from "../../core/primitives/numbers/number_compare_ascending.js";
|
|
8
8
|
import Future from "../../core/process/Future.js";
|
|
9
9
|
import Task from "../../core/process/task/Task.js";
|
|
10
10
|
import TaskGroup from "../../core/process/task/TaskGroup.js";
|
|
11
|
-
import {TaskSignal} from "../../core/process/task/TaskSignal.js";
|
|
12
|
-
import {actionTask} from "../../core/process/task/util/actionTask.js";
|
|
13
|
-
import {countTask} from "../../core/process/task/util/countTask.js";
|
|
14
|
-
import {emptyTask} from "../../core/process/task/util/emptyTask.js";
|
|
15
|
-
import {futureTask} from "../../core/process/task/util/futureTask.js";
|
|
16
|
-
import {TerrainLayer} from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
17
|
-
import {TerrainFlags} from "../../engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
18
|
-
import {obtainTerrain} from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
19
|
-
import {Sampler2D} from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
20
|
-
import {TerrainLayerRuleAggregator} from "./TerrainLayerRuleAggregator.js";
|
|
11
|
+
import { TaskSignal } from "../../core/process/task/TaskSignal.js";
|
|
12
|
+
import { actionTask } from "../../core/process/task/util/actionTask.js";
|
|
13
|
+
import { countTask } from "../../core/process/task/util/countTask.js";
|
|
14
|
+
import { emptyTask } from "../../core/process/task/util/emptyTask.js";
|
|
15
|
+
import { futureTask } from "../../core/process/task/util/futureTask.js";
|
|
16
|
+
import { TerrainLayer } from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
17
|
+
import { TerrainFlags } from "../../engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
18
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
19
|
+
import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
20
|
+
import { TerrainLayerRuleAggregator } from "./TerrainLayerRuleAggregator.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
@@ -52,6 +52,38 @@ function prepare_terrain_for_themes(layer_mapping, themes) {
|
|
|
52
52
|
return max;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {Terrain} terrain
|
|
58
|
+
* @returns {Task}
|
|
59
|
+
*/
|
|
60
|
+
function makeTaskEnsureAllTiles(terrain) {
|
|
61
|
+
return futureTask(new Future((resolve, reject) => {
|
|
62
|
+
|
|
63
|
+
const is_linked = terrain.getFlag(TerrainFlags.Linked);
|
|
64
|
+
|
|
65
|
+
if (!is_linked) {
|
|
66
|
+
terrain.startBuildService();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!terrain.getFlag(TerrainFlags.Built)) {
|
|
70
|
+
terrain.buildNonVisual();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
terrain.__tiles.rebuild();
|
|
74
|
+
|
|
75
|
+
terrain.promiseAllTiles()
|
|
76
|
+
.then(resolve, reject)
|
|
77
|
+
.finally(() => {
|
|
78
|
+
if (!is_linked && !terrain.getFlag(TerrainFlags.Linked)) {
|
|
79
|
+
// cleanup after ourselves
|
|
80
|
+
terrain.stopBuildService();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
}), 'Wait for terrain tiles to be built');
|
|
85
|
+
}
|
|
86
|
+
|
|
55
87
|
export class ThemeEngine {
|
|
56
88
|
|
|
57
89
|
/**
|
|
@@ -77,6 +109,22 @@ export class ThemeEngine {
|
|
|
77
109
|
this.__assetManager = v;
|
|
78
110
|
}
|
|
79
111
|
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {number} v
|
|
115
|
+
*/
|
|
116
|
+
set seed(v) {
|
|
117
|
+
this.random.setCurrentSeed(v);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
get seed() {
|
|
125
|
+
return this.random.getCurrentSeed();
|
|
126
|
+
}
|
|
127
|
+
|
|
80
128
|
/**
|
|
81
129
|
*
|
|
82
130
|
* @param {AreaTheme} theme
|
|
@@ -180,8 +228,8 @@ export class ThemeEngine {
|
|
|
180
228
|
*/
|
|
181
229
|
applyTerrainThemes(grid, terrain) {
|
|
182
230
|
|
|
183
|
-
|
|
184
231
|
assert.notNull(terrain);
|
|
232
|
+
assert.notNull(this.__assetManager, 'assetManager');
|
|
185
233
|
|
|
186
234
|
const width = grid.width;
|
|
187
235
|
const height = grid.height;
|
|
@@ -255,7 +303,7 @@ export class ThemeEngine {
|
|
|
255
303
|
});
|
|
256
304
|
|
|
257
305
|
terrain.clearFlag(TerrainFlags.Built);
|
|
258
|
-
terrain.build(
|
|
306
|
+
terrain.build(this.__assetManager);
|
|
259
307
|
|
|
260
308
|
splatWeightData = splat.weightData;
|
|
261
309
|
}, 'Initialize');
|
|
@@ -540,70 +588,59 @@ export class ThemeEngine {
|
|
|
540
588
|
apply(grid, ecd) {
|
|
541
589
|
const terrain = obtainTerrain(ecd);
|
|
542
590
|
|
|
543
|
-
// build terrain tiles
|
|
544
|
-
const tTerrainGeometry = futureTask(new Future((resolve, reject) => {
|
|
545
|
-
|
|
546
|
-
const is_linked = terrain.getFlag(TerrainFlags.Linked);
|
|
547
|
-
|
|
548
|
-
if (!is_linked) {
|
|
549
|
-
terrain.startBuildService();
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (!terrain.getFlag(TerrainFlags.Built)) {
|
|
553
|
-
terrain.buildNonVisual();
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
terrain.__tiles.rebuild();
|
|
557
|
-
|
|
558
|
-
terrain.promiseAllTiles()
|
|
559
|
-
.then(resolve, reject)
|
|
560
|
-
.finally(() => {
|
|
561
|
-
if (!is_linked && !terrain.getFlag(TerrainFlags.Linked)) {
|
|
562
|
-
// cleanup after ourselves
|
|
563
|
-
terrain.stopBuildService();
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
}), 'Wait for terrain tiles');
|
|
568
|
-
|
|
569
591
|
const tInitializeThemes = this.initializeThemes(this.random(), ecd, grid);
|
|
570
592
|
|
|
571
|
-
const tTerrain = this.applyTerrainThemes(grid, terrain);
|
|
572
|
-
|
|
573
593
|
const tNodes = this.applyNodes(grid, ecd);
|
|
574
594
|
|
|
575
595
|
const tCells = this.applyCellRules(grid, ecd);
|
|
576
596
|
|
|
577
|
-
tTerrain.addDependency(tInitializeThemes);
|
|
578
|
-
|
|
579
597
|
tNodes.addDependencies([
|
|
580
598
|
tInitializeThemes,
|
|
581
|
-
tTerrainGeometry,
|
|
582
|
-
tTerrain
|
|
583
599
|
]);
|
|
584
600
|
|
|
585
601
|
tCells.addDependency(tInitializeThemes);
|
|
586
|
-
tTerrainGeometry.addDependency(tCells);
|
|
587
602
|
|
|
588
603
|
const tOptimize = this.optimize(ecd);
|
|
589
604
|
|
|
590
|
-
const tUpdateTerrain = this.updateTerrain(terrain);
|
|
591
|
-
|
|
592
|
-
tUpdateTerrain.addDependencies([
|
|
593
|
-
tTerrain,
|
|
594
|
-
tNodes,
|
|
595
|
-
tCells,
|
|
596
|
-
tTerrainGeometry
|
|
597
|
-
]);
|
|
598
|
-
|
|
599
605
|
tOptimize.addDependencies([
|
|
600
|
-
tUpdateTerrain,
|
|
601
|
-
tTerrain,
|
|
602
606
|
tNodes,
|
|
603
607
|
tCells,
|
|
604
608
|
tInitializeThemes
|
|
605
609
|
]);
|
|
606
610
|
|
|
607
|
-
|
|
611
|
+
const subtasks = [tInitializeThemes, tNodes, tCells, tOptimize];
|
|
612
|
+
|
|
613
|
+
if (terrain !== null) {
|
|
614
|
+
// build terrain tiles
|
|
615
|
+
const tTerrainGeometry = makeTaskEnsureAllTiles(terrain);
|
|
616
|
+
const tTerrain = this.applyTerrainThemes(grid, terrain);
|
|
617
|
+
tTerrain.addDependency(tInitializeThemes);
|
|
618
|
+
|
|
619
|
+
const tUpdateTerrain = this.updateTerrain(terrain);
|
|
620
|
+
|
|
621
|
+
tUpdateTerrain.addDependencies([
|
|
622
|
+
tTerrain,
|
|
623
|
+
tNodes,
|
|
624
|
+
tCells,
|
|
625
|
+
tTerrainGeometry
|
|
626
|
+
]);
|
|
627
|
+
|
|
628
|
+
tNodes.addDependencies([
|
|
629
|
+
tTerrain,
|
|
630
|
+
tTerrainGeometry,
|
|
631
|
+
]);
|
|
632
|
+
tTerrainGeometry.addDependency(tCells);
|
|
633
|
+
|
|
634
|
+
tOptimize.addDependencies([
|
|
635
|
+
tUpdateTerrain,
|
|
636
|
+
tTerrain,
|
|
637
|
+
]);
|
|
638
|
+
|
|
639
|
+
subtasks.push(tTerrainGeometry, tTerrain, tUpdateTerrain);
|
|
640
|
+
} else {
|
|
641
|
+
console.warn(`No terrain present, skipping terrain theming`);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return new TaskGroup(subtasks);
|
|
608
645
|
}
|
|
609
646
|
}
|