sockets runtime, component construction

beta.r3js.org
-=yb4f310 2017-12-02 11:49:27 +01:00
parent df490baa34
commit ececa4428a
82 changed files with 3006 additions and 1543 deletions

28
build/game-lib-min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -79,7 +79,7 @@ GameLib.Event.STOP_VISUALIZE = 0x3d;
GameLib.Event.FETCH_COMPONENT_TYPES = 0x3e; GameLib.Event.FETCH_COMPONENT_TYPES = 0x3e;
GameLib.Event.FETCH_COMPONENTS = 0x3f; GameLib.Event.FETCH_COMPONENTS = 0x3f;
GameLib.Event.GET_API_URL = 0x40; GameLib.Event.GET_API_URL = 0x40;
GameLib.Event.GET_PHYSICS_IMPLEMENTATION = 0x41; GameLib.Event.GET_RUNTIME = 0x41;
GameLib.Event.PARENT_WORLD_CHANGE = 0x42; GameLib.Event.PARENT_WORLD_CHANGE = 0x42;
GameLib.Event.ANIMATE = 0x43; GameLib.Event.ANIMATE = 0x43;
GameLib.Event.ANIMATION_COMPILE_SUCCESS = 0x44; GameLib.Event.ANIMATION_COMPILE_SUCCESS = 0x44;
@ -92,9 +92,9 @@ GameLib.Event.TOUCH_END = 0x4a;
GameLib.Event.TOUCH_MOVE = 0x4b; GameLib.Event.TOUCH_MOVE = 0x4b;
GameLib.Event.TOUCH_CANCEL = 0x4c; GameLib.Event.TOUCH_CANCEL = 0x4c;
GameLib.Event.GET_REMOTE_API_URL = 0x4d; GameLib.Event.GET_REMOTE_API_URL = 0x4d;
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION = 0x4e; //GameLib.Event.GET_GRAPHICS_RUNTIME = 0x4e;
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f; GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
GameLib.Event.GET_CODER_IMPLEMENTATION = 0x50; //GameLib.Event.GET_CODER_IMPLEMENTATION = 0x50;
GameLib.Event.ANIMATION_MESH_ADDED = 0x51; GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52; GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
GameLib.Event.GET_SCENE = 0x53; GameLib.Event.GET_SCENE = 0x53;
@ -199,7 +199,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x3e : return 'fetch_component_types'; case 0x3e : return 'fetch_component_types';
case 0x3f : return 'fetch_components'; case 0x3f : return 'fetch_components';
case 0x40 : return 'get_api_url'; case 0x40 : return 'get_api_url';
case 0x41 : return 'get_physics_implementation'; case 0x41 : return 'get_runtime';
case 0x42 : return 'parent_world_change'; case 0x42 : return 'parent_world_change';
case 0x43 : return 'animate'; case 0x43 : return 'animate';
case 0x44 : return 'animation_compile_success'; case 0x44 : return 'animation_compile_success';
@ -212,9 +212,9 @@ GameLib.Event.GetEventName = function(number) {
case 0x4b : return 'touch_move'; case 0x4b : return 'touch_move';
case 0x4c : return 'touch_cancel'; case 0x4c : return 'touch_cancel';
case 0x4d : return 'get_remote_api_url'; case 0x4d : return 'get_remote_api_url';
case 0x4e : return 'get_graphics_implementation'; case 0x4e : return 'unused';//'get_graphics_implementation';
case 0x4f : return 'delayed_instance_encountered'; case 0x4f : return 'delayed_instance_encountered';
case 0x50 : return 'get_coder_implementation'; case 0x50 : return 'unused';//'get_coder_implementation';
case 0x51 : return 'animation_mesh_added'; case 0x51 : return 'animation_mesh_added';
case 0x52 : return 'animation_mesh_removed'; case 0x52 : return 'animation_mesh_removed';
case 0x53 : return 'get_scene'; case 0x53 : return 'get_scene';

View File

@ -212,23 +212,23 @@ GameLib.Component.prototype.toString = function() {
return this.id; return this.id;
}; };
GameLib.Component.COMPONENT_PATH_FOLLOWING = 0x1; //GameLib.Component.COMPONENT_PATH_FOLLOWING = 0x1;
GameLib.Component.COMPONENT_MATERIAL = 0x2; GameLib.Component.COMPONENT_MATERIAL = 0x2;
GameLib.Component.COMPONENT_RENDERER = 0x3; GameLib.Component.COMPONENT_RENDERER = 0x3;
GameLib.Component.COMPONENT_LOOK_AT = 0x4; //GameLib.Component.COMPONENT_LOOK_AT = 0x4;
GameLib.Component.COMPONENT_CAMERA = 0x5; GameLib.Component.COMPONENT_CAMERA = 0x5;
GameLib.Component.COMPONENT_FOLLOW = 0x6; //GameLib.Component.COMPONENT_FOLLOW = 0x6;
GameLib.Component.COMPONENT_MESH = 0x7; GameLib.Component.COMPONENT_MESH = 0x7;
GameLib.Component.COMPONENT_SPLINE = 0x8; GameLib.Component.COMPONENT_SPLINE = 0x8;
GameLib.Component.COMPONENT_LIGHT = 0x9; GameLib.Component.COMPONENT_LIGHT = 0x9;
GameLib.Component.COMPONENT_INPUT_DRIVE = 0xa; //GameLib.Component.COMPONENT_INPUT_DRIVE = 0xa;
GameLib.Component.COMPONENT_COMPOSER = 0xb; GameLib.Component.COMPONENT_COMPOSER = 0xb;
GameLib.Component.COMPONENT_RENDER_TARGET = 0xc; GameLib.Component.COMPONENT_RENDER_TARGET = 0xc;
GameLib.Component.COMPONENT_PASS = 0xd; GameLib.Component.COMPONENT_PASS = 0xd;
GameLib.Component.COMPONENT_SCENE = 0xe; GameLib.Component.COMPONENT_SCENE = 0xe;
GameLib.Component.COMPONENT_RAYCASTER = 0xf; GameLib.Component.COMPONENT_RAYCASTER = 0xf;
GameLib.Component.COMPONENT_INPUT_EDITOR = 0x10; //GameLib.Component.COMPONENT_INPUT_EDITOR = 0x10;
GameLib.Component.COMPONENT_EDITOR = 0x11; //GameLib.Component.COMPONENT_EDITOR = 0x11;
GameLib.Component.COMPONENT_VIEWPORT = 0x12; GameLib.Component.COMPONENT_VIEWPORT = 0x12;
GameLib.Component.COMPONENT_SYSTEM = 0x13; GameLib.Component.COMPONENT_SYSTEM = 0x13;
GameLib.Component.COMPONENT_GRAPHICS = 0x14; GameLib.Component.COMPONENT_GRAPHICS = 0x14;
@ -239,7 +239,7 @@ GameLib.Component.COMPONENT_SKELETON = 0x18;
GameLib.Component.COMPONENT_TEXTURE = 0x19; GameLib.Component.COMPONENT_TEXTURE = 0x19;
GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1a; GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1a;
GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1b; GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1b;
GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1c; //GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1c;
GameLib.Component.COMPONENT_STATS = 0x1d; GameLib.Component.COMPONENT_STATS = 0x1d;
GameLib.Component.COMPONENT_GUI = 0x1e; GameLib.Component.COMPONENT_GUI = 0x1e;
GameLib.Component.COMPONENT_IMAGE = 0x1f; GameLib.Component.COMPONENT_IMAGE = 0x1f;
@ -292,6 +292,15 @@ GameLib.Component.COMPONENT_SYSTEM_PARTICLE = 0x53;
GameLib.Component.COMPONENT_PARTICLE = 0x54; GameLib.Component.COMPONENT_PARTICLE = 0x54;
GameLib.Component.COMPONENT_AUDIO = 0x55; GameLib.Component.COMPONENT_AUDIO = 0x55;
GameLib.Component.COMPONENT_SYSTEM_AUDIO = 0x56; GameLib.Component.COMPONENT_SYSTEM_AUDIO = 0x56;
GameLib.Component.COMPONENT_CAST = 0x57;
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
GameLib.Component.PHYSICS_RUNTIME = 0x2;
GameLib.Component.SOCKET_RUNTIME = 0x3;
GameLib.Component.STATISTICS_RUNTIME = 0x4;
GameLib.Component.DEFAULT_RUNTIME = 0x5;
GameLib.Component.GUI_RUNTIME = 0x6;
GameLib.Component.CODER_RUNTIME = 0x7;
/** /**
* Returns string name for component number * Returns string name for component number
@ -299,94 +308,344 @@ GameLib.Component.COMPONENT_SYSTEM_AUDIO = 0x56;
* @returns {*} * @returns {*}
* @constructor * @constructor
*/ */
GameLib.Component.GetComponentName = function(number) { GameLib.Component.GetComponentInfo = function(number) {
switch(number) { switch(number) {
case 0x1 : return 'GameLib.D3.PathFollowing'; case 0x1 : return null;
case 0x2 : return 'GameLib.D3.Material'; case 0x2 : return {
case 0x3 : return 'GameLib.D3.Renderer'; name : 'GameLib.D3.Material',
case 0x4 : return 'GameLib.D3.LookAt'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x5 : return 'GameLib.D3.Camera'; };
case 0x6 : return 'GameLib.D3.Follow'; case 0x3 : return {
case 0x7 : return 'GameLib.D3.Mesh'; name : 'GameLib.D3.Renderer',
case 0x8 : return 'GameLib.D3.Spline'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x9 : return 'GameLib.D3.Light'; };
case 0xa : return 'GameLib.D3.InputDrive'; case 0x4 : return null;
case 0xb : return 'GameLib.D3.Composer'; case 0x5 : return {
case 0xc : return 'GameLib.D3.RenderTarget'; name : 'GameLib.D3.Camera',
case 0xd : return 'GameLib.D3.Pass'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0xe : return 'GameLib.D3.Scene'; };
case 0xf : return 'GameLib.D3.Raycaster'; case 0x6 : return null;
case 0x10 : return 'GameLib.D3.InputEditor'; case 0x7 : return {
case 0x11 : return 'GameLib.D3.Editor'; name : 'GameLib.D3.Mesh',
case 0x12 : return 'GameLib.D3.Viewport'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x13 : return 'GameLib.System'; };
case 0x14 : return 'GameLib.D3.Graphics'; case 0x8 : return {
case 0x15 : return 'GameLib.D3.Helper'; name : 'GameLib.D3.Spline',
case 0x16 : return 'GameLib.D3.CustomCode'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x17 : return 'GameLib.Mouse'; };
case 0x18 : return 'GameLib.D3.Skeleton'; case 0x9 : return {
case 0x19 : return 'GameLib.D3.Texture'; name : 'GameLib.D3.Light',
case 0x1a : return 'GameLib.EntityManager'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x1b : return 'GameLib.DomElement'; };
case 0x1c : return 'GameLib.D3.ImageFactory'; case 0xa : return null;
case 0x1d : return 'GameLib.D3.Stats'; case 0xb : return {
case 0x1e : return 'GameLib.GUI'; name : 'GameLib.D3.Composer',
case 0x1f : return 'GameLib.D3.Image'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x20 : return 'GameLib.Entity'; };
case 0x21 : return 'GameLib.D3.Mesh.Sphere'; case 0xc : return {
case 0x22 : return 'GameLib.D3.Mesh.Plane'; name : 'GameLib.D3.RenderTarget',
case 0x23 : return 'GameLib.D3.Mesh.Curve'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x24 : return 'GameLib.D3.PhysicsWorld'; };
case 0x25 : return 'GameLib.D3.Broadphase'; case 0xd : return {
case 0x26 : return 'GameLib.D3.Solver'; name : 'GameLib.D3.Pass',
case 0x27 : return 'GameLib.D3.RigidBody'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x28 : return 'GameLib.D3.Shape'; };
case 0x29 : return 'GameLib.D3.Shape.Box'; case 0xe : return {
case 0x2a : return 'GameLib.D3.Shape.Sphere'; name : 'GameLib.D3.Scene',
case 0x2b : return 'GameLib.D3.Shape.TriMesh'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x2c : return 'GameLib.D3.Shape.ConvexHull'; };
case 0x2d : return 'GameLib.D3.Shape.ConvexHull.Cylinder'; case 0xf : return {
case 0x2e : return 'GameLib.D3.Shape.HeightMap'; name : 'GameLib.D3.Raycaster',
case 0x2f : return 'GameLib.D3.Shape.Plane'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x30 : return 'GameLib.D3.Controls'; };
case 0x31 : return 'GameLib.D3.Controls.Editor'; case 0x10 : return null;
case 0x32 : return 'GameLib.D3.Controls.Touch'; case 0x11 : return null;
case 0x33 : return 'GameLib.D3.FrictionMaterial'; case 0x12 : return {
case 0x34 : return 'GameLib.D3.FrictionContactMaterial'; name : 'GameLib.D3.Viewport',
case 0x35 : return 'GameLib.D3.RaycastVehicle'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x36 : return 'GameLib.D3.RaycastWheel'; };
case 0x37 : return 'GameLib.Clock'; case 0x13 : return {
case 0x38 : return 'GameLib.D3.Animation'; name : 'GameLib.System',
case 0x39 : return 'GameLib.D3.Controls.Keyboard'; runtime : GameLib.Component.DEFAULT_RUNTIME
case 0x3a : return 'GameLib.D3.Controls.Mouse'; };
case 0x3b : return 'GameLib.D3.Mesh.Text'; case 0x14 : return {
case 0x3c : return 'GameLib.D3.Font'; name : 'GameLib.GraphicsRuntime',
case 0x3d : return 'GameLib.D3.Canvas'; runtime : GameLib.Component.DEFAULT_RUNTIME
case 0x3e : return 'GameLib.D3.Bone'; };
case 0x3f : return 'GameLib.D3.Mesh.Box'; case 0x15 : return {
case 0x40 : return 'GameLib.D3.Mesh.Cylinder'; name : 'GameLib.D3.Helper',
case 0x41 : return 'GameLib.D3.System.Animation'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x42 : return 'GameLib.D3.System.CustomCode'; };
case 0x43 : return 'GameLib.D3.System.GUI'; case 0x16 : return {
case 0x44 : return 'GameLib.D3.System.Input'; name : 'GameLib.D3.CustomCode',
case 0x45 : return 'GameLib.D3.System.Linking'; runtime : GameLib.Component.DEFAULT_RUNTIME
case 0x46 : return 'GameLib.D3.System.Physics'; };
case 0x47 : return 'GameLib.D3.System.Render'; case 0x17 : return {
case 0x48 : return 'GameLib.D3.System.Storage'; name : 'GameLib.Mouse',
case 0x49 : return 'GameLib.D3.System.Visualization'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x50 : return 'GameLib.D3.Fog'; };
case 0x51 : return 'GameLib.D3.Mesh.Line'; case 0x18 : return {
case 0x52 : return 'GameLib.D3.ParticleEngine'; name : 'GameLib.D3.Skeleton',
case 0x53 : return 'GameLib.D3.System.Particle'; runtime : GameLib.Component.GRAPHICS_RUNTIME
case 0x54 : return 'GameLib.D3.Particle'; };
case 0x55 : return 'GameLib.D3.Audio'; case 0x19 : return {
case 0x56 : return 'GameLib.D3.System.Audio'; name : 'GameLib.D3.Texture',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x1a : return {
name : 'GameLib.EntityManager',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x1b : return {
name : 'GameLib.DomElement',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x1c : return null;
case 0x1d : return {
name : 'GameLib.D3.Stats',
runtime : GameLib.Component.STATISTICS_RUNTIME
};
case 0x1e : return {
name : 'GameLib.GUI',
runtime : GameLib.Component.GUI_RUNTIME
};
case 0x1f : return {
name : 'GameLib.D3.Image',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x20 : return {
name : 'GameLib.Entity',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x21 : return {
name : 'GameLib.D3.Mesh.Sphere',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x22 : return {
name : 'GameLib.D3.Mesh.Plane',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x23 : return {
name : 'GameLib.D3.Mesh.Curve',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x24 : return {
name : 'GameLib.D3.PhysicsWorld',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x25 : return {
name : 'GameLib.D3.Broadphase',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x26 : return {
name : 'GameLib.D3.Solver',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x27 : return {
name : 'GameLib.D3.RigidBody',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x28 : return {
name : 'GameLib.D3.Shape',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x29 : return {
name : 'GameLib.D3.Shape.Box',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x2a : return {
name : 'GameLib.D3.Shape.Sphere',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x2b : return {
name : 'GameLib.D3.Shape.TriMesh',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x2c : return {
name : 'GameLib.D3.Shape.ConvexHull',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x2d : return {
name : 'GameLib.D3.Shape.ConvexHull.Cylinder',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x2e : return {
name : 'GameLib.D3.Shape.HeightMap',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x2f : return {
name : 'GameLib.D3.Shape.Plane',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x30 : return {
name : 'GameLib.D3.Controls',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x31 : return {
name : 'GameLib.D3.Controls.Editor',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x32 : return {
name : 'GameLib.D3.Controls.Touch',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x33 : return {
name : 'GameLib.D3.FrictionMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x34 : return {
name : 'GameLib.D3.FrictionContactMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x35 : return {
name : 'GameLib.D3.RaycastVehicle',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x36 : return {
name : 'GameLib.D3.RaycastWheel',
runtime : GameLib.Component.PHYSICS_RUNTIME
};
case 0x37 : return {
name : 'GameLib.Clock',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x38 : return {
name : 'GameLib.D3.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x39 : return {
name : 'GameLib.D3.Controls.Keyboard',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x3a : return {
name : 'GameLib.D3.Controls.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x3b : return {
name : 'GameLib.D3.Mesh.Text',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x3c : return {
name : 'GameLib.D3.Font',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x3d : return {
name : 'GameLib.Canvas',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x3e : return {
name : 'GameLib.D3.Bone',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x3f : return {
name : 'GameLib.D3.Mesh.Box',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x40 : return {
name : 'GameLib.D3.Mesh.Cylinder',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x41 : return {
name : 'GameLib.D3.System.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x42 : return {
name : 'GameLib.D3.System.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x43 : return {
name : 'GameLib.D3.System.GUI',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x44 : return {
name : 'GameLib.D3.System.Input',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x45 : return {
name : 'GameLib.D3.System.Linking',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x46 : return {
name : 'GameLib.D3.System.Physics',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x47 : return {
name : 'GameLib.D3.System.Render',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x48 : return {
name : 'GameLib.D3.System.Storage',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x49 : return {
name : 'GameLib.D3.System.Visualization',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x50 : return {
name : 'GameLib.D3.Fog',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x51 : return {
name : 'GameLib.D3.Mesh.Line',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x52 : return {
name : 'GameLib.D3.ParticleEngine',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x53 : return {
name : 'GameLib.D3.System.Particle',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x54 : return {
name : 'GameLib.D3.Particle',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x55 : return {
name : 'GameLib.D3.Audio',
runtime : GameLib.Component.GRAPHICS_RUNTIME
};
case 0x56 : return {
name : 'GameLib.System.Audio',
runtime : GameLib.Component.DEFAULT_RUNTIME
};
case 0x57 : return {
name : 'GameLib.Cast',
runtime : GameLib.Component.SOCKET_RUNTIME
};
break; break;
} }
throw new Error('Unknown component type: ' + number ); throw new Error('Unknown component type: ' + number );
}; };
/**
* @return {string}
*/
GameLib.Component.GetComponentName = function(componentType) {
var info = GameLib.Component.GetComponentInfo(componentType);
if (info) {
return info.name;
}
return 'unused';
};
/**
* @return {null}
*/
GameLib.Component.GetComponentRuntime = function(componentType) {
var info = GameLib.Component.GetComponentInfo(componentType);
if (info) {
return info.runtime;
}
return null;
};
/** /**
* Components are linked at runtime - for storing, we just store the ID * Components are linked at runtime - for storing, we just store the ID
* @returns {*} * @returns {*}
@ -560,44 +819,21 @@ GameLib.Component.prototype.clone = function() {
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')'; apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
var runtimeObject = null; var runtimeComponent = GameLib.Component.Construct(apiObject);
try { runtimeComponent.isClone = true;
runtimeObject = new this.constructor(this.graphics, apiObject);
} catch (e){
console.log(e);
try {
runtimeObject = new this.constructor(this.physics, apiObject);
} catch (e) {
console.log(e);
try {
runtimeObject = new this.constructor(this.coder, apiObject);
} catch (e) {
console.log(e);
console.log('failed to construct a runtime component');
return;
}
}
}
runtimeObject.isClone = true;
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.COMPONENT_CLONED, GameLib.Event.COMPONENT_CLONED,
{ {
parent : this, parent : this,
component : runtimeObject component : runtimeComponent
} }
); );
runtimeObject.parentEntity = null; runtimeComponent.parentEntity = null;
// if (this.parentEntity instanceof GameLib.Entity) {
// this.parentEntity.addComponent(runtimeObject);
// }
return runtimeObject;
return runtimeComponent;
}; };
/** /**
@ -727,5 +963,79 @@ GameLib.Component.prototype.save = function(remote) {
); );
} }
} }
};
GameLib.Component.Construct = function(rawComponentObject) {
var runtimeComponent = null;
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = eval(info.name);
var fn = componentClass['FromObject'];
var runtime = null;
GameLib.Event.Emit(
GameLib.Event.GET_RUNTIME,
function(runtimeObject) {
runtime = runtimeObject;
}
);
if (rawComponentObject.componentType === GameLib.Component.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);
}
return runtimeComponent;
}; };

View File

@ -7,7 +7,7 @@
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Canvas = function( GameLib.API.Canvas = function(
id, id,
name, name,
width, width,
@ -40,16 +40,16 @@ GameLib.D3.API.Canvas = function(
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.D3.API.Canvas.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Canvas.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Canvas.prototype.constructor = GameLib.D3.API.Canvas; GameLib.API.Canvas.prototype.constructor = GameLib.API.Canvas;
/** /**
* Returns an API light from an Object light * Returns an API light from an Object light
* @param objectCanvas * @param objectCanvas
* @constructor * @constructor
*/ */
GameLib.D3.API.Canvas.FromObject = function(objectCanvas) { GameLib.API.Canvas.FromObject = function(objectCanvas) {
return new GameLib.D3.API.Canvas( return new GameLib.API.Canvas(
objectCanvas.id, objectCanvas.id,
objectCanvas.name, objectCanvas.name,
objectCanvas.width, objectCanvas.width,

86
src/game-lib-api-cast.js Normal file
View File

@ -0,0 +1,86 @@
/**
* Raw Cast API object - should always correspond with the Cast Schema
* @param id
* @param name
* @param castType
* @param roomId
* @param peer
* @param serverIp
* @param port
* @param parentEntity
* @constructor
*/
GameLib.API.Cast = function(
id,
name,
castType,
roomId,
peer,
serverIp,
port,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Cast (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(castType)) {
castType = GameLib.Cast.CAST_TYPE_ROOM;
}
this.castType = castType;
if (GameLib.Utils.UndefinedOrNull(roomId)) {
roomId = 'default';
}
this.roomId = roomId;
if (GameLib.Utils.UndefinedOrNull(peer)) {
peer = null;
}
this.peer = peer;
if (GameLib.Utils.UndefinedOrNull(serverIp)) {
serverIp = '127.0.0.1';
}
this.serverIp = serverIp;
if (GameLib.Utils.UndefinedOrNull(port)) {
port = 80;
}
this.port = port;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
};
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
/**
* Creates an API Cast from an Object Cast
* @param objectCast
* @constructor
*/
GameLib.API.Cast.FromObject = function(objectCast) {
return new GameLib.API.Cast(
objectCast.id,
objectCast.name,
objectCast.castType,
objectCast.roomId,
objectCast.peer,
objectCast.serverIp,
objectCast.port,
objectCast.parentEntity
);
};

94
src/game-lib-canvas.js Normal file
View File

@ -0,0 +1,94 @@
/**
* Canvas object
* @param apiCanvas
* @returns {GameLib.Canvas}
* @constructor
*/
GameLib.Canvas = function(
apiCanvas
) {
if (GameLib.Utils.UndefinedOrNull(apiCanvas)) {
apiCanvas = {};
}
if (apiCanvas instanceof GameLib.Canvas) {
return apiCanvas;
}
GameLib.API.Canvas.call(
this,
apiCanvas.id,
apiCanvas.name,
apiCanvas.width,
apiCanvas.height,
apiCanvas.parentEntity
);
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_CANVAS
);
};
GameLib.Canvas.prototype = Object.create(GameLib.API.Canvas.prototype);
GameLib.Canvas.prototype.constructor = GameLib.Canvas;
/**
* Creates a light instance
* @returns {*}
*/
GameLib.Canvas.prototype.createInstance = function() {
this.instance = document.createElement('canvas');
this.instance.width = this.width;
this.instance.height = this.height;
GameLib.Component.prototype.createInstance.call(this);
};
/**
* Updates the instance with the current state
*/
GameLib.Canvas.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Canvas: ' + property);
}
if (property === 'width') {
this.instance.width = this.width;
}
if (property === 'height') {
this.instance.height = this.height;
}
};
/**
* Converts a GameLib.Canvas to a GameLib.API.Canvas
* @returns {GameLib.API.Canvas}
*/
GameLib.Canvas.prototype.toApiObject = function() {
return new GameLib.API.Canvas(
this.id,
this.name,
this.width,
this.height,
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
/**
* Returns a new GameLib.Canvas from a GameLib.API.Canvas
* @param objectCanvas GameLib.API.Canvas
* @returns {GameLib.Canvas}
*/
GameLib.Canvas.FromObject = function(objectCanvas) {
return new GameLib.Canvas(
GameLib.API.Canvas.FromObject(objectCanvas)
);
};

266
src/game-lib-cast.js Normal file
View File

@ -0,0 +1,266 @@
/**
* Creates a Cast object
* @param socket GameLib.Socket
* @param apiCast GameLib.API.Cast
* @constructor
*/
GameLib.Cast = function(
socket,
apiCast
) {
this.socket = socket;
this.socket.isNotWebSocketThrow();
if (GameLib.Utils.UndefinedOrNull(apiCast)) {
apiCast = {};
}
if (apiCast instanceof GameLib.Cast) {
return apiCast;
}
GameLib.API.Cast.call(
this,
apiCast.id,
apiCast.name,
apiCast.castType,
apiCast.roomId,
apiCast.peer,
apiCast.serverIp,
apiCast.port,
apiCast.parentEntity
);
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_CAST,
{
peer : GameLib.Component
}
);
};
GameLib.Cast.prototype = Object.create(GameLib.API.Cast.prototype);
GameLib.Cast.prototype.constructor = GameLib.Cast;
GameLib.Cast.CAST_TYPE_ROOM = 0x1;
GameLib.Cast.CAST_TYPE_PEER = 0x2;
GameLib.Cast.CAST_TYPE_ALL = 0x3;
GameLib.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
/**
* We don't use a 3rd party particle engine right now
* @returns true
*/
GameLib.Cast.prototype.createInstance = function() {
this.instance = true;
// if (this.templateParticle) {
//
// this.templateParticle.mesh.position.x = this.position.x;
// this.templateParticle.mesh.position.y = this.position.y;
// this.templateParticle.mesh.position.z = this.position.z;
//
// this.templateParticle.direction.x = this.direction.x;
// this.templateParticle.direction.y = this.direction.y;
// this.templateParticle.direction.z = this.direction.z;
//
// this.templateParticle.scale.x = this.scale.x;
// this.templateParticle.scale.y = this.scale.y;
// this.templateParticle.scale.z = this.scale.z;
// }
GameLib.Component.prototype.createInstance.call(this);
};
/**
* Updates the instance with the current state
*/
GameLib.Cast.prototype.updateInstance = function(property) {
if (property === 'particlesPerSecond') {
this.frequency = Number(1 / this.particlesPerSecond);
}
if (property === 'frequency') {
this.particlesPerSecond = Math.round(1 / this.frequency);
}
if (property === 'position') {
this.position.instance.x = this.position.x;
this.position.instance.y = this.position.y;
this.position.instance.z = this.position.z;
this.templateParticle.mesh.position = this.position.clone();
this.templateParticle.mesh.updateInstance('position', true);
}
if (property === 'direction') {
this.direction.instance.x = this.direction.x;
this.direction.instance.y = this.direction.y;
this.direction.instance.z = this.direction.z;
this.templateParticle.direction = this.direction.clone();
this.templateParticle.direction.updateInstance('direction', true);
}
};
GameLib.Cast.prototype.remove = function() {
if (this.removeSubscription) {
console.log('already another remove subscription for ' + this.name);
return;
}
this.removeSubscription = GameLib.Event.Subscribe(
GameLib.Event.REMOVE_PARTICLE_ENGINE,
function(data){
if (data.component === this) {
if (this.isClone) {
/**
* We only remove the things we cloned, the mesh, particle, and this
*/
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component: this.templateParticle.mesh
}
);
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component: this.templateParticle
}
);
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component: this
}
)
} else {
GameLib.Component.prototype.remove.call(this);
}
this.removeSubscription.remove();
this.removeSubscription = null;
}
}.bind(this)
);
/**
* Below signals the particle system to continue processing the particles, but don't create more, and
* we wait for the system to signal REMOVE_PARTICLE_ENGINE so we can destroy ourselves
* @type {boolean}
*/
this.disabledForRemoval = true;
};
// GameLib.Cast.prototype.getChildrenComponents = function() {
//
// var components = [];
//
// if (this.templateParticle) {
// components.push(this.templateParticle);
//
// if (this.templateParticle.mesh) {
// components.push(this.templateParticle.mesh);
//
// if (this.templateParticle.mesh.materials && this.templateParticle.mesh.materials[0]) {
//
// components.push(this.templateParticle.mesh.materials[0]);
//
// if (this.templateParticle.mesh.materials[0].diffuseMap) {
// components.push(this.templateParticle.mesh.materials[0].diffuseMap);
// }
// }
// }
// }
//
// return components;
// };
GameLib.Cast.prototype.clone = function() {
var mesh = this.templateParticle.mesh.clone();
var templateParticle = this.templateParticle.clone();
templateParticle.mesh = mesh;
templateParticle.instance = mesh.instance;
var engine = GameLib.Component.prototype.clone.call(this);
engine.templateParticle = templateParticle;
return engine;
};
GameLib.Cast.prototype.processParticles = function(delta) {
// this.particles = this.particles.reduce(
// function(result, particle){
//
// particle.position.x += particle.userData.direction.x * delta;
// particle.position.y += particle.userData.direction.y * delta;
// particle.position.z += particle.userData.direction.z * delta;
//
// particle.userData.elapsed += delta;
// if (particle.userData.elapsed > particle.userData.lifeTime) {
// particle.parent.remove(particle);
// } else {
// result.push(particle);
// }
//
// return result;
// },
// []
// );
};
GameLib.Cast.prototype.createNewParticle = function(camera) {
//
// var particle = this.templateParticle.clone(camera);
//
// this.particles.push(particle);
};
/**
* Converts a GameLib.Cast to a new GameLib.API.Cast
* @returns {GameLib.API.Cast}
*/
GameLib.Cast.prototype.toApiObject = function() {
return new GameLib.API.Cast(
this.id,
this.name,
this.position.toApiObject(),
this.direction.toApiObject(),
this.enabled,
GameLib.Utils.IdOrNull(this.templateParticle),
this.particlesPerSecond,
this.frequency,
this.elapsed,
GameLib.Utils.IdOrNull(this.camera),
this.pulse,
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
/**
* Converts from an Object Cast to a GameLib.Cast
* @param graphics GameLib.GraphicsRuntime
* @param objectCast Object
* @returns {GameLib.Cast}
* @constructor
*/
GameLib.Cast.FromObject = function(graphics, objectCast) {
var apiCast = GameLib.API.Cast.FromObject(objectCast);
return new GameLib.Cast(
graphics,
apiCast
);
};

View File

@ -1,16 +1,16 @@
/** /**
* Creates a camera object * Creates a Clock object
* @param implementation * @param graphics
* @param apiClock GameLib.API.Clock * @param apiClock GameLib.API.Clock
* @constructor * @constructor
*/ */
GameLib.Clock = function( GameLib.Clock = function(
implementation, graphics,
apiClock apiClock
) { ) {
this.implementation = implementation; this.graphics = graphics;
this.implementation.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiClock)) { if (GameLib.Utils.UndefinedOrNull(apiClock)) {
apiClock = {}; apiClock = {};

View File

@ -0,0 +1,60 @@
/**
* Coder
* @param id
* @param name
* @param coderType
* @constructor
*/
GameLib.CoderRuntime = function(
id,
name,
coderType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Coder (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(coderType)) {
coderType = GameLib.CoderRuntime.TYPE_CODE_MIRROR;
}
this.coderType = coderType;
this.createInstance();
};
/**
* GameLib.CoderRuntime Types
* @type {number}
*/
GameLib.CoderRuntime.TYPE_CODE_MIRROR = 0x1;
GameLib.CoderRuntime.prototype.createInstance = function() {
if (this.coderType === GameLib.CoderRuntime.TYPE_CODE_MIRROR) {
this.instance = CodeMirror;
} else {
this.instance = null;
}
};
GameLib.CoderRuntime.prototype.updateInstance = function(property) {
if (property === 'coderType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.CoderRuntime.prototype.isNotCodeMirrorThrow = function() {
if (!(this.instance instanceof CodeMirror)) {
console.error('Only CodeMirror supported');
throw new Error('Only CodeMirror supported');
}
};

View File

@ -1,6 +1,6 @@
/** /**
* Runtime color for updating instance objects * Runtime color for updating instance objects
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param parentObject GameLib.D3.* * @param parentObject GameLib.D3.*
* @param apiColor GameLib.API.Color * @param apiColor GameLib.API.Color
* @param grain Number * @param grain Number

View File

@ -193,10 +193,10 @@ GameLib.D3.Animation.FromObject = function(objectAnimation) {
GameLib.D3.Animation.prototype.launchEditor = function(){ GameLib.D3.Animation.prototype.launchEditor = function(){
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION, GameLib.Event.GET_RUNTIME,
null, null,
function(coder) { function(runtime) {
this.coder = coder; this.coder = runtime.coder;
this.coder.isNotCodeMirrorThrow(); this.coder.isNotCodeMirrorThrow();
}.bind(this) }.bind(this)
); );

View File

@ -1,6 +1,6 @@
/** /**
* Creates a Audio object * Creates a Audio object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiAudio GameLib.D3.API.Audio * @param apiAudio GameLib.D3.API.Audio
* @constructor * @constructor
*/ */
@ -140,7 +140,7 @@ GameLib.D3.Audio.prototype.toApiObject = function() {
/** /**
* Converts from an Object Audio to a GameLib.D3.Audio * Converts from an Object Audio to a GameLib.D3.Audio
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectAudio Object * @param objectAudio Object
* @returns {GameLib.D3.Audio} * @returns {GameLib.D3.Audio}
* @constructor * @constructor

View File

@ -1,7 +1,7 @@
/** /**
* BoneWeight Superset * BoneWeight Superset
* @constructor * @constructor
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiBoneWeight GameLib.D3.API.BoneWeight * @param apiBoneWeight GameLib.D3.API.BoneWeight
*/ */
GameLib.D3.BoneWeight = function ( GameLib.D3.BoneWeight = function (
@ -45,7 +45,7 @@ GameLib.D3.BoneWeight.prototype.toApiObject = function() {
/** /**
* Returns a GameLib.D3.BoneWeight from a boneWeight Object * Returns a GameLib.D3.BoneWeight from a boneWeight Object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectBoneWeight Object * @param objectBoneWeight Object
* @returns {GameLib.D3.BoneWeight} * @returns {GameLib.D3.BoneWeight}
* @constructor * @constructor

View File

@ -1,7 +1,7 @@
/** /**
* Bone Superset * Bone Superset
* @constructor * @constructor
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiBone GameLib.D3.API.Bone * @param apiBone GameLib.D3.API.Bone
*/ */
GameLib.D3.Bone = function ( GameLib.D3.Bone = function (
@ -141,7 +141,7 @@ GameLib.D3.Bone.prototype.toApiObject = function() {
/** /**
* Returns a GameLib.D3.Bone from a bone Object * Returns a GameLib.D3.Bone from a bone Object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectBone Object * @param objectBone Object
* @returns {GameLib.D3.Bone} * @returns {GameLib.D3.Bone}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Broadphase Runtime * Broadphase Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiBroadphase GameLib.D3.API.Broadphase * @param apiBroadphase GameLib.D3.API.Broadphase
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Creates a Camera object * Creates a Camera object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiCamera GameLib.D3.API.Camera * @param apiCamera GameLib.D3.API.Camera
* @constructor * @constructor
*/ */
@ -277,7 +277,7 @@ GameLib.D3.Camera.prototype.toApiObject = function() {
/** /**
* Converts from an Object Camera to a GameLib.D3.Camera * Converts from an Object Camera to a GameLib.D3.Camera
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectCamera Object * @param objectCamera Object
* @returns {GameLib.D3.Camera} * @returns {GameLib.D3.Camera}
* @constructor * @constructor

View File

@ -1,94 +0,0 @@
/**
* Canvas Superset - The apiCanvas properties get moved into the Canvas object itself, and then the instance is created
* @param graphics GameLib.D3.Graphics
* @param apiCanvas GameLib.D3.API.Canvas
* @constructor
*/
GameLib.D3.Canvas = function(
graphics,
apiCanvas
) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiCanvas)) {
apiCanvas = {};
}
if (apiCanvas instanceof GameLib.D3.Canvas) {
return apiCanvas;
}
GameLib.D3.API.Canvas.call(
this,
apiCanvas.id,
apiCanvas.name,
apiCanvas.width,
apiCanvas.height,
apiCanvas.parentEntity
);
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_CANVAS
);
};
GameLib.D3.Canvas.prototype = Object.create(GameLib.D3.API.Canvas.prototype);
GameLib.D3.Canvas.prototype.constructor = GameLib.D3.Canvas;
/**
* Creates a light instance
* @returns {*}
*/
GameLib.D3.Canvas.prototype.createInstance = function() {
this.instance = document.createElement('canvas');
this.instance.width = this.width;
this.instance.height = this.height;
GameLib.Component.prototype.createInstance.call(this);
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Canvas.prototype.updateInstance = function() {
if (GameLib.Utils.UndefinedOrNull(this.instance)) {
this.createInstance();
}
this.instance.width = this.width;
this.instance.height = this.height;
};
/**
* Converts a GameLib.D3.Canvas to a GameLib.D3.API.Canvas
* @returns {GameLib.D3.API.Canvas}
*/
GameLib.D3.Canvas.prototype.toApiObject = function() {
return new GameLib.D3.API.Canvas(
this.id,
this.name,
this.width,
this.height,
GameLib.Utils.IdOrNull(this.parentEntity)
);
};
/**
* Returns a new GameLib.D3.Canvas from a GameLib.D3.API.Canvas
* @param graphics GameLib.D3.Graphics
* @param objectCanvas GameLib.D3.API.Canvas
* @returns {GameLib.D3.Canvas}
*/
GameLib.D3.Canvas.FromObject = function(graphics, objectCanvas) {
return new GameLib.D3.Canvas(
graphics,
GameLib.D3.API.Canvas.FromObject(objectCanvas)
);
};

View File

@ -1,66 +0,0 @@
/**
* Coder
* @param id
* @param name
* @param coderType
* @constructor
*/
GameLib.D3.Coder = function Coder(
id,
name,
coderType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Coder (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(coderType)) {
coderType = GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR;
}
this.coderType = coderType;
this.createInstance();
};
/**
* GameLib.D3.Coder Types
* @type {number}
*/
GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR = 0x1;
/**
* @returns {THREE.Coder}
*/
GameLib.D3.Coder.prototype.createInstance = function() {
this.instance = CodeMirror;
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Coder.prototype.updateInstance = function() {
};
/**
* True if THREE physics
* @returns {boolean}
*/
GameLib.D3.Coder.prototype.isCodeMirror = function() {
return (this.coderType === GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR)
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.D3.Coder.prototype.isNotCodeMirrorThrow = function() {
if (this.coderType !== GameLib.D3.Coder.CODER_TYPE_CODE_MIRROR) {
console.warn('Only CodeMirror supported for this function');
throw new Error('Only CodeMirror supported for this function');
}
};

View File

@ -1,6 +1,6 @@
/** /**
* Renders a scene with a camera * Renders a scene with a camera
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiComposer GameLib.D3.API.Composer * @param apiComposer GameLib.D3.API.Composer
* @constructor * @constructor
*/ */

View File

@ -1,15 +1,11 @@
/** /**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created * Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics GameLib.D3.Graphics
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.D3.API.Controls
* @constructor * @constructor
*/ */
GameLib.D3.Controls = function ( GameLib.D3.Controls = function (
graphics,
apiControls apiControls
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiControls)) { if (GameLib.Utils.UndefinedOrNull(apiControls)) {
apiControls = {}; apiControls = {};
@ -111,16 +107,14 @@ GameLib.D3.Controls.prototype.toApiObject = function() {
/** /**
* Converts a data object to a GameLib.D3.Controls * Converts a data object to a GameLib.D3.Controls
* @param graphics GameLib.D3.Graphics
* @param objectControls {Object} * @param objectControls {Object}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.FromObject = function(graphics, objectControls) { GameLib.D3.Controls.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls( return new GameLib.D3.Controls(
graphics,
apiControls apiControls
); );

View File

@ -1,6 +1,6 @@
/** /**
* Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created * Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.D3.API.Controls
* @param raycaster * @param raycaster
* @param camera * @param camera
@ -42,7 +42,6 @@ GameLib.D3.Controls.Editor = function (
GameLib.D3.Controls.call( GameLib.D3.Controls.call(
this, this,
this.graphics,
apiControls apiControls
); );
}; };

View File

@ -1,20 +1,13 @@
/** /**
* Keyboard Controls * Keyboard Controls
* @param graphics GameLib.D3.Graphics
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.D3.API.Controls
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Keyboard = function ( GameLib.D3.Controls.Keyboard = function (
graphics,
apiControls apiControls
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.D3.Controls.call( GameLib.D3.Controls.call(
this, this,
this.graphics,
apiControls apiControls
); );
}; };
@ -59,17 +52,15 @@ GameLib.D3.Controls.Keyboard.prototype.toApiObject = function() {
/** /**
* Construct an Keyboard Controls object from data * Construct an Keyboard Controls object from data
* @param graphics
* @param objectControls * @param objectControls
* @returns {GameLib.D3.Controls.Keyboard} * @returns {GameLib.D3.Controls.Keyboard}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Keyboard.FromObject = function(graphics, objectControls) { GameLib.D3.Controls.Keyboard.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Keyboard( return new GameLib.D3.Controls.Keyboard(
graphics,
apiControls apiControls
); );

View File

@ -1,20 +1,13 @@
/** /**
* Mouse Controls * Mouse Controls
* @param graphics GameLib.D3.Graphics
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.D3.API.Controls
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Mouse = function ( GameLib.D3.Controls.Mouse = function (
graphics,
apiControls apiControls
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.D3.Controls.call( GameLib.D3.Controls.call(
this, this,
this.graphics,
apiControls apiControls
); );
}; };
@ -59,17 +52,15 @@ GameLib.D3.Controls.Mouse.prototype.toApiObject = function() {
/** /**
* Construct an Mouse Controls object from data * Construct an Mouse Controls object from data
* @param graphics
* @param objectControls * @param objectControls
* @returns {GameLib.D3.Controls.Mouse} * @returns {GameLib.D3.Controls.Mouse}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Mouse.FromObject = function(graphics, objectControls) { GameLib.D3.Controls.Mouse.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Mouse( return new GameLib.D3.Controls.Mouse(
graphics,
apiControls apiControls
); );

View File

@ -1,19 +1,13 @@
/** /**
* Touch Controls * Touch Controls
* @param graphics GameLib.D3.Graphics
* @param apiControls GameLib.D3.API.Controls * @param apiControls GameLib.D3.API.Controls
* @param sensitivity * @param sensitivity
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Touch = function ( GameLib.D3.Controls.Touch = function (
graphics,
apiControls, apiControls,
sensitivity sensitivity
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(sensitivity)) { if (GameLib.Utils.UndefinedOrNull(sensitivity)) {
sensitivity = 5; sensitivity = 5;
} }
@ -21,7 +15,6 @@ GameLib.D3.Controls.Touch = function (
GameLib.D3.Controls.call( GameLib.D3.Controls.call(
this, this,
this.graphics,
apiControls apiControls
); );
}; };
@ -70,17 +63,15 @@ GameLib.D3.Controls.Touch.prototype.toApiObject = function() {
/** /**
* Construct an Touch Controls object from data * Construct an Touch Controls object from data
* @param graphics
* @param objectControls * @param objectControls
* @returns {GameLib.D3.Controls.Touch} * @returns {GameLib.D3.Controls.Touch}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Touch.FromObject = function(graphics, objectControls) { GameLib.D3.Controls.Touch.FromObject = function(objectControls) {
var apiControls = GameLib.D3.API.Controls.FromObject(objectControls); var apiControls = GameLib.D3.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Touch( return new GameLib.D3.Controls.Touch(
graphics,
apiControls, apiControls,
objectControls.sensitivity objectControls.sensitivity
); );

View File

@ -107,10 +107,10 @@ GameLib.D3.CustomCode.FromObject = function(objectCustomCode) {
GameLib.D3.CustomCode.prototype.launchEditor = function(){ GameLib.D3.CustomCode.prototype.launchEditor = function(){
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION, GameLib.Event.GET_RUNTIME,
null, null,
function(coder) { function(runtime) {
this.coder = coder; this.coder = runtime.coder;
this.coder.isNotCodeMirrorThrow(); this.coder.isNotCodeMirrorThrow();
}.bind(this) }.bind(this)
); );

View File

@ -10,9 +10,9 @@ GameLib.D3.Face = function Face(
) { ) {
this.implementation = implementation; this.implementation = implementation;
if (implementation instanceof GameLib.D3.Graphics) { if (implementation instanceof GameLib.GraphicsRuntime) {
this.implementation.isNotThreeThrow(); this.implementation.isNotThreeThrow();
} else if (implementation instanceof GameLib.D3.Physics) { } else if (implementation instanceof GameLib.PhysicsRuntime) {
this.implementation.isNotCannonThrow(); this.implementation.isNotCannonThrow();
} else { } else {
throw new Error('Unhandled implementation : ' + implementation); throw new Error('Unhandled implementation : ' + implementation);
@ -41,7 +41,7 @@ GameLib.D3.Face = function Face(
apiFace.normal apiFace.normal
); );
if (this.implementation instanceof GameLib.D3.Graphics) { if (this.implementation instanceof GameLib.GraphicsRuntime) {
/** /**
* physics faces have no color... a little sad right? * physics faces have no color... a little sad right?
*/ */

View File

@ -141,7 +141,7 @@ GameLib.D3.Fog.prototype.toApiObject = function() {
/** /**
* Converts a scene Object to a GameLib.D3.Fog object * Converts a scene Object to a GameLib.D3.Fog object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectFog Object * @param objectFog Object
* @returns {GameLib.D3.Fog} * @returns {GameLib.D3.Fog}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Font Superset - The apiFont properties get moved into the Font object itself, and then the instance is created * Font Superset - The apiFont properties get moved into the Font object itself, and then the instance is created
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiFont GameLib.D3.API.Font * @param apiFont GameLib.D3.API.Font
* @constructor * @constructor
*/ */
@ -88,7 +88,7 @@ GameLib.D3.Font.prototype.toApiObject = function() {
/** /**
* Returns a new GameLib.D3.Font from a GameLib.D3.API.Font * Returns a new GameLib.D3.Font from a GameLib.D3.API.Font
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectFont GameLib.D3.API.Font * @param objectFont GameLib.D3.API.Font
* @returns {GameLib.D3.Font} * @returns {GameLib.D3.Font}
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* FrictionContactMaterial Runtime * FrictionContactMaterial Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiFrictionContactMaterial GameLib.D3.API.FrictionContactMaterial * @param apiFrictionContactMaterial GameLib.D3.API.FrictionContactMaterial
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* FrictionMaterial Runtime * FrictionMaterial Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiFrictionMaterial GameLib.D3.API.FrictionMaterial * @param apiFrictionMaterial GameLib.D3.API.FrictionMaterial
* @constructor * @constructor
*/ */

View File

@ -1,66 +0,0 @@
/**
* Graphics
* @param id
* @param name
* @param graphicsType
* @constructor
*/
GameLib.D3.Graphics = function Graphics(
id,
name,
graphicsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Graphics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(graphicsType)) {
graphicsType = GameLib.D3.Graphics.GRAPHICS_TYPE_THREE;
}
this.graphicsType = graphicsType;
this.createInstance();
};
/**
* GameLib.D3.Graphics Types
* @type {number}
*/
GameLib.D3.Graphics.GRAPHICS_TYPE_THREE = 0x1;
/**
* @returns {THREE.Graphics}
*/
GameLib.D3.Graphics.prototype.createInstance = function() {
this.instance = THREE;
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Graphics.prototype.updateInstance = function() {
};
/**
* True if THREE physics
* @returns {boolean}
*/
GameLib.D3.Graphics.prototype.isThree = function() {
return (this.graphicsType === GameLib.D3.Graphics.GRAPHICS_TYPE_THREE)
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.D3.Graphics.prototype.isNotThreeThrow = function() {
if (this.graphicsType !== GameLib.D3.Graphics.GRAPHICS_TYPE_THREE) {
console.warn('Only THREE supported for this function');
throw new Error('Only THREE supported for this function');
}
};

View File

@ -1,6 +1,6 @@
/** /**
* Helpers for displaying outlines or making 'invisible' scene objects visible * Helpers for displaying outlines or making 'invisible' scene objects visible
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param id * @param id
* @param name * @param name
* @param object * @param object

View File

@ -33,17 +33,9 @@ GameLib.D3.Image = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_IMAGE, GameLib.Component.COMPONENT_IMAGE
null,
true
); );
GameLib.Event.Emit(
GameLib.Event.LOAD_IMAGE,
{
image : this
}
);
}; };
GameLib.D3.Image.prototype = Object.create(GameLib.D3.API.Image.prototype); GameLib.D3.Image.prototype = Object.create(GameLib.D3.API.Image.prototype);
@ -54,14 +46,41 @@ GameLib.D3.Image.prototype.constructor = GameLib.D3.Image;
* @returns {*} * @returns {*}
*/ */
GameLib.D3.Image.prototype.createInstance = function() { GameLib.D3.Image.prototype.createInstance = function() {
GameLib.Component.prototype.createInstance.call(this);
GameLib.Event.Emit(
GameLib.Event.LOAD_IMAGE,
{
image : this
},
function(imageInstance) {
this.instance = imageInstance;
GameLib.Component.prototype.createInstance.call(this);
}.bind(this),
function(error) {
console.error(error);
this.instance = null;
GameLib.Component.prototype.createInstance.call(this);
}.bind(this)
);
}; };
/** /**
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.D3.Image.prototype.updateInstance = function() { GameLib.D3.Image.prototype.updateInstance = function(property) {
this.createInstance();
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Image: ' + property);
}
if (
property === 'fileName' ||
property === 'extension' ||
property === 'path'
) {
this.createInstance();
}
}; };
/** /**

View File

@ -1,6 +1,6 @@
/** /**
* Light Superset - The apiLight properties get moved into the Light object itself, and then the instance is created * Light Superset - The apiLight properties get moved into the Light object itself, and then the instance is created
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiLight GameLib.D3.API.Light * @param apiLight GameLib.D3.API.Light
* @constructor * @constructor
*/ */
@ -257,7 +257,7 @@ GameLib.D3.Light.prototype.toApiObject = function() {
/** /**
* Returns a new GameLib.D3.Light from a GameLib.D3.API.Light * Returns a new GameLib.D3.Light from a GameLib.D3.API.Light
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectLight GameLib.D3.API.Light * @param objectLight GameLib.D3.API.Light
* @returns {GameLib.D3.Light} * @returns {GameLib.D3.Light}
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Entities with LookAt component looks to targetPosition (default up is 0,1,0) * Entities with LookAt component looks to targetPosition (default up is 0,1,0)
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiLookAt GameLib.D3.API.LookAt * @param apiLookAt GameLib.D3.API.LookAt
* @constructor * @constructor
*/ */

View File

@ -1,7 +1,7 @@
/** /**
* Material Superset - The apiMaterial properties get moved into the Material object itself, and then the instance is * Material Superset - The apiMaterial properties get moved into the Material object itself, and then the instance is
* created * created
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiMaterial GameLib.D3.API.Material * @param apiMaterial GameLib.D3.API.Material
* @constructor * @constructor
* @returns {GameLib.D3.Material | GameLib.D3.API.Material} * @returns {GameLib.D3.Material | GameLib.D3.API.Material}
@ -1254,7 +1254,7 @@ GameLib.D3.Material.prototype.getTextures = function() {
/** /**
* Creates a GameLib.D3.Material from a material Object * Creates a GameLib.D3.Material from a material Object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMaterial Object * @param objectMaterial Object
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @constructor * @constructor
*/ */
@ -1096,7 +1096,7 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param width * @param width
* @param height * @param height
@ -118,7 +118,7 @@ GameLib.D3.Mesh.Box.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param radiusTop * @param radiusTop
* @param radiusBottom * @param radiusBottom
@ -182,7 +182,7 @@ GameLib.D3.Mesh.Cylinder.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param lineWidth * @param lineWidth
* @constructor * @constructor
@ -80,7 +80,7 @@ GameLib.D3.Mesh.Line.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param width * @param width
* @param height * @param height
@ -216,7 +216,7 @@ GameLib.D3.Mesh.Plane.prototype.toApiObject = function() {
/** /**
* TODO fix all this weird loading shit * TODO fix all this weird loading shit
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */
@ -325,7 +325,7 @@ GameLib.D3.Mesh.Plane.prototype.generateHeightMapFromBumpMap = function() {
GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() { GameLib.D3.Mesh.Plane.prototype.createPhysicsObjects = function() {
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GET_PHYSICS_IMPLEMENTATION, GameLib.Event.GET_PHYSICS_RUNTIME,
null, null,
function(physics){ function(physics){

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param radius * @param radius
* @param widthSegments * @param widthSegments
@ -120,7 +120,7 @@ GameLib.D3.Mesh.Sphere.prototype.toApiObject = function() {
GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() { GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GET_PHYSICS_IMPLEMENTATION, GameLib.Event.GET_PHYSICS_RUNTIME,
null, null,
function(physics){ function(physics){
var apiShapeSphere = new GameLib.D3.API.Shape( var apiShapeSphere = new GameLib.D3.API.Shape(
@ -187,7 +187,7 @@ GameLib.D3.Mesh.Sphere.prototype.createPhysicsObjects = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* 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.GraphicsRuntime
* @param apiMesh GameLib.D3.API.Mesh * @param apiMesh GameLib.D3.API.Mesh
* @param font * @param font
* @param size * @param size
@ -202,7 +202,7 @@ GameLib.D3.Mesh.Text.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Mesh * Converts a standard object mesh to a GameLib.D3.Mesh
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMesh {Object} * @param objectMesh {Object}
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Creates a ParticleEngine object * Creates a ParticleEngine object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiParticleEngine GameLib.D3.API.ParticleEngine * @param apiParticleEngine GameLib.D3.API.ParticleEngine
* @constructor * @constructor
*/ */
@ -289,7 +289,7 @@ GameLib.D3.ParticleEngine.prototype.toApiObject = function() {
/** /**
* Converts from an Object ParticleEngine to a GameLib.D3.ParticleEngine * Converts from an Object ParticleEngine to a GameLib.D3.ParticleEngine
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectParticleEngine Object * @param objectParticleEngine Object
* @returns {GameLib.D3.ParticleEngine} * @returns {GameLib.D3.ParticleEngine}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Creates a Particle object * Creates a Particle object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiParticle GameLib.D3.API.Particle * @param apiParticle GameLib.D3.API.Particle
* @constructor * @constructor
*/ */
@ -378,7 +378,7 @@ GameLib.D3.Particle.prototype.toApiObject = function() {
/** /**
* Converts from an Object Particle to a GameLib.D3.Particle * Converts from an Object Particle to a GameLib.D3.Particle
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectParticle Object * @param objectParticle Object
* @returns {GameLib.D3.Particle} * @returns {GameLib.D3.Particle}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Renders a scene with a camera * Renders a scene with a camera
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiPass GameLib.D3.API.Pass * @param apiPass GameLib.D3.API.Pass
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* This component makes the parentEntity (ex. car) follow the path provided by the spline * This component makes the parentEntity (ex. car) follow the path provided by the spline
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiPathFollowing GameLib.D3.API.PathFollowing * @param apiPathFollowing GameLib.D3.API.PathFollowing
* @constructor * @constructor
*/ */

View File

@ -105,7 +105,7 @@ GameLib.D3.PhysicsWorld.prototype.constructor = GameLib.D3.PhysicsWorld;
/** /**
* private * private
* @returns {GameLib.D3.PhysicsWorld|GameLib.D3.Physics.World|*} * @returns {GameLib.D3.PhysicsWorld|GameLib.PhysicsRuntime.World|*}
*/ */
GameLib.D3.PhysicsWorld.prototype.createInstance = function() { GameLib.D3.PhysicsWorld.prototype.createInstance = function() {
@ -510,7 +510,7 @@ GameLib.D3.PhysicsWorld.FromObject = function(graphics, objectComponent) {
// }; // };
// //
// /** // /**
// * @param graphics GameLib.D3.Graphics // * @param graphics GameLib.GraphicsRuntime
// * @param graphicsMesh THREE.Mesh // * @param graphicsMesh THREE.Mesh
// * @param mass Number // * @param mass Number
// * @param friction Number // * @param friction Number
@ -674,7 +674,7 @@ GameLib.D3.PhysicsWorld.FromObject = function(graphics, objectComponent) {
// }; // };
// //
// /** // /**
// * @param graphics GameLib.D3.Graphics // * @param graphics GameLib.GraphicsRuntime
// * @param graphicsMesh THREE.Mesh // * @param graphicsMesh THREE.Mesh
// * @returns {GameLib.D3.Shape} // * @returns {GameLib.D3.Shape}
// * @constructor // * @constructor
@ -760,7 +760,7 @@ GameLib.D3.PhysicsWorld.FromObject = function(graphics, objectComponent) {
// * @param rayscale Number // * @param rayscale Number
// * @param maxTriangleDistance Number // * @param maxTriangleDistance Number
// * @param createCompoundShape Boolean // * @param createCompoundShape Boolean
// * @param graphics GameLib.D3.Graphics // * @param graphics GameLib.GraphicsRuntime
// * @param triangleMeshShapes GameLib.D3.Shape[] // * @param triangleMeshShapes GameLib.D3.Shape[]
// * @param createDebugView Boolean // * @param createDebugView Boolean
// * @returns {GameLib.D3.RigidBody} // * @returns {GameLib.D3.RigidBody}

View File

@ -1,58 +0,0 @@
/**
* Physics
* @param id
* @param name
* @param physicsType
* @constructor
*/
GameLib.D3.Physics = function Physics(
id,
name,
physicsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Physics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(physicsType)) {
physicsType = GameLib.D3.Physics.PHYSICS_TYPE_CANNON;
}
this.physicsType = physicsType;
this.createInstance();
};
/**
* GameLib.D3.Physics Types
* @type {number}
*/
GameLib.D3.Physics.PHYSICS_TYPE_CANNON = 0x1;
/**
* @returns {THREE.Physics}
*/
GameLib.D3.Physics.prototype.createInstance = function() {
this.instance = CANNON;
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Physics.prototype.updateInstance = function() {
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.D3.Physics.prototype.isNotCannonThrow = function() {
if (this.physicsType !== GameLib.D3.Physics.PHYSICS_TYPE_CANNON) {
console.warn('Only CANNON supported for this function');
throw new Error('Only CANNON supported for this function');
}
};

View File

@ -1,6 +1,6 @@
/** /**
* RaycastVehicle Runtime * RaycastVehicle Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiRaycastVehicle GameLib.D3.API.RaycastVehicle * @param apiRaycastVehicle GameLib.D3.API.RaycastVehicle
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* RaycastWheel Runtime * RaycastWheel Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiRaycastWheel GameLib.D3.API.RaycastWheel * @param apiRaycastWheel GameLib.D3.API.RaycastWheel
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Raycaster for GameLib.D3 * Raycaster for GameLib.D3
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiRaycaster * @param apiRaycaster
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Renders a scene with a camera * Renders a scene with a camera
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiRenderTarget GameLib.D3.API.RenderTarget * @param apiRenderTarget GameLib.D3.API.RenderTarget
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Renders a scene with a camera * Renders a scene with a camera
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiRenderer GameLib.D3.API.Renderer * @param apiRenderer GameLib.D3.API.Renderer
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* RigidBody Runtime * RigidBody Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiRigidBody GameLib.D3.API.RigidBody * @param apiRigidBody GameLib.D3.API.RigidBody
* @constructor * @constructor
*/ */

View File

@ -410,7 +410,7 @@ GameLib.D3.Scene.prototype.toApiObject = function() {
/** /**
* Converts a scene Object to a GameLib.D3.Scene object * Converts a scene Object to a GameLib.D3.Scene object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectScene Object * @param objectScene Object
* @returns {GameLib.D3.Scene} * @returns {GameLib.D3.Scene}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created * Shape Superset - The apiShape properties get moved into the Shape object itself, and then the instance is created
* @param physics GameLib.D3.Physics * @param physics GameLib.PhysicsRuntime
* @param apiShape GameLib.D3.API.Shape * @param apiShape GameLib.D3.API.Shape
* @constructor * @constructor
*/ */
@ -110,7 +110,7 @@ GameLib.D3.Shape.prototype.toApiObject = function() {
/** /**
* Converts a standard object mesh to a GameLib.D3.Shape * Converts a standard object mesh to a GameLib.D3.Shape
* @param physics GameLib.D3.Physics * @param physics GameLib.PhysicsRuntime
* @param objectShape {Object} * @param objectShape {Object}
* @constructor * @constructor
*/ */

View File

@ -1,7 +1,7 @@
/** /**
* Skeleton Superset * Skeleton Superset
* @constructor * @constructor
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiSkeleton GameLib.D3.API.Skeleton * @param apiSkeleton GameLib.D3.API.Skeleton
*/ */
GameLib.D3.Skeleton = function Skeleton( GameLib.D3.Skeleton = function Skeleton(
@ -217,7 +217,7 @@ GameLib.D3.Skeleton.prototype.toApiObject = function() {
/** /**
* Returns a GameLib.D3.Skeleton from a skeleton Object * Returns a GameLib.D3.Skeleton from a skeleton Object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectSkeleton Object * @param objectSkeleton Object
* @returns {GameLib.D3.Skeleton} * @returns {GameLib.D3.Skeleton}
* @constructor * @constructor

View File

@ -1,6 +1,6 @@
/** /**
* Solver Runtime * Solver Runtime
* @param physics GameLib.D3.Graphics * @param physics GameLib.GraphicsRuntime
* @param apiSolver GameLib.D3.API.Solver * @param apiSolver GameLib.D3.API.Solver
* @constructor * @constructor
*/ */

View File

@ -1,6 +1,6 @@
/** /**
* Spline constructor * Spline constructor
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiSpline GameLib.D3.API.Spline * @param apiSpline GameLib.D3.API.Spline
* @constructor * @constructor
*/ */
@ -115,7 +115,7 @@ GameLib.D3.Spline.prototype.toApiObject = function() {
/** /**
* Returns a GameLib.D3.Spline from a spline Object * Returns a GameLib.D3.Spline from a spline Object
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectComponent Object * @param objectComponent Object
* @returns {GameLib.D3.Spline} * @returns {GameLib.D3.Spline}
* @constructor * @constructor

View File

@ -14,10 +14,8 @@ GameLib.D3.Stats = function(
domElement, domElement,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(stats)) { this.stats = stats;
throw new Error('Need Stats object') this.stats.isNotStatsThrow();
}
this.stats = stats;
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
@ -60,7 +58,8 @@ GameLib.D3.Stats.prototype.resize = function() {
* Creates a helper instance * Creates a helper instance
*/ */
GameLib.D3.Stats.prototype.createInstance = function() { GameLib.D3.Stats.prototype.createInstance = function() {
this.instance = this.stats();
this.instance = this.stats.instance();
this.resize(); this.resize();

View File

@ -2,7 +2,7 @@
* Texture Superset - The apiTexture properties get moved into the Texture object itself, and then the instance is * Texture Superset - The apiTexture properties get moved into the Texture object itself, and then the instance is
* created * created
* @param apiTexture * @param apiTexture
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @constructor * @constructor
*/ */
GameLib.D3.Texture = function( GameLib.D3.Texture = function(
@ -83,8 +83,8 @@ GameLib.D3.Texture = function(
}.bind(this) }.bind(this)
); );
if (this.canvas instanceof GameLib.D3.API.Canvas) { if (this.canvas instanceof GameLib.API.Canvas) {
this.canvas = new GameLib.D3.Canvas( this.canvas = new GameLib.Canvas(
this.graphics, this.graphics,
this.canvas this.canvas
); );
@ -96,7 +96,7 @@ GameLib.D3.Texture = function(
{ {
'image' : GameLib.D3.Image, 'image' : GameLib.D3.Image,
'images' : [GameLib.D3.Image], 'images' : [GameLib.D3.Image],
'canvas' : GameLib.D3.Canvas 'canvas' : GameLib.Canvas
} }
); );
}; };
@ -443,7 +443,7 @@ GameLib.D3.Texture.prototype.toApiObject = function() {
/** /**
* Converts from an Object texture to a GameLib.D3.Texture * Converts from an Object texture to a GameLib.D3.Texture
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectTexture Object * @param objectTexture Object
* @constructor * @constructor
*/ */

View File

@ -9,9 +9,9 @@ GameLib.D3.Vertex = function Vertex(
apiVertex apiVertex
) { ) {
this.implementation = implementation; this.implementation = implementation;
if (implementation instanceof GameLib.D3.Graphics) { if (implementation instanceof GameLib.GraphicsRuntime) {
this.implementation.isNotThreeThrow(); this.implementation.isNotThreeThrow();
} else if (implementation instanceof GameLib.D3.Physics) { } else if (implementation instanceof GameLib.PhysicsRuntime) {
this.implementation.isNotCannonThrow(); this.implementation.isNotCannonThrow();
} else { } else {
throw new Error('Unhandled implementation : ' + implementation); throw new Error('Unhandled implementation : ' + implementation);
@ -37,7 +37,7 @@ GameLib.D3.Vertex = function Vertex(
null null
); );
if (implementation instanceof GameLib.D3.Graphics) { if (implementation instanceof GameLib.GraphicsRuntime) {
this.boneWeights = this.boneWeights.map( this.boneWeights = this.boneWeights.map(
function(apiBoneWeight) { function(apiBoneWeight) {
return new GameLib.D3.BoneWeight( return new GameLib.D3.BoneWeight(

View File

@ -1,6 +1,6 @@
/** /**
* Viewport Runtime * Viewport Runtime
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiViewport GameLib.D3.API.Viewport * @param apiViewport GameLib.D3.API.Viewport
* @constructor * @constructor
*/ */

View File

@ -0,0 +1,59 @@
/**
* Graphics
* @param id
* @param name
* @param graphicsType
* @constructor
*/
GameLib.GraphicsRuntime = function(
id,
name,
graphicsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Graphics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(graphicsType)) {
graphicsType = GameLib.GraphicsRuntime.TYPE_THREE_JS;
}
this.graphicsType = graphicsType;
this.createInstance();
};
/**
* GameLib.GraphicsRuntime Types
* @type {number}
*/
GameLib.GraphicsRuntime.TYPE_THREE_JS = 0x1;
GameLib.GraphicsRuntime.prototype.createInstance = function() {
if (this.graphicsType === GameLib.GraphicsRuntime.TYPE_THREE_JS) {
this.instance = THREE;
} else {
this.instance = null;
}
};
GameLib.GraphicsRuntime.prototype.updateInstance = function(property) {
if (property === 'graphicsType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.GraphicsRuntime.prototype.isNotThreeThrow = function() {
if (this.instance !== THREE) {
console.error('Only THREE supported');
throw new Error('Only THREE supported');
}
};

View File

@ -0,0 +1,59 @@
/**
* GUI
* @param id
* @param name
* @param guiType
* @constructor
*/
GameLib.GUIRuntime = function(
id,
name,
guiType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'GUI (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(guiType)) {
guiType = GameLib.GUIRuntime.TYPE_DAT_GUI;
}
this.guiType = guiType;
this.createInstance();
};
/**
* GameLib.GUIRuntime Types
* @type {number}
*/
GameLib.GUIRuntime.TYPE_DAT_GUI = 0x1;
GameLib.GUIRuntime.prototype.createInstance = function() {
if (this.guiType === GameLib.GUIRuntime.TYPE_DAT_GUI) {
this.instance = dat.GUI;
} else {
this.instance = null;
}
};
GameLib.GUIRuntime.prototype.updateInstance = function(property) {
if (property === 'guiType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.GUIRuntime.prototype.isNotDatGuiThrow = function() {
if (this.instance !== dat.GUI) {
console.error('Only dat.gui supported');
throw new Error('Only dat.gui supported');
}
};

View File

@ -1,6 +1,6 @@
/** /**
* Stats component for displaying some render statistics (framerate, memory consumption, etc) * Stats component for displaying some render statistics (framerate, memory consumption, etc)
* @param gui * @param guiRuntime
* @param id * @param id
* @param name * @param name
* @param domElement * @param domElement
@ -9,17 +9,15 @@
* @constructor * @constructor
*/ */
GameLib.GUI = function( GameLib.GUI = function(
gui, guiRuntime,
id, id,
name, name,
domElement, domElement,
objects, objects,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(gui)) { this.guiRuntime = guiRuntime;
throw new Error('Need GUI object') this.guiRuntime.isNotDatGuiThrow();
}
this.gui = gui;
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
@ -32,8 +30,7 @@ GameLib.GUI = function(
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) { if (GameLib.Utils.UndefinedOrNull(domElement)) {
console.warn('Need a DOM element for stats'); domElement = null;
throw new Error('Need a DOM element for stats');
} }
this.domElement = domElement; this.domElement = domElement;
@ -63,15 +60,15 @@ GameLib.GUI.prototype.constructor = GameLib.GUI;
* Creates a helper instance * Creates a helper instance
*/ */
GameLib.GUI.prototype.createInstance = function() { GameLib.GUI.prototype.createInstance = function() {
this.instance = new dat.GUI( { autoPlace: false } ); this.instance = new this.guiRuntime.instance( { autoPlace: false } );
GameLib.Component.prototype.createInstance.call(this); GameLib.Component.prototype.createInstance.call(this);
}; };
/** /**
* Updates the instance with the current state * Updates the instance with the current state
*/ */
GameLib.GUI.prototype.updateInstance = function() { GameLib.GUI.prototype.updateInstance = function(property) {
this.instance = new dat.GUI( { autoPlace: false } ); console.log('todo: implement gui update instance');
}; };
/** /**

View File

@ -164,7 +164,7 @@ GameLib.Matrix4.prototype.toApiObject = function () {
/** /**
* Creates a GameLib.Matrix4 from an Object matrix * Creates a GameLib.Matrix4 from an Object matrix
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param objectMatrix Object * @param objectMatrix Object
* @param parentObject * @param parentObject
* @returns {GameLib.Matrix4} * @returns {GameLib.Matrix4}

View File

@ -1,13 +1,10 @@
/** /**
* Runtime mouse for updating instance objects * Runtime Mouse
* @param graphics GameLib.D3.Graphics * @param apiMouse
* @param apiMouse GameLib.API.Mouse * @returns {GameLib.Mouse}
* @constructor * @constructor
*/ */
GameLib.Mouse = function (graphics, apiMouse) { GameLib.Mouse = function (apiMouse) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMouse)){ if (GameLib.Utils.UndefinedOrNull(apiMouse)){
apiMouse = {}; apiMouse = {};
@ -36,23 +33,25 @@ GameLib.Mouse.prototype = Object.create(GameLib.API.Mouse.prototype);
GameLib.Mouse.prototype.constructor = GameLib.Mouse; GameLib.Mouse.prototype.constructor = GameLib.Mouse;
/** /**
* Creates an instance mouse * createInstance
* @param update
* @returns {*}
*/ */
GameLib.Mouse.prototype.createInstance = function(update) { GameLib.Mouse.prototype.createInstance = function() {
this.instance = true; this.instance = true;
GameLib.Component.prototype.createInstance.call(this); GameLib.Component.prototype.createInstance.call(this);
}; };
/** /**
* Updates the instance vector, calls updateInstance on the parent object * updateInstance
* @param property
*/ */
GameLib.Mouse.prototype.updateInstance = function() { GameLib.Mouse.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Mouse: ' + property);
}
}; };
/** /**
* Converts runtime vector to API Vector * Converts GameLib.Mouse vector to GameLib.API.Mouse
* @returns {GameLib.API.Mouse} * @returns {GameLib.API.Mouse}
*/ */
GameLib.Mouse.prototype.toApiObject = function() { GameLib.Mouse.prototype.toApiObject = function() {
@ -64,3 +63,15 @@ GameLib.Mouse.prototype.toApiObject = function() {
this.parentEntity this.parentEntity
); );
}; };
/**
* GameLib.Mouse from Object
* @param objectMouse
* @returns {GameLib.Mouse}
* @constructor
*/
GameLib.Mouse.prototype.FromObject = function(objectMouse) {
return new GameLib.Mouse(
GameLib.API.Mouse.FromObject(objectMouse)
);
};

View File

@ -0,0 +1,59 @@
/**
* Physics
* @param id
* @param name
* @param physicsType
* @constructor
*/
GameLib.PhysicsRuntime = function(
id,
name,
physicsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Physics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(physicsType)) {
physicsType = GameLib.PhysicsRuntime.TYPE_CANNON_JS;
}
this.physicsType = physicsType;
this.createInstance();
};
/**
* GameLib.PhysicsRuntime Types
* @type {number}
*/
GameLib.PhysicsRuntime.TYPE_CANNON_JS = 0x1;
GameLib.PhysicsRuntime.prototype.createInstance = function() {
if (this.physicsType === GameLib.PhysicsRuntime.TYPE_CANNON_JS) {
this.instance = CANNON;
} else {
this.instance = null;
}
};
GameLib.PhysicsRuntime.prototype.updateInstance = function(property) {
if (property === 'physicsType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.PhysicsRuntime.prototype.isNotCannonThrow = function() {
if (this.instance !== CANNON) {
console.error('Only CANNON supported');
throw new Error('Only CANNON supported');
}
};

View File

@ -14,11 +14,11 @@ GameLib.Quaternion = function (
) { ) {
this.implementation = implementation; this.implementation = implementation;
if (implementation instanceof GameLib.D3.Graphics) { if (implementation instanceof GameLib.GraphicsRuntime) {
this.physics = null; this.physics = null;
this.graphics = implementation; this.graphics = implementation;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
} else if (implementation instanceof GameLib.D3.Physics) { } else if (implementation instanceof GameLib.PhysicsRuntime) {
this.graphics = null; this.graphics = null;
this.physics = implementation; this.physics = implementation;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();

View File

@ -0,0 +1,59 @@
/**
* Sockets
* @param id
* @param name
* @param socketsType
* @constructor
*/
GameLib.SocketsRuntime = function(
id,
name,
socketsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Sockets (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(socketsType)) {
socketsType = GameLib.SocketsRuntime.TYPE_WEB_SOCKET;
}
this.socketsType = socketsType;
this.createInstance();
};
/**
* GameLib.SocketsRuntime Types
* @type {number}
*/
GameLib.SocketsRuntime.TYPE_WEB_SOCKET = 0x1;
GameLib.SocketsRuntime.prototype.createInstance = function() {
if (this.socketsType === GameLib.SocketsRuntime.TYPE_WEB_SOCKET) {
this.instance = WebSocket;
} else {
this.instance = null;
}
};
GameLib.SocketsRuntime.prototype.updateInstance = function(property) {
if (property === 'socketsType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.SocketsRuntime.prototype.isNotWebSocketThrow = function() {
if (!(this.instance instanceof stats)) {
console.error('Only WebSocket supported');
throw new Error('Only WebSocket supported');
}
};

View File

@ -0,0 +1,59 @@
/**
* Statistics
* @param id
* @param name
* @param statisticsType
* @constructor
*/
GameLib.StatisticsRuntime = function(
id,
name,
statisticsType
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Statistics (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(statisticsType)) {
statisticsType = GameLib.StatisticsRuntime.TYPE_STATS;
}
this.statisticsType = statisticsType;
this.createInstance();
};
/**
* GameLib.StatisticsRuntime Types
* @type {number}
*/
GameLib.StatisticsRuntime.TYPE_STATS = 0x1;
GameLib.StatisticsRuntime.prototype.createInstance = function() {
if (this.statisticsType === GameLib.StatisticsRuntime.TYPE_STATS) {
this.instance = Stats;
} else {
this.instance = null;
}
};
GameLib.StatisticsRuntime.prototype.updateInstance = function(property) {
if (property === 'statisticsType') {
this.createInstance();
}
};
/**
* Logs a warning and throws an error if not cannon
*/
GameLib.StatisticsRuntime.prototype.isNotStatsThrow = function() {
if (this.instance !== Stats) {
console.error('Only stats supported');
throw new Error('Only stats supported');
}
};

View File

@ -1,21 +1,16 @@
/** /**
* System takes care of updating all the entities (based on their component data) * System takes care of updating all the entities (based on their component data)
* @param apiSystem GameLib.API.System * @param apiSystem GameLib.API.System
* @param graphics
* @constructor * @constructor
*/ */
GameLib.System.Input = function( GameLib.System.Input = function(
apiSystem, apiSystem
graphics
) { ) {
GameLib.System.call( GameLib.System.call(
this, this,
apiSystem apiSystem
); );
this.graphics = graphics;
this.graphics.isNotThreeThrow();
this.selectAll = false; this.selectAll = false;
this.controlLeft = false; this.controlLeft = false;
@ -67,9 +62,7 @@ GameLib.System.Input = function(
this.instanceCreatedSubscription = null; this.instanceCreatedSubscription = null;
this.removeComponentSubscription = null; this.removeComponentSubscription = null;
this.mouse = new GameLib.Mouse( this.mouse = new GameLib.Mouse();
graphics
)
}; };
GameLib.System.Input.prototype = Object.create(GameLib.System.prototype); GameLib.System.Input.prototype = Object.create(GameLib.System.prototype);
@ -888,8 +881,8 @@ GameLib.System.Input.prototype.onMouseDownEdit = function(event) {
return; return;
} }
this.mouse.x = (event.offsetX / event.target.width ) * 2 - 1; this.mouse.position.x = (event.offsetX / event.target.width ) * 2 - 1;
this.mouse.y = -(event.offsetY / event.target.height) * 2 + 1; this.mouse.position.y = -(event.offsetY / event.target.height) * 2 + 1;
var scenes = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Scene); var scenes = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Scene);
@ -898,7 +891,7 @@ GameLib.System.Input.prototype.onMouseDownEdit = function(event) {
function (result, scene) { function (result, scene) {
editorControl.raycaster.instance.setFromCamera( editorControl.raycaster.instance.setFromCamera(
this.mouse, this.mouse.position,
editorControl.camera.instance editorControl.camera.instance
); );

View File

@ -1,18 +1,11 @@
/** /**
* System takes care of updating all the entities (based on their component data) * System takes care of updating all the entities (based on their component data)
* @param graphics
* @param camera
* @param apiSystem GameLib.API.System * @param apiSystem GameLib.API.System
* @constructor * @constructor
*/ */
GameLib.System.Particle = function( GameLib.System.Particle = function(
graphics,
camera,
apiSystem apiSystem
) { ) {
this.graphics = graphics;
this.graphics.isNotThreeThrow();
GameLib.System.call( GameLib.System.call(
this, this,
apiSystem apiSystem
@ -25,8 +18,6 @@ GameLib.System.Particle = function(
*/ */
this.engines = []; this.engines = [];
this.camera = camera;
this.totalTime = 0; this.totalTime = 0;
this.instanceCreatedSubscription = null; this.instanceCreatedSubscription = null;
@ -70,17 +61,9 @@ GameLib.System.Particle.prototype.start = function() {
* @param data * @param data
*/ */
GameLib.System.Particle.prototype.instanceCreated = function(data) { GameLib.System.Particle.prototype.instanceCreated = function(data) {
if (data.component instanceof GameLib.D3.ParticleEngine) { if (data.component instanceof GameLib.D3.ParticleEngine) {
// console.log('new particle engine');
this.particleEngines.push(data.component); this.particleEngines.push(data.component);
} }
if (data.component instanceof GameLib.D3.Camera) {
// console.log('new camera');
this.camera = data.component;
}
}; };
/** /**

View File

@ -1,6 +1,5 @@
/** /**
* Storage System takes care loading and linking components and dependencies * Storage System takes care loading and linking components and dependencies
* @param graphics
* @param apiSystem GameLib.API.System * @param apiSystem GameLib.API.System
* @param token * @param token
* @param apiUploadUrl * @param apiUploadUrl
@ -13,7 +12,6 @@
* @constructor * @constructor
*/ */
GameLib.System.Storage = function( GameLib.System.Storage = function(
graphics,
apiSystem, apiSystem,
token, token,
apiUploadUrl, apiUploadUrl,
@ -93,39 +91,6 @@ GameLib.System.Storage.prototype.start = function() {
GameLib.System.prototype.start.call(this); GameLib.System.prototype.start.call(this);
GameLib.Event.Emit(
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION,
null,
function(graphics) {
this.graphics = graphics;
}.bind(this),
function() {
this.graphics = null;
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.GET_PHYSICS_IMPLEMENTATION,
null,
function(physics) {
this.physics = physics;
}.bind(this),
function() {
this.physics = null;
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.GET_CODER_IMPLEMENTATION,
null,
function(coder) {
this.coder = coder;
}.bind(this),
function() {
this.coder = null;
}.bind(this)
);
this.loginSubscription = this.subscribe( this.loginSubscription = this.subscribe(
GameLib.Event.LOGGED_IN, GameLib.Event.LOGGED_IN,
function(data) { function(data) {
@ -370,72 +335,20 @@ GameLib.System.Storage.prototype.createRuntimeObject = function(responseText, cl
return null; return null;
} }
var runtimeComponent = null;
/** /**
* Now we need to create the runtime component - this happens systematically. * Now we need to create the runtime component - this happens systematically.
* First, we create an API object from the Object, then a Runtime object from the API object * 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 * Each component has a function 'FromObject' which essentially does this for you
*/ */
var component = object.component[0]; var runtimeComponent = GameLib.Component.Construct(object.component[0]);
var componentName = GameLib.Component.GetComponentName(component.componentType);
var componentClass = eval(componentName);
var fn = componentClass['FromObject'];
if (component.componentType === GameLib.Component.COMPONENT_ENTITY) {
runtimeComponent = fn(component, GameLib.EntityManager.Instance);
} else {
try {
runtimeComponent = fn(component);
} catch (error) {
if (this.coder) {
try {
runtimeComponent = fn(this.coder, component);
} catch (error) {
}
}
if (!runtimeComponent && this.graphics) {
try {
runtimeComponent = fn(this.graphics, component);
} catch (error) {
}
}
if (!runtimeComponent && this.physics) {
try {
runtimeComponent = fn(this.physics, component);
} catch (error) {
/**
* ok - we don't cannot create this component
*/
}
}
if (!runtimeComponent) {
if (clientErrorCallback) {
clientErrorCallback({
result: 'failure',
message: 'Could not create a runtime component: ' + object.component[0].name
});
} }
if (!runtimeComponent) {
if (clientErrorCallback) {
clientErrorCallback({
result: 'failure',
message: 'Could not create a runtime component: ' + component.name
});
}
}
} }
return runtimeComponent; return runtimeComponent;
@ -807,13 +720,11 @@ GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
var image = null; var image = null;
if (imageData) { if (imageData) {
/**
* Overrride this image if possible GameLib.Component.Construct(imageData);
* @type {GameLib.D3.Image}
*/
GameLib.D3.Image.FromObject(this.graphics, imageData);
} else { } else {
image = runtimeImages.reduce( image = runtimeImages.reduce(
function(result, runtimeImage){ function(result, runtimeImage){
@ -828,7 +739,10 @@ GameLib.System.Storage.prototype.imageUploadComplete = function(data) {
null null
); );
image.updateInstance(); /**
* Even though the path did not technically change, this should trigger an image reload
*/
image.updateInstance('path');
} }
}.bind(this)); }.bind(this));
@ -847,22 +761,23 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
/** /**
* Process all images - we have to load them in addition to creating their runtime components * Process all images - we have to load them in addition to creating their runtime components
*/ */
data.images.map(function(imageData){ data.images.map(
var image = GameLib.D3.Image.FromObject(this.graphics, imageData); function(rawImageObject) {
GameLib.Event.Emit( var image = GameLib.Component.Construct(rawImageObject);
GameLib.Event.COMPONENT_CREATED, GameLib.Event.Emit(
{ GameLib.Event.COMPONENT_CREATED,
component: image {
} component: image
); }
);
}.bind(this)); }.bind(this)
);
/** /**
* Process all textures * Process all textures
*/ */
data.textures.map(function(textureData){ data.textures.map(function(rawTextureObject){
var texture = GameLib.D3.Texture.FromObject(this.graphics, textureData); var texture = GameLib.Component.Construct(rawTextureObject);
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED, GameLib.Event.COMPONENT_CREATED,
{ {
@ -874,10 +789,8 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
/** /**
* Process all materials * Process all materials
*/ */
data.materials.map(function(materialData){ data.materials.map(function(rawMaterialObject){
var material = GameLib.Component.Construct(rawMaterialObject);
var material = GameLib.D3.Material.FromObject(this.graphics, materialData);
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED, GameLib.Event.COMPONENT_CREATED,
{ {
@ -889,8 +802,8 @@ GameLib.System.Storage.prototype.processBlenderData = function(data) {
/** /**
* Now process all meshes * Now process all meshes
*/ */
data.meshes.map(function(meshData){ data.meshes.map(function(rawMeshObject){
var mesh = GameLib.D3.Mesh.FromObject(this.graphics, meshData); var mesh = GameLib.Component.Construct(rawMeshObject);
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.COMPONENT_CREATED, GameLib.Event.COMPONENT_CREATED,
{ {

View File

@ -18,11 +18,33 @@ GameLib.System.Visualization = function(
apiSystem apiSystem
); );
if (GameLib.Utils.UndefinedOrNull(graphics)){
GameLib.Event.Emit(
GameLib.Event.GET_GRAPHICS_RUNTIME,
null,
function(graphicsRuntime) {
graphics = graphicsRuntime;
}.bind(this),
function() {
graphics = null;
}.bind(this)
);
}
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(physics)){
GameLib.Event.Emit(
GameLib.Event.GET_PHYSICS_RUNTIME,
null,
function(physicsRuntime) {
physics = physicsRuntime;
}.bind(this),
function() {
physics = null;
}.bind(this)
);
}
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow();
this.visualizationSubscription = null; this.visualizationSubscription = null;
this.stopVisualizationSubscription = null; this.stopVisualizationSubscription = null;

View File

@ -1,6 +1,6 @@
/** /**
* Runtime vector2 for updating instance objects * Runtime vector2 for updating instance objects
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param parentObject GameLib.D3.* * @param parentObject GameLib.D3.*
* @param apiVector2 GameLib.API.Vector2 * @param apiVector2 GameLib.API.Vector2
* @param grain Number * @param grain Number

View File

@ -1,6 +1,6 @@
/** /**
* Runtime apiVector3 for updating instance objects * Runtime apiVector3 for updating instance objects
* @param implementation GameLib.D3.Graphics * @param implementation GameLib.GraphicsRuntime
* @param apiVector3 GameLib.API.Vector3 * @param apiVector3 GameLib.API.Vector3
* @param parentObject GameLib.* * @param parentObject GameLib.*
* @param grain Number * @param grain Number
@ -15,11 +15,11 @@ GameLib.Vector3 = function (
this.implementation = implementation; this.implementation = implementation;
if (implementation instanceof GameLib.D3.Graphics) { if (implementation instanceof GameLib.GraphicsRuntime) {
this.physics = null; this.physics = null;
this.graphics = implementation; this.graphics = implementation;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
} else if (implementation instanceof GameLib.D3.Physics) { } else if (implementation instanceof GameLib.PhysicsRuntime) {
this.graphics = null; this.graphics = null;
this.physics = implementation; this.physics = implementation;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();

View File

@ -1,6 +1,6 @@
/** /**
* Runtime apiVector4 for updating instance objects * Runtime apiVector4 for updating instance objects
* @param graphics GameLib.D3.Graphics * @param graphics GameLib.GraphicsRuntime
* @param apiVector4 GameLib.API.Vector4 * @param apiVector4 GameLib.API.Vector4
* @param parentObject GameLib.* * @param parentObject GameLib.*
* @param grain Number * @param grain Number