#

API Docs for: 0.6.0
Show: Inherited Protected Private Deprecated

# File: src/shapes/Shape.js

    module.exports = Shape;

    var Shape = require('./Shape');
    var Vec3 = require('../math/Vec3');
    var Quaternion = require('../math/Quaternion');
    var Material = require('../material/Material');

    /**
     * Base class for shapes
     * @class Shape
     * @constructor
     * @author schteppe
     * @todo Should have a mechanism for caching bounding sphere radius instead of calculating it each time
     */
    function Shape(){

        /**
         * The type of this shape. Must be set to an int > 0 by subclasses.
         * @property type
         * @type {Number}
         * @see Shape.types
         */
        this.type = 0;

        /**
         * The local bounding sphere radius of this shape.
         * @property {Number} boundingSphereRadius
         */
        this.boundingSphereRadius = 0;

        /**
         * @property {boolean} collisionResponse
         */
        this.collisionResponse = true;
    }
    Shape.prototype.constructor = Shape;

    /**
     * Computes the bounding sphere radius. The result is stored in the property .boundingSphereRadius
     * @method updateBoundingSphereRadius
     * @return {Number}
     */
    Shape.prototype.updateBoundingSphereRadius = function(){
        throw "computeBoundingSphereRadius() not implemented for shape type "+this.type;
    };

    /**
     * Get the volume of this shape
     * @method volume
     * @return {Number}
     */
    Shape.prototype.volume = function(){
        throw "volume() not implemented for shape type "+this.type;
    };

    /**
     * Calculates the inertia in the local frame for this shape.
     * @method calculateLocalInertia
     * @return {Vec3}
     * @see http://en.wikipedia.org/wiki/List_of_moments_of_inertia
     */
    Shape.prototype.calculateLocalInertia = function(mass,target){
        throw "calculateLocalInertia() not implemented for shape type "+this.type;
    };

    /**
     * The available shape types.
     * @static
     * @property types
     * @type {Object}
     */
    Shape.types = {
        SPHERE:1,
        PLANE:2,
        BOX:4,
        COMPOUND:8,
        CONVEXPOLYHEDRON:16,
        HEIGHTFIELD:32,
        PARTICLE:64,
        CYLINDER:128
    };