@woosh/meep-engine 2.108.2 → 2.108.4

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 (122) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +490 -193
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +490 -193
  5. package/package.json +1 -1
  6. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts +6 -0
  7. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  8. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +15 -3
  9. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +3 -3
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  11. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +25 -14
  12. package/src/core/collection/array/arrayQuickSort.d.ts +0 -9
  13. package/src/core/collection/array/arrayQuickSort.d.ts.map +1 -1
  14. package/src/core/collection/array/arrayQuickSort.js +0 -73
  15. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts +10 -0
  16. package/src/core/collection/array/array_quick_sort_by_comparator.d.ts.map +1 -0
  17. package/src/core/collection/array/array_quick_sort_by_comparator.js +75 -0
  18. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +8 -0
  19. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +1 -0
  20. package/src/core/collection/array/array_quick_sort_by_lookup.js +78 -0
  21. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +15 -0
  22. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -0
  23. package/src/core/geom/2d/triangle2d_get_barycentric.js +48 -0
  24. package/src/core/geom/3d/aabb/aabb3_from_v3_array.d.ts.map +1 -1
  25. package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +2 -7
  26. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts +11 -0
  27. package/src/core/geom/3d/aabb3_compute_from_triangle.d.ts.map +1 -0
  28. package/src/core/geom/3d/aabb3_compute_from_triangle.js +43 -0
  29. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +5 -5
  30. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts +9 -0
  31. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.d.ts.map +1 -0
  32. package/src/core/geom/3d/sphere/harmonics/sh_compute_K.js +17 -0
  33. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +6 -3
  34. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
  35. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +56 -18
  36. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts +1 -1
  37. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.d.ts.map +1 -1
  38. package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_walk_towards_containing_tetrahedron.js +11 -4
  39. package/src/core/geom/3d/tetrahedra/{GetDepthForTetrahedronProbe.glsl → triangle/GetDepthForTetrahedronProbe.glsl} +17 -10
  40. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts +2 -0
  41. package/src/core/geom/3d/tetrahedra/triangle/prototype.d.ts.map +1 -0
  42. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +128 -0
  43. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts +13 -0
  44. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -0
  45. package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +120 -0
  46. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts +3 -0
  47. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.d.ts.map +1 -0
  48. package/src/core/geom/3d/tetrahedra/triangle/triangle_encode_rasterized_depth.js +106 -0
  49. package/src/core/math/factorial.d.ts +7 -0
  50. package/src/core/math/factorial.d.ts.map +1 -0
  51. package/src/core/math/factorial.js +15 -0
  52. package/src/core/math/factorial.spec.d.ts +2 -0
  53. package/src/core/math/factorial.spec.d.ts.map +1 -0
  54. package/src/core/math/factorial.spec.js +9 -0
  55. package/src/core/model/DebouncedObservedBoolean.d.ts +1 -1
  56. package/src/core/model/DebouncedObservedBoolean.d.ts.map +1 -1
  57. package/src/core/model/node-graph/node/NodeDescription.d.ts +6 -4
  58. package/src/engine/asset/loaders/material/computeTextureEquality.d.ts.map +1 -1
  59. package/src/engine/asset/loaders/material/computeTextureEquality.js +8 -1
  60. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +3 -1
  62. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts +8 -0
  63. package/src/engine/graphics/filter/sampler2d_flipY_in_place.d.ts.map +1 -0
  64. package/src/engine/graphics/filter/{FlipArrayInPlace.js → sampler2d_flipY_in_place.js} +1 -1
  65. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.d.ts.map +1 -1
  66. package/src/engine/graphics/geometry/bvh/buffered/bvh32_set_leaf_from_triangle.js +5 -27
  67. package/src/engine/graphics/render/Lines.d.ts.map +1 -1
  68. package/src/engine/graphics/render/Lines.js +10 -2
  69. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts +24 -0
  70. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -0
  71. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +293 -0
  72. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts +6 -0
  73. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.d.ts.map +1 -0
  74. package/src/engine/graphics/sh3/gi/material/build_fragment_shader.js +71 -0
  75. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts +6 -0
  76. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.d.ts.map +1 -0
  77. package/src/engine/graphics/sh3/gi/material/build_vertex_shader.js +256 -0
  78. package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +4 -4
  79. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +3 -1
  80. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  81. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +12 -1
  82. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +2 -1
  83. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  84. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +6 -6
  85. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +8 -0
  86. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  87. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +3 -2
  88. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  89. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +9 -4
  90. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +3 -3
  91. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  92. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
  93. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts +2 -2
  94. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +1 -1
  95. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +18 -8
  96. package/src/engine/graphics/sh3/prototypeSH3Probe.js +51 -22
  97. package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
  98. package/src/engine/graphics/texture/AttributeDataTexture.js +8 -2
  99. package/src/engine/graphics/texture/computeThreeTextureFormat.js +2 -1
  100. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts +7 -0
  101. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.d.ts.map +1 -0
  102. package/src/engine/graphics/texture/computeThreeTextureFormatFromDataType.js +13 -0
  103. package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
  104. package/src/engine/graphics/texture/formatToChannelCount.js +8 -1
  105. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts +9 -0
  106. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.d.ts.map +1 -0
  107. package/src/engine/graphics/texture/numericTypeFromBinaryDataType.js +31 -0
  108. package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
  109. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
  110. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +47 -19
  111. package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.js +5 -33
  112. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts +11 -0
  113. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.d.ts.map +1 -0
  114. package/src/engine/graphics/texture/sampler/sampler2d_copy_rectangle.js +41 -0
  115. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts +0 -4
  116. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.d.ts.map +1 -1
  117. package/src/engine/graphics/texture/virtual/VirtualTextureUsage.js +19 -30
  118. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts +0 -8
  119. package/src/engine/graphics/filter/FlipArrayInPlace.d.ts.map +0 -1
  120. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +0 -3
  121. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +0 -1
  122. package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +0 -3
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.2",
8
+ "version": "2.108.4",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -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
  }
@@ -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,15 @@
1
+ /**
2
+ *
3
+ * @param {number[]} output
4
+ * @param {number} output_offset
5
+ * @param {number} ax
6
+ * @param {number} ay
7
+ * @param {number} bx
8
+ * @param {number} by
9
+ * @param {number} cx
10
+ * @param {number} cy
11
+ * @param {number} px
12
+ * @param {number} py
13
+ */
14
+ export function triangle2d_get_barycentric(output: number[], output_offset: number, ax: number, ay: number, bx: number, by: number, cx: number, cy: number, px: number, py: number): void;
15
+ //# sourceMappingURL=triangle2d_get_barycentric.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle2d_get_barycentric.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/triangle2d_get_barycentric.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,mDAXW,MAAM,EAAE,iBACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAkChB"}
@@ -0,0 +1,48 @@
1
+ import { v2_dot } from "../vec2/v2_dot.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} output
6
+ * @param {number} output_offset
7
+ * @param {number} ax
8
+ * @param {number} ay
9
+ * @param {number} bx
10
+ * @param {number} by
11
+ * @param {number} cx
12
+ * @param {number} cy
13
+ * @param {number} px
14
+ * @param {number} py
15
+ */
16
+ export function triangle2d_get_barycentric(
17
+ output, output_offset,
18
+ ax, ay,
19
+ bx, by,
20
+ cx, cy,
21
+ px, py
22
+ ) {
23
+
24
+ const v0_x = bx - ax;
25
+ const v0_y = by - ay;
26
+
27
+ const v1_x = cx - ax;
28
+ const v1_y = cy - ay;
29
+
30
+ const v2_x = px - ax;
31
+ const v2_y = py - ay;
32
+
33
+ const d00 = v2_dot(v0_x, v0_y, v0_x, v0_y);
34
+ const d01 = v2_dot(v0_x, v0_y, v1_x, v1_y);
35
+ const d11 = v2_dot(v1_x, v1_y, v1_x, v1_y);
36
+ const d20 = v2_dot(v2_x, v2_y, v0_x, v0_y);
37
+ const d21 = v2_dot(v2_x, v2_y, v1_x, v1_y);
38
+
39
+ const denom = d00 * d11 - d01 * d01;
40
+
41
+ const v = (d11 * d20 - d01 * d21) / denom;
42
+ const w = (d00 * d21 - d01 * d20) / denom;
43
+ const u = 1.0 - v - w;
44
+
45
+ output[output_offset] = v;
46
+ output[output_offset + 1] = w;
47
+ output[output_offset + 2] = u;
48
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"aabb3_from_v3_array.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,4CAJW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAAM,SAC7C,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,gBACvC,MAAM,QAmChB"}
1
+ {"version":3,"file":"aabb3_from_v3_array.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,4CAJW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAAM,SAC7C,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,gBACvC,MAAM,QA6BhB"}
@@ -1,6 +1,7 @@
1
1
  import { assert } from "../../../assert.js";
2
2
  import { max2 } from "../../../math/max2.js";
3
3
  import { min2 } from "../../../math/min2.js";
4
+ import { aabb3_array_set } from "./aabb3_array_set.js";
4
5
 
5
6
  /**
6
7
  *
@@ -34,11 +35,5 @@ export function aabb3_from_v3_array(result, input, input_length) {
34
35
  }
35
36
 
36
37
  // read out
37
- result[0] = x0;
38
- result[1] = y0;
39
- result[2] = z0;
40
-
41
- result[3] = x1;
42
- result[4] = y1;
43
- result[5] = z1;
38
+ aabb3_array_set(result, 0, x0, y0, z0, x1, y1, z1);
44
39
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {number[]|Float32Array} output
4
+ * @param {number} output_offset
5
+ * @param {number[]|Float32Array} vertices
6
+ * @param {number} a_index
7
+ * @param {number} b_index
8
+ * @param {number} c_index
9
+ */
10
+ export function aabb3_compute_from_triangle(output: number[] | Float32Array, output_offset: number, vertices: number[] | Float32Array, a_index: number, b_index: number, c_index: number): void;
11
+ //# sourceMappingURL=aabb3_compute_from_triangle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb3_compute_from_triangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/aabb3_compute_from_triangle.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,oDAPW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,YACN,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,QAgChB"}
@@ -0,0 +1,43 @@
1
+ import { max3 } from "../../math/max3.js";
2
+ import { min3 } from "../../math/min3.js";
3
+
4
+ /**
5
+ *
6
+ * @param {number[]|Float32Array} output
7
+ * @param {number} output_offset
8
+ * @param {number[]|Float32Array} vertices
9
+ * @param {number} a_index
10
+ * @param {number} b_index
11
+ * @param {number} c_index
12
+ */
13
+ export function aabb3_compute_from_triangle(
14
+ output, output_offset,
15
+ vertices, a_index, b_index, c_index
16
+ ) {
17
+ const a = a_index * 3;
18
+ const b = b_index * 3;
19
+ const c = c_index * 3;
20
+
21
+ // read actual positions of each vertex
22
+ const aX = vertices[a];
23
+ const aY = vertices[a + 1];
24
+ const aZ = vertices[a + 2];
25
+
26
+ const bX = vertices[b];
27
+ const bY = vertices[b + 1];
28
+ const bZ = vertices[b + 2];
29
+
30
+ const cX = vertices[c];
31
+ const cY = vertices[c + 1];
32
+ const cZ = vertices[c + 2];
33
+
34
+ // compute bounds of the triangle
35
+ output[output_offset] = min3(aX, bX, cX);
36
+ output[output_offset + 1] = min3(aY, bY, cY);
37
+ output[output_offset + 2] = min3(aZ, bZ, cZ);
38
+
39
+ output[output_offset + 3] = max3(aX, bX, cX);
40
+ output[output_offset + 4] = max3(aY, bY, cY);
41
+ output[output_offset + 5] = max3(aZ, bZ, cZ);
42
+
43
+ }
@@ -10,6 +10,7 @@ import { sh_index } from "./sh_index.js";
10
10
  @see https://github.com/Bestmaker602/olacziy/blob/212b64ea5f1856b390cdf7629801243f76a4466d/libs/ibl/src/CubemapSH.cpp
11
11
  */
12
12
 
13
+ const scratch_sh3 = new Float32Array(9);
13
14
 
14
15
  /**
15
16
  * SH from environment with high dynamic range (or high frequencies -- high dynamic range creates
@@ -233,14 +234,13 @@ function windowSH(
233
234
  }
234
235
 
235
236
  cutoff = numBands * 4 + 1;// start at a large band
236
- // We need to process each channel separately
237
- const SH = new Float32Array(9);
238
237
 
238
+ // We need to process each channel separately
239
239
  for (let channel = 0; channel < channel_count; channel++) {
240
240
 
241
241
  for (let i = 0; i < numBands * numBands; i++) {
242
242
  // copy this channel
243
- SH[i] = output[output_offset + i * channel_count + channel];
243
+ scratch_sh3[i] = input[input_offset + i * channel_count + channel];
244
244
  }
245
245
 
246
246
  // find a cut-off band that works
@@ -251,9 +251,9 @@ function windowSH(
251
251
 
252
252
  const m = 0.5 * (l + r);
253
253
 
254
- windowing(SH, m, numBands);
254
+ windowing(scratch_sh3, m, numBands);
255
255
 
256
- if (sh3_min(SH) < 0) {
256
+ if (sh3_min(scratch_sh3) < 0) {
257
257
  r = m;
258
258
  } else {
259
259
  l = m;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * computes K(m,l) normalization constant
3
+ * @see "Deringing Spherical Harmonics" by Peter-Pike Sloan
4
+ * @param {number} m
5
+ * @param {number} l
6
+ * @returns {number}
7
+ */
8
+ export function sh_compute_K(m: number, l: number): number;
9
+ //# sourceMappingURL=sh_compute_K.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sh_compute_K.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/sphere/harmonics/sh_compute_K.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,gCAJW,MAAM,KACN,MAAM,GACJ,MAAM,CASlB"}