mesh line - untested and probably stupid
parent
16eca4acb7
commit
4e82b8dd53
|
@ -279,6 +279,7 @@ GameLib.Component.COMPONENT_SYSTEM_RENDER = 0x47;
|
|||
GameLib.Component.COMPONENT_SYSTEM_STORAGE = 0x48;
|
||||
GameLib.Component.COMPONENT_SYSTEM_VISUALIZATION = 0x49;
|
||||
GameLib.Component.COMPONENT_FOG = 0x50;
|
||||
GameLib.Component.COMPONENT_MESH_LINE = 0x51;
|
||||
|
||||
/**
|
||||
* Returns string name for component number
|
||||
|
@ -362,6 +363,7 @@ GameLib.Component.GetComponentName = function(number) {
|
|||
case 0x48 : return 'GameLib.D3.System.Storage';
|
||||
case 0x49 : return 'GameLib.D3.System.Visualization';
|
||||
case 0x50 : return 'GameLib.D3.Fog';
|
||||
case 0x51 : return 'GameLib.D3.Mesh.Line';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,10 @@ GameLib.D3.Mesh = function (
|
|||
componentType = GameLib.Component.COMPONENT_MESH_SPHERE
|
||||
}
|
||||
|
||||
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_LINE) {
|
||||
componentType = GameLib.Component.COMPONENT_MESH_LINE
|
||||
}
|
||||
|
||||
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_TEXT) {
|
||||
componentType = GameLib.Component.COMPONENT_MESH_TEXT;
|
||||
linkedObjects.font = GameLib.D3.Font;
|
||||
|
@ -188,6 +192,7 @@ GameLib.D3.Mesh.MESH_TYPE_PLANE = 0x4;
|
|||
GameLib.D3.Mesh.MESH_TYPE_BOX = 0x5;
|
||||
GameLib.D3.Mesh.MESH_TYPE_CYLINDER = 0x6;
|
||||
GameLib.D3.Mesh.MESH_TYPE_TEXT = 0x7;
|
||||
GameLib.D3.Mesh.MESH_TYPE_LINE = 0x8;
|
||||
|
||||
GameLib.D3.Mesh.prototype.createInstanceGeometry = function(instanceGeometry) {
|
||||
|
||||
|
|
|
@ -2,17 +2,13 @@
|
|||
* Mesh Superset - The apiMesh properties get moved into the Mesh object itself, and then the instance is created
|
||||
* @param graphics GameLib.D3.Graphics
|
||||
* @param apiMesh GameLib.D3.API.Mesh
|
||||
* @param width
|
||||
* @param height
|
||||
* @param depth
|
||||
* @param lineWidth
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Box = function (
|
||||
GameLib.D3.Mesh.Line = function (
|
||||
graphics,
|
||||
apiMesh,
|
||||
width,
|
||||
height,
|
||||
depth
|
||||
lineWidth
|
||||
) {
|
||||
this.graphics = graphics;
|
||||
this.graphics.isNotThreeThrow();
|
||||
|
@ -21,26 +17,16 @@ GameLib.D3.Mesh.Box = function (
|
|||
apiMesh = {};
|
||||
}
|
||||
|
||||
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
|
||||
if (apiMesh instanceof GameLib.D3.Mesh.Line) {
|
||||
return apiMesh;
|
||||
}
|
||||
|
||||
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_BOX;
|
||||
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_LINE;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(width)) {
|
||||
width = 1;
|
||||
if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
|
||||
lineWidth = 1;
|
||||
}
|
||||
this.width = width;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(height)) {
|
||||
height = 1;
|
||||
}
|
||||
this.height = height;
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(depth)) {
|
||||
depth = 1;
|
||||
}
|
||||
this.depth = depth;
|
||||
this.lineWidth = lineWidth;
|
||||
|
||||
GameLib.D3.Mesh.call(
|
||||
this,
|
||||
|
@ -49,53 +35,31 @@ GameLib.D3.Mesh.Box = function (
|
|||
);
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Box.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Box.prototype.constructor = GameLib.D3.Mesh.Box;
|
||||
GameLib.D3.Mesh.Line.prototype = Object.create(GameLib.D3.Mesh.prototype);
|
||||
GameLib.D3.Mesh.Line.prototype.constructor = GameLib.D3.Mesh.Line;
|
||||
|
||||
GameLib.D3.Mesh.Box.prototype.createInstance = function() {
|
||||
GameLib.D3.Mesh.Line.prototype.createInstance = function() {
|
||||
|
||||
var geometry = null;
|
||||
var geometry = new THREE.Geometry();
|
||||
|
||||
if (this.vertices.length === 0) {
|
||||
geometry = new THREE.BoxGeometry(
|
||||
this.width,
|
||||
this.height,
|
||||
this.depth
|
||||
);
|
||||
geometry.vertices.push(
|
||||
this.vertices.map(
|
||||
function(vertex){
|
||||
return vertex.instance;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
this.updateVerticesFromGeometryInstance(geometry);
|
||||
}
|
||||
this.instance = new THREE.Line(geometry);
|
||||
|
||||
GameLib.D3.Mesh.prototype.createInstance.call(this);
|
||||
|
||||
this.instance.userData.width = this.width;
|
||||
this.instance.userData.height = this.height;
|
||||
this.instance.userData.depth = this.depth;
|
||||
this.instance.userData.lineWidth = this.lineWidth;
|
||||
};
|
||||
|
||||
GameLib.D3.Mesh.Box.prototype.updateInstance = function() {
|
||||
GameLib.D3.Mesh.Line.prototype.updateInstance = function() {
|
||||
|
||||
if (
|
||||
this.instance.userData.width !== this.width ||
|
||||
this.instance.userData.height !== this.height ||
|
||||
this.instance.userData.depth !== this.depth
|
||||
) {
|
||||
this.instance.userData.width = this.width;
|
||||
this.instance.userData.height = this.height;
|
||||
this.instance.userData.depth = this.depth;
|
||||
|
||||
var geometry = new THREE.BoxGeometry(
|
||||
this.width,
|
||||
this.height,
|
||||
this.depth
|
||||
);
|
||||
|
||||
this.updateVerticesFromGeometryInstance(geometry);
|
||||
|
||||
geometry = this.createInstanceGeometry();
|
||||
|
||||
this.instance.geometry = geometry;
|
||||
}
|
||||
this.instance.linewidth = this.lineWidth;
|
||||
|
||||
GameLib.D3.Mesh.prototype.updateInstance.call(this);
|
||||
|
||||
|
@ -105,13 +69,11 @@ GameLib.D3.Mesh.Box.prototype.updateInstance = function() {
|
|||
* Converts a GameLib.D3.Mesh to a GameLib.D3.API.Mesh
|
||||
* @returns {GameLib.D3.API.Mesh}
|
||||
*/
|
||||
GameLib.D3.Mesh.Box.prototype.toApiObject = function() {
|
||||
GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
|
||||
|
||||
var apiMesh = GameLib.D3.Mesh.prototype.toApiObject.call(this);
|
||||
|
||||
apiMesh.width = this.width;
|
||||
apiMesh.height = this.height;
|
||||
apiMesh.depth = this.depth;
|
||||
apiMesh.lineWidth = this.lineWidth;
|
||||
|
||||
return apiMesh;
|
||||
};
|
||||
|
@ -122,16 +84,14 @@ GameLib.D3.Mesh.Box.prototype.toApiObject = function() {
|
|||
* @param objectMesh {Object}
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Mesh.Box.FromObject = function(graphics, objectMesh) {
|
||||
GameLib.D3.Mesh.Line.FromObject = function(graphics, objectMesh) {
|
||||
|
||||
var apiMesh = GameLib.D3.API.Mesh.FromObject(objectMesh);
|
||||
|
||||
return new GameLib.D3.Mesh.Box(
|
||||
return new GameLib.D3.Mesh.Line(
|
||||
graphics,
|
||||
apiMesh,
|
||||
objectMesh.width,
|
||||
objectMesh.height,
|
||||
objectMesh.depth
|
||||
objectMesh.lineWidth
|
||||
);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue