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

78 lines
1.8 KiB
JavaScript

/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime
* @param apiMeshLine
* @constructor
*/
GameLib.D3.Mesh.Line = function (
graphics,
apiMeshLine
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
}
GameLib.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
GameLib.D3.Mesh.call(
this,
this.graphics,
this
);
};
GameLib.D3.Mesh.Line.prototype = Object.create(GameLib.D3.Mesh.prototype);
GameLib.D3.Mesh.Line.prototype.constructor = GameLib.D3.Mesh.Line;
GameLib.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);
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.lineWidth = this.lineWidth;
};
GameLib.D3.Mesh.Line.prototype.updateInstance = function(property) {
this.instance.linewidth = this.lineWidth;
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
};
/**
* Converts a GameLib.D3.Mesh.Line to a GameLib.D3.API.Mesh.Line
* @returns {GameLib.D3.API.Mesh.Line}
*/
GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshLine = new GameLib.D3.API.Mesh.Line(
apiMesh,
this.lineWidth
);
return apiMeshLine;
};