/** * 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 points * @param faces * @constructor */ GameLib.D3.Shape.ConvexHull = function ( physics, apiShape, points, faces ) { this.physics = physics; this.physics.isNotCannonThrow(); if (GameLib.Utils.UndefinedOrNull(points)) { points = []; } this.points = points; if (GameLib.Utils.UndefinedOrNull(faces)) { faces = []; } this.faces = faces; GameLib.D3.Shape.call( this, this.physics, apiShape ); }; GameLib.D3.Shape.ConvexHull.prototype = Object.create(GameLib.D3.Shape.prototype); GameLib.D3.Shape.ConvexHull.prototype.constructor = GameLib.D3.Shape.ConvexHull; /** * Create instance * @returns {GameLib.D3.Shape.ConvexHull} */ GameLib.D3.Shape.ConvexHull.prototype.createInstance = function() { var instance = new CANNON.ConvexPolyhedron( this.points.map(function(point){ return point.instance; }), this.faces ); return instance; }; /** * Update instance */ GameLib.D3.Shape.ConvexHull.prototype.updateInstance = function() { // this.instance.vertices = this.vertices; // this.instance.indices = this.indices; // this.instance.updateAABB(); // this.instance.updateBoundingSphereRadius(); // this.instance.updateEdges(); // this.instance.updateNormals(); // this.instance.updateTree(); };