@gg-web-engine/rapier3d 0.0.49 → 0.0.57
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/rapier-3d-rigid-body.component.d.ts +5 -5
- package/dist/components/rapier-3d-rigid-body.component.js +6 -12
- package/dist/components/rapier-3d-trigger.component.d.ts +2 -1
- package/dist/components/rapier-3d-trigger.component.js +17 -5
- package/dist/components/rapier-3d-world.component.d.ts +1 -0
- package/dist/components/rapier-3d-world.component.js +2 -1
- package/dist/rapier-3d-factory.js +1 -1
- package/package.json +3 -3
|
@@ -18,7 +18,7 @@ export declare class Rapier3dRigidBodyComponent implements IRigidBody3dComponent
|
|
|
18
18
|
set linearVelocity(value: Point3);
|
|
19
19
|
get angularVelocity(): Point3;
|
|
20
20
|
set angularVelocity(value: Point3);
|
|
21
|
-
|
|
21
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
22
22
|
protected _nativeBody: RigidBody | null;
|
|
23
23
|
protected _nativeBodyColliders: Collider[] | null;
|
|
24
24
|
get nativeBody(): RigidBody | null;
|
|
@@ -32,10 +32,10 @@ export declare class Rapier3dRigidBodyComponent implements IRigidBody3dComponent
|
|
|
32
32
|
];
|
|
33
33
|
constructor(world: Rapier3dWorldComponent, _colliderDescr: ColliderDesc[], shape: Shape3DDescriptor, _bodyDescr: RigidBodyDesc, _colliderOptions: Omit<Omit<Body3DOptions, 'dynamic'>, 'mass'>);
|
|
34
34
|
protected collisionGroups: InteractionGroups;
|
|
35
|
-
get interactWithCollisionGroups(): CollisionGroup
|
|
36
|
-
set interactWithCollisionGroups(value: CollisionGroup
|
|
37
|
-
get ownCollisionGroups(): CollisionGroup
|
|
38
|
-
set ownCollisionGroups(value: CollisionGroup
|
|
35
|
+
get interactWithCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
36
|
+
set interactWithCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
37
|
+
get ownCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
38
|
+
set ownCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
39
39
|
clone(): Rapier3dRigidBodyComponent;
|
|
40
40
|
addToWorld(world: Gg3dWorld<VisualTypeDocRepo3D, Rapier3dPhysicsTypeDocRepo>): void;
|
|
41
41
|
removeFromWorld(world: Gg3dWorld<VisualTypeDocRepo3D, Rapier3dPhysicsTypeDocRepo>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BitMask, Pnt3, Qtrn, } from '@gg-web-engine/core';
|
|
1
|
+
import { BitMask, DebugBody3DSettings, Pnt3, Qtrn, } from '@gg-web-engine/core';
|
|
2
2
|
import { ColliderDesc, Quaternion, RigidBodyDesc, Vector3 } from '@dimforge/rapier3d-compat';
|
|
3
3
|
export class Rapier3dRigidBodyComponent {
|
|
4
4
|
get position() {
|
|
@@ -41,15 +41,6 @@ export class Rapier3dRigidBodyComponent {
|
|
|
41
41
|
this.nativeBody.setAngvel(new Vector3(value.x, value.y, value.z), false);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
get debugBodySettings() {
|
|
45
|
-
var _a;
|
|
46
|
-
if (this._bodyDescr.mass > 0) {
|
|
47
|
-
return { shape: this.shape, type: 'RIGID_DYNAMIC', sleeping: !!((_a = this._nativeBody) === null || _a === void 0 ? void 0 : _a.isSleeping()) };
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return { shape: this.shape, type: 'RIGID_STATIC' };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
44
|
get nativeBody() {
|
|
54
45
|
return this._nativeBody;
|
|
55
46
|
}
|
|
@@ -85,12 +76,15 @@ export class Rapier3dRigidBodyComponent {
|
|
|
85
76
|
this._bodyDescr = _bodyDescr;
|
|
86
77
|
this._colliderOptions = _colliderOptions;
|
|
87
78
|
this.entity = null;
|
|
79
|
+
this.debugBodySettings = new DebugBody3DSettings(this._bodyDescr.mass > 0
|
|
80
|
+
? { type: 'RIGID_DYNAMIC', sleeping: () => { var _a; return !!((_a = this._nativeBody) === null || _a === void 0 ? void 0 : _a.isSleeping()); } }
|
|
81
|
+
: { type: 'RIGID_STATIC' }, this.shape);
|
|
88
82
|
this._nativeBody = null;
|
|
89
83
|
this._nativeBodyColliders = null;
|
|
90
84
|
this.name = '';
|
|
91
85
|
this.collisionGroups = BitMask.full(32);
|
|
92
|
-
this.ownCollisionGroups = (_colliderOptions === null || _colliderOptions === void 0 ? void 0 : _colliderOptions.ownCollisionGroups) ||
|
|
93
|
-
this.interactWithCollisionGroups = (_colliderOptions === null || _colliderOptions === void 0 ? void 0 : _colliderOptions.interactWithCollisionGroups) ||
|
|
86
|
+
this.ownCollisionGroups = (_colliderOptions === null || _colliderOptions === void 0 ? void 0 : _colliderOptions.ownCollisionGroups) || [world.mainCollisionGroup];
|
|
87
|
+
this.interactWithCollisionGroups = (_colliderOptions === null || _colliderOptions === void 0 ? void 0 : _colliderOptions.interactWithCollisionGroups) || [world.mainCollisionGroup];
|
|
94
88
|
}
|
|
95
89
|
get interactWithCollisionGroups() {
|
|
96
90
|
return BitMask.unpack(this.collisionGroups, 16);
|
|
@@ -13,7 +13,8 @@ export declare class Rapier3dTriggerComponent extends Rapier3dRigidBodyComponent
|
|
|
13
13
|
get onEntityLeft(): Observable<Rapier3dRigidBodyComponent>;
|
|
14
14
|
protected readonly onEnter$: Subject<Rapier3dRigidBodyComponent>;
|
|
15
15
|
protected readonly onLeft$: Subject<Rapier3dRigidBodyComponent>;
|
|
16
|
-
|
|
16
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
17
|
+
protected intersectionsAmount: number;
|
|
17
18
|
constructor(world: Rapier3dWorldComponent, _colliderDescr: ColliderDesc[], shape: Shape3DDescriptor, _bodyDescr: RigidBodyDesc);
|
|
18
19
|
addToWorld(world: Gg3dWorld<VisualTypeDocRepo3D, Rapier3dPhysicsTypeDocRepo>): void;
|
|
19
20
|
checkOverlaps(): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
1
|
+
import { map, merge, Subject } from 'rxjs';
|
|
2
2
|
import { Rapier3dRigidBodyComponent } from './rapier-3d-rigid-body.component';
|
|
3
|
+
import { DebugBody3DSettings, } from '@gg-web-engine/core';
|
|
3
4
|
export class Rapier3dTriggerComponent extends Rapier3dRigidBodyComponent {
|
|
4
5
|
get onEntityEntered() {
|
|
5
6
|
return this.onEnter$.asObservable();
|
|
@@ -7,9 +8,6 @@ export class Rapier3dTriggerComponent extends Rapier3dRigidBodyComponent {
|
|
|
7
8
|
get onEntityLeft() {
|
|
8
9
|
return this.onLeft$.asObservable();
|
|
9
10
|
}
|
|
10
|
-
get debugBodySettings() {
|
|
11
|
-
return { shape: this.shape, type: 'TRIGGER' };
|
|
12
|
-
}
|
|
13
11
|
constructor(world, _colliderDescr, shape, _bodyDescr) {
|
|
14
12
|
super(world, _colliderDescr, shape, _bodyDescr, null);
|
|
15
13
|
this.world = world;
|
|
@@ -18,11 +16,22 @@ export class Rapier3dTriggerComponent extends Rapier3dRigidBodyComponent {
|
|
|
18
16
|
this._bodyDescr = _bodyDescr;
|
|
19
17
|
this.onEnter$ = new Subject();
|
|
20
18
|
this.onLeft$ = new Subject();
|
|
19
|
+
this.debugBodySettings = new DebugBody3DSettings({ type: 'TRIGGER', activated: () => this.intersectionsAmount > 0 }, this.shape);
|
|
20
|
+
this.intersectionsAmount = 0;
|
|
21
|
+
merge(this.onEnter$.pipe(map(() => true)), this.onLeft$.pipe(map(() => false))).subscribe(enter => {
|
|
22
|
+
if (enter) {
|
|
23
|
+
this.intersectionsAmount++;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.intersectionsAmount--;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
21
29
|
}
|
|
22
30
|
addToWorld(world) {
|
|
23
31
|
if (world.physicsWorld != this.world) {
|
|
24
32
|
throw new Error('Rapier3D bodies cannot be shared between different worlds');
|
|
25
33
|
}
|
|
34
|
+
this.intersectionsAmount = 0;
|
|
26
35
|
this._nativeBody = this.world.nativeWorld.createRigidBody(this._bodyDescr);
|
|
27
36
|
this._nativeBodyColliders = this._colliderDescr.map(c => this.world.nativeWorld.createCollider(c, this._nativeBody));
|
|
28
37
|
this.world.handleIdEntityMap.set(this._nativeBody.handle, this);
|
|
@@ -45,6 +54,9 @@ export class Rapier3dTriggerComponent extends Rapier3dRigidBodyComponent {
|
|
|
45
54
|
}
|
|
46
55
|
clone() {
|
|
47
56
|
const [colliderDescr, sd, bd] = super.factoryProps;
|
|
48
|
-
|
|
57
|
+
let component = new Rapier3dTriggerComponent(this.world, colliderDescr, sd, bd);
|
|
58
|
+
component.ownCollisionGroups = this.ownCollisionGroups;
|
|
59
|
+
component.interactWithCollisionGroups = this.interactWithCollisionGroups;
|
|
60
|
+
return component;
|
|
49
61
|
}
|
|
50
62
|
}
|
|
@@ -16,6 +16,7 @@ export declare class Rapier3dWorldComponent implements IPhysicsWorld3dComponent<
|
|
|
16
16
|
private _gravity;
|
|
17
17
|
get gravity(): Point3;
|
|
18
18
|
set gravity(value: Point3);
|
|
19
|
+
readonly mainCollisionGroup: CollisionGroup;
|
|
19
20
|
protected _nativeWorld: World | null;
|
|
20
21
|
get nativeWorld(): World;
|
|
21
22
|
private _eventQueue;
|
|
@@ -54,6 +54,7 @@ export class Rapier3dWorldComponent {
|
|
|
54
54
|
this.removed$ = new Subject();
|
|
55
55
|
this.children = [];
|
|
56
56
|
this._gravity = { x: 0, y: 0, z: -9.82 };
|
|
57
|
+
this.mainCollisionGroup = 0;
|
|
57
58
|
this._nativeWorld = null;
|
|
58
59
|
this._eventQueue = null;
|
|
59
60
|
this.handleIdEntityMap = new Map();
|
|
@@ -76,7 +77,7 @@ export class Rapier3dWorldComponent {
|
|
|
76
77
|
(_a = this._nativeWorld) === null || _a === void 0 ? void 0 : _a.step(this.eventQueue);
|
|
77
78
|
}
|
|
78
79
|
registerCollisionGroup() {
|
|
79
|
-
for (let i =
|
|
80
|
+
for (let i = 1; i < 16; i++) {
|
|
80
81
|
if (!this.lockedCollisionGroups.includes(i)) {
|
|
81
82
|
this.lockedCollisionGroups.push(i);
|
|
82
83
|
return i;
|
|
@@ -7,7 +7,7 @@ export class Rapier3dFactory {
|
|
|
7
7
|
this.world = world;
|
|
8
8
|
}
|
|
9
9
|
createRigidBody(descriptor, transform) {
|
|
10
|
-
return new Rapier3dRigidBodyComponent(this.world, this.createColliderDescr(descriptor.shape), descriptor.shape, this.createRigidBodyDescr(descriptor.body, transform), Object.assign({ friction: 0.5, restitution: 0.1, ownCollisionGroups:
|
|
10
|
+
return new Rapier3dRigidBodyComponent(this.world, this.createColliderDescr(descriptor.shape), descriptor.shape, this.createRigidBodyDescr(descriptor.body, transform), Object.assign({ friction: 0.5, restitution: 0.1, ownCollisionGroups: [this.world.mainCollisionGroup], interactWithCollisionGroups: [this.world.mainCollisionGroup] }, descriptor.body));
|
|
11
11
|
}
|
|
12
12
|
createTrigger(descriptor, transform) {
|
|
13
13
|
const colliderDescr = this.createColliderDescr(descriptor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/rapier3d",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"homepage": "https://github.com/AndyGura/gg-web-engine#readme",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@dimforge/rapier3d-compat": "0.0.0-50223ff-20240729",
|
|
31
|
-
"@gg-web-engine/core": "0.0.
|
|
31
|
+
"@gg-web-engine/core": "0.0.57",
|
|
32
32
|
"@types/jest": "^29.5.12",
|
|
33
33
|
"jest": "^29.7.0",
|
|
34
34
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@dimforge/rapier3d-compat": "0.0.0-50223ff-20240729",
|
|
42
|
-
"@gg-web-engine/core": "0.0.
|
|
42
|
+
"@gg-web-engine/core": "0.0.57",
|
|
43
43
|
"rxjs": "7.8.1"
|
|
44
44
|
},
|
|
45
45
|
"jest": {
|