@woosh/meep-engine 2.79.0 → 2.80.1

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 (60) hide show
  1. package/build/meep.cjs +179 -199
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +179 -199
  4. package/package.json +1 -1
  5. package/src/core/geom/2d/aabb/AABB2.js +6 -18
  6. package/src/core/geom/3d/SurfacePoint3.spec.js +1 -1
  7. package/src/core/geom/3d/{matrix → mat4}/m4_multiply.spec.js +3 -4
  8. package/src/core/geom/3d/{matrix → mat4}/m4_multiply_alphatensor.spec.js +3 -3
  9. package/src/core/geom/3d/morton/v3_morton_encode_transformed.spec.js +1 -1
  10. package/src/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.spec.js +1 -1
  11. package/src/core/geom/Vector3.js +2 -2
  12. package/src/core/geom/Vector3.spec.js +2 -2
  13. package/src/core/geom/packing/max-rect/{MaxRectangles.js → MaxRectanglesPacker.js} +25 -32
  14. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.spec.js +60 -0
  15. package/src/core/geom/packing/max-rect/packMaxRectangles.js +19 -0
  16. package/src/core/graph/cluster_mesh_metis.js +3 -3
  17. package/src/core/graph/metis/metis.js +16 -1
  18. package/src/core/graph/metis/metis_options.js +32 -29
  19. package/src/core/math/bell_membership_function.js +1 -1
  20. package/src/core/math/computeIsoscelesTriangleApexAngle.js +2 -2
  21. package/src/core/math/computeIsoscelesTriangleApexAngle.spec.js +6 -0
  22. package/src/core/math/interval/overlap1D.js +7 -0
  23. package/src/core/math/noise/create_simplex_noise_2d.js +4 -0
  24. package/src/core/math/spline/computeCatmullRomSplineUniformDistance.js +3 -3
  25. package/src/core/math/spline/v3_computeCatmullRomSplineUniformDistance.js +42 -0
  26. package/src/core/math/statistics/computeStatisticalPartialMedian.js +7 -1
  27. package/src/core/math/statistics/computeStatisticalPercentile.js +12 -3
  28. package/src/core/math/statistics/computeStatisticalPercentile.spec.js +11 -0
  29. package/src/core/math/statistics/computeStatisticalStandardDeviation.js +12 -0
  30. package/src/core/math/statistics/{computeSampleStandardDeviation.js → computeStatisticalVariance.js} +4 -6
  31. package/src/core/math/statistics/computeStatisticalVariance.spec.js +10 -0
  32. package/src/core/model/node-graph/Connection.js +6 -5
  33. package/src/core/model/node-graph/Connection.spec.js +12 -0
  34. package/src/core/model/node-graph/DataType.spec.js +19 -0
  35. package/src/core/model/node-graph/node/NodeDescription.js +12 -10
  36. package/src/core/model/node-graph/node/NodeDescription.spec.js +52 -1
  37. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +66 -0
  38. package/src/core/model/node-graph/util/graph_clone_by_node_subset.js +4 -7
  39. package/src/core/model/node-graph/util/graph_collect_connections_amongst_nodes.js +0 -2
  40. package/src/core/model/object/objectKeyByValue.js +3 -2
  41. package/src/engine/ecs/renderable/Renderable.js +1 -1
  42. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +1 -1
  43. package/src/engine/ecs/terrain/tiles/TerrainTile.spec.js +2 -2
  44. package/src/engine/ecs/transform/Transform.js +3 -3
  45. package/src/engine/ecs/transform/Transform.spec.js +3 -3
  46. package/src/engine/graphics/ecs/path/entity/testEntityPath.js +16 -10
  47. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  48. package/src/engine/graphics/texture/atlas/TextureAtlas.js +1 -1
  49. package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +3 -3
  50. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.js +1 -1
  51. package/src/engine/graphics/three/expand_aabb_by_transformed_three_object.spec.js +2 -2
  52. package/src/engine/navigation/ecs/components/Path.js +5 -12
  53. package/src/engine/simulation/Ticker.js +40 -61
  54. package/src/core/geom/LineSegment.js +0 -207
  55. /package/src/core/geom/3d/{matrix → mat4}/MATRIX_4_IDENTITY.js +0 -0
  56. /package/src/core/geom/3d/{matrix → mat4}/MATRIX_4_IDENTITY.spec.js +0 -0
  57. /package/src/core/geom/3d/{matrix → mat4}/allocate_transform_m4.js +0 -0
  58. /package/src/core/geom/3d/{matrix → mat4}/m4_make_translation.js +0 -0
  59. /package/src/core/geom/3d/{matrix → mat4}/m4_multiply.js +0 -0
  60. /package/src/core/geom/3d/{matrix → mat4}/m4_multiply_alphatensor.js +0 -0
@@ -1,5 +1,5 @@
1
- import { NodeDescription } from "./NodeDescription.js";
2
1
  import { DataType } from "../DataType.js";
2
+ import { NodeDescription } from "./NodeDescription.js";
3
3
  import { PortDirection } from "./PortDirection.js";
4
4
 
5
5
  const DUMMY_TYPE = DataType.from(0, 'dummy');
@@ -12,3 +12,54 @@ test('ports are assigned unique IDs', () => {
12
12
 
13
13
  expect(id_a).not.toEqual(id_b);
14
14
  });
15
+
16
+ test("get port by ID", () => {
17
+ const node = new NodeDescription();
18
+
19
+ expect(node.getPortById(1)).toBeNull();
20
+
21
+ const id = node.createPort(DUMMY_TYPE, "a", PortDirection.In);
22
+
23
+ const port = node.getPortById(id);
24
+
25
+ expect(port).not.toBeNull();
26
+ expect(port.name).toBe("a");
27
+ });
28
+
29
+ test("get ports by name", () => {
30
+
31
+ const node = new NodeDescription();
32
+
33
+ expect(node.getPortsByName("a")).toEqual([]);
34
+
35
+ node.createPort(DUMMY_TYPE, "a", PortDirection.In);
36
+
37
+ const result_0 = node.getPortsByName("a");
38
+ expect(result_0.length).toBe(1);
39
+ expect(result_0[0].name).toBe("a");
40
+
41
+ node.createPort(DUMMY_TYPE, "b", PortDirection.In);
42
+
43
+ const result_1 = node.getPortsByName("a");
44
+ expect(result_1.length).toBe(1);
45
+ expect(result_1[0].name).toBe("a");
46
+ });
47
+
48
+ test("delete port", () => {
49
+ const node = new NodeDescription();
50
+
51
+ expect(node.deletePort(1)).toBe(false);
52
+
53
+ const id = node.createPort(DUMMY_TYPE, "a", PortDirection.In);
54
+
55
+ expect(node.deletePort(id)).toBe(true);
56
+
57
+ expect(node.getPorts()).toEqual([]);
58
+ });
59
+
60
+ test("toString", () => {
61
+ const node = new NodeDescription();
62
+
63
+ expect(typeof node.toString()).toBe("string");
64
+ expect(node.toString().length).toBeGreaterThan(0);
65
+ });
@@ -0,0 +1,66 @@
1
+ import { DataType } from "../DataType.js";
2
+ import { NodeGraph } from "../NodeGraph.js";
3
+ import { NodeDescription } from "./NodeDescription.js";
4
+ import { NodeInstancePortReference } from "./NodeInstancePortReference.js";
5
+ import { PortDirection } from "./PortDirection.js";
6
+
7
+ const DUMMY_TYPE = DataType.from(0, 'dummy');
8
+ test("constructor does not throw", () => {
9
+ new NodeInstancePortReference()
10
+ });
11
+
12
+ test("outgoing connections", () => {
13
+ const nd = new NodeDescription();
14
+ const port_a_id = nd.createPort(DUMMY_TYPE, "a", PortDirection.Out);
15
+ const port_b_id = nd.createPort(DUMMY_TYPE, "b", PortDirection.In);
16
+
17
+
18
+ const graph = new NodeGraph();
19
+ const node_instance_id = graph.createNode(nd);
20
+
21
+ const port_a_ref = graph.getConnectionEndpoint(node_instance_id, port_a_id);
22
+
23
+ expect(port_a_ref.outConnections).toEqual([]);
24
+
25
+ const connection_id = graph.createConnection(node_instance_id, port_a_id, node_instance_id, port_b_id);
26
+
27
+ const connection = graph.getConnection(connection_id);
28
+
29
+ expect(port_a_ref.outConnections).toEqual([connection]);
30
+ });
31
+
32
+ test("incoming connections", () => {
33
+ const nd = new NodeDescription();
34
+ const port_a_id = nd.createPort(DUMMY_TYPE, "a", PortDirection.Out);
35
+ const port_b_id = nd.createPort(DUMMY_TYPE, "b", PortDirection.In);
36
+
37
+
38
+ const graph = new NodeGraph();
39
+ const node_instance_id = graph.createNode(nd);
40
+
41
+ const port_b_ref = graph.getConnectionEndpoint(node_instance_id, port_b_id);
42
+
43
+ expect(port_b_ref.inConnections).toEqual([]);
44
+
45
+ const connection_id = graph.createConnection(node_instance_id, port_a_id, node_instance_id, port_b_id);
46
+
47
+ const connection = graph.getConnection(connection_id);
48
+
49
+ expect(port_b_ref.inConnections).toEqual([connection]);
50
+ });
51
+
52
+ test("hash", () => {
53
+
54
+ const nd = new NodeDescription();
55
+ const port_a_id = nd.createPort(DUMMY_TYPE, "a", PortDirection.Out);
56
+
57
+
58
+ const graph = new NodeGraph();
59
+ const node_instance_id = graph.createNode(nd);
60
+
61
+ const port_a_ref = graph.getConnectionEndpoint(node_instance_id, port_a_id);
62
+
63
+ expect(port_a_ref.hash()).toEqual(port_a_ref.hash());
64
+ expect(typeof port_a_ref.hash()).toBe("number");
65
+ expect(Number.isInteger(port_a_ref.hash())).toBe(true);
66
+ });
@@ -1,16 +1,13 @@
1
- import { NodeGraph } from "../NodeGraph.js";
2
1
  import { assert } from "../../../assert.js";
2
+ import { NodeGraph } from "../NodeGraph.js";
3
3
  import { graph_collect_connections_amongst_nodes } from "./graph_collect_connections_amongst_nodes.js";
4
4
 
5
5
  /**
6
6
  * Clone portion of a graph as a new graph, retaining connections amongst those nodes
7
- * @param {NodeGraph} graph
8
7
  * @param {NodeInstance[]} nodes
8
+ * @returns {NodeGraph}
9
9
  */
10
- export function graph_clone_by_node_subset({ graph, nodes }) {
11
-
12
- assert.defined(graph, 'graph');
13
- assert.notNull(graph, 'graph');
10
+ export function graph_clone_by_node_subset({ nodes }) {
14
11
 
15
12
  assert.defined(nodes, 'nodes');
16
13
  assert.notNull(nodes, 'nodes');
@@ -18,7 +15,7 @@ export function graph_clone_by_node_subset({ graph, nodes }) {
18
15
 
19
16
  const result = new NodeGraph();
20
17
 
21
- const connections = graph_collect_connections_amongst_nodes({ graph, nodes });
18
+ const connections = graph_collect_connections_amongst_nodes({ nodes });
22
19
 
23
20
  result.mergeFragment({
24
21
  nodes,
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * Given a graph and a set of nodes, get all connections that connect these nodes amongst themselves
3
- * @param {NodeGraph} graph
4
3
  * @param {NodeInstance[]} nodes
5
4
  * @returns {Connection[]}
6
5
  */
7
6
  export function graph_collect_connections_amongst_nodes({
8
- graph,
9
7
  nodes
10
8
  }) {
11
9
 
@@ -1,8 +1,9 @@
1
1
  /**
2
- *
2
+ * Given an object and a value, find the first property with matching value and returns name of that property
3
+ * Useful for working with ENUM-like objects
3
4
  * @param {Object<T>} object
4
5
  * @param {T} value
5
- * @returns {string|undefined}
6
+ * @returns {string|undefined} name of the property, or undefined if property not found
6
7
  */
7
8
  export function objectKeyByValue(object, value) {
8
9
  for (let i in object) {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { BvhClient } from "../../../core/bvh2/bvh3/BvhClient.js";
7
7
  import { AABB3 } from "../../../core/geom/3d/aabb/AABB3.js";
8
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
8
+ import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
9
9
  import {
10
10
  expand_aabb_by_transformed_three_object
11
11
  } from "../../graphics/three/expand_aabb_by_transformed_three_object.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
6
6
  import { noop } from "../../../../core/function/Functions.js";
7
7
  import { read_three_planes_to_array } from "../../../../core/geom/3d/frustum/read_three_planes_to_array.js";
8
- import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
8
+ import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
9
9
  import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
10
10
  import { CameraSystem } from '../../../graphics/ecs/camera/CameraSystem.js';
11
11
  import { System } from '../../System.js';
@@ -1,5 +1,5 @@
1
+ import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
1
2
  import TerrainTile from "./TerrainTile.js";
2
- import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
3
3
 
4
4
  test("constructor does not throw", () => {
5
5
  new TerrainTile();
@@ -21,5 +21,5 @@ test("using 'dispose' method on newly created tile", () => {
21
21
  const tile = new TerrainTile();
22
22
 
23
23
  expect(() => tile.dispose()).not.toThrow();
24
-
24
+
25
25
  });
@@ -5,9 +5,9 @@
5
5
  import { assert } from "../../../core/assert.js";
6
6
  import { compose_matrix4_array } from "../../../core/geom/3d/compose_matrix4_array.js";
7
7
  import { decompose_matrix_4_array } from "../../../core/geom/3d/decompose_matrix_4_array.js";
8
- import { allocate_transform_m4 } from "../../../core/geom/3d/matrix/allocate_transform_m4.js";
9
- import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
10
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
8
+ import { allocate_transform_m4 } from "../../../core/geom/3d/mat4/allocate_transform_m4.js";
9
+ import { m4_multiply } from "../../../core/geom/3d/mat4/m4_multiply.js";
10
+ import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
11
11
  import Quaternion from "../../../core/geom/Quaternion.js";
12
12
  import Vector3 from "../../../core/geom/Vector3.js";
13
13
  import { TransformFlags } from "./TransformFlags.js";
@@ -1,7 +1,7 @@
1
- import { Transform } from "./Transform.js";
2
- import Vector3 from "../../../core/geom/Vector3.js";
1
+ import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
3
2
  import Quaternion from "../../../core/geom/Quaternion.js";
4
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
3
+ import Vector3 from "../../../core/geom/Vector3.js";
4
+ import { Transform } from "./Transform.js";
5
5
  import { TransformFlags } from "./TransformFlags.js";
6
6
 
7
7
  test("constructor does not throw", () => {
@@ -1,16 +1,19 @@
1
- import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
2
- import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
3
1
  import { makeMirEngineConfig } from "../../../../../../../model/game/makeMirEngineConfig.js";
4
- import { EngineHarness } from "../../../../EngineHarness.js";
5
- import { EntityPath } from "./EntityPath.js";
6
- import Path from "../../../../navigation/ecs/components/Path.js";
2
+ import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
7
3
  import Vector3 from "../../../../../core/geom/Vector3.js";
8
- import { EntityPathStyle } from "./EntityPathStyle.js";
9
- import { EntityPathMarkerDefinition } from "./EntityPathMarkerDefinition.js";
4
+ import {
5
+ v3_computeCatmullRomSplineUniformDistance
6
+ } from "../../../../../core/math/spline/v3_computeCatmullRomSplineUniformDistance.js";
7
+ import { Animation } from "../../../../ecs/animation/Animation.js";
10
8
  import { EntityBlueprint } from "../../../../ecs/EntityBlueprint.js";
9
+ import RenderSystem from "../../../../ecs/systems/RenderSystem.js";
11
10
  import { Transform } from "../../../../ecs/transform/Transform.js";
11
+ import { EngineHarness } from "../../../../EngineHarness.js";
12
+ import Path from "../../../../navigation/ecs/components/Path.js";
12
13
  import Mesh from "../../mesh/Mesh.js";
13
- import { Animation } from "../../../../ecs/animation/Animation.js";
14
+ import { EntityPath } from "./EntityPath.js";
15
+ import { EntityPathMarkerDefinition } from "./EntityPathMarkerDefinition.js";
16
+ import { EntityPathStyle } from "./EntityPathStyle.js";
14
17
 
15
18
  const engineHarness = new EngineHarness();
16
19
 
@@ -38,12 +41,15 @@ function main(engine) {
38
41
 
39
42
  const path = new EntityPath();
40
43
  const _p = new Path();
41
- _p.setPositionsFromVectorArray(Path.smoothPath([
44
+
45
+ const curve_points = v3_computeCatmullRomSplineUniformDistance([
42
46
  new Vector3(3, 0, 3),
43
47
  new Vector3(7, 0, 3),
44
48
  new Vector3(7, 0, 7),
45
49
  new Vector3(3, 0, 7)
46
- ], 50));
50
+ ], 50);
51
+
52
+ _p.setPositionsFromVectorArray(curve_points);
47
53
 
48
54
  const style = new EntityPathStyle();
49
55
  style.spacing = 1;
@@ -16,7 +16,7 @@ import { typedArrayToDataType } from "../../../../core/collection/array/typed/ty
16
16
  import { collectIteratorValueToArray } from "../../../../core/collection/collectIteratorValueToArray.js";
17
17
  import { HashMap } from "../../../../core/collection/map/HashMap.js";
18
18
  import AABB2 from "../../../../core/geom/AABB2.js";
19
- import { MaxRectanglesPacker } from "../../../../core/geom/packing/max-rect/MaxRectangles.js";
19
+ import { MaxRectanglesPacker } from "../../../../core/geom/packing/max-rect/MaxRectanglesPacker.js";
20
20
  import { computeMaterialEquality } from "../../../asset/loaders/material/computeMaterialEquality.js";
21
21
  import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
22
22
  import { TextureAttachmentsByMaterialType } from "../../../asset/loaders/material/TextureAttachmensByMaterialType.js";
@@ -5,7 +5,7 @@ import {
5
5
  DataType2TypedArrayConstructorMapping
6
6
  } from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
7
7
  import Signal from "../../../../core/events/signal/Signal.js";
8
- import { MaxRectanglesPacker } from "../../../../core/geom/packing/max-rect/MaxRectangles.js";
8
+ import { MaxRectanglesPacker } from "../../../../core/geom/packing/max-rect/MaxRectanglesPacker.js";
9
9
  import Vector2 from "../../../../core/geom/Vector2.js";
10
10
  import IdPool from "../../../../core/IdPool.js";
11
11
  import { max2 } from "../../../../core/math/max2.js";
@@ -1,6 +1,3 @@
1
- import { AtlasPatch } from "../AtlasPatch.js";
2
- import IdPool from "../../../../../core/IdPool.js";
3
- import { MaxRectanglesPacker } from "../../../../../core/geom/packing/max-rect/MaxRectangles.js";
4
1
  import {
5
2
  ClampToEdgeWrapping,
6
3
  DataTexture,
@@ -11,7 +8,10 @@ import {
11
8
  UnsignedByteType,
12
9
  UVMapping
13
10
  } from "three";
11
+ import { MaxRectanglesPacker } from "../../../../../core/geom/packing/max-rect/MaxRectanglesPacker.js";
12
+ import IdPool from "../../../../../core/IdPool.js";
14
13
  import { formatToChannelCount } from "../../formatToChannelCount.js";
14
+ import { AtlasPatch } from "../AtlasPatch.js";
15
15
 
16
16
  export class WebGLTextureAtlas {
17
17
  constructor({
@@ -1,7 +1,7 @@
1
1
  import { aabb3_array_combine } from "../../../core/geom/3d/aabb/aabb3_array_combine.js";
2
2
  import { aabb3_from_threejs_geometry } from "../../../core/geom/3d/aabb/aabb3_from_threejs_geometry.js";
3
3
  import { aabb3_matrix4_project } from "../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
4
- import { m4_multiply } from "../../../core/geom/3d/matrix/m4_multiply.js";
4
+ import { m4_multiply } from "../../../core/geom/3d/mat4/m4_multiply.js";
5
5
  import { ensureGeometryBoundingBox } from "../util/ensureGeometryBoundingBox.js";
6
6
 
7
7
  const scratch_aabb3_array_0 = new Float32Array(6);
@@ -1,6 +1,6 @@
1
- import { expand_aabb_by_transformed_three_object } from "./expand_aabb_by_transformed_three_object.js";
2
- import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
3
1
  import { BufferAttribute, BufferGeometry, Group, Mesh } from "three";
2
+ import { MATRIX_4_IDENTITY } from "../../../core/geom/3d/mat4/MATRIX_4_IDENTITY.js";
3
+ import { expand_aabb_by_transformed_three_object } from "./expand_aabb_by_transformed_three_object.js";
4
4
 
5
5
  /**
6
6
  *
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
 
6
- import { CatmullRomCurve3 } from "three";
7
6
  import { assert } from "../../../../core/assert.js";
8
7
  import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
9
8
  import { RowFirstTable } from "../../../../core/collection/table/RowFirstTable.js";
@@ -18,6 +17,9 @@ import { min2 } from "../../../../core/math/min2.js";
18
17
  import {
19
18
  computeNonuniformCatmullRomSplineSample
20
19
  } from "../../../../core/math/spline/computeNonuniformCatmullRomSplineSample.js";
20
+ import {
21
+ v3_computeCatmullRomSplineUniformDistance
22
+ } from "../../../../core/math/spline/v3_computeCatmullRomSplineUniformDistance.js";
21
23
  import { AttributeSpec } from "../../../graphics/geometry/AttributeSpec.js";
22
24
  import { VertexDataSpec } from "../../../graphics/geometry/VertexDataSpec.js";
23
25
  import { InterpolationType } from "./InterpolationType.js";
@@ -701,22 +703,13 @@ class Path {
701
703
  }
702
704
 
703
705
  /**
704
- *
706
+ * @deprecated use {@link v3_computeCatmullRomSplineUniformDistance} directly instead
705
707
  * @param {Vector3[]} points
706
708
  * @param {number} samples
707
709
  * @returns {Vector3[]}
708
710
  */
709
711
  static smoothPath(points, samples) {
710
-
711
- const curve = new CatmullRomCurve3(points);
712
- const points2 = curve.getPoints(samples);
713
-
714
- //Convert to engine vector format
715
- const result = points2.map(function (p) {
716
- return new Vector3(p.x, p.y, p.z);
717
- });
718
-
719
- return result;
712
+ throw new Error('Deprecated, use v3_computeCatmullRomSplineUniformDistance directly instead. Please note, there is already a CatmullRom interpolation type as well');
720
713
  }
721
714
  }
722
715
 
@@ -1,27 +1,42 @@
1
1
  /**
2
2
  * Created by Alex on 06/05/2015.
3
3
  */
4
- import Clock from '../Clock.js';
5
- import { SignalHandler } from "../../core/events/signal/SignalHandler.js";
6
4
  import { assert } from "../../core/assert.js";
5
+ import Signal from "../../core/events/signal/Signal.js";
6
+ import Clock from '../Clock.js';
7
7
 
8
+ /**
9
+ * Simulation tick generator
10
+ * Dispatches "tick" every animation frame or "maxDelay" time, whichever happens to be soonest
11
+ * This is essentially the timing bus that all the simulation systems subscribe to for their step advancement
12
+ */
8
13
  class Ticker {
9
14
  /**
10
15
  * @readonly
11
16
  * @type {Clock}
12
17
  */
13
18
  clock = new Clock();
19
+
14
20
  /**
15
21
  * @private
16
22
  * @type {boolean}
17
23
  */
18
- isRunning = false;
24
+ #isRunning = false;
25
+
19
26
 
20
27
  /**
21
- *
22
- * @type {SignalHandler[]}
28
+ * Dispatches time delta in seconds since last tick
29
+ * @readonly
30
+ * @type {Signal<number>}
23
31
  */
24
- callbacks = [];
32
+ onTick = new Signal();
33
+
34
+ /**
35
+ * @deprecated
36
+ */
37
+ get callbacks() {
38
+ throw new Error('deprecated, use onTick signal instead');
39
+ }
25
40
 
26
41
  /**
27
42
  *
@@ -32,80 +47,44 @@ class Ticker {
32
47
  }
33
48
 
34
49
  /**
35
- *
50
+ * @deprecated use onTick signal directly instead
36
51
  * @param {function} callback
37
52
  * @param {*} [thisArg]
38
53
  */
39
54
  subscribe(callback, thisArg) {
40
- const handler = new SignalHandler(callback, thisArg);
41
-
42
- this.callbacks.push(handler);
55
+ this.onTick.add(callback, thisArg);
43
56
  }
44
57
 
45
58
  /**
46
- *
59
+ * @deprecated use onTick signal directly instead
47
60
  * @param {function} callback
48
61
  * @param {*} [thisArg]
49
62
  */
50
63
  unsubscribe(callback, thisArg) {
51
- assert.isFunction(callback, 'callback');
52
-
53
- const callbacks = this.callbacks;
54
- const n = callbacks.length;
55
- for (let i = 0; i < n; i++) {
56
- const cb = callbacks[i];
57
-
58
- if (cb.handle === callback) {
59
- if (thisArg !== undefined) {
60
- if (thisArg === cb.context) {
61
- callbacks.splice(i, 1);
62
- return;
63
- }
64
- } else {
65
- callbacks.splice(i, 1);
66
- return;
67
- }
68
- }
69
- }
70
-
64
+ this.onTick.remove(callback, thisArg);
71
65
  }
72
66
 
73
67
  /**
74
68
  *
75
- * @param {number} maxTimeout
69
+ * @param {number} [maxTimeout]
76
70
  */
77
71
  start({ maxTimeout = 100 } = {}) {
78
- assert.typeOf(maxTimeout, 'number', 'maxTimeout');
72
+ assert.isNumber(maxTimeout, 'maxTimeout');
73
+ assert.greaterThan(maxTimeout, 0);
79
74
 
80
-
81
- const self = this;
82
75
  let timeout = null;
83
76
  let animationFrame = null;
84
77
 
85
- this.isRunning = true;
86
-
87
- function update() {
88
- if (self.isRunning) {
89
-
90
- const delta = self.clock.getDelta();
78
+ this.#isRunning = true;
91
79
 
92
- const callbacks = self.callbacks;
93
-
94
- for (let i = 0; i < callbacks.length; i++) {
95
- const callback = callbacks[i];
96
-
97
- try {
98
- callback.handle.call(callback.context, delta);
99
- } catch (e) {
100
- console.error('Error in ticker subscription:', e);
101
- }
102
-
103
- }
80
+ const update = () => {
81
+ if (!this.#isRunning) {
82
+ return;
104
83
  }
105
- }
106
84
 
107
- function cycle() {
108
- update();
85
+ const delta = this.clock.getDelta();
86
+
87
+ this.onTick.send1(delta);
109
88
  }
110
89
 
111
90
  function timeoutCallback() {
@@ -122,22 +101,22 @@ class Ticker {
122
101
 
123
102
  function animate() {
124
103
  animationFrame = requestAnimationFrame(animationFrameCallback);
125
- cycle();
104
+ update();
126
105
  timeout = setTimeout(timeoutCallback, maxTimeout);
127
106
  }
128
107
 
129
- self.clock.getDelta(); //purge delta
130
- self.clock.start();
108
+ this.clock.getDelta(); //purge delta
109
+ this.clock.start();
131
110
 
132
111
  requestAnimationFrame(animationFrameCallback);
133
112
  }
134
113
 
135
114
  pause() {
136
- this.isRunning = false;
115
+ this.#isRunning = false;
137
116
  }
138
117
 
139
118
  resume() {
140
- this.isRunning = true;
119
+ this.#isRunning = true;
141
120
  }
142
121
  }
143
122