r3-legacy/src/r3-a-4-component.js

2650 lines
85 KiB
JavaScript

/**
* R3.Component is an R3.Event
* @param linkedObjects
* @constructor
*/
R3.Component = function(
linkedObjects
) {
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
linkedObjects = {};
}
this.linkedObjects = linkedObjects;
/**
* Call the Event constructor first so we can set the parent right away
*/
R3.Event.call(this);
this.componentType = this.getComponentType();
this.idToObject = {};
this.building = false;
this.loaded = false;
this.linked = false;
this.cloneNumber = 0;
this.isClone = false;
this.generateNewImageIds = false;
this.dependencies = this.getDependencies();
if (this.register) {
this.emit(
R3.Event.COMPONENT_REGISTER,
{
component : this
}
);
}
if (this.dependencies.length === 0) {
this.performInstanceCreation();
} else {
this.emit(
R3.Event.REGISTER_DEPENDENCIES,
{
component : this
}
);
}
};
R3.Component.prototype = Object.create(R3.Event.prototype);
R3.Component.prototype.constructor = R3.Component;
/**
* This function, performs standard instance creation steps for all our components, which means
* Ensure we have no dependencies
* Build a list of all child components - if they are all linked, we are ready to create an instance
* Ensure we are linked
* Try to create the instance
* Error Log if failed
* Don't do anything if we are not fully linked
*/
R3.Component.prototype.performInstanceCreation = function() {
var dependencies = true;
if (R3.Utils.UndefinedOrNull(this.dependencies)) {
dependencies = false;
}
if (this.dependencies && this.dependencies instanceof Array && this.dependencies.length === 0) {
dependencies = false;
}
if (dependencies) {
throw new Error('performInstanceCreation called while this object still has dependencies');
}
delete this.dependencies;
/**
* Build ID to object should run through all sub components -
* if one is found which is not linked, this component is not linked fully
*/
this.buildIdToObject();
/**
* Don't try to create an instance of this object until it is fully linked
*/
if (this.linked) {
try {
this.createInstance();
} catch (error) {
console.error(error);
}
}
};
R3.Component.prototype.createInstance = function() {
if (this.instance) {
this.loaded = true;
R3.Event.Emit(
R3.Event.INSTANCE_CREATED,
{
component: this
}
);
R3.Event.Emit(
R3.Event.RESOLVE_DEPENDENCIES,
{
component: this
}
);
}
if (this instanceof R3.Entity) {
if (this instanceof R3.Project) {
R3.Event.Emit(
R3.Event.PROJECT_LOADED,
{
entity:this
}
)
} else {
R3.Event.Emit(
R3.Event.ENTITY_LOADED,
{
entity: this
}
)
}
}
};
/**
* Dependencies are everything which is either a string or an object with an id which is linked to this object
* @returns {Array}
*/
R3.Component.prototype.getDependencies = function() {
var dependencies = [];
for (var property in this.linkedObjects) {
if (
this.linkedObjects.hasOwnProperty(property) &&
this.hasOwnProperty(property)
){
if (typeof this[property] === 'string') {
R3.Utils.PushUnique(dependencies, this[property]);
}
if (this[property] instanceof Array) {
this[property].map(
function(arrayProperty) {
if (typeof arrayProperty === 'string') {
R3.Utils.PushUnique(dependencies, arrayProperty);
}
if (arrayProperty &&
arrayProperty instanceof R3.Component
) {
R3.Utils.PushUnique(dependencies, arrayProperty.id);
}
}
);
}
if (this[property] &&
this[property] instanceof R3.Component
) {
R3.Utils.PushUnique(dependencies, this[property].id);
}
}
}
return dependencies;
};
R3.Component.prototype.updateInstance = function(property) {
if (property === 'id') {
console.warn('TODO: update id');
return;
}
if (property === 'name') {
console.warn('TODO: update name');
return;
}
if (property === 'parent') {
console.warn('TODO: update parent');
return;
}
};
/**
* R3.Component.prototype.updateFromInstance
*
* - Updates the component by its instance data
*
* @param property
*/
R3.Component.prototype.updateFromInstance = function(property) {
if (
this[property] instanceof R3.Color
) {
this[property].r = this.instance[property].r;
this[property].g = this.instance[property].g;
this[property].b = this.instance[property].b;
this[property].a = this.instance[property].a;
}
if (
this[property] instanceof R3.Vector2
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
}
if (
this[property] instanceof R3.Vector3
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
this[property].z = this.instance[property].z;
}
if (
this[property] instanceof R3.Vector4 ||
this[property] instanceof R3.Quaternion
) {
this[property].x = this.instance[property].x;
this[property].y = this.instance[property].y;
this[property].z = this.instance[property].z;
this[property].w = this.instance[property].w;
}
if (
this[property] instanceof R3.Matrix4
) {
throw new Error('TODO : implement this code - no use case yet');
}
if (R3.Utils.IsObject(this[property])) {
throw new Error('TODO : update component object from instance object');
}
this[property] = this.instance[property];
};
/**
* Wrapper for R3.Utils.GetFirstParent
* @param constructor
* @returns {*}
*/
R3.Component.prototype.getFirstParent = function(constructor) {
return R3.D3.GetFirstParent(this, constructor);
};
/**
* Wrapper for R3.Utils.GetParent
* @param property
* @param index
* @param constructor
* @returns {*}
*/
R3.Component.getParent = function(property, index, constructor) {
return R3.D3.GetParent(this, property, index, constructor);
};
R3.Component.prototype.toString = function() {
return this.id;
};
R3.Component.SOCKET_RECEIVE = 0x1;
R3.Component.MATERIAL_STANDARD = 0x2;
R3.Component.RENDERER = 0x3;
R3.Component.SERVER = 0x4;
R3.Component.CAMERA_PERSPECTIVE = 0x5;
R3.Component.UNUSED = 0x6;
R3.Component.MESH = 0x7;
R3.Component.SPLINE = 0x8;
R3.Component.SHADOW_DIRECTIONAL = 0x9;
R3.Component.PLANE = 0xa;
R3.Component.COMPOSER = 0xb;
R3.Component.RENDER_TARGET = 0xc;
R3.Component.PASS_RENDER = 0xd;
R3.Component.SCENE = 0xe;
R3.Component.RAYCASTER = 0xf;
R3.Component.TEXT = 0x10;
R3.Component.FACE = 0x11;
R3.Component.VIEWPORT = 0x12;
R3.Component.SYSTEM = 0x13;
R3.Component.GRAPHICS = 0x14;
R3.Component.HELPER = 0x15;
R3.Component.CUSTOM_CODE = 0x16;
R3.Component.MOUSE = 0x17;
R3.Component.SKELETON = 0x18;
R3.Component.TEXTURE_IMAGE = 0x19;
R3.Component.ENTITY_MANAGER = 0x1a;
R3.Component.DOM_ELEMENT = 0x1b;
R3.Component.SHADOW_SPOT = 0x1c;
R3.Component.STATS = 0x1d;
R3.Component.GUI = 0x1e;
R3.Component.IMAGE = 0x1f;
R3.Component.ENTITY = 0x20;
R3.Component.OBJECT = 0x21;
R3.Component.RENDERER_D2 = 0x22;
R3.Component.RENDERER_D3 = 0x23;
R3.Component.PHYSICS_WORLD = 0x24;
R3.Component.BROADPHASE = 0x25;
R3.Component.SOLVER = 0x26;
R3.Component.RIGID_BODY = 0x27;
R3.Component.SHAPE = 0x28;
R3.Component.SHAPE_BOX = 0x29;
R3.Component.SHAPE_SPHERE = 0x2a;
R3.Component.SHAPE_TRI_MESH = 0x2b;
R3.Component.SHAPE_CONVEX_HULL = 0x2c;
R3.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
R3.Component.SHAPE_HEIGHT_MAP = 0x2e;
R3.Component.SHAPE_PLANE = 0x2f;
R3.Component.CONTROLS = 0x30;
R3.Component.CONTROLS_EDITOR = 0x31;
R3.Component.CONTROLS_TOUCH = 0x32;
R3.Component.FRICTION_MATERIAL = 0x33;
R3.Component.FRICTION_CONTACT_MATERIAL = 0x34;
R3.Component.RAYCAST_VEHICLE = 0x35;
R3.Component.RAYCAST_WHEEL = 0x36;
R3.Component.CLOCK = 0x37;
R3.Component.ANIMATION = 0x38;
R3.Component.CONTROLS_KEYBOARD = 0x39;
R3.Component.CONTROLS_MOUSE = 0x3a;
R3.Component.RENDERER_D3_CANVAS_TARGET = 0x3b;
R3.Component.FONT = 0x3c;
R3.Component.CANVAS = 0x3d;
R3.Component.BONE = 0x3e;
R3.Component.RENDERER_D3_CANVAS = 0x3f;
R3.Component.CONTROLS_FIRST_PERSON = 0x40;
R3.Component.RENDERER_D3_TARGET = 0x41;
R3.Component.SPHERE = 0x42;
R3.Component.UNUSED = 0x43;
R3.Component.UNUSED = 0x44;
R3.Component.UNUSED = 0x45;
R3.Component.UNUSED = 0x46;
R3.Component.UNUSED = 0x47;
R3.Component.UNUSED = 0x48;
R3.Component.UNUSED = 0x49;
R3.Component.LIGHT_AMBIENT = 0x4a;
R3.Component.LIGHT_DIRECTIONAL = 0x4b;
R3.Component.LIGHT_HEMISPHERE = 0x4c;
R3.Component.LIGHT_POINT = 0x4d;
R3.Component.LIGHT_RECT_AREA = 0x4e;
R3.Component.LIGHT_SPOT = 0x4f;
R3.Component.FOG = 0x50;
R3.Component.CONTROLS_ORBIT = 0x51;
R3.Component.PARTICLE_ENGINE = 0x52;
R3.Component.SYSTEM_PARTICLE = 0x53;
R3.Component.PARTICLE = 0x54;
R3.Component.AUDIO = 0x55;
R3.Component.SYSTEM_AUDIO = 0x56;
R3.Component.SOCKET_CAST = 0x57;
R3.Component.CAMERA_ORTHOGRAPHIC = 0x58;
R3.Component.CAMERA_PERSPECTIVE_STEREO = 0x59;
R3.Component.CAMERA_CUBE = 0x5a;
R3.Component.SHADOW = 0x5b;
R3.Component.RENDER_TARGET_CUBE = 0x5c;
R3.Component.TEXTURE_CUBE = 0x5d;
R3.Component.TEXTURE_CANVAS = 0x5e;
R3.Component.EFFECT_STEREO = 0x5f;
R3.Component.EFFECT_ANAGLYPH = 0x60;
R3.Component.EFFECT_PARALLAX = 0x61;
R3.Component.PASS_SSAO = 0x62;
R3.Component.PASS_BLOOM = 0x63;
R3.Component.PASS_FXAA = 0x64;
R3.Component.RENDER_CONFIGURATION = 0x65;
R3.Component.MATERIAL_BASIC = 0x66;
R3.Component.TEXTURE = 0x67;
R3.Component.MATERIAL_PHONG = 0x68;
R3.Component.GEOMETRY_NORMAL = 0x69;
R3.Component.GEOMETRY_NORMAL_BOX = 0x6a;
R3.Component.GEOMETRY_NORMAL_CIRCLE = 0x6b;
R3.Component.GEOMETRY_NORMAL_CONE = 0x6c;
R3.Component.GEOMETRY_NORMAL_CYLINDER = 0x6d;
R3.Component.GEOMETRY_NORMAL_DODECAHEDRON = 0x6e;
R3.Component.GEOMETRY_NORMAL_EDGES = 0x6f;
R3.Component.GEOMETRY_NORMAL_EXTRUDE = 0x70;
R3.Component.GEOMETRY_NORMAL_ICOSAHEDRON = 0x71;
R3.Component.GEOMETRY_NORMAL_LATHE = 0x72;
R3.Component.GEOMETRY_NORMAL_OCTAHEDRON = 0x73;
R3.Component.GEOMETRY_NORMAL_PARAMETRIC = 0x74;
R3.Component.GEOMETRY_NORMAL_PLANE = 0x75;
R3.Component.GEOMETRY_NORMAL_POLYHEDRON = 0x76;
R3.Component.GEOMETRY_NORMAL_RING = 0x77;
R3.Component.GEOMETRY_NORMAL_SHAPE = 0x78;
R3.Component.GEOMETRY_NORMAL_SPHERE = 0x79;
R3.Component.GEOMETRY_NORMAL_TETRAHEDRON = 0x7a;
R3.Component.GEOMETRY_NORMAL_TEXT = 0x7b;
R3.Component.GEOMETRY_NORMAL_TORUS = 0x7c;
R3.Component.GEOMETRY_NORMAL_TORUS_KNOT = 0x7d;
R3.Component.GEOMETRY_NORMAL_TUBE = 0x7e;
R3.Component.GEOMETRY_NORMAL_WIREFRAME = 0x7f;
R3.Component.GEOMETRY_BUFFER = 0x80;
R3.Component.GEOMETRY_BUFFER_BOX = 0x81;
R3.Component.GEOMETRY_BUFFER_CIRCLE = 0x82;
R3.Component.GEOMETRY_BUFFER_CONE = 0x83;
R3.Component.GEOMETRY_BUFFER_CYLINDER = 0x84;
R3.Component.GEOMETRY_BUFFER_DODECAHEDRON = 0x85;
R3.Component.GEOMETRY_BUFFER_EXTRUDE = 0x86;
R3.Component.GEOMETRY_BUFFER_ICOSAHEDRON = 0x87;
R3.Component.GEOMETRY_BUFFER_LATHE = 0x88;
R3.Component.GEOMETRY_BUFFER_OCTAHEDRON = 0x89;
R3.Component.GEOMETRY_BUFFER_PARAMETRIC = 0x8a;
R3.Component.GEOMETRY_BUFFER_PLANE = 0x8b;
R3.Component.GEOMETRY_BUFFER_POLYHEDRON = 0x8c;
R3.Component.GEOMETRY_BUFFER_RING = 0x8d;
R3.Component.GEOMETRY_BUFFER_SHAPE = 0x8e;
R3.Component.GEOMETRY_BUFFER_SPHERE = 0x8f;
R3.Component.GEOMETRY_BUFFER_TETRAHEDRON = 0x90;
R3.Component.GEOMETRY_BUFFER_TEXT = 0x91;
R3.Component.GEOMETRY_BUFFER_TORUS = 0x92;
R3.Component.GEOMETRY_BUFFER_TORUS_KNOT = 0x93;
R3.Component.GEOMETRY_BUFFER_TUBE = 0x94;
R3.Component.GEOMETRY = 0x95;
R3.Component.CURVE = 0x96;
R3.Component.CURVE_PATH = 0x97;
R3.Component.CURVE_PATH_D2 = 0x98;
R3.Component.CURVE_PATH_D2_SHAPE = 0x99;
R3.Component.BOX3 = 0x9a;
R3.Component.DRAW_RANGE = 0x9b;
R3.Component.GROUP = 0x9c;
R3.Component.MATERIAL_SHADER = 0x9d;
R3.Component.SHADER = 0x9e;
R3.Component.SHADER_VERTEX = 0x9f;
R3.Component.SHADER_FRAGMENT = 0xa0;
R3.Component.GEOMETRY_BUFFER_INSTANCED = 0xa1;
R3.Component.MATERIAL_SHADER_RAW = 0xa2;
R3.Component.MATERIAL_POINTS = 0xa3;
R3.Component.VIDEO = 0xa4;
R3.Component.USER = 0xa5;
R3.Component.PROJECT = 0xa6;
R3.Component.VIEWPORT_FIXED_ASPECT = 0xa7;
R3.Component.VIEWPORT_ZOOMED_ASPECT = 0xa8;
R3.Component.MAX_COMPONENTS = 0xa9;
R3.Component.GRAPHICS_RUNTIME = 0x1;
R3.Component.PHYSICS_RUNTIME = 0x2;
R3.Component.SOCKET_RUNTIME = 0x3;
R3.Component.STATISTICS_RUNTIME = 0x4;
R3.Component.DEFAULT_RUNTIME = 0x5;
R3.Component.GUI_RUNTIME = 0x6;
R3.Component.CODER_RUNTIME = 0x7;
/**
* Returns string name for component number
* @param number
* @returns {*}
* @constructor
*/
R3.Component.GetComponentInfo = function(number) {
switch(number) {
case 0x1 : return {
name : 'R3.Socket.Receive',
runtime : R3.Component.SOCKET_RUNTIME,
constructor : R3.Socket.Receive,
apiConstructor : R3.API.Socket.Receive
};
case 0x2 : return {
name : 'R3.D3.Material.Standard',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Standard,
apiConstructor : R3.D3.API.Material.Standard
};
case 0x3 : return {
name : 'R3.Renderer',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer,
apiConstructor : R3.API.Renderer
};
case 0x4 : return {
name : 'R3.Server',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Server,
apiConstructor : R3.API.Server
};
case 0x5 : return {
name : 'R3.D3.Camera.Perspective',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Camera.Perspective,
apiConstructor : R3.D3.API.Camera.Perspective
};
case 0x6 : return {
name : 'R3.Color',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Color,
apiConstructor : R3.API.Color
};
case 0x7 : return {
name : 'R3.D3.Mesh',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Mesh,
apiConstructor : R3.D3.API.Mesh
};
case 0x8 : return {
name : 'R3.D3.Spline',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Spline,
apiConstructor : R3.D3.API.Spline
};
case 0x9 : return {
name : 'R3.D3.Shadow.Directional',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shadow.Directional,
apiConstructor : R3.D3.API.Shadow.Directional
};
case 0xa : return {
name : 'R3.Plane',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Plane,
apiConstructor : R3.API.Plane
};
case 0xb : return {
name : 'R3.D3.Composer',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Composer,
apiConstructor : R3.D3.API.Composer
};
case 0xc : return {
name : 'R3.D3.RenderTarget',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.RenderTarget,
apiConstructor : R3.D3.API.RenderTarget
};
case 0xd : return {
name : 'R3.D3.Pass.Render',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Pass.Render,
apiConstructor : R3.D3.API.Pass.Render
};
case 0xe : return {
name : 'R3.D3.Scene',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Scene
};
case 0xf : return {
name : 'R3.D3.Raycaster',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Raycaster,
apiConstructor : R3.D3.API.Raycaster
};
case 0x10 : return {
name : 'R3.D3.Text',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Text,
apiConstructor : R3.D3.API.Text
};
case 0x11 : return {
name : 'R3.D3.Face',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Face,
apiConstructor : R3.D3.API.Face
};
case 0x12 : return {
name : 'R3.D3.Viewport',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Viewport,
apiConstructor : R3.D3.API.Viewport
};
case 0x13 : return {
name : 'R3.System',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System,
apiConstructor : R3.API.System
};
case 0x14 : return {
name : 'R3.Runtime.Graphics',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Runtime.Graphics
};
case 0x15 : return {
name : 'R3.D3.Helper',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Helper
};
case 0x16 : return {
name : 'R3.CustomCode',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.CustomCode,
apiConstructor : R3.API.CustomCode
};
case 0x17 : return {
name : 'R3.Mouse',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Mouse,
apiConstructor : R3.API.Mouse
};
case 0x18 : return {
name : 'R3.D3.Skeleton',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Skeleton,
apiConstructor : R3.D3.API.Skeleton
};
case 0x19 : return {
name : 'R3.D3.Texture.Image',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Texture.Image,
apiConstructor : R3.D3.API.Texture.Image
};
case 0x1a : return {
name : 'R3.EntityManager',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.EntityManager,
apiConstructor : R3.API.EntityManager
};
case 0x1b : return {
name : 'R3.DomElement',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.DomElement,
apiConstructor : R3.API.DomElement
};
case 0x1c : return {
name : 'R3.D3.Shadow.Spot',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shadow.Spot,
apiConstructor : R3.D3.API.Shadow.Spot
};
case 0x1d : return {
name : 'R3.Stats',
runtime : R3.Component.STATISTICS_RUNTIME,
constructor : R3.Stats,
apiConstructor : R3.API.Stats
};
case 0x1e : return {
name : 'R3.GUI',
runtime : R3.Component.GUI_RUNTIME,
constructor : R3.GUI,
apiConstructor : R3.API.GUI
};
case 0x1f : return {
name : 'R3.Image',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Image
};
case 0x20 : return {
name : 'R3.Entity',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Entity,
apiConstructor : R3.API.Entity
};
case 0x21 : return {
name : 'R3.D3.Object',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Object,
apiConstructor : R3.D3.API.Object
};
case 0x22 : return {
name : 'R3.Renderer.D2',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer.D2,
apiConstructor : R3.API.Renderer.D2
};
case 0x23 : return {
name : 'R3.Renderer.D3',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer.D3,
apiConstructor : R3.API.Renderer.D3
};
case 0x24 : return {
name : 'R3.D3.PhysicsWorld',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.PhysicsWorld,
apiConstructor : R3.D3.API.PhysicsWorld
};
case 0x25 : return {
name : 'R3.D3.Broadphase',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Broadphase,
apiConstructor : R3.D3.API.Broadphase
};
case 0x26 : return {
name : 'R3.D3.Solver',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Solver,
apiConstructor : R3.D3.API.Solver
};
case 0x27 : return {
name : 'R3.D3.RigidBody',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.RigidBody,
apiConstructor : R3.D3.API.RigidBody
};
case 0x28 : return {
name : 'R3.D3.Shape',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape,
apiConstructor : R3.D3.API.Shape
};
case 0x29 : return {
name : 'R3.D3.Shape.Box',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.Box,
apiConstructor : R3.D3.API.Shape
};
case 0x2a : return {
name : 'R3.D3.Shape.Sphere',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.Sphere,
apiConstructor : R3.D3.API.Shape
};
case 0x2b : return {
name : 'R3.D3.Shape.TriMesh',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.TriMesh,
apiConstructor : R3.D3.API.Shape
};
case 0x2c : return {
name : 'R3.D3.Shape.ConvexHull',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.ConvexHull,
apiConstructor : R3.D3.API.Shape
};
case 0x2d : return {
name : 'R3.D3.Shape.ConvexHull.Cylinder',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.ConvexHull.Cylinder,
apiConstructor : R3.D3.API.Shape
};
case 0x2e : return {
name : 'R3.D3.Shape.HeightMap',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.D3.Shape.HeightMap,
apiConstructor : R3.D3.API.Shape
};
case 0x2f : return {
name : 'R3.D3.Shape.Plane',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.Shape.Plane,
apiConstructor : R3.D3.API.Shape
};
case 0x30 : return {
name : 'R3.Controls',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Controls,
apiConstructor : R3.API.Controls
};
case 0x31 : return {
name : 'R3.Controls.D3.Editor',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Controls.D3.Editor,
apiConstructor : R3.API.Controls
};
case 0x32 : return {
name : 'R3.Controls.Touch',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Controls.Touch,
apiConstructor : R3.API.Controls
};
case 0x33 : return {
name : 'R3.D3.FrictionMaterial',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.FrictionMaterial,
apiConstructor : R3.D3.API.FrictionMaterial
};
case 0x34 : return {
name : 'R3.D3.FrictionContactMaterial',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.FrictionContactMaterial,
apiConstructor : R3.D3.API.FrictionContactMaterial
};
case 0x35 : return {
name : 'R3.D3.RaycastVehicle',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.RaycastVehicle,
apiConstructor : R3.D3.API.RaycastVehicle
};
case 0x36 : return {
name : 'R3.D3.RaycastWheel',
runtime : R3.Component.PHYSICS_RUNTIME,
constructor : R3.D3.RaycastWheel,
apiConstructor : R3.D3.API.RaycastWheel
};
case 0x37 : return {
name : 'R3.Clock',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Clock,
apiConstructor : R3.API.Clock
};
case 0x38 : return {
name : 'R3.D3.Animation',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.D3.Animation,
apiConstructor : R3.D3.API.Animation
};
case 0x39 : return {
name : 'R3.Controls.Keyboard',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Controls.Keyboard,
apiConstructor : R3.API.Controls
};
case 0x3a : return {
name : 'R3.Controls.Mouse',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Controls.Mouse,
apiConstructor : R3.API.Controls
};
case 0x3b : return {
name : 'R3.Renderer.D3.Canvas.Target',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer.D3.Canvas.Target,
apiConstructor : R3.API.Renderer.D3.Canvas.Target
};
case 0x3c : return {
name : 'R3.D3.Font',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Font,
apiConstructor : R3.D3.API.Font
};
case 0x3d : return {
name : 'R3.Canvas',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Canvas,
apiConstructor : R3.API.Canvas
};
case 0x3e : return {
name : 'R3.D3.Bone',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Bone,
apiConstructor : R3.D3.API.Bone
};
case 0x3f : return {
name : 'R3.Renderer.D3.Canvas',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer.D3.Canvas,
apiConstructor : R3.API.Renderer.D3.Canvas
};
case 0x40 : return {
name : 'R3.Controls.D3.FirstPerson',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Controls.D3.FirstPerson,
apiConstructor : R3.API.Controls.D3.FirstPerson
};
case 0x41 : return {
name : 'R3.Renderer.D3.Target',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Renderer.D3.Target,
apiConstructor : R3.API.Renderer.D3.Target
};
case 0x42 : return {
name : 'R3.Sphere',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Sphere,
apiConstructor : R3.API.Sphere
};
case 0x43 : return {
name : 'R3.System.GUI',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.GUI,
apiConstructor : R3.API.System
};
case 0x44 : return {
name : 'R3.System.Input',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Input,
apiConstructor : R3.API.System
};
case 0x45 : return {
name : 'R3.System.Linking',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Linking,
apiConstructor : R3.API.System
};
case 0x46 : return {
name : 'R3.System.Physics',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Physics,
apiConstructor : R3.API.System
};
case 0x47 : return {
name : 'R3.System.Render',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Render,
apiConstructor : R3.API.System
};
case 0x48 : return {
name : 'R3.System.Storage',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Storage,
apiConstructor : R3.API.System
};
case 0x49 : return {
name : 'R3.System.Visualization',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Visualization,
apiConstructor : R3.API.System
};
case 0x4a : return {
name : 'R3.D3.Light.Ambient',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.Ambient,
apiConstructor : R3.D3.API.Light.Ambient
};
case 0x4b : return {
name : 'R3.D3.Light.Directional',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.Directional,
apiConstructor : R3.D3.API.Light.Directional
};
case 0x4c : return {
name : 'R3.D3.Light.Hemisphere',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.Hemisphere,
apiConstructor : R3.D3.API.Light.Hemisphere
};
case 0x4d : return {
name : 'R3.D3.Light.Point',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.Point,
apiConstructor : R3.D3.API.Light.Point
};
case 0x4e : return {
name : 'R3.D3.Light.RectArea',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.RectArea,
apiConstructor : R3.D3.API.Light.RectArea
};
case 0x4f : return {
name : 'R3.D3.Light.Spot',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Light.Spot,
apiConstructor : R3.D3.API.Light.Spot
};
case 0x50 : return {
name : 'R3.D3.Fog',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Fog,
apiConstructor : R3.D3.API.Fog
};
case 0x51 : return {
name : 'R3.Controls.D3.Orbit',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Controls.D3.Orbit,
apiConstructor : R3.API.Controls.D3.Orbit
};
case 0x52 : return {
name : 'R3.D3.Particle.Engine',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Particle.Engine,
apiConstructor : R3.D3.API.Particle.Engine
};
case 0x53 : return {
name : 'R3.System.Particle',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Particle,
apiConstructor : R3.API.System
};
case 0x54 : return {
name : 'R3.D3.Particle',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Particle,
apiConstructor : R3.D3.API.Particle
};
case 0x55 : return {
name : 'R3.D3.Audio',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Audio,
apiConstructor : R3.D3.API.Audio
};
case 0x56 : return {
name : 'R3.System.Audio',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.System.Audio,
apiConstructor : R3.API.System
};
case 0x57 : return {
name : 'R3.Socket.Cast',
runtime : R3.Component.SOCKET_RUNTIME,
constructor : R3.Socket.Cast,
apiConstructor : R3.API.Socket.Cast
};
case 0x58 : return {
name : 'R3.D3.Camera.Orthographic',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Camera.Orthographic,
apiConstructor : R3.D3.API.Camera.Orthographic
};
case 0x59 : return {
name : 'R3.D3.Camera.Perspective.Stereo',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Camera.Perspective.Stereo,
apiConstructor : R3.D3.API.Camera.Perspective.Stereo
};
case 0x5a : return {
name : 'R3.D3.Camera.Cube',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Camera.Cube,
apiConstructor : R3.D3.API.Camera.Cube
};
case 0x5b : return {
name : 'R3.D3.Shadow',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shadow,
apiConstructor : R3.D3.API.Shadow
};
case 0x5c : return {
name : 'R3.D3.RenderTarget.Cube',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.RenderTarget.Cube,
apiConstructor : R3.D3.API.RenderTarget.Cube
};
case 0x5d : return {
name : 'R3.D3.Texture.Cube',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Texture.Cube,
apiConstructor : R3.D3.API.Texture.Cube
};
case 0x5e : return {
name : 'R3.D3.Texture.Canvas',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Texture.Canvas,
apiConstructor : R3.D3.API.Texture.Canvas
};
case 0x5f : return {
name : 'R3.D3.Effect.Stereo',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Effect.Stereo,
apiConstructor : R3.D3.API.Effect.Stereo
};
case 0x60 : return {
name : 'R3.D3.Effect.Anaglyph',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Effect.Anaglyph,
apiConstructor : R3.D3.API.Effect.Anaglyph
};
case 0x61 : return {
name : 'R3.D3.Effect.Parallax',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Effect.Parallax,
apiConstructor : R3.D3.API.Effect.Parallax
};
case 0x62 : return {
name : 'R3.D3.Pass.SSAO',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Pass.SSAO,
apiConstructor : R3.D3.API.Pass.SSAO
};
case 0x63 : return {
name : 'R3.D3.Pass.Bloom',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Pass.Bloom,
apiConstructor : R3.D3.API.Pass.Bloom
};
case 0x64 : return {
name : 'R3.D3.Pass.FXAA',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Pass.FXAA,
apiConstructor : R3.D3.API.Pass.FXAA
};
case 0x65 : return {
name : 'R3.RenderConfiguration',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.RenderConfiguration,
apiConstructor : R3.API.RenderConfiguration
};
case 0x66 : return {
name : 'R3.D3.Material.Basic',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Basic,
apiConstructor : R3.D3.API.Material.Basic
};
case 0x67 : return {
name : 'R3.D3.Texture',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Texture,
apiConstructor : R3.D3.API.Texture
};
case 0x68 : return {
name : 'R3.D3.Material.Phong',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Phong,
apiConstructor : R3.D3.API.Material.Phong
};
case 0x69 : return {
name : 'R3.D3.Geometry.Normal',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal,
apiConstructor : R3.D3.API.Geometry.Normal
};
case 0x6a : return {
name : 'R3.D3.Geometry.Normal.Box',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Box,
apiConstructor : R3.D3.API.Geometry.Normal.Box
};
case 0x6b : return {
name : 'R3.D3.Geometry.Normal.Circle',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Circle,
apiConstructor : R3.D3.API.Geometry.Normal.Circle
};
case 0x6c : return {
name : 'R3.D3.Geometry.Normal.Cone',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Cone,
apiConstructor : R3.D3.API.Geometry.Normal.Cone
};
case 0x6d : return {
name : 'R3.D3.Geometry.Normal.Cylinder',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Cylinder,
apiConstructor : R3.D3.API.Geometry.Normal.Cylinder
};
case 0x6e : return {
name : 'R3.D3.Geometry.Normal.Dodecahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Dodecahedron,
apiConstructor : R3.D3.API.Geometry.Normal.Dodecahedron
};
case 0x6f : return {
name : 'R3.D3.Geometry.Normal.Edges',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Edges,
apiConstructor : R3.D3.API.Geometry.Normal.Edges
};
case 0x70 : return {
name : 'R3.D3.Geometry.Normal.Extrude',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Extrude,
apiConstructor : R3.D3.API.Geometry.Normal.Extrude
};
case 0x71 : return {
name : 'R3.D3.Geometry.Normal.Icosahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Icosahedron,
apiConstructor : R3.D3.API.Geometry.Normal.Icosahedron
};
case 0x72 : return {
name : 'R3.D3.Geometry.Normal.Lathe',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Lathe,
apiConstructor : R3.D3.API.Geometry.Normal.Lathe
};
case 0x73 : return {
name : 'R3.D3.Geometry.Normal.Octahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Octahedron,
apiConstructor : R3.D3.API.Geometry.Normal.Octahedron
};
case 0x74 : return {
name : 'R3.D3.Geometry.Normal.Parametric',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Parametric,
apiConstructor : R3.D3.API.Geometry.Normal.Parametric
};
case 0x75 : return {
name : 'R3.D3.Geometry.Normal.Plane',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Plane,
apiConstructor : R3.D3.API.Geometry.Normal.Plane
};
case 0x76 : return {
name : 'R3.D3.Geometry.Normal.Polyhedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Polyhedron,
apiConstructor : R3.D3.API.Geometry.Normal.Polyhedron
};
case 0x77 : return {
name : 'R3.D3.Geometry.Normal.Ring',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Ring,
apiConstructor : R3.D3.API.Geometry.Normal.Ring
};
case 0x78 : return {
name : 'R3.D3.Geometry.Normal.Shape',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Shape,
apiConstructor : R3.D3.API.Geometry.Normal.Shape
};
case 0x79 : return {
name : 'R3.D3.Geometry.Normal.Sphere',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Sphere,
apiConstructor : R3.D3.API.Geometry.Normal.Sphere
};
case 0x7a : return {
name : 'R3.D3.Geometry.Normal.Tetrahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Tetrahedron,
apiConstructor : R3.D3.API.Geometry.Normal.Tetrahedron
};
case 0x7b : return {
name : 'R3.D3.Geometry.Normal.Text',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Text,
apiConstructor : R3.D3.API.Geometry.Normal.Text
};
case 0x7c : return {
name : 'R3.D3.Geometry.Normal.Torus',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Torus,
apiConstructor : R3.D3.API.Geometry.Normal.Torus
};
case 0x7d : return {
name : 'R3.D3.Geometry.Normal.TorusKnot',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.TorusKnot,
apiConstructor : R3.D3.API.Geometry.Normal.TorusKnot
};
case 0x7e : return {
name : 'R3.D3.Geometry.Normal.Tube',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Tube,
apiConstructor : R3.D3.API.Geometry.Normal.Tube
};
case 0x7f : return {
name : 'R3.D3.Geometry.Normal.Wireframe',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Normal.Wireframe,
apiConstructor : R3.D3.API.Geometry.Normal.Wireframe
};
case 0x80 : return {
name : 'R3.D3.Geometry.Buffer',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer,
apiConstructor : R3.D3.API.Geometry.Buffer
};
case 0x81 : return {
name : 'R3.D3.Geometry.Buffer.Box',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Box,
apiConstructor : R3.D3.API.Geometry.Buffer.Box
};
case 0x82 : return {
name : 'R3.D3.Geometry.Buffer.Circle',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Circle,
apiConstructor : R3.D3.API.Geometry.Buffer.Circle
};
case 0x83 : return {
name : 'R3.D3.Geometry.Buffer.Cone',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Cone,
apiConstructor : R3.D3.API.Geometry.Buffer.Cone
};
case 0x84 : return {
name : 'R3.D3.Geometry.Buffer.Cylinder',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Cylinder,
apiConstructor : R3.D3.API.Geometry.Buffer.Cylinder
};
case 0x85 : return {
name : 'R3.D3.Geometry.Buffer.Dodecahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Dodecahedron,
apiConstructor : R3.D3.API.Geometry.Buffer.Dodecahedron
};
case 0x86 : return {
name : 'R3.D3.Geometry.Buffer.Extrude',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Extrude,
apiConstructor : R3.D3.API.Geometry.Buffer.Extrude
};
case 0x87 : return {
name : 'R3.D3.Geometry.Buffer.Icosahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Icosahedron,
apiConstructor : R3.D3.API.Geometry.Buffer.Icosahedron
};
case 0x88 : return {
name : 'R3.D3.Geometry.Buffer.Lathe',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Lathe,
apiConstructor : R3.D3.API.Geometry.Buffer.Lathe
};
case 0x89 : return {
name : 'R3.D3.Geometry.Buffer.Octahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Octahedron,
apiConstructor : R3.D3.API.Geometry.Buffer.Octahedron
};
case 0x8a : return {
name : 'R3.D3.Geometry.Buffer.Parametric',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Parametric,
apiConstructor : R3.D3.API.Geometry.Buffer.Parametric
};
case 0x8b : return {
name : 'R3.D3.Geometry.Buffer.Plane',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Plane,
apiConstructor : R3.D3.API.Geometry.Buffer.Plane
};
case 0x8c : return {
name : 'R3.D3.Geometry.Buffer.Polyhedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Polyhedron,
apiConstructor : R3.D3.API.Geometry.Buffer.Polyhedron
};
case 0x8d : return {
name : 'R3.D3.Geometry.Buffer.Ring',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Ring,
apiConstructor : R3.D3.API.Geometry.Buffer.Ring
};
case 0x8e : return {
name : 'R3.D3.Geometry.Buffer.Shape',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Shape,
apiConstructor : R3.D3.API.Geometry.Buffer.Shape
};
case 0x8f : return {
name : 'R3.D3.Geometry.Buffer.Sphere',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Sphere,
apiConstructor : R3.D3.API.Geometry.Buffer.Sphere
};
case 0x90 : return {
name : 'R3.D3.Geometry.Buffer.Tetrahedron',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Tetrahedron,
apiConstructor : R3.D3.API.Geometry.Buffer.Tetrahedron
};
case 0x91 : return {
name : 'R3.D3.Geometry.Buffer.Text',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Text,
apiConstructor : R3.D3.API.Geometry.Buffer.Text
};
case 0x92 : return {
name : 'R3.D3.Geometry.Buffer.Torus',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Torus,
apiConstructor : R3.D3.API.Geometry.Buffer.Torus
};
case 0x93 : return {
name : 'R3.D3.Geometry.Buffer.TorusKnot',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.TorusKnot,
apiConstructor : R3.D3.API.Geometry.Buffer.TorusKnot
};
case 0x94 : return {
name : 'R3.D3.Geometry.Buffer.Tube',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Tube,
apiConstructor : R3.D3.API.Geometry.Buffer.Tube
};
case 0x95 : return {
name : 'R3.D3.Geometry',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry,
apiConstructor : R3.D3.API.Geometry
};
case 0x96 : return {
name : 'R3.Curve',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Curve,
apiConstructor : R3.API.Curve
};
case 0x97 : return {
name : 'R3.Curve.Path',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Curve.Path,
apiConstructor : R3.API.Curve.Path
};
case 0x98 : return {
name : 'R3.Curve.Path.D2',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Curve.Path.D2,
apiConstructor : R3.API.Curve.Path.D2
};
case 0x99 : return {
name : 'R3.Curve.Path.D2.Shape',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Curve.Path.D2.Shape,
apiConstructor : R3.API.Curve.Path.D2.Shape
};
case 0x9a : return {
name : 'R3.Box3',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Box3,
apiConstructor : R3.API.Box3
};
case 0x9b : return {
name : 'R3.DrawRange',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.DrawRange,
apiConstructor : R3.API.DrawRange
};
case 0x9c : return {
name : 'R3.Group',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Group,
apiConstructor : R3.API.Group
};
case 0x9d : return {
name : 'R3.D3.Material.Shader',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Shader,
apiConstructor : R3.D3.API.Material.Shader
};
case 0x9e : return {
name : 'R3.D3.Shader',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shader,
apiConstructor : R3.D3.API.Shader
};
case 0x9f : return {
name : 'R3.D3.Shader.Vertex',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shader.Vertex,
apiConstructor : R3.D3.API.Shader.Vertex
};
case 0xa0 : return {
name : 'R3.D3.Shader.Fragment',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Shader.Fragment,
apiConstructor : R3.D3.API.Shader.Fragment
};
case 0xa1 : return {
name : 'R3.D3.Geometry.Buffer.Instanced',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Geometry.Buffer.Instanced,
apiConstructor : R3.D3.API.Geometry.Buffer.Instanced
};
case 0xa2 : return {
name : 'R3.D3.Material.Shader.Raw',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Shader.Raw,
apiConstructor : R3.D3.API.Material.Shader.Raw
};
case 0xa3 : return {
name : 'R3.D3.Material.Points',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.D3.Material.Points,
apiConstructor : R3.D3.API.Material.Points
};
case 0xa4 : return {
name : 'R3.Video',
runtime : R3.Component.GRAPHICS_RUNTIME,
constructor : R3.Video,
apiConstructor : R3.API.Video
};
case 0xa5 : return {
name : 'R3.User',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.User,
apiConstructor : R3.API.User
};
case 0xa6 : return {
name : 'R3.Project',
runtime : R3.Component.DEFAULT_RUNTIME,
constructor : R3.Project,
apiConstructor : R3.API.Project
};
break;
}
throw new Error('Unknown component type: ' + number );
};
/**
* Returns the runtime friendly name
* @param runtime
* @returns string
* @constructor
*/
R3.Component.GetRuntimeName = function(runtime) {
if (runtime === R3.Component.GRAPHICS_RUNTIME) {
return 'Graphics';
}
if (runtime === R3.Component.PHYSICS_RUNTIME) {
return 'Physics';
}
if (runtime === R3.Component.GUI_RUNTIME) {
return 'GUI';
}
if (runtime === R3.Component.STATISTICS_RUNTIME) {
return 'Statistics';
}
if (runtime === R3.Component.SOCKET_RUNTIME) {
return 'Sockets';
}
if (runtime === R3.Component.CODER_RUNTIME) {
return 'Coder';
}
return 'Default';
};
/**
* @return {string}
*/
R3.Component.GetComponentName = function(componentType) {
var info = R3.Component.GetComponentInfo(componentType);
if (info) {
return info.name;
}
return 'unused';
};
/**
* Gets a friendly name for the component
* @param componentType
* @returns {string}
* @constructor
*/
R3.Component.GetComponentFriendlyName = function(componentType) {
var name = R3.Component.GetComponentName(componentType);
name = name.replace('R3.D3.','');
name = name.replace('.', ' ');
return name;
};
/**
* @return {null || Object}
*/
R3.Component.GetComponentRuntime = function(componentType) {
var info = R3.Component.GetComponentInfo(componentType);
if (info) {
return info.runtime;
}
return null;
};
/**
* Returns the component type based on the constructor
* @returns {number}
* @constructor
*/
R3.Component.prototype.getComponentType = function() {
if (this instanceof R3.Box3) {
return R3.Component.BOX3;
}
if (this instanceof R3.Canvas) {
return R3.Component.CANVAS;
}
if (this instanceof R3.Clock) {
return R3.Component.CLOCK;
}
if (this instanceof R3.Controls.D3.Orbit) {
return R3.Component.CONTROLS_ORBIT;
}
if (this instanceof R3.Controls.D3.FirstPerson) {
return R3.Component.CONTROLS_FIRST_PERSON;
}
if (this instanceof R3.Controls.D3.Editor) {
return R3.Component.CONTROLS_EDITOR;
}
if (this instanceof R3.Controls.Keyboard) {
return R3.Component.CONTROLS_KEYBOARD;
}
if (this instanceof R3.Controls.Mouse) {
return R3.Component.CONTROLS_MOUSE;
}
if (this instanceof R3.Controls.Touch) {
return R3.Component.CONTROLS_TOUCH;
}
if (this instanceof R3.Curve.Path.D2.Shape) {
return R3.Component.CURVE_PATH_D2_SHAPE;
}
if (this instanceof R3.Curve.Path.D2) {
return R3.Component.CURVE_PATH_D2;
}
if (this instanceof R3.Curve.Path) {
return R3.Component.CURVE_PATH;
}
if (this instanceof R3.Curve) {
return R3.Component.CURVE;
}
if (this instanceof R3.CustomCode) {
return R3.Component.CUSTOM_CODE;
}
if (this instanceof R3.D3.Animation) {
return R3.Component.ANIMATION;
}
if (this instanceof R3.D3.Object) {
return R3.Component.OBJECT;
}
if (this instanceof R3.D3.Audio) {
return R3.Component.AUDIO;
}
if (this instanceof R3.D3.Bone) {
return R3.Component.BONE;
}
if (this instanceof R3.D3.Broadphase) {
return R3.Component.BROADPHASE;
}
if (this instanceof R3.D3.Camera.Cube) {
return R3.Component.CAMERA_CUBE;
}
if (this instanceof R3.D3.Camera.Orthographic) {
return R3.Component.CAMERA_ORTHOGRAPHIC;
}
if (this instanceof R3.D3.Camera.Perspective) {
return R3.Component.CAMERA_PERSPECTIVE;
}
if (this instanceof R3.D3.Camera.Perspective.Stereo) {
return R3.Component.CAMERA_PERSPECTIVE_STEREO;
}
if (this instanceof R3.D3.Composer) {
return R3.Component.COMPOSER;
}
if (this instanceof R3.D3.Effect.Anaglyph) {
return R3.Component.EFFECT_ANAGLYPH;
}
if (this instanceof R3.D3.Effect.Parallax) {
return R3.Component.EFFECT_PARALLAX;
}
if (this instanceof R3.D3.Effect.Stereo) {
return R3.Component.EFFECT_STEREO;
}
if (this instanceof R3.D3.Face) {
return R3.Component.FACE;
}
if (this instanceof R3.D3.Fog) {
return R3.Component.FOG;
}
if (this instanceof R3.D3.Font) {
return R3.Component.FONT;
}
if (this instanceof R3.D3.FrictionContactMaterial) {
return R3.Component.FRICTION_CONTACT_MATERIAL;
}
if (this instanceof R3.D3.FrictionMaterial) {
return R3.Component.FRICTION_MATERIAL;
}
if (this instanceof R3.D3.Geometry.Buffer.Box) {
return R3.Component.GEOMETRY_BUFFER_BOX;
}
if (this instanceof R3.D3.Geometry.Buffer.Circle) {
return R3.Component.GEOMETRY_BUFFER_CIRCLE;
}
if (this instanceof R3.D3.Geometry.Buffer.Cone) {
return R3.Component.GEOMETRY_BUFFER_CONE;
}
if (this instanceof R3.D3.Geometry.Buffer.Cylinder) {
return R3.Component.GEOMETRY_BUFFER_CYLINDER;
}
if (this instanceof R3.D3.Geometry.Buffer.Dodecahedron) {
return R3.Component.GEOMETRY_BUFFER_DODECAHEDRON;
}
if (this instanceof R3.D3.Geometry.Buffer.Extrude) {
return R3.Component.GEOMETRY_BUFFER_EXTRUDE;
}
if (this instanceof R3.D3.Geometry.Buffer.Icosahedron) {
return R3.Component.GEOMETRY_BUFFER_ICOSAHEDRON;
}
if (this instanceof R3.D3.Geometry.Buffer.Instanced) {
return R3.Component.GEOMETRY_BUFFER_INSTANCED;
}
if (this instanceof R3.D3.Geometry.Buffer.Lathe) {
return R3.Component.GEOMETRY_BUFFER_LATHE;
}
if (this instanceof R3.D3.Geometry.Buffer.Octahedron) {
return R3.Component.GEOMETRY_BUFFER_OCTAHEDRON;
}
if (this instanceof R3.D3.Geometry.Buffer.Parametric) {
return R3.Component.GEOMETRY_BUFFER_PARAMETRIC;
}
if (this instanceof R3.D3.Geometry.Buffer.Plane) {
return R3.Component.GEOMETRY_BUFFER_PLANE;
}
if (this instanceof R3.D3.Geometry.Buffer.Polyhedron) {
return R3.Component.GEOMETRY_BUFFER_POLYHEDRON;
}
if (this instanceof R3.D3.Geometry.Buffer.Ring) {
return R3.Component.GEOMETRY_BUFFER_RING;
}
if (this instanceof R3.D3.Geometry.Buffer.Shape) {
return R3.Component.GEOMETRY_BUFFER_SHAPE;
}
if (this instanceof R3.D3.Geometry.Buffer.Sphere) {
return R3.Component.GEOMETRY_BUFFER_SPHERE;
}
if (this instanceof R3.D3.Geometry.Buffer.Tetrahedron) {
return R3.Component.GEOMETRY_BUFFER_TETRAHEDRON;
}
if (this instanceof R3.D3.Geometry.Buffer.Text) {
return R3.Component.GEOMETRY_BUFFER_TEXT;
}
if (this instanceof R3.D3.Geometry.Buffer.Torus) {
return R3.Component.GEOMETRY_BUFFER_TORUS_KNOT;
}
if (this instanceof R3.D3.Geometry.Buffer.TorusKnot) {
return R3.Component.GEOMETRY_BUFFER_TORUS_KNOT;
}
if (this instanceof R3.D3.Geometry.Buffer.Tube) {
return R3.Component.GEOMETRY_BUFFER_TUBE;
}
if (this instanceof R3.D3.Geometry.Buffer) {
return R3.Component.GEOMETRY_BUFFER;
}
if (this instanceof R3.D3.Geometry.Normal.Box) {
return R3.Component.GEOMETRY_NORMAL_BOX;
}
if (this instanceof R3.D3.Geometry.Normal.Circle) {
return R3.Component.GEOMETRY_NORMAL_CIRCLE;
}
if (this instanceof R3.D3.Geometry.Normal.Cone) {
return R3.Component.GEOMETRY_NORMAL_CONE;
}
if (this instanceof R3.D3.Geometry.Normal.Cylinder) {
return R3.Component.GEOMETRY_NORMAL_CYLINDER;
}
if (this instanceof R3.D3.Geometry.Normal.Dodecahedron) {
return R3.Component.GEOMETRY_NORMAL_DODECAHEDRON;
}
if (this instanceof R3.D3.Geometry.Normal.Edges) {
return R3.Component.GEOMETRY_NORMAL_EDGES;
}
if (this instanceof R3.D3.Geometry.Normal.Extrude) {
return R3.Component.GEOMETRY_NORMAL_EXTRUDE;
}
if (this instanceof R3.D3.Geometry.Normal.Icosahedron) {
return R3.Component.GEOMETRY_NORMAL_ICOSAHEDRON;
}
if (this instanceof R3.D3.Geometry.Normal.Lathe) {
return R3.Component.GEOMETRY_NORMAL_LATHE;
}
if (this instanceof R3.D3.Geometry.Normal.Octahedron) {
return R3.Component.GEOMETRY_NORMAL_OCTAHEDRON;
}
if (this instanceof R3.D3.Geometry.Normal.Parametric) {
return R3.Component.GEOMETRY_NORMAL_PARAMETRIC;
}
if (this instanceof R3.D3.Geometry.Normal.Plane) {
return R3.Component.GEOMETRY_NORMAL_PLANE;
}
if (this instanceof R3.D3.Geometry.Normal.Polyhedron) {
return R3.Component.GEOMETRY_NORMAL_POLYHEDRON;
}
if (this instanceof R3.D3.Geometry.Normal.Ring) {
return R3.Component.GEOMETRY_NORMAL_RING;
}
if (this instanceof R3.D3.Geometry.Normal.Shape) {
return R3.Component.GEOMETRY_NORMAL_SHAPE;
}
if (this instanceof R3.D3.Geometry.Normal.Sphere) {
return R3.Component.GEOMETRY_NORMAL_SPHERE;
}
if (this instanceof R3.D3.Geometry.Normal.Tetrahedron) {
return R3.Component.GEOMETRY_NORMAL_TETRAHEDRON;
}
if (this instanceof R3.D3.Geometry.Normal.Text) {
return R3.Component.GEOMETRY_NORMAL_TEXT;
}
if (this instanceof R3.D3.Geometry.Normal.Torus) {
return R3.Component.GEOMETRY_NORMAL_TORUS;
}
if (this instanceof R3.D3.Geometry.Normal.TorusKnot) {
return R3.Component.GEOMETRY_NORMAL_TORUS_KNOT;
}
if (this instanceof R3.D3.Geometry.Normal.Tube) {
return R3.Component.GEOMETRY_NORMAL_TUBE;
}
if (this instanceof R3.D3.Geometry.Normal.Wireframe) {
return R3.Component.GEOMETRY_NORMAL_WIREFRAME;
}
if (this instanceof R3.D3.Helper) {
return R3.Component.HELPER;
}
if (this instanceof R3.D3.Light.Ambient) {
return R3.Component.LIGHT_AMBIENT;
}
if (this instanceof R3.D3.Light.Directional) {
return R3.Component.LIGHT_DIRECTIONAL;
}
if (this instanceof R3.D3.Light.Hemisphere) {
return R3.Component.LIGHT_HEMISPHERE;
}
if (this instanceof R3.D3.Light.Point) {
return R3.Component.LIGHT_POINT;
}
if (this instanceof R3.D3.Light.RectArea) {
return R3.Component.LIGHT_RECT_AREA;
}
if (this instanceof R3.D3.Light.Spot) {
return R3.Component.LIGHT_SPOT;
}
if (this instanceof R3.D3.Material.Basic) {
return R3.Component.MATERIAL_BASIC;
}
if (this instanceof R3.D3.Material.Phong) {
return R3.Component.MATERIAL_PHONG;
}
if (this instanceof R3.D3.Material.Points) {
return R3.Component.MATERIAL_POINTS;
}
if (this instanceof R3.D3.Material.Shader) {
return R3.Component.MATERIAL_SHADER;
}
if (this instanceof R3.D3.Material.Shader.Raw) {
return R3.Component.MATERIAL_SHADER_RAW;
}
if (this instanceof R3.D3.Material.Standard) {
return R3.Component.MATERIAL_STANDARD;
}
if (this instanceof R3.D3.Mesh) {
return R3.Component.MESH;
}
if (this instanceof R3.D3.Particle.Engine) {
return R3.Component.PARTICLE_ENGINE;
}
if (this instanceof R3.D3.Particle) {
return R3.Component.PARTICLE;
}
if (this instanceof R3.D3.Pass.Bloom) {
return R3.Component.PASS_BLOOM;
}
if (this instanceof R3.D3.Pass.FXAA) {
return R3.Component.PASS_FXAA;
}
if (this instanceof R3.D3.Pass.Render) {
return R3.Component.PASS_RENDER;
}
if (this instanceof R3.D3.Pass.SSAO) {
return R3.Component.PASS_SSAO;
}
if (this instanceof R3.D3.PhysicsWorld) {
return R3.Component.PHYSICS_WORLD;
}
if (this instanceof R3.D3.Raycaster) {
return R3.Component.RAYCASTER;
}
if (this instanceof R3.D3.RaycastVehicle) {
return R3.Component.RAYCAST_VEHICLE;
}
if (this instanceof R3.D3.RaycastWheel) {
return R3.Component.RAYCAST_WHEEL;
}
if (this instanceof R3.D3.RenderTarget.Cube) {
return R3.Component.RENDER_TARGET_CUBE;
}
if (this instanceof R3.D3.RenderTarget) {
return R3.Component.RENDER_TARGET;
}
if (this instanceof R3.D3.RigidBody) {
return R3.Component.RIGID_BODY;
}
if (this instanceof R3.D3.Scene) {
return R3.Component.SCENE;
}
if (this instanceof R3.D3.Shader.Fragment) {
return R3.Component.SHADER_FRAGMENT;
}
if (this instanceof R3.D3.Shader.Vertex) {
return R3.Component.SHADER_VERTEX;
}
if (this instanceof R3.D3.Shader) {
return R3.Component.SHADER;
}
if (this instanceof R3.D3.Shadow.Directional) {
return R3.Component.SHADOW_DIRECTIONAL;
}
if (this instanceof R3.D3.Shadow.Spot) {
return R3.Component.SHADOW_SPOT;
}
if (this instanceof R3.D3.Shadow) {
return R3.Component.SHADOW;
}
if (this instanceof R3.D3.Shape.Box) {
return R3.Component.SHAPE_BOX;
}
if (this instanceof R3.D3.Shape.ConvexHull) {
return R3.Component.SHAPE_CONVEX_HULL;
}
if (this instanceof R3.D3.Shape.ConvexHull.Cylinder) {
return R3.Component.SHAPE_CONVEX_HULL_CYLINDER;
}
if (this instanceof R3.D3.Shape.HeightMap) {
return R3.Component.SHAPE_HEIGHT_MAP;
}
if (this instanceof R3.D3.Shape.Plane) {
return R3.Component.SHAPE_PLANE;
}
if (this instanceof R3.D3.Shape.Sphere) {
return R3.Component.SHAPE_SPHERE;
}
if (this instanceof R3.D3.Shape.TriMesh) {
return R3.Component.SHAPE_TRI_MESH;
}
if (this instanceof R3.D3.Shape) {
return R3.Component.SHAPE;
}
if (this instanceof R3.D3.Solver) {
return R3.Component.SOLVER;
}
if (this instanceof R3.D3.Spline) {
return R3.Component.SPLINE;
}
if (this instanceof R3.D3.Text) {
return R3.Component.TEXT;
}
if (this instanceof R3.D3.Texture.Canvas) {
return R3.Component.TEXTURE_CANVAS;
}
if (this instanceof R3.D3.Texture.Cube) {
return R3.Component.TEXTURE_CUBE;
}
if (this instanceof R3.D3.Texture.Image) {
return R3.Component.TEXTURE_IMAGE;
}
if (this instanceof R3.D3.Texture) {
return R3.Component.TEXTURE;
}
if (this instanceof R3.D3.Viewport.Fixed.Aspect) {
return R3.Component.VIEWPORT_FIXED_ASPECT;
}
if (this instanceof R3.D3.Viewport.Zoomed.Aspect) {
return R3.Component.VIEWPORT_ZOOMED_ASPECT;
}
if (this instanceof R3.D3.Viewport) {
return R3.Component.VIEWPORT;
}
if (this instanceof R3.DomElement) {
return R3.Component.DOM_ELEMENT;
}
if (this instanceof R3.DrawRange) {
return R3.Component.DRAW_RANGE;
}
if (this instanceof R3.Entity) {
return R3.Component.ENTITY;
}
if (this instanceof R3.EntityManager) {
return R3.Component.ENTITY_MANAGER;
}
if (this instanceof R3.Group) {
return R3.Component.GROUP;
}
if (this instanceof R3.GUI) {
return R3.Component.GUI;
}
if (this instanceof R3.Runtime.GUI) {
return R3.Component.GUI_RUNTIME;
}
if (this instanceof R3.Image) {
return R3.Component.IMAGE;
}
if (this instanceof R3.Mouse) {
return R3.Component.MOUSE;
}
if (this instanceof R3.Plane) {
return R3.Component.PLANE;
}
if (this instanceof R3.Project) {
return R3.Component.PROJECT;
}
if (this instanceof R3.Renderer.D3.Canvas.Target) {
return R3.Component.RENDERER_D3_CANVAS_TARGET;
}
if (this instanceof R3.Renderer.D3.Canvas) {
return R3.Component.RENDERER_D3_CANVAS;
}
if (this instanceof R3.Renderer.D3.Target) {
return R3.Component.RENDERER_D3_TARGET;
}
if (this instanceof R3.Renderer.D2) {
return R3.Component.RENDERER_D2;
}
if (this instanceof R3.Renderer.D3) {
return R3.Component.RENDERER_D3;
}
if (this instanceof R3.Renderer) {
return R3.Component.RENDERER;
}
if (this instanceof R3.Server) {
return R3.Component.SERVER;
}
if (this instanceof R3.Socket.Cast) {
return R3.Component.SOCKET_CAST;
}
if (this instanceof R3.Socket.Receive) {
return R3.Component.SOCKET_RECEIVE;
}
if (this instanceof R3.Sphere) {
return R3.Component.SPHERE;
}
if (this instanceof R3.Stats) {
return R3.Component.STATS;
}
if (this instanceof R3.User) {
return R3.Component.USER;
}
if (this instanceof R3.Video) {
return R3.Component.VIDEO;
}
console.warn('Component Type not Registered' + this);
};
/**
* @return {null || Object}
*/
R3.Component.GetComponentConstructor = function(componentType) {
var info = R3.Component.GetComponentInfo(componentType);
if (info) {
return info.constructor;
}
return null;
};
R3.Component.prototype.getPropertyValue = function(item) {
/**
* We found data that we need to process - here we have to pay attention.
* For linked objects - we only store the ID
*/
if (item instanceof R3.Component) {
return R3.Utils.IdOrNull(item);
}
/**
* Handle colors, vectors and matrices - they are not components so they have their own toApiObject functions
*/
if (
item instanceof R3.Color ||
item instanceof R3.Vector2 ||
item instanceof R3.Vector3 ||
item instanceof R3.Vector4 ||
item instanceof R3.Quaternion ||
item instanceof R3.Matrix4
) {
return item.toApiObject();
}
/**
* If we get to this point and we still have an Object - we throw an error
*/
if (R3.Utils.IsObject(item)) {
throw new Error('We still have an object here which is trying to get saved: ' + item);
}
return item;
};
/**
* Components are linked at runtime - for storing, we just store the ID
* @returns {*}
*/
R3.Component.prototype.toApiObject = function() {
var info = R3.Component.GetComponentInfo(this.componentType);
var apiConstructor = info.apiConstructor;
var apiObject = new apiConstructor();
for (var property in apiObject) {
if (apiObject.hasOwnProperty(property)) {
/**
* Check if the current component also has this property
*/
if (this.hasOwnProperty(property)) {
if (this[property] instanceof R3.Runtime) {
/**
* Check if this is a runtime object - we ignore those
*/
continue;
}
/**
* Check if this property is an array of something
*/
if (this[property].isArray) {
/**
* Quick sanity check that the apiObject also thinks this is an array
*/
if (!arrayObject[property].isArray) {
throw new Error('The API Object ' + apiObject + ' does not seem to think ' + property + ' is an array');
}
/**
* Loop through the array - assign the contents of
* the array to the apiObject
*/
apiObject[property] = this[property].reduce(
function(result, item, index) {
if (item instanceof R3.Runtime) {
throw new Error('Please don\'t store Runtime Objects in Arrays');
}
if (item.isArray) {
result[index] = item.reduce(
function (subResult, subItem) {
subResult.push(this.getPropertyValue(subItem));
return subResult;
}.bind(this),
[]
)
} else {
result.push(this.getPropertyValue(item));
}
return result;
}.bind(this),
[]
);
} else {
/**
* This is not an array, so get the proper value directly from the property
*/
apiObject[property] = this.getPropertyValue(this[property]);
}
}
}
}
};
/**
* Gets all children components of this Object (all linked objects only - no object references i.e. string ids)
* @returns {Array}
*/
R3.Component.prototype.getChildrenComponents = function() {
var components = [];
this.buildIdToObject();
Object.keys(this.idToObject).map(
function(objectId) {
if (this.id !== objectId) {
components.push(this.idToObject[objectId]);
}
}.bind(this)
);
return components;
};
R3.Component.prototype.processComponent = function(object) {
if (object instanceof R3.Component) {
object.buildIdToObject();
if (!object.linked) {
this.linked = false;
}
var idToObject = object.idToObject;
for (var objectProperty in idToObject) {
if (idToObject.hasOwnProperty(objectProperty)) {
this.idToObject[objectProperty] = idToObject[objectProperty];
}
}
if (object.id) {
this.idToObject[object.id] = object;
} else {
console.warn('Object with no ID passed: ' + object)
}
} else if (typeof object === 'string') {
this.linked = false;
} else {
console.warn('Unhandled type of object: ', object);
}
};
/**
* This function - builds an 'id to object' object - which contains the ids which point directly
* to its corresponding object, for all the objects contained inside this object
*/
R3.Component.prototype.buildIdToObject = function() {
if (this.building) {
return;
}
/**
* If this component 'building' flag is true - it is in the process of building idToObject up the callstack and the
* caller should know to not try to build idToObject again (prevent infinite recursion)
*/
this.building = true;
/**
* If any child component is not fully linked, this component will show as not linked
* @type {boolean}
*/
this.linked = true;
this.idToObject = {};
for (var property in this.linkedObjects) {
if (
this.linkedObjects.hasOwnProperty(property) &&
this.hasOwnProperty(property) &&
this[property] &&
property.indexOf('parent') !== 0
) {
if (this.linkedObjects[property] instanceof Array) {
/**
* Remove null objects (can happen)
*/
this[property] = this[property].filter(
function(object) {
if (object === null) {
console.log('null object found and removed');
return false;
}
return true;
}
);
this[property].map(
function(object) {
this.processComponent(object);
}.bind(this)
);
} else {
this.processComponent(this[property]);
}
}
}
if (this instanceof R3.D3.Scene) {
if (!this.storeClones) {
this.clones.map(
function(clone) {
if (this.idToObject.hasOwnProperty(clone.id)) {
delete this.idToObject[clone.id];
}
}.bind(this)
)
}
}
this.idToObject[this.id] = this;
this.building = false;
};
R3.Component.prototype.generateNewIds = function() {
this.buildIdToObject();
var codeComponents = R3.EntityManager.Instance.queryComponents(R3.Component.CUSTOM_CODE);
for (var property in this.idToObject) {
if (this.idToObject.hasOwnProperty(property)) {
var oldId = this.idToObject[property].id;
var newId = R3.Utils.RandomId();
this.idToObject[property].id = newId;
this.idToObject[property].name = this.idToObject[property].name.replace(oldId,newId);
if (this.generateNewImageIds) {
// TODO: replace image filenames - but then also copy them server side?
if (this.idToObject[property].fileName) {
this.idToObject[property].fileName = this.idToObject[property].fileName.replace(oldId,newId);
}
}
codeComponents.map(function(codeComponent){
codeComponent.code = codeComponent.code.replace(oldId,newId);
});
}
}
};
/**
* TODO: don't remove components which are still in use elsewhere - this is important to prevent 'register out
* of sync' messages
*/
R3.Component.prototype.remove = function() {
this.buildIdToObject();
Object.keys(this.idToObject).map(
function(componentId){
R3.Event.Emit(
R3.Event.REMOVE_COMPONENT,
{
component : this.idToObject[componentId]
}
)
}.bind(this)
);
};
R3.Component.prototype.replace = function(componentType) {
var replacement = R3.Component.Construct(componentType);
R3.Event.Emit(
R3.Event.REPLACE_COMPONENT,
{
current : this,
replacement : replacement
}
);
if (this.parent && this.parent.loaded) {
this.parent.addComponent(replacement);
}
this.remove();
R3.Event.Emit(
R3.Event.COMPONENT_REPLACED
);
};
R3.Component.prototype.clone = function() {
var apiObject = this.toApiObject();
this.cloneNumber += 1;
apiObject.id = R3.Utils.RandomId();
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
var runtimeComponent = R3.Component.ConstructFromObject(apiObject);
runtimeComponent.isClone = true;
R3.Event.Emit(
R3.Event.COMPONENT_CLONED,
{
parent : this,
component : runtimeComponent
}
);
runtimeComponent.parent = null;
return runtimeComponent;
};
/**
* Clones only the instance
*/
R3.Component.prototype.cloneInstance = function() {
var clone = null;
if (
this.instance &&
this.instance.clone &&
typeof (this.instance.clone === 'function')) {
clone = this.instance.clone();
R3.Event.Emit(
R3.Event.INSTANCE_CLONED,
{
component : this,
instance : clone
}
)
}
return clone;
};
R3.Component.prototype.saveToRemoteAPI = function() {
this.save(true);
};
R3.Component.prototype.save = function(remote) {
var toSave = [];
var saved = [];
var failed = [];
this.buildIdToObject();
if (this.saveSubscription || this.saveErrorSubscription) {
console.warn('another save is in progress');
return;
}
R3.Event.Emit(
R3.Event.SAVING,
{
component: this
}
);
this.saveSubscription = R3.Event.Subscribe(
R3.Event.COMPONENT_SAVED,
function(data) {
saved.push(data.component);
if (failed.length + saved.length === toSave.length) {
this.saveSubscription.remove();
this.saveSubscription = null;
this.saveErrorSubscription.remove();
this.saveErrorSubscription = null;
R3.Event.Emit(
R3.Event.DONE_SAVING,
{
failed: failed,
saved: saved
}
)
}
}.bind(this)
);
this.saveErrorSubscription = R3.Event.Subscribe(
R3.Event.SAVE_COMPONENT_ERROR,
function(data) {
failed.push(data.component);
if (failed.length + saved.length === toSave.length) {
this.saveSubscription.remove();
this.saveSubscription = null;
this.saveErrorSubscription.remove();
this.saveErrorSubscription = null;
R3.Event.Emit(
R3.Event.DONE_SAVING,
{
failed: failed,
saved: saved
}
)
}
}.bind(this)
);
Object.keys(this.idToObject).map(
function(componentId) {
var component = this.idToObject[componentId];
if (this instanceof R3.Entity) {
/**
* We don't store children objects of entities which are not explicitly defined as children of this entity.
*/
if (
this.components.indexOf(component) === -1 &&
this !== component
) {
/**
* We don't want to store this component - but other components may depend on it
*/
console.warn(component.name + ' is being stored because a component depends on it - even though it was not explicitly added to this entity.');
}
}
var apiObject = component.toApiObject();
toSave.push(apiObject);
this.emit(
R3.Event.SAVE_COMPONENT,
{
apiObject: apiObject,
remote: remote
},
function success(result) {
console.log(result);
},
function error(error) {
console.log(error);
}
);
}.bind(this)
);
};
/**
* @return {null|Object}
*/
R3.Component.GetRuntimeObject = function(info) {
var runtime = null;
R3.Event.Emit(
R3.Event.GET_RUNTIME,
null,
function(runtimeObject) {
runtime = runtimeObject;
}
);
if (info.runtime instanceof R3.Runtime.Graphics) {
if (R3.Utils.UndefinedOrNull(runtime.graphics)) {
console.warn('no runtime graphics: ', info);
return null;
}
return runtime.graphics;
} else if (info.runtime === R3.Component.PHYSICS_RUNTIME) {
if (R3.Utils.UndefinedOrNull(runtime.physics)) {
console.warn('no runtime physics ', info);
return null;
}
return runtime.physics;
} else if (info.runtime === R3.Component.GUI_RUNTIME) {
if (R3.Utils.UndefinedOrNull(runtime.gui)) {
console.warn('no runtime gui ', info);
return null;
}
return runtime.gui;
} else if (info.runtime === R3.Component.SOCKET_RUNTIME) {
if (R3.Utils.UndefinedOrNull(runtime.sockets)) {
console.warn('no runtime sockets ', info);
return null;
}
return runtime.sockets;
} else if (info.runtime === R3.Component.STATISTICS_RUNTIME) {
if (R3.Utils.UndefinedOrNull(runtime.statistics)) {
console.warn('no runtime statistics ', info);
return null;
}
return runtime.statistics;
} else if (info.runtime === R3.Component.DEFAULT_RUNTIME) {
return null;
} else {
throw new Error('unknown runtime object found: ' + info);
}
return null;
};
R3.Component.Construct = function(componentType) {
var info = R3.Component.GetComponentInfo(componentType);
var componentClass = info.constructor;
var runtime = R3.Component.GetRuntimeObject(info);
if (runtime) {
return new componentClass(runtime);
} else {
return new componentClass();
}
};
R3.Component.ConstructFromObject = function(rawComponentObject) {
var runtimeComponent = null;
var info = R3.Component.GetComponentInfo(rawComponentObject.componentType);
var runtime = R3.Component.GetRuntimeObject(info);
if (runtime) {
runtimeComponent = new info.constructor(runtime, rawComponentObject);
} else {
runtimeComponent = new info.constructor(rawComponentObject);
}
return runtimeComponent;
};