@woosh/meep-engine 2.50.2 → 2.51.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/README.md +4 -1
- package/editor/actions/concrete/WriteGridValueAction.js +13 -18
- package/editor/ecs/component/editors/Sampler2DEditor.js +2 -2
- package/editor/process/SymbolicDisplayProcess.js +1 -1
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +1 -1
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePathSymbolicDisplay.js +1 -1
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +1 -1
- package/editor/view/ecs/components/GridObstacleController.js +2 -2
- package/editor/view/ecs/components/TerrainController.js +2 -2
- package/package.json +1 -1
- package/samples/terrain/editor.js +2 -2
- package/src/core/UUID.spec.js +8 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +4 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +57 -55
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.spec.js +54 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.spec.js +60 -0
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +2 -2
- package/src/core/cache/Cache.d.ts +4 -0
- package/src/core/cache/Cache.js +32 -18
- package/src/core/cache/Cache.spec.js +33 -0
- package/src/core/cache/CacheElement.js +1 -0
- package/src/core/cache/FrequencySketch.js +26 -23
- package/src/core/cache/FrequencySketch.spec.js +5 -0
- package/src/core/cache/LoadingCache.d.ts +2 -0
- package/src/core/cache/LoadingCache.js +16 -7
- package/src/core/cache/LoadingCache.spec.js +24 -0
- package/src/core/collection/HashMap.d.ts +2 -0
- package/src/core/collection/HashMap.spec.js +51 -2
- package/src/core/collection/list/List.d.ts +13 -1
- package/src/core/collection/list/List.js +702 -684
- package/src/core/collection/list/List.spec.js +93 -0
- package/src/core/collection/map/AsyncLoadingCache.js +1 -0
- package/src/core/fsm/simple/SimpleStateMachine.js +23 -22
- package/src/core/function/extractFunctionBody.spec.js +15 -0
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.js +69 -33
- package/src/core/geom/2d/convex-hull/convex_hull_monotone_2d.spec.js +33 -0
- package/src/core/geom/2d/convex-hull/orientation3.js +55 -10
- package/src/core/geom/2d/quad-tree/PointQuadTree.js +10 -0
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +3 -3
- package/src/core/graph/{convertGraphToDotString.js → convert_graph_to_dot_string.js} +1 -1
- package/src/core/graph/convert_graph_to_dot_string.spec.js +28 -0
- package/src/core/math/noise/sdnoise.js +5 -7
- package/src/core/math/noise/sdnoise.spec.js +87 -0
- package/src/core/process/matcher/Matchers.js +1 -1
- package/src/engine/asset/loaders/image/png/PNG.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/PNGReader.spec.js +5 -0
- package/src/engine/asset/loaders/image/png/crc.spec.js +15 -0
- package/src/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/EntityBlueprint.js +4 -0
- package/src/engine/ecs/EntityBuilder.js +48 -49
- package/src/engine/ecs/EntityBuilderFlags.js +2 -2
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- package/src/engine/ecs/guid/GUID.js +1 -0
- package/src/engine/ecs/{systems → renderable}/RenderSystem.d.ts +1 -1
- package/src/engine/ecs/{systems → renderable}/RenderSystem.js +10 -38
- package/src/engine/ecs/renderable/Renderable.d.ts +25 -0
- package/src/engine/ecs/{components → renderable}/Renderable.js +18 -83
- package/src/engine/ecs/renderable/Renderable.spec.js +10 -0
- package/src/engine/ecs/speaker/VoiceSystem.js +15 -9
- package/src/engine/ecs/systems/MeshColliderSystem.js +1 -1
- package/src/engine/ecs/systems/RangedAttackSystem.js +1 -1
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -2
- package/src/engine/ecs/terrain/ecs/splat/SplatMapOptimizerDebugger.js +3 -3
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +2 -2
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +2 -2
- package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
- package/src/engine/graphics/copy_transform_to_threejs_object.js +12 -0
- package/src/engine/graphics/debug/VisualSymbolLine.js +1 -1
- package/src/engine/graphics/ecs/decal/DecalSystem.js +1 -1
- package/src/engine/graphics/ecs/highlight/renderer/makeGaussianBlurShader.js +1 -4
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +2 -5
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -2
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.spec.js +24 -0
- package/src/engine/graphics/texture/atlas/TextureAtlas.spec.js +46 -0
- package/src/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
- package/src/engine/graphics/texture/sampler/bicubic.spec.js +13 -0
- package/src/engine/graphics/texture/sampler/differenceSampler.js +1 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +5 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.spec.js +183 -0
- package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +20 -0
- package/src/engine/graphics/texture/sampler/filter/mitchell.js +0 -21
- package/src/engine/graphics/texture/sampler/filter/mitchell_v1.js +21 -0
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +17 -16
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +11 -9
- package/src/engine/graphics/texture/sampler/{scaleSampler2D.js → resize/sampler2d_scale.js} +8 -8
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale.spec.js +73 -0
- package/src/engine/graphics/texture/sampler/{sampler2_d_scale_down_lanczos.js → resize/sampler2d_scale_down_lanczos.js} +3 -24
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +29 -0
- package/src/engine/graphics/texture/sampler/{sampler2d_scale_down_linear.js → resize/sampler2d_scale_down_linear.js} +5 -5
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.spec.js +44 -0
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.js → sampler2d_scale_down_mipmap.js} +2 -2
- package/src/engine/graphics/texture/sampler/resize/{sampler2d_downsample_mipmap.spec.js → sampler2d_scale_down_mipmap.spec.js} +2 -2
- package/src/engine/graphics/texture/sampler/{genericResampleSampler2D.js → resize/sampler2d_scale_generic.js} +16 -12
- package/src/engine/graphics/texture/sampler/{upsampleSampler2D.js → resize/sampler2d_scale_up_linear.js} +5 -2
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_up_linear.spec.js +14 -0
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +4 -2
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.spec.js +15 -0
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +2 -2
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +66 -0
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.spec.js +108 -0
- package/src/engine/graphics/trail/TemporalPath.js +83 -78
- package/src/engine/graphics/trail/TemporalPath.spec.js +5 -0
- package/src/engine/graphics/trail/x/RibbonX.spec.js +5 -0
- package/src/engine/input/devices/InputDeviceSwitch.spec.js +5 -0
- package/src/engine/input/ecs/{InputBinding.js → components/InputBinding.js} +1 -1
- package/src/engine/input/ecs/components/InputController.js +2 -2
- package/src/engine/input/ecs/ism/InputBinding.js +2 -2
- package/src/engine/input/ecs/util/TerrainCameraTargetSampler.js +1 -1
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +1 -1
- package/src/engine/intelligence/behavior/behavior_to_dot.spec.js +25 -0
- package/src/engine/intelligence/behavior/util/DelayBehavior.js +6 -4
- package/src/engine/intelligence/blackboard/Blackboard.d.ts +2 -0
- package/src/engine/intelligence/blackboard/Blackboard.js +36 -2
- package/src/engine/intelligence/blackboard/Blackboard.spec.js +49 -0
- package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.spec.js +2 -0
- package/src/engine/navigation/grid/{AStar.js → find_path_on_grid_astar.js} +21 -18
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +7 -0
- package/src/engine/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- package/src/engine/MeepSettings.js +0 -9
- package/src/engine/User.js +0 -28
- package/src/engine/UserController.js +0 -273
- package/src/engine/ecs/components/AABB.js +0 -33
- package/src/engine/ecs/components/AABBCollider.js +0 -15
- package/src/engine/ecs/components/Renderable.d.ts +0 -14
- package/src/engine/ecs/grid/Sampler2DDecoder.js +0 -57
- package/src/engine/ecs/grid/makeTerrainGeometry.js +0 -110
- package/src/engine/ecs/systems/AABBColliderSystem.js +0 -61
- package/src/engine/ecs/systems/AABBSystem.js +0 -89
- package/src/engine/graphics/texture/sampler/sampler2d_make_array_filler_function.js +0 -65
- package/src/engine/graphics/texture/sampler/sampler2d_scale_down_linear.spec.js +0 -17
- package/src/engine/graphics/trail/x/simulator/RibbonState.js +0 -10
- package/src/engine/grid/Grid.js +0 -131
- package/src/engine/navigation/grid/GridField.js +0 -328
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jest } from "@jest/globals";
|
|
2
2
|
import { Cache } from "./Cache.js";
|
|
3
|
+
import { returnOne } from "../function/Functions.js";
|
|
3
4
|
|
|
4
5
|
test("constructor doesn't throw", () => {
|
|
5
6
|
new Cache({});
|
|
@@ -162,3 +163,35 @@ test("calling 'evictOne' on empty cache should return false", () => {
|
|
|
162
163
|
|
|
163
164
|
expect(cache.evictOne()).toBe(false);
|
|
164
165
|
});
|
|
166
|
+
|
|
167
|
+
test("recomputeWeight", () => {
|
|
168
|
+
const cache = new Cache({
|
|
169
|
+
valueWeigher: () => 3,
|
|
170
|
+
keyWeigher: returnOne
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
cache.set(1, 1);
|
|
174
|
+
|
|
175
|
+
expect(cache.weight).toBe(4);
|
|
176
|
+
|
|
177
|
+
cache.recomputeWeight();
|
|
178
|
+
|
|
179
|
+
expect(cache.weight).toBe(4);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("silentRemove should not notify", () => {
|
|
183
|
+
|
|
184
|
+
const cache = new Cache();
|
|
185
|
+
|
|
186
|
+
cache.set("x", 1);
|
|
187
|
+
|
|
188
|
+
const mock = jest.fn();
|
|
189
|
+
|
|
190
|
+
cache.onRemoved.add(mock);
|
|
191
|
+
|
|
192
|
+
cache.silentRemove("x");
|
|
193
|
+
|
|
194
|
+
expect(cache.contains('x')).toBe(false);
|
|
195
|
+
|
|
196
|
+
expect(mock).not.toHaveBeenCalled();
|
|
197
|
+
});
|
|
@@ -4,7 +4,12 @@ import { ceilPowerOfTwo } from "../binary/operations/ceilPowerOfTwo.js";
|
|
|
4
4
|
import { min2 } from "../math/min2.js";
|
|
5
5
|
|
|
6
6
|
const SEED = [ // A mixture of seeds from FNV-1a, CityHash, and Murmur3
|
|
7
|
-
0x97cb3127,
|
|
7
|
+
0x97cb3127,
|
|
8
|
+
0xbe98f273,
|
|
9
|
+
0x2f90404f,
|
|
10
|
+
0x84222325
|
|
11
|
+
];
|
|
12
|
+
|
|
8
13
|
const RESET_MASK = 0x77777777;
|
|
9
14
|
const ONE_MASK = 0x11111111;
|
|
10
15
|
|
|
@@ -49,28 +54,26 @@ const MAX_INT_32 = 2147483647;
|
|
|
49
54
|
* @template T
|
|
50
55
|
*/
|
|
51
56
|
export class FrequencySketch {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.size = 0;
|
|
73
|
-
}
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @type {number}
|
|
60
|
+
*/
|
|
61
|
+
sampleSize = 0;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @type {number}
|
|
65
|
+
*/
|
|
66
|
+
tableMask = 0;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @type {Uint32Array|null}
|
|
70
|
+
*/
|
|
71
|
+
table = null;
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @type {number}
|
|
75
|
+
*/
|
|
76
|
+
size = 0;
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* Initializes and increases the capacity of this <tt>FrequencySketch</tt> instance, if necessary,
|
|
@@ -51,13 +51,13 @@ export class LoadingCache {
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* @see {@link Cache} for more details on what each parameter means
|
|
54
|
-
* @param maxWeight
|
|
55
|
-
* @param keyWeigher
|
|
56
|
-
* @param valueWeigher
|
|
57
|
-
* @param keyHashFunction
|
|
58
|
-
* @param keyEqualityFunction
|
|
59
|
-
* @param capacity
|
|
60
|
-
* @param {number} [timeToLive] in seconds
|
|
54
|
+
* @param [maxWeight]
|
|
55
|
+
* @param [keyWeigher]
|
|
56
|
+
* @param [valueWeigher]
|
|
57
|
+
* @param [keyHashFunction]
|
|
58
|
+
* @param [keyEqualityFunction]
|
|
59
|
+
* @param [capacity]
|
|
60
|
+
* @param {number} [timeToLive] in seconds, default is 10 seconds
|
|
61
61
|
* @param load
|
|
62
62
|
* @param {boolean} [retryFailed]
|
|
63
63
|
*/
|
|
@@ -141,6 +141,15 @@ export class LoadingCache {
|
|
|
141
141
|
return record.value;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Directly insert value into the cache
|
|
146
|
+
* @param {K} key
|
|
147
|
+
* @param {V} value
|
|
148
|
+
*/
|
|
149
|
+
put(key, value) {
|
|
150
|
+
this.#internal.put(key, new Record(Promise.resolve(value), current_time_in_seconds()));
|
|
151
|
+
}
|
|
152
|
+
|
|
144
153
|
/**
|
|
145
154
|
*
|
|
146
155
|
* @param {K} key
|
|
@@ -45,3 +45,27 @@ test("timeout reload reuse", async () => {
|
|
|
45
45
|
|
|
46
46
|
expect(await cache.get(1)).toEqual(3);
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
test("insert element directly", async () => {
|
|
50
|
+
|
|
51
|
+
const cache = new LoadingCache({
|
|
52
|
+
load: async () => 3
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
cache.put("x", 1);
|
|
56
|
+
|
|
57
|
+
expect(await cache.get("x")).toEqual(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("clear", async () => {
|
|
61
|
+
|
|
62
|
+
const cache = new LoadingCache({
|
|
63
|
+
load: async () => 3
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
cache.put("x", 1);
|
|
67
|
+
|
|
68
|
+
cache.clear();
|
|
69
|
+
|
|
70
|
+
expect(await cache.get("x")).toEqual(3);
|
|
71
|
+
});
|
|
@@ -83,6 +83,23 @@ test("getOrCompute", () => {
|
|
|
83
83
|
expect(map.getOrCompute("y", compute)).toBe(3);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
test("getOrSet", () => {
|
|
87
|
+
|
|
88
|
+
const map = new HashMap({
|
|
89
|
+
keyHashFunction: returnOne,
|
|
90
|
+
keyEqualityFunction: strictEquals
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
map.getOrSet(3, "hello");
|
|
94
|
+
|
|
95
|
+
expect(map.get(3)).toBe("hello");
|
|
96
|
+
|
|
97
|
+
map.getOrSet(3, "kitty");
|
|
98
|
+
|
|
99
|
+
expect(map.get(3)).toBe("hello");
|
|
100
|
+
|
|
101
|
+
});
|
|
102
|
+
|
|
86
103
|
test("retrieval works as intended after hash map grows", () => {
|
|
87
104
|
const m = new HashMap({
|
|
88
105
|
keyHashFunction: passThrough,
|
|
@@ -155,7 +172,12 @@ test("key iterator", () => {
|
|
|
155
172
|
|
|
156
173
|
map.set(7, "hello");
|
|
157
174
|
|
|
158
|
-
|
|
175
|
+
const iterator = map.keys();
|
|
176
|
+
expect(iterator.next().value).toBe(7);
|
|
177
|
+
expect(iterator.next()).toEqual({
|
|
178
|
+
done: true,
|
|
179
|
+
value: undefined
|
|
180
|
+
});
|
|
159
181
|
});
|
|
160
182
|
|
|
161
183
|
test("value iterator", () => {
|
|
@@ -166,7 +188,34 @@ test("value iterator", () => {
|
|
|
166
188
|
|
|
167
189
|
map.set(7, "hello");
|
|
168
190
|
|
|
169
|
-
|
|
191
|
+
const iterator = map.values();
|
|
192
|
+
expect(iterator.next().value).toBe("hello");
|
|
193
|
+
expect(iterator.next()).toEqual({
|
|
194
|
+
done: true,
|
|
195
|
+
value: undefined
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("forEach", () => {
|
|
200
|
+
const map = new HashMap({
|
|
201
|
+
keyHashFunction: returnOne,
|
|
202
|
+
keyEqualityFunction: strictEquals
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const mock = jest.fn();
|
|
206
|
+
|
|
207
|
+
map.forEach(mock);
|
|
208
|
+
|
|
209
|
+
expect(mock).not.toHaveBeenCalled();
|
|
210
|
+
|
|
211
|
+
map.set(7, "hello");
|
|
212
|
+
map.set(3, "kitty");
|
|
213
|
+
|
|
214
|
+
map.forEach(mock);
|
|
215
|
+
|
|
216
|
+
expect(mock).toHaveBeenCalledTimes(2);
|
|
217
|
+
expect(mock).toHaveBeenCalledWith("kitty", 3, map);
|
|
218
|
+
expect(mock).toHaveBeenCalledWith("hello", 7, map);
|
|
170
219
|
});
|
|
171
220
|
|
|
172
221
|
|
|
@@ -12,21 +12,33 @@ export default class List<T> {
|
|
|
12
12
|
|
|
13
13
|
get(index: number): T
|
|
14
14
|
|
|
15
|
-
add(el: T):
|
|
15
|
+
add(el: T): this
|
|
16
16
|
|
|
17
17
|
addAll(el: T[]): void
|
|
18
18
|
|
|
19
|
+
insert(index: number, element: T): this
|
|
20
|
+
|
|
19
21
|
remove(index: number): T
|
|
20
22
|
|
|
21
23
|
removeOneOf(value: T): boolean
|
|
22
24
|
|
|
25
|
+
removeIf(condition: (element: T) => boolean, thisArg?: any): void
|
|
26
|
+
|
|
27
|
+
removeOneIf(condition: (element: T) => boolean, thisArg?: any): void
|
|
28
|
+
|
|
29
|
+
reset(): void
|
|
30
|
+
|
|
23
31
|
asArray(): T[]
|
|
24
32
|
|
|
25
33
|
forEach(f: (element: T, index: number) => any, thisArg?: any): void
|
|
26
34
|
|
|
35
|
+
map<X>(f: (element: T, index: number) => X, thisArg?: any): X[]
|
|
36
|
+
|
|
27
37
|
isEmpty(): boolean
|
|
28
38
|
|
|
29
39
|
indexOf(el: T): number
|
|
30
40
|
|
|
41
|
+
find(matcher: (element: T) => boolean): T | undefined
|
|
42
|
+
|
|
31
43
|
equals(other: List<T>): boolean
|
|
32
44
|
}
|