@woosh/meep-engine 2.93.3 → 2.94.1
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-terrain.js +1 -1
- package/build/meep.cjs +336 -269
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +336 -269
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +4 -2
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +2 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +12 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +11 -1
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts +14 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.js +146 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts +16 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +90 -0
- package/src/core/collection/heap/Uint32Heap.d.ts.map +1 -1
- package/src/core/collection/heap/Uint32Heap.js +22 -17
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +17 -7
- package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -1
- package/src/core/geom/2d/bvh/BVH2D.js +24 -29
- package/src/core/geom/2d/bvh/BVH2D.spec.js +10 -9
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts +2 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts.map +1 -0
- package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.js +89 -0
- package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +8 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_array_combine.js +5 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +2 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +9 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts +16 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js +55 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts +8 -0
- package/src/core/math/build_gaussian_kernel_1d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_1d.js +26 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts +10 -0
- package/src/core/math/build_gaussian_kernel_2d.d.ts.map +1 -0
- package/src/core/math/build_gaussian_kernel_2d.js +55 -0
- package/src/core/math/nextOdd.d.ts +8 -0
- package/src/core/math/nextOdd.d.ts.map +1 -0
- package/src/core/math/nextOdd.js +15 -0
- package/src/core/math/nextOdd.spec.d.ts +2 -0
- package/src/core/math/nextOdd.spec.d.ts.map +1 -0
- package/src/core/math/nextOdd.spec.js +9 -0
- package/src/engine/animation/curve/prototypeGLTF.js +4 -1
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts +2 -0
- package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/LightBinding.js +16 -0
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts +13 -2
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +37 -4
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +12 -8
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts +0 -9
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +100 -129
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -4
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +11 -4
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +6 -4
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js +1 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts +2 -2
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +3 -3
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +5 -31
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts +3 -6
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.js +8 -27
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts +4 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts.map +1 -1
- package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js +12 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts +29 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts.map +1 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureSystem.js +102 -0
- package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +1 -1
- package/src/engine/graphics/texture/virtual/prototype.js +221 -79
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +18 -19
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
- package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
- package/src/generation/filtering/numeric/CellFilterCache.js +7 -7
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +9 -6
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts +1 -13
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +39 -111
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +6 -5
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts.map +1 -1
- package/src/generation/grid/generation/util/buildDistanceMapToObjective.js +5 -12
- package/src/core/math/makeNextOdd.d.ts +0 -8
- package/src/core/math/makeNextOdd.d.ts.map +0 -1
- package/src/core/math/makeNextOdd.js +0 -15
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BVH.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/BVH.js"],"names":[],"mappings":"AAQA,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;
|
|
1
|
+
{"version":3,"file":"BVH.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/BVH.js"],"names":[],"mappings":"AAQA,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;AAE/B;;;;;GAKG;AACH,+BAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEqB;AAgBrC;;;;;;GAMG;AACH;IAEI;;;;OAIG;IACH,sBAA2E;IAE3E;;;;OAIG;IACH,uBAAsD;IAEtD;;;;OAIG;IACH,sBAAoD;IAEpD;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,eAAW;IAEX;;;;OAIG;IACH,eAAY;IAEZ;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAmB;IAEnB;;;OAGG;IACH,mBAEC;IAUD;;;OAGG;IACH,+BAMC;IAlBD;;;OAGG;IACH,4BAEC;IAcD,wBAgBC;IAED;;;;OAIG;IACH,uBAqBC;IAED;;OAEG;IACH,aAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAqDlB;IAED;;;;OAIG;IACH,iBAFW,MAAM,QAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAOnB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,SACN,MAAM,QAOhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAA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|
|
@@ -17,7 +17,7 @@ export const COLUMN_HEIGHT = 9;
|
|
|
17
17
|
* @readonly
|
|
18
18
|
* @type {number}
|
|
19
19
|
*/
|
|
20
|
-
const COLUMN_USER_DATA = COLUMN_CHILD_2;
|
|
20
|
+
export const COLUMN_USER_DATA = COLUMN_CHILD_2;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
@@ -553,8 +553,11 @@ export class BVH {
|
|
|
553
553
|
* @param {number} index_b
|
|
554
554
|
*/
|
|
555
555
|
node_set_combined_aabb(destination, index_a, index_b) {
|
|
556
|
+
assert.isNonNegativeInteger(destination, 'destination');
|
|
557
|
+
|
|
556
558
|
const address_a = ELEMENT_WORD_COUNT * index_a;
|
|
557
559
|
const address_b = ELEMENT_WORD_COUNT * index_b;
|
|
560
|
+
const address_destination = ELEMENT_WORD_COUNT * destination;
|
|
558
561
|
|
|
559
562
|
const float32 = this.__data_float32;
|
|
560
563
|
|
|
@@ -582,7 +585,6 @@ export class BVH {
|
|
|
582
585
|
const b_z1 = float32[address_b + 5];
|
|
583
586
|
const z1 = max2(a_z1, b_z1);
|
|
584
587
|
|
|
585
|
-
const address_destination = destination * ELEMENT_WORD_COUNT;
|
|
586
588
|
|
|
587
589
|
float32[address_destination] = x0;
|
|
588
590
|
float32[address_destination + 1] = y0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,
|
|
1
|
+
{"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QA4DhB"}
|
|
@@ -26,6 +26,7 @@ export function build_triangle_morton_codes(
|
|
|
26
26
|
const aabb_size_y = aabb_y1 - aabb_y0;
|
|
27
27
|
const aabb_size_z = aabb_z1 - aabb_z0;
|
|
28
28
|
|
|
29
|
+
// compute multipliers to bring normalized values in range of 10bit unsigned integer each
|
|
29
30
|
const morton_scale_x = aabb_size_x === 0 ? 0 : 1023 / aabb_size_x;
|
|
30
31
|
const morton_scale_y = aabb_size_y === 0 ? 0 : 1023 / aabb_size_y;
|
|
31
32
|
const morton_scale_z = aabb_size_z === 0 ? 0 : 1023 / aabb_size_z;
|
|
@@ -59,7 +60,7 @@ export function build_triangle_morton_codes(
|
|
|
59
60
|
const center_y = (ay + by + cy) * 0.333333333;
|
|
60
61
|
const center_z = (az + bz + cz) * 0.333333333;
|
|
61
62
|
|
|
62
|
-
// normalize to
|
|
63
|
+
// normalize to 10bit range
|
|
63
64
|
const ncx = (center_x - aabb_x0) * morton_scale_x;
|
|
64
65
|
const ncy = (center_y - aabb_y0) * morton_scale_y;
|
|
65
66
|
const ncz = (center_z - aabb_z0) * morton_scale_z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,sEAHW,MAAM,EAAE,GAAC,YAAY,kBACrB,MAAM,EAAE,GAAC,YAAY,QA0E/B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compute_triangle_group_aabb3 } from "../../../engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js";
|
|
2
|
+
import { assert } from "../../assert.js";
|
|
2
3
|
import { arrayQuickSort } from "../../collection/array/arrayQuickSort.js";
|
|
3
4
|
import { AABB3 } from "../../geom/3d/aabb/AABB3.js";
|
|
4
5
|
import { aabb3_from_v3_array } from "../../geom/3d/aabb/aabb3_from_v3_array.js";
|
|
@@ -15,6 +16,14 @@ import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
|
|
|
15
16
|
* @param {number[]|Float32Array} position_array
|
|
16
17
|
*/
|
|
17
18
|
export function ebvh_build_for_geometry_morton(bvh, index_array, position_array) {
|
|
19
|
+
assert.defined(bvh, 'bvh');
|
|
20
|
+
|
|
21
|
+
assert.defined(index_array, 'index_array');
|
|
22
|
+
assert.isArrayLike(index_array, 'index_array');
|
|
23
|
+
|
|
24
|
+
assert.defined(position_array, 'position_array');
|
|
25
|
+
assert.isArrayLike(position_array, 'position_array');
|
|
26
|
+
|
|
18
27
|
// clear out existing BVH
|
|
19
28
|
bvh.release_all();
|
|
20
29
|
|
|
@@ -42,6 +51,8 @@ export function ebvh_build_for_geometry_morton(bvh, index_array, position_array)
|
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
const morton_codes = new Uint32Array(tri_count);
|
|
54
|
+
|
|
55
|
+
// indices of triangles, but sorted by morton codes
|
|
45
56
|
const sorted_triangle_order = new Uint32Array(tri_count);
|
|
46
57
|
|
|
47
58
|
for (let i = 0; i < tri_count; i++) {
|
|
@@ -75,5 +86,5 @@ export function ebvh_build_for_geometry_morton(bvh, index_array, position_array)
|
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
// assign root
|
|
78
|
-
bvh.__root = ebvh_build_hierarchy(bvh,unprocessed_nodes,tri_count,nodes,used_index);
|
|
89
|
+
bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, used_index);
|
|
79
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,kEANW,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,aACN,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,GACJ,MAAM,CAyDlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
1
2
|
import { max2 } from "../../math/max2.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -10,7 +11,16 @@ import { max2 } from "../../math/max2.js";
|
|
|
10
11
|
* @param {number} node_pool_offset
|
|
11
12
|
* @returns {number} new root
|
|
12
13
|
*/
|
|
13
|
-
export function ebvh_build_hierarchy(
|
|
14
|
+
export function ebvh_build_hierarchy(
|
|
15
|
+
bvh,
|
|
16
|
+
unprocessed_nodes,
|
|
17
|
+
input_node_count,
|
|
18
|
+
node_pool,
|
|
19
|
+
node_pool_offset
|
|
20
|
+
) {
|
|
21
|
+
|
|
22
|
+
assert.isNonNegativeInteger(input_node_count,'input_node_count');
|
|
23
|
+
assert.isNonNegativeInteger(node_pool_offset,'node_pool_offset');
|
|
14
24
|
|
|
15
25
|
let used_index = node_pool_offset;
|
|
16
26
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} output
|
|
4
|
+
* @param {number} output_offset
|
|
5
|
+
* @param {BVH} bvh
|
|
6
|
+
* @param {number} root
|
|
7
|
+
* @param {number[]} ray
|
|
8
|
+
* @param {number} min_distance
|
|
9
|
+
* @param {number} max_distance
|
|
10
|
+
* @param {number[]|Uint32Array} indices
|
|
11
|
+
* @param {number[]|Float32Array} positions
|
|
12
|
+
*/
|
|
13
|
+
export function ebvh_geometry_query_nearest_triangle_ray(output: number[], output_offset: number, bvh: BVH, root: number, ray: number[], min_distance: number, max_distance: number, indices: number[] | Uint32Array, positions: number[] | Float32Array): boolean;
|
|
14
|
+
//# sourceMappingURL=ebvh_geometry_query_nearest_triangle_ray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ebvh_geometry_query_nearest_triangle_ray.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH,iEAVW,MAAM,EAAE,iBACR,MAAM,kBAEN,MAAM,OACN,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,WACN,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,EAAE,GAAC,YAAY,WA4H/B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
2
|
+
import { aabb3_intersects_ray } from "../../geom/3d/aabb/aabb3_intersects_ray.js";
|
|
3
|
+
import { aabb3_signed_distance_sqr_to_point } from "../../geom/3d/aabb/aabb3_signed_distance_sqr_to_point.js";
|
|
4
|
+
import {
|
|
5
|
+
computeTriangleRayIntersectionBarycentricGeometry
|
|
6
|
+
} from "../../geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js";
|
|
7
|
+
import { COLUMN_CHILD_1, COLUMN_CHILD_2, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
|
|
8
|
+
|
|
9
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
10
|
+
const v3_scratch_0 = [];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {number[]} output
|
|
15
|
+
* @param {number} output_offset
|
|
16
|
+
* @param {BVH} bvh
|
|
17
|
+
* @param {number} root
|
|
18
|
+
* @param {number[]} ray
|
|
19
|
+
* @param {number} min_distance
|
|
20
|
+
* @param {number} max_distance
|
|
21
|
+
* @param {number[]|Uint32Array} indices
|
|
22
|
+
* @param {number[]|Float32Array} positions
|
|
23
|
+
*/
|
|
24
|
+
export function ebvh_geometry_query_nearest_triangle_ray(
|
|
25
|
+
output, output_offset,
|
|
26
|
+
bvh, root,
|
|
27
|
+
ray, min_distance, max_distance,
|
|
28
|
+
indices, positions
|
|
29
|
+
) {
|
|
30
|
+
|
|
31
|
+
const origin_x = ray[0];
|
|
32
|
+
const origin_y = ray[1];
|
|
33
|
+
const origin_z = ray[2];
|
|
34
|
+
|
|
35
|
+
const direction_x = ray[3];
|
|
36
|
+
const direction_y = ray[4];
|
|
37
|
+
const direction_z = ray[5];
|
|
38
|
+
|
|
39
|
+
let best_t = max_distance;
|
|
40
|
+
|
|
41
|
+
let best_index = -1;
|
|
42
|
+
let best_u = 0;
|
|
43
|
+
let best_v = 0;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {number}
|
|
48
|
+
*/
|
|
49
|
+
const stack_top = stack.pointer++;
|
|
50
|
+
|
|
51
|
+
stack[stack_top] = root;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
56
|
+
*/
|
|
57
|
+
const float32 = bvh.__data_float32;
|
|
58
|
+
const uint32 = bvh.__data_uint32;
|
|
59
|
+
|
|
60
|
+
do {
|
|
61
|
+
stack.pointer--;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @type {number}
|
|
66
|
+
*/
|
|
67
|
+
const node = stack[stack.pointer];
|
|
68
|
+
|
|
69
|
+
const address = node * ELEMENT_WORD_COUNT;
|
|
70
|
+
|
|
71
|
+
// test node against the ray
|
|
72
|
+
const aabb_x0 = float32[address];
|
|
73
|
+
const aabb_y0 = float32[address + 1];
|
|
74
|
+
const aabb_z0 = float32[address + 2];
|
|
75
|
+
const aabb_x1 = float32[address + 3];
|
|
76
|
+
const aabb_y1 = float32[address + 4];
|
|
77
|
+
const aabb_z1 = float32[address + 5];
|
|
78
|
+
|
|
79
|
+
const intersects = aabb3_intersects_ray(
|
|
80
|
+
aabb_x0, aabb_y0, aabb_z0,
|
|
81
|
+
aabb_x1, aabb_y1, aabb_z1,
|
|
82
|
+
origin_x, origin_y, origin_z,
|
|
83
|
+
direction_x, direction_y, direction_z
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (!intersects) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const distance = aabb3_signed_distance_sqr_to_point(
|
|
91
|
+
aabb_x0, aabb_y0, aabb_z0,
|
|
92
|
+
aabb_x1, aabb_y1, aabb_z1,
|
|
93
|
+
origin_x, origin_y, origin_z
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (distance > best_t * best_t) {
|
|
97
|
+
// whole AABB is too far
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// get fist child to check if this is a leaf node or not
|
|
102
|
+
const child_1 = uint32[address + COLUMN_CHILD_1];
|
|
103
|
+
|
|
104
|
+
if (child_1 !== NULL_NODE) {
|
|
105
|
+
|
|
106
|
+
// this is not a leaf node, push children onto traversal stack
|
|
107
|
+
stack[stack.pointer++] = child_1;
|
|
108
|
+
stack[stack.pointer++] = uint32[address + COLUMN_CHILD_2];
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// leaf node
|
|
113
|
+
const triangle_index = uint32[address + COLUMN_USER_DATA];
|
|
114
|
+
|
|
115
|
+
const intersection_found = computeTriangleRayIntersectionBarycentricGeometry(
|
|
116
|
+
v3_scratch_0,
|
|
117
|
+
origin_x, origin_y, origin_z,
|
|
118
|
+
direction_x, direction_y, direction_z,
|
|
119
|
+
indices, triangle_index,
|
|
120
|
+
positions
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (intersection_found && v3_scratch_0[0] < best_t && v3_scratch_0[0] > min_distance) {
|
|
124
|
+
best_t = v3_scratch_0[0];
|
|
125
|
+
|
|
126
|
+
best_index = triangle_index;
|
|
127
|
+
best_u = v3_scratch_0[1];
|
|
128
|
+
best_v = v3_scratch_0[2];
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
} while (stack.pointer > stack_top);
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if (best_t === max_distance) {
|
|
136
|
+
// no intersection
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
output[0] = best_index; // index of hit triangle
|
|
141
|
+
output[1] = best_u;
|
|
142
|
+
output[2] = best_v;
|
|
143
|
+
output[3] = best_t;
|
|
144
|
+
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {BVH} bvh
|
|
4
|
+
* @param {number} root
|
|
5
|
+
* @param {number[]} result
|
|
6
|
+
* @param {number} result_offset
|
|
7
|
+
* @param {number} origin_x
|
|
8
|
+
* @param {number} origin_y
|
|
9
|
+
* @param {number} origin_z
|
|
10
|
+
* @param {number} direction_x
|
|
11
|
+
* @param {number} direction_y
|
|
12
|
+
* @param {number} direction_z
|
|
13
|
+
* @returns {number}
|
|
14
|
+
*/
|
|
15
|
+
export function bvh_query_user_data_ray(bvh: BVH, root: number, result: number[], result_offset: number, origin_x: number, origin_y: number, origin_z: number, direction_x: number, direction_y: number, direction_z: number): number;
|
|
16
|
+
//# sourceMappingURL=bvh_query_user_data_ray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bvh_query_user_data_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,wDAXW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,GACJ,MAAM,CAsElB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
2
|
+
import { aabb3_intersects_ray } from "../../../geom/3d/aabb/aabb3_intersects_ray.js";
|
|
3
|
+
import { COLUMN_CHILD_1, COLUMN_CHILD_2, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, NULL_NODE } from "../BVH.js";
|
|
4
|
+
|
|
5
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {BVH} bvh
|
|
11
|
+
* @param {number} root
|
|
12
|
+
* @param {number[]} result
|
|
13
|
+
* @param {number} result_offset
|
|
14
|
+
* @param {number} origin_x
|
|
15
|
+
* @param {number} origin_y
|
|
16
|
+
* @param {number} origin_z
|
|
17
|
+
* @param {number} direction_x
|
|
18
|
+
* @param {number} direction_y
|
|
19
|
+
* @param {number} direction_z
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
export function bvh_query_user_data_ray(
|
|
23
|
+
bvh, root,
|
|
24
|
+
result, result_offset,
|
|
25
|
+
origin_x, origin_y, origin_z,
|
|
26
|
+
direction_x, direction_y, direction_z
|
|
27
|
+
) {
|
|
28
|
+
|
|
29
|
+
if (root === NULL_NODE) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
const stack_top = stack.pointer++;
|
|
39
|
+
|
|
40
|
+
stack[stack_top] = root;
|
|
41
|
+
|
|
42
|
+
let result_cursor = result_offset;
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
46
|
+
*/
|
|
47
|
+
const float32 = bvh.__data_float32;
|
|
48
|
+
const uint32 = bvh.__data_uint32;
|
|
49
|
+
|
|
50
|
+
do {
|
|
51
|
+
stack.pointer--;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @type {number}
|
|
56
|
+
*/
|
|
57
|
+
const node = stack[stack.pointer];
|
|
58
|
+
|
|
59
|
+
const address = node * ELEMENT_WORD_COUNT;
|
|
60
|
+
|
|
61
|
+
// test node against the ray
|
|
62
|
+
const intersects = aabb3_intersects_ray(
|
|
63
|
+
float32[address], float32[address + 1], float32[address + 2],
|
|
64
|
+
float32[address + 3], float32[address + 4], float32[address + 5],
|
|
65
|
+
origin_x, origin_y, origin_z,
|
|
66
|
+
direction_x, direction_y, direction_z
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (!intersects) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// get fist child to check if this is a leaf node or not
|
|
74
|
+
const child_1 = uint32[address + COLUMN_CHILD_1];
|
|
75
|
+
|
|
76
|
+
if (child_1 !== NULL_NODE) {
|
|
77
|
+
|
|
78
|
+
// this is not a leaf node, push children onto traversal stack
|
|
79
|
+
stack[stack.pointer++] = child_1;
|
|
80
|
+
stack[stack.pointer++] = uint32[address + COLUMN_CHILD_2];
|
|
81
|
+
|
|
82
|
+
} else {
|
|
83
|
+
// leaf node
|
|
84
|
+
|
|
85
|
+
result[result_cursor++] = uint32[address + COLUMN_USER_DATA];
|
|
86
|
+
}
|
|
87
|
+
} while (stack.pointer > stack_top);
|
|
88
|
+
|
|
89
|
+
return result_cursor - result_offset;
|
|
90
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Uint32Heap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IACI;;;OAGG;IACH,+BAFW,MAAM,EAuBhB;IAlBG,2BAA0E;IAE1E;;;;OAIG;IACH,sBAAwD;IAExD;;;;OAIG;IACH,uBAA0D;IAE1D,mBAAkC;IAClC,eAAe;IAGnB;;;OAGG;IACH,wBAsBC;IAED;;;;;OAKG;IACH,gBAOC;IAED;;;;;OAKG;IACH,aAiBC;IAED;;;OAGG;IACH,kBA6BC;IAED;;;;OAIG;IACH,gBAeC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,YAFa,OAAO,CAInB;IAED,mBAEC;IAED,
|
|
1
|
+
{"version":3,"file":"Uint32Heap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH;IACI;;;OAGG;IACH,+BAFW,MAAM,EAuBhB;IAlBG,2BAA0E;IAE1E;;;;OAIG;IACH,sBAAwD;IAExD;;;;OAIG;IACH,uBAA0D;IAE1D,mBAAkC;IAClC,eAAe;IAGnB;;;OAGG;IACH,wBAsBC;IAED;;;;;OAKG;IACH,gBAOC;IAED;;;;;OAKG;IACH,aAiBC;IAED;;;OAGG;IACH,kBA6BC;IAED;;;;OAIG;IACH,gBAeC;IAED;;;OAGG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,qBAEC;IAED;;;OAGG;IACH,YAFa,OAAO,CAInB;IAED,mBAEC;IAED,kBAoBC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,cAEC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACJ,OAAO,CAWnB;IAED;;;OAGG;IACH,yBAFW,MAAM,QAehB;IAED;;;;OAIG;IACH,iBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,+BAHW,MAAM,SACN,MAAM,QAiBhB;IAED;;;;OAIG;IACH,cAHW,MAAM,GACJ,MAAM,CAYlB;IAGD;;;;OAIG;IACH,qBAHW,MAAM,SACN,MAAM,QAUhB;IAED;;;;OAIG;IACH,WAHW,MAAM,SACN,MAAM,QA0BhB;CAGJ"}
|
|
@@ -159,17 +159,17 @@ export class Uint32Heap {
|
|
|
159
159
|
const size = this.__size;
|
|
160
160
|
|
|
161
161
|
while (true) {
|
|
162
|
-
const
|
|
163
|
-
const
|
|
162
|
+
const left = (i << 1) + 1;
|
|
163
|
+
const right = left + 1;
|
|
164
164
|
|
|
165
165
|
let smallest = i;
|
|
166
166
|
|
|
167
|
-
if (
|
|
168
|
-
smallest =
|
|
167
|
+
if (left < size && this.compare(left, smallest)) {
|
|
168
|
+
smallest = left;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
if (
|
|
172
|
-
smallest =
|
|
171
|
+
if (right < size && this.compare(right, smallest)) {
|
|
172
|
+
smallest = right;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (smallest === i) {
|
|
@@ -244,19 +244,23 @@ export class Uint32Heap {
|
|
|
244
244
|
pop_min() {
|
|
245
245
|
assert.greaterThan(this.__size, 0, 'heap is empty');
|
|
246
246
|
|
|
247
|
-
const
|
|
247
|
+
const new_size = this.__size - 1;
|
|
248
|
+
this.__size = new_size;
|
|
248
249
|
|
|
249
|
-
this.
|
|
250
|
+
const uint32 = this.__data_uint32;
|
|
251
|
+
const top_id = uint32[1];
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
// move bottom element to the top.
|
|
254
|
+
// the top doesn't need to be moved down as we have discarded it already
|
|
255
|
+
const i2 = new_size << 1; // same as *2
|
|
254
256
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
uint32[0] = uint32[i2];
|
|
258
|
+
uint32[1] = uint32[i2 + 1];
|
|
259
|
+
|
|
260
|
+
// re-balance
|
|
261
|
+
this.heap_down(0);
|
|
258
262
|
|
|
259
|
-
return
|
|
263
|
+
return top_id;
|
|
260
264
|
}
|
|
261
265
|
|
|
262
266
|
/**
|
|
@@ -274,6 +278,7 @@ export class Uint32Heap {
|
|
|
274
278
|
const _id = uint32[address];
|
|
275
279
|
|
|
276
280
|
if (_id === id) {
|
|
281
|
+
// reverse address to index
|
|
277
282
|
return (address >>> 1);
|
|
278
283
|
}
|
|
279
284
|
}
|
|
@@ -287,7 +292,7 @@ export class Uint32Heap {
|
|
|
287
292
|
* @param {number} id
|
|
288
293
|
* @returns {boolean}
|
|
289
294
|
*/
|
|
290
|
-
contains(id){
|
|
295
|
+
contains(id) {
|
|
291
296
|
return this.find_index_by_id(id) !== -1;
|
|
292
297
|
}
|
|
293
298
|
|
|
@@ -422,7 +427,7 @@ export class Uint32Heap {
|
|
|
422
427
|
|
|
423
428
|
// insert at the end
|
|
424
429
|
const index = current_size;
|
|
425
|
-
const address = index << 1;
|
|
430
|
+
const address = index << 1; // same as *2
|
|
426
431
|
|
|
427
432
|
// write data
|
|
428
433
|
this.__data_float32[address] = score;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"AAeA;;GAEG;AACH;
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"AAeA;;GAEG;AACH;IAwiBI;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,KAAK,CAIjB;IAED;;;;;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MAAM,QA6ChB;IAED;;;OAGG;IACH,oBAFY,MAAM,CAIjB;IAED;;;;MAEC;IAED;;;OAGG;IACH,UAFa,MAAM,CAKlB;IAED;;;OAGG;IACH,gBAFW,MAAM,QAUhB;IAED;;;;OAIG;IACH,SAFa,MAAM,CAQlB;IAED;;;OAGG;IACH,mBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,cAFW,KAAK,WAOf;IAED;;;OAGG;IACH,YAFW,KAAK,QAKf;IAED;;;OAGG;IACH,SAFa,KAAK,CAQjB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;;aAGC;IAED;;;;;MAOC;IAWD;;;;OAIG;IACH,0BAHW,MAAM,EAAE,sBACR,MAAM,QAOhB;IAED;;;OAGG;IACH,2CAKC;IAED;;;OAGG;IACH,6CAQC;IAED;;;;OAIG;IACH,WAHW,MAAM,GACJ,IAAI,CAYhB;IAED;;;;;OAKG;IACH,cAJW,KAAK,KACL,KAAK,KACL,MAAM,QAOhB;IA1ED,sDAOC;CA8HJ;;aAIS,SAAS,KAAK,CAAC;eAMf,SAAS,KAAK,CAAC;cAMf,SAAS,KAAK,CAAC;gBAMf,SAAS,KAAK,CAAC;cAMf,SAAS,KAAK,CAAC;iBAMf,SAAS,KAAK,CAAC;eAMf,SAAS,KAAK,CAAC;eAMf,SAAS,KAAK,CAAC;qBAMf,SAAS,KAAK,CAAC;;mBArqBN,4BAA4B"}
|
package/src/core/color/Color.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { assert } from "../assert.js";
|
|
2
|
+
import { float2uint8 } from "../binary/float2uint8.js";
|
|
2
3
|
import Signal from "../events/signal/Signal.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { clamp01 } from "../math/clamp01.js";
|
|
5
|
+
import { lerp } from "../math/lerp.js";
|
|
5
6
|
import { max2 } from "../math/max2.js";
|
|
7
|
+
import { min2 } from "../math/min2.js";
|
|
6
8
|
import { min3 } from "../math/min3.js";
|
|
9
|
+
import { rgb2hex } from "./hex/rgb2hex.js";
|
|
7
10
|
import { rgb2hsv } from "./hsv/rgb2hsv.js";
|
|
11
|
+
import { parse_color } from "./parse_color.js";
|
|
8
12
|
import { rgb2uint24 } from "./rgb2uint24.js";
|
|
9
|
-
import { clamp01 } from "../math/clamp01.js";
|
|
10
|
-
import { rgb2hex } from "./hex/rgb2hex.js";
|
|
11
13
|
import { linear_to_sRGB } from "./sRGB/linear_to_sRGB.js";
|
|
12
14
|
import { sRGB_to_linear } from "./sRGB/sRGB_to_linear.js";
|
|
13
|
-
import { lerp } from "../math/lerp.js";
|
|
14
|
-
import { float2uint8 } from "../binary/float2uint8.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* @class
|
|
@@ -22,7 +22,7 @@ export class Color {
|
|
|
22
22
|
* @param {number} r value from 0 to 1
|
|
23
23
|
* @param {number} g value from 0 to 1
|
|
24
24
|
* @param {number} b value from 0 to 1
|
|
25
|
-
* @param {number} [a] value from 0 to 1
|
|
25
|
+
* @param {number} [a] value from 0 to 1 Alpha channel (transparency)
|
|
26
26
|
*/
|
|
27
27
|
constructor(r = 0, g = 0, b = 0, a = 1) {
|
|
28
28
|
/**
|
|
@@ -122,6 +122,14 @@ export class Color {
|
|
|
122
122
|
this.a = v;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Pretending to be an array
|
|
127
|
+
* @return {number}
|
|
128
|
+
*/
|
|
129
|
+
get length() {
|
|
130
|
+
return 4;
|
|
131
|
+
}
|
|
132
|
+
|
|
125
133
|
/**
|
|
126
134
|
*
|
|
127
135
|
* @param {number} r
|
|
@@ -400,6 +408,8 @@ export class Color {
|
|
|
400
408
|
* @param {number} value
|
|
401
409
|
*/
|
|
402
410
|
fromUint(value) {
|
|
411
|
+
assert.isNonNegativeInteger(value, 'value');
|
|
412
|
+
|
|
403
413
|
const r = value >> 16;
|
|
404
414
|
const g = (value >> 8) & 0xFF;
|
|
405
415
|
const b = (value) & 0xFF;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BVH2D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/bvh/BVH2D.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BVH2D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/bvh/BVH2D.js"],"names":[],"mappings":"AAUA,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;AAE/B;;;;;GAKG;AACH,+BAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEoB;AAgBpC;;;;GAIG;AACH;IAEI;;;;OAIG;IACH,sBAA2E;IAE3E;;;;OAIG;IACH,uBAAsD;IAEtD;;;;OAIG;IACH,sBAAoD;IAEpD;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,eAAW;IAEX;;;;OAIG;IACH,eAAY;IAEZ;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAmB;IAEnB;;;OAGG;IACH,mBAEC;IAUD;;;OAGG;IACH,+BAMC;IAlBD;;;OAGG;IACH,4BAEC;IAcD,wBAgBC;IAED;;;;OAIG;IACH,uBAqBC;IAED;;OAEG;IACH,aAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAmDlB;IAED;;;;OAIG;IACH,iBAFW,MAAM,QAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAOnB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,SACN,MAAM,QAOhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;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