@woosh/meep-engine 2.36.28 → 2.37.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/core/bvh2/bvh3/{bvh_query_user_data_by_frustum.js → bvh_query_user_data_overlaps_frustum.js} +4 -5
- package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +1 -1
- package/core/color/Color.js +54 -3
- package/core/color/hsv2rgb.js +3 -3
- package/core/color/kelvin_to_rgb.js +51 -0
- package/core/color/kelvin_to_rgb.spec.js +61 -0
- package/core/color/linear_to_sRGB.js +17 -0
- package/core/color/prototype_kelvin_to_rgb.js +44 -0
- package/core/color/rgb_to_kelvin.js +34 -0
- package/core/color/rgb_to_kelvin.spec.js +15 -0
- package/core/color/sRGB_to_linear.js +16 -0
- package/core/geom/3d/frustum/read_frustum_planes_to_array.d.ts +3 -0
- package/{engine/graphics/render/forward_plus/cluster → core/geom/3d/frustum}/read_frustum_planes_to_array.js +1 -1
- package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +2 -2
- package/core/geom/LineSegment.js +2 -2
- package/core/geom/Vector3.js +14 -0
- package/core/math/DEG_TO_RAD.js +1 -0
- package/core/math/MathUtils.spec.js +0 -13
- package/core/math/RAD_TO_DEG.js +1 -0
- package/core/math/clamp01.js +15 -0
- package/core/math/fract.js +10 -0
- package/core/math/newton_solver_1d.js +21 -0
- package/core/math/smoothStep.js +3 -3
- package/core/math/solveQuadratic.js +32 -12
- package/core/math/solveQuadratic.spec.js +18 -0
- package/core/primitives/strings/StringUtils.js +10 -0
- package/core/process/task/TaskUtils.js +2 -2
- package/core/process/undo/Action.d.ts +2 -2
- package/core/process/undo/Action.js +4 -4
- package/core/process/undo/ActionGroup.js +4 -4
- package/core/process/undo/ActionProcessor.d.ts +6 -6
- package/core/process/undo/ActionProcessor.js +106 -16
- package/core/process/undo/ActionProcessor.spec.js +20 -15
- package/editor/actions/concrete/ComponentAddAction.js +2 -2
- package/editor/actions/concrete/ComponentRemoveAction.js +2 -2
- package/editor/actions/concrete/EntityCreateAction.js +2 -2
- package/editor/actions/concrete/EntityRemoveAction.js +2 -2
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +2 -2
- package/editor/actions/concrete/PatchTerrainHeightAction.js +2 -2
- package/editor/actions/concrete/PatchTerrainTextureAction.js +2 -2
- package/editor/actions/concrete/SelectionAddAction.js +2 -2
- package/editor/actions/concrete/SelectionClearAction.js +2 -2
- package/editor/actions/concrete/SelectionRemoveAction.js +2 -2
- package/editor/actions/concrete/TransformModifyAction.js +2 -2
- package/editor/actions/concrete/WriteGridValueAction.js +2 -2
- package/editor/view/EditorView.js +11 -9
- package/editor/view/ecs/components/color/GaugeView.js +2 -2
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +5 -4
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +5 -3
- package/engine/Clock.js +4 -0
- package/engine/UserController.js +2 -1
- package/engine/animation/behavior/animateProperty.js +6 -1
- package/engine/animation/keyed2/behavior/AnimationBehavior.js +0 -1
- package/engine/ecs/EntityBuilder.js +12 -1
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -1
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +2 -1
- package/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +14 -11
- package/engine/ecs/systems/AimControllerSystem.js +3 -2
- package/engine/ecs/systems/RangedAttackSystem.js +3 -2
- package/engine/ecs/systems/SteeringSystem.js +3 -3
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
- package/engine/graphics/GraphicsEngine.js +2 -1
- package/engine/graphics/camera/CameraShake.js +4 -4
- package/engine/graphics/ecs/animation/animator/graph/AnimationTransition.js +2 -2
- package/engine/graphics/ecs/camera/TiltCameraController.js +3 -2
- package/engine/graphics/ecs/compileAllMaterials.js +2 -2
- package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +10 -11
- package/engine/graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js +2 -2
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +19 -0
- package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +4 -2
- package/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.js +6 -0
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +31 -0
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -2
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -3
- package/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/engine/graphics/render/gizmo/Gizmo.js +3 -0
- package/engine/graphics/render/gizmo/GizmoRenderingPlugin.js +5 -0
- package/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +91 -0
- package/engine/graphics/render/view/CameraView.js +1 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +110 -18
- package/engine/graphics/three/OrbitControls.js +3 -2
- package/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.js +2 -2
- package/engine/graphics/util/makeMeshPreviewScene.js +11 -3
- package/engine/intelligence/behavior/Behavior.js +36 -17
- package/engine/intelligence/behavior/SelectorBehavior.js +6 -5
- package/engine/intelligence/behavior/composite/ParallelBehavior.js +0 -66
- package/engine/intelligence/behavior/composite/ParallelBehaviorSerializationAdapter.js +63 -0
- package/engine/intelligence/behavior/composite/SequenceBehavior.js +36 -11
- package/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +0 -2
- package/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.js +2 -4
- package/engine/intelligence/behavior/decorator/InverterBehavior.js +3 -3
- package/engine/intelligence/behavior/decorator/RepeatBehavior.js +0 -35
- package/engine/intelligence/behavior/decorator/RepeatBehavior.spec.js +0 -10
- package/engine/intelligence/behavior/decorator/RepeatBehaviorSerializationAdapter.js +37 -0
- package/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.js +0 -3
- package/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.js +5 -10
- package/engine/intelligence/behavior/ecs/BehaviorComponent.js +95 -7
- package/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +15 -8
- package/engine/intelligence/behavior/ecs/BehaviorSystem.js +28 -37
- package/engine/intelligence/behavior/ecs/DieBehavior.js +2 -7
- package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +2 -29
- package/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +29 -0
- package/engine/intelligence/behavior/primitive/ActionBehavior.js +6 -13
- package/engine/intelligence/behavior/primitive/FailingBehavior.js +1 -29
- package/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +29 -0
- package/engine/intelligence/behavior/primitive/PromiseBehavior.js +15 -3
- package/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +1 -5
- package/engine/intelligence/behavior/util/ConditionBehavior.js +1 -3
- package/engine/intelligence/behavior/util/ConditionBehavior.spec.js +1 -7
- package/engine/intelligence/behavior/util/ConditionalBehavior.js +3 -6
- package/engine/intelligence/behavior/util/DelayBehavior.js +2 -4
- package/engine/intelligence/behavior/util/SelectorBehavior.js +13 -12
- package/engine/intelligence/blackboard/AbstractBlackboard.js +16 -2
- package/engine/plugin/EnginePluginManager.js +4 -14
- package/engine/sound/ecs/emitter/SoundEmitter.js +3 -0
- package/generation/filtering/numeric/math/CellFilterSaturate.js +2 -2
- package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +3 -2
- package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +1 -1
- package/generation/rules/CellMatcherLayerBitMaskTest.js +3 -3
- package/package.json +1 -1
- package/view/elements/progress/SmoothProgressBar.js +2 -2
- package/view/elements/progress/segmented/SegmentedResourceBarView.js +3 -3
- package/view/elements/radial/RadialProgressView.js +2 -2
|
@@ -16,16 +16,11 @@ export class DieBehavior extends EntityBehavior {
|
|
|
16
16
|
if (!ecd.entityExists(entity)) {
|
|
17
17
|
//entity doesn't exist, count as success
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return this.__status;
|
|
19
|
+
return BehaviorStatus.Succeeded;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
ecd.removeEntity(entity);
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return this.__status;
|
|
29
|
-
|
|
24
|
+
return BehaviorStatus.Succeeded;
|
|
30
25
|
}
|
|
31
26
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EntityBehavior } from "./EntityBehavior.js";
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
|
-
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
4
3
|
import { assert } from "../../../../core/assert.js";
|
|
5
4
|
|
|
6
5
|
export class WaitForEventBehavior extends EntityBehavior {
|
|
@@ -48,10 +47,10 @@ export class WaitForEventBehavior extends EntityBehavior {
|
|
|
48
47
|
|
|
49
48
|
tick(timeDelta) {
|
|
50
49
|
if (this.detected) {
|
|
51
|
-
|
|
50
|
+
return BehaviorStatus.Succeeded;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
return
|
|
53
|
+
return BehaviorStatus.Running;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
/**
|
|
@@ -89,29 +88,3 @@ export class WaitForEventBehavior extends EntityBehavior {
|
|
|
89
88
|
*/
|
|
90
89
|
WaitForEventBehavior.typeName = "WaitForEventBehavior";
|
|
91
90
|
|
|
92
|
-
export class WaitForEventBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
93
|
-
constructor() {
|
|
94
|
-
super();
|
|
95
|
-
|
|
96
|
-
this.klass = WaitForEventBehavior;
|
|
97
|
-
this.version = 0;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
* @param {BinaryBuffer} buffer
|
|
103
|
-
* @param {WaitForEventBehavior} value
|
|
104
|
-
*/
|
|
105
|
-
serialize(buffer, value) {
|
|
106
|
-
buffer.writeUTF8String(value.event);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {BinaryBuffer} buffer
|
|
112
|
-
* @param {WaitForEventBehavior} value
|
|
113
|
-
*/
|
|
114
|
-
deserialize(buffer, value) {
|
|
115
|
-
value.event = buffer.readUTF8String();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { WaitForEventBehavior } from "./WaitForEventBehavior.js";
|
|
3
|
+
|
|
4
|
+
export class WaitForEventBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = WaitForEventBehavior;
|
|
9
|
+
this.version = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {BinaryBuffer} buffer
|
|
15
|
+
* @param {WaitForEventBehavior} value
|
|
16
|
+
*/
|
|
17
|
+
serialize(buffer, value) {
|
|
18
|
+
buffer.writeUTF8String(value.event);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {BinaryBuffer} buffer
|
|
24
|
+
* @param {WaitForEventBehavior} value
|
|
25
|
+
*/
|
|
26
|
+
deserialize(buffer, value) {
|
|
27
|
+
value.event = buffer.readUTF8String();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -19,24 +19,17 @@ export class ActionBehavior extends Behavior {
|
|
|
19
19
|
|
|
20
20
|
tick(timeDelta) {
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
try {
|
|
23
|
+
this.__action.call(this.__context, timeDelta);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
this.__action.call(this.__context, timeDelta);
|
|
25
|
+
return BehaviorStatus.Succeeded;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
} catch (e) {
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
console.warn(e);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.setStatus(BehaviorStatus.Failed);
|
|
34
|
-
|
|
35
|
-
}
|
|
31
|
+
return BehaviorStatus.Failed;
|
|
36
32
|
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return this.__status;
|
|
41
34
|
}
|
|
42
35
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Behavior } from "../Behavior.js";
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
|
-
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
4
3
|
|
|
5
4
|
export class FailingBehavior extends Behavior {
|
|
6
5
|
constructor(delayTicks = 0) {
|
|
@@ -9,9 +8,8 @@ export class FailingBehavior extends Behavior {
|
|
|
9
8
|
this.delayTicks = delayTicks;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
tick() {
|
|
11
|
+
tick(td) {
|
|
13
12
|
if (this.delayTicks === 0) {
|
|
14
|
-
this.__status = BehaviorStatus.Failed;
|
|
15
13
|
|
|
16
14
|
return BehaviorStatus.Failed;
|
|
17
15
|
} else {
|
|
@@ -24,29 +22,3 @@ export class FailingBehavior extends Behavior {
|
|
|
24
22
|
|
|
25
23
|
FailingBehavior.typeName = "FailingBehavior";
|
|
26
24
|
|
|
27
|
-
export class FailingBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
28
|
-
constructor() {
|
|
29
|
-
super();
|
|
30
|
-
|
|
31
|
-
this.klass = FailingBehavior;
|
|
32
|
-
this.version = 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {BinaryBuffer} buffer
|
|
38
|
-
* @param {FailingBehavior} value
|
|
39
|
-
*/
|
|
40
|
-
serialize(buffer, value) {
|
|
41
|
-
buffer.writeUintVar(value.delayTicks);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {BinaryBuffer} buffer
|
|
47
|
-
* @param {FailingBehavior} value
|
|
48
|
-
*/
|
|
49
|
-
deserialize(buffer, value) {
|
|
50
|
-
value.delayTicks = buffer.readUintVar();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { FailingBehavior } from "./FailingBehavior.js";
|
|
3
|
+
|
|
4
|
+
export class FailingBehaviorSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = FailingBehavior;
|
|
9
|
+
this.version = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {BinaryBuffer} buffer
|
|
15
|
+
* @param {FailingBehavior} value
|
|
16
|
+
*/
|
|
17
|
+
serialize(buffer, value) {
|
|
18
|
+
buffer.writeUintVar(value.delayTicks);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {BinaryBuffer} buffer
|
|
24
|
+
* @param {FailingBehavior} value
|
|
25
|
+
*/
|
|
26
|
+
deserialize(buffer, value) {
|
|
27
|
+
value.delayTicks = buffer.readUintVar();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -2,30 +2,42 @@ import { Behavior } from "../Behavior.js";
|
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
3
|
|
|
4
4
|
export class PromiseBehavior extends Behavior {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {()=>Promise} factory
|
|
8
|
+
*/
|
|
5
9
|
constructor(factory) {
|
|
6
10
|
super();
|
|
7
11
|
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @type {function(): Promise}
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
8
17
|
this.__factory = factory;
|
|
9
18
|
|
|
10
19
|
this.__promise = null;
|
|
20
|
+
|
|
21
|
+
this.__promise_state = BehaviorStatus.Running;
|
|
11
22
|
}
|
|
12
23
|
|
|
13
24
|
initialize(context) {
|
|
14
25
|
super.initialize(context);
|
|
15
26
|
|
|
16
27
|
this.__promise = this.__factory();
|
|
28
|
+
this.__promise_state = BehaviorStatus.Running;
|
|
17
29
|
|
|
18
30
|
this.__promise.then(
|
|
19
31
|
() => {
|
|
20
|
-
this.
|
|
32
|
+
this.__promise_state = BehaviorStatus.Succeeded;
|
|
21
33
|
},
|
|
22
34
|
() => {
|
|
23
|
-
this.
|
|
35
|
+
this.__promise_state = BehaviorStatus.Failed;
|
|
24
36
|
}
|
|
25
37
|
);
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
tick(timeDelta) {
|
|
29
|
-
return this.
|
|
41
|
+
return this.__promise_state;
|
|
30
42
|
}
|
|
31
43
|
}
|
|
@@ -5,8 +5,6 @@ test('initialize', () => {
|
|
|
5
5
|
const b = new ConditionBehavior(() => true);
|
|
6
6
|
|
|
7
7
|
b.initialize();
|
|
8
|
-
|
|
9
|
-
expect(b.getStatus()).toBe(BehaviorStatus.Running);
|
|
10
8
|
});
|
|
11
9
|
|
|
12
10
|
test('positive', () => {
|
|
@@ -15,8 +13,6 @@ test('positive', () => {
|
|
|
15
13
|
b.initialize();
|
|
16
14
|
|
|
17
15
|
expect(b.tick(0)).toBe(BehaviorStatus.Succeeded);
|
|
18
|
-
|
|
19
|
-
expect(b.getStatus()).toBe(BehaviorStatus.Succeeded);
|
|
20
16
|
});
|
|
21
17
|
|
|
22
18
|
test('negative', () => {
|
|
@@ -25,6 +21,4 @@ test('negative', () => {
|
|
|
25
21
|
b.initialize();
|
|
26
22
|
|
|
27
23
|
expect(b.tick(0)).toBe(BehaviorStatus.Failed);
|
|
28
|
-
|
|
29
|
-
expect(b.getStatus()).toBe(BehaviorStatus.Failed);
|
|
30
|
-
});
|
|
24
|
+
});
|
|
@@ -33,19 +33,18 @@ export class ConditionalBehavior extends AbstractDecoratorBehavior {
|
|
|
33
33
|
|
|
34
34
|
const s1 = this.__source.tick(timeDelta);
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
return s1;
|
|
37
37
|
|
|
38
38
|
} else if (s === BehaviorStatus.Failed) {
|
|
39
39
|
condition.finalize();
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
return s;
|
|
42
42
|
|
|
43
43
|
} else {
|
|
44
44
|
//waiting?
|
|
45
|
-
|
|
45
|
+
return s;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return this.__status;
|
|
49
48
|
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -54,9 +53,7 @@ export class ConditionalBehavior extends AbstractDecoratorBehavior {
|
|
|
54
53
|
|
|
55
54
|
const condition = this.condition;
|
|
56
55
|
|
|
57
|
-
if (condition.getStatus() === BehaviorStatus.Running) {
|
|
58
56
|
condition.finalize();
|
|
59
|
-
}
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
/**
|
|
@@ -52,8 +52,6 @@ export class DelayBehavior extends Behavior {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
initialize() {
|
|
55
|
-
super.initialize();
|
|
56
|
-
|
|
57
55
|
this.elapsed = 0;
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -61,9 +59,9 @@ export class DelayBehavior extends Behavior {
|
|
|
61
59
|
this.elapsed += timeDelta;
|
|
62
60
|
|
|
63
61
|
if (this.elapsed >= this.value) {
|
|
64
|
-
|
|
62
|
+
return BehaviorStatus.Succeeded;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
return
|
|
65
|
+
return BehaviorStatus.Running;
|
|
68
66
|
}
|
|
69
67
|
}
|
|
@@ -22,15 +22,21 @@ export class SelectorBehavior extends CompositeBehavior {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
tick(timeDelta) {
|
|
25
|
+
const children = this.__children;
|
|
26
|
+
const child_count = children.length;
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
if (child_count === 0) {
|
|
29
|
+
// arbitrarily decide success
|
|
30
|
+
return BehaviorStatus.Succeeded;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (; ;) {
|
|
34
|
+
const child = children[this.__index];
|
|
28
35
|
|
|
29
36
|
const s = child.tick(timeDelta);
|
|
30
37
|
|
|
31
38
|
//if child succeeds or keeps running, do the same
|
|
32
39
|
if (s !== BehaviorStatus.Failed) {
|
|
33
|
-
this.__status = s;
|
|
34
40
|
return s;
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -38,21 +44,19 @@ export class SelectorBehavior extends CompositeBehavior {
|
|
|
38
44
|
//continue search for fallback behavior until the last child
|
|
39
45
|
this.__index++;
|
|
40
46
|
|
|
41
|
-
if (this.__index >=
|
|
42
|
-
|
|
43
|
-
return this.__status;
|
|
47
|
+
if (this.__index >= child_count) {
|
|
48
|
+
return BehaviorStatus.Failed;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
//initialize new child
|
|
47
|
-
const next =
|
|
52
|
+
const next = children[this.__index];
|
|
48
53
|
|
|
49
54
|
child.finalize();
|
|
50
55
|
next.initialize(this.context);
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
//we should never reach this point
|
|
54
|
-
|
|
55
|
-
return this.__status;
|
|
59
|
+
return BehaviorStatus.Invalid;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
finalize() {
|
|
@@ -73,9 +77,6 @@ export class SelectorBehavior extends CompositeBehavior {
|
|
|
73
77
|
|
|
74
78
|
if (this.__children.length > 0) {
|
|
75
79
|
this.__children[0].initialize(context);
|
|
76
|
-
} else {
|
|
77
|
-
//empty, resolve as succeeded straight away
|
|
78
|
-
this.__status = BehaviorStatus.Succeeded;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -24,6 +24,15 @@ export class AbstractBlackboard {
|
|
|
24
24
|
throw new Error('Not implemented');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Release reference to a value
|
|
29
|
+
* @param {string} name
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*/
|
|
32
|
+
release(name) {
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
/**
|
|
28
37
|
*
|
|
29
38
|
* @param {string} name
|
|
@@ -51,10 +60,15 @@ export class AbstractBlackboard {
|
|
|
51
60
|
/**
|
|
52
61
|
*
|
|
53
62
|
* @param {string} name
|
|
63
|
+
* @param {number} [value=1]
|
|
54
64
|
* @returns {void}
|
|
55
65
|
*/
|
|
56
|
-
incrementNumber(name) {
|
|
57
|
-
this.acquireNumber(name)
|
|
66
|
+
incrementNumber(name, value = 1) {
|
|
67
|
+
const vector1 = this.acquireNumber(name);
|
|
68
|
+
|
|
69
|
+
vector1._add(value);
|
|
70
|
+
|
|
71
|
+
this.release(name);
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
/**
|
|
@@ -259,17 +259,7 @@ export class EnginePluginManager extends BaseProcess {
|
|
|
259
259
|
|
|
260
260
|
const engine = this.engine;
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
await instance.initialize(engine);
|
|
265
|
-
|
|
266
|
-
} else if (manager_state_value === ProcessState.Running) {
|
|
267
|
-
|
|
268
|
-
await instance.initialize(engine);
|
|
269
|
-
|
|
270
|
-
await instance.startup();
|
|
271
|
-
}
|
|
272
|
-
|
|
262
|
+
await ctx.transition(manager_state_value,engine);
|
|
273
263
|
|
|
274
264
|
return reference;
|
|
275
265
|
|
|
@@ -289,9 +279,9 @@ export class EnginePluginManager extends BaseProcess {
|
|
|
289
279
|
}
|
|
290
280
|
|
|
291
281
|
/**
|
|
292
|
-
*
|
|
293
|
-
* @param {Class<
|
|
294
|
-
* @returns {
|
|
282
|
+
* @template T
|
|
283
|
+
* @param {Class<T>} PluginClass
|
|
284
|
+
* @returns {T|undefined}
|
|
295
285
|
*/
|
|
296
286
|
getPlugin(PluginClass) {
|
|
297
287
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellFilterUnaryOperation } from "../../core/CellFilterUnaryOperation.js";
|
|
2
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
3
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
4
4
|
|
|
5
5
|
export class CellFilterSaturate extends CellFilterUnaryOperation {
|
|
6
6
|
operation(v) {
|
|
7
|
-
return
|
|
7
|
+
return clamp01(v);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -11,6 +11,7 @@ import { computeStatisticalMean } from "../../../core/math/statistics/computeSta
|
|
|
11
11
|
import TaskGroup from "../../../core/process/task/TaskGroup.js";
|
|
12
12
|
import { actionTask } from "../../../core/process/task/TaskUtils.js";
|
|
13
13
|
import { ArrayIteratorRandom } from "../../../core/collection/array/ArrayIteratorRandom.js";
|
|
14
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -123,7 +124,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
123
124
|
|
|
124
125
|
const densityValue = this.density.execute(grid, x, y, 0);
|
|
125
126
|
|
|
126
|
-
const density =
|
|
127
|
+
const density = clamp01(densityValue);
|
|
127
128
|
|
|
128
129
|
samplesDensity.push(density);
|
|
129
130
|
|
|
@@ -305,7 +306,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
305
306
|
return 0;
|
|
306
307
|
}
|
|
307
308
|
|
|
308
|
-
return
|
|
309
|
+
return clamp01(iteration / iterationLimit);
|
|
309
310
|
}
|
|
310
311
|
});
|
|
311
312
|
}
|
|
@@ -4,8 +4,8 @@ import { GridDataLayer } from "../../grid/layers/GridDataLayer.js";
|
|
|
4
4
|
import { CellFilterReadGridLayer } from "../../filtering/numeric/CellFilterReadGridLayer.js";
|
|
5
5
|
import { MarkerNode } from "../MarkerNode.js";
|
|
6
6
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
7
|
+
import { RAD_TO_DEG } from "../../../core/math/RAD_TO_DEG.js";
|
|
7
8
|
|
|
8
|
-
const RAD_TO_DEG = 180 / Math.PI;
|
|
9
9
|
|
|
10
10
|
test('constructor does not throw', () => {
|
|
11
11
|
const t = new MarkerNodeTransformerYRotateByFilterGradient();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../core/assert.js";
|
|
2
|
-
import { clamp } from "../../core/math/clamp.js";
|
|
3
2
|
import { GridLayerCellMatcher } from "./GridLayerCellMatcher.js";
|
|
3
|
+
import { clamp01 } from "../../core/math/clamp01.js";
|
|
4
4
|
|
|
5
5
|
export class CellMatcherLayerBitMaskTest extends GridLayerCellMatcher {
|
|
6
6
|
constructor() {
|
|
@@ -30,13 +30,13 @@ export class CellMatcherLayerBitMaskTest extends GridLayerCellMatcher {
|
|
|
30
30
|
if (x_max === 0) {
|
|
31
31
|
u = 0;
|
|
32
32
|
} else {
|
|
33
|
-
u =
|
|
33
|
+
u = clamp01(x / x_max);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (y_max === 0) {
|
|
37
37
|
v = 0;
|
|
38
38
|
} else {
|
|
39
|
-
v =
|
|
39
|
+
v = clamp01(y / y_max);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const _x = Math.round(u * (sampler.width - 1));
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.37.0",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { clamp } from "../../../core/math/clamp.js";
|
|
2
1
|
import View from "../../View.js";
|
|
3
2
|
import dom from "../../DOM.js";
|
|
4
3
|
|
|
5
4
|
import BoundedValue from "../../../core/model/BoundedValue.js";
|
|
6
5
|
import { frameThrottle } from "../../../engine/graphics/FrameThrottle.js";
|
|
7
6
|
import { passThrough } from "../../../core/function/Functions.js";
|
|
7
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
8
8
|
|
|
9
9
|
function makeTextPercentage(value, max, process) {
|
|
10
10
|
const r = (value / max) * 100;
|
|
@@ -147,7 +147,7 @@ class ProgressBarView extends View {
|
|
|
147
147
|
const style = this.__el_fill.style;
|
|
148
148
|
//sanitize input to be in range 0 to 1
|
|
149
149
|
|
|
150
|
-
const fill =
|
|
150
|
+
const fill = clamp01(value / max);
|
|
151
151
|
|
|
152
152
|
const fill_percent_string = (fill * 100) + "%";
|
|
153
153
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { clamp } from "../../../../core/math/clamp.js";
|
|
2
1
|
import View from "../../../View.js";
|
|
3
2
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
4
3
|
import { CanvasView } from "../../CanvasView.js";
|
|
@@ -7,6 +6,7 @@ import { DomSizeObserver } from "../../../util/DomSizeObserver.js";
|
|
|
7
6
|
import { RESOURCE_BAR_SEGMENTS } from "./RESOURCE_BAR_SEGMENTS.js";
|
|
8
7
|
import List from "../../../../core/collection/list/List.js";
|
|
9
8
|
import ListView from "../../../common/ListView.js";
|
|
9
|
+
import { clamp01 } from "../../../../core/math/clamp01.js";
|
|
10
10
|
|
|
11
11
|
export class SegmentedResourceBarView extends View {
|
|
12
12
|
/**
|
|
@@ -283,7 +283,7 @@ export class SegmentedResourceBarView extends View {
|
|
|
283
283
|
|
|
284
284
|
total_current += value;
|
|
285
285
|
|
|
286
|
-
const v_fraction =
|
|
286
|
+
const v_fraction = clamp01(v / m);
|
|
287
287
|
|
|
288
288
|
const fill_view = this.__value_fills[i];
|
|
289
289
|
|
|
@@ -291,7 +291,7 @@ export class SegmentedResourceBarView extends View {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
|
|
294
|
-
const f =
|
|
294
|
+
const f = clamp01(total_current / m);
|
|
295
295
|
|
|
296
296
|
const width = `${f * 100}%`;
|
|
297
297
|
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import { clamp } from "../../../core/math/clamp.js";
|
|
7
6
|
import View from "../../View.js";
|
|
8
7
|
import SVG from '../../SVG.js';
|
|
9
8
|
|
|
10
9
|
import ObservedValue from "../../../core/model/ObservedValue.js";
|
|
11
10
|
import BoundedValue from "../../../core/model/BoundedValue.js";
|
|
11
|
+
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
12
12
|
|
|
13
13
|
class RadialProgressView extends View {
|
|
14
14
|
constructor(model, options) {
|
|
@@ -46,7 +46,7 @@ class RadialProgressView extends View {
|
|
|
46
46
|
limit = value;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const n0 =
|
|
49
|
+
const n0 = clamp01(value / limit);
|
|
50
50
|
|
|
51
51
|
const a0 = 0;
|
|
52
52
|
const a1 = n0 * Math.PI * 2;
|