@woosh/meep-engine 2.109.19 → 2.109.21
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 +12 -8
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +12 -8
- 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/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/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
- package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
- package/src/engine/input/devices/PointerDevice.js +3 -3
package/build/meep.module.js
CHANGED
|
@@ -12,9 +12,7 @@ function isArrayEqualStrict(a, b) {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
let i = 0;
|
|
16
|
-
|
|
17
|
-
for (; i < il; i++) {
|
|
15
|
+
for (let i = 0; i < il; i++) {
|
|
18
16
|
|
|
19
17
|
if (a[i] !== b[i]) {
|
|
20
18
|
return false;
|
|
@@ -49014,7 +49012,7 @@ function compute_typed_array_constructor_from_data_type(dt) {
|
|
|
49014
49012
|
//
|
|
49015
49013
|
|
|
49016
49014
|
/**
|
|
49017
|
-
*
|
|
49015
|
+
* Optimized equality method for typed arrays, typically significantly faster than `isArrayEqualStrict`, especially for larger arrays
|
|
49018
49016
|
* @param {Uint8Array|Uint32Array} a
|
|
49019
49017
|
* @param {Uint8Array|Uint32Array} b
|
|
49020
49018
|
* @returns {boolean}
|
|
@@ -49032,7 +49030,12 @@ function is_typed_array_equals(a, b) {
|
|
|
49032
49030
|
return false;
|
|
49033
49031
|
}
|
|
49034
49032
|
|
|
49035
|
-
if (a_length
|
|
49033
|
+
if (a_length === 0) {
|
|
49034
|
+
// both arrays are empty
|
|
49035
|
+
return true;
|
|
49036
|
+
}
|
|
49037
|
+
|
|
49038
|
+
if (a_length < 128) { // size is determined empirically, nothing special about the number itself
|
|
49036
49039
|
// small array, do direct compare
|
|
49037
49040
|
return isArrayEqualStrict(a, b);
|
|
49038
49041
|
}
|
|
@@ -49071,6 +49074,7 @@ function is_typed_array_equals(a, b) {
|
|
|
49071
49074
|
a_proxy = new Uint32Array(a_buffer, a.byteOffset, byte_length / 4);
|
|
49072
49075
|
b_proxy = new Uint32Array(b_buffer, b.byteOffset, byte_length / 4);
|
|
49073
49076
|
} else if (bytes_per_element < 2 && byte_length % 2 === 0) {
|
|
49077
|
+
// 2 byte alignment, can use uint16
|
|
49074
49078
|
a_proxy = new Uint16Array(a_buffer, a.byteOffset, byte_length / 2);
|
|
49075
49079
|
b_proxy = new Uint16Array(b_buffer, b.byteOffset, byte_length / 2);
|
|
49076
49080
|
}
|
|
@@ -91716,7 +91720,7 @@ function observeDrag(up, down, move, dragStart, dragEnd, drag) {
|
|
|
91716
91720
|
/**
|
|
91717
91721
|
*
|
|
91718
91722
|
* @param {Vector2} result
|
|
91719
|
-
* @param {MouseEvent} event
|
|
91723
|
+
* @param {MouseEvent|Touch} event
|
|
91720
91724
|
* @param {Element} source
|
|
91721
91725
|
*/
|
|
91722
91726
|
function readPositionFromMouseEvent(result, event, source = event.target) {
|
|
@@ -91945,7 +91949,7 @@ class PointerDevice {
|
|
|
91945
91949
|
#eventHandlerTouchMove = (event) => {
|
|
91946
91950
|
event.preventDefault();
|
|
91947
91951
|
|
|
91948
|
-
getTouchCenter(event.touches, position);
|
|
91952
|
+
getTouchCenter(event.touches, this.position);
|
|
91949
91953
|
|
|
91950
91954
|
const delta = new Vector2();
|
|
91951
91955
|
|
|
@@ -92042,7 +92046,7 @@ class PointerDevice {
|
|
|
92042
92046
|
/**
|
|
92043
92047
|
*
|
|
92044
92048
|
* @param {Vector2} result
|
|
92045
|
-
* @param {MouseEvent|
|
|
92049
|
+
* @param {MouseEvent|Touch} event
|
|
92046
92050
|
*/
|
|
92047
92051
|
readPointerPositionFromEvent(result, event) {
|
|
92048
92052
|
readPositionFromMouseEvent(result, event, this.domElement);
|
package/package.json
CHANGED
|
@@ -66,7 +66,7 @@ export function bvh_query_leaves_ray_segment(
|
|
|
66
66
|
float32[address], float32[address + 1], float32[address + 2],
|
|
67
67
|
float32[address + 3], float32[address + 4], float32[address + 5],
|
|
68
68
|
origin_x, origin_y, origin_z,
|
|
69
|
-
direction_x, direction_y, direction_z,
|
|
69
|
+
1 / direction_x, 1 / direction_y, 1 / direction_z,
|
|
70
70
|
t_min, t_max
|
|
71
71
|
);
|
|
72
72
|
|
|
@@ -70,7 +70,7 @@ export function bvh_query_user_data_ray_segment(
|
|
|
70
70
|
float32[address], float32[address + 1], float32[address + 2],
|
|
71
71
|
float32[address + 3], float32[address + 4], float32[address + 5],
|
|
72
72
|
origin_x, origin_y, origin_z,
|
|
73
|
-
direction_x, direction_y, direction_z,
|
|
73
|
+
1 / direction_x, 1 / direction_y, 1 / direction_z,
|
|
74
74
|
t_min, t_max
|
|
75
75
|
);
|
|
76
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isArrayEqualStrict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqualStrict.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sCAJW,QAAM,UAAU,KAChB,QAAM,UAAU,GACd,OAAO,
|
|
1
|
+
{"version":3,"file":"isArrayEqualStrict.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArrayEqualStrict.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sCAJW,QAAM,UAAU,KAChB,QAAM,UAAU,GACd,OAAO,CAoBnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_typed_array_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/is_typed_array_equals.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,UAAU,GAAC,WAAW,KACtB,UAAU,GAAC,WAAW,GACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"is_typed_array_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/is_typed_array_equals.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,UAAU,GAAC,WAAW,KACtB,UAAU,GAAC,WAAW,GACpB,OAAO,CAiEnB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isArrayEqualStrict } from "../isArrayEqualStrict.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Optimized equality method for typed arrays, typically significantly faster than `isArrayEqualStrict`, especially for larger arrays
|
|
6
6
|
* @param {Uint8Array|Uint32Array} a
|
|
7
7
|
* @param {Uint8Array|Uint32Array} b
|
|
8
8
|
* @returns {boolean}
|
|
@@ -20,7 +20,12 @@ export function is_typed_array_equals(a, b) {
|
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if (a_length
|
|
23
|
+
if (a_length === 0) {
|
|
24
|
+
// both arrays are empty
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (a_length < 128) { // size is determined empirically, nothing special about the number itself
|
|
24
29
|
// small array, do direct compare
|
|
25
30
|
return isArrayEqualStrict(a, b);
|
|
26
31
|
}
|
|
@@ -59,6 +64,7 @@ export function is_typed_array_equals(a, b) {
|
|
|
59
64
|
a_proxy = new Uint32Array(a_buffer, a.byteOffset, byte_length / 4);
|
|
60
65
|
b_proxy = new Uint32Array(b_buffer, b.byteOffset, byte_length / 4);
|
|
61
66
|
} else if (bytes_per_element < 2 && byte_length % 2 === 0) {
|
|
67
|
+
// 2 byte alignment, can use uint16
|
|
62
68
|
a_proxy = new Uint16Array(a_buffer, a.byteOffset, byte_length / 2);
|
|
63
69
|
b_proxy = new Uint16Array(b_buffer, b.byteOffset, byte_length / 2);
|
|
64
70
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
|
|
3
|
+
* @param {number[]|Float32Array} box
|
|
4
|
+
* @param {number} box_address
|
|
5
|
+
* @param {number} origin_x
|
|
6
|
+
* @param {number} origin_y
|
|
7
|
+
* @param {number} origin_z
|
|
8
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
9
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
10
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
11
|
+
* @param {number} min_distance
|
|
12
|
+
* @param {number} max_distance
|
|
13
|
+
* @returns {number}
|
|
14
|
+
*/
|
|
15
|
+
export function aabb3_array_near_distance_to_intersection_ray_segment(box: number[] | Float32Array, box_address: number, origin_x: number, origin_y: number, origin_z: number, inv_direction_x: number, inv_direction_y: number, inv_direction_z: number, min_distance: number, max_distance: number): number;
|
|
16
|
+
//# sourceMappingURL=aabb3_array_near_distance_to_intersection_ray_segment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aabb3_array_near_distance_to_intersection_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_array_near_distance_to_intersection_ray_segment.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,2EAZW,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,MAAM,CAelB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { aabb3_near_distance_to_intersection_ray_segment } from "./aabb3_near_distance_to_intersection_ray_segment.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
|
|
5
|
+
* @param {number[]|Float32Array} box
|
|
6
|
+
* @param {number} box_address
|
|
7
|
+
* @param {number} origin_x
|
|
8
|
+
* @param {number} origin_y
|
|
9
|
+
* @param {number} origin_z
|
|
10
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
11
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
12
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
13
|
+
* @param {number} min_distance
|
|
14
|
+
* @param {number} max_distance
|
|
15
|
+
* @returns {number}
|
|
16
|
+
*/
|
|
17
|
+
export function aabb3_array_near_distance_to_intersection_ray_segment(
|
|
18
|
+
box, box_address,
|
|
19
|
+
origin_x, origin_y, origin_z,
|
|
20
|
+
inv_direction_x, inv_direction_y, inv_direction_z,
|
|
21
|
+
min_distance, max_distance) {
|
|
22
|
+
return aabb3_near_distance_to_intersection_ray_segment(
|
|
23
|
+
box[box_address], box[box_address + 1], box[box_address + 2],
|
|
24
|
+
box[box_address + 3], box[box_address + 4], box[box_address + 5],
|
|
25
|
+
|
|
26
|
+
origin_x, origin_y, origin_z,
|
|
27
|
+
inv_direction_x, inv_direction_y, inv_direction_z,
|
|
28
|
+
min_distance, max_distance
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
* @param {number} origin_x
|
|
10
10
|
* @param {number} origin_y
|
|
11
11
|
* @param {number} origin_z
|
|
12
|
-
* @param {number}
|
|
13
|
-
* @param {number}
|
|
14
|
-
* @param {number}
|
|
12
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
13
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
14
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
15
15
|
* @param {number} min_distance
|
|
16
16
|
* @param {number} max_distance
|
|
17
17
|
* @returns {boolean}
|
|
18
|
-
* @returns {boolean}
|
|
19
18
|
*/
|
|
20
|
-
export function aabb3_intersects_ray_segment(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, origin_x: number, origin_y: number, origin_z: number,
|
|
19
|
+
export function aabb3_intersects_ray_segment(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, origin_x: number, origin_y: number, origin_z: number, inv_direction_x: number, inv_direction_y: number, inv_direction_z: number, min_distance: number, max_distance: number): boolean;
|
|
21
20
|
//# sourceMappingURL=aabb3_intersects_ray_segment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aabb3_intersects_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_intersects_ray_segment.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"aabb3_intersects_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_intersects_ray_segment.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,iDAhBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,OAAO,CA2CnB"}
|
|
@@ -12,19 +12,18 @@ import { min2 } from "../../../math/min2.js";
|
|
|
12
12
|
* @param {number} origin_x
|
|
13
13
|
* @param {number} origin_y
|
|
14
14
|
* @param {number} origin_z
|
|
15
|
-
* @param {number}
|
|
16
|
-
* @param {number}
|
|
17
|
-
* @param {number}
|
|
15
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
16
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
17
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
18
18
|
* @param {number} min_distance
|
|
19
19
|
* @param {number} max_distance
|
|
20
20
|
* @returns {boolean}
|
|
21
|
-
* @returns {boolean}
|
|
22
21
|
*/
|
|
23
22
|
export function aabb3_intersects_ray_segment(
|
|
24
23
|
x0, y0, z0,
|
|
25
24
|
x1, y1, z1,
|
|
26
25
|
origin_x, origin_y, origin_z,
|
|
27
|
-
|
|
26
|
+
inv_direction_x, inv_direction_y, inv_direction_z,
|
|
28
27
|
min_distance, max_distance
|
|
29
28
|
) {
|
|
30
29
|
|
|
@@ -37,9 +36,6 @@ export function aabb3_intersects_ray_segment(
|
|
|
37
36
|
const _y1 = y1 - origin_y;
|
|
38
37
|
const _z1 = z1 - origin_z;
|
|
39
38
|
|
|
40
|
-
const inv_direction_x = 1 / direction_x;
|
|
41
|
-
const inv_direction_y = 1 / direction_y;
|
|
42
|
-
const inv_direction_z = 1 / direction_z;
|
|
43
39
|
|
|
44
40
|
// Absolute distances to lower and upper box coordinates
|
|
45
41
|
const t_lower_x = _x0 * inv_direction_x;
|
|
@@ -64,4 +60,5 @@ export function aabb3_intersects_ray_segment(
|
|
|
64
60
|
const t_box_max = Math.min(t_max_x, t_max_y, t_max_z, max_distance);
|
|
65
61
|
|
|
66
62
|
return t_box_min <= t_box_max;
|
|
67
|
-
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
|
|
3
|
+
* @param {number} x0
|
|
4
|
+
* @param {number} y0
|
|
5
|
+
* @param {number} z0
|
|
6
|
+
* @param {number} x1
|
|
7
|
+
* @param {number} y1
|
|
8
|
+
* @param {number} z1
|
|
9
|
+
* @param {number} origin_x
|
|
10
|
+
* @param {number} origin_y
|
|
11
|
+
* @param {number} origin_z
|
|
12
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
13
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
14
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
15
|
+
* @param {number} min_distance
|
|
16
|
+
* @param {number} max_distance
|
|
17
|
+
* @returns {number} Infinity when no intersection found
|
|
18
|
+
*/
|
|
19
|
+
export function aabb3_near_distance_to_intersection_ray_segment(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, origin_x: number, origin_y: number, origin_z: number, inv_direction_x: number, inv_direction_y: number, inv_direction_z: number, min_distance: number, max_distance: number): number;
|
|
20
|
+
//# sourceMappingURL=aabb3_near_distance_to_intersection_ray_segment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aabb3_near_distance_to_intersection_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,oEAhBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,mBACN,MAAM,mBACN,MAAM,mBACN,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,MAAM,CA+ClB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { max2 } from "../../../math/max2.js";
|
|
2
|
+
import { min2 } from "../../../math/min2.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
|
|
6
|
+
* @param {number} x0
|
|
7
|
+
* @param {number} y0
|
|
8
|
+
* @param {number} z0
|
|
9
|
+
* @param {number} x1
|
|
10
|
+
* @param {number} y1
|
|
11
|
+
* @param {number} z1
|
|
12
|
+
* @param {number} origin_x
|
|
13
|
+
* @param {number} origin_y
|
|
14
|
+
* @param {number} origin_z
|
|
15
|
+
* @param {number} inv_direction_x 1/ direction_X
|
|
16
|
+
* @param {number} inv_direction_y 1/ direction_Y
|
|
17
|
+
* @param {number} inv_direction_z 1/ direction_Z
|
|
18
|
+
* @param {number} min_distance
|
|
19
|
+
* @param {number} max_distance
|
|
20
|
+
* @returns {number} Infinity when no intersection found
|
|
21
|
+
*/
|
|
22
|
+
export function aabb3_near_distance_to_intersection_ray_segment(
|
|
23
|
+
x0, y0, z0,
|
|
24
|
+
x1, y1, z1,
|
|
25
|
+
origin_x, origin_y, origin_z,
|
|
26
|
+
inv_direction_x, inv_direction_y, inv_direction_z,
|
|
27
|
+
min_distance, max_distance
|
|
28
|
+
) {
|
|
29
|
+
|
|
30
|
+
// move aabb into ray space
|
|
31
|
+
const _x0 = x0 - origin_x;
|
|
32
|
+
const _y0 = y0 - origin_y;
|
|
33
|
+
const _z0 = z0 - origin_z;
|
|
34
|
+
|
|
35
|
+
const _x1 = x1 - origin_x;
|
|
36
|
+
const _y1 = y1 - origin_y;
|
|
37
|
+
const _z1 = z1 - origin_z;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// Absolute distances to lower and upper box coordinates
|
|
41
|
+
const t_lower_x = _x0 * inv_direction_x;
|
|
42
|
+
const t_lower_y = _y0 * inv_direction_y;
|
|
43
|
+
const t_lower_z = _z0 * inv_direction_z;
|
|
44
|
+
|
|
45
|
+
const t_upper_x = _x1 * inv_direction_x;
|
|
46
|
+
const t_upper_y = _y1 * inv_direction_y;
|
|
47
|
+
const t_upper_z = _z1 * inv_direction_z;
|
|
48
|
+
|
|
49
|
+
// The four t-intervals (for x-/y-/z-slabs, and ray p(t))
|
|
50
|
+
const t_min_x = min2(t_lower_x, t_upper_x);
|
|
51
|
+
const t_min_y = min2(t_lower_y, t_upper_y);
|
|
52
|
+
const t_min_z = min2(t_lower_z, t_upper_z);
|
|
53
|
+
|
|
54
|
+
const t_max_x = max2(t_lower_x, t_upper_x);
|
|
55
|
+
const t_max_y = max2(t_lower_y, t_upper_y);
|
|
56
|
+
const t_max_z = max2(t_lower_z, t_upper_z);
|
|
57
|
+
|
|
58
|
+
// Easy to remember: ``max of mins, and min of maxes''
|
|
59
|
+
const t_box_min = Math.max(t_min_x, t_min_y, t_min_z, min_distance);
|
|
60
|
+
const t_box_max = Math.min(t_max_x, t_max_y, t_max_z, max_distance);
|
|
61
|
+
|
|
62
|
+
if (t_box_min > t_box_max) {
|
|
63
|
+
return Infinity;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return t_box_min;
|
|
67
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line3_compute_nearest_point_to_point.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/line/line3_compute_nearest_point_to_point.js"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"line3_compute_nearest_point_to_point.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/line/line3_compute_nearest_point_to_point.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,6DAZW,MAAM,EAAE,iBACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,SACN,MAAM,SACN,MAAM,SACN,MAAM,QAkChB"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
2
1
|
import { clamp01 } from "../../../math/clamp01.js";
|
|
2
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]} result
|
|
7
|
+
* @param {number} result_offset
|
|
8
|
+
* @param {number} ax
|
|
9
|
+
* @param {number} ay
|
|
10
|
+
* @param {number} az
|
|
11
|
+
* @param {number} bx
|
|
12
|
+
* @param {number} by
|
|
13
|
+
* @param {number} bz
|
|
14
|
+
* @param {number} ref_x
|
|
15
|
+
* @param {number} ref_y
|
|
16
|
+
* @param {number} ref_z
|
|
17
|
+
*/
|
|
4
18
|
export function line3_compute_nearest_point_to_point(
|
|
5
19
|
result, result_offset,
|
|
6
20
|
ax, ay, az,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param {number} output_offset
|
|
6
6
|
* @param {number} u range [-1,1]
|
|
7
7
|
* @param {number} v range [-1,1]
|
|
8
|
+
* @returns {number} length of octahedral vector, larger value means more distortion
|
|
8
9
|
*/
|
|
9
|
-
export function decode_octahedron_to_unit(output: number[] | Vector3 | Float32Array, output_offset: number, u: number, v: number):
|
|
10
|
+
export function decode_octahedron_to_unit(output: number[] | Vector3 | Float32Array, output_offset: number, u: number, v: number): number;
|
|
10
11
|
//# sourceMappingURL=decode_octahedron_to_unit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,kDANW,MAAM,EAAE,aAAS,YAAY,iBAC7B,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CA8BlB"}
|
|
@@ -8,6 +8,7 @@ import { v3_length } from "../../../vec3/v3_length.js";
|
|
|
8
8
|
* @param {number} output_offset
|
|
9
9
|
* @param {number} u range [-1,1]
|
|
10
10
|
* @param {number} v range [-1,1]
|
|
11
|
+
* @returns {number} length of octahedral vector, larger value means more distortion
|
|
11
12
|
*/
|
|
12
13
|
export function decode_octahedron_to_unit(
|
|
13
14
|
output, output_offset,
|
|
@@ -28,9 +29,13 @@ export function decode_octahedron_to_unit(
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// normalize
|
|
31
|
-
const
|
|
32
|
+
const octahedral_length = v3_length(v_x, v_y, v_z);
|
|
33
|
+
|
|
34
|
+
const m = 1 / octahedral_length;
|
|
32
35
|
|
|
33
36
|
output[output_offset] = v_x * m;
|
|
34
37
|
output[output_offset + 1] = v_y * m;
|
|
35
38
|
output[output_offset + 2] = v_z * m;
|
|
39
|
+
|
|
40
|
+
return octahedral_length;
|
|
36
41
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result result is written as a 2d vector, since barycentrics add up to 1, we omit the last value
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {number} px reference point
|
|
6
|
+
* @param {number} py reference point
|
|
7
|
+
* @param {number} pz reference point
|
|
8
|
+
* @param {number} ax Triangle apex A
|
|
9
|
+
* @param {number} ay Triangle apex A
|
|
10
|
+
* @param {number} az Triangle apex A
|
|
11
|
+
* @param {number} bx Triangle apex B
|
|
12
|
+
* @param {number} by Triangle apex B
|
|
13
|
+
* @param {number} bz Triangle apex B
|
|
14
|
+
* @param {number} cx Triangle apex C
|
|
15
|
+
* @param {number} cy Triangle apex C
|
|
16
|
+
* @param {number} cz Triangle apex C
|
|
17
|
+
* @returns {void}
|
|
18
|
+
*/
|
|
19
|
+
export function computeTriangleClosestPointToPointBarycentric(result: number[], result_offset: number, px: number, py: number, pz: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): void;
|
|
20
|
+
//# sourceMappingURL=computeTriangleClosestPointToPointBarycentric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeTriangleClosestPointToPointBarycentric.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleClosestPointToPointBarycentric.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,sEAhBW,MAAM,EAAE,iBACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,IAAI,CAgIhB"}
|
|
@@ -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":""}
|