@woosh/meep-engine 2.119.42 → 2.119.43
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/geom/3d/sphere/sphere_project.d.ts +8 -3
- package/src/core/geom/3d/sphere/sphere_project.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/sphere_project.js +19 -9
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.d.ts +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +4 -4
- package/src/engine/ecs/systems/AnimationSystem.js +1 -1
- package/src/engine/graphics/ecs/animation/animator/AnimationGraphSystem.js +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Computations of screen-space pixel area covered by a sphere
|
|
3
3
|
* NOTE: Port of GLSL code by Ingo Quilez. Source: http://www.iquilezles.org/www/articles/sphereproj/sphereproj.htm
|
|
4
|
-
* @param {
|
|
5
|
-
* @param {
|
|
4
|
+
* @param {number[]|{0:number,1:number,2:number,3:number}} sph Sphere in world space
|
|
5
|
+
* @param {number[]|Float32Array} cam camera transform matrix (world to camera)(inverse world matrix of camera)
|
|
6
6
|
* @param {number} fl focal length (fov in Radians)
|
|
7
7
|
* @returns {number} area on the screen as a fraction, 1=entire screen, 0=zero area
|
|
8
8
|
*/
|
|
9
|
-
export function sphere_project(sph:
|
|
9
|
+
export function sphere_project(sph: number[] | {
|
|
10
|
+
0: number;
|
|
11
|
+
1: number;
|
|
12
|
+
2: number;
|
|
13
|
+
3: number;
|
|
14
|
+
}, cam: number[] | Float32Array, fl: number): number;
|
|
10
15
|
//# sourceMappingURL=sphere_project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sphere_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/sphere/sphere_project.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH
|
|
1
|
+
{"version":3,"file":"sphere_project.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/sphere/sphere_project.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,oCALW,MAAM,EAAE,GAAC;IAAC,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAC;IAAA,CAAC,EAAC,MAAM,CAAA;CAAC,OAC9C,MAAM,EAAE,GAAC,YAAY,MACrB,MAAM,GACJ,MAAM,CAoClB"}
|
|
@@ -7,23 +7,26 @@ const v4 = [];
|
|
|
7
7
|
/**
|
|
8
8
|
* Computations of screen-space pixel area covered by a sphere
|
|
9
9
|
* NOTE: Port of GLSL code by Ingo Quilez. Source: http://www.iquilezles.org/www/articles/sphereproj/sphereproj.htm
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {number[]|{0:number,1:number,2:number,3:number}} sph Sphere in world space
|
|
11
|
+
* @param {number[]|Float32Array} cam camera transform matrix (world to camera)(inverse world matrix of camera)
|
|
12
12
|
* @param {number} fl focal length (fov in Radians)
|
|
13
13
|
* @returns {number} area on the screen as a fraction, 1=entire screen, 0=zero area
|
|
14
14
|
*/
|
|
15
15
|
export function sphere_project(sph, cam, fl) {
|
|
16
16
|
assert.notNull(cam, 'cam');
|
|
17
|
+
assert.isNumber(fl, 'fl');
|
|
18
|
+
assert.greaterThan(fl, 0, 'fl');
|
|
17
19
|
|
|
18
|
-
v4[0] = sph
|
|
19
|
-
v4[1] = sph
|
|
20
|
-
v4[2] = sph
|
|
20
|
+
v4[0] = sph[0];
|
|
21
|
+
v4[1] = sph[1];
|
|
22
|
+
v4[2] = sph[2];
|
|
21
23
|
v4[3] = 1;
|
|
22
24
|
|
|
23
25
|
//transform to camera space
|
|
24
|
-
v4_multiply_mat4(v4, v4, cam
|
|
26
|
+
v4_multiply_mat4(v4, v4, cam);
|
|
25
27
|
|
|
26
|
-
const
|
|
28
|
+
const r = sph[3];
|
|
29
|
+
const r2 = r * r;
|
|
27
30
|
|
|
28
31
|
const v4_x = v4[0];
|
|
29
32
|
const v4_y = v4[1];
|
|
@@ -33,7 +36,14 @@ export function sphere_project(sph, cam, fl) {
|
|
|
33
36
|
|
|
34
37
|
const l2 = v3_dot(v4_x, v4_y, v4_z, v4_x, v4_y, v4_z);
|
|
35
38
|
|
|
36
|
-
const
|
|
39
|
+
const rz2 = r2 - z2;
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
if (rz2 === 0) {
|
|
42
|
+
// avoid division by 0
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const area = -Math.PI * fl * fl * r2 * Math.sqrt(Math.abs((l2 - r2) / rz2)) / rz2;
|
|
47
|
+
|
|
48
|
+
return Math.abs(area);
|
|
39
49
|
}
|
|
@@ -54,7 +54,7 @@ export class Quadratic3 {
|
|
|
54
54
|
/**
|
|
55
55
|
* Find optimal vertex position based on the quadratic
|
|
56
56
|
*
|
|
57
|
-
* Based on
|
|
57
|
+
* Based on Blender's implementation: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/quadric.c
|
|
58
58
|
*
|
|
59
59
|
* @param {number[]} out
|
|
60
60
|
* @returns {boolean}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quadratic3.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Quadratic3.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/simplify/quadratic/Quadratic3.js"],"names":[],"mappings":"AASA;;;GAGG;AACH;IAGI,WAAO;IACP,WAAO;IACP,WAAO;IACP,WAAO;IAGP,WAAO;IACP,WAAO;IACP,WAAO;IAGP,WAAO;IACP,WAAO;IAGP,WAAO;IAGP;;;OAGG;IACH,kBAFW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAMjD;IAED;;;OAGG;IACH,eAFW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QAcjD;IAED;;;;;OAKG;IACH,sBAJW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,WACvC,MAAM,GACJ,OAAO,CAkCnB;IAED;;;;;;OAMG;IACH,kBALW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAgBhB;IAED;;;OAGG;IACH,sCAmBC;IAED;;;;;;OAMG;IACH,YALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CASlB;IAED;;;;;;;OAOG;IACH,cAHW,MAAM,EAAE,GACN,OAAO,CAgBnB;IAED;;;OAGG;IACH,OAFW,UAAU,QAuBpB;IAED;;;OAGG;IACH,kBAFW,MAAM,QAoBhB;IAED;;;OAGG;IACH,SAFa,UAAU,CAQtB;IAED;;;OAGG;IACH,YAFW,UAAU,QAqBpB;IAED;;OAEG;IACH,cAmBC;CACJ"}
|
|
@@ -5,6 +5,7 @@ import { v3_dot } from "../../../../vec3/v3_dot.js";
|
|
|
5
5
|
import { compute_triangle_normal } from "../../../compute_triangle_normal.js";
|
|
6
6
|
|
|
7
7
|
const scratch_v3 = new Float32Array(3);
|
|
8
|
+
const scratch_m3 = new Float32Array(9);
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Quadric Error Metric
|
|
@@ -166,19 +167,18 @@ export class Quadratic3 {
|
|
|
166
167
|
/**
|
|
167
168
|
* Find optimal vertex position based on the quadratic
|
|
168
169
|
*
|
|
169
|
-
* Based on
|
|
170
|
+
* Based on Blender's implementation: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/quadric.c
|
|
170
171
|
*
|
|
171
172
|
* @param {number[]} out
|
|
172
173
|
* @returns {boolean}
|
|
173
174
|
*/
|
|
174
175
|
optimize(out) {
|
|
175
|
-
const m = new Float32Array(9);
|
|
176
176
|
|
|
177
|
-
if (this.toTensorM3Inverse(
|
|
177
|
+
if (this.toTensorM3Inverse(scratch_m3, EPSILON)) {
|
|
178
178
|
|
|
179
179
|
this.toVector3(out);
|
|
180
180
|
|
|
181
|
-
vec3.transformMat3(out, out,
|
|
181
|
+
vec3.transformMat3(out, out, scratch_m3);
|
|
182
182
|
vec3.negate(out, out);
|
|
183
183
|
|
|
184
184
|
return true;
|
|
@@ -286,7 +286,7 @@ class AnimationSystem extends System {
|
|
|
286
286
|
v4boundingSphere.multiplyScalar(scaleMax);
|
|
287
287
|
v4boundingSphere.add3(position);
|
|
288
288
|
|
|
289
|
-
const area = sphere_project(v4boundingSphere, cameraMatrix, focalLength);
|
|
289
|
+
const area = sphere_project(v4boundingSphere, cameraMatrix.elements, focalLength);
|
|
290
290
|
const inPixels = area * viewportSize.x * viewportSize.y;
|
|
291
291
|
return inPixels;
|
|
292
292
|
}
|
|
@@ -240,7 +240,7 @@ export class AnimationGraphSystem extends System {
|
|
|
240
240
|
v4boundingSphere.multiplyScalar(scaleMax);
|
|
241
241
|
v4boundingSphere.add3(position);
|
|
242
242
|
|
|
243
|
-
const area = sphere_project(v4boundingSphere, cameraMatrix, this.__focalLength);
|
|
243
|
+
const area = sphere_project(v4boundingSphere, cameraMatrix.elements, this.__focalLength);
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
246
|
*
|