@woosh/meep-engine 2.60.0 → 2.61.0
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 +20211 -20240
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +20211 -20240
- package/package.json +1 -1
- package/src/core/binary/BitSet.js +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +30 -182
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.spec.js +27 -1
- package/src/core/geom/ConicRay.js +16 -21
- package/src/core/geom/ConicRay.spec.js +24 -0
- package/src/core/geom/packing/miniball/Miniball.js +68 -117
- package/src/core/geom/packing/miniball/Miniball.spec.js +3 -3
- package/src/core/geom/packing/miniball/Subspan.js +47 -34
- package/src/core/geom/packing/miniball/miniball_compute_quality.js +64 -0
- package/src/core/math/bessel_3.js +1 -0
- package/src/core/math/random/randomBytes.js +2 -2
- package/src/core/math/sqr.js +8 -0
- package/src/core/model/node-graph/Connection.js +21 -23
- package/src/core/model/node-graph/DataType.js +16 -17
- package/src/core/model/node-graph/NodeGraph.js +49 -50
- package/src/core/model/node-graph/node/NodeDescription.js +42 -44
- package/src/core/model/node-graph/node/NodeInstance.js +59 -60
- package/src/core/model/node-graph/node/NodeInstancePortReference.js +27 -29
- package/src/core/model/node-graph/node/NodeRegistry.js +16 -18
- package/src/core/model/node-graph/node/Port.js +35 -37
- package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +27 -13
- package/src/core/path/computePathDirectory.spec.js +8 -0
- package/src/core/process/BaseProcess.d.ts +5 -0
- package/src/core/process/WatchDog.js +76 -75
- package/src/core/process/action/AsynchronousAction.js +24 -22
- package/src/core/process/executor/profile/Profile.js +34 -24
- package/src/core/process/executor/profile/TraceEvent.js +75 -75
- package/src/core/process/worker/OnDemandWorkerManager.js +27 -30
- package/src/core/process/worker/WorkerBuilder.js +149 -149
- package/src/core/process/worker/WorkerProxy.js +25 -21
- package/src/core/process/worker/extractTransferables.js +2 -2
- package/src/engine/Engine.js +58 -53
- package/src/engine/EngineConfiguration.d.ts +4 -4
- package/src/engine/ecs/EntityManager.js +517 -614
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/ecs/transform/Transform.d.ts +7 -5
- package/src/engine/ecs/transform/Transform.js +30 -16
- package/src/engine/ecs/validateSystem.js +89 -0
- package/src/engine/graphics/GraphicsEngine.js +433 -483
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +46 -48
- package/src/engine/graphics/ecs/camera/Camera.js +11 -11
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +60 -62
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +20 -22
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +15 -4
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +156 -180
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +69 -71
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +51 -53
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +67 -69
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +56 -58
- package/src/engine/graphics/shadows/testShadowMapRendering.js +30 -34
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +22 -20
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +10 -13
- package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +1 -1
- package/src/engine/plugin/EnginePluginManager.d.ts +6 -1
- package/src/engine/ecs/components/ClingToHeightMap.js +0 -19
- package/src/engine/ecs/components/SynchronizePosition.js +0 -15
- package/src/engine/ecs/systems/ClingToHeightMapSystem.js +0 -170
- package/src/engine/ecs/systems/SynchronizePositionSystem.js +0 -43
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {assert} from "../../../../../core/assert.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -37,38 +37,35 @@ export function sampler2d_scale_down_linear(input, output) {
|
|
|
37
37
|
const input_data = input.data;
|
|
38
38
|
const output_data = output.data;
|
|
39
39
|
|
|
40
|
-
let
|
|
41
|
-
let x, y;
|
|
42
|
-
|
|
43
|
-
for (y = 0; y < oH; y++) {
|
|
40
|
+
for (let y = 0; y < oH; y++) {
|
|
44
41
|
|
|
45
42
|
const sampleOffsetY = y * sH;
|
|
46
43
|
|
|
47
44
|
const row_address = y * oW * itemSize;
|
|
48
45
|
|
|
49
|
-
for (x = 0; x < oW; x++) {
|
|
46
|
+
for (let x = 0; x < oW; x++) {
|
|
50
47
|
|
|
51
48
|
const output_texel_address = row_address + x * itemSize;
|
|
52
49
|
|
|
53
50
|
const sampleOffsetX = x * sW;
|
|
54
51
|
|
|
55
52
|
// accumulate sample
|
|
56
|
-
for (j = 0; j < sH; j++) {
|
|
53
|
+
for (let j = 0; j < sH; j++) {
|
|
57
54
|
const row_index = (sampleOffsetY + j) * iW;
|
|
58
55
|
const texel_offset = row_index + sampleOffsetX;
|
|
56
|
+
let input_texel_address = texel_offset * itemSize;
|
|
59
57
|
|
|
60
|
-
for (i =
|
|
61
|
-
|
|
62
|
-
const iAddress = (texel_offset + i) * itemSize;
|
|
58
|
+
for (let i = sW; i > 0; i--) {
|
|
63
59
|
|
|
64
|
-
for (k = 0; k < itemSize; k++) {
|
|
65
|
-
sample[k] += input_data[k +
|
|
60
|
+
for (let k = 0; k < itemSize; k++) {
|
|
61
|
+
sample[k] += input_data[k + input_texel_address];
|
|
66
62
|
}
|
|
67
63
|
|
|
64
|
+
input_texel_address += itemSize;
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
|
|
71
|
-
for (i = 0; i < itemSize; i++) {
|
|
68
|
+
for (let i = 0; i < itemSize; i++) {
|
|
72
69
|
// dilute the sample
|
|
73
70
|
output_data[output_texel_address + i] = sample[i] * sampleSizeInv;
|
|
74
71
|
//reset sample
|
|
@@ -25,7 +25,7 @@ test("constructor doesn't throw", () => {
|
|
|
25
25
|
new VirtualTexture(assetManager)
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
test("init computes sizes correctly", () => {
|
|
28
|
+
test.skip("init computes sizes correctly", () => {
|
|
29
29
|
const assetManager = mockAssetManager();
|
|
30
30
|
|
|
31
31
|
const sut = new VirtualTexture(assetManager);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import {BaseProcess} from "../../core/process/BaseProcess";
|
|
1
2
|
import {Reference} from "../reference/v2/Reference";
|
|
2
3
|
|
|
3
4
|
interface Type<T> extends Function {
|
|
4
5
|
new(...args: any[]): T;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export class EnginePluginManager {
|
|
8
|
+
export class EnginePluginManager extends BaseProcess {
|
|
8
9
|
acquire<T>(klass: Type<T>): Promise<Reference<T>>
|
|
9
10
|
|
|
10
11
|
getPlugin<T>(klass: Type<T>): T | undefined
|
|
12
|
+
|
|
13
|
+
startup(): Promise<void>
|
|
14
|
+
|
|
15
|
+
shutdown(): Promise<void>
|
|
11
16
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User: Alex Goldring
|
|
3
|
-
* Date: 1/10/2014
|
|
4
|
-
* Time: 21:29
|
|
5
|
-
*/
|
|
6
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
7
|
-
|
|
8
|
-
function ClingToHeightMap(options) {
|
|
9
|
-
if (options === void 0) {
|
|
10
|
-
options = {};
|
|
11
|
-
}
|
|
12
|
-
this.normalAlign = options.normalAlign !== void 0 ? options.normalAlign : false;
|
|
13
|
-
this.sampleCount = options.sampleCount !== void 0 ? options.sampleCount : 1;
|
|
14
|
-
this.samplingRadius = options.samplingRadius !== void 0 ? options.samplingRadius : 0;
|
|
15
|
-
const inf = Number.POSITIVE_INFINITY;
|
|
16
|
-
this.__prevPosition = new Vector3(inf, inf, inf);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default ClingToHeightMap;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 05/02/2015.
|
|
3
|
-
*/
|
|
4
|
-
function SynchronizePosition(options) {
|
|
5
|
-
this.targetEntity = options.targetEntity;
|
|
6
|
-
this.x = options.x !== void 0 ? options.x : true;
|
|
7
|
-
this.y = options.y !== void 0 ? options.y : true;
|
|
8
|
-
this.z = options.z !== void 0 ? options.z : true;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
SynchronizePosition.typeName = "SynchronizePosition";
|
|
12
|
-
|
|
13
|
-
SynchronizePosition.serializable = false;
|
|
14
|
-
|
|
15
|
-
export default SynchronizePosition;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User: Alex Goldring
|
|
3
|
-
* Date: 1/10/2014
|
|
4
|
-
* Time: 21:32
|
|
5
|
-
*/
|
|
6
|
-
import { System } from '../System.js';
|
|
7
|
-
import ClingToHeightMap from '../components/ClingToHeightMap.js';
|
|
8
|
-
import { Transform } from '../transform/Transform.js';
|
|
9
|
-
import { Euler as ThreeEuler, Matrix4 as ThreeMatrix4, Vector2 as ThreeVector2, Vector3 as ThreeVector3 } from 'three';
|
|
10
|
-
|
|
11
|
-
class ClingToHeightMapSystem extends System {
|
|
12
|
-
constructor(grid) {
|
|
13
|
-
super();
|
|
14
|
-
|
|
15
|
-
this.dependencies = [ClingToHeightMap];
|
|
16
|
-
//
|
|
17
|
-
this.entityManager = null;
|
|
18
|
-
this.grid = grid;
|
|
19
|
-
this.update = function () {
|
|
20
|
-
const uv = new ThreeVector2();
|
|
21
|
-
let u, v;
|
|
22
|
-
const euler = new ThreeEuler();
|
|
23
|
-
const normal = new ThreeVector3();
|
|
24
|
-
const m = new ThreeMatrix4();
|
|
25
|
-
const vUp = new ThreeVector3(0, 1, 0);
|
|
26
|
-
const vOrigin = new ThreeVector3();
|
|
27
|
-
|
|
28
|
-
function update(timeDelta) {
|
|
29
|
-
const entityManager = this.entityManager;
|
|
30
|
-
const terrain = this.terrain;
|
|
31
|
-
if (terrain === void 0) {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
const grid = this.grid;
|
|
35
|
-
const heightSampler = terrain.samplerHeight;
|
|
36
|
-
const samplerNormal = terrain.samplerNormal;
|
|
37
|
-
entityManager.traverseEntities([ClingToHeightMap, Transform], function (clingon, transform) {
|
|
38
|
-
const position = transform.global.position;
|
|
39
|
-
if (position.equals(clingon.__prevPosition)) {
|
|
40
|
-
return; //already correct placement
|
|
41
|
-
} else {
|
|
42
|
-
clingon.__prevPosition.copy(position);
|
|
43
|
-
}
|
|
44
|
-
grid.pointWorld2Grid(position, uv);
|
|
45
|
-
uv.divide(grid.size);
|
|
46
|
-
u = uv.x;
|
|
47
|
-
v = uv.y;
|
|
48
|
-
position.y = heightSampler.sample(u, v);
|
|
49
|
-
transform.setGlobalPosition(position.x, position.y, position.z);
|
|
50
|
-
//
|
|
51
|
-
if (clingon.normalAlign) {
|
|
52
|
-
if (clingon.samplingRadius !== 0 && clingon.sampleCount > 1) {
|
|
53
|
-
//more than one sample is to be used to compute normal by averaging
|
|
54
|
-
sampleNormalOnDisk(clingon.sampleCount, clingon.samplingRadius, samplerNormal, uv, normal);
|
|
55
|
-
} else {
|
|
56
|
-
samplerNormal.sample(u, v, normal);
|
|
57
|
-
}
|
|
58
|
-
vOrigin.set(0, 0, 0);
|
|
59
|
-
vUp.set(0, 1, 0);
|
|
60
|
-
//normal.set(-normal.x, normal.z, -normal.y);
|
|
61
|
-
//
|
|
62
|
-
m.identity();
|
|
63
|
-
m.lookAt(normal, vOrigin, vUp);
|
|
64
|
-
euler.setFromRotationMatrix(m, "XZY");
|
|
65
|
-
if (Math.abs(euler.y) + 0.0001 >= Math.PI) {
|
|
66
|
-
euler.z = -euler.z;
|
|
67
|
-
}
|
|
68
|
-
euler.y = 0; //drop rotation orthogonal to terrain
|
|
69
|
-
transform.rotation.setFromEuler(euler);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return update;
|
|
75
|
-
}();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
remove(component) {
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
add(component) {
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
clearCache() {
|
|
85
|
-
const em = this.entityManager;
|
|
86
|
-
em.traverseEntities([ClingToHeightMap], function (clingon) {
|
|
87
|
-
clingon.__prevPosition.set(Number.NaN, Number.NaN, Number.NaN);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const sampleNormalOnDisk = (function () {
|
|
94
|
-
const tempNormal = new ThreeVector3();
|
|
95
|
-
const offset = new ThreeVector2();
|
|
96
|
-
const PI2 = Math.PI * 2;
|
|
97
|
-
|
|
98
|
-
//TODO consider plane-fitting algorithm from: http://www.ilikebigbits.com/blog/2015/3/2/plane-from-points
|
|
99
|
-
/*
|
|
100
|
-
// source: http://www.ilikebigbits.com/blog/2015/3/2/plane-from-points
|
|
101
|
-
// @author Emil Ernerfeldt
|
|
102
|
-
// Constructs a plane from a collection of points
|
|
103
|
-
// so that the summed squared distance to all points is minimzized
|
|
104
|
-
fn plane_from_points(points: &[Vec3]) -> Plane {
|
|
105
|
-
let n = points.len();
|
|
106
|
-
assert!(n >= 3, "At least three points required");
|
|
107
|
-
|
|
108
|
-
let mut sum = Vec3{x:0.0, y:0.0, z:0.0};
|
|
109
|
-
for p in points {
|
|
110
|
-
sum = &sum + &p;
|
|
111
|
-
}
|
|
112
|
-
let centroid = &sum * (1.0 / (n as f64));
|
|
113
|
-
|
|
114
|
-
// Calc full 3x3 covariance matrix, excluding symmetries:
|
|
115
|
-
let mut xx = 0.0; let mut xy = 0.0; let mut xz = 0.0;
|
|
116
|
-
let mut yy = 0.0; let mut yz = 0.0; let mut zz = 0.0;
|
|
117
|
-
|
|
118
|
-
for p in points {
|
|
119
|
-
let r = p - ¢roid;
|
|
120
|
-
xx += r.x * r.x;
|
|
121
|
-
xy += r.x * r.y;
|
|
122
|
-
xz += r.x * r.z;
|
|
123
|
-
yy += r.y * r.y;
|
|
124
|
-
yz += r.y * r.z;
|
|
125
|
-
zz += r.z * r.z;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let det_x = yy*zz - yz*yz;
|
|
129
|
-
let det_y = xx*zz - xz*xz;
|
|
130
|
-
let det_z = xx*yy - xy*xy;
|
|
131
|
-
|
|
132
|
-
let det_max = max3(det_x, det_y, det_z);
|
|
133
|
-
assert!(det_max > 0.0, 'The points don't span a plane");
|
|
134
|
-
|
|
135
|
-
// Pick path with best conditioning:
|
|
136
|
-
let dir =
|
|
137
|
-
if det_max == det_x {
|
|
138
|
-
let a = (xz*yz - xy*zz) / det_x;
|
|
139
|
-
let b = (xy*yz - xz*yy) / det_x;
|
|
140
|
-
Vec3{x: 1.0, y: a, z: b}
|
|
141
|
-
} else if det_max == det_y {
|
|
142
|
-
let a = (yz*xz - xy*zz) / det_y;
|
|
143
|
-
let b = (xy*xz - yz*xx) / det_y;
|
|
144
|
-
Vec3{x: a, y: 1.0, z: b}
|
|
145
|
-
} else {
|
|
146
|
-
let a = (yz*xy - xz*yy) / det_z;
|
|
147
|
-
let b = (xz*xy - yz*xx) / det_z;
|
|
148
|
-
Vec3{x: a, y: b, z: 1.0}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
plane_from_point_and_normal(¢roid, &normalize(dir))
|
|
152
|
-
}
|
|
153
|
-
*/
|
|
154
|
-
function sampleNormalOnDisk(sampleCount, radius, sampler, origin, result) {
|
|
155
|
-
const radiusU = radius / sampler.width;
|
|
156
|
-
const radiusV = radius / sampler.height;
|
|
157
|
-
result.set(0, 0, 0);
|
|
158
|
-
for (let i = 0; i < sampleCount; i++) {
|
|
159
|
-
const angle = PI2 * (i / sampleCount);
|
|
160
|
-
offset.set(radiusU * Math.cos(angle), radiusV * Math.sin(angle));
|
|
161
|
-
sampler.sample(origin.x + offset.x, origin.y + offset.y, tempNormal);
|
|
162
|
-
result.add(tempNormal);
|
|
163
|
-
}
|
|
164
|
-
result.normalize();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return sampleNormalOnDisk;
|
|
168
|
-
})();
|
|
169
|
-
|
|
170
|
-
export default ClingToHeightMapSystem;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 05/02/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { System } from '../System.js';
|
|
5
|
-
import SynchronizePosition from '../components/SynchronizePosition.js';
|
|
6
|
-
import { Transform } from '../transform/Transform.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class SynchronizePositionSystem extends System {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
|
|
13
|
-
this.dependencies = [SynchronizePosition];
|
|
14
|
-
|
|
15
|
-
this.entityManager = null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
update(timeDelta) {
|
|
19
|
-
const em = this.entityManager;
|
|
20
|
-
const ecd = em.dataset;
|
|
21
|
-
|
|
22
|
-
if (ecd === null) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
ecd.traverseEntities([SynchronizePosition, Transform], function (sync, transform) {
|
|
27
|
-
const targetEntity = sync.targetEntity;
|
|
28
|
-
const targetTransform = ecd.getComponent(targetEntity, Transform);
|
|
29
|
-
if (sync.x) {
|
|
30
|
-
transform.position.x = targetTransform.position.x;
|
|
31
|
-
}
|
|
32
|
-
if (sync.y) {
|
|
33
|
-
transform.position.y = targetTransform.position.y;
|
|
34
|
-
}
|
|
35
|
-
if (sync.z) {
|
|
36
|
-
transform.position.z = targetTransform.position.z;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export default SynchronizePositionSystem;
|