@woosh/meep-engine 2.120.0 → 2.120.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/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/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/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/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/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
|
@@ -21,7 +21,11 @@ const scratch_matrix = new Float32Array(16);
|
|
|
21
21
|
const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* A Transform represents the position, rotation, and scale of an object in 3D space.
|
|
25
|
+
* Think of it like the object's location, orientation, and size.
|
|
26
|
+
* It has properties for position (like coordinates), rotation (how it's turned), and scale (how big it is).
|
|
27
|
+
*
|
|
28
|
+
* It also uses a "matrix" (a table of numbers) internally to efficiently store and calculate transformations, but you usually interact with the position, rotation, and scale directly.
|
|
25
29
|
* @class
|
|
26
30
|
*/
|
|
27
31
|
export class Transform {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cascading blackboard interface. Allows composition of multiple blackboard to be used to represent a single whole
|
|
3
|
-
*
|
|
3
|
+
* The access is always done from top to bottom. If a value is not found at the top of the stack, a lower slot will be considered until the end. In which case value will be created in the blackboard identified by "write_slot"
|
|
4
4
|
*/
|
|
5
5
|
export class BlackboardStack extends AbstractBlackboard {
|
|
6
6
|
/**
|
|
@@ -2,7 +2,7 @@ import { AbstractBlackboard } from "./AbstractBlackboard.js";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Cascading blackboard interface. Allows composition of multiple blackboard to be used to represent a single whole
|
|
5
|
-
*
|
|
5
|
+
* The access is always done from top to bottom. If a value is not found at the top of the stack, a lower slot will be considered until the end. In which case value will be created in the blackboard identified by "write_slot"
|
|
6
6
|
*/
|
|
7
7
|
export class BlackboardStack extends AbstractBlackboard {
|
|
8
8
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathFollowerSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,2BAAqB;IAGrB;;;;OAIG;IACH,kBAHW,YAAY,SACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"PathFollowerSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,2BAAqB;IAGrB;;;;OAIG;IACH,kBAHW,YAAY,SACZ,YAAY,QAUtB;IAED;;;;OAIG;IACH,oBAHW,YAAY,SACZ,YAAY,QAUtB;CACJ;gDArC+C,gEAAgE;yBACvF,mBAAmB"}
|
|
@@ -4,7 +4,7 @@ import PathFollower from "./PathFollower.js";
|
|
|
4
4
|
export class PathFollowerSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
5
|
|
|
6
6
|
klass = PathFollower;
|
|
7
|
-
version =
|
|
7
|
+
version = 4;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -18,6 +18,7 @@ export class PathFollowerSerializationAdapter extends BinaryClassSerializationAd
|
|
|
18
18
|
buffer.writeFloat32(value.rotationSpeed.getValue());
|
|
19
19
|
|
|
20
20
|
buffer.writeFloat32(value.maxMoveDistance);
|
|
21
|
+
buffer.writeFloat32(value.position); // Serialize position
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -32,5 +33,6 @@ export class PathFollowerSerializationAdapter extends BinaryClassSerializationAd
|
|
|
32
33
|
value.rotationSpeed.set(buffer.readFloat32());
|
|
33
34
|
|
|
34
35
|
value.maxMoveDistance = buffer.readFloat32();
|
|
36
|
+
value.position = buffer.readFloat32(); // Deserialize position
|
|
35
37
|
}
|
|
36
38
|
}
|
package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathFollowerSerializationUpgrader_2_3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.js"],"names":[],"mappings":"AAGA;
|
|
1
|
+
{"version":3,"file":"PathFollowerSerializationUpgrader_2_3.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.js"],"names":[],"mappings":"AAGA;IAII,wCAWC;CACJ;oCAlBmC,oDAAoD"}
|
|
@@ -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(
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import Quaternion from '../../../core/geom/Quaternion.js';
|
|
2
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} options
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
const Body = function (options) {
|
|
10
|
-
if (!options) {
|
|
11
|
-
options = {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
this.id = -1;
|
|
15
|
-
|
|
16
|
-
this.shape = options.shape || null;
|
|
17
|
-
this.position = new Vector3();
|
|
18
|
-
this.rotation = new Quaternion();
|
|
19
|
-
this.linearVelocity = new Vector3();
|
|
20
|
-
if (options.position !== void 0) {
|
|
21
|
-
this.position.copy(options.position);
|
|
22
|
-
}
|
|
23
|
-
if (options.rotation !== void 0) {
|
|
24
|
-
this.rotation.copy(options.rotation);
|
|
25
|
-
}
|
|
26
|
-
if (options.linearVelocity !== void 0) {
|
|
27
|
-
this.linearVelocity.copy(options.linearVelocity);
|
|
28
|
-
}
|
|
29
|
-
this.angularFactor = options.angularFactor || new Vector3(1, 1, 1);
|
|
30
|
-
this.mass = options.mass || 0;
|
|
31
|
-
this.friction = options.friction || 0;
|
|
32
|
-
this.disableGravity = options.disableGravity || false;
|
|
33
|
-
this.disableCollisionResponse = options.disableCollisionResponse || false;
|
|
34
|
-
//
|
|
35
|
-
const self = this;
|
|
36
|
-
this.changedAttributes = [];
|
|
37
|
-
[
|
|
38
|
-
"position",
|
|
39
|
-
"rotation",
|
|
40
|
-
"linearVelocity"
|
|
41
|
-
].forEach(function (prop) {
|
|
42
|
-
|
|
43
|
-
this[prop].onChange.add(function () {
|
|
44
|
-
self.changedAttributes.push(prop);
|
|
45
|
-
});
|
|
46
|
-
}, this);
|
|
47
|
-
|
|
48
|
-
//callbacks
|
|
49
|
-
this.__callbacksChange = [];
|
|
50
|
-
this.__callbacksCollision = [];
|
|
51
|
-
//central impulse
|
|
52
|
-
this.__centralImpulse = null;
|
|
53
|
-
//Collision contacts
|
|
54
|
-
this.__contacts = [];
|
|
55
|
-
};
|
|
56
|
-
Body.prototype.getContacts = function () {
|
|
57
|
-
return this.__contacts;
|
|
58
|
-
};
|
|
59
|
-
Body.prototype.onChange = function (f) {
|
|
60
|
-
this.__callbacksChange.push(f);
|
|
61
|
-
};
|
|
62
|
-
Body.prototype.update = function (newPosition, newRotation, newLinearVelocity) {
|
|
63
|
-
let hasChanged = false;
|
|
64
|
-
const position = this.position;
|
|
65
|
-
if (position.x !== newPosition.x || position.y !== newPosition.y || position.z !== newPosition.z) {
|
|
66
|
-
position.set(newPosition.x, newPosition.y, newPosition.z);
|
|
67
|
-
hasChanged = true;
|
|
68
|
-
}
|
|
69
|
-
const rotation = this.rotation;
|
|
70
|
-
if (rotation.x !== newRotation.x || rotation.y !== newRotation.y || rotation.z !== newRotation.z || rotation.w !== newRotation.w) {
|
|
71
|
-
rotation.set(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
|
|
72
|
-
hasChanged = true;
|
|
73
|
-
}
|
|
74
|
-
const linearVelocity = this.linearVelocity;
|
|
75
|
-
if (linearVelocity.x !== newLinearVelocity.x || linearVelocity.y !== newLinearVelocity.y || linearVelocity.z !== newLinearVelocity.z) {
|
|
76
|
-
linearVelocity.copy(newLinearVelocity);
|
|
77
|
-
}
|
|
78
|
-
if (hasChanged) {
|
|
79
|
-
//execute callbacks
|
|
80
|
-
this.__callbacksChange.forEach(function (callback) {
|
|
81
|
-
callback();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
Body.prototype.applyCentralImpulse = function (force) {
|
|
86
|
-
|
|
87
|
-
if (this.__centralImpulse) {
|
|
88
|
-
this.__centralImpulse.add(force);
|
|
89
|
-
} else {
|
|
90
|
-
//impulse not defined
|
|
91
|
-
this.__centralImpulse = new Vector3(force.x, force.y, force.z);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
Body.prototype.onCollision = function (f) {
|
|
95
|
-
this.__callbacksCollision.push(f);
|
|
96
|
-
};
|
|
97
|
-
Body.prototype.collide = function (otherBody) {
|
|
98
|
-
this.__callbacksCollision.forEach(function (callback) {
|
|
99
|
-
callback(otherBody);
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
export default Body;
|
|
103
|
-
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
declare function registerCollision(body1: any, body2: any, contactPoint: any): void;
|
|
2
|
-
declare function getElementByTowersId(id: any, collection: any): any;
|
|
3
|
-
declare function getShapeById(id: any): any;
|
|
4
|
-
declare function getBodyById(id: any): any;
|
|
5
|
-
declare function btVector3ToJSON(vector: any): {
|
|
6
|
-
x: any;
|
|
7
|
-
y: any;
|
|
8
|
-
z: any;
|
|
9
|
-
};
|
|
10
|
-
declare function write_btVector3(ptr: any, value: any): void;
|
|
11
|
-
declare function write_btVector4(ptr: any, value: any): void;
|
|
12
|
-
declare function btQuaternionToJSON(q: any): {
|
|
13
|
-
x: any;
|
|
14
|
-
y: any;
|
|
15
|
-
z: any;
|
|
16
|
-
w: any;
|
|
17
|
-
};
|
|
18
|
-
declare function make_btVector3(json: any): any;
|
|
19
|
-
declare function make_btQuaternion(json: any): any;
|
|
20
|
-
declare function threeGeometryTobtTriangleMesh(geometry: any): any;
|
|
21
|
-
/**
|
|
22
|
-
* This will be called every simulation tick, including sub-steps. Collision detection is done inside this function
|
|
23
|
-
* @param world
|
|
24
|
-
* @param timeStep
|
|
25
|
-
*/
|
|
26
|
-
declare function simulationTickCallback(world: any, timeStep: any): void;
|
|
27
|
-
declare function sendCollisions(): void;
|
|
28
|
-
declare namespace Module {
|
|
29
|
-
let TOTAL_MEMORY: number;
|
|
30
|
-
let ALLOW_MEMORY_GROWTH: number;
|
|
31
|
-
}
|
|
32
|
-
declare namespace btRigidBodyFlags {
|
|
33
|
-
let BT_DISABLE_WORLD_GRAVITY: number;
|
|
34
|
-
let BT_ENABLE_GYROPSCOPIC_FORCE: number;
|
|
35
|
-
}
|
|
36
|
-
declare namespace CollisionFlags {
|
|
37
|
-
let CF_STATIC_OBJECT: number;
|
|
38
|
-
let CF_KINEMATIC_OBJECT: number;
|
|
39
|
-
let CF_NO_CONTACT_RESPONSE: number;
|
|
40
|
-
let CF_CUSTOM_MATERIAL_CALLBACK: number;
|
|
41
|
-
let CF_CHARACTER_OBJECT: number;
|
|
42
|
-
let CF_DISABLE_VISUALIZE_OBJECT: number;
|
|
43
|
-
let CF_DISABLE_SPU_COLLISION_PROCESSING: number;
|
|
44
|
-
}
|
|
45
|
-
declare const broadphase: any;
|
|
46
|
-
declare const collisionConfiguration: any;
|
|
47
|
-
declare const dispatcher: any;
|
|
48
|
-
declare const solver: any;
|
|
49
|
-
declare const dynamicsWorld: any;
|
|
50
|
-
declare const globalGravity: any;
|
|
51
|
-
declare const simulationTickCallbackPointer: any;
|
|
52
|
-
declare const bodies: any[];
|
|
53
|
-
declare const shapes: any[];
|
|
54
|
-
declare const transform: any;
|
|
55
|
-
/**
|
|
56
|
-
* @type {Array<Array>}
|
|
57
|
-
*/
|
|
58
|
-
declare const collisions: Array<any[]>;
|
|
59
|
-
declare let simulationStepInProgress: boolean;
|
|
60
|
-
declare namespace api {
|
|
61
|
-
function addShape(options: any): void;
|
|
62
|
-
function addBody(options: any): void;
|
|
63
|
-
function removeBody(options: any): void;
|
|
64
|
-
function writeBodyAttributes(options: any): void;
|
|
65
|
-
function rayTest(options: any): void;
|
|
66
|
-
function rayCast(options: any): void;
|
|
67
|
-
function simulate(delta: any): void;
|
|
68
|
-
function applyCentralImpulse(data: any): void;
|
|
69
|
-
}
|
|
70
|
-
declare const raytest_from: any;
|
|
71
|
-
declare const raytest_to: any;
|
|
72
|
-
//# sourceMappingURL=PhysicsWorker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsWorker.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/ammo/PhysicsWorker.js"],"names":[],"mappings":"AAsDA,oFAoBC;AAED,qEASC;AAED,4CAGC;AAED,2CAGC;AAED;;;;EAOC;AAED,6DAIC;AAED,6DAKC;AAED;;;;;EAQC;AAED,gDAGC;AAED,mDAGC;AAED,mEAeC;AAED;;;;GAIG;AACH,yEAyBC;AA0KD,wCAaC;;;;;;;;;;;;;;;;;;AAxVD,8BAA+C;AAG/C,0CAA0E;AAC1E,8BAA0E;AAG1E,0BAA8D;AAG9D,iCAA+G;AAC/G,iCAAoD;AAIpD,iDAAuF;AAKvF,4BAAkB;AAClB,4BAAkB;AAClB,6BAAyC;AACzC;;GAEG;AACH,0BAFU,KAAK,OAAO,CAEA;AACtB,8CAAqC;;IAyIrC,sCA6BC;IACD,qCAgDC;IACD,wCAMC;IACD,iDAqCC;IAID,qCAgBC;IACD,qCAqBC;IAiBD,oCA2CC;IACD,8CAUC;;AA/GK,gCAA0C;AAC5C,8BAAwC"}
|