@woosh/meep-engine 2.34.16 → 2.34.20
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/core/bvh2/aabb3/aabb3_array_intersects_ray.js +20 -0
- package/core/geom/v3_distance_sqr.d.ts +1 -0
- package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.d.ts +7 -0
- package/engine/graphics/micron/build/hierarchy/merge_patches.js +7 -1
- package/engine/graphics/micron/format/MicronGeometry.d.ts +2 -0
- package/engine/graphics/micron/format/MicronGeometry.js +21 -4
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { intersectRay } from "./AABB3Math.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {ArrayLike<number>|number[]|Float32Array} aabb bounding box, order: x0,y0,z0,x1,y1,z1
|
|
8
|
+
* @param {number} origin_x
|
|
9
|
+
* @param {number} origin_y
|
|
10
|
+
* @param {number} origin_z
|
|
11
|
+
* @param {number} direction_x
|
|
12
|
+
* @param {number} direction_y
|
|
13
|
+
* @param {number} direction_z
|
|
14
|
+
*/
|
|
15
|
+
export function aabb3_array_intersects_ray(aabb, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z) {
|
|
16
|
+
return intersectRay(aabb[0], aabb[1], aabb[2], aabb[3], aabb[4], aabb[5],
|
|
17
|
+
origin_x, origin_y, origin_z,
|
|
18
|
+
direction_x, direction_y, direction_z
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function v3_distance_sqr(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): number
|
|
@@ -8,4 +8,11 @@ export class GeometrySpatialQueryAccelerator {
|
|
|
8
8
|
queryContainmentViaClippingPlanes(geometry: BufferGeometry, planes: Plane[]): number
|
|
9
9
|
|
|
10
10
|
queryRaycastNearest(destination: SurfacePoint3, geometry: BufferGeometry, ray_origin: Vector3, ray_direction: Vector3): boolean
|
|
11
|
+
|
|
12
|
+
queryRaycastNearest_primitive(
|
|
13
|
+
destination: SurfacePoint3,
|
|
14
|
+
geometry: BufferGeometry,
|
|
15
|
+
origin_x: number, origin_y: number, origin_z: number,
|
|
16
|
+
direction_x: number, direction_y: number, direction_z: number
|
|
17
|
+
): boolean
|
|
11
18
|
}
|
|
@@ -513,7 +513,13 @@ export async function merge_patches(
|
|
|
513
513
|
return 0;
|
|
514
514
|
} else if (node_count === 1) {
|
|
515
515
|
// only 1 patch, no merge opportunity, forward it to output directly
|
|
516
|
-
|
|
516
|
+
const node = nodes[0];
|
|
517
|
+
|
|
518
|
+
//set group bounds to produce a valid root
|
|
519
|
+
node.group_aabb.copy(node.bounding_box);
|
|
520
|
+
node.group_bounding_sphere.set(node.bounding_sphere);
|
|
521
|
+
|
|
522
|
+
output[output_offset.value++] = node;
|
|
517
523
|
return 1;
|
|
518
524
|
} else {
|
|
519
525
|
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { VertexDataSpec } from "../../geometry/VertexDataSpec.js";
|
|
2
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
|
-
import { intersectRay } from "../../../../core/bvh2/aabb3/AABB3Math.js";
|
|
4
3
|
import { computeTriangleRayIntersection } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
5
4
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
5
|
+
import { aabb3_array_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_array_intersects_ray.js";
|
|
6
6
|
|
|
7
7
|
let id_counter = 0;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @readonly
|
|
11
|
+
* @type {MicronGeometryPatch[]}
|
|
12
|
+
*/
|
|
13
|
+
const scratch_traversal_stack = [];
|
|
14
|
+
|
|
9
15
|
export class MicronGeometry {
|
|
10
16
|
constructor() {
|
|
11
17
|
/**
|
|
@@ -79,8 +85,10 @@ export class MicronGeometry {
|
|
|
79
85
|
*/
|
|
80
86
|
const hits = [];
|
|
81
87
|
|
|
88
|
+
// initialize stack
|
|
82
89
|
let stack_cursor = 1;
|
|
83
|
-
const stack =
|
|
90
|
+
const stack = scratch_traversal_stack;
|
|
91
|
+
stack[0] = this.root;
|
|
84
92
|
|
|
85
93
|
const spec = this.vertex_spec;
|
|
86
94
|
|
|
@@ -99,8 +107,8 @@ export class MicronGeometry {
|
|
|
99
107
|
// using group bounding box because it's conservative, as we want to be able to hit LOD_0
|
|
100
108
|
const bb = patch.group_bounding_box;
|
|
101
109
|
|
|
102
|
-
const bb_intersection_exists =
|
|
103
|
-
bb
|
|
110
|
+
const bb_intersection_exists = aabb3_array_intersects_ray(
|
|
111
|
+
bb,
|
|
104
112
|
origin_x, origin_y, origin_z,
|
|
105
113
|
direction_x, direction_y, direction_z
|
|
106
114
|
);
|
|
@@ -113,6 +121,15 @@ export class MicronGeometry {
|
|
|
113
121
|
if (patch.lod === 0) {
|
|
114
122
|
// LOD 0 - source geometry
|
|
115
123
|
|
|
124
|
+
// cast against bounds
|
|
125
|
+
if (!aabb3_array_intersects_ray(
|
|
126
|
+
patch.bounding_box,
|
|
127
|
+
origin_x, origin_y, origin_z,
|
|
128
|
+
direction_x, direction_y, direction_z
|
|
129
|
+
)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
116
133
|
// raycast against geometry
|
|
117
134
|
const indices = patch.face_indices;
|
|
118
135
|
const index_count = indices.length;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.34.
|
|
8
|
+
"version": "2.34.20",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|