@woosh/meep-engine 2.69.0 → 2.71.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.
Files changed (50) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/build/meep.cjs +498 -429
  4. package/build/meep.min.js +1 -1
  5. package/build/meep.module.js +498 -429
  6. package/package.json +1 -1
  7. package/src/core/__module.js +1 -0
  8. package/src/core/binary/BinaryBuffer.js +37 -31
  9. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +21 -24
  10. package/src/core/bvh2/binary/2/BinaryUint32BVH.spec.js +2 -4
  11. package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +3 -2
  12. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +34 -0
  13. package/src/core/geom/3d/morton/v3_morton_encode_transformed.js +2 -1
  14. package/src/core/geom/3d/quaternion/quat3_createFromAxisAngle.js +11 -0
  15. package/src/core/geom/3d/quaternion/quat_decode_from_uint32.js +53 -0
  16. package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +105 -0
  17. package/src/core/geom/Quaternion.js +8 -142
  18. package/src/core/geom/Vector2.js +6 -7
  19. package/src/core/geom/Vector3.js +15 -82
  20. package/src/core/geom/vec3/v3_binary_equality_decode.js +44 -0
  21. package/src/core/geom/vec3/v3_binary_equality_encode.js +47 -0
  22. package/src/core/math/remap.js +5 -1
  23. package/src/core/math/statistics/computeStatisticalPartialMedian.js +1 -1
  24. package/src/core/primitives/numbers/computeHashFloat.js +2 -2
  25. package/src/core/process/task/Task.js +53 -34
  26. package/src/engine/achievements/AchievementManager.js +19 -19
  27. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +6 -6
  28. package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +11 -6
  29. package/src/engine/ecs/dynamic_actions/DynamicActor.js +5 -10
  30. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +82 -89
  31. package/src/engine/ecs/dynamic_actions/RuleExecution.js +10 -12
  32. package/src/engine/ecs/gui/GUIElement.js +44 -61
  33. package/src/engine/ecs/gui/GUIElementSystem.js +26 -24
  34. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +12 -15
  35. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +15 -15
  36. package/src/engine/ecs/gui/parallax/GuiElementParallax.js +3 -3
  37. package/src/engine/ecs/gui/parallax/GuiElementParallaxSystem.js +2 -2
  38. package/src/engine/ecs/gui/position/ViewportPosition.js +5 -50
  39. package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.js +42 -0
  40. package/src/engine/ecs/transform/Transform.js +8 -9
  41. package/src/engine/ecs/transform/TransformSerializationAdapter.js +20 -14
  42. package/src/engine/graphics/ecs/mesh/Mesh.js +11 -11
  43. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +20 -20
  44. package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +12 -12
  45. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +1 -4
  46. package/src/core/binary/ValidatingBitSetWrapper.js +0 -81
  47. package/src/core/binary/jsonToStringToByteArray.js +0 -27
  48. package/src/engine/ecs/components/AreaOfEffect.js +0 -12
  49. package/src/engine/ecs/components/Mortality.js +0 -27
  50. package/src/engine/ecs/systems/AreaOfEffectSystem.js +0 -48
@@ -546,11 +546,7 @@ class Vector2 {
546
546
  const x = computeHashFloat(this.x);
547
547
  const y = computeHashFloat(this.y);
548
548
 
549
- let hash = ((x << 5) - x) + y;
550
-
551
- hash |= 0; //convert to 32bit int
552
-
553
- return hash;
549
+ return ((x << 5) - x) + y;
554
550
  }
555
551
 
556
552
  /**
@@ -561,8 +557,11 @@ class Vector2 {
561
557
  const sin = Math.sin(angle);
562
558
  const cos = Math.cos(angle);
563
559
 
564
- const x = this.x * cos - this.y * sin
565
- const y = this.x * sin + this.y * cos;
560
+ const _x = this.x;
561
+ const _y = this.y;
562
+
563
+ const x = _x * cos - _y * sin
564
+ const y = _x * sin + _y * cos;
566
565
 
567
566
  this.set(x, y);
568
567
  }
@@ -5,17 +5,19 @@
5
5
 
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
+ import { EPSILON } from "../math/EPSILON.js";
9
+ import { epsilonEquals } from "../math/epsilonEquals.js";
8
10
  import { lerp } from "../math/lerp.js";
9
11
  import { sign } from "../math/sign.js";
12
+ import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
13
+ import { v3_angle_between } from "./vec3/v3_angle_between.js";
14
+ import { v3_binary_equality_decode } from "./vec3/v3_binary_equality_decode.js";
15
+ import { v3_binary_equality_encode } from "./vec3/v3_binary_equality_encode.js";
10
16
  import { v3_dot } from "./vec3/v3_dot.js";
11
- import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
12
17
  import { v3_length } from "./vec3/v3_length.js";
13
- import { v3_angle_between } from "./vec3/v3_angle_between.js";
18
+ import { v3_length_sqr } from "./vec3/v3_length_sqr.js";
14
19
  import { v3_lerp } from "./vec3/v3_lerp.js";
15
20
  import { v3_slerp } from "./vec3/v3_slerp.js";
16
- import { computeHashFloat } from "../primitives/numbers/computeHashFloat.js";
17
- import { epsilonEquals } from "../math/epsilonEquals.js";
18
- import { EPSILON } from "../math/EPSILON.js";
19
21
 
20
22
  class Vector3 {
21
23
  /**
@@ -856,100 +858,31 @@ class Vector3 {
856
858
  /**
857
859
  *
858
860
  * @param {BinaryBuffer} buffer
861
+ * @deprecated use dedicated method directly instead
859
862
  */
860
863
  toBinaryBufferFloat32_EqualityEncoded(buffer) {
861
864
  const x = this.x;
862
865
  const y = this.y;
863
866
  const z = this.z;
864
867
 
865
- let header = 0;
866
-
867
- if (x === y) {
868
- header |= 1;
869
- }
870
-
871
- if (y === z) {
872
- header |= 2;
873
- }
874
-
875
- if (x === z) {
876
- header |= 4;
877
- }
878
-
879
- buffer.writeUint8(header);
880
-
881
- if ((header & 7) === 7) {
882
- //all components are the same
883
- buffer.writeFloat32(x);
884
- } else if (header === 1) {
885
- //X and Y are the same, Z is different
886
- buffer.writeFloat32(x);
887
- buffer.writeFloat32(z);
888
- } else if (header === 2) {
889
- //Y and Z are the same, X is different
890
- buffer.writeFloat32(x);
891
- buffer.writeFloat32(y);
892
- } else if (header === 4) {
893
- //X and Z are the same, Y is different
894
- buffer.writeFloat32(x);
895
- buffer.writeFloat32(y);
896
- } else {
897
- //scale components are different
898
- buffer.writeFloat32(x);
899
- buffer.writeFloat32(y);
900
- buffer.writeFloat32(z);
901
- }
868
+ v3_binary_equality_encode(buffer, x, y, z);
902
869
  }
903
870
 
904
871
  /**
905
872
  * Uses an extra byte for a header. Only writes unique components. Useful for things like scale where all components usually have the same value
906
873
  * @param {BinaryBuffer} buffer
874
+ * @deprecated use dedicated method directly instead
907
875
  */
908
876
  fromBinaryBufferFloat32_EqualityEncoded(buffer) {
909
- const header = buffer.readUint8();
910
-
911
- let x = 0;
912
- let y = 0;
913
- let z = 0;
914
-
915
- if ((header & 7) === 7) {
916
- //all scale components are the same
917
- x = buffer.readFloat32();
918
- y = x;
919
- z = x;
920
- } else if ((header & 1) === 1) {
921
- //X and Y are the same, Z is different
922
- x = buffer.readFloat32();
923
- y = x;
924
- z = buffer.readFloat32();
925
- } else if ((header & 2) === 2) {
926
- //Y and Z are the same, X is different
927
- x = buffer.readFloat32();
928
- y = buffer.readFloat32();
929
- z = y;
930
- } else if ((header & 4) === 4) {
931
- //X and Z are the same, Y is different
932
- x = buffer.readFloat32();
933
- y = buffer.readFloat32();
934
- z = x;
935
- } else {
936
- //scale components are different
937
- x = buffer.readFloat32();
938
- y = buffer.readFloat32();
939
- z = buffer.readFloat32();
940
- }
941
-
942
- this.set(x, y, z);
877
+ v3_binary_equality_decode(buffer, this, 0);
943
878
  }
944
879
 
945
880
  hash() {
946
- let hash = computeHashFloat(this.x);
947
-
948
- hash = ((hash << 5) - hash) + computeHashFloat(this.y);
949
-
950
- hash = ((hash << 5) - hash) + computeHashFloat(this.z);
881
+ const x = computeHashFloat(this.x);
882
+ const y = computeHashFloat(this.y);
883
+ const z = computeHashFloat(this.z);
951
884
 
952
- return hash;
885
+ return x ^ (y << 1) ^ (z << 2);
953
886
  }
954
887
 
955
888
 
@@ -0,0 +1,44 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {number[]} result
5
+ * @param {number} result_offset
6
+ */
7
+ export function v3_binary_equality_decode(buffer, result, result_offset) {
8
+ const header = buffer.readUint8();
9
+
10
+ let x = 0;
11
+ let y = 0;
12
+ let z = 0;
13
+
14
+ if ((header & 7) === 7) {
15
+ //all scale components are the same
16
+ x = buffer.readFloat32();
17
+ y = x;
18
+ z = x;
19
+ } else if ((header & 1) === 1) {
20
+ //X and Y are the same, Z is different
21
+ x = buffer.readFloat32();
22
+ y = x;
23
+ z = buffer.readFloat32();
24
+ } else if ((header & 2) === 2) {
25
+ //Y and Z are the same, X is different
26
+ x = buffer.readFloat32();
27
+ y = buffer.readFloat32();
28
+ z = y;
29
+ } else if ((header & 4) === 4) {
30
+ //X and Z are the same, Y is different
31
+ x = buffer.readFloat32();
32
+ y = buffer.readFloat32();
33
+ z = x;
34
+ } else {
35
+ //scale components are different
36
+ x = buffer.readFloat32();
37
+ y = buffer.readFloat32();
38
+ z = buffer.readFloat32();
39
+ }
40
+
41
+ result[result_offset] = x;
42
+ result[result_offset + 1] = y;
43
+ result[result_offset + 2] = z;
44
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ *
3
+ * @param {BinaryBuffer} buffer
4
+ * @param {number} x
5
+ * @param {number} y
6
+ * @param {number} z
7
+ */
8
+ export function v3_binary_equality_encode(buffer, x, y, z){
9
+
10
+ let header = 0;
11
+
12
+ if (x === y) {
13
+ header |= 1;
14
+ }
15
+
16
+ if (y === z) {
17
+ header |= 2;
18
+ }
19
+
20
+ if (x === z) {
21
+ header |= 4;
22
+ }
23
+
24
+ buffer.writeUint8(header);
25
+
26
+ if ((header & 7) === 7) {
27
+ //all components are the same
28
+ buffer.writeFloat32(x);
29
+ } else if (header === 1) {
30
+ //X and Y are the same, Z is different
31
+ buffer.writeFloat32(x);
32
+ buffer.writeFloat32(z);
33
+ } else if (header === 2) {
34
+ //Y and Z are the same, X is different
35
+ buffer.writeFloat32(x);
36
+ buffer.writeFloat32(y);
37
+ } else if (header === 4) {
38
+ //X and Z are the same, Y is different
39
+ buffer.writeFloat32(x);
40
+ buffer.writeFloat32(y);
41
+ } else {
42
+ //scale components are different
43
+ buffer.writeFloat32(x);
44
+ buffer.writeFloat32(y);
45
+ buffer.writeFloat32(z);
46
+ }
47
+ }
@@ -11,7 +11,11 @@ import { lerp } from "./lerp.js";
11
11
  * @param {number} value
12
12
  * @return {number}
13
13
  */
14
- export function remap(source_first, source_second, target_first, target_second, value) {
14
+ export function remap(
15
+ source_first, source_second,
16
+ target_first, target_second,
17
+ value
18
+ ) {
15
19
 
16
20
  const relative = inverseLerp(source_first, source_second, value);
17
21
 
@@ -18,7 +18,7 @@ export function computeStatisticalPartialMedian(values, start, end) {
18
18
 
19
19
  const range = end - start;
20
20
 
21
- const position = (start + range / 2) | 0;
21
+ const position = (start + range) >> 1;
22
22
 
23
23
  return copy[position];
24
24
  }
@@ -5,10 +5,10 @@
5
5
  */
6
6
  export function computeHashFloat(v) {
7
7
  //we break the number up into fractional and whole parts
8
- const fraction = v % 1;
9
-
10
8
  const whole = v | 0;
11
9
 
10
+ const fraction = v - whole;
11
+
12
12
  //fractional part is scaled up into int32 range, this inexact method, as it will produce 0 hash for values below a certain threshold
13
13
  const fractionHash = fraction * 1367130550;
14
14
 
@@ -4,14 +4,51 @@
4
4
 
5
5
 
6
6
  import { assert } from "../../assert.js";
7
+ import { array_push_if_unique } from "../../collection/array/array_push_if_unique.js";
7
8
  import Signal from "../../events/signal/Signal.js";
8
9
  import { noop } from "../../function/Functions.js";
9
10
  import ObservedInteger from "../../model/ObservedInteger.js";
10
11
  import { TaskSignal } from "./TaskSignal.js";
11
12
  import TaskState from "./TaskState.js";
12
13
 
14
+ /**
15
+ *
16
+ * @type {number}
17
+ */
18
+ let id_counter = 0;
13
19
 
14
20
  class Task {
21
+ /**
22
+ * @readonly
23
+ * @type {number}
24
+ */
25
+ id = id_counter++;
26
+
27
+ on = {
28
+ started: new Signal(),
29
+ completed: new Signal(),
30
+ failed: new Signal()
31
+ };
32
+
33
+ /**
34
+ *
35
+ * @type {ObservedInteger}
36
+ */
37
+ state = new ObservedInteger(TaskState.INITIAL);
38
+
39
+ /**
40
+ * amount of time spent running this task in milliseconds
41
+ * @type {number}
42
+ * @public
43
+ */
44
+ __executedCpuTime = 0;
45
+ /**
46
+ * number of time task's cycle function was executed
47
+ * @type {number}
48
+ * @public
49
+ */
50
+ __executedCycleCount = 0;
51
+
15
52
  /**
16
53
  *
17
54
  * @param {string} [name] useful for identifying the task later on, for various UI and debug purposes
@@ -36,9 +73,16 @@ class Task {
36
73
  assert.isFunction(cycleFunction, 'cycleFunction');
37
74
  assert.isNumber(estimatedDuration, 'estimatedDuration');
38
75
 
39
-
76
+ /**
77
+ *
78
+ * @type {Task[]}
79
+ */
40
80
  this.dependencies = dependencies;
41
81
 
82
+ /**
83
+ *
84
+ * @type {number}
85
+ */
42
86
  this.estimatedDuration = estimatedDuration;
43
87
 
44
88
  /**
@@ -66,30 +110,6 @@ class Task {
66
110
 
67
111
  }
68
112
 
69
- this.on = {
70
- started: new Signal(),
71
- completed: new Signal(),
72
- failed: new Signal()
73
- };
74
-
75
- /**
76
- *
77
- * @type {ObservedInteger}
78
- */
79
- this.state = new ObservedInteger(TaskState.INITIAL);
80
-
81
- /**
82
- * amount of time spent running this task in milliseconds
83
- * @type {number}
84
- * @public
85
- */
86
- this.__executedCpuTime = 0;
87
- /**
88
- * number of time task's cycle function was executed
89
- * @type {number}
90
- * @public
91
- */
92
- this.__executedCycleCount = 0;
93
113
  }
94
114
 
95
115
  computeProgress() {
@@ -134,11 +154,7 @@ class Task {
134
154
  } else if (task.isTask) {
135
155
 
136
156
  //check that the dependency is not registered yet
137
- if (this.dependencies.indexOf(task) === -1) {
138
-
139
- this.dependencies.push(task);
140
-
141
- }
157
+ array_push_if_unique(this.dependencies, task);
142
158
 
143
159
  } else {
144
160
  throw new Error('Expected a Task or a TaskGroup, got something else');
@@ -152,11 +168,14 @@ class Task {
152
168
  * @param {Array<(Task|TaskGroup)>} tasks
153
169
  */
154
170
  addDependencies(tasks) {
155
- if (!Array.isArray(tasks)) {
156
- throw new Error(`argument 'tasks' is not an Array`);
157
- }
171
+ assert.isArray(tasks, 'tasks');
158
172
 
159
- tasks.forEach(t => this.addDependency(t));
173
+ const task_count = tasks.length;
174
+
175
+ for (let i = 0; i < task_count; i++) {
176
+ const task = tasks[i];
177
+ this.addDependency(task);
178
+ }
160
179
  }
161
180
 
162
181
  toString() {
@@ -1,31 +1,31 @@
1
- import { GameAssetType } from "../asset/GameAssetType.js";
2
- import { Achievement } from "./Achievement.js";
1
+ import { assert } from "../../core/assert.js";
2
+ import Vector2 from "../../core/geom/Vector2.js";
3
+ import { makeCubicCurve } from "../../core/math/spline/makeCubicCurve.js";
4
+ import ObservedBoolean from "../../core/model/ObservedBoolean.js";
3
5
  import { ReactiveAnd } from "../../core/model/reactive/model/logic/ReactiveAnd.js";
4
6
  import { ReactiveReference } from "../../core/model/reactive/model/terminal/ReactiveReference.js";
5
- import ObservedBoolean from "../../core/model/ObservedBoolean.js";
6
7
  import { AchievementNotificationView } from "../../view/game/achievements/AchievementNotificationView.js";
7
- import ViewportPosition from "../ecs/gui/position/ViewportPosition.js";
8
- import Vector2 from "../../core/geom/Vector2.js";
9
- import Entity from "../ecs/Entity.js";
10
- import GUIElement from "../ecs/gui/GUIElement.js";
11
8
  import AnimationTrack from "../animation/keyed2/AnimationTrack.js";
9
+ import AnimationTrackPlayback from "../animation/keyed2/AnimationTrackPlayback.js";
10
+ import { AnimationBehavior } from "../animation/keyed2/behavior/AnimationBehavior.js";
12
11
  import TransitionFunctions from "../animation/TransitionFunctions.js";
12
+ import { GameAssetType } from "../asset/GameAssetType.js";
13
+ import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
14
+ import Entity from "../ecs/Entity.js";
15
+ import GUIElement from "../ecs/gui/GUIElement.js";
16
+ import ViewportPosition from "../ecs/gui/position/ViewportPosition.js";
17
+ import { Transform } from "../ecs/transform/Transform.js";
13
18
  import { SequenceBehavior } from "../intelligence/behavior/composite/SequenceBehavior.js";
14
- import { ActionBehavior } from "../intelligence/behavior/primitive/ActionBehavior.js";
15
- import { AnimationBehavior } from "../animation/keyed2/behavior/AnimationBehavior.js";
16
- import AnimationTrackPlayback from "../animation/keyed2/AnimationTrackPlayback.js";
17
19
  import { BehaviorComponent } from "../intelligence/behavior/ecs/BehaviorComponent.js";
18
- import { SoundEmitter } from "../sound/ecs/emitter/SoundEmitter.js";
19
- import { SoundEmitterChannels } from "../sound/ecs/emitter/SoundEmitterSystem.js";
20
- import { Transform } from "../ecs/transform/Transform.js";
21
- import { SerializationMetadata } from "../ecs/components/SerializationMetadata.js";
20
+ import { ClockChannelType } from "../intelligence/behavior/ecs/ClockChannelType.js";
21
+ import { ActionBehavior } from "../intelligence/behavior/primitive/ActionBehavior.js";
22
+ import { logger } from "../logging/GlobalLogger.js";
22
23
  import { globalMetrics } from "../metrics/GlobalMetrics.js";
23
24
  import { MetricsCategory } from "../metrics/MetricsCategory.js";
24
- import { ClockChannelType } from "../intelligence/behavior/ecs/ClockChannelType.js";
25
25
  import { EnginePlugin } from "../plugin/EnginePlugin.js";
26
- import { makeCubicCurve } from "../../core/math/spline/makeCubicCurve.js";
27
- import { logger } from "../logging/GlobalLogger.js";
28
- import { assert } from "../../core/assert.js";
26
+ import { SoundEmitter } from "../sound/ecs/emitter/SoundEmitter.js";
27
+ import { SoundEmitterChannels } from "../sound/ecs/emitter/SoundEmitterSystem.js";
28
+ import { Achievement } from "./Achievement.js";
29
29
 
30
30
 
31
31
  const SLOW_CUBIC = makeCubicCurve(0.04, 0.4, 0.9, 0.99);
@@ -291,7 +291,7 @@ export class AchievementManager extends EnginePlugin {
291
291
  achievementView.size.x = 460;
292
292
  achievementView.size.y = 58;
293
293
 
294
- const viewportPosition = new ViewportPosition({
294
+ const viewportPosition = ViewportPosition.fromJSON({
295
295
  position: new Vector2(0.5, 0)
296
296
  });
297
297
 
@@ -1,12 +1,12 @@
1
+ import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
2
+ import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
3
+ import { EngineConfiguration } from "../../../EngineConfiguration.js";
1
4
  import { EngineHarness } from "../../../EngineHarness.js";
2
5
  import { AnimationCurve } from "../AnimationCurve.js";
6
+ import { build_plot_entity_from_array } from "../draw/build_plot_entity_from_array.js";
3
7
  import { Keyframe } from "../Keyframe.js";
4
- import { EngineConfiguration } from "../../../EngineConfiguration.js";
5
- import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
6
- import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
7
- import { sample_animation_curve_to_float_array } from "./sample_animation_curve_to_float_array.js";
8
8
  import { downsample_float_array_curve_by_error } from "./downsample_float_array_curve_by_error.js";
9
- import { build_plot_entity_from_array } from "../draw/build_plot_entity_from_array.js";
9
+ import { sample_animation_curve_to_float_array } from "./sample_animation_curve_to_float_array.js";
10
10
 
11
11
  const eh = new EngineHarness();
12
12
 
@@ -134,7 +134,7 @@ async function main(engine) {
134
134
  return curve;
135
135
  }
136
136
 
137
- const curve = sample_curve_4();
137
+ const curve = sample_curve_0();
138
138
 
139
139
  curve.smoothAllTangents();
140
140
 
@@ -1,10 +1,10 @@
1
+ import Vector2 from "../../../../core/geom/Vector2.js";
1
2
  import { CanvasView } from "../../../../view/elements/CanvasView.js";
2
- import { plot_data } from "./plot_data.js";
3
- import { draw_label } from "./draw_label.js";
4
3
  import Entity from "../../../ecs/Entity.js";
5
- import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
6
4
  import GUIElement from "../../../ecs/gui/GUIElement.js";
7
- import Vector2 from "../../../../core/geom/Vector2.js";
5
+ import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
6
+ import { draw_label } from "./draw_label.js";
7
+ import { plot_data } from "./plot_data.js";
8
8
 
9
9
  /**
10
10
  *
@@ -22,12 +22,17 @@ export function build_plot_entity_from_array({
22
22
  x, y,
23
23
  width = 600,
24
24
  height = 200,
25
- margin = new Vector2(10,10),
25
+ margin = new Vector2(10, 10),
26
26
  label = ''
27
27
  }) {
28
28
 
29
29
  const canvasView = new CanvasView();
30
30
  canvasView.size.set(width, height);
31
+ canvasView.css({
32
+ position: "absolute",
33
+ left: "0",
34
+ top: "0"
35
+ });
31
36
  const ctx = canvasView.context2d;
32
37
 
33
38
  plot_data({ ctx, data, width, height, margin });
@@ -36,7 +41,7 @@ export function build_plot_entity_from_array({
36
41
  draw_label(ctx, text, margin.x, height - (20));
37
42
 
38
43
  if (typeof label === "string" && label.length > 0) {
39
- draw_label(ctx, label, 0, 0)
44
+ draw_label(ctx, label, width - margin.x - 50 , 20)
40
45
  }
41
46
 
42
47
  return new Entity()
@@ -1,15 +1,10 @@
1
1
  export class DynamicActor {
2
2
 
3
- constructor() {
4
-
5
-
6
- /**
7
- * Entities who's blackboards should be included into evaluation context
8
- * @type {number[]}
9
- */
10
- this.context = [];
11
-
12
- }
3
+ /**
4
+ * Entities whose blackboards should be included into evaluation context
5
+ * @type {number[]}
6
+ */
7
+ context = [];
13
8
  }
14
9
 
15
10
  /**