matrix-engine-wgpu 1.2.9 → 1.2.11
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/package.json +1 -1
- package/src/physics/matrix-ammo.js +23 -0
- package/src/world.js +3 -3
package/package.json
CHANGED
|
@@ -196,6 +196,29 @@ export default class MatrixAmmo {
|
|
|
196
196
|
return b;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
deactivatePhysics(body) {
|
|
200
|
+
const CF_KINEMATIC_OBJECT = 2;
|
|
201
|
+
const DISABLE_DEACTIVATION = 4;
|
|
202
|
+
// 1. Remove from world
|
|
203
|
+
this.dynamicsWorld.removeRigidBody(body);
|
|
204
|
+
// 2. Set body to kinematic
|
|
205
|
+
const flags = body.getCollisionFlags();
|
|
206
|
+
body.setCollisionFlags(flags | CF_KINEMATIC_OBJECT);
|
|
207
|
+
body.setActivationState(DISABLE_DEACTIVATION); // no auto-wakeup
|
|
208
|
+
// 3. Clear motion
|
|
209
|
+
const zero = new Ammo.btVector3(0, 0, 0);
|
|
210
|
+
body.setLinearVelocity(zero);
|
|
211
|
+
body.setAngularVelocity(zero);
|
|
212
|
+
// 4. Reset transform to current position (optional — preserves pose)
|
|
213
|
+
const currentTransform = body.getWorldTransform();
|
|
214
|
+
body.setWorldTransform(currentTransform);
|
|
215
|
+
body.getMotionState().setWorldTransform(currentTransform);
|
|
216
|
+
// 5. Add back to physics world
|
|
217
|
+
this.matrixAmmo.dynamicsWorld.addRigidBody(body);
|
|
218
|
+
// 6. Mark it manually (logic flag)
|
|
219
|
+
body.isKinematic = true;
|
|
220
|
+
}
|
|
221
|
+
|
|
199
222
|
detectCollision() {
|
|
200
223
|
console.log('override this')
|
|
201
224
|
return;
|
package/src/world.js
CHANGED
|
@@ -51,6 +51,8 @@ export default class MatrixEngineWGPU {
|
|
|
51
51
|
|
|
52
52
|
this.mainCameraParams = options.mainCameraParams;
|
|
53
53
|
|
|
54
|
+
const target = this.options.appendTo || document.body;
|
|
55
|
+
|
|
54
56
|
var canvas = document.createElement('canvas')
|
|
55
57
|
if(this.options.canvasSize == 'fullscreen') {
|
|
56
58
|
canvas.width = window.innerWidth;
|
|
@@ -59,7 +61,7 @@ export default class MatrixEngineWGPU {
|
|
|
59
61
|
canvas.width = this.options.canvasSize.w;
|
|
60
62
|
canvas.height = this.options.canvasSize.h;
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
target.append(canvas);
|
|
63
65
|
|
|
64
66
|
// The camera types
|
|
65
67
|
const initialCameraPosition = vec3.create(0, 0, 0);
|
|
@@ -280,8 +282,6 @@ export default class MatrixEngineWGPU {
|
|
|
280
282
|
if(typeof o.physics.name === 'undefined') {o.physics.name = o.name;}
|
|
281
283
|
if(typeof o.physics.scale === 'undefined') {o.physics.scale = o.scale;}
|
|
282
284
|
if(typeof o.physics.rotation === 'undefined') {o.physics.rotation = o.rotation;}
|
|
283
|
-
|
|
284
|
-
// send same pos
|
|
285
285
|
o.physics.position = o.position;
|
|
286
286
|
// console.log('Mesh procedure', o)
|
|
287
287
|
let myMesh1 = new MEMeshObj(this.canvas, this.device, this.context, o)
|