@gg-web-engine/matter 0.0.28 → 0.0.30
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/dist/components/matter-rigid-body.component.d.ts +10 -5
- package/dist/components/matter-rigid-body.component.js +13 -1
- package/dist/components/matter-world.component.d.ts +5 -2
- package/dist/components/matter-world.component.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/matter-factory.d.ts +3 -2
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +3 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Entity2d, Gg2dWorld, IRigidBody2dComponent, IVisualScene2dComponent, Point2 } from '@gg-web-engine/core';
|
|
2
|
-
import { MatterWorldComponent } from './matter-world.component';
|
|
1
|
+
import { CollisionGroup, Entity2d, Gg2dWorld, IRigidBody2dComponent, IVisualScene2dComponent, Point2, VisualTypeDocRepo2D } from '@gg-web-engine/core';
|
|
3
2
|
import { Body } from 'matter-js';
|
|
4
|
-
|
|
3
|
+
import { MatterPhysicsTypeDocRepo } from '../types';
|
|
4
|
+
import { MatterWorldComponent } from './matter-world.component';
|
|
5
|
+
export declare class MatterRigidBodyComponent implements IRigidBody2dComponent<MatterPhysicsTypeDocRepo> {
|
|
5
6
|
nativeBody: Body;
|
|
6
7
|
get position(): Point2;
|
|
7
8
|
set position(value: Point2);
|
|
@@ -14,9 +15,13 @@ export declare class MatterRigidBodyComponent implements IRigidBody2dComponent<M
|
|
|
14
15
|
name: string;
|
|
15
16
|
entity: Entity2d | null;
|
|
16
17
|
constructor(nativeBody: Body);
|
|
18
|
+
get interactWithCollisionGroups(): CollisionGroup[];
|
|
19
|
+
set interactWithCollisionGroups(value: CollisionGroup[] | 'all');
|
|
20
|
+
get ownCollisionGroups(): CollisionGroup[];
|
|
21
|
+
set ownCollisionGroups(value: CollisionGroup[] | 'all');
|
|
17
22
|
clone(): MatterRigidBodyComponent;
|
|
18
|
-
addToWorld(world: Gg2dWorld<IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
19
|
-
removeFromWorld(world: Gg2dWorld<IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
23
|
+
addToWorld(world: Gg2dWorld<VisualTypeDocRepo2D, MatterPhysicsTypeDocRepo, IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
24
|
+
removeFromWorld(world: Gg2dWorld<VisualTypeDocRepo2D, MatterPhysicsTypeDocRepo, IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
20
25
|
dispose(): void;
|
|
21
26
|
resetMotion(): void;
|
|
22
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pnt2 } from '@gg-web-engine/core';
|
|
1
|
+
import { Pnt2, } from '@gg-web-engine/core';
|
|
2
2
|
import { Body, Composite, Vector } from 'matter-js';
|
|
3
3
|
export class MatterRigidBodyComponent {
|
|
4
4
|
constructor(nativeBody) {
|
|
@@ -30,6 +30,18 @@ export class MatterRigidBodyComponent {
|
|
|
30
30
|
set angularVelocity(value) {
|
|
31
31
|
Body.setAngularVelocity(this.nativeBody, value);
|
|
32
32
|
}
|
|
33
|
+
get interactWithCollisionGroups() {
|
|
34
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
35
|
+
}
|
|
36
|
+
set interactWithCollisionGroups(value) {
|
|
37
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
38
|
+
}
|
|
39
|
+
get ownCollisionGroups() {
|
|
40
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
41
|
+
}
|
|
42
|
+
set ownCollisionGroups(value) {
|
|
43
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
44
|
+
}
|
|
33
45
|
clone() {
|
|
34
46
|
// TODO
|
|
35
47
|
throw new Error('Gg2dBody.clone() not implemented for Matter.js');
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CollisionGroup, Gg2dWorld, IDebugPhysicsDrawer, IPhysicsWorld2dComponent, Point2 } from '@gg-web-engine/core';
|
|
2
2
|
import { Engine, World } from 'matter-js';
|
|
3
3
|
import { MatterFactory } from '../matter-factory';
|
|
4
|
-
|
|
4
|
+
import { MatterPhysicsTypeDocRepo } from '../types';
|
|
5
|
+
export declare class MatterWorldComponent implements IPhysicsWorld2dComponent<MatterPhysicsTypeDocRepo> {
|
|
5
6
|
protected matterEngine: Engine | null;
|
|
6
7
|
get matterWorld(): World | null;
|
|
7
8
|
readonly factory: MatterFactory;
|
|
@@ -13,6 +14,8 @@ export declare class MatterWorldComponent implements IPhysicsWorld2dComponent {
|
|
|
13
14
|
set timeScale(value: number);
|
|
14
15
|
get physicsDebugViewActive(): boolean;
|
|
15
16
|
init(): Promise<void>;
|
|
17
|
+
registerCollisionGroup(): CollisionGroup;
|
|
18
|
+
deregisterCollisionGroup(group: CollisionGroup): void;
|
|
16
19
|
simulate(delta: number): void;
|
|
17
20
|
startDebugger(world: Gg2dWorld, drawer: IDebugPhysicsDrawer<Point2, number>): void;
|
|
18
21
|
stopDebugger(): void;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Engine } from 'matter-js';
|
|
11
11
|
import { MatterFactory } from '../matter-factory';
|
|
12
|
+
// TODO implement bindings for collision groups. Matter.js has elegant solution for that, read body.collisionFilter
|
|
12
13
|
export class MatterWorldComponent {
|
|
13
14
|
constructor() {
|
|
14
15
|
this.matterEngine = null;
|
|
@@ -43,6 +44,12 @@ export class MatterWorldComponent {
|
|
|
43
44
|
this.matterEngine = Engine.create({ gravity: Object.assign(Object.assign({}, this._gravity), { scale: 0.0001 }) });
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
registerCollisionGroup() {
|
|
48
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
49
|
+
}
|
|
50
|
+
deregisterCollisionGroup(group) {
|
|
51
|
+
throw new Error('Collision groups not implemented for Matter.js');
|
|
52
|
+
}
|
|
46
53
|
simulate(delta) {
|
|
47
54
|
Engine.update(this.matterEngine, this._timeScale * delta);
|
|
48
55
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/matter-factory.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BodyShape2DDescriptor, IPhysicsBody2dComponentFactory, Point2, Shape2DDescriptor } from '@gg-web-engine/core';
|
|
2
2
|
import { MatterRigidBodyComponent } from './components/matter-rigid-body.component';
|
|
3
|
-
|
|
3
|
+
import { MatterPhysicsTypeDocRepo } from './types';
|
|
4
|
+
export declare class MatterFactory implements IPhysicsBody2dComponentFactory<MatterPhysicsTypeDocRepo> {
|
|
4
5
|
createRigidBody(descriptor: BodyShape2DDescriptor, transform?: {
|
|
5
6
|
position?: Point2;
|
|
6
7
|
rotation?: number;
|
|
@@ -8,6 +9,6 @@ export declare class MatterFactory implements IPhysicsBody2dComponentFactory<Mat
|
|
|
8
9
|
createTrigger(descriptor: Shape2DDescriptor, transform?: {
|
|
9
10
|
position?: Point2;
|
|
10
11
|
rotation?: number;
|
|
11
|
-
}):
|
|
12
|
+
}): never;
|
|
12
13
|
private transformOptions;
|
|
13
14
|
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MatterFactory } from './matter-factory';
|
|
2
|
+
import { MatterRigidBodyComponent } from './components/matter-rigid-body.component';
|
|
3
|
+
export declare type MatterPhysicsTypeDocRepo = {
|
|
4
|
+
factory: MatterFactory;
|
|
5
|
+
rigidBody: MatterRigidBodyComponent;
|
|
6
|
+
trigger: never;
|
|
7
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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.30",
|
|
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,13 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/matter-js": "0.19.1",
|
|
33
|
-
"@gg-web-engine/core": "0.0.
|
|
33
|
+
"@gg-web-engine/core": "0.0.30",
|
|
34
34
|
"matter-js": "0.19.0",
|
|
35
35
|
"prettier": "^2.8.6",
|
|
36
36
|
"typescript": "~4.7.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@gg-web-engine/core": "0.0.
|
|
39
|
+
"@gg-web-engine/core": "0.0.30",
|
|
40
40
|
"matter-js": "0.19.0"
|
|
41
41
|
}
|
|
42
42
|
}
|