/** * 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 vertices * @param indices * @constructor */ GameLib.D3.Shape.TriMesh = function ( physics, apiShape, vertices, indices ) { this.physics = physics; this.physics.isNotCannonThrow(); if (GameLib.Utils.UndefinedOrNull(vertices)) { vertices = []; } this.vertices = vertices; if (GameLib.Utils.UndefinedOrNull(indices)) { indices = []; } this.indices = indices; GameLib.D3.Shape.call( this, this.physics, apiShape ); }; GameLib.D3.Shape.TriMesh.prototype = Object.create(GameLib.D3.Shape.prototype); GameLib.D3.Shape.TriMesh.prototype.constructor = GameLib.D3.Shape.TriMesh; /** * Create instance * @returns {GameLib.D3.Shape.TriMesh} */ GameLib.D3.Shape.TriMesh.prototype.createInstance = function() { var instance = new CANNON.TriMesh( this.vertices, this.indices ); return instance; }; /** * Update instance */ GameLib.D3.Shape.TriMesh.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(); };