@woosh/meep-engine 2.49.8 → 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 (197) 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/bessel_i0.spec.js +43 -0
  56. package/src/core/math/bessel_j0.js +30 -0
  57. package/src/core/math/hash/murmur3_32.spec.js +8 -0
  58. package/src/core/math/hash/squirrel3.spec.js +16 -0
  59. package/src/core/math/interval/NumericInterval.js +1 -0
  60. package/src/core/math/{bessel_i0.js → modified_bessel_i0.js} +5 -2
  61. package/src/core/math/noise/{create_noise_2d.js → create_simplex_noise_2d.js} +2 -2
  62. package/src/core/math/noise/create_simplex_noise_2d.spec.js +21 -0
  63. package/src/core/math/physics/irradiance/interpolate_irradiance_linear.spec.js +20 -0
  64. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js +4 -4
  65. package/src/core/math/physics/irradiance/interpolate_irradiance_lograrithmic.spec.js +18 -0
  66. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.js +1 -1
  67. package/src/core/math/physics/irradiance/interpolate_irradiance_smith.spec.js +20 -0
  68. package/src/core/math/random/seededRandomMersenneTwister.spec.js +10 -0
  69. package/src/core/math/spline/spline_bezier3.js +1 -1
  70. package/src/core/math/spline/spline_bezier3_bounds.js +2 -1
  71. package/src/core/math/spline/spline_bezier3_bounds.spec.js +37 -0
  72. package/src/core/math/statistics/computeSampleSize_Cochran.spec.js +12 -0
  73. package/src/core/math/statistics/computeStatisticalPartialMedian.js +4 -0
  74. package/src/core/math/statistics/computeStatisticalPartialMedian.spec.js +13 -0
  75. package/src/core/math/vector_nd_dot.js +16 -0
  76. package/src/core/math/{normalizeArrayVector.js → vector_nd_normalize.js} +3 -3
  77. package/src/core/math/vector_nd_normalize.spec.js +15 -0
  78. package/src/core/process/PromiseWatcher.spec.js +1 -1
  79. package/src/engine/achievements/Achievement.spec.js +21 -0
  80. package/src/engine/animation/curve/compression/downsample_float_array_curve_by_error.js +1 -1
  81. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +2 -2
  82. package/src/engine/animation/curve/compression/{animation_curve_to_float_array.js → sample_animation_curve_to_float_array.js} +10 -3
  83. package/src/engine/animation/curve/compression/sample_animation_curve_to_float_array.spec.js +29 -0
  84. package/src/engine/animation/curve/draw/build_curve_editor.js +3 -3
  85. package/src/engine/development/performance/RingBufferMetric.js +1 -1
  86. package/src/engine/ecs/EntityManager.js +1 -205
  87. package/src/engine/ecs/animation/Animation.js +2 -180
  88. package/src/engine/ecs/animation/AnimationClip.js +132 -0
  89. package/src/engine/ecs/animation/AnimationClip.spec.js +5 -0
  90. package/src/engine/ecs/animation/AnimationClipFlag.js +7 -0
  91. package/src/engine/ecs/animation/AnimationFlags.js +8 -0
  92. package/src/engine/ecs/animation/AnimationSerializationAdapter.js +32 -0
  93. package/src/engine/ecs/fow/FogOfWar.js +1 -1
  94. package/src/engine/ecs/guid/GUID.js +1 -1
  95. package/src/engine/ecs/systems/AnimationSystem.js +3 -1
  96. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +1 -1
  97. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +1 -1
  98. package/src/engine/ecs/terrain/tiles/TerrainTile.js +1 -1
  99. package/src/engine/ecs/transform/Transform.d.ts +2 -0
  100. package/src/engine/ecs/transform/Transform.spec.js +63 -0
  101. package/src/engine/ecs/transform-attachment/TransformAttachment.d.ts +17 -1
  102. package/src/engine/ecs/transform-attachment/TransformAttachment.js +12 -2
  103. package/src/engine/ecs/transform-attachment/TransformAttachment.spec.js +103 -0
  104. package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
  105. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -1
  106. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +1 -1
  107. package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +1 -1
  108. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
  109. package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +1 -1
  110. package/src/engine/graphics/geometry/MikkT/m_getNormal.js +1 -1
  111. package/src/engine/graphics/geometry/MikkT/m_getTexCoord.js +1 -1
  112. package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
  113. package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +1 -1
  114. package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
  115. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +1 -1
  116. package/src/engine/graphics/load_and_set_cubemap_v0.js +1 -1
  117. package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
  118. package/src/engine/graphics/render/Lines.js +1 -1
  119. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
  120. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +1 -1
  121. package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
  122. package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
  123. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  124. package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +1 -1
  125. package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +1 -1
  126. package/src/engine/graphics/render/view/CameraView.js +1 -1
  127. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  128. package/src/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +1 -1
  129. package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +1 -1
  130. package/src/engine/graphics/sh3/LightProbeVolume.js +1 -1
  131. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
  132. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  133. package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +1 -1
  134. package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
  135. package/src/engine/graphics/texture/3d/scs3d_read_2d_slice.js +1 -1
  136. package/src/engine/graphics/texture/CanvasClone.js +5 -1
  137. package/src/engine/graphics/texture/sampler/Sampler2D.js +14 -75
  138. package/src/engine/graphics/texture/sampler/bicubic.js +19 -19
  139. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.spec.js +10 -0
  140. package/src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.spec.js +90 -0
  141. package/src/engine/graphics/texture/sampler/differenceSampler.js +13 -8
  142. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +140 -0
  143. package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_NaiveFlood.js +130 -0
  144. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.js +10 -0
  145. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField.spec.js +183 -0
  146. package/src/engine/graphics/texture/sampler/distance/computeUnsignedDistanceField_Chamfer.js +133 -0
  147. package/src/engine/graphics/texture/sampler/filter/kaiser_1.js +8 -4
  148. package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +2 -0
  149. package/src/engine/graphics/texture/sampler/filter/mitchell.js +4 -0
  150. package/src/engine/graphics/texture/sampler/loadSampler2D.js +5 -2
  151. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +8 -3
  152. package/src/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.spec.js +13 -0
  153. package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min_indices.js +58 -0
  154. package/src/engine/graphics/trail/TemporalPath.js +0 -36
  155. package/src/engine/intelligence/behavior/composite/ParallelBehavior.spec.js +12 -12
  156. package/src/engine/intelligence/behavior/composite/SequenceBehavior.spec.js +17 -0
  157. package/src/engine/intelligence/behavior/primitive/SucceedingBehavior.js +2 -0
  158. package/src/engine/knowledge/database/StaticKnowledgeDataTable.d.ts +7 -1
  159. package/src/engine/knowledge/database/StaticKnowledgeDataTable.spec.js +21 -0
  160. package/src/engine/knowledge/database/StaticKnowledgeDataTableDescriptor.d.ts +2 -2
  161. package/src/engine/logging/ConsoleLoggerBackend.js +4 -0
  162. package/src/engine/logging/VoidLoggerBackend.js +12 -0
  163. package/src/engine/navigation/ecs/components/computeCatmullRomSpline.js +1 -1
  164. package/src/engine/navigation/ecs/components/computeCatmullRomSplineUniformDistance.js +1 -1
  165. package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +1 -1
  166. package/src/engine/save/GameStateLoader.js +1 -1
  167. package/src/engine/scene/Scene.d.ts +2 -0
  168. package/src/engine/scene/Scene.js +2 -2
  169. package/src/engine/scene/Scene.spec.js +20 -0
  170. package/src/engine/scene/SceneManager.d.ts +4 -0
  171. package/src/engine/scene/SceneManager.js +46 -23
  172. package/src/engine/scene/SceneManager.spec.js +107 -0
  173. package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +2 -2
  174. package/src/engine/ui/GUIEngine.js +1 -1
  175. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +11 -4
  176. package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.spec.js +30 -0
  177. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +18 -2
  178. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.spec.js +17 -0
  179. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -2
  180. package/src/generation/grid/GridData.js +0 -60
  181. package/src/generation/grid/generation/util/buildUnsignedDistanceField.js +3 -1
  182. package/src/generation/markers/MarkerNode.js +2 -2
  183. package/src/generation/theme/AreaMask.js +3 -1
  184. package/src/view/elements/progress/RectangularPieProgressView.js +8 -6
  185. package/src/core/geom/2d/LineSegment2.js +0 -175
  186. package/src/core/geom/Matrix4.js +0 -275
  187. package/src/engine/graphics/texture/sampler/distanceField.js +0 -411
  188. package/src/engine/graphics/texture/sampler/distanceField.spec.js +0 -184
  189. package/src/engine/physics/cannon/cannon.min.js +0 -27
  190. /package/src/engine/ecs/{animation → ik}/IKMath.js +0 -0
  191. /package/src/engine/ecs/{animation → ik}/IKProblem.js +0 -0
  192. /package/src/engine/ecs/{animation → ik}/IKSolver.js +0 -0
  193. /package/src/engine/ecs/{animation → ik}/InverseKinematics.js +0 -0
  194. /package/src/engine/ecs/{animation → ik}/InverseKinematicsSystem.js +0 -0
  195. /package/src/engine/ecs/{animation → ik}/OneBoneSurfaceAlignmentSolver.js +0 -0
  196. /package/src/engine/ecs/{animation → ik}/TwoBoneInverseKinematicsSolver.js +0 -0
  197. /package/src/engine/physics/spring/{Spring.js → computeHookeForce.js} +0 -0
@@ -4,157 +4,10 @@
4
4
 
5
5
 
6
6
  import List from '../../../core/collection/list/List.js';
7
- import ObservedString from "../../../core/model/ObservedString.js";
8
- import ObservedInteger from "../../../core/model/ObservedInteger.js";
9
- import Vector1 from "../../../core/geom/Vector1.js";
10
- import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
11
7
  import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
12
8
  import { computeHashFloat } from "../../../core/primitives/numbers/computeHashFloat.js";
13
-
14
- /**
15
- *
16
- * @enum {number}
17
- */
18
- export const AnimationClipFlag = {
19
- ClampWhenFinished: 1
20
- };
21
-
22
- class AnimationClip {
23
- constructor() {
24
- this.name = new ObservedString("");
25
- this.repeatCount = new ObservedInteger(1);
26
-
27
- /**
28
- *
29
- * @type {Vector1}
30
- */
31
- this.weight = new Vector1(1);
32
-
33
- /**
34
- *
35
- * @type {Vector1}
36
- */
37
- this.timeScale = new Vector1(1);
38
-
39
- /**
40
- *
41
- * @type {number}
42
- */
43
- this.flags = 0;
44
- }
45
-
46
- /**
47
- *
48
- * @param {AnimationClip} other
49
- * @returns {boolean}
50
- */
51
- equals(other) {
52
- return this.name.equals(other.name)
53
- && this.repeatCount.equals(other.repeatCount)
54
- && this.weight.equals(other.weight)
55
- && this.timeScale.equals(other.timeScale)
56
- && this.flags === other.flags;
57
- }
58
-
59
- /**
60
- *
61
- * @returns {number}
62
- */
63
- hash() {
64
- return computeHashIntegerArray(
65
- this.name.hash(),
66
- this.repeatCount.hash(),
67
- this.weight.hash(),
68
- this.timeScale.hash(),
69
- this.flags
70
- );
71
- }
72
-
73
- /**
74
- *
75
- * @param {number|AnimationClipFlag} v
76
- * @returns {boolean}
77
- */
78
- getFlag(v) {
79
- return (this.flags & v) !== 0;
80
- }
81
-
82
- fromJSON(json) {
83
- if (typeof json.name === "string") {
84
- this.name.fromJSON(json.name);
85
- }
86
-
87
- if (typeof json.repeatCount === "number") {
88
- this.repeatCount.fromJSON(json.repeatCount);
89
- } else {
90
- this.repeatCount.set(Number.POSITIVE_INFINITY);
91
- }
92
-
93
- if (typeof json.weight === "number") {
94
- this.weight.fromJSON(json.weight);
95
- } else {
96
- this.weight.set(1);
97
- }
98
-
99
- if (typeof json.timeScale === "number") {
100
- this.timeScale.fromJSON(json.timeScale);
101
- } else {
102
- this.timeScale.set(1);
103
- }
104
-
105
- if (typeof json.flags === "number") {
106
- this.flags = json.flags;
107
- } else {
108
- this.flags = 0;
109
- }
110
- }
111
-
112
- toJSON() {
113
- return {
114
- name: this.name.toJSON(),
115
- repeatCount: this.repeatCount.toJSON(),
116
- weight: this.weight.toJSON(),
117
- timeScale: this.timeScale.toJSON(),
118
- flags: this.flags
119
- };
120
- }
121
-
122
- /**
123
- *
124
- * @param {BinaryBuffer} buffer
125
- */
126
- toBinaryBuffer(buffer) {
127
- //write flags
128
- buffer.writeUint8(this.flags);
129
-
130
- this.name.toBinaryBuffer(buffer);
131
- this.repeatCount.toBinaryBuffer(buffer);
132
- this.weight.toBinaryBuffer(buffer);
133
- this.timeScale.toBinaryBuffer(buffer);
134
- }
135
-
136
- /**
137
- *
138
- * @param {BinaryBuffer} buffer
139
- */
140
- fromBinaryBuffer(buffer) {
141
- this.flags = buffer.readUint8();
142
-
143
- this.name.fromBinaryBuffer(buffer);
144
- this.repeatCount.fromBinaryBuffer(buffer);
145
- this.weight.fromBinaryBuffer(buffer);
146
- this.timeScale.fromBinaryBuffer(buffer);
147
- }
148
- }
149
-
150
- /**
151
- *
152
- * @enum {number}
153
- */
154
- export const AnimationFlags = {
155
- Playing: 1,
156
- MeshSizeCulling: 2
157
- };
9
+ import { AnimationClip } from "./AnimationClip.js";
10
+ import { AnimationFlags } from "./AnimationFlags.js";
158
11
 
159
12
  /**
160
13
  * @class
@@ -308,8 +161,6 @@ export class Animation {
308
161
 
309
162
  }
310
163
 
311
- Animation.Clip = AnimationClip;
312
-
313
164
  /**
314
165
  *
315
166
  * @param json
@@ -324,32 +175,3 @@ Animation.fromJSON = function (json) {
324
175
  };
325
176
 
326
177
  Animation.typeName = "Animation";
327
-
328
- export class AnimationSerializationAdapter extends BinaryClassSerializationAdapter {
329
- constructor() {
330
- super();
331
-
332
- this.klass = Animation;
333
- this.version = 0;
334
- }
335
-
336
- /**
337
- *
338
- * @param {BinaryBuffer} buffer
339
- * @param {Animation} value
340
- */
341
- serialize(buffer, value) {
342
- value.clips.toBinaryBuffer(buffer);
343
- buffer.writeFloat64(value.debtTime);
344
- }
345
-
346
- /**
347
- *
348
- * @param {BinaryBuffer} buffer
349
- * @param {Animation} value
350
- */
351
- deserialize(buffer, value) {
352
- value.clips.fromBinaryBuffer(buffer, AnimationClip);
353
- value.debtTime = buffer.readFloat64();
354
- }
355
- }
@@ -0,0 +1,132 @@
1
+ import ObservedString from "../../../core/model/ObservedString.js";
2
+ import ObservedInteger from "../../../core/model/ObservedInteger.js";
3
+ import Vector1 from "../../../core/geom/Vector1.js";
4
+ import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
5
+
6
+ export class AnimationClip {
7
+ constructor() {
8
+ this.name = new ObservedString("");
9
+ this.repeatCount = new ObservedInteger(1);
10
+
11
+ /**
12
+ *
13
+ * @type {Vector1}
14
+ */
15
+ this.weight = new Vector1(1);
16
+
17
+ /**
18
+ *
19
+ * @type {Vector1}
20
+ */
21
+ this.timeScale = new Vector1(1);
22
+
23
+ /**
24
+ *
25
+ * @type {number}
26
+ */
27
+ this.flags = 0;
28
+ }
29
+
30
+ /**
31
+ *
32
+ * @param {AnimationClip} other
33
+ * @returns {boolean}
34
+ */
35
+ equals(other) {
36
+ return this.name.equals(other.name)
37
+ && this.repeatCount.equals(other.repeatCount)
38
+ && this.weight.equals(other.weight)
39
+ && this.timeScale.equals(other.timeScale)
40
+ && this.flags === other.flags;
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @returns {number}
46
+ */
47
+ hash() {
48
+ return computeHashIntegerArray(
49
+ this.name.hash(),
50
+ this.repeatCount.hash(),
51
+ this.weight.hash(),
52
+ this.timeScale.hash(),
53
+ this.flags
54
+ );
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param {number|AnimationClipFlag} v
60
+ * @returns {boolean}
61
+ */
62
+ getFlag(v) {
63
+ return (this.flags & v) !== 0;
64
+ }
65
+
66
+ fromJSON(json) {
67
+ if (typeof json.name === "string") {
68
+ this.name.fromJSON(json.name);
69
+ }
70
+
71
+ if (typeof json.repeatCount === "number") {
72
+ this.repeatCount.fromJSON(json.repeatCount);
73
+ } else {
74
+ this.repeatCount.set(Number.POSITIVE_INFINITY);
75
+ }
76
+
77
+ if (typeof json.weight === "number") {
78
+ this.weight.fromJSON(json.weight);
79
+ } else {
80
+ this.weight.set(1);
81
+ }
82
+
83
+ if (typeof json.timeScale === "number") {
84
+ this.timeScale.fromJSON(json.timeScale);
85
+ } else {
86
+ this.timeScale.set(1);
87
+ }
88
+
89
+ if (typeof json.flags === "number") {
90
+ this.flags = json.flags;
91
+ } else {
92
+ this.flags = 0;
93
+ }
94
+ }
95
+
96
+ toJSON() {
97
+ return {
98
+ name: this.name.toJSON(),
99
+ repeatCount: this.repeatCount.toJSON(),
100
+ weight: this.weight.toJSON(),
101
+ timeScale: this.timeScale.toJSON(),
102
+ flags: this.flags
103
+ };
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param {BinaryBuffer} buffer
109
+ */
110
+ toBinaryBuffer(buffer) {
111
+ //write flags
112
+ buffer.writeUint8(this.flags);
113
+
114
+ this.name.toBinaryBuffer(buffer);
115
+ this.repeatCount.toBinaryBuffer(buffer);
116
+ this.weight.toBinaryBuffer(buffer);
117
+ this.timeScale.toBinaryBuffer(buffer);
118
+ }
119
+
120
+ /**
121
+ *
122
+ * @param {BinaryBuffer} buffer
123
+ */
124
+ fromBinaryBuffer(buffer) {
125
+ this.flags = buffer.readUint8();
126
+
127
+ this.name.fromBinaryBuffer(buffer);
128
+ this.repeatCount.fromBinaryBuffer(buffer);
129
+ this.weight.fromBinaryBuffer(buffer);
130
+ this.timeScale.fromBinaryBuffer(buffer);
131
+ }
132
+ }
@@ -0,0 +1,5 @@
1
+ import { AnimationClip } from "./AnimationClip.js";
2
+
3
+ test("constructor does not throw", () => {
4
+ expect(() => new AnimationClip()).not.toThrow();
5
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ export const AnimationClipFlag = {
6
+ ClampWhenFinished: 1
7
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @enum {number}
4
+ */
5
+ export const AnimationFlags = {
6
+ Playing: 1,
7
+ MeshSizeCulling: 2
8
+ };
@@ -0,0 +1,32 @@
1
+ import { BinaryClassSerializationAdapter } from "../storage/binary/BinaryClassSerializationAdapter.js";
2
+ import { AnimationClip } from "./AnimationClip.js";
3
+ import { Animation } from "./Animation.js";
4
+
5
+ export class AnimationSerializationAdapter extends BinaryClassSerializationAdapter {
6
+ constructor() {
7
+ super();
8
+
9
+ this.klass = Animation;
10
+ this.version = 0;
11
+ }
12
+
13
+ /**
14
+ *
15
+ * @param {BinaryBuffer} buffer
16
+ * @param {Animation} value
17
+ */
18
+ serialize(buffer, value) {
19
+ value.clips.toBinaryBuffer(buffer);
20
+ buffer.writeFloat64(value.debtTime);
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @param {BinaryBuffer} buffer
26
+ * @param {Animation} value
27
+ */
28
+ deserialize(buffer, value) {
29
+ value.clips.fromBinaryBuffer(buffer, AnimationClip);
30
+ value.debtTime = buffer.readFloat64();
31
+ }
32
+ }
@@ -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
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { max3 } from "../../../core/math/max3.js";
9
9
  import { System } from '../System.js';
10
- import { Animation, AnimationClipFlag, AnimationFlags } from '../animation/Animation.js';
10
+ import { Animation } from '../animation/Animation.js';
11
11
  import Mesh from '../../graphics/ecs/mesh/Mesh.js';
12
12
  import Future, { FutureStates } from '../../../core/process/Future.js';
13
13
 
@@ -25,6 +25,8 @@ import { MeshSystem } from "../../graphics/ecs/mesh/MeshSystem.js";
25
25
  import { projectSphere } from "../../graphics/util/projectSphere.js";
26
26
  import { threeUpdateTransform } from "../../graphics/util/threeUpdateTransform.js";
27
27
  import { MeshEvents } from "../../graphics/ecs/mesh/MeshEvents.js";
28
+ import { AnimationClipFlag } from "../animation/AnimationClipFlag.js";
29
+ import { AnimationFlags } from "../animation/AnimationFlags.js";
28
30
 
29
31
  /**
30
32
  *
@@ -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
+ });