api objects can no longer be instances of runtime objects

beta.r3js.org
-=yb4f310 2018-01-07 12:58:15 +01:00
parent 5775e1fc58
commit 9ee7b26c1e
67 changed files with 89 additions and 353 deletions

View File

@ -49,66 +49,3 @@ GameLib.API.Color.FromObject = function(objectColor) {
);
};
/**
* Converts the current color to HTML hex format (ex. #ffffff)
* @returns {string}
*/
GameLib.API.Color.prototype.toHex = function() {
if (this.r < 0) {
this.r = 0;
}
if (this.g < 0) {
this.g = 0;
}
if (this.b < 0) {
this.b = 0;
}
if (this.r > 1) {
this.r = 1;
}
if (this.g > 1) {
this.g = 1;
}
if (this.b > 1) {
this.b = 1;
}
var rf = Math.floor(this.r >= 1? 255 : this.r * 256.0).toString(16);
var gf = Math.floor(this.g >= 1? 255 : this.g * 256.0).toString(16);
var bf = Math.floor(this.b >= 1? 255 : this.b * 256.0).toString(16);
if (rf.length < 2) {
rf = '0' + rf;
}
if (gf.length < 2) {
gf = '0' + gf;
}
if (bf.length < 2) {
bf = '0' + bf;
}
return '#' + rf + gf + bf;
};
/**
* Sets this object color to what the hex value is
* @param hex
* @returns {string}
*/
GameLib.API.Color.prototype.fromHex = function(hex) {
var matches = hex.match(new RegExp('#+(..)(..)(..)'));
this.r = parseInt(matches[1], 16) / 255.0;
this.g = parseInt(matches[2], 16) / 255.0;
this.b = parseInt(matches[3], 16) / 255.0;
};

View File

@ -11,10 +11,6 @@ GameLib.Canvas = function(
apiCanvas = {};
}
if (apiCanvas instanceof GameLib.Canvas) {
return apiCanvas;
}
GameLib.API.Canvas.call(
this,
apiCanvas.id,

View File

@ -16,10 +16,6 @@ GameLib.Clock = function(
apiClock = {};
}
if (apiClock instanceof GameLib.Clock) {
return apiClock;
}
GameLib.API.Clock.call(
this,
apiClock.id,

View File

@ -20,10 +20,6 @@ GameLib.Color = function (
apiColor = {};
}
if (apiColor instanceof GameLib.Color) {
return apiColor;
}
GameLib.API.Color.call(
this,
apiColor.r,
@ -87,3 +83,66 @@ GameLib.Color.prototype.toApiObject = function() {
this.a
);
};
/**
* Converts the current color to HTML hex format (ex. #ffffff)
* @returns {string}
*/
GameLib.Color.prototype.toHex = function() {
if (this.r < 0) {
this.r = 0;
}
if (this.g < 0) {
this.g = 0;
}
if (this.b < 0) {
this.b = 0;
}
if (this.r > 1) {
this.r = 1;
}
if (this.g > 1) {
this.g = 1;
}
if (this.b > 1) {
this.b = 1;
}
var rf = Math.floor(this.r >= 1? 255 : this.r * 256.0).toString(16);
var gf = Math.floor(this.g >= 1? 255 : this.g * 256.0).toString(16);
var bf = Math.floor(this.b >= 1? 255 : this.b * 256.0).toString(16);
if (rf.length < 2) {
rf = '0' + rf;
}
if (gf.length < 2) {
gf = '0' + gf;
}
if (bf.length < 2) {
bf = '0' + bf;
}
return '#' + rf + gf + bf;
};
/**
* Sets this object color to what the hex value is
* @param hex
* @returns {string}
*/
GameLib.Color.prototype.fromHex = function(hex) {
var matches = hex.match(new RegExp('#+(..)(..)(..)'));
this.r = parseInt(matches[1], 16) / 255.0;
this.g = parseInt(matches[2], 16) / 255.0;
this.b = parseInt(matches[3], 16) / 255.0;
};

View File

@ -11,11 +11,7 @@ GameLib.Controls = function (
apiControls = {};
}
if (apiControls instanceof GameLib.Controls) {
return apiControls;
}
GameLib.API.Controls.call(
GameLib.API.Controls.call(
this,
apiControls.id,
apiControls.controlsType,

View File

@ -11,11 +11,7 @@ GameLib.CustomCode = function(
apiCustomCode = {};
}
if (apiCustomCode instanceof GameLib.CustomCode) {
return apiCustomCode;
}
GameLib.API.CustomCode.call(
GameLib.API.CustomCode.call(
this,
apiCustomCode.id,
apiCustomCode.name,

View File

@ -11,11 +11,7 @@ GameLib.D3.Animation = function(
apiAnimation = {};
}
if (apiAnimation instanceof GameLib.D3.Animation) {
return apiAnimation;
}
GameLib.D3.API.Animation.call(
GameLib.D3.API.Animation.call(
this,
apiAnimation.id,
apiAnimation.name,

View File

@ -16,10 +16,6 @@ GameLib.D3.Audio = function(
apiAudio = {};
}
if (apiAudio instanceof GameLib.D3.Audio) {
return apiAudio;
}
GameLib.D3.API.Audio.call(
this,
apiAudio.id,

View File

@ -15,11 +15,7 @@ GameLib.D3.BoneWeight = function (
apiBoneWeight = {};
}
if (apiBoneWeight instanceof GameLib.D3.BoneWeight) {
return apiBoneWeight;
}
GameLib.D3.API.BoneWeight.call(
GameLib.D3.API.BoneWeight.call(
this,
apiBoneWeight.boneIndex,
apiBoneWeight.weight

View File

@ -15,11 +15,7 @@ GameLib.D3.Bone = function (
apiBone = {};
}
if (apiBone instanceof GameLib.D3.Bone) {
return apiBone;
}
GameLib.D3.API.Bone.call(
GameLib.D3.API.Bone.call(
this,
apiBone.id,
apiBone.name,

View File

@ -16,10 +16,6 @@ GameLib.D3.Broadphase = function (
apiBroadphase = {};
}
if (apiBroadphase instanceof GameLib.D3.Broadphase) {
return apiBroadphase;
}
GameLib.D3.API.Broadphase.call(
this,
apiBroadphase.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.Camera = function(
apiCamera = {};
}
if (apiCamera instanceof GameLib.D3.Camera) {
return apiCamera;
}
GameLib.D3.API.Camera.call(
this,
apiCamera.id,

View File

@ -16,11 +16,7 @@ GameLib.D3.Composer = function (
apiComposer = {};
}
if (apiComposer instanceof GameLib.D3.Composer) {
return apiComposer;
}
GameLib.D3.API.Composer.call(
GameLib.D3.API.Composer.call(
this,
apiComposer.id,
apiComposer.name,

View File

@ -22,10 +22,6 @@ GameLib.D3.Face = function Face(
apiFace = {};
}
if (apiFace instanceof GameLib.D3.Face) {
return apiFace;
}
GameLib.D3.API.Face.call(
this,
apiFace.id,

View File

@ -16,11 +16,7 @@ GameLib.D3.Fog = function (
apiFog = {};
}
if (apiFog instanceof GameLib.D3.Fog) {
return apiFog;
}
GameLib.D3.API.Fog.call(
GameLib.D3.API.Fog.call(
this,
apiFog.id,
apiFog.name,

View File

@ -15,10 +15,6 @@ GameLib.D3.Font = function(
apiFont = {};
}
if (apiFont instanceof GameLib.D3.Font) {
return apiFont;
}
GameLib.D3.API.Font.call(
this,
apiFont.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.FrictionContactMaterial = function (
apiFrictionContactMaterial = {};
}
if (apiFrictionContactMaterial instanceof GameLib.D3.FrictionContactMaterial) {
return apiFrictionContactMaterial;
}
GameLib.D3.API.FrictionContactMaterial.call(
this,
apiFrictionContactMaterial.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.FrictionMaterial = function (
apiFrictionMaterial = {};
}
if (apiFrictionMaterial instanceof GameLib.D3.FrictionMaterial) {
return apiFrictionMaterial;
}
GameLib.D3.API.FrictionMaterial.call(
this,
apiFrictionMaterial.id,

View File

@ -15,10 +15,6 @@ GameLib.D3.Light = function(
apiLight = {};
}
if (apiLight instanceof GameLib.D3.Light) {
return apiLight;
}
GameLib.D3.API.Light.call(
this,
apiLight.id,

View File

@ -18,11 +18,7 @@ GameLib.D3.Material = function(
apiMaterial = {};
}
if (apiMaterial instanceof GameLib.D3.Material) {
return apiMaterial;
}
GameLib.D3.API.Material.call(
GameLib.D3.API.Material.call(
this,
apiMaterial.id,
apiMaterial.materialType,

View File

@ -17,11 +17,7 @@ GameLib.D3.Mesh = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh) {
return apiMesh;
}
GameLib.D3.API.Mesh.call(
GameLib.D3.API.Mesh.call(
this,
apiMesh.id,
apiMesh.meshType,

View File

@ -23,10 +23,6 @@ GameLib.D3.Mesh.Box = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Box) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(width)) {
width = 1;
}

View File

@ -17,10 +17,6 @@ GameLib.D3.Mesh.Curve = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Curve) {
return apiMesh;
}
GameLib.D3.Mesh.call(
this,
this.graphics,

View File

@ -34,10 +34,6 @@ GameLib.D3.Mesh.Cylinder = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Cylinder) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;
}

View File

@ -19,10 +19,6 @@ GameLib.D3.Mesh.Line = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Line) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
lineWidth = 1;
}

View File

@ -23,10 +23,6 @@ GameLib.D3.Mesh.Sphere = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Sphere) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}

View File

@ -35,10 +35,6 @@ GameLib.D3.Mesh.Text = function (
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Text) {
return apiMesh;
}
if (GameLib.Utils.UndefinedOrNull(text)) {
text = '-=<yb4f310';
}

View File

@ -16,10 +16,6 @@ GameLib.D3.ParticleEngine = function(
apiParticleEngine = {};
}
if (apiParticleEngine instanceof GameLib.D3.ParticleEngine) {
return apiParticleEngine;
}
GameLib.D3.API.ParticleEngine.call(
this,
apiParticleEngine.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.Particle = function(
apiParticle = {};
}
if (apiParticle instanceof GameLib.D3.Particle) {
return apiParticle;
}
GameLib.D3.API.Particle.call(
this,
apiParticle.id,

View File

@ -16,11 +16,7 @@ GameLib.D3.Pass = function (
apiPass = {};
}
if (apiPass instanceof GameLib.D3.Pass) {
return apiPass;
}
GameLib.D3.API.Pass.call(
GameLib.D3.API.Pass.call(
this,
apiPass.id,
apiPass.name,

View File

@ -16,10 +16,6 @@ GameLib.D3.PhysicsWorld = function(
apiWorld = {};
}
if (apiWorld instanceof GameLib.D3.PhysicsWorld) {
return apiWorld;
}
GameLib.D3.API.PhysicsWorld.call(
this,
apiWorld.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.RaycastVehicle = function (
apiRaycastVehicle = {};
}
if (apiRaycastVehicle instanceof GameLib.D3.RaycastVehicle) {
return apiRaycastVehicle;
}
GameLib.D3.API.RaycastVehicle.call(
this,
apiRaycastVehicle.id,

View File

@ -16,10 +16,6 @@ GameLib.D3.RaycastWheel = function (
apiRaycastWheel = {};
}
if (apiRaycastWheel instanceof GameLib.D3.RaycastWheel) {
return apiRaycastWheel;
}
GameLib.D3.API.RaycastWheel.call(
this,
apiRaycastWheel.id,

View File

@ -16,11 +16,7 @@ GameLib.D3.Raycaster = function(
apiRaycaster = {};
}
if (apiRaycaster instanceof GameLib.D3.Raycaster) {
return apiRaycaster;
}
GameLib.D3.API.Raycaster.call(
GameLib.D3.API.Raycaster.call(
this,
apiRaycaster.id,
apiRaycaster.name,

View File

@ -16,11 +16,7 @@ GameLib.D3.RenderTarget = function (
apiRenderTarget = {};
}
if (apiRenderTarget instanceof GameLib.D3.RenderTarget) {
return apiRenderTarget;
}
GameLib.D3.API.RenderTarget.call(
GameLib.D3.API.RenderTarget.call(
this,
apiRenderTarget.id,
apiRenderTarget.name,

View File

@ -16,11 +16,7 @@ GameLib.D3.Renderer = function (
apiRenderer = {};
}
if (apiRenderer instanceof GameLib.D3.Renderer) {
return apiRenderer;
}
GameLib.D3.API.Renderer.call(
GameLib.D3.API.Renderer.call(
this,
apiRenderer.id,
apiRenderer.name,

View File

@ -16,10 +16,6 @@ GameLib.D3.RigidBody = function (
apiRigidBody = {};
}
if (apiRigidBody instanceof GameLib.D3.RigidBody) {
return apiRigidBody;
}
GameLib.D3.API.RigidBody.call(
this,
apiRigidBody.id,

View File

@ -16,11 +16,7 @@ GameLib.D3.Scene = function (
apiScene = {};
}
if (apiScene instanceof GameLib.D3.Scene) {
return apiScene;
}
GameLib.D3.API.Scene.call(
GameLib.D3.API.Scene.call(
this,
apiScene.id,
apiScene.name,

View File

@ -17,11 +17,7 @@ GameLib.D3.Shape = function (
};
}
if (apiShape instanceof GameLib.D3.Shape) {
return apiShape;
}
GameLib.D3.API.Shape.call(
GameLib.D3.API.Shape.call(
this,
apiShape.id,
apiShape.name,

View File

@ -19,10 +19,6 @@ GameLib.D3.Shape.Box = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.Box) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(halfExtents)) {
halfExtents = new GameLib.Vector3(
physics,

View File

@ -25,10 +25,6 @@ GameLib.D3.Shape.ConvexHull = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.ConvexHull) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = [];
}

View File

@ -25,10 +25,6 @@ GameLib.D3.Shape.ConvexHull.Cylinder = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.ConvexHull.Cylinder) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1;
}

View File

@ -25,10 +25,6 @@ GameLib.D3.Shape.HeightMap = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.HeightMap) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(heightData)) {
heightData = [[10, 10, 10], [10, 10, 10], [10, 10, 10]];
}

View File

@ -17,10 +17,6 @@ GameLib.D3.Shape.Plane = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.Plane) {
return apiShape;
}
GameLib.D3.Shape.call(
this,
this.physics,

View File

@ -19,10 +19,6 @@ GameLib.D3.Shape.Sphere = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.Sphere) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1;
}

View File

@ -21,10 +21,6 @@ GameLib.D3.Shape.TriMesh = function (
};
}
if (apiShape instanceof GameLib.D3.Shape.TriMesh) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = [];
}

View File

@ -15,11 +15,7 @@ GameLib.D3.Skeleton = function Skeleton(
apiSkeleton = {};
}
if (apiSkeleton instanceof GameLib.D3.Skeleton) {
return apiSkeleton;
}
GameLib.D3.API.Skeleton.call(
GameLib.D3.API.Skeleton.call(
this,
apiSkeleton.id,
apiSkeleton.name,

View File

@ -16,10 +16,6 @@ GameLib.D3.Solver = function (
apiSolver = {};
}
if (apiSolver instanceof GameLib.D3.Solver) {
return apiSolver;
}
GameLib.D3.API.Solver.call(
this,
apiSolver.id,

View File

@ -15,11 +15,7 @@ GameLib.D3.Spline = function (
apiSpline = {};
}
if (apiSpline instanceof GameLib.D3.Spline) {
return apiSpline;
}
GameLib.D3.API.Spline.call(
GameLib.D3.API.Spline.call(
this,
apiSpline.id,
apiSpline.name,

View File

@ -16,11 +16,7 @@ GameLib.D3.Texture = function(
apiTexture = {};
}
if (apiTexture instanceof GameLib.D3.Texture) {
return apiTexture;
}
GameLib.D3.API.Texture.call(
GameLib.D3.API.Texture.call(
this,
apiTexture.id,
apiTexture.textureType,

View File

@ -21,10 +21,6 @@ GameLib.D3.Vertex = function Vertex(
apiVertex = {};
}
if (apiVertex instanceof GameLib.D3.Vertex) {
return apiVertex;
}
GameLib.D3.API.Vertex.call(
this,
apiVertex.position,

View File

@ -16,11 +16,7 @@ GameLib.D3.Viewport = function (
apiViewport = {};
}
if (apiViewport instanceof GameLib.D3.Viewport) {
return apiViewport;
}
GameLib.D3.API.Viewport.call(
GameLib.D3.API.Viewport.call(
this,
apiViewport.id,
apiViewport.name,

View File

@ -9,10 +9,6 @@ GameLib.DomElement = function (apiDomElement) {
apiDomElement = {};
}
if (apiDomElement instanceof GameLib.DomElement) {
return apiDomElement;
}
GameLib.API.DomElement.call(
this,
apiDomElement.id,

View File

@ -8,10 +8,6 @@ GameLib.EntityManager = function(apiEntityManager) {
apiEntityManager = {};
}
if (apiEntityManager instanceof GameLib.EntityManager) {
return apiEntityManager;
}
GameLib.API.EntityManager.call(
this,
apiEntityManager.id,

View File

@ -10,11 +10,7 @@ GameLib.Entity = function (
apiEntity = {};
}
if (apiEntity instanceof GameLib.Entity) {
return apiEntity;
}
GameLib.API.Entity.call(
GameLib.API.Entity.call(
this,
apiEntity.id,
apiEntity.name,

View File

@ -15,10 +15,6 @@ GameLib.GUI = function(
apiGUI = {};
}
if (apiGUI instanceof GameLib.GUI) {
return apiGUI;
}
GameLib.API.GUI.call(
this,
apiGUI.id,

View File

@ -11,10 +11,6 @@ GameLib.Image = function(
apiImage = {};
}
if (apiImage instanceof GameLib.Image) {
return apiImage;
}
GameLib.API.Image.call(
this,
apiImage.id,

View File

@ -20,11 +20,7 @@ GameLib.Matrix4 = function(
apiMatrix4 = {};
}
if (apiMatrix4 instanceof GameLib.Matrix4) {
return apiMatrix4;
}
GameLib.API.Matrix4.call(
GameLib.API.Matrix4.call(
this,
apiMatrix4.rows[0],
apiMatrix4.rows[1],

View File

@ -10,11 +10,7 @@ GameLib.Mouse = function (apiMouse) {
apiMouse = {};
}
if (apiMouse instanceof GameLib.Mouse) {
return apiMouse;
}
GameLib.API.Mouse.call(
GameLib.API.Mouse.call(
this,
apiMouse.id,
apiMouse.name,

View File

@ -30,11 +30,7 @@ GameLib.Quaternion = function (
apiQuaternion = {};
}
if (apiQuaternion instanceof GameLib.Quaternion) {
return apiQuaternion;
}
GameLib.API.Quaternion.call(
GameLib.API.Quaternion.call(
this,
apiQuaternion.x,
apiQuaternion.y,

View File

@ -11,10 +11,6 @@ GameLib.Server = function(
apiServer = {};
}
if (apiServer instanceof GameLib.Server) {
return apiServer;
}
GameLib.API.Server.call(
this,
apiServer.id,

View File

@ -16,10 +16,6 @@ GameLib.Socket = function(
apiSocket = {};
}
if (apiSocket instanceof GameLib.Socket) {
return apiSocket;
}
GameLib.API.Socket.call(
this,
apiSocket.id,

View File

@ -15,10 +15,6 @@ GameLib.Stats = function(
apiStats = {};
}
if (apiStats instanceof GameLib.Stats) {
return apiStats;
}
GameLib.API.Stats.call(
this,
apiStats.id,

View File

@ -11,11 +11,7 @@ GameLib.System = function(
apiSystem = {};
}
if (apiSystem instanceof GameLib.System) {
return apiSystem;
}
GameLib.API.System.call(
GameLib.API.System.call(
this,
apiSystem.id,
apiSystem.name,

View File

@ -20,11 +20,7 @@ GameLib.Vector2 = function (
apiVector2 = {};
}
if (apiVector2 instanceof GameLib.Vector2) {
return apiVector2;
}
GameLib.API.Vector2.call(
GameLib.API.Vector2.call(
this,
apiVector2.x,
apiVector2.y

View File

@ -31,11 +31,7 @@ GameLib.Vector3 = function (
apiVector3 = {};
}
if (apiVector3 instanceof GameLib.Vector3) {
return apiVector3;
}
GameLib.API.Vector3.call(
GameLib.API.Vector3.call(
this,
apiVector3.x,
apiVector3.y,

View File

@ -20,10 +20,6 @@ GameLib.Vector4 = function (
apiVector4 = {};
}
if (apiVector4 instanceof GameLib.Vector4) {
return apiVector4;
}
GameLib.API.Vector4.call(
this,
apiVector4.x,