/** * Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created * @param physics * @param apiShape GameLib.D3.API.Shape * @param halfExtents * @constructor */ GameLib.D3.Shape.Box = function ( physics, apiShape, halfExtents ) { this.physics = physics; this.physics.isNotCannonThrow(); if (GameLib.Utils.UndefinedOrNull(halfExtents)) { halfExtents = new GameLib.Vector3( physics, new GameLib.API.Vector3( 1,1,1 ) ); } this.halfExtents = halfExtents; GameLib.D3.Shape.call( this, this.physics, apiShape ); }; GameLib.D3.Shape.Box.prototype = Object.create(GameLib.D3.Shape.prototype); GameLib.D3.Shape.Box.prototype.constructor = GameLib.D3.Shape.Box; /** * * @returns {GameLib.D3.Shape.Box|*|SEA3D.Box} */ GameLib.D3.Shape.Box.prototype.createInstance = function() { var instance = new CANNON.Box( this.halfExtents.instance ); return instance; }; GameLib.D3.Shape.Box.prototype.updateInstance = function() { this.instance.halfExtents.x = this.halfExtents.x; this.instance.halfExtents.y = this.halfExtents.y; this.instance.halfExtents.z = this.halfExtents.z; this.instance.updateAABB(); this.instance.updateBoundingSphereRadius(); this.instance.updateEdges(); this.instance.updateNormals(); this.instance.updateTree(); };