@woosh/meep-engine 2.60.0 → 2.60.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/meep.cjs +104 -93
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +104 -93
- package/package.json +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +3 -3
- package/src/engine/graphics/ecs/camera/Camera.js +11 -11
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +15 -4
package/build/meep.module.js
CHANGED
|
@@ -69552,6 +69552,84 @@ function computeSystemName(system) {
|
|
|
69552
69552
|
return system.constructor.name;
|
|
69553
69553
|
}
|
|
69554
69554
|
|
|
69555
|
+
/**
|
|
69556
|
+
*
|
|
69557
|
+
* @param {Vector3} out Result will be written here
|
|
69558
|
+
* @param {number} originX Ray origin
|
|
69559
|
+
* @param {number} originY Ray origin
|
|
69560
|
+
* @param {number} originZ Ray origin
|
|
69561
|
+
* @param {number} directionX Ray direction
|
|
69562
|
+
* @param {number} directionY Ray direction
|
|
69563
|
+
* @param {number} directionZ Ray direction
|
|
69564
|
+
* @param {number} normalX Plane normal
|
|
69565
|
+
* @param {number} normalY Plane normal
|
|
69566
|
+
* @param {number} normalZ Plane normal
|
|
69567
|
+
* @param {number} dist Plane distance
|
|
69568
|
+
* @returns {boolean} true if intersection is found, false otherwise
|
|
69569
|
+
*/
|
|
69570
|
+
function plane3_compute_ray_intersection(
|
|
69571
|
+
out,
|
|
69572
|
+
originX, originY, originZ,
|
|
69573
|
+
directionX, directionY, directionZ,
|
|
69574
|
+
normalX, normalY, normalZ, dist
|
|
69575
|
+
) {
|
|
69576
|
+
const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
|
|
69577
|
+
|
|
69578
|
+
const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
|
|
69579
|
+
|
|
69580
|
+
if (denom !== 0) {
|
|
69581
|
+
|
|
69582
|
+
const t = -p / denom;
|
|
69583
|
+
|
|
69584
|
+
if (t < 0) {
|
|
69585
|
+
return false;
|
|
69586
|
+
}
|
|
69587
|
+
|
|
69588
|
+
out.set(
|
|
69589
|
+
directionX * t + originX,
|
|
69590
|
+
directionY * t + originY,
|
|
69591
|
+
directionZ * t + originZ
|
|
69592
|
+
);
|
|
69593
|
+
|
|
69594
|
+
return true;
|
|
69595
|
+
|
|
69596
|
+
} else {
|
|
69597
|
+
|
|
69598
|
+
if (p === 0) {
|
|
69599
|
+
|
|
69600
|
+
out.set(originX, originY, originZ);
|
|
69601
|
+
|
|
69602
|
+
return true;
|
|
69603
|
+
|
|
69604
|
+
} else {
|
|
69605
|
+
|
|
69606
|
+
//no intersection
|
|
69607
|
+
return false;
|
|
69608
|
+
|
|
69609
|
+
}
|
|
69610
|
+
|
|
69611
|
+
}
|
|
69612
|
+
}
|
|
69613
|
+
|
|
69614
|
+
/**
|
|
69615
|
+
* Orthogonal distance of a point to a plane, the distance is positive when the point lies above the plane and negative when the point is below
|
|
69616
|
+
* @param {number} x
|
|
69617
|
+
* @param {number} y
|
|
69618
|
+
* @param {number} z
|
|
69619
|
+
* @param {number} normalX
|
|
69620
|
+
* @param {number} normalY
|
|
69621
|
+
* @param {number} normalZ
|
|
69622
|
+
* @param {number} planeConstant
|
|
69623
|
+
* @returns {number}
|
|
69624
|
+
*/
|
|
69625
|
+
function v3_distance_above_plane(
|
|
69626
|
+
x, y, z,
|
|
69627
|
+
normalX, normalY, normalZ, planeConstant
|
|
69628
|
+
) {
|
|
69629
|
+
// this is the same as v4_dot(v4(x,y,z,1.0), v4(plane.normal, plane.constant));
|
|
69630
|
+
return v3_dot(normalX, normalY, normalZ, x, y, z) + planeConstant;
|
|
69631
|
+
}
|
|
69632
|
+
|
|
69555
69633
|
class ObservedBoolean extends Boolean {
|
|
69556
69634
|
/**
|
|
69557
69635
|
*
|
|
@@ -69792,21 +69870,6 @@ ObservedEnum.prototype.fromJSON = function (obj) {
|
|
|
69792
69870
|
this.set(obj);
|
|
69793
69871
|
};
|
|
69794
69872
|
|
|
69795
|
-
//
|
|
69796
|
-
|
|
69797
|
-
/**
|
|
69798
|
-
*
|
|
69799
|
-
* @param {Vector3} result
|
|
69800
|
-
* @param {Vector3} input
|
|
69801
|
-
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
69802
|
-
* @param {number[]} world_matrix world transform
|
|
69803
|
-
*/
|
|
69804
|
-
function unprojectPoint(result, input, projection_matrix_inverse, world_matrix) {
|
|
69805
|
-
result.copy(input);
|
|
69806
|
-
result.applyMatrix4(projection_matrix_inverse);
|
|
69807
|
-
result.applyMatrix4(world_matrix);
|
|
69808
|
-
}
|
|
69809
|
-
|
|
69810
69873
|
const matrix4 = new Matrix4();
|
|
69811
69874
|
|
|
69812
69875
|
/**
|
|
@@ -69850,25 +69913,6 @@ function invertQuaternionOrientation(output, input) {
|
|
|
69850
69913
|
output.setFromRotationMatrix(m4_scratch);
|
|
69851
69914
|
}
|
|
69852
69915
|
|
|
69853
|
-
/**
|
|
69854
|
-
* Orthogonal distance of a point to a plane, the distance is positive when the point lies above the plane and negative when the point is below
|
|
69855
|
-
* @param {number} x
|
|
69856
|
-
* @param {number} y
|
|
69857
|
-
* @param {number} z
|
|
69858
|
-
* @param {number} normalX
|
|
69859
|
-
* @param {number} normalY
|
|
69860
|
-
* @param {number} normalZ
|
|
69861
|
-
* @param {number} planeConstant
|
|
69862
|
-
* @returns {number}
|
|
69863
|
-
*/
|
|
69864
|
-
function v3_distance_above_plane(
|
|
69865
|
-
x, y, z,
|
|
69866
|
-
normalX, normalY, normalZ, planeConstant
|
|
69867
|
-
) {
|
|
69868
|
-
// this is the same as v4_dot(v4(x,y,z,1.0), v4(plane.normal, plane.constant));
|
|
69869
|
-
return v3_dot(normalX, normalY, normalZ, x, y, z) + planeConstant;
|
|
69870
|
-
}
|
|
69871
|
-
|
|
69872
69916
|
/**
|
|
69873
69917
|
*
|
|
69874
69918
|
* @enum {String}
|
|
@@ -69879,63 +69923,19 @@ const ProjectionType = {
|
|
|
69879
69923
|
Orthographic: "orthographic"
|
|
69880
69924
|
};
|
|
69881
69925
|
|
|
69926
|
+
//
|
|
69927
|
+
|
|
69882
69928
|
/**
|
|
69883
69929
|
*
|
|
69884
|
-
* @param {Vector3}
|
|
69885
|
-
* @param {
|
|
69886
|
-
* @param {number}
|
|
69887
|
-
* @param {number}
|
|
69888
|
-
* @param {number} directionX Ray direction
|
|
69889
|
-
* @param {number} directionY Ray direction
|
|
69890
|
-
* @param {number} directionZ Ray direction
|
|
69891
|
-
* @param {number} normalX Plane normal
|
|
69892
|
-
* @param {number} normalY Plane normal
|
|
69893
|
-
* @param {number} normalZ Plane normal
|
|
69894
|
-
* @param {number} dist Plane distance
|
|
69895
|
-
* @returns {boolean} true if intersection is found, false otherwise
|
|
69930
|
+
* @param {Vector3} result
|
|
69931
|
+
* @param {Vector3} input
|
|
69932
|
+
* @param {number[]} projection_matrix_inverse inverse of projection matrix
|
|
69933
|
+
* @param {number[]} world_matrix world transform
|
|
69896
69934
|
*/
|
|
69897
|
-
function
|
|
69898
|
-
|
|
69899
|
-
|
|
69900
|
-
|
|
69901
|
-
normalX, normalY, normalZ, dist
|
|
69902
|
-
) {
|
|
69903
|
-
const denom = v3_dot(directionX, directionY, directionZ, normalX, normalY, normalZ);
|
|
69904
|
-
|
|
69905
|
-
const p = v3_dot(normalX, normalY, normalZ, originX, originY, originZ) + dist;
|
|
69906
|
-
|
|
69907
|
-
if (denom !== 0) {
|
|
69908
|
-
|
|
69909
|
-
const t = -p / denom;
|
|
69910
|
-
|
|
69911
|
-
if (t < 0) {
|
|
69912
|
-
return false;
|
|
69913
|
-
}
|
|
69914
|
-
|
|
69915
|
-
out.set(
|
|
69916
|
-
directionX * t + originX,
|
|
69917
|
-
directionY * t + originY,
|
|
69918
|
-
directionZ * t + originZ
|
|
69919
|
-
);
|
|
69920
|
-
|
|
69921
|
-
return true;
|
|
69922
|
-
|
|
69923
|
-
} else {
|
|
69924
|
-
|
|
69925
|
-
if (p === 0) {
|
|
69926
|
-
|
|
69927
|
-
out.set(originX, originY, originZ);
|
|
69928
|
-
|
|
69929
|
-
return true;
|
|
69930
|
-
|
|
69931
|
-
} else {
|
|
69932
|
-
|
|
69933
|
-
//no intersection
|
|
69934
|
-
return false;
|
|
69935
|
-
|
|
69936
|
-
}
|
|
69937
|
-
|
|
69938
|
-
}
|
|
69935
|
+
function unprojectPoint(result, input, projection_matrix_inverse, world_matrix) {
|
|
69936
|
+
result.copy(input);
|
|
69937
|
+
result.applyMatrix4(projection_matrix_inverse);
|
|
69938
|
+
result.applyMatrix4(world_matrix);
|
|
69939
69939
|
}
|
|
69940
69940
|
|
|
69941
69941
|
/**
|
|
@@ -69977,7 +69977,7 @@ class Camera {
|
|
|
69977
69977
|
*
|
|
69978
69978
|
* @type {ObservedBoolean}
|
|
69979
69979
|
*/
|
|
69980
|
-
this.active = new ObservedBoolean(
|
|
69980
|
+
this.active = new ObservedBoolean(true);
|
|
69981
69981
|
|
|
69982
69982
|
/**
|
|
69983
69983
|
* Near clipping plane
|
|
@@ -77701,9 +77701,15 @@ function rewriteMaterial(shader) {
|
|
|
77701
77701
|
`+shader.fragmentShader;
|
|
77702
77702
|
}
|
|
77703
77703
|
|
|
77704
|
+
/**
|
|
77705
|
+
* @typedef {Object} CacheKey
|
|
77706
|
+
* @property {Material} color
|
|
77707
|
+
* @property {Material} depth
|
|
77708
|
+
*/
|
|
77709
|
+
|
|
77704
77710
|
/**
|
|
77705
77711
|
* @readonly
|
|
77706
|
-
* @type {Cache<Material,
|
|
77712
|
+
* @type {Cache<Material,CacheKey>}
|
|
77707
77713
|
*/
|
|
77708
77714
|
const material_cache = new Cache({
|
|
77709
77715
|
maxWeight: 1024,
|
|
@@ -77718,14 +77724,14 @@ class InstancedMeshGroup {
|
|
|
77718
77724
|
constructor() {
|
|
77719
77725
|
/**
|
|
77720
77726
|
* Instanced geometry
|
|
77721
|
-
* @type {
|
|
77727
|
+
* @type {InstancedBufferGeometry|null}
|
|
77722
77728
|
* @private
|
|
77723
77729
|
*/
|
|
77724
77730
|
this.__threeGeometry = null;
|
|
77725
77731
|
|
|
77726
77732
|
/**
|
|
77727
77733
|
* Geometry of a single instance
|
|
77728
|
-
* @type {
|
|
77734
|
+
* @type {BufferGeometry|null}
|
|
77729
77735
|
* @private
|
|
77730
77736
|
*/
|
|
77731
77737
|
this.__threeInstanceGeometry = null;
|
|
@@ -77753,7 +77759,12 @@ class InstancedMeshGroup {
|
|
|
77753
77759
|
*/
|
|
77754
77760
|
this.growConstant = 16;
|
|
77755
77761
|
|
|
77762
|
+
/**
|
|
77763
|
+
*
|
|
77764
|
+
* @type {number}
|
|
77765
|
+
*/
|
|
77756
77766
|
this.shrinkFactor = 0.5;
|
|
77767
|
+
|
|
77757
77768
|
/**
|
|
77758
77769
|
* Minimum capacity reduction for shrinkage to occur
|
|
77759
77770
|
* @type {number}
|
|
@@ -77918,7 +77929,7 @@ class InstancedMeshGroup {
|
|
|
77918
77929
|
/**
|
|
77919
77930
|
*
|
|
77920
77931
|
* @param {THREE.Material|THREE.ShaderMaterial} sourceMaterial
|
|
77921
|
-
* @returns {
|
|
77932
|
+
* @returns {CacheKey}
|
|
77922
77933
|
*/
|
|
77923
77934
|
#buildMaterial(sourceMaterial) {
|
|
77924
77935
|
//console.warn(`building material : {id:${sourceMaterial.id}, name: ${sourceMaterial.name}, type: ${sourceMaterial.type}`)
|
package/package.json
CHANGED
|
@@ -53,17 +53,17 @@ function factorial(n, d = 1) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
const F_PI = 3.14159265358979323846264338327950288;
|
|
56
|
-
const F_2_PI = 0.636619772367581343075535053490057448;
|
|
57
56
|
const F_2_SQRTPI = 1.12837916709551257389615890312154517;
|
|
58
57
|
const F_SQRT2 = 1.41421356237309504880168872420969808;
|
|
59
58
|
const F_SQRT1_2 = 0.707106781186547524400844362104849039;
|
|
60
59
|
const M_SQRT_3 = 1.7320508076;
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
|
-
* SH scaling factors
|
|
64
|
-
* returns sqrt((2*l + 1) / 4*pi) * sqrt( (l-|m|)! / (l+|m|)! )
|
|
62
|
+
* SH scaling factors
|
|
65
63
|
*/
|
|
66
64
|
function Kml(m, l) {
|
|
65
|
+
// returns sqrt((2*l + 1) / 4*pi) * sqrt( (l-|m|)! / (l+|m|)! )
|
|
66
|
+
|
|
67
67
|
m = m < 0 ? -m : m; // abs() is not constexpr
|
|
68
68
|
const K = (2 * l + 1) * factorial((l - m), (l + m));
|
|
69
69
|
return Math.sqrt(K) * (F_2_SQRTPI * 0.25);
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import {Frustum} from 'three';
|
|
7
|
+
import {assert} from "../../../../core/assert.js";
|
|
8
|
+
import {plane3_compute_ray_intersection} from "../../../../core/geom/3d/plane/plane3_compute_ray_intersection.js";
|
|
9
|
+
import {v3_distance_above_plane} from "../../../../core/geom/vec3/v3_distance_above_plane.js";
|
|
10
10
|
import Vector1 from "../../../../core/geom/Vector1.js";
|
|
11
|
-
import { unprojectPoint } from "./unprojectPoint.js";
|
|
12
11
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
|
|
13
|
+
import ObservedEnum from "../../../../core/model/ObservedEnum.js";
|
|
14
|
+
import {frustum_from_camera} from "./frustum_from_camera.js";
|
|
15
|
+
import {invertQuaternionOrientation} from "./InvertQuaternionOrientation.js";
|
|
16
|
+
import {ProjectionType} from "./ProjectionType.js";
|
|
17
|
+
import {unprojectPoint} from "./unprojectPoint.js";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @class
|
|
@@ -51,7 +51,7 @@ export class Camera {
|
|
|
51
51
|
*
|
|
52
52
|
* @type {ObservedBoolean}
|
|
53
53
|
*/
|
|
54
|
-
this.active = new ObservedBoolean(
|
|
54
|
+
this.active = new ObservedBoolean(true);
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Near clipping plane
|
|
@@ -21,9 +21,15 @@ import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
|
21
21
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
22
22
|
import { computeMaterialHash } from "../../../asset/loaders/material/computeMaterialHash.js";
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {Object} CacheKey
|
|
26
|
+
* @property {Material} color
|
|
27
|
+
* @property {Material} depth
|
|
28
|
+
*/
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* @readonly
|
|
26
|
-
* @type {Cache<Material,
|
|
32
|
+
* @type {Cache<Material,CacheKey>}
|
|
27
33
|
*/
|
|
28
34
|
const material_cache = new Cache({
|
|
29
35
|
maxWeight: 1024,
|
|
@@ -38,14 +44,14 @@ export class InstancedMeshGroup {
|
|
|
38
44
|
constructor() {
|
|
39
45
|
/**
|
|
40
46
|
* Instanced geometry
|
|
41
|
-
* @type {
|
|
47
|
+
* @type {InstancedBufferGeometry|null}
|
|
42
48
|
* @private
|
|
43
49
|
*/
|
|
44
50
|
this.__threeGeometry = null;
|
|
45
51
|
|
|
46
52
|
/**
|
|
47
53
|
* Geometry of a single instance
|
|
48
|
-
* @type {
|
|
54
|
+
* @type {BufferGeometry|null}
|
|
49
55
|
* @private
|
|
50
56
|
*/
|
|
51
57
|
this.__threeInstanceGeometry = null;
|
|
@@ -73,7 +79,12 @@ export class InstancedMeshGroup {
|
|
|
73
79
|
*/
|
|
74
80
|
this.growConstant = 16;
|
|
75
81
|
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @type {number}
|
|
85
|
+
*/
|
|
76
86
|
this.shrinkFactor = 0.5;
|
|
87
|
+
|
|
77
88
|
/**
|
|
78
89
|
* Minimum capacity reduction for shrinkage to occur
|
|
79
90
|
* @type {number}
|
|
@@ -238,7 +249,7 @@ export class InstancedMeshGroup {
|
|
|
238
249
|
/**
|
|
239
250
|
*
|
|
240
251
|
* @param {THREE.Material|THREE.ShaderMaterial} sourceMaterial
|
|
241
|
-
* @returns {
|
|
252
|
+
* @returns {CacheKey}
|
|
242
253
|
*/
|
|
243
254
|
#buildMaterial(sourceMaterial) {
|
|
244
255
|
//console.warn(`building material : {id:${sourceMaterial.id}, name: ${sourceMaterial.name}, type: ${sourceMaterial.type}`)
|