@woosh/meep-engine 2.50.3 → 2.52.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/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/NumberFormat.js +0 -71
- 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 +58 -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/bvh3/query/BVHQueryAny.js +16 -0
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +5 -5
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +2 -3
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.spec.js +22 -0
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +2 -2
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.spec.js +64 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +2 -3
- package/src/core/bvh2/visual/convert_bvh_to_dot_format_string.js +2 -2
- package/src/core/cache/Cache.js +3 -5
- package/src/core/cache/CacheElement.js +1 -0
- 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/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
- package/src/core/geom/3d/topology/struct/TopoMesh.js +3 -2
- package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +4 -4
- package/src/core/geom/Vector2.d.ts +9 -0
- package/src/core/geom/Vector2.js +8 -22
- package/src/core/geom/Vector2.spec.js +153 -0
- 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/model/ModuleRegistry.js +2 -4
- package/src/core/model/ModuleRegistry.spec.js +31 -0
- package/src/core/model/reactive/js/compileReactiveToJS.spec.js +14 -0
- package/src/core/model/reactive/model/logic/ReactiveAnd.spec.js +31 -1
- package/src/core/model/reactive/model/logic/ReactiveOr.spec.js +53 -0
- package/src/core/model/stat/LinearModifier.js +2 -2
- package/src/core/model/stat/LinearModifier.spec.js +62 -0
- package/src/core/model/stat/Stat.js +12 -0
- package/src/core/model/stat/Stat.spec.js +36 -0
- package/src/core/primitives/array/computeStridedIntegerArrayHash.spec.js +28 -0
- package/src/core/primitives/numbers/number_format_by_thousands.js +14 -0
- package/src/core/primitives/numbers/number_pretty_print.js +49 -0
- package/src/core/primitives/strings/computeStringHash.spec.js +12 -5
- package/src/core/process/BaseProcess.js +8 -8
- package/src/engine/Clock.js +30 -29
- package/src/engine/Clock.spec.js +26 -0
- package/src/engine/{Platform.js → browserInfo.js} +1 -5
- package/src/engine/ecs/EntityBuilder.js +3 -1
- package/src/engine/ecs/EntityBuilder.spec.js +21 -0
- package/src/engine/ecs/fow/FogOfWar.js +48 -54
- package/src/engine/ecs/gui/GUIElement.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
- 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/terrain/ecs/TerrainClassifier.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +3 -3
- 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/ecs/transform/Transform.js +1 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- 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/animation/animator/graph/AnimationGraph.spec.js +5 -0
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +24 -25
- package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/DecalSystem.js +3 -21
- package/src/engine/graphics/ecs/decal/v2/Decal.js +32 -32
- package/src/engine/graphics/ecs/decal/v2/Decal.spec.js +5 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +4 -2
- 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/mesh-v2/ShadedGeometry.js +4 -33
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +8 -4
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.spec.js +5 -0
- package/src/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +0 -12
- package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +2 -2
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -4
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +0 -2
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/prototypeGeometryMerge.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -3
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -4
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -5
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +2 -6
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +4 -4
- package/src/engine/graphics/shaders/SoftOutlineShader.js +2 -4
- package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- 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/Sampler2D.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 +46 -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/grid/components/GridObstacle.js +45 -25
- package/src/engine/grid/components/GridObstacle.spec.js +130 -1
- package/src/engine/grid/components/GridPosition.js +5 -17
- package/src/engine/grid/components/GridPosition2Transform.js +1 -70
- package/src/engine/grid/components/GridPosition2TransformSerializationAdapter.js +70 -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/plugin/EnginePlugin.js +12 -14
- package/src/engine/plugin/EnginePlugin.spec.js +5 -0
- package/src/engine/plugin/EnginePluginManager.js +18 -22
- package/src/engine/scene/transitionToScene.js +12 -1
- package/src/engine/simulation/Ticker.js +1 -1
- package/src/engine/sound/ecs/SoundListenerSystem.js +1 -1
- package/src/generation/markers/debug/visualizeMarkers.js +1 -1
- package/src/generation/theme/TerrainLayerDescription.js +1 -1
- package/src/view/common/LabelView.js +3 -3
- 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/AimController.js +0 -18
- package/src/engine/ecs/components/Attacker.js +0 -13
- package/src/engine/ecs/components/MeshCollider.js +0 -15
- package/src/engine/ecs/components/RangedAttack.js +0 -12
- package/src/engine/ecs/components/Renderable.d.ts +0 -14
- package/src/engine/ecs/components/TargetAI.js +0 -11
- package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
- 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/ecs/systems/AimControllerSystem.js +0 -63
- package/src/engine/ecs/systems/AttackerSystem.js +0 -67
- package/src/engine/ecs/systems/MeshColliderSystem.js +0 -47
- package/src/engine/ecs/systems/MonsterAISystem.js +0 -163
- package/src/engine/ecs/systems/MortalitySystem.js +0 -46
- package/src/engine/ecs/systems/RangedAttackSystem.js +0 -132
- package/src/engine/ecs/systems/SerializationMetadataSystem.js +0 -10
- package/src/engine/ecs/systems/TargetAISystem.js +0 -107
- package/src/engine/ecs/systems/ViewportMeshProjectionSystem.js +0 -68
- package/src/engine/graphics/particles/ParticleEmitterLibrary.js +0 -87
- 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/grid/components/ViewportGridProjection.js +0 -20
- package/src/engine/grid/systems/GridObstacleSystem.js +0 -58
- package/src/engine/grid/systems/ViewportGridProjectionSystem.js +0 -105
- package/src/engine/navigation/grid/GridField.js +0 -328
- /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
- /package/src/engine/ecs/{components → renderable}/RenderableFlags.js +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { expand_aabb_by_transformed_three_object } from "./expand_aabb_by_transformed_three_object.js";
|
|
2
|
+
import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
3
|
+
import { BufferAttribute, BufferGeometry, Group, Mesh } from "three";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Object3D} object
|
|
8
|
+
* @return {number[]}
|
|
9
|
+
*/
|
|
10
|
+
function compute(object) {
|
|
11
|
+
object.updateMatrixWorld();
|
|
12
|
+
|
|
13
|
+
const result = [
|
|
14
|
+
Infinity, Infinity, Infinity,
|
|
15
|
+
-Infinity, -Infinity, -Infinity
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
expand_aabb_by_transformed_three_object(result, object, MATRIX_4_IDENTITY);
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {number} x
|
|
26
|
+
* @param {number} y
|
|
27
|
+
* @param {number} z
|
|
28
|
+
* @return {BufferGeometry}
|
|
29
|
+
*/
|
|
30
|
+
function makePointGeometry(x, y, z) {
|
|
31
|
+
const geo = new BufferGeometry();
|
|
32
|
+
geo.setIndex([0, 0, 0]);
|
|
33
|
+
geo.setAttribute(
|
|
34
|
+
"position",
|
|
35
|
+
new BufferAttribute(new Float32Array([x, y, z]), 3, false)
|
|
36
|
+
);
|
|
37
|
+
return geo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
test("single point at depth 0", () => {
|
|
41
|
+
|
|
42
|
+
const geo = makePointGeometry(1, 3, 5);
|
|
43
|
+
|
|
44
|
+
const aabb = compute(new Mesh(geo));
|
|
45
|
+
|
|
46
|
+
expect(aabb[0]).toBeCloseTo(1);
|
|
47
|
+
expect(aabb[3]).toBeCloseTo(1);
|
|
48
|
+
|
|
49
|
+
expect(aabb[1]).toBeCloseTo(3);
|
|
50
|
+
expect(aabb[4]).toBeCloseTo(3);
|
|
51
|
+
|
|
52
|
+
expect(aabb[2]).toBeCloseTo(5);
|
|
53
|
+
expect(aabb[5]).toBeCloseTo(5);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("single point at depth 1", () => {
|
|
57
|
+
|
|
58
|
+
const geo = makePointGeometry(1, 3, 5);
|
|
59
|
+
|
|
60
|
+
const object_1 = new Group();
|
|
61
|
+
const object_2 = new Mesh(geo);
|
|
62
|
+
|
|
63
|
+
object_1.add(object_2);
|
|
64
|
+
object_2.position.set(7, -11, 13);
|
|
65
|
+
|
|
66
|
+
const aabb = compute(object_1);
|
|
67
|
+
|
|
68
|
+
expect(aabb[0]).toBeCloseTo(8);
|
|
69
|
+
expect(aabb[3]).toBeCloseTo(8);
|
|
70
|
+
|
|
71
|
+
expect(aabb[1]).toBeCloseTo(-8);
|
|
72
|
+
expect(aabb[4]).toBeCloseTo(-8);
|
|
73
|
+
|
|
74
|
+
expect(aabb[2]).toBeCloseTo(18);
|
|
75
|
+
expect(aabb[5]).toBeCloseTo(18);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("single point at depth 2", () => {
|
|
79
|
+
|
|
80
|
+
const geo = makePointGeometry(1, 3, 5);
|
|
81
|
+
|
|
82
|
+
const object_0 = new Group();
|
|
83
|
+
const object_1 = new Group();
|
|
84
|
+
const object_2 = new Mesh(geo);
|
|
85
|
+
|
|
86
|
+
object_0.add(object_1);
|
|
87
|
+
object_1.add(object_2);
|
|
88
|
+
|
|
89
|
+
object_1.position.set(10, 20, 30);
|
|
90
|
+
object_1.scale.set(0.1, 0.2, 0.5);
|
|
91
|
+
|
|
92
|
+
object_2.position.set(7, -17, 13);
|
|
93
|
+
|
|
94
|
+
const aabb = compute(object_0);
|
|
95
|
+
|
|
96
|
+
const x = 10 + 8 * 0.1;
|
|
97
|
+
|
|
98
|
+
expect(aabb[0]).toBeCloseTo(x);
|
|
99
|
+
expect(aabb[3]).toBeCloseTo(x);
|
|
100
|
+
|
|
101
|
+
const y = 20 - 14 * 0.2;
|
|
102
|
+
expect(aabb[1]).toBeCloseTo(y);
|
|
103
|
+
expect(aabb[4]).toBeCloseTo(y);
|
|
104
|
+
|
|
105
|
+
const z = 30 + 18 * 0.5;
|
|
106
|
+
expect(aabb[2]).toBeCloseTo(z);
|
|
107
|
+
expect(aabb[5]).toBeCloseTo(z);
|
|
108
|
+
});
|
|
@@ -1,124 +1,129 @@
|
|
|
1
1
|
import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
|
|
2
2
|
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
3
|
+
import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
|
|
3
4
|
|
|
5
|
+
const TABLE_SPEC = RowFirstTableSpec.get([
|
|
6
|
+
// time
|
|
7
|
+
BinaryDataType.Float32,
|
|
8
|
+
// position XYZ
|
|
9
|
+
BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32
|
|
10
|
+
]);
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Keeps tracks of a moving point for a given time window
|
|
14
|
+
*/
|
|
15
|
+
export class TemporalPath {
|
|
6
16
|
/**
|
|
7
17
|
* How long to track the points for
|
|
8
18
|
* @type {number}
|
|
9
19
|
*/
|
|
10
|
-
|
|
20
|
+
memory = 0;
|
|
11
21
|
|
|
12
22
|
/**
|
|
13
23
|
*
|
|
14
24
|
* @type {number}
|
|
15
25
|
*/
|
|
16
|
-
|
|
26
|
+
time = 0;
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
29
|
*
|
|
20
30
|
* @type {RowFirstTable}
|
|
21
31
|
*/
|
|
22
|
-
|
|
23
|
-
BinaryDataType.Float32,
|
|
24
|
-
BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
32
|
+
data = new RowFirstTable(TABLE_SPEC);
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
updateSequence() {
|
|
35
|
+
const sequence = this.data;
|
|
36
|
+
//determine if position sequence can be cropped
|
|
37
|
+
const numRecords = sequence.length;
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const numRecords = sequence.length;
|
|
39
|
+
if (numRecords === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
43
|
+
const lastUsefulMemory = this.time - this.memory;
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
let i = 0;
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
while (i < numRecords && sequence.readCellValue(i, 0) < lastUsefulMemory) {
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
42
50
|
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
if (i > 0) {
|
|
52
|
+
sequence.removeRows(0, i);
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {number} timeDelta
|
|
59
|
+
*/
|
|
60
|
+
update(timeDelta) {
|
|
61
|
+
this.time += timeDelta;
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @param {number} timeDelta
|
|
55
|
-
*/
|
|
56
|
-
TemporalPath.prototype.update = function (timeDelta) {
|
|
57
|
-
this.time += timeDelta;
|
|
63
|
+
this.updateSequence();
|
|
64
|
+
}
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
}
|
|
66
|
+
/**
|
|
67
|
+
* @returns {number}
|
|
68
|
+
*/
|
|
69
|
+
computeLength() {
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
TemporalPath.prototype.computeLength = function () {
|
|
71
|
+
let i;
|
|
72
|
+
const numRecords = this.data.length;
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
if (numRecords === 0) {
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
78
|
+
let _x, _y, _z;
|
|
73
79
|
|
|
74
|
-
|
|
80
|
+
this.data.getRow(0, tempSequenceRecord);
|
|
75
81
|
|
|
76
|
-
|
|
82
|
+
_x = tempSequenceRecord[1];
|
|
83
|
+
_y = tempSequenceRecord[2];
|
|
84
|
+
_z = tempSequenceRecord[3];
|
|
77
85
|
|
|
78
|
-
_x = tempSequenceRecord[1];
|
|
79
|
-
_y = tempSequenceRecord[2];
|
|
80
|
-
_z = tempSequenceRecord[3];
|
|
81
86
|
|
|
87
|
+
let result = 0;
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
for (i = 1; i < numRecords; i++) {
|
|
90
|
+
this.data.getRow(i, tempSequenceRecord);
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
const x = tempSequenceRecord[1];
|
|
93
|
+
const y = tempSequenceRecord[2];
|
|
94
|
+
const z = tempSequenceRecord[3];
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
const dX = x - _x;
|
|
97
|
+
const dY = y - _y;
|
|
98
|
+
const dZ = z - _z;
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
const dY = y - _y;
|
|
94
|
-
const dZ = z - _z;
|
|
100
|
+
const d = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
|
|
95
101
|
|
|
96
|
-
|
|
102
|
+
result += d;
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
//remember current coordinates
|
|
105
|
+
_x = x;
|
|
106
|
+
_y = y;
|
|
107
|
+
_z = z;
|
|
108
|
+
}
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
_x = x;
|
|
102
|
-
_y = y;
|
|
103
|
-
_z = z;
|
|
110
|
+
return result;
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
tempSequenceRecord[1] = x;
|
|
118
|
-
tempSequenceRecord[2] = y;
|
|
119
|
-
tempSequenceRecord[3] = z;
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @param {number} x
|
|
116
|
+
* @param {number} y
|
|
117
|
+
* @param {number} z
|
|
118
|
+
*/
|
|
119
|
+
append(x, y, z) {
|
|
120
|
+
tempSequenceRecord[0] = this.time;
|
|
121
|
+
tempSequenceRecord[1] = x;
|
|
122
|
+
tempSequenceRecord[2] = y;
|
|
123
|
+
tempSequenceRecord[3] = z;
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
}
|
|
125
|
+
this.data.addRow(tempSequenceRecord);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
123
128
|
|
|
124
|
-
|
|
129
|
+
const tempSequenceRecord = [];
|
|
@@ -10,10 +10,13 @@ import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualS
|
|
|
10
10
|
import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
|
|
11
11
|
|
|
12
12
|
class GridObstacle {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
data = [1];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @readonly
|
|
17
|
+
* @type {Vector2}
|
|
18
|
+
*/
|
|
19
|
+
size = new Vector2(1, 1);
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
22
|
*
|
|
@@ -21,8 +24,8 @@ class GridObstacle {
|
|
|
21
24
|
* @param {number} h
|
|
22
25
|
*/
|
|
23
26
|
resize(w, h) {
|
|
24
|
-
assert.
|
|
25
|
-
assert.
|
|
27
|
+
assert.isNonNegativeInteger(w, 'w');
|
|
28
|
+
assert.isNonNegativeInteger(h, 'h');
|
|
26
29
|
|
|
27
30
|
const x1 = this.size.x;
|
|
28
31
|
const y1 = this.size.y;
|
|
@@ -61,9 +64,9 @@ class GridObstacle {
|
|
|
61
64
|
* @param {*} [thisArg]
|
|
62
65
|
*/
|
|
63
66
|
traverseMask(offsetX, offsetY, visitor, thisArg) {
|
|
64
|
-
assert.
|
|
65
|
-
assert.
|
|
66
|
-
assert.
|
|
67
|
+
assert.isNumber(offsetX, 'offsetX');
|
|
68
|
+
assert.isNumber(offsetY, 'offsetY');
|
|
69
|
+
assert.isFunction(visitor, 'visitor');
|
|
67
70
|
|
|
68
71
|
const size = this.size;
|
|
69
72
|
const sX = size.x;
|
|
@@ -100,11 +103,11 @@ class GridObstacle {
|
|
|
100
103
|
* @returns {number}
|
|
101
104
|
*/
|
|
102
105
|
readPoint(x, y) {
|
|
103
|
-
assert.
|
|
104
|
-
assert.
|
|
106
|
+
assert.isNumber(x, 'x');
|
|
107
|
+
assert.isNumber(y, 'y');
|
|
105
108
|
|
|
106
|
-
assert.
|
|
107
|
-
assert.
|
|
109
|
+
assert.isInteger(x, 'x');
|
|
110
|
+
assert.isInteger(y, 'y');
|
|
108
111
|
|
|
109
112
|
const index = y * this.size.x + x;
|
|
110
113
|
return this.data[index];
|
|
@@ -117,6 +120,9 @@ class GridObstacle {
|
|
|
117
120
|
* @param {number} value
|
|
118
121
|
*/
|
|
119
122
|
writePoint(x, y, value) {
|
|
123
|
+
assert.isNonNegativeInteger(value, 'value');
|
|
124
|
+
assert.lessThanOrEqual(value, 255);
|
|
125
|
+
|
|
120
126
|
const index = y * this.size.x + x;
|
|
121
127
|
|
|
122
128
|
this.data[index] = value;
|
|
@@ -129,8 +135,8 @@ class GridObstacle {
|
|
|
129
135
|
* @returns {boolean}
|
|
130
136
|
*/
|
|
131
137
|
isPointWithin(x, y) {
|
|
132
|
-
assert.
|
|
133
|
-
assert.
|
|
138
|
+
assert.isNumber(x, 'x');
|
|
139
|
+
assert.isNumber(y, 'y');
|
|
134
140
|
|
|
135
141
|
const size = this.size;
|
|
136
142
|
|
|
@@ -141,18 +147,20 @@ class GridObstacle {
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
/**
|
|
144
|
-
*
|
|
150
|
+
* Is a given point adjacent to a blocking cell?
|
|
145
151
|
* @param {number} x Obstacle-Local X position
|
|
146
152
|
* @param {number} y Obstacle-Local Y position
|
|
147
153
|
* @param {number[]} adjacencyMask Mask that defines adjacency, contains pairs of number for each X,Y coordinate offset from obstacle point
|
|
148
154
|
* @returns {boolean}
|
|
149
155
|
*/
|
|
150
156
|
isPointAdjacent(x, y, adjacencyMask) {
|
|
151
|
-
assert.
|
|
152
|
-
assert.
|
|
157
|
+
assert.isNumber(x, 'x');
|
|
158
|
+
assert.isNumber(y, 'y');
|
|
159
|
+
|
|
160
|
+
assert.defined(adjacencyMask, 'mask');
|
|
161
|
+
assert.notNull(adjacencyMask, 'mask');
|
|
153
162
|
|
|
154
|
-
assert.
|
|
155
|
-
assert.notEqual(adjacencyMask, null, 'mask is null');
|
|
163
|
+
assert.isArrayLike(adjacencyMask, 'mask');
|
|
156
164
|
|
|
157
165
|
const size = this.size;
|
|
158
166
|
|
|
@@ -163,7 +171,8 @@ class GridObstacle {
|
|
|
163
171
|
|
|
164
172
|
const maskLength = adjacencyMask.length;
|
|
165
173
|
|
|
166
|
-
assert.
|
|
174
|
+
assert.isNonNegativeInteger(maskLength, 'maskLength');
|
|
175
|
+
assert.equal(maskLength % 2, 0, `maskLength must be a multiple of 2`);
|
|
167
176
|
|
|
168
177
|
|
|
169
178
|
for (let k = 0; k < maskLength; k += 2) {
|
|
@@ -203,16 +212,27 @@ class GridObstacle {
|
|
|
203
212
|
};
|
|
204
213
|
}
|
|
205
214
|
|
|
206
|
-
fromJSON(
|
|
207
|
-
|
|
215
|
+
fromJSON({ size, data }) {
|
|
216
|
+
assert.isArrayLike(data, 'data');
|
|
217
|
+
|
|
208
218
|
this.size.fromJSON(size);
|
|
209
219
|
|
|
210
220
|
const sX = this.size.x;
|
|
211
221
|
const sY = this.size.y;
|
|
212
222
|
|
|
223
|
+
assert.equal(data.length, sX * sY, 'invalid array length');
|
|
224
|
+
|
|
213
225
|
this.data = new Uint8Array(sX * sY);
|
|
214
226
|
|
|
215
|
-
this.data.set(
|
|
227
|
+
this.data.set(data, 0);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static fromJSON(j) {
|
|
231
|
+
const r = new GridObstacle();
|
|
232
|
+
|
|
233
|
+
r.fromJSON(j);
|
|
234
|
+
|
|
235
|
+
return r;
|
|
216
236
|
}
|
|
217
237
|
|
|
218
238
|
/**
|
|
@@ -221,7 +241,7 @@ class GridObstacle {
|
|
|
221
241
|
*/
|
|
222
242
|
hash() {
|
|
223
243
|
return computeHashIntegerArray(
|
|
224
|
-
this.size.
|
|
244
|
+
this.size.hash(),
|
|
225
245
|
computeIntegerArrayHash(this.data, 0, this.data.length)
|
|
226
246
|
);
|
|
227
247
|
}
|
|
@@ -43,4 +43,133 @@ test('resize 1x2 to 1x1', () => {
|
|
|
43
43
|
g.resize(1, 1);
|
|
44
44
|
|
|
45
45
|
expect(g.data[0]).toBe(3);
|
|
46
|
-
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("readPoint", () => {
|
|
49
|
+
const g = new GridObstacle();
|
|
50
|
+
|
|
51
|
+
g.resize(2, 2);
|
|
52
|
+
|
|
53
|
+
g.data[0] = 1;
|
|
54
|
+
g.data[1] = 3;
|
|
55
|
+
g.data[2] = 5;
|
|
56
|
+
g.data[3] = 7;
|
|
57
|
+
|
|
58
|
+
expect(g.readPoint(0, 0)).toBe(1);
|
|
59
|
+
expect(g.readPoint(1, 0)).toBe(3);
|
|
60
|
+
expect(g.readPoint(0, 1)).toBe(5);
|
|
61
|
+
expect(g.readPoint(1, 1)).toBe(7);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("writePoint", () => {
|
|
65
|
+
|
|
66
|
+
const g = new GridObstacle();
|
|
67
|
+
|
|
68
|
+
g.resize(2, 2);
|
|
69
|
+
|
|
70
|
+
g.writePoint(0, 0, 1);
|
|
71
|
+
g.writePoint(1, 0, 3);
|
|
72
|
+
g.writePoint(0, 1, 5);
|
|
73
|
+
g.writePoint(1, 1, 7);
|
|
74
|
+
|
|
75
|
+
expect(Array.from(g.data)).toEqual([1, 3, 5, 7]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
test("hash", () => {
|
|
80
|
+
const g = new GridObstacle();
|
|
81
|
+
|
|
82
|
+
const hash = g.hash();
|
|
83
|
+
|
|
84
|
+
expect(typeof hash).toEqual("number");
|
|
85
|
+
expect(Number.isInteger(hash)).toBe(true);
|
|
86
|
+
expect(g.hash()).toEqual(hash); // stability
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("to/from JSON consistency", () => {
|
|
90
|
+
|
|
91
|
+
const a = new GridObstacle();
|
|
92
|
+
a.resize(1, 3);
|
|
93
|
+
|
|
94
|
+
a.writePoint(0, 0, 1);
|
|
95
|
+
a.writePoint(0, 1, 3);
|
|
96
|
+
a.writePoint(0, 2, 7);
|
|
97
|
+
|
|
98
|
+
const b = new GridObstacle();
|
|
99
|
+
|
|
100
|
+
b.fromJSON(a.toJSON());
|
|
101
|
+
|
|
102
|
+
expect(b.size.x).toEqual(1);
|
|
103
|
+
expect(b.size.y).toEqual(3);
|
|
104
|
+
|
|
105
|
+
expect(b.readPoint(0, 0)).toEqual(1);
|
|
106
|
+
expect(b.readPoint(0, 1)).toEqual(3);
|
|
107
|
+
expect(b.readPoint(0, 2)).toEqual(7);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("equals", () => {
|
|
111
|
+
const a = new GridObstacle();
|
|
112
|
+
const b = new GridObstacle();
|
|
113
|
+
|
|
114
|
+
const c = GridObstacle.fromJSON({
|
|
115
|
+
size: { x: 1, y: 1 },
|
|
116
|
+
data: [
|
|
117
|
+
7
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const d = GridObstacle.fromJSON({
|
|
122
|
+
size: { x: 2, y: 3 },
|
|
123
|
+
data: [
|
|
124
|
+
1, 3,
|
|
125
|
+
5, 7,
|
|
126
|
+
11, 13
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const f = GridObstacle.fromJSON({
|
|
131
|
+
size: { x: 2, y: 3 },
|
|
132
|
+
data: [
|
|
133
|
+
1, 3,
|
|
134
|
+
5, 7,
|
|
135
|
+
11, 13
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const g = GridObstacle.fromJSON({
|
|
140
|
+
size: { x: 3, y: 2 },
|
|
141
|
+
data: [
|
|
142
|
+
1, 3,
|
|
143
|
+
5, 7,
|
|
144
|
+
11, 13
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const h = GridObstacle.fromJSON({
|
|
149
|
+
size: { x: 3, y: 2 },
|
|
150
|
+
data: [
|
|
151
|
+
1, 3,
|
|
152
|
+
5, 7,
|
|
153
|
+
17, 13
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
expect(a.equals(b)).toBe(true);
|
|
158
|
+
expect(a.equals(c)).toBe(false);
|
|
159
|
+
expect(a.equals(d)).toBe(false);
|
|
160
|
+
|
|
161
|
+
expect(f.equals(g)).toBe(false);
|
|
162
|
+
expect(g.equals(h)).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("isPointAdjacent", () => {
|
|
166
|
+
const grid = new GridObstacle();
|
|
167
|
+
|
|
168
|
+
grid.writePoint(0, 0, 7);
|
|
169
|
+
|
|
170
|
+
expect(grid.isPointAdjacent(0, 0, [0, 0])).toBe(true);
|
|
171
|
+
|
|
172
|
+
grid.writePoint(0, 0, 0);
|
|
173
|
+
|
|
174
|
+
expect(grid.isPointAdjacent(0, 0, [0, 0])).toBe(false);
|
|
175
|
+
});
|
|
@@ -4,23 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import Vector2 from '../../../core/geom/Vector2.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {GridPosition|Vector2} other
|
|
19
|
-
*/
|
|
20
|
-
copy(other) {
|
|
21
|
-
Vector2.prototype.copy.call(this, other);
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
7
|
+
/**
|
|
8
|
+
* @extends {Vector2}
|
|
9
|
+
* @class
|
|
10
|
+
*/
|
|
11
|
+
class GridPosition extends Vector2 {
|
|
24
12
|
|
|
25
13
|
clone() {
|
|
26
14
|
const clone = new GridPosition();
|