@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
|
@@ -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 = [];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import List from '../../../../core/collection/list/List.js';
|
|
6
6
|
import { assert } from "../../../../core/assert.js";
|
|
7
7
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
8
|
-
import { InputBinding } from "
|
|
8
|
+
import { InputBinding } from "./InputBinding.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class InputController {
|
|
@@ -15,7 +15,7 @@ class InputController {
|
|
|
15
15
|
* @constructor
|
|
16
16
|
*/
|
|
17
17
|
constructor(bindings = []) {
|
|
18
|
-
assert.
|
|
18
|
+
assert.isArray(bindings, 'bindings');
|
|
19
19
|
|
|
20
20
|
this.mapping = new List();
|
|
21
21
|
|
|
@@ -20,8 +20,8 @@ export class InputBinding {
|
|
|
20
20
|
* @param {string} event
|
|
21
21
|
*/
|
|
22
22
|
set(path, event) {
|
|
23
|
-
assert.
|
|
24
|
-
assert.
|
|
23
|
+
assert.isString(path, "path");
|
|
24
|
+
assert.isString(event, "event");
|
|
25
25
|
|
|
26
26
|
this.path = path;
|
|
27
27
|
this.event = event;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
2
|
-
import { sampler2d_scale_down_linear } from "../../../graphics/texture/sampler/sampler2d_scale_down_linear.js";
|
|
2
|
+
import { sampler2d_scale_down_linear } from "../../../graphics/texture/sampler/resize/sampler2d_scale_down_linear.js";
|
|
3
3
|
import { computeWholeDivisorLow } from "../../../../core/math/computeWholeDivisorLow.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Created by Alex on 22/08/2015.
|
|
3
3
|
*/
|
|
4
4
|
import { Transform } from '../../../ecs/transform/Transform.js';
|
|
5
|
-
import Renderable from '../../../ecs/
|
|
5
|
+
import Renderable from '../../../ecs/renderable/Renderable.js';
|
|
6
6
|
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
7
7
|
import EntityBuilder from '../../../ecs/EntityBuilder.js';
|
|
8
8
|
import { Group as ThreeGroup, Matrix4 as ThreeMatrix4, Mesh as ThreeMesh, MeshLambertMaterial } from 'three';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { behavior_to_dot } from "./behavior_to_dot.js";
|
|
2
|
+
import { SucceedingBehavior } from "./primitive/SucceedingBehavior.js";
|
|
3
|
+
import { SequenceBehavior } from "./composite/SequenceBehavior.js";
|
|
4
|
+
import { ParallelBehavior } from "./composite/ParallelBehavior.js";
|
|
5
|
+
|
|
6
|
+
test("single behavior should produce a valid string", () => {
|
|
7
|
+
const dot = behavior_to_dot(SucceedingBehavior.INSTANCE);
|
|
8
|
+
|
|
9
|
+
expect(typeof dot).toEqual("string");
|
|
10
|
+
expect(dot.trim().length).toBeGreaterThan(0);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("'sequence' should produce a valid string", () => {
|
|
14
|
+
const dot = behavior_to_dot(SequenceBehavior.from([SucceedingBehavior.INSTANCE]));
|
|
15
|
+
|
|
16
|
+
expect(typeof dot).toEqual("string");
|
|
17
|
+
expect(dot.trim().length).toBeGreaterThan(0);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("'parallel' should produce a valid string", () => {
|
|
21
|
+
const dot = behavior_to_dot(ParallelBehavior.from([SucceedingBehavior.INSTANCE]));
|
|
22
|
+
|
|
23
|
+
expect(typeof dot).toEqual("string");
|
|
24
|
+
expect(dot.trim().length).toBeGreaterThan(0);
|
|
25
|
+
});
|
|
@@ -45,9 +45,9 @@ export class DelayBehavior extends Behavior {
|
|
|
45
45
|
* @return {DelayBehavior}
|
|
46
46
|
*/
|
|
47
47
|
static from(value) {
|
|
48
|
-
assert.isNumber(value,
|
|
49
|
-
assert.notNaN(value,'value');
|
|
50
|
-
assert.isFiniteNumber(value,'value');
|
|
48
|
+
assert.isNumber(value, 'value');
|
|
49
|
+
assert.notNaN(value, 'value');
|
|
50
|
+
assert.isFiniteNumber(value, 'value');
|
|
51
51
|
|
|
52
52
|
const r = new DelayBehavior();
|
|
53
53
|
|
|
@@ -56,7 +56,9 @@ export class DelayBehavior extends Behavior {
|
|
|
56
56
|
return r;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
initialize() {
|
|
59
|
+
initialize(ctx) {
|
|
60
|
+
super.initialize(ctx);
|
|
61
|
+
|
|
60
62
|
this.elapsed = 0;
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -164,14 +164,48 @@ export class Blackboard extends AbstractBlackboard {
|
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
166
|
*
|
|
167
|
+
* NOTE: where variables of same type with same names exist - they are kept and their values are updated
|
|
167
168
|
* @param {Blackboard} other
|
|
168
169
|
*/
|
|
169
170
|
copy(other) {
|
|
170
|
-
|
|
171
|
+
// perform coalescence
|
|
172
|
+
|
|
173
|
+
const this_data = this.data;
|
|
171
174
|
|
|
172
175
|
other.traverse((name, value, type) => {
|
|
173
|
-
|
|
176
|
+
|
|
177
|
+
const variable = this_data[name];
|
|
178
|
+
|
|
179
|
+
const other_value = value.getValue();
|
|
180
|
+
|
|
181
|
+
if (variable === undefined) {
|
|
182
|
+
this.acquire(name, type, other_value);
|
|
183
|
+
} else if (variable.type !== type) {
|
|
184
|
+
// type mismatch
|
|
185
|
+
delete this_data[name]
|
|
186
|
+
this.acquire(name, type, other_value);
|
|
187
|
+
} else {
|
|
188
|
+
// variable exists and types match
|
|
189
|
+
variable.value.set(other_value);
|
|
190
|
+
}
|
|
191
|
+
|
|
174
192
|
});
|
|
193
|
+
|
|
194
|
+
// find out which keys should be removed
|
|
195
|
+
const garbage = [];
|
|
196
|
+
|
|
197
|
+
for (const dataKey in this_data) {
|
|
198
|
+
const variable = this_data[dataKey];
|
|
199
|
+
if (!other.contains(dataKey, variable.type)) {
|
|
200
|
+
garbage.push(dataKey);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
for (let i = 0; i < garbage.length; i++) {
|
|
205
|
+
const key = garbage[i];
|
|
206
|
+
|
|
207
|
+
delete this_data[key];
|
|
208
|
+
}
|
|
175
209
|
}
|
|
176
210
|
|
|
177
211
|
/**
|
|
@@ -39,6 +39,41 @@ test("entry is copied across when blackboard is copied", () => {
|
|
|
39
39
|
expect(b.acquireNumber('test').getValue()).toBe(7);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
test('copy when destination has a variable with the same name but a different type', () => {
|
|
43
|
+
|
|
44
|
+
const a = new Blackboard();
|
|
45
|
+
|
|
46
|
+
a.acquireNumber('test', 7);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const b = new Blackboard();
|
|
50
|
+
|
|
51
|
+
b.acquireBoolean("test", true);
|
|
52
|
+
|
|
53
|
+
b.copy(a);
|
|
54
|
+
|
|
55
|
+
expect(b.acquireNumber('test').getValue()).toEqual(7);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("copy preserves existing references and updates their value", () => {
|
|
59
|
+
|
|
60
|
+
const a = new Blackboard();
|
|
61
|
+
|
|
62
|
+
a.acquireNumber('test', 7);
|
|
63
|
+
|
|
64
|
+
const b = new Blackboard();
|
|
65
|
+
|
|
66
|
+
const vector_before = b.acquireNumber("test", 3);
|
|
67
|
+
|
|
68
|
+
b.copy(a);
|
|
69
|
+
|
|
70
|
+
const vector_after = b.acquireNumber("test");
|
|
71
|
+
|
|
72
|
+
expect(vector_after).toBe(vector_before);
|
|
73
|
+
expect(vector_after.getValue()).toBe(7);
|
|
74
|
+
|
|
75
|
+
});
|
|
76
|
+
|
|
42
77
|
test("to/from JSON serialization consistency", () => {
|
|
43
78
|
|
|
44
79
|
const source = new Blackboard();
|
|
@@ -60,3 +95,17 @@ test("to/from JSON serialization consistency", () => {
|
|
|
60
95
|
expect(target.contains('label', DataType.String)).toBe(true);
|
|
61
96
|
expect(target.acquireString('label').getValue()).toBe('hello');
|
|
62
97
|
});
|
|
98
|
+
|
|
99
|
+
test("increment number", () => {
|
|
100
|
+
const bb = new Blackboard();
|
|
101
|
+
|
|
102
|
+
bb.acquireNumber("x", 3);
|
|
103
|
+
|
|
104
|
+
bb.incrementNumber("x", 5);
|
|
105
|
+
|
|
106
|
+
expect(bb.acquireNumber('x').getValue()).toEqual(8);
|
|
107
|
+
|
|
108
|
+
bb.incrementNumber("x");
|
|
109
|
+
|
|
110
|
+
expect(bb.acquireNumber('x').getValue()).toEqual(9);
|
|
111
|
+
});
|
|
@@ -9,6 +9,7 @@ test('to/from binary buffer serialization', () => {
|
|
|
9
9
|
|
|
10
10
|
bb.acquireBoolean('a.true').set(true);
|
|
11
11
|
bb.acquireBoolean('a.false').set(false);
|
|
12
|
+
bb.acquireString('x').set("test string");
|
|
12
13
|
|
|
13
14
|
const buffer = new BinaryBuffer();
|
|
14
15
|
|
|
@@ -25,4 +26,5 @@ test('to/from binary buffer serialization', () => {
|
|
|
25
26
|
expect(ba.acquireNumber('a/b/c').getValue()).toBe(42.3);
|
|
26
27
|
expect(ba.acquireBoolean('a.true').getValue()).toBe(true);
|
|
27
28
|
expect(ba.acquireBoolean('a.false').getValue()).toBe(false);
|
|
29
|
+
expect(ba.acquireString('x').getValue()).toBe("test string");
|
|
28
30
|
});
|
|
@@ -42,32 +42,35 @@ function computeOrthogonalNeighbors(result, index, width, height) {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
*
|
|
45
|
-
* @param {number|Uint8Array|Uint16Array|Float32Array} field
|
|
46
|
-
* @param {
|
|
47
|
-
* @param {
|
|
45
|
+
* @param {number[]|Uint8Array|Uint16Array|Float32Array} field
|
|
46
|
+
* @param {number} width
|
|
47
|
+
* @param {number} height
|
|
48
48
|
* @param {number} start
|
|
49
49
|
* @param {number} goal
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {
|
|
50
|
+
* @param {number} crossingPenalty
|
|
51
|
+
* @param {number} bendPenalty
|
|
52
52
|
* @param {number} blockValue
|
|
53
|
-
* @returns {Array.<
|
|
53
|
+
* @returns {Array.<number>} array of indices representing path from start to end
|
|
54
54
|
*/
|
|
55
|
-
export function
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export function find_path_on_grid_astar(
|
|
56
|
+
field,
|
|
57
|
+
width, height,
|
|
58
|
+
start, goal,
|
|
59
|
+
crossingPenalty,
|
|
60
|
+
bendPenalty,
|
|
61
|
+
blockValue
|
|
62
|
+
) {
|
|
58
63
|
|
|
59
|
-
assert.
|
|
60
|
-
assert.
|
|
64
|
+
assert.defined(field, 'field');
|
|
65
|
+
assert.notNull(field, 'field');
|
|
61
66
|
|
|
62
|
-
assert.notEqual(goal, undefined, 'end is undefined');
|
|
63
|
-
assert.notEqual(goal, null, 'end is null');
|
|
64
67
|
|
|
65
|
-
assert.
|
|
66
|
-
assert.
|
|
68
|
+
assert.isNonNegativeInteger(start, "start");
|
|
69
|
+
assert.isNonNegativeInteger(goal, "goal");
|
|
67
70
|
|
|
68
|
-
assert.
|
|
69
|
-
assert.
|
|
70
|
-
assert.
|
|
71
|
+
assert.isNumber(crossingPenalty, 'crossingPenalty');
|
|
72
|
+
assert.isNumber(bendPenalty, 'bendPenalty');
|
|
73
|
+
assert.isNumber(blockValue, 'blockValue');
|
|
71
74
|
|
|
72
75
|
|
|
73
76
|
let limitCycles = 5000000;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { System } from '../../ecs/System.js';
|
|
7
7
|
import SoundListener from './SoundListener.js';
|
|
8
8
|
import { Transform } from '../../ecs/transform/Transform.js';
|
|
9
|
-
import { browserInfo } from "../../
|
|
9
|
+
import { browserInfo } from "../../browserInfo.js";
|
|
10
10
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
11
11
|
import { noop } from "../../../core/function/Functions.js";
|
|
12
12
|
import { assert } from "../../../core/assert.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
TetrahedronBufferGeometry
|
|
10
10
|
} from "three";
|
|
11
11
|
import EntityBuilder from "../../../engine/ecs/EntityBuilder.js";
|
|
12
|
-
import Renderable from "../../../engine/ecs/
|
|
12
|
+
import Renderable from "../../../engine/ecs/renderable/Renderable.js";
|
|
13
13
|
import { Transform } from "../../../engine/ecs/transform/Transform.js";
|
|
14
14
|
import LabelView from "../../../view/common/LabelView.js";
|
|
15
15
|
import GUIElement from "../../../engine/ecs/gui/GUIElement.js";
|