@woosh/meep-engine 2.126.42 → 2.126.44
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/package.json +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.d.ts +2 -2
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +92 -39
- package/src/core/math/spline/spline3_hermite_derivative.d.ts +12 -0
- package/src/core/math/spline/spline3_hermite_derivative.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_derivative.js +23 -0
- package/src/core/math/spline/spline3_hermite_subdivide.d.ts +14 -0
- package/src/core/math/spline/spline3_hermite_subdivide.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_subdivide.js +46 -0
- package/src/engine/ecs/transform/Transform.js +1 -1
- package/src/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +1 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.126.
|
|
8
|
+
"version": "2.126.44",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
*
|
|
3
3
|
* @param {number[]} result
|
|
4
4
|
* @param {number} result_offset
|
|
5
|
-
* @param {number}
|
|
5
|
+
* @param {number} plane_mask if bit is set to 0, that plane is not allowed to move
|
|
6
6
|
* @param {BVH} bvh
|
|
7
7
|
* @param {number[]|ArrayLike<number>|Float32Array} frustum
|
|
8
8
|
*/
|
|
9
|
-
export function compute_tight_near_far_clipping_planes(result: number[], result_offset: number,
|
|
9
|
+
export function compute_tight_near_far_clipping_planes(result: number[], result_offset: number, plane_mask: number, bvh: BVH, frustum: number[] | ArrayLike<number> | Float32Array): boolean;
|
|
10
10
|
//# sourceMappingURL=compute_tight_near_far_clipping_planes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,+DANW,MAAM,EAAE,iBACR,MAAM,cACN,MAAM,OACN,GAAG,WACH,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,WA+LjD"}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
5
2
|
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
6
|
-
import { aabb3_array_intersects_frustum_degree } from "../../../geom/3d/aabb/aabb3_array_intersects_frustum_degree.js";
|
|
7
3
|
import { v3_distance_above_plane } from "../../../geom/vec3/v3_distance_above_plane.js";
|
|
8
4
|
import { NULL_NODE } from "../BVH.js";
|
|
9
|
-
import { bvh_collect_user_data } from "./bvh_collect_user_data.js";
|
|
10
5
|
|
|
11
6
|
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
12
7
|
|
|
13
8
|
const scratch_aabb = [];
|
|
14
9
|
|
|
10
|
+
const scratch_frustum = new Float32Array(24);
|
|
11
|
+
|
|
15
12
|
/**
|
|
16
13
|
*
|
|
17
14
|
* @param {number[]} result
|
|
18
15
|
* @param {number} result_offset
|
|
19
|
-
* @param {number}
|
|
16
|
+
* @param {number} plane_mask if bit is set to 0, that plane is not allowed to move
|
|
20
17
|
* @param {BVH} bvh
|
|
21
18
|
* @param {number[]|ArrayLike<number>|Float32Array} frustum
|
|
22
19
|
*/
|
|
23
|
-
export function compute_tight_near_far_clipping_planes(
|
|
20
|
+
export function compute_tight_near_far_clipping_planes(
|
|
21
|
+
result,
|
|
22
|
+
result_offset,
|
|
23
|
+
plane_mask,
|
|
24
|
+
bvh,
|
|
25
|
+
frustum
|
|
26
|
+
) {
|
|
27
|
+
|
|
24
28
|
// initialize result
|
|
25
|
-
array_copy(frustum, 0,
|
|
29
|
+
array_copy(frustum, 0, scratch_frustum, 0, 24);
|
|
30
|
+
|
|
31
|
+
// set output planes to infinity so we can slowly bring them in
|
|
32
|
+
for (let i = 0; i < 6; i++) {
|
|
33
|
+
if (((plane_mask >> i) & 1) === 1) {
|
|
34
|
+
scratch_frustum[i * 4 + 3] = Infinity;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
26
37
|
|
|
27
38
|
const root = bvh.root;
|
|
28
39
|
|
|
@@ -68,13 +79,19 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
68
79
|
const _z1 = scratch_aabb[5];
|
|
69
80
|
|
|
70
81
|
for (let plane_index = 0; plane_index < 6; plane_index++) {
|
|
82
|
+
|
|
83
|
+
if (((plane_mask >> plane_index) & 1) === 1) {
|
|
84
|
+
// plane is not fixed, we're done here
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
71
88
|
const plane_address = plane_index * 4;
|
|
72
89
|
|
|
73
90
|
//read out plane
|
|
74
|
-
const plane_normal_x =
|
|
75
|
-
const plane_normal_y =
|
|
76
|
-
const plane_normal_z =
|
|
77
|
-
const plane_offset =
|
|
91
|
+
const plane_normal_x = scratch_frustum[plane_address];
|
|
92
|
+
const plane_normal_y = scratch_frustum[plane_address + 1];
|
|
93
|
+
const plane_normal_z = scratch_frustum[plane_address + 2];
|
|
94
|
+
const plane_offset = scratch_frustum[plane_address + 3];
|
|
78
95
|
|
|
79
96
|
|
|
80
97
|
// construct nearest and farthest corners along the plane normal
|
|
@@ -112,45 +129,81 @@ export function compute_tight_near_far_clipping_planes(result, result_offset, co
|
|
|
112
129
|
continue node_loop;
|
|
113
130
|
}
|
|
114
131
|
|
|
115
|
-
if ((constrained_planes_mask & (1 << plane_index)) !== 0) {
|
|
116
|
-
// plane is constrained, we're done here
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
122
132
|
}
|
|
123
133
|
|
|
124
|
-
const intersection = aabb3_array_intersects_frustum_degree(scratch_aabb, 0, frustum);
|
|
125
|
-
|
|
126
|
-
if (intersection === 0) {
|
|
127
|
-
// fully outside
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
134
|
|
|
131
135
|
const node_is_leaf = bvh.node_is_leaf(node);
|
|
132
136
|
|
|
133
137
|
if (!node_is_leaf) {
|
|
134
138
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// write to stack in reverse order, so that fist child ends up being visited first
|
|
145
|
-
stack[stack.pointer++] = child1;
|
|
146
|
-
stack[stack.pointer++] = child2;
|
|
147
|
-
}
|
|
139
|
+
// inside
|
|
140
|
+
// read in-order
|
|
141
|
+
const child1 = bvh.node_get_child1(node);
|
|
142
|
+
const child2 = bvh.node_get_child2(node);
|
|
143
|
+
|
|
144
|
+
// write to stack in reverse order, so that fist child ends up being visited first
|
|
145
|
+
stack[stack.pointer++] = child1;
|
|
146
|
+
stack[stack.pointer++] = child2;
|
|
148
147
|
|
|
149
148
|
} else {
|
|
149
|
+
|
|
150
150
|
// leaf node
|
|
151
151
|
|
|
152
|
+
// update planes
|
|
153
|
+
for (let i = 0; i < 6; i++) {
|
|
154
|
+
if (((plane_mask >> i) & 1) === 1) {
|
|
155
|
+
|
|
156
|
+
const plane_address = i * 4;
|
|
157
|
+
|
|
158
|
+
//read out plane
|
|
159
|
+
const plane_normal_x = scratch_frustum[plane_address];
|
|
160
|
+
const plane_normal_y = scratch_frustum[plane_address + 1];
|
|
161
|
+
const plane_normal_z = scratch_frustum[plane_address + 2];
|
|
162
|
+
const plane_offset = scratch_frustum[plane_address + 3];
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
// construct nearest and farthest corners along the plane normal
|
|
166
|
+
if (plane_normal_x > 0) {
|
|
167
|
+
x0 = _x0;
|
|
168
|
+
x1 = _x1;
|
|
169
|
+
} else {
|
|
170
|
+
x0 = _x1;
|
|
171
|
+
x1 = _x0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (plane_normal_y > 0) {
|
|
175
|
+
y0 = _y0;
|
|
176
|
+
y1 = _y1;
|
|
177
|
+
} else {
|
|
178
|
+
y0 = _y1;
|
|
179
|
+
y1 = _y0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (plane_normal_z > 0) {
|
|
183
|
+
z0 = _z0;
|
|
184
|
+
z1 = _z1;
|
|
185
|
+
} else {
|
|
186
|
+
z0 = _z1;
|
|
187
|
+
z1 = _z0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const distance_above_plane = v3_distance_above_plane(
|
|
191
|
+
x1, y1, z1,
|
|
192
|
+
plane_normal_x, plane_normal_y, plane_normal_z, 0
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (distance_above_plane < plane_offset) {
|
|
196
|
+
// move plane
|
|
197
|
+
scratch_frustum[plane_address + 3] = distance_above_plane;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
152
202
|
}
|
|
153
203
|
}
|
|
154
204
|
|
|
155
|
-
|
|
205
|
+
// TODO check if results are still at infinity
|
|
206
|
+
|
|
207
|
+
array_copy(scratch_frustum, 0, result, result_offset, 24);
|
|
208
|
+
|
|
156
209
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the first-order partial derivative of a hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
|
|
3
|
+
*
|
|
4
|
+
* @param {number} t
|
|
5
|
+
* @param {number} p0
|
|
6
|
+
* @param {number} p1
|
|
7
|
+
* @param {number} m0
|
|
8
|
+
* @param {number} m1
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function spline3_hermite_derivative(t: number, p0: number, p1: number, m0: number, m1: number): number;
|
|
12
|
+
//# sourceMappingURL=spline3_hermite_derivative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline3_hermite_derivative.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_derivative.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,8CAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAclB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the first-order partial derivative of a hermite curve with control points p0, m0, p1, m1 at the parameter t in [0,1].
|
|
3
|
+
*
|
|
4
|
+
* @param {number} t
|
|
5
|
+
* @param {number} p0
|
|
6
|
+
* @param {number} p1
|
|
7
|
+
* @param {number} m0
|
|
8
|
+
* @param {number} m1
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function spline3_hermite_derivative(t, p0, p1, m0, m1) {
|
|
12
|
+
|
|
13
|
+
// see https://github.com/krishauser/Klampt/blob/0ed16608a3eceee59d04383a17c207ebc33a399f/Python/klampt/math/spline.py#L22
|
|
14
|
+
|
|
15
|
+
const t2 = t * t
|
|
16
|
+
const dcx1 = (6.0 * t2 - 6.0 * t)
|
|
17
|
+
const dcx2 = (-6.0 * t2 + 6.0 * t)
|
|
18
|
+
const dcv1 = 3.0 * t2 - 4.0 * t + 1.0
|
|
19
|
+
const dcv2 = 3.0 * t2 - 2.0 * t
|
|
20
|
+
|
|
21
|
+
return dcx1 * p0 + dcx2 * p1 + dcv1 * m0 + dcv2 * m1
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subdivides a hermite curve into two hermite curves.
|
|
3
|
+
* The result is written in form [a_p0, a_p1, a_m0, a_m1, b_p0, b_p1, b_m0, b_m1], note the stride and offset.
|
|
4
|
+
* @param {number[]} output where to write the result
|
|
5
|
+
* @param {number} output_offset where to start writing
|
|
6
|
+
* @param {number} output_stride what should be the step between result values, useful when working in higher dimensions. Typically, this will be 1.
|
|
7
|
+
* @param {number} p0
|
|
8
|
+
* @param {number} p1
|
|
9
|
+
* @param {number} m0 tangent at p0
|
|
10
|
+
* @param {number} m1 tangent at p1
|
|
11
|
+
* @param {number} [t=0.5] where to split, normalized position, must be value between 0 and 1
|
|
12
|
+
*/
|
|
13
|
+
export function spline3_hermite_subdivide(output: number[], output_offset: number, output_stride: number, p0: number, p1: number, m0: number, m1: number, t?: number): void;
|
|
14
|
+
//# sourceMappingURL=spline3_hermite_subdivide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spline3_hermite_subdivide.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/spline/spline3_hermite_subdivide.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,kDATW,MAAM,EAAE,iBACR,MAAM,iBACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QA+BhB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { spline3_hermite } from "./spline3_hermite.js";
|
|
3
|
+
import { spline3_hermite_derivative } from "./spline3_hermite_derivative.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Subdivides a hermite curve into two hermite curves.
|
|
7
|
+
* The result is written in form [a_p0, a_p1, a_m0, a_m1, b_p0, b_p1, b_m0, b_m1], note the stride and offset.
|
|
8
|
+
* @param {number[]} output where to write the result
|
|
9
|
+
* @param {number} output_offset where to start writing
|
|
10
|
+
* @param {number} output_stride what should be the step between result values, useful when working in higher dimensions. Typically, this will be 1.
|
|
11
|
+
* @param {number} p0
|
|
12
|
+
* @param {number} p1
|
|
13
|
+
* @param {number} m0 tangent at p0
|
|
14
|
+
* @param {number} m1 tangent at p1
|
|
15
|
+
* @param {number} [t=0.5] where to split, normalized position, must be value between 0 and 1
|
|
16
|
+
*/
|
|
17
|
+
export function spline3_hermite_subdivide(
|
|
18
|
+
output,
|
|
19
|
+
output_offset,
|
|
20
|
+
output_stride,
|
|
21
|
+
p0, p1, m0, m1,
|
|
22
|
+
t = 0.5
|
|
23
|
+
) {
|
|
24
|
+
assert.isNonNegativeInteger(output_offset, 'output_offset');
|
|
25
|
+
assert.isNonNegativeInteger(output_stride, 'output_stride');
|
|
26
|
+
assert.greaterThanOrEqual(output_stride, 1, 'output_stride must be at least 1');
|
|
27
|
+
|
|
28
|
+
// see https://github.com/krishauser/Klampt/blob/0ed16608a3eceee59d04383a17c207ebc33a399f/Python/klampt/math/spline.py#L63
|
|
29
|
+
|
|
30
|
+
const xm = spline3_hermite(t, p0, p1, m0, m1);
|
|
31
|
+
const vm = spline3_hermite_derivative(t, p0, p1, m0, m1);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// first segment
|
|
35
|
+
output[output_offset] = p0;
|
|
36
|
+
output[output_offset + output_stride] = xm;
|
|
37
|
+
output[output_offset + output_stride * 2] = m0 * t;
|
|
38
|
+
output[output_offset + output_stride * 3] = vm * t;
|
|
39
|
+
|
|
40
|
+
// second segment
|
|
41
|
+
output[output_offset + output_stride * 4] = xm;
|
|
42
|
+
output[output_offset + output_stride * 5] = p1;
|
|
43
|
+
output[output_offset + output_stride * 6] = vm * (1 - t);
|
|
44
|
+
output[output_offset + output_stride * 7] = m1 * (1 - t);
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -2,8 +2,8 @@ import { assert } from "../../../core/assert.js";
|
|
|
2
2
|
import { allocate_m4 } from "../../../core/geom/3d/mat4/allocate_m4.js";
|
|
3
3
|
import { compose_matrix4_array } from "../../../core/geom/3d/mat4/compose_matrix4_array.js";
|
|
4
4
|
import { decompose_matrix_4_array } from "../../../core/geom/3d/mat4/decompose_matrix_4_array.js";
|
|
5
|
-
import { m4_multiply } from "../../../core/geom/3d/mat4/m4_multiply.js";
|
|
6
5
|
import { M4_IDENTITY } from "../../../core/geom/3d/mat4/M4_IDENTITY.js";
|
|
6
|
+
import { m4_multiply } from "../../../core/geom/3d/mat4/m4_multiply.js";
|
|
7
7
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
8
8
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
9
9
|
import { TransformFlags } from "./TransformFlags.js";
|
|
@@ -2,8 +2,8 @@ import { Group, Matrix4, Mesh } from "three";
|
|
|
2
2
|
import { mergeBufferGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
3
3
|
import { array_copy } from "../../../../../core/collection/array/array_copy.js";
|
|
4
4
|
import { HashMap } from "../../../../../core/collection/map/HashMap.js";
|
|
5
|
-
import { m4_multiply } from "../../../../../core/geom/3d/mat4/m4_multiply.js";
|
|
6
5
|
import { M4_IDENTITY } from "../../../../../core/geom/3d/mat4/M4_IDENTITY.js";
|
|
6
|
+
import { m4_multiply } from "../../../../../core/geom/3d/mat4/m4_multiply.js";
|
|
7
7
|
import { StaticMaterialCache } from "../../../../asset/loaders/material/StaticMaterialCache.js";
|
|
8
8
|
import { computeGeometryEquality } from "../../buffered/computeGeometryEquality.js";
|
|
9
9
|
import { computeGeometryHash } from "../../buffered/computeGeometryHash.js";
|