@woosh/meep-engine 2.49.9 → 2.50.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 (141) hide show
  1. package/editor/actions/concrete/ArrayCopyAction.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BinaryBuffer.js +1 -1
  4. package/src/core/binary/BinaryBuffer.spec.js +128 -0
  5. package/src/core/binary/int32_to_binary_string.js +4 -1
  6. package/src/core/binary/int32_to_binary_string.spec.js +9 -0
  7. package/src/core/bvh2/BinaryNode.js +0 -30
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
  9. package/src/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  10. package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
  11. package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
  12. package/src/core/cache/Cache.js +31 -29
  13. package/src/core/cache/Cache.spec.js +4 -1
  14. package/src/core/collection/HashMap.js +1 -1
  15. package/src/core/collection/array/{copyArray.js → array_copy.js} +1 -24
  16. package/src/core/collection/array/array_copy_entire.js +21 -0
  17. package/src/core/collection/array/typed/typed_array_copy.js +1 -1
  18. package/src/core/collection/queue/Deque.d.ts +4 -0
  19. package/src/core/collection/queue/Deque.js +5 -7
  20. package/src/core/collection/queue/Deque.spec.js +107 -0
  21. package/src/core/collection/table/RowFirstTable.js +1 -1
  22. package/src/core/geom/2d/aabb/AABB2.d.ts +14 -0
  23. package/src/core/geom/2d/aabb/AABB2.js +9 -7
  24. package/src/core/geom/2d/aabb/AABB2.spec.js +100 -0
  25. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.spec.js +11 -0
  26. package/src/core/geom/2d/aabb/aabb2_compute_overlap.spec.js +56 -0
  27. package/src/core/geom/2d/aabb/aabb2_contains.spec.js +40 -0
  28. package/src/core/geom/2d/bvh/Node2.js +1 -1
  29. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +1 -1
  30. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +1 -1
  31. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_2d.js +35 -0
  32. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_array_2d.js +51 -0
  33. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_2d.js +15 -0
  34. package/src/core/geom/2d/line/line_segment_compute_line_segment_intersection_vectors_array_2d.js +30 -0
  35. package/src/core/geom/2d/line/line_segment_line_segment_intersection_exists_2d.js +29 -0
  36. package/src/core/geom/3d/aabb/AABB3.d.ts +4 -0
  37. package/src/core/geom/3d/aabb/AABB3.spec.js +30 -0
  38. package/src/core/geom/3d/matrix/m4_make_translation.js +1 -1
  39. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +1 -1
  40. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
  41. package/src/core/geom/3d/tetrahedra/compute_circumsphere.js +1 -1
  42. package/src/core/geom/3d/tetrahedra/delaunay/fill_in_a_cavity.js +1 -1
  43. package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +1 -1
  44. package/src/core/geom/3d/topology/expandConnectivityByLocality.js +1 -1
  45. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +1 -1
  46. package/src/core/geom/Quaternion.d.ts +11 -0
  47. package/src/core/geom/Quaternion.js +36 -27
  48. package/src/core/geom/Quaternion.spec.js +141 -0
  49. package/src/core/geom/Vector2.d.ts +5 -1
  50. package/src/core/geom/Vector2.js +24 -0
  51. package/src/core/geom/Vector3.d.ts +4 -0
  52. package/src/core/geom/Vector3.spec.js +60 -0
  53. package/src/core/graph/GraphUtils.js +4 -2
  54. package/src/core/graph/layout/CircleLayout.js +4 -2
  55. package/src/core/math/vector_nd_dot.js +16 -0
  56. package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
  57. package/src/core/math/{normalizeArrayVector.spec.js → vector_nd_normalize.spec.js} +3 -3
  58. package/src/core/process/PromiseWatcher.spec.js +1 -1
  59. package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
  60. package/src/engine/ecs/EntityManager.js +1 -205
  61. package/src/engine/ecs/fow/FogOfWar.js +1 -1
  62. package/src/engine/ecs/guid/GUID.js +1 -1
  63. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
  64. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
  65. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  66. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  67. package/src/engine/ecs/transform/Transform.spec.js +63 -0
  68. package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
  69. package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
  70. package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
  71. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
  72. package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
  73. package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
  74. package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
  75. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  76. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
  77. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  78. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
  79. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  80. package/src/engine/graphics/render/Lines.js +1 -1
  81. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
  82. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  83. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
  84. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  85. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
  86. package/src/engine/graphics/render/view/CameraView.js +1 -1
  87. package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
  88. package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
  89. package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
  90. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
  91. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  92. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
  93. package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
  94. package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
  95. package/src/engine/graphics/texture/CanvasClone.js +5 -1
  96. package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
  97. package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
  98. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
  99. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
  100. package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
  101. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
  102. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
  103. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
  104. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
  105. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
  106. package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
  107. package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
  108. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
  109. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
  110. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
  111. package/src/engine/graphics/trail/TemporalPath.js +0 -36
  112. package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
  113. package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
  114. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
  115. package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
  116. package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
  117. package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
  118. package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
  119. package/src/engine/logging/VoidLoggerBackend.js +12 -0
  120. package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
  121. package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
  122. package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
  123. package/src/engine/save/GameStateLoader.js +1 -1
  124. package/src/engine/scene/Scene.d.ts +2 -0
  125. package/src/engine/scene/Scene.js +2 -2
  126. package/src/engine/scene/Scene.spec.js +20 -0
  127. package/src/engine/scene/SceneManager.d.ts +4 -0
  128. package/src/engine/scene/SceneManager.js +46 -23
  129. package/src/engine/scene/SceneManager.spec.js +107 -0
  130. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
  131. package/src/engine/ui/GUIEngine.js +1 -1
  132. package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
  133. package/src/generation/markers/MarkerNode.js +2 -2
  134. package/src/generation/theme/AreaMask.js +3 -1
  135. package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
  136. package/src/core/geom/2d/LineSegment2.js +0 -175
  137. package/src/core/geom/Matrix4.js +0 -275
  138. package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
  139. package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
  140. package/src/engine/physics/cannon/cannon.min.js +0 -27
  141. /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
@@ -831,7 +831,7 @@ EntityManager.prototype.shutdown = function (readyCallback, errorCallback) {
831
831
 
832
832
  system.state.set(System.State.STOPPED);
833
833
 
834
- self.on.systemStopped.dispatch(system);
834
+ self.on.systemStopped.send1(system);
835
835
  if (readyCount === expectedReadyCount) {
836
836
  finalizeShutdown();
837
837
  }
@@ -870,210 +870,6 @@ EntityManager.prototype.shutdown = function (readyCallback, errorCallback) {
870
870
  });
871
871
  };
872
872
 
873
-
874
- /**
875
- * @deprecated
876
- * @returns {number}
877
- */
878
- EntityManager.prototype.createEntity = function () {
879
- console.warn("EntityManager.createEntity is deprecated");
880
-
881
- return this.dataset.createEntity();
882
- };
883
-
884
- /**
885
- * @deprecated
886
- * @param id
887
- */
888
- EntityManager.prototype.createEntitySpecific = function (id) {
889
- console.warn("EntityManager.createEntitySpecific is deprecated");
890
- this.dataset.createEntitySpecific(id);
891
- };
892
-
893
-
894
- /**
895
- * @deprecated
896
- * Remove association of specified component type from entity
897
- * @param {Number} entityId
898
- * @param {Number} componentType
899
- */
900
- EntityManager.prototype.removeComponentFromEntity = function (entityId, componentType) {
901
- console.warn("EntityManager.removeComponentFromEntity is deprecated");
902
-
903
- this.dataset.removeComponentFromEntityByIndex(entityId, componentType);
904
- };
905
-
906
- /**
907
- * @deprecated use dataset directly
908
- * Retrieves component instance associated with entity
909
- * @template T
910
- * @param {Number} entityId
911
- * @param {class.<T>} componentClass
912
- * @returns {T|null}
913
- * @nosideeffects
914
- */
915
- EntityManager.prototype.getComponent = function (entityId, componentClass) {
916
- console.warn("EntityManager.getComponent is deprecated");
917
-
918
- return this.dataset.getComponent(entityId, componentClass);
919
- };
920
-
921
- /**
922
- * @deprecated use {@link EntityComponentDataset.entityExists} instead
923
- * @param {number} entityIndex
924
- * @returns {boolean}
925
- */
926
- EntityManager.prototype.entityExists = function (entityIndex) {
927
- console.warn("EntityManager.entityExists is deprecated");
928
- if (this.dataset === null) {
929
- //no dataset - no entities
930
- return false;
931
- }
932
- return this.dataset.entityExists(entityIndex);
933
- };
934
-
935
-
936
- /**
937
- * @deprecated Use {@link EntityManager#dataset} direction
938
- * @param entity
939
- * @returns {Array}
940
- */
941
- EntityManager.prototype.getComponents = function (entity) {
942
- console.warn("EntityManager.getComponents is deprecated");
943
-
944
- return this.dataset.getAllComponents(entity);
945
- };
946
-
947
- /**
948
- * @deprecated
949
- * Retrieves component instance associated with entity
950
- * @param {Number} entityId
951
- * @param {Number} componentType
952
- * @returns {*|undefined} component of specified type or undefined if it was not found
953
- */
954
- EntityManager.prototype.getComponentByType = function (entityId, componentType) {
955
- console.warn("EntityManager.getComponentByType is deprecated");
956
- return this.dataset.getComponentByIndex(entityId, componentType);
957
- };
958
-
959
- /**
960
- * @deprecated
961
- * does traversal on a subset of entities which have specified components.
962
- * @example traverseEntities([Transform,Renderable,Tag],function(transform, renderable, tag, entity){ ... }, this);
963
- * @param {Array.<class>} classes
964
- * @param {Function} callback
965
- * @param {Object} [thisArg] specifies context object on which callbacks are to be called, optional
966
- */
967
- EntityManager.prototype.traverseEntities = function (classes, callback, thisArg) {
968
- console.warn("EntityManager.traverseEntities is deprecated");
969
-
970
- if (this.dataset === null) {
971
- //no data to traverse
972
- return;
973
- }
974
- this.dataset.traverseEntities(classes, callback, thisArg);
975
- };
976
-
977
- /**
978
- * @deprecated
979
- * @param entity
980
- * @param eventName
981
- * @param listener
982
- */
983
- EntityManager.prototype.addEntityEventListener = function (entity, eventName, listener) {
984
- console.warn("EntityManager.addEntityEventListener is deprecated");
985
- this.dataset.addEntityEventListener(entity, eventName, listener);
986
- };
987
-
988
- /**
989
- * @deprecated
990
- * @param {number} entity
991
- * @param {string} eventName
992
- * @param {function} listener
993
- */
994
- EntityManager.prototype.removeEntityEventListener = function (entity, eventName, listener) {
995
- console.warn("EntityManager.removeEntityEventListener is deprecated");
996
- this.dataset.removeEntityEventListener(entity, eventName, listener);
997
- };
998
-
999
- /**
1000
- * @deprecated use dataset directly instead
1001
- * @param entity
1002
- * @param eventName
1003
- * @param event
1004
- */
1005
- EntityManager.prototype.sendEvent = function (entity, eventName, event) {
1006
- console.warn("EntityManager.sendEvent is deprecated");
1007
- this.dataset.sendEvent(entity, eventName, event);
1008
- };
1009
-
1010
- /**
1011
- * @deprecated
1012
- * @param {function} klazz
1013
- * @param {function(component: *, entity: number):boolean} callback
1014
- * @param {*} [thisArg]
1015
- * @deprecated
1016
- */
1017
- EntityManager.prototype.traverseComponents = function (klazz, callback, thisArg) {
1018
- console.warn("EntityManager.traverseComponents is deprecated");
1019
- if (this.dataset !== null) {
1020
- this.dataset.traverseComponents(klazz, callback, thisArg);
1021
- }
1022
- };
1023
-
1024
- /**
1025
- * @deprecated Use {@link #getSystem} instead
1026
- * @template T,C
1027
- * @param {C} klazz
1028
- * @returns {System|T}
1029
- */
1030
- EntityManager.prototype.getOwnerSystemByComponentClass = function (klazz) {
1031
-
1032
- console.warn("EntityManager.getOwnerSystemByComponentClass is deprecated, use .getSystem instead");
1033
- const index = this.getOwnerSystemIdByComponentClass(klazz);
1034
- return this.systems[index];
1035
- };
1036
-
1037
- /**
1038
- * @deprecated
1039
- * @param {function} clazz
1040
- * @returns {number} value >= 0, representing system Id, or -1 if system was not found
1041
- */
1042
- EntityManager.prototype.getOwnerSystemIdByComponentClass = function (clazz) {
1043
- console.warn("EntityManager.getOwnerSystemIdByComponentClass is deprecated, use .getSystem instead");
1044
-
1045
- const systems = this.systems;
1046
- let i = 0;
1047
- const l = systems.length;
1048
- for (; i < l; i++) {
1049
- if (systems[i].componentClass === clazz) {
1050
- return i;
1051
- }
1052
- }
1053
- return -1;
1054
- };
1055
-
1056
-
1057
- /**
1058
- * same as getComponent when component exists, if component is not associated with the entity, callback will be invoked once when it is added.
1059
- * @param {Number} entityId
1060
- * @param {Class} componentClass
1061
- * @param {function} callback
1062
- * @param {*} [thisArg]
1063
- */
1064
- EntityManager.prototype.getComponentAsync = function (entityId, componentClass, callback, thisArg) {
1065
- console.warn("EntityManager.getComponentAsync is deprecated");
1066
-
1067
- const dataset = this.dataset;
1068
-
1069
- if (dataset === undefined) {
1070
- throw new Error('No dataset attached');
1071
- }
1072
-
1073
- dataset.getComponentAsync(entityId, componentClass, callback, thisArg);
1074
-
1075
- };
1076
-
1077
873
  export {
1078
874
  EventType,
1079
875
  EntityManager
@@ -6,13 +6,13 @@ import { ClampToEdgeWrapping, DataTexture, LinearFilter, RedFormat, UnsignedByte
6
6
  import Vector1 from "../../../core/geom/Vector1.js";
7
7
  import Vector2 from "../../../core/geom/Vector2.js";
8
8
  import { assert } from "../../../core/assert.js";
9
- import { computeUnsignedDistanceField } from "../../graphics/texture/sampler/distanceField.js";
10
9
  import Vector4 from "../../../core/geom/Vector4.js";
11
10
  import Signal from "../../../core/events/signal/Signal.js";
12
11
  import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
13
12
  import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
14
13
  import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
15
14
  import { writeSample2DDataToDataTexture } from "../../graphics/texture/sampler/writeSampler2DDataToDataTexture.js";
15
+ import { computeUnsignedDistanceField } from "../../graphics/texture/sampler/distance/computeUnsignedDistanceField.js";
16
16
 
17
17
  const samplePosition = [];
18
18
 
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
2
  import { randomUint8 } from "../../../core/math/random/randomUint8.js";
3
3
  import { dec2hex } from "../../../core/binary/dec2hex.js";
4
- import { array_copy } from "../../../core/collection/array/copyArray.js";
4
+ import { array_copy } from "../../../core/collection/array/array_copy.js";
5
5
  import { randomBytes } from "../../../core/math/random/randomBytes.js";
6
6
  import { assert } from "../../../core/assert.js";
7
7
 
@@ -5,7 +5,7 @@ import { min2 } from "../../../../../core/math/min2.js";
5
5
  import { Sampler2D } from "../../../../graphics/texture/sampler/Sampler2D.js";
6
6
  import { assert } from "../../../../../core/assert.js";
7
7
  import { scaleSampler2D } from "../../../../graphics/texture/sampler/scaleSampler2D.js";
8
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
8
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
9
9
  import { typed_array_copy } from "../../../../../core/collection/array/typed/typed_array_copy.js";
10
10
  import { Base64 } from "../../../../../core/binary/Base64.js";
11
11
  import { countTask } from "../../../../../core/process/task/util/countTask.js";
@@ -15,7 +15,7 @@ import { scaleSampler2D } from "../../../graphics/texture/sampler/scaleSampler2D
15
15
  import { uint82float } from "../../../../core/binary/uint82float.js";
16
16
  import { float2uint8 } from "../../../../core/binary/float2uint8.js";
17
17
  import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
18
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
18
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
19
19
  import { WHITE_PIXEL_DATA_URL } from "../../../graphics/WHITE_PIXEL_DATA_URL.js";
20
20
 
21
21
  class Context {
@@ -26,7 +26,7 @@ import Signal from "../../../../core/events/signal/Signal.js";
26
26
  import { mat4 } from "gl-matrix";
27
27
  import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
28
28
  import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
29
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
29
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
30
30
  import { passThrough } from "../../../../core/function/Functions.js";
31
31
 
32
32
  /**
@@ -6,6 +6,8 @@ export class Transform {
6
6
  public readonly rotation: Quaternion
7
7
  public readonly scale: Vector3
8
8
 
9
+ flags: number
10
+
9
11
  public readonly matrix: ArrayLike<number>
10
12
 
11
13
  public lookAt(target: Vector3): void
@@ -86,3 +86,66 @@ test("toString produces a valid string", () => {
86
86
 
87
87
  expect(typeof t.toString()).toBe("string");
88
88
  });
89
+
90
+
91
+ test("setFlag", () => {
92
+ const ut = new Transform();
93
+
94
+ ut.flags = 0;
95
+
96
+ ut.setFlag(0b101);
97
+
98
+ expect(ut.flags).toBe(5);
99
+
100
+ ut.setFlag(0b010);
101
+
102
+ expect(ut.flags).toBe(7);
103
+
104
+ ut.setFlag(0b1);
105
+
106
+ expect(ut.flags).toBe(7);
107
+ });
108
+
109
+ test("clearFlag", () => {
110
+ const ut = new Transform();
111
+ ut.flags = 0b101;
112
+
113
+ ut.clearFlag(0b1);
114
+
115
+ expect(ut.flags).toBe(4);
116
+
117
+ ut.clearFlag(0b10);
118
+
119
+ expect(ut.flags).toBe(4);
120
+
121
+ ut.clearFlag(0b100);
122
+
123
+ expect(ut.flags).toBe(0);
124
+ });
125
+
126
+ test("getFlag", () => {
127
+
128
+ const ut = new Transform();
129
+
130
+ ut.flags = 0b101;
131
+
132
+ expect(ut.getFlag(0b1)).toBe(true);
133
+ expect(ut.getFlag(0b10)).toBe(false);
134
+ expect(ut.getFlag(0b100)).toBe(true);
135
+ expect(ut.getFlag(0b1000)).toBe(false);
136
+ expect(ut.getFlag(0b101)).toBe(true);
137
+ expect(ut.getFlag(0b011)).toBe(false);
138
+ });
139
+
140
+ test("writeFlag", () => {
141
+ const ut = new Transform();
142
+
143
+ ut.flags = 0;
144
+
145
+ ut.writeFlag(0b101, true);
146
+ expect(ut.flags).toBe(5);
147
+
148
+ ut.writeFlag(0b100, false);
149
+
150
+ expect(ut.flags).toBe(1);
151
+ });
@@ -1,3 +1,19 @@
1
+ import {Transform} from "../transform/Transform";
2
+
1
3
  export class TransformAttachment {
2
-
4
+ readonly transform: Transform
5
+ parent: number
6
+ flags: number
7
+
8
+ setFlag(flags: number): void
9
+
10
+ clearFlag(flags: number): void
11
+
12
+ getFlag(flags: number): boolean
13
+
14
+ writeFlag(flags: number, value: boolean): void
15
+
16
+ toJSON(): any
17
+
18
+ fromJSON(json: any): void
3
19
  }
@@ -1,5 +1,5 @@
1
1
  import { Transform } from "../transform/Transform.js";
2
- import { int32_to_binary_string } from "../../../core/binary/int32_to_binary_string.js";
2
+ import { assert } from "../../../core/assert.js";
3
3
 
4
4
  export const TransformAttachmentFlags = {
5
5
  /**
@@ -40,10 +40,20 @@ export class TransformAttachment {
40
40
  return {
41
41
  transform: this.transform.toJSON(),
42
42
  parent: this.parent,
43
- flags: int32_to_binary_string(this.flags)
43
+ flags: this.flags
44
44
  };
45
45
  }
46
46
 
47
+ fromJSON({ transform, parent = -1, flags = DEFAULT_FLAGS }) {
48
+ assert.defined(transform, 'transform');
49
+ assert.isInteger(parent, 'parent');
50
+ assert.isNonNegativeInteger(flags, 'flags');
51
+
52
+ this.transform.fromJSON(transform);
53
+ this.parent = parent;
54
+ this.flags = flags;
55
+ }
56
+
47
57
  get immediate() {
48
58
  return this.getFlag(TransformAttachmentFlags.Immediate);
49
59
  }
@@ -0,0 +1,103 @@
1
+ import { TransformAttachment } from "./TransformAttachment.js";
2
+
3
+ test("newly created object has valid state", () => {
4
+
5
+ const ut = new TransformAttachment();
6
+
7
+ expect(ut.transform).toBeDefined();
8
+ expect(ut.transform).not.toBeNull();
9
+
10
+ expect(ut.parent).toBe(-1);
11
+ expect(typeof ut.flags).toBe("number");
12
+ expect(Number.isInteger(ut.flags)).toBe(true);
13
+ expect(ut.flags).toBeGreaterThanOrEqual(0);
14
+
15
+ });
16
+
17
+ test("to/from JSON", () => {
18
+
19
+ const expected = new TransformAttachment();
20
+ expected.flags = 123457;
21
+
22
+ expected.parent = 13;
23
+
24
+ // just position is enough. don't need to check the entire transform as that's not the point
25
+ expected.transform.position.set(1, 3, -5);
26
+
27
+ const actual = new TransformAttachment();
28
+
29
+ actual.fromJSON(expected.toJSON());
30
+
31
+ expect(actual.parent).toBe(13);
32
+ expect(actual.flags).toBe(123457);
33
+ expect(actual.transform.position.x).toBe(1);
34
+ expect(actual.transform.position.y).toBe(3);
35
+ expect(actual.transform.position.z).toBe(-5);
36
+ });
37
+
38
+ test("toString produces a non-empty string", () => {
39
+ const ut = new TransformAttachment();
40
+
41
+ const string = ut.toString();
42
+
43
+ expect(typeof string).toBe('string');
44
+ expect(string.trim().length).toBeGreaterThan(0);
45
+ });
46
+
47
+ test("setFlag", () => {
48
+ const ut = new TransformAttachment();
49
+
50
+ ut.setFlag(0b101);
51
+
52
+ expect(ut.flags).toBe(5);
53
+
54
+ ut.setFlag(0b010);
55
+
56
+ expect(ut.flags).toBe(7);
57
+
58
+ ut.setFlag(0b1);
59
+
60
+ expect(ut.flags).toBe(7);
61
+ });
62
+
63
+ test("clearFlag", () => {
64
+ const ut = new TransformAttachment();
65
+ ut.flags = 0b101;
66
+
67
+ ut.clearFlag(0b1);
68
+
69
+ expect(ut.flags).toBe(4);
70
+
71
+ ut.clearFlag(0b10);
72
+
73
+ expect(ut.flags).toBe(4);
74
+
75
+ ut.clearFlag(0b100);
76
+
77
+ expect(ut.flags).toBe(0);
78
+ });
79
+
80
+ test("getFlag", () => {
81
+
82
+ const ut = new TransformAttachment();
83
+
84
+ ut.flags = 0b101;
85
+
86
+ expect(ut.getFlag(0b1)).toBe(true);
87
+ expect(ut.getFlag(0b10)).toBe(false);
88
+ expect(ut.getFlag(0b100)).toBe(true);
89
+ expect(ut.getFlag(0b1000)).toBe(false);
90
+ expect(ut.getFlag(0b101)).toBe(true);
91
+ expect(ut.getFlag(0b011)).toBe(false);
92
+ });
93
+
94
+ test("writeFlag", () => {
95
+ const ut = new TransformAttachment();
96
+
97
+ ut.writeFlag(0b101, true);
98
+ expect(ut.flags).toBe(5);
99
+
100
+ ut.writeFlag(0b100, false);
101
+
102
+ expect(ut.flags).toBe(1);
103
+ });
@@ -3,7 +3,7 @@ import { max2 } from "../../../../../../core/math/max2.js";
3
3
  import { min2 } from "../../../../../../core/math/min2.js";
4
4
  import { clamp } from "../../../../../../core/math/clamp.js";
5
5
  import { vec3 } from "gl-matrix";
6
- import { array_copy } from "../../../../../../core/collection/array/copyArray.js";
6
+ import { array_copy } from "../../../../../../core/collection/array/array_copy.js";
7
7
 
8
8
  /**
9
9
  * Compute a normal vector for Frenet frame based on a tangent (direction in which vertex points)
@@ -8,7 +8,7 @@ import { GROUP_WITH_ANY } from "./constants/GROUP_WITH_ANY.js";
8
8
  import { INTERNAL_RND_SORT_SEED } from "./constants/INTERNAL_RND_SORT_SEED.js";
9
9
  import { QuickSort } from "./QuickSort.js";
10
10
  import { CompareSubGroups } from "./CompareSubGroups.js";
11
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
11
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
12
12
  import { EvalTspace } from "./EvalTspace.js";
13
13
  import { ORIENT_PRESERVING } from "./constants/ORIENT_PRESERVING.js";
14
14
  import { AvgTSpace } from "./AvgTSpace.js";
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
1
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
2
2
 
3
3
  /**
4
4
  *
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
1
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
2
2
 
3
3
  /**
4
4
  *
@@ -8,7 +8,7 @@ import { v3_length } from "../../../../../core/geom/v3_length.js";
8
8
  import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
9
9
  import { mat4 } from "gl-matrix";
10
10
  import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
11
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
11
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
12
12
  import { MATRIX_4_IDENTITY } from "../../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
13
13
 
14
14
  const hit = new ThreeVector3();
@@ -17,7 +17,7 @@ import { rewriteMaterial } from "./rewriteMaterial.js";
17
17
  import { max3 } from "../../../../core/math/max3.js";
18
18
  import { min2 } from "../../../../core/math/min2.js";
19
19
  import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
20
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
20
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
21
21
  import { Cache } from "../../../../core/cache/Cache.js";
22
22
  import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
23
23
 
@@ -2,7 +2,7 @@ import { StaticMaterialCache } from "../../../../asset/loaders/material/StaticMa
2
2
  import { HashMap } from "../../../../../core/collection/HashMap.js";
3
3
  import { computeGeometryEquality } from "../../buffered/computeGeometryEquality.js";
4
4
  import { computeGeometryHash } from "../../buffered/computeGeometryHash.js";
5
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
5
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
6
6
  import { mat4 } from "gl-matrix";
7
7
  import { Group, Matrix4, Mesh } from "three";
8
8
  import { mergeBufferGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
@@ -3,7 +3,7 @@
3
3
  import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
4
4
  import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
5
5
  import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
6
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
6
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
7
7
  import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
8
8
  import { max2 } from "../../../../../core/math/max2.js";
9
9
  import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
@@ -2,7 +2,7 @@ import Signal from "../../../../../../../core/events/signal/Signal.js";
2
2
  import {
3
3
  DataType2TypedArrayConstructorMapping
4
4
  } from "../../../../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
5
- import { array_copy } from "../../../../../../../core/collection/array/copyArray.js";
5
+ import { array_copy } from "../../../../../../../core/collection/array/array_copy.js";
6
6
  import { min2 } from "../../../../../../../core/math/min2.js";
7
7
  import { assert } from "../../../../../../../core/assert.js";
8
8
  import { ParameterLookupTable } from "../../parameter/ParameterLookupTable.js";
@@ -1,5 +1,5 @@
1
1
  import { DynamicDrawUsage, LineBasicMaterial, LineSegments } from "three";
2
- import { array_copy } from "../../../core/collection/array/copyArray.js";
2
+ import { array_copy } from "../../../core/collection/array/array_copy.js";
3
3
  import { BufferGeometry } from "three/src/core/BufferGeometry.js";
4
4
  import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { EnginePlugin } from "../../../../../plugin/EnginePlugin.js";
2
2
  import { halton_sequence } from "../../../../../../core/math/statistics/halton_sequence.js";
3
- import { array_copy } from "../../../../../../core/collection/array/copyArray.js";
3
+ import { array_copy } from "../../../../../../core/collection/array/array_copy.js";
4
4
 
5
5
  /**
6
6
  * Generates a number of 2d jitter offsets in range -1...1
@@ -38,7 +38,7 @@ import { Decal } from "./model/Decal.js";
38
38
  import { ReferencedTextureAtlas } from "../../texture/atlas/ReferencedTextureAtlas.js";
39
39
  import { v3_morton_encode_transformed } from "../../../../core/geom/3d/morton/v3_morton_encode_transformed.js";
40
40
  import { v3_distance } from "../../../../core/geom/v3_distance.js";
41
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
41
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
42
42
  import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
43
43
  import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
44
44
  import { arraySwapElements } from "../../../../core/collection/array/arraySwapElements.js";
@@ -1,7 +1,7 @@
1
1
  import { AbstractLight } from "./AbstractLight.js";
2
2
  import { aabb3_matrix4_project_by_corners } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js";
3
3
  import { aabb3_build_corners } from "../../../../../core/geom/3d/aabb/aabb3_build_corners.js";
4
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
4
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
5
5
  import { mat4 } from "gl-matrix";
6
6
  import Signal from "../../../../../core/events/signal/Signal.js";
7
7
 
@@ -49,7 +49,7 @@ import { Decal } from "../model/Decal.js";
49
49
  import { mat4 } from "gl-matrix";
50
50
  import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
51
51
  import { makeHelperBoxGeometry } from "../../../../../../editor/process/symbolic/makeHelperBoxGeometry.js";
52
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
52
+ import { array_copy } from "../../../../../core/collection/array/array_copy.js";
53
53
  import { BufferGeometry } from "three/src/core/BufferGeometry.js";
54
54
  import { Float32BufferAttribute } from "three/src/core/BufferAttribute.js";
55
55
  import Quaternion from "../../../../../core/geom/Quaternion.js";
@@ -1,4 +1,4 @@
1
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
1
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
3
  import { InstancedMeshGroup } from "../../geometry/instancing/InstancedMeshGroup.js";
4
4
  import { BoxBufferGeometry, LineBasicMaterial, MeshBasicMaterial, OctahedronBufferGeometry } from "three";
@@ -6,7 +6,7 @@ import { read_frustum_planes_to_array } from "../../../../core/geom/3d/frustum/r
6
6
  import Signal from "../../../../core/events/signal/Signal.js";
7
7
  import { compare_three_objects } from "../../three/compare_three_objects.js";
8
8
  import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
9
- import { array_copy } from "../../../../core/collection/array/copyArray.js";
9
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
10
10
  import { array_remove_first } from "../../../../core/collection/array/array_remove_first.js";
11
11
 
12
12
  const DEFAULT_FLAGS = CameraViewFlags.Active