@gg-web-engine/ammo 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/ammo-body.component.d.ts +4 -4
- package/dist/components/ammo-body.component.js +1 -0
- package/dist/components/ammo-raycast-vehicle.component.d.ts +4 -4
- package/dist/components/ammo-raycast-vehicle.component.js +8 -4
- package/dist/components/ammo-rigid-body.component.d.ts +1 -1
- package/dist/components/ammo-rigid-body.component.js +4 -8
- package/dist/components/ammo-trigger.component.d.ts +1 -1
- package/dist/components/ammo-trigger.component.js +2 -3
- package/dist/components/ammo-world.component.d.ts +1 -0
- package/dist/components/ammo-world.component.js +2 -1
- package/package.json +3 -3
|
@@ -18,11 +18,11 @@ export declare abstract class AmmoBodyComponent<T extends Ammo.btCollisionObject
|
|
|
18
18
|
protected addedToWorld: boolean;
|
|
19
19
|
protected _interactWithCGsMask: number;
|
|
20
20
|
protected _ownCGsMask: number;
|
|
21
|
-
get interactWithCollisionGroups(): CollisionGroup
|
|
21
|
+
get interactWithCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
22
22
|
abstract refreshCG(): void;
|
|
23
|
-
set interactWithCollisionGroups(value: CollisionGroup
|
|
24
|
-
get ownCollisionGroups(): CollisionGroup
|
|
25
|
-
set ownCollisionGroups(value: CollisionGroup
|
|
23
|
+
set interactWithCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
24
|
+
get ownCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
25
|
+
set ownCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
26
26
|
protected constructor(world: AmmoWorldComponent, _nativeBody: T, shape: Shape3DDescriptor);
|
|
27
27
|
abstract clone(): AmmoBodyComponent<T>;
|
|
28
28
|
addToWorld(world: Gg3dWorld<VisualTypeDocRepo3D, AmmoPhysicsTypeDocRepo>): void;
|
|
@@ -75,6 +75,7 @@ export class AmmoBodyComponent {
|
|
|
75
75
|
this._interactWithCGsMask = BitMask.full(16);
|
|
76
76
|
this._ownCGsMask = BitMask.full(16);
|
|
77
77
|
AmmoBodyComponent.nativeBodyReverseMap.set(Ammo.getPointer(this.nativeBody), this);
|
|
78
|
+
this.ownCollisionGroups = this.interactWithCollisionGroups = [world.mainCollisionGroup];
|
|
78
79
|
}
|
|
79
80
|
addToWorld(world) {
|
|
80
81
|
if (world.physicsWorld != this.world) {
|
|
@@ -12,10 +12,10 @@ export declare class AmmoRaycastVehicleComponent extends AmmoRigidBodyComponent
|
|
|
12
12
|
protected readonly wheelAxleCS: Ammo.btVector3;
|
|
13
13
|
entity: RaycastVehicle3dEntity | null;
|
|
14
14
|
protected readonly raycaster: Ammo.btDefaultVehicleRaycaster;
|
|
15
|
-
get interactWithCollisionGroups(): CollisionGroup
|
|
16
|
-
set interactWithCollisionGroups(value: CollisionGroup
|
|
17
|
-
get ownCollisionGroups(): CollisionGroup
|
|
18
|
-
set ownCollisionGroups(value: CollisionGroup
|
|
15
|
+
get interactWithCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
16
|
+
set interactWithCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
17
|
+
get ownCollisionGroups(): ReadonlyArray<CollisionGroup>;
|
|
18
|
+
set ownCollisionGroups(value: ReadonlyArray<CollisionGroup> | 'all');
|
|
19
19
|
refreshCG(): void;
|
|
20
20
|
constructor(world: AmmoWorldComponent, chassisBody: AmmoRigidBodyComponent);
|
|
21
21
|
get wheelSpeed(): number;
|
|
@@ -6,15 +6,19 @@ export class AmmoRaycastVehicleComponent extends AmmoRigidBodyComponent {
|
|
|
6
6
|
return this.chassisBody.interactWithCollisionGroups;
|
|
7
7
|
}
|
|
8
8
|
set interactWithCollisionGroups(value) {
|
|
9
|
-
this.chassisBody
|
|
10
|
-
|
|
9
|
+
if (this.chassisBody) {
|
|
10
|
+
this.chassisBody.interactWithCollisionGroups = value;
|
|
11
|
+
this.raycaster.set_m_collisionFilterMask(BitMask.pack(this.chassisBody.interactWithCollisionGroups, 16));
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
get ownCollisionGroups() {
|
|
13
15
|
return this.chassisBody.ownCollisionGroups;
|
|
14
16
|
}
|
|
15
17
|
set ownCollisionGroups(value) {
|
|
16
|
-
this.chassisBody
|
|
17
|
-
|
|
18
|
+
if (this.chassisBody) {
|
|
19
|
+
this.chassisBody.ownCollisionGroups = value;
|
|
20
|
+
this.raycaster.set_m_collisionFilterGroup(BitMask.pack(this.chassisBody.ownCollisionGroups, 16));
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
refreshCG() {
|
|
20
24
|
this.chassisBody.refreshCG();
|
|
@@ -12,7 +12,7 @@ export declare class AmmoRigidBodyComponent extends AmmoBodyComponent<Ammo.btRig
|
|
|
12
12
|
set linearVelocity(value: Point3);
|
|
13
13
|
get angularVelocity(): Point3;
|
|
14
14
|
set angularVelocity(value: Point3);
|
|
15
|
-
|
|
15
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
16
16
|
constructor(world: AmmoWorldComponent, _nativeBody: Ammo.btRigidBody, shape: Shape3DDescriptor);
|
|
17
17
|
clone(): AmmoRigidBodyComponent;
|
|
18
18
|
addToWorld(world: Gg3dWorld<VisualTypeDocRepo3D, AmmoPhysicsTypeDocRepo>): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Ammo from '../ammo.js/ammo';
|
|
2
2
|
import { AmmoBodyComponent } from './ammo-body.component';
|
|
3
|
+
import { DebugBody3DSettings, } from '@gg-web-engine/core';
|
|
3
4
|
import { first } from 'rxjs';
|
|
4
5
|
export class AmmoRigidBodyComponent extends AmmoBodyComponent {
|
|
5
6
|
get linearVelocity() {
|
|
@@ -16,20 +17,15 @@ export class AmmoRigidBodyComponent extends AmmoBodyComponent {
|
|
|
16
17
|
set angularVelocity(value) {
|
|
17
18
|
this.nativeBody.setAngularVelocity(new Ammo.btVector3(value.x, value.y, value.z));
|
|
18
19
|
}
|
|
19
|
-
get debugBodySettings() {
|
|
20
|
-
if (this._nativeBody.isStaticOrKinematicObject()) {
|
|
21
|
-
return { shape: this.shape, type: 'RIGID_STATIC' };
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return { shape: this.shape, type: 'RIGID_DYNAMIC', sleeping: !this._nativeBody.isActive() };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
20
|
constructor(world, _nativeBody, shape) {
|
|
28
21
|
super(world, _nativeBody, shape);
|
|
29
22
|
this.world = world;
|
|
30
23
|
this._nativeBody = _nativeBody;
|
|
31
24
|
this.shape = shape;
|
|
32
25
|
this.entity = null;
|
|
26
|
+
this.debugBodySettings = new DebugBody3DSettings(this._nativeBody.isStaticOrKinematicObject()
|
|
27
|
+
? { type: 'RIGID_STATIC' }
|
|
28
|
+
: { type: 'RIGID_DYNAMIC', sleeping: () => !this._nativeBody.isActive() }, this.shape);
|
|
33
29
|
}
|
|
34
30
|
clone() {
|
|
35
31
|
return this.world.factory.createRigidBodyFromShape(this._nativeBody.getCollisionShape(), this.shape, {
|
|
@@ -10,7 +10,7 @@ export declare class AmmoTriggerComponent extends AmmoBodyComponent<Ammo.btPairC
|
|
|
10
10
|
protected _nativeBody: Ammo.btPairCachingGhostObject;
|
|
11
11
|
readonly shape: Shape3DDescriptor;
|
|
12
12
|
entity: IEntity | null;
|
|
13
|
-
|
|
13
|
+
readonly debugBodySettings: DebugBody3DSettings;
|
|
14
14
|
get onEntityEntered(): Observable<AmmoRigidBodyComponent>;
|
|
15
15
|
get onEntityLeft(): Observable<AmmoRigidBodyComponent | null>;
|
|
16
16
|
constructor(world: AmmoWorldComponent, _nativeBody: Ammo.btPairCachingGhostObject, shape: Shape3DDescriptor);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { DebugBody3DSettings, } from '@gg-web-engine/core';
|
|
1
2
|
import { filter, map, Subject } from 'rxjs';
|
|
2
3
|
import Ammo from '../ammo.js/ammo';
|
|
3
4
|
import { AmmoBodyComponent } from './ammo-body.component';
|
|
4
5
|
export class AmmoTriggerComponent extends AmmoBodyComponent {
|
|
5
|
-
get debugBodySettings() {
|
|
6
|
-
return { shape: this.shape, type: 'TRIGGER' };
|
|
7
|
-
}
|
|
8
6
|
get onEntityEntered() {
|
|
9
7
|
return this.onEnter$.pipe(map(b => AmmoBodyComponent.nativeBodyReverseMap.get(b)), filter(x => !!x));
|
|
10
8
|
}
|
|
@@ -17,6 +15,7 @@ export class AmmoTriggerComponent extends AmmoBodyComponent {
|
|
|
17
15
|
this._nativeBody = _nativeBody;
|
|
18
16
|
this.shape = shape;
|
|
19
17
|
this.entity = null;
|
|
18
|
+
this.debugBodySettings = new DebugBody3DSettings({ type: 'TRIGGER', activated: () => this.overlaps.size > 0 }, this.shape);
|
|
20
19
|
this.onEnter$ = new Subject();
|
|
21
20
|
this.onLeft$ = new Subject();
|
|
22
21
|
this.overlaps = new Set();
|
|
@@ -18,6 +18,7 @@ export declare class AmmoWorldComponent implements IPhysicsWorld3dComponent<Ammo
|
|
|
18
18
|
private _gravity;
|
|
19
19
|
get gravity(): Point3;
|
|
20
20
|
set gravity(value: Point3);
|
|
21
|
+
readonly mainCollisionGroup: CollisionGroup;
|
|
21
22
|
maxSubSteps?: number;
|
|
22
23
|
fixedTimeStep?: number;
|
|
23
24
|
get dynamicAmmoWorld(): Ammo.btDiscreteDynamicsWorld | undefined;
|
|
@@ -46,6 +46,7 @@ export class AmmoWorldComponent {
|
|
|
46
46
|
this.children = [];
|
|
47
47
|
this._loader = null;
|
|
48
48
|
this._gravity = { x: 0, y: 0, z: -9.82 };
|
|
49
|
+
this.mainCollisionGroup = 0;
|
|
49
50
|
this.maxSubSteps = 100;
|
|
50
51
|
this.fixedTimeStep = 0.01;
|
|
51
52
|
this.lockedCollisionGroups = [];
|
|
@@ -77,7 +78,7 @@ export class AmmoWorldComponent {
|
|
|
77
78
|
this.afterTick$.next();
|
|
78
79
|
}
|
|
79
80
|
registerCollisionGroup() {
|
|
80
|
-
for (let i =
|
|
81
|
+
for (let i = 1; i < 16; i++) {
|
|
81
82
|
if (!this.lockedCollisionGroups.includes(i)) {
|
|
82
83
|
this.lockedCollisionGroups.push(i);
|
|
83
84
|
return i;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gg-web-engine/ammo",
|
|
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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@gg-web-engine/core": "0.0.
|
|
37
|
+
"@gg-web-engine/core": "0.0.57",
|
|
38
38
|
"@types/jest": "^29.5.12",
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
40
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typescript": "~5.5.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@gg-web-engine/core": "0.0.
|
|
48
|
+
"@gg-web-engine/core": "0.0.57",
|
|
49
49
|
"mini-signals": "2.0.0",
|
|
50
50
|
"rxjs": "7.8.1"
|
|
51
51
|
},
|