@gg-web-engine/ammo 0.0.39 → 0.0.48
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/README.md +0 -0
- package/build_gg_ammo/Makefile +2 -2
- package/build_gg_ammo/README.md +0 -0
- package/build_gg_ammo/ammo_patches.txt +0 -0
- package/build_gg_ammo/bullet_patches.txt +0 -0
- package/build_gg_ammo/patch_files/ammo.idl +0 -0
- package/dist/ammo-factory.d.ts +0 -0
- package/dist/ammo-factory.js +0 -0
- package/dist/ammo-loader.d.ts +0 -0
- package/dist/ammo-loader.js +0 -0
- package/dist/ammo.js/ammo-ambient.d.ts +0 -0
- package/dist/ammo.js/ammo.d.ts +0 -0
- package/dist/ammo.js/ammo.js +22 -22
- package/dist/ammo.js/ammo.wasm.js +1299 -1300
- package/dist/ammo.js/ammo.wasm.wasm +0 -0
- package/dist/components/ammo-body.component.d.ts +0 -0
- package/dist/components/ammo-body.component.js +10 -10
- package/dist/components/ammo-raycast-vehicle.component.d.ts +0 -0
- package/dist/components/ammo-raycast-vehicle.component.js +14 -14
- package/dist/components/ammo-rigid-body.component.d.ts +0 -0
- package/dist/components/ammo-rigid-body.component.js +7 -7
- package/dist/components/ammo-trigger.component.d.ts +0 -0
- package/dist/components/ammo-trigger.component.js +9 -9
- package/dist/components/ammo-world.component.d.ts +0 -0
- package/dist/components/ammo-world.component.js +12 -12
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.js +0 -0
- package/package.json +9 -9
- package/test/components/ammo-trigger.component.spec.ts +0 -0
- package/tsconfig.json +0 -0
|
Binary file
|
|
File without changes
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { BitMask, } from '@gg-web-engine/core';
|
|
2
2
|
import Ammo from '../ammo.js/ammo';
|
|
3
3
|
export class AmmoBodyComponent {
|
|
4
|
-
constructor(world, _nativeBody, shape) {
|
|
5
|
-
this.world = world;
|
|
6
|
-
this._nativeBody = _nativeBody;
|
|
7
|
-
this.shape = shape;
|
|
8
|
-
this.name = '';
|
|
9
|
-
this.addedToWorld = false;
|
|
10
|
-
this._interactWithCGsMask = BitMask.full(16);
|
|
11
|
-
this._ownCGsMask = BitMask.full(16);
|
|
12
|
-
AmmoBodyComponent.nativeBodyReverseMap.set(Ammo.getPointer(this.nativeBody), this);
|
|
13
|
-
}
|
|
14
4
|
get position() {
|
|
15
5
|
const origin = this.nativeBody.getWorldTransform().getOrigin();
|
|
16
6
|
return { x: origin.x(), y: origin.y(), z: origin.z() };
|
|
@@ -76,6 +66,16 @@ export class AmmoBodyComponent {
|
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
}
|
|
69
|
+
constructor(world, _nativeBody, shape) {
|
|
70
|
+
this.world = world;
|
|
71
|
+
this._nativeBody = _nativeBody;
|
|
72
|
+
this.shape = shape;
|
|
73
|
+
this.name = '';
|
|
74
|
+
this.addedToWorld = false;
|
|
75
|
+
this._interactWithCGsMask = BitMask.full(16);
|
|
76
|
+
this._ownCGsMask = BitMask.full(16);
|
|
77
|
+
AmmoBodyComponent.nativeBodyReverseMap.set(Ammo.getPointer(this.nativeBody), this);
|
|
78
|
+
}
|
|
79
79
|
addToWorld(world) {
|
|
80
80
|
if (world.physicsWorld != this.world) {
|
|
81
81
|
throw new Error('Ammo bodies cannot be shared between different worlds');
|
|
File without changes
|
|
@@ -2,20 +2,6 @@ import { BitMask, } from '@gg-web-engine/core';
|
|
|
2
2
|
import Ammo from '../ammo.js/ammo';
|
|
3
3
|
import { AmmoRigidBodyComponent } from './ammo-rigid-body.component';
|
|
4
4
|
export class AmmoRaycastVehicleComponent extends AmmoRigidBodyComponent {
|
|
5
|
-
constructor(world, chassisBody) {
|
|
6
|
-
super(world, chassisBody.nativeBody, chassisBody.shape);
|
|
7
|
-
this.world = world;
|
|
8
|
-
this.chassisBody = chassisBody;
|
|
9
|
-
this.vehicleTuning = new Ammo.btVehicleTuning();
|
|
10
|
-
this.wheelDirectionCS0 = new Ammo.btVector3(0, 0, -1);
|
|
11
|
-
this.wheelAxleCS = new Ammo.btVector3(1, 0, 0);
|
|
12
|
-
this.entity = null;
|
|
13
|
-
this.raycaster = new Ammo.btDefaultVehicleRaycaster(world.dynamicAmmoWorld);
|
|
14
|
-
this.nativeVehicle = new Ammo.btRaycastVehicle(this.vehicleTuning, this.chassisBody.nativeBody, this.raycaster);
|
|
15
|
-
this.raycaster.set_m_collisionFilterGroup(BitMask.pack(this.chassisBody.ownCollisionGroups, 16));
|
|
16
|
-
this.raycaster.set_m_collisionFilterMask(BitMask.pack(this.chassisBody.interactWithCollisionGroups, 16));
|
|
17
|
-
this.nativeVehicle.setCoordinateSystem(0, 2, 1);
|
|
18
|
-
}
|
|
19
5
|
get interactWithCollisionGroups() {
|
|
20
6
|
return this.chassisBody.interactWithCollisionGroups;
|
|
21
7
|
}
|
|
@@ -33,6 +19,20 @@ export class AmmoRaycastVehicleComponent extends AmmoRigidBodyComponent {
|
|
|
33
19
|
refreshCG() {
|
|
34
20
|
this.chassisBody.refreshCG();
|
|
35
21
|
}
|
|
22
|
+
constructor(world, chassisBody) {
|
|
23
|
+
super(world, chassisBody.nativeBody, chassisBody.shape);
|
|
24
|
+
this.world = world;
|
|
25
|
+
this.chassisBody = chassisBody;
|
|
26
|
+
this.vehicleTuning = new Ammo.btVehicleTuning();
|
|
27
|
+
this.wheelDirectionCS0 = new Ammo.btVector3(0, 0, -1);
|
|
28
|
+
this.wheelAxleCS = new Ammo.btVector3(1, 0, 0);
|
|
29
|
+
this.entity = null;
|
|
30
|
+
this.raycaster = new Ammo.btDefaultVehicleRaycaster(world.dynamicAmmoWorld);
|
|
31
|
+
this.nativeVehicle = new Ammo.btRaycastVehicle(this.vehicleTuning, this.chassisBody.nativeBody, this.raycaster);
|
|
32
|
+
this.raycaster.set_m_collisionFilterGroup(BitMask.pack(this.chassisBody.ownCollisionGroups, 16));
|
|
33
|
+
this.raycaster.set_m_collisionFilterMask(BitMask.pack(this.chassisBody.interactWithCollisionGroups, 16));
|
|
34
|
+
this.nativeVehicle.setCoordinateSystem(0, 2, 1);
|
|
35
|
+
}
|
|
36
36
|
get wheelSpeed() {
|
|
37
37
|
// FIXME not correct (shows chassis speed in world)
|
|
38
38
|
return this.nativeVehicle.getCurrentSpeedKmHour() / 3.6;
|
|
File without changes
|
|
@@ -2,13 +2,6 @@ import Ammo from '../ammo.js/ammo';
|
|
|
2
2
|
import { AmmoBodyComponent } from './ammo-body.component';
|
|
3
3
|
import { first } from 'rxjs';
|
|
4
4
|
export class AmmoRigidBodyComponent extends AmmoBodyComponent {
|
|
5
|
-
constructor(world, _nativeBody, shape) {
|
|
6
|
-
super(world, _nativeBody, shape);
|
|
7
|
-
this.world = world;
|
|
8
|
-
this._nativeBody = _nativeBody;
|
|
9
|
-
this.shape = shape;
|
|
10
|
-
this.entity = null;
|
|
11
|
-
}
|
|
12
5
|
get linearVelocity() {
|
|
13
6
|
const v = this.nativeBody.getLinearVelocity();
|
|
14
7
|
return { x: v.x(), y: v.y(), z: v.z() };
|
|
@@ -31,6 +24,13 @@ export class AmmoRigidBodyComponent extends AmmoBodyComponent {
|
|
|
31
24
|
return { shape: this.shape, type: 'RIGID_DYNAMIC', sleeping: !this._nativeBody.isActive() };
|
|
32
25
|
}
|
|
33
26
|
}
|
|
27
|
+
constructor(world, _nativeBody, shape) {
|
|
28
|
+
super(world, _nativeBody, shape);
|
|
29
|
+
this.world = world;
|
|
30
|
+
this._nativeBody = _nativeBody;
|
|
31
|
+
this.shape = shape;
|
|
32
|
+
this.entity = null;
|
|
33
|
+
}
|
|
34
34
|
clone() {
|
|
35
35
|
return this.world.factory.createRigidBodyFromShape(this._nativeBody.getCollisionShape(), this.shape, {
|
|
36
36
|
dynamic: !this._nativeBody.isStaticOrKinematicObject(),
|
|
File without changes
|
|
@@ -2,6 +2,15 @@ import { filter, map, Subject } from 'rxjs';
|
|
|
2
2
|
import Ammo from '../ammo.js/ammo';
|
|
3
3
|
import { AmmoBodyComponent } from './ammo-body.component';
|
|
4
4
|
export class AmmoTriggerComponent extends AmmoBodyComponent {
|
|
5
|
+
get debugBodySettings() {
|
|
6
|
+
return { shape: this.shape, type: 'TRIGGER' };
|
|
7
|
+
}
|
|
8
|
+
get onEntityEntered() {
|
|
9
|
+
return this.onEnter$.pipe(map(b => AmmoBodyComponent.nativeBodyReverseMap.get(b)), filter(x => !!x));
|
|
10
|
+
}
|
|
11
|
+
get onEntityLeft() {
|
|
12
|
+
return this.onLeft$.pipe(map(b => AmmoBodyComponent.nativeBodyReverseMap.get(b) || null));
|
|
13
|
+
}
|
|
5
14
|
constructor(world, _nativeBody, shape) {
|
|
6
15
|
super(world, _nativeBody, shape);
|
|
7
16
|
this.world = world;
|
|
@@ -12,15 +21,6 @@ export class AmmoTriggerComponent extends AmmoBodyComponent {
|
|
|
12
21
|
this.onLeft$ = new Subject();
|
|
13
22
|
this.overlaps = new Set();
|
|
14
23
|
}
|
|
15
|
-
get debugBodySettings() {
|
|
16
|
-
return { shape: this.shape, type: 'TRIGGER' };
|
|
17
|
-
}
|
|
18
|
-
get onEntityEntered() {
|
|
19
|
-
return this.onEnter$.pipe(map(b => AmmoBodyComponent.nativeBodyReverseMap.get(b)), filter(x => !!x));
|
|
20
|
-
}
|
|
21
|
-
get onEntityLeft() {
|
|
22
|
-
return this.onLeft$.pipe(map(b => AmmoBodyComponent.nativeBodyReverseMap.get(b) || null));
|
|
23
|
-
}
|
|
24
24
|
checkOverlaps() {
|
|
25
25
|
const numOverlappingObjects = this.nativeBody.getNumOverlappingObjects();
|
|
26
26
|
const newOverlaps = new Set(new Array(numOverlappingObjects).fill(null).map((_, i) => this.nativeBody.getOverlappingObject(i)));
|
|
File without changes
|
|
@@ -12,18 +12,6 @@ import Ammo from '../ammo.js/ammo';
|
|
|
12
12
|
import { AmmoFactory } from '../ammo-factory';
|
|
13
13
|
import { AmmoLoader } from '../ammo-loader';
|
|
14
14
|
export class AmmoWorldComponent {
|
|
15
|
-
constructor() {
|
|
16
|
-
this._factory = null;
|
|
17
|
-
this.afterTick$ = new Subject();
|
|
18
|
-
this.added$ = new Subject();
|
|
19
|
-
this.removed$ = new Subject();
|
|
20
|
-
this.children = [];
|
|
21
|
-
this._loader = null;
|
|
22
|
-
this._gravity = { x: 0, y: 0, z: -9.82 };
|
|
23
|
-
this.lockedCollisionGroups = [];
|
|
24
|
-
this.added$.subscribe(c => this.children.push(c));
|
|
25
|
-
this.removed$.subscribe(c => this.children.splice(this.children.indexOf(c), 1));
|
|
26
|
-
}
|
|
27
15
|
get factory() {
|
|
28
16
|
if (!this._factory) {
|
|
29
17
|
throw new Error('Ammo world not initialized');
|
|
@@ -50,6 +38,18 @@ export class AmmoWorldComponent {
|
|
|
50
38
|
get dynamicAmmoWorld() {
|
|
51
39
|
return this._dynamicAmmoWorld;
|
|
52
40
|
}
|
|
41
|
+
constructor() {
|
|
42
|
+
this._factory = null;
|
|
43
|
+
this.afterTick$ = new Subject();
|
|
44
|
+
this.added$ = new Subject();
|
|
45
|
+
this.removed$ = new Subject();
|
|
46
|
+
this.children = [];
|
|
47
|
+
this._loader = null;
|
|
48
|
+
this._gravity = { x: 0, y: 0, z: -9.82 };
|
|
49
|
+
this.lockedCollisionGroups = [];
|
|
50
|
+
this.added$.subscribe(c => this.children.push(c));
|
|
51
|
+
this.removed$.subscribe(c => this.children.splice(this.children.indexOf(c), 1));
|
|
52
|
+
}
|
|
53
53
|
init() {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
yield Ammo.bind(Ammo)(Ammo);
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AmmoTriggerComponent } from './components/ammo-trigger.component';
|
|
|
3
3
|
import { AmmoRaycastVehicleComponent } from './components/ammo-raycast-vehicle.component';
|
|
4
4
|
import { AmmoFactory } from './ammo-factory';
|
|
5
5
|
import { AmmoLoader } from './ammo-loader';
|
|
6
|
-
export
|
|
6
|
+
export type AmmoPhysicsTypeDocRepo = {
|
|
7
7
|
factory: AmmoFactory;
|
|
8
8
|
loader: AmmoLoader;
|
|
9
9
|
rigidBody: AmmoRigidBodyComponent;
|
package/dist/types.js
CHANGED
|
File without changes
|
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.48",
|
|
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,18 +34,18 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@gg-web-engine/core": "0.0.
|
|
38
|
-
"@types/jest": "^29.5.
|
|
39
|
-
"jest": "^29.
|
|
40
|
-
"jest-environment-jsdom": "^29.
|
|
37
|
+
"@gg-web-engine/core": "0.0.48",
|
|
38
|
+
"@types/jest": "^29.5.12",
|
|
39
|
+
"jest": "^29.7.0",
|
|
40
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
41
41
|
"mini-signals": "2.0.0",
|
|
42
|
-
"prettier": "^
|
|
42
|
+
"prettier": "^3.3.3",
|
|
43
43
|
"rxjs": "7.8.1",
|
|
44
|
-
"ts-jest": "^29.
|
|
45
|
-
"typescript": "~
|
|
44
|
+
"ts-jest": "^29.2.4",
|
|
45
|
+
"typescript": "~5.5.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@gg-web-engine/core": "0.0.
|
|
48
|
+
"@gg-web-engine/core": "0.0.48",
|
|
49
49
|
"mini-signals": "2.0.0",
|
|
50
50
|
"rxjs": "7.8.1"
|
|
51
51
|
},
|
|
File without changes
|
package/tsconfig.json
CHANGED
|
File without changes
|