@woosh/meep-engine 2.53.0 → 2.55.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 (149) hide show
  1. package/package.json +1 -1
  2. package/src/core/__module.js +1 -1
  3. package/src/core/cache/Cache.js +1 -1
  4. package/src/core/collection/Stack.js +11 -14
  5. package/src/core/collection/array/array_contains_duplicates.js +5 -2
  6. package/src/core/collection/array/array_contains_duplicates.spec.js +14 -0
  7. package/src/core/collection/array/array_copy_entire.js +6 -11
  8. package/src/core/collection/array/array_get_index_in_range.js +5 -0
  9. package/src/core/collection/array/array_get_index_in_range.spec.js +16 -0
  10. package/src/core/collection/array/groupArrayBy.js +1 -1
  11. package/src/core/collection/array/isArrayEqual.js +4 -1
  12. package/src/core/collection/array/randomizeArrayElementOrder.js +1 -0
  13. package/src/core/collection/array/randomizeArrayElementOrder.spec.js +27 -0
  14. package/src/core/collection/heap/Uin32Heap.spec.js +64 -0
  15. package/src/core/collection/heap/Uint32Heap.js +6 -2
  16. package/src/core/collection/list/List.js +1 -0
  17. package/src/core/collection/{HashMap.js → map/HashMap.js} +10 -10
  18. package/src/core/collection/{HashMap.spec.js → map/HashMap.spec.js} +1 -1
  19. package/src/core/collection/{ObservedMap.js → map/ObservedMap.js} +1 -1
  20. package/src/core/collection/{HashSet.js → set/HashSet.js} +4 -3
  21. package/src/core/collection/{Set.d.ts → set/Set.d.ts} +1 -1
  22. package/src/core/collection/{Set.js → set/Set.js} +17 -14
  23. package/src/core/geom/2d/aabb/AABB2.js +1 -1
  24. package/src/core/geom/3d/aabb/AABB3.js +3 -1
  25. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_calc_edges.js +1 -1
  26. package/src/core/model/ObservedInteger.js +12 -7
  27. package/src/core/model/ObservedString.js +10 -8
  28. package/src/core/model/node-graph/visual/NodeGraphVisualData.js +1 -1
  29. package/src/core/model/object/ImmutableObjectPool.js +1 -1
  30. package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +1 -1
  31. package/src/engine/EngineConfiguration.js +24 -25
  32. package/src/engine/asset/AssetManager.js +3 -3
  33. package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
  34. package/src/engine/ecs/EntityBlueprint.js +10 -14
  35. package/src/engine/ecs/EntityComponentDataset.spec.js +77 -0
  36. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +2 -5
  37. package/src/engine/ecs/components/Motion.js +0 -27
  38. package/src/engine/ecs/components/MotionSerializationAdapter.js +26 -0
  39. package/src/engine/ecs/components/PropertySet.js +0 -29
  40. package/src/engine/ecs/components/PropertySetSerializationAdapter.js +29 -0
  41. package/src/engine/ecs/components/SerializationMetadata.js +0 -28
  42. package/src/engine/ecs/components/SerializationMetadataSerializationAdapter.js +26 -0
  43. package/src/engine/ecs/components/Steering.js +0 -35
  44. package/src/engine/ecs/components/SteeringSerializationAdapter.js +34 -0
  45. package/src/engine/ecs/components/Tag.js +6 -102
  46. package/src/engine/ecs/components/TagSerializationAdapter.js +44 -0
  47. package/src/engine/ecs/components/TagSerializationUpgrader_0_1.js +18 -0
  48. package/src/engine/ecs/components/Timer.js +1 -1
  49. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +1 -1
  50. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleCooldownDescription.js +10 -14
  51. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +31 -39
  52. package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescriptionTable.js +1 -1
  53. package/src/engine/ecs/dynamic_actions/{DynamicRuleDescriptionTable.spec.js → rules/DynamicRuleDescriptionTable.spec.js} +12 -12
  54. package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +2 -5
  55. package/src/engine/ecs/fow/serialization/FogOfWarRevealerSerializationAdapter.js +2 -5
  56. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +5 -8
  57. package/src/engine/ecs/gui/GUIElementSerializationAdapter.js +2 -5
  58. package/src/engine/ecs/gui/hud/HeadsUpDisplaySerializationAdapter.js +3 -6
  59. package/src/engine/ecs/gui/position/ViewportPosition.js +2 -5
  60. package/src/engine/ecs/ik/IKConstraint.js +95 -0
  61. package/src/engine/ecs/ik/InverseKinematics.js +10 -169
  62. package/src/engine/ecs/ik/InverseKinematicsSerializationAdapter.js +72 -0
  63. package/src/engine/ecs/speaker/Voice.js +5 -8
  64. package/src/engine/ecs/speaker/VoiceSystem.js +15 -19
  65. package/src/engine/ecs/speaker/lines/LineDescription.js +20 -25
  66. package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +15 -19
  67. package/src/engine/ecs/storage/binary/BinaryClassSerializationAdapter.js +7 -0
  68. package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +1 -1
  69. package/src/engine/ecs/storage/binary/object/ObjectBasedClassSerializationAdapter.js +6 -9
  70. package/src/engine/ecs/team/TeamSerializationAdapter.js +2 -5
  71. package/src/engine/ecs/terrain/ecs/Terrain.spec.js +5 -0
  72. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +23 -21
  73. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +2 -5
  74. package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +2 -40
  75. package/src/engine/ecs/terrain/overlay/TerrainOverlay.spec.js +6 -0
  76. package/src/engine/ecs/terrain/serialization/TerrainSerializationAdapter.js +7 -10
  77. package/src/engine/ecs/terrain/tiles/TerrainTile.js +79 -76
  78. package/src/engine/ecs/terrain/tiles/TerrainTile.spec.js +25 -0
  79. package/src/engine/ecs/tooltip/TooltipComponent.spec.js +47 -0
  80. package/src/engine/ecs/tooltip/TooltipComponentSerializationAdapter.js +2 -5
  81. package/src/engine/ecs/transform/Transform.spec.js +52 -0
  82. package/src/engine/ecs/transform/TransformSerializationAdapter.js +2 -5
  83. package/src/engine/ecs/transform-attachment/TransformAttachment.js +18 -19
  84. package/src/engine/graphics/ecs/animation/AnimationController.js +20 -129
  85. package/src/engine/graphics/ecs/animation/AnimationControllerSerializationAdapter.js +27 -0
  86. package/src/engine/graphics/ecs/animation/AnimationRule.js +79 -0
  87. package/src/engine/graphics/ecs/animation/animator/graph/AnimationGraphSerializationAdapter.js +9 -11
  88. package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionSerializationAdapter.js +3 -5
  89. package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +2 -5
  90. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSerializationAdapter.js +2 -6
  91. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraLander.js +3 -15
  92. package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +2 -4
  93. package/src/engine/graphics/ecs/highlight/HighlightSerializationAdapter.js +2 -5
  94. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +1 -1
  95. package/src/engine/graphics/ecs/light/LightSerializationAdapter.js +2 -5
  96. package/src/engine/graphics/ecs/mesh/serialization/MeshSerializationAdapter.js +2 -5
  97. package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +3 -0
  98. package/src/engine/graphics/ecs/mesh-v2/render/adapters/InstancedRendererAdapter.js +1 -1
  99. package/src/engine/graphics/ecs/water/WaterSerializationAdapter.js +2 -5
  100. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  101. package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +1 -1
  102. package/src/engine/graphics/material/manager/MaterialManager.js +1 -1
  103. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -1
  104. package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +1 -1
  105. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -5
  106. package/src/engine/graphics/particles/particular/engine/emitter/serde/ParticleEmitterSerializationAdapter.js +2 -5
  107. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +1 -1
  108. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +1 -1
  109. package/src/engine/graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js +2 -5
  110. package/src/engine/grid/grid2transform/GridPosition2Transform.js +11 -13
  111. package/src/engine/grid/grid2transform/GridPosition2TransformSerializationAdapter.js +3 -5
  112. package/src/engine/grid/obstacle/GridObstacleSerializationAdapter.js +2 -5
  113. package/src/engine/grid/position/GridPositionSerializationAdapter.js +2 -5
  114. package/src/engine/grid/transform2grid/Transform2GridPosition.js +10 -13
  115. package/src/engine/input/devices/KeyboardDevice.js +5 -2
  116. package/src/engine/input/devices/KeyboardDevice.spec.js +12 -0
  117. package/src/engine/input/devices/PointerDevice.js +5 -1
  118. package/src/engine/input/ecs/components/Input.js +37 -11
  119. package/src/engine/input/ecs/ism/InputBinding.js +30 -12
  120. package/src/engine/intelligence/behavior/ecs/BehaviorComponentSerializationAdapter.js +7 -10
  121. package/src/engine/intelligence/behavior/ecs/WaitForEventBehaviorSerializationAdapter.js +2 -5
  122. package/src/engine/intelligence/behavior/primitive/FailingBehaviorSerializationAdapter.js +2 -6
  123. package/src/engine/intelligence/behavior/primitive/SucceedingBehaviorSerializationAdapter.js +2 -5
  124. package/src/engine/intelligence/blackboard/BlackboardSerializationAdapter.js +2 -5
  125. package/src/engine/knowledge/database/StaticKnowledgeDatabase.js +12 -13
  126. package/src/engine/knowledge/database/StaticKnowledgeDatabase.spec.js +23 -0
  127. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +2 -5
  128. package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +2 -5
  129. package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +25 -0
  130. package/src/engine/options/OptionAbstract.js +6 -5
  131. package/src/engine/options/OptionGroup.js +13 -25
  132. package/src/engine/options/OptionGroup.spec.js +61 -0
  133. package/src/engine/platform/EnginePlatform.js +0 -4
  134. package/src/engine/save/storage/InMemoryStorage.js +3 -2
  135. package/src/engine/sound/ecs/SoundController.js +2 -6
  136. package/src/engine/sound/ecs/SoundListener.js +3 -21
  137. package/src/engine/sound/ecs/emitter/SoundEmitterSerializationAdapter.js +2 -6
  138. package/src/generation/theme/ThemeEngine.js +1 -1
  139. package/src/core/collection/LazyStream.js +0 -23
  140. package/src/core/collection/LazyStream.spec.js +0 -13
  141. package/src/core/collection/heap/BinaryHeap.js +0 -153
  142. package/src/engine/InputEngine.js +0 -94
  143. package/src/engine/PointerLock.js +0 -60
  144. package/src/engine/ecs/components/GeometryBVH.js +0 -44
  145. package/src/engine/ecs/systems/GeometryBVHSystem.js +0 -36
  146. package/src/engine/ecs/terrain/ecs/layers/loadLegacyTerrainLayers.js +0 -99
  147. package/src/engine/ecs/terrain/ecs/splat/loadLegacyTerrainSplats.js +0 -73
  148. /package/src/core/collection/{HashMap.d.ts → map/HashMap.d.ts} +0 -0
  149. /package/src/core/collection/{HashSet.d.ts → set/HashSet.d.ts} +0 -0
@@ -52,25 +52,21 @@ const TIMING_MINIMUM_READ_TIME = 1.2;
52
52
  const temp_lines = [];
53
53
 
54
54
  class LineWeigher {
55
- constructor() {
56
-
57
- /**
58
- *
59
- * @type {number}
60
- */
61
- this.entity = -1;
62
- /**
63
- *
64
- * @type {VoiceSystem}
65
- */
66
- this.system = null;
67
-
68
- /**
69
- *
70
- * @type {number}
71
- */
72
- this.time = 0;
73
- }
55
+ /**
56
+ *
57
+ * @type {number}
58
+ */
59
+ entity = -1;
60
+ /**
61
+ *
62
+ * @type {VoiceSystem}
63
+ */
64
+ system = null;
65
+ /**
66
+ *
67
+ * @type {number}
68
+ */
69
+ time = 0;
74
70
 
75
71
  /**
76
72
  *
@@ -1,31 +1,26 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
 
3
3
  export class LineDescription {
4
- constructor() {
5
- /**
6
- * Unique id
7
- * @type {string}
8
- */
9
- this.id = "";
10
-
11
- /**
12
- * Comment about the line, useful for development purposes
13
- * @type {string}
14
- */
15
- this.comment = "";
16
-
17
- /**
18
- * Localization key for the line of text
19
- * @type {string}
20
- */
21
- this.text = "";
22
-
23
- /**
24
- * Time the line should be displayed on the screen before being removed, normalized value, 1 means standard, 1.5 means 50% longer
25
- * @type {number}
26
- */
27
- this.displayDuration = 1;
28
- }
4
+ /**
5
+ * Unique id
6
+ * @type {string}
7
+ */
8
+ id = "";
9
+ /**
10
+ * Comment about the line, useful for development purposes
11
+ * @type {string}
12
+ */
13
+ comment = "";
14
+ /**
15
+ * Localization key for the line of text
16
+ * @type {string}
17
+ */
18
+ text = "";
19
+ /**
20
+ * Time the line should be displayed on the screen before being removed, normalized value, 1 means standard, 1.5 means 50% longer
21
+ * @type {number}
22
+ */
23
+ displayDuration = 1;
29
24
 
30
25
  fromJSON({
31
26
  id,
@@ -1,25 +1,21 @@
1
1
  const temp_array = [];
2
2
 
3
3
  export class LineSetDescription {
4
- constructor() {
5
- /**
6
- *
7
- * @type {string}
8
- */
9
- this.id = "";
10
-
11
- /**
12
- *
13
- * @type {LineDescription[]}
14
- */
15
- this.lines = [];
16
-
17
- /**
18
- *
19
- * @type {LineSetDescription[]}
20
- */
21
- this.sets = [];
22
- }
4
+ /**
5
+ *
6
+ * @type {string}
7
+ */
8
+ id = "";
9
+ /**
10
+ *
11
+ * @type {LineDescription[]}
12
+ */
13
+ lines = [];
14
+ /**
15
+ *
16
+ * @type {LineSetDescription[]}
17
+ */
18
+ sets = [];
23
19
 
24
20
  /**
25
21
  * Collect all lines from this set recursively
@@ -1,12 +1,19 @@
1
+ /**
2
+ * Defines how to serialize and deserialize an instance of a given class
3
+ */
1
4
  export class BinaryClassSerializationAdapter {
2
5
 
3
6
  /**
7
+ * Class that this adapter handles
4
8
  * @protected
5
9
  * @type {Class}
6
10
  */
7
11
  klass = null;
8
12
 
9
13
  /**
14
+ * Format version number, used to check for format changes and data compatibility
15
+ * Increment the number if you change the adapter to indicate the change in format
16
+ * See {@link BinaryClassUpgrader} for details on how to handle support for outdated format versions
10
17
  * @protected
11
18
  * @type {number}
12
19
  */
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../../../../core/assert.js";
2
2
  import { BinaryCollectionHeaderCodec, BinaryCollectionHeaderLayout } from "./BinaryCollectionHeaderCodec.js";
3
- import { HashMap } from "../../../../../core/collection/HashMap.js";
3
+ import { HashMap } from "../../../../../core/collection/map/HashMap.js";
4
4
  import { returnEmptyArray } from "../../../../../core/function/Functions.js";
5
5
 
6
6
  export class BinaryCollectionSerializer {
@@ -1,15 +1,12 @@
1
1
  import { BinaryClassSerializationAdapter } from "../BinaryClassSerializationAdapter.js";
2
2
 
3
- export class ObjectBasedClassSerializationAdapter extends BinaryClassSerializationAdapter{
4
- constructor(){
5
- super();
3
+ export class ObjectBasedClassSerializationAdapter extends BinaryClassSerializationAdapter {
6
4
 
7
- /**
8
- *
9
- * @type {BinaryObjectSerializationAdapter}
10
- */
11
- this.objectAdapter = null;
12
- }
5
+ /**
6
+ *
7
+ * @type {BinaryObjectSerializationAdapter}
8
+ */
9
+ objectAdapter = null;
13
10
 
14
11
  /**
15
12
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSe
2
2
  import Team from "./Team.js";
3
3
 
4
4
  export class TeamSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = Team;
9
- this.version = 0;
10
- }
6
+ klass = Team;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -0,0 +1,5 @@
1
+ import Terrain from "./Terrain.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ new Terrain();
5
+ });
@@ -5,28 +5,30 @@ import Vector3 from "../../../../../core/geom/Vector3.js";
5
5
  import Quaternion from "../../../../../core/geom/Quaternion.js";
6
6
 
7
7
  class ClingToTerrain {
8
- constructor({ normalAlign = false } = {}) {
9
- /**
10
- * @type {boolean}
11
- */
12
- this.normalAlign = normalAlign;
13
-
14
- /**
15
- * Used internally for caching updates
16
- * @type {Vector3}
17
- */
18
- this.__lastPosition = new Vector3(0, 0, 0);
19
- /**
20
- *
21
- * @type {Quaternion}
22
- */
23
- this.__lastRotation = new Quaternion(0, 0, 0, 1);
8
+ /**
9
+ * @type {boolean}
10
+ */
11
+ normalAlign = false;
12
+ /**
13
+ * Used internally for caching updates
14
+ * @type {Vector3}
15
+ */
16
+ __lastPosition=new Vector3(0, 0, 0);
17
+ /**
18
+ *
19
+ * @type {Quaternion}
20
+ */
21
+ __lastRotation=new Quaternion(0, 0, 0, 1);
22
+ /**
23
+ * Speed in Rad/s (Radians/second) by which rotation can change
24
+ * @type {number}
25
+ */
26
+ rotationSpeed = 3;
24
27
 
25
- /**
26
- * Speed in Rad/s (Radians/second) by which rotation can change
27
- * @type {number}
28
- */
29
- this.rotationSpeed = 3;
28
+ constructor(opt) {
29
+ if(opt !== undefined){
30
+ throw new Error("constructor options deprecated");
31
+ }
30
32
  }
31
33
 
32
34
  toJSON() {
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../../storage/binary/BinaryC
2
2
  import ClingToTerrain from "./ClingToTerrain.js";
3
3
 
4
4
  export class ClingToTerrainSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = ClingToTerrain;
9
- this.version = 0;
10
- }
6
+ klass = ClingToTerrain;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -19,18 +19,15 @@ import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
19
19
  import { sampler2d_scale } from "../../../../graphics/texture/sampler/resize/sampler2d_scale.js";
20
20
  import List from "../../../../../core/collection/list/List.js";
21
21
  import { Cache } from "../../../../../core/cache/Cache.js";
22
- import { BinaryClassSerializationAdapter } from "../../../storage/binary/BinaryClassSerializationAdapter.js";
23
22
  import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
24
23
  import { invokeObjectEquals } from "../../../../../core/model/object/invokeObjectEquals.js";
25
24
  import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
26
25
  import { typed_array_copy } from "../../../../../core/collection/array/typed/typed_array_copy.js";
27
26
 
28
27
  class ScaledTextureKey {
29
- constructor() {
30
- this.uri = '';
28
+ uri = '';
31
29
 
32
- this.size = new Vector2();
33
- }
30
+ size = new Vector2();
34
31
 
35
32
  /**
36
33
  *
@@ -58,41 +55,6 @@ class ScaledTextureKey {
58
55
  }
59
56
  }
60
57
 
61
- class ScaledTextureKeySerializationAdapter extends BinaryClassSerializationAdapter {
62
- constructor() {
63
- super();
64
- this.klass = ScaledTextureKey;
65
- this.version = 0;
66
- }
67
-
68
- /**
69
- *
70
- * @param {BinaryBuffer} buffer
71
- * @param {ScaledTextureKey} value
72
- */
73
- serialize(buffer, value) {
74
- // serialize uri
75
- buffer.writeUTF8String(value.uri);
76
- // serialize size
77
- buffer.writeFloat64(value.size.x);
78
- buffer.writeFloat64(value.size.y);
79
- }
80
-
81
- /**
82
- *
83
- * @param {BinaryBuffer} buffer
84
- * @param {ScaledTextureKey} value
85
- */
86
- deserialize(buffer, value) {
87
- value.uri = buffer.readUTF8String();
88
-
89
- const size_x = buffer.readFloat64();
90
- const size_y = buffer.readFloat64();
91
-
92
- value.size.set(size_x, size_y);
93
- }
94
- }
95
-
96
58
  /**
97
59
  *
98
60
  * @type {Cache<ScaledTextureKey,Sampler2D>}
@@ -0,0 +1,6 @@
1
+ import { TerrainOverlay } from "./TerrainOverlay.js";
2
+ import Vector2 from "../../../../core/geom/Vector2.js";
3
+
4
+ test("constructor does not throw", () => {
5
+ new TerrainOverlay(new Vector2(1, 1))
6
+ });
@@ -7,18 +7,15 @@ import { objectKeyByValue } from "../../../../core/model/object/objectKeyByValue
7
7
  import { TerrainFlags } from "../ecs/TerrainFlags.js";
8
8
 
9
9
  export class TerrainSerializationAdapter extends BinaryClassSerializationAdapter {
10
- constructor() {
11
- super();
12
10
 
13
- this.klass = Terrain;
14
- this.version = 2;
11
+ klass = Terrain;
12
+ version = 2;
15
13
 
16
- /**
17
- *
18
- * @type {TerrainSystem}
19
- */
20
- this.system = null;
21
- }
14
+ /**
15
+ *
16
+ * @type {TerrainSystem}
17
+ */
18
+ system = null;
22
19
 
23
20
  initialize(system) {
24
21
  this.system = system;
@@ -33,98 +33,101 @@ import { passThrough } from "../../../../core/function/Functions.js";
33
33
  * terrain tile is a part of a 2d array
34
34
  */
35
35
  class TerrainTile {
36
- constructor() {
37
- this.gridPosition = new Vector2();
38
- this.scale = new Vector2(1, 1);
39
- this.size = new Vector2();
40
- this.position = new Vector2();
41
- this.resolution = new ObservedInteger(1);
36
+ gridPosition = new Vector2();
37
+ scale = new Vector2(1, 1);
38
+ size = new Vector2();
39
+ position = new Vector2();
40
+ resolution = new ObservedInteger(1);
42
41
 
43
- /**
44
- *
45
- * @type {Material}
46
- */
47
- this.material = null;
48
- this.mesh = ThreeFactory.createMesh();
42
+ /**
43
+ *
44
+ * @type {Material}
45
+ */
46
+ material = null;
47
+ mesh = ThreeFactory.createMesh();
49
48
 
50
- this.mesh.name = "TerrainTile";
51
49
 
52
- /**
53
- * Terrain mesh is static, it never changes its transform. Updates are wasteful.
54
- * @type {boolean}
55
- */
56
- this.mesh.matrixWorldNeedsUpdate = false;
50
+ /**
51
+ *
52
+ * @type {THREE.BufferGeometry}
53
+ */
54
+ geometry = null;
57
55
 
58
- /**
59
- *
60
- * @type {THREE.BufferGeometry}
61
- */
62
- this.geometry = null;
56
+ /**
57
+ *
58
+ * @type {boolean}
59
+ */
60
+ enableBVH = true;
63
61
 
64
- /**
65
- *
66
- * @type {boolean}
67
- */
68
- this.enableBVH = true;
62
+ /**
63
+ *
64
+ * @type {LeafNode}
65
+ */
66
+ boundingBox = new LeafNode(this);
69
67
 
70
- /**
71
- *
72
- * @type {LeafNode}
73
- */
74
- this.boundingBox = new LeafNode(this);
68
+ /**
69
+ *
70
+ * @type {BinaryNode}
71
+ */
72
+ bvh = null;
75
73
 
76
- /**
77
- *
78
- * @type {BinaryNode}
79
- */
80
- this.bvh = null;
74
+ /**
75
+ *
76
+ * @type {boolean}
77
+ */
78
+ isBuilt = false;
79
+ /**
80
+ *
81
+ * @type {boolean}
82
+ */
83
+ isBuildInProgress = false;
84
+ referenceCount = 0;
81
85
 
82
- /**
83
- *
84
- * @type {boolean}
85
- */
86
- this.isBuilt = false;
87
- /**
88
- *
89
- * @type {boolean}
90
- */
91
- this.isBuildInProgress = false;
92
- this.referenceCount = 0;
86
+ /**
87
+ *
88
+ * @type {Signal<TerrainTile>}
89
+ */
90
+ onBuilt = new Signal();
91
+ onDestroyed = new Signal();
93
92
 
94
- /**
95
- *
96
- * @type {Signal<TerrainTile>}
97
- */
98
- this.onBuilt = new Signal();
99
- this.onDestroyed = new Signal();
93
+ /**
94
+ * Encodes whether stitching has been performed on per-neighbour basis
95
+ * @private
96
+ * @type {{bottomLeft: boolean, top: boolean, left: boolean, bottom: boolean, bottomRight: boolean, topLeft: boolean, topRight: boolean, right: boolean}}
97
+ */
98
+ stitching = {
99
+ top: false,
100
+ bottom: false,
101
+ left: false,
102
+ right: false,
100
103
 
101
- /**
102
- * Encodes whether stitching has been performed on per-neighbour basis
103
- * @private
104
- * @type {{bottomLeft: boolean, top: boolean, left: boolean, bottom: boolean, bottomRight: boolean, topLeft: boolean, topRight: boolean, right: boolean}}
105
- */
106
- this.stitching = {
107
- top: false,
108
- bottom: false,
109
- left: false,
110
- right: false,
104
+ topLeft: false,
105
+ topRight: false,
106
+
107
+ bottomLeft: false,
108
+ bottomRight: false
109
+ };
111
110
 
112
- topLeft: false,
113
- topRight: false,
111
+ /**
112
+ * Initial estimate of height bounds for this tile
113
+ * Untransformed by transform matrix
114
+ * @type {NumericInterval}
115
+ * @private
116
+ */
117
+ __initial_height_range = new NumericInterval(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
114
118
 
115
- bottomLeft: false,
116
- bottomRight: false
117
- };
119
+ raycaster = new BVHGeometryRaycaster();
120
+
121
+ constructor() {
122
+
123
+ this.mesh.name = "TerrainTile";
118
124
 
119
125
  /**
120
- * Initial estimate of height bounds for this tile
121
- * Untransformed by transform matrix
122
- * @type {NumericInterval}
123
- * @private
126
+ * Terrain mesh is static, it never changes its transform. Updates are wasteful.
127
+ * @type {boolean}
124
128
  */
125
- this.__initial_height_range = new NumericInterval(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
129
+ this.mesh.matrixWorldNeedsUpdate = false;
126
130
 
127
- this.raycaster = new BVHGeometryRaycaster();
128
131
  //Binary BVH form doesn't have distinct leaf objects and stores face indices directly, this requires a special face index extractor that treats leaves as indices directly.
129
132
  this.raycaster.extractFaceIndexFromLeaf = passThrough;
130
133
  }
@@ -0,0 +1,25 @@
1
+ import TerrainTile from "./TerrainTile.js";
2
+ import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
3
+
4
+ test("constructor does not throw", () => {
5
+ new TerrainTile();
6
+ });
7
+
8
+ test("get/set transform", () => {
9
+
10
+ const tile = new TerrainTile();
11
+ tile.setInitialHeightBounds(1, 7);
12
+
13
+ tile.transform = MATRIX_4_IDENTITY;
14
+
15
+ expect(Array.from(tile.transform)).toEqual(Array.from(MATRIX_4_IDENTITY));
16
+
17
+ });
18
+
19
+ test("using 'dispose' method on newly created tile", () => {
20
+
21
+ const tile = new TerrainTile();
22
+
23
+ expect(() => tile.dispose()).not.toThrow();
24
+
25
+ });
@@ -0,0 +1,47 @@
1
+ import { TooltipComponent } from "./TooltipComponent.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ new TooltipComponent()
5
+ });
6
+
7
+ test("to/from JSON", () => {
8
+
9
+ const source = new TooltipComponent();
10
+
11
+ source.key = "x";
12
+
13
+ const destination = new TooltipComponent();
14
+
15
+ destination.fromJSON(source.toJSON());
16
+
17
+ expect(destination.equals(source)).toBe(true);
18
+ });
19
+
20
+ test("equals", () => {
21
+
22
+ const a = new TooltipComponent();
23
+
24
+ a.key = "x";
25
+
26
+ const b = new TooltipComponent();
27
+
28
+ b.key = "a";
29
+
30
+ expect(a.equals(b)).toBe(false);
31
+
32
+ b.key = "x";
33
+
34
+ expect(a.equals(b)).toBe(true);
35
+ });
36
+
37
+ test("hash", () => {
38
+ const tip = new TooltipComponent();
39
+
40
+ tip.key = "x";
41
+
42
+ const hash = tip.hash();
43
+
44
+ expect(tip.hash()).toEqual(hash);
45
+ expect(typeof hash).toEqual("number");
46
+ expect(Number.isInteger(hash)).toBe(true);
47
+ });
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSe
2
2
  import { TooltipComponent } from "./TooltipComponent.js";
3
3
 
4
4
  export class TooltipComponentSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = TooltipComponent;
9
- this.version = 0;
10
- }
6
+ klass = TooltipComponent;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *