@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,16 @@
1
+ import { AbstractShape3D } from "./AbstractShape3D.js";
2
+ import { randomPointInSphere } from "../../random/randomPointInSphere.js";
3
+
4
+ export class UnitSphereShape3D extends AbstractShape3D {
5
+ get volume() {
6
+ return 0.523598776;
7
+ }
8
+
9
+ get surface_area() {
10
+ return 3.14159265;
11
+ }
12
+
13
+ sample_random_point_in_volume(result, result_offset, random) {
14
+ randomPointInSphere(random, result, result_offset);
15
+ }
16
+ }
@@ -6,11 +6,11 @@
6
6
 
7
7
  import { assert } from "../assert.js";
8
8
  import { clamp } from "../math/clamp.js";
9
- import { overlap1D } from "../math/MathUtils.js";
10
9
  import { max2 } from "../math/max2.js";
11
10
  import { min2 } from "../math/min2.js";
12
11
  import LineSegment2 from "./LineSegment2.js";
13
12
  import Vector2 from "./Vector2.js";
13
+ import { overlap1D } from "../math/overlap1D.js";
14
14
 
15
15
  /**
16
16
  *
@@ -1,6 +1,8 @@
1
1
  import { assert } from "../assert.js";
2
- import { computeHashFloat, computeHashIntegerArray, EPSILON, epsilonEquals } from "../math/MathUtils.js";
2
+ import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
3
3
  import Vector3 from "./Vector3.js";
4
+ import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
5
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
4
6
 
5
7
 
6
8
  /**
@@ -3,8 +3,6 @@
3
3
  */
4
4
  import { clamp } from "../math/clamp.js";
5
5
  import Vector3 from "./Vector3.js";
6
- import { v3_dot } from "./v3_dot.js";
7
- import { v3_distance_sqr } from "./v3_distance_sqr.js";
8
6
 
9
7
 
10
8
  const SMALL_NUM = 1e-9;
@@ -19,82 +17,6 @@ const LineSegment = function (first, second) {
19
17
 
20
18
  };
21
19
 
22
- /**
23
- *
24
- * @param {Vector3} result
25
- * @param {number} origin_x
26
- * @param {number} origin_y
27
- * @param {number} origin_z
28
- * @param {number} direction_x
29
- * @param {number} direction_y
30
- * @param {number} direction_z
31
- * @param {number} px
32
- * @param {number} py
33
- * @param {number} pz
34
- * @returns {number} distance from origin, negative means that the point lies behind the origin in the direction opposite to the ray's own
35
- */
36
- export function ray_computeNearestPointToPoint(result, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z, px, py, pz) {
37
- // find closest point
38
- const sp0_x = px - origin_x;
39
- const sp0_y = py - origin_y;
40
- const sp0_z = pz - origin_z;
41
-
42
- //
43
- const d2 = v3_dot(direction_x, direction_y, direction_z, direction_x, direction_y, direction_z);
44
- const d3 = v3_dot(direction_x, direction_y, direction_z, sp0_x, sp0_y, sp0_z);
45
-
46
- const t = d3 / d2;
47
-
48
- // compute point on the ray
49
- const lp_x = direction_x * t + origin_x;
50
- const lp_y = direction_y * t + origin_y;
51
- const lp_z = direction_z * t + origin_z;
52
-
53
- result.set(lp_x, lp_y, lp_z);
54
-
55
- return t;
56
- }
57
-
58
- /**
59
- * Computes shortest distance between a line segment(defined by 2 points) and a point
60
- * @param {number} x0
61
- * @param {number} y0
62
- * @param {number} z0
63
- * @param {number} x1
64
- * @param {number} y1
65
- * @param {number} z1
66
- * @param {number} px
67
- * @param {number} py
68
- * @param {number} pz
69
- */
70
- export function line3_computeSegmentPointDistance_sqr(x0, y0, z0, x1, y1, z1, px, py, pz) {
71
- // find closest point
72
- const sp0_x = px - x0;
73
- const sp0_y = py - y0;
74
- const sp0_z = pz - z0;
75
-
76
- // get line delta
77
- const line_delta_x = x1 - x0;
78
- const line_delta_y = y1 - y0;
79
- const line_delta_z = z1 - z0;
80
-
81
- //
82
- const d2 = line_delta_x * line_delta_x + line_delta_y * line_delta_y + line_delta_z * line_delta_z;
83
-
84
-
85
- const d3 = line_delta_x * sp0_x + line_delta_y * sp0_y + line_delta_z * sp0_z;
86
-
87
- const t = clamp(d3 / d2, 0, 1);
88
-
89
- // compute point on the line
90
- const lp_x = line_delta_x * t + x0;
91
- const lp_y = line_delta_y * t + y0;
92
- const lp_z = line_delta_z * t + z0;
93
-
94
- // compute distance from the point in question to the point on the line
95
- return v3_distance_sqr(px, py, pz, lp_x, lp_y, lp_z);
96
- }
97
-
98
20
  LineSegment.prototype.closestPointToPointParameter = function (point, clampToLine) {
99
21
 
100
22
 
@@ -1,5 +1,4 @@
1
1
  import Vector3 from "./Vector3.js";
2
- import { v3_length } from "./v3_length.js";
3
2
 
4
3
  const _z = new Vector3();
5
4
  const _x = new Vector3();
@@ -193,12 +192,12 @@ export class Matrix4 {
193
192
  decompose(position, rotation, scale) {
194
193
 
195
194
 
196
- var sx = v3_length(this.a0, this.a1, this.a2);
197
- var sy = v3_length(this.b0, this.b1, this.b2);
198
- var sz = v3_length(this.c0, this.c1, this.c2);
195
+ let sx = Math.hypot(this.a0, this.a1, this.a2);
196
+ const sy = Math.hypot(this.b0, this.b1, this.b2);
197
+ const sz = Math.hypot(this.c0, this.c1, this.c2);
199
198
 
200
199
  // if determine is negative, we need to invert one scale
201
- var det = this.determinant();
200
+ const det = this.determinant();
202
201
  if (det < 0) sx = -sx;
203
202
 
204
203
  position.set(
@@ -208,9 +207,9 @@ export class Matrix4 {
208
207
  );
209
208
 
210
209
  // scale the rotation part
211
- var invSX = 1 / sx;
212
- var invSY = 1 / sy;
213
- var invSZ = 1 / sz;
210
+ const invSX = 1 / sx;
211
+ const invSY = 1 / sy;
212
+ const invSZ = 1 / sz;
214
213
 
215
214
  const i_a0 = this.a0 * invSX;
216
215
  const i_a1 = this.a1 * invSX;
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Created by Alex on 14/03/2016.
3
3
  */
4
- import { intersects1D, overlap1D } from "../math/MathUtils.js";
5
4
  import { max2 } from "../math/max2.js";
6
5
  import { min2 } from "../math/min2.js";
7
6
  import Vector2 from "./Vector2.js";
7
+ import { intersects1D } from "../math/intersects1D.js";
8
+ import { overlap1D } from "../math/overlap1D.js";
8
9
 
9
10
 
10
11
  /**
@@ -6,7 +6,7 @@
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
8
  import { clamp } from "../math/clamp.js";
9
- import { computeHashFloat } from "../math/MathUtils.js";
9
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
10
10
 
11
11
 
12
12
  class Vector1 extends Number {
@@ -6,7 +6,7 @@
6
6
  import { assert } from "../assert.js";
7
7
  import Signal from "../events/signal/Signal.js";
8
8
  import { lerp } from "../math/lerp.js";
9
- import { computeHashFloat, EPSILON, epsilonEquals } from "../math/MathUtils.js";
9
+ import { EPSILON, epsilonEquals } from "../math/MathUtils.js";
10
10
  import { sign } from "../math/sign.js";
11
11
  import { v3_dot } from "./v3_dot.js";
12
12
  import { v3_length_sqr } from "./v3_length_sqr.js";
@@ -14,6 +14,7 @@ import { v3_length } from "./v3_length.js";
14
14
  import { v3_angle_between } from "./v3_angle_between.js";
15
15
  import { v3_lerp } from "./v3_lerp.js";
16
16
  import { v3_slerp } from "./v3_slerp.js";
17
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
17
18
 
18
19
  class Vector3 {
19
20
  /**
@@ -5,7 +5,8 @@
5
5
  import { assert } from "../assert.js";
6
6
  import { Signal } from "../events/signal/Signal.js";
7
7
  import { lerp } from "../math/lerp.js";
8
- import { computeHashFloat, computeHashIntegerArray } from "../math/MathUtils.js";
8
+ import { computeHashIntegerArray } from "../collection/array/computeHashIntegerArray.js";
9
+ import { computeHashFloat } from "../math/hash/computeHashFloat.js";
9
10
 
10
11
  /**
11
12
  *
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  *
3
3
  * @param {function} random
4
- * @param {Vector3} result
4
+ * @param {number[]} result
5
+ * @param {number} result_offset
5
6
  */
6
- export function randomPointInBox(random, result) {
7
+ export function randomPointInBox(random, result, result_offset) {
7
8
  const x = random() - 0.5;
8
9
  const y = random() - 0.5;
9
10
  const z = random() - 0.5;
10
11
 
11
- result.set(x, y, z);
12
+ //write the result
13
+ result[result_offset] = x;
14
+ result[result_offset + 1] = y;
15
+ result[result_offset + 2] = z;
12
16
  }
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * Volumetric sampling method, since sample volume is a point, it simply sets result to origin
3
3
  * @param {function} random
4
- * @param {Vector3} result
4
+ * @param {number[]} result
5
+ * @param {number} destination_offset
5
6
  */
6
- export function randomPointInPoint(random, result) {
7
- result.set(0, 0, 0);
7
+ export function randomPointInPoint(random, result, destination_offset) {
8
+ result[destination_offset] = 0;
9
+ result[destination_offset + 1] = 0;
10
+ result[destination_offset + 2] = 0;
8
11
  }
@@ -4,9 +4,10 @@ import { PI2 } from "../../math/MathUtils.js";
4
4
  *
5
5
  * @see based on python code suggested here: https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
6
6
  * @param {function} random
7
- * @param {Vector3} result
7
+ * @param {number[]} result
8
+ * @param {number} result_offset
8
9
  */
9
- export function randomPointInSphere(random, result) {
10
+ export function randomPointInSphere(random, result, result_offset) {
10
11
  const phi = PI2 * random();
11
12
 
12
13
  const cosTheta = random() * 2 - 1;
@@ -27,5 +28,7 @@ export function randomPointInSphere(random, result) {
27
28
  const z = r * cosTheta;
28
29
 
29
30
  //write the result
30
- result.set(x, y, z);
31
+ result[result_offset] = x;
32
+ result[result_offset + 1] = y;
33
+ result[result_offset + 2] = z;
31
34
  }
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  *
3
3
  * @param {function} random
4
- * @param {Vector3} result
4
+ * @param {number[]} result
5
+ * @param {number} result_offset
5
6
  */
6
- export function randomPointOnBox(random, result) {
7
+ export function randomPointOnBox(random, result, result_offset) {
7
8
  //pick a side
8
9
  const side = random();
9
10
 
@@ -29,5 +30,8 @@ export function randomPointOnBox(random, result) {
29
30
  z = fixedAxis;
30
31
  }
31
32
 
32
- result.set(x, y, z);
33
+ //write the result
34
+ result[result_offset] = x;
35
+ result[result_offset + 1] = y;
36
+ result[result_offset + 2] = z;
33
37
  }
@@ -2,9 +2,10 @@
2
2
  *
3
3
  * @see based on python code suggested here: https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
4
4
  * @param {function} random
5
- * @param {Vector3} result
5
+ * @param {number[]} result
6
+ * @param {number} result_offset
6
7
  */
7
- export function randomPointOnSphere(random, result) {
8
+ export function randomPointOnSphere(random, result, result_offset) {
8
9
  const phi = Math.PI * 2 * random();
9
10
 
10
11
  const cosTheta = random() * 2 - 1;
@@ -23,5 +24,7 @@ export function randomPointOnSphere(random, result) {
23
24
  const z = r * cosTheta;
24
25
 
25
26
  //write the result
26
- result.set(x, y, z);
27
+ result[result_offset] = x;
28
+ result[result_offset + 1] = y;
29
+ result[result_offset + 2] = z;
27
30
  }
@@ -1,5 +1,10 @@
1
- import { v3_length_sqr } from "./v3_length_sqr.js";
2
-
1
+ /**
2
+ *
3
+ * @param {number} x
4
+ * @param {number} y
5
+ * @param {number} z
6
+ * @returns {number}
7
+ */
3
8
  export function v3_length(x, y, z) {
4
- return Math.sqrt(v3_length_sqr(x, y, z));
9
+ return Math.hypot(x, y, z);
5
10
  }
@@ -1,10 +1,10 @@
1
1
  //
2
2
  import { seededRandom } from "../math/random/seededRandom.js";
3
- import { randomIntegerBetween } from "../math/MathUtils.js";
4
3
  import { SquareMatrix } from "./SquareMatrix.js";
5
4
  import { DataType } from "../collection/table/DataType.js";
6
5
  import { BitSet } from "../binary/BitSet.js";
7
6
  import FastBinaryHeap from "../../engine/navigation/grid/FastBinaryHeap.js";
7
+ import { randomIntegerBetween } from "../math/random/randomIntegerBetween.js";
8
8
 
9
9
  /**
10
10
  * @template N