60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
|
/**
|
||
|
* R3.D3.Vertex
|
||
|
* @param implementation
|
||
|
* @param apiVertex
|
||
|
* @constructor
|
||
|
*/
|
||
|
R3.D3.Vertex = function Vertex(
|
||
|
implementation,
|
||
|
apiVertex
|
||
|
) {
|
||
|
this.implementation = implementation;
|
||
|
this.implementation.isNotThreeThrow();
|
||
|
|
||
|
if (R3.Utils.UndefinedOrNull(apiVertex)) {
|
||
|
apiVertex = {};
|
||
|
}
|
||
|
|
||
|
R3.D3.API.Vertex.call(
|
||
|
this,
|
||
|
apiVertex.position,
|
||
|
apiVertex.boneWeights
|
||
|
);
|
||
|
|
||
|
this.position = new R3.Vector3(
|
||
|
this.implementation,
|
||
|
this.position,
|
||
|
this
|
||
|
);
|
||
|
|
||
|
this.boneWeights = this.boneWeights.map(
|
||
|
function(boneWeight) {
|
||
|
return new R3.Vector4(
|
||
|
this.graphics,
|
||
|
boneWeight
|
||
|
)
|
||
|
}
|
||
|
);
|
||
|
|
||
|
};
|
||
|
|
||
|
R3.D3.Vertex.prototype = Object.create(R3.Component.prototype);
|
||
|
R3.D3.Vertex.prototype.constructor = R3.D3.Vertex;
|
||
|
|
||
|
/**
|
||
|
* Converts a R3.D3.Vertex to R3.D3.API.Vertex
|
||
|
* @returns {R3.D3.API.Vertex}
|
||
|
*/
|
||
|
R3.D3.Vertex.prototype.toApiObject = function() {
|
||
|
|
||
|
return new R3.D3.API.Vertex(
|
||
|
this.position.toApiObject(),
|
||
|
this.boneWeights.map(
|
||
|
function(boneWeight){
|
||
|
return boneWeight.toApiObject();
|
||
|
}
|
||
|
)
|
||
|
);
|
||
|
|
||
|
};
|