@woosh/meep-engine 2.109.20 → 2.109.22
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/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +66 -33
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +66 -33
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray_segment.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.js +1 -1
- package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
- package/src/core/collection/array/isArrayEqualStrict.js +1 -3
- package/src/core/collection/array/isArraysEqualWithComparator.d.ts.map +1 -1
- package/src/core/collection/array/isArraysEqualWithComparator.js +3 -2
- package/src/core/collection/array/typed/is_typed_array_equals.d.ts +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.d.ts.map +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.js +8 -2
- package/src/core/geom/3d/aabb/aabb3_array_near_distance_to_intersection_ray_segment.d.ts +16 -0
- package/src/core/geom/3d/aabb/aabb3_array_near_distance_to_intersection_ray_segment.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/aabb3_array_near_distance_to_intersection_ray_segment.js +30 -0
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.d.ts +4 -5
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.js +6 -9
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.d.ts +20 -0
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.js +67 -0
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.d.ts.map +1 -1
- package/src/core/geom/3d/line/line3_compute_nearest_point_to_point.js +15 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +2 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +6 -1
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.d.ts +20 -0
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.js +147 -0
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.spec.d.ts +2 -0
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.spec.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.spec.js +100 -0
- package/src/core/geom/octahedral_uv_crease_distance.d.ts +8 -0
- package/src/core/geom/octahedral_uv_crease_distance.d.ts.map +1 -0
- package/src/core/geom/octahedral_uv_crease_distance.js +26 -0
- package/src/core/math/random/generate_halton_jitter.js +2 -2
- package/src/core/math/statistics/generate_hammersley_jitter.d.ts +7 -0
- package/src/core/math/statistics/generate_hammersley_jitter.d.ts.map +1 -0
- package/src/core/math/statistics/generate_hammersley_jitter.js +16 -0
- package/src/core/math/statistics/hammersley_sequence_2d.js +2 -1
- package/src/core/model/object/objectDeepEquals.d.ts +1 -1
- package/src/core/model/object/objectDeepEquals.d.ts.map +1 -1
- package/src/core/model/object/objectDeepEquals.js +54 -26
- package/src/engine/graphics/geometry/buffered/computeGeometryEquality.d.ts.map +1 -1
- package/src/engine/graphics/geometry/buffered/computeGeometryEquality.js +4 -0
- package/src/engine/graphics/sh3/gi/material/common.glsl +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +0 -7
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +0 -11
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts +7 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +39 -25
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +34 -35
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +18 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +421 -21
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +4 -4
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +4 -2
- package/src/engine/graphics/texture/virtual/prototype.js +3 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} result result is written as a 2d vector, since barycentrics add up to 1, we omit the last value
|
|
6
|
+
* @param {number} result_offset
|
|
7
|
+
* @param {number} px reference point
|
|
8
|
+
* @param {number} py reference point
|
|
9
|
+
* @param {number} pz reference point
|
|
10
|
+
* @param {number} ax Triangle apex A
|
|
11
|
+
* @param {number} ay Triangle apex A
|
|
12
|
+
* @param {number} az Triangle apex A
|
|
13
|
+
* @param {number} bx Triangle apex B
|
|
14
|
+
* @param {number} by Triangle apex B
|
|
15
|
+
* @param {number} bz Triangle apex B
|
|
16
|
+
* @param {number} cx Triangle apex C
|
|
17
|
+
* @param {number} cy Triangle apex C
|
|
18
|
+
* @param {number} cz Triangle apex C
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
export function computeTriangleClosestPointToPointBarycentric(
|
|
22
|
+
result, result_offset,
|
|
23
|
+
px, py, pz,
|
|
24
|
+
ax, ay, az,
|
|
25
|
+
bx, by, bz,
|
|
26
|
+
cx, cy, cz
|
|
27
|
+
){
|
|
28
|
+
|
|
29
|
+
let v, w;
|
|
30
|
+
|
|
31
|
+
// algorithm thanks to Real-Time Collision Detection by Christer Ericson,
|
|
32
|
+
// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,
|
|
33
|
+
// under the accompanying license; see chapter 5.1.5 for detailed explanation.
|
|
34
|
+
// basically, we're distinguishing which of the voronoi regions of the triangle
|
|
35
|
+
// the point lies in with the minimum amount of redundant computation.
|
|
36
|
+
|
|
37
|
+
// localize coordinates with respect to A
|
|
38
|
+
const _vab_x = bx - ax;
|
|
39
|
+
const _vab_y = by - ay;
|
|
40
|
+
const _vab_z = bz - az;
|
|
41
|
+
|
|
42
|
+
const _vac_x = cx - ax;
|
|
43
|
+
const _vac_y = cy - ay;
|
|
44
|
+
const _vac_z = cz - az;
|
|
45
|
+
|
|
46
|
+
const _vap_x = px - ax;
|
|
47
|
+
const _vap_y = py - ay;
|
|
48
|
+
const _vap_z = pz - az;
|
|
49
|
+
|
|
50
|
+
const d1 = v3_dot(_vab_x, _vab_y, _vab_z, _vap_x, _vap_y, _vap_z );
|
|
51
|
+
const d2 = v3_dot(_vac_x, _vac_y, _vac_z, _vap_x, _vap_y, _vap_z );
|
|
52
|
+
|
|
53
|
+
if ( d1 <= 0 && d2 <= 0 ) {
|
|
54
|
+
|
|
55
|
+
// vertex region of A; barycentric coords (1, 0, 0)
|
|
56
|
+
|
|
57
|
+
result[result_offset] = 1;
|
|
58
|
+
result[result_offset+1] = 0;
|
|
59
|
+
|
|
60
|
+
return;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const _vbp_x = px - bx;
|
|
65
|
+
const _vbp_y = py - by;
|
|
66
|
+
const _vbp_z = pz - bz;
|
|
67
|
+
|
|
68
|
+
const d3 = v3_dot(_vab_x, _vab_y, _vab_z, _vbp_x, _vbp_y, _vbp_z );
|
|
69
|
+
const d4 = v3_dot(_vac_x, _vac_y, _vac_z, _vbp_x, _vbp_y, _vbp_z );
|
|
70
|
+
|
|
71
|
+
if ( d3 >= 0 && d4 <= d3 ) {
|
|
72
|
+
|
|
73
|
+
// vertex region of B; barycentric coords (0, 1, 0)
|
|
74
|
+
|
|
75
|
+
result[result_offset] = 0;
|
|
76
|
+
result[result_offset+1] = 1;
|
|
77
|
+
|
|
78
|
+
return;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const vc = d1 * d4 - d3 * d2;
|
|
83
|
+
if ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {
|
|
84
|
+
|
|
85
|
+
v = d1 / ( d1 - d3 );
|
|
86
|
+
// edge region of AB; barycentric coords (1-v, v, 0)
|
|
87
|
+
|
|
88
|
+
result[result_offset] = 1-v;
|
|
89
|
+
result[result_offset+1] = v;
|
|
90
|
+
|
|
91
|
+
return;
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const _vcp_x = px - cx;
|
|
96
|
+
const _vcp_y = py - cy;
|
|
97
|
+
const _vcp_z = pz - cz;
|
|
98
|
+
|
|
99
|
+
const d5 = v3_dot(_vab_x, _vab_y, _vab_z, _vcp_x, _vcp_y, _vcp_z );
|
|
100
|
+
const d6 = v3_dot(_vac_x, _vac_y, _vac_z, _vcp_x, _vcp_y, _vcp_z );
|
|
101
|
+
|
|
102
|
+
if ( d6 >= 0 && d5 <= d6 ) {
|
|
103
|
+
|
|
104
|
+
// vertex region of C; barycentric coords (0, 0, 1)
|
|
105
|
+
|
|
106
|
+
result[result_offset] = 0;
|
|
107
|
+
result[result_offset+1] = 0;
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const vb = d5 * d2 - d1 * d6;
|
|
114
|
+
if ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {
|
|
115
|
+
|
|
116
|
+
w = d2 / ( d2 - d6 );
|
|
117
|
+
|
|
118
|
+
// edge region of AC; barycentric coords (1-w, 0, w)
|
|
119
|
+
|
|
120
|
+
result[result_offset] = 1-w;
|
|
121
|
+
result[result_offset+1] = 0;
|
|
122
|
+
|
|
123
|
+
return;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const va = d3 * d6 - d5 * d4;
|
|
128
|
+
if ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {
|
|
129
|
+
|
|
130
|
+
w = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );
|
|
131
|
+
// edge region of BC; barycentric coords (0, 1-w, w)
|
|
132
|
+
|
|
133
|
+
result[result_offset] = 0;
|
|
134
|
+
result[result_offset+1] = 1-w;
|
|
135
|
+
|
|
136
|
+
return;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// face region
|
|
141
|
+
const denom = 1 / ( va + vb + vc );
|
|
142
|
+
const u = va * denom
|
|
143
|
+
v = vb * denom;
|
|
144
|
+
|
|
145
|
+
result[result_offset] = u;
|
|
146
|
+
result[result_offset+1] = v;
|
|
147
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeTriangleClosestPointToPointBarycentric.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.spec.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { computeTriangleClosestPointToPointBarycentric } from "./computeTriangleClosestPointToPointBarycentric.js";
|
|
2
|
+
|
|
3
|
+
test("basics", () => {
|
|
4
|
+
|
|
5
|
+
const result = [];
|
|
6
|
+
|
|
7
|
+
// internal point
|
|
8
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
9
|
+
result, 0,
|
|
10
|
+
0, 0.5, 0,
|
|
11
|
+
-1, 0, 0,
|
|
12
|
+
1, 0, 0,
|
|
13
|
+
0, 1, 0
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(result).toEqual([0.25,0.25]);
|
|
17
|
+
|
|
18
|
+
// point lies on a vertex
|
|
19
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
20
|
+
result, 0,
|
|
21
|
+
-1, 0, 0,
|
|
22
|
+
-1, 0, 0,
|
|
23
|
+
1, 0, 0,
|
|
24
|
+
0, 1, 0
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(result).toEqual([1,0]);
|
|
28
|
+
|
|
29
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
30
|
+
result, 0,
|
|
31
|
+
1, 0, 0,
|
|
32
|
+
-1, 0, 0,
|
|
33
|
+
1, 0, 0,
|
|
34
|
+
0, 1, 0
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect(result).toEqual([0,1]);
|
|
38
|
+
|
|
39
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
40
|
+
result, 0,
|
|
41
|
+
0, 1, 0,
|
|
42
|
+
-1, 0, 0,
|
|
43
|
+
1, 0, 0,
|
|
44
|
+
0, 1, 0
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(result).toEqual([0,0]);
|
|
48
|
+
|
|
49
|
+
// point lies on an edge
|
|
50
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
51
|
+
result, 0,
|
|
52
|
+
0, 0, 0,
|
|
53
|
+
-1, 0, 0,
|
|
54
|
+
1, 0, 0,
|
|
55
|
+
0, 1, 0
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(result).toEqual([0.5,0.5]);
|
|
59
|
+
|
|
60
|
+
// point lies outside the triangle
|
|
61
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
62
|
+
result, 0,
|
|
63
|
+
- 2, 0, 0,
|
|
64
|
+
-1, 0, 0,
|
|
65
|
+
1, 0, 0,
|
|
66
|
+
0, 1, 0
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(result).toEqual([1,0]);
|
|
70
|
+
|
|
71
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
72
|
+
result, 0,
|
|
73
|
+
2, 0, 0 ,
|
|
74
|
+
-1, 0, 0,
|
|
75
|
+
1, 0, 0,
|
|
76
|
+
0, 1, 0
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(result).toEqual([0,1]);
|
|
80
|
+
|
|
81
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
82
|
+
result, 0,
|
|
83
|
+
0, 2, 0 ,
|
|
84
|
+
-1, 0, 0,
|
|
85
|
+
1, 0, 0,
|
|
86
|
+
0, 1, 0
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(result).toEqual([0,0]);
|
|
90
|
+
|
|
91
|
+
computeTriangleClosestPointToPointBarycentric(
|
|
92
|
+
result, 0,
|
|
93
|
+
0, -2, 0 ,
|
|
94
|
+
-1, 0, 0,
|
|
95
|
+
1, 0, 0,
|
|
96
|
+
0, 1, 0
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(result).toEqual([0.5,0.5]);
|
|
100
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distance to the nearest crease
|
|
3
|
+
* @param {number} u from 0 to 1
|
|
4
|
+
* @param {number} v from 0 to 1
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function octahedral_uv_crease_distance(u: number, v: number): number;
|
|
8
|
+
//# sourceMappingURL=octahedral_uv_crease_distance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"octahedral_uv_crease_distance.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/octahedral_uv_crease_distance.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,iDAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAqBlB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distance to the nearest crease
|
|
3
|
+
* @param {number} u from 0 to 1
|
|
4
|
+
* @param {number} v from 0 to 1
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function octahedral_uv_crease_distance(u, v) {
|
|
8
|
+
|
|
9
|
+
const cross_distance_u = Math.abs(u - 0.5);
|
|
10
|
+
const cross_distance_v = Math.abs(v - 0.5);
|
|
11
|
+
|
|
12
|
+
const cross_distance = Math.min(cross_distance_u, cross_distance_v);
|
|
13
|
+
|
|
14
|
+
const n_u = u * 2 - 1;
|
|
15
|
+
const n_v = v * 2 - 1;
|
|
16
|
+
|
|
17
|
+
// for the belt of the fold
|
|
18
|
+
const fold = 1 - Math.abs(n_u) - Math.abs(n_v);
|
|
19
|
+
|
|
20
|
+
const fold_distance = Math.abs(fold);
|
|
21
|
+
|
|
22
|
+
// distance to the edge of the map, which folds the welding crease
|
|
23
|
+
const welding_crease_distance = Math.min(Math.min(u, 1 - u), Math.min(v, 1 - v));
|
|
24
|
+
|
|
25
|
+
return Math.min(fold_distance, cross_distance, welding_crease_distance);
|
|
26
|
+
}
|
|
@@ -13,8 +13,8 @@ export function generate_halton_jitter(point_count) {
|
|
|
13
13
|
|
|
14
14
|
for (let i = 0; i < point_count; i++) {
|
|
15
15
|
const i2 = i * 2;
|
|
16
|
-
result[i2] =
|
|
17
|
-
result[i2 + 1] =
|
|
16
|
+
result[i2] = halton_sequence(2, i) * 2 - 1;
|
|
17
|
+
result[i2 + 1] = halton_sequence(3, i) * 2 - 1;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
return result;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_hammersley_jitter.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/statistics/generate_hammersley_jitter.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,yDAHW,MAAM,GACJ,YAAY,CAUxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hammersley_sequence_2d } from "./hammersley_sequence_2d.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} sample_count
|
|
6
|
+
* @returns {Float32Array}
|
|
7
|
+
*/
|
|
8
|
+
export function generate_hammersley_jitter(sample_count) {
|
|
9
|
+
const result = new Float32Array(sample_count * 2);
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < sample_count; i++) {
|
|
12
|
+
hammersley_sequence_2d(result, i * 2, i, sample_count);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function objectDeepEquals(a:
|
|
1
|
+
export function objectDeepEquals<A extends object, B extends object>(a: A, b: B, value_equals: (a: A, b: B) => boolean, value_equals_context?: any): boolean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectDeepEquals.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/objectDeepEquals.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"objectDeepEquals.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/objectDeepEquals.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,8IAFa,OAAO,CAiFnB"}
|
|
@@ -5,9 +5,16 @@ import { isArraysEqualWithComparator } from "../../collection/array/isArraysEqua
|
|
|
5
5
|
* @template A,B
|
|
6
6
|
* @param {A} a
|
|
7
7
|
* @param {B} b
|
|
8
|
+
* @param {function(a:A, b:B):boolean} [value_equality_function] allows you to insert custom element comparison function
|
|
9
|
+
* @param {*} [value_equality_function_context]
|
|
8
10
|
* @returns {boolean}
|
|
9
11
|
*/
|
|
10
|
-
export function objectDeepEquals(
|
|
12
|
+
export function objectDeepEquals(
|
|
13
|
+
a, b,
|
|
14
|
+
value_equality_function = objectDeepEquals,
|
|
15
|
+
value_equality_function_context = null
|
|
16
|
+
) {
|
|
17
|
+
|
|
11
18
|
if (a === b) {
|
|
12
19
|
// identity shortcut
|
|
13
20
|
return true;
|
|
@@ -23,41 +30,62 @@ export function objectDeepEquals(a, b) {
|
|
|
23
30
|
if (tA !== "object") {
|
|
24
31
|
// primitive types, identity equality already checked
|
|
25
32
|
return false;
|
|
26
|
-
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (a === null || b === null) {
|
|
36
|
+
// we know that A and B are not the same, so if one of them is a null - there is no possible equality
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
if (Array.isArray(a)) {
|
|
41
|
+
// special fast path for arrays
|
|
42
|
+
if (!Array.isArray(b)) {
|
|
43
|
+
// one is an array, the other is not
|
|
30
44
|
return false;
|
|
31
45
|
}
|
|
46
|
+
return isArraysEqualWithComparator(a, b, value_equality_function, value_equality_function_context);
|
|
47
|
+
}
|
|
32
48
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
49
|
+
// try equals function
|
|
50
|
+
if (
|
|
51
|
+
typeof a.equals === "function"
|
|
52
|
+
&& typeof b.equals === "function"
|
|
53
|
+
) {
|
|
54
|
+
return a.equals(b);
|
|
55
|
+
}
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
const keys_a = Object.keys(a);
|
|
58
|
+
const keys_b = Object.keys(b);
|
|
44
59
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
60
|
+
// sort keys to eliminate ordering concerns
|
|
61
|
+
keys_a.sort();
|
|
62
|
+
keys_b.sort();
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
if (!isArrayEqualStrict(keys_a, keys_b)) {
|
|
65
|
+
// different fields
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
const key = keys_a[i];
|
|
69
|
+
const key_count = keys_a.length;
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
71
|
+
for (let i = 0; i < key_count; i++) {
|
|
72
|
+
const key = keys_a[i];
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
const a_value = a[key];
|
|
75
|
+
const b_value = b[key];
|
|
76
|
+
|
|
77
|
+
const values_are_equal = value_equality_function.call(
|
|
78
|
+
value_equality_function_context,
|
|
79
|
+
a_value,
|
|
80
|
+
b_value
|
|
81
|
+
);
|
|
61
82
|
|
|
83
|
+
if (!values_are_equal) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
62
86
|
}
|
|
87
|
+
|
|
88
|
+
// looks like we have equality
|
|
89
|
+
return true;
|
|
90
|
+
|
|
63
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeGeometryEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeGeometryEquality.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,2CAJW,MAAM,cAAc,KACpB,MAAM,cAAc,GAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"computeGeometryEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeGeometryEquality.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,2CAJW,MAAM,cAAc,KACpB,MAAM,cAAc,GAClB,OAAO,CAmDnB"}
|
|
@@ -9,6 +9,10 @@ import { is_typed_array_equals } from "../../../../core/collection/array/typed/i
|
|
|
9
9
|
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
11
|
export function computeGeometryEquality(a, b) {
|
|
12
|
+
if (a === b) {
|
|
13
|
+
// identity shortcut
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
const a_index = a.getIndex();
|
|
14
18
|
const b_index = b.getIndex();
|
|
@@ -362,7 +362,7 @@ float lpv_probe_getVisibilityMask(vec3 position, uint probe_index) {
|
|
|
362
362
|
float chebyshevWeight = variance / (variance + distance_delta * distance_delta);
|
|
363
363
|
|
|
364
364
|
// Increase contrast in the weight
|
|
365
|
-
chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
|
|
365
|
+
// chebyshevWeight = max(chebyshevWeight * chebyshevWeight * chebyshevWeight, 0.0);
|
|
366
366
|
|
|
367
367
|
return (distToProbe <= mean) ? 1.0 : chebyshevWeight;
|
|
368
368
|
}
|
|
@@ -28,13 +28,6 @@ export class LightProbeVolume {
|
|
|
28
28
|
* @param {number} z
|
|
29
29
|
*/
|
|
30
30
|
add_point(x: number, y: number, z: number): void;
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {number} index
|
|
34
|
-
* @param {number[]} source
|
|
35
|
-
* @param {number} source_offset
|
|
36
|
-
*/
|
|
37
|
-
write_probe(index: number, source: number[], source_offset: number): void;
|
|
38
31
|
/**
|
|
39
32
|
* Build tetrahedral mesh
|
|
40
33
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH;IAiCI,sBAEC;IAED,cAkBC;IAED;;;OAGG;IACH,4BAEC;IAED,uBAEC;IAED,0BAEC;IAMD;;;OAGG;IACH,sCAIC;IAZD,mCAEC;IAYD,sBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;;OAKG;IACH,mCAJW,MAAM,GAEJ,UAAU,CAsBtB;IAGD,yBAEC;;CAEJ;gCAvL+B,wDAAwD;2BAC7D,mCAAmC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
-
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
3
2
|
import {
|
|
4
3
|
compute_delaunay_tetrahedral_mesh
|
|
5
4
|
} from "../../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
@@ -134,16 +133,6 @@ export class LightProbeVolume {
|
|
|
134
133
|
this.#probe_count++;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* @param {number} index
|
|
140
|
-
* @param {number[]} source
|
|
141
|
-
* @param {number} source_offset
|
|
142
|
-
*/
|
|
143
|
-
write_probe(index, source, source_offset) {
|
|
144
|
-
array_copy(source, source_offset, this.#sh3_rgb, index * 9 * 3, 9 * 3);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
136
|
/**
|
|
148
137
|
* Build tetrahedral mesh
|
|
149
138
|
*/
|
|
@@ -7,6 +7,13 @@ export class LightProbeVolumeBaker {
|
|
|
7
7
|
* @param {EntityComponentDataset} ecd
|
|
8
8
|
*/
|
|
9
9
|
bake(lpv: LightProbeVolume, ecd: EntityComponentDataset): TaskGroup;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {PathTracerProbeRenderer} renderer
|
|
13
|
+
* @param {LightProbeVolume} lpv
|
|
14
|
+
* @param {number} probe_index
|
|
15
|
+
*/
|
|
16
|
+
bake_probe(renderer: PathTracerProbeRenderer, lpv: LightProbeVolume, probe_index: number): void;
|
|
10
17
|
}
|
|
11
18
|
import { PathTracerProbeRenderer } from "./PathTracerProbeRenderer.js";
|
|
12
19
|
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightProbeVolumeBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LightProbeVolumeBaker.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js"],"names":[],"mappings":"AAQA;IAEI,8BAAqC;IAGrC;;;;;OAKG;IACH,0DAJa,SAAS,CA2CrB;IAED;;;;;OAKG;IACH,qBAJW,uBAAuB,sCAEvB,MAAM,QA8BhB;CACJ;wCAzFuC,8BAA8B;sBALhD,4CAA4C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
1
2
|
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
2
3
|
import { actionTask } from "../../../../core/process/task/util/actionTask.js";
|
|
3
4
|
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
@@ -29,31 +30,8 @@ export class LightProbeVolumeBaker {
|
|
|
29
30
|
|
|
30
31
|
const probe_count = lpv.count;
|
|
31
32
|
|
|
32
|
-
const tBakeIrradiance = countTask(0, probe_count, (
|
|
33
|
-
|
|
34
|
-
// Bake color
|
|
35
|
-
renderer.bake(
|
|
36
|
-
lpv.points, i * 3,
|
|
37
|
-
lpv.harmonics, i * 9 * 3
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Bake depth
|
|
42
|
-
const max_distance = find_max_depth_radius_for_point(i, lpv.mesh, lpv.points);
|
|
43
|
-
|
|
44
|
-
// bias a little to ensure we capture everything
|
|
45
|
-
const max_depth = max_distance * 1.01 + 1e-6;
|
|
46
|
-
|
|
47
|
-
const depth_resolution = lpv.depth_map_resolution;
|
|
48
|
-
|
|
49
|
-
const probe_element_count = depth_resolution * depth_resolution;
|
|
50
|
-
|
|
51
|
-
renderer.bake_depth_octahedral(
|
|
52
|
-
depth_resolution,
|
|
53
|
-
max_depth,
|
|
54
|
-
lpv.points, i * 3,
|
|
55
|
-
lpv.depth, i * probe_element_count
|
|
56
|
-
);
|
|
33
|
+
const tBakeIrradiance = countTask(0, probe_count, (probe_index) => {
|
|
34
|
+
this.bake_probe(renderer, lpv, probe_index);
|
|
57
35
|
|
|
58
36
|
});
|
|
59
37
|
tBakeIrradiance.estimatedDuration = probe_count;
|
|
@@ -79,4 +57,40 @@ export class LightProbeVolumeBaker {
|
|
|
79
57
|
tPrepare, tBakeIrradiance, tFinish
|
|
80
58
|
], "LightProbeVolume Bake");
|
|
81
59
|
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {PathTracerProbeRenderer} renderer
|
|
64
|
+
* @param {LightProbeVolume} lpv
|
|
65
|
+
* @param {number} probe_index
|
|
66
|
+
*/
|
|
67
|
+
bake_probe(renderer, lpv, probe_index) {
|
|
68
|
+
assert.isNonNegativeInteger(probe_index, 'probe_index');
|
|
69
|
+
|
|
70
|
+
const position_offset = probe_index * 3;
|
|
71
|
+
|
|
72
|
+
// Bake color
|
|
73
|
+
renderer.bake(
|
|
74
|
+
lpv.points, position_offset,
|
|
75
|
+
lpv.harmonics, probe_index * 9 * 3
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// Bake depth
|
|
80
|
+
const max_distance = find_max_depth_radius_for_point(probe_index, lpv.mesh, lpv.points);
|
|
81
|
+
|
|
82
|
+
// bias a little to ensure we capture everything
|
|
83
|
+
const max_depth = max_distance * 1.01 + 1e-6;
|
|
84
|
+
|
|
85
|
+
const depth_resolution = lpv.depth_map_resolution;
|
|
86
|
+
|
|
87
|
+
const probe_element_count = depth_resolution * depth_resolution;
|
|
88
|
+
|
|
89
|
+
renderer.bake_depth_octahedral(
|
|
90
|
+
depth_resolution,
|
|
91
|
+
max_depth,
|
|
92
|
+
lpv.points, position_offset,
|
|
93
|
+
lpv.depth, probe_index * probe_element_count
|
|
94
|
+
);
|
|
95
|
+
}
|
|
82
96
|
}
|
|
@@ -24,7 +24,7 @@ const sampled_irradiance = new Float32Array(3);
|
|
|
24
24
|
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
25
25
|
tracer = new PathTracer();
|
|
26
26
|
max_bounce_count = 7;
|
|
27
|
-
sample_count =
|
|
27
|
+
sample_count = 1024;
|
|
28
28
|
random = seededRandom(0);
|
|
29
29
|
|
|
30
30
|
scene = new PathTracedScene()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bake_octahedral_depth_map.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js"],"names":[],"mappings":"AAiCA;;;;;;;;;GASG;AACH,kDARW,MAAM,EAAE,iBACR,MAAM,oCAEN,MAAM,EAAE,UAAQ,mBAChB,MAAM,cACN,MAAM,aACN,MAAM,QAuHhB"}
|