@woosh/meep-engine 2.36.26 → 2.36.29

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 (106) hide show
  1. package/core/bvh2/bvh3/{bvh_query_user_data_by_frustum.js → bvh_query_user_data_overlaps_frustum.js} +4 -5
  2. package/core/color/Color.js +54 -3
  3. package/core/color/hsv2rgb.js +3 -3
  4. package/core/color/kelvin_to_rgb.js +51 -0
  5. package/core/color/kelvin_to_rgb.spec.js +61 -0
  6. package/core/color/linear_to_sRGB.js +17 -0
  7. package/core/color/prototype_kelvin_to_rgb.js +44 -0
  8. package/core/color/rgb_to_kelvin.js +34 -0
  9. package/core/color/rgb_to_kelvin.spec.js +15 -0
  10. package/core/color/sRGB_to_linear.js +16 -0
  11. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +2 -2
  12. package/core/geom/LineSegment.js +2 -2
  13. package/core/geom/Vector3.js +14 -0
  14. package/core/math/DEG_TO_RAD.js +1 -0
  15. package/core/math/MathUtils.spec.js +0 -13
  16. package/core/math/RAD_TO_DEG.js +1 -0
  17. package/core/math/clamp01.js +15 -0
  18. package/core/math/fract.js +10 -0
  19. package/core/math/newton_solver_1d.js +21 -0
  20. package/core/math/smoothStep.js +3 -3
  21. package/core/math/solveQuadratic.js +32 -12
  22. package/core/math/solveQuadratic.spec.js +18 -0
  23. package/core/primitives/strings/StringUtils.js +10 -0
  24. package/core/process/task/TaskUtils.js +2 -2
  25. package/editor/view/ecs/components/color/GaugeView.js +2 -2
  26. package/editor/view/ecs/components/particles/ColorParameterLUTController.js +5 -4
  27. package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +5 -3
  28. package/engine/Clock.js +4 -0
  29. package/engine/UserController.js +2 -1
  30. package/engine/animation/behavior/animateProperty.js +6 -1
  31. package/engine/animation/keyed2/behavior/AnimationBehavior.js +0 -1
  32. package/engine/ecs/EntityBuilder.js +12 -1
  33. package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +2 -1
  34. package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +2 -1
  35. package/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +14 -11
  36. package/engine/ecs/systems/AimControllerSystem.js +3 -2
  37. package/engine/ecs/systems/RangedAttackSystem.js +3 -2
  38. package/engine/ecs/systems/SteeringSystem.js +3 -3
  39. package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
  40. package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +2 -2
  41. package/engine/graphics/GraphicsEngine.js +2 -1
  42. package/engine/graphics/camera/CameraShake.js +4 -4
  43. package/engine/graphics/ecs/animation/animator/graph/AnimationTransition.js +2 -2
  44. package/engine/graphics/ecs/camera/TiltCameraController.js +3 -2
  45. package/engine/graphics/ecs/compileAllMaterials.js +2 -2
  46. package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +14 -24
  47. package/engine/graphics/ecs/light/LightSystem.js +2 -3
  48. package/engine/graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js +2 -2
  49. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  50. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +19 -0
  51. package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +4 -2
  52. package/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +9 -0
  53. package/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.js +11 -0
  54. package/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +3 -0
  55. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +31 -0
  56. package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -2
  57. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +0 -82
  58. package/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +28 -3
  59. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +5 -3
  60. package/engine/graphics/render/gizmo/Gizmo.js +3 -0
  61. package/engine/graphics/render/gizmo/GizmoRenderingPlugin.js +5 -0
  62. package/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +91 -0
  63. package/engine/graphics/texture/sampler/Sampler2D.js +110 -18
  64. package/engine/graphics/three/OrbitControls.js +3 -2
  65. package/engine/graphics/trail/x/simulator/RibbonXFixedPhysicsSimulator.js +2 -2
  66. package/engine/graphics/util/makeMeshPreviewScene.js +11 -3
  67. package/engine/intelligence/behavior/Behavior.js +36 -17
  68. package/engine/intelligence/behavior/SelectorBehavior.js +6 -5
  69. package/engine/intelligence/behavior/composite/ParallelBehavior.js +0 -66
  70. package/engine/intelligence/behavior/composite/ParallelBehaviorSerializationAdapter.js +63 -0
  71. package/engine/intelligence/behavior/composite/SequenceBehavior.js +36 -11
  72. package/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +0 -2
  73. package/engine/intelligence/behavior/decorator/IgnoreFailureBehavior.js +2 -4
  74. package/engine/intelligence/behavior/decorator/InverterBehavior.js +3 -3
  75. package/engine/intelligence/behavior/decorator/RepeatBehavior.js +0 -35
  76. package/engine/intelligence/behavior/decorator/RepeatBehavior.spec.js +0 -10
  77. package/engine/intelligence/behavior/decorator/RepeatBehaviorSerializationAdapter.js +37 -0
  78. package/engine/intelligence/behavior/decorator/RepeatUntilFailureBehavior.js +0 -3
  79. package/engine/intelligence/behavior/decorator/RepeatUntilSuccessBehavior.js +5 -10
  80. package/engine/intelligence/behavior/ecs/BehaviorComponent.js +95 -7
  81. package/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +15 -8
  82. package/engine/intelligence/behavior/ecs/BehaviorSystem.js +28 -37
  83. package/engine/intelligence/behavior/ecs/DieBehavior.js +2 -7
  84. package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +2 -29
  85. package/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +29 -0
  86. package/engine/intelligence/behavior/primitive/ActionBehavior.js +6 -13
  87. package/engine/intelligence/behavior/primitive/FailingBehavior.js +1 -29
  88. package/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +29 -0
  89. package/engine/intelligence/behavior/primitive/PromiseBehavior.js +15 -3
  90. package/engine/intelligence/behavior/selector/WeightedRandomBehavior.js +1 -5
  91. package/engine/intelligence/behavior/util/ConditionBehavior.js +1 -3
  92. package/engine/intelligence/behavior/util/ConditionBehavior.spec.js +1 -7
  93. package/engine/intelligence/behavior/util/ConditionalBehavior.js +3 -6
  94. package/engine/intelligence/behavior/util/DelayBehavior.js +2 -4
  95. package/engine/intelligence/behavior/util/SelectorBehavior.js +13 -12
  96. package/engine/intelligence/blackboard/AbstractBlackboard.js +16 -2
  97. package/engine/plugin/EnginePluginManager.js +4 -14
  98. package/engine/sound/ecs/emitter/SoundEmitter.js +3 -0
  99. package/generation/filtering/numeric/math/CellFilterSaturate.js +2 -2
  100. package/generation/grid/generation/GridTaskDensityMarkerDistribution.js +3 -2
  101. package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +1 -1
  102. package/generation/rules/CellMatcherLayerBitMaskTest.js +3 -3
  103. package/package.json +1 -1
  104. package/view/elements/progress/SmoothProgressBar.js +2 -2
  105. package/view/elements/progress/segmented/SegmentedResourceBarView.js +3 -3
  106. package/view/elements/radial/RadialProgressView.js +2 -2
@@ -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
- for (;;) {
27
- const child = this.__children[this.__index];
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 >= this.__children.length) {
42
- this.__status = BehaviorStatus.Failed;
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 = this.__children[this.__index];
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
- this.__status = BehaviorStatus.Invalid;
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).increment();
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
- if (manager_state_value === ProcessState.Initialized) {
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<EnginePlugin>} PluginClass
294
- * @returns {EnginePlugin|undefined}
282
+ * @template T
283
+ * @param {Class<T>} PluginClass
284
+ * @returns {T|undefined}
295
285
  */
296
286
  getPlugin(PluginClass) {
297
287
 
@@ -37,6 +37,9 @@ function volume2dB(volume) {
37
37
  return 20 * Math.log10(volume);
38
38
  }
39
39
 
40
+ /**
41
+ * @class
42
+ */
40
43
  export class SoundEmitter {
41
44
  /**
42
45
  *
@@ -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 clamp(v, 0, 1);
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 = clamp(densityValue, 0, 1);
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 clamp(iteration / iterationLimit, 0, 1);
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 = clamp(x / x_max, 0, 1);
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 = clamp(y / y_max, 0, 1);
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.36.26",
8
+ "version": "2.36.29",
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 = clamp(value / max, 0, 1);
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 = clamp(v / m, 0, 1);
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 = clamp(total_current / m, 0, 1);
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 = clamp(value / limit, 0, 1);
49
+ const n0 = clamp01(value / limit);
50
50
 
51
51
  const a0 = 0;
52
52
  const a1 = n0 * Math.PI * 2;