@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
@@ -1,20 +1,16 @@
1
1
  import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
2
2
 
3
3
  export class DynamicRuleCooldownDescription {
4
- constructor() {
5
-
6
- /**
7
- *
8
- * @type {string}
9
- */
10
- this.id = "";
11
-
12
- /**
13
- *
14
- * @type {NumericInterval}
15
- */
16
- this.value = new NumericInterval(0, 0);
17
- }
4
+ /**
5
+ *
6
+ * @type {string}
7
+ */
8
+ id = "";
9
+ /**
10
+ *
11
+ * @type {NumericInterval}
12
+ */
13
+ value= new NumericInterval(0, 0);
18
14
 
19
15
  fromJSON({ id, value }) {
20
16
 
@@ -7,45 +7,37 @@ import { deserializeActionFromJSON } from "../actions/definition/deserializeActi
7
7
  import { DynamicRuleCooldownDescription } from "./DynamicRuleCooldownDescription.js";
8
8
 
9
9
  export class DynamicRuleDescription {
10
- constructor() {
11
- this.id = 0;
12
-
13
- /**
14
- *
15
- * @type {ReactiveExpression}
16
- */
17
- this.condition = null;
18
-
19
- /**
20
- *
21
- * @type {AbstractActionDescription}
22
- */
23
- this.action = null;
24
-
25
- /**
26
- *
27
- * @type {ReactiveReference[]}
28
- */
29
- this.references = [];
30
-
31
- /**
32
- * Rules with higher priority have the right to interrupt lower priority rules
33
- * @type {number}
34
- */
35
- this.priority = 0;
36
-
37
- /**
38
- * @private
39
- * @type {number}
40
- */
41
- this.predicate_complexity = 0;
42
-
43
- /**
44
- * Specified which global cooldowns will be triggered and for how long
45
- * @type {DynamicRuleCooldownDescription[]}
46
- */
47
- this.cooldowns_global = [];
48
- }
10
+ id = 0;
11
+ /**
12
+ *
13
+ * @type {ReactiveExpression}
14
+ */
15
+ condition = null;
16
+ /**
17
+ *
18
+ * @type {AbstractActionDescription}
19
+ */
20
+ action = null;
21
+ /**
22
+ *
23
+ * @type {ReactiveReference[]}
24
+ */
25
+ references = [];
26
+ /**
27
+ * Rules with higher priority have the right to interrupt lower priority rules
28
+ * @type {number}
29
+ */
30
+ priority = 0;
31
+ /**
32
+ * @private
33
+ * @type {number}
34
+ */
35
+ predicate_complexity = 0;
36
+ /**
37
+ * Specified which global cooldowns will be triggered and for how long
38
+ * @type {DynamicRuleCooldownDescription[]}
39
+ */
40
+ cooldowns_global = [];
49
41
 
50
42
  /**
51
43
  *
@@ -1,7 +1,7 @@
1
1
  import { StaticKnowledgeDataTable } from "../../../knowledge/database/StaticKnowledgeDataTable.js";
2
2
  import { DynamicRuleDescription } from "./DynamicRuleDescription.js";
3
3
  import { MultiPredicateEvaluator } from "../../../../core/model/reactive/evaluation/MultiPredicateEvaluator.js";
4
- import { HashMap } from "../../../../core/collection/HashMap.js";
4
+ import { HashMap } from "../../../../core/collection/map/HashMap.js";
5
5
 
6
6
 
7
7
  export class DynamicRuleDescriptionTable extends StaticKnowledgeDataTable {
@@ -1,17 +1,17 @@
1
- import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
- import { DynamicRuleDescriptionTable } from "./rules/DynamicRuleDescriptionTable.js";
1
+ import { seededRandom } from "../../../../core/math/random/seededRandom.js";
2
+ import { DynamicRuleDescriptionTable } from "./DynamicRuleDescriptionTable.js";
3
3
  import {
4
4
  createRandomReactiveExpression
5
- } from "../../../core/model/reactive/model/util/createRandomReactiveExpression.js";
6
- import { ReactiveReference } from "../../../core/model/reactive/model/terminal/ReactiveReference.js";
7
- import { ReactiveLiteralNumber } from "../../../core/model/reactive/model/terminal/ReactiveLiteralNumber.js";
8
- import { ReactiveLiteralString } from "../../../core/model/reactive/model/terminal/ReactiveLiteralString.js";
9
- import { ReactiveLiteralBoolean } from "../../../core/model/reactive/model/terminal/ReactiveLiteralBoolean.js";
10
- import { DynamicRuleDescription } from "./rules/DynamicRuleDescription.js";
11
- import DataType from "../../../core/parser/simple/DataType.js";
12
- import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
13
- import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
14
- import { randomIntegerBetween } from "../../../core/math/random/randomIntegerBetween.js";
5
+ } from "../../../../core/model/reactive/model/util/createRandomReactiveExpression.js";
6
+ import { ReactiveReference } from "../../../../core/model/reactive/model/terminal/ReactiveReference.js";
7
+ import { ReactiveLiteralNumber } from "../../../../core/model/reactive/model/terminal/ReactiveLiteralNumber.js";
8
+ import { ReactiveLiteralString } from "../../../../core/model/reactive/model/terminal/ReactiveLiteralString.js";
9
+ import { ReactiveLiteralBoolean } from "../../../../core/model/reactive/model/terminal/ReactiveLiteralBoolean.js";
10
+ import { DynamicRuleDescription } from "./DynamicRuleDescription.js";
11
+ import DataType from "../../../../core/parser/simple/DataType.js";
12
+ import { randomFromArray } from "../../../../core/math/random/randomFromArray.js";
13
+ import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetween.js";
14
+ import { randomIntegerBetween } from "../../../../core/math/random/randomIntegerBetween.js";
15
15
 
16
16
  describe.skip('performance', () => {
17
17
 
@@ -3,12 +3,9 @@ import { InstancedMeshComponent } from "./InstancedMeshComponent.js";
3
3
  import { InstancedMeshLayer } from "./InstancedMeshLayer.js";
4
4
 
5
5
  export class InstancedMeshSerializationAdapter extends BinaryClassSerializationAdapter {
6
- constructor() {
7
- super();
8
6
 
9
- this.klass = InstancedMeshComponent;
10
- this.version = 0;
11
- }
7
+ klass = InstancedMeshComponent;
8
+ version = 0;
12
9
 
13
10
  /**
14
11
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClas
2
2
  import { FogOfWarRevealer } from "../FogOfWarRevealer.js";
3
3
 
4
4
  export class FogOfWarRevealerSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = FogOfWarRevealer;
9
- this.version = 0;
10
- }
6
+ klass = FogOfWarRevealer;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -7,14 +7,11 @@ import {
7
7
  } from "../../../graphics/texture/sampler/serialization/Sampler2DSerializationAdapter.js";
8
8
 
9
9
  export class FogOfWarSerializationAdapter extends BinaryClassSerializationAdapter {
10
- constructor() {
11
- super();
12
10
 
13
- this.klass = FogOfWar;
14
- this.version = 1;
11
+ klass = FogOfWar;
12
+ version = 1;
15
13
 
16
- this.__sampler_serializer = new Sampler2DSerializationAdapter();
17
- }
14
+ __sampler_serializer = new Sampler2DSerializationAdapter();
18
15
 
19
16
  /**
20
17
  *
@@ -40,7 +37,7 @@ export class FogOfWarSerializationAdapter extends BinaryClassSerializationAdapte
40
37
 
41
38
  buffer.writeUint32(color);
42
39
 
43
- this.__sampler_serializer.serialize(buffer,value.sampler);
40
+ this.__sampler_serializer.serialize(buffer, value.sampler);
44
41
 
45
42
  //serialize reveal state
46
43
  serializeRowFirstTable(buffer, value.fadeMask);
@@ -73,7 +70,7 @@ export class FogOfWarSerializationAdapter extends BinaryClassSerializationAdapte
73
70
  color_a / 255
74
71
  );
75
72
 
76
- this.__sampler_serializer.deserialize(buffer,value.sampler);
73
+ this.__sampler_serializer.deserialize(buffer, value.sampler);
77
74
 
78
75
  //deserialize reveal state
79
76
  deserializeRowFirstTable(buffer, value.fadeMask);
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSe
2
2
  import GUIElement, { GUIElementFlag } from "./GUIElement.js";
3
3
 
4
4
  export class GUIElementSerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = GUIElement;
9
- this.version = 0;
10
- }
6
+ klass = GUIElement;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -2,12 +2,9 @@ import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClas
2
2
  import HeadsUpDisplay from "./HeadsUpDisplay.js";
3
3
 
4
4
  export class HeadsUpDisplaySerializationAdapter extends BinaryClassSerializationAdapter {
5
- constructor() {
6
- super();
7
5
 
8
- this.klass = HeadsUpDisplay;
9
- this.version = 0;
10
- }
6
+ klass = HeadsUpDisplay;
7
+ version = 0;
11
8
 
12
9
  /**
13
10
  *
@@ -16,7 +13,7 @@ export class HeadsUpDisplaySerializationAdapter extends BinaryClassSerialization
16
13
  */
17
14
  serialize(buffer, value) {
18
15
  value.worldOffset.toBinaryBuffer(buffer);
19
- buffer.writeUint8(value.flags );
16
+ buffer.writeUint8(value.flags);
20
17
  }
21
18
 
22
19
  /**
@@ -151,12 +151,9 @@ ViewportPosition.serializable = true;
151
151
  export default ViewportPosition;
152
152
 
153
153
  export class ViewportPositionSerializationAdapter extends BinaryClassSerializationAdapter {
154
- constructor() {
155
- super();
156
154
 
157
- this.version = 0;
158
- this.klass = ViewportPosition;
159
- }
155
+ version = 0;
156
+ klass = ViewportPosition;
160
157
 
161
158
  /**
162
159
  *
@@ -0,0 +1,95 @@
1
+ import { NumericInterval } from "../../../core/math/interval/NumericInterval.js";
2
+ import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
3
+ import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
4
+ import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
5
+
6
+ export class IKConstraint {
7
+
8
+ /**
9
+ * End bone that is going to be placed
10
+ * @type {String}
11
+ */
12
+ effector = "";
13
+
14
+ /**
15
+ * How far should effector be from the contact, positive values result in effector not reaching the surface, and negative result in penetration
16
+ * @example For a foot effector this would be distance above the ground
17
+ * @type {number}
18
+ */
19
+ offset = 0;
20
+
21
+ /**
22
+ * Positive distance from the surface at which IK starts to take effect, low value represents full effect and high value represents where the influence begins
23
+ * @type {NumericInterval}
24
+ */
25
+ distance = new NumericInterval(0, 0);
26
+
27
+ /**
28
+ *
29
+ * @type {number}
30
+ */
31
+ strength = 1;
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ */
37
+ limit = Math.PI;
38
+
39
+ /**
40
+ * Solver to be used for this constraint
41
+ * @type {string}
42
+ */
43
+ solver = "2BIK";
44
+
45
+
46
+ /**
47
+ *
48
+ * @param {IKConstraint} other
49
+ */
50
+ copy(other) {
51
+ this.effector = other.effector;
52
+ this.offset = other.offset;
53
+ this.distance.copy(other.distance);
54
+ this.strength = other.strength;
55
+ this.limit = other.limit;
56
+ this.solver = other.solver;
57
+ }
58
+
59
+ clone() {
60
+ const r = new IKConstraint();
61
+
62
+ r.copy(this);
63
+
64
+ return r;
65
+ }
66
+
67
+ /**
68
+ *
69
+ * @param {IKConstraint} other
70
+ * @returns {boolean}
71
+ */
72
+ equals(other) {
73
+ return this.effector === other.effector
74
+ && this.offset === other.offset
75
+ && this.distance.equals(other.distance)
76
+ && this.strength === other.strength
77
+ && this.limit === other.limit
78
+ && this.solver === other.solver;
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @return {number}
84
+ */
85
+ hash() {
86
+ return computeHashIntegerArray(
87
+ computeStringHash(this.effector),
88
+ computeHashFloat(this.offset),
89
+ this.distance.hash(),
90
+ computeHashFloat(this.strength),
91
+ computeHashFloat(this.limit),
92
+ computeStringHash(this.solver)
93
+ );
94
+ }
95
+ }
@@ -1,100 +1,4 @@
1
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
- import { NumericInterval } from "../../../core/math/interval/NumericInterval.js";
3
- import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
4
- import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
5
- import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
6
-
7
- class IKConstraint {
8
- constructor() {
9
-
10
- /**
11
- * End bone that is going to be placed
12
- * @type {String}
13
- */
14
- this.effector = "";
15
-
16
- /**
17
- * How far should effector be from the contact, positive values result in effector not reaching the surface, and negative result in penetration
18
- * @example For a foot effector this would be distance above the ground
19
- * @type {number}
20
- */
21
- this.offset = 0;
22
-
23
- /**
24
- * Positive distance from the surface at which IK starts to take effect, low value represents full effect and high value represents where the influence begins
25
- * @type {NumericInterval}
26
- */
27
- this.distance = new NumericInterval(0, 0);
28
-
29
- /**
30
- *
31
- * @type {number}
32
- */
33
- this.strength = 1;
34
-
35
- /**
36
- *
37
- * @type {number}
38
- */
39
- this.limit = Math.PI;
40
-
41
- /**
42
- * Solver to be used for this constraint
43
- * @type {string}
44
- */
45
- this.solver = "2BIK";
46
- }
47
-
48
- /**
49
- *
50
- * @param {IKConstraint} other
51
- */
52
- copy(other) {
53
- this.effector = other.effector;
54
- this.offset = other.offset;
55
- this.distance.copy(other.distance);
56
- this.strength = other.strength;
57
- this.limit = other.limit;
58
- this.solver = other.solver;
59
- }
60
-
61
- clone() {
62
- const r = new IKConstraint();
63
-
64
- r.copy(this);
65
-
66
- return r;
67
- }
68
-
69
- /**
70
- *
71
- * @param {IKConstraint} other
72
- * @returns {boolean}
73
- */
74
- equals(other) {
75
- return this.effector === other.effector
76
- && this.offset === other.offset
77
- && this.distance.equals(other.distance)
78
- && this.strength === other.strength
79
- && this.limit === other.limit
80
- && this.solver === other.solver;
81
- }
82
-
83
- /**
84
- *
85
- * @return {number}
86
- */
87
- hash() {
88
- return computeHashIntegerArray(
89
- computeStringHash(this.effector),
90
- computeHashFloat(this.offset),
91
- this.distance.hash(),
92
- computeHashFloat(this.strength),
93
- computeHashFloat(this.limit),
94
- computeStringHash(this.solver)
95
- );
96
- }
97
- }
1
+ import { IKConstraint } from "./IKConstraint.js";
98
2
 
99
3
 
100
4
  export class InverseKinematics {
@@ -143,7 +47,15 @@ export class InverseKinematics {
143
47
  * @param {number} limit
144
48
  * @param {String} solver
145
49
  */
146
- add({ effector, offset = 0, distanceMin = 0, distanceMax = 0.1, strength = 1, limit = Math.PI * 0.9, solver = "2BIK" }) {
50
+ add({
51
+ effector,
52
+ offset = 0,
53
+ distanceMin = 0,
54
+ distanceMax = 0.1,
55
+ strength = 1,
56
+ limit = Math.PI * 0.9,
57
+ solver = "2BIK"
58
+ }) {
147
59
  const c = new IKConstraint();
148
60
 
149
61
  c.effector = effector;
@@ -205,74 +117,3 @@ export class InverseKinematics {
205
117
 
206
118
  InverseKinematics.typeName = "InverseKinematics";
207
119
 
208
- export class InverseKinematicsSerializationAdapter extends BinaryClassSerializationAdapter {
209
- constructor() {
210
- super();
211
-
212
- this.klass = InverseKinematics;
213
- this.version = 0;
214
- }
215
-
216
- /**
217
- *
218
- * @param {BinaryBuffer} buffer
219
- * @param {InverseKinematics} value
220
- */
221
- serialize(buffer, value) {
222
- const constraints = value.constraints;
223
- const n = constraints.length;
224
- buffer.writeUintVar(n);
225
-
226
- for (let i = 0; i < n; i++) {
227
- const constraint = constraints[i];
228
-
229
- buffer.writeUTF8String(constraint.effector);
230
-
231
- buffer.writeFloat32(constraint.offset);
232
- buffer.writeFloat32(constraint.strength);
233
- buffer.writeFloat32(constraint.limit);
234
-
235
- buffer.writeFloat32(constraint.distance.min);
236
- buffer.writeFloat32(constraint.distance.max);
237
-
238
- buffer.writeUTF8String(constraint.solver);
239
- }
240
- }
241
-
242
- /**
243
- *
244
- * @param {BinaryBuffer} buffer
245
- * @param {InverseKinematics} value
246
- */
247
- deserialize(buffer, value) {
248
- const n = buffer.readUintVar();
249
-
250
- const constraints = [];
251
-
252
- for (let i = 0; i < n; i++) {
253
- const effector = buffer.readUTF8String();
254
-
255
- const offset = buffer.readFloat32();
256
- const strength = buffer.readFloat32();
257
- const limit = buffer.readFloat32();
258
-
259
- const distanceMin = buffer.readFloat32();
260
- const distanceMax = buffer.readFloat32();
261
-
262
- const solver = buffer.readUTF8String();
263
-
264
- const ikConstraint = new IKConstraint();
265
-
266
- ikConstraint.effector = effector;
267
- ikConstraint.offset = offset;
268
- ikConstraint.strength = strength;
269
- ikConstraint.limit = limit;
270
- ikConstraint.distance.set(distanceMin, distanceMax);
271
- ikConstraint.solver = solver;
272
-
273
- constraints.push(ikConstraint);
274
- }
275
-
276
- value.constraints = constraints;
277
- }
278
- }
@@ -0,0 +1,72 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import { IKConstraint } from "./IKConstraint.js";
3
+ import { InverseKinematics } from "./InverseKinematics.js";
4
+
5
+ export class InverseKinematicsSerializationAdapter extends BinaryClassSerializationAdapter {
6
+
7
+ klass = InverseKinematics;
8
+ version = 0;
9
+
10
+ /**
11
+ *
12
+ * @param {BinaryBuffer} buffer
13
+ * @param {InverseKinematics} value
14
+ */
15
+ serialize(buffer, value) {
16
+ const constraints = value.constraints;
17
+ const n = constraints.length;
18
+ buffer.writeUintVar(n);
19
+
20
+ for (let i = 0; i < n; i++) {
21
+ const constraint = constraints[i];
22
+
23
+ buffer.writeUTF8String(constraint.effector);
24
+
25
+ buffer.writeFloat32(constraint.offset);
26
+ buffer.writeFloat32(constraint.strength);
27
+ buffer.writeFloat32(constraint.limit);
28
+
29
+ buffer.writeFloat32(constraint.distance.min);
30
+ buffer.writeFloat32(constraint.distance.max);
31
+
32
+ buffer.writeUTF8String(constraint.solver);
33
+ }
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @param {BinaryBuffer} buffer
39
+ * @param {InverseKinematics} value
40
+ */
41
+ deserialize(buffer, value) {
42
+ const n = buffer.readUintVar();
43
+
44
+ const constraints = [];
45
+
46
+ for (let i = 0; i < n; i++) {
47
+ const effector = buffer.readUTF8String();
48
+
49
+ const offset = buffer.readFloat32();
50
+ const strength = buffer.readFloat32();
51
+ const limit = buffer.readFloat32();
52
+
53
+ const distanceMin = buffer.readFloat32();
54
+ const distanceMax = buffer.readFloat32();
55
+
56
+ const solver = buffer.readUTF8String();
57
+
58
+ const ikConstraint = new IKConstraint();
59
+
60
+ ikConstraint.effector = effector;
61
+ ikConstraint.offset = offset;
62
+ ikConstraint.strength = strength;
63
+ ikConstraint.limit = limit;
64
+ ikConstraint.distance.set(distanceMin, distanceMax);
65
+ ikConstraint.solver = solver;
66
+
67
+ constraints.push(ikConstraint);
68
+ }
69
+
70
+ value.constraints = constraints;
71
+ }
72
+ }
@@ -1,12 +1,9 @@
1
1
  export class Voice {
2
- constructor() {
3
-
4
- /**
5
- *
6
- * @type {number}
7
- */
8
- this.flags = 0;
9
- }
2
+ /**
3
+ *
4
+ * @type {number}
5
+ */
6
+ flags = 0;
10
7
 
11
8
  /**
12
9
  *