@gg-web-engine/ammo 0.0.40 → 0.0.49

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 CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  # Define variables
2
- AMMOJS_GIT_REPO=https://github.com/i12345/ammo.js.git
3
- AMMOJS_GIT_COMMIT=98d8fb3e8d5b3f3b581e7c5fe8856edb91b578d8
2
+ AMMOJS_GIT_REPO=https://github.com/AndyGura/ammo.js.git
3
+ AMMOJS_GIT_COMMIT=c3d7c801e49c0f41273874e643da4794e1915bf8
4
4
  BULLET_GIT_REPO=https://github.com/bulletphysics/bullet3.git
5
5
  BULLET_GIT_COMMIT=2c204c49e56ed15ec5fcfa71d199ab6d6570b3f5 # 3.25 release
6
6
  REPLACE_SRC_DIR=./patch_files
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -17,21 +17,28 @@ export class AmmoFactory {
17
17
  return new AmmoRaycastVehicleComponent(this.world, chassis);
18
18
  }
19
19
  createShape(descriptor) {
20
+ let shape;
20
21
  switch (descriptor.shape) {
21
22
  case 'PLANE':
22
- return new Ammo.btStaticPlaneShape(new Ammo.btVector3(0, 0, 1), 0);
23
+ shape = new Ammo.btStaticPlaneShape(new Ammo.btVector3(0, 0, 1), 0);
24
+ break;
23
25
  case 'BOX':
24
- return new Ammo.btBoxShape(new Ammo.btVector3(descriptor.dimensions.x / 2, descriptor.dimensions.y / 2, descriptor.dimensions.z / 2));
26
+ shape = new Ammo.btBoxShape(new Ammo.btVector3(descriptor.dimensions.x / 2, descriptor.dimensions.y / 2, descriptor.dimensions.z / 2));
27
+ break;
25
28
  case 'CAPSULE':
26
- return new Ammo.btCapsuleShapeZ(descriptor.radius, descriptor.centersDistance);
29
+ shape = new Ammo.btCapsuleShapeZ(descriptor.radius, descriptor.centersDistance);
30
+ break;
27
31
  case 'CYLINDER':
28
- return new Ammo.btCylinderShapeZ(new Ammo.btVector3(descriptor.radius, descriptor.radius, descriptor.height / 2));
32
+ shape = new Ammo.btCylinderShapeZ(new Ammo.btVector3(descriptor.radius, descriptor.radius, descriptor.height / 2));
33
+ break;
29
34
  case 'CONE':
30
- return new Ammo.btConeShapeZ(descriptor.radius, descriptor.height);
35
+ shape = new Ammo.btConeShapeZ(descriptor.radius, descriptor.height);
36
+ break;
31
37
  case 'SPHERE':
32
- return new Ammo.btSphereShape(descriptor.radius);
38
+ shape = new Ammo.btSphereShape(descriptor.radius);
39
+ break;
33
40
  case 'COMPOUND':
34
- const compoundShape = new Ammo.btCompoundShape();
41
+ let cs = new Ammo.btCompoundShape();
35
42
  for (const item of descriptor.children) {
36
43
  const subShape = this.createShape(item.shape);
37
44
  if (!subShape) {
@@ -42,19 +49,21 @@ export class AmmoFactory {
42
49
  const rot = item.rotation || Qtrn.O;
43
50
  subShapeTransform.setOrigin(new Ammo.btVector3(pos.x, pos.y, pos.z));
44
51
  subShapeTransform.setRotation(new Ammo.btQuaternion(rot.x, rot.y, rot.z, rot.w));
45
- compoundShape.addChildShape(subShapeTransform, subShape);
52
+ cs.addChildShape(subShapeTransform, subShape);
46
53
  }
47
- return compoundShape;
54
+ shape = cs;
55
+ break;
48
56
  case 'CONVEX_HULL':
49
- const shape = new Ammo.btConvexHullShape();
57
+ const s = new Ammo.btConvexHullShape();
50
58
  const tmpVector = new Ammo.btVector3();
51
59
  for (const v of descriptor.vertices) {
52
60
  tmpVector.setValue(v.x, v.y, v.z);
53
- shape.addPoint(tmpVector);
61
+ s.addPoint(tmpVector);
54
62
  }
55
63
  Ammo.destroy(tmpVector);
56
- shape.recalcLocalAabb();
57
- return shape;
64
+ s.recalcLocalAabb();
65
+ shape = s;
66
+ break;
58
67
  case 'MESH':
59
68
  const mesh = new Ammo.btTriangleMesh(true, true);
60
69
  const tmpVectors = [
@@ -71,9 +80,15 @@ export class AmmoFactory {
71
80
  tmpVectors.forEach(v => {
72
81
  Ammo.destroy(v);
73
82
  });
74
- return new Ammo.btBvhTriangleMeshShape(mesh, false, true);
83
+ shape = new Ammo.btBvhTriangleMeshShape(mesh, false, true);
84
+ break;
85
+ default:
86
+ throw new Error(`Shape "${descriptor.shape}" not implemented for Ammo.js`);
75
87
  }
76
- throw new Error(`Shape "${descriptor.shape}" not implemented for Ammo.js`);
88
+ if (descriptor.collisionMargin) {
89
+ shape.setMargin(descriptor.collisionMargin);
90
+ }
91
+ return shape;
77
92
  }
78
93
  createRigidBodyFromShape(nativeShape, shapeDescr, options, transform) {
79
94
  if (options.dynamic === false) {
File without changes
File without changes
File without changes
File without changes