2016-10-14 12:32:53 +02:00
|
|
|
/**
|
2016-12-22 17:22:19 +01:00
|
|
|
* Runtime Vertex
|
2016-10-14 12:32:53 +02:00
|
|
|
* @constructor
|
2016-12-22 17:22:19 +01:00
|
|
|
* @param graphics
|
|
|
|
* @param apiVertex
|
2016-10-14 12:32:53 +02:00
|
|
|
*/
|
2016-11-21 16:08:39 +01:00
|
|
|
GameLib.D3.Vertex = function Vertex(
|
2016-12-22 17:22:19 +01:00
|
|
|
graphics,
|
|
|
|
apiVertex
|
2016-10-14 12:32:53 +02:00
|
|
|
) {
|
2016-12-22 17:22:19 +01:00
|
|
|
this.graphics = graphics;
|
|
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
|
2017-01-17 13:24:45 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(apiVertex)) {
|
|
|
|
apiVertex = {};
|
|
|
|
}
|
|
|
|
|
2016-12-22 17:22:19 +01:00
|
|
|
GameLib.D3.API.Vertex.call(
|
|
|
|
this,
|
|
|
|
apiVertex.position,
|
|
|
|
apiVertex.boneWeights
|
|
|
|
);
|
|
|
|
|
2016-12-23 16:07:10 +01:00
|
|
|
this.position = new GameLib.Vector3(
|
|
|
|
this.graphics,
|
2017-01-17 13:24:45 +01:00
|
|
|
this.position,
|
|
|
|
null
|
2016-12-23 16:07:10 +01:00
|
|
|
);
|
2016-12-22 17:22:19 +01:00
|
|
|
|
2017-01-06 16:53:53 +01:00
|
|
|
this.boneWeights = this.boneWeights.map(
|
|
|
|
function(apiBoneWeight) {
|
|
|
|
return new GameLib.D3.BoneWeight(
|
|
|
|
this.graphics,
|
|
|
|
apiBoneWeight
|
|
|
|
)
|
|
|
|
}.bind(this)
|
|
|
|
)
|
2016-12-22 17:22:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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(),
|
2017-01-06 16:53:53 +01:00
|
|
|
this.boneWeights.map(function(boneWeight){
|
|
|
|
return boneWeight.toApiBoneWeight();
|
|
|
|
})
|
2016-12-22 17:22:19 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
) {
|
2017-01-05 19:34:28 +01:00
|
|
|
var apiVertex = GameLib.D3.API.Vertex.FromObjectVertex(objectVertex);
|
2016-12-22 17:22:19 +01:00
|
|
|
|
|
|
|
return new GameLib.D3.Vertex(
|
|
|
|
graphics,
|
|
|
|
apiVertex
|
|
|
|
);
|
|
|
|
};
|