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

78 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-10-30 19:34:26 +01:00
/**
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
* @param graphics GameLib.GraphicsRuntime
* @param apiMeshLine
2017-10-30 19:34:26 +01:00
* @constructor
*/
GameLib.D3.Mesh.Line = function (
2017-10-30 19:34:26 +01:00
graphics,
apiMeshLine
2017-10-30 19:34:26 +01:00
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMeshLine)) {
apiMeshLine = {
2017-12-04 13:23:15 +01:00
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
2017-10-30 19:34:26 +01:00
}
GameLib.D3.API.Mesh.Line.call(
this,
apiMeshLine,
apiMeshLine.lineWidth
);
2017-10-30 19:34:26 +01:00
GameLib.D3.Mesh.call(
this,
this.graphics,
this
2017-10-30 19:34:26 +01:00
);
};
GameLib.D3.Mesh.Line.prototype = Object.create(GameLib.D3.Mesh.prototype);
GameLib.D3.Mesh.Line.prototype.constructor = GameLib.D3.Mesh.Line;
2017-10-30 19:34:26 +01:00
GameLib.D3.Mesh.Line.prototype.createInstance = function() {
2017-10-30 19:34:26 +01:00
var geometry = new THREE.Geometry();
2017-10-30 19:34:26 +01:00
geometry.vertices.push(
this.vertices.map(
function(vertex){
return vertex.instance;
}
)
);
2017-10-30 19:34:26 +01:00
this.instance = new THREE.Line(geometry);
2017-10-30 19:34:26 +01:00
GameLib.D3.Mesh.prototype.createInstance.call(this);
this.instance.userData.lineWidth = this.lineWidth;
2017-10-30 19:34:26 +01:00
};
2017-11-13 15:06:59 +01:00
GameLib.D3.Mesh.Line.prototype.updateInstance = function(property) {
2017-10-30 19:34:26 +01:00
this.instance.linewidth = this.lineWidth;
2017-10-30 19:34:26 +01:00
2017-11-13 15:06:59 +01:00
GameLib.D3.Mesh.prototype.updateInstance.call(this, property);
2017-10-30 19:34:26 +01:00
};
/**
* Converts a GameLib.D3.Mesh.Line to a GameLib.D3.API.Mesh.Line
* @returns {GameLib.D3.API.Mesh.Line}
2017-10-30 19:34:26 +01:00
*/
GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
2017-10-30 19:34:26 +01:00
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
var apiMeshLine = new GameLib.D3.API.Mesh.Line(
2017-10-30 19:34:26 +01:00
apiMesh,
this.lineWidth
2017-10-30 19:34:26 +01:00
);
return apiMeshLine;
2017-10-30 19:34:26 +01:00
};