@gg-web-engine/matter 0.0.63 → 0.0.65
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.
|
@@ -25,7 +25,7 @@ export declare class MatterRigidBodyComponent implements IRigidBody2dComponent<M
|
|
|
25
25
|
protected updateCollisionFilter(): void;
|
|
26
26
|
clone(): MatterRigidBodyComponent;
|
|
27
27
|
addToWorld(world: MatterGgWorld): void;
|
|
28
|
-
removeFromWorld(world: MatterGgWorld): void;
|
|
28
|
+
removeFromWorld(world: MatterGgWorld, dispose?: boolean): void;
|
|
29
29
|
dispose(): void;
|
|
30
30
|
resetMotion(): void;
|
|
31
31
|
}
|
|
@@ -85,10 +85,17 @@ export class MatterRigidBodyComponent {
|
|
|
85
85
|
Composite.add(world.physicsWorld.matterWorld, this.nativeBody);
|
|
86
86
|
world.physicsWorld.added$.next(this);
|
|
87
87
|
}
|
|
88
|
-
removeFromWorld(world) {
|
|
88
|
+
removeFromWorld(world, dispose = false) {
|
|
89
89
|
Composite.remove(world.physicsWorld.matterWorld, this.nativeBody);
|
|
90
90
|
world.physicsWorld.removed$.next(this);
|
|
91
|
+
if (dispose) {
|
|
92
|
+
this.dispose();
|
|
93
|
+
}
|
|
91
94
|
}
|
|
95
|
+
// matter.js bodies are plain JS objects with no native/WASM handle - ordinary GC reclaims them
|
|
96
|
+
// once `Composite.remove` above drops the engine's own reference, so there's nothing to free here
|
|
97
|
+
// at this level. `MatterTriggerComponent` overrides this to complete its own RxJS subjects, which
|
|
98
|
+
// *do* need an explicit dispose.
|
|
92
99
|
dispose() { }
|
|
93
100
|
resetMotion() {
|
|
94
101
|
Body.setVelocity(this.nativeBody, Pnt2.O);
|
|
@@ -18,7 +18,10 @@ export declare class MatterTriggerComponent extends MatterRigidBodyComponent imp
|
|
|
18
18
|
private onCollisionEnd;
|
|
19
19
|
constructor(nativeBody: Body, shape: Shape2DDescriptor, world: MatterWorldComponent);
|
|
20
20
|
addToWorld(world: MatterGgWorld): void;
|
|
21
|
-
removeFromWorld(world: MatterGgWorld): void;
|
|
21
|
+
removeFromWorld(world: MatterGgWorld, dispose?: boolean): void;
|
|
22
|
+
/** Completes `onEnter$`/`onLeft$` - `MatterRigidBodyComponent.dispose()` is a no-op (see its own
|
|
23
|
+
* doc), so this is the only place these two subjects ever get completed. */
|
|
24
|
+
dispose(): void;
|
|
22
25
|
checkOverlaps(): void;
|
|
23
26
|
clone(): MatterTriggerComponent;
|
|
24
27
|
}
|
|
@@ -74,14 +74,21 @@ export class MatterTriggerComponent extends MatterRigidBodyComponent {
|
|
|
74
74
|
Events.on(world.physicsWorld.matterEngine, 'collisionStart', this.onCollisionStart);
|
|
75
75
|
Events.on(world.physicsWorld.matterEngine, 'collisionEnd', this.onCollisionEnd);
|
|
76
76
|
}
|
|
77
|
-
removeFromWorld(world) {
|
|
77
|
+
removeFromWorld(world, dispose) {
|
|
78
78
|
Events.off(world.physicsWorld.matterEngine, 'collisionStart', this.onCollisionStart);
|
|
79
79
|
Events.off(world.physicsWorld.matterEngine, 'collisionEnd', this.onCollisionEnd);
|
|
80
80
|
for (const body of this.currentOverlaps) {
|
|
81
81
|
this.onLeft$.next(body);
|
|
82
82
|
}
|
|
83
83
|
this.currentOverlaps.clear();
|
|
84
|
-
super.removeFromWorld(world);
|
|
84
|
+
super.removeFromWorld(world, dispose);
|
|
85
|
+
}
|
|
86
|
+
/** Completes `onEnter$`/`onLeft$` - `MatterRigidBodyComponent.dispose()` is a no-op (see its own
|
|
87
|
+
* doc), so this is the only place these two subjects ever get completed. */
|
|
88
|
+
dispose() {
|
|
89
|
+
this.onEnter$.complete();
|
|
90
|
+
this.onLeft$.complete();
|
|
91
|
+
super.dispose();
|
|
85
92
|
}
|
|
86
93
|
checkOverlaps() {
|
|
87
94
|
// do nothing, for matter.js we handle this differently
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/matter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"description": "An attempt to create open source game engine for browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/matter-js": "0.20.2",
|
|
33
|
-
"@gg-web-engine/core": "0.0.
|
|
33
|
+
"@gg-web-engine/core": "0.0.65",
|
|
34
34
|
"@types/jest": "^30.0.0",
|
|
35
35
|
"@types/node": "^26.4.0",
|
|
36
36
|
"jest": "^30.5.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"typescript": "~6.0.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@gg-web-engine/core": "0.0.
|
|
45
|
+
"@gg-web-engine/core": "0.0.65",
|
|
46
46
|
"matter-js": "0.20.0",
|
|
47
47
|
"rxjs": "7.8.2"
|
|
48
48
|
},
|