38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
|
/**
|
||
|
* 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();
|
||
|
}
|
||
|
}
|
||
|
};
|