@woosh/meep-engine 2.36.27 → 2.36.30
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/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 +14 -24
- package/engine/graphics/ecs/light/LightSystem.js +2 -3
- 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
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { System } from "../../../ecs/System.js";
|
|
2
|
-
import { BehaviorComponent } from "./BehaviorComponent.js";
|
|
2
|
+
import { BehaviorComponent, BehaviorComponentFlag } from "./BehaviorComponent.js";
|
|
3
3
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
4
4
|
import Clock from "../../../Clock.js";
|
|
5
5
|
import { ClockChannelType } from "./ClockChannelType.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {Behavior} behavior
|
|
10
10
|
* @param {number} timeDelta
|
|
11
|
+
* @returns {BehaviorStatus}
|
|
11
12
|
*/
|
|
12
13
|
function updateBehavior(behavior, timeDelta) {
|
|
13
14
|
|
|
14
15
|
try {
|
|
15
|
-
behavior.tick(timeDelta);
|
|
16
|
+
return behavior.tick(timeDelta);
|
|
16
17
|
} catch (e) {
|
|
17
18
|
console.error('Behavior threw an exception', e);
|
|
18
19
|
|
|
19
20
|
// Transition behavior into failed state
|
|
20
|
-
|
|
21
|
+
return BehaviorStatus.Failed;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class BehaviorSystem extends System {
|
|
@@ -60,24 +60,18 @@ export class BehaviorSystem extends System {
|
|
|
60
60
|
* @param {number} entity
|
|
61
61
|
*/
|
|
62
62
|
link(component, entity) {
|
|
63
|
+
const behavior = component.behavior;
|
|
64
|
+
component.clearFlag(BehaviorComponentFlag.Resolved);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
const l = list.length;
|
|
66
|
-
|
|
67
|
-
for (let i = 0; i < l; i++) {
|
|
68
|
-
const behavior = list[i];
|
|
69
|
-
|
|
70
|
-
if (behavior.getStatus() === BehaviorStatus.Initial) {
|
|
71
|
-
// initialize behavior
|
|
72
|
-
const dataset = this.entityManager.dataset;
|
|
66
|
+
if (behavior !== null) {
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} catch (e) {
|
|
77
|
-
console.warn('Behavior initialization failed:', e);
|
|
68
|
+
// initialize behavior
|
|
69
|
+
const dataset = this.entityManager.dataset;
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
}
|
|
71
|
+
try {
|
|
72
|
+
behavior.initialize({ entity, ecd: dataset, engine: this.engine });
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.warn('Behavior initialization failed:', e);
|
|
81
75
|
}
|
|
82
76
|
}
|
|
83
77
|
}
|
|
@@ -88,17 +82,12 @@ export class BehaviorSystem extends System {
|
|
|
88
82
|
* @param {number} entity
|
|
89
83
|
*/
|
|
90
84
|
unlink(component, entity) {
|
|
85
|
+
const behavior = component.behavior;
|
|
91
86
|
|
|
92
|
-
|
|
93
|
-
const l = list.length;
|
|
94
|
-
|
|
95
|
-
for (let i = 0; i < l; i++) {
|
|
96
|
-
const behavior = list[i];
|
|
87
|
+
if (behavior !== null) {
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
behavior.finalize();
|
|
101
|
-
}
|
|
89
|
+
// finalize behavior
|
|
90
|
+
behavior.finalize();
|
|
102
91
|
}
|
|
103
92
|
}
|
|
104
93
|
|
|
@@ -118,8 +107,9 @@ export class BehaviorSystem extends System {
|
|
|
118
107
|
* @param {number} entity
|
|
119
108
|
*/
|
|
120
109
|
function visitBehavior(b, entity) {
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
if (b.getFlag(BehaviorComponentFlag.Resolved)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
123
113
|
|
|
124
114
|
let td;
|
|
125
115
|
|
|
@@ -131,15 +121,16 @@ export class BehaviorSystem extends System {
|
|
|
131
121
|
td = systemDelta;
|
|
132
122
|
}
|
|
133
123
|
|
|
134
|
-
|
|
135
|
-
const behavior = list[i];
|
|
124
|
+
const behavior = b.behavior;
|
|
136
125
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
126
|
+
if (behavior !== null) {
|
|
127
|
+
const state = updateBehavior(behavior, td);
|
|
140
128
|
|
|
141
|
-
|
|
129
|
+
if (state === BehaviorStatus.Failed || state === BehaviorStatus.Succeeded) {
|
|
130
|
+
b.setFlag(BehaviorComponentFlag.Resolved);
|
|
131
|
+
}
|
|
142
132
|
}
|
|
133
|
+
|
|
143
134
|
}
|
|
144
135
|
|
|
145
136
|
dataset.traverseComponents(BehaviorComponent, visitBehavior);
|
|
@@ -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();
|