@woosh/meep-engine 2.70.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 (31) hide show
  1. package/build/meep.cjs +109 -120
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +109 -120
  4. package/package.json +1 -1
  5. package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +2 -3
  6. package/src/core/math/remap.js +5 -1
  7. package/src/core/math/statistics/computeStatisticalPartialMedian.js +1 -1
  8. package/src/core/process/task/Task.js +53 -34
  9. package/src/engine/achievements/AchievementManager.js +19 -19
  10. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +6 -6
  11. package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +11 -6
  12. package/src/engine/ecs/dynamic_actions/DynamicActor.js +5 -10
  13. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +82 -89
  14. package/src/engine/ecs/dynamic_actions/RuleExecution.js +10 -12
  15. package/src/engine/ecs/gui/GUIElement.js +44 -61
  16. package/src/engine/ecs/gui/GUIElementSystem.js +26 -24
  17. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +12 -15
  18. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +15 -15
  19. package/src/engine/ecs/gui/parallax/GuiElementParallax.js +3 -3
  20. package/src/engine/ecs/gui/parallax/GuiElementParallaxSystem.js +2 -2
  21. package/src/engine/ecs/gui/position/ViewportPosition.js +5 -50
  22. package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.js +42 -0
  23. package/src/engine/ecs/transform/TransformSerializationAdapter.js +5 -10
  24. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +20 -20
  25. package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +12 -12
  26. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +1 -4
  27. package/src/core/binary/ValidatingBitSetWrapper.js +0 -81
  28. package/src/core/binary/jsonToStringToByteArray.js +0 -27
  29. package/src/engine/ecs/components/AreaOfEffect.js +0 -12
  30. package/src/engine/ecs/components/Mortality.js +0 -27
  31. package/src/engine/ecs/systems/AreaOfEffectSystem.js +0 -48
@@ -0,0 +1,42 @@
1
+ import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import ViewportPosition from "./ViewportPosition.js";
3
+
4
+ export class ViewportPositionSerializationAdapter extends BinaryClassSerializationAdapter {
5
+
6
+ version = 0;
7
+ klass = ViewportPosition;
8
+
9
+ /**
10
+ *
11
+ * @param {BinaryBuffer} buffer
12
+ * @param {ViewportPosition} value
13
+ */
14
+ serialize(buffer, value) {
15
+ value.position.toBinaryBufferFloat32(buffer);
16
+ value.offset.toBinaryBufferFloat32(buffer);
17
+ value.anchor.toBinaryBufferFloat32(buffer);
18
+
19
+ buffer.writeFloat32(value.screenEdgeWidth);
20
+
21
+ buffer.writeUint8(value.resolveGuiCollisions ? 1 : 0);
22
+ buffer.writeUint8(value.stickToScreenEdge ? 1 : 0);
23
+ buffer.writeUint8(value.enabled.getValue() ? 1 : 0);
24
+ }
25
+
26
+ /**
27
+ *
28
+ * @param {BinaryBuffer} buffer
29
+ * @param {ViewportPosition} value
30
+ */
31
+ deserialize(buffer, value) {
32
+ value.position.fromBinaryBufferFloat32(buffer);
33
+ value.offset.fromBinaryBufferFloat32(buffer);
34
+ value.anchor.fromBinaryBufferFloat32(buffer);
35
+
36
+ value.screenEdgeWidth = buffer.readFloat32();
37
+
38
+ value.resolveGuiCollisions = buffer.readUint8() !== 0;
39
+ value.stickToScreenEdge = buffer.readUint8() !== 0;
40
+ value.enabled.set(buffer.readUint8() !== 0);
41
+ }
42
+ }
@@ -18,16 +18,13 @@ export class TransformSerializationAdapter extends BinaryClassSerializationAdapt
18
18
  serialize(buffer, value) {
19
19
 
20
20
  const position = value.position;
21
+ const rotation = value.rotation;
22
+ const scale = value.scale;
21
23
 
22
- const positionX = position.x;
23
- const positionY = position.y;
24
- const positionZ = position.z;
25
-
26
- buffer.writeFloat64(positionX);
27
- buffer.writeFloat64(positionY);
28
- buffer.writeFloat64(positionZ);
24
+ buffer.writeFloat64(position.x);
25
+ buffer.writeFloat64(position.y);
26
+ buffer.writeFloat64(position.z);
29
27
 
30
- const rotation = value.rotation;
31
28
  const encoded_rotation = quat_encode_to_uint32(
32
29
  rotation.x,
33
30
  rotation.y,
@@ -37,8 +34,6 @@ export class TransformSerializationAdapter extends BinaryClassSerializationAdapt
37
34
 
38
35
  buffer.writeUint32(encoded_rotation);
39
36
 
40
- const scale = value.scale;
41
-
42
37
  v3_binary_equality_encode(buffer, scale.x, scale.y, scale.z);
43
38
  }
44
39
 
@@ -1,32 +1,32 @@
1
- import { EngineHarness } from "../../../EngineHarness.js";
2
- import { ImpostorBaker } from "./ImpostorBaker.js";
3
- import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
1
+ import Quaternion from "../../../../core/geom/Quaternion.js";
2
+ import Vector2 from "../../../../core/geom/Vector2.js";
3
+ import Vector3 from "../../../../core/geom/Vector3.js";
4
+ import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
5
+ import { GameAssetType } from "../../../asset/GameAssetType.js";
6
+ import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
4
7
  import Entity from "../../../ecs/Entity.js";
5
- import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
6
8
  import GUIElement from "../../../ecs/gui/GUIElement.js";
7
9
  import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
10
+ import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
8
11
  import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
9
- import Vector2 from "../../../../core/geom/Vector2.js";
10
- import { GameAssetType } from "../../../asset/GameAssetType.js";
11
- import { Transform } from "../../../ecs/transform/Transform.js";
12
- import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
13
- import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
14
- import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
15
- import { ImpostorShaderV0 } from "./shader/ImpostorShaderV0.js";
16
- import Quaternion from "../../../../core/geom/Quaternion.js";
17
- import { SGMesh } from "../../ecs/mesh-v2/aggregate/SGMesh.js";
18
- import { SGMeshSystem } from "../../ecs/mesh-v2/aggregate/SGMeshSystem.js";
19
- import { ShadedGeometryFlags } from "../../ecs/mesh-v2/ShadedGeometryFlags.js";
20
12
  import { TransformAttachmentSystem } from "../../../ecs/transform-attachment/TransformAttachmentSystem.js";
13
+ import { Transform } from "../../../ecs/transform/Transform.js";
14
+ import { EngineHarness } from "../../../EngineHarness.js";
21
15
  import { BehaviorComponent } from "../../../intelligence/behavior/ecs/BehaviorComponent.js";
22
- import Vector3 from "../../../../core/geom/Vector3.js";
23
16
  import { BehaviorSystem } from "../../../intelligence/behavior/ecs/BehaviorSystem.js";
24
17
  import { RotationBehavior } from "../../../intelligence/behavior/util/RotationBehavior.js";
25
- import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
18
+ import { SGMesh } from "../../ecs/mesh-v2/aggregate/SGMesh.js";
19
+ import { SGMeshSystem } from "../../ecs/mesh-v2/aggregate/SGMeshSystem.js";
20
+ import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
21
+ import { ShadedGeometryFlags } from "../../ecs/mesh-v2/ShadedGeometryFlags.js";
22
+ import { ShadedGeometrySystem } from "../../ecs/mesh-v2/ShadedGeometrySystem.js";
23
+ import { ImpostorBaker } from "./ImpostorBaker.js";
24
+ import { ImpostorCaptureType } from "./ImpostorCaptureType.js";
25
+ import { ImpostorShaderV0 } from "./shader/ImpostorShaderV0.js";
26
26
  import { ImpostorShaderWireframeV0 } from "./shader/ImpostorShaderWireframeV0.js";
27
- import { makeImpostorAtlasPreview } from "./util/makeImpostorAtlasPreview.js";
28
- import { load_mesh_for_bake } from "./util/load_mesh_for_bake.js";
29
27
  import { build_geometry_from_cutout_shape } from "./util/build_geometry_from_cutout_shape.js";
28
+ import { load_mesh_for_bake } from "./util/load_mesh_for_bake.js";
29
+ import { makeImpostorAtlasPreview } from "./util/makeImpostorAtlasPreview.js";
30
30
 
31
31
  /**
32
32
  *
@@ -80,7 +80,7 @@ async function main(engine) {
80
80
  });
81
81
 
82
82
  new Entity()
83
- .add(new ViewportPosition({
83
+ .add(ViewportPosition.fromJSON({
84
84
  offset: new Vector2(0, 0)
85
85
  }))
86
86
  .add(GUIElement.fromView(ctrl))
@@ -1,20 +1,20 @@
1
- import { EngineHarness } from "../../../EngineHarness.js";
2
- import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
3
- import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
1
+ import { compute_polygon_area_2d } from "../../../../core/geom/2d/compute_polygon_area_2d.js";
2
+ import { convex_hull_jarvis_2d } from "../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
3
+ import { fixed_convex_hull_humus } from "../../../../core/geom/2d/convex-hull/fixed_convex_hull_humus.js";
4
+ import Vector2 from "../../../../core/geom/Vector2.js";
5
+ import { CanvasView } from "../../../../view/elements/CanvasView.js";
4
6
  import EmptyView from "../../../../view/elements/EmptyView.js";
7
+ import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
5
8
  import Entity from "../../../ecs/Entity.js";
6
9
  import GUIElement from "../../../ecs/gui/GUIElement.js";
7
- import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
8
- import { CanvasView } from "../../../../view/elements/CanvasView.js";
9
- import sampler2D2Canvas from "../sampler/Sampler2D2Canvas.js";
10
+ import GUIElementSystem from "../../../ecs/gui/GUIElementSystem.js";
10
11
  import ViewportPosition from "../../../ecs/gui/position/ViewportPosition.js";
11
- import Vector2 from "../../../../core/geom/Vector2.js";
12
- import { convex_hull_jarvis_2d } from "../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
12
+ import ViewportPositionSystem from "../../../ecs/gui/position/ViewportPositionSystem.js";
13
+ import { EngineHarness } from "../../../EngineHarness.js";
13
14
  import { Sampler2D } from "../sampler/Sampler2D.js";
14
- import { compute_polygon_area_2d } from "../../../../core/geom/2d/compute_polygon_area_2d.js";
15
- import { sampler2d_find_pixels } from "../sampler/search/sampler2d_find_pixels.js";
15
+ import sampler2D2Canvas from "../sampler/Sampler2D2Canvas.js";
16
16
  import { make_edge_condition_channel_threshold } from "../sampler/search/make_edge_condition_channel_threshold.js";
17
- import { fixed_convex_hull_humus } from "../../../../core/geom/2d/convex-hull/fixed_convex_hull_humus.js";
17
+ import { sampler2d_find_pixels } from "../sampler/search/sampler2d_find_pixels.js";
18
18
 
19
19
  const edge_condition_alpha0 = make_edge_condition_channel_threshold(3, 0);
20
20
 
@@ -195,7 +195,7 @@ async function main(engine) {
195
195
 
196
196
  new Entity()
197
197
  .add(GUIElement.fromView(vContainer))
198
- .add(new ViewportPosition({
198
+ .add(ViewportPosition.fromJSON({
199
199
  offset: new Vector2(100, 100)
200
200
  }))
201
201
  .build(engine.entityManager.dataset);
@@ -1,5 +1,5 @@
1
- import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
1
  import Vector3 from "../../../../core/geom/Vector3.js";
2
+ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
3
3
  import Path from "./Path.js";
4
4
 
5
5
 
@@ -54,8 +54,5 @@ export class PathSerializationAdapter extends BinaryClassSerializationAdapter {
54
54
 
55
55
  value.setPosition(i, x, y, z);
56
56
  }
57
-
58
- // mark length for update
59
- value.__length = -1;
60
57
  }
61
58
  }
@@ -1,81 +0,0 @@
1
- //
2
-
3
- /**
4
- * Debug tool to verify correct behavior of a BitSet
5
- */
6
- export class ValidatingBitSetWrapper {
7
- /**
8
- *
9
- * @param {BitSet} source
10
- */
11
- constructor(source) {
12
- this.__source = source;
13
- }
14
-
15
- preventShrink() {
16
- this.__source.preventShrink();
17
- }
18
-
19
- setShrinkFactor(x) {
20
- this.__source.setShrinkFactor(x);
21
- }
22
-
23
- setCapacity(x) {
24
- this.__source.setCapacity(x);
25
- }
26
-
27
- size() {
28
- return this.__source.size();
29
- }
30
-
31
- capacity() {
32
- return this.__source.capacity();
33
- }
34
-
35
- previousSetBit(i) {
36
- const bit = this.__source.previousSetBit(i);
37
-
38
- if (bit !== -1 && (this.__source.get(bit) !== true || bit > i)) {
39
- debugger;
40
- }
41
-
42
- return bit;
43
- }
44
-
45
- nextSetBit(i) {
46
- const bit = this.__source.nextSetBit(i);
47
-
48
- if (bit !== -1 && (this.__source.get(bit) !== true || bit < i)) {
49
- debugger;
50
- }
51
-
52
- return bit;
53
- }
54
-
55
- nextClearBit(i) {
56
- const bit = this.__source.nextClearBit(i);
57
-
58
- if (bit !== -1 && (this.__source.get(bit) !== false || bit < i)) {
59
- debugger;
60
- }
61
-
62
- return bit;
63
- }
64
-
65
- set(x, y) {
66
- this.__source.set(x, y);
67
- }
68
-
69
- clear(i) {
70
- this.__source.clear(i);
71
- }
72
-
73
- get(i) {
74
- return this.__source.get(i);
75
- }
76
-
77
-
78
- reset() {
79
- this.__source.reset();
80
- }
81
- }
@@ -1,27 +0,0 @@
1
- import {stringifyStream} from "../json/JsonUtils.js";
2
-
3
- /**
4
- *
5
- * @param {Object} json
6
- * @returns {number[]}
7
- */
8
- function jsonToStringToByteArray(json) {
9
- const output = [];
10
- let p = 0;
11
-
12
- function addToOutput(str) {
13
- for (let i = 0; i < str.length; i++) {
14
- let c = str.charCodeAt(i);
15
- while (c > 0xff) {
16
- output[p++] = c & 0xff;
17
- c >>= 8;
18
- }
19
- output[p++] = c;
20
- }
21
- }
22
-
23
- stringifyStream(json, addToOutput);
24
- return output;
25
- }
26
-
27
- export {jsonToStringToByteArray};
@@ -1,12 +0,0 @@
1
- /**
2
- * Created by Alex on 11/08/2014.
3
- */
4
-
5
-
6
- function AreaOfEffect(options) {
7
- this.tags = options.tags.slice();
8
- this.radius = options.radius || new THREE.Vector3(1, 1, 1);
9
- this.action = options.action || void 0;
10
- }
11
-
12
- export default AreaOfEffect;
@@ -1,27 +0,0 @@
1
- /**
2
- * User: Alex Goldring
3
- * Date: 17/6/2014
4
- * Time: 21:26
5
- */
6
-
7
-
8
- /**
9
- * @deprecated entirely superseded by the {@link BehaviorSystem}
10
- * @param actions
11
- * @constructor
12
- */
13
- function Mortality(actions) {
14
- if (actions === void 0) {
15
- actions = []
16
- } else if (typeof actions === "function") {
17
- actions = [actions];
18
- }
19
- this.actions = actions;
20
- }
21
-
22
- Mortality.typeName = "Mortality";
23
-
24
- Mortality.serializable = false;
25
-
26
- export default Mortality;
27
-
@@ -1,48 +0,0 @@
1
- /**
2
- * Created by Alex on 11/08/2014.
3
- */
4
- import { System } from '../System.js';
5
- import Tag from '../components/Tag.js';
6
- import { Transform } from '../transform/Transform.js';
7
- import AreaOfEffect from '../components/AreaOfEffect.js';
8
-
9
-
10
- class AreaOfEffectSystem extends System {
11
- constructor() {
12
- super();
13
-
14
- this.dependencies = [AreaOfEffect];
15
- }
16
-
17
- add(component, entity) {
18
- }
19
-
20
- remove(component) {
21
- }
22
-
23
- update(timeDelta) {
24
- const entityManager = this.entityManager;
25
- entityManager.traverseEntities([AreaOfEffect, Transform], function (aoe, transform) {
26
- const position = transform.position;
27
- const tags = aoe.tags;
28
- const radius = aoe.radius;
29
- entityManager.traverseEntities([Tag, Transform], function (tag, transform2, entity) {
30
- if (tags.indexOf(tag.name) === -1) {
31
- return; //not a tag we care about
32
- }
33
- const position2 = transform2.position;
34
- //check range, doing one component at a time makes evaluation lazy, giving us a bit of speed
35
- if (
36
- Math.abs(position2.x - position.x) < radius.x
37
- && Math.abs(position2.y - position.y) < radius.y
38
- && Math.abs(position2.z - position.z) < radius.z
39
- ) {
40
- //within box
41
- aoe.action(entityManager, timeDelta, entity);
42
- }
43
- })
44
- });
45
- }
46
- }
47
-
48
- export default AreaOfEffectSystem;