diff --git a/src/game-lib-a-2-utils.js b/src/game-lib-a-2-utils.js index 146c651..60628ec 100644 --- a/src/game-lib-a-2-utils.js +++ b/src/game-lib-a-2-utils.js @@ -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) { diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index 7a300b3..96f1a0f 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -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; } diff --git a/src/game-lib-d3-mesh-0.js b/src/game-lib-d3-mesh-0.js index bbae1e2..2b7c0cb 100644 --- a/src/game-lib-d3-mesh-0.js +++ b/src/game-lib-d3-mesh-0.js @@ -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 } diff --git a/src/game-lib-d3-mesh-box.js b/src/game-lib-d3-mesh-box.js index dccb366..5003629 100644 --- a/src/game-lib-d3-mesh-box.js +++ b/src/game-lib-d3-mesh-box.js @@ -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; } diff --git a/src/game-lib-d3-mesh-cylinder.js b/src/game-lib-d3-mesh-cylinder.js index 24dfb62..c33f67e 100644 --- a/src/game-lib-d3-mesh-cylinder.js +++ b/src/game-lib-d3-mesh-cylinder.js @@ -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; } diff --git a/src/game-lib-d3-mesh-plane.js b/src/game-lib-d3-mesh-plane.js index ffe205b..6025f4a 100644 --- a/src/game-lib-d3-mesh-plane.js +++ b/src/game-lib-d3-mesh-plane.js @@ -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; } diff --git a/src/game-lib-d3-mesh-sphere.js b/src/game-lib-d3-mesh-sphere.js index 3ae9d75..8aba1ac 100644 --- a/src/game-lib-d3-mesh-sphere.js +++ b/src/game-lib-d3-mesh-sphere.js @@ -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; } diff --git a/src/game-lib-d3-mesh-text.js b/src/game-lib-d3-mesh-text.js index 393e345..33e7b43 100644 --- a/src/game-lib-d3-mesh-text.js +++ b/src/game-lib-d3-mesh-text.js @@ -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 = '-=