@woosh/meep-engine 2.51.0 → 2.53.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 +1 -1
- package/editor/ecs/component/prototypeObjectEditor.js +1 -1
- package/editor/process/ObstacleGridDisplayProcess.js +2 -2
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/tools/GridPaintTool.js +2 -2
- package/package.json +4 -3
- package/samples/generation/SampleGenerator0.js +1 -1
- package/samples/generation/generators/interactive/mir_generator_place_buff_objects.js +1 -1
- package/samples/generation/generators/mir_generator_place_bases.js +1 -1
- package/samples/generation/generators/mir_generator_place_road_decorators.js +1 -1
- package/samples/generation/generators/mir_generator_place_starting_point.js +1 -1
- package/samples/generation/main.js +2 -2
- package/samples/generation/rules/matcher_play_area.js +1 -1
- package/samples/generation/rules/matcher_tag_occupied.js +1 -1
- package/samples/generation/rules/matcher_tag_traversable.js +1 -1
- package/samples/generation/themes/SampleTheme0.js +5 -5
- package/src/core/NumberFormat.js +0 -71
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -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/collection/table/RowFirstTableSpec.js +8 -4
- package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +41 -0
- package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.spec.js +10 -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/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/Engine.spec.js +4 -0
- package/src/engine/ecs/EntityBuilder.js +3 -1
- package/src/engine/ecs/EntityBuilder.spec.js +21 -0
- package/src/engine/ecs/EntityComponentDataset.js +1 -1
- package/src/engine/ecs/EntityObserver.spec.js +1 -1
- package/src/engine/ecs/dynamic_actions/actions/definition/{WhiteToBlackboardActionDescription.js → WriteToBlackboardActionDescription.js} +2 -2
- package/src/engine/ecs/dynamic_actions/actions/definition/deserializeActionFromJSON.js +2 -2
- package/src/engine/ecs/gui/GUIElement.js +1 -1
- package/src/engine/ecs/gui/position/ViewportPosition.js +3 -3
- package/src/engine/ecs/guid/GUIDSerializationAdapter.spec.js +21 -0
- package/src/engine/ecs/parent/EntityNode.js +1 -1
- package/src/engine/ecs/parent/EntityNode.spec.js +104 -0
- package/src/engine/ecs/speaker/Voice.js +4 -0
- package/src/engine/ecs/team/Team.js +0 -44
- package/src/engine/ecs/team/TeamSerializationAdapter.js +46 -0
- package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +1 -1
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +1 -1
- package/src/engine/ecs/transform/Transform.js +2 -1
- package/src/engine/ecs/transform/Transform.spec.js +24 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +2 -6
- 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 +2 -20
- 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/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/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +2 -6
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +2 -4
- package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +0 -2
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -6
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -6
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +2 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +4 -8
- 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 +2 -2
- package/src/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/src/engine/graphics/texture/TextureBackedMemoryRegion.js +4 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
- package/src/engine/graphics/texture/sampler/filter/filter_lanczos3.js +7 -2
- package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +3 -23
- package/src/engine/grid/grid2transform/GridPosition2Transform.js +122 -0
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +70 -0
- package/src/engine/grid/grid2transform/GridPosition2TransformSerializationUpgrader_0_1.js +40 -0
- package/src/engine/grid/{systems → grid2transform}/GridPosition2TransformSystem.js +3 -3
- package/src/engine/grid/{components → obstacle}/GridObstacle.js +45 -25
- package/src/engine/grid/obstacle/GridObstacle.spec.js +175 -0
- package/src/engine/grid/{components → position}/GridPosition.js +6 -14
- package/src/engine/grid/{systems → position}/GridPositionSystem.js +1 -1
- package/src/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/src/engine/input/devices/PointerDevice.spec.js +5 -0
- package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +5 -1
- package/src/engine/navigation/ecs/path_following/PathFollower.js +40 -32
- package/src/engine/navigation/ecs/path_following/PathFollower.spec.js +27 -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/generation/filtering/CellFilter.js +6 -9
- package/src/generation/filtering/boolean/CellFilterLiteralBoolean.js +1 -4
- package/src/generation/filtering/core/CellFilterBinaryOperation.js +12 -15
- package/src/generation/filtering/core/CellFilterOperationTertiary.js +15 -19
- package/src/generation/filtering/numeric/CellFilterLiteralFloat.js +6 -9
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.js +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.js +2 -2
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
- package/src/generation/theme/TerrainLayerDescription.js +1 -1
- package/src/view/common/LabelView.js +3 -3
- 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/TargetAI.js +0 -11
- package/src/engine/ecs/components/ViewportMeshProjection.js +0 -18
- 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/ExportCanvasAsPNG.js +0 -7
- package/src/engine/grid/components/GridObstacle.spec.js +0 -46
- package/src/engine/grid/components/GridPosition2Transform.js +0 -232
- 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/PathFinder.js +0 -172
- package/src/engine/navigation/PathWorker.js +0 -78
- package/src/engine/navigation/ecs/systems/PathFinderSystem.js +0 -63
- package/src/engine/navigation/ecs/systems/PathSystem.js +0 -19
- package/src/engine/navigation/funnel/Funnel.js +0 -196
- package/src/generation/ZoneNode.js +0 -9
- /package/{src/generation → samples/generation/grid}/GridTags.js +0 -0
- /package/src/{engine → core/primitives/array}/computeStridedIntegerArrayHash.js +0 -0
- /package/src/engine/grid/{components → grid2transform}/GridPosition2TransformFlags.js +0 -0
- /package/src/engine/grid/{components → obstacle}/GridObstacleSerializationAdapter.js +0 -0
- /package/src/engine/grid/{components → position}/GridPositionSerializationAdapter.js +0 -0
- /package/src/engine/grid/{components → position}/GridPositionSerializationUpdater_0_1.js +0 -0
package/src/engine/Clock.js
CHANGED
|
@@ -5,16 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import Stat from "../core/model/stat/Stat.js";
|
|
7
7
|
|
|
8
|
+
//Use highest available resolution time source
|
|
9
|
+
const source = typeof performance === "undefined" ? Date : performance;
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
*
|
|
11
13
|
* @returns {number}
|
|
12
14
|
*/
|
|
13
15
|
export function currentTimeInSeconds() {
|
|
14
|
-
|
|
15
|
-
const source = typeof performance === "undefined" ? Date : performance;
|
|
16
|
-
|
|
17
|
-
return source.now() / 1000;
|
|
16
|
+
return source.now() * 0.001;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -29,35 +28,37 @@ function updateElapsedTime(clock) {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
class Clock {
|
|
32
|
-
constructor() {
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @type {number}
|
|
36
|
-
* @private
|
|
37
|
-
*/
|
|
38
|
-
this.__lastMeasurement = 0;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @type {number}
|
|
43
|
-
*/
|
|
44
|
-
this.elapsedTime = 0;
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @type {number}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
__lastMeasurement = 0;
|
|
47
38
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @type {number}
|
|
42
|
+
*/
|
|
43
|
+
elapsedTime = 0;
|
|
44
|
+
|
|
45
|
+
timeAtDelta = 0;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
__isRunning = false;
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
/**
|
|
56
|
+
* how fast clock ticks in relation to real time
|
|
57
|
+
* @type {Stat}
|
|
58
|
+
*/
|
|
59
|
+
speed = new Stat(1);
|
|
60
|
+
|
|
61
|
+
constructor() {
|
|
61
62
|
this.speed.postprocess = Stat.Process.clampMin(0);
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Clock from "./Clock.js";
|
|
2
|
+
import { delay } from "../core/process/delay.js";
|
|
3
|
+
|
|
4
|
+
test("constructor does not throw", () => {
|
|
5
|
+
new Clock();
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("reset", () => {
|
|
9
|
+
const clock = new Clock();
|
|
10
|
+
clock.reset();
|
|
11
|
+
|
|
12
|
+
expect(clock.getElapsedTime()).toBe(0);
|
|
13
|
+
expect(clock.getDelta()).toBe(0);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("getDelta", async () => {
|
|
17
|
+
const clock = new Clock();
|
|
18
|
+
|
|
19
|
+
clock.start();
|
|
20
|
+
|
|
21
|
+
await delay(30);
|
|
22
|
+
|
|
23
|
+
const delta = clock.getDelta();
|
|
24
|
+
|
|
25
|
+
expect(delta).toBeCloseTo(0.03, 0.01);
|
|
26
|
+
});
|
|
@@ -229,7 +229,7 @@ class EntityBuilder {
|
|
|
229
229
|
/**
|
|
230
230
|
*
|
|
231
231
|
* @param {string} eventName
|
|
232
|
-
* @param {*} event
|
|
232
|
+
* @param {*} [event]
|
|
233
233
|
*/
|
|
234
234
|
sendEvent(eventName, event) {
|
|
235
235
|
if (this.getFlag(EntityBuilderFlags.Built)) {
|
|
@@ -368,6 +368,8 @@ class EntityBuilder {
|
|
|
368
368
|
const subscription = listeners[i];
|
|
369
369
|
dataset.addEntityEventListener(entity, subscription.name, subscription.listener, subscription.context);
|
|
370
370
|
}
|
|
371
|
+
// reset listeners
|
|
372
|
+
this.deferredListeners.splice(0, listeners_count);
|
|
371
373
|
|
|
372
374
|
const element = this.element;
|
|
373
375
|
const element_count = element.length;
|
|
@@ -55,13 +55,18 @@ test("'Built' flag is reset when entity is removed without invoking 'destroy' me
|
|
|
55
55
|
|
|
56
56
|
const b = new EntityBuilder();
|
|
57
57
|
|
|
58
|
+
expect(b.getFlag(EntityBuilderFlags.Built)).toBe(false);
|
|
59
|
+
expect(b.isBuilt).toBe(false);
|
|
60
|
+
|
|
58
61
|
b.build(dataset);
|
|
59
62
|
|
|
60
63
|
expect(b.getFlag(EntityBuilderFlags.Built)).toBe(true);
|
|
64
|
+
expect(b.isBuilt).toBe(true);
|
|
61
65
|
|
|
62
66
|
dataset.removeEntity(b.entity);
|
|
63
67
|
|
|
64
68
|
expect(b.getFlag(EntityBuilderFlags.Built)).toBe(false);
|
|
69
|
+
expect(b.isBuilt).toBe(false);
|
|
65
70
|
});
|
|
66
71
|
|
|
67
72
|
test("removeAllComponents from empty", () => {
|
|
@@ -131,4 +136,20 @@ test("adding component to live entity results in component being added to the da
|
|
|
131
136
|
entity.add(component);
|
|
132
137
|
|
|
133
138
|
expect(ecd.getComponent(entity.entity, DummyComponent)).toBe(component);
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("promiseEvent", async () => {
|
|
143
|
+
|
|
144
|
+
const entity = new EntityBuilder();
|
|
145
|
+
|
|
146
|
+
const ecd = sampleDataset();
|
|
147
|
+
|
|
148
|
+
entity.build(ecd)
|
|
149
|
+
|
|
150
|
+
const promise = entity.promiseEvent("x");
|
|
151
|
+
|
|
152
|
+
entity.sendEvent("x");
|
|
153
|
+
|
|
154
|
+
await promise;
|
|
134
155
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityObserver } from "./EntityObserver.js";
|
|
2
2
|
import { Transform } from "./transform/Transform.js";
|
|
3
|
-
import GridPosition from "../grid/
|
|
3
|
+
import GridPosition from "../grid/position/GridPosition.js";
|
|
4
4
|
import EntityBuilder from "./EntityBuilder.js";
|
|
5
5
|
import { EntityComponentDataset } from "./EntityComponentDataset.js";
|
|
6
6
|
import { noop } from "../../core/function/Functions.js";
|
|
@@ -4,7 +4,7 @@ import { Blackboard } from "../../../../intelligence/blackboard/Blackboard.js";
|
|
|
4
4
|
import { compileReactiveExpression } from "../../../../../core/lang/reactive/compileReactiveExpression.js";
|
|
5
5
|
import { assert } from "../../../../../core/assert.js";
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class WriteToBlackboardActionDescription extends AbstractActionDescription {
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
10
|
|
|
@@ -55,4 +55,4 @@ export class WhiteToBlackboardActionDescription extends AbstractActionDescriptio
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
WriteToBlackboardActionDescription.prototype.type = "Write";
|
|
@@ -5,7 +5,7 @@ import { ActionSequenceDescription } from "./ActionSequenceDescription.js";
|
|
|
5
5
|
import { DelayActionDescription } from "./DelayActionDescription.js";
|
|
6
6
|
import { NoopActionDescription } from "./NoopActionDescription.js";
|
|
7
7
|
import { WeightedRandomActionDescription } from "./WeightedRandomActionDescription.js";
|
|
8
|
-
import {
|
|
8
|
+
import { WriteToBlackboardActionDescription } from "./WriteToBlackboardActionDescription.js";
|
|
9
9
|
|
|
10
10
|
const type_map = {
|
|
11
11
|
Sequence({ elements }) {
|
|
@@ -59,7 +59,7 @@ registerType(SpeakLineActionDescription);
|
|
|
59
59
|
registerType(SendRequestActionDescription);
|
|
60
60
|
registerType(DelayActionDescription);
|
|
61
61
|
registerType(NoopActionDescription);
|
|
62
|
-
registerType(
|
|
62
|
+
registerType(WriteToBlackboardActionDescription);
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
*
|
|
@@ -97,9 +97,9 @@ class ViewportPosition {
|
|
|
97
97
|
|
|
98
98
|
hash() {
|
|
99
99
|
return computeHashIntegerArray(
|
|
100
|
-
this.position.
|
|
101
|
-
this.offset.
|
|
102
|
-
this.anchor.
|
|
100
|
+
this.position.hash(),
|
|
101
|
+
this.offset.hash(),
|
|
102
|
+
this.anchor.hash(),
|
|
103
103
|
this.resolveGuiCollisions ? 1 : 0,
|
|
104
104
|
computeHashFloat(this.screenEdgeWidth),
|
|
105
105
|
this.stickToScreenEdge ? 1 : 0,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GUID } from "./GUID.js";
|
|
2
|
+
import { GUIDSerializationAdapter } from "./GUIDSerializationAdapter.js";
|
|
3
|
+
import { BinaryBuffer } from "../../../core/binary/BinaryBuffer.js";
|
|
4
|
+
|
|
5
|
+
test("to/from consistency", () => {
|
|
6
|
+
|
|
7
|
+
const source = GUID.parse("a88bb73a-c89f-11ed-afa1-0242ac120002");
|
|
8
|
+
|
|
9
|
+
const adapter = new GUIDSerializationAdapter();
|
|
10
|
+
|
|
11
|
+
const buffer = new BinaryBuffer();
|
|
12
|
+
|
|
13
|
+
adapter.serialize(buffer, source);
|
|
14
|
+
buffer.position = 0; // rewind
|
|
15
|
+
|
|
16
|
+
const destination = new GUID();
|
|
17
|
+
|
|
18
|
+
adapter.deserialize(buffer, destination);
|
|
19
|
+
|
|
20
|
+
expect(destination.equals(source)).toBe(true);
|
|
21
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { EntityNode } from "./EntityNode.js";
|
|
2
|
+
import { EntityComponentDataset } from "../EntityComponentDataset.js";
|
|
3
|
+
|
|
4
|
+
test("constructor does not throw", () => {
|
|
5
|
+
new EntityNode()
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test("setFlag", () => {
|
|
9
|
+
const ut = new EntityNode();
|
|
10
|
+
|
|
11
|
+
ut.setFlag(0b101);
|
|
12
|
+
|
|
13
|
+
expect(ut.flags).toBe(5);
|
|
14
|
+
|
|
15
|
+
ut.setFlag(0b010);
|
|
16
|
+
|
|
17
|
+
expect(ut.flags).toBe(7);
|
|
18
|
+
|
|
19
|
+
ut.setFlag(0b1);
|
|
20
|
+
|
|
21
|
+
expect(ut.flags).toBe(7);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("clearFlag", () => {
|
|
25
|
+
const ut = new EntityNode();
|
|
26
|
+
ut.flags = 0b101;
|
|
27
|
+
|
|
28
|
+
ut.clearFlag(0b1);
|
|
29
|
+
|
|
30
|
+
expect(ut.flags).toBe(4);
|
|
31
|
+
|
|
32
|
+
ut.clearFlag(0b10);
|
|
33
|
+
|
|
34
|
+
expect(ut.flags).toBe(4);
|
|
35
|
+
|
|
36
|
+
ut.clearFlag(0b100);
|
|
37
|
+
|
|
38
|
+
expect(ut.flags).toBe(0);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("getFlag", () => {
|
|
42
|
+
|
|
43
|
+
const ut = new EntityNode();
|
|
44
|
+
|
|
45
|
+
ut.flags = 0b101;
|
|
46
|
+
|
|
47
|
+
expect(ut.getFlag(0b1)).toBe(true);
|
|
48
|
+
expect(ut.getFlag(0b10)).toBe(false);
|
|
49
|
+
expect(ut.getFlag(0b100)).toBe(true);
|
|
50
|
+
expect(ut.getFlag(0b1000)).toBe(false);
|
|
51
|
+
expect(ut.getFlag(0b101)).toBe(true);
|
|
52
|
+
expect(ut.getFlag(0b011)).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("writeFlag", () => {
|
|
56
|
+
const ut = new EntityNode();
|
|
57
|
+
|
|
58
|
+
ut.writeFlag(0b101, true);
|
|
59
|
+
expect(ut.flags).toBe(5);
|
|
60
|
+
|
|
61
|
+
ut.writeFlag(0b100, false);
|
|
62
|
+
|
|
63
|
+
expect(ut.flags).toBe(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("traverse without children", () => {
|
|
67
|
+
const node = new EntityNode();
|
|
68
|
+
|
|
69
|
+
const visited = [];
|
|
70
|
+
|
|
71
|
+
node.traverse(Array.prototype.push, visited);
|
|
72
|
+
|
|
73
|
+
expect(visited.length).toBe(1);
|
|
74
|
+
expect(visited).toContain(node);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("build empty", () => {
|
|
78
|
+
const node = new EntityNode();
|
|
79
|
+
|
|
80
|
+
const dataset = new EntityComponentDataset();
|
|
81
|
+
|
|
82
|
+
node.build(dataset);
|
|
83
|
+
|
|
84
|
+
expect(node.isBuilt).toBe(true);
|
|
85
|
+
expect(node.entity.isBuilt).toBe(true);
|
|
86
|
+
expect(dataset.entityExists(node.entity.entity)).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("destroy empty", () => {
|
|
90
|
+
const node = new EntityNode();
|
|
91
|
+
|
|
92
|
+
const dataset = new EntityComponentDataset();
|
|
93
|
+
|
|
94
|
+
node.build(dataset);
|
|
95
|
+
|
|
96
|
+
const entity = node.entity.entity;
|
|
97
|
+
|
|
98
|
+
node.destroy();
|
|
99
|
+
|
|
100
|
+
expect(node.isBuilt).toBe(false);
|
|
101
|
+
expect(node.entity.isBuilt).toBe(false);
|
|
102
|
+
expect(dataset.entityExists(entity)).toBe(false);
|
|
103
|
+
|
|
104
|
+
});
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Created by Alex on 13/04/2016.
|
|
3
3
|
*/
|
|
4
4
|
import ObservedInteger from "../../../core/model/ObservedInteger.js";
|
|
5
|
-
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
6
5
|
|
|
7
6
|
class Team extends ObservedInteger {
|
|
8
7
|
/**
|
|
@@ -37,46 +36,3 @@ Team.typeName = "Team";
|
|
|
37
36
|
|
|
38
37
|
export default Team;
|
|
39
38
|
|
|
40
|
-
export class TeamSerializationAdapter extends BinaryClassSerializationAdapter{
|
|
41
|
-
constructor(){
|
|
42
|
-
super();
|
|
43
|
-
|
|
44
|
-
this.klass = Team;
|
|
45
|
-
this.version = 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {BinaryBuffer} buffer
|
|
51
|
-
* @param {Team} value
|
|
52
|
-
*/
|
|
53
|
-
serialize(buffer, value) {
|
|
54
|
-
const v = value.getValue();
|
|
55
|
-
|
|
56
|
-
if (v === Infinity) {
|
|
57
|
-
buffer.writeInt32(2147483647);
|
|
58
|
-
} else if (v === -Infinity) {
|
|
59
|
-
buffer.writeInt32(-2147483648);
|
|
60
|
-
} else {
|
|
61
|
-
//TODO it's possible to write encoded Infinity values by accident
|
|
62
|
-
buffer.writeInt32(v);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {BinaryBuffer} buffer
|
|
69
|
-
* @param {Team} value
|
|
70
|
-
*/
|
|
71
|
-
deserialize(buffer, value) {
|
|
72
|
-
const v = buffer.readInt32();
|
|
73
|
-
|
|
74
|
-
if (v === 2147483647) {
|
|
75
|
-
value.set(Infinity);
|
|
76
|
-
} else if (v === -2147483648) {
|
|
77
|
-
value.set(-Infinity);
|
|
78
|
-
} else {
|
|
79
|
-
value.set(v);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import Team from "./Team.js";
|
|
3
|
+
|
|
4
|
+
export class TeamSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = Team;
|
|
9
|
+
this.version = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {BinaryBuffer} buffer
|
|
15
|
+
* @param {Team} value
|
|
16
|
+
*/
|
|
17
|
+
serialize(buffer, value) {
|
|
18
|
+
const v = value.getValue();
|
|
19
|
+
|
|
20
|
+
if (v === Infinity) {
|
|
21
|
+
buffer.writeInt32(2147483647);
|
|
22
|
+
} else if (v === -Infinity) {
|
|
23
|
+
buffer.writeInt32(-2147483648);
|
|
24
|
+
} else {
|
|
25
|
+
//TODO it's possible to write encoded Infinity values by accident
|
|
26
|
+
buffer.writeInt32(v);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {BinaryBuffer} buffer
|
|
33
|
+
* @param {Team} value
|
|
34
|
+
*/
|
|
35
|
+
deserialize(buffer, value) {
|
|
36
|
+
const v = buffer.readInt32();
|
|
37
|
+
|
|
38
|
+
if (v === 2147483647) {
|
|
39
|
+
value.set(Infinity);
|
|
40
|
+
} else if (v === -2147483648) {
|
|
41
|
+
value.set(-Infinity);
|
|
42
|
+
} else {
|
|
43
|
+
value.set(v);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -25,6 +25,7 @@ const scratch_matrix = new Float32Array(16);
|
|
|
25
25
|
const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
+
* Described position/rotation/scale in 3d space
|
|
28
29
|
* @class
|
|
29
30
|
*/
|
|
30
31
|
export class Transform {
|
|
@@ -302,7 +303,7 @@ export class Transform {
|
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
/**
|
|
305
|
-
*
|
|
306
|
+
* Write out the current transform to a supplied container
|
|
306
307
|
* @param {number[]|Float32Array} result
|
|
307
308
|
*/
|
|
308
309
|
toMatrix4(result) {
|
|
@@ -149,3 +149,27 @@ test("writeFlag", () => {
|
|
|
149
149
|
|
|
150
150
|
expect(ut.flags).toBe(1);
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
test("toMatrix from identity transform", () => {
|
|
154
|
+
const t = new Transform();
|
|
155
|
+
|
|
156
|
+
t.makeIdentity();
|
|
157
|
+
|
|
158
|
+
const matrix = [];
|
|
159
|
+
|
|
160
|
+
t.toMatrix4(matrix);
|
|
161
|
+
|
|
162
|
+
expect(matrix).toEqual(Array.from(MATRIX_4_IDENTITY));
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("hash", () => {
|
|
166
|
+
|
|
167
|
+
const t = new Transform();
|
|
168
|
+
|
|
169
|
+
const hash = t.hash();
|
|
170
|
+
|
|
171
|
+
expect(typeof hash).toBe("number");
|
|
172
|
+
expect(Number.isInteger(hash)).toBe(true);
|
|
173
|
+
expect(t.hash()).toEqual(hash);
|
|
174
|
+
|
|
175
|
+
});
|
|
@@ -23,11 +23,10 @@ import WaterSystem from "../ecs/water/WaterSystem.js";
|
|
|
23
23
|
import Trail2DSystem from "../ecs/trail2d/Trail2DSystem.js";
|
|
24
24
|
import { Foliage2System } from "../../ecs/foliage/ecs/Foliage2System.js";
|
|
25
25
|
import ViewportPositionSystem from "../../ecs/gui/position/ViewportPositionSystem.js";
|
|
26
|
-
import { GridPosition2TransformSystem } from "../../grid/
|
|
26
|
+
import { GridPosition2TransformSystem } from "../../grid/grid2transform/GridPosition2TransformSystem.js";
|
|
27
27
|
import { Transform2GridPositionSystem } from "../../grid/transform2grid/Transform2GridPositionSystem.js";
|
|
28
28
|
import SynchronizePositionSystem from "../../ecs/systems/SynchronizePositionSystem.js";
|
|
29
|
-
import
|
|
30
|
-
import GridPositionSystem from "../../grid/systems/GridPositionSystem.js";
|
|
29
|
+
import GridPositionSystem from "../../grid/position/GridPositionSystem.js";
|
|
31
30
|
import InputControllerSystem from "../../input/ecs/systems/InputControllerSystem.js";
|
|
32
31
|
import { InputSystem } from "../../input/ecs/systems/InputSystem.js";
|
|
33
32
|
import MeshHighlightSystem from "../ecs/highlight/system/MeshHighlightSystem.js";
|
|
@@ -37,7 +36,6 @@ import { AnimationGraphSystem } from "../ecs/animation/animator/AnimationGraphSy
|
|
|
37
36
|
import { FogOfWarSystem } from "../../ecs/fow/FogOfWarSystem.js";
|
|
38
37
|
import { FogOfWarRevealerSystem } from "../../ecs/fow/FogOfWarRevealerSystem.js";
|
|
39
38
|
import { BehaviorSystem } from "../../intelligence/behavior/ecs/BehaviorSystem.js";
|
|
40
|
-
import { SerializationMetadataSystem } from "../../ecs/systems/SerializationMetadataSystem.js";
|
|
41
39
|
import { InverseKinematicsSystem } from "../../ecs/ik/InverseKinematicsSystem.js";
|
|
42
40
|
import { PathDisplaySystem } from "../ecs/path/PathDisplaySystem.js";
|
|
43
41
|
import RenderSystem from "../../ecs/systems/RenderSystem.js";
|
|
@@ -105,7 +103,6 @@ function makeConfig(engine) {
|
|
|
105
103
|
new GridPosition2TransformSystem(),
|
|
106
104
|
new Transform2GridPositionSystem(),
|
|
107
105
|
new SynchronizePositionSystem(),
|
|
108
|
-
new GridObstacleSystem(),
|
|
109
106
|
new GridPositionSystem(),
|
|
110
107
|
new InputControllerSystem(devices),
|
|
111
108
|
new InputSystem(devices),
|
|
@@ -119,7 +116,6 @@ function makeConfig(engine) {
|
|
|
119
116
|
new FogOfWarSystem(graphics),
|
|
120
117
|
new FogOfWarRevealerSystem(0),
|
|
121
118
|
new BehaviorSystem(engine),
|
|
122
|
-
new SerializationMetadataSystem(),
|
|
123
119
|
new InverseKinematicsSystem(),
|
|
124
120
|
new PathDisplaySystem(engine),
|
|
125
121
|
);
|
package/src/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js
CHANGED
|
@@ -9,31 +9,30 @@ import { computeHashIntegerArray } from "../../../../../../../core/collection/ar
|
|
|
9
9
|
import { isArrayEqual } from "../../../../../../../core/collection/array/isArrayEqual.js";
|
|
10
10
|
|
|
11
11
|
export class AnimationGraphDefinition {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @type {AnimationStateDefinition[]}
|
|
16
|
+
*/
|
|
17
|
+
states = [];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {AnimationTransitionDefinition[]}
|
|
22
|
+
*/
|
|
23
|
+
transitions = [];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {AnimationStateDefinition}
|
|
28
|
+
*/
|
|
29
|
+
startingSate = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @type {AnimationClipDefinition[]}
|
|
34
|
+
*/
|
|
35
|
+
clipIndex = [];
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
*
|