construct from object and new

beta.r3js.org
-=yb4f310 2017-12-05 21:19:09 +01:00
parent ee53a76cf0
commit aef4286386
5 changed files with 565 additions and 281 deletions

28
build/game-lib-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
// COMPILE TIME DEFINITIONS (Generated via gulp)
var __DATE__ = "Tue Dec 05 2017 17:00:21 GMT+0100 (CET)";
var __DATE__ = "Tue Dec 05 2017 21:13:00 GMT+0100 (CET)";
// END COMPILE TIME DEFINITIONS
/**
@ -1615,50 +1615,59 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x2 : return {
name : 'GameLib.D3.Material',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Material
constructor : GameLib.D3.Material,
apiConstructor : GameLib.D3.API.Material
};
case 0x3 : return {
name : 'GameLib.D3.Renderer',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Renderer
constructor : GameLib.D3.Renderer,
apiConstructor : GameLib.D3.API.Renderer
};
case 0x4 : return null;
case 0x5 : return {
name : 'GameLib.D3.Camera',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera
constructor : GameLib.D3.Camera,
apiConstructor : GameLib.D3.API.Camera
};
case 0x6 : return null;
case 0x7 : return {
name : 'GameLib.D3.Mesh',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh
constructor : GameLib.D3.Mesh,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x8 : return {
name : 'GameLib.D3.Spline',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Spline
constructor : GameLib.D3.Spline,
apiConstructor : GameLib.D3.API.Spline
};
case 0x9 : return {
name : 'GameLib.D3.Light',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Light
constructor : GameLib.D3.Light,
apiConstructor : GameLib.D3.API.Light
};
case 0xa : return null;
case 0xb : return {
name : 'GameLib.D3.Composer',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Composer
constructor : GameLib.D3.Composer,
apiConstructor : GameLib.D3.API.Composer
};
case 0xc : return {
name : 'GameLib.D3.RenderTarget',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.RenderTarget
constructor : GameLib.D3.RenderTarget,
apiConstructor : GameLib.D3.API.RenderTarget
};
case 0xd : return {
name : 'GameLib.D3.Pass',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Pass
constructor : GameLib.D3.Pass,
apiConstructor : GameLib.D3.API.Pass
};
case 0xe : return {
name : 'GameLib.D3.Scene',
@ -1668,19 +1677,22 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0xf : return {
name : 'GameLib.D3.Raycaster',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Raycaster
constructor : GameLib.D3.Raycaster,
apiConstructor : GameLib.D3.API.Raycaster
};
case 0x10 : return null;
case 0x11 : return null;
case 0x12 : return {
name : 'GameLib.D3.Viewport',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Viewport
constructor : GameLib.D3.Viewport,
apiConstructor : GameLib.D3.API.Viewport
};
case 0x13 : return {
name : 'GameLib.System',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System
constructor : GameLib.System,
apiConstructor : GameLib.API.System
};
case 0x14 : return {
name : 'GameLib.GraphicsRuntime',
@ -1695,43 +1707,51 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x16 : return {
name : 'GameLib.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.CustomCode
constructor : GameLib.CustomCode,
apiConstructor : GameLib.API.CustomCode
};
case 0x17 : return {
name : 'GameLib.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Mouse
constructor : GameLib.Mouse,
apiConstructor : GameLib.API.Mouse
};
case 0x18 : return {
name : 'GameLib.D3.Skeleton',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Skeleton
constructor : GameLib.D3.Skeleton,
apiConstructor : GameLib.D3.API.Skeleton
};
case 0x19 : return {
name : 'GameLib.D3.Texture',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Texture
constructor : GameLib.D3.Texture,
apiConstructor : GameLib.D3.API.Texture
};
case 0x1a : return {
name : 'GameLib.EntityManager',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.EntityManager
constructor : GameLib.EntityManager,
apiConstructor : GameLib.API.EntityManager
};
case 0x1b : return {
name : 'GameLib.DomElement',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.DomElement
constructor : GameLib.DomElement,
apiConstructor : GameLib.API.DomElement
};
case 0x1c : return null;
case 0x1d : return {
name : 'GameLib.Stats',
runtime : GameLib.Component.STATISTICS_RUNTIME,
constructor : GameLib.Stats
constructor : GameLib.Stats,
apiConstructor : GameLib.API.Stats
};
case 0x1e : return {
name : 'GameLib.GUI',
runtime : GameLib.Component.GUI_RUNTIME,
constructor : GameLib.GUI
constructor : GameLib.GUI,
apiConstructor : GameLib.API.GUI
};
case 0x1f : return {
name : 'GameLib.Image',
@ -1741,252 +1761,302 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x20 : return {
name : 'GameLib.Entity',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Entity
constructor : GameLib.Entity,
apiConstructor : GameLib.API.Entity
};
case 0x21 : return {
name : 'GameLib.D3.Mesh.Sphere',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Sphere
constructor : GameLib.D3.Mesh.Sphere,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x22 : return {
name : 'GameLib.D3.Mesh.Plane',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Plane
constructor : GameLib.D3.Mesh.Plane,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x23 : return {
name : 'GameLib.D3.Mesh.Curve',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Curve
constructor : GameLib.D3.Mesh.Curve,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x24 : return {
name : 'GameLib.D3.PhysicsWorld',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.PhysicsWorld
constructor : GameLib.D3.PhysicsWorld,
apiConstructor : GameLib.D3.API.PhysicsWorld
};
case 0x25 : return {
name : 'GameLib.D3.Broadphase',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Broadphase
constructor : GameLib.D3.Broadphase,
apiConstructor : GameLib.D3.API.Broadphase
};
case 0x26 : return {
name : 'GameLib.D3.Solver',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Solver
constructor : GameLib.D3.Solver,
apiConstructor : GameLib.D3.API.Solver
};
case 0x27 : return {
name : 'GameLib.D3.RigidBody',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RigidBody
constructor : GameLib.D3.RigidBody,
apiConstructor : GameLib.D3.API.RigidBody
};
case 0x28 : return {
name : 'GameLib.D3.Shape',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape
constructor : GameLib.D3.Shape,
apiConstructor : GameLib.D3.API.Shape
};
case 0x29 : return {
name : 'GameLib.D3.Shape.Box',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Box
constructor : GameLib.D3.Shape.Box,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2a : return {
name : 'GameLib.D3.Shape.Sphere',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Sphere
constructor : GameLib.D3.Shape.Sphere,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2b : return {
name : 'GameLib.D3.Shape.TriMesh',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.TriMesh
constructor : GameLib.D3.Shape.TriMesh,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2c : return {
name : 'GameLib.D3.Shape.ConvexHull',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull
constructor : GameLib.D3.Shape.ConvexHull,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2d : return {
name : 'GameLib.D3.Shape.ConvexHull.Cylinder',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull.Cylinder
constructor : GameLib.D3.Shape.ConvexHull.Cylinder,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2e : return {
name : 'GameLib.D3.Shape.HeightMap',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Shape.HeightMap
constructor : GameLib.D3.Shape.HeightMap,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2f : return {
name : 'GameLib.D3.Shape.Plane',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Plane
constructor : GameLib.D3.Shape.Plane,
apiConstructor : GameLib.D3.API.Shape
};
case 0x30 : return {
name : 'GameLib.Controls',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls
constructor : GameLib.Controls,
apiConstructor : GameLib.API.Controls
};
case 0x31 : return {
name : 'GameLib.Controls.D3.Editor',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Controls.D3.Editor
constructor : GameLib.Controls.D3.Editor,
apiConstructor : GameLib.API.Controls
};
case 0x32 : return {
name : 'GameLib.Controls.Touch',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Touch
constructor : GameLib.Controls.Touch,
apiConstructor : GameLib.API.Controls
};
case 0x33 : return {
name : 'GameLib.D3.FrictionMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionMaterial
constructor : GameLib.D3.FrictionMaterial,
apiConstructor : GameLib.D3.API.FrictionMaterial
};
case 0x34 : return {
name : 'GameLib.D3.FrictionContactMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionContactMaterial
constructor : GameLib.D3.FrictionContactMaterial,
apiConstructor : GameLib.D3.API.FrictionContactMaterial
};
case 0x35 : return {
name : 'GameLib.D3.RaycastVehicle',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastVehicle
constructor : GameLib.D3.RaycastVehicle,
apiConstructor : GameLib.D3.API.RaycastVehicle
};
case 0x36 : return {
name : 'GameLib.D3.RaycastWheel',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastWheel
constructor : GameLib.D3.RaycastWheel,
apiConstructor : GameLib.D3.API.RaycastWheel
};
case 0x37 : return {
name : 'GameLib.Clock',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Clock
constructor : GameLib.Clock,
apiConstructor : GameLib.API.Clock
};
case 0x38 : return {
name : 'GameLib.D3.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Animation
constructor : GameLib.D3.Animation,
apiConstructor : GameLib.D3.API.Animation
};
case 0x39 : return {
name : 'GameLib.Controls.Keyboard',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Keyboard
constructor : GameLib.Controls.Keyboard,
apiConstructor : GameLib.API.Controls
};
case 0x3a : return {
name : 'GameLib.Controls.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Mouse
constructor : GameLib.Controls.Mouse,
apiConstructor : GameLib.API.Controls
};
case 0x3b : return {
name : 'GameLib.D3.Mesh.Text',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Text
constructor : GameLib.D3.Mesh.Text,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x3c : return {
name : 'GameLib.D3.Font',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Font
constructor : GameLib.D3.Font,
apiConstructor : GameLib.D3.API.Font
};
case 0x3d : return {
name : 'GameLib.Canvas',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Canvas
constructor : GameLib.Canvas,
apiConstructor : GameLib.API.Canvas
};
case 0x3e : return {
name : 'GameLib.D3.Bone',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Bone
constructor : GameLib.D3.Bone,
apiConstructor : GameLib.D3.API.Bone
};
case 0x3f : return {
name : 'GameLib.D3.Mesh.Box',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Box
constructor : GameLib.D3.Mesh.Box,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x40 : return {
name : 'GameLib.D3.Mesh.Cylinder',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Cylinder
constructor : GameLib.D3.Mesh.Cylinder,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x41 : return {
name : 'GameLib.System.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Animation
constructor : GameLib.System.Animation,
apiConstructor : GameLib.API.System
};
case 0x42 : return {
name : 'GameLib.System.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.CustomCode
constructor : GameLib.System.CustomCode,
apiConstructor : GameLib.API.System
};
case 0x43 : return {
name : 'GameLib.System.GUI',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.GUI
constructor : GameLib.System.GUI,
apiConstructor : GameLib.API.System
};
case 0x44 : return {
name : 'GameLib.System.Input',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Input
constructor : GameLib.System.Input,
apiConstructor : GameLib.API.System
};
case 0x45 : return {
name : 'GameLib.System.Linking',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Linking
constructor : GameLib.System.Linking,
apiConstructor : GameLib.API.System
};
case 0x46 : return {
name : 'GameLib.System.Physics',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Physics
constructor : GameLib.System.Physics,
apiConstructor : GameLib.API.System
};
case 0x47 : return {
name : 'GameLib.System.Render',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Render
constructor : GameLib.System.Render,
apiConstructor : GameLib.API.System
};
case 0x48 : return {
name : 'GameLib.System.Storage',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Storage
constructor : GameLib.System.Storage,
apiConstructor : GameLib.API.System
};
case 0x49 : return {
name : 'GameLib.System.Visualization',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Visualization
constructor : GameLib.System.Visualization,
apiConstructor : GameLib.API.System
};
case 0x50 : return {
name : 'GameLib.D3.Fog',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Fog
constructor : GameLib.D3.Fog,
apiConstructor : GameLib.D3.API.Fog
};
case 0x51 : return {
name : 'GameLib.D3.Mesh.Line',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Line
constructor : GameLib.D3.Mesh.Line,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x52 : return {
name : 'GameLib.D3.ParticleEngine',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.ParticleEngine
constructor : GameLib.D3.ParticleEngine,
apiConstructor : GameLib.D3.API.ParticleEngine
};
case 0x53 : return {
name : 'GameLib.System.Particle',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Particle
constructor : GameLib.System.Particle,
apiConstructor : GameLib.API.System
};
case 0x54 : return {
name : 'GameLib.D3.Particle',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Particle
constructor : GameLib.D3.Particle,
apiConstructor : GameLib.D3.API.Particle
};
case 0x55 : return {
name : 'GameLib.D3.Audio',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Audio
constructor : GameLib.D3.Audio,
apiConstructor : GameLib.D3.API.Audio
};
case 0x56 : return {
name : 'GameLib.System.Audio',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Audio
constructor : GameLib.System.Audio,
apiConstructor : GameLib.API.System
};
case 0x57 : return {
name : 'GameLib.Cast',
runtime : GameLib.Component.SOCKET_RUNTIME,
constructor : GameLib.Cast
constructor : GameLib.Cast,
apiConstructor : GameLib.API.Cast
};
break;
}
@ -2245,7 +2315,7 @@ GameLib.Component.prototype.clone = function() {
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
var runtimeComponent = GameLib.Component.Construct(apiObject);
var runtimeComponent = GameLib.Component.ConstructFromObject(apiObject);
runtimeComponent.isClone = true;
@ -2389,15 +2459,10 @@ GameLib.Component.prototype.save = function(remote) {
}
};
GameLib.Component.Construct = function(rawComponentObject) {
var runtimeComponent = null;
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = info.constructor;
var fn = componentClass['FromObject'];
/**
* @return {null|Object}
*/
GameLib.Component.GetRuntimeObject = function(runtimeInfo) {
var runtime = null;
@ -2409,57 +2474,98 @@ GameLib.Component.Construct = function(rawComponentObject) {
}
);
if (runtimeInfo === GameLib.Component.GRAPHICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics');
return null;
}
return runtime.graphics;
} else if (runtimeInfo === GameLib.Component.PHYSICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.physics)) {
console.warn('no runtime physics');
return null;
}
return runtime.physics;
} else if (runtimeInfo === GameLib.Component.GUI_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.gui)) {
console.warn('no runtime gui');
return null;
}
return runtime.gui;
} else if (runtimeInfo === GameLib.Component.SOCKET_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.sockets)) {
console.warn('no runtime sockets');
return null;
}
return runtime.sockets;
} else if (runtimeInfo === GameLib.Component.STATISTICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.statistics)) {
console.warn('no runtime statistics');
return null;
}
return runtime.statistics;
} else if (runtimeInfo === GameLib.Component.DEFAULT_RUNTIME) {
} else {
console.log('unknown runtime object found : ' + info.runtime);
}
return null;
};
GameLib.Component.Construct = function(componentType) {
var info = GameLib.Component.GetComponentInfo(componentType);
var componentClass = info.constructor;
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
if (runtime) {
return new componentClass(runtime);
} else {
return new componentClass();
}
};
GameLib.Component.ConstructFromObject = function(rawComponentObject) {
var runtimeComponent = null;
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = info.constructor;
var fn = componentClass['FromObject'];
if (rawComponentObject.componentType === GameLib.Component.ENTITY) {
runtimeComponent = fn(rawComponentObject, GameLib.EntityManager.Instance);
} else if (info.runtime === GameLib.Component.GRAPHICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics');
}
runtimeComponent = fn(runtime.graphics, rawComponentObject);
} else if (info.runtime === GameLib.Component.PHYSICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.physics)) {
console.warn('no runtime physics');
}
runtimeComponent = fn(runtime.physics, rawComponentObject);
} else if (info.runtime === GameLib.Component.GUI_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.gui)) {
console.warn('no runtime gui');
}
runtimeComponent = fn(runtime.gui, rawComponentObject);
} else if (info.runtime === GameLib.Component.SOCKET_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.sockets)) {
console.warn('no runtime sockets');
}
runtimeComponent = fn(runtime.sockets, rawComponentObject);
} else if (info.runtime === GameLib.Component.STATISTICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.statistics)) {
console.warn('no runtime statistics');
}
runtimeComponent = fn(runtime.statistics, rawComponentObject);
} else if (info.runtime === GameLib.Component.DEFAULT_RUNTIME) {
runtimeComponent = fn(rawComponentObject);
} else {
console.log('unknown runtime object found : ' + rawComponentObject.name);
console.error(rawComponentObject);
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
if (runtime) {
runtimeComponent = fn(runtime, rawComponentObject);
} else {
runtimeComponent = fn(rawComponentObject);
}
}
return runtimeComponent;
@ -7877,9 +7983,45 @@ GameLib.D3.API.Mesh.FromObject = function (objectMesh){
apiModelMatrix = GameLib.API.Matrix4.FromObject(objectMesh.modelMatrix);
}
var meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
if (objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_NORMAL ||
objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_SKINNED
) {
meshType = objectMesh.meshType;
}
if (objectMesh.componentType === GameLib.Component.MESH_PLANE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE;
}
if (objectMesh.componentType === GameLib.Component.MESH_SPHERE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE;
}
if (objectMesh.componentType === GameLib.Component.MESH_CURVE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE;
}
if (objectMesh.componentType === GameLib.Component.MESH_BOX) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX;
}
if (objectMesh.componentType === GameLib.Component.MESH_CYLINDER) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER;
}
if (objectMesh.componentType === GameLib.Component.MESH_TEXT) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT;
}
if (objectMesh.componentType === GameLib.Component.MESH_TYPE_LINE) {
meshType = GameLib.D3.API.Mesh.MESH_LINE;
}
return new GameLib.D3.API.Mesh(
objectMesh.id,
objectMesh.meshType,
meshType,
objectMesh.name,
apiVertices,
apiFaces,
@ -31724,7 +31866,7 @@ GameLib.System.Storage.prototype.createRuntimeObject = function(responseText, cl
* First, we create an API object from the Object, then a Runtime object from the API object
* Each component has a function 'FromObject' which essentially does this for you
*/
var runtimeComponent = GameLib.Component.Construct(object.component[0]);
var runtimeComponent = GameLib.Component.ConstructFromObject(object.component[0]);
if (!runtimeComponent) {
if (clientErrorCallback) {
@ -32116,7 +32258,7 @@ GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
/**
* We are creating a new image
*/
GameLib.Component.Construct(rawImage);
GameLib.Component.ConstructFromObject(rawImage);
}
}.bind(this));
@ -32137,7 +32279,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
*/
data.images.map(
function(rawImageObject) {
var image = GameLib.Component.Construct(rawImageObject);
var image = GameLib.Component.ConstructFromObject(rawImageObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -32151,7 +32293,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Process all textures
*/
data.textures.map(function(rawTextureObject){
var texture = GameLib.Component.Construct(rawTextureObject);
var texture = GameLib.Component.ConstructFromObject(rawTextureObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -32164,7 +32306,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Process all materials
*/
data.materials.map(function(rawMaterialObject){
var material = GameLib.Component.Construct(rawMaterialObject);
var material = GameLib.Component.ConstructFromObject(rawMaterialObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -32177,7 +32319,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Now process all meshes
*/
data.meshes.map(function(rawMeshObject){
var mesh = GameLib.Component.Construct(rawMeshObject);
var mesh = GameLib.Component.ConstructFromObject(rawMeshObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{

View File

@ -314,50 +314,59 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x2 : return {
name : 'GameLib.D3.Material',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Material
constructor : GameLib.D3.Material,
apiConstructor : GameLib.D3.API.Material
};
case 0x3 : return {
name : 'GameLib.D3.Renderer',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Renderer
constructor : GameLib.D3.Renderer,
apiConstructor : GameLib.D3.API.Renderer
};
case 0x4 : return null;
case 0x5 : return {
name : 'GameLib.D3.Camera',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera
constructor : GameLib.D3.Camera,
apiConstructor : GameLib.D3.API.Camera
};
case 0x6 : return null;
case 0x7 : return {
name : 'GameLib.D3.Mesh',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh
constructor : GameLib.D3.Mesh,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x8 : return {
name : 'GameLib.D3.Spline',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Spline
constructor : GameLib.D3.Spline,
apiConstructor : GameLib.D3.API.Spline
};
case 0x9 : return {
name : 'GameLib.D3.Light',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Light
constructor : GameLib.D3.Light,
apiConstructor : GameLib.D3.API.Light
};
case 0xa : return null;
case 0xb : return {
name : 'GameLib.D3.Composer',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Composer
constructor : GameLib.D3.Composer,
apiConstructor : GameLib.D3.API.Composer
};
case 0xc : return {
name : 'GameLib.D3.RenderTarget',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.RenderTarget
constructor : GameLib.D3.RenderTarget,
apiConstructor : GameLib.D3.API.RenderTarget
};
case 0xd : return {
name : 'GameLib.D3.Pass',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Pass
constructor : GameLib.D3.Pass,
apiConstructor : GameLib.D3.API.Pass
};
case 0xe : return {
name : 'GameLib.D3.Scene',
@ -367,19 +376,22 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0xf : return {
name : 'GameLib.D3.Raycaster',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Raycaster
constructor : GameLib.D3.Raycaster,
apiConstructor : GameLib.D3.API.Raycaster
};
case 0x10 : return null;
case 0x11 : return null;
case 0x12 : return {
name : 'GameLib.D3.Viewport',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Viewport
constructor : GameLib.D3.Viewport,
apiConstructor : GameLib.D3.API.Viewport
};
case 0x13 : return {
name : 'GameLib.System',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System
constructor : GameLib.System,
apiConstructor : GameLib.API.System
};
case 0x14 : return {
name : 'GameLib.GraphicsRuntime',
@ -394,43 +406,51 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x16 : return {
name : 'GameLib.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.CustomCode
constructor : GameLib.CustomCode,
apiConstructor : GameLib.API.CustomCode
};
case 0x17 : return {
name : 'GameLib.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Mouse
constructor : GameLib.Mouse,
apiConstructor : GameLib.API.Mouse
};
case 0x18 : return {
name : 'GameLib.D3.Skeleton',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Skeleton
constructor : GameLib.D3.Skeleton,
apiConstructor : GameLib.D3.API.Skeleton
};
case 0x19 : return {
name : 'GameLib.D3.Texture',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Texture
constructor : GameLib.D3.Texture,
apiConstructor : GameLib.D3.API.Texture
};
case 0x1a : return {
name : 'GameLib.EntityManager',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.EntityManager
constructor : GameLib.EntityManager,
apiConstructor : GameLib.API.EntityManager
};
case 0x1b : return {
name : 'GameLib.DomElement',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.DomElement
constructor : GameLib.DomElement,
apiConstructor : GameLib.API.DomElement
};
case 0x1c : return null;
case 0x1d : return {
name : 'GameLib.Stats',
runtime : GameLib.Component.STATISTICS_RUNTIME,
constructor : GameLib.Stats
constructor : GameLib.Stats,
apiConstructor : GameLib.API.Stats
};
case 0x1e : return {
name : 'GameLib.GUI',
runtime : GameLib.Component.GUI_RUNTIME,
constructor : GameLib.GUI
constructor : GameLib.GUI,
apiConstructor : GameLib.API.GUI
};
case 0x1f : return {
name : 'GameLib.Image',
@ -440,252 +460,302 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x20 : return {
name : 'GameLib.Entity',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Entity
constructor : GameLib.Entity,
apiConstructor : GameLib.API.Entity
};
case 0x21 : return {
name : 'GameLib.D3.Mesh.Sphere',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Sphere
constructor : GameLib.D3.Mesh.Sphere,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x22 : return {
name : 'GameLib.D3.Mesh.Plane',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Plane
constructor : GameLib.D3.Mesh.Plane,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x23 : return {
name : 'GameLib.D3.Mesh.Curve',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Curve
constructor : GameLib.D3.Mesh.Curve,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x24 : return {
name : 'GameLib.D3.PhysicsWorld',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.PhysicsWorld
constructor : GameLib.D3.PhysicsWorld,
apiConstructor : GameLib.D3.API.PhysicsWorld
};
case 0x25 : return {
name : 'GameLib.D3.Broadphase',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Broadphase
constructor : GameLib.D3.Broadphase,
apiConstructor : GameLib.D3.API.Broadphase
};
case 0x26 : return {
name : 'GameLib.D3.Solver',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Solver
constructor : GameLib.D3.Solver,
apiConstructor : GameLib.D3.API.Solver
};
case 0x27 : return {
name : 'GameLib.D3.RigidBody',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RigidBody
constructor : GameLib.D3.RigidBody,
apiConstructor : GameLib.D3.API.RigidBody
};
case 0x28 : return {
name : 'GameLib.D3.Shape',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape
constructor : GameLib.D3.Shape,
apiConstructor : GameLib.D3.API.Shape
};
case 0x29 : return {
name : 'GameLib.D3.Shape.Box',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Box
constructor : GameLib.D3.Shape.Box,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2a : return {
name : 'GameLib.D3.Shape.Sphere',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Sphere
constructor : GameLib.D3.Shape.Sphere,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2b : return {
name : 'GameLib.D3.Shape.TriMesh',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.TriMesh
constructor : GameLib.D3.Shape.TriMesh,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2c : return {
name : 'GameLib.D3.Shape.ConvexHull',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull
constructor : GameLib.D3.Shape.ConvexHull,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2d : return {
name : 'GameLib.D3.Shape.ConvexHull.Cylinder',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull.Cylinder
constructor : GameLib.D3.Shape.ConvexHull.Cylinder,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2e : return {
name : 'GameLib.D3.Shape.HeightMap',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Shape.HeightMap
constructor : GameLib.D3.Shape.HeightMap,
apiConstructor : GameLib.D3.API.Shape
};
case 0x2f : return {
name : 'GameLib.D3.Shape.Plane',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Plane
constructor : GameLib.D3.Shape.Plane,
apiConstructor : GameLib.D3.API.Shape
};
case 0x30 : return {
name : 'GameLib.Controls',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls
constructor : GameLib.Controls,
apiConstructor : GameLib.API.Controls
};
case 0x31 : return {
name : 'GameLib.Controls.D3.Editor',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Controls.D3.Editor
constructor : GameLib.Controls.D3.Editor,
apiConstructor : GameLib.API.Controls
};
case 0x32 : return {
name : 'GameLib.Controls.Touch',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Touch
constructor : GameLib.Controls.Touch,
apiConstructor : GameLib.API.Controls
};
case 0x33 : return {
name : 'GameLib.D3.FrictionMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionMaterial
constructor : GameLib.D3.FrictionMaterial,
apiConstructor : GameLib.D3.API.FrictionMaterial
};
case 0x34 : return {
name : 'GameLib.D3.FrictionContactMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionContactMaterial
constructor : GameLib.D3.FrictionContactMaterial,
apiConstructor : GameLib.D3.API.FrictionContactMaterial
};
case 0x35 : return {
name : 'GameLib.D3.RaycastVehicle',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastVehicle
constructor : GameLib.D3.RaycastVehicle,
apiConstructor : GameLib.D3.API.RaycastVehicle
};
case 0x36 : return {
name : 'GameLib.D3.RaycastWheel',
runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastWheel
constructor : GameLib.D3.RaycastWheel,
apiConstructor : GameLib.D3.API.RaycastWheel
};
case 0x37 : return {
name : 'GameLib.Clock',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Clock
constructor : GameLib.Clock,
apiConstructor : GameLib.API.Clock
};
case 0x38 : return {
name : 'GameLib.D3.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Animation
constructor : GameLib.D3.Animation,
apiConstructor : GameLib.D3.API.Animation
};
case 0x39 : return {
name : 'GameLib.Controls.Keyboard',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Keyboard
constructor : GameLib.Controls.Keyboard,
apiConstructor : GameLib.API.Controls
};
case 0x3a : return {
name : 'GameLib.Controls.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Mouse
constructor : GameLib.Controls.Mouse,
apiConstructor : GameLib.API.Controls
};
case 0x3b : return {
name : 'GameLib.D3.Mesh.Text',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Text
constructor : GameLib.D3.Mesh.Text,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x3c : return {
name : 'GameLib.D3.Font',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Font
constructor : GameLib.D3.Font,
apiConstructor : GameLib.D3.API.Font
};
case 0x3d : return {
name : 'GameLib.Canvas',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Canvas
constructor : GameLib.Canvas,
apiConstructor : GameLib.API.Canvas
};
case 0x3e : return {
name : 'GameLib.D3.Bone',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Bone
constructor : GameLib.D3.Bone,
apiConstructor : GameLib.D3.API.Bone
};
case 0x3f : return {
name : 'GameLib.D3.Mesh.Box',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Box
constructor : GameLib.D3.Mesh.Box,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x40 : return {
name : 'GameLib.D3.Mesh.Cylinder',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Cylinder
constructor : GameLib.D3.Mesh.Cylinder,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x41 : return {
name : 'GameLib.System.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Animation
constructor : GameLib.System.Animation,
apiConstructor : GameLib.API.System
};
case 0x42 : return {
name : 'GameLib.System.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.CustomCode
constructor : GameLib.System.CustomCode,
apiConstructor : GameLib.API.System
};
case 0x43 : return {
name : 'GameLib.System.GUI',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.GUI
constructor : GameLib.System.GUI,
apiConstructor : GameLib.API.System
};
case 0x44 : return {
name : 'GameLib.System.Input',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Input
constructor : GameLib.System.Input,
apiConstructor : GameLib.API.System
};
case 0x45 : return {
name : 'GameLib.System.Linking',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Linking
constructor : GameLib.System.Linking,
apiConstructor : GameLib.API.System
};
case 0x46 : return {
name : 'GameLib.System.Physics',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Physics
constructor : GameLib.System.Physics,
apiConstructor : GameLib.API.System
};
case 0x47 : return {
name : 'GameLib.System.Render',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Render
constructor : GameLib.System.Render,
apiConstructor : GameLib.API.System
};
case 0x48 : return {
name : 'GameLib.System.Storage',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Storage
constructor : GameLib.System.Storage,
apiConstructor : GameLib.API.System
};
case 0x49 : return {
name : 'GameLib.System.Visualization',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Visualization
constructor : GameLib.System.Visualization,
apiConstructor : GameLib.API.System
};
case 0x50 : return {
name : 'GameLib.D3.Fog',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Fog
constructor : GameLib.D3.Fog,
apiConstructor : GameLib.D3.API.Fog
};
case 0x51 : return {
name : 'GameLib.D3.Mesh.Line',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Line
constructor : GameLib.D3.Mesh.Line,
apiConstructor : GameLib.D3.API.Mesh
};
case 0x52 : return {
name : 'GameLib.D3.ParticleEngine',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.ParticleEngine
constructor : GameLib.D3.ParticleEngine,
apiConstructor : GameLib.D3.API.ParticleEngine
};
case 0x53 : return {
name : 'GameLib.System.Particle',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Particle
constructor : GameLib.System.Particle,
apiConstructor : GameLib.API.System
};
case 0x54 : return {
name : 'GameLib.D3.Particle',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Particle
constructor : GameLib.D3.Particle,
apiConstructor : GameLib.D3.API.Particle
};
case 0x55 : return {
name : 'GameLib.D3.Audio',
runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Audio
constructor : GameLib.D3.Audio,
apiConstructor : GameLib.D3.API.Audio
};
case 0x56 : return {
name : 'GameLib.System.Audio',
runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Audio
constructor : GameLib.System.Audio,
apiConstructor : GameLib.API.System
};
case 0x57 : return {
name : 'GameLib.Cast',
runtime : GameLib.Component.SOCKET_RUNTIME,
constructor : GameLib.Cast
constructor : GameLib.Cast,
apiConstructor : GameLib.API.Cast
};
break;
}
@ -944,7 +1014,7 @@ GameLib.Component.prototype.clone = function() {
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
var runtimeComponent = GameLib.Component.Construct(apiObject);
var runtimeComponent = GameLib.Component.ConstructFromObject(apiObject);
runtimeComponent.isClone = true;
@ -1088,15 +1158,10 @@ GameLib.Component.prototype.save = function(remote) {
}
};
GameLib.Component.Construct = function(rawComponentObject) {
var runtimeComponent = null;
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = info.constructor;
var fn = componentClass['FromObject'];
/**
* @return {null|Object}
*/
GameLib.Component.GetRuntimeObject = function(runtimeInfo) {
var runtime = null;
@ -1108,57 +1173,98 @@ GameLib.Component.Construct = function(rawComponentObject) {
}
);
if (runtimeInfo === GameLib.Component.GRAPHICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics');
return null;
}
return runtime.graphics;
} else if (runtimeInfo === GameLib.Component.PHYSICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.physics)) {
console.warn('no runtime physics');
return null;
}
return runtime.physics;
} else if (runtimeInfo === GameLib.Component.GUI_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.gui)) {
console.warn('no runtime gui');
return null;
}
return runtime.gui;
} else if (runtimeInfo === GameLib.Component.SOCKET_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.sockets)) {
console.warn('no runtime sockets');
return null;
}
return runtime.sockets;
} else if (runtimeInfo === GameLib.Component.STATISTICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.statistics)) {
console.warn('no runtime statistics');
return null;
}
return runtime.statistics;
} else if (runtimeInfo === GameLib.Component.DEFAULT_RUNTIME) {
} else {
console.log('unknown runtime object found : ' + info.runtime);
}
return null;
};
GameLib.Component.Construct = function(componentType) {
var info = GameLib.Component.GetComponentInfo(componentType);
var componentClass = info.constructor;
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
if (runtime) {
return new componentClass(runtime);
} else {
return new componentClass();
}
};
GameLib.Component.ConstructFromObject = function(rawComponentObject) {
var runtimeComponent = null;
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = info.constructor;
var fn = componentClass['FromObject'];
if (rawComponentObject.componentType === GameLib.Component.ENTITY) {
runtimeComponent = fn(rawComponentObject, GameLib.EntityManager.Instance);
} else if (info.runtime === GameLib.Component.GRAPHICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics');
}
runtimeComponent = fn(runtime.graphics, rawComponentObject);
} else if (info.runtime === GameLib.Component.PHYSICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.physics)) {
console.warn('no runtime physics');
}
runtimeComponent = fn(runtime.physics, rawComponentObject);
} else if (info.runtime === GameLib.Component.GUI_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.gui)) {
console.warn('no runtime gui');
}
runtimeComponent = fn(runtime.gui, rawComponentObject);
} else if (info.runtime === GameLib.Component.SOCKET_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.sockets)) {
console.warn('no runtime sockets');
}
runtimeComponent = fn(runtime.sockets, rawComponentObject);
} else if (info.runtime === GameLib.Component.STATISTICS_RUNTIME) {
if (GameLib.Utils.UndefinedOrNull(runtime.statistics)) {
console.warn('no runtime statistics');
}
runtimeComponent = fn(runtime.statistics, rawComponentObject);
} else if (info.runtime === GameLib.Component.DEFAULT_RUNTIME) {
runtimeComponent = fn(rawComponentObject);
} else {
console.log('unknown runtime object found : ' + rawComponentObject.name);
console.error(rawComponentObject);
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
if (runtime) {
runtimeComponent = fn(runtime, rawComponentObject);
} else {
runtimeComponent = fn(rawComponentObject);
}
}
return runtimeComponent;

View File

@ -281,9 +281,45 @@ GameLib.D3.API.Mesh.FromObject = function (objectMesh){
apiModelMatrix = GameLib.API.Matrix4.FromObject(objectMesh.modelMatrix);
}
var meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
if (objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_NORMAL ||
objectMesh.meshType === GameLib.D3.API.Mesh.MESH_TYPE_SKINNED
) {
meshType = objectMesh.meshType;
}
if (objectMesh.componentType === GameLib.Component.MESH_PLANE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_PLANE;
}
if (objectMesh.componentType === GameLib.Component.MESH_SPHERE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_SPHERE;
}
if (objectMesh.componentType === GameLib.Component.MESH_CURVE) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CURVE;
}
if (objectMesh.componentType === GameLib.Component.MESH_BOX) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_BOX;
}
if (objectMesh.componentType === GameLib.Component.MESH_CYLINDER) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER;
}
if (objectMesh.componentType === GameLib.Component.MESH_TEXT) {
meshType = GameLib.D3.API.Mesh.MESH_TYPE_TEXT;
}
if (objectMesh.componentType === GameLib.Component.MESH_TYPE_LINE) {
meshType = GameLib.D3.API.Mesh.MESH_LINE;
}
return new GameLib.D3.API.Mesh(
objectMesh.id,
objectMesh.meshType,
meshType,
objectMesh.name,
apiVertices,
apiFaces,

View File

@ -340,7 +340,7 @@ GameLib.System.Storage.prototype.createRuntimeObject = function(responseText, cl
* First, we create an API object from the Object, then a Runtime object from the API object
* Each component has a function 'FromObject' which essentially does this for you
*/
var runtimeComponent = GameLib.Component.Construct(object.component[0]);
var runtimeComponent = GameLib.Component.ConstructFromObject(object.component[0]);
if (!runtimeComponent) {
if (clientErrorCallback) {
@ -732,7 +732,7 @@ GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
/**
* We are creating a new image
*/
GameLib.Component.Construct(rawImage);
GameLib.Component.ConstructFromObject(rawImage);
}
}.bind(this));
@ -753,7 +753,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
*/
data.images.map(
function(rawImageObject) {
var image = GameLib.Component.Construct(rawImageObject);
var image = GameLib.Component.ConstructFromObject(rawImageObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -767,7 +767,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Process all textures
*/
data.textures.map(function(rawTextureObject){
var texture = GameLib.Component.Construct(rawTextureObject);
var texture = GameLib.Component.ConstructFromObject(rawTextureObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -780,7 +780,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Process all materials
*/
data.materials.map(function(rawMaterialObject){
var material = GameLib.Component.Construct(rawMaterialObject);
var material = GameLib.Component.ConstructFromObject(rawMaterialObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{
@ -793,7 +793,7 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
* Now process all meshes
*/
data.meshes.map(function(rawMeshObject){
var mesh = GameLib.Component.Construct(rawMeshObject);
var mesh = GameLib.Component.ConstructFromObject(rawMeshObject);
GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED,
{