@woosh/meep-engine 2.81.4 → 2.82.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 (108) hide show
  1. package/build/meep.cjs +4394 -4423
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +4394 -4423
  4. package/editor/ecs/component/editors/primitive/ArrayEditor.js +2 -2
  5. package/editor/enableEditor.js +1 -1
  6. package/editor/view/EditorView.js +25 -25
  7. package/editor/view/ecs/components/particles/ParticleEmitterController.js +11 -11
  8. package/editor/view/node-graph/NodeView.js +7 -7
  9. package/package.json +1 -1
  10. package/samples/terrain/editor.js +19 -18
  11. package/src/core/cache/Cache.js +4 -2
  12. package/src/core/cache/Cache.spec.js +1 -1
  13. package/src/core/collection/array/arraySetDiff.js +8 -2
  14. package/src/core/collection/array/groupArrayBy.js +1 -1
  15. package/src/core/collection/array/weightedRandomFromArray.spec.js +3 -1
  16. package/src/core/collection/heap/FastBinaryHeap.spec.js +3 -2
  17. package/src/core/collection/list/List.js +8 -17
  18. package/src/core/collection/list/List.spec.js +55 -0
  19. package/src/core/collection/map/HashMap.spec.js +3 -1
  20. package/src/core/collection/set/HashSet.spec.js +23 -0
  21. package/src/core/events/signal/signal_aggregate_by_time_window.js +1 -1
  22. package/src/core/fsm/simple/SimpleStateMachine.js +2 -1
  23. package/src/core/function/chain.js +19 -0
  24. package/src/core/function/makeReturnValue.js +8 -0
  25. package/src/core/function/noop.js +6 -0
  26. package/src/core/function/objectsEqual.js +14 -0
  27. package/src/core/function/passThrough.js +9 -0
  28. package/src/core/function/returnEmptyArray.js +7 -0
  29. package/src/core/function/returnFalse.js +7 -0
  30. package/src/core/function/returnOne.js +7 -0
  31. package/src/core/function/returnTrue.js +7 -0
  32. package/src/core/function/returnZero.js +7 -0
  33. package/src/core/function/strictEquals.js +10 -0
  34. package/src/core/geom/3d/tetrahedra/validate_tetrahedral_mesh.js +2 -2
  35. package/src/core/geom/3d/topology/struct/prototypeBinaryTopology.js +5 -4
  36. package/src/core/lang/reactive/AbstractCachingParser.js +2 -1
  37. package/src/core/math/random/randomFloatBetween.spec.js +2 -1
  38. package/src/core/math/random/randomIntegerBetween.spec.js +2 -1
  39. package/src/core/model/node-graph/Connection.js +2 -1
  40. package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +2 -2
  41. package/src/core/model/object/ObjectPoolFactory.js +2 -1
  42. package/src/core/model/stat/Stat.js +4 -4
  43. package/src/core/process/PromiseWatcher.spec.js +1 -1
  44. package/src/core/process/task/Task.js +2 -1
  45. package/src/engine/EngineHarness.js +2 -1
  46. package/src/engine/achievements/gateway/StorageAchievementGateway.js +1 -1
  47. package/src/engine/asset/AssetManager.js +14 -14
  48. package/src/engine/asset/loaders/ArrayBufferLoader.js +1 -1
  49. package/src/engine/ecs/EntityComponentDataset.spec.js +2 -2
  50. package/src/engine/ecs/EntityManager.js +2 -1
  51. package/src/engine/ecs/EntityObserver.spec.js +4 -4
  52. package/src/engine/ecs/System.js +2 -2
  53. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  54. package/src/engine/ecs/ik/IKProblem.js +1 -1
  55. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +2 -1
  56. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +2 -1
  57. package/src/engine/ecs/terrain/ecs/TerrainSystem.js +2 -1
  58. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +2 -1
  59. package/src/engine/ecs/terrain/util/obtainTerrain.js +1 -1
  60. package/src/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +3 -3
  61. package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -1
  62. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +7 -7
  63. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -1
  64. package/src/engine/graphics/material/SplatMaterial.js +1 -15
  65. package/src/engine/graphics/render/layers/RenderLayer.js +1 -1
  66. package/src/engine/graphics/render/utils/ThreeBypassRenderer.js +2 -1
  67. package/src/engine/graphics/render/visibility/VisibilityFilter.js +2 -1
  68. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +2 -1
  69. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +5 -5
  70. package/src/engine/graphics/texture/cubemap/load_environment_map.js +2 -2
  71. package/src/engine/graphics/texture/makeOnePixelTexture.js +5 -3
  72. package/src/engine/graphics/texture/virtual/VirtualTexturePage.js +2 -1
  73. package/src/engine/graphics/texture/whitePixelTexture.js +9 -0
  74. package/src/engine/intelligence/behavior/ecs/BehaviorSystem.spec.js +5 -5
  75. package/src/engine/intelligence/blackboard/BlackboardDynamicStorageAdapter.js +3 -3
  76. package/src/engine/intelligence/mcts/MonteCarlo.js +3 -3
  77. package/src/engine/knowledge/database/StaticKnowledgeDataTable.js +3 -3
  78. package/src/engine/network/PriorityFetch.js +2 -2
  79. package/src/engine/options/Option.js +2 -2
  80. package/src/engine/options/Option.spec.js +1 -1
  81. package/src/engine/options/OptionGroup.js +2 -2
  82. package/src/engine/options/OptionGroup.spec.js +2 -2
  83. package/src/engine/save/Storage.js +2 -1
  84. package/src/engine/save/StorageBackedList.js +2 -1
  85. package/src/engine/save/storage/InMemoryStorage.js +2 -2
  86. package/src/engine/scene/transitionToScene.js +2 -1
  87. package/src/engine/sound/ecs/SoundListenerSystem.js +7 -7
  88. package/src/engine/sound/ecs/emitter/loadSoundTrackAsset.js +3 -3
  89. package/src/engine/ui/DraggableAspect.js +2 -2
  90. package/src/engine/ui/GUIEngine.js +17 -17
  91. package/src/engine/ui/notification/AnimatedObjectEmitter.js +3 -3
  92. package/src/engine/ui/notification/NotificationManager.js +4 -4
  93. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +9 -9
  94. package/src/generation/grid/generation/util/buildPathFromDistanceMap.js +1 -1
  95. package/src/generation/markers/actions/util/GridCellActionDebugBreak.js +1 -1
  96. package/src/view/common/LabelView.js +9 -9
  97. package/src/view/common/ListView.js +3 -2
  98. package/src/view/common/VirtualListView.js +7 -6
  99. package/src/view/common/dnd/DropTarget.js +2 -2
  100. package/src/view/elements/DropDownSelectionView.js +2 -2
  101. package/src/view/elements/image/ImageView.js +4 -4
  102. package/src/view/elements/progress/SmoothProgressBar.js +4 -4
  103. package/src/view/elements/radial/RadialMenuElementDefinition.js +1 -1
  104. package/src/view/elements/tiles2d/TileGrid.js +8 -8
  105. package/src/view/elements/video/VideoView.js +5 -5
  106. package/src/view/math/FunctionGraphView.js +1 -1
  107. package/src/view/tooltip/gml/TooltipParser.js +6 -5
  108. package/src/core/function/Functions.js +0 -103
@@ -1,9 +1,9 @@
1
- import { TypeEditor } from "../../TypeEditor.js";
2
1
  import List from "../../../../../src/core/collection/list/List.js";
2
+ import { noop } from "../../../../../src/core/function/noop.js";
3
3
  import { FieldDescriptor } from "../../FieldDescriptor.js";
4
4
  import { FieldValueAdapter } from "../../FieldValueAdapter.js";
5
+ import { TypeEditor } from "../../TypeEditor.js";
5
6
  import { ListEditor } from "../collection/ListEditor.js";
6
- import { noop } from "../../../../../src/core/function/Functions.js";
7
7
 
8
8
  export class ArrayEditor extends TypeEditor {
9
9
  inline = false;
@@ -1,5 +1,5 @@
1
+ import { noop } from "../src/core/function/noop.js";
1
2
  import Editor from "./Editor.js";
2
- import { noop } from "../src/core/function/Functions.js";
3
3
 
4
4
  /**
5
5
  *
@@ -3,38 +3,38 @@
3
3
  */
4
4
 
5
5
 
6
- import View from "../../src/view/View.js";
6
+ import { passThrough } from "../../src/core/function/passThrough.js";
7
+ import { SurfacePoint3 } from "../../src/core/geom/3d/SurfacePoint3.js";
8
+ import Vector2 from "../../src/core/geom/Vector2.js";
9
+ import Vector3 from "../../src/core/geom/Vector3.js";
10
+ import { ProcessState } from "../../src/core/process/ProcessState.js";
11
+ import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
12
+ import { Transform } from "../../src/engine/ecs/transform/Transform.js";
13
+ import Mesh from "../../src/engine/graphics/ecs/mesh/Mesh.js";
14
+ import { MeshEvents } from "../../src/engine/graphics/ecs/mesh/MeshEvents.js";
15
+ import { make_ray_from_viewport_position } from "../../src/engine/graphics/make_ray_from_viewport_position.js";
16
+ import LabelView from '../../src/view/common/LabelView.js';
17
+ import ListView from "../../src/view/common/ListView.js";
18
+ import VirtualListView from '../../src/view/common/VirtualListView.js';
7
19
  import dom from "../../src/view/DOM.js";
20
+ import BottomLeftResizeHandleView from "../../src/view/elements/BottomLeftResizeHandleView.js";
8
21
 
9
- import EntityListView from './ecs/EntityList.js';
10
- import EntityEditorView from './ecs/EntityEditor.js';
22
+ import SimpleWindow from '../../src/view/elements/SimpleWindow.js';
23
+ import View from "../../src/view/View.js";
24
+ import ComponentAddAction from "../actions/concrete/ComponentAddAction.js";
25
+ import EntityCreateAction from "../actions/concrete/EntityCreateAction.js";
26
+ import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
27
+ import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
11
28
  import ComponentControlFactory from './ecs/ComponentControlFactory.js';
12
- import VirtualListView from '../../src/view/common/VirtualListView.js';
13
- import LabelView from '../../src/view/common/LabelView.js';
14
- import ToolView from './tools/ToolView.js';
29
+ import EntityEditorView from './ecs/EntityEditor.js';
15
30
 
16
- import SimpleWindow from '../../src/view/elements/SimpleWindow.js';
17
- import ToolSettingsView from "./tools/ToolSettingsView.js";
31
+ import EntityListView from './ecs/EntityList.js';
18
32
  import GridPickCoordinateView from "./GridPickCoordinateView.js";
19
- import ListView from "../../src/view/common/ListView.js";
20
- import ProcessView from "./process/ProcessView.js";
21
33
  import MeshLibraryView from "./library/MeshLibraryView.js";
22
- import BottomLeftResizeHandleView from "../../src/view/elements/BottomLeftResizeHandleView.js";
23
- import Vector2 from "../../src/core/geom/Vector2.js";
24
- import Vector3 from "../../src/core/geom/Vector3.js";
25
- import Mesh from "../../src/engine/graphics/ecs/mesh/Mesh.js";
26
- import { Transform } from "../../src/engine/ecs/transform/Transform.js";
27
- import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
28
- import EntityCreateAction from "../actions/concrete/EntityCreateAction.js";
29
- import ComponentAddAction from "../actions/concrete/ComponentAddAction.js";
30
- import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
31
- import { passThrough } from "../../src/core/function/Functions.js";
32
- import { ProcessState } from "../../src/core/process/ProcessState.js";
33
- import { MeshEvents } from "../../src/engine/graphics/ecs/mesh/MeshEvents.js";
34
- import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
35
- import { SurfacePoint3 } from "../../src/core/geom/3d/SurfacePoint3.js";
36
- import { make_ray_from_viewport_position } from "../../src/engine/graphics/make_ray_from_viewport_position.js";
37
34
  import { makeEntityDecorators } from "./makeEntityDecorators.js";
35
+ import ProcessView from "./process/ProcessView.js";
36
+ import ToolSettingsView from "./tools/ToolSettingsView.js";
37
+ import ToolView from './tools/ToolView.js';
38
38
 
39
39
 
40
40
  class ViewManager extends View {
@@ -1,20 +1,20 @@
1
- import DatGuiController from "../DatGuiController.js";
2
- import { BlendingType } from "../../../../../src/engine/graphics/texture/sampler/BlendingType.js";
3
- import { ParticleLayer } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
4
- import ParticleLayerController from "./ParticleLayerController.js";
1
+ import { noop } from "../../../../../src/core/function/noop.js";
2
+ import ObservedValue from "../../../../../src/core/model/ObservedValue.js";
5
3
  import {
6
4
  ParticleEmitterFlag
7
5
  } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js";
8
- import { NativeListController } from "../../../../../src/view/controller/controls/NativeListController.js";
9
- import EmptyView from "../../../../../src/view/elements/EmptyView.js";
10
- import ObservedValue from "../../../../../src/core/model/ObservedValue.js";
11
- import { noop } from "../../../../../src/core/function/Functions.js";
12
- import {
13
- SimulationStepType
14
- } from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepType.js";
6
+ import { ParticleLayer } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
15
7
  import {
16
8
  SimulationStepDefinition
17
9
  } from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepDefinition.js";
10
+ import {
11
+ SimulationStepType
12
+ } from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepType.js";
13
+ import { BlendingType } from "../../../../../src/engine/graphics/texture/sampler/BlendingType.js";
14
+ import { NativeListController } from "../../../../../src/view/controller/controls/NativeListController.js";
15
+ import EmptyView from "../../../../../src/view/elements/EmptyView.js";
16
+ import DatGuiController from "../DatGuiController.js";
17
+ import ParticleLayerController from "./ParticleLayerController.js";
18
18
 
19
19
 
20
20
  /**
@@ -1,13 +1,13 @@
1
- import View from "../../../src/view/View.js";
2
- import { PortView } from "./PortView.js";
3
- import EmptyView from "../../../src/view/elements/EmptyView.js";
4
- import LabelView from "../../../src/view/common/LabelView.js";
5
- import { DraggableAspect } from "../../../src/engine/ui/DraggableAspect.js";
1
+ import { noop } from "../../../src/core/function/noop.js";
6
2
  import Vector2 from "../../../src/core/geom/Vector2.js";
7
- import { noop } from "../../../src/core/function/Functions.js";
8
3
  import { NodeParameterDataType } from "../../../src/core/model/node-graph/node/parameter/NodeParameterDataType.js";
9
- import DatGuiController from "../ecs/components/DatGuiController.js";
10
4
  import { PortDirection } from "../../../src/core/model/node-graph/node/PortDirection.js";
5
+ import { DraggableAspect } from "../../../src/engine/ui/DraggableAspect.js";
6
+ import LabelView from "../../../src/view/common/LabelView.js";
7
+ import EmptyView from "../../../src/view/elements/EmptyView.js";
8
+ import View from "../../../src/view/View.js";
9
+ import DatGuiController from "../ecs/components/DatGuiController.js";
10
+ import { PortView } from "./PortView.js";
11
11
 
12
12
  export class NodeView extends View {
13
13
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.81.4",
8
+ "version": "2.82.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,27 +1,28 @@
1
- import { EngineHarness } from "../../src/engine/EngineHarness.js";
2
- import EmptyView from "../../src/view/elements/EmptyView.js";
3
- import { EngineConfiguration } from "../../src/engine/EngineConfiguration.js";
4
- import { ArrayBufferLoader } from "../../src/engine/asset/loaders/ArrayBufferLoader.js";
5
- import { TerrainFlags } from "../../src/engine/ecs/terrain/ecs/TerrainFlags.js";
6
- import Signal from "../../src/core/events/signal/Signal.js";
7
- import { NativeListController } from "../../src/view/controller/controls/NativeListController.js";
8
- import { TerrainLayer } from "../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
9
- import CheckersTextureURI from "../../src/engine/graphics/texture/CheckersTextureURI.js";
10
- import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
11
- import { Cache } from "../../src/core/cache/Cache.js";
12
- import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
13
- import { noop, strictEquals } from "../../src/core/function/Functions.js";
14
- import { sampler2d_scale } from "../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
15
- import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
16
1
  import { BinaryDataType } from "../../src/core/binary/type/BinaryDataType.js";
17
2
  import {
18
3
  compute_typed_array_constructor_from_data_type
19
4
  } from "../../src/core/binary/type/DataType2TypedArrayConstructorMapping.js";
20
- import { copy_Sampler2D_channel_data } from "../../src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js";
5
+ import { Cache } from "../../src/core/cache/Cache.js";
6
+ import Signal from "../../src/core/events/signal/Signal.js";
7
+ import { noop } from "../../src/core/function/noop.js";
8
+ import { strictEquals } from "../../src/core/function/strictEquals.js";
9
+ import { computeStringHash } from "../../src/core/primitives/strings/computeStringHash.js";
10
+ import { ArrayBufferLoader } from "../../src/engine/asset/loaders/ArrayBufferLoader.js";
21
11
  import { TextureAssetLoader } from "../../src/engine/asset/loaders/texture/TextureAssetLoader.js";
22
- import { CanvasView } from "../../src/view/elements/CanvasView.js";
23
- import convertSampler2D2Canvas from "../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
12
+ import { TerrainLayer } from "../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
13
+ import { TerrainFlags } from "../../src/engine/ecs/terrain/ecs/TerrainFlags.js";
14
+ import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
15
+ import { EngineConfiguration } from "../../src/engine/EngineConfiguration.js";
16
+ import { EngineHarness } from "../../src/engine/EngineHarness.js";
24
17
  import { load_and_set_cubemap_v0 } from "../../src/engine/graphics/load_and_set_cubemap_v0.js";
18
+ import CheckersTextureURI from "../../src/engine/graphics/texture/CheckersTextureURI.js";
19
+ import { copy_Sampler2D_channel_data } from "../../src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js";
20
+ import { sampler2d_scale } from "../../src/engine/graphics/texture/sampler/resize/sampler2d_scale.js";
21
+ import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
22
+ import convertSampler2D2Canvas from "../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
23
+ import { NativeListController } from "../../src/view/controller/controls/NativeListController.js";
24
+ import { CanvasView } from "../../src/view/elements/CanvasView.js";
25
+ import EmptyView from "../../src/view/elements/EmptyView.js";
25
26
 
26
27
  const engineHarness = new EngineHarness();
27
28
 
@@ -1,9 +1,11 @@
1
1
  import { assert } from "../assert.js";
2
+ import { collectIteratorValueToArray } from "../collection/collectIteratorValueToArray.js";
2
3
  import { HashMap } from "../collection/map/HashMap.js";
3
4
  import Signal from "../events/signal/Signal.js";
4
- import { returnOne, returnZero, strictEquals } from "../function/Functions.js";
5
+ import { returnOne } from "../function/returnOne.js";
6
+ import { returnZero } from "../function/returnZero.js";
7
+ import { strictEquals } from "../function/strictEquals.js";
5
8
  import { CacheElement } from "./CacheElement.js";
6
- import { collectIteratorValueToArray } from "../collection/collectIteratorValueToArray.js";
7
9
 
8
10
  // TODO validate hashes of held elements to keep them up to date. Keys are assumed to be immutable, but this assumption may be broken by users
9
11
 
@@ -1,6 +1,6 @@
1
1
  import { jest } from "@jest/globals";
2
+ import { returnOne } from "../function/returnOne.js";
2
3
  import { Cache } from "./Cache.js";
3
- import { returnOne } from "../function/Functions.js";
4
4
 
5
5
  test("constructor doesn't throw", () => {
6
6
  new Cache({});
@@ -1,5 +1,7 @@
1
- import {strictEquals} from "../../function/Functions.js";
2
- import {arrayIndexByEquality} from "./arrayIndexByEquality.js";
1
+ import { assert } from "../../assert.js";
2
+
3
+ import { strictEquals } from "../../function/strictEquals.js";
4
+ import { arrayIndexByEquality } from "./arrayIndexByEquality.js";
3
5
 
4
6
  /**
5
7
  * Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
@@ -10,6 +12,10 @@ import {arrayIndexByEquality} from "./arrayIndexByEquality.js";
10
12
  * @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
11
13
  */
12
14
  export function arraySetDiff(a, b, equals = strictEquals) {
15
+ assert.isArray(a, 'a');
16
+ assert.isArray(b, 'b');
17
+ assert.isFunction(equals, 'equals');
18
+
13
19
  // TODO we can do this faster if we use a comparator instead of equality and pre-sort the data
14
20
  const uniqueA = a.slice();
15
21
  const uniqueB = b.slice();
@@ -1,4 +1,4 @@
1
- import { returnZero } from "../../function/Functions.js";
1
+ import { returnZero } from "../../function/returnZero.js";
2
2
  import { HashMap } from "../map/HashMap.js";
3
3
 
4
4
  /**
@@ -1,5 +1,7 @@
1
+ import { passThrough } from "../../function/passThrough.js";
2
+ import { returnOne } from "../../function/returnOne.js";
3
+ import { returnZero } from "../../function/returnZero.js";
1
4
  import { weightedRandomFromArray } from "./weightedRandomFromArray.js";
2
- import { passThrough, returnOne, returnZero } from "../../function/Functions.js";
3
5
 
4
6
  test("empty array", () => {
5
7
  expect(weightedRandomFromArray([], returnZero, passThrough, null, 0))
@@ -1,7 +1,8 @@
1
+ import { passThrough } from "../../function/passThrough.js";
2
+ import { returnZero } from "../../function/returnZero.js";
3
+ import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
1
4
  import { seededRandom } from "../../math/random/seededRandom.js";
2
5
  import BinaryHeap from "./FastBinaryHeap.js";
3
- import { passThrough, returnZero } from "../../function/Functions.js";
4
- import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
5
6
 
6
7
  test("constructor doesn't throw", () => {
7
8
  new BinaryHeap(returnZero);
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { assert } from "../../assert.js";
7
7
  import Signal from "../../events/signal/Signal.js";
8
+ import { objectsEqual } from "../../function/objectsEqual.js";
8
9
  import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
9
10
  import { arrayIndexByEquality } from "../array/arrayIndexByEquality.js";
10
11
  import { arraySetDiff } from "../array/arraySetDiff.js";
@@ -190,13 +191,13 @@ class List {
190
191
  * Replace the data, replacements is performed surgically, meaning that diff is computed and add/remove operations are performed on the set
191
192
  * This method is tailored to work well with visualisation as only elements that's missing from the new set is removed, and only elements that are new to are added
192
193
  * Conversely, relevant events are dispatched that can observe. This results in fewer changes required to the visualisation
193
- * @param {T[]} newOutput
194
+ * @param {T[]} new_data
194
195
  */
195
- patch(newOutput) {
196
+ patch(new_data) {
196
197
 
197
198
  const data = this.data;
198
199
 
199
- const diff = arraySetDiff(data, newOutput, invokeObjectEquals);
200
+ const diff = arraySetDiff(data, new_data, objectsEqual);
200
201
 
201
202
  //resolve diff
202
203
  const removals = diff.uniqueA;
@@ -213,8 +214,8 @@ class List {
213
214
 
214
215
  //sort additions by their position in the input
215
216
  additions.sort((a, b) => {
216
- const ai = this.indexOf(a);
217
- const bi = this.indexOf(b);
217
+ const ai = new_data.indexOf(a);
218
+ const bi = new_data.indexOf(b);
218
219
 
219
220
  return bi - ai;
220
221
  });
@@ -225,11 +226,11 @@ class List {
225
226
  const item = additions[i];
226
227
 
227
228
  //find where the item is in the input
228
- const inputIndex = this.indexOf(item);
229
+ const inputIndex = new_data.indexOf(item);
229
230
 
230
231
  let p = 0;
231
232
  for (let i = inputIndex - 1; i >= 0; i--) {
232
- const prev = this.get(i);
233
+ const prev = new_data[i];
233
234
 
234
235
  //look for previous item in the output
235
236
  const j = this.indexOf(prev);
@@ -949,16 +950,6 @@ class List {
949
950
  }
950
951
  }
951
952
 
952
- /**
953
- *
954
- * @param {Object} a
955
- * @param {Object} b
956
- * @returns {boolean}
957
- */
958
- function objectsEqual(a, b) {
959
- return a === b || (typeof a.equals === "function" && a.equals(b));
960
- }
961
-
962
953
  function conditionEqualsViaMethod(v) {
963
954
  return this === v || this.equals(v);
964
955
  }
@@ -94,6 +94,27 @@ test("'set' at the end of the list", () => {
94
94
  expect(addHandler).toHaveBeenLastCalledWith(42, 0);
95
95
  });
96
96
 
97
+ test("'set' replace existing value", () => {
98
+ const list = new List();
99
+
100
+ const fn = jest.fn();
101
+
102
+ list.on.removed.add(fn);
103
+
104
+ list.set(0, "a");
105
+
106
+ expect(fn).not.toHaveBeenCalled();
107
+
108
+ list.set(0, "b");
109
+
110
+ expect(list.length).toBe(1);
111
+
112
+ expect(list.get(0)).toBe("b");
113
+
114
+ expect(fn).toHaveBeenCalledTimes(1);
115
+ expect(fn).toHaveBeenCalledWith("a", 0);
116
+ });
117
+
97
118
  test("add increases length", () => {
98
119
  const list = new List();
99
120
 
@@ -200,3 +221,37 @@ test("map", () => {
200
221
 
201
222
  expect(list.map(a => a * 7)).toEqual([7, 14, 21]);
202
223
  });
224
+
225
+ test("patch", () => {
226
+
227
+ /**
228
+ *
229
+ * @type {List<number>}
230
+ */
231
+ const list = new List();
232
+
233
+ list.patch([]);
234
+
235
+ expect(list.asArray()).toEqual([]);
236
+ expect(list.length).toBe(0);
237
+
238
+ list.patch([1]);
239
+
240
+ expect(list.asArray()).toEqual([1]);
241
+ expect(list.length).toBe(1);
242
+
243
+ list.patch([1, 2]);
244
+
245
+ expect(list.asArray()).toEqual([1, 2]);
246
+ expect(list.length).toBe(2);
247
+
248
+ list.patch([3, 1, 2]);
249
+
250
+ expect(list.asArray()).toEqual([3, 1, 2]);
251
+ expect(list.length).toBe(3);
252
+
253
+ list.patch([3, 1, 2]);
254
+
255
+ expect(list.asArray()).toEqual([3, 1, 2]);
256
+ expect(list.length).toBe(3);
257
+ });
@@ -1,5 +1,7 @@
1
+ import { passThrough } from "../../function/passThrough.js";
2
+ import { returnOne } from "../../function/returnOne.js";
3
+ import { strictEquals } from "../../function/strictEquals.js";
1
4
  import { generate_next_linear_congruential_index, HashMap } from "./HashMap.js";
2
- import { passThrough, returnOne, strictEquals } from "../../function/Functions.js";
3
5
 
4
6
  /**
5
7
  *
@@ -0,0 +1,23 @@
1
+ import { strictEquals } from "../../function/strictEquals.js";
2
+ import { computeStringHash } from "../../primitives/strings/computeStringHash.js";
3
+ import { HashSet } from "./HashSet.js";
4
+
5
+ test("constructor", () => {
6
+ const set = new HashSet();
7
+ });
8
+
9
+ test("add same element twice", () => {
10
+
11
+ const set = new HashSet({
12
+ keyHashFunction: computeStringHash,
13
+ keyEqualityFunction: strictEquals
14
+ });
15
+
16
+ set.add("a");
17
+
18
+ expect(set.size).toBe(1);
19
+
20
+ set.add("a");
21
+
22
+ expect(set.size).toBe(1);
23
+ });
@@ -1,4 +1,4 @@
1
- import { passThrough } from "../../function/Functions.js";
1
+ import { passThrough } from "../../function/passThrough.js";
2
2
  import Signal from "./Signal.js";
3
3
 
4
4
  /**
@@ -1,6 +1,7 @@
1
1
  import { dispatchViaProxy, findSignalHandlerIndexByHandle } from "../../events/signal/Signal.js";
2
2
  import { SignalHandler } from "../../events/signal/SignalHandler.js";
3
- import { noop } from "../../function/Functions.js";
3
+
4
+ import { noop } from "../../function/noop.js";
4
5
  import { SimpleStateMachineDescription } from "./SimpleStateMachineDescription.js";
5
6
 
6
7
  export class SimpleStateMachine {
@@ -0,0 +1,19 @@
1
+ /**
2
+ *
3
+ * @param {...function} processes
4
+ * @returns {function(*): *}
5
+ */
6
+ export function chain(...processes) {
7
+ const numProcesses = processes.length;
8
+
9
+ return function chain(v) {
10
+ let result = v;
11
+
12
+ for (let i = 0; i < numProcesses; i++) {
13
+ const process = processes[i];
14
+ result = process(result);
15
+ }
16
+
17
+ return result;
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @template T
3
+ * @param {T} v
4
+ * @returns {function():T}
5
+ */
6
+ export function makeReturnValue(v) {
7
+ return () => v;
8
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * No-operation function. Does nothing. Useful when a callback is required to avoid checks for a missing function.
3
+ * @param {*} arguments
4
+ */
5
+ export function noop() {
6
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {Object} a
4
+ * @param {Object} b
5
+ * @returns {boolean}
6
+ */
7
+ export function objectsEqual(a, b) {
8
+ return a === b
9
+ || (
10
+ typeof a === "object" //guard against null and undefined values
11
+ && typeof a.equals === "function" // check for equals method
12
+ && a.equals(b)
13
+ );
14
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns value that's pass in
3
+ * @template A
4
+ * @param {A} a
5
+ * @returns {A}
6
+ */
7
+ export function passThrough(a) {
8
+ return a;
9
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @template T
3
+ * @returns {T[]}
4
+ */
5
+ export function returnEmptyArray() {
6
+ return [];
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns boolean false value.
3
+ * @returns {boolean} always false
4
+ */
5
+ export function returnFalse() {
6
+ return false;
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @returns {number} always 1
4
+ */
5
+ export function returnOne() {
6
+ return 1;
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns boolean true value.
3
+ * @returns {boolean} always true
4
+ */
5
+ export function returnTrue() {
6
+ return true;
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @returns {number} always 0
4
+ */
5
+ export function returnZero() {
6
+ return 0;
7
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Executes strict equality check, a === b
3
+ * @template A
4
+ * @param {A} a
5
+ * @param {A} b
6
+ * @returns {boolean}
7
+ */
8
+ export function strictEquals(a, b) {
9
+ return a === b;
10
+ }
@@ -1,6 +1,6 @@
1
- import { tetrahedron_compute_signed_volume } from "./tetrahedron_compute_signed_volume.js";
2
- import { noop } from "../../../function/Functions.js";
1
+ import { noop } from "../../../function/noop.js";
3
2
  import { INVALID_NEIGHBOUR } from "./TetrahedralMesh.js";
3
+ import { tetrahedron_compute_signed_volume } from "./tetrahedron_compute_signed_volume.js";
4
4
 
5
5
  /**
6
6
  *
@@ -1,12 +1,13 @@
1
1
  import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
2
- import { noop } from "../../../../function/Functions.js";
3
- import { bt_index_geometry_to_topology } from "./binary/io/bt_index_geometry_to_topology.js";
4
- import { BinaryTopology } from "./binary/BinaryTopology.js";
5
2
  import {
6
3
  compute_buffer_geometry_byte_size
7
4
  } from "../../../../../engine/graphics/geometry/buffered/compute_buffer_geometry_byte_size.js";
8
- import { TopoMesh } from "./TopoMesh.js";
5
+
6
+ import { noop } from "../../../../function/noop.js";
9
7
  import { number_pretty_print } from "../../../../primitives/numbers/number_pretty_print.js";
8
+ import { BinaryTopology } from "./binary/BinaryTopology.js";
9
+ import { bt_index_geometry_to_topology } from "./binary/io/bt_index_geometry_to_topology.js";
10
+ import { TopoMesh } from "./TopoMesh.js";
10
11
 
11
12
  function promise_ply(url) {
12
13
 
@@ -1,6 +1,7 @@
1
1
  import { assert } from "../../assert.js";
2
2
  import { Cache } from "../../cache/Cache.js";
3
- import { noop } from "../../function/Functions.js";
3
+
4
+ import { noop } from "../../function/noop.js";
4
5
  import { computeStringHash } from "../../primitives/strings/computeStringHash.js";
5
6
 
6
7
  export class AbstractCachingParser {
@@ -1,4 +1,5 @@
1
- import { returnOne, returnZero } from "../../function/Functions.js";
1
+ import { returnOne } from "../../function/returnOne.js";
2
+ import { returnZero } from "../../function/returnZero.js";
2
3
  import { randomFloatBetween } from "./randomFloatBetween.js";
3
4
 
4
5
  test("limits", () => {
@@ -1,5 +1,6 @@
1
+ import { returnOne } from "../../function/returnOne.js";
2
+ import { returnZero } from "../../function/returnZero.js";
1
3
  import { randomIntegerBetween } from "./randomIntegerBetween.js";
2
- import { returnOne, returnZero } from "../../function/Functions.js";
3
4
 
4
5
  test("limits", () => {
5
6
  expect(randomIntegerBetween(returnZero, -3, 7)).toEqual(-3);