@woosh/meep-engine 2.114.0 → 2.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/build/meep.cjs +92 -53
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +92 -53
  4. package/editor/ecs/component/editors/Sampler2DEditor.js +3 -3
  5. package/package.json +1 -1
  6. package/src/core/binary/clz32.d.ts +7 -0
  7. package/src/core/binary/clz32.d.ts.map +1 -0
  8. package/src/core/binary/clz32.js +37 -0
  9. package/src/core/binary/is_data_url.d.ts.map +1 -1
  10. package/src/core/binary/is_data_url.js +1 -0
  11. package/src/core/binary/makeArrayBuffer.d.ts.map +1 -1
  12. package/src/core/binary/makeArrayBuffer.js +1 -0
  13. package/src/core/binary/msb_32.d.ts +7 -1
  14. package/src/core/binary/msb_32.d.ts.map +1 -1
  15. package/src/core/binary/msb_32.js +3 -12
  16. package/src/core/collection/RingBuffer.d.ts +1 -1
  17. package/src/core/collection/RingBuffer.js +1 -1
  18. package/src/core/collection/array/combine_hash.js +1 -1
  19. package/src/core/{primitives → collection}/array/compareArrays.d.ts.map +1 -1
  20. package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts.map +1 -1
  21. package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts.map +1 -1
  22. package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts.map +1 -1
  23. package/src/core/collection/array/randomMultipleFromArray.d.ts +6 -6
  24. package/src/core/collection/array/randomMultipleFromArray.d.ts.map +1 -1
  25. package/src/core/collection/array/randomMultipleFromArray.js +5 -5
  26. package/src/core/collection/array/typed/sparse_typed_array_hash.js +1 -1
  27. package/src/core/collection/array/typed/typedArrayConstructorByInstance.d.ts.map +1 -0
  28. package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
  29. package/src/core/geom/2d/Rectangle.js +18 -5
  30. package/src/core/geom/2d/aabb/aabb2_overlap_exists.d.ts.map +1 -1
  31. package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +4 -1
  32. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts +3 -3
  33. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts.map +1 -1
  34. package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +11 -4
  35. package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +2 -2
  36. package/src/core/geom/2d/convex-hull/orientation3_array.js +2 -2
  37. package/src/core/geom/2d/intersect_ray_2d.d.ts.map +1 -1
  38. package/src/core/geom/2d/intersect_ray_2d.js +5 -5
  39. package/src/core/geom/2d/{compute_triangle_area_2d.d.ts → triangle2d_compute_area.d.ts} +2 -2
  40. package/src/core/geom/2d/triangle2d_compute_area.d.ts.map +1 -0
  41. package/src/core/geom/2d/{compute_triangle_area_2d.js → triangle2d_compute_area.js} +1 -1
  42. package/src/core/geom/2d/triangle2d_contains_point.d.ts +14 -0
  43. package/src/core/geom/2d/triangle2d_contains_point.d.ts.map +1 -0
  44. package/src/core/geom/2d/triangle2d_contains_point.js +39 -0
  45. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +2 -2
  46. package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -1
  47. package/src/core/geom/2d/triangle2d_get_barycentric.js +1 -1
  48. package/src/core/geom/Vector2.d.ts.map +1 -1
  49. package/src/core/geom/Vector2.js +2 -2
  50. package/src/core/math/bessel_3.d.ts +1 -1
  51. package/src/core/math/bessel_3.js +1 -1
  52. package/src/core/math/computeWholeDivisorLow.d.ts +1 -1
  53. package/src/core/math/computeWholeDivisorLow.d.ts.map +1 -1
  54. package/src/core/math/computeWholeDivisorLow.js +8 -5
  55. package/src/core/math/interval/separation1D.d.ts.map +1 -0
  56. package/src/core/math/{separation1D.js → interval/separation1D.js} +3 -3
  57. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  58. package/src/core/math/solveQuadratic.js +10 -0
  59. package/src/core/model/object/compareValues.js +3 -3
  60. package/src/engine/EntityCreator.d.ts +11 -11
  61. package/src/engine/EntityCreator.d.ts.map +1 -1
  62. package/src/engine/EntityCreator.js +2 -4
  63. package/src/engine/ecs/grid/HeightMap2NormalMap.js +2 -2
  64. package/src/engine/ecs/grid/NormalMap2AOMap.js +3 -3
  65. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +2 -2
  66. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
  67. package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +5 -55
  68. package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts +9 -0
  69. package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts.map +1 -0
  70. package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.js +64 -0
  71. package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +2 -2
  72. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  73. package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -2
  74. package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +1 -1
  75. package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +1 -1
  76. package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts +8 -0
  77. package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts.map +1 -0
  78. package/src/engine/graphics/texture/sampler/{sampler_multiply_vector.js → sampler2d_multiply_vector.js} +1 -1
  79. package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts +8 -0
  80. package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts.map +1 -0
  81. package/src/engine/graphics/texture/sampler/{sampler2DToFloat32Texture.js → sampler2d_to_float32_texture.js} +2 -2
  82. package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.d.ts.map +1 -1
  83. package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -1
  84. package/src/engine/grid/obstacle/GridObstacle.d.ts.map +1 -1
  85. package/src/engine/grid/obstacle/GridObstacle.js +1 -1
  86. package/src/engine/physics/computeInterceptPoint.js +20 -6
  87. package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
  88. package/src/engine/physics/mls-mpm/MLS_MPM.js +14 -17
  89. package/src/core/UUID.d.ts +0 -6
  90. package/src/core/UUID.d.ts.map +0 -1
  91. package/src/core/UUID.js +0 -21
  92. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +0 -1
  93. package/src/core/geom/2d/convex-hull/orientation3.d.ts +0 -12
  94. package/src/core/geom/2d/convex-hull/orientation3.d.ts.map +0 -1
  95. package/src/core/geom/2d/convex-hull/orientation3.js +0 -489
  96. package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts +0 -9
  97. package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts.map +0 -1
  98. package/src/core/geom/2d/convex-hull/orientation3_v2.js +0 -12
  99. package/src/core/math/separation1D.d.ts.map +0 -1
  100. package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts +0 -8
  101. package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts.map +0 -1
  102. package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts +0 -8
  103. package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts.map +0 -1
  104. package/src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.d.ts.map +0 -1
  105. package/src/engine/save/storage/InMemoryLocalStorage.d.ts +0 -6
  106. package/src/engine/save/storage/InMemoryLocalStorage.d.ts.map +0 -1
  107. package/src/engine/save/storage/InMemoryLocalStorage.js +0 -13
  108. /package/src/core/{primitives → collection}/array/compareArrays.d.ts +0 -0
  109. /package/src/core/{primitives → collection}/array/compareArrays.js +0 -0
  110. /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts +0 -0
  111. /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.js +0 -0
  112. /package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts +0 -0
  113. /package/src/core/{primitives → collection}/array/computeStridedArrayHash.js +0 -0
  114. /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts +0 -0
  115. /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.js +0 -0
  116. /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.d.ts +0 -0
  117. /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.js +0 -0
  118. /package/src/core/math/{separation1D.d.ts → interval/separation1D.d.ts} +0 -0
@@ -13,9 +13,9 @@ import { intersect_ray_2d } from "../intersect_ray_2d.js";
13
13
  * @param {number[]|Float32Array} output result will be written here
14
14
  * @param {number} output_offset offset into output array where to write the result
15
15
  * @param {number} output_point_count number of points to comprise bounding polygon
16
- * @param {number[]} input_points Points to be bounded, must be an ordered loop
16
+ * @param {number[]} input_points Points to be bounded, must be an ordered loop. Must form a convex hull
17
17
  * @param {number} input_point_count number of points in the input to consider
18
- * @returns {boolean} whether or not a valid result could be found
18
+ * @returns {number} number of points added to the output
19
19
  *
20
20
  * @see 2014 "Implementation of linear minimum area enclosing triangle algorithm" Ovidiu Pârvu & David Gilbert
21
21
  * @see https://github.com/MagnusTiberius/humus3/blob/9d43412d6e6be869e224817f0a966fe48a1af40f/Util/ConvexHull.cpp#L281
@@ -24,9 +24,11 @@ export function fixed_convex_hull_humus(
24
24
  output, output_offset, output_point_count,
25
25
  input_points, input_point_count
26
26
  ) {
27
+
27
28
  if (output_point_count >= input_point_count) {
28
29
  // special case, input polygon is smaller or equal to in cardinality to what's desired
29
30
  array_copy(input_points, 0, output, output_offset, input_point_count * 2);
31
+
30
32
  return input_point_count;
31
33
  }
32
34
 
@@ -61,6 +63,7 @@ export function fixed_convex_hull_humus(
61
63
  combos++;
62
64
 
63
65
  for (let i = 0; i < k; i++) {
66
+ // pick point indices to represent a line
64
67
  const i0 = subset[i];
65
68
  const i1 = subset[(i + 1) % k];
66
69
 
@@ -143,7 +146,11 @@ export function fixed_convex_hull_humus(
143
146
  process_combination(s);
144
147
  }
145
148
 
146
- console.log(`combinations: ${combos}, valid: ${combos_valid} (${(combos_valid * 100 / combos).toFixed(2)}%)`);
149
+ // console.log(`combinations: ${combos}, valid: ${combos_valid} (${(combos_valid * 100 / combos).toFixed(2)}%)`);
150
+ if(combos_valid === 0){
151
+ // no valid combinations
152
+ return 0;
153
+ }
147
154
 
148
- return combos_valid > 0;
155
+ return output_point_count;
149
156
  }
@@ -1,7 +1,7 @@
1
1
  import { array_copy } from "../../../collection/array/array_copy.js";
2
2
  import { Uint32Heap } from "../../../collection/heap/Uint32Heap.js";
3
3
  import { intersect_ray_2d } from "../intersect_ray_2d.js";
4
- import { compute_triangle_area_2d } from "../compute_triangle_area_2d.js";
4
+ import { triangle2d_compute_area } from "../triangle2d_compute_area.js";
5
5
 
6
6
 
7
7
  const v2_temp = new Float32Array(2);
@@ -158,7 +158,7 @@ function compute_collapse_cost(edge, vertex_buffer) {
158
158
  const v1x = vertex_buffer[edge.v1 * 2];
159
159
  const v1y = vertex_buffer[edge.v1 * 2 + 1];
160
160
 
161
- const area = compute_triangle_area_2d(
161
+ const area = triangle2d_compute_area(
162
162
  v0x, v0y, v2_temp[0], v2_temp[1], v1x, v1y
163
163
  );
164
164
 
@@ -1,4 +1,4 @@
1
- import { orientation3 } from "./orientation3.js";
1
+ import { orient2d } from "robust-predicates";
2
2
 
3
3
  /**
4
4
  *
@@ -18,5 +18,5 @@ export function orientation3_array(points, a, b, c) {
18
18
  const cx = points[c * 2];
19
19
  const cy = points[c * 2 + 1];
20
20
 
21
- return orientation3(ax, ay, bx, by, cx, cy);
21
+ return orient2d(ax, ay, bx, by, cx, cy);
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"intersect_ray_2d.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/intersect_ray_2d.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,sCAZW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,cACN,MAAM,cACN,MAAM,iBACN,MAAM,iBACN,MAAM,cACN,MAAM,cACN,MAAM,iBACN,MAAM,iBACN,MAAM,GACJ,OAAO,CAkCnB"}
1
+ {"version":3,"file":"intersect_ray_2d.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/intersect_ray_2d.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,sCAZW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,cACN,MAAM,cACN,MAAM,iBACN,MAAM,iBACN,MAAM,cACN,MAAM,cACN,MAAM,iBACN,MAAM,iBACN,MAAM,GACJ,OAAO,CAoCnB"}
@@ -1,5 +1,3 @@
1
- import { fabsf } from "../../math/fabsf.js";
2
-
3
1
  /**
4
2
  * NOTE: that direction must not be normalized for correct results and instead derived from line length
5
3
  * @param {number[]|Float32Array|Float64Array} out
@@ -20,15 +18,17 @@ export function intersect_ray_2d(
20
18
  origin_b_x, origin_b_y, direction_b_x, direction_b_y
21
19
  ) {
22
20
 
23
- const d = (direction_a_x * direction_b_y - direction_a_y * direction_b_x);
21
+ const denominator = (direction_a_x * direction_b_y - direction_a_y * direction_b_x);
24
22
 
25
- if (fabsf(d) < 0.000000000001) // Parallel lines
23
+ if (Math.abs(denominator) < 1e-7){
24
+ // Parallel lines
26
25
  return false;
26
+ }
27
27
 
28
28
  const oab_y = origin_a_y - origin_b_y;
29
29
  const oab_x = origin_a_x - origin_b_x;
30
30
 
31
- const t = (direction_b_x * oab_y - direction_b_y * oab_x) / d;
31
+ const t = (direction_b_x * oab_y - direction_b_y * oab_x) / denominator;
32
32
 
33
33
  if (t < 0.5) // Intersects on the wrong side
34
34
  return false;
@@ -8,5 +8,5 @@
8
8
  * @param {number} y2
9
9
  * @returns {number}
10
10
  */
11
- export function compute_triangle_area_2d(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): number;
12
- //# sourceMappingURL=compute_triangle_area_2d.d.ts.map
11
+ export function triangle2d_compute_area(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): number;
12
+ //# sourceMappingURL=triangle2d_compute_area.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle2d_compute_area.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/triangle2d_compute_area.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,4CARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAclB"}
@@ -8,7 +8,7 @@
8
8
  * @param {number} y2
9
9
  * @returns {number}
10
10
  */
11
- export function compute_triangle_area_2d(
11
+ export function triangle2d_compute_area(
12
12
  x0, y0,
13
13
  x1, y1,
14
14
  x2, y2
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {number} ax
4
+ * @param {number} ay
5
+ * @param {number} bx
6
+ * @param {number} by
7
+ * @param {number} cx
8
+ * @param {number} cy
9
+ * @param {number} px reference point X
10
+ * @param {number} py reference point Y
11
+ * @returns {boolean}
12
+ */
13
+ export function triangle2d_contains_point(ax: number, ay: number, bx: number, by: number, cx: number, cy: number, px: number, py: number): boolean;
14
+ //# sourceMappingURL=triangle2d_contains_point.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle2d_contains_point.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/triangle2d_contains_point.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,8CAVW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAwBnB"}
@@ -0,0 +1,39 @@
1
+ import { triangle2d_get_barycentric } from "./triangle2d_get_barycentric.js";
2
+
3
+ const scratch = new Float32Array(3);
4
+
5
+ /**
6
+ *
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 reference point X
14
+ * @param {number} py reference point Y
15
+ * @returns {boolean}
16
+ */
17
+ export function triangle2d_contains_point(
18
+ ax, ay,
19
+ bx, by,
20
+ cx, cy,
21
+ px, py
22
+ ) {
23
+ triangle2d_get_barycentric(
24
+ scratch, 0,
25
+ ax, ay,
26
+ bx, by,
27
+ cx, cy,
28
+ px, py
29
+ );
30
+
31
+ const u = scratch[0];
32
+ const v = scratch[1];
33
+ const w = scratch[2];
34
+
35
+ return u >= 0
36
+ && v >= 0
37
+ && w >= 0
38
+ && Math.abs(1 - u - v - w) < 1e-7;
39
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  *
3
- * @param {number[]} output
3
+ * @param {number[]|TypedArray|Float32Array} output
4
4
  * @param {number} output_offset
5
5
  * @param {number} ax
6
6
  * @param {number} ay
@@ -11,5 +11,5 @@
11
11
  * @param {number} px reference point X
12
12
  * @param {number} py reference point Y
13
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;
14
+ export function triangle2d_get_barycentric(output: number[] | TypedArray | Float32Array, output_offset: number, ax: number, ay: number, bx: number, by: number, cx: number, cy: number, px: number, py: number): void;
15
15
  //# sourceMappingURL=triangle2d_get_barycentric.d.ts.map
@@ -1 +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"}
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,gBAAY,YAAY,iBAChC,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAkChB"}
@@ -2,7 +2,7 @@ import { v2_dot } from "../vec2/v2_dot.js";
2
2
 
3
3
  /**
4
4
  *
5
- * @param {number[]} output
5
+ * @param {number[]|TypedArray|Float32Array} output
6
6
  * @param {number} output_offset
7
7
  * @param {number} ax
8
8
  * @param {number} ay
@@ -1 +1 @@
1
- {"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":";AAmBA;IACI;;;;;OAKG;IACH,gBAJW,MAAM,MACN,MAAM,EAuBhB;IAbG;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV,0DAA6B;IAGjC;;;;OAIG;IACH,iBAHW,MAAM,EAAE,WACR,MAAM,QAOhB;IAED;;;;OAIG;IACH,eAHW,MAAM,EAAE,WACR,MAAM,QAKhB;IAED,iBAMC;IAED;;;;;OAKG;IACH,OAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAqBnB;IAED;;;;OAIG;IACH,aAHW,MAAM,KACN,MAAM,QAYhB;IAED;;;;OAIG;IACH,QAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,QAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;OAKG;IACH,QAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,OAAO,KACP,OAAO,QAIjB;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,OAAO,CAInB;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;I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BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,eAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,2BAHW,OAAO,GACL,MAAM,CAOlB;IAED;;OAEG;IACH,UAFa,MAAM,CAIlB;IAED;;OAEG;IACH,kBAWC;IAGD;;;OAGG;IACH,QAFa,MAAM,CAOlB;IAED;;;OAGG;IACH,cAFW,MAAM,QAahB;IAED;;;;;OAKG;IACH,6CAFa,OAAO,CAQnB;IAED,mBAEC;IAED;;;;OAIG;IACH,cAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,qBAJW,OAAO,cACP,MAAM,GACL,OAAO,CAIlB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,cACN,MAAM,GACL,OAAO,CAKlB;IAUD,mBAEC;IAVD,gBAEC;IAUD,mBAEC;IAVD,gBAEC;IAsDL;;;OAGG;IACH,oBAFU,OAAO,CAEU;IAI3B;;OAEG;IACH,sBAznBe,MAAM,EAAE,WACR,MAAM,UAwnBS;IAE9B;;OAEG;IACH,uBA1oBe,MAAM,EAAE,WACR,MAAM,UAyoBU;IA3D3B,sDAKC;CACJ;;mBAIS,OAAO;qBAMP,OAAO;qBAMP,OAAO;sBAMP,OAAO;qBAMP,OAAO;oBAKP,OAAO;;;mBAlqBE,4BAA4B;4BAQnB,uBAAuB"}
1
+ {"version":3,"file":"Vector2.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector2.js"],"names":[],"mappings":";AAmBA;IACI;;;;;OAKG;IACH,gBAJW,MAAM,MACN,MAAM,EAuBhB;IAbG;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV;;;OAGG;IACH,GAFU,MAAM,CAEN;IAEV,0DAA6B;IAGjC;;;;OAIG;IACH,iBAHW,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,QAOhB;IAED;;;;OAIG;IACH,eAHW,MAAM,EAAE,GAAC,YAAY,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MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,UAyoBU;IA3D3B,sDAKC;CACJ;;mBAIS,OAAO;qBAMP,OAAO;qBAMP,OAAO;sBAMP,OAAO;qBAMP,OAAO;oBAKP,OAAO;;;mBAlqBE,4BAA4B;4BAQnB,uBAAuB"}
@@ -48,7 +48,7 @@ class Vector2 {
48
48
 
49
49
  /**
50
50
  *
51
- * @param {number[]} array
51
+ * @param {number[]|Float32Array} array
52
52
  * @param {number} offset
53
53
  */
54
54
  fromArray(array, offset = 0) {
@@ -60,7 +60,7 @@ class Vector2 {
60
60
 
61
61
  /**
62
62
  *
63
- * @param {number[]} array
63
+ * @param {number[]|Float32Array} array
64
64
  * @param {number} offset
65
65
  */
66
66
  toArray(array, offset = 0) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Kaiser Bessel Function of third kind
2
+ * Kaiser Bessel Function of third kind (BesselJ(3,x))
3
3
  * NOTE: this is an approximation, if input value is sufficiently large - results will be way off
4
4
  * This is a Tylor series approximation
5
5
  * @see https://www.shadertoy.com/view/wlf3RH
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Kaiser Bessel Function of third kind
2
+ * Kaiser Bessel Function of third kind (BesselJ(3,x))
3
3
  * NOTE: this is an approximation, if input value is sufficiently large - results will be way off
4
4
  * This is a Tylor series approximation
5
5
  * @see https://www.shadertoy.com/view/wlf3RH
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Compute lowest positive integer divisor of a given "product" value
2
+ * Compute the largest positive integer divisor of a given "product" value
3
3
  * @param {number} product
4
4
  * @param {number} limit
5
5
  * @returns {number}
@@ -1 +1 @@
1
- {"version":3,"file":"computeWholeDivisorLow.d.ts","sourceRoot":"","sources":["../../../../src/core/math/computeWholeDivisorLow.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,gDAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAuBlB"}
1
+ {"version":3,"file":"computeWholeDivisorLow.d.ts","sourceRoot":"","sources":["../../../../src/core/math/computeWholeDivisorLow.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,gDAJW,MAAM,SACN,MAAM,GACJ,MAAM,CA0BlB"}
@@ -1,18 +1,21 @@
1
1
  import { assert } from "../assert.js";
2
2
 
3
3
  /**
4
- * Compute lowest positive integer divisor of a given "product" value
4
+ * Compute the largest positive integer divisor of a given "product" value
5
5
  * @param {number} product
6
6
  * @param {number} limit
7
7
  * @returns {number}
8
8
  */
9
9
  export function computeWholeDivisorLow(product, limit) {
10
- assert.typeOf(product, 'number', 'product');
11
- assert.typeOf(limit, 'number', 'limit');
12
10
 
11
+ assert.isNumber(product, 'product');
12
+ assert.isInteger(product, 'product');
13
13
 
14
- assert.ok(Number.isInteger(product), `expected product to be an integer, instead got '${product}'`);
15
- assert.ok(Number.isInteger(limit), `expected limit to be an integer, instead got '${limit}'`);
14
+ assert.isNumber(limit, 'limit');
15
+ assert.isInteger(limit, 'limit');
16
+
17
+ assert.isFiniteNumber(limit,'limit');
18
+ assert.isFiniteNumber(product,'product');
16
19
 
17
20
  let i = limit;
18
21
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separation1D.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/interval/separation1D.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,iCANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CASlB"}
@@ -1,6 +1,6 @@
1
- import { assert } from "../assert.js";
2
- import { max2 } from "./max2.js";
3
- import { min2 } from "./min2.js";
1
+ import { assert } from "../../assert.js";
2
+ import { max2 } from "../max2.js";
3
+ import { min2 } from "../min2.js";
4
4
 
5
5
  /**
6
6
  * Returns a number representing overlap distance between two 1D line segments.
@@ -1 +1 @@
1
- {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAuClB"}
1
+ {"version":3,"file":"solveQuadratic.d.ts","sourceRoot":"","sources":["../../../../src/core/math/solveQuadratic.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,KAJN,MAAM,KACN,MAAM,KACN,MAAM,GAGJ,MAAM,CAgDlB"}
@@ -1,3 +1,4 @@
1
+ import { assert } from "../assert.js";
1
2
  import { EPSILON } from "./EPSILON.js";
2
3
 
3
4
  /**
@@ -10,10 +11,17 @@ import { EPSILON } from "./EPSILON.js";
10
11
  * @returns {number} number of found solutions (roots)
11
12
  */
12
13
  export function solveQuadratic(result, result_offset, a, b, c) {
14
+ assert.isNumber(a, 'a');
15
+ assert.isNumber(b, 'b');
16
+ assert.isNumber(c, 'c');
17
+
13
18
 
14
19
  if (Math.abs(a) < EPSILON) {
20
+
15
21
  if (Math.abs(b) < EPSILON) {
22
+
16
23
  if (Math.abs(c) < EPSILON) {
24
+ // special case, all variables are close to 0
17
25
 
18
26
  result[result_offset] = 0;
19
27
  result[result_offset + 1] = 0;
@@ -21,12 +29,14 @@ export function solveQuadratic(result, result_offset, a, b, c) {
21
29
  return 2;
22
30
 
23
31
  }
32
+
24
33
  } else {
25
34
  result[result_offset] = -c / b;
26
35
  result[result_offset + 1] = -c / b;
27
36
 
28
37
  return 2;
29
38
  }
39
+
30
40
  } else {
31
41
  // 2 root solution
32
42
 
@@ -1,8 +1,8 @@
1
- import { compareStrings } from "../../primitives/strings/compareStrings.js";
2
- import { compareBooleans } from "../../primitives/boolean/compareBooleans.js";
1
+ import { compareArrays } from "../../collection/array/compareArrays.js";
3
2
  import { extractFunctionBody } from "../../function/extractFunctionBody.js";
4
- import { compareArrays } from "../../primitives/array/compareArrays.js";
3
+ import { compareBooleans } from "../../primitives/boolean/compareBooleans.js";
5
4
  import { number_compare_ascending } from "../../primitives/numbers/number_compare_ascending.js";
5
+ import { compareStrings } from "../../primitives/strings/compareStrings.js";
6
6
 
7
7
  /**
8
8
  *
@@ -1,14 +1,3 @@
1
- /**
2
- *
3
- * @param timeout
4
- * @param action
5
- * @returns {Entity}
6
- */
7
- export function createTimer({ timeout, action }: {
8
- timeout: any;
9
- action: any;
10
- }): Entity;
11
- import Entity from './ecs/Entity.js';
12
1
  /**
13
2
  *
14
3
  * @param {Vector3} [position]
@@ -21,5 +10,16 @@ import Entity from './ecs/Entity.js';
21
10
  * @returns {Entity}
22
11
  */
23
12
  export function createSound({ position, timeout, url, track, positioned, channel, volume }?: Vector3): Entity;
13
+ /**
14
+ *
15
+ * @param timeout
16
+ * @param action
17
+ * @returns {Entity}
18
+ */
19
+ export function createTimer({ timeout, action }: {
20
+ timeout: any;
21
+ action: any;
22
+ }): Entity;
24
23
  import Vector3 from "../core/geom/Vector3.js";
24
+ import Entity from './ecs/Entity.js';
25
25
  //# sourceMappingURL=EntityCreator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityCreator.d.ts","sourceRoot":"","sources":["../../../src/engine/EntityCreator.js"],"names":[],"mappings":"AAwEA;;;;;GAKG;AACH;;;IAFa,MAAM,CAkBlB;mBA3FkB,iBAAiB;AASpC;;;;;;;;;;GAUG;AACH,6FATW,OAAO,GAOL,MAAM,CAiDlB;oBAtEmB,yBAAyB"}
1
+ {"version":3,"file":"EntityCreator.d.ts","sourceRoot":"","sources":["../../../src/engine/EntityCreator.js"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,6FATW,OAAO,GAOL,MAAM,CAiDlB;AAED;;;;;GAKG;AACH;;;IAFa,MAAM,CAkBlB;oBA9FmB,yBAAyB;mBAG1B,iBAAiB"}
@@ -21,7 +21,7 @@ import { SoundEmitterChannels } from "./sound/ecs/emitter/SoundEmitterSystem.js"
21
21
  * @param {number} [volume]
22
22
  * @returns {Entity}
23
23
  */
24
- function createSound(
24
+ export function createSound(
25
25
  {
26
26
  position = Vector3.zero,
27
27
  timeout = 60,
@@ -92,6 +92,4 @@ export function createTimer({ timeout, action }) {
92
92
  }));
93
93
 
94
94
  return builder;
95
- }
96
-
97
- export { createSound };
95
+ }
@@ -1,7 +1,7 @@
1
1
  import ImageFilter from '../../graphics/filter/ImageFilter.js';
2
2
  import NormalMapShader from '../../graphics/shaders/NormalMapShader2.js';
3
3
  import { Sampler2D } from '../../graphics/texture/sampler/Sampler2D.js';
4
- import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
4
+ import { sampler2d_to_float32_texture } from "../../graphics/texture/sampler/sampler2d_to_float32_texture.js";
5
5
 
6
6
 
7
7
  function convertChannel(v) {
@@ -51,7 +51,7 @@ function heightMap2NormalMap(renderer, sampler) {
51
51
  const width = sampler.width;
52
52
  const height = sampler.height;
53
53
 
54
- const texture = sampler2DtoFloat32Texture(sampler);
54
+ const texture = sampler2d_to_float32_texture(sampler);
55
55
 
56
56
  //construct shader
57
57
  const shader = new NormalMapShader();
@@ -3,7 +3,7 @@ import ImageFilter from '../../graphics/filter/ImageFilter.js';
3
3
  import AmbientOcclusionShader from '../../graphics/shaders/AmbientOcclusionShader.js';
4
4
  import { DenoiseShader } from "../../graphics/shaders/DenoiseShader.js";
5
5
  import { Sampler2D } from '../../graphics/texture/sampler/Sampler2D.js';
6
- import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
6
+ import { sampler2d_to_float32_texture } from "../../graphics/texture/sampler/sampler2d_to_float32_texture.js";
7
7
 
8
8
  function filterResult2Texture(data, width, height) {
9
9
  const result = new DataTexture();
@@ -46,9 +46,9 @@ function normalMap2OcclusionMap(
46
46
  const width = resultSize.x;
47
47
  const height = resultSize.y;
48
48
  //
49
- const normalTexture = sampler2DtoFloat32Texture(normalMap);
49
+ const normalTexture = sampler2d_to_float32_texture(normalMap);
50
50
 
51
- const heightTexture = sampler2DtoFloat32Texture(heightMap);
51
+ const heightTexture = sampler2d_to_float32_texture(heightMap);
52
52
 
53
53
 
54
54
  //construct shader
@@ -4,7 +4,7 @@
4
4
  * @param {ImpostorDescription} impostor
5
5
  * @param {THREE.WebGLRenderer} renderer
6
6
  * @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
7
- * @returns {number[]}
7
+ * @returns {Float32Array}
8
8
  */
9
- export function build_cutout_from_atlas_by_alpha({ impostor, renderer, vertex_limit }: ImpostorDescription): number[];
9
+ export function build_cutout_from_atlas_by_alpha({ impostor, renderer, vertex_limit }: ImpostorDescription): Float32Array;
10
10
  //# sourceMappingURL=build_cutout_from_atlas_by_alpha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,6GAFa,MAAM,EAAE,CAqHpB"}
1
+ {"version":3,"file":"build_cutout_from_atlas_by_alpha.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,6GAFa,YAAY,CA0ExB"}
@@ -1,17 +1,10 @@
1
1
  //
2
2
 
3
3
  import { assert } from "../../../../../core/assert.js";
4
- import { array_copy } from "../../../../../core/collection/array/array_copy.js";
5
- import { compute_polygon_area_2d } from "../../../../../core/geom/2d/compute_polygon_area_2d.js";
6
- import { convex_hull_jarvis_2d } from "../../../../../core/geom/2d/convex-hull/convex_hull_jarvis_2d.js";
7
- import { fixed_convex_hull_relaxation } from "../../../../../core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js";
8
4
  import { max2 } from "../../../../../core/math/max2.js";
9
5
  import { renderSamplerFromTexture } from "../../../render/visibility/hiz/buildCanvasViewFromTexture.js";
10
6
  import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
11
- import {
12
- make_edge_condition_channel_threshold
13
- } from "../../../texture/sampler/search/make_edge_condition_channel_threshold.js";
14
- import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d_find_pixels.js";
7
+ import { sampler2d_build_cutout } from "./sampler2d_build_cutout.js";
15
8
 
16
9
  /**
17
10
  * TODO For this specific use-case with octahedral impostors we can get away tracing a circular shape in general.
@@ -19,7 +12,7 @@ import { sampler2d_find_pixels } from "../../../texture/sampler/search/sampler2d
19
12
  * @param {ImpostorDescription} impostor
20
13
  * @param {THREE.WebGLRenderer} renderer
21
14
  * @param {number} vertex_limit how many vertices to use for the billboard, more vertices will provide better fit and lower area reducing overdraw at the cost of extra triangles. Prefer values between 4 and 16
22
- * @returns {number[]}
15
+ * @returns {Float32Array}
23
16
  */
24
17
  export function build_cutout_from_atlas_by_alpha({
25
18
 
@@ -50,7 +43,7 @@ export function build_cutout_from_atlas_by_alpha({
50
43
  const frame_size = impostor.resolution / impostor.frame_count;
51
44
  const frame_size_i = Math.ceil(frame_size);
52
45
 
53
- const accummulator = Sampler2D.uint8(1, frame_size_i, frame_size_i);
46
+ const accumulator = Sampler2D.uint8(1, frame_size_i, frame_size_i);
54
47
 
55
48
  for (let i = 0; i < impostor.frame_count; i++) {
56
49
 
@@ -76,44 +69,14 @@ export function build_cutout_from_atlas_by_alpha({
76
69
 
77
70
  const local_index = y * frame_size_i + x;
78
71
 
79
- accummulator.data[local_index] = max2(v, accummulator.data[local_index]);
72
+ accumulator.data[local_index] = max2(v, accumulator.data[local_index]);
80
73
  }
81
74
  }
82
75
  }
83
76
  }
84
77
  }
85
78
 
86
-
87
- const edge_pixels = sampler2d_find_pixels(accummulator, make_edge_condition_channel_threshold(0, 5));
88
-
89
- // filtered pixels
90
- const filtered_edge_pixels = [];
91
-
92
- const half_pixel = 0.5;
93
-
94
- for (let i = 0; i < edge_pixels.length; i += 2) {
95
- const x = edge_pixels[i];
96
- const y = edge_pixels[i + 1];
97
-
98
- filtered_edge_pixels.push(x - half_pixel, y - half_pixel);
99
- filtered_edge_pixels.push(x + half_pixel, y - half_pixel);
100
- filtered_edge_pixels.push(x + half_pixel, y + half_pixel);
101
- filtered_edge_pixels.push(x - half_pixel, y + half_pixel);
102
- }
103
-
104
- const hull_point_indices = convex_hull_jarvis_2d(filtered_edge_pixels, filtered_edge_pixels.length / 2);
105
-
106
- const hull_points = [];
107
-
108
- for (let i = 0; i < hull_point_indices.length; i++) {
109
- const hpi = hull_point_indices[i];
110
-
111
- array_copy(filtered_edge_pixels, hpi * 2, hull_points, i * 2, 2);
112
- }
113
-
114
- const cutout_points = new Float32Array(vertex_limit * 2);
115
-
116
- fixed_convex_hull_relaxation(cutout_points, 0, vertex_limit, hull_points, hull_point_indices.length);
79
+ const cutout_points = sampler2d_build_cutout(accumulator, vertex_limit, frame_size);
117
80
 
118
81
  // normalize points
119
82
  for (let i = 0; i < vertex_limit; i++) {
@@ -121,19 +84,6 @@ export function build_cutout_from_atlas_by_alpha({
121
84
  cutout_points[i * 2 + 1] /= frame_size;
122
85
  }
123
86
 
124
- const area = compute_polygon_area_2d(cutout_points, vertex_limit);
125
-
126
- console.log(`Cutout area: ${area}`);
127
-
128
- if (area >= 0.99 && vertex_limit >= 4) {
129
- // default back to aligned quad, produced result is a degradation
130
- return new Float32Array([
131
- 0, 0,
132
- 1, 0,
133
- 1, 1,
134
- 0, 1
135
- ]);
136
- }
137
87
 
138
88
  return cutout_points;
139
89
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {Sampler2D} accumulator
4
+ * @param {number} vertex_limit
5
+ * @param {number} frame_size
6
+ * @returns {Float32Array}
7
+ */
8
+ export function sampler2d_build_cutout(accumulator: Sampler2D, vertex_limit: number, frame_size: number): Float32Array;
9
+ //# sourceMappingURL=sampler2d_build_cutout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampler2d_build_cutout.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,6EAJW,MAAM,cACN,MAAM,GACJ,YAAY,CAiDxB"}