@woosh/meep-engine 2.54.0 → 2.55.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.
- package/package.json +1 -1
- package/src/core/__module.js +1 -1
- package/src/core/cache/Cache.js +1 -1
- package/src/core/collection/Stack.js +11 -14
- package/src/core/collection/array/array_contains_duplicates.js +5 -2
- package/src/core/collection/array/array_contains_duplicates.spec.js +14 -0
- package/src/core/collection/array/array_copy_entire.js +6 -11
- package/src/core/collection/array/array_get_index_in_range.js +5 -0
- package/src/core/collection/array/array_get_index_in_range.spec.js +16 -0
- package/src/core/collection/array/groupArrayBy.js +1 -1
- package/src/core/collection/array/isArrayEqual.js +4 -1
- package/src/core/collection/array/randomizeArrayElementOrder.js +1 -0
- package/src/core/collection/array/randomizeArrayElementOrder.spec.js +27 -0
- package/src/core/collection/heap/Uin32Heap.spec.js +64 -0
- package/src/core/collection/heap/Uint32Heap.js +6 -2
- package/src/core/collection/list/List.js +1 -0
- package/src/core/collection/{HashMap.js → map/HashMap.js} +10 -10
- package/src/core/collection/{HashMap.spec.js → map/HashMap.spec.js} +1 -1
- package/src/core/collection/{ObservedMap.js → map/ObservedMap.js} +1 -1
- package/src/core/collection/{HashSet.js → set/HashSet.js} +4 -3
- package/src/core/collection/{Set.d.ts → set/Set.d.ts} +1 -1
- package/src/core/collection/{Set.js → set/Set.js} +17 -14
- package/src/core/geom/2d/aabb/AABB2.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +3 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.js +1 -1
- package/src/core/model/ObservedInteger.js +12 -7
- package/src/core/model/ObservedString.js +10 -8
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
- package/src/core/model/object/ImmutableObjectPool.js +1 -1
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +1 -1
- package/src/engine/asset/AssetManager.js +3 -3
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/ecs/EntityBlueprint.js +8 -10
- package/src/engine/ecs/animation/AnimationSerializationAdapter.js +2 -5
- package/src/engine/ecs/components/Motion.js +0 -27
- package/src/engine/ecs/components/MotionSerializationAdapter.js +26 -0
- package/src/engine/ecs/components/PropertySet.js +0 -29
- package/src/engine/ecs/components/PropertySetSerializationAdapter.js +29 -0
- package/src/engine/ecs/components/SerializationMetadata.js +0 -28
- package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.js +26 -0
- package/src/engine/ecs/components/Steering.js +0 -35
- package/src/engine/ecs/components/SteeringSerializationAdapter.js +34 -0
- package/src/engine/ecs/components/Tag.js +6 -102
- package/src/engine/ecs/components/TagSerializationAdapter.js +44 -0
- package/src/engine/ecs/components/TagSerializationUpgrader_0_1.js +18 -0
- package/src/engine/ecs/components/Timer.js +1 -1
- package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleCooldownDescription.js +10 -14
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +31 -39
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.js +1 -1
- package/src/engine/ecs/dynamic_actions/{DynamicRuleDescriptionTable.spec.js → rules/DynamicRuleDescriptionTable.spec.js} +12 -12
- package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +2 -5
- package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +2 -5
- package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +5 -8
- package/src/engine/ecs/gui/GUIElementSerializationAdapter.js +2 -5
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.js +3 -6
- package/src/engine/ecs/gui/position/ViewportPosition.js +2 -5
- package/src/engine/ecs/ik/IKConstraint.js +95 -0
- package/src/engine/ecs/ik/InverseKinematics.js +10 -169
- package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +72 -0
- package/src/engine/ecs/speaker/Voice.js +5 -8
- package/src/engine/ecs/speaker/VoiceSystem.js +15 -19
- package/src/engine/ecs/speaker/lines/LineDescription.js +20 -25
- package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +15 -19
- package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +7 -0
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
- package/src/engine/ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js +6 -9
- package/src/engine/ecs/team/TeamSerializationAdapter.js +2 -5
- package/src/engine/ecs/terrain/ecs/Terrain.spec.js +5 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +23 -21
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +2 -5
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -40
- package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +7 -10
- package/src/engine/ecs/tooltip/TooltipComponent.spec.js +47 -0
- package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.js +2 -5
- package/src/engine/ecs/transform/Transform.spec.js +52 -0
- package/src/engine/ecs/transform/TransformSerializationAdapter.js +2 -5
- package/src/engine/ecs/transform-attachment/TransformAttachment.js +18 -19
- package/src/engine/graphics/ecs/animation/AnimationController.js +20 -129
- package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.js +27 -0
- package/src/engine/graphics/ecs/animation/AnimationRule.js +79 -0
- package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.js +9 -11
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.js +3 -5
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +2 -6
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +3 -15
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +2 -4
- package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +1 -1
- package/src/engine/graphics/ecs/light/LightSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.js +2 -5
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +3 -0
- package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +1 -1
- package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +2 -5
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
- package/src/engine/graphics/material/manager/MaterialManager.js +1 -1
- package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
- package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -5
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.js +2 -5
- package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -1
- package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
- package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js +2 -5
- package/src/engine/grid/grid2transform/GridPosition2Transform.js +11 -13
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +3 -5
- package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.js +2 -5
- package/src/engine/grid/position/GridPositionSerializationAdapter.js +2 -5
- package/src/engine/grid/transform2grid/Transform2GridPosition.js +10 -13
- package/src/engine/input/devices/KeyboardDevice.js +5 -2
- package/src/engine/input/devices/KeyboardDevice.spec.js +12 -0
- package/src/engine/input/devices/PointerDevice.js +5 -1
- package/src/engine/input/ecs/components/Input.js +37 -11
- package/src/engine/input/ecs/ism/InputBinding.js +30 -12
- package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +7 -10
- package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +2 -5
- package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +2 -6
- package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +2 -5
- package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.js +2 -5
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +12 -13
- package/src/engine/knowledge/database/StaticKnowledgeDatabase.spec.js +23 -0
- package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +2 -5
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +2 -5
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +25 -0
- package/src/engine/options/OptionAbstract.js +6 -5
- package/src/engine/options/OptionGroup.js +13 -25
- package/src/engine/options/OptionGroup.spec.js +61 -0
- package/src/engine/save/storage/InMemoryStorage.js +3 -2
- package/src/engine/sound/ecs/SoundController.js +2 -6
- package/src/engine/sound/ecs/SoundListener.js +3 -21
- package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.js +2 -6
- package/src/generation/theme/ThemeEngine.js +1 -1
- package/src/core/collection/LazyStream.js +0 -23
- package/src/core/collection/LazyStream.spec.js +0 -13
- package/src/core/collection/heap/BinaryHeap.js +0 -153
- package/src/engine/ecs/components/GeometryBVH.js +0 -44
- package/src/engine/ecs/systems/GeometryBVHSystem.js +0 -36
- /package/src/core/collection/{HashMap.d.ts → map/HashMap.d.ts} +0 -0
- /package/src/core/collection/{HashSet.d.ts → set/HashSet.d.ts} +0 -0
|
@@ -4,12 +4,9 @@ import { Blackboard } from "./Blackboard.js";
|
|
|
4
4
|
import { BlackboardValue } from "./BlackboardValue.js";
|
|
5
5
|
|
|
6
6
|
export class BlackboardSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
8
|
+
klass = Blackboard;
|
|
9
|
+
version = 0;
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
*
|
|
@@ -18,22 +18,21 @@ export const StaticKnowledgeState = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export class StaticKnowledgeDatabase {
|
|
21
|
-
constructor() {
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {ObservedEnum<StaticKnowledgeState>}
|
|
25
|
+
*/
|
|
26
|
+
__state = new ObservedEnum(StaticKnowledgeState.Initial, StaticKnowledgeState);
|
|
28
27
|
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {StaticKnowledgeDataTableDescriptor[]}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
__specs = [];
|
|
35
|
+
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Reset database, drop all table data
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StaticKnowledgeDatabase } from "./StaticKnowledgeDatabase.js";
|
|
2
|
+
import { StaticKnowledgeDataTable } from "./StaticKnowledgeDataTable.js";
|
|
3
|
+
|
|
4
|
+
test("constructor does not throw", () => {
|
|
5
|
+
new StaticKnowledgeDatabase()
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("reset empty", () => {
|
|
9
|
+
const database = new StaticKnowledgeDatabase();
|
|
10
|
+
|
|
11
|
+
database.reset();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("add/get", () => {
|
|
15
|
+
const database = new StaticKnowledgeDatabase();
|
|
16
|
+
|
|
17
|
+
const table = new StaticKnowledgeDataTable();
|
|
18
|
+
database.add("x", "y", table)
|
|
19
|
+
|
|
20
|
+
const actual = database.getTable('x');
|
|
21
|
+
|
|
22
|
+
expect(actual).toBe(table);
|
|
23
|
+
});
|
|
@@ -6,12 +6,9 @@ import Path from "./Path.js";
|
|
|
6
6
|
const v0 = new Vector3();
|
|
7
7
|
|
|
8
8
|
export class PathSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
10
|
+
klass = Path;
|
|
11
|
+
version = 3;
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
*
|
|
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/Bin
|
|
|
2
2
|
import PathFollower from "./PathFollower.js";
|
|
3
3
|
|
|
4
4
|
export class PathFollowerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
6
|
+
klass = PathFollower;
|
|
7
|
+
version = 3;
|
|
11
8
|
|
|
12
9
|
/**
|
|
13
10
|
*
|
|
@@ -5,3 +5,28 @@ test("sanity check on 1x1 grid", () => {
|
|
|
5
5
|
|
|
6
6
|
expect(path).toEqual([0]);
|
|
7
7
|
});
|
|
8
|
+
|
|
9
|
+
test("sanity check on 2x1 grid", () => {
|
|
10
|
+
const path = find_path_on_grid_astar(
|
|
11
|
+
[0, 0], 2, 1,
|
|
12
|
+
0, 1,
|
|
13
|
+
0, 0, 1
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(path).toEqual([0, 1]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("sanity check on 2x2 grid", () => {
|
|
20
|
+
|
|
21
|
+
const path = find_path_on_grid_astar(
|
|
22
|
+
[
|
|
23
|
+
0, 0,
|
|
24
|
+
1, 0
|
|
25
|
+
],
|
|
26
|
+
2, 2,
|
|
27
|
+
0, 3,
|
|
28
|
+
0, 0, 1
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(path).toEqual([0, 1, 3]);
|
|
32
|
+
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export class OptionAbstract {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @type {OptionGroup|null}
|
|
5
|
+
*/
|
|
6
|
+
parent = null;
|
|
7
|
+
|
|
2
8
|
/**
|
|
3
9
|
*
|
|
4
10
|
* @param {string} id
|
|
@@ -11,11 +17,6 @@ export class OptionAbstract {
|
|
|
11
17
|
*/
|
|
12
18
|
this.id = id;
|
|
13
19
|
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {OptionGroup|null}
|
|
17
|
-
*/
|
|
18
|
-
this.parent = null;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -8,20 +8,12 @@ function isOption(c) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class OptionGroup extends OptionAbstract {
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
13
|
*
|
|
13
|
-
* @
|
|
14
|
-
* @constructor
|
|
14
|
+
* @type {Array<OptionGroup|Option>}
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
super(id);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @type {Array<OptionGroup|Option>}
|
|
22
|
-
*/
|
|
23
|
-
this.children = [];
|
|
24
|
-
}
|
|
16
|
+
children = [];
|
|
25
17
|
|
|
26
18
|
/**
|
|
27
19
|
*
|
|
@@ -141,6 +133,7 @@ export class OptionGroup extends OptionAbstract {
|
|
|
141
133
|
*
|
|
142
134
|
* @param {string} path
|
|
143
135
|
* @param {Storage} storage
|
|
136
|
+
* @returns {Promise}
|
|
144
137
|
*/
|
|
145
138
|
attachToStorage(path, storage) {
|
|
146
139
|
const group = this;
|
|
@@ -151,20 +144,6 @@ export class OptionGroup extends OptionAbstract {
|
|
|
151
144
|
storage.load(key, resolve, reject);
|
|
152
145
|
});
|
|
153
146
|
|
|
154
|
-
p
|
|
155
|
-
.then((loaded) => {
|
|
156
|
-
try {
|
|
157
|
-
group.fromJSON(JSON.parse(loaded));
|
|
158
|
-
} catch (e) {
|
|
159
|
-
console.log('Failed to load options')
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
.catch(console.error)
|
|
163
|
-
.finally(() => {
|
|
164
|
-
|
|
165
|
-
group.traverseOptions(op => op.on.written.add(store));
|
|
166
|
-
});
|
|
167
|
-
|
|
168
147
|
|
|
169
148
|
function store() {
|
|
170
149
|
const json = group.toJSON();
|
|
@@ -174,6 +153,15 @@ export class OptionGroup extends OptionAbstract {
|
|
|
174
153
|
storage.store(key, value, noop, console.error, noop);
|
|
175
154
|
}
|
|
176
155
|
|
|
156
|
+
return p
|
|
157
|
+
.then((loaded) => {
|
|
158
|
+
group.fromJSON(JSON.parse(loaded));
|
|
159
|
+
})
|
|
160
|
+
.finally(() => {
|
|
161
|
+
|
|
162
|
+
group.traverseOptions(op => op.on.written.add(store));
|
|
163
|
+
});
|
|
164
|
+
|
|
177
165
|
}
|
|
178
166
|
}
|
|
179
167
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { OptionGroup } from "./OptionGroup.js";
|
|
2
|
+
import { noop } from "../../core/function/Functions.js";
|
|
3
|
+
import { InMemoryStorage } from "../save/storage/InMemoryStorage.js";
|
|
4
|
+
|
|
5
|
+
test("constructor", () => {
|
|
6
|
+
const group = new OptionGroup("x");
|
|
7
|
+
|
|
8
|
+
expect(group.id).toEqual("x");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("resolve non-existent", () => {
|
|
12
|
+
|
|
13
|
+
const group = new OptionGroup("x");
|
|
14
|
+
|
|
15
|
+
expect(() => group.resolve(['a'])).toThrow();
|
|
16
|
+
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("add/get", () => {
|
|
20
|
+
const group = new OptionGroup("x");
|
|
21
|
+
|
|
22
|
+
group.add("a", noop, noop, {});
|
|
23
|
+
|
|
24
|
+
expect(group.getChildById('a')).toBeDefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("to/from JSON", () => {
|
|
28
|
+
const group = new OptionGroup("x");
|
|
29
|
+
|
|
30
|
+
const writer = jest.fn();
|
|
31
|
+
|
|
32
|
+
group.add("a", () => 7, writer, {});
|
|
33
|
+
|
|
34
|
+
const json = group.toJSON();
|
|
35
|
+
|
|
36
|
+
expect(json).toEqual({ a: 7 });
|
|
37
|
+
|
|
38
|
+
group.fromJSON({ a: 13 });
|
|
39
|
+
|
|
40
|
+
expect(writer).toHaveBeenCalledTimes(1);
|
|
41
|
+
expect(writer).toHaveBeenCalledWith(13);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
test("attach to storage", async () => {
|
|
46
|
+
const group = new OptionGroup("x");
|
|
47
|
+
|
|
48
|
+
const op_a = {
|
|
49
|
+
value: 3
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
group.add('a', () => op_a.value, v => op_a.value = v, {});
|
|
53
|
+
|
|
54
|
+
const storage = new InMemoryStorage();
|
|
55
|
+
|
|
56
|
+
storage.store('options', JSON.stringify({ a: 13 }));
|
|
57
|
+
|
|
58
|
+
await group.attachToStorage('options', storage);
|
|
59
|
+
|
|
60
|
+
expect(op_a.value).toEqual(13);
|
|
61
|
+
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Storage from "../Storage.js";
|
|
2
2
|
import { collectIteratorValueToArray } from "../../../core/collection/collectIteratorValueToArray.js";
|
|
3
|
+
import { noop } from "../../../core/function/Functions.js";
|
|
3
4
|
|
|
4
5
|
export class InMemoryStorage extends Storage {
|
|
5
6
|
#data = new Map();
|
|
6
7
|
|
|
7
|
-
store(key, value, resolve, reject, progress) {
|
|
8
|
+
store(key, value, resolve=noop, reject, progress) {
|
|
8
9
|
this.#data.set(key, value);
|
|
9
10
|
|
|
10
11
|
resolve();
|
|
@@ -14,7 +15,7 @@ export class InMemoryStorage extends Storage {
|
|
|
14
15
|
resolve(this.#data.get(key));
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
remove(key, resolve, reject) {
|
|
18
|
+
remove(key, resolve=noop, reject) {
|
|
18
19
|
this.#data.delete(key);
|
|
19
20
|
|
|
20
21
|
resolve();
|
|
@@ -146,12 +146,8 @@ export default SoundController;
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
export class SoundControllerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.klass = SoundController;
|
|
153
|
-
this.version = 0;
|
|
154
|
-
}
|
|
149
|
+
klass = SoundController;
|
|
150
|
+
version = 0;
|
|
155
151
|
|
|
156
152
|
/**
|
|
157
153
|
*
|
|
@@ -42,26 +42,8 @@ export default SoundListener;
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
export class SoundListenerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
klass = SoundListener;
|
|
46
|
+
version = 0;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
this.version = 0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {BinaryBuffer} buffer
|
|
55
|
-
* @param {SoundListener} value
|
|
56
|
-
*/
|
|
57
|
-
serialize(buffer, value) {
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {BinaryBuffer} buffer
|
|
63
|
-
* @param {SoundListener} value
|
|
64
|
-
*/
|
|
65
|
-
deserialize(buffer, value) {
|
|
66
|
-
}
|
|
48
|
+
// NO-OP
|
|
67
49
|
}
|
|
@@ -3,13 +3,9 @@ import { SoundEmitter } from "./SoundEmitter.js";
|
|
|
3
3
|
import { SoundTrack } from "./SoundTrack.js";
|
|
4
4
|
|
|
5
5
|
export class SoundEmitterSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this.klass = SoundEmitter;
|
|
10
|
-
this.version = 2;
|
|
11
|
-
}
|
|
12
6
|
|
|
7
|
+
klass = SoundEmitter;
|
|
8
|
+
version = 2;
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
*
|
|
@@ -10,7 +10,7 @@ import TaskGroup from "../../core/process/task/TaskGroup.js";
|
|
|
10
10
|
import Future from "../../core/process/Future.js";
|
|
11
11
|
import { optimizeIndividualMeshesEntitiesToInstances } from "../../engine/ecs/foliage/ecs/InstancedMeshUtils.js";
|
|
12
12
|
import TaskState from "../../core/process/task/TaskState.js";
|
|
13
|
-
import { HashMap } from "../../core/collection/HashMap.js";
|
|
13
|
+
import { HashMap } from "../../core/collection/map/HashMap.js";
|
|
14
14
|
import { TerrainLayer } from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
15
15
|
import { TerrainFlags } from "../../engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
16
16
|
import { binarySearchLowIndex } from "../../core/collection/array/binarySearchLowIndex.js";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template A,B
|
|
3
|
-
* @param {A[]} source
|
|
4
|
-
* @param {function(A,index:number):B} transformer
|
|
5
|
-
* @returns {B[]}
|
|
6
|
-
*/
|
|
7
|
-
export function lazyArrayMap(source, transformer) {
|
|
8
|
-
return new Proxy(source, {
|
|
9
|
-
get(target, p, receiver) {
|
|
10
|
-
if (/^([0-9]+)$/.test(p)) {
|
|
11
|
-
|
|
12
|
-
const targetElement = target[p];
|
|
13
|
-
|
|
14
|
-
const resultElement = transformer(targetElement, p);
|
|
15
|
-
|
|
16
|
-
return resultElement;
|
|
17
|
-
} else {
|
|
18
|
-
|
|
19
|
-
return target[p];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { lazyArrayMap } from "./LazyStream.js";
|
|
2
|
-
|
|
3
|
-
test('lazyArrayMap', () => {
|
|
4
|
-
const source = [1, 2, 3];
|
|
5
|
-
|
|
6
|
-
const map = lazyArrayMap(source, a => a * 2);
|
|
7
|
-
|
|
8
|
-
expect(map.length).toBe(source.length);
|
|
9
|
-
|
|
10
|
-
for (let i = 0; i < source.length; i++) {
|
|
11
|
-
expect(map[i]).toBe(source[i] * 2);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated use {@link FastBinaryHeap} instead
|
|
3
|
-
* @param scoreFunction
|
|
4
|
-
* @constructor
|
|
5
|
-
*/
|
|
6
|
-
function BinaryHeap(scoreFunction) {
|
|
7
|
-
this.content = [];
|
|
8
|
-
this.hash = [];
|
|
9
|
-
this.scoreFunction = scoreFunction;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
BinaryHeap.prototype = {
|
|
13
|
-
push: function (element) {
|
|
14
|
-
const content = this.content;
|
|
15
|
-
const length = content.length;
|
|
16
|
-
// Add the new element to the end of the array.
|
|
17
|
-
content.push(element);
|
|
18
|
-
//update hash
|
|
19
|
-
this.hash[element] = length;
|
|
20
|
-
|
|
21
|
-
// Allow it to sink down.
|
|
22
|
-
this.sinkDown(length);
|
|
23
|
-
},
|
|
24
|
-
pop: function () {
|
|
25
|
-
// Store the first element so we can return it later.
|
|
26
|
-
const content = this.content;
|
|
27
|
-
const hash = this.hash;
|
|
28
|
-
const result = content[0];
|
|
29
|
-
//update hash
|
|
30
|
-
delete hash[result];
|
|
31
|
-
// Get the element at the end of the array.
|
|
32
|
-
const end = content.pop();
|
|
33
|
-
// If there are any elements left, put the end element at the
|
|
34
|
-
// start, and let it bubble up.
|
|
35
|
-
const length = content.length;
|
|
36
|
-
if (length > 0) {
|
|
37
|
-
content[0] = end;
|
|
38
|
-
hash[end] = 0;
|
|
39
|
-
this.bubbleUp(0);
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
},
|
|
43
|
-
contains: function (node) {
|
|
44
|
-
return this.hash[node] !== void 0;
|
|
45
|
-
},
|
|
46
|
-
remove: function (node) {
|
|
47
|
-
|
|
48
|
-
const length = this.content.length;
|
|
49
|
-
const i = this.hash[node];
|
|
50
|
-
|
|
51
|
-
// When it is found, the process seen in 'pop' is repeated
|
|
52
|
-
// to fill up the hole.
|
|
53
|
-
const end = this.content.pop();
|
|
54
|
-
if (i !== length) {
|
|
55
|
-
this.content[i] = end;
|
|
56
|
-
|
|
57
|
-
if (this.scoreFunction(end) < this.scoreFunction(node)) {
|
|
58
|
-
this.sinkDown(i);
|
|
59
|
-
} else {
|
|
60
|
-
this.bubbleUp(i);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
size: function () {
|
|
65
|
-
return this.content.length;
|
|
66
|
-
},
|
|
67
|
-
rescoreElement: function (node) {
|
|
68
|
-
this.sinkDown(this.hash[node]);
|
|
69
|
-
},
|
|
70
|
-
sinkDown: function (n) {
|
|
71
|
-
// Fetch the element that has to be sunk.
|
|
72
|
-
const content = this.content;
|
|
73
|
-
const hash = this.hash;
|
|
74
|
-
const element = content[n];
|
|
75
|
-
|
|
76
|
-
// When at 0, an element can not sink any further.
|
|
77
|
-
while (n > 0) {
|
|
78
|
-
|
|
79
|
-
// Compute the parent element's index, and fetch it.
|
|
80
|
-
const parentN = ((n + 1) >> 1) - 1,
|
|
81
|
-
parent = content[parentN];
|
|
82
|
-
// Swap the elements if the parent is greater.
|
|
83
|
-
if (this.scoreFunction(element) < this.scoreFunction(parent)) {
|
|
84
|
-
content[parentN] = element;
|
|
85
|
-
content[n] = parent;
|
|
86
|
-
//update hash
|
|
87
|
-
hash[element] = parentN;
|
|
88
|
-
hash[parent] = n;
|
|
89
|
-
// Update 'n' to continue at the new position.
|
|
90
|
-
n = parentN;
|
|
91
|
-
}
|
|
92
|
-
// Found a parent that is less, no need to sink any further.
|
|
93
|
-
else {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
bubbleUp: function (n) {
|
|
99
|
-
// Look up the target element and its score.
|
|
100
|
-
const content = this.content;
|
|
101
|
-
const hash = this.hash;
|
|
102
|
-
const scoreFunction = this.scoreFunction;
|
|
103
|
-
const length = content.length,
|
|
104
|
-
element = content[n],
|
|
105
|
-
elemScore = scoreFunction(element);
|
|
106
|
-
|
|
107
|
-
for (; ;) {
|
|
108
|
-
// Compute the indices of the child elements.
|
|
109
|
-
const child2N = (n + 1) << 1,
|
|
110
|
-
child1N = child2N - 1;
|
|
111
|
-
// This is used to store the new position of the element, if any.
|
|
112
|
-
let swap = null,
|
|
113
|
-
child1Score;
|
|
114
|
-
// If the first child exists (is inside the array)...
|
|
115
|
-
if (child1N < length) {
|
|
116
|
-
// Look it up and compute its score.
|
|
117
|
-
const child1 = content[child1N];
|
|
118
|
-
child1Score = scoreFunction(child1);
|
|
119
|
-
|
|
120
|
-
// If the score is less than our element's, we need to swap.
|
|
121
|
-
if (child1Score < elemScore) {
|
|
122
|
-
swap = child1N;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Do the same checks for the other child.
|
|
128
|
-
if (child2N < length) {
|
|
129
|
-
const child2 = content[child2N],
|
|
130
|
-
child2Score = scoreFunction(child2);
|
|
131
|
-
if (child2Score < (swap === null ? elemScore : child1Score)) {
|
|
132
|
-
swap = child2N;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// If the element needs to be moved, swap it, and continue.
|
|
137
|
-
if (swap !== null) {
|
|
138
|
-
const swapContent = content[swap];
|
|
139
|
-
content[n] = swapContent;
|
|
140
|
-
content[swap] = element;
|
|
141
|
-
//update hash
|
|
142
|
-
hash[element] = swap;
|
|
143
|
-
hash[swapContent] = n;
|
|
144
|
-
n = swap;
|
|
145
|
-
}
|
|
146
|
-
// Otherwise, we are done.
|
|
147
|
-
else {
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
export default BinaryHeap;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 02/02/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { Ray as ThreeRay, Vector3 as ThreeVector3 } from 'three';
|
|
5
|
-
|
|
6
|
-
function GeometryBVH(geometry) {
|
|
7
|
-
this.geometry = geometry;
|
|
8
|
-
this.bvh = null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
GeometryBVH.prototype.raycast = (function () {
|
|
12
|
-
const hit = new ThreeVector3();
|
|
13
|
-
const ray = new ThreeRay();
|
|
14
|
-
|
|
15
|
-
function raycast(origin, direction, callback) {
|
|
16
|
-
const geometry = this.geometry;
|
|
17
|
-
const vertices = geometry.vertices;
|
|
18
|
-
let hitCount = 0;
|
|
19
|
-
this.bvh.traverseRayLeafIntersections(origin.x, origin.y, origin.z, direction.x, direction.y, direction.z, function (leaf) {
|
|
20
|
-
const face = leaf.object;
|
|
21
|
-
hitCount++;
|
|
22
|
-
ray.set(origin, direction);
|
|
23
|
-
const vA = vertices[face.a];
|
|
24
|
-
const vB = vertices[face.b];
|
|
25
|
-
const vC = vertices[face.c];
|
|
26
|
-
let hitFound = ray.intersectTriangle(vA, vB, vC, false, hit);
|
|
27
|
-
if (hitFound) {
|
|
28
|
-
callback(hit, face, geometry);
|
|
29
|
-
} else {
|
|
30
|
-
//try opposite way
|
|
31
|
-
hitFound = ray.intersectTriangle(vC, vB, vA, false, hit);
|
|
32
|
-
if (hitFound) {
|
|
33
|
-
callback(hit, face, geometry);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return raycast;
|
|
40
|
-
})();
|
|
41
|
-
|
|
42
|
-
GeometryBVH.typeName = "GeometryBVH";
|
|
43
|
-
|
|
44
|
-
export default GeometryBVH;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 02/02/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { System } from '../System.js';
|
|
5
|
-
import GeometryBVH from '../components/GeometryBVH.js';
|
|
6
|
-
import BVHFromGeometry from '../../graphics/geometry/bvh/BVHFromGeometry.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class GeometryBVHSystem extends System {
|
|
10
|
-
constructor(grid) {
|
|
11
|
-
super();
|
|
12
|
-
|
|
13
|
-
this.dependencies = [GeometryBVH];
|
|
14
|
-
//
|
|
15
|
-
this.entityManager = null;
|
|
16
|
-
this.grid = grid;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
unlink(component, entity) {
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
link(component, entity) {
|
|
23
|
-
//build bvh
|
|
24
|
-
const g = component.geometry;
|
|
25
|
-
//check if bvh exists
|
|
26
|
-
if (component.bvh === null) {
|
|
27
|
-
component.bvh = BVHFromGeometry(g);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
update(timeDelta) {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export default GeometryBVHSystem;
|
|
File without changes
|
|
File without changes
|