@woosh/meep-engine 2.47.3 → 2.47.8
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 -0
- package/build/bundle-worker-terrain.js +1 -0
- package/build/meep.cjs +659 -553
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +659 -553
- package/package.json +2 -2
- package/src/core/binary/BitSet.spec.js +3 -3
- package/src/core/bvh2/BinaryNode.js +12 -10
- package/src/core/bvh2/aabb3/AABB3.js +30 -31
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
- package/src/core/bvh2/binary/BinaryBVH.js +1 -1
- package/src/core/bvh2/binary/RayLeafIntersectionVisitor.js +1 -1
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +2 -2
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +1 -1
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +10 -8
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +14 -22
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +13 -15
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +14 -21
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +16 -24
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +23 -26
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +10 -11
- package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +2 -2
- package/src/core/bvh2/transform/tryRotateSingleNode.js +2 -2
- package/src/core/bvh2/traversal/aabb3_detailed_volume_intersection_callback_based.js +1 -1
- package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +1 -1
- package/src/core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js +13 -0
- package/src/core/color/Color.d.ts +2 -1
- package/src/core/color/Color.js +30 -5
- package/src/core/color/ColorUtils.js +7 -5
- package/src/core/color/parseHex.js +11 -3
- package/src/core/color/rgb2hex.js +1 -1
- package/src/core/geom/3d/SurfacePoint3.d.ts +7 -0
- package/src/core/geom/3d/SurfacePoint3.js +56 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_combine.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_contains_point.js +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_degree.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_combined_surface_area.js +2 -2
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.spec.js +8 -0
- package/src/core/geom/3d/aabb/{computeAABB3PlaneSide.js → aabb3_compute_plane_side.js} +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_detailed_volume_intersection.js +7 -7
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array.js +4 -4
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array_transformed.js +2 -2
- package/src/core/{bvh2/aabb3/aabb3_intersect_aabb3.js → geom/3d/aabb/aabb3_intersects_aabb3.js} +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_array.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_degree.js +4 -4
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_line_segment.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +87 -0
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray.spec.js +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_branchless.js +2 -2
- package/src/core/{bvh2/aabb3/aabb3_intersect_ray_slab.js → geom/3d/aabb/aabb3_intersects_ray_slab.js} +35 -17
- package/src/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +5 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_nearest_point_on_surface.js +2 -2
- package/src/core/geom/3d/aabb/aabb3_raycast.js +103 -0
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_signed_distance_sqr_to_point.js +1 -1
- package/src/core/geom/3d/aabb/computeBoundingBoxFromVertexData.js +4 -12
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +8 -1
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +4 -7
- package/src/core/model/node-graph/DataType.d.ts +4 -0
- package/src/core/model/node-graph/node/NodeDescription.d.ts +11 -1
- package/src/core/model/node-graph/node/NodeRegistry.spec.js +47 -1
- package/src/core/model/node-graph/node/Port.d.ts +3 -0
- package/src/core/model/node-graph/node/Port.js +7 -3
- package/src/core/model/node-graph/node/Port.spec.js +44 -0
- package/src/core/model/node-graph/node/PortDirection.d.ts +5 -0
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/ecs/foliage/InstancedFoliage.js +1 -1
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +13 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +11 -4
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.js +54 -0
- package/src/engine/ecs/systems/RenderSystem.js +1 -33
- package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +2 -4
- package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +6 -1
- package/src/engine/graphics/GraphicsEngine.js +5 -1
- package/src/engine/graphics/ecs/decal/v2/Decal.js +44 -2
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +31 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +16 -5
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +88 -56
- package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js +2 -2
- package/src/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +3 -2
- package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +3 -2
- package/src/engine/graphics/micron/format/MicronGeometry.js +1 -1
- package/src/engine/graphics/micron/format/validate_patch_bounds.js +1 -1
- package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +1 -1
- package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +16 -16
- package/src/engine/graphics/render/forward_plus/LightManager.js +3 -0
- package/src/engine/graphics/render/forward_plus/LightManager.spec.js +5 -5
- package/src/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_APPLY_DECALS.js +4 -0
- package/src/engine/graphics/render/forward_plus/model/Decal.js +10 -2
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +2 -2
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +18 -16
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +2 -0
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.js +26 -13
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +8 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +3 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +18 -15
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min.js +1 -1
- package/src/engine/graphics/three/three_computeObjectBoundingBox.js +56 -0
- package/src/engine/input/devices/{InputDeviceButton.d.ts → InputDeviceSwitch.d.ts} +1 -1
- package/src/engine/input/devices/{InputDeviceButton.js → InputDeviceSwitch.js} +1 -1
- package/src/engine/input/devices/KeyboardDevice.d.ts +2 -2
- package/src/engine/input/devices/KeyboardDevice.js +58 -40
- package/src/engine/input/devices/PointerDevice.js +224 -179
- package/src/core/bvh2/aabb3/aabb3_intersects_ray.js +0 -97
- package/src/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane_max.spec.js +0 -8
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_box_surface_area_2.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_half_surface_area.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_surface_area.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.spec.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.spec.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_plane_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_expand_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_fast.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_score_boxes_SAH.js +0 -0
- /package/src/core/{bvh2/aabb3/aabb_score_boxes_SAH_delta.js → geom/3d/aabb/aabb3_score_boxes_SAH_delta.js} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
//
|
|
2
2
|
import { NULL_NODE } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
3
|
-
import { aabb3_array_intersects_frustum_degree } from "
|
|
3
|
+
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
4
4
|
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
5
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
7
8
|
|
|
8
|
-
const scratch_aabb =
|
|
9
|
+
const scratch_aabb = new Float32Array(6);
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
@@ -30,20 +31,20 @@ export function bvh_query_user_data_overlaps_frustum(
|
|
|
30
31
|
*
|
|
31
32
|
* @type {number}
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
+
const stack_top = stack.pointer++;
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
stack[stack_top] = root;
|
|
36
37
|
|
|
37
38
|
let result_cursor = result_offset;
|
|
38
39
|
|
|
39
|
-
while (
|
|
40
|
-
|
|
40
|
+
while (stack.pointer > stack_top) {
|
|
41
|
+
stack.pointer--;
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
*
|
|
44
45
|
* @type {number}
|
|
45
46
|
*/
|
|
46
|
-
const node =
|
|
47
|
+
const node = stack[stack.pointer];
|
|
47
48
|
|
|
48
49
|
// test node against the ray
|
|
49
50
|
bvh.node_get_aabb(node, scratch_aabb);
|
|
@@ -56,26 +57,22 @@ export function bvh_query_user_data_overlaps_frustum(
|
|
|
56
57
|
|
|
57
58
|
const node_is_leaf = bvh.node_is_leaf(node);
|
|
58
59
|
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
if (intersection === 2) {
|
|
62
|
-
// fully inside, fast collection path
|
|
63
|
-
result_cursor += bvh_collect_user_data(result, result_cursor, bvh, node);
|
|
64
|
-
} else {
|
|
65
|
-
// partially inside
|
|
66
|
-
// read in-order
|
|
67
|
-
const child1 = bvh.node_get_child1(node);
|
|
68
|
-
const child2 = bvh.node_get_child2(node);
|
|
69
|
-
|
|
70
|
-
// write to stack in reverse order, so that fist child ends up being visited first
|
|
71
|
-
traversal_stack[traversal_cursor++] = child1;
|
|
72
|
-
traversal_stack[traversal_cursor++] = child2;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
} else {
|
|
60
|
+
if (node_is_leaf) {
|
|
76
61
|
// leaf node
|
|
77
|
-
|
|
78
62
|
result[result_cursor++] = bvh.node_get_user_data(node);
|
|
63
|
+
|
|
64
|
+
} else if (intersection === 2) {
|
|
65
|
+
// fully inside, fast collection path
|
|
66
|
+
result_cursor += bvh_collect_user_data(result, result_cursor, bvh, node);
|
|
67
|
+
} else {
|
|
68
|
+
// partially inside
|
|
69
|
+
// read in-order
|
|
70
|
+
const child1 = bvh.node_get_child1(node);
|
|
71
|
+
const child2 = bvh.node_get_child2(node);
|
|
72
|
+
|
|
73
|
+
// write to stack in reverse order, so that fist child ends up being visited first
|
|
74
|
+
stack[stack.pointer++] = child1;
|
|
75
|
+
stack[stack.pointer++] = child2;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
import { array_copy } from "../../../collection/array/copyArray.js";
|
|
5
5
|
import { NULL_NODE } from "../ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
6
|
-
import { aabb3_array_intersects_frustum_degree } from "
|
|
6
|
+
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
7
7
|
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
8
8
|
import { v3_distance_above_plane } from "../../../geom/v3_distance_above_plane.js";
|
|
9
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
11
12
|
|
|
12
13
|
const scratch_aabb = [];
|
|
13
14
|
|
|
@@ -33,9 +34,9 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
33
34
|
*
|
|
34
35
|
* @type {number}
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
+
const stack_top = stack.pointer++;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
stack[stack_top] = root;
|
|
39
40
|
|
|
40
41
|
let result_cursor = result_offset;
|
|
41
42
|
|
|
@@ -47,14 +48,14 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
47
48
|
y1,
|
|
48
49
|
z1;
|
|
49
50
|
|
|
50
|
-
node_loop: while (
|
|
51
|
-
|
|
51
|
+
node_loop: while (stack.pointer > stack_top) {
|
|
52
|
+
stack.pointer--;
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
*
|
|
55
56
|
* @type {number}
|
|
56
57
|
*/
|
|
57
|
-
const node =
|
|
58
|
+
const node = stack[stack.pointer];
|
|
58
59
|
|
|
59
60
|
// test node against the ray
|
|
60
61
|
bvh.node_get_aabb(node, scratch_aabb);
|
|
@@ -141,8 +142,8 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
141
142
|
const child2 = bvh.node_get_child2(node);
|
|
142
143
|
|
|
143
144
|
// write to stack in reverse order, so that fist child ends up being visited first
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
stack[stack.pointer++] = child1;
|
|
146
|
+
stack[stack.pointer++] = child2;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
} else {
|
|
@@ -151,6 +152,4 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
// drop stack frame
|
|
155
|
-
|
|
156
155
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BinaryNode } from "../BinaryNode.js";
|
|
2
2
|
import { isLeaf } from "../LeafNode.js";
|
|
3
3
|
import { surfaceAreaHeuristic } from "../sah/surfaceAreaHeuristic.js";
|
|
4
|
-
import { aabb3_score_boxes_SAH } from "
|
|
5
|
-
import { aabb3_box_surface_area_2 } from "
|
|
4
|
+
import { aabb3_score_boxes_SAH } from "../../geom/3d/aabb/aabb3_score_boxes_SAH.js";
|
|
5
|
+
import { aabb3_box_surface_area_2 } from "../../geom/3d/aabb/aabb3_box_surface_area_2.js";
|
|
6
6
|
|
|
7
7
|
function BottomUpOptimizingRebuilder() {
|
|
8
8
|
this.root = null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { surfaceAreaHeuristic as sah } from "../sah/surfaceAreaHeuristic.js";
|
|
2
2
|
import { isLeaf } from "../LeafNode.js";
|
|
3
|
-
import { aabb3_score_boxes_SAH as computeAreaFor2 } from "
|
|
4
|
-
import { aabb3_box_surface_area_2 as computeArea } from "
|
|
3
|
+
import { aabb3_score_boxes_SAH as computeAreaFor2 } from "../../geom/3d/aabb/aabb3_score_boxes_SAH.js";
|
|
4
|
+
import { aabb3_box_surface_area_2 as computeArea } from "../../geom/3d/aabb/aabb3_box_surface_area_2.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aabb3_intersects_frustum_degree } from "
|
|
1
|
+
import { aabb3_intersects_frustum_degree } from "../../geom/3d/aabb/aabb3_intersects_frustum_degree.js";
|
|
2
2
|
import { queryBinaryNode_CollectData } from "./queryBinaryNode_CollectData.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Useful for traversals, such as tree-walking. When using - make sure you manage dependencies nad understand the call-graph to avoid overwriting data that is used else-where
|
|
3
|
+
* Using a pre-allocated continuous chunk of memory gets us better cache coherence
|
|
4
|
+
* @readonly
|
|
5
|
+
* @type {Uint32Array|{pointer:number}}
|
|
6
|
+
*/
|
|
7
|
+
export const SCRATCH_UINT32_TRAVERSAL_STACK = new Uint32Array(781250);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pointer used to track current top of the stack, make sure to unwind once your traversal is done
|
|
11
|
+
* @type {number}
|
|
12
|
+
*/
|
|
13
|
+
SCRATCH_UINT32_TRAVERSAL_STACK.pointer = 0;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Signal from "../events/signal/Signal";
|
|
2
2
|
|
|
3
3
|
export class Color {
|
|
4
|
-
constructor(r?: number, g?: number, b?: number)
|
|
4
|
+
constructor(r?: number, g?: number, b?: number,a?:number)
|
|
5
5
|
|
|
6
6
|
r: number
|
|
7
7
|
g: number
|
|
8
8
|
b: number
|
|
9
|
+
a:number
|
|
9
10
|
|
|
10
11
|
readonly onChanged: Signal<number, number, number, number, number, number>
|
|
11
12
|
|
package/src/core/color/Color.js
CHANGED
|
@@ -55,7 +55,7 @@ export class Color {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* @readonly
|
|
58
|
-
* @type {Signal<number,number,number,number,number,number>}
|
|
58
|
+
* @type {Signal<number,number,number,number,number,number,number,number>}
|
|
59
59
|
*/
|
|
60
60
|
this.onChanged = new Signal();
|
|
61
61
|
}
|
|
@@ -131,19 +131,34 @@ export class Color {
|
|
|
131
131
|
* @param {number} b
|
|
132
132
|
*/
|
|
133
133
|
setRGB(r, g, b) {
|
|
134
|
+
|
|
135
|
+
this.set(r, g, b, this.a);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* @param {number} r
|
|
141
|
+
* @param {number} g
|
|
142
|
+
* @param {number} b
|
|
143
|
+
* @param {number} a
|
|
144
|
+
*/
|
|
145
|
+
set(r, g, b, a) {
|
|
134
146
|
assert.isNumber(r, 'r');
|
|
135
147
|
assert.isNumber(g, 'g');
|
|
136
148
|
assert.isNumber(b, 'b');
|
|
149
|
+
assert.isNumber(a, 'a');
|
|
137
150
|
|
|
138
151
|
const _r = this.r;
|
|
139
152
|
const _g = this.g;
|
|
140
153
|
const _b = this.b;
|
|
154
|
+
const _a = this.a;
|
|
141
155
|
|
|
142
156
|
this.r = r;
|
|
143
157
|
this.g = g;
|
|
144
158
|
this.b = b;
|
|
159
|
+
this.a = a;
|
|
145
160
|
|
|
146
|
-
this.onChanged.
|
|
161
|
+
this.onChanged.send8(r, g, b, a, _r, _g, _b, _a);
|
|
147
162
|
}
|
|
148
163
|
|
|
149
164
|
/**
|
|
@@ -407,7 +422,10 @@ export class Color {
|
|
|
407
422
|
* @param {Color} other
|
|
408
423
|
*/
|
|
409
424
|
equals(other) {
|
|
410
|
-
return this.r === other.r
|
|
425
|
+
return this.r === other.r
|
|
426
|
+
&& this.g === other.g
|
|
427
|
+
&& this.b === other.b
|
|
428
|
+
&& this.a === other.a;
|
|
411
429
|
}
|
|
412
430
|
|
|
413
431
|
/**
|
|
@@ -443,15 +461,17 @@ export class Color {
|
|
|
443
461
|
);
|
|
444
462
|
}
|
|
445
463
|
|
|
446
|
-
fromJSON({ r, g, b }) {
|
|
464
|
+
fromJSON({ r, g, b, a = 1 }) {
|
|
447
465
|
this.setRGB(r, g, b);
|
|
466
|
+
this.a = a;
|
|
448
467
|
}
|
|
449
468
|
|
|
450
469
|
toJSON() {
|
|
451
470
|
return {
|
|
452
471
|
r: this.r,
|
|
453
472
|
g: this.g,
|
|
454
|
-
b: this.b
|
|
473
|
+
b: this.b,
|
|
474
|
+
a: this.a
|
|
455
475
|
};
|
|
456
476
|
}
|
|
457
477
|
|
|
@@ -460,6 +480,7 @@ export class Color {
|
|
|
460
480
|
yield this.r;
|
|
461
481
|
yield this.g;
|
|
462
482
|
yield this.b;
|
|
483
|
+
yield this.a;
|
|
463
484
|
|
|
464
485
|
}
|
|
465
486
|
|
|
@@ -472,6 +493,7 @@ export class Color {
|
|
|
472
493
|
destination[destination_offset] = this.r;
|
|
473
494
|
destination[destination_offset + 1] = this.g;
|
|
474
495
|
destination[destination_offset + 2] = this.b;
|
|
496
|
+
destination[destination_offset + 3] = this.a;
|
|
475
497
|
}
|
|
476
498
|
|
|
477
499
|
/**
|
|
@@ -482,6 +504,7 @@ export class Color {
|
|
|
482
504
|
buffer.writeFloat32(this.r);
|
|
483
505
|
buffer.writeFloat32(this.g);
|
|
484
506
|
buffer.writeFloat32(this.b);
|
|
507
|
+
buffer.writeFloat32(this.a);
|
|
485
508
|
}
|
|
486
509
|
|
|
487
510
|
/**
|
|
@@ -492,8 +515,10 @@ export class Color {
|
|
|
492
515
|
const r = buffer.readFloat32();
|
|
493
516
|
const g = buffer.readFloat32();
|
|
494
517
|
const b = buffer.readFloat32();
|
|
518
|
+
const a = buffer.readFloat32();
|
|
495
519
|
|
|
496
520
|
this.setRGB(r, g, b);
|
|
521
|
+
this.a = a;
|
|
497
522
|
}
|
|
498
523
|
|
|
499
524
|
/**
|
|
@@ -7,7 +7,7 @@ import { parseHex } from "./parseHex.js";
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const rgbRegEx = /rgb\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+)\s*\)/;
|
|
10
|
-
const rgbaRegEx = /rgba\(\s*([0-9]+),\s*([0-9]+),\s*([0-9]+),\s*([0-9]+(?:\.[0-9]*)?)\s*\)/;
|
|
10
|
+
const rgbaRegEx = /rgba\(\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\s*\)/;
|
|
11
11
|
const hsvRegEx = /hsv\(([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?),\s*([0-9]+(?:\.[0-9]*)?)\)/;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -36,10 +36,10 @@ export function parseColor(c) {
|
|
|
36
36
|
|
|
37
37
|
} else if ((match = cL.match(rgbaRegEx)) !== null) {
|
|
38
38
|
|
|
39
|
-
r =
|
|
40
|
-
g =
|
|
41
|
-
b =
|
|
42
|
-
a =
|
|
39
|
+
r = parseFloat(match[1]);
|
|
40
|
+
g = parseFloat(match[2]);
|
|
41
|
+
b = parseFloat(match[3]);
|
|
42
|
+
a = parseFloat(match[4]);
|
|
43
43
|
|
|
44
44
|
} else if ((match = cL.match(hsvRegEx)) !== null) {
|
|
45
45
|
|
|
@@ -60,6 +60,8 @@ export function parseColor(c) {
|
|
|
60
60
|
r = rgb.r;
|
|
61
61
|
g = rgb.g;
|
|
62
62
|
b = rgb.b;
|
|
63
|
+
a = rgb.a;
|
|
64
|
+
|
|
63
65
|
|
|
64
66
|
} else {
|
|
65
67
|
throw new Error(`Failed to decode color string '${c}' `);
|
|
@@ -5,14 +5,22 @@ function hex2dec(v) {
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param {string} hex
|
|
8
|
-
* @returns {{r:
|
|
8
|
+
* @returns {{r: number, g: number, b: number, a:number}} rgb
|
|
9
9
|
*/
|
|
10
10
|
export function parseHex(hex) {
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const result = {
|
|
14
14
|
r: hex2dec(hex.slice(1, 3)),
|
|
15
15
|
g: hex2dec(hex.slice(3, 5)),
|
|
16
|
-
b: hex2dec(hex.slice(5))
|
|
16
|
+
b: hex2dec(hex.slice(5, 7))
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
if (hex.length > 7) {
|
|
20
|
+
result.a = hex2dec(hex.slice(7, 9));
|
|
21
|
+
}else{
|
|
22
|
+
result.a = 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return result;
|
|
18
26
|
}
|
|
@@ -6,10 +6,17 @@ export class SurfacePoint3 {
|
|
|
6
6
|
position: Vector3
|
|
7
7
|
index: number
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated use {@link applyMatrix4} instead
|
|
11
|
+
*/
|
|
9
12
|
applyMatrix4_three(matrix4: Matrix4): void
|
|
10
13
|
|
|
11
14
|
applyMatrix4(m4: ArrayLike<number>): void
|
|
12
15
|
|
|
16
|
+
fromArray(array: ArrayLike<number>, offset?: number): void
|
|
17
|
+
|
|
18
|
+
toArray(array: ArrayLike<number>, offset?: number): void
|
|
19
|
+
|
|
13
20
|
copy(other: SurfacePoint3): void
|
|
14
21
|
|
|
15
22
|
clone(): SurfacePoint3
|
|
@@ -7,7 +7,16 @@ import { assert } from "../../assert.js";
|
|
|
7
7
|
*/
|
|
8
8
|
export class SurfacePoint3 {
|
|
9
9
|
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* @readonly
|
|
12
|
+
* @type {Vector3}
|
|
13
|
+
*/
|
|
10
14
|
this.normal = new Vector3(0, 1, 0);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @readonly
|
|
18
|
+
* @type {Vector3}
|
|
19
|
+
*/
|
|
11
20
|
this.position = new Vector3(0, 0, 0);
|
|
12
21
|
|
|
13
22
|
/**
|
|
@@ -18,6 +27,30 @@ export class SurfacePoint3 {
|
|
|
18
27
|
this.index = -1;
|
|
19
28
|
}
|
|
20
29
|
|
|
30
|
+
get 0() {
|
|
31
|
+
return this.position.x;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get 1() {
|
|
35
|
+
return this.position.y;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get 2() {
|
|
39
|
+
return this.position.z;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get 3() {
|
|
43
|
+
return this.normal.x;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get 4() {
|
|
47
|
+
return this.normal.y;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get 5() {
|
|
51
|
+
return this.normal.z;
|
|
52
|
+
}
|
|
53
|
+
|
|
21
54
|
/**
|
|
22
55
|
*
|
|
23
56
|
* @param {number[]|mat4|Float32Array} m
|
|
@@ -67,13 +100,35 @@ export class SurfacePoint3 {
|
|
|
67
100
|
}
|
|
68
101
|
|
|
69
102
|
/**
|
|
70
|
-
*
|
|
103
|
+
* @deprecated use {@link applyMatrix4} instead
|
|
71
104
|
* @param {THREE.Matrix4} matrix4
|
|
72
105
|
*/
|
|
73
106
|
applyMatrix4_three(matrix4) {
|
|
107
|
+
console.warn('applyMatrix4_three is deprecated, use applyMatrix4 instead');
|
|
108
|
+
|
|
74
109
|
this.applyMatrix4(matrix4.elements);
|
|
75
110
|
}
|
|
76
111
|
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {number[]|ArrayLike<number>|Float32Array} array
|
|
115
|
+
* @param {number} [offset=0]
|
|
116
|
+
*/
|
|
117
|
+
fromArray(array, offset = 0) {
|
|
118
|
+
this.position.readFromArray(array, offset);
|
|
119
|
+
this.normal.readFromArray(array, offset + 3);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* @param {number[]|ArrayLike<number>|Float32Array} array
|
|
125
|
+
* @param {number} [offset=0]
|
|
126
|
+
*/
|
|
127
|
+
toArray(array, offset = 0) {
|
|
128
|
+
this.position.writeToArray(array, offset);
|
|
129
|
+
this.normal.writeToArray(array, offset + 3);
|
|
130
|
+
}
|
|
131
|
+
|
|
77
132
|
/**
|
|
78
133
|
*
|
|
79
134
|
* @param {SurfacePoint3} other
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import { min2 } from "
|
|
4
|
-
import { max2 } from "
|
|
3
|
+
import { min2 } from "../../../math/min2.js";
|
|
4
|
+
import { max2 } from "../../../math/max2.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
|
|
@@ -3,8 +3,8 @@ import { aabb3_intersects_frustum_degree } from "./aabb3_intersects_frustum_degr
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
|
-
* @param {number[]} aabb
|
|
7
|
-
* @param {number[]} frustum
|
|
6
|
+
* @param {number[]|Float32Array} aabb
|
|
7
|
+
* @param {number[]|Float32Array} frustum
|
|
8
8
|
* @returns {number}
|
|
9
9
|
*/
|
|
10
10
|
export function aabb3_array_intersects_frustum_degree(aabb, frustum) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { min2 } from "
|
|
2
|
-
import { max2 } from "
|
|
1
|
+
import { min2 } from "../../../math/min2.js";
|
|
2
|
+
import { max2 } from "../../../math/max2.js";
|
|
3
3
|
import { aabb3_compute_half_surface_area } from "./aabb3_compute_half_surface_area.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @param {number} _z1
|
|
13
13
|
* @returns {number}
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function aabb3_compute_distance_above_plane_max(
|
|
16
16
|
plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
|
|
17
17
|
_x0, _y0, _z0,
|
|
18
18
|
_x1, _y1, _z1
|
|
@@ -14,7 +14,7 @@ import { v3_distance_above_plane } from "../../v3_distance_above_plane.js";
|
|
|
14
14
|
* @param {number} _z1
|
|
15
15
|
* @returns {number}
|
|
16
16
|
*/
|
|
17
|
-
export function
|
|
17
|
+
export function aabb3_compute_plane_side(
|
|
18
18
|
plane_normal_x,
|
|
19
19
|
plane_normal_y,
|
|
20
20
|
plane_normal_z,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { aabb3_build_corners } from "
|
|
2
|
-
import { aabb_build_frustum } from "
|
|
3
|
-
import { plane3_computeLineSegmentIntersection } from "../../
|
|
1
|
+
import { aabb3_build_corners } from "./aabb3_build_corners.js";
|
|
2
|
+
import { aabb_build_frustum } from "./aabb3_build_frustum.js";
|
|
3
|
+
import { plane3_computeLineSegmentIntersection } from "../../Plane.js";
|
|
4
4
|
import { aabb3_corner_edge_mapping } from "./aabb3_corner_edge_mapping.js";
|
|
5
5
|
import { aabb3_edge_corner_mapping } from "./aabb3_edge_corner_mapping.js";
|
|
6
|
-
import { plane_computeConvex3PlaneIntersection } from "
|
|
7
|
-
import { is_point_within_planes } from "
|
|
8
|
-
import { v3_distance_above_plane } from "../../
|
|
9
|
-
import { EPSILON } from "
|
|
6
|
+
import { plane_computeConvex3PlaneIntersection } from "../plane/plane_computeConvex3PlaneIntersection.js";
|
|
7
|
+
import { is_point_within_planes } from "../plane/is_point_within_planes.js";
|
|
8
|
+
import { v3_distance_above_plane } from "../../v3_distance_above_plane.js";
|
|
9
|
+
import { EPSILON } from "../../../math/EPSILON.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Common piece of continuous memory for better cache coherence
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { min2 } from "
|
|
2
|
-
import { max2 } from "
|
|
1
|
+
import { min2 } from "../../../math/min2.js";
|
|
2
|
+
import { max2 } from "../../../math/max2.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {AABB3} result
|
|
7
|
-
* @param {number[]|ArrayLike<number
|
|
8
|
-
* @param {number} input_length
|
|
7
|
+
* @param {number[]|ArrayLike<number>|Float32Array} input
|
|
8
|
+
* @param {number} input_length length of the input array
|
|
9
9
|
*/
|
|
10
10
|
export function aabb3_from_v3_array(result, input, input_length) {
|
|
11
11
|
let x0 = Infinity;
|
package/src/core/{bvh2/aabb3/aabb3_intersect_aabb3.js → geom/3d/aabb/aabb3_intersects_aabb3.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { intersects1D } from "
|
|
1
|
+
import { intersects1D } from "../../../math/intersects1D.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -16,7 +16,7 @@ import { intersects1D } from "../../math/intersects1D.js";
|
|
|
16
16
|
* @param {number} bz1
|
|
17
17
|
* @returns {boolean}
|
|
18
18
|
*/
|
|
19
|
-
export function
|
|
19
|
+
export function aabb3_intersects_aabb3(
|
|
20
20
|
ax0, ay0, az0,
|
|
21
21
|
ax1, ay1, az1,
|
|
22
22
|
bx0, by0, bz0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aabb3_compute_distance_above_plane_max } from "./aabb3_compute_distance_above_plane_max.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -19,7 +19,7 @@ export function aabb3_intersects_frustum_array(x0, y0, z0, x1, y1, z1, frustum)
|
|
|
19
19
|
const plane_z = frustum[i + 2];
|
|
20
20
|
const plane_w = frustum[i + 3];
|
|
21
21
|
|
|
22
|
-
const plane_distance =
|
|
22
|
+
const plane_distance = aabb3_compute_distance_above_plane_max(
|
|
23
23
|
plane_x, plane_y, plane_z, plane_w,
|
|
24
24
|
x0, y0, z0,
|
|
25
25
|
x1, y1, z1
|