@woosh/meep-engine 2.114.0 → 2.116.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.
- package/build/meep.cjs +236 -197
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +236 -197
- package/editor/ecs/component/editors/Sampler2DEditor.js +3 -3
- package/editor/view/ecs/HierarchicalEntityListView.js +2 -2
- package/package.json +1 -1
- package/src/core/binary/clz32.d.ts +7 -0
- package/src/core/binary/clz32.d.ts.map +1 -0
- package/src/core/binary/clz32.js +37 -0
- package/src/core/binary/is_data_url.d.ts.map +1 -1
- package/src/core/binary/is_data_url.js +1 -0
- package/src/core/binary/makeArrayBuffer.d.ts.map +1 -1
- package/src/core/binary/makeArrayBuffer.js +1 -0
- package/src/core/binary/msb_32.d.ts +7 -1
- package/src/core/binary/msb_32.d.ts.map +1 -1
- package/src/core/binary/msb_32.js +3 -12
- package/src/core/collection/RingBuffer.d.ts +1 -1
- package/src/core/collection/RingBuffer.js +1 -1
- package/src/core/{primitives/array/compareArrays.d.ts → collection/array/array_compare.d.ts} +2 -2
- package/src/core/collection/array/array_compare.d.ts.map +1 -0
- package/src/core/{primitives/array/compareArrays.js → collection/array/array_compare.js} +5 -1
- package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts} +2 -2
- package/src/core/collection/array/array_index_by_equality.d.ts.map +1 -0
- package/src/core/collection/array/{arrayIndexByEquality.js → array_index_by_equality.js} +1 -1
- package/src/core/collection/array/array_pick_best_element.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElement.js → array_pick_best_element.js} +2 -2
- package/src/core/collection/array/array_pick_best_elements.d.ts +8 -0
- package/src/core/collection/array/array_pick_best_elements.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElements.js → array_pick_best_elements.js} +1 -1
- package/src/core/collection/array/{arraySetDiff.d.ts → array_set_diff.d.ts} +3 -3
- package/src/core/collection/array/array_set_diff.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetDiff.js → array_set_diff.js} +4 -4
- package/src/core/collection/array/{arraySetSortingDiff.d.ts → array_set_diff_sorting.d.ts} +2 -2
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetSortingDiff.js → array_set_diff_sorting.js} +1 -1
- package/src/core/collection/array/combine_hash.js +1 -1
- package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.d.ts +6 -6
- package/src/core/collection/array/randomMultipleFromArray.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.js +5 -5
- package/src/core/collection/array/typed/sparse_typed_array_hash.js +1 -1
- package/src/core/collection/array/typed/typedArrayConstructorByInstance.d.ts.map +1 -0
- package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
- package/src/core/collection/list/FilteredListProjection.js +2 -2
- package/src/core/collection/list/List.js +4 -4
- package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
- package/src/core/geom/2d/Rectangle.js +18 -5
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +4 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts +3 -3
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +11 -4
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +2 -2
- package/src/core/geom/2d/convex-hull/orientation3_array.js +2 -2
- package/src/core/geom/2d/intersect_ray_2d.d.ts.map +1 -1
- package/src/core/geom/2d/intersect_ray_2d.js +5 -5
- package/src/core/geom/2d/{compute_triangle_area_2d.d.ts → triangle2d_compute_area.d.ts} +2 -2
- package/src/core/geom/2d/triangle2d_compute_area.d.ts.map +1 -0
- package/src/core/geom/2d/{compute_triangle_area_2d.js → triangle2d_compute_area.js} +1 -1
- package/src/core/geom/2d/triangle2d_contains_point.d.ts +14 -0
- package/src/core/geom/2d/triangle2d_contains_point.d.ts.map +1 -0
- package/src/core/geom/2d/triangle2d_contains_point.js +39 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +2 -2
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -1
- package/src/core/geom/2d/triangle2d_get_barycentric.js +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +2 -2
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +2 -2
- package/src/core/math/bessel_3.d.ts +1 -1
- package/src/core/math/bessel_3.js +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts.map +1 -1
- package/src/core/math/computeWholeDivisorLow.js +8 -5
- package/src/core/math/interval/separation1D.d.ts.map +1 -0
- package/src/core/math/{separation1D.js → interval/separation1D.js} +3 -3
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +10 -0
- package/src/core/model/object/compareValues.js +5 -5
- package/src/engine/EntityCreator.d.ts +11 -11
- package/src/engine/EntityCreator.d.ts.map +1 -1
- package/src/engine/EntityCreator.js +2 -4
- package/src/engine/ecs/EntityComponentDataset.js +3 -3
- package/src/engine/ecs/grid/HeightMap2NormalMap.js +2 -2
- package/src/engine/ecs/grid/NormalMap2AOMap.js +3 -3
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +2 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +2 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +5 -55
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts +9 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.js +64 -0
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -2
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler_multiply_vector.js → sampler2d_multiply_vector.js} +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler2DToFloat32Texture.js → sampler2d_to_float32_texture.js} +2 -2
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -1
- package/src/engine/grid/obstacle/GridObstacle.d.ts.map +1 -1
- package/src/engine/grid/obstacle/GridObstacle.js +1 -1
- package/src/engine/physics/computeInterceptPoint.js +20 -6
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +14 -17
- package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
- package/src/engine/platform/WebEnginePlatform.js +4 -4
- package/src/engine/save/GameStateLoader.js +2 -2
- package/src/engine/ui/cursor/CursorCoalescence.d.ts.map +1 -1
- package/src/engine/ui/cursor/CursorCoalescence.js +2 -2
- package/src/view/elements/radial/RadialMenu.js +2 -2
- package/src/core/UUID.d.ts +0 -6
- package/src/core/UUID.d.ts.map +0 -1
- package/src/core/UUID.js +0 -21
- package/src/core/collection/array/arrayIndexByEquality.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElements.d.ts +0 -8
- package/src/core/collection/array/arrayPickBestElements.d.ts.map +0 -1
- package/src/core/collection/array/arraySetDiff.d.ts.map +0 -1
- package/src/core/collection/array/arraySetSortingDiff.d.ts.map +0 -1
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.d.ts +0 -12
- package/src/core/geom/2d/convex-hull/orientation3.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.js +0 -489
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts +0 -9
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3_v2.js +0 -12
- package/src/core/math/separation1D.d.ts.map +0 -1
- package/src/core/primitives/array/compareArrays.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts +0 -6
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.js +0 -13
- /package/src/core/collection/array/{arrayPickBestElement.d.ts → array_pick_best_element.d.ts} +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.js +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.d.ts +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.js +0 -0
- /package/src/core/math/{separation1D.d.ts → interval/separation1D.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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":"
|
|
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
|
|
21
|
+
const denominator = (direction_a_x * direction_b_y - direction_a_y * direction_b_x);
|
|
24
22
|
|
|
25
|
-
if (
|
|
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) /
|
|
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
|
|
12
|
-
//# sourceMappingURL=
|
|
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"}
|
|
@@ -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,
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
2
|
-
import {
|
|
2
|
+
import { array_set_diff_sorting } from "../../../collection/array/array_set_diff_sorting.js";
|
|
3
3
|
import { compareFaces } from "./compareFaces.js";
|
|
4
4
|
import { computeTopoMeshVertexDuplicates } from "./computeTopoMeshVertexDuplicates.js";
|
|
5
5
|
import { query_edge_other_vertex } from "./query/query_edge_other_vertex.js";
|
|
@@ -53,7 +53,7 @@ function connectEdges(a, b) {
|
|
|
53
53
|
const faces_a = a.faces;
|
|
54
54
|
const faces_b = b.faces;
|
|
55
55
|
|
|
56
|
-
const diff =
|
|
56
|
+
const diff = array_set_diff_sorting(faces_a, faces_b, compareFaces);
|
|
57
57
|
|
|
58
58
|
const unique_a = diff.uniqueA;
|
|
59
59
|
const unique_b = diff.uniqueB;
|
|
@@ -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,
|
|
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,WACrB,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;IACH,OAFa,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,GACL,OAAO,CAInB;IAED;;;;OAIG;IACH,gBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAMnB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,SAFa,OAAO,CAInB;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,QAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,gCAEC;IAED;;;OAGG;IACH,eAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,6BAFa,OAAO,CAOnB;IAED;;;MAEC;IAED,0BAOC;IAED;;;OAGG;IACH,2CAGC;IAED;;;OAGG;IACH,6CAKC;IAED;;;OAGG;IACH,kDAGC;IAED;;;OAGG;IACH,oDAKC;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;;;;OAMG;IACH,uEAIC;IAED;;;;OAIG;IACH,8CAIC;IAED;;;;OAIG;IACH,iDAIC;IAED;;;;OAIG;IACH,qBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;;OAKG;IACH,eAJW,OAAO,KACP,OAAO,YACP,MAAM,QAOhB;IAED;;;OAGG;IACH,sBAFW,MAAM,EAAE,QAUlB;IAED;;;;OAIG;IACH,kBAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;;OAKG;IACH,kBAJW,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,GAAC,YAAY,WACrB,MAAM,UAwnBS;IAE9B;;OAEG;IACH,uBA1oBe,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"}
|
package/src/core/geom/Vector2.js
CHANGED
|
@@ -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 +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,
|
|
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
|
|
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.
|
|
15
|
-
assert.
|
|
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 "
|
|
2
|
-
import { max2 } from "
|
|
3
|
-
import { min2 } from "
|
|
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":"
|
|
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 {
|
|
2
|
-
import { compareBooleans } from "../../primitives/boolean/compareBooleans.js";
|
|
1
|
+
import { array_compare } from "../../collection/array/array_compare.js";
|
|
3
2
|
import { extractFunctionBody } from "../../function/extractFunctionBody.js";
|
|
4
|
-
import {
|
|
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
|
*
|
|
@@ -42,13 +42,13 @@ export function compareValues(a, b) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
45
|
-
return
|
|
45
|
+
return array_compare(a, b, compareValues);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const aKeys = Object.keys(a);
|
|
49
49
|
const bKeys = Object.keys(b);
|
|
50
50
|
|
|
51
|
-
const dKeys =
|
|
51
|
+
const dKeys = array_compare(aKeys, bKeys, compareStrings);
|
|
52
52
|
|
|
53
53
|
if (dKeys !== 0) {
|
|
54
54
|
return dKeys;
|
|
@@ -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":"
|
|
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 { assert } from "../../core/assert.js";
|
|
2
2
|
import { BitSet } from "../../core/binary/BitSet.js";
|
|
3
|
+
import { array_set_diff } from "../../core/collection/array/array_set_diff.js";
|
|
3
4
|
import { array_shrink_to_size } from "../../core/collection/array/array_shrink_to_size.js";
|
|
4
|
-
import { arraySetDiff } from "../../core/collection/array/arraySetDiff.js";
|
|
5
5
|
import { findSignalHandlerIndexByHandle } from "../../core/events/signal/findSignalHandlerIndexByHandle.js";
|
|
6
6
|
import {
|
|
7
7
|
findSignalHandlerIndexByHandleAndContext
|
|
@@ -463,7 +463,7 @@ export class EntityComponentDataset {
|
|
|
463
463
|
|
|
464
464
|
const newComponentTypeCount = map.length;
|
|
465
465
|
|
|
466
|
-
const diff =
|
|
466
|
+
const diff = array_set_diff(map, this.componentTypeMap);
|
|
467
467
|
|
|
468
468
|
const typesToAdd = diff.uniqueA;
|
|
469
469
|
const typesToRemove = diff.uniqueB;
|
|
@@ -681,7 +681,7 @@ export class EntityComponentDataset {
|
|
|
681
681
|
* @returns {boolean} false if no new classes were added, true if at least one new class was added
|
|
682
682
|
*/
|
|
683
683
|
registerManyComponentTypes(types) {
|
|
684
|
-
const diff =
|
|
684
|
+
const diff = array_set_diff(types, this.componentTypeMap);
|
|
685
685
|
|
|
686
686
|
if (diff.uniqueA.length === 0) {
|
|
687
687
|
// all classes area already registered
|
|
@@ -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 {
|
|
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 =
|
|
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 {
|
|
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 =
|
|
49
|
+
const normalTexture = sampler2d_to_float32_texture(normalMap);
|
|
50
50
|
|
|
51
|
-
const heightTexture =
|
|
51
|
+
const heightTexture = sampler2d_to_float32_texture(heightMap);
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
//construct shader
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bone } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { array_pick_best_element } from "../../../../core/collection/array/array_pick_best_element.js";
|
|
3
3
|
import { string_compute_similarity } from "../../../../core/primitives/strings/string_compute_similarity.js";
|
|
4
4
|
import { extractName } from "../../../../extractName.js";
|
|
5
5
|
import { BoneMapping } from "./skeleton/BoneMapping.js";
|
|
@@ -43,7 +43,7 @@ export function getSkeletonBone(component, boneName) {
|
|
|
43
43
|
//bone not found
|
|
44
44
|
|
|
45
45
|
//try to find similar bones
|
|
46
|
-
const bestMatch =
|
|
46
|
+
const bestMatch = array_pick_best_element(bones, function (bone) {
|
|
47
47
|
return string_compute_similarity(bone.name, boneName);
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -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 {
|
|
7
|
+
* @returns {Float32Array}
|
|
8
8
|
*/
|
|
9
|
-
export function build_cutout_from_atlas_by_alpha({ impostor, renderer, vertex_limit }: ImpostorDescription):
|
|
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
|
package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map
CHANGED
|
@@ -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":"
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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"}
|