@woosh/meep-engine 2.108.0 → 2.108.3

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 (216) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +650 -308
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +650 -308
  5. package/editor/tools/paint/TerrainHeightPaintTool.js +5 -5
  6. package/package.json +1 -1
  7. package/src/core/binary/float_to_uint8.d.ts +7 -0
  8. package/src/core/binary/float_to_uint8.d.ts.map +1 -0
  9. package/src/core/binary/{float2uint8.js → float_to_uint8.js} +1 -1
  10. package/src/core/binary/uint8_to_float.d.ts +7 -0
  11. package/src/core/binary/uint8_to_float.d.ts.map +1 -0
  12. package/src/core/binary/{uint82float.js → uint8_to_float.js} +1 -1
  13. package/src/core/binary/uint8_to_float.spec.d.ts +2 -0
  14. package/src/core/binary/uint8_to_float.spec.d.ts.map +1 -0
  15. package/src/core/binary/uint8_to_float.spec.js +7 -0
  16. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +6 -0
  17. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  18. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +15 -3
  19. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -3
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +25 -14
  22. package/src/core/codegen/codeToBlob.d.ts +8 -0
  23. package/src/core/codegen/codeToBlob.d.ts.map +1 -0
  24. package/src/core/codegen/codeToBlob.js +36 -0
  25. package/src/core/codegen/codeToURL.d.ts +8 -0
  26. package/src/core/codegen/codeToURL.d.ts.map +1 -0
  27. package/src/core/codegen/codeToURL.js +22 -0
  28. package/src/core/collection/array/arrayQuickSort.d.ts +0 -9
  29. package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
  30. package/src/core/collection/array/arrayQuickSort.js +0 -73
  31. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts +10 -0
  32. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts.map +1 -0
  33. package/src/core/collection/array/array_quick_sort_by_comparator.js +75 -0
  34. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +8 -0
  35. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +1 -0
  36. package/src/core/collection/array/array_quick_sort_by_lookup.js +78 -0
  37. package/src/core/collection/array/array_shuffle.d.ts +8 -0
  38. package/src/core/collection/array/array_shuffle.d.ts.map +1 -0
  39. package/src/core/collection/array/array_shuffle.js +22 -0
  40. package/src/core/collection/array/array_shuffle.spec.d.ts +2 -0
  41. package/src/core/collection/array/array_shuffle.spec.d.ts.map +1 -0
  42. package/src/core/collection/array/{randomizeArrayElementOrder.spec.js → array_shuffle.spec.js} +4 -4
  43. package/src/core/collection/array/iterator/ArrayIteratorRandom.js +2 -2
  44. package/src/core/collection/array/randomMultipleFromArray.js +2 -2
  45. package/src/core/color/Color.js +9 -9
  46. package/src/core/color/hsv/hsv2rgb.js +4 -4
  47. package/src/core/color/rgb2uint24.js +4 -4
  48. package/src/core/color/sRGB/linear_to_sRGB.d.ts +1 -0
  49. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  50. package/src/core/color/sRGB/linear_to_sRGB.js +4 -4
  51. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +15 -0
  52. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -0
  53. package/src/core/geom/2d/triangle2d_get_barycentric.js +48 -0
  54. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  55. package/src/core/geom/3d/aabb/AABB3.js +4 -1
  56. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  57. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +2 -7
  58. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +3 -3
  59. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts +11 -0
  60. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts.map +1 -0
  61. package/src/core/geom/3d/aabb3_compute_from_triangle.js +43 -0
  62. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  63. package/src/core/geom/3d/shape/UnitSphereShape3D.js +14 -14
  64. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -1
  65. package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +2 -0
  66. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +5 -5
  67. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +9 -0
  68. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts.map +1 -0
  69. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +17 -0
  70. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +6 -3
  71. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  72. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +56 -18
  73. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts +1 -1
  74. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts.map +1 -1
  75. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +11 -4
  76. package/src/core/geom/3d/tetrahedra/{GetDepthForTetrahedronProbe.glsl → triangle/GetDepthForTetrahedronProbe.glsl} +17 -10
  77. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts +2 -0
  78. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts.map +1 -0
  79. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +128 -0
  80. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts +13 -0
  81. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -0
  82. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +120 -0
  83. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +3 -0
  84. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -0
  85. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +106 -0
  86. package/src/core/geom/Vector3.js +3 -3
  87. package/src/core/geom/random/randomPointInSphere.d.ts +1 -1
  88. package/src/core/geom/random/randomPointInSphere.js +2 -2
  89. package/src/core/geom/random/randomPointOnSphere.d.ts +3 -3
  90. package/src/core/geom/random/randomPointOnSphere.d.ts.map +1 -1
  91. package/src/core/geom/random/randomPointOnSphere.js +5 -9
  92. package/src/core/math/factorial.d.ts +7 -0
  93. package/src/core/math/factorial.d.ts.map +1 -0
  94. package/src/core/math/factorial.js +15 -0
  95. package/src/core/math/factorial.spec.d.ts +2 -0
  96. package/src/core/math/factorial.spec.d.ts.map +1 -0
  97. package/src/core/math/factorial.spec.js +9 -0
  98. package/src/core/model/DebouncedObservedBoolean.d.ts +1 -1
  99. package/src/core/model/DebouncedObservedBoolean.d.ts.map +1 -1
  100. package/src/core/model/node-graph/node/NodeDescription.d.ts +6 -4
  101. package/src/core/process/task/util/randomCountTask.js +3 -3
  102. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  103. package/src/core/process/worker/WorkerBuilder.js +5 -35
  104. package/src/engine/EngineHarness.d.ts.map +1 -1
  105. package/src/engine/EngineHarness.js +7 -1
  106. package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
  107. package/src/engine/asset/loaders/ArrayBufferLoader.js +17 -10
  108. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.d.ts.map +1 -1
  109. package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +3 -0
  110. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  111. package/src/engine/asset/loaders/material/computeTextureEquality.js +8 -1
  112. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +4 -4
  113. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
  114. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -0
  115. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +1 -1
  116. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +3 -1
  117. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  118. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +7 -7
  119. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts +8 -0
  120. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts.map +1 -0
  121. package/src/engine/graphics/filter/{FlipArrayInPlace.js → sampler2d_flipY_in_place.js} +1 -1
  122. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.d.ts.map +1 -1
  123. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +5 -27
  124. package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +3 -3
  125. package/src/engine/graphics/render/Lines.d.ts.map +1 -1
  126. package/src/engine/graphics/render/Lines.js +10 -2
  127. package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +1 -1
  128. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -6
  129. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +24 -0
  130. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -0
  131. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +293 -0
  132. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts +6 -0
  133. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +1 -0
  134. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +71 -0
  135. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts +6 -0
  136. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +1 -0
  137. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +256 -0
  138. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +4 -4
  139. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +3 -1
  140. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  141. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +12 -1
  142. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  143. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +4 -5
  144. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +2 -1
  145. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  146. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -6
  147. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +8 -0
  148. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  149. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +3 -2
  150. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  151. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +9 -4
  152. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
  153. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  154. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  155. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts +2 -2
  156. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +1 -1
  157. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +18 -8
  158. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +14 -6
  159. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts +10 -0
  160. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts.map +1 -0
  161. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.js +20 -0
  162. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts +10 -0
  163. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts.map +1 -0
  164. package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.js +31 -0
  165. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts +9 -0
  166. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts.map +1 -0
  167. package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.js +21 -0
  168. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +1 -1
  169. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -1
  170. package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +2 -3
  171. package/src/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +4 -4
  172. package/src/engine/graphics/sh3/prototypeSH3Probe.js +116 -19
  173. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  174. package/src/engine/graphics/texture/AttributeDataTexture.js +8 -2
  175. package/src/engine/graphics/texture/computeThreeTextureFormat.js +2 -1
  176. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts +7 -0
  177. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts.map +1 -0
  178. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.js +13 -0
  179. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts +9 -0
  180. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts.map +1 -0
  181. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.js +31 -0
  182. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  183. package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -4
  184. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
  185. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +47 -19
  186. package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.js +5 -33
  187. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts +11 -0
  188. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts.map +1 -0
  189. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.js +41 -0
  190. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +0 -4
  191. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
  192. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +19 -30
  193. package/src/engine/network/convertPathToURL.d.ts +3 -1
  194. package/src/engine/network/convertPathToURL.d.ts.map +1 -1
  195. package/src/engine/network/convertPathToURL.js +68 -51
  196. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  197. package/src/engine/physics/fluid/SliceVisualiser.js +4 -4
  198. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  199. package/src/generation/filtering/numeric/CellFilterCache.js +1 -0
  200. package/src/core/binary/float2uint8.d.ts +0 -7
  201. package/src/core/binary/float2uint8.d.ts.map +0 -1
  202. package/src/core/binary/uint82float.d.ts +0 -7
  203. package/src/core/binary/uint82float.d.ts.map +0 -1
  204. package/src/core/binary/uint82float.spec.d.ts +0 -2
  205. package/src/core/binary/uint82float.spec.d.ts.map +0 -1
  206. package/src/core/binary/uint82float.spec.js +0 -7
  207. package/src/core/collection/array/randomizeArrayElementOrder.d.ts +0 -8
  208. package/src/core/collection/array/randomizeArrayElementOrder.d.ts.map +0 -1
  209. package/src/core/collection/array/randomizeArrayElementOrder.js +0 -24
  210. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts +0 -2
  211. package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts.map +0 -1
  212. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts +0 -8
  213. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts.map +0 -1
  214. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +0 -3
  215. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +0 -1
  216. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +0 -3
@@ -1,13 +1,13 @@
1
+ import { uint8_to_float } from "../../../src/core/binary/uint8_to_float.js";
2
+ import { QuadTreeNode } from "../../../src/core/geom/2d/quad-tree/QuadTreeNode.js";
1
3
  import { clamp } from "../../../src/core/math/clamp.js";
2
4
  import { inverseLerp } from "../../../src/core/math/inverseLerp.js";
3
5
  import { lerp } from "../../../src/core/math/lerp.js";
4
- import { TerrainPaintTool } from "./TerrainPaintTool.js";
5
- import { PatchTerrainHeightAction } from "../../actions/concrete/PatchTerrainHeightAction.js";
6
- import { QuadTreeNode } from "../../../src/core/geom/2d/quad-tree/QuadTreeNode.js";
7
6
  import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
7
+ import { PatchTerrainHeightAction } from "../../actions/concrete/PatchTerrainHeightAction.js";
8
8
  import TransformModifyAction from "../../actions/concrete/TransformModifyAction.js";
9
9
  import EditorEntity from "../../ecs/EditorEntity.js";
10
- import { uint82float } from "../../../src/core/binary/uint82float.js";
10
+ import { TerrainPaintTool } from "./TerrainPaintTool.js";
11
11
 
12
12
  const LIMIT_VALUE = 1000;
13
13
 
@@ -56,7 +56,7 @@ function make_mod_action(terrain, uv_x0, uv_y0, uv_x1, uv_y1, marker, value_delt
56
56
  //Get alpha
57
57
  const markerValue = marker.sampleChannelBilinearUV(u, v, 3);
58
58
 
59
- const marker_value_normalized = uint82float(markerValue);
59
+ const marker_value_normalized = uint8_to_float(markerValue);
60
60
 
61
61
  const source_address = y * heightMap.width + x;
62
62
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.108.0",
8
+ "version": "2.108.3",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} v
4
+ * @returns {number}
5
+ */
6
+ export function float_to_uint8(v: number): number;
7
+ //# sourceMappingURL=float_to_uint8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float_to_uint8.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/float_to_uint8.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -3,6 +3,6 @@
3
3
  * @param {number} v
4
4
  * @returns {number}
5
5
  */
6
- export function float2uint8(v) {
6
+ export function float_to_uint8(v) {
7
7
  return Math.round(v * 255);
8
8
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} v
4
+ * @returns {number}
5
+ */
6
+ export function uint8_to_float(v: number): number;
7
+ //# sourceMappingURL=uint8_to_float.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uint8_to_float.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAIlB"}
@@ -3,6 +3,6 @@
3
3
  * @param {number} v
4
4
  * @returns {number}
5
5
  */
6
- export function uint82float(v) {
6
+ export function uint8_to_float(v) {
7
7
  return v / 255;
8
8
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=uint8_to_float.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uint8_to_float.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/uint8_to_float.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { uint8_to_float } from "./uint8_to_float.js";
2
+
3
+ test("correctness", () => {
4
+ expect(uint8_to_float(0)).toBe(0);
5
+ expect(uint8_to_float(1)).toBeCloseTo(1 / 255);
6
+ expect(uint8_to_float(255)).toBe(1);
7
+ });
@@ -78,6 +78,12 @@ export class BinaryUint32BVH {
78
78
  * @param {number} count
79
79
  */
80
80
  setLeafCount(count: number): void;
81
+ /**
82
+ *
83
+ * @param {number} index
84
+ * @return {number}
85
+ */
86
+ getLeafAddress(index: number): number;
81
87
  /**
82
88
  *
83
89
  * @param {number} index
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAgBhB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsChB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
1
+ {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAgBhB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACL,MAAM,CASjB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAoChB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
@@ -219,6 +219,20 @@ export class BinaryUint32BVH {
219
219
 
220
220
  }
221
221
 
222
+ /**
223
+ *
224
+ * @param {number} index
225
+ * @return {number}
226
+ */
227
+ getLeafAddress(index) {
228
+ assert.isNonNegativeInteger(index, 'index');
229
+ assert.lessThan(index, this.__node_count_leaf, 'leaf index overflow');
230
+
231
+ const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
232
+
233
+ return index * BVH_LEAF_NODE_SIZE + leaf_block_address;
234
+ }
235
+
222
236
  /**
223
237
  *
224
238
  * @param {number} index
@@ -254,9 +268,7 @@ export class BinaryUint32BVH {
254
268
 
255
269
  assert.isNonNegativeInteger(payload, 'payload');
256
270
 
257
- const leaf_block_address = this.__node_count_binary * BVH_BINARY_NODE_SIZE;
258
-
259
- const address = index * BVH_LEAF_NODE_SIZE + leaf_block_address;
271
+ const address = this.getLeafAddress(index);
260
272
 
261
273
  aabb3_array_set(
262
274
  this.__data_float32,
@@ -34,7 +34,6 @@ export function build_triangle_morton_codes(
34
34
  // compute morton codes
35
35
  for (let i = 0; i < tri_count; i++) {
36
36
 
37
-
38
37
  const i3 = i * 3;
39
38
 
40
39
  // read indices
@@ -44,16 +43,17 @@ export function build_triangle_morton_codes(
44
43
 
45
44
  // read vertex positions
46
45
  const a_address = a * 3;
46
+ const c_address = c * 3;
47
+ const b_address = b * 3;
48
+
47
49
  const ax = position_array[a_address];
48
50
  const ay = position_array[a_address + 1];
49
51
  const az = position_array[a_address + 2];
50
52
 
51
- const b_address = b * 3;
52
53
  const bx = position_array[b_address];
53
54
  const by = position_array[b_address + 1];
54
55
  const bz = position_array[b_address + 2];
55
56
 
56
- const c_address = c * 3;
57
57
  const cx = position_array[c_address];
58
58
  const cy = position_array[c_address + 1];
59
59
  const cz = position_array[c_address + 2];
@@ -1 +1 @@
1
- {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,sEAHW,MAAM,EAAE,GAAC,YAAY,kBACrB,MAAM,EAAE,GAAC,YAAY,QA0E/B"}
1
+ {"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,sEAHW,MAAM,EAAE,GAAC,YAAY,kBACrB,MAAM,EAAE,GAAC,YAAY,QAoF/B"}
@@ -1,11 +1,12 @@
1
- import { compute_triangle_group_aabb3 } from "../../../engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js";
2
1
  import { assert } from "../../assert.js";
3
- import { arrayQuickSort } from "../../collection/array/arrayQuickSort.js";
2
+ import { array_copy } from "../../collection/array/array_copy.js";
3
+ import { array_quick_sort_by_lookup } from "../../collection/array/array_quick_sort_by_lookup.js";
4
4
  import { AABB3 } from "../../geom/3d/aabb/AABB3.js";
5
5
  import { aabb3_from_v3_array } from "../../geom/3d/aabb/aabb3_from_v3_array.js";
6
+ import { aabb3_compute_from_triangle } from "../../geom/3d/aabb3_compute_from_triangle.js";
6
7
  import { max2 } from "../../math/max2.js";
7
8
  import { build_triangle_morton_codes } from "./build_triangle_morton_codes.js";
8
- import { NULL_NODE } from "./BVH.js";
9
+ import { ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
9
10
  import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
10
11
 
11
12
  /**
@@ -50,7 +51,6 @@ export function ebvh_build_for_geometry_morton(bvh, index_array, position_array)
50
51
  nodes[i] = (node_total_count - 1) - i;
51
52
  }
52
53
 
53
- const morton_codes = new Uint32Array(tri_count);
54
54
 
55
55
  // indices of triangles, but sorted by morton codes
56
56
  const sorted_triangle_order = new Uint32Array(tri_count);
@@ -59,32 +59,43 @@ export function ebvh_build_for_geometry_morton(bvh, index_array, position_array)
59
59
  sorted_triangle_order[i] = i;
60
60
  }
61
61
 
62
+ const morton_codes = new Uint32Array(tri_count);
63
+
62
64
  build_triangle_morton_codes(morton_codes, tri_count, index_array, position_array, aabb3.x0, aabb3.y0, aabb3.z0, aabb3.x1, aabb3.y1, aabb3.z1);
63
65
 
64
66
  // sort leaves by morton codes
65
- arrayQuickSort(sorted_triangle_order, (triangle_index) => morton_codes[triangle_index], null, 0, tri_count - 1);
67
+ array_quick_sort_by_lookup(sorted_triangle_order, morton_codes, 0, tri_count - 1);
66
68
 
67
- let used_index = 0;
68
- const unprocessed_nodes = new Uint32Array(tri_count);
69
69
  // assign leaves
70
- const aabb_array = new Float32Array(6);
71
70
  for (let i = 0; i < tri_count; i++) {
72
- const node = nodes[used_index++];
71
+ const node = nodes[i];
73
72
 
74
73
  const triangle_index = sorted_triangle_order[i];
75
74
 
76
- bvh.node_set_child1(node, NULL_NODE);
75
+ bvh.node_set_child1(node, NULL_NODE); //mark node as a leaf
77
76
  bvh.node_set_user_data(node, triangle_index);
78
77
 
79
78
  bvh.node_set_height(node, 0);
80
79
 
81
- compute_triangle_group_aabb3(aabb_array, 0, index_array, position_array, triangle_index * 3, 1, 3);
80
+ const triangle_index3 = triangle_index * 3;
82
81
 
83
- bvh.node_set_aabb(node, aabb_array);
82
+ const a_index = index_array[triangle_index3];
83
+ const b_index = index_array[triangle_index3 + 1];
84
+ const c_index = index_array[triangle_index3 + 2];
85
+
86
+ const aabb_address = ELEMENT_WORD_COUNT * node;
87
+
88
+ aabb3_compute_from_triangle(
89
+ bvh.__data_float32, aabb_address,
90
+ position_array, a_index, b_index, c_index
91
+ );
84
92
 
85
- unprocessed_nodes[i] = node;
86
93
  }
87
94
 
95
+ // record newly generated nodes as "unprocessed"
96
+ const unprocessed_nodes = new Uint32Array(tri_count);
97
+ array_copy(nodes, 0, unprocessed_nodes, 0, tri_count);
98
+
88
99
  // assign root
89
- bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, used_index);
100
+ bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, tri_count);
90
101
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {string} code
4
+ * @param {string} [mime_type]
5
+ * @return {Blob}
6
+ */
7
+ export function codeToBlob(code: string, mime_type?: string): Blob;
8
+ //# sourceMappingURL=codeToBlob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeToBlob.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/codeToBlob.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iCAJW,MAAM,cACN,MAAM,GACL,IAAI,CA6Bf"}
@@ -0,0 +1,36 @@
1
+ import { assert } from "../assert.js";
2
+
3
+ /**
4
+ *
5
+ * @param {string} code
6
+ * @param {string} [mime_type]
7
+ * @return {Blob}
8
+ */
9
+ export function codeToBlob(code, mime_type = 'application/javascript') {
10
+ assert.isString(code, 'code');
11
+ assert.isString(mime_type, 'mime_type');
12
+
13
+ let blob;
14
+
15
+ if (typeof globalThis.Blob !== "undefined") {
16
+ blob = new Blob([code], { type: mime_type });
17
+ } else {
18
+ // Backwards-compatibility
19
+ const BlobBuilder = globalThis.BlobBuilder
20
+ || globalThis.BlobBuilder
21
+ || globalThis.WebKitBlobBuilder
22
+ || globalThis.MozBlobBuilder;
23
+
24
+ if (BlobBuilder !== undefined) {
25
+ blob = new BlobBuilder();
26
+ blob.append(code);
27
+ blob = blob.getBlob();
28
+ } else {
29
+ throw new Error(`No BlobBuilder interface supported in current context`);
30
+ }
31
+
32
+ }
33
+
34
+
35
+ return blob;
36
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {string} code
4
+ * @param {string} [mime_type]
5
+ * @return {string}
6
+ */
7
+ export function codeToURL(code: string, mime_type?: string): string;
8
+ //# sourceMappingURL=codeToURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeToURL.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/codeToURL.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,gCAJW,MAAM,cACN,MAAM,GACL,MAAM,CAcjB"}
@@ -0,0 +1,22 @@
1
+ import { assert } from "../assert.js";
2
+ import { codeToBlob } from "./codeToBlob.js";
3
+
4
+ /**
5
+ *
6
+ * @param {string} code
7
+ * @param {string} [mime_type]
8
+ * @return {string}
9
+ */
10
+ export function codeToURL(code, mime_type = 'application/javascript') {
11
+ assert.isString(code, 'code');
12
+ assert.isString(mime_type, 'mime_type');
13
+
14
+ const blob = codeToBlob(code, mime_type);
15
+
16
+ if (blob !== undefined && URL.createObjectURL !== undefined) {
17
+ return URL.createObjectURL(blob);
18
+ } else {
19
+ // build data URL in a slowest way possible
20
+ return `data:${mime_type},${encodeURIComponent(code)}`;
21
+ }
22
+ }
@@ -9,13 +9,4 @@
9
9
  * @param {*} [swap_context]
10
10
  */
11
11
  export function arrayQuickSort<T>(data: ArrayLike<number> | Uint32Array | T[], score_function: (arg0: T) => number, score_function_context: any, start: number, end: number, swap_operator?: (arg0: T[], arg1: number, arg2: number) => any, swap_context?: any): void;
12
- /**
13
- * @template T
14
- * @param {T[]} data
15
- * @param {function(T,T):number} compare_function
16
- * @param {*} compare_function_context
17
- * @param {number} start
18
- * @param {number} end
19
- */
20
- export function array_quick_sort_by_comparator<T>(data: T[], compare_function: (arg0: T, arg1: T) => number, compare_function_context: any, start: number, end: number): void;
21
12
  //# sourceMappingURL=arrayQuickSort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrayQuickSort.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/arrayQuickSort.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,4GAPuB,MAAM,sCAElB,MAAM,OACN,MAAM,oCACO,MAAM,QAAE,MAAM,oCAiErC;AAED;;;;;;;GAOG;AACH,qGALyB,MAAM,wCAEpB,MAAM,OACN,MAAM,QAkEhB"}
1
+ {"version":3,"file":"arrayQuickSort.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/arrayQuickSort.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,4GAPuB,MAAM,sCAElB,MAAM,OACN,MAAM,oCACO,MAAM,QAAE,MAAM,oCAiErC"}
@@ -76,76 +76,3 @@ export function arrayQuickSort(
76
76
  }
77
77
  }
78
78
 
79
- /**
80
- * @template T
81
- * @param {T[]} data
82
- * @param {function(T,T):number} compare_function
83
- * @param {*} compare_function_context
84
- * @param {number} start
85
- * @param {number} end
86
- */
87
- export function array_quick_sort_by_comparator(
88
- data,
89
- compare_function, compare_function_context,
90
- start, end
91
- ) {
92
- if (start >= end) {
93
- // section of 0 size, nothing to sort
94
- return;
95
- }
96
-
97
- let stackPointer = 2;
98
- let i, j;
99
-
100
- stack[0] = start;
101
- stack[1] = end;
102
-
103
- while (stackPointer > 0) {
104
- stackPointer -= 2;
105
-
106
- const right = stack[stackPointer + 1];
107
- const left = stack[stackPointer];
108
-
109
- i = left;
110
- j = right;
111
-
112
- const pivotIndex = (left + right) >> 1;
113
-
114
- const pivot = data[pivotIndex];
115
-
116
- /* partition */
117
- while (i <= j) {
118
- while (compare_function.call(compare_function_context, data[i], pivot) < 0) {
119
- i++;
120
- }
121
-
122
- while (compare_function.call(compare_function_context, data[j], pivot) > 0) {
123
- j--;
124
- }
125
-
126
- if (i <= j) {
127
-
128
- if (i !== j) {
129
- //do swap
130
- const tmp = data[i];
131
- data[i] = data[j];
132
- data[j] = tmp;
133
-
134
- }
135
-
136
- i++;
137
- j--;
138
- }
139
- }
140
-
141
- /* recursion */
142
- if (left < j) {
143
- stack[stackPointer++] = left;
144
- stack[stackPointer++] = j;
145
- }
146
- if (i < right) {
147
- stack[stackPointer++] = i;
148
- stack[stackPointer++] = right;
149
- }
150
- }
151
- }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @template T
3
+ * @param {T[]|Uint32Array} data
4
+ * @param {function(T,T):number} compare_function
5
+ * @param {*} compare_function_context
6
+ * @param {number} start
7
+ * @param {number} end
8
+ */
9
+ export function array_quick_sort_by_comparator<T>(data: Uint32Array | T[], compare_function: (arg0: T, arg1: T) => number, compare_function_context: any, start: number, end: number): void;
10
+ //# sourceMappingURL=array_quick_sort_by_comparator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_quick_sort_by_comparator.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_quick_sort_by_comparator.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,mHALyB,MAAM,wCAEpB,MAAM,OACN,MAAM,QAkEhB"}
@@ -0,0 +1,75 @@
1
+ const stack = [];
2
+
3
+ /**
4
+ * @template T
5
+ * @param {T[]|Uint32Array} data
6
+ * @param {function(T,T):number} compare_function
7
+ * @param {*} compare_function_context
8
+ * @param {number} start
9
+ * @param {number} end
10
+ */
11
+ export function array_quick_sort_by_comparator(
12
+ data,
13
+ compare_function, compare_function_context,
14
+ start, end
15
+ ) {
16
+ if (start >= end) {
17
+ // section of 0 size, nothing to sort
18
+ return;
19
+ }
20
+
21
+ let stackPointer = 2;
22
+ let i, j;
23
+
24
+ stack[0] = start;
25
+ stack[1] = end;
26
+
27
+ while (stackPointer > 0) {
28
+ stackPointer -= 2;
29
+
30
+ const right = stack[stackPointer + 1];
31
+ const left = stack[stackPointer];
32
+
33
+ i = left;
34
+ j = right;
35
+
36
+ const pivotIndex = (left + right) >> 1;
37
+
38
+ const pivot = data[pivotIndex];
39
+
40
+ /* partition */
41
+ while (i <= j) {
42
+ while (compare_function.call(compare_function_context, data[i], pivot) < 0) {
43
+ i++;
44
+ }
45
+
46
+ while (compare_function.call(compare_function_context, data[j], pivot) > 0) {
47
+ j--;
48
+ }
49
+
50
+ if (i <= j) {
51
+
52
+ if (i !== j) {
53
+ //do swap
54
+ const tmp = data[i];
55
+ data[i] = data[j];
56
+ data[j] = tmp;
57
+
58
+ }
59
+
60
+ i++;
61
+ j--;
62
+ }
63
+ }
64
+
65
+ /* recursion */
66
+ if (left < j) {
67
+ stack[stackPointer++] = left;
68
+ stack[stackPointer++] = j;
69
+ }
70
+ if (i < right) {
71
+ stack[stackPointer++] = i;
72
+ stack[stackPointer++] = right;
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {number[]|Uint32Array} data
3
+ * @param {number[]|Uint32Array} lookup
4
+ * @param {number} start
5
+ * @param {number} end
6
+ */
7
+ export function array_quick_sort_by_lookup(data: number[] | Uint32Array, lookup: number[] | Uint32Array, start: number, end: number): void;
8
+ //# sourceMappingURL=array_quick_sort_by_lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_quick_sort_by_lookup.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_quick_sort_by_lookup.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,iDALW,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,EAAE,GAAC,WAAW,SACpB,MAAM,OACN,MAAM,QAqEhB"}
@@ -0,0 +1,78 @@
1
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../SCRATCH_UINT32_TRAVERSAL_STACK.js";
2
+
3
+ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
4
+
5
+ /**
6
+ * @param {number[]|Uint32Array} data
7
+ * @param {number[]|Uint32Array} lookup
8
+ * @param {number} start
9
+ * @param {number} end
10
+ */
11
+ export function array_quick_sort_by_lookup(
12
+ data,
13
+ lookup,
14
+ start, end
15
+ ) {
16
+ if (start >= end) {
17
+ // section of 0 size, nothing to sort
18
+ return;
19
+ }
20
+
21
+ const stack_frame = start.pointer;
22
+ let stackPointer = stack_frame;
23
+
24
+ let i, j;
25
+
26
+ stack[stackPointer++] = start;
27
+ stack[stackPointer++] = end;
28
+
29
+ while (stackPointer > stack_frame) {
30
+ stackPointer -= 2;
31
+
32
+ const right = stack[stackPointer + 1];
33
+ const left = stack[stackPointer];
34
+
35
+ i = left;
36
+ j = right;
37
+
38
+ const pivotIndex = (left + right) >> 1;
39
+
40
+ const pivot = data[pivotIndex];
41
+ const pivot_score = lookup[pivot];
42
+
43
+ /* partition */
44
+ while (i <= j) {
45
+ while (lookup[data[i]] < pivot_score) {
46
+ i++;
47
+ }
48
+
49
+ while (lookup[data[j]] > pivot_score) {
50
+ j--;
51
+ }
52
+
53
+ if (i <= j) {
54
+
55
+ if (i !== j) {
56
+ //do swap
57
+ const tmp = data[i];
58
+ data[i] = data[j];
59
+ data[j] = tmp;
60
+
61
+ }
62
+
63
+ i++;
64
+ j--;
65
+ }
66
+ }
67
+
68
+ /* recursion */
69
+ if (left < j) {
70
+ stack[stackPointer++] = left;
71
+ stack[stackPointer++] = j;
72
+ }
73
+ if (i < right) {
74
+ stack[stackPointer++] = i;
75
+ stack[stackPointer++] = right;
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Randomly re-orders items in-place
3
+ * @template T
4
+ * @param {function} random
5
+ * @param {T[]} array
6
+ */
7
+ export function array_shuffle<T>(random: Function, array: T[]): void;
8
+ //# sourceMappingURL=array_shuffle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_shuffle.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_shuffle.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qEAYC"}