@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
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import Vector3 from '../../core/geom/Vector3';
|
|
2
|
-
import PhysicalBody from '../../engine/ecs/components/PhysicalBody';
|
|
3
|
-
import Transform from '../../engine/ecs/components/Transform';
|
|
4
|
-
import { System } from '../../engine/ecs/System';
|
|
5
|
-
import Cannon from './cannon.min.js'; //TODO replace with package import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class CannonPhysicsSystem extends System {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
|
|
12
|
-
this.dependencies = [PhysicalBody];
|
|
13
|
-
this.entityManager = null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
startup(entityManager, readyCallback, errorCallback) {
|
|
17
|
-
this.entityManager = entityManager;
|
|
18
|
-
const world = this.world = new Cannon.World();
|
|
19
|
-
world.gravity.set(0, -30, 0);
|
|
20
|
-
world.broadphase = new Cannon.NaiveBroadphase();
|
|
21
|
-
world.solver.iterations = 3;
|
|
22
|
-
this.bodies = [];
|
|
23
|
-
this.delayRemove = false;
|
|
24
|
-
this.defferredRemoveBodies = [];
|
|
25
|
-
this.materials = [];
|
|
26
|
-
readyCallback();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
add(component, entity) {
|
|
30
|
-
const em = this.entityManager;
|
|
31
|
-
//make a shape
|
|
32
|
-
const shape = createShape(component.shape);
|
|
33
|
-
const body = new Cannon.Body({
|
|
34
|
-
mass: component.mass,
|
|
35
|
-
position: new Cannon.Vec3(0, 0, 0)
|
|
36
|
-
});
|
|
37
|
-
body.collisionResponse = component.collisionResponse;
|
|
38
|
-
body.angularDamping = 0;
|
|
39
|
-
body.linearDamping = component.linearDamping;
|
|
40
|
-
body.addShape(shape);
|
|
41
|
-
body.entity = entity;
|
|
42
|
-
if (component.rotationAxis.x === false && component.rotationAxis.y === false && component.rotationAxis.z === false) {
|
|
43
|
-
//lock rotation
|
|
44
|
-
body.fixedRotation = true;
|
|
45
|
-
body.updateMassProperties();
|
|
46
|
-
}
|
|
47
|
-
this.bodies[entity] = body;
|
|
48
|
-
const world = this.world;
|
|
49
|
-
em.getComponentAsync(entity, Transform, function (t) {
|
|
50
|
-
const p = t.global.position;
|
|
51
|
-
body.position.set(p.x, p.y, p.z);
|
|
52
|
-
body.initPosition.set(p.x, p.y, p.z);
|
|
53
|
-
world.add(body);
|
|
54
|
-
});
|
|
55
|
-
//watch component and update body
|
|
56
|
-
const handlers = body.entityEventHandlers = {
|
|
57
|
-
velocity: function (x, y, z) {
|
|
58
|
-
body.velocity.set(x, y, z);
|
|
59
|
-
},
|
|
60
|
-
angularVelocity: function (x, y, z) {
|
|
61
|
-
body.angularVelocity.set(x, y, z);
|
|
62
|
-
},
|
|
63
|
-
collision: function (evt) {
|
|
64
|
-
const body = evt.body;
|
|
65
|
-
const contact = evt.contact;
|
|
66
|
-
collisionPoint.copy(contact.bi.position).add(contact.ri);
|
|
67
|
-
em.sendEvent(entity, "collision", { entity: body.entity, point: collisionPoint });
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
body.addEventListener("collide", handlers.collision);
|
|
71
|
-
//
|
|
72
|
-
component.velocity.onChanged.add(handlers.velocity);
|
|
73
|
-
component.angularVelocity.onChanged.add(handlers.angularVelocity);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
remove(component, entity) {
|
|
77
|
-
const body = this.bodies[entity];
|
|
78
|
-
if (body === undefined) {
|
|
79
|
-
//trying to remove something that isn't registered
|
|
80
|
-
console.warn("Entity " + entity + " was not found.");
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
//handlers
|
|
84
|
-
const handlers = body.entityEventHandlers;
|
|
85
|
-
component.velocity.onChanged.remove(handlers.velocity);
|
|
86
|
-
component.angularVelocity.onChanged.remove(handlers.angularVelocity);
|
|
87
|
-
body.removeEventListener("collide", handlers.collision);
|
|
88
|
-
//
|
|
89
|
-
if (this.delayRemove) {
|
|
90
|
-
this.defferredRemoveBodies.push(body);
|
|
91
|
-
} else {
|
|
92
|
-
this.world.remove(body);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
update(timeDelta) {
|
|
97
|
-
const bodies = this.bodies;
|
|
98
|
-
const em = this.entityManager;
|
|
99
|
-
em.traverseEntities([PhysicalBody, Transform], function (pb, transform, entity) {
|
|
100
|
-
const body = bodies[entity];
|
|
101
|
-
body.angularVelocity.copy(pb.angularVelocity);
|
|
102
|
-
body.velocity.copy(pb.velocity);
|
|
103
|
-
//
|
|
104
|
-
//record old inertia
|
|
105
|
-
body.position.copy(transform.position);
|
|
106
|
-
body.quaternion.copy(transform.rotation);
|
|
107
|
-
});
|
|
108
|
-
this.delayRemove = true;
|
|
109
|
-
const world = this.world;
|
|
110
|
-
if (timeDelta <= 0) {
|
|
111
|
-
//time delta not supported, return without doing simulation
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
world.step(timeDelta, timeDelta, 5);
|
|
115
|
-
this.delayRemove = false;
|
|
116
|
-
if (this.defferredRemoveBodies.length !== 0) {
|
|
117
|
-
this.defferredRemoveBodies.forEach(function (body) {
|
|
118
|
-
world.remove(body);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
//write body parameters back
|
|
122
|
-
world.bodies.forEach(function (body) {
|
|
123
|
-
if (body.sleepState === Cannon.Body.SLEEPING) {
|
|
124
|
-
//ignore sleeping bodies
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const entity = body.entity;
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
const pb = em.getComponent(entity, PhysicalBody);
|
|
131
|
-
const transform = em.getComponent(entity, Transform);
|
|
132
|
-
//
|
|
133
|
-
pb.velocity.copy(body.velocity);
|
|
134
|
-
pb.angularVelocity.copy(body.angularVelocity);
|
|
135
|
-
if (!pb.angularVelocity.isZero() && quaternionsEqual(body.quaternion, transform.rotation)) {
|
|
136
|
-
//this is an override to cannon not applying angular velocity to bodies of mass 0
|
|
137
|
-
const av = pb.angularVelocity;
|
|
138
|
-
tempQuaternion.setFromEuler(av.x * timeDelta, av.y * timeDelta, av.z * timeDelta, "XYZ");
|
|
139
|
-
body.quaternion.mult(tempQuaternion, body.quaternion);
|
|
140
|
-
}
|
|
141
|
-
transform.position.copy(body.position);
|
|
142
|
-
transform.rotation.copy(body.quaternion);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
function createShape(desc) {
|
|
150
|
-
let result = void 0;
|
|
151
|
-
switch (desc.type) {
|
|
152
|
-
case "sphere":
|
|
153
|
-
result = new Cannon.Sphere(desc.radius);
|
|
154
|
-
break;
|
|
155
|
-
case "box":
|
|
156
|
-
const size = desc.size;
|
|
157
|
-
result = new Cannon.Box(new Cannon.Vec3(size.x / 2, size.y / 2, size.z / 2));
|
|
158
|
-
size.onChanged.add(function (newValue) {
|
|
159
|
-
result.halfExtents.set(size.x / 2, size.y / 2, size.z / 2);
|
|
160
|
-
});
|
|
161
|
-
result.updateConvexPolyhedronRepresentation();
|
|
162
|
-
result.updateBoundingSphereRadius();
|
|
163
|
-
break;
|
|
164
|
-
default :
|
|
165
|
-
console.error("unsupported shape type " + desc.type);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
return result;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function obtainMaterial(existing, options) {
|
|
172
|
-
let i = 0;
|
|
173
|
-
const l = existing.length;
|
|
174
|
-
for (; i < l; i++) {
|
|
175
|
-
const m = existing[i];
|
|
176
|
-
const match = false;
|
|
177
|
-
for (let j in options) {
|
|
178
|
-
if (options.hasOwnProperty(j) && options[j] !== m[j]) {
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (match) {
|
|
183
|
-
return m;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const collisionPoint = new Vector3();
|
|
189
|
-
|
|
190
|
-
function quaternionsEqual(q0, q1) {
|
|
191
|
-
return q0.x === q1.x && q0.y === q1.y && q0.z === q1.z && q0.w === q1.w;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const tempQuaternion = new Cannon.Quaternion();
|
|
195
|
-
|
|
196
|
-
export default CannonPhysicsSystem;
|