@woosh/meep-engine 2.33.23 → 2.33.24

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 (204) hide show
  1. package/core/bvh2/BinaryNode.js +1 -1
  2. package/core/bvh2/aabb3/AABB3.js +18 -0
  3. package/core/bvh2/aabb3/AABB3Math.js +1 -1
  4. package/core/bvh2/binary/2/BinaryUint32BVH.js +498 -0
  5. package/core/bvh2/binary/2/BinaryUint32BVH.spec.js +54 -0
  6. package/core/bvh2/binary/IndexedBinaryBVH.js +22 -26
  7. package/core/collection/ArrayUtils.js +1 -1
  8. package/core/collection/array/arrayQuickSort.js +9 -6
  9. package/core/collection/array/array_swap.js +22 -0
  10. package/core/collection/array/computeHashArray.js +22 -0
  11. package/core/collection/array/computeHashIntegerArray.js +15 -0
  12. package/core/collection/table/DataType2TypedArrayConstructorMapping.js +15 -0
  13. package/core/color/Color.js +2 -1
  14. package/core/function/FunctionCompiler.js +2 -1
  15. package/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js +9 -33
  16. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
  17. package/core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js +41 -0
  18. package/core/geom/3d/morton/mortonEncode_magicbits.js +2 -1
  19. package/core/geom/3d/morton/reinterpret_float32_as_int32.js +13 -0
  20. package/core/geom/3d/morton/v3_morton_encode_transformed.js +33 -0
  21. package/core/geom/3d/ray/ray_computeNearestPointToPoint.js +37 -0
  22. package/core/geom/3d/shape/AbstractShape3D.js +29 -0
  23. package/core/geom/3d/shape/CompositeShape.js +60 -0
  24. package/core/geom/3d/shape/TransformedShape3D.js +70 -0
  25. package/core/geom/3d/shape/UnitCubeShape3D.js +13 -0
  26. package/core/geom/3d/shape/UnitSphereShape3D.js +16 -0
  27. package/core/geom/AABB2.js +1 -1
  28. package/core/geom/ConicRay.js +3 -1
  29. package/core/geom/LineSegment.js +0 -78
  30. package/core/geom/Matrix4.js +7 -8
  31. package/core/geom/Rectangle.js +2 -1
  32. package/core/geom/Vector1.js +1 -1
  33. package/core/geom/Vector3.js +2 -1
  34. package/core/geom/Vector4.js +2 -1
  35. package/core/geom/random/randomPointInBox.js +7 -3
  36. package/core/geom/random/randomPointInPoint.js +6 -3
  37. package/core/geom/random/randomPointInSphere.js +6 -3
  38. package/core/geom/random/randomPointOnBox.js +7 -3
  39. package/core/geom/random/randomPointOnSphere.js +6 -3
  40. package/core/geom/v3_length.js +8 -3
  41. package/core/graph/graph_k_means_cluster.js +1 -1
  42. package/core/math/MathUtils.js +0 -354
  43. package/core/math/MathUtils.spec.js +7 -1
  44. package/core/math/gaussian.js +9 -0
  45. package/core/math/hash/computeHashFloat.js +17 -0
  46. package/core/math/hash/computeHashFloatArray.js +34 -0
  47. package/core/math/hash/computeObjectHash.js +54 -0
  48. package/core/math/intersects1D.js +19 -0
  49. package/core/math/interval/NumericInterval.js +2 -2
  50. package/core/math/isValueBetween.js +10 -0
  51. package/core/math/isValueBetweenInclusive.js +10 -0
  52. package/core/math/noise/curl_noise_3dt.js +1 -1
  53. package/core/math/noise/sdnoise.js +10 -10
  54. package/core/math/overlap1D.js +19 -0
  55. package/core/math/pingpong.js +17 -0
  56. package/core/math/random/makeRangedRandom.js +19 -0
  57. package/core/math/random/randomFloatBetween.js +14 -0
  58. package/core/math/random/randomFromArray.js +19 -0
  59. package/core/math/random/randomGaussian.js +15 -0
  60. package/core/math/random/randomIntegerBetween.js +14 -0
  61. package/core/math/random/roundFair.js +15 -0
  62. package/core/math/separation1D.js +21 -0
  63. package/core/math/solveQuadratic.js +25 -0
  64. package/core/model/BoundedValue.js +1 -1
  65. package/core/model/node-graph/node/NodeInstancePortReference.js +1 -1
  66. package/core/model/node-graph/node/Port.js +1 -1
  67. package/core/model/reactive/evaluation/MultiPredicateEvaluator.spec.js +3 -1
  68. package/core/model/reactive/model/ReactiveBinaryExpression.js +1 -1
  69. package/core/model/reactive/model/terminal/ReactiveLiteralNumber.js +1 -1
  70. package/core/model/reactive/model/terminal/ReactiveReference.js +1 -1
  71. package/core/model/reactive/model/util/createRandomReactiveExpression.js +1 -1
  72. package/core/model/stat/LinearModifier.js +1 -1
  73. package/engine/animation/curve/AnimationCurve.js +72 -0
  74. package/engine/animation/curve/Keyframe.js +27 -0
  75. package/engine/animation/keyed2/AnimationTrack.js +27 -3
  76. package/engine/asset/Asset.js +1 -1
  77. package/engine/asset/loaders/GLTFAssetLoader.d.ts +1 -1
  78. package/engine/asset/loaders/GLTFAssetLoader.js +10 -0
  79. package/engine/asset/loaders/image/ImageRGBADataAsset.js +8 -1
  80. package/engine/asset/loaders/material/computeMaterialHash.js +3 -1
  81. package/engine/asset/loaders/material/computeTextureHash.js +2 -1
  82. package/engine/ecs/animation/Animation.js +2 -1
  83. package/engine/ecs/animation/InverseKinematics.js +2 -1
  84. package/engine/ecs/dynamic_actions/DynamicActorSystem.js +2 -1
  85. package/engine/ecs/dynamic_actions/DynamicRuleDescriptionTable.spec.js +3 -5
  86. package/engine/ecs/dynamic_actions/actions/definition/WeightedRandomActionDescription.js +1 -1
  87. package/engine/ecs/evaluation/complex/PointFitnessGaussianBlur.js +1 -1
  88. package/engine/ecs/foliage/ecs/Foliage2.js +1 -1
  89. package/engine/ecs/fow/shader/FogOfWarRenderer.js +1 -1
  90. package/engine/ecs/gui/GUIElement.js +1 -1
  91. package/engine/ecs/gui/hud/HeadsUpDisplay.js +1 -1
  92. package/engine/ecs/gui/position/ViewportPosition.js +2 -1
  93. package/engine/ecs/systems/RangedAttackSystem.js +1 -1
  94. package/engine/ecs/systems/SteeringSystem.js +1 -1
  95. package/engine/ecs/terrain/tiles/TerrainTileManager.js +1 -1
  96. package/engine/ecs/tooltip/TooltipComponent.js +15 -0
  97. package/engine/graphics/ecs/animation/animator/AnimationClip.js +2 -1
  98. package/engine/graphics/ecs/animation/animator/AnimationClipDefinition.js +2 -1
  99. package/engine/graphics/ecs/animation/animator/AnimationNotification.js +2 -1
  100. package/engine/graphics/ecs/animation/animator/AnimationNotificationDefinition.js +2 -1
  101. package/engine/graphics/ecs/animation/animator/graph/AnimationGraph.js +2 -1
  102. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationGraphDefinition.js +2 -1
  103. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationStateDefinition.js +1 -1
  104. package/engine/graphics/ecs/animation/animator/graph/definition/AnimationTransitionDefinition.js +2 -1
  105. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  106. package/engine/graphics/ecs/highlight/HighlightDefinition.js +2 -1
  107. package/engine/graphics/ecs/light/Light.d.ts +1 -1
  108. package/engine/graphics/ecs/light/Light.js +3 -0
  109. package/engine/graphics/ecs/mesh/Mesh.js +2 -1
  110. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +13 -0
  111. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts +6 -0
  112. package/engine/graphics/geometry/AttributeSpec.js +105 -0
  113. package/engine/graphics/{micron/format/MicronVertexDataSpec.js → geometry/VertexDataSpec.js} +56 -25
  114. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +7 -7
  115. package/engine/graphics/micron/build/fill_patch_geometry_data.js +1 -1
  116. package/engine/graphics/micron/buildPatchwork.js +1 -1
  117. package/engine/graphics/micron/format/MicronGeometry.js +3 -3
  118. package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +2 -2
  119. package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
  120. package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
  121. package/engine/graphics/micron/render/PatchCacheKey.js +1 -1
  122. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +5 -5
  123. package/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
  124. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +80 -16
  125. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +57 -52
  126. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +2 -1
  127. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +51 -12
  128. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -2
  129. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +1 -1
  130. package/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +8 -2
  131. package/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -1
  132. package/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +1 -1
  133. package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +1 -1
  134. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +21 -0
  135. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +0 -20
  136. package/engine/graphics/particles/particular/engine/renderers/billboard/prototypeBillboardRenderer.js +9 -9
  137. package/engine/graphics/particles/particular/engine/simulator/SimulationStepApplyForce.js +2 -5
  138. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseAcceleration.js +2 -6
  139. package/engine/graphics/particles/particular/engine/simulator/SimulationStepCurlNoiseVelocity.js +2 -7
  140. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +2 -5
  141. package/engine/graphics/particles/particular/engine/simulator/update_parameters.js +1 -1
  142. package/engine/graphics/particles/particular/engine/utils/distributeParticlesOnObject3D.js +1 -1
  143. package/engine/graphics/particles/particular/engine/utils/distrubuteParticlesOnMesh.js +1 -1
  144. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +384 -0
  145. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +558 -0
  146. package/engine/graphics/particles/particular/group/Operation.js +18 -0
  147. package/engine/graphics/particles/particular/group/OperationType.js +9 -0
  148. package/engine/graphics/particles/particular/group/ParticleAttribute.js +2 -1
  149. package/engine/graphics/particles/particular/group/ParticleAttributeType.js +11 -0
  150. package/engine/graphics/particles/particular/group/ParticleDataType.js +10 -0
  151. package/engine/graphics/particles/particular/group/ParticleGroup.js +7 -245
  152. package/engine/graphics/particles/particular/group/ParticleGroup.spec.js +3 -1
  153. package/engine/graphics/particles/particular/group/ParticleSpecification.js +21 -14
  154. package/engine/graphics/particles/particular/group/itemSizeFromAttributeType.js +20 -0
  155. package/engine/graphics/particles/particular/group/optimizeCommandQueue.js +162 -0
  156. package/engine/graphics/particles/particular/group/typedArrayConstructorFromDataType.js +19 -0
  157. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +1 -1
  158. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameter.js +2 -1
  159. package/engine/graphics/render/buffer/slot/parameter/ProgramValueSlotParameterSet.js +1 -1
  160. package/engine/graphics/render/forward_plus/LightManager.js +117 -94
  161. package/engine/graphics/render/forward_plus/PointLight.js +9 -0
  162. package/engine/graphics/render/forward_plus/PointLightData.js +1 -1
  163. package/engine/graphics/render/forward_plus/SpotLight.js +9 -0
  164. package/engine/graphics/render/forward_plus/cluster/compute_light_data_hash_0.js +2 -2
  165. package/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +1 -1
  166. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +5 -5
  167. package/engine/graphics/render/forward_plus/prototypeLightManager.js +180 -86
  168. package/engine/graphics/render/forward_plus/query/analytical_triplanar_corner_mapping.js +8 -0
  169. package/engine/graphics/render/forward_plus/query/cube_mapping.js +38 -0
  170. package/engine/graphics/render/forward_plus/query/detailed_sphere_frustum_intersection_test.js +86 -0
  171. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +73 -0
  172. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +131 -0
  173. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +129 -0
  174. package/engine/graphics/render/forward_plus/query/spot_light_inside_volume.js +33 -0
  175. package/engine/graphics/render/forward_plus/read_frustum_corner.js +14 -0
  176. package/engine/graphics/render/forward_plus/testClusterEquality.js +22 -0
  177. package/engine/graphics/render/visibility/IncrementalDeltaSet.js +11 -0
  178. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  179. package/engine/graphics/texture/sampler/HarmonicDiffusionGrid.spec.js +1 -1
  180. package/engine/graphics/texture/sampler/SampleTraverser.js +1 -1
  181. package/engine/graphics/texture/sampler/distanceField.spec.js +1 -1
  182. package/engine/grid/components/GridObstacle.js +1 -1
  183. package/engine/intelligence/behavior/selector/WeightedElement.js +2 -1
  184. package/engine/intelligence/optimization/RandomOptimizer.js +1 -1
  185. package/engine/navigation/ecs/components/Path.js +1 -1
  186. package/engine/navigation/grid/FastBinaryHeap.spec.js +1 -1
  187. package/engine/sound/ecs/emitter/SoundEmitter.js +2 -1
  188. package/engine/sound/ecs/emitter/SoundTrack.js +2 -1
  189. package/engine/sound/material/concrete/RandomSoundMaterial.js +1 -1
  190. package/engine/ui/notification/notificationGenerator.js +1 -1
  191. package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +1 -1
  192. package/generation/grid/generation/GridTaskExecuteRuleTimes.js +2 -1
  193. package/generation/markers/actions/MarkerNodeActionSelectRandom.js +1 -1
  194. package/generation/markers/transform/MarkerNodeTransformerRecordUniqueRandomEnum.js +1 -1
  195. package/generation/placement/action/random/CellActionSelectRandom.js +1 -1
  196. package/generation/theme/ThemeEngine.js +1 -1
  197. package/misc/makeMaterialIconCached.js +2 -2
  198. package/package.json +1 -1
  199. package/view/elements/image/HTMLElementCacheKey.js +2 -1
  200. package/view/elements/radial/RadialText.js +2 -1
  201. package/view/minimap/gl/MinimapMarkersGL.js +6 -100
  202. package/view/minimap/gl/buildMaterial.js +94 -0
  203. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +0 -71
  204. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +0 -357
@@ -0,0 +1,131 @@
1
+ import { aabb3_computeDistanceAbovePlane } from "../../../../../core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js";
2
+ import { point_light_inside_volume } from "./point_light_inside_volume.js";
3
+ import { spot_light_inside_volume } from "./spot_light_inside_volume.js";
4
+
5
+ /**
6
+ *
7
+ * @type {(BinaryNode|LeafNode)[]}
8
+ */
9
+ const stack = [];
10
+
11
+ let stackPointer = 0;
12
+
13
+ /**
14
+ * Most of the data is in flat continuous array for cache coherence
15
+ * @param {PointLightData[]} destination
16
+ * @param {number} destination_offset
17
+ * @param {BinaryNode<PointLightData>} root
18
+ * @param {number[]|Float32Array|Float64Array} planes
19
+ * @param {number[]|Float32Array|Float64Array} points
20
+ * @returns {number} number of items added to the destination, non-negative integer
21
+ */
22
+ export function query_bvh_frustum_from_objects(
23
+ destination,
24
+ destination_offset,
25
+ root, planes, points
26
+ ) {
27
+ let i = 0;
28
+ let j = 0;
29
+ // read out points
30
+ const stackOffset = stackPointer;
31
+
32
+ stack[stackPointer] = root;
33
+
34
+ stackPointer++;
35
+
36
+ stack_loop:while (stackPointer-- > stackOffset) {
37
+
38
+ // query_bvh_frustum_from_objects.iteration_count++;
39
+
40
+ const n = stack[stackPointer];
41
+
42
+ if (n.isBinaryNode === true) {
43
+
44
+ for (j = 0; j < 6; j++) {
45
+
46
+ const plane_address = j * 4;
47
+
48
+ const plane_normal_x = planes[plane_address];
49
+ const plane_normal_y = planes[plane_address + 1];
50
+ const plane_normal_z = planes[plane_address + 2];
51
+ const plane_constant = planes[plane_address + 3];
52
+
53
+ const distanceAbovePlane = aabb3_computeDistanceAbovePlane(
54
+ plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
55
+ n.x0, n.y0, n.z0,
56
+ n.x1, n.y1, n.z1
57
+ );
58
+
59
+ if (distanceAbovePlane < 0) {
60
+ // node is below the plane
61
+
62
+ // query_bvh_frustum_from_objects.rejection_count++;
63
+
64
+ continue stack_loop;
65
+ }
66
+ }
67
+
68
+
69
+ if (n.right !== null) {
70
+ stack[stackPointer] = n.right;
71
+ stackPointer++;
72
+ }
73
+
74
+ if (n.left !== null) {
75
+ stack[stackPointer] = n.left;
76
+ stackPointer++
77
+ }
78
+
79
+ } else {
80
+
81
+ // leaf node
82
+
83
+ /**
84
+ *
85
+ * @type {PointLightData}
86
+ */
87
+ const light_data = n.object;
88
+
89
+ const light = light_data.light;
90
+
91
+ if (light.isPointLight) {
92
+
93
+ const light_position = light.position;
94
+
95
+ const light_x = light_position.x;
96
+ const light_y = light_position.y;
97
+ const light_z = light_position.z;
98
+
99
+ const radius = light.radius.getValue();
100
+
101
+ if (!point_light_inside_volume(light_x, light_y, light_z, radius, points, planes)) {
102
+ continue;
103
+ }
104
+ } else if (light.isSpotLight) {
105
+ if (!spot_light_inside_volume(light, points, planes)) {
106
+ continue;
107
+ }
108
+ }
109
+
110
+ destination[destination_offset + i] = light_data;
111
+
112
+ i++;
113
+ }
114
+
115
+ }
116
+
117
+ //drop the stack frame
118
+ stackPointer = stackOffset;
119
+
120
+ return i;
121
+ }
122
+
123
+ query_bvh_frustum_from_objects.iteration_count = 0;
124
+ query_bvh_frustum_from_objects.rejection_count = 0;
125
+ query_bvh_frustum_from_objects.rejection_sphere_count = 0;
126
+ query_bvh_frustum_from_objects.plane_tests = 0;
127
+ query_bvh_frustum_from_objects.plane_tests_early_exits = 0;
128
+ query_bvh_frustum_from_objects.checks_sphere = 0;
129
+ query_bvh_frustum_from_objects.checks_sphere_plane = 0;
130
+ query_bvh_frustum_from_objects.checks_sphere_frustum_corner = 0;
131
+ query_bvh_frustum_from_objects.checks_sphere_frustum_edge = 0;
@@ -0,0 +1,129 @@
1
+ import { aabb3_computeDistanceAbovePlane } from "../../../../../core/geom/3d/aabb/aabb3_computeDistanceAbovePlane.js";
2
+ import { point_light_inside_volume } from "./point_light_inside_volume.js";
3
+ import { BVH_BINARY_NODE_SIZE, BVH_LEAF_NODE_SIZE } from "../../../../../core/bvh2/binary/2/BinaryUint32BVH.js";
4
+
5
+ /**
6
+ *
7
+ * @type {number[]}
8
+ */
9
+ const stack = [];
10
+
11
+ /**
12
+ * Most of the data is in flat continuous array for cache coherence
13
+ * @param {number[]} destination
14
+ * @param {number} destination_offset
15
+ * @param {BinaryUint32BVH} root
16
+ * @param {number[]|Uint8ClampedArray} source_data
17
+ * @param {number[]|Float32Array|Float64Array} planes
18
+ * @param {number[]|Float32Array|Float64Array} points
19
+ * @returns {number} number of items added to the destination, non-negative integer
20
+ */
21
+ export function query_bvh_frustum_from_texture(
22
+ destination,
23
+ destination_offset,
24
+ root,
25
+ source_data,
26
+ planes, points
27
+ ) {
28
+
29
+ let stackPointer = 1;
30
+ let result = 0;
31
+
32
+ /**
33
+ * After performing empirical tests, stack-based depth-first traversal turns out faster than using a queue
34
+ * @type {number}
35
+ */
36
+ stack[0] = 0;
37
+
38
+ const binary_node_count = root.getBinaryNodeCount();
39
+ const last_valid_index = binary_node_count + root.getLeafNodeCount();
40
+ const data_view = root.getDataView();
41
+
42
+ stack_loop:while (stackPointer-- > 0) {
43
+
44
+ // query_bvh_frustum_from_objects.iteration_count++;
45
+ const node_index = stack[stackPointer];
46
+
47
+ if (node_index < binary_node_count) {
48
+ // is intermediate node
49
+ const node_address = node_index * BVH_BINARY_NODE_SIZE;
50
+
51
+ const n_x0 = data_view.getFloat32(node_address);
52
+ const n_y0 = data_view.getFloat32(node_address + 4);
53
+ const n_z0 = data_view.getFloat32(node_address + 8);
54
+ const n_x1 = data_view.getFloat32(node_address + 12);
55
+ const n_y1 = data_view.getFloat32(node_address + 16);
56
+ const n_z1 = data_view.getFloat32(node_address + 20);
57
+
58
+ for (let j = 0; j < 6; j++) {
59
+
60
+ const plane_address = j * 4;
61
+
62
+ const plane_normal_x = planes[plane_address];
63
+ const plane_normal_y = planes[plane_address + 1];
64
+ const plane_normal_z = planes[plane_address + 2];
65
+ const plane_constant = planes[plane_address + 3];
66
+
67
+ const distanceAbovePlane = aabb3_computeDistanceAbovePlane(
68
+ plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
69
+ n_x0, n_y0, n_z0,
70
+ n_x1, n_y1, n_z1
71
+ );
72
+
73
+ if (distanceAbovePlane < 0) {
74
+ // node is below the plane
75
+
76
+ // query_bvh_frustum_from_objects.rejection_count++;
77
+
78
+ continue stack_loop;
79
+ }
80
+
81
+ // TODO under current scheme we can reserve 6 bit in what we push onto the stack for plane mask (allows us to skip some planar tests)
82
+ }
83
+
84
+ const left_index = (node_index << 1) + 1;
85
+ const right_index = left_index + 1;
86
+
87
+ if (left_index < last_valid_index) {
88
+ stack[stackPointer] = left_index;
89
+ stackPointer++;
90
+ }
91
+
92
+ if (right_index < last_valid_index) {
93
+ stack[stackPointer] = right_index;
94
+ stackPointer++;
95
+ }
96
+
97
+
98
+ } else {
99
+ // leaf node
100
+ const leaf_index = node_index - binary_node_count;
101
+ const node_address = leaf_index * BVH_LEAF_NODE_SIZE + binary_node_count * BVH_BINARY_NODE_SIZE;
102
+
103
+ const light_index = data_view.getUint32(node_address + 24);
104
+
105
+ const light_address = light_index * 8;
106
+
107
+ // TODO figure out light type from address
108
+
109
+
110
+ const light_x = source_data[light_address];
111
+ const light_y = source_data[light_address + 1];
112
+ const light_z = source_data[light_address + 2];
113
+
114
+ const radius = source_data[light_address + 3];
115
+
116
+ if (!point_light_inside_volume(light_x, light_y, light_z, radius, points, planes)) {
117
+ continue;
118
+ }
119
+
120
+ // write to output
121
+ destination[destination_offset + result] = light_index;
122
+
123
+ result++;
124
+ }
125
+
126
+ }
127
+
128
+ return result;
129
+ }
@@ -0,0 +1,33 @@
1
+ import { computeConePlaneSide } from "../../../../../core/geom/3d/cone/computeConePlaneSide.js";
2
+
3
+ /**
4
+ *
5
+ * @param {SpotLight} light
6
+ * @param {number[]} points
7
+ * @param {number[]|Float32Array|Float64Array} planes
8
+ * @returns {boolean}
9
+ */
10
+ export function spot_light_inside_volume(light, points, planes) {
11
+ for (let j = 0; j < 6; j++) {
12
+
13
+ const plane_address = j * 4;
14
+
15
+ const plane_normal_x = planes[plane_address];
16
+ const plane_normal_y = planes[plane_address + 1];
17
+ const plane_normal_z = planes[plane_address + 2];
18
+ const plane_constant = planes[plane_address + 3];
19
+
20
+ const side = computeConePlaneSide(
21
+ plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
22
+ light.position.x, light.position.y, light.position.z,
23
+ light.direction.x, light.direction.y, light.direction.z,
24
+ light.angle.getValue(), light.distance.getValue()
25
+ );
26
+
27
+ if (side < 0) {
28
+ return false;
29
+ }
30
+ }
31
+
32
+ return true;
33
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float32Array|Float64Array} source
4
+ * @param {number} source_index
5
+ * @param {number[]|Float32Array|Float64Array} destination
6
+ * @param {number} destination_offset
7
+ */
8
+ export function read_frustum_corner(source, source_index, destination, destination_offset) {
9
+ const address = source_index * 3;
10
+
11
+ destination[destination_offset] = source[address];
12
+ destination[destination_offset + 1] = source[address + 1];
13
+ destination[destination_offset + 2] = source[address + 2];
14
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * @param {number[]} light_data
4
+ * @param {number} count
5
+ * @param {number[]|Uint32Array|Uint16Array|Uint8Array|Uint8ClampedArray} light_lookup_texture_data
6
+ * @param {number} address
7
+ * @returns {boolean}
8
+ */
9
+ export function testClusterEquality(light_data, count, light_lookup_texture_data, address) {
10
+ for (let i = 0; i < count; i++) {
11
+
12
+ const existing_light_address = light_lookup_texture_data[address + i];
13
+
14
+ const datum = light_data[i] * 2;
15
+
16
+ if (datum !== existing_light_address) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ return true;
22
+ }
@@ -2,6 +2,7 @@ import { BitSet } from "../../../../core/binary/BitSet.js";
2
2
  import Signal from "../../../../core/events/signal/Signal.js";
3
3
  import { assert } from "../../../../core/assert.js";
4
4
  import { IllegalStateException } from "../../../../core/fsm/exceptions/IllegalStateException.js";
5
+ import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
5
6
 
6
7
  /**
7
8
  * @readonly
@@ -68,6 +69,16 @@ export class IncrementalDeltaSet {
68
69
  this.state = IncrementalDeltaSetState.Clear;
69
70
  }
70
71
 
72
+
73
+ /**
74
+ *
75
+ * @param {function(T):number} score_function
76
+ * @param {*} [score_context]
77
+ */
78
+ sort(score_function, score_context) {
79
+ arrayQuickSort(this.elements, score_function, score_context, 0, this.size - 1);
80
+ }
81
+
71
82
  /**
72
83
  *
73
84
  * @param {V} element
@@ -62,7 +62,6 @@ import { buildCanvasViewFromTexture } from "./buildCanvasViewFromTexture.js";
62
62
  import { BatchOcclusionQuery } from "./query/BatchOcclusionQuery.js";
63
63
  import HeadsUpDisplay from "../../../../ecs/gui/hud/HeadsUpDisplay.js";
64
64
  import LabelView from "../../../../../view/common/LabelView.js";
65
- import { randomFloatBetween } from "../../../../../core/math/MathUtils.js";
66
65
  import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
67
66
  import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
68
67
  import { inverseLerp } from "../../../../../core/math/inverseLerp.js";
@@ -71,6 +70,7 @@ import { max2 } from "../../../../../core/math/max2.js";
71
70
  import { min2 } from "../../../../../core/math/min2.js";
72
71
  import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
73
72
  import { mat4 } from "gl-matrix";
73
+ import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
74
74
 
75
75
  const engineHarness = new EngineHarness();
76
76
 
@@ -1,6 +1,6 @@
1
1
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
2
2
  import { HarmonicDiffusionGrid } from "./HarmonicDiffusionGrid.js";
3
- import { randomIntegerBetween} from "../../../../core/math/MathUtils.js";
3
+ import { randomIntegerBetween } from "../../../../core/math/random/randomIntegerBetween.js";
4
4
 
5
5
  test("constructor doesn't throw", () => {
6
6
  new HarmonicDiffusionGrid([], 0, 0);
@@ -3,8 +3,8 @@
3
3
  */
4
4
  import QuadTree from '../../../../core/geom/2d/quad-tree/PointQuadTree.js';
5
5
  import AABB2 from '../../../../core/geom/AABB2.js';
6
- import { makeRangedRandom} from '../../../../core/math/MathUtils.js';
7
6
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
7
+ import { makeRangedRandom } from "../../../../core/math/random/makeRangedRandom.js";
8
8
 
9
9
 
10
10
  const Point2 = function (x, y) {
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
2
2
  import { Sampler2D } from "./Sampler2D.js";
3
3
  import { computeUnsignedDistanceField } from "./distanceField.js";
4
- import { randomIntegerBetween} from "../../../../core/math/MathUtils.js";
4
+ import { randomIntegerBetween } from "../../../../core/math/random/randomIntegerBetween.js";
5
5
 
6
6
  describe('computeUnsignedDistanceField', () => {
7
7
  test('empty', () => {
@@ -4,11 +4,11 @@
4
4
 
5
5
 
6
6
  import Vector2 from '../../../core/geom/Vector2.js';
7
- import { computeHashIntegerArray } from "../../../core/math/MathUtils.js";
8
7
  import { assert } from "../../../core/assert.js";
9
8
  import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
10
9
  import { computeIntegerArrayHash } from "../../../core/primitives/array/computeIntegerArrayHash.js";
11
10
  import { isArrayEqualStrict } from "../../../core/collection/array/isArrayEqualStrict.js";
11
+ import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
12
12
 
13
13
  class GridObstacle {
14
14
  constructor() {
@@ -1,7 +1,8 @@
1
- import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
2
1
  import { assert } from "../../../../core/assert.js";
3
2
  import { invokeObjectEquals } from "../../../../core/model/object/invokeObjectEquals.js";
4
3
  import { invokeObjectHash } from "../../../../core/model/object/invokeObjectHash.js";
4
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
5
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
5
6
 
6
7
  export class WeightedElement {
7
8
 
@@ -1,5 +1,5 @@
1
- import { randomFromArray} from "../../../core/math/MathUtils.js";
2
1
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
+ import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
3
3
 
4
4
  /**
5
5
  * Hill climbing optimizer based on random moves
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
 
6
- import { line3_computeSegmentPointDistance_sqr } from "../../../../core/geom/LineSegment.js";
7
6
  import Vector3 from "../../../../core/geom/Vector3.js";
8
7
 
9
8
  import { CatmullRomCurve3 } from "three";
@@ -18,6 +17,7 @@ import { min2 } from "../../../../core/math/min2.js";
18
17
  import { computeNonuniformCatmullRomSplineSample } from "./computeNonuniformCatmullRomSplineSample.js";
19
18
  import { InterpolationType } from "./InterpolationType.js";
20
19
  import { v3_distance } from "../../../../core/geom/v3_distance.js";
20
+ import { line3_computeSegmentPointDistance_sqr } from "../../../../core/geom/3d/line/line3_computeSegmentPointDistance_sqr.js";
21
21
 
22
22
  const v3_a = new Vector3();
23
23
  const v3_b = new Vector3();
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
2
  import BinaryHeap from "./FastBinaryHeap.js";
3
3
  import { passThrough, returnZero } from "../../../core/function/Functions.js";
4
- import { randomIntegerBetween} from "../../../core/math/MathUtils.js";
4
+ import { randomIntegerBetween } from "../../../core/math/random/randomIntegerBetween.js";
5
5
 
6
6
  test("constructor doesn't throw", () => {
7
7
  new BinaryHeap(returnZero);
@@ -10,11 +10,12 @@ import { SoundEmitterFlags } from "./SoundEmitterFlags.js";
10
10
  import { SoundAttenuationFunction } from "./SoundAttenuationFunction.js";
11
11
  import { attenuateSoundLinear } from "./attenuate/attenuateSoundLinear.js";
12
12
  import { attenuateSoundLogarithmic } from "./attenuate/attenuateSoundLogarithmic.js";
13
- import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
14
13
  import { SoundPanningModelType } from "./SoundPanningModelType.js";
15
14
  import { attenuateSoundSmith } from "./attenuate/attenuateSoundSmith.js";
16
15
  import { objectKeyByValue } from "../../../../core/model/object/objectKeyByValue.js";
17
16
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
17
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
18
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
18
19
 
19
20
  /**
20
21
  * Convert decibel to percentage volume
@@ -1,8 +1,9 @@
1
1
  import Signal from "../../../../core/events/signal/Signal.js";
2
2
  import { SoundTrackFlags } from "./SoundTrackFlags.js";
3
- import { computeHashFloat, computeHashIntegerArray } from "../../../../core/math/MathUtils.js";
4
3
  import { assert } from "../../../../core/assert.js";
5
4
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
5
+ import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
6
+ import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
6
7
 
7
8
  const DEFAULT_FLAGS = SoundTrackFlags.StartWhenReady;
8
9
 
@@ -1,6 +1,6 @@
1
1
  import { AbstractSoundMaterialDefinition } from "../AbstractSoundMaterialDefinition.js";
2
- import { randomFromArray } from "../../../../core/math/MathUtils.js";
3
2
  import { SoundAssetPlaybackSpec } from "../../asset/SoundAssetPlaybackSpec.js";
3
+ import { randomFromArray } from "../../../../core/math/random/randomFromArray.js";
4
4
 
5
5
  export class RandomSoundMaterial extends AbstractSoundMaterialDefinition {
6
6
  constructor() {
@@ -1,6 +1,6 @@
1
1
  import { Notification } from "../../notify/Notification.js";
2
- import { randomFromArray } from "../../../core/math/MathUtils.js";
3
2
  import { NotificationAreaKind } from "../GUIEngine.js";
3
+ import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
4
4
 
5
5
  function notificationGenerator(callback, timeout = 5) {
6
6
  const phrases = [
@@ -1,5 +1,5 @@
1
1
  import { CellFilter } from "../../CellFilter.js";
2
- import { gaussian } from "../../../../core/math/MathUtils.js";
2
+ import { gaussian } from "../../../../core/math/gaussian.js";
3
3
 
4
4
  function buildKernel(result, samplesX, samplesY, sigma_x, sigma_y) {
5
5
  const half_samples_x = (samplesX / 2);
@@ -3,9 +3,10 @@ import { GridTaskGenerator } from "../GridTaskGenerator.js";
3
3
  import Task from "../../../core/process/task/Task.js";
4
4
  import TaskSignal from "../../../core/process/task/TaskSignal.js";
5
5
  import { BitSet } from "../../../core/binary/BitSet.js";
6
- import { PI_HALF, randomIntegerBetween} from "../../../core/math/MathUtils.js";
6
+ import { PI_HALF } from "../../../core/math/MathUtils.js";
7
7
  import { actionTask } from "../../../core/process/task/TaskUtils.js";
8
8
  import TaskGroup from "../../../core/process/task/TaskGroup.js";
9
+ import { randomIntegerBetween } from "../../../core/math/random/randomIntegerBetween.js";
9
10
 
10
11
  export class GridTaskExecuteRuleTimes extends GridTaskGenerator {
11
12
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
2
  import { MarkerNodeAction } from "./MarkerNodeAction.js";
3
3
  import { assert } from "../../../core/assert.js";
4
- import { randomFromArray} from "../../../core/math/MathUtils.js";
4
+ import { randomFromArray } from "../../../core/math/random/randomFromArray.js";
5
5
 
6
6
  export class MarkerNodeActionSelectRandom extends MarkerNodeAction {
7
7
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../core/math/random/seededRandom.js";
2
2
  import { MarkerNodeTransformer } from "./MarkerNodeTransformer.js";
3
- import { randomIntegerBetween} from "../../../core/math/MathUtils.js";
4
3
  import { assert } from "../../../core/assert.js";
4
+ import { randomIntegerBetween } from "../../../core/math/random/randomIntegerBetween.js";
5
5
 
6
6
  export class MarkerNodeTransformerRecordUniqueRandomEnum extends MarkerNodeTransformer {
7
7
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import { seededRandom } from "../../../../core/math/random/seededRandom.js";
2
2
  import { GridCellAction } from "../GridCellAction.js";
3
- import { randomFromArray} from "../../../../core/math/MathUtils.js";
4
3
  import { assert } from "../../../../core/assert.js";
4
+ import { randomFromArray } from "../../../../core/math/random/randomFromArray.js";
5
5
 
6
6
  export class CellActionSelectRandom extends GridCellAction {
7
7
  constructor() {
@@ -1,7 +1,6 @@
1
1
  import { QuadTreeNode } from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
2
2
  import { assert } from "../../core/assert.js";
3
3
  import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
4
- import { randomFloatBetween } from "../../core/math/MathUtils.js";
5
4
  import { seededRandom } from "../../core/math/random/seededRandom.js";
6
5
  import { TerrainLayerRuleAggregator } from "./TerrainLayerRuleAggregator.js";
7
6
  import { actionTask, countTask, emptyTask, futureTask } from "../../core/process/task/TaskUtils.js";
@@ -17,6 +16,7 @@ import { HashMap } from "../../core/collection/HashMap.js";
17
16
  import { TerrainLayer } from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.js";
18
17
  import { TerrainFlags } from "../../engine/ecs/terrain/ecs/TerrainFlags.js";
19
18
  import { binarySearchLowIndex } from "../../core/collection/array/binarySearchLowIndex.js";
19
+ import { randomFloatBetween } from "../../core/math/random/randomFloatBetween.js";
20
20
 
21
21
  /**
22
22
  *
@@ -1,8 +1,8 @@
1
1
  import { Cache } from "../core/cache/Cache.js";
2
- import { computeHashIntegerArray } from "../core/math/MathUtils.js";
3
2
  import { computeMaterialEquality } from "../engine/asset/loaders/material/computeMaterialEquality.js";
4
3
  import { computeMaterialHash } from "../engine/asset/loaders/material/computeMaterialHash.js";
5
4
  import { makeMaterialIcon } from "./makeMaterialIcon.js";
5
+ import { computeHashIntegerArray } from "../core/collection/array/computeHashIntegerArray.js";
6
6
 
7
7
  /**
8
8
  *
@@ -47,4 +47,4 @@ export function makeMaterialIconCached(material, renderer, size) {
47
47
  }
48
48
 
49
49
  return sampler;
50
- }
50
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "productName": "Meep",
5
5
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
6
6
  "author": "Alexander Goldring",
7
- "version": "2.33.23",
7
+ "version": "2.33.24",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",
@@ -1,7 +1,8 @@
1
- import { computeHashArray, computeHashIntegerArray } from "../../../core/math/MathUtils.js";
2
1
  import { isArrayEqual } from "../../../core/collection/ArrayUtils.js";
3
2
  import { KeyValuePair } from "../../../core/collection/KeyValuePair.js";
4
3
  import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js";
4
+ import { computeHashArray } from "../../../core/collection/array/computeHashArray.js";
5
+ import { computeHashIntegerArray } from "../../../core/collection/array/computeHashIntegerArray.js";
5
6
 
6
7
  /**
7
8
  *
@@ -1,7 +1,8 @@
1
1
  import View from "../../View.js";
2
2
  import SVG, { svgCircularPath } from "../../SVG.js";
3
- import { isValueBetween, PI2 } from "../../../core/math/MathUtils.js";
3
+ import { PI2 } from "../../../core/math/MathUtils.js";
4
4
  import { assert } from "../../../core/assert.js";
5
+ import { isValueBetween } from "../../../core/math/isValueBetween.js";
5
6
 
6
7
  let idCount = 0;
7
8