2031 lines
65 KiB
JavaScript
2031 lines
65 KiB
JavaScript
/**
|
|
* Component Interface
|
|
* @constructor
|
|
* @param linkedObjects
|
|
* @param delayed
|
|
*/
|
|
R3.Component = function(
|
|
linkedObjects,
|
|
delayed
|
|
) {
|
|
if (R3.Utils.UndefinedOrNull(linkedObjects)) {
|
|
linkedObjects = {};
|
|
}
|
|
this.linkedObjects = linkedObjects;
|
|
this.linkedObjects.parentEntity = R3.Entity;
|
|
|
|
this.idToObject = {};
|
|
|
|
this.selected = false;
|
|
|
|
this.building = false;
|
|
|
|
this.loaded = false;
|
|
|
|
this.linked = false;
|
|
|
|
this.cloneNumber = 0;
|
|
|
|
this.isClone = false;
|
|
|
|
this.generateNewImageIds = false;
|
|
|
|
if (R3.Utils.UndefinedOrNull(delayed)) {
|
|
delayed = false;
|
|
}
|
|
this.delayed = delayed;
|
|
|
|
this.dependencies = this.getDependencies();
|
|
|
|
R3.Event.Emit(
|
|
R3.Event.COMPONENT_REGISTER,
|
|
{
|
|
component : this
|
|
}
|
|
);
|
|
|
|
if (this.dependencies.length === 0) {
|
|
|
|
this.performInstanceCreation();
|
|
|
|
} else {
|
|
R3.Event.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
|
|
* Ensure we are not delayed
|
|
* 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) {
|
|
if (!this.delayed) {
|
|
try {
|
|
this.createInstance();
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
} else {
|
|
/**
|
|
* Some systems require an instance creation at an exact time, like System.Input for Edit Controls -
|
|
* we need to give them the opportunity to handle this situation
|
|
*/
|
|
R3.Event.Emit(
|
|
R3.Event.DELAYED_INSTANCE_ENCOUNTERED,
|
|
{
|
|
component : this
|
|
}
|
|
)
|
|
}
|
|
}
|
|
};
|
|
|
|
R3.Component.prototype.createInstance = function() {
|
|
|
|
// console.log('create instance : '+ this.name);
|
|
|
|
/**
|
|
* When you do actually call 'createInstance' - it is wise to state we are no longer delayed - we assume the caller
|
|
* knows when to call createInstance, so we do the housekeeping here
|
|
* @type {boolean}
|
|
*/
|
|
this.delayed = false;
|
|
|
|
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) {
|
|
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) &&
|
|
property.indexOf('parent') !== 0 &&
|
|
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 === 'parentEntity') {
|
|
|
|
if (this.parentEntity instanceof R3.Entity) {
|
|
this.parentEntity.addComponent(this);
|
|
|
|
this.buildIdToObject();
|
|
|
|
Object.keys(this.idToObject).map(
|
|
function(componentId) {
|
|
|
|
if (this.id !== componentId) {
|
|
this.parentEntity.addComponent(this.idToObject[componentId]);
|
|
}
|
|
|
|
}.bind(this)
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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.SOCKET = 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.GRAPHICS_THREE = 0x3b;
|
|
R3.Component.FONT = 0x3c;
|
|
R3.Component.CANVAS = 0x3d;
|
|
R3.Component.BONE = 0x3e;
|
|
R3.Component.GRAPHICS_IMPACT = 0x3f;
|
|
R3.Component.CONTROLS_FIRST_PERSON = 0x40;
|
|
R3.Component.SYSTEM_ANIMATION = 0x41;
|
|
R3.Component.SYSTEM_CUSTOM_CODE = 0x42;
|
|
R3.Component.SYSTEM_GUI = 0x43;
|
|
R3.Component.SYSTEM_INPUT = 0x44;
|
|
R3.Component.SYSTEM_LINKING = 0x45;
|
|
R3.Component.SYSTEM_PHYSICS = 0x46;
|
|
R3.Component.SYSTEM_RENDER = 0x47;
|
|
R3.Component.SYSTEM_STORAGE = 0x48;
|
|
R3.Component.SYSTEM_VISUALIZATION = 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_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.AR = 0xa5;
|
|
|
|
R3.Component.MAX_COMPONENTS = 0xa6;
|
|
|
|
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;
|
|
R3.Component.AUGMENTED_RUNTIME = 0x8;
|
|
|
|
R3.Component.GetCompentTypes = function(constructor) {
|
|
|
|
if (constructor === R3.Component) {
|
|
|
|
}
|
|
};
|
|
|
|
/**
|
|
* 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.Socket',
|
|
runtime : R3.Component.SOCKET_RUNTIME,
|
|
constructor : R3.Socket,
|
|
apiConstructor : R3.API.Socket
|
|
};*/
|
|
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.GraphicsRuntime',
|
|
runtime : R3.Component.DEFAULT_RUNTIME,
|
|
constructor : R3.GraphicsRuntime
|
|
};
|
|
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.GraphicsRuntime.Three',
|
|
runtime : R3.Component.DEFAULT_RUNTIME,
|
|
constructor : R3.GraphicsRuntime.Three,
|
|
apiConstructor : R3.API.GraphicsRuntime.Three
|
|
};
|
|
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.GraphicsRuntime.Impact',
|
|
runtime : R3.Component.DEFAULT_RUNTIME,
|
|
constructor : R3.GraphicsRuntime.Impact,
|
|
apiConstructor : R3.API.GraphicsRuntime.Impact
|
|
};
|
|
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.System.Animation',
|
|
runtime : R3.Component.DEFAULT_RUNTIME,
|
|
constructor : R3.System.Animation,
|
|
apiConstructor : R3.API.System
|
|
};
|
|
case 0x42 : return {
|
|
name : 'R3.System.CustomCode',
|
|
runtime : R3.Component.DEFAULT_RUNTIME,
|
|
constructor : R3.System.CustomCode,
|
|
apiConstructor : R3.API.System
|
|
};
|
|
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.ParticleEngine',
|
|
runtime : R3.Component.GRAPHICS_RUNTIME,
|
|
constructor : R3.D3.ParticleEngine,
|
|
apiConstructor : R3.D3.API.ParticleEngine
|
|
};
|
|
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.Stereo',
|
|
runtime : R3.Component.GRAPHICS_RUNTIME,
|
|
constructor : R3.D3.Camera.Stereo,
|
|
apiConstructor : R3.D3.API.Camera.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.AR',
|
|
runtime : R3.Component.AUGMENTED_RUNTIME,
|
|
constructor : R3.AR,
|
|
apiConstructor : R3.API.AR
|
|
};
|
|
break;
|
|
}
|
|
|
|
throw new Error('Unknown component type: ' + number );
|
|
};
|
|
|
|
/**
|
|
* Returns the runtime friendly name
|
|
* @param runtime
|
|
* @returns {*}
|
|
* @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';
|
|
}
|
|
|
|
if (runtime === R3.Component.AUGMENTED_RUNTIME) {
|
|
return 'Augmented';
|
|
}
|
|
|
|
return 'Default';
|
|
};
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
R3.Component.GetComponentName = function(componentType) {
|
|
|
|
var info = R3.Component.GetComponentInfo(componentType);
|
|
|
|
if (info) {
|
|
return info.name;
|
|
}
|
|
|
|
return 'unused';
|
|
};
|
|
|
|
/**
|
|
* @return {null || Object}
|
|
*/
|
|
R3.Component.GetComponentRuntime = function(componentType) {
|
|
|
|
var info = R3.Component.GetComponentInfo(componentType);
|
|
|
|
if (info) {
|
|
return info.runtime;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
/**
|
|
* @return {null || Object}
|
|
*/
|
|
R3.Component.GetComponentConstructor = function(componentType) {
|
|
|
|
var info = R3.Component.GetComponentInfo(componentType);
|
|
|
|
if (info) {
|
|
return info.constructor;
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/**
|
|
* 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;
|
|
|
|
console.warn('implement generic component toApiObject');
|
|
|
|
var parameters = R3.Utils.GetParameters(apiConstructor);
|
|
|
|
throw new Error(parameters);
|
|
|
|
return this.id;
|
|
// return new info.apiConstructor()
|
|
|
|
};
|
|
|
|
/**
|
|
* 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.parentEntity && this.parentEntity.loaded) {
|
|
this.parentEntity.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.parentEntity = 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.publish(
|
|
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(runtimeInfo) {
|
|
|
|
var runtime = null;
|
|
|
|
R3.Event.Emit(
|
|
R3.Event.GET_RUNTIME,
|
|
null,
|
|
function(runtimeObject) {
|
|
runtime = runtimeObject;
|
|
}
|
|
);
|
|
|
|
if (runtimeInfo === R3.Component.GRAPHICS_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.graphics)) {
|
|
console.warn('no runtime graphics');
|
|
return null;
|
|
}
|
|
|
|
return runtime.graphics;
|
|
|
|
} else if (runtimeInfo === R3.Component.PHYSICS_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.physics)) {
|
|
console.warn('no runtime physics');
|
|
return null;
|
|
}
|
|
|
|
return runtime.physics;
|
|
|
|
} else if (runtimeInfo === R3.Component.GUI_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.gui)) {
|
|
console.warn('no runtime gui');
|
|
return null;
|
|
}
|
|
|
|
return runtime.gui;
|
|
|
|
} else if (runtimeInfo === R3.Component.SOCKET_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.sockets)) {
|
|
console.warn('no runtime sockets');
|
|
return null;
|
|
}
|
|
|
|
return runtime.sockets;
|
|
|
|
} else if (runtimeInfo === R3.Component.STATISTICS_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.statistics)) {
|
|
console.warn('no runtime statistics');
|
|
return null;
|
|
}
|
|
|
|
return runtime.statistics;
|
|
|
|
} else if (runtimeInfo === R3.Component.AUGMENTED_RUNTIME) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(runtime.augmented)) {
|
|
console.warn('no augmented runtime');
|
|
return null;
|
|
}
|
|
|
|
return runtime.augmented;
|
|
|
|
} else if (runtimeInfo === R3.Component.DEFAULT_RUNTIME) {
|
|
|
|
} else {
|
|
console.log('unknown runtime object found : ' + info.runtime);
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
R3.Component.Construct = function(componentType) {
|
|
|
|
var info = R3.Component.GetComponentInfo(componentType);
|
|
|
|
var componentClass = info.constructor;
|
|
|
|
var runtime = R3.Component.GetRuntimeObject(info.runtime);
|
|
|
|
if (runtime) {
|
|
return new componentClass(runtime);
|
|
} else {
|
|
return new componentClass();
|
|
}
|
|
|
|
};
|
|
|
|
R3.Component.ConstructFromObject = function(rawComponentObject) {
|
|
|
|
var runtimeComponent = null;
|
|
|
|
// if (
|
|
// rawComponentObject.componentType === 34 &&
|
|
// rawComponentObject.name.indexOf('Mesh') !== -1
|
|
// ) {
|
|
// rawComponentObject.componentType = 7;
|
|
// }
|
|
|
|
var info = R3.Component.GetComponentInfo(rawComponentObject.componentType);
|
|
|
|
var runtime = R3.Component.GetRuntimeObject(info.runtime);
|
|
|
|
if (runtime) {
|
|
runtimeComponent = new info.constructor(runtime, rawComponentObject);
|
|
} else {
|
|
runtimeComponent = new info.constructor(rawComponentObject);
|
|
}
|
|
|
|
return runtimeComponent;
|
|
}; |