mesh types in mesh constructors (like it should have been)

beta.r3js.org
-=yb4f310 2017-10-29 20:54:34 +01:00
parent 922673e21e
commit 1fb49ac3c1
9 changed files with 90 additions and 1 deletions

View File

@ -69,6 +69,32 @@ GameLib.Utils.LoadIdsFromObjectToIdObject = function(object, idToObject) {
};
/**
* Gets random int exclusive of maximum
* @param min
* @param max
* @returns {*}
* @constructor
*/
GameLib.Utils.GetRandomInt = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
};
/**
* Gets random int inclusive of maximum
* @param min
* @param max
* @returns {*}
* @constructor
*/
GameLib.Utils.GetRandomIntInclusive = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
};
GameLib.Utils.InterpolateArray = function(data, fitCount) {
var linearInterpolate = function (before, after, atPoint) {

View File

@ -267,6 +267,8 @@ GameLib.Component.COMPONENT_MESH_TEXT = 0x3b;
GameLib.Component.COMPONENT_FONT = 0x3c;
GameLib.Component.COMPONENT_CANVAS = 0x3d;
GameLib.Component.COMPONENT_BONE = 0x3e;
GameLib.Component.COMPONENT_MESH_BOX = 0x3f;
GameLib.Component.COMPONENT_MESH_CYLINDER = 0x40;
/**
* Returns string name for component number
@ -338,6 +340,8 @@ GameLib.Component.GetComponentName = function(number) {
case 0x3c : return 'GameLib.D3.Font';
case 0x3d : return 'GameLib.D3.Canvas';
case 0x3e : return 'GameLib.D3.Bone';
case 0x3f : return 'GameLib.D3.Mesh.Box';
case 0x40 : return 'GameLib.D3.Mesh.Cylinder';
break;
}

View File

@ -141,6 +141,14 @@ GameLib.D3.Mesh = function (
componentType = GameLib.Component.COMPONENT_MESH_PLANE
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_BOX) {
componentType = GameLib.Component.COMPONENT_MESH_BOX
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_CYLINDER) {
componentType = GameLib.Component.COMPONENT_MESH_CYLINDER
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_SPHERE) {
componentType = GameLib.Component.COMPONENT_MESH_SPHERE
}

View File

@ -17,6 +17,16 @@ GameLib.D3.Mesh.Box = function (
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_BOX;
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}

View File

@ -27,6 +27,17 @@ GameLib.D3.Mesh.Cylinder = function (
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_CYLINDER;
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;
}

View File

@ -27,6 +27,16 @@ GameLib.D3.Mesh.Plane = function (
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_PLANE;
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}

View File

@ -17,6 +17,16 @@ GameLib.D3.Mesh.Sphere = function (
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_SPHERE;
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}

View File

@ -29,6 +29,16 @@ GameLib.D3.Mesh.Text = function (
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_TEXT;
if (GameLib.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';
}

View File

@ -183,7 +183,7 @@ GameLib.System.Input.prototype.start = function() {
);
}
editorControl.createInstance();
editorControl.domElement.instance.addEventListener(