@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
package/package.json
CHANGED
package/src/core/__module.js
CHANGED
package/src/core/cache/Cache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
-
import { HashMap } from "../collection/HashMap.js";
|
|
2
|
+
import { HashMap } from "../collection/map/HashMap.js";
|
|
3
3
|
import Signal from "../events/signal/Signal.js";
|
|
4
4
|
import { returnOne, returnZero, strictEquals } from "../function/Functions.js";
|
|
5
5
|
import { CacheElement } from "./CacheElement.js";
|
|
@@ -5,23 +5,20 @@ import Signal from "../events/signal/Signal.js";
|
|
|
5
5
|
* @class
|
|
6
6
|
*/
|
|
7
7
|
export class Stack {
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
|
-
* @
|
|
10
|
+
* @private
|
|
11
|
+
* @type {T[]}
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @private
|
|
15
|
-
* @type {T[]}
|
|
16
|
-
*/
|
|
17
|
-
this.data = [];
|
|
18
|
-
|
|
19
|
-
this.on = {
|
|
20
|
-
removed: new Signal(),
|
|
21
|
-
added: new Signal()
|
|
22
|
-
};
|
|
13
|
+
data = [];
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @readonly
|
|
17
|
+
*/
|
|
18
|
+
on = {
|
|
19
|
+
removed: new Signal(),
|
|
20
|
+
added: new Signal()
|
|
21
|
+
};
|
|
25
22
|
|
|
26
23
|
/**
|
|
27
24
|
* @returns {T[]}
|
|
@@ -11,12 +11,15 @@ export function array_contains_duplicates(
|
|
|
11
11
|
end_index = source.length - 1
|
|
12
12
|
) {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// going to n-1, as we check all elements forward from the current
|
|
15
|
+
const last = end_index - 1;
|
|
16
|
+
|
|
17
|
+
for (let k = start_index; k <= last; k++) {
|
|
15
18
|
|
|
16
19
|
const element = source[k];
|
|
17
20
|
|
|
18
21
|
// look for future occurrences of the same element
|
|
19
|
-
if (source.indexOf(element, k + 1)
|
|
22
|
+
if (source.indexOf(element, k + 1) !== -1) {
|
|
20
23
|
return true;
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { array_contains_duplicates } from "./array_contains_duplicates.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
expect(array_contains_duplicates([])).toBe(false);
|
|
5
|
+
|
|
6
|
+
expect(array_contains_duplicates([1])).toBe(false);
|
|
7
|
+
|
|
8
|
+
expect(array_contains_duplicates([1, 2, 3])).toBe(false);
|
|
9
|
+
|
|
10
|
+
expect(array_contains_duplicates([1, 1])).toBe(true);
|
|
11
|
+
expect(array_contains_duplicates([0, 1, 1])).toBe(true);
|
|
12
|
+
expect(array_contains_duplicates([1, 0, 1])).toBe(true);
|
|
13
|
+
expect(array_contains_duplicates([1, 1, 0])).toBe(true);
|
|
14
|
+
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { array_copy } from "./array_copy.js";
|
|
2
|
+
import { array_shrink_to_size } from "./array_shrink_to_size.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @template T
|
|
3
6
|
* @param {T[]} source
|
|
@@ -5,17 +8,9 @@
|
|
|
5
8
|
*/
|
|
6
9
|
export function array_copy_entire(source, target) {
|
|
7
10
|
|
|
8
|
-
const
|
|
9
|
-
for (let i = 0; i < n; i++) {
|
|
10
|
-
const v = source[i];
|
|
11
|
-
|
|
12
|
-
target[i] = v;
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
const source_length = source.length;
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
array_copy(source, 0, target, 0, source_length);
|
|
14
|
+
array_shrink_to_size(target, source_length);
|
|
17
15
|
|
|
18
|
-
if (n > tL) {
|
|
19
|
-
target.splice(n, tL - n);
|
|
20
|
-
}
|
|
21
16
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} array
|
|
@@ -6,6 +8,9 @@
|
|
|
6
8
|
* @param {number} max_index
|
|
7
9
|
*/
|
|
8
10
|
export function array_get_index_in_range(array, needle, min_index, max_index) {
|
|
11
|
+
assert.lessThanOrEqual(max_index, array.length - 1, 'max_length must is too large');
|
|
12
|
+
assert.isNonNegativeInteger(min_index, 'min_index');
|
|
13
|
+
|
|
9
14
|
for (let i = min_index; i <= max_index; i++) {
|
|
10
15
|
if (array[i] === needle) {
|
|
11
16
|
return i;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { array_get_index_in_range } from "./array_get_index_in_range.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
|
|
5
|
+
expect(array_get_index_in_range([], 1, 0, -1)).toBe(-1);
|
|
6
|
+
expect(array_get_index_in_range([1], 1, 0, 0)).toBe(0);
|
|
7
|
+
|
|
8
|
+
expect(array_get_index_in_range([3, 1], 1, 0, 1)).toBe(1);
|
|
9
|
+
expect(array_get_index_in_range([3, 1], 1, 0, 0)).toBe(-1);
|
|
10
|
+
expect(array_get_index_in_range([3, 1], 1, 1, 1)).toBe(1);
|
|
11
|
+
|
|
12
|
+
expect(array_get_index_in_range([1, 3], 1, 0, 1)).toBe(0);
|
|
13
|
+
expect(array_get_index_in_range([1, 3], 1, 1, 1)).toBe(-1);
|
|
14
|
+
expect(array_get_index_in_range([1, 3], 1, 0, 0)).toBe(0);
|
|
15
|
+
|
|
16
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { randomizeArrayElementOrder } from "./randomizeArrayElementOrder.js";
|
|
2
|
+
|
|
3
|
+
test("sanity", () => {
|
|
4
|
+
|
|
5
|
+
const random = () => 0;
|
|
6
|
+
|
|
7
|
+
const a = [];
|
|
8
|
+
|
|
9
|
+
randomizeArrayElementOrder(random, a);
|
|
10
|
+
|
|
11
|
+
expect(a).toEqual([]);
|
|
12
|
+
|
|
13
|
+
const b = [1];
|
|
14
|
+
|
|
15
|
+
randomizeArrayElementOrder(random, b);
|
|
16
|
+
|
|
17
|
+
expect(b).toEqual([1]);
|
|
18
|
+
|
|
19
|
+
const c = [1, 2, 3];
|
|
20
|
+
|
|
21
|
+
randomizeArrayElementOrder(random, c);
|
|
22
|
+
|
|
23
|
+
expect(c.length).toBe(3);
|
|
24
|
+
expect(c).toContain(1);
|
|
25
|
+
expect(c).toContain(2);
|
|
26
|
+
expect(c).toContain(3);
|
|
27
|
+
});
|
|
@@ -57,3 +57,67 @@ test('insert 5 out of order, retrieve in order', () => {
|
|
|
57
57
|
expect(heap.pop_min()).toBe(3);
|
|
58
58
|
expect(heap.pop_min()).toBe(5);
|
|
59
59
|
});
|
|
60
|
+
|
|
61
|
+
test("remove", () => {
|
|
62
|
+
|
|
63
|
+
const heap = new Uint32Heap();
|
|
64
|
+
|
|
65
|
+
expect(heap.remove(7)).toBe(false);
|
|
66
|
+
|
|
67
|
+
heap.insert(7, 3);
|
|
68
|
+
|
|
69
|
+
expect(heap.remove(7)).toBe(true);
|
|
70
|
+
|
|
71
|
+
expect(heap.is_empty()).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("is_empty", () => {
|
|
75
|
+
|
|
76
|
+
const heap = new Uint32Heap();
|
|
77
|
+
|
|
78
|
+
expect(heap.is_empty()).toBe(true);
|
|
79
|
+
|
|
80
|
+
heap.insert(7, 0);
|
|
81
|
+
|
|
82
|
+
expect(heap.is_empty()).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("update_score", () => {
|
|
86
|
+
|
|
87
|
+
const heap = new Uint32Heap();
|
|
88
|
+
|
|
89
|
+
heap.insert(1, 3);
|
|
90
|
+
heap.insert(7, 11);
|
|
91
|
+
|
|
92
|
+
heap.update_score(7, -1);
|
|
93
|
+
|
|
94
|
+
expect(heap.pop_min()).toEqual(7);
|
|
95
|
+
expect(heap.pop_min()).toEqual(1);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("get_score", () => {
|
|
99
|
+
|
|
100
|
+
const heap = new Uint32Heap();
|
|
101
|
+
|
|
102
|
+
expect(heap.get_score(7)).toBeNaN();
|
|
103
|
+
|
|
104
|
+
heap.insert(7, 31);
|
|
105
|
+
|
|
106
|
+
expect(heap.get_score(7)).toBe(31);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("insert_or_update", () => {
|
|
110
|
+
|
|
111
|
+
const heap = new Uint32Heap();
|
|
112
|
+
|
|
113
|
+
heap.insert_or_update(7, 1);
|
|
114
|
+
|
|
115
|
+
expect(heap.size).toBe(1);
|
|
116
|
+
expect(heap.get_score(7)).toBe(1);
|
|
117
|
+
|
|
118
|
+
heap.insert_or_update(7, 17);
|
|
119
|
+
|
|
120
|
+
expect(heap.size).toBe(1);
|
|
121
|
+
expect(heap.get_score(7)).toBe(17);
|
|
122
|
+
|
|
123
|
+
});
|
|
@@ -279,13 +279,17 @@ export class Uint32Heap {
|
|
|
279
279
|
/**
|
|
280
280
|
*
|
|
281
281
|
* @param {number} id
|
|
282
|
+
* @returns {boolean}
|
|
282
283
|
*/
|
|
283
284
|
remove(id) {
|
|
284
285
|
const i = this.find_index_by_id(id);
|
|
285
286
|
|
|
286
|
-
if (i
|
|
287
|
-
|
|
287
|
+
if (i === -1) {
|
|
288
|
+
return false;
|
|
288
289
|
}
|
|
290
|
+
|
|
291
|
+
this.__remove_by_index(i);
|
|
292
|
+
return true;
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { assert } from "
|
|
2
|
-
import { invokeObjectEquals } from "
|
|
3
|
-
import { invokeObjectHash } from "
|
|
4
|
-
import { isPowerOfTwo } from "
|
|
5
|
-
import { ctz32 } from "
|
|
6
|
-
import { ceilPowerOfTwo } from "
|
|
7
|
-
import { UintArrayForCount } from "
|
|
8
|
-
import { array_copy } from "
|
|
9
|
-
import { min2 } from "
|
|
10
|
-
import { arraySwapElements } from "
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
3
|
+
import { invokeObjectHash } from "../../model/object/invokeObjectHash.js";
|
|
4
|
+
import { isPowerOfTwo } from "../../math/isPowerOrTwo.js";
|
|
5
|
+
import { ctz32 } from "../../binary/ctz32.js";
|
|
6
|
+
import { ceilPowerOfTwo } from "../../binary/operations/ceilPowerOfTwo.js";
|
|
7
|
+
import { UintArrayForCount } from "../array/typed/uint_array_for_count.js";
|
|
8
|
+
import { array_copy } from "../array/array_copy.js";
|
|
9
|
+
import { min2 } from "../../math/min2.js";
|
|
10
|
+
import { arraySwapElements } from "../array/arraySwapElements.js";
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* Heavily inspired by ruby's "new" (circa 2016) hash table implementation
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { invokeObjectEquals } from "
|
|
2
|
-
import { invokeObjectHash } from "
|
|
3
|
-
import { HashMap } from "
|
|
1
|
+
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
2
|
+
import { invokeObjectHash } from "../../model/object/invokeObjectHash.js";
|
|
3
|
+
import { HashMap } from "../map/HashMap.js";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Spec-compliant with ES Set interface
|
|
8
8
|
* @template T
|
|
9
|
+
* @extends {Set}
|
|
9
10
|
*/
|
|
10
11
|
export class HashSet {
|
|
11
12
|
/**
|
|
@@ -3,12 +3,28 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import Signal from "
|
|
6
|
+
import Signal from "../../events/signal/Signal.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Structure with event signals for observing changes.
|
|
10
10
|
*/
|
|
11
11
|
class Set {
|
|
12
|
+
/**
|
|
13
|
+
* @readonly
|
|
14
|
+
*/
|
|
15
|
+
on = {
|
|
16
|
+
added: new Signal(),
|
|
17
|
+
removed: new Signal()
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @private
|
|
22
|
+
* @type {T[]}
|
|
23
|
+
*/
|
|
24
|
+
data = [];
|
|
25
|
+
|
|
26
|
+
length = 0;
|
|
27
|
+
|
|
12
28
|
/**
|
|
13
29
|
*
|
|
14
30
|
* @param {Array.<T>} [array=[]]
|
|
@@ -17,19 +33,6 @@ class Set {
|
|
|
17
33
|
* @property {{added: Signal, removed: Signal}} on
|
|
18
34
|
*/
|
|
19
35
|
constructor(array) {
|
|
20
|
-
this.on = {
|
|
21
|
-
added: new Signal(),
|
|
22
|
-
removed: new Signal()
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {T[]}
|
|
28
|
-
*/
|
|
29
|
-
this.data = [];
|
|
30
|
-
|
|
31
|
-
this.length = 0;
|
|
32
|
-
|
|
33
36
|
if (array !== undefined) {
|
|
34
37
|
this.addAll(array);
|
|
35
38
|
}
|
|
@@ -17,7 +17,9 @@ import { aabb3_matrix4_project } from "./aabb3_matrix4_project.js";
|
|
|
17
17
|
import { aabb3_signed_distance_sqr_to_point } from "./aabb3_signed_distance_sqr_to_point.js";
|
|
18
18
|
import { aabb3_array_contains_point } from "./aabb3_array_contains_point.js";
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Axis-Aligned bounding box in 3D
|
|
22
|
+
*/
|
|
21
23
|
export class AABB3 {
|
|
22
24
|
/**
|
|
23
25
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderedEdge } from "./OrderedEdge.js";
|
|
2
|
-
import { HashMap } from "../../../../../../collection/HashMap.js";
|
|
2
|
+
import { HashMap } from "../../../../../../collection/map/HashMap.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @see https://github.com/blender/blender/blob/9cb061f4f0119e647173e7d354e1457e97632333/source/blender/blenkernel/intern/mesh_calc_edges.cc#L209
|
|
@@ -2,17 +2,24 @@ import { assert } from "../assert.js";
|
|
|
2
2
|
import Signal from "../events/signal/Signal.js";
|
|
3
3
|
|
|
4
4
|
class ObservedInteger extends Number {
|
|
5
|
+
/**
|
|
6
|
+
* @readonly
|
|
7
|
+
* @type {Signal}
|
|
8
|
+
*/
|
|
9
|
+
onChanged = new Signal();
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
*
|
|
7
|
-
* @param {Number} value
|
|
13
|
+
* @param {Number} [value]
|
|
8
14
|
* @constructor
|
|
9
15
|
*/
|
|
10
|
-
constructor(value) {
|
|
16
|
+
constructor(value = 0) {
|
|
11
17
|
super();
|
|
12
18
|
|
|
13
|
-
assert.
|
|
19
|
+
assert.isNumber(value, 'value');
|
|
14
20
|
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
15
21
|
|
|
22
|
+
|
|
16
23
|
/**
|
|
17
24
|
*
|
|
18
25
|
* @type {Number}
|
|
@@ -20,7 +27,6 @@ class ObservedInteger extends Number {
|
|
|
20
27
|
*/
|
|
21
28
|
this.__value = value;
|
|
22
29
|
|
|
23
|
-
this.onChanged = new Signal();
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
/**
|
|
@@ -41,7 +47,7 @@ class ObservedInteger extends Number {
|
|
|
41
47
|
* @returns {ObservedInteger}
|
|
42
48
|
*/
|
|
43
49
|
set(value) {
|
|
44
|
-
assert.
|
|
50
|
+
assert.isNumber(value, 'value');
|
|
45
51
|
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
46
52
|
|
|
47
53
|
const oldValue = this.__value;
|
|
@@ -58,8 +64,7 @@ class ObservedInteger extends Number {
|
|
|
58
64
|
* @param {number} value
|
|
59
65
|
*/
|
|
60
66
|
setSilent(value) {
|
|
61
|
-
|
|
62
|
-
assert.equal(typeof value, "number", `Value must be of type "number", instead was "${typeof value}"`);
|
|
67
|
+
assert.isNumber(value, 'value');
|
|
63
68
|
assert.ok(Number.isInteger(value) || !Number.isFinite(value), `Value must be an integer, instead was ${value}`);
|
|
64
69
|
|
|
65
70
|
this.__value = value;
|
|
@@ -10,13 +10,13 @@ import { computeStringHash } from "../primitives/strings/computeStringHash.js";
|
|
|
10
10
|
class ObservedString extends String {
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
|
-
* @param {String} value
|
|
13
|
+
* @param {String} [value]
|
|
14
14
|
* @constructor
|
|
15
15
|
*/
|
|
16
|
-
constructor(value) {
|
|
16
|
+
constructor(value = "") {
|
|
17
17
|
super();
|
|
18
18
|
|
|
19
|
-
assert.
|
|
19
|
+
assert.isString(value, 'value');
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
@@ -26,11 +26,6 @@ class ObservedString extends String {
|
|
|
26
26
|
this.__value = value;
|
|
27
27
|
|
|
28
28
|
this.onChanged = new Signal();
|
|
29
|
-
/**
|
|
30
|
-
* Used for optimized "instanceof" check
|
|
31
|
-
* @type {boolean}
|
|
32
|
-
*/
|
|
33
|
-
this.isObservedString = true;
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
/**
|
|
@@ -133,4 +128,11 @@ class ObservedString extends String {
|
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Used for optimized "instanceof" check
|
|
133
|
+
* @readonly
|
|
134
|
+
* @type {boolean}
|
|
135
|
+
*/
|
|
136
|
+
ObservedString.prototype.isObservedString = true;
|
|
137
|
+
|
|
136
138
|
export default ObservedString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
|
-
import { HashMap } from "../../../collection/HashMap.js";
|
|
2
|
+
import { HashMap } from "../../../collection/map/HashMap.js";
|
|
3
3
|
import { Color } from "../../../color/Color.js";
|
|
4
4
|
import { BoxLayoutSpec } from "./layout/BoxLayoutSpec.js";
|
|
5
5
|
import { ConnectedBoxLayouter } from "./layout/ConnectedBoxLayouter.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../../assert.js";
|
|
2
2
|
import { BitSet } from "../../../binary/BitSet.js";
|
|
3
|
-
import { HashMap } from "../../../collection/HashMap.js";
|
|
3
|
+
import { HashMap } from "../../../collection/map/HashMap.js";
|
|
4
4
|
import { max2 } from "../../../math/max2.js";
|
|
5
5
|
import DataType from "../../../parser/simple/DataType.js";
|
|
6
6
|
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import { ObservedMap } from "../../core/collection/ObservedMap.js";
|
|
7
|
-
import { HashMap } from "../../core/collection/HashMap.js";
|
|
6
|
+
import { ObservedMap } from "../../core/collection/map/ObservedMap.js";
|
|
7
|
+
import { HashMap } from "../../core/collection/map/HashMap.js";
|
|
8
8
|
import { extractAssetListFromManager } from "./preloader/extractAssetListFromManager.js";
|
|
9
9
|
import { assert } from "../../core/assert.js";
|
|
10
|
-
import { HashSet } from "../../core/collection/HashSet.js";
|
|
10
|
+
import { HashSet } from "../../core/collection/set/HashSet.js";
|
|
11
11
|
import { CrossOriginConfig } from "./CORS/CrossOriginConfig.js";
|
|
12
12
|
import { array_remove_element } from "../../core/collection/array/array_remove_element.js";
|
|
13
13
|
import { AssetDescription } from "./AssetDescription.js";
|
|
@@ -20,7 +20,7 @@ import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
|
|
|
20
20
|
import { computeObjectBoundingSphere } from "./gltf/computeObjectBoundingSphere.js";
|
|
21
21
|
import { isMesh } from "./gltf/isMesh.js";
|
|
22
22
|
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
23
|
-
import { HashSet } from "../../../core/collection/HashSet.js";
|
|
23
|
+
import { HashSet } from "../../../core/collection/set/HashSet.js";
|
|
24
24
|
import { computeGeometryHash } from "../../graphics/geometry/buffered/computeGeometryHash.js";
|
|
25
25
|
import { computeGeometryEquality } from "../../graphics/geometry/buffered/computeGeometryEquality.js";
|
|
26
26
|
import { traverseThreeObject } from "../../graphics/ecs/highlight/renderer/traverseThreeObject.js";
|
|
@@ -59,13 +59,11 @@ function populateJsonTemplate(template, seed) {
|
|
|
59
59
|
* @class
|
|
60
60
|
*/
|
|
61
61
|
export class EntityBlueprint {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.componentnts = new Map();
|
|
68
|
-
}
|
|
62
|
+
/**
|
|
63
|
+
* @private
|
|
64
|
+
* @type {Map<Class, Object>}
|
|
65
|
+
*/
|
|
66
|
+
#components = new Map();
|
|
69
67
|
|
|
70
68
|
/**
|
|
71
69
|
*
|
|
@@ -95,7 +93,7 @@ export class EntityBlueprint {
|
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
clear() {
|
|
98
|
-
this.
|
|
96
|
+
this.#components.clear();
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
/**
|
|
@@ -104,7 +102,7 @@ export class EntityBlueprint {
|
|
|
104
102
|
* @param {Object} json
|
|
105
103
|
*/
|
|
106
104
|
addJSON(klass, json) {
|
|
107
|
-
this.
|
|
105
|
+
this.#components.set(klass, json);
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
/**
|
|
@@ -148,7 +146,7 @@ export class EntityBlueprint {
|
|
|
148
146
|
build(templateSeed) {
|
|
149
147
|
const eb = new EntityBuilder();
|
|
150
148
|
|
|
151
|
-
this.
|
|
149
|
+
this.#components.forEach((template, ComponentClass) => {
|
|
152
150
|
const component = new ComponentClass();
|
|
153
151
|
|
|
154
152
|
const json = populateJsonTemplate(template, templateSeed);
|