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