r3-legacy/src/game-lib-shape.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-10-14 12:32:53 +02:00
/**
* Physics Shape Superset
* @constructor
*/
GameLib.D3.Physics.Shape = function(
shapeObject, // Physics engine specific
shapeType
) {
this.shapeObject = shapeObject;
this.shapeType = shapeType;
this.scale = new GameLib.D3.Vector3(1, 1, 1);
};
GameLib.D3.Physics.SHAPE_TYPE_SPHERE = 1;
GameLib.D3.Physics.SHAPE_TYPE_BOX = 2;
GameLib.D3.Physics.SHAPE_TYPE_TRIMESH = 3;
GameLib.D3.Physics.SHAPE_TYPE_CYLINDER = 4;
GameLib.D3.Physics.Shape.prototype.Update = function() {
if(this.physics.engineType === GameLib.D3.Physics.TYPE_CANNON) {
if(this.shapeType === GameLib.D3.Physics.SHAPE_TYPE_TRIMESH) {
this.shapeObject.setScale(
new this.physics.CANNON.Vec3(
this.scale.x,
this.scale.y,
this.scale.z
)
);
this.shapeObject.updateAABB();
this.shapeObject.updateNormals();
this.shapeObject.updateEdges();
this.shapeObject.updateBoundingSphereRadius();
this.shapeObject.updateTree();
}
}
};