/** * Runtime Vertex * @constructor * @param graphics * @param apiVertex */ GameLib.D3.Vertex = function Vertex( graphics, apiVertex ) { this.graphics = graphics; this.graphics.isNotThreeThrow(); GameLib.D3.API.Vertex.call( this, apiVertex.position, apiVertex.boneWeights ); this.position = new GameLib.Vector3( this.graphics, null, this.position ); this.boneWeights = this.boneWeights.map( function(apiBoneWeight) { return new GameLib.D3.BoneWeight( this.graphics, apiBoneWeight ) }.bind(this) ) }; GameLib.D3.Vertex.prototype = Object.create(GameLib.D3.API.Vertex.prototype); GameLib.D3.Vertex.prototype.constructor = GameLib.D3.Vertex; /** * Converts a GameLib.D3.Vertex to GameLib.D3.API.Vertex * @returns {GameLib.D3.API.Vertex} */ GameLib.D3.Vertex.prototype.toApiVertex = function() { return new GameLib.D3.API.Vertex( this.position.toApiVector(), this.boneWeights.map(function(boneWeight){ return boneWeight.toApiBoneWeight(); }) ); }; /** * Returns a GameLib.D3.Vertex from a vertex Object * @param graphics GameLib.D3.Graphics * @param objectVertex Object * @returns {GameLib.D3.Vertex} * @constructor */ GameLib.D3.Vertex.FromObjectVertex = function( graphics, objectVertex ) { var apiVertex = GameLib.D3.API.Vertex.FromObjectVertex(objectVertex); return new GameLib.D3.Vertex( graphics, apiVertex ); };