@woosh/meep-engine 2.120.0 → 2.120.2
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/README.md +1 -1
- package/package.json +1 -1
- package/src/core/binary/FLOAT32_MAX.d.ts +2 -0
- package/src/core/binary/FLOAT32_MAX.d.ts.map +1 -0
- package/src/core/binary/FLOAT32_MAX.js +1 -0
- package/src/core/collection/RingBuffer.d.ts +2 -3
- package/src/core/collection/RingBuffer.d.ts.map +1 -1
- package/src/core/collection/RingBuffer.js +9 -4
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +15 -1
- package/src/core/geom/2d/circle/Circle.d.ts +7 -5
- package/src/core/geom/2d/circle/Circle.d.ts.map +1 -1
- package/src/core/geom/2d/circle/Circle.js +7 -5
- package/src/core/geom/2d/circle/circle_area.d.ts +7 -0
- package/src/core/geom/2d/circle/circle_area.d.ts.map +1 -0
- package/src/core/geom/2d/circle/circle_area.js +8 -0
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +57 -23
- package/src/core/geom/Vector4.d.ts.map +1 -1
- package/src/core/geom/Vector4.js +32 -0
- package/src/core/geom/mat2/M2_IDENTITY.d.ts +6 -0
- package/src/core/geom/mat2/M2_IDENTITY.d.ts.map +1 -0
- package/src/core/geom/mat2/M2_IDENTITY.js +8 -0
- package/src/core/geom/mat2/m2_is_diagonal.d.ts +8 -0
- package/src/core/geom/mat2/m2_is_diagonal.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_is_diagonal.js +9 -0
- package/src/core/geom/mat2/m2_is_orthogonal.d.ts +8 -0
- package/src/core/geom/mat2/m2_is_orthogonal.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_is_orthogonal.js +23 -0
- package/src/core/geom/mat2/m2_transpose.d.ts +9 -0
- package/src/core/geom/mat2/m2_transpose.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_transpose.js +17 -0
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts +7 -5
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_adjacency_matrix.js +11 -5
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_distance_matrix.js +30 -56
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts +6 -6
- package/src/core/graph/graph_compute_laplacian_matrix.js +6 -6
- package/src/core/json/abstractJSONDeserializer.d.ts.map +1 -1
- package/src/core/json/abstractJSONDeserializer.js +7 -1
- package/src/core/math/bell_membership_function.d.ts.map +1 -1
- package/src/core/math/bell_membership_function.js +6 -1
- package/src/core/math/linalg/m2/m2_polar_decomp.d.ts +19 -0
- package/src/core/math/linalg/m2/m2_polar_decomp.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_polar_decomp.js +27 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts +15 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.js +32 -0
- package/src/core/math/linalg/m2/m2_svd.d.ts +19 -0
- package/src/core/math/linalg/m2/m2_svd.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_svd.js +96 -0
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +1 -1
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +1 -1
- package/src/core/model/node-graph/node/NodeDescription.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeDescription.js +14 -0
- package/src/core/model/node-graph/type/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/type/DataType.js +4 -0
- package/src/core/process/WatchDog.d.ts +41 -12
- package/src/core/process/WatchDog.d.ts.map +1 -1
- package/src/core/process/WatchDog.js +47 -16
- package/src/engine/development/performance/RingBufferMetric.d.ts +1 -1
- package/src/engine/development/performance/RingBufferMetric.d.ts.map +1 -1
- package/src/engine/ecs/Entity.js +2 -2
- package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
- package/src/engine/ecs/EntityComponentDataset.js +31 -13
- package/src/engine/ecs/EntityManager.d.ts.map +1 -1
- package/src/engine/ecs/EntityManager.js +10 -1
- package/src/engine/ecs/EntityObserver.d.ts.map +1 -1
- package/src/engine/ecs/EntityObserver.js +2 -10
- package/src/engine/ecs/EntityReference.d.ts +10 -2
- package/src/engine/ecs/EntityReference.d.ts.map +1 -1
- package/src/engine/ecs/EntityReference.js +24 -6
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +3 -3
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.d.ts +4 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.js +24 -0
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +3 -9
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.d.ts.map +1 -1
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +14 -8
- package/src/engine/ecs/transform/Transform.d.ts +5 -1
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +5 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts +349 -50
- package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts +3 -0
- package/src/engine/intelligence/behavior/ecs/DieBehavior.d.ts.map +1 -1
- package/src/engine/intelligence/behavior/ecs/DieBehavior.js +4 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts +17 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.d.ts.map +1 -0
- package/src/engine/intelligence/behavior/ecs/KillBehavior.js +47 -0
- package/src/engine/intelligence/blackboard/BlackboardStack.d.ts +1 -1
- package/src/engine/intelligence/blackboard/BlackboardStack.js +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.d.ts.map +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +3 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.d.ts.map +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.js +3 -7
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.d.ts +5 -0
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.d.ts.map +1 -0
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.js +19 -0
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +9 -114
- package/src/engine/physics/mls-mpm/README.md +5 -0
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts +7 -6
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +51 -43
- package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts +0 -48
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts.map +0 -1
- package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts.map +0 -1
- package/editor/actions/concrete/PatchTerrainHeightAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionAddAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionClearAction.d.ts.map +0 -1
- package/editor/actions/concrete/SelectionRemoveAction.d.ts.map +0 -1
- package/editor/actions/concrete/TransformModifyAction.d.ts.map +0 -1
- package/editor/actions/concrete/WriteGridValueAction.d.ts.map +0 -1
- package/src/engine/ecs/read_entity_reference.d.ts +0 -9
- package/src/engine/ecs/read_entity_reference.d.ts.map +0 -1
- package/src/engine/ecs/read_entity_reference.js +0 -15
- package/src/engine/physics/ammo/Body.js +0 -103
- package/src/engine/physics/ammo/PhysicsWorker.d.ts +0 -72
- package/src/engine/physics/ammo/PhysicsWorker.d.ts.map +0 -1
- package/src/engine/physics/ammo/PhysicsWorker.js +0 -437
- package/src/engine/physics/ammo/World.d.ts +0 -68
- package/src/engine/physics/ammo/World.d.ts.map +0 -1
- package/src/engine/physics/ammo/World.js +0 -336
- package/src/engine/physics/ammo/shapes/BoxShape.d.ts +0 -10
- package/src/engine/physics/ammo/shapes/BoxShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/BoxShape.js +0 -11
- package/src/engine/physics/ammo/shapes/CapsuleShape.d.ts +0 -9
- package/src/engine/physics/ammo/shapes/CapsuleShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/CapsuleShape.js +0 -10
- package/src/engine/physics/ammo/shapes/MeshShape.d.ts +0 -8
- package/src/engine/physics/ammo/shapes/MeshShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/MeshShape.js +0 -9
- package/src/engine/physics/ammo/shapes/PlaneShape.d.ts +0 -11
- package/src/engine/physics/ammo/shapes/PlaneShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/PlaneShape.js +0 -14
- package/src/engine/physics/ammo/shapes/Shape.d.ts +0 -7
- package/src/engine/physics/ammo/shapes/Shape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/Shape.js +0 -9
- package/src/engine/physics/ammo/shapes/SphereShape.d.ts +0 -8
- package/src/engine/physics/ammo/shapes/SphereShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/SphereShape.js +0 -9
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.d.ts +0 -15
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.d.ts.map +0 -1
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +0 -196
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { BinaryClassUpgrader } from "../../../ecs/storage/binary/BinaryClassUpgrader.js";
|
|
2
1
|
import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { BinaryClassUpgrader } from "../../../ecs/storage/binary/BinaryClassUpgrader.js";
|
|
3
3
|
|
|
4
4
|
export class PathFollowerSerializationUpgrader_2_3 extends BinaryClassUpgrader {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.__startVersion = 2;
|
|
9
|
-
this.__targetVersion = 3;
|
|
10
|
-
}
|
|
5
|
+
__startVersion = 2;
|
|
6
|
+
__targetVersion = 3;
|
|
11
7
|
|
|
12
8
|
upgrade(source, target) {
|
|
13
9
|
const flags = source.readUint8();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export class PathFollowerSerializationUpgrader_3_4 extends BinaryClassUpgrader {
|
|
2
|
+
upgrade(source: any, target: any): void;
|
|
3
|
+
}
|
|
4
|
+
import { BinaryClassUpgrader } from "../../../ecs/storage/binary/BinaryClassUpgrader.js";
|
|
5
|
+
//# sourceMappingURL=PathFollowerSerializationUpgrader_3_4.d.ts.map
|
package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathFollowerSerializationUpgrader_3_4.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.js"],"names":[],"mappings":"AAGA;IAII,wCAUC;CACJ;oCAjBmC,oDAAoD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BinaryBuffer } from "../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { BinaryClassUpgrader } from "../../../ecs/storage/binary/BinaryClassUpgrader.js";
|
|
3
|
+
|
|
4
|
+
export class PathFollowerSerializationUpgrader_3_4 extends BinaryClassUpgrader {
|
|
5
|
+
__startVersion = 3;
|
|
6
|
+
__targetVersion = 4;
|
|
7
|
+
|
|
8
|
+
upgrade(source, target) {
|
|
9
|
+
// Copy existing fields
|
|
10
|
+
BinaryBuffer.copyUint16(source, target); // flags
|
|
11
|
+
|
|
12
|
+
BinaryBuffer.copyFloat32(source, target); // speed
|
|
13
|
+
BinaryBuffer.copyFloat32(source, target); // rotationSpeed
|
|
14
|
+
BinaryBuffer.copyFloat32(source, target); // maxMoveDistance
|
|
15
|
+
|
|
16
|
+
// Add the new field with a default value
|
|
17
|
+
target.writeFloat32(0); // Default position
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLS_MPM.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/mls-mpm/MLS_MPM.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MLS_MPM.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/mls-mpm/MLS_MPM.js"],"names":[],"mappings":"AAcA;IAGQ,iBAAmB;IAGnB;;;;;OAKG;IACH,MAFU,YAAY,CAEiB;IAI3C;;;OAGG;IACH,YAFW,MAAM,QAyVhB;IAED,0DAeC;CACJ"}
|
|
@@ -1,123 +1,17 @@
|
|
|
1
1
|
import { m2_add } from "../../../core/geom/mat2/m2_add.js";
|
|
2
2
|
import { m2_determinant } from "../../../core/geom/mat2/m2_determinant.js";
|
|
3
|
+
import { M2_IDENTITY } from "../../../core/geom/mat2/M2_IDENTITY.js";
|
|
3
4
|
import { m2_multiply } from "../../../core/geom/mat2/m2_multiply.js";
|
|
4
5
|
import { m2_multiply_scalar } from "../../../core/geom/mat2/m2_multiply_scalar.js";
|
|
5
6
|
import { m2_multiply_transposed } from "../../../core/geom/mat2/m2_multiply_transposed.js";
|
|
6
7
|
import { m2_sub_transposed } from "../../../core/geom/mat2/m2_sub_transposed.js";
|
|
7
8
|
import { clamp } from "../../../core/math/clamp.js";
|
|
9
|
+
import { m2_polar_decomp_noS } from "../../../core/math/linalg/m2/m2_polar_decomp_noS.js";
|
|
10
|
+
import { m2_svd } from "../../../core/math/linalg/m2/m2_svd.js";
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
/**
|
|
11
|
-
* transposed as in taichi
|
|
12
|
-
* @param {number[]} R
|
|
13
|
-
* @param {number[]} S
|
|
14
|
-
* @param {number[]} m
|
|
15
|
-
*/
|
|
16
|
-
function polar_decomp(R, S, m) {
|
|
17
|
-
polar_decomp_noS(R, m);
|
|
18
|
-
|
|
19
|
-
m2_multiply(S, m, R);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {number[]} R
|
|
25
|
-
* @param {number[]} m
|
|
26
|
-
*/
|
|
27
|
-
function polar_decomp_noS(R, m) { // transposed as in taichi
|
|
28
|
-
const x = m[0] + m[3];
|
|
29
|
-
const y = m[2] - m[1];
|
|
30
|
-
|
|
31
|
-
const scale = 1.0 / Math.sqrt(x * x + y * y);
|
|
32
|
-
|
|
33
|
-
const c = x * scale;
|
|
34
|
-
const s = y * scale;
|
|
35
|
-
|
|
36
|
-
R[0] = c;
|
|
37
|
-
R[1] = s;
|
|
38
|
-
R[2] = -s;
|
|
39
|
-
R[3] = c;
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {number[]} U
|
|
46
|
-
* @param {number[]} S
|
|
47
|
-
* @param {number[]} V
|
|
48
|
-
* @param {number[]} sig
|
|
49
|
-
* @param {number[]} m
|
|
50
|
-
*/
|
|
51
|
-
function svd(U, S, V, sig, m) { // transposed as in taichi
|
|
52
|
-
|
|
53
|
-
polar_decomp(U, S, m);
|
|
54
|
-
|
|
55
|
-
let c, s;
|
|
56
|
-
|
|
57
|
-
if (Math.abs(S[1]) < 1e-6) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
sig[0] = S[0];
|
|
61
|
-
sig[1] = S[1];
|
|
62
|
-
sig[2] = S[2];
|
|
63
|
-
sig[3] = S[3];
|
|
64
|
-
|
|
65
|
-
c = 1;
|
|
66
|
-
s = 0;
|
|
67
|
-
|
|
68
|
-
} else {
|
|
69
|
-
const tao = 0.5 * (S[0] - S[3]);
|
|
70
|
-
|
|
71
|
-
const w = Math.sqrt(tao * tao + S[1] * S[1]);
|
|
72
|
-
|
|
73
|
-
const t = tao > 0 ? S[1] / (tao + w) : S[1] / (tao - w);
|
|
74
|
-
|
|
75
|
-
c = 1.0 / Math.sqrt(t * t + 1);
|
|
76
|
-
|
|
77
|
-
s = -t * c;
|
|
78
|
-
|
|
79
|
-
const s2 = s * s;
|
|
80
|
-
const c2 = c * c;
|
|
81
|
-
|
|
82
|
-
const cs_2 = 2 * c * s;
|
|
83
|
-
|
|
84
|
-
sig[0] = c2 * S[0] - cs_2 * S[1] + s2 * S[3];
|
|
85
|
-
sig[1] = 0;
|
|
86
|
-
sig[2] = 0;
|
|
87
|
-
sig[3] = s2 * S[0] + cs_2 * S[1] + c2 * S[3];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (sig[0] < sig[3]) {
|
|
91
|
-
|
|
92
|
-
const tmp = sig[0];
|
|
93
|
-
|
|
94
|
-
sig[0] = sig[3];
|
|
95
|
-
sig[3] = tmp;
|
|
96
|
-
|
|
97
|
-
V[3] = -s;
|
|
98
|
-
V[2] = -c;
|
|
99
|
-
V[1] = c;
|
|
100
|
-
V[0] = -s;
|
|
101
|
-
|
|
102
|
-
} else {
|
|
103
|
-
|
|
104
|
-
V[3] = c;
|
|
105
|
-
V[2] = -s;
|
|
106
|
-
V[1] = s;
|
|
107
|
-
V[0] = c;
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
m2_multiply(U, U, V);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
13
|
const dimensions = 2;
|
|
115
14
|
|
|
116
|
-
const m2_indentity = [
|
|
117
|
-
1, 0,
|
|
118
|
-
0, 1
|
|
119
|
-
];
|
|
120
|
-
|
|
121
15
|
export class MLS_MPMSolver {
|
|
122
16
|
constructor() {
|
|
123
17
|
|
|
@@ -257,7 +151,7 @@ export class MLS_MPMSolver {
|
|
|
257
151
|
// original taichi: stress = -4*inv_dx*inv_dx*dt*vol*( 2*mu*(p.F-r)*transposed(p.F) + lambda*(J-1)*J )
|
|
258
152
|
// (in taichi matrices are coded transposed)
|
|
259
153
|
const J = m2_determinant(p.F); // Current volume
|
|
260
|
-
|
|
154
|
+
m2_polar_decomp_noS(r, p.F); // Polar decomp. for fixed corotated model
|
|
261
155
|
const k1 = -4 * inv_dx * inv_dx * dt * vol;
|
|
262
156
|
const k2 = lambda * (J - 1) * J;
|
|
263
157
|
|
|
@@ -463,11 +357,12 @@ export class MLS_MPMSolver {
|
|
|
463
357
|
// MLS-MPM F-update
|
|
464
358
|
// original taichi: F = (Mat(1) + dt * p.C) * p.F
|
|
465
359
|
m2_multiply_scalar(m2_temp0, p.C, dt);
|
|
466
|
-
m2_add(m2_temp0,
|
|
360
|
+
m2_add(m2_temp0, M2_IDENTITY, m2_temp0);
|
|
467
361
|
m2_multiply(F, p.F, m2_temp0);
|
|
468
362
|
|
|
469
363
|
// Snow-like plasticity
|
|
470
|
-
|
|
364
|
+
m2_svd(svd_u, m2_temp0, svd_v, sig, F);
|
|
365
|
+
|
|
471
366
|
|
|
472
367
|
for (let i = 0; i < 2 * plastic; i++) {
|
|
473
368
|
sig[i + 2 * i] = clamp(sig[i + 2 * i], 1.0 - 2.5e-2, 1.0 + 7.5e-3);
|
|
@@ -482,10 +377,10 @@ export class MLS_MPMSolver {
|
|
|
482
377
|
}
|
|
483
378
|
}
|
|
484
379
|
|
|
485
|
-
add_rnd_square(center, c) {
|
|
380
|
+
add_rnd_square(center, c, count=1000) {
|
|
486
381
|
const particles = this.particles;
|
|
487
382
|
|
|
488
|
-
for (let i = 0; i <
|
|
383
|
+
for (let i = 0; i < count; i++) {
|
|
489
384
|
// Randomly sample 1000 particles in the square
|
|
490
385
|
particles.push(
|
|
491
386
|
new Particle(
|
|
@@ -23,7 +23,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
23
23
|
*/
|
|
24
24
|
scale: NumericInterval;
|
|
25
25
|
/**
|
|
26
|
-
* RNG seed
|
|
26
|
+
* RNG seed
|
|
27
27
|
* @type {number}
|
|
28
28
|
* @private
|
|
29
29
|
*/
|
|
@@ -31,12 +31,13 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
33
|
* @param {GridData} grid
|
|
34
|
-
* @param x0
|
|
35
|
-
* @param y0
|
|
36
|
-
* @param x1
|
|
37
|
-
* @param y1
|
|
34
|
+
* @param {number} x0
|
|
35
|
+
* @param {number} y0
|
|
36
|
+
* @param {number} x1
|
|
37
|
+
* @param {number} y1
|
|
38
|
+
* @returns {number}
|
|
38
39
|
*/
|
|
39
|
-
estimateTapCount(grid: GridData, x0:
|
|
40
|
+
estimateTapCount(grid: GridData, x0: number, y0: number, x1: number, y1: number): number;
|
|
40
41
|
/**
|
|
41
42
|
*
|
|
42
43
|
* @param {number} seed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTaskDensityMarkerDistribution.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/generation/GridTaskDensityMarkerDistribution.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GridTaskDensityMarkerDistribution.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/generation/GridTaskDensityMarkerDistribution.js"],"names":[],"mappings":"AAgBA;IA4BI;;;;;;OAMG;IACH,qBALW,UAAU,UACV,yBAAyB,SACzB,eAAe,SACf,MAAM,qCAgBhB;IA/CD;;;OAGG;IACH,SAFU,UAAU,CAEL;IAEf;;;OAGG;IACH,QAFU,yBAAyB,CAErB;IAEd;;;OAGG;IACH,OAFU,eAAe,CAES;IAElC;;;;OAIG;IACH,eAAW;IA2BX;;;;;;;;OAQG;IACH,uBAPW,QAAQ,MACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAwFlB;IAED;;;;;;;;;OASG;IACH,kBARW,MAAM,QACN,QAAQ,MACR,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,IAAI,CAkIhB;IAGD,iDA6EC;CACJ;kCAlXiC,yBAAyB;gCAT3B,gDAAgD;iBAI/D,oCAAoC;sBAC/B,yCAAyC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
2
|
import { ArrayIteratorRandom } from "../../../core/collection/array/iterator/ArrayIteratorRandom.js";
|
|
3
|
+
import { circle_area } from "../../../core/geom/2d/circle/circle_area.js";
|
|
3
4
|
import { clamp } from "../../../core/math/clamp.js";
|
|
4
5
|
import { clamp01 } from "../../../core/math/clamp01.js";
|
|
5
6
|
import { NumericInterval } from "../../../core/math/interval/NumericInterval.js";
|
|
@@ -13,15 +14,6 @@ import { actionTask } from "../../../core/process/task/util/actionTask.js";
|
|
|
13
14
|
import { MarkerNodeMatcherAny } from "../../markers/matcher/MarkerNodeMatcherAny.js";
|
|
14
15
|
import { GridTaskGenerator } from "../GridTaskGenerator.js";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {number} radius
|
|
20
|
-
*/
|
|
21
|
-
function estimateDensityTarget(radius) {
|
|
22
|
-
return Math.PI * radius * radius;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
26
18
|
|
|
27
19
|
/**
|
|
@@ -43,7 +35,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
43
35
|
scale = new NumericInterval(1, 1);
|
|
44
36
|
|
|
45
37
|
/**
|
|
46
|
-
* RNG seed
|
|
38
|
+
* RNG seed
|
|
47
39
|
* @type {number}
|
|
48
40
|
* @private
|
|
49
41
|
*/
|
|
@@ -77,13 +69,14 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
77
69
|
/**
|
|
78
70
|
*
|
|
79
71
|
* @param {GridData} grid
|
|
80
|
-
* @param x0
|
|
81
|
-
* @param y0
|
|
82
|
-
* @param x1
|
|
83
|
-
* @param y1
|
|
72
|
+
* @param {number} x0
|
|
73
|
+
* @param {number} y0
|
|
74
|
+
* @param {number} x1
|
|
75
|
+
* @param {number} y1
|
|
76
|
+
* @returns {number}
|
|
84
77
|
*/
|
|
85
78
|
estimateTapCount(grid, x0, y0, x1, y1) {
|
|
86
|
-
const random = seededRandom(
|
|
79
|
+
const random = seededRandom(this.__seed + 91234);
|
|
87
80
|
|
|
88
81
|
/*
|
|
89
82
|
for tap count we ween 3 things:
|
|
@@ -95,17 +88,23 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
95
88
|
const width = x1 - x0;
|
|
96
89
|
const height = y1 - y0;
|
|
97
90
|
|
|
98
|
-
const
|
|
91
|
+
const grid_cell_count = width * height;
|
|
99
92
|
|
|
100
|
-
const SAMPLE_SIZE = 60 +
|
|
93
|
+
const SAMPLE_SIZE = 60 + grid_cell_count * 0.01;
|
|
101
94
|
|
|
102
95
|
const x_max = width - 1;
|
|
103
96
|
const y_max = height - 1;
|
|
104
97
|
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @type {number[]}
|
|
101
|
+
*/
|
|
105
102
|
const samplesCollisions = [];
|
|
106
103
|
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @type {number[]}
|
|
107
|
+
*/
|
|
109
108
|
const samplesSize = [];
|
|
110
109
|
|
|
111
110
|
const SIZE_SAMPLE_LIMIT = 10 + SAMPLE_SIZE * 3;
|
|
@@ -121,8 +120,6 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
121
120
|
|
|
122
121
|
const density = clamp01(densityValue);
|
|
123
122
|
|
|
124
|
-
samplesDensity.push(density);
|
|
125
|
-
|
|
126
123
|
if (density <= 0) {
|
|
127
124
|
continue;
|
|
128
125
|
}
|
|
@@ -156,9 +153,9 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
156
153
|
const meanNodeSize = samplesSize.length > 0 ? computeStatisticalMean(samplesSize) : 1;
|
|
157
154
|
|
|
158
155
|
//compute relative density per unit square of a single marker
|
|
159
|
-
const meanSingleNodeDensity =
|
|
156
|
+
const meanSingleNodeDensity = circle_area(meanNodeSize);
|
|
160
157
|
|
|
161
|
-
const saturationTapCount =
|
|
158
|
+
const saturationTapCount = grid_cell_count / meanSingleNodeDensity;
|
|
162
159
|
|
|
163
160
|
// it is possible that a tap will collide with other existing nodes, in which situation the tap is rejected, to account for that we want to estimate how often this will happen and increase the tap count accordingly
|
|
164
161
|
const collisionCompensation = clamp(1 / (1 - collisionProbability), 1, 10);
|
|
@@ -176,7 +173,11 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
176
173
|
* @param {number} y1
|
|
177
174
|
* @returns {Task}
|
|
178
175
|
*/
|
|
179
|
-
processArea(
|
|
176
|
+
processArea(
|
|
177
|
+
seed,
|
|
178
|
+
grid,
|
|
179
|
+
x0, y0, x1, y1
|
|
180
|
+
) {
|
|
180
181
|
|
|
181
182
|
//we want to estimate average size of a marker
|
|
182
183
|
|
|
@@ -203,8 +204,6 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
203
204
|
*/
|
|
204
205
|
const scale = this.scale;
|
|
205
206
|
|
|
206
|
-
const self = this;
|
|
207
|
-
|
|
208
207
|
const random = seededRandom(seed);
|
|
209
208
|
|
|
210
209
|
const width = x1 - x0;
|
|
@@ -232,7 +231,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
232
231
|
//sample density mask
|
|
233
232
|
const densityValue = density.execute(grid, _x, _y, 0);
|
|
234
233
|
|
|
235
|
-
if (densityValue
|
|
234
|
+
if (densityValue <= 1e-6) {
|
|
236
235
|
// 0% chance
|
|
237
236
|
return TaskSignal.Continue;
|
|
238
237
|
}
|
|
@@ -277,24 +276,22 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
277
276
|
return TaskSignal.Continue;
|
|
278
277
|
}
|
|
279
278
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
return new Task({
|
|
280
|
+
name: 'Density marker distribution',
|
|
281
|
+
cycleFunction,
|
|
282
|
+
initializer: () => {
|
|
283
283
|
|
|
284
|
-
|
|
285
|
-
iteration = 0;
|
|
284
|
+
random.setCurrentSeed(seed);
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
assert.ok(!Number.isNaN(iterationLimit), 'iterationLimit is NaN');
|
|
286
|
+
iterationLimit = this.estimateTapCount(grid, x0, y0, x1, y1);
|
|
287
|
+
iteration = 0;
|
|
290
288
|
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
assert.isNumber(iterationLimit, 'iterationLimit');
|
|
290
|
+
assert.isFiniteNumber(iterationLimit, 'iterationLimit');
|
|
291
|
+
assert.ok(!Number.isNaN(iterationLimit), 'iterationLimit is NaN');
|
|
293
292
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
cycleFunction,
|
|
297
|
-
initializer,
|
|
293
|
+
rejectedSampleBudget = iterationLimit * 0.15;
|
|
294
|
+
},
|
|
298
295
|
estimatedDuration: height * width / 6000,
|
|
299
296
|
computeProgress() {
|
|
300
297
|
if (iterationLimit === 0) {
|
|
@@ -312,9 +309,11 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
312
309
|
const random = seededRandom(seed);
|
|
313
310
|
|
|
314
311
|
const tile_size = 16;
|
|
315
|
-
|
|
312
|
+
|
|
313
|
+
|
|
316
314
|
const tasks = [];
|
|
317
315
|
|
|
316
|
+
//we want to estimate average size of a marker
|
|
318
317
|
const tInitialize = actionTask(() => {
|
|
319
318
|
|
|
320
319
|
if (!this.density.initialized) {
|
|
@@ -324,12 +323,21 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
324
323
|
this.action.initialize(grid, seed);
|
|
325
324
|
});
|
|
326
325
|
|
|
326
|
+
/*
|
|
327
|
+
we break the entire region into smaller tiles (16x16)
|
|
328
|
+
this puts an upper bound of sorts on how many samples we have to take, irrespective of actual grid size
|
|
329
|
+
these tiles also give us something closer to blue noise distribution
|
|
330
|
+
The assumption with which the tile size was chosen is average marker size of ~1
|
|
331
|
+
Actual tile size was tweaked using empirical tests
|
|
332
|
+
*/
|
|
327
333
|
|
|
328
334
|
for (let j = 0; j < grid.height; j += tile_size) {
|
|
335
|
+
|
|
329
336
|
const y0 = j;
|
|
330
337
|
const y1 = min2(grid.height, j + tile_size);
|
|
331
338
|
|
|
332
339
|
for (let i = 0; i < grid.width; i += tile_size) {
|
|
340
|
+
|
|
333
341
|
const x0 = i;
|
|
334
342
|
const x1 = min2(grid.width, i + tile_size);
|
|
335
343
|
|
|
@@ -343,7 +351,7 @@ export class GridTaskDensityMarkerDistribution extends GridTaskGenerator {
|
|
|
343
351
|
}
|
|
344
352
|
}
|
|
345
353
|
|
|
346
|
-
//build a random dependency chain to ensure that tiles are not processed in parallel, thus crating race
|
|
354
|
+
// build a random dependency chain to ensure that tiles are not processed in parallel, thus crating race conditions and leading to non-deterministic result
|
|
347
355
|
const iteratorRandom = new ArrayIteratorRandom();
|
|
348
356
|
iteratorRandom.initialize(tasks);
|
|
349
357
|
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export class ModifyPatchSampler2DAction extends Action<any> {
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {Sampler2D} sampler
|
|
5
|
-
* @param {number[]} bounds
|
|
6
|
-
*/
|
|
7
|
-
constructor(sampler: Sampler2D, bounds: number[]);
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @type {Sampler2D}
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
private __sampler;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @type {number[]}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private __bounds;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @type {Sampler2D}
|
|
23
|
-
*/
|
|
24
|
-
__patch_new: Sampler2D;
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @type {Sampler2D}
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private __patch_old;
|
|
31
|
-
get patch(): Sampler2D;
|
|
32
|
-
get x(): number;
|
|
33
|
-
get y(): number;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {number} x coordinate in global space
|
|
37
|
-
* @param {number} y coordinate in global space
|
|
38
|
-
* @param {number} [channel]
|
|
39
|
-
* @returns {number} delta between original value and the new one after the change
|
|
40
|
-
*/
|
|
41
|
-
computeDelta(x: number, y: number, channel?: number): number;
|
|
42
|
-
computeByteSize(): any;
|
|
43
|
-
apply(context: any): Promise<void>;
|
|
44
|
-
revert(context: any): Promise<void>;
|
|
45
|
-
}
|
|
46
|
-
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
47
|
-
import { Sampler2D } from "../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
48
|
-
//# sourceMappingURL=ModifyPatchSampler2DAction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModifyPatchTextureArray2DAction.d.ts","sourceRoot":"","sources":["ModifyPatchTextureArray2DAction.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,kBAJW,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,YAAY,mBAC5C,MAAM,EAAE,UACR,MAAM,EAAE,EA6BlB;IAtBG,2DAAkB;IAClB,4BAAwC;IACxC,mBAAsB;IAUtB;;;OAGG;IACH,oBAAmD;IACnD;;;OAGG;IACH,oBAAmD;IAGvD;;;;;;;;;OASG;IACH,kCARW,MAAM,YACN,MAAM,iCAEN,MAAM,UACN,MAAM,cACN,MAAM,cACN,MAAM,QAiEhB;IAED,oCAEC;IAOD,mCA8BC;IAED,oCAuBC;CACJ;uBArLsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PaintTerrainOverlayAction.d.ts","sourceRoot":"","sources":["PaintTerrainOverlayAction.js"],"names":[],"mappings":";AAIA;IACI;;;;;;;OAOG;IACH,oBANW,MAAM,KACN,MAAM,KACN,MAAM,SACN,OAAO,EAYjB;IAPG,eAAoB;IACpB,UAAU;IACV,UAAU;IACV,eAAkB;IAElB,aAAmB;IACnB,kBAA6B;IAGjC,kCASC;IAED,mCAKC;CACJ;uBAxCsB,0CAA0C;oBAD7C,mCAAmC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PatchTerrainHeightAction.d.ts","sourceRoot":"","sources":["PatchTerrainHeightAction.js"],"names":[],"mappings":"AAEA;IACI;;;;;;;OAOG;IACH,iCALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,EAUhB;IALG;;;OAGG;IACH,iBAAsB;IAG1B,+BAgCC;CAaJ;2CAlE0C,iCAAiC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionAddAction.d.ts","sourceRoot":"","sources":["SelectionAddAction.js"],"names":[],"mappings":";AAGA;IACI;;;;OAIG;IACH,sBAHW,KAAK,EAWf;IANG,cAAoB;IACpB;;;OAGG;IACH,UAFU,KAAK,CAES;IAG5B,kCAMC;IAED,mCAEC;CACJ;uBA9BsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionClearAction.d.ts","sourceRoot":"","sources":["SelectionClearAction.js"],"names":[],"mappings":";AAEA;IACI,cAGC;IADG,cAAoB;IAGxB,kCAGC;IAED,mCAEC;CACJ;uBAhBsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionRemoveAction.d.ts","sourceRoot":"","sources":["SelectionRemoveAction.js"],"names":[],"mappings":";AAEA;IACI,2BAIC;IAFG,cAAoB;IACpB,cAAwB;IAG5B,kCAUC;IAED,mCAEC;CACJ;uBAxBsB,0CAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransformModifyAction.d.ts","sourceRoot":"","sources":["TransformModifyAction.js"],"names":[],"mappings":";AAGA;IACI;;;;;OAKG;IACH,mCAHW,SAAS,EASnB;IAHG,cAAoB;IACpB,oBAAwB;IACxB,YAAoB;IAqBxB,mCAMC;CACJ;uBA1CsB,0CAA0C;0BADvC,gDAAgD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WriteGridValueAction.d.ts","sourceRoot":"","sources":["WriteGridValueAction.js"],"names":[],"mappings":";AAGA;IACI,qDAUC;IAPG,YAAoB;IACpB,OAAU;IACV,OAAU;IACV,WAAkB;IAElB,uBAAoB;IACpB,iBAAoB;IAGxB,kCAgBC;IAED,mCAGC;CACJ;uBArCsB,0CAA0C;yBADxC,mDAAmD"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {EntityComponentDataset} ecd
|
|
4
|
-
* @param {number} entity
|
|
5
|
-
* @returns {EntityReference}
|
|
6
|
-
*/
|
|
7
|
-
export function read_entity_reference(ecd: EntityComponentDataset, entity: number): EntityReference;
|
|
8
|
-
import { EntityReference } from "./EntityReference.js";
|
|
9
|
-
//# sourceMappingURL=read_entity_reference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read_entity_reference.d.ts","sourceRoot":"","sources":["../../../../src/engine/ecs/read_entity_reference.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,sBAAsB,UACtB,MAAM,GACJ,eAAe,CAQ3B;gCAd+B,sBAAsB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { EntityReference } from "./EntityReference.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {EntityComponentDataset} ecd
|
|
6
|
-
* @param {number} entity
|
|
7
|
-
* @returns {EntityReference}
|
|
8
|
-
*/
|
|
9
|
-
export function read_entity_reference(ecd, entity) {
|
|
10
|
-
|
|
11
|
-
const generation = ecd.getEntityGeneration(entity);
|
|
12
|
-
|
|
13
|
-
return EntityReference.from(entity, generation);
|
|
14
|
-
|
|
15
|
-
}
|