r3-legacy/bak/r3-d3-mesh-line.js

78 lines
1.7 KiB
JavaScript

/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics R3.GraphicsRuntime
* @param apiMeshLine
* @constructor
*/
R3.D3.Mesh.Line = function (
graphics,
apiMeshLine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (R3.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
meshType: R3.D3.API.Mesh.MESH_TYPE_LINE
};
}
R3.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
R3.D3.Mesh.call(
this,
this.graphics,
this
);
};
R3.D3.Mesh.Line.prototype = Object.create(R3.D3.Mesh.prototype);
R3.D3.Mesh.Line.prototype.constructor = R3.D3.Mesh.Line;
R3.D3.Mesh.Line.prototype.createInstance = function() {
var geometry = new THREE.Geometry();
geometry.vertices.push(
this.vertices.map(
function(vertex){
return vertex.instance;
}
)
);
this.instance = new THREE.Line(geometry);
R3.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.lineWidth = this.lineWidth;
};
R3.D3.Mesh.Line.prototype.updateInstance = function(property) {
this.instance.linewidth = this.lineWidth;
R3.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a R3.D3.Mesh.Line to a R3.D3.API.Mesh.Line
* @returns {R3.D3.API.Mesh.Line}
*/
R3.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = R3.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshLine = new R3.D3.API.Mesh.Line(
apiMesh,
this.lineWidth
);
return apiMeshLine;
};