start with linked objects

beta.r3js.org
-=yb4f310 2017-12-04 13:23:15 +01:00
parent e9ac1c9c9e
commit 70ebe7a5ec
118 changed files with 4013 additions and 3990 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

@ -727,4 +727,19 @@ GameLib.Utils.UpperCaseWordsSpaces = function(word) {
}, },
'' ''
).trim(); ).trim();
};
GameLib.Utils.UpperCaseUnderscore = function(word) {
var str = '';
word.map(function(letter){
if (letter === letter.toUpperCase()) {
str += '_' + letter;
} else {
str += letter.toUpperCase();
}
});
return str;
}; };

View File

@ -9,12 +9,11 @@ GameLib.API.Component = function(
parentEntity parentEntity
) { ) {
this.componentType = componentType; this.componentType = componentType;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null; parentEntity = null;
} }
this.parentEntity = parentEntity; this.parentEntity = parentEntity;
}; };
GameLib.API.Component.prototype = Object.create(GameLib.Event.prototype); GameLib.API.Component.prototype = Object.create(GameLib.Event.prototype);

View File

@ -1,12 +1,10 @@
/** /**
* Component Interface * Component Interface
* @constructor * @constructor
* @param componentType
* @param linkedObjects * @param linkedObjects
* @param delayed * @param delayed
*/ */
GameLib.Component = function( GameLib.Component = function(
componentType,
linkedObjects, linkedObjects,
delayed delayed
) { ) {
@ -16,12 +14,6 @@ GameLib.Component = function(
this.linkedObjects = linkedObjects; this.linkedObjects = linkedObjects;
this.linkedObjects.parentEntity = GameLib.Entity; this.linkedObjects.parentEntity = GameLib.Entity;
GameLib.API.Component.call(
this,
componentType,
this.parentEntity
);
this.idToObject = {}; this.idToObject = {};
this.selected = false; this.selected = false;
@ -212,87 +204,87 @@ GameLib.Component.prototype.toString = function() {
return this.id; return this.id;
}; };
//GameLib.Component.COMPONENT_PATH_FOLLOWING = 0x1; //GameLib.Component.PATH_FOLLOWING = 0x1;
GameLib.Component.COMPONENT_MATERIAL = 0x2; GameLib.Component.MATERIAL = 0x2;
GameLib.Component.COMPONENT_RENDERER = 0x3; GameLib.Component.RENDERER = 0x3;
//GameLib.Component.COMPONENT_LOOK_AT = 0x4; //GameLib.Component.LOOK_AT = 0x4;
GameLib.Component.COMPONENT_CAMERA = 0x5; GameLib.Component.CAMERA = 0x5;
//GameLib.Component.COMPONENT_FOLLOW = 0x6; //GameLib.Component.FOLLOW = 0x6;
GameLib.Component.COMPONENT_MESH = 0x7; GameLib.Component.MESH = 0x7;
GameLib.Component.COMPONENT_SPLINE = 0x8; GameLib.Component.SPLINE = 0x8;
GameLib.Component.COMPONENT_LIGHT = 0x9; GameLib.Component.LIGHT = 0x9;
//GameLib.Component.COMPONENT_INPUT_DRIVE = 0xa; //GameLib.Component.INPUT_DRIVE = 0xa;
GameLib.Component.COMPONENT_COMPOSER = 0xb; GameLib.Component.COMPOSER = 0xb;
GameLib.Component.COMPONENT_RENDER_TARGET = 0xc; GameLib.Component.RENDER_TARGET = 0xc;
GameLib.Component.COMPONENT_PASS = 0xd; GameLib.Component.PASS = 0xd;
GameLib.Component.COMPONENT_SCENE = 0xe; GameLib.Component.SCENE = 0xe;
GameLib.Component.COMPONENT_RAYCASTER = 0xf; GameLib.Component.RAYCASTER = 0xf;
//GameLib.Component.COMPONENT_INPUT_EDITOR = 0x10; //GameLib.Component.INPUT_EDITOR = 0x10;
//GameLib.Component.COMPONENT_EDITOR = 0x11; //GameLib.Component.EDITOR = 0x11;
GameLib.Component.COMPONENT_VIEWPORT = 0x12; GameLib.Component.VIEWPORT = 0x12;
GameLib.Component.COMPONENT_SYSTEM = 0x13; GameLib.Component.SYSTEM = 0x13;
GameLib.Component.COMPONENT_GRAPHICS = 0x14; GameLib.Component.GRAPHICS = 0x14;
GameLib.Component.COMPONENT_HELPER = 0x15; GameLib.Component.HELPER = 0x15;
GameLib.Component.COMPONENT_CUSTOM_CODE = 0x16; GameLib.Component.CUSTOM_CODE = 0x16;
GameLib.Component.COMPONENT_MOUSE = 0x17; GameLib.Component.MOUSE = 0x17;
GameLib.Component.COMPONENT_SKELETON = 0x18; GameLib.Component.SKELETON = 0x18;
GameLib.Component.COMPONENT_TEXTURE = 0x19; GameLib.Component.TEXTURE = 0x19;
GameLib.Component.COMPONENT_ENTITY_MANAGER = 0x1a; GameLib.Component.ENTITY_MANAGER = 0x1a;
GameLib.Component.COMPONENT_DOM_ELEMENT = 0x1b; GameLib.Component.DOM_ELEMENT = 0x1b;
//GameLib.Component.COMPONENT_IMAGE_FACTORY = 0x1c; //GameLib.Component.IMAGE_FACTORY = 0x1c;
GameLib.Component.COMPONENT_STATS = 0x1d; GameLib.Component.STATS = 0x1d;
GameLib.Component.COMPONENT_GUI = 0x1e; GameLib.Component.GUI = 0x1e;
GameLib.Component.COMPONENT_IMAGE = 0x1f; GameLib.Component.IMAGE = 0x1f;
GameLib.Component.COMPONENT_ENTITY = 0x20; GameLib.Component.ENTITY = 0x20;
GameLib.Component.COMPONENT_MESH_SPHERE = 0x21; GameLib.Component.MESH_SPHERE = 0x21;
GameLib.Component.COMPONENT_MESH_PLANE = 0x22; GameLib.Component.MESH_PLANE = 0x22;
GameLib.Component.COMPONENT_MESH_CURVE = 0x23; GameLib.Component.MESH_CURVE = 0x23;
GameLib.Component.COMPONENT_PHYSICS_WORLD = 0x24; GameLib.Component.PHYSICS_WORLD = 0x24;
GameLib.Component.COMPONENT_BROADPHASE = 0x25; GameLib.Component.BROADPHASE = 0x25;
GameLib.Component.COMPONENT_SOLVER = 0x26; GameLib.Component.SOLVER = 0x26;
GameLib.Component.COMPONENT_RIGID_BODY = 0x27; GameLib.Component.RIGID_BODY = 0x27;
GameLib.Component.COMPONENT_SHAPE = 0x28; GameLib.Component.SHAPE = 0x28;
GameLib.Component.COMPONENT_SHAPE_BOX = 0x29; GameLib.Component.SHAPE_BOX = 0x29;
GameLib.Component.COMPONENT_SHAPE_SPHERE = 0x2a; GameLib.Component.SHAPE_SPHERE = 0x2a;
GameLib.Component.COMPONENT_SHAPE_TRI_MESH = 0x2b; GameLib.Component.SHAPE_TRI_MESH = 0x2b;
GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL = 0x2c; GameLib.Component.SHAPE_CONVEX_HULL = 0x2c;
GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL_CYLINDER = 0x2d; GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
GameLib.Component.COMPONENT_SHAPE_HEIGHT_MAP = 0x2e; GameLib.Component.SHAPE_HEIGHT_MAP = 0x2e;
GameLib.Component.COMPONENT_SHAPE_PLANE = 0x2f; GameLib.Component.SHAPE_PLANE = 0x2f;
GameLib.Component.COMPONENT_CONTROLS = 0x30; GameLib.Component.CONTROLS = 0x30;
GameLib.Component.COMPONENT_CONTROLS_EDITOR = 0x31; GameLib.Component.CONTROLS_EDITOR = 0x31;
GameLib.Component.COMPONENT_CONTROLS_TOUCH = 0x32; GameLib.Component.CONTROLS_TOUCH = 0x32;
GameLib.Component.COMPONENT_FRICTION_MATERIAL = 0x33; GameLib.Component.FRICTION_MATERIAL = 0x33;
GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL = 0x34; GameLib.Component.FRICTION_CONTACT_MATERIAL = 0x34;
GameLib.Component.COMPONENT_RAYCAST_VEHICLE = 0x35; GameLib.Component.RAYCAST_VEHICLE = 0x35;
GameLib.Component.COMPONENT_RAYCAST_WHEEL = 0x36; GameLib.Component.RAYCAST_WHEEL = 0x36;
GameLib.Component.COMPONENT_CLOCK = 0x37; GameLib.Component.CLOCK = 0x37;
GameLib.Component.COMPONENT_ANIMATION = 0x38; GameLib.Component.ANIMATION = 0x38;
GameLib.Component.COMPONENT_CONTROLS_KEYBOARD = 0x39; GameLib.Component.CONTROLS_KEYBOARD = 0x39;
GameLib.Component.COMPONENT_CONTROLS_MOUSE = 0x3a; GameLib.Component.CONTROLS_MOUSE = 0x3a;
GameLib.Component.COMPONENT_MESH_TEXT = 0x3b; GameLib.Component.MESH_TEXT = 0x3b;
GameLib.Component.COMPONENT_FONT = 0x3c; GameLib.Component.FONT = 0x3c;
GameLib.Component.COMPONENT_CANVAS = 0x3d; GameLib.Component.CANVAS = 0x3d;
GameLib.Component.COMPONENT_BONE = 0x3e; GameLib.Component.BONE = 0x3e;
GameLib.Component.COMPONENT_MESH_BOX = 0x3f; GameLib.Component.MESH_BOX = 0x3f;
GameLib.Component.COMPONENT_MESH_CYLINDER = 0x40; GameLib.Component.MESH_CYLINDER = 0x40;
GameLib.Component.COMPONENT_SYSTEM_ANIMATION = 0x41; GameLib.Component.SYSTEM_ANIMATION = 0x41;
GameLib.Component.COMPONENT_SYSTEM_CUSTOM_CODE = 0x42; GameLib.Component.SYSTEM_CUSTOM_CODE = 0x42;
GameLib.Component.COMPONENT_SYSTEM_GUI = 0x43; GameLib.Component.SYSTEM_GUI = 0x43;
GameLib.Component.COMPONENT_SYSTEM_INPUT = 0x44; GameLib.Component.SYSTEM_INPUT = 0x44;
GameLib.Component.COMPONENT_SYSTEM_LINKING = 0x45; GameLib.Component.SYSTEM_LINKING = 0x45;
GameLib.Component.COMPONENT_SYSTEM_PHYSICS = 0x46; GameLib.Component.SYSTEM_PHYSICS = 0x46;
GameLib.Component.COMPONENT_SYSTEM_RENDER = 0x47; GameLib.Component.SYSTEM_RENDER = 0x47;
GameLib.Component.COMPONENT_SYSTEM_STORAGE = 0x48; GameLib.Component.SYSTEM_STORAGE = 0x48;
GameLib.Component.COMPONENT_SYSTEM_VISUALIZATION = 0x49; GameLib.Component.SYSTEM_VISUALIZATION = 0x49;
GameLib.Component.COMPONENT_FOG = 0x50; GameLib.Component.FOG = 0x50;
GameLib.Component.COMPONENT_MESH_LINE = 0x51; GameLib.Component.MESH_LINE = 0x51;
GameLib.Component.COMPONENT_PARTICLE_ENGINE = 0x52; GameLib.Component.PARTICLE_ENGINE = 0x52;
GameLib.Component.COMPONENT_SYSTEM_PARTICLE = 0x53; GameLib.Component.SYSTEM_PARTICLE = 0x53;
GameLib.Component.COMPONENT_PARTICLE = 0x54; GameLib.Component.PARTICLE = 0x54;
GameLib.Component.COMPONENT_AUDIO = 0x55; GameLib.Component.AUDIO = 0x55;
GameLib.Component.COMPONENT_SYSTEM_AUDIO = 0x56; GameLib.Component.SYSTEM_AUDIO = 0x56;
GameLib.Component.COMPONENT_CAST = 0x57; GameLib.Component.CAST = 0x57;
GameLib.Component.GRAPHICS_RUNTIME = 0x1; GameLib.Component.GRAPHICS_RUNTIME = 0x1;
GameLib.Component.PHYSICS_RUNTIME = 0x2; GameLib.Component.PHYSICS_RUNTIME = 0x2;
@ -302,6 +294,10 @@ GameLib.Component.DEFAULT_RUNTIME = 0x5;
GameLib.Component.GUI_RUNTIME = 0x6; GameLib.Component.GUI_RUNTIME = 0x6;
GameLib.Component.CODER_RUNTIME = 0x7; GameLib.Component.CODER_RUNTIME = 0x7;
GameLib.Component.GetCompentType = function(constructor) {
console.log('todo: implement?');
};
/** /**
* Returns string name for component number * Returns string name for component number
* @param number * @param number
@ -313,305 +309,379 @@ GameLib.Component.GetComponentInfo = function(number) {
case 0x1 : return null; case 0x1 : return null;
case 0x2 : return { case 0x2 : return {
name : 'GameLib.D3.Material', name : 'GameLib.D3.Material',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Material
}; };
case 0x3 : return { case 0x3 : return {
name : 'GameLib.D3.Renderer', name : 'GameLib.D3.Renderer',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Renderer
}; };
case 0x4 : return null; case 0x4 : return null;
case 0x5 : return { case 0x5 : return {
name : 'GameLib.D3.Camera', name : 'GameLib.D3.Camera',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Camera
}; };
case 0x6 : return null; case 0x6 : return null;
case 0x7 : return { case 0x7 : return {
name : 'GameLib.D3.Mesh', name : 'GameLib.D3.Mesh',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh
}; };
case 0x8 : return { case 0x8 : return {
name : 'GameLib.D3.Spline', name : 'GameLib.D3.Spline',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Spline
}; };
case 0x9 : return { case 0x9 : return {
name : 'GameLib.D3.Light', name : 'GameLib.D3.Light',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Light
}; };
case 0xa : return null; case 0xa : return null;
case 0xb : return { case 0xb : return {
name : 'GameLib.D3.Composer', name : 'GameLib.D3.Composer',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Composer
}; };
case 0xc : return { case 0xc : return {
name : 'GameLib.D3.RenderTarget', name : 'GameLib.D3.RenderTarget',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.RenderTarget
}; };
case 0xd : return { case 0xd : return {
name : 'GameLib.D3.Pass', name : 'GameLib.D3.Pass',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Pass
}; };
case 0xe : return { case 0xe : return {
name : 'GameLib.D3.Scene', name : 'GameLib.D3.Scene',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Scene
}; };
case 0xf : return { case 0xf : return {
name : 'GameLib.D3.Raycaster', name : 'GameLib.D3.Raycaster',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Raycaster
}; };
case 0x10 : return null; case 0x10 : return null;
case 0x11 : return null; case 0x11 : return null;
case 0x12 : return { case 0x12 : return {
name : 'GameLib.D3.Viewport', name : 'GameLib.D3.Viewport',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Viewport
}; };
case 0x13 : return { case 0x13 : return {
name : 'GameLib.System', name : 'GameLib.System',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System
}; };
case 0x14 : return { case 0x14 : return {
name : 'GameLib.GraphicsRuntime', name : 'GameLib.GraphicsRuntime',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.GraphicsRuntime
}; };
case 0x15 : return { case 0x15 : return {
name : 'GameLib.D3.Helper', name : 'GameLib.D3.Helper',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Helper
}; };
case 0x16 : return { case 0x16 : return {
name : 'GameLib.CustomCode', name : 'GameLib.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.CustomCode
}; };
case 0x17 : return { case 0x17 : return {
name : 'GameLib.Mouse', name : 'GameLib.Mouse',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Mouse
}; };
case 0x18 : return { case 0x18 : return {
name : 'GameLib.D3.Skeleton', name : 'GameLib.D3.Skeleton',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Skeleton
}; };
case 0x19 : return { case 0x19 : return {
name : 'GameLib.D3.Texture', name : 'GameLib.D3.Texture',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Texture
}; };
case 0x1a : return { case 0x1a : return {
name : 'GameLib.EntityManager', name : 'GameLib.EntityManager',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.EntityManager
}; };
case 0x1b : return { case 0x1b : return {
name : 'GameLib.DomElement', name : 'GameLib.DomElement',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.DomElement
}; };
case 0x1c : return null; case 0x1c : return null;
case 0x1d : return { case 0x1d : return {
name : 'GameLib.D3.Stats', name : 'GameLib.Stats',
runtime : GameLib.Component.STATISTICS_RUNTIME runtime : GameLib.Component.STATISTICS_RUNTIME,
constructor : GameLib.Stats
}; };
case 0x1e : return { case 0x1e : return {
name : 'GameLib.GUI', name : 'GameLib.GUI',
runtime : GameLib.Component.GUI_RUNTIME runtime : GameLib.Component.GUI_RUNTIME,
constructor : GameLib.GUI
}; };
case 0x1f : return { case 0x1f : return {
name : 'GameLib.Image', name : 'GameLib.Image',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Image
}; };
case 0x20 : return { case 0x20 : return {
name : 'GameLib.Entity', name : 'GameLib.Entity',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Entity
}; };
case 0x21 : return { case 0x21 : return {
name : 'GameLib.D3.Mesh.Sphere', name : 'GameLib.D3.Mesh.Sphere',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Sphere
}; };
case 0x22 : return { case 0x22 : return {
name : 'GameLib.D3.Mesh.Plane', name : 'GameLib.D3.Mesh.Plane',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Plane
}; };
case 0x23 : return { case 0x23 : return {
name : 'GameLib.D3.Mesh.Curve', name : 'GameLib.D3.Mesh.Curve',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Curve
}; };
case 0x24 : return { case 0x24 : return {
name : 'GameLib.D3.PhysicsWorld', name : 'GameLib.D3.PhysicsWorld',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.PhysicsWorld
}; };
case 0x25 : return { case 0x25 : return {
name : 'GameLib.D3.Broadphase', name : 'GameLib.D3.Broadphase',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Broadphase
}; };
case 0x26 : return { case 0x26 : return {
name : 'GameLib.D3.Solver', name : 'GameLib.D3.Solver',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Solver
}; };
case 0x27 : return { case 0x27 : return {
name : 'GameLib.D3.RigidBody', name : 'GameLib.D3.RigidBody',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RigidBody
}; };
case 0x28 : return { case 0x28 : return {
name : 'GameLib.D3.Shape', name : 'GameLib.D3.Shape',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape
}; };
case 0x29 : return { case 0x29 : return {
name : 'GameLib.D3.Shape.Box', name : 'GameLib.D3.Shape.Box',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Box
}; };
case 0x2a : return { case 0x2a : return {
name : 'GameLib.D3.Shape.Sphere', name : 'GameLib.D3.Shape.Sphere',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Sphere
}; };
case 0x2b : return { case 0x2b : return {
name : 'GameLib.D3.Shape.TriMesh', name : 'GameLib.D3.Shape.TriMesh',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.TriMesh
}; };
case 0x2c : return { case 0x2c : return {
name : 'GameLib.D3.Shape.ConvexHull', name : 'GameLib.D3.Shape.ConvexHull',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull
}; };
case 0x2d : return { case 0x2d : return {
name : 'GameLib.D3.Shape.ConvexHull.Cylinder', name : 'GameLib.D3.Shape.ConvexHull.Cylinder',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.ConvexHull.Cylinder
}; };
case 0x2e : return { case 0x2e : return {
name : 'GameLib.D3.Shape.HeightMap', name : 'GameLib.D3.Shape.HeightMap',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Shape.HeightMap
}; };
case 0x2f : return { case 0x2f : return {
name : 'GameLib.D3.Shape.Plane', name : 'GameLib.D3.Shape.Plane',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.Shape.Plane
}; };
case 0x30 : return { case 0x30 : return {
name : 'GameLib.Controls', name : 'GameLib.Controls',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls
}; };
case 0x31 : return { case 0x31 : return {
name : 'GameLib.D3.Controls.Editor', name : 'GameLib.Controls.D3.Editor',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Controls.D3.Editor
}; };
case 0x32 : return { case 0x32 : return {
name : 'GameLib.Controls.Touch', name : 'GameLib.Controls.Touch',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Touch
}; };
case 0x33 : return { case 0x33 : return {
name : 'GameLib.D3.FrictionMaterial', name : 'GameLib.D3.FrictionMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionMaterial
}; };
case 0x34 : return { case 0x34 : return {
name : 'GameLib.D3.FrictionContactMaterial', name : 'GameLib.D3.FrictionContactMaterial',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.FrictionContactMaterial
}; };
case 0x35 : return { case 0x35 : return {
name : 'GameLib.D3.RaycastVehicle', name : 'GameLib.D3.RaycastVehicle',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastVehicle
}; };
case 0x36 : return { case 0x36 : return {
name : 'GameLib.D3.RaycastWheel', name : 'GameLib.D3.RaycastWheel',
runtime : GameLib.Component.PHYSICS_RUNTIME runtime : GameLib.Component.PHYSICS_RUNTIME,
constructor : GameLib.D3.RaycastWheel
}; };
case 0x37 : return { case 0x37 : return {
name : 'GameLib.Clock', name : 'GameLib.Clock',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.Clock
}; };
case 0x38 : return { case 0x38 : return {
name : 'GameLib.D3.Animation', name : 'GameLib.D3.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.Animation
}; };
case 0x39 : return { case 0x39 : return {
name : 'GameLib.Controls.Keyboard', name : 'GameLib.Controls.Keyboard',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Keyboard
}; };
case 0x3a : return { case 0x3a : return {
name : 'GameLib.Controls.Mouse', name : 'GameLib.Controls.Mouse',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Controls.Mouse
}; };
case 0x3b : return { case 0x3b : return {
name : 'GameLib.D3.Mesh.Text', name : 'GameLib.D3.Mesh.Text',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Text
}; };
case 0x3c : return { case 0x3c : return {
name : 'GameLib.D3.Font', name : 'GameLib.D3.Font',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Font
}; };
case 0x3d : return { case 0x3d : return {
name : 'GameLib.Canvas', name : 'GameLib.Canvas',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.Canvas
}; };
case 0x3e : return { case 0x3e : return {
name : 'GameLib.D3.Bone', name : 'GameLib.D3.Bone',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Bone
}; };
case 0x3f : return { case 0x3f : return {
name : 'GameLib.D3.Mesh.Box', name : 'GameLib.D3.Mesh.Box',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Box
}; };
case 0x40 : return { case 0x40 : return {
name : 'GameLib.D3.Mesh.Cylinder', name : 'GameLib.D3.Mesh.Cylinder',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Cylinder
}; };
case 0x41 : return { case 0x41 : return {
name : 'GameLib.D3.System.Animation', name : 'GameLib.D3.System.Animation',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Animation
}; };
case 0x42 : return { case 0x42 : return {
name : 'GameLib.D3.System.CustomCode', name : 'GameLib.D3.System.CustomCode',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.CustomCode
}; };
case 0x43 : return { case 0x43 : return {
name : 'GameLib.D3.System.GUI', name : 'GameLib.D3.System.GUI',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.GUI
}; };
case 0x44 : return { case 0x44 : return {
name : 'GameLib.D3.System.Input', name : 'GameLib.D3.System.Input',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Input
}; };
case 0x45 : return { case 0x45 : return {
name : 'GameLib.D3.System.Linking', name : 'GameLib.D3.System.Linking',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Linking
}; };
case 0x46 : return { case 0x46 : return {
name : 'GameLib.D3.System.Physics', name : 'GameLib.D3.System.Physics',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Physics
}; };
case 0x47 : return { case 0x47 : return {
name : 'GameLib.D3.System.Render', name : 'GameLib.D3.System.Render',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Render
}; };
case 0x48 : return { case 0x48 : return {
name : 'GameLib.D3.System.Storage', name : 'GameLib.D3.System.Storage',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Storage
}; };
case 0x49 : return { case 0x49 : return {
name : 'GameLib.D3.System.Visualization', name : 'GameLib.D3.System.Visualization',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Visualization
}; };
case 0x50 : return { case 0x50 : return {
name : 'GameLib.D3.Fog', name : 'GameLib.D3.Fog',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Fog
}; };
case 0x51 : return { case 0x51 : return {
name : 'GameLib.D3.Mesh.Line', name : 'GameLib.D3.Mesh.Line',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Mesh.Line
}; };
case 0x52 : return { case 0x52 : return {
name : 'GameLib.D3.ParticleEngine', name : 'GameLib.D3.ParticleEngine',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.ParticleEngine
}; };
case 0x53 : return { case 0x53 : return {
name : 'GameLib.D3.System.Particle', name : 'GameLib.D3.System.Particle',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.D3.System.Particle
}; };
case 0x54 : return { case 0x54 : return {
name : 'GameLib.D3.Particle', name : 'GameLib.D3.Particle',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Particle
}; };
case 0x55 : return { case 0x55 : return {
name : 'GameLib.D3.Audio', name : 'GameLib.D3.Audio',
runtime : GameLib.Component.GRAPHICS_RUNTIME runtime : GameLib.Component.GRAPHICS_RUNTIME,
constructor : GameLib.D3.Audio
}; };
case 0x56 : return { case 0x56 : return {
name : 'GameLib.System.Audio', name : 'GameLib.System.Audio',
runtime : GameLib.Component.DEFAULT_RUNTIME runtime : GameLib.Component.DEFAULT_RUNTIME,
constructor : GameLib.System.Audio
}; };
case 0x57 : return { case 0x57 : return {
name : 'GameLib.Cast', name : 'GameLib.Cast',
runtime : GameLib.Component.SOCKET_RUNTIME runtime : GameLib.Component.SOCKET_RUNTIME,
constructor : GameLib.Cast
}; };
break; break;
} }
@ -634,7 +704,7 @@ GameLib.Component.GetComponentName = function(componentType) {
}; };
/** /**
* @return {null} * @return {null || Object}
*/ */
GameLib.Component.GetComponentRuntime = function(componentType) { GameLib.Component.GetComponentRuntime = function(componentType) {
@ -646,6 +716,22 @@ GameLib.Component.GetComponentRuntime = function(componentType) {
return null; return null;
}; };
/**
* @return {null || Object}
*/
GameLib.Component.GetComponentConstructor = function(componentType) {
var info = GameLib.Component.GetComponentInfo(componentType);
if (info) {
return info.constructor;
}
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 {*}
@ -764,7 +850,7 @@ GameLib.Component.prototype.generateNewIds = function() {
this.buildIdToObject(); this.buildIdToObject();
var codeComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.CustomCode); var codeComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.CUSTOM_CODE);
for (var property in this.idToObject) { for (var property in this.idToObject) {
if (this.idToObject.hasOwnProperty(property)) { if (this.idToObject.hasOwnProperty(property)) {
@ -950,8 +1036,6 @@ GameLib.Component.prototype.save = function(remote) {
var apiObject = this.idToObject[property].toApiObject(); var apiObject = this.idToObject[property].toApiObject();
apiObject.componentType = this.idToObject[property].componentType;
toSave.push(apiObject); toSave.push(apiObject);
this.publish( this.publish(
@ -971,7 +1055,7 @@ GameLib.Component.Construct = function(rawComponentObject) {
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType); var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
var componentClass = eval(info.name); var componentClass = info.constructor;
var fn = componentClass['FromObject']; var fn = componentClass['FromObject'];
@ -979,12 +1063,13 @@ GameLib.Component.Construct = function(rawComponentObject) {
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GET_RUNTIME, GameLib.Event.GET_RUNTIME,
null,
function(runtimeObject) { function(runtimeObject) {
runtime = runtimeObject; runtime = runtimeObject;
} }
); );
if (rawComponentObject.componentType === GameLib.Component.COMPONENT_ENTITY) { if (rawComponentObject.componentType === GameLib.Component.ENTITY) {
runtimeComponent = fn(rawComponentObject, GameLib.EntityManager.Instance); runtimeComponent = fn(rawComponentObject, GameLib.EntityManager.Instance);

View File

@ -34,10 +34,11 @@ GameLib.API.Canvas = function(
} }
this.height = height; this.height = height;
if (GameLib.Utils.UndefinedOrNull(parentEntity)){ GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.CANVAS,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.Canvas.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Canvas.prototype = Object.create(GameLib.Component.prototype);

View File

@ -56,10 +56,11 @@ GameLib.API.Cast = function(
} }
this.port = port; this.port = port;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.CAST,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);

View File

@ -21,10 +21,11 @@ GameLib.API.Clock = function(
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.CLOCK,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.Clock.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Clock.prototype = Object.create(GameLib.Component.prototype);

View File

@ -22,7 +22,7 @@ GameLib.API.Controls = function(
if (GameLib.Utils.UndefinedOrNull(controlsType)) { if (GameLib.Utils.UndefinedOrNull(controlsType)) {
if (this instanceof GameLib.D3.Controls.Editor) { if (this instanceof GameLib.Controls.D3.Editor) {
controlsType = GameLib.Controls.CONTROLS_TYPE_EDITOR; controlsType = GameLib.Controls.CONTROLS_TYPE_EDITOR;
} }
@ -71,15 +71,29 @@ GameLib.API.Controls = function(
} }
this.domElement = domElement; this.domElement = domElement;
// if (GameLib.Utils.UndefinedOrNull(fullscreen)) { var componentType = GameLib.Component.CONTROLS;
// fullscreen = false;
// }
// this.fullscreen = fullscreen;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_EDITOR) {
parentEntity = null; componentType = GameLib.Component.CONTROLS_EDITOR;
} }
this.parentEntity = parentEntity;
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_TOUCH) {
componentType = GameLib.Component.CONTROLS_TOUCH
}
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_KEYBOARD) {
componentType = GameLib.Component.CONTROLS_KEYBOARD
}
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_MOUSE) {
componentType = GameLib.Component.CONTROLS_MOUSE
}
GameLib.API.Component.call(
this,
componentType,
parentEntity
);
}; };
GameLib.API.Controls.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Controls.prototype = Object.create(GameLib.Component.prototype);

View File

@ -34,11 +34,11 @@ GameLib.API.CustomCode = function (
} }
this.code = code; this.code = code;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.CUSTOM_CODE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.CustomCode.prototype = Object.create(GameLib.Component.prototype); GameLib.API.CustomCode.prototype = Object.create(GameLib.Component.prototype);

View File

@ -28,10 +28,11 @@ GameLib.API.DomElement = function(
} }
this.domElementId = domElementId; this.domElementId = domElementId;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.DOM_ELEMENT,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.DomElement.prototype = Object.create(GameLib.Component.prototype); GameLib.API.DomElement.prototype = Object.create(GameLib.Component.prototype);

View File

@ -6,13 +6,15 @@
* @param entities GameLib.API.Entity[] * @param entities GameLib.API.Entity[]
* @param defaultEntity * @param defaultEntity
* @param defaultRenderer * @param defaultRenderer
* @param parentEntity
*/ */
GameLib.API.EntityManager = function( GameLib.API.EntityManager = function(
id, id,
name, name,
entities, entities,
defaultEntity, defaultEntity,
defaultRenderer defaultRenderer,
parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
@ -38,6 +40,12 @@ GameLib.API.EntityManager = function(
defaultRenderer = null; defaultRenderer = null;
} }
this.defaultRenderer = defaultRenderer; this.defaultRenderer = defaultRenderer;
GameLib.API.Component.call(
this,
GameLib.Component.ENTITY_MANAGER,
parentEntity
);
}; };
GameLib.API.EntityManager.prototype = Object.create(GameLib.Component.prototype); GameLib.API.EntityManager.prototype = Object.create(GameLib.Component.prototype);
@ -61,6 +69,7 @@ GameLib.API.EntityManager.FromObject = function(objectEntityManager) {
objectEntityManager.name, objectEntityManager.name,
apiEntities, apiEntities,
objectEntityManager.defaultEntity, objectEntityManager.defaultEntity,
objectEntityManager.defaultRenderer objectEntityManager.defaultRenderer,
objectEntityManager.parentEntity
); );
}; };

View File

@ -29,10 +29,11 @@ GameLib.API.Entity = function(
} }
this.components = components; this.components = components;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.ENTITY,
this.parentEntity = parentEntity; parentEntity
);
if (GameLib.Utils.UndefinedOrNull(parentEntityManager)) { if (GameLib.Utils.UndefinedOrNull(parentEntityManager)) {
parentEntityManager = null; parentEntityManager = null;

72
src/game-lib-api-gui.js Normal file
View File

@ -0,0 +1,72 @@
/**
* Raw GUI API object - should always correspond with the GUI Schema
* @param id
* @param name
* @param domElement
* @param objects
* @param parentEntity
* @constructor
*/
GameLib.API.GUI = function(
id,
name,
domElement,
objects,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'GUI (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) {
domElement = null;
}
this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(objects)) {
objects = [];
}
this.objects = objects;
GameLib.API.Component.call(
this,
GameLib.Component.GUI,
parentEntity
);
};
GameLib.API.GUI.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.GUI.prototype.constructor = GameLib.API.GUI;
/**
* Creates an API GUI from an Object GUI
* @param objectGUI
* @constructor
*/
GameLib.API.GUI.FromObject = function(objectGUI) {
var apiDomElement = null;
if (objectGUI.domElement) {
if (objectGUI.domElement instanceof Object) {
apiDomElement = GameLib.API.DomElement.FromObject(objectGUI.domElement);
} else {
apiDomElement = objectGUI.domElement;
}
}
return new GameLib.API.GUI(
objectGUI.id,
objectGUI.name,
apiDomElement,
objectGUI.objects,
objectGUI.parentEntity
);
};

View File

@ -68,10 +68,11 @@ GameLib.API.Image = function(
} }
this.size = size; this.size = size;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.IMAGE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.API.Image.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Image.prototype = Object.create(GameLib.Component.prototype);

View File

@ -14,12 +14,6 @@ GameLib.API.Mouse = function(
y, y,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
} }
@ -40,6 +34,11 @@ GameLib.API.Mouse = function(
} }
this.y = y; this.y = y;
GameLib.API.Component.call(
this,
GameLib.Component.MOUSE,
parentEntity
);
}; };
GameLib.API.Mouse.prototype = Object.create(GameLib.Component.prototype); GameLib.API.Mouse.prototype = Object.create(GameLib.Component.prototype);

64
src/game-lib-api-stats.js Normal file
View File

@ -0,0 +1,64 @@
/**
* Raw Stats API object - should always correspond with the Stats Schema
* @param id
* @param name
* @param domElement
* @param parentEntity
* @constructor
*/
GameLib.API.Stats = function(
id,
name,
domElement,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Stats (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) {
domElement = null;
}
this.domElement = domElement;
GameLib.API.Component.call(
this,
GameLib.Component.STATS,
parentEntity
);
};
GameLib.API.Stats.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.Stats.prototype.constructor = GameLib.API.Stats;
/**
* Creates an API Stats from an Object Stats
* @param objectStats
* @constructor
*/
GameLib.API.Stats.FromObject = function(objectStats) {
var apiDomElement = null;
if (objectStats.domElement) {
if (objectStats.domElement instanceof Object) {
apiDomElement = GameLib.API.DomElement.FromObject(objectStats.domElement);
} else {
apiDomElement = objectStats.domElement;
}
}
return new GameLib.API.Stats(
objectStats.id,
objectStats.name,
apiDomElement,
objectStats.parentEntity
);
};

View File

@ -22,16 +22,67 @@ GameLib.API.System = function (
name = "System (" + this.id + ")"; name = "System (" + this.id + ")";
} }
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(systemType)) { if (GameLib.Utils.UndefinedOrNull(systemType)) {
systemType = GameLib.System.SYSTEM_TYPE_RENDER; systemType = GameLib.System.SYSTEM_TYPE_NONE;
} }
this.systemType = systemType; this.systemType = systemType;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { var componentType = GameLib.Component.SYSTEM;
parentEntity = null;
if (this.systemType === GameLib.System.SYSTEM_TYPE_NONE) {
componentType = GameLib.Component.SYSTEM;
} }
this.parentEntity = parentEntity;
if (this.systemType === GameLib.System.SYSTEM_TYPE_ANIMATION) {
componentType = GameLib.Component.SYSTEM_ANIMATION;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_CUSTOM) {
componentType = GameLib.Component.SYSTEM_CUSTOM_CODE;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_GUI) {
componentType = GameLib.Component.SYSTEM_GUI;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_INPUT) {
componentType = GameLib.Component.SYSTEM_INPUT;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_LINKING) {
componentType = GameLib.Component.SYSTEM_LINKING;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_PHYSICS) {
componentType = GameLib.Component.SYSTEM_PHYSICS;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_RENDER) {
componentType = GameLib.Component.SYSTEM_RENDER;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_STORAGE) {
componentType = GameLib.Component.SYSTEM_STORAGE;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_VISUALIZATION) {
componentType = GameLib.Component.SYSTEM_VISUALIZATION;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_PARTICLE) {
componentType = GameLib.Component.SYSTEM_PARTICLE;
}
if (this.systemType === GameLib.System.SYSTEM_TYPE_AUDIO) {
componentType = GameLib.Component.SYSTEM_AUDIO;
}
GameLib.API.Component.call(
this,
componentType,
parentEntity
);
}; };

View File

@ -24,10 +24,7 @@ GameLib.Canvas = function(
apiCanvas.parentEntity apiCanvas.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_CANVAS
);
}; };
GameLib.Canvas.prototype = Object.create(GameLib.API.Canvas.prototype); GameLib.Canvas.prototype = Object.create(GameLib.API.Canvas.prototype);

View File

@ -34,7 +34,6 @@ GameLib.Cast = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_CAST,
{ {
peer : GameLib.Component peer : GameLib.Component
} }

View File

@ -27,11 +27,7 @@ GameLib.Clock = function(
apiClock.parentEntity apiClock.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_CLOCK
);
} ; } ;
GameLib.Clock.prototype = Object.create(GameLib.API.Clock.prototype); GameLib.Clock.prototype = Object.create(GameLib.API.Clock.prototype);

View File

@ -24,8 +24,6 @@ GameLib.Controls = function (
apiControls.parentEntity apiControls.parentEntity
); );
var componentType = GameLib.Component.COMPONENT_CONTROLS;
var linkedObjects = { var linkedObjects = {
domElement : GameLib.DomElement domElement : GameLib.DomElement
}; };
@ -34,29 +32,14 @@ GameLib.Controls = function (
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_EDITOR) { if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_EDITOR) {
componentType = GameLib.Component.COMPONENT_CONTROLS_EDITOR;
linkedObjects.raycaster = GameLib.D3.Raycaster; linkedObjects.raycaster = GameLib.D3.Raycaster;
linkedObjects.camera = GameLib.D3.Camera; linkedObjects.camera = GameLib.D3.Camera;
delayed = true; delayed = true;
} }
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_TOUCH) {
componentType = GameLib.Component.COMPONENT_CONTROLS_TOUCH
}
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_KEYBOARD) {
componentType = GameLib.Component.COMPONENT_CONTROLS_KEYBOARD
}
if (this.controlsType === GameLib.Controls.CONTROLS_TYPE_MOUSE) {
componentType = GameLib.Component.COMPONENT_CONTROLS_MOUSE
}
GameLib.Component.call( GameLib.Component.call(
this, this,
componentType,
linkedObjects, linkedObjects,
delayed delayed
); );
@ -65,6 +48,8 @@ GameLib.Controls = function (
GameLib.Controls.prototype = Object.create(GameLib.API.Controls.prototype); GameLib.Controls.prototype = Object.create(GameLib.API.Controls.prototype);
GameLib.Controls.prototype.constructor = GameLib.Controls; GameLib.Controls.prototype.constructor = GameLib.Controls;
GameLib.Controls.D3 = function() {};
/** /**
* Controls Type * Controls Type
* @type {number} * @type {number}

View File

@ -6,7 +6,7 @@
* @param camera * @param camera
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Editor = function ( GameLib.Controls.D3.Editor = function (
graphics, graphics,
apiControls, apiControls,
raycaster, raycaster,
@ -50,14 +50,14 @@ GameLib.D3.Controls.Editor = function (
* Inheritance * Inheritance
* @type {GameLib.Controls} * @type {GameLib.Controls}
*/ */
GameLib.D3.Controls.Editor.prototype = Object.create(GameLib.Controls.prototype); GameLib.Controls.D3.Editor.prototype = Object.create(GameLib.Controls.prototype);
GameLib.D3.Controls.Editor.prototype.constructor = GameLib.D3.Controls.Editor; GameLib.Controls.D3.Editor.prototype.constructor = GameLib.Controls.D3.Editor;
/** /**
* Create Instance * Create Instance
* @returns {THREE.EditorControls} * @returns {THREE.EditorControls}
*/ */
GameLib.D3.Controls.Editor.prototype.createInstance = function() { GameLib.Controls.D3.Editor.prototype.createInstance = function() {
if (!this.camera || !this.camera.instance) { if (!this.camera || !this.camera.instance) {
throw new Error('No camera at time of instance'); throw new Error('No camera at time of instance');
@ -78,7 +78,7 @@ GameLib.D3.Controls.Editor.prototype.createInstance = function() {
/** /**
* Update Instance * Update Instance
*/ */
GameLib.D3.Controls.Editor.prototype.updateInstance = function() { GameLib.Controls.D3.Editor.prototype.updateInstance = function() {
console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability'); console.warn('an update instance was called on editor controls - which, if not called from within a running system at the right time will affect the order of input event handling and cause system instability');
@ -86,10 +86,10 @@ GameLib.D3.Controls.Editor.prototype.updateInstance = function() {
}; };
/** /**
* Converts a GameLib.D3.Controls.Editor to a GameLib.D3.API.Mesh * Converts a GameLib.Controls.D3.Editor to a GameLib.D3.API.Mesh
* @returns {GameLib.API.Controls} * @returns {GameLib.API.Controls}
*/ */
GameLib.D3.Controls.Editor.prototype.toApiObject = function() { GameLib.Controls.D3.Editor.prototype.toApiObject = function() {
var apiControls = GameLib.Controls.prototype.toApiObject.call(this); var apiControls = GameLib.Controls.prototype.toApiObject.call(this);
@ -103,14 +103,14 @@ GameLib.D3.Controls.Editor.prototype.toApiObject = function() {
* Construct an Editor Controls object from data * Construct an Editor Controls object from data
* @param graphics * @param graphics
* @param objectControls * @param objectControls
* @returns {GameLib.D3.Controls.Editor} * @returns {GameLib.Controls.D3.Editor}
* @constructor * @constructor
*/ */
GameLib.D3.Controls.Editor.FromObject = function(graphics, objectControls) { GameLib.Controls.D3.Editor.FromObject = function(graphics, objectControls) {
var apiControls = GameLib.API.Controls.FromObject(objectControls); var apiControls = GameLib.API.Controls.FromObject(objectControls);
return new GameLib.D3.Controls.Editor( return new GameLib.Controls.D3.Editor(
graphics, graphics,
apiControls, apiControls,
objectControls.raycaster, objectControls.raycaster,

View File

@ -26,10 +26,7 @@ GameLib.CustomCode = function(
this.editor = null; this.editor = null;
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_CUSTOM_CODE
);
}; };
GameLib.CustomCode.prototype = Object.create(GameLib.API.CustomCode.prototype); GameLib.CustomCode.prototype = Object.create(GameLib.API.CustomCode.prototype);

View File

@ -87,10 +87,11 @@ GameLib.D3.API.Animation = function (
} }
this.meshes = meshes; this.meshes = meshes;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.ANIMATION,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Animation.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Animation.prototype = Object.create(GameLib.Component.prototype);

View File

@ -7,6 +7,7 @@
* @param volume * @param volume
* @param camera * @param camera
* @param overplay * @param overplay
* @param paused
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
@ -62,10 +63,11 @@ GameLib.D3.API.Audio = function(
} }
this.paused = paused; this.paused = paused;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.AUDIO,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Audio.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Audio.prototype = Object.create(GameLib.Component.prototype);

View File

@ -8,6 +8,7 @@
* @param position GameLib.API.Vector3 * @param position GameLib.API.Vector3
* @param scale GameLib.API.Vector3 * @param scale GameLib.API.Vector3
* @param up GameLib.API.Vector3 * @param up GameLib.API.Vector3
* @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Bone = function ( GameLib.D3.API.Bone = function (
@ -18,7 +19,8 @@ GameLib.D3.API.Bone = function (
position, position,
quaternion, quaternion,
scale, scale,
up up,
parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
@ -60,8 +62,17 @@ GameLib.D3.API.Bone = function (
up = new GameLib.API.Vector3(0,1,0); up = new GameLib.API.Vector3(0,1,0);
} }
this.up = up; this.up = up;
GameLib.API.Component.call(
this,
GameLib.Component.BONE,
parentEntity
);
}; };
GameLib.D3.API.Bone.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Bone.prototype.constructor = GameLib.D3.API.Bone;
/** /**
* Returns an API bone from an Object bone * Returns an API bone from an Object bone
* @param objectBone * @param objectBone
@ -76,6 +87,7 @@ GameLib.D3.API.Bone.FromObject = function(objectBone) {
GameLib.API.Vector3.FromObject(objectBone.position), GameLib.API.Vector3.FromObject(objectBone.position),
GameLib.API.Quaternion.FromObject(objectBone.quaternion), GameLib.API.Quaternion.FromObject(objectBone.quaternion),
GameLib.API.Vector3.FromObject(objectBone.scale), GameLib.API.Vector3.FromObject(objectBone.scale),
GameLib.API.Vector3.FromObject(objectBone.up) GameLib.API.Vector3.FromObject(objectBone.up),
objectBone.parentEntity
); );
}; };

View File

@ -28,10 +28,11 @@ GameLib.D3.API.Broadphase = function(
} }
this.broadphaseType = broadphaseType; this.broadphaseType = broadphaseType;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.BROADPHASE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Broadphase.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Broadphase.prototype = Object.create(GameLib.Component.prototype);

View File

@ -18,9 +18,9 @@
* @param offsetX * @param offsetX
* @param offsetY * @param offsetY
* @param quaternion GameLib.Quaternion * @param quaternion GameLib.Quaternion
* @param parentEntity
* @param eyeSeparation * @param eyeSeparation
* @param focalLength * @param focalLength
* @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Camera = function( GameLib.D3.API.Camera = function(
@ -42,9 +42,9 @@ GameLib.D3.API.Camera = function(
offsetX, offsetX,
offsetY, offsetY,
quaternion, quaternion,
parentEntity,
eyeSeparation, eyeSeparation,
focalLength focalLength,
parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
@ -155,10 +155,11 @@ GameLib.D3.API.Camera = function(
} }
this.focalLength = focalLength; this.focalLength = focalLength;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.CAMERA,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Camera.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Camera.prototype = Object.create(GameLib.Component.prototype);
@ -190,9 +191,9 @@ GameLib.D3.API.Camera.FromObject = function(objectCamera) {
objectCamera.offsetX, objectCamera.offsetX,
objectCamera.offsetY, objectCamera.offsetY,
GameLib.API.Quaternion.FromObject(objectCamera.quaternion), GameLib.API.Quaternion.FromObject(objectCamera.quaternion),
objectCamera.parentEntity,
objectCamera.eyeSeparation, objectCamera.eyeSeparation,
objectCamera.focalLength objectCamera.focalLength,
objectCamera.parentEntity
); );
}; };

View File

@ -41,10 +41,11 @@ GameLib.D3.API.Composer = function (
} }
this.passes = passes; this.passes = passes;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.COMPOSER,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Composer.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Composer.prototype = Object.create(GameLib.Component.prototype);

View File

@ -56,11 +56,11 @@ GameLib.D3.API.Fog = function(
} }
this.density = density; this.density = density;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.FOG,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Fog.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Fog.prototype = Object.create(GameLib.Component.prototype);

View File

@ -27,10 +27,11 @@ GameLib.D3.API.Font = function(
} }
this.url = url; this.url = url;
if (GameLib.Utils.UndefinedOrNull(parentEntity)){ GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.FONT,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Font.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Font.prototype = Object.create(GameLib.Component.prototype);

View File

@ -2,8 +2,7 @@
* Raw FrictionContactMaterial API object - should always correspond with the FrictionContactMaterial Schema * Raw FrictionContactMaterial API object - should always correspond with the FrictionContactMaterial Schema
* @param id * @param id
* @param name * @param name
* @param material1 * @param materials
* @param material2
* @param friction * @param friction
* @param restitution * @param restitution
* @param contactEquationStiffness * @param contactEquationStiffness
@ -71,10 +70,11 @@ GameLib.D3.API.FrictionContactMaterial = function(
} }
this.frictionEquationRelaxation = frictionEquationRelaxation; this.frictionEquationRelaxation = frictionEquationRelaxation;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.FRICTION_CONTACT_MATERIAL,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.FrictionContactMaterial.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.FrictionContactMaterial.prototype = Object.create(GameLib.Component.prototype);

View File

@ -35,10 +35,11 @@ GameLib.D3.API.FrictionMaterial = function(
} }
this.restitution = restitution; this.restitution = restitution;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.FRICTION_MATERIAL,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.FrictionMaterial.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.FrictionMaterial.prototype = Object.create(GameLib.Component.prototype);

View File

@ -135,10 +135,11 @@ GameLib.D3.API.Light = function(
} }
this.parentScene = parentScene; this.parentScene = parentScene;
if (GameLib.Utils.UndefinedOrNull(parentEntity)){ GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.LIGHT,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Light.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Light.prototype = Object.create(GameLib.Component.prototype);

View File

@ -483,10 +483,11 @@ GameLib.D3.API.Material = function(
} }
this.specularMap = specularMap; this.specularMap = specularMap;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.MATERIAL,
this.parentEntity = parentEntity; parentEntity
);
this.needsUpdate = false; this.needsUpdate = false;
}; };

View File

@ -2,25 +2,27 @@
* Raw Mesh API object - should always correspond with the Mesh Schema * Raw Mesh API object - should always correspond with the Mesh Schema
* @param id * @param id
* @param meshType * @param meshType
* @param name * @param name
* @param vertices GameLib.D3.Vertex[] * @param vertices
* @param faces GameLib.D3.Face[] * @param faces
* @param materials GameLib.D3.API.Material[] * @param materials
* @param parentMesh * @param parentMesh
* @param parentScene * @param parentScene
* @param skeleton * @param skeleton
* @param skinIndices * @param skinIndices
* @param skinWeights * @param skinWeights
* @param position GameLib.API.Vector3 * @param position
* @param quaternion GameLib.API.Quaternion * @param quaternion
* @param rotation * @param rotation
* @param scale GameLib.API.Vector3 * @param scale
* @param up * @param up
* @param modelMatrix GameLib.API.Matrix4 * @param modelMatrix
* @param parentEntity
* @param renderOrder * @param renderOrder
* @param isBufferMesh * @param isBufferMesh
* @param useQuaternion (use quaternion property for rotation rather than rotation property) * @param useQuaternion
* @param visible
* @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Mesh = function( GameLib.D3.API.Mesh = function(
@ -41,11 +43,11 @@ GameLib.D3.API.Mesh = function(
scale, scale,
up, up,
modelMatrix, modelMatrix,
parentEntity,
renderOrder, renderOrder,
isBufferMesh, isBufferMesh,
useQuaternion, useQuaternion,
visible visible,
parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
@ -53,7 +55,7 @@ GameLib.D3.API.Mesh = function(
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(meshType)) { if (GameLib.Utils.UndefinedOrNull(meshType)) {
meshType = GameLib.D3.Mesh.MESH_TYPE_NORMAL; meshType = GameLib.D3.API.Mesh.MESH_TYPE_NORMAL;
} }
this.meshType = meshType; this.meshType = meshType;
@ -137,11 +139,6 @@ GameLib.D3.API.Mesh = function(
} }
this.renderOrder = renderOrder; this.renderOrder = renderOrder;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(isBufferMesh)) { if (GameLib.Utils.UndefinedOrNull(isBufferMesh)) {
isBufferMesh = false; isBufferMesh = false;
} }
@ -156,11 +153,58 @@ GameLib.D3.API.Mesh = function(
visible = true; visible = true;
} }
this.visible = visible; this.visible = visible;
var componentType = GameLib.Component.MESH;
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_PLANE) {
componentType = GameLib.Component.MESH_PLANE
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_BOX) {
componentType = GameLib.Component.MESH_BOX
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER) {
componentType = GameLib.Component.MESH_CYLINDER
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_SPHERE) {
componentType = GameLib.Component.MESH_SPHERE
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_LINE) {
componentType = GameLib.Component.MESH_LINE
}
if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
componentType = GameLib.Component.MESH_TEXT;
}
GameLib.API.Component.call(
this,
componentType,
parentEntity
);
}; };
GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Mesh.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Mesh.prototype.constructor = GameLib.D3.API.Mesh; GameLib.D3.API.Mesh.prototype.constructor = GameLib.D3.API.Mesh;
/**
* Mesh Type
* @type {number}
*/
GameLib.D3.API.Mesh.MESH_TYPE_NORMAL = 0x0;
GameLib.D3.API.Mesh.MESH_TYPE_SKINNED = 0x1;
GameLib.D3.API.Mesh.MESH_TYPE_CURVE = 0x2;
GameLib.D3.API.Mesh.MESH_TYPE_SPHERE = 0x3;
GameLib.D3.API.Mesh.MESH_TYPE_PLANE = 0x4;
GameLib.D3.API.Mesh.MESH_TYPE_BOX = 0x5;
GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER = 0x6;
GameLib.D3.API.Mesh.MESH_TYPE_TEXT = 0x7;
GameLib.D3.API.Mesh.MESH_TYPE_LINE = 0x8;
/** /**
* Returns an API Mesh from an Object mesh * Returns an API Mesh from an Object mesh
* @param objectMesh * @param objectMesh
@ -255,10 +299,10 @@ GameLib.D3.API.Mesh.FromObject = function (objectMesh){
apiScale, apiScale,
apiUp, apiUp,
apiModelMatrix, apiModelMatrix,
objectMesh.parentEntity,
objectMesh.renderOrder, objectMesh.renderOrder,
objectMesh.isBufferMesh, objectMesh.isBufferMesh,
objectMesh.useQuaternion, objectMesh.useQuaternion,
objectMesh.visible objectMesh.visible,
objectMesh.parentEntity
); );
}; };

View File

@ -84,10 +84,11 @@ GameLib.D3.API.ParticleEngine = function(
} }
this.pulse = pulse; this.pulse = pulse;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.PARTICLE_ENGINE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.ParticleEngine.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.ParticleEngine.prototype = Object.create(GameLib.Component.prototype);

View File

@ -161,10 +161,11 @@ GameLib.D3.API.Particle = function(
} }
this.parentEngine = parentEngine; this.parentEngine = parentEngine;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.PARTICLE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Particle.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Particle.prototype = Object.create(GameLib.Component.prototype);

View File

@ -57,10 +57,11 @@ GameLib.D3.API.Pass = function (
} }
this.renderToScreen = renderToScreen; this.renderToScreen = renderToScreen;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.PASS,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Pass.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Pass.prototype = Object.create(GameLib.Component.prototype);

View File

@ -8,6 +8,7 @@
* @param rigidBodies * @param rigidBodies
* @param contactMaterials * @param contactMaterials
* @param allowSleep * @param allowSleep
* @param defaultContactMaterial
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
@ -78,10 +79,11 @@ GameLib.D3.API.PhysicsWorld = function(
} }
this.defaultContactMaterial = defaultContactMaterial; this.defaultContactMaterial = defaultContactMaterial;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.PHYSICS_WORLD,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.PhysicsWorld.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.PhysicsWorld.prototype = Object.create(GameLib.Component.prototype);

View File

@ -5,7 +5,7 @@
* @param chassis * @param chassis
* @param wheels * @param wheels
* @param raycastWheels * @param raycastWheels
* @param parentWorld * @param parentPhysicsWorld
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
@ -15,7 +15,7 @@ GameLib.D3.API.RaycastVehicle = function(
chassis, chassis,
wheels, wheels,
raycastWheels, raycastWheels,
parentWorld, parentPhysicsWorld,
parentEntity parentEntity
) { ) {
@ -44,15 +44,16 @@ GameLib.D3.API.RaycastVehicle = function(
} }
this.raycastWheels = raycastWheels; this.raycastWheels = raycastWheels;
if (GameLib.Utils.UndefinedOrNull(parentWorld)) { if (GameLib.Utils.UndefinedOrNull(parentPhysicsWorld)) {
parentWorld = null; parentPhysicsWorld = null;
} }
this.parentWorld = parentWorld; this.parentPhysicsWorld = parentPhysicsWorld;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.RAYCAST_VEHICLE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.RaycastVehicle.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.RaycastVehicle.prototype = Object.create(GameLib.Component.prototype);
@ -70,7 +71,7 @@ GameLib.D3.API.RaycastVehicle.FromObject = function(objectRaycastVehicle) {
objectRaycastVehicle.chassis, objectRaycastVehicle.chassis,
objectRaycastVehicle.wheels, objectRaycastVehicle.wheels,
objectRaycastVehicle.raycastWheels, objectRaycastVehicle.raycastWheels,
objectRaycastVehicle.parentWorld, objectRaycastVehicle.parentPhysicsWorld,
objectRaycastVehicle.parentEntity objectRaycastVehicle.parentEntity
); );
}; };

View File

@ -37,8 +37,8 @@ GameLib.D3.API.RaycastWheel = function(
maxSuspensionTravel, maxSuspensionTravel,
customSlidingRotationalSpeed, customSlidingRotationalSpeed,
useCustomSlidingRotationalSpeed, useCustomSlidingRotationalSpeed,
parentEntity, parentMesh,
parentMesh parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
@ -121,15 +121,16 @@ GameLib.D3.API.RaycastWheel = function(
} }
this.useCustomSlidingRotationalSpeed = useCustomSlidingRotationalSpeed; this.useCustomSlidingRotationalSpeed = useCustomSlidingRotationalSpeed;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(parentMesh)) { if (GameLib.Utils.UndefinedOrNull(parentMesh)) {
parentMesh = null; parentMesh = null;
} }
this.parentMesh = parentMesh; this.parentMesh = parentMesh;
GameLib.API.Component.call(
this,
GameLib.Component.RAYCAST_WHEEL,
parentEntity
);
}; };
GameLib.D3.API.RaycastWheel.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.RaycastWheel.prototype = Object.create(GameLib.Component.prototype);
@ -158,8 +159,8 @@ GameLib.D3.API.RaycastWheel.FromObject = function(objectRaycastWheel) {
objectRaycastWheel.maxSuspensionTravel, objectRaycastWheel.maxSuspensionTravel,
objectRaycastWheel.customSlidingRotationalSpeed, objectRaycastWheel.customSlidingRotationalSpeed,
objectRaycastWheel.useCustomSlidingRotationalSpeed, objectRaycastWheel.useCustomSlidingRotationalSpeed,
objectRaycastWheel.parentEntity, objectRaycastWheel.parentMesh,
objectRaycastWheel.parentMesh objectRaycastWheel.parentEntity
); );
}; };

View File

@ -4,13 +4,15 @@
* @param name * @param name
* @param position GameLib.API.Vector3 * @param position GameLib.API.Vector3
* @param direction GameLib.API.Vector3 * @param direction GameLib.API.Vector3
* @param parentEntity
* @constructor * @constructor
*/ */
GameLib.D3.API.Raycaster = function( GameLib.D3.API.Raycaster = function(
id, id,
name, name,
position, position,
direction direction,
parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
@ -32,6 +34,12 @@ GameLib.D3.API.Raycaster = function(
direction = new GameLib.API.Vector3(0, -1, 0); direction = new GameLib.API.Vector3(0, -1, 0);
} }
this.direction = direction; this.direction = direction;
GameLib.API.Component.call(
this,
GameLib.Component.RAYCASTER,
parentEntity
);
}; };
GameLib.D3.API.Raycaster.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Raycaster.prototype = Object.create(GameLib.Component.prototype);
@ -47,6 +55,7 @@ GameLib.D3.API.Raycaster.FromObject = function(objectRaycaster) {
objectRaycaster.id, objectRaycaster.id,
objectRaycaster.name, objectRaycaster.name,
GameLib.API.Vector3.FromObject(objectRaycaster.position), GameLib.API.Vector3.FromObject(objectRaycaster.position),
GameLib.API.Vector3.FromObject(objectRaycaster.direction) GameLib.API.Vector3.FromObject(objectRaycaster.direction),
objectRaycaster.parentEntity
); );
}; };

View File

@ -1,12 +1,9 @@
/** /**
* This component renders a scene * RenderTarget is used to render a scene to a target
* @param id String * @param id
* @param name String * @param name
* @param width * @param width
* @param height * @param height
* @param minFilter
* @param magFilter
* @param format
* @param stencilBuffer * @param stencilBuffer
* @param texture * @param texture
* @param parentEntity * @param parentEntity
@ -51,10 +48,11 @@ GameLib.D3.API.RenderTarget = function (
} }
this.texture = texture; this.texture = texture;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.RENDER_TARGET,
this.parentEntity = parentEntity; parentEntity
);
}; };

View File

@ -17,6 +17,7 @@
* @param bufferScene * @param bufferScene
* @param bufferCamera * @param bufferCamera
* @param renderTarget * @param renderTarget
* @param sortObjects
* @param defaultScene * @param defaultScene
* @constructor * @constructor
*/ */
@ -135,10 +136,11 @@ GameLib.D3.API.Renderer = function (
} }
this.sortObjects = sortObjects; this.sortObjects = sortObjects;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.RENDERER,
this.parentEntity = parentEntity; parentEntity
);
}; };

View File

@ -19,7 +19,7 @@
* @param shapes * @param shapes
* @param kinematic * @param kinematic
* @param parentMesh * @param parentMesh
* @param parentWorld * @param parentPhysicsWorld
* @param parentEntity * @param parentEntity
* @constructor * @constructor
*/ */
@ -43,7 +43,7 @@ GameLib.D3.API.RigidBody = function(
shapes, shapes,
kinematic, kinematic,
parentMesh, parentMesh,
parentWorld, parentPhysicsWorld,
parentEntity parentEntity
) { ) {
@ -142,15 +142,16 @@ GameLib.D3.API.RigidBody = function(
} }
this.parentMesh = parentMesh; this.parentMesh = parentMesh;
if (GameLib.Utils.UndefinedOrNull(parentWorld)) { if (GameLib.Utils.UndefinedOrNull(parentPhysicsWorld)) {
parentWorld = null; parentPhysicsWorld = null;
} }
this.parentWorld = parentWorld; this.parentPhysicsWorld = parentPhysicsWorld;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.RIGID_BODY,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.RigidBody.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.RigidBody.prototype = Object.create(GameLib.Component.prototype);
@ -182,7 +183,7 @@ GameLib.D3.API.RigidBody.FromObject = function(objectRigidBody) {
objectRigidBody.shapes, objectRigidBody.shapes,
objectRigidBody.kinematic, objectRigidBody.kinematic,
objectRigidBody.parentMesh, objectRigidBody.parentMesh,
objectRigidBody.parentWorld, objectRigidBody.parentPhysicsWorld,
objectRigidBody.parentEntity objectRigidBody.parentEntity
); );
}; };

View File

@ -98,10 +98,11 @@ GameLib.D3.API.Scene = function(
} }
this.gridColor = gridColor; this.gridColor = gridColor;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.SCENE,
this.parentEntity = parentEntity; parentEntity
);
}; };

View File

@ -2,6 +2,7 @@
* Raw Shape API object - should always correspond with the Shape Schema * Raw Shape API object - should always correspond with the Shape Schema
* @param id * @param id
* @param name * @param name
* @param shapeType
* @param boundingSphereRadius * @param boundingSphereRadius
* @param collisionResponse * @param collisionResponse
* @param frictionMaterial * @param frictionMaterial
@ -12,6 +13,7 @@
GameLib.D3.API.Shape = function( GameLib.D3.API.Shape = function(
id, id,
name, name,
shapeType,
boundingSphereRadius, boundingSphereRadius,
collisionResponse, collisionResponse,
frictionMaterial, frictionMaterial,
@ -24,35 +26,40 @@ GameLib.D3.API.Shape = function(
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(shapeType)) {
shapeType = GameLib.D3.API.Shape.SHAPE_TYPE_NONE;
}
this.shapeType = shapeType;
if (GameLib.Utils.UndefinedOrNull(name)) { if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Shape (' + this.id + ')'; name = 'Shape (' + this.id + ')';
if (this instanceof GameLib.D3.Shape.ConvexHull) { if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_BOX) {
name = 'Shape Convex Hull (' + this.id + ')';
}
if (this instanceof GameLib.D3.Shape.ConvexHull.Cylinder) {
name = 'Shape Convex Hull Cylinder (' + this.id + ')';
}
if (this instanceof GameLib.D3.Shape.HeightMap) {
name = 'Shape Heightmap (' + this.id + ')';
}
if (this instanceof GameLib.D3.Shape.Box) {
name = 'Shape Box (' + this.id + ')'; name = 'Shape Box (' + this.id + ')';
} }
if (this instanceof GameLib.D3.Shape.Plane) { if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL) {
name = 'Shape Convex Hull (' + this.id + ')';
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER) {
name = 'Shape Convex Hull Cylinder (' + this.id + ')';
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP) {
name = 'Shape HeightMap (' + this.id + ')';
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_PLANE) {
name = 'Shape Plane (' + this.id + ')'; name = 'Shape Plane (' + this.id + ')';
} }
if (this instanceof GameLib.D3.Shape.Sphere) { if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE) {
name = 'Shape Sphere (' + this.id + ')'; name = 'Shape Sphere (' + this.id + ')';
} }
if (this instanceof GameLib.D3.Shape.TriMesh) { if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH) {
name = 'Shape TriMesh (' + this.id + ')'; name = 'Shape TriMesh (' + this.id + ')';
} }
} }
@ -78,15 +85,55 @@ GameLib.D3.API.Shape = function(
} }
this.parentMesh = parentMesh; this.parentMesh = parentMesh;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { var componentType = GameLib.Component.SHAPE;
parentEntity = null;
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_BOX) {
componentType = GameLib.Component.SHAPE_BOX;
} }
this.parentEntity = parentEntity;
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL) {
componentType = GameLib.Component.SHAPE_CONVEX_HULL;
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER) {
componentType = GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER;
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP) {
componentType = GameLib.Component.SHAPE_HEIGHT_MAP;
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_PLANE) {
componentType = GameLib.Component.SHAPE_PLANE;
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE) {
componentType = GameLib.Component.SHAPE_SPHERE;
}
if (this.shapeType === GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH) {
componentType = GameLib.Component.SHAPE_TRI_MESH;
}
GameLib.API.Component.call(
this,
componentType,
parentEntity
);
}; };
GameLib.D3.API.Shape.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Shape.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Shape.prototype.constructor = GameLib.D3.API.Shape; GameLib.D3.API.Shape.prototype.constructor = GameLib.D3.API.Shape;
GameLib.D3.API.Shape.SHAPE_TYPE_NONE = 0x0;
GameLib.D3.API.Shape.SHAPE_TYPE_BOX = 0x1;
GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL = 0x2;
GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER = 0x3;
GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP = 0x4;
GameLib.D3.API.Shape.SHAPE_TYPE_PLANE = 0x5;
GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE = 0x6;
GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH = 0x7;
/** /**
* Creates an API Shape from an Object Shape * Creates an API Shape from an Object Shape
* @param objectShape * @param objectShape
@ -96,6 +143,7 @@ GameLib.D3.API.Shape.FromObject = function(objectShape) {
return new GameLib.D3.API.Shape( return new GameLib.D3.API.Shape(
objectShape.id, objectShape.id,
objectShape.name, objectShape.name,
objectShape.shapeType,
objectShape.boundingSphereRadius, objectShape.boundingSphereRadius,
objectShape.collisionResponse, objectShape.collisionResponse,
objectShape.frictionMaterial, objectShape.frictionMaterial,

View File

@ -24,11 +24,6 @@ GameLib.D3.API.Skeleton = function (
boneTexture, boneTexture,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
} }
@ -82,6 +77,12 @@ GameLib.D3.API.Skeleton = function (
boneTexture = null; boneTexture = null;
} }
this.boneTexture = boneTexture; this.boneTexture = boneTexture;
GameLib.API.Component.call(
this,
GameLib.Component.SKELETON,
parentEntity
);
}; };
GameLib.D3.API.Skeleton.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Skeleton.prototype = Object.create(GameLib.Component.prototype);

View File

@ -28,7 +28,7 @@ GameLib.D3.API.Solver = function(
this.name = name; this.name = name;
if (GameLib.Utils.UndefinedOrNull(solverType)) { if (GameLib.Utils.UndefinedOrNull(solverType)) {
solverType = GameLib.D3.Solver.GS_SOLVER; solverType = GameLib.D3.API.Solver.GS_SOLVER;
} }
this.solverType = solverType; this.solverType = solverType;
@ -42,15 +42,23 @@ GameLib.D3.API.Solver = function(
} }
this.tolerance = tolerance; this.tolerance = tolerance;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.SOLVER,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Solver.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Solver.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Solver.prototype.constructor = GameLib.D3.API.Solver; GameLib.D3.API.Solver.prototype.constructor = GameLib.D3.API.Solver;
/**
* Solver Types
* @type {number}
*/
GameLib.D3.API.Solver.GS_SOLVER = 0x1;
GameLib.D3.API.Solver.SPLIT_SOLVER = 0x2;
/** /**
* Creates an API Solver from an Object Solver * Creates an API Solver from an Object Solver
* @param objectSolver * @param objectSolver

View File

@ -18,7 +18,7 @@ GameLib.D3.API.Spline = function(
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) { if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Spline (unknown)'; name = 'Spline (' + this.id + ')';
} }
this.name = name; this.name = name;
@ -27,10 +27,11 @@ GameLib.D3.API.Spline = function(
} }
this.vertices = vertices; this.vertices = vertices;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.SPLINE,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Spline.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Spline.prototype = Object.create(GameLib.Component.prototype);

View File

@ -1,7 +1,7 @@
/** /**
* Raw Texture API object - should always correspond with the Texture Schema * Raw Texture API object - should always correspond with the Texture Schema
* @param id * @param id
* @param typeId * @param textureType
* @param name * @param name
* @param image * @param image
* @param images * @param images
@ -31,7 +31,7 @@
*/ */
GameLib.D3.API.Texture = function( GameLib.D3.API.Texture = function(
id, id,
typeId, textureType,
name, name,
image, image,
images, images,
@ -58,20 +58,16 @@ GameLib.D3.API.Texture = function(
forward, forward,
parentEntity parentEntity
) { ) {
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(id)) { if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId(); id = GameLib.Utils.RandomId();
} }
this.id = id; this.id = id;
if (GameLib.Utils.UndefinedOrNull(typeId)) { if (GameLib.Utils.UndefinedOrNull(textureType)) {
typeId = GameLib.D3.Texture.TEXTURE_TYPE_NORMAL; textureType = GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL;
} }
this.typeId = typeId; this.textureType = textureType;
if (GameLib.Utils.UndefinedOrNull(name)) { if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Texture (' + id + ')'; name = 'Texture (' + id + ')';
@ -89,12 +85,12 @@ GameLib.D3.API.Texture = function(
this.images = images; this.images = images;
if (GameLib.Utils.UndefinedOrNull(wrapS)) { if (GameLib.Utils.UndefinedOrNull(wrapS)) {
wrapS = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING; wrapS = GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING;
} }
this.wrapS = wrapS; this.wrapS = wrapS;
if (GameLib.Utils.UndefinedOrNull(wrapT)) { if (GameLib.Utils.UndefinedOrNull(wrapT)) {
wrapT = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING; wrapT = GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING;
} }
this.wrapT = wrapT; this.wrapT = wrapT;
@ -109,27 +105,27 @@ GameLib.D3.API.Texture = function(
this.data = data; this.data = data;
if (GameLib.Utils.UndefinedOrNull(format)) { if (GameLib.Utils.UndefinedOrNull(format)) {
format = GameLib.D3.Texture.TYPE_RGBA_FORMAT; format = GameLib.D3.API.Texture.TYPE_RGBA_FORMAT;
} }
this.format = format; this.format = format;
if (GameLib.Utils.UndefinedOrNull(mapping)) { if (GameLib.Utils.UndefinedOrNull(mapping)) {
mapping = GameLib.D3.Texture.TYPE_UV_MAPPING; mapping = GameLib.D3.API.Texture.TYPE_UV_MAPPING;
} }
this.mapping = mapping; this.mapping = mapping;
if (GameLib.Utils.UndefinedOrNull(magFilter)) { if (GameLib.Utils.UndefinedOrNull(magFilter)) {
magFilter = GameLib.D3.Texture.TYPE_LINEAR_FILTER; magFilter = GameLib.D3.API.Texture.TYPE_LINEAR_FILTER;
} }
this.magFilter = magFilter; this.magFilter = magFilter;
if (GameLib.Utils.UndefinedOrNull(minFilter)) { if (GameLib.Utils.UndefinedOrNull(minFilter)) {
minFilter = GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER; minFilter = GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
} }
this.minFilter = minFilter; this.minFilter = minFilter;
if (GameLib.Utils.UndefinedOrNull(textureType)) { if (GameLib.Utils.UndefinedOrNull(textureType)) {
textureType = GameLib.D3.Texture.TYPE_UNSIGNED_BYTE; textureType = GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE;
} }
this.textureType = textureType; this.textureType = textureType;
@ -169,7 +165,7 @@ GameLib.D3.API.Texture = function(
this.premultiplyAlpha = premultiplyAlpha; this.premultiplyAlpha = premultiplyAlpha;
if (GameLib.Utils.UndefinedOrNull(encoding)) { if (GameLib.Utils.UndefinedOrNull(encoding)) {
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING; encoding = GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING;
} }
this.encoding = encoding; this.encoding = encoding;
@ -194,11 +190,91 @@ GameLib.D3.API.Texture = function(
this.forward = forward; this.forward = forward;
this.needsUpdate = false; this.needsUpdate = false;
GameLib.API.Component.call(
this,
GameLib.Component.TEXTURE,
parentEntity
);
}; };
GameLib.D3.API.Texture.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Texture.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.API.Texture.prototype.constructor = GameLib.D3.API.Texture; GameLib.D3.API.Texture.prototype.constructor = GameLib.D3.API.Texture;
/**
* Texture Formats
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_ALPHA_FORMAT = 1019;
GameLib.D3.API.Texture.TYPE_RGB_FORMAT = 1020;
GameLib.D3.API.Texture.TYPE_RGBA_FORMAT = 1021;
GameLib.D3.API.Texture.TYPE_LUMINANCE_FORMAT = 1022;
GameLib.D3.API.Texture.TYPE_LUMINANCE_ALPHA_FORMAT = 1023;
GameLib.D3.API.Texture.TYPE_DEPTH_FORMAT = 1026;
/**
* Mapping modes
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_UV_MAPPING = 300;
GameLib.D3.API.Texture.TYPE_CUBE_REFLECTION_MAPPING = 301;
GameLib.D3.API.Texture.TYPE_CUBE_REFRACTION_MAPPING = 302;
GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING = 303;
GameLib.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING = 304;
GameLib.D3.API.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING = 305;
GameLib.D3.API.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING = 306;
GameLib.D3.API.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING = 307;
/**
* Wrapping Modes
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_REPEAT_WRAPPING = 1000;
GameLib.D3.API.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING = 1001;
GameLib.D3.API.Texture.TYPE_MIRRORED_REPEAT_WRAPPING = 1002;
/**
* Mipmap Filters
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_NEAREST_FILTER = 1003;
GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER = 1004;
GameLib.D3.API.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER = 1005;
GameLib.D3.API.Texture.TYPE_LINEAR_FILTER = 1006;
GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER = 1007;
GameLib.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER = 1008;
/**
* Texture Data Types
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_UNSIGNED_BYTE = 1009;
GameLib.D3.API.Texture.TYPE_BYTE = 1010;
GameLib.D3.API.Texture.TYPE_SHORT = 1011;
GameLib.D3.API.Texture.TYPE_UNSIGNED_SHORT = 1012;
GameLib.D3.API.Texture.TYPE_INT = 1013;
GameLib.D3.API.Texture.TYPE_UNSIGNED_INT = 1014;
GameLib.D3.API.Texture.TYPE_FLOAT = 1015;
GameLib.D3.API.Texture.TYPE_HALF_FLOAT = 1025;
/**
* Encoding Modes
* @type {number}
*/
GameLib.D3.API.Texture.TYPE_LINEAR_ENCODING = 3000; // NO ENCODING AT ALL.
GameLib.D3.API.Texture.TYPE_SRGB_ENCODING = 3001;
GameLib.D3.API.Texture.TYPE_GAMMA_ENCODING = 3007; // USES GAMMA_FACTOR, FOR BACKWARDS COMPATIBILITY WITH WEBGLRENDERER.GAMMAINPUT/GAMMAOUTPUT
GameLib.D3.API.Texture.TYPE_RGBE_ENCODING = 3002; // AKA RADIANCE.
GameLib.D3.API.Texture.TYPE_LOG_LUV_ENCODING = 3003;
GameLib.D3.API.Texture.TYPE_RGBM7_ENCODING = 3004;
GameLib.D3.API.Texture.TYPE_RGBM16_ENCODING = 3005;
GameLib.D3.API.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL = 0x1;
GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE = 0x2;
GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS = 0x3;
/** /**
* Creates an API texture from Object data * Creates an API texture from Object data
* @param objectTexture * @param objectTexture
@ -207,7 +283,7 @@ GameLib.D3.API.Texture.prototype.constructor = GameLib.D3.API.Texture;
GameLib.D3.API.Texture.FromObject = function(objectTexture) { GameLib.D3.API.Texture.FromObject = function(objectTexture) {
return new GameLib.D3.API.Texture( return new GameLib.D3.API.Texture(
objectTexture.id, objectTexture.id,
objectTexture.typeId, objectTexture.textureType,
objectTexture.name, objectTexture.name,
objectTexture.image, objectTexture.image,
objectTexture.images, objectTexture.images,

View File

@ -49,10 +49,11 @@ GameLib.D3.API.Viewport = function(
} }
this.y = y; this.y = y;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) { GameLib.API.Component.call(
parentEntity = null; this,
} GameLib.Component.VIEWPORT,
this.parentEntity = parentEntity; parentEntity
);
}; };
GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype);

View File

@ -43,7 +43,6 @@ GameLib.D3.Animation = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_ANIMATION,
{ {
'meshes' : [GameLib.D3.Mesh] 'meshes' : [GameLib.D3.Mesh]
} }

View File

@ -42,7 +42,6 @@ GameLib.D3.Audio = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_AUDIO,
{ {
'camera' : GameLib.D3.Camera 'camera' : GameLib.D3.Camera
} }

View File

@ -28,7 +28,8 @@ GameLib.D3.Bone = function (
apiBone.position, apiBone.position,
apiBone.quaternion, apiBone.quaternion,
apiBone.scale, apiBone.scale,
apiBone.up apiBone.up,
apiBone.parentEntity
); );
this.position = new GameLib.Vector3( this.position = new GameLib.Vector3(
@ -55,10 +56,7 @@ GameLib.D3.Bone = function (
this this
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_BONE
);
}; };
GameLib.D3.Bone.prototype = Object.create(GameLib.D3.API.Bone.prototype); GameLib.D3.Bone.prototype = Object.create(GameLib.D3.API.Bone.prototype);
@ -133,7 +131,8 @@ GameLib.D3.Bone.prototype.toApiObject = function() {
this.position.toApiObject(), this.position.toApiObject(),
this.quaternion.toApiObject(), this.quaternion.toApiObject(),
this.scale.toApiObject(), this.scale.toApiObject(),
this.up.toApiObject() this.up.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity)
); );
return apiBone; return apiBone;

View File

@ -28,10 +28,7 @@ GameLib.D3.Broadphase = function (
apiBroadphase.parentEntity apiBroadphase.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_BROADPHASE
);
}; };
GameLib.D3.Broadphase.prototype = Object.create(GameLib.D3.API.Broadphase.prototype); GameLib.D3.Broadphase.prototype = Object.create(GameLib.D3.API.Broadphase.prototype);

View File

@ -40,9 +40,9 @@ GameLib.D3.Camera = function(
apiCamera.offsetX, apiCamera.offsetX,
apiCamera.offsetY, apiCamera.offsetY,
apiCamera.quaternion, apiCamera.quaternion,
apiCamera.parentEntity,
apiCamera.eyeSeparation, apiCamera.eyeSeparation,
apiCamera.focalLength apiCamera.focalLength,
apiCamera.parentEntity
); );
if (this.position instanceof GameLib.API.Vector3) { if (this.position instanceof GameLib.API.Vector3) {
@ -80,7 +80,7 @@ GameLib.D3.Camera = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_CAMERA GameLib.Component.CAMERA
); );
} ; } ;
@ -268,9 +268,9 @@ GameLib.D3.Camera.prototype.toApiObject = function() {
this.offsetX, this.offsetX,
this.offsetY, this.offsetY,
this.quaternion.toApiObject(), this.quaternion.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity),
this.eyeSeparation, this.eyeSeparation,
this.focalLength this.focalLength,
GameLib.Utils.IdOrNull(this.parentEntity)
); );
}; };

View File

@ -32,7 +32,6 @@ GameLib.D3.Composer = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_COMPOSER,
{ {
'renderer' : GameLib.D3.Renderer, 'renderer' : GameLib.D3.Renderer,
'renderTarget' : GameLib.D3.RenderTarget, 'renderTarget' : GameLib.D3.RenderTarget,

View File

@ -38,10 +38,7 @@ GameLib.D3.Fog = function (
this this
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_FOG
);
}; };
GameLib.D3.Fog.prototype = Object.create(GameLib.D3.API.Fog.prototype); GameLib.D3.Fog.prototype = Object.create(GameLib.D3.API.Fog.prototype);

View File

@ -27,10 +27,7 @@ GameLib.D3.Font = function(
apiFont.parentEntity apiFont.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_FONT
);
}; };
GameLib.D3.Font.prototype = Object.create(GameLib.D3.API.Font.prototype); GameLib.D3.Font.prototype = Object.create(GameLib.D3.API.Font.prototype);

View File

@ -36,7 +36,6 @@ GameLib.D3.FrictionContactMaterial = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_FRICTION_CONTACT_MATERIAL,
{ {
materials : [GameLib.D3.FrictionMaterial] materials : [GameLib.D3.FrictionMaterial]
} }

View File

@ -29,10 +29,7 @@ GameLib.D3.FrictionMaterial = function (
apiFrictionMaterial.parentEntity apiFrictionMaterial.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_FRICTION_MATERIAL
);
}; };
GameLib.D3.FrictionMaterial.prototype = Object.create(GameLib.D3.API.FrictionMaterial.prototype); GameLib.D3.FrictionMaterial.prototype = Object.create(GameLib.D3.API.FrictionMaterial.prototype);

View File

@ -41,7 +41,7 @@ GameLib.D3.Helper = function(
if ( if (
object instanceof GameLib.D3.Mesh && object instanceof GameLib.D3.Mesh &&
object.meshType !== GameLib.D3.Mesh.MESH_TYPE_CURVE object.meshType !== GameLib.D3.API.Mesh.MESH_TYPE_CURVE
) { ) {
helperType = GameLib.D3.Helper.HELPER_TYPE_EDGES; helperType = GameLib.D3.Helper.HELPER_TYPE_EDGES;
} }
@ -77,7 +77,7 @@ GameLib.D3.Helper = function(
*/ */
// GameLib.Component.call( // GameLib.Component.call(
// this, // this,
// GameLib.Component.COMPONENT_HELPER // GameLib.Component.HELPER
// ); // );
}; };

View File

@ -78,7 +78,6 @@ GameLib.D3.Light = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_LIGHT,
{ {
'parentScene' : GameLib.D3.Scene 'parentScene' : GameLib.D3.Scene
} }

View File

@ -223,7 +223,6 @@ GameLib.D3.Material = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_MATERIAL,
{ {
'alphaMap' : GameLib.D3.Texture, 'alphaMap' : GameLib.D3.Texture,
'aoMap' : GameLib.D3.Texture, 'aoMap' : GameLib.D3.Texture,

View File

@ -12,7 +12,9 @@ GameLib.D3.Mesh = function (
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {}; apiMesh = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_NORMAL
};
} }
if (apiMesh instanceof GameLib.D3.Mesh) { if (apiMesh instanceof GameLib.D3.Mesh) {
@ -38,11 +40,11 @@ GameLib.D3.Mesh = function (
apiMesh.scale, apiMesh.scale,
apiMesh.up, apiMesh.up,
apiMesh.modelMatrix, apiMesh.modelMatrix,
apiMesh.parentEntity,
apiMesh.renderOrder, apiMesh.renderOrder,
apiMesh.isBufferMesh, apiMesh.isBufferMesh,
apiMesh.useQuaternion, apiMesh.useQuaternion,
apiMesh.visible apiMesh.visible,
apiMesh.parentEntity
); );
this.faces = this.faces.map( this.faces = this.faces.map(
@ -136,30 +138,7 @@ GameLib.D3.Mesh = function (
'skeleton' : GameLib.D3.Skeleton 'skeleton' : GameLib.D3.Skeleton
}; };
var componentType = GameLib.Component.COMPONENT_MESH; if (this.meshType === GameLib.D3.API.Mesh.MESH_TYPE_TEXT) {
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_PLANE) {
componentType = GameLib.Component.COMPONENT_MESH_PLANE
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_BOX) {
componentType = GameLib.Component.COMPONENT_MESH_BOX
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_CYLINDER) {
componentType = GameLib.Component.COMPONENT_MESH_CYLINDER
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_SPHERE) {
componentType = GameLib.Component.COMPONENT_MESH_SPHERE
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_LINE) {
componentType = GameLib.Component.COMPONENT_MESH_LINE
}
if (this.meshType === GameLib.D3.Mesh.MESH_TYPE_TEXT) {
componentType = GameLib.Component.COMPONENT_MESH_TEXT;
linkedObjects.font = GameLib.D3.Font; linkedObjects.font = GameLib.D3.Font;
} }
@ -173,7 +152,6 @@ GameLib.D3.Mesh = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
componentType,
linkedObjects linkedObjects
); );
}; };
@ -181,20 +159,6 @@ GameLib.D3.Mesh = function (
GameLib.D3.Mesh.prototype = Object.create(GameLib.D3.API.Mesh.prototype); GameLib.D3.Mesh.prototype = Object.create(GameLib.D3.API.Mesh.prototype);
GameLib.D3.Mesh.prototype.constructor = GameLib.D3.Mesh; GameLib.D3.Mesh.prototype.constructor = GameLib.D3.Mesh;
/**
* Mesh Type
* @type {number}
*/
GameLib.D3.Mesh.MESH_TYPE_NORMAL = 0x0;
GameLib.D3.Mesh.MESH_TYPE_SKINNED = 0x1;
GameLib.D3.Mesh.MESH_TYPE_CURVE = 0x2;
GameLib.D3.Mesh.MESH_TYPE_SPHERE = 0x3;
GameLib.D3.Mesh.MESH_TYPE_PLANE = 0x4;
GameLib.D3.Mesh.MESH_TYPE_BOX = 0x5;
GameLib.D3.Mesh.MESH_TYPE_CYLINDER = 0x6;
GameLib.D3.Mesh.MESH_TYPE_TEXT = 0x7;
GameLib.D3.Mesh.MESH_TYPE_LINE = 0x8;
GameLib.D3.Mesh.prototype.lookAt = function(vector) { GameLib.D3.Mesh.prototype.lookAt = function(vector) {
this.instance.lookAt( this.instance.lookAt(
@ -1084,11 +1048,11 @@ GameLib.D3.Mesh.prototype.toApiObject = function() {
this.scale.toApiObject(), this.scale.toApiObject(),
this.up.toApiObject(), this.up.toApiObject(),
this.modelMatrix.toApiObject(), this.modelMatrix.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity),
this.renderOrder, this.renderOrder,
this.isBufferMesh, this.isBufferMesh,
this.useQuaternion, this.useQuaternion,
this.visible this.visible,
GameLib.Utils.IdOrNull(this.parentEntity)
); );
return apiMesh; return apiMesh;
@ -1408,7 +1372,7 @@ GameLib.D3.Mesh.prototype.getChildrenComponents = function() {
/** /**
* Push RigidBodies * Push RigidBodies
*/ */
var rigidBodies = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.RigidBody); var rigidBodies = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.RIGID_BODY);
rigidBodies.map( rigidBodies.map(
function(rigidBody) { function(rigidBody) {
@ -1422,7 +1386,7 @@ GameLib.D3.Mesh.prototype.getChildrenComponents = function() {
/** /**
* Push Shapes * Push Shapes
*/ */
var shapes = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Shape); var shapes = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SHAPE);
shapes.map( shapes.map(
function(shape) { function(shape) {

View File

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

View File

@ -11,6 +11,16 @@ GameLib.D3.Mesh.Curve = function (
this.graphics = graphics; this.graphics = graphics;
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_CURVE
};
}
if (apiMesh instanceof GameLib.D3.Mesh.Curve) {
return apiMesh;
}
GameLib.D3.Mesh.call( GameLib.D3.Mesh.call(
this, this,
this.graphics, this.graphics,

View File

@ -29,15 +29,15 @@ GameLib.D3.Mesh.Cylinder = function (
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {}; apiMesh = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_CYLINDER
};
} }
if (apiMesh instanceof GameLib.D3.Mesh.Box) { if (apiMesh instanceof GameLib.D3.Mesh.Cylinder) {
return apiMesh; return apiMesh;
} }
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_CYLINDER;
if (GameLib.Utils.UndefinedOrNull(radiusTop)) { if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1; radiusTop = 1;
} }

View File

@ -14,15 +14,15 @@ GameLib.D3.Mesh.Line = function (
this.graphics.isNotThreeThrow(); this.graphics.isNotThreeThrow();
if (GameLib.Utils.UndefinedOrNull(apiMesh)) { if (GameLib.Utils.UndefinedOrNull(apiMesh)) {
apiMesh = {}; apiMesh = {
meshType: GameLib.D3.API.Mesh.MESH_TYPE_LINE
};
} }
if (apiMesh instanceof GameLib.D3.Mesh.Line) { if (apiMesh instanceof GameLib.D3.Mesh.Line) {
return apiMesh; return apiMesh;
} }
apiMesh.meshType = GameLib.D3.Mesh.MESH_TYPE_LINE;
if (GameLib.Utils.UndefinedOrNull(lineWidth)) { if (GameLib.Utils.UndefinedOrNull(lineWidth)) {
lineWidth = 1; lineWidth = 1;
} }

View File

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

View File

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

View File

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

View File

@ -78,7 +78,6 @@ GameLib.D3.ParticleEngine = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_PARTICLE_ENGINE,
{ {
templateParticle : GameLib.D3.Particle, templateParticle : GameLib.D3.Particle,
camera : GameLib.D3.Camera camera : GameLib.D3.Camera

View File

@ -100,7 +100,6 @@ GameLib.D3.Particle = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_PARTICLE,
{ {
mesh : GameLib.D3.Mesh, mesh : GameLib.D3.Mesh,
parentEngine : GameLib.D3.ParticleEngine parentEngine : GameLib.D3.ParticleEngine

View File

@ -33,7 +33,6 @@ GameLib.D3.Pass = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_PASS,
{ {
'camera' : GameLib.D3.Camera, 'camera' : GameLib.D3.Camera,
'scene' : GameLib.D3.Scene 'scene' : GameLib.D3.Scene

View File

@ -89,7 +89,6 @@ GameLib.D3.PhysicsWorld = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_PHYSICS_WORLD,
{ {
'broadphase' : GameLib.D3.Broadphase, 'broadphase' : GameLib.D3.Broadphase,
'solver' : GameLib.D3.Solver, 'solver' : GameLib.D3.Solver,
@ -158,7 +157,7 @@ GameLib.D3.PhysicsWorld.prototype.createInstance = function() {
throw new Error('no rigidbody instance'); throw new Error('no rigidbody instance');
} }
rigidBody.parentWorld = this; rigidBody.parentPhysicsWorld = this;
this.instance.add(rigidBody.instance); this.instance.add(rigidBody.instance);
@ -185,10 +184,10 @@ GameLib.D3.PhysicsWorld.prototype.addRigidBody = function(rigidBody) {
this.instance.add(rigidBody.instance); this.instance.add(rigidBody.instance);
/** /**
* Remember to set the parentWorld for this rigidBody * Remember to set the parentPhysicsWorld for this rigidBody
* @type {GameLib.D3.PhysicsWorld} * @type {GameLib.D3.PhysicsWorld}
*/ */
rigidBody.parentWorld = this; rigidBody.parentPhysicsWorld = this;
/** /**
* Ensure this rigidBody is in our rigidBodies array, just not too many times.. * Ensure this rigidBody is in our rigidBodies array, just not too many times..
@ -223,10 +222,10 @@ GameLib.D3.PhysicsWorld.prototype.removeRigidBody = function(rigidBody) {
} }
/** /**
* Remember to set the parentWorld for this rigidBody * Remember to set the parentPhysicsWorld for this rigidBody
* @type {GameLib.D3.PhysicsWorld} * @type {GameLib.D3.PhysicsWorld}
*/ */
rigidBody.parentWorld = null; rigidBody.parentPhysicsWorld = null;
/** /**
* Remove from this rigidBodies array * Remove from this rigidBodies array

View File

@ -27,7 +27,7 @@ GameLib.D3.RaycastVehicle = function (
apiRaycastVehicle.chassis, apiRaycastVehicle.chassis,
apiRaycastVehicle.wheels, apiRaycastVehicle.wheels,
apiRaycastVehicle.raycastWheels, apiRaycastVehicle.raycastWheels,
apiRaycastVehicle.parentWorld, apiRaycastVehicle.parentPhysicsWorld,
apiRaycastVehicle.parentEntity apiRaycastVehicle.parentEntity
); );
@ -62,12 +62,11 @@ GameLib.D3.RaycastVehicle = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_RAYCAST_VEHICLE,
{ {
'chassis' : GameLib.D3.RigidBody, 'chassis' : GameLib.D3.RigidBody,
'wheels' : [GameLib.D3.RigidBody], 'wheels' : [GameLib.D3.RigidBody],
'raycastWheels' : [GameLib.D3.RaycastWheel], 'raycastWheels' : [GameLib.D3.RaycastWheel],
'parentWorld' : GameLib.D3.PhysicsWorld 'parentPhysicsWorld' : GameLib.D3.PhysicsWorld
} }
); );
}; };
@ -96,11 +95,11 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
throw new Error('no chassis instance'); throw new Error('no chassis instance');
} }
if (GameLib.Utils.UndefinedOrNull(this.parentWorld)) { if (GameLib.Utils.UndefinedOrNull(this.parentPhysicsWorld)) {
throw new Error('no parent world'); throw new Error('no parent world');
} }
if (GameLib.Utils.UndefinedOrNull(this.parentWorld.instance)) { if (GameLib.Utils.UndefinedOrNull(this.parentPhysicsWorld.instance)) {
throw new Error('no parent world instance'); throw new Error('no parent world instance');
} }
@ -124,7 +123,7 @@ GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
}.bind(this) }.bind(this)
); );
this.instance.addToWorld(this.parentWorld.instance); this.instance.addToWorld(this.parentPhysicsWorld.instance);
GameLib.Component.prototype.createInstance.call(this); GameLib.Component.prototype.createInstance.call(this);
@ -152,7 +151,7 @@ GameLib.D3.RaycastVehicle.prototype.toApiObject = function() {
this.raycastWheels.map(function(raycastWheel){ this.raycastWheels.map(function(raycastWheel){
return GameLib.Utils.IdOrNull(raycastWheel); return GameLib.Utils.IdOrNull(raycastWheel);
}), }),
GameLib.Utils.IdOrNull(this.parentWorld), GameLib.Utils.IdOrNull(this.parentPhysicsWorld),
GameLib.Utils.IdOrNull(this.parentEntity) GameLib.Utils.IdOrNull(this.parentEntity)
); );

View File

@ -38,8 +38,8 @@ GameLib.D3.RaycastWheel = function (
apiRaycastWheel.maxSuspensionTravel, apiRaycastWheel.maxSuspensionTravel,
apiRaycastWheel.customSlidingRotationalSpeed, apiRaycastWheel.customSlidingRotationalSpeed,
apiRaycastWheel.useCustomSlidingRotationalSpeed, apiRaycastWheel.useCustomSlidingRotationalSpeed,
apiRaycastWheel.parentEntity, apiRaycastWheel.parentMesh,
apiRaycastWheel.parentMesh apiRaycastWheel.parentEntity
); );
this.directionLocal = new GameLib.Vector3( this.directionLocal = new GameLib.Vector3(
@ -62,7 +62,6 @@ GameLib.D3.RaycastWheel = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_RAYCAST_WHEEL,
{ {
'parentMesh' : GameLib.D3.Mesh 'parentMesh' : GameLib.D3.Mesh
} }
@ -138,8 +137,8 @@ GameLib.D3.RaycastWheel.prototype.toApiObject = function() {
this.maxSuspensionTravel, this.maxSuspensionTravel,
this.customSlidingRotationalSpeed, this.customSlidingRotationalSpeed,
this.useCustomSlidingRotationalSpeed, this.useCustomSlidingRotationalSpeed,
GameLib.Utils.IdOrNull(this.parentEntity), GameLib.Utils.IdOrNull(this.parentMesh),
GameLib.Utils.IdOrNull(this.parentMesh) GameLib.Utils.IdOrNull(this.parentEntity)
); );
return apiRaycastWheel; return apiRaycastWheel;

View File

@ -40,10 +40,7 @@ GameLib.D3.Raycaster = function(
this this
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_RAYCASTER
);
}; };
GameLib.D3.Raycaster.prototype = Object.create(GameLib.D3.API.Raycaster.prototype); GameLib.D3.Raycaster.prototype = Object.create(GameLib.D3.API.Raycaster.prototype);
@ -83,7 +80,8 @@ GameLib.D3.Raycaster.prototype.toApiObject = function() {
this.id, this.id,
this.name, this.name,
this.position.toApiObject(), this.position.toApiObject(),
this.direction.toApiObject() this.direction.toApiObject(),
GameLib.Utils.IdOrNull(this.parentEntity)
) )
}; };

View File

@ -32,7 +32,6 @@ GameLib.D3.RenderTarget = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_RENDER_TARGET,
{ {
'texture' : GameLib.D3.Texture 'texture' : GameLib.D3.Texture
} }

View File

@ -126,7 +126,6 @@ GameLib.D3.Renderer = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_RENDERER,
{ {
'domElement' : GameLib.DomElement, 'domElement' : GameLib.DomElement,
'camera' : GameLib.D3.Camera, 'camera' : GameLib.D3.Camera,

View File

@ -41,7 +41,7 @@ GameLib.D3.RigidBody = function (
apiRigidBody.shapes, apiRigidBody.shapes,
apiRigidBody.kinematic, apiRigidBody.kinematic,
apiRigidBody.parentMesh, apiRigidBody.parentMesh,
apiRigidBody.parentWorld, apiRigidBody.parentPhysicsWorld,
apiRigidBody.parentEntity apiRigidBody.parentEntity
); );
@ -79,11 +79,10 @@ GameLib.D3.RigidBody = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_RIGID_BODY,
{ {
'shapes' : [GameLib.D3.Shape], 'shapes' : [GameLib.D3.Shape],
'parentMesh' : GameLib.D3.Mesh, 'parentMesh' : GameLib.D3.Mesh,
'parentWorld' : GameLib.D3.PhysicsWorld 'parentPhysicsWorld' : GameLib.D3.PhysicsWorld
} }
); );
}; };
@ -251,7 +250,7 @@ GameLib.D3.RigidBody.prototype.toApiObject = function() {
this.shapes.map(function(shape){return GameLib.Utils.IdOrNull(shape)}), this.shapes.map(function(shape){return GameLib.Utils.IdOrNull(shape)}),
this.kinematic, this.kinematic,
GameLib.Utils.IdOrNull(this.parentMesh), GameLib.Utils.IdOrNull(this.parentMesh),
GameLib.Utils.IdOrNull(this.parentWorld), GameLib.Utils.IdOrNull(this.parentPhysicsWorld),
GameLib.Utils.IdOrNull(this.parentEntity) GameLib.Utils.IdOrNull(this.parentEntity)
); );

View File

@ -167,7 +167,6 @@ GameLib.D3.Scene = function (
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_SCENE,
{ {
'meshes' : [GameLib.D3.Mesh], 'meshes' : [GameLib.D3.Mesh],
'lights' : [GameLib.D3.Light], 'lights' : [GameLib.D3.Light],

View File

@ -12,7 +12,9 @@ GameLib.D3.Shape = function (
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) { if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {}; apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_NONE
};
} }
if (apiShape instanceof GameLib.D3.Shape) { if (apiShape instanceof GameLib.D3.Shape) {
@ -23,6 +25,7 @@ GameLib.D3.Shape = function (
this, this,
apiShape.id, apiShape.id,
apiShape.name, apiShape.name,
apiShape.shapeType,
apiShape.boundingSphereRadius, apiShape.boundingSphereRadius,
apiShape.collisionResponse, apiShape.collisionResponse,
apiShape.frictionMaterial, apiShape.frictionMaterial,
@ -30,44 +33,13 @@ GameLib.D3.Shape = function (
apiShape.parentEntity apiShape.parentEntity
); );
var componentType = GameLib.Component.COMPONENT_SHAPE;
var linkedObjects = { var linkedObjects = {
frictionMaterial : GameLib.D3.FrictionMaterial, frictionMaterial : GameLib.D3.FrictionMaterial,
parentMesh : GameLib.D3.Mesh parentMesh : GameLib.D3.Mesh
}; };
if (this instanceof GameLib.D3.Shape.Box) {
componentType = GameLib.Component.COMPONENT_SHAPE_BOX;
}
if (this instanceof GameLib.D3.Shape.ConvexHull) {
componentType = GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL;
}
if (this instanceof GameLib.D3.Shape.ConvexHull.Cylinder) {
componentType = GameLib.Component.COMPONENT_SHAPE_CONVEX_HULL_CYLINDER;
}
if (this instanceof GameLib.D3.Shape.Sphere) {
componentType = GameLib.Component.COMPONENT_SHAPE_SPHERE;
}
if (this instanceof GameLib.D3.Shape.TriMesh) {
componentType = GameLib.Component.COMPONENT_SHAPE_TRI_MESH;
}
if (this instanceof GameLib.D3.Shape.Plane) {
componentType = GameLib.Component.COMPONENT_SHAPE_PLANE;
}
if (this instanceof GameLib.D3.Shape.HeightMap) {
componentType = GameLib.Component.COMPONENT_SHAPE_HEIGHT_MAP;
}
GameLib.Component.call( GameLib.Component.call(
this, this,
componentType,
linkedObjects linkedObjects
); );
}; };
@ -75,6 +47,7 @@ GameLib.D3.Shape = function (
GameLib.D3.Shape.prototype = Object.create(GameLib.D3.API.Shape.prototype); GameLib.D3.Shape.prototype = Object.create(GameLib.D3.API.Shape.prototype);
GameLib.D3.Shape.prototype.constructor = GameLib.D3.Shape; GameLib.D3.Shape.prototype.constructor = GameLib.D3.Shape;
/** /**
* Creates a shape instance or updates it * Creates a shape instance or updates it
*/ */
@ -98,6 +71,7 @@ GameLib.D3.Shape.prototype.toApiObject = function() {
var apiShape = new GameLib.D3.API.Shape( var apiShape = new GameLib.D3.API.Shape(
this.id, this.id,
this.name, this.name,
this.shapeType,
this.boundingSphereRadius, this.boundingSphereRadius,
this.collisionResponse, this.collisionResponse,
GameLib.Utils.IdOrNull(this.frictionMaterial), GameLib.Utils.IdOrNull(this.frictionMaterial),

View File

@ -13,6 +13,16 @@ GameLib.D3.Shape.Box = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_BOX
};
}
if (apiShape instanceof GameLib.D3.Shape.Box) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(halfExtents)) { if (GameLib.Utils.UndefinedOrNull(halfExtents)) {
halfExtents = new GameLib.Vector3( halfExtents = new GameLib.Vector3(
physics, physics,

View File

@ -20,7 +20,9 @@ GameLib.D3.Shape.ConvexHull = function (
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) { if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {}; apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL
};
} }
if (apiShape instanceof GameLib.D3.Shape.ConvexHull) { if (apiShape instanceof GameLib.D3.Shape.ConvexHull) {

View File

@ -19,6 +19,16 @@ GameLib.D3.Shape.ConvexHull.Cylinder = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_CONVEX_HULL_CYLINDER
};
}
if (apiShape instanceof GameLib.D3.Shape.ConvexHull.Cylinder) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(radiusTop)) { if (GameLib.Utils.UndefinedOrNull(radiusTop)) {
radiusTop = 1; radiusTop = 1;
} }

View File

@ -19,6 +19,16 @@ GameLib.D3.Shape.HeightMap = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_HEIGHT_MAP
};
}
if (apiShape instanceof GameLib.D3.Shape.HeightMap) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(heightData)) { if (GameLib.Utils.UndefinedOrNull(heightData)) {
heightData = [[10, 10, 10], [10, 10, 10], [10, 10, 10]]; heightData = [[10, 10, 10], [10, 10, 10], [10, 10, 10]];
} }

View File

@ -11,6 +11,16 @@ GameLib.D3.Shape.Plane = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_PLANE
};
}
if (apiShape instanceof GameLib.D3.Shape.Plane) {
return apiShape;
}
GameLib.D3.Shape.call( GameLib.D3.Shape.call(
this, this,
this.physics, this.physics,

View File

@ -13,6 +13,16 @@ GameLib.D3.Shape.Sphere = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_SPHERE
};
}
if (apiShape instanceof GameLib.D3.Shape.Sphere) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(radius)) { if (GameLib.Utils.UndefinedOrNull(radius)) {
radius = 1; radius = 1;
} }

View File

@ -15,6 +15,16 @@ GameLib.D3.Shape.TriMesh = function (
this.physics = physics; this.physics = physics;
this.physics.isNotCannonThrow(); this.physics.isNotCannonThrow();
if (GameLib.Utils.UndefinedOrNull(apiShape)) {
apiShape = {
shapeType : GameLib.D3.API.Shape.SHAPE_TYPE_TRIMESH
};
}
if (apiShape instanceof GameLib.D3.Shape.TriMesh) {
return apiShape;
}
if (GameLib.Utils.UndefinedOrNull(vertices)) { if (GameLib.Utils.UndefinedOrNull(vertices)) {
vertices = []; vertices = [];
} }

View File

@ -66,7 +66,6 @@ GameLib.D3.Skeleton = function Skeleton(
}.bind(this) }.bind(this)
); );
this.boneMatrices = this.boneMatrices.map( this.boneMatrices = this.boneMatrices.map(
function(boneMatrices) { function(boneMatrices) {
if (boneMatrices instanceof GameLib.API.Matrix4) { if (boneMatrices instanceof GameLib.API.Matrix4) {
@ -85,9 +84,8 @@ GameLib.D3.Skeleton = function Skeleton(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_SKELETON,
{ {
'bones' : [GameLib.D3.Bone] 'bones' : [GameLib.D3.Bone]
} }
); );
}; };
@ -209,7 +207,7 @@ GameLib.D3.Skeleton.prototype.toApiObject = function() {
} }
), ),
this.boneTexture, this.boneTexture,
this.parentEntity GameLib.Utils.IdOrNull(this.parentEntity)
); );
return apiSkeleton; return apiSkeleton;

View File

@ -30,10 +30,7 @@ GameLib.D3.Solver = function (
apiSolver.parentEntity apiSolver.parentEntity
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_SOLVER
);
}; };
GameLib.D3.Solver.prototype = Object.create(GameLib.D3.API.Solver.prototype); GameLib.D3.Solver.prototype = Object.create(GameLib.D3.API.Solver.prototype);
@ -45,9 +42,9 @@ GameLib.D3.Solver.prototype.constructor = GameLib.D3.Solver;
*/ */
GameLib.D3.Solver.prototype.createInstance = function() { GameLib.D3.Solver.prototype.createInstance = function() {
if (this.solverType === GameLib.D3.Solver.GS_SOLVER) { if (this.solverType === GameLib.D3.API.Solver.GS_SOLVER) {
this.instance = new CANNON.GSSolver(); this.instance = new CANNON.GSSolver();
} else if (this.solverType === GameLib.D3.Solver.SPLIT_SOLVER) { } else if (this.solverType === GameLib.D3.API.Solver.SPLIT_SOLVER) {
this.instance = new CANNON.SplitSolver(); this.instance = new CANNON.SplitSolver();
} else { } else {
throw new Error('unsupported solver type: ' + this.solverType); throw new Error('unsupported solver type: ' + this.solverType);
@ -64,13 +61,13 @@ GameLib.D3.Solver.prototype.createInstance = function() {
*/ */
GameLib.D3.Solver.prototype.updateInstance = function() { GameLib.D3.Solver.prototype.updateInstance = function() {
if (this.solverType === GameLib.D3.Solver.GS_SOLVER) { if (this.solverType === GameLib.D3.API.Solver.GS_SOLVER) {
if (!(this.instance instanceof CANNON.GSSolver)) { if (!(this.instance instanceof CANNON.GSSolver)) {
this.instance = new CANNON.GSSolver(); this.instance = new CANNON.GSSolver();
} }
} }
if (this.solverType === GameLib.D3.Solver.SPLIT_SOLVER) { if (this.solverType === GameLib.D3.API.Solver.SPLIT_SOLVER) {
if (!(this.instance instanceof CANNON.SplitSolver)) { if (!(this.instance instanceof CANNON.SplitSolver)) {
this.instance = new CANNON.SplitSolver(); this.instance = new CANNON.SplitSolver();
} }
@ -114,10 +111,3 @@ GameLib.D3.Solver.FromObject = function(graphics, objectComponent) {
apiSolver apiSolver
); );
}; };
/**
* Solver Types
* @type {number}
*/
GameLib.D3.Solver.GS_SOLVER = 0x1;
GameLib.D3.Solver.SPLIT_SOLVER = 0x2;

View File

@ -37,10 +37,7 @@ GameLib.D3.Spline = function (
} }
); );
GameLib.Component.call( GameLib.Component.call(this);
this,
GameLib.Component.COMPONENT_SPLINE
);
}; };
GameLib.D3.Spline.prototype = Object.create(GameLib.D3.API.Spline.prototype); GameLib.D3.Spline.prototype = Object.create(GameLib.D3.API.Spline.prototype);

View File

@ -1,84 +0,0 @@
/**
* Stats component for displaying some render statistics (framerate, memory consumption, etc)
* @param stats
* @param id
* @param name
* @param domElement
* @param parentEntity
* @constructor
*/
GameLib.D3.Stats = function(
stats,
id,
name,
domElement,
parentEntity
) {
this.stats = stats;
this.stats.isNotStatsThrow();
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Stats (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(domElement)) {
console.warn('Need a DOM element for stats');
throw new Error('Need a DOM element for stats');
}
this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_STATS,
{
'domElement': GameLib.DomElement
}
);
};
GameLib.D3.Stats.prototype = Object.create(GameLib.Component.prototype);
GameLib.D3.Stats.prototype.constructor = GameLib.D3.Stats;
GameLib.D3.Stats.prototype.resize = function() {
console.log('override stats resize per implementation');
};
/**
* Creates a helper instance
*/
GameLib.D3.Stats.prototype.createInstance = function() {
this.instance = this.stats.instance();
this.resize();
this.domElement.instance.parentElement.appendChild(this.instance.dom);
GameLib.Component.prototype.createInstance.call(this);
};
/**
* Updates the instance with the current state
*/
GameLib.D3.Stats.prototype.updateInstance = function() {
this.instance = new this.stats();
};
GameLib.D3.Stats.prototype.start = function() {
this.instance.begin();
};
GameLib.D3.Stats.prototype.end = function() {
this.instance.end();
};

View File

@ -23,7 +23,7 @@ GameLib.D3.Texture = function(
GameLib.D3.API.Texture.call( GameLib.D3.API.Texture.call(
this, this,
apiTexture.id, apiTexture.id,
apiTexture.typeId, apiTexture.textureType,
apiTexture.name, apiTexture.name,
apiTexture.image, apiTexture.image,
apiTexture.images, apiTexture.images,
@ -92,7 +92,6 @@ GameLib.D3.Texture = function(
GameLib.Component.call( GameLib.Component.call(
this, this,
GameLib.Component.COMPONENT_TEXTURE,
{ {
'image' : GameLib.Image, 'image' : GameLib.Image,
'images' : [GameLib.Image], 'images' : [GameLib.Image],
@ -104,86 +103,13 @@ GameLib.D3.Texture = function(
GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype); GameLib.D3.Texture.prototype = Object.create(GameLib.D3.API.Texture.prototype);
GameLib.D3.Texture.prototype.constructor = GameLib.D3.Texture; GameLib.D3.Texture.prototype.constructor = GameLib.D3.Texture;
/**
* Texture Formats
* @type {number}
*/
GameLib.D3.Texture.TYPE_ALPHA_FORMAT = 1019;
GameLib.D3.Texture.TYPE_RGB_FORMAT = 1020;
GameLib.D3.Texture.TYPE_RGBA_FORMAT = 1021;
GameLib.D3.Texture.TYPE_LUMINANCE_FORMAT = 1022;
GameLib.D3.Texture.TYPE_LUMINANCE_ALPHA_FORMAT = 1023;
GameLib.D3.Texture.TYPE_DEPTH_FORMAT = 1026;
/**
* Mapping modes
* @type {number}
*/
GameLib.D3.Texture.TYPE_UV_MAPPING = 300;
GameLib.D3.Texture.TYPE_CUBE_REFLECTION_MAPPING = 301;
GameLib.D3.Texture.TYPE_CUBE_REFRACTION_MAPPING = 302;
GameLib.D3.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING = 303;
GameLib.D3.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING = 304;
GameLib.D3.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING = 305;
GameLib.D3.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING = 306;
GameLib.D3.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING = 307;
/**
* Wrapping Modes
* @type {number}
*/
GameLib.D3.Texture.TYPE_REPEAT_WRAPPING = 1000;
GameLib.D3.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING = 1001;
GameLib.D3.Texture.TYPE_MIRRORED_REPEAT_WRAPPING = 1002;
/**
* Mipmap Filters
* @type {number}
*/
GameLib.D3.Texture.TYPE_NEAREST_FILTER = 1003;
GameLib.D3.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER = 1004;
GameLib.D3.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER = 1005;
GameLib.D3.Texture.TYPE_LINEAR_FILTER = 1006;
GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER = 1007;
GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER = 1008;
/**
* Texture Data Types
* @type {number}
*/
GameLib.D3.Texture.TYPE_UNSIGNED_BYTE = 1009;
GameLib.D3.Texture.TYPE_BYTE = 1010;
GameLib.D3.Texture.TYPE_SHORT = 1011;
GameLib.D3.Texture.TYPE_UNSIGNED_SHORT = 1012;
GameLib.D3.Texture.TYPE_INT = 1013;
GameLib.D3.Texture.TYPE_UNSIGNED_INT = 1014;
GameLib.D3.Texture.TYPE_FLOAT = 1015;
GameLib.D3.Texture.TYPE_HALF_FLOAT = 1025;
/**
* Encoding Modes
* @type {number}
*/
GameLib.D3.Texture.TYPE_LINEAR_ENCODING = 3000; // NO ENCODING AT ALL.
GameLib.D3.Texture.TYPE_SRGB_ENCODING = 3001;
GameLib.D3.Texture.TYPE_GAMMA_ENCODING = 3007; // USES GAMMA_FACTOR, FOR BACKWARDS COMPATIBILITY WITH WEBGLRENDERER.GAMMAINPUT/GAMMAOUTPUT
GameLib.D3.Texture.TYPE_RGBE_ENCODING = 3002; // AKA RADIANCE.
GameLib.D3.Texture.TYPE_LOG_LUV_ENCODING = 3003;
GameLib.D3.Texture.TYPE_RGBM7_ENCODING = 3004;
GameLib.D3.Texture.TYPE_RGBM16_ENCODING = 3005;
GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
GameLib.D3.Texture.TEXTURE_TYPE_NORMAL = 0x1;
GameLib.D3.Texture.TEXTURE_TYPE_CUBE = 0x2;
GameLib.D3.Texture.TEXTURE_TYPE_CANVAS = 0x3;
/** /**
* Creates an instance of our texture object * Creates an instance of our texture object
* @returns {*} * @returns {*}
*/ */
GameLib.D3.Texture.prototype.createInstance = function() { GameLib.D3.Texture.prototype.createInstance = function() {
if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CUBE) { if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE) {
if (this.images.length !== 6) { if (this.images.length !== 6) {
throw new Error('not enough images for cube texture'); throw new Error('not enough images for cube texture');
@ -206,7 +132,7 @@ GameLib.D3.Texture.prototype.createInstance = function() {
this.instance = new THREE.CubeTexture(imageInstances); this.instance = new THREE.CubeTexture(imageInstances);
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) { } else if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL) {
if ( if (
GameLib.Utils.UndefinedOrNull(this.image) || GameLib.Utils.UndefinedOrNull(this.image) ||
@ -227,7 +153,7 @@ GameLib.D3.Texture.prototype.createInstance = function() {
} }
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CANVAS) { } else if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS) {
if (GameLib.Utils.UndefinedOrNull(this.canvas)) { if (GameLib.Utils.UndefinedOrNull(this.canvas)) {
@ -291,7 +217,7 @@ GameLib.D3.Texture.prototype.updateInstance = function(property) {
if (property === 'image') { if (property === 'image') {
if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_NORMAL) { if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_NORMAL) {
if ( if (
GameLib.Utils.UndefinedOrNull(this.image) && GameLib.Utils.UndefinedOrNull(this.image) &&
@ -312,7 +238,7 @@ GameLib.D3.Texture.prototype.updateInstance = function(property) {
} }
} }
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CANVAS) { } else if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_CANVAS) {
if ( if (
GameLib.Utils.UndefinedOrNull(this.canvas) && GameLib.Utils.UndefinedOrNull(this.canvas) &&
@ -333,7 +259,7 @@ GameLib.D3.Texture.prototype.updateInstance = function(property) {
} }
} }
} else if (this.typeId === GameLib.D3.Texture.TEXTURE_TYPE_CUBE) { } else if (this.textureType === GameLib.D3.API.Texture.TEXTURE_TYPE_CUBE) {
console.log('todo : cube images change check here'); console.log('todo : cube images change check here');
@ -405,7 +331,7 @@ GameLib.D3.Texture.prototype.toApiObject = function() {
var apiTexture = new GameLib.D3.API.Texture( var apiTexture = new GameLib.D3.API.Texture(
this.id, this.id,
this.typeId, this.textureType,
this.name, this.name,
GameLib.Utils.IdOrNull(this.image), GameLib.Utils.IdOrNull(this.image),
this.images.map( this.images.map(

Some files were not shown because too many files have changed in this diff Show More