@gg-web-engine/matter 0.0.20 → 0.0.24
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 +18 -0
- package/dist/{impl/gg-2d-body.js → components/matter-rigid-body.component.js} +3 -7
- package/dist/{impl/gg-2d-physics-world.d.ts → components/matter-world.component.d.ts} +5 -5
- package/dist/{impl/gg-2d-physics-world.js → components/matter-world.component.js} +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/matter-factory.d.ts +13 -0
- package/dist/{impl/gg-2d-body-factory.js → matter-factory.js} +3 -3
- package/package.json +6 -6
- package/dist/impl/gg-2d-body-factory.d.ts +0 -13
- package/dist/impl/gg-2d-body.d.ts +0 -19
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entity2d, Gg2dWorld, IRigidBody2dComponent, IVisualScene2dComponent, Point2 } from '@gg-web-engine/core';
|
|
2
|
+
import { MatterWorldComponent } from './matter-world.component';
|
|
3
|
+
import { Body } from 'matter-js';
|
|
4
|
+
export declare class MatterRigidBodyComponent implements IRigidBody2dComponent<MatterWorldComponent> {
|
|
5
|
+
nativeBody: Body;
|
|
6
|
+
get position(): Point2;
|
|
7
|
+
set position(value: Point2);
|
|
8
|
+
get rotation(): number;
|
|
9
|
+
set rotation(value: number);
|
|
10
|
+
name: string;
|
|
11
|
+
entity: Entity2d | null;
|
|
12
|
+
constructor(nativeBody: Body);
|
|
13
|
+
clone(): MatterRigidBodyComponent;
|
|
14
|
+
addToWorld(world: Gg2dWorld<IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
15
|
+
removeFromWorld(world: Gg2dWorld<IVisualScene2dComponent, MatterWorldComponent>): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
resetMotion(): void;
|
|
18
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Pnt2 } from '@gg-web-engine/core';
|
|
2
2
|
import { Body, Composite, Vector } from 'matter-js';
|
|
3
|
-
export class
|
|
3
|
+
export class MatterRigidBodyComponent {
|
|
4
4
|
constructor(nativeBody) {
|
|
5
5
|
this.nativeBody = nativeBody;
|
|
6
6
|
this.name = '';
|
|
@@ -18,19 +18,15 @@ export class Gg2dBody {
|
|
|
18
18
|
set rotation(value) {
|
|
19
19
|
this.nativeBody.angle = value;
|
|
20
20
|
}
|
|
21
|
-
get scale() {
|
|
22
|
-
// hmm, is it even possible to be different?
|
|
23
|
-
return { x: 1, y: 1 };
|
|
24
|
-
}
|
|
25
21
|
clone() {
|
|
26
22
|
// TODO
|
|
27
23
|
throw new Error('Gg2dBody.clone() not implemented for Matter.js');
|
|
28
24
|
}
|
|
29
25
|
addToWorld(world) {
|
|
30
|
-
Composite.add(world.matterWorld, this.nativeBody);
|
|
26
|
+
Composite.add(world.physicsWorld.matterWorld, this.nativeBody);
|
|
31
27
|
}
|
|
32
28
|
removeFromWorld(world) {
|
|
33
|
-
Composite.remove(world.matterWorld, this.nativeBody);
|
|
29
|
+
Composite.remove(world.physicsWorld.matterWorld, this.nativeBody);
|
|
34
30
|
}
|
|
35
31
|
dispose() { }
|
|
36
32
|
resetMotion() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDebugPhysicsDrawer, Point2, Gg2dWorld, IPhysicsWorld2dComponent } from '@gg-web-engine/core';
|
|
2
2
|
import { Engine, World } from 'matter-js';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
3
|
+
import { MatterFactory } from '../matter-factory';
|
|
4
|
+
export declare class MatterWorldComponent implements IPhysicsWorld2dComponent {
|
|
5
5
|
protected matterEngine: Engine | null;
|
|
6
6
|
get matterWorld(): World | null;
|
|
7
|
-
readonly factory:
|
|
7
|
+
readonly factory: MatterFactory;
|
|
8
8
|
private _gravity;
|
|
9
9
|
get gravity(): Point2;
|
|
10
10
|
set gravity(value: Point2);
|
|
@@ -14,7 +14,7 @@ export declare class Gg2dPhysicsWorld implements IGg2dPhysicsWorld {
|
|
|
14
14
|
get physicsDebugViewActive(): boolean;
|
|
15
15
|
init(): Promise<void>;
|
|
16
16
|
simulate(delta: number): void;
|
|
17
|
-
startDebugger(world: Gg2dWorld, drawer:
|
|
17
|
+
startDebugger(world: Gg2dWorld, drawer: IDebugPhysicsDrawer<Point2, number>): void;
|
|
18
18
|
stopDebugger(): void;
|
|
19
19
|
dispose(): void;
|
|
20
20
|
}
|
|
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { Engine } from 'matter-js';
|
|
11
|
-
import {
|
|
12
|
-
export class
|
|
11
|
+
import { MatterFactory } from '../matter-factory';
|
|
12
|
+
export class MatterWorldComponent {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.matterEngine = null;
|
|
15
|
-
this.factory = new
|
|
15
|
+
this.factory = new MatterFactory();
|
|
16
16
|
this._gravity = { x: 0, y: 9.82 };
|
|
17
17
|
this._timeScale = 1;
|
|
18
18
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './components/matter-rigid-body.component';
|
|
2
|
+
export * from './components/matter-world.component';
|
|
3
|
+
export * from './matter-factory';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './components/matter-rigid-body.component';
|
|
2
|
+
export * from './components/matter-world.component';
|
|
3
|
+
export * from './matter-factory';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BodyShape2DDescriptor, IPhysicsBody2dComponentFactory, Point2, Shape2DDescriptor } from '@gg-web-engine/core';
|
|
2
|
+
import { MatterRigidBodyComponent } from './components/matter-rigid-body.component';
|
|
3
|
+
export declare class MatterFactory implements IPhysicsBody2dComponentFactory<MatterRigidBodyComponent, any> {
|
|
4
|
+
createRigidBody(descriptor: BodyShape2DDescriptor, transform?: {
|
|
5
|
+
position?: Point2;
|
|
6
|
+
rotation?: number;
|
|
7
|
+
}): MatterRigidBodyComponent;
|
|
8
|
+
createTrigger(descriptor: Shape2DDescriptor, transform?: {
|
|
9
|
+
position?: Point2;
|
|
10
|
+
rotation?: number;
|
|
11
|
+
}): any;
|
|
12
|
+
private transformOptions;
|
|
13
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MatterRigidBodyComponent } from './components/matter-rigid-body.component';
|
|
2
2
|
import { Bodies, Vector } from 'matter-js';
|
|
3
|
-
export class
|
|
3
|
+
export class MatterFactory {
|
|
4
4
|
createRigidBody(descriptor, transform) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
let nativeBody = null;
|
|
@@ -17,7 +17,7 @@ export class Gg2dBodyFactory {
|
|
|
17
17
|
}
|
|
18
18
|
nativeBody.position = Vector.create(((_a = transform === null || transform === void 0 ? void 0 : transform.position) === null || _a === void 0 ? void 0 : _a.x) || 0, ((_b = transform === null || transform === void 0 ? void 0 : transform.position) === null || _b === void 0 ? void 0 : _b.y) || 0);
|
|
19
19
|
nativeBody.angle = (transform === null || transform === void 0 ? void 0 : transform.rotation) || 0;
|
|
20
|
-
return new
|
|
20
|
+
return new MatterRigidBodyComponent(nativeBody);
|
|
21
21
|
}
|
|
22
22
|
createTrigger(descriptor, transform) {
|
|
23
23
|
throw new Error('Triggers not implemented for Matter.js');
|
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.24",
|
|
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",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/matter-js": "
|
|
33
|
-
"@gg-web-engine/core": "
|
|
34
|
-
"matter-js": "
|
|
32
|
+
"@types/matter-js": "0.19.1",
|
|
33
|
+
"@gg-web-engine/core": "0.0.24",
|
|
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": "
|
|
40
|
-
"matter-js": "
|
|
39
|
+
"@gg-web-engine/core": "0.0.24",
|
|
40
|
+
"matter-js": "0.19.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BodyShape2DDescriptor, IGg2dBodyFactory, Point2, Shape2DDescriptor } from '@gg-web-engine/core';
|
|
2
|
-
import { Gg2dBody } from './gg-2d-body';
|
|
3
|
-
export declare class Gg2dBodyFactory implements IGg2dBodyFactory<Gg2dBody, any> {
|
|
4
|
-
createRigidBody(descriptor: BodyShape2DDescriptor, transform?: {
|
|
5
|
-
position?: Point2;
|
|
6
|
-
rotation?: number;
|
|
7
|
-
}): Gg2dBody;
|
|
8
|
-
createTrigger(descriptor: Shape2DDescriptor, transform?: {
|
|
9
|
-
position?: Point2;
|
|
10
|
-
rotation?: number;
|
|
11
|
-
}): any;
|
|
12
|
-
private transformOptions;
|
|
13
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Gg2dEntity, IGg2dBody, Point2 } from '@gg-web-engine/core';
|
|
2
|
-
import { Gg2dPhysicsWorld } from './gg-2d-physics-world';
|
|
3
|
-
import { Body } from 'matter-js';
|
|
4
|
-
export declare class Gg2dBody implements IGg2dBody {
|
|
5
|
-
nativeBody: Body;
|
|
6
|
-
get position(): Point2;
|
|
7
|
-
set position(value: Point2);
|
|
8
|
-
get rotation(): number;
|
|
9
|
-
set rotation(value: number);
|
|
10
|
-
get scale(): Point2;
|
|
11
|
-
name: string;
|
|
12
|
-
entity: Gg2dEntity | null;
|
|
13
|
-
constructor(nativeBody: Body);
|
|
14
|
-
clone(): Gg2dBody;
|
|
15
|
-
addToWorld(world: Gg2dPhysicsWorld): void;
|
|
16
|
-
removeFromWorld(world: Gg2dPhysicsWorld): void;
|
|
17
|
-
dispose(): void;
|
|
18
|
-
resetMotion(): void;
|
|
19
|
-
}
|