diff --git a/bak/r3-d3-api-composer-render-target.js b/bak/r3-d3-api-composer-render-target.js new file mode 100644 index 0000000..9f63613 --- /dev/null +++ b/bak/r3-d3-api-composer-render-target.js @@ -0,0 +1,30 @@ +/** + * R3.D3.API.Composer.RenderTarget + * @param apiComponent + * + * @property renderTarget + * + * @constructor + */ +R3.D3.API.Composer.RenderTarget = function( + apiComponent +) { + + R3.D3.API.Composer.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.renderTarget)) { + apiComponent.renderTarget = new R3.D3.API.RenderTarget( + { + parent : this + } + ); + } + this.renderTarget = apiComponent.renderTarget + +}; + +R3.D3.API.Composer.RenderTarget.prototype = Object.create(R3.D3.API.Composer.prototype); +R3.D3.API.Composer.RenderTarget.prototype.constructor = R3.D3.API.Composer.RenderTarget; diff --git a/bak/r3-d3-api-composer-renderer.js b/bak/r3-d3-api-composer-renderer.js new file mode 100644 index 0000000..c8ec09a --- /dev/null +++ b/bak/r3-d3-api-composer-renderer.js @@ -0,0 +1,26 @@ +/** + * R3.D3.API.Composer.Renderer + * @param apiComposer + * + * @property renderer + * + * @constructor + */ +R3.D3.API.Composer.Renderer = function( + apiComposer +) { + + R3.D3.API.Composer.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.renderer)) { + apiComponent.renderer = this.getFirstParent(R3.API.Renderer.D3); + } + this.renderer = apiComponent.renderer; + +}; + +R3.D3.API.Composer.Renderer.prototype = Object.create(R3.D3.API.Composer.prototype); +R3.D3.API.Composer.Renderer.prototype.constructor = R3.D3.API.Composer.Renderer; diff --git a/src/r3-d3-composer-render-target.js b/bak/r3-d3-composer-render-target.js similarity index 95% rename from src/r3-d3-composer-render-target.js rename to bak/r3-d3-composer-render-target.js index 2ca47dd..899ac73 100644 --- a/src/r3-d3-composer-render-target.js +++ b/bak/r3-d3-composer-render-target.js @@ -7,7 +7,7 @@ R3.D3.Composer.RenderTarget = function( apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; R3.D3.API.Composer.RenderTarget.call( this, @@ -58,7 +58,7 @@ R3.D3.Composer.RenderTarget.prototype.createInstance = function() { } ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-d3-composer-renderer.js b/bak/r3-d3-composer-renderer.js similarity index 97% rename from src/r3-d3-composer-renderer.js rename to bak/r3-d3-composer-renderer.js index 9dba2b2..0770102 100644 --- a/src/r3-d3-composer-renderer.js +++ b/bak/r3-d3-composer-renderer.js @@ -7,7 +7,7 @@ R3.D3.Composer.Renderer = function( apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; R3.D3.API.Composer.Renderer.call( this, @@ -89,7 +89,7 @@ R3.D3.Composer.Renderer.prototype.createInstance = function() { } ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/defines/editor.js b/defines/editor.js deleted file mode 100644 index 076a55e..0000000 --- a/defines/editor.js +++ /dev/null @@ -1,2 +0,0 @@ -//#define EDITOR__ -//#define DEBUG__ \ No newline at end of file diff --git a/defines/runtime.js b/defines/runtime.js deleted file mode 100644 index 5ebd2fa..0000000 --- a/defines/runtime.js +++ /dev/null @@ -1,2 +0,0 @@ -//#define RUNTIME__ -//#define DEBUG__ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 4381a62..ca21304 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,86 +21,19 @@ code += '\t\tthis.apiComponent.register,\n'; code += '\t\tthis.apiComponent.selected\n'; code += '\t)'; -var code2 = 'if (R3.Utils.UndefinedOrNull(apiGeometryBuffer)) {\n'; -code2 += '\t\tapiGeometryBuffer = {};\n'; -code2 += '\t}\n'; -code2 += '\tthis.apiGeometryBuffer = apiGeometryBuffer;\n'; -code2 += '\n'; -code2 += '\tR3.D3.API.Geometry.Buffer.call(\n'; +var code2 = 'R3.D3.API.Geometry.Buffer.call(\n'; code2 += '\t\tthis,\n'; -code2 += '\t\tthis.apiGeometryBuffer,\n'; -code2 += '\t\tthis.apiGeometryBuffer.attributes,\n'; -code2 += '\t\tthis.apiGeometryBuffer.drawRange,\n'; -code2 += '\t\tthis.apiGeometryBuffer.groups,\n'; -code2 += '\t\tthis.apiGeometryBuffer.index,\n'; -code2 += '\t\tthis.apiGeometryBuffer.morphAttributes\n'; +code2 += '\t\tapiComponent\n'; code2 += '\t)'; -var code3 = 'if (R3.Utils.UndefinedOrNull(apiGeometryNormal)) {\n'; -code3 += '\t\tapiGeometryNormal = {};\n'; -code3 += '\t}\n'; -code3 += '\tthis.apiGeometryNormal = apiGeometryNormal;\n'; -code3 += '\n'; -code3 += '\tR3.D3.API.Geometry.Normal.call(\n'; +var code3 = 'R3.D3.API.Geometry.Normal.call(\n'; code3 += '\t\tthis,\n'; -code3 += '\t\tthis.apiGeometryNormal,\n'; -code3 += '\t\tthis.apiGeometryNormal.colors,\n'; -code3 += '\t\tthis.apiGeometryNormal.lineDistances,\n'; -code3 += '\t\tthis.apiGeometryNormal.morphTargets,\n'; -code3 += '\t\tthis.apiGeometryNormal.morphNormals,\n'; -code3 += '\t\tthis.apiGeometryNormal.skinWeights,\n'; -code3 += '\t\tthis.apiGeometryNormal.skinIndices,\n'; -code3 += '\t\tthis.apiGeometryNormal.verticesNeedsUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.elementsNeedUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.uvsNeedUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.normalsNeedUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.colorsNeedUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.groupsNeedUpdate,\n'; -code3 += '\t\tthis.apiGeometryNormal.lineDistancesNeedUpdate\n'; +code3 += '\t\tapiComponent\n'; code3 += '\t)'; -var code4 = 'if (R3.Utils.UndefinedOrNull(apiMaterial)) {\n'; -code4 += '\t\tapiMaterial = {};\n'; -code4 += '\t}\n'; -code4 += '\tthis.apiMaterial = apiMaterial;\n'; -code4 += '\n'; -code4 += '\tR3.D3.API.Material.call(\n'; +var code4 = 'R3.D3.API.Material.call(\n'; code4 += '\t\tthis,\n'; -code4 += '\t\tthis.apiMaterial,\n'; -code4 += '\t\tthis.apiMaterial.parentMeshes,\n'; -code4 += '\t\tthis.apiMaterial.alphaTest,\n'; -code4 += '\t\tthis.apiMaterial.blendDst,\n'; -code4 += '\t\tthis.apiMaterial.blendDstAlpha,\n'; -code4 += '\t\tthis.apiMaterial.blendEquation,\n'; -code4 += '\t\tthis.apiMaterial.blendEquationAlpha,\n'; -code4 += '\t\tthis.apiMaterial.blending,\n'; -code4 += '\t\tthis.apiMaterial.blendSrc,\n'; -code4 += '\t\tthis.apiMaterial.blendSrcAlpha,\n'; -code4 += '\t\tthis.apiMaterial.clipIntersection,\n'; -code4 += '\t\tthis.apiMaterial.clippingPlanes,\n'; -code4 += '\t\tthis.apiMaterial.clipShadows,\n'; -code4 += '\t\tthis.apiMaterial.colorWrite,\n'; -code4 += '\t\tthis.apiMaterial.customDepthMaterial,\n'; -code4 += '\t\tthis.apiMaterial.customDistanceMaterial,\n'; -code4 += '\t\tthis.apiMaterial.defines,\n'; -code4 += '\t\tthis.apiMaterial.depthFunc,\n'; -code4 += '\t\tthis.apiMaterial.depthTest,\n'; -code4 += '\t\tthis.apiMaterial.depthWrite,\n'; -code4 += '\t\tthis.apiMaterial.fog,\n'; -code4 += '\t\tthis.apiMaterial.lights,\n'; -code4 += '\t\tthis.apiMaterial.opacity,\n'; -code4 += '\t\tthis.apiMaterial.overdraw,\n'; -code4 += '\t\tthis.apiMaterial.polygonOffset,\n'; -code4 += '\t\tthis.apiMaterial.polygonOffsetFactor,\n'; -code4 += '\t\tthis.apiMaterial.polygonOffsetUnits,\n'; -code4 += '\t\tthis.apiMaterial.precision,\n'; -code4 += '\t\tthis.apiMaterial.premultipliedAlpha,\n'; -code4 += '\t\tthis.apiMaterial.dithering,\n'; -code4 += '\t\tthis.apiMaterial.flatShading,\n'; -code4 += '\t\tthis.apiMaterial.side,\n'; -code4 += '\t\tthis.apiMaterial.transparent,\n'; -code4 += '\t\tthis.apiMaterial.vertexColors,\n'; -code4 += '\t\tthis.apiMaterial.visible\n'; +code4 += '\t\tapiComponent\n'; code4 += '\t)'; var code5 = 'if (R3.Utils.UndefinedOrNull(apiTexture)) {\n'; @@ -144,6 +77,7 @@ code6 += '\tthis.apiComponent = apiComponent;\n'; code6 += '\n'; code6 += '\tthis.graphics\t= null;\n'; code6 += '\tthis.physics\t= null;\n'; +code6 += '\tthis.coder\t\t= null;\n'; code6 += '\tthis.gui\t\t= null;\n'; code6 += '\tthis.stats\t\t= null;\n'; code6 += '\n'; @@ -152,23 +86,59 @@ code6 += '\t\tR3.Event.GET_RUNTIME,\n'; code6 += '\t\tfunction(runtime) {\n'; code6 += '\t\t\tthis.graphics\t= runtime.graphics;\n'; code6 += '\t\t\tthis.physics\t= runtime.physics;\n'; -code6 += '\t\t\tthis.coder\t= runtime.coder;\n'; +code6 += '\t\t\tthis.coder\t\t= runtime.coder;\n'; code6 += '\t\t\tthis.gui\t\t= runtime.gui;\n'; code6 += '\t\t\tthis.stats\t\t= runtime.stats;\n'; code6 += '\t\t}.bind(this)\n'; -code6 += '\t)'; +code6 += '\t);\n'; +code6 += '\n'; +code6 += '\tthis.initialize(apiComponent)'; + +var code7 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; +code7 += '\t\tapiComponent = {};\n'; +code7 += '\t}\n'; +code7 += '\n'; +code7 += '\tif (R3.Utils.UndefinedOrNull(apiComponent.register)) {\n'; +code7 += '\t\tapiComponent.register = false;\n'; +code7 += '\t}\n'; +code7 += '\n'; +code7 += '\tR3.Event.Emit(\n'; +code7 += '\t\tR3.Event.GET_REGISTER_FACES,\n'; +code7 += '\t\tnull,\n'; +code7 += '\t\tfunction(register) {\n'; +code7 += '\t\t\tif (register) {\n'; +code7 += '\t\t\t\tapiComponent.register = true;\n'; +code7 += '\t\t\t}\n'; +code7 += '\t\t}\n'; +code7 += '\t)'; + +var code8 = 'R3.Component.call(this)'; + +var code9 = 'R3.Component.prototype.createInstance.call(this)'; + +var code10 = 'R3.Component.prototype.updateInstance.call(this, property)'; + +var code11 = 'R3.D3.Geometry.Buffer.call(\n'; +code11 += '\t\tthis,\n'; +code11 += '\t\ttrue\n'; +code11 += '\t);'; function build() { return gulp.src('./src/r3-*.js') .pipe(sort()) .pipe(concat('r3.js')) .pipe(replace('__DATE__', new Date().toString())) - .pipe(replace('__API_COMPONENT_MACRO__', code)) - .pipe(replace('__API_GEOMETRY_BUFFER_MACRO__', code2)) - .pipe(replace('__API_GEOMETRY_NORMAL_MACRO__', code3)) - .pipe(replace('__API_MATERIAL_MACRO__', code4)) - .pipe(replace('__API_TEXTURE_MACRO__', code5)) - .pipe(replace('__RUNTIME_COMPONENT_MACRO__', code6)) + .pipe(replace('__API_COMPONENT__', code)) + .pipe(replace('__API_GEOMETRY_BUFFER__', code2)) + .pipe(replace('__API_GEOMETRY_NORMAL__', code3)) + .pipe(replace('__API_MATERIAL__', code4)) + .pipe(replace('__API_TEXTURE__', code5)) + .pipe(replace('__RUNTIME_COMPONENT__', code6)) + .pipe(replace('__DEREGISTER_COMPONENT__', code7)) + .pipe(replace('__UPGRADE_TO_RUNTIME__', code8)) + .pipe(replace('__CREATE_INSTANCE__', code9)) + .pipe(replace('__UPDATE_INSTANCE__', code10)) + .pipe(replace('__RUNTIME_BUFFER_COMPONENT__', code11)) .pipe(minify({ ext:{ src:'.js', diff --git a/package.json b/package.json index f2bcb00..dfc5fcd 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dependencies": { "cannon": "^0.6.2", "gulp-cli": "^2.0.1", - "three": "*" + "three": "^0.107.0" }, "devDependencies": { "gulp": "git://github.com/gulpjs/gulp.git#6d71a658c61edb3090221579d8f97dbe086ba2ed", @@ -17,7 +17,7 @@ "gulp-minify": "*", "gulp-sort": "*", "gulp-string-replace": "*", - "lodash": "^4.17.2", - "npm": "^6.4.1" + "lodash": "^4.17.15", + "npm": "^6.11.1" } } diff --git a/src/build_component_lists.php b/src/build_component_lists.php new file mode 100755 index 0000000..aa6ded0 --- /dev/null +++ b/src/build_component_lists.php @@ -0,0 +1,152 @@ +#!/usr/bin/php + diff --git a/src/r3-a-0.js b/src/r3-a-0.js index 410d73b..719bcd7 100644 --- a/src/r3-a-0.js +++ b/src/r3-a-0.js @@ -1,3 +1,5 @@ +console.log("Loading R3 compiled at: __DATE__"); + /** * R3 Namespace */ @@ -35,7 +37,3 @@ if (typeof R3.D3.Runtime === 'undefined') { R3.D3.Runtime = function(){}; } -/** - * This gets injected by gulp - */ -console.log("Loading R3 compiled at: __DATE__"); diff --git a/src/r3-a-1-component-info.js b/src/r3-a-1-component-info.js new file mode 100644 index 0000000..d2f3fec --- /dev/null +++ b/src/r3-a-1-component-info.js @@ -0,0 +1,2840 @@ +R3.COMPONENT_VIDEO = 0x1; +R3.COMPONENT_VECTOR4 = 0x2; +R3.COMPONENT_VECTOR3 = 0x3; +R3.COMPONENT_VECTOR2 = 0x4; +R3.COMPONENT_USER = 0x5; +R3.COMPONENT_STATS = 0x6; +R3.COMPONENT_SPHERE = 0x7; +R3.COMPONENT_SOCKET_RECEIVE = 0x8; +R3.COMPONENT_SOCKET_CAST = 0x9; +R3.COMPONENT_SOCKET = 0xa; +R3.COMPONENT_SERVER = 0xb; +R3.COMPONENT_RENDERER_D3_CANVAS_TARGET = 0xc; +R3.COMPONENT_RENDERER_D3_CANVAS = 0xd; +R3.COMPONENT_RENDERER_D3 = 0xe; +R3.COMPONENT_RENDERER_D2 = 0xf; +R3.COMPONENT_RENDERER = 0x10; +R3.COMPONENT_QUERY_ALERTS_TIMESERIES = 0x11; +R3.COMPONENT_QUERY_ALERTS_SUMMARY = 0x12; +R3.COMPONENT_QUERY_ALERTS_LIST = 0x13; +R3.COMPONENT_QUERY_ALERTS_BUCKETS = 0x14; +R3.COMPONENT_QUERY_ALERTS = 0x15; +R3.COMPONENT_QUERY = 0x16; +R3.COMPONENT_QUATERNION_POINTS = 0x17; +R3.COMPONENT_QUATERNION = 0x18; +R3.COMPONENT_PROJECT = 0x19; +R3.COMPONENT_PLANE = 0x1a; +R3.COMPONENT_MOUSE = 0x1b; +R3.COMPONENT_MATRIX4 = 0x1c; +R3.COMPONENT_IMAGE = 0x1d; +R3.COMPONENT_GUI = 0x1e; +R3.COMPONENT_GROUP = 0x1f; +R3.COMPONENT_GRAPH_TABLE = 0x20; +R3.COMPONENT_GRAPH_METRIC = 0x21; +R3.COMPONENT_GRAPH_BARCHART_STACKED = 0x22; +R3.COMPONENT_GRAPH_BARCHART = 0x23; +R3.COMPONENT_GRAPH = 0x24; +R3.COMPONENT_FONT = 0x25; +R3.COMPONENT_ENTITYMANAGER = 0x26; +R3.COMPONENT_ENTITY = 0x27; +R3.COMPONENT_DRAWRANGE = 0x28; +R3.COMPONENT_DOMELEMENT = 0x29; +R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT = 0x2a; +R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT = 0x2b; +R3.COMPONENT_D3_VIEWPORT = 0x2c; +R3.COMPONENT_D3_VERTEX = 0x2d; +R3.COMPONENT_D3_TEXTURE_IMAGE = 0x2e; +R3.COMPONENT_D3_TEXTURE_CUBE = 0x2f; +R3.COMPONENT_D3_TEXTURE_CANVAS = 0x30; +R3.COMPONENT_D3_TEXTURE = 0x31; +R3.COMPONENT_D3_TEXT = 0x32; +R3.COMPONENT_D3_SPLINE = 0x33; +R3.COMPONENT_D3_SOLVER = 0x34; +R3.COMPONENT_D3_SKELETON = 0x35; +R3.COMPONENT_D3_SHAPE_TRIMESH = 0x36; +R3.COMPONENT_D3_SHAPE_SPHERE = 0x37; +R3.COMPONENT_D3_SHAPE_PLANE = 0x38; +R3.COMPONENT_D3_SHAPE_HEIGHTMAP = 0x39; +R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER = 0x3a; +R3.COMPONENT_D3_SHAPE_CONVEXHULL = 0x3b; +R3.COMPONENT_D3_SHAPE_BOX = 0x3c; +R3.COMPONENT_D3_SHAPE = 0x3d; +R3.COMPONENT_D3_SHADOW_SPOT = 0x3e; +R3.COMPONENT_D3_SHADOW_DIRECTIONAL = 0x3f; +R3.COMPONENT_D3_SHADOW = 0x40; +R3.COMPONENT_D3_SHADER_VERTEX = 0x41; +R3.COMPONENT_D3_SHADER_FRAGMENT = 0x42; +R3.COMPONENT_D3_SHADER = 0x43; +R3.COMPONENT_D3_SCENE = 0x44; +R3.COMPONENT_D3_RIGIDBODY = 0x45; +R3.COMPONENT_D3_RENDERTARGET_CUBE = 0x46; +R3.COMPONENT_D3_RENDERTARGET = 0x47; +R3.COMPONENT_D3_RAYCASTER = 0x48; +R3.COMPONENT_D3_RAYCASTWHEEL = 0x49; +R3.COMPONENT_D3_RAYCASTVEHICLE = 0x4a; +R3.COMPONENT_D3_PHYSICS_WORLD = 0x4b; +R3.COMPONENT_D3_PASS_RENDER_SSAO = 0x4c; +R3.COMPONENT_D3_PASS_RENDER = 0x4d; +R3.COMPONENT_D3_PASS_FXAA = 0x4e; +R3.COMPONENT_D3_PASS_COPY = 0x4f; +R3.COMPONENT_D3_PASS_BLOOM = 0x50; +R3.COMPONENT_D3_PASS = 0x51; +R3.COMPONENT_D3_PARTICLE_ENGINE = 0x52; +R3.COMPONENT_D3_PARTICLE = 0x53; +R3.COMPONENT_D3_MESH_SKELETON = 0x54; +R3.COMPONENT_D3_MESH = 0x55; +R3.COMPONENT_D3_MATERIAL_STANDARD = 0x56; +R3.COMPONENT_D3_MATERIAL_SHADER_RAW = 0x57; +R3.COMPONENT_D3_MATERIAL_SHADER = 0x58; +R3.COMPONENT_D3_MATERIAL_POINTS = 0x59; +R3.COMPONENT_D3_MATERIAL_PHONG = 0x5a; +R3.COMPONENT_D3_MATERIAL_BASIC = 0x5b; +R3.COMPONENT_D3_MATERIAL = 0x5c; +R3.COMPONENT_D3_LIGHT_SPOT = 0x5d; +R3.COMPONENT_D3_LIGHT_RECTAREA = 0x5e; +R3.COMPONENT_D3_LIGHT_POINT = 0x5f; +R3.COMPONENT_D3_LIGHT_HEMISPHERE = 0x60; +R3.COMPONENT_D3_LIGHT_DIRECTIONAL = 0x61; +R3.COMPONENT_D3_LIGHT_AMBIENT = 0x62; +R3.COMPONENT_D3_LIGHT = 0x63; +R3.COMPONENT_D3_HELPER = 0x64; +R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME = 0x65; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE = 0x66; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT = 0x67; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS = 0x68; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT = 0x69; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON = 0x6a; +R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE = 0x6b; +R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE = 0x6c; +R3.COMPONENT_D3_GEOMETRY_NORMAL_RING = 0x6d; +R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON = 0x6e; +R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE = 0x6f; +R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC = 0x70; +R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON = 0x71; +R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE = 0x72; +R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON = 0x73; +R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE = 0x74; +R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES = 0x75; +R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON = 0x76; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER = 0x77; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE = 0x78; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE = 0x79; +R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX = 0x7a; +R3.COMPONENT_D3_GEOMETRY_NORMAL = 0x7b; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE = 0x7c; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT = 0x7d; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS = 0x7e; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT = 0x7f; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON = 0x80; +R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE = 0x81; +R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE = 0x82; +R3.COMPONENT_D3_GEOMETRY_BUFFER_RING = 0x83; +R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON = 0x84; +R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE = 0x85; +R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC = 0x86; +R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON = 0x87; +R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE = 0x88; +R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED = 0x89; +R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON = 0x8a; +R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE = 0x8b; +R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON = 0x8c; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER = 0x8d; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE = 0x8e; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE = 0x8f; +R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX = 0x90; +R3.COMPONENT_D3_GEOMETRY_BUFFER = 0x91; +R3.COMPONENT_D3_GEOMETRY = 0x92; +R3.COMPONENT_D3_FRICTIONMATERIAL = 0x93; +R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL = 0x94; +R3.COMPONENT_D3_FOG_NORMAL = 0x95; +R3.COMPONENT_D3_FOG_EXP = 0x96; +R3.COMPONENT_D3_FOG = 0x97; +R3.COMPONENT_D3_FACE_GRAPHICS = 0x98; +R3.COMPONENT_D3_FACE = 0x99; +R3.COMPONENT_D3_EFFECT_STEREO = 0x9a; +R3.COMPONENT_D3_EFFECT_PARALLAX = 0x9b; +R3.COMPONENT_D3_EFFECT_ANAGLYPH = 0x9c; +R3.COMPONENT_D3_EFFECT = 0x9d; +R3.COMPONENT_D3_COMPOSER = 0x9e; +R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO = 0x9f; +R3.COMPONENT_D3_CAMERA_PERSPECTIVE = 0xa0; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT = 0xa1; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT = 0xa2; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC = 0xa3; +R3.COMPONENT_D3_CAMERA_CUBE = 0xa4; +R3.COMPONENT_D3_CAMERA = 0xa5; +R3.COMPONENT_D3_BROADPHASE = 0xa6; +R3.COMPONENT_D3_BONEWEIGHT = 0xa7; +R3.COMPONENT_D3_BONE = 0xa8; +R3.COMPONENT_D3_AUDIO = 0xa9; +R3.COMPONENT_D3_ANIMATION = 0xaa; +R3.COMPONENT_D3_OBJECT = 0xab; +R3.COMPONENT_CUSTOMCODE = 0xac; +R3.COMPONENT_CURVE_PATH_D2_SHAPE = 0xad; +R3.COMPONENT_CURVE_PATH_D2 = 0xae; +R3.COMPONENT_CURVE_PATH = 0xaf; +R3.COMPONENT_CURVE = 0xb0; +R3.COMPONENT_CONTROLS_TOUCH = 0xb1; +R3.COMPONENT_CONTROLS_MOUSE = 0xb2; +R3.COMPONENT_CONTROLS_KEYBOARD = 0xb3; +R3.COMPONENT_CONTROLS_D3_ORBIT = 0xb4; +R3.COMPONENT_CONTROLS_D3_FIRSTPERSON = 0xb5; +R3.COMPONENT_CONTROLS_D3_EDITOR = 0xb6; +R3.COMPONENT_CONTROLS_D3 = 0xb7; +R3.COMPONENT_CONTROLS = 0xb8; +R3.COMPONENT_COLOR = 0xb9; +R3.COMPONENT_CLOCK = 0xba; +R3.COMPONENT_CANVAS = 0xbb; +R3.COMPONENT_BOX3 = 0xbc; +R3.MAX_COMPONENTS = 0xbd; + +/**\ + * R3.GetComponentType\ + * @returns {number}\ + * @constructor\ + */ +R3.GetComponentType = function(component) { + + if (component instanceof R3.Video) { + return R3.COMPONENT_VIDEO; + } + + if (component instanceof R3.Vector4) { + return R3.COMPONENT_VECTOR4; + } + + if (component instanceof R3.Vector3) { + return R3.COMPONENT_VECTOR3; + } + + if (component instanceof R3.Vector2) { + return R3.COMPONENT_VECTOR2; + } + + if (component instanceof R3.User) { + return R3.COMPONENT_USER; + } + + if (component instanceof R3.Stats) { + return R3.COMPONENT_STATS; + } + + if (component instanceof R3.Sphere) { + return R3.COMPONENT_SPHERE; + } + + if (component instanceof R3.Socket.Receive) { + return R3.COMPONENT_SOCKET_RECEIVE; + } + + if (component instanceof R3.Socket.Cast) { + return R3.COMPONENT_SOCKET_CAST; + } + + if (component instanceof R3.Socket) { + return R3.COMPONENT_SOCKET; + } + + if (component instanceof R3.Server) { + return R3.COMPONENT_SERVER; + } + + if (component instanceof R3.Renderer.D3.Canvas.Target) { + return R3.COMPONENT_RENDERER_D3_CANVAS_TARGET; + } + + if (component instanceof R3.Renderer.D3.Canvas) { + return R3.COMPONENT_RENDERER_D3_CANVAS; + } + + if (component instanceof R3.Renderer.D3) { + return R3.COMPONENT_RENDERER_D3; + } + + if (component instanceof R3.Renderer.D2) { + return R3.COMPONENT_RENDERER_D2; + } + + if (component instanceof R3.Renderer) { + return R3.COMPONENT_RENDERER; + } + + if (component instanceof R3.Query.Alerts.Timeseries) { + return R3.COMPONENT_QUERY_ALERTS_TIMESERIES; + } + + if (component instanceof R3.Query.Alerts.Summary) { + return R3.COMPONENT_QUERY_ALERTS_SUMMARY; + } + + if (component instanceof R3.Query.Alerts.List) { + return R3.COMPONENT_QUERY_ALERTS_LIST; + } + + if (component instanceof R3.Query.Alerts.Buckets) { + return R3.COMPONENT_QUERY_ALERTS_BUCKETS; + } + + if (component instanceof R3.Query.Alerts) { + return R3.COMPONENT_QUERY_ALERTS; + } + + if (component instanceof R3.Query) { + return R3.COMPONENT_QUERY; + } + + if (component instanceof R3.Quaternion.Points) { + return R3.COMPONENT_QUATERNION_POINTS; + } + + if (component instanceof R3.Quaternion) { + return R3.COMPONENT_QUATERNION; + } + + if (component instanceof R3.Project) { + return R3.COMPONENT_PROJECT; + } + + if (component instanceof R3.Plane) { + return R3.COMPONENT_PLANE; + } + + if (component instanceof R3.Mouse) { + return R3.COMPONENT_MOUSE; + } + + if (component instanceof R3.Matrix4) { + return R3.COMPONENT_MATRIX4; + } + + if (component instanceof R3.Image) { + return R3.COMPONENT_IMAGE; + } + + if (component instanceof R3.GUI) { + return R3.COMPONENT_GUI; + } + + if (component instanceof R3.Group) { + return R3.COMPONENT_GROUP; + } + + if (component instanceof R3.Graph.Table) { + return R3.COMPONENT_GRAPH_TABLE; + } + + if (component instanceof R3.Graph.Metric) { + return R3.COMPONENT_GRAPH_METRIC; + } + + if (component instanceof R3.Graph.Barchart.Stacked) { + return R3.COMPONENT_GRAPH_BARCHART_STACKED; + } + + if (component instanceof R3.Graph.Barchart) { + return R3.COMPONENT_GRAPH_BARCHART; + } + + if (component instanceof R3.Graph) { + return R3.COMPONENT_GRAPH; + } + + if (component instanceof R3.Font) { + return R3.COMPONENT_FONT; + } + + if (component instanceof R3.EntityManager) { + return R3.COMPONENT_ENTITYMANAGER; + } + + if (component instanceof R3.Entity) { + return R3.COMPONENT_ENTITY; + } + + if (component instanceof R3.DrawRange) { + return R3.COMPONENT_DRAWRANGE; + } + + if (component instanceof R3.DomElement) { + return R3.COMPONENT_DOMELEMENT; + } + + if (component instanceof R3.D3.Viewport.ZoomedAspect) { + return R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT; + } + + if (component instanceof R3.D3.Viewport.FixedAspect) { + return R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT; + } + + if (component instanceof R3.D3.Viewport) { + return R3.COMPONENT_D3_VIEWPORT; + } + + if (component instanceof R3.D3.Vertex) { + return R3.COMPONENT_D3_VERTEX; + } + + if (component instanceof R3.D3.Texture.Image) { + return R3.COMPONENT_D3_TEXTURE_IMAGE; + } + + if (component instanceof R3.D3.Texture.Cube) { + return R3.COMPONENT_D3_TEXTURE_CUBE; + } + + if (component instanceof R3.D3.Texture.Canvas) { + return R3.COMPONENT_D3_TEXTURE_CANVAS; + } + + if (component instanceof R3.D3.Texture) { + return R3.COMPONENT_D3_TEXTURE; + } + + if (component instanceof R3.D3.Text) { + return R3.COMPONENT_D3_TEXT; + } + + if (component instanceof R3.D3.Spline) { + return R3.COMPONENT_D3_SPLINE; + } + + if (component instanceof R3.D3.Solver) { + return R3.COMPONENT_D3_SOLVER; + } + + if (component instanceof R3.D3.Skeleton) { + return R3.COMPONENT_D3_SKELETON; + } + + if (component instanceof R3.D3.Shape.TriMesh) { + return R3.COMPONENT_D3_SHAPE_TRIMESH; + } + + if (component instanceof R3.D3.Shape.Sphere) { + return R3.COMPONENT_D3_SHAPE_SPHERE; + } + + if (component instanceof R3.D3.Shape.Plane) { + return R3.COMPONENT_D3_SHAPE_PLANE; + } + + if (component instanceof R3.D3.Shape.HeightMap) { + return R3.COMPONENT_D3_SHAPE_HEIGHTMAP; + } + + if (component instanceof R3.D3.Shape.ConvexHull.Cylinder) { + return R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER; + } + + if (component instanceof R3.D3.Shape.ConvexHull) { + return R3.COMPONENT_D3_SHAPE_CONVEXHULL; + } + + if (component instanceof R3.D3.Shape.Box) { + return R3.COMPONENT_D3_SHAPE_BOX; + } + + if (component instanceof R3.D3.Shape) { + return R3.COMPONENT_D3_SHAPE; + } + + if (component instanceof R3.D3.Shadow.Spot) { + return R3.COMPONENT_D3_SHADOW_SPOT; + } + + if (component instanceof R3.D3.Shadow.Directional) { + return R3.COMPONENT_D3_SHADOW_DIRECTIONAL; + } + + if (component instanceof R3.D3.Shadow) { + return R3.COMPONENT_D3_SHADOW; + } + + if (component instanceof R3.D3.Shader.Vertex) { + return R3.COMPONENT_D3_SHADER_VERTEX; + } + + if (component instanceof R3.D3.Shader.Fragment) { + return R3.COMPONENT_D3_SHADER_FRAGMENT; + } + + if (component instanceof R3.D3.Shader) { + return R3.COMPONENT_D3_SHADER; + } + + if (component instanceof R3.D3.Scene) { + return R3.COMPONENT_D3_SCENE; + } + + if (component instanceof R3.D3.RigidBody) { + return R3.COMPONENT_D3_RIGIDBODY; + } + + if (component instanceof R3.D3.RenderTarget.Cube) { + return R3.COMPONENT_D3_RENDERTARGET_CUBE; + } + + if (component instanceof R3.D3.RenderTarget) { + return R3.COMPONENT_D3_RENDERTARGET; + } + + if (component instanceof R3.D3.Raycaster) { + return R3.COMPONENT_D3_RAYCASTER; + } + + if (component instanceof R3.D3.RaycastWheel) { + return R3.COMPONENT_D3_RAYCASTWHEEL; + } + + if (component instanceof R3.D3.RaycastVehicle) { + return R3.COMPONENT_D3_RAYCASTVEHICLE; + } + + if (component instanceof R3.D3.Physics.World) { + return R3.COMPONENT_D3_PHYSICS_WORLD; + } + + if (component instanceof R3.D3.Pass.Render.SSAO) { + return R3.COMPONENT_D3_PASS_RENDER_SSAO; + } + + if (component instanceof R3.D3.Pass.Render) { + return R3.COMPONENT_D3_PASS_RENDER; + } + + if (component instanceof R3.D3.Pass.FXAA) { + return R3.COMPONENT_D3_PASS_FXAA; + } + + if (component instanceof R3.D3.Pass.Copy) { + return R3.COMPONENT_D3_PASS_COPY; + } + + if (component instanceof R3.D3.Pass.Bloom) { + return R3.COMPONENT_D3_PASS_BLOOM; + } + + if (component instanceof R3.D3.Pass) { + return R3.COMPONENT_D3_PASS; + } + + if (component instanceof R3.D3.Particle.Engine) { + return R3.COMPONENT_D3_PARTICLE_ENGINE; + } + + if (component instanceof R3.D3.Particle) { + return R3.COMPONENT_D3_PARTICLE; + } + + if (component instanceof R3.D3.Mesh.Skeleton) { + return R3.COMPONENT_D3_MESH_SKELETON; + } + + if (component instanceof R3.D3.Mesh) { + return R3.COMPONENT_D3_MESH; + } + + if (component instanceof R3.D3.Material.Standard) { + return R3.COMPONENT_D3_MATERIAL_STANDARD; + } + + if (component instanceof R3.D3.Material.Shader.Raw) { + return R3.COMPONENT_D3_MATERIAL_SHADER_RAW; + } + + if (component instanceof R3.D3.Material.Shader) { + return R3.COMPONENT_D3_MATERIAL_SHADER; + } + + if (component instanceof R3.D3.Material.Points) { + return R3.COMPONENT_D3_MATERIAL_POINTS; + } + + if (component instanceof R3.D3.Material.Phong) { + return R3.COMPONENT_D3_MATERIAL_PHONG; + } + + if (component instanceof R3.D3.Material.Basic) { + return R3.COMPONENT_D3_MATERIAL_BASIC; + } + + if (component instanceof R3.D3.Material) { + return R3.COMPONENT_D3_MATERIAL; + } + + if (component instanceof R3.D3.Light.Spot) { + return R3.COMPONENT_D3_LIGHT_SPOT; + } + + if (component instanceof R3.D3.Light.RectArea) { + return R3.COMPONENT_D3_LIGHT_RECTAREA; + } + + if (component instanceof R3.D3.Light.Point) { + return R3.COMPONENT_D3_LIGHT_POINT; + } + + if (component instanceof R3.D3.Light.Hemisphere) { + return R3.COMPONENT_D3_LIGHT_HEMISPHERE; + } + + if (component instanceof R3.D3.Light.Directional) { + return R3.COMPONENT_D3_LIGHT_DIRECTIONAL; + } + + if (component instanceof R3.D3.Light.Ambient) { + return R3.COMPONENT_D3_LIGHT_AMBIENT; + } + + if (component instanceof R3.D3.Light) { + return R3.COMPONENT_D3_LIGHT; + } + + if (component instanceof R3.D3.Helper) { + return R3.COMPONENT_D3_HELPER; + } + + if (component instanceof R3.D3.Geometry.Normal.Wireframe) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME; + } + + if (component instanceof R3.D3.Geometry.Normal.Tube) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE; + } + + if (component instanceof R3.D3.Geometry.Normal.TorusKnot) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT; + } + + if (component instanceof R3.D3.Geometry.Normal.Torus) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS; + } + + if (component instanceof R3.D3.Geometry.Normal.Text) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT; + } + + if (component instanceof R3.D3.Geometry.Normal.Tetrahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Normal.Sphere) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE; + } + + if (component instanceof R3.D3.Geometry.Normal.Shape) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE; + } + + if (component instanceof R3.D3.Geometry.Normal.Ring) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_RING; + } + + if (component instanceof R3.D3.Geometry.Normal.Polyhedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON; + } + + if (component instanceof R3.D3.Geometry.Normal.Plane) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE; + } + + if (component instanceof R3.D3.Geometry.Normal.Parametric) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC; + } + + if (component instanceof R3.D3.Geometry.Normal.Octahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Normal.Lathe) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE; + } + + if (component instanceof R3.D3.Geometry.Normal.Icosahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Normal.Extrude) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE; + } + + if (component instanceof R3.D3.Geometry.Normal.Edges) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES; + } + + if (component instanceof R3.D3.Geometry.Normal.Dodecahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Normal.Cylinder) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER; + } + + if (component instanceof R3.D3.Geometry.Normal.Cone) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE; + } + + if (component instanceof R3.D3.Geometry.Normal.Circle) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE; + } + + if (component instanceof R3.D3.Geometry.Normal.Box) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX; + } + + if (component instanceof R3.D3.Geometry.Normal) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL; + } + + if (component instanceof R3.D3.Geometry.Buffer.Tube) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE; + } + + if (component instanceof R3.D3.Geometry.Buffer.TorusKnot) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT; + } + + if (component instanceof R3.D3.Geometry.Buffer.Torus) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS; + } + + if (component instanceof R3.D3.Geometry.Buffer.Text) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT; + } + + if (component instanceof R3.D3.Geometry.Buffer.Tetrahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Buffer.Sphere) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Shape) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Ring) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_RING; + } + + if (component instanceof R3.D3.Geometry.Buffer.Polyhedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON; + } + + if (component instanceof R3.D3.Geometry.Buffer.Plane) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Parametric) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC; + } + + if (component instanceof R3.D3.Geometry.Buffer.Octahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Buffer.Lathe) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Instanced) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED; + } + + if (component instanceof R3.D3.Geometry.Buffer.Icosahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Buffer.Extrude) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Dodecahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON; + } + + if (component instanceof R3.D3.Geometry.Buffer.Cylinder) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER; + } + + if (component instanceof R3.D3.Geometry.Buffer.Cone) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Circle) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE; + } + + if (component instanceof R3.D3.Geometry.Buffer.Box) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX; + } + + if (component instanceof R3.D3.Geometry.Buffer) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER; + } + + if (component instanceof R3.D3.Geometry) { + return R3.COMPONENT_D3_GEOMETRY; + } + + if (component instanceof R3.D3.FrictionMaterial) { + return R3.COMPONENT_D3_FRICTIONMATERIAL; + } + + if (component instanceof R3.D3.FrictionContactMaterial) { + return R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL; + } + + if (component instanceof R3.D3.Fog.Normal) { + return R3.COMPONENT_D3_FOG_NORMAL; + } + + if (component instanceof R3.D3.Fog.Exp) { + return R3.COMPONENT_D3_FOG_EXP; + } + + if (component instanceof R3.D3.Fog) { + return R3.COMPONENT_D3_FOG; + } + + if (component instanceof R3.D3.Face.Graphics) { + return R3.COMPONENT_D3_FACE_GRAPHICS; + } + + if (component instanceof R3.D3.Face) { + return R3.COMPONENT_D3_FACE; + } + + if (component instanceof R3.D3.Effect.Stereo) { + return R3.COMPONENT_D3_EFFECT_STEREO; + } + + if (component instanceof R3.D3.Effect.Parallax) { + return R3.COMPONENT_D3_EFFECT_PARALLAX; + } + + if (component instanceof R3.D3.Effect.Anaglyph) { + return R3.COMPONENT_D3_EFFECT_ANAGLYPH; + } + + if (component instanceof R3.D3.Effect) { + return R3.COMPONENT_D3_EFFECT; + } + + if (component instanceof R3.D3.Composer) { + return R3.COMPONENT_D3_COMPOSER; + } + + if (component instanceof R3.D3.Camera.Perspective.Stereo) { + return R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO; + } + + if (component instanceof R3.D3.Camera.Perspective) { + return R3.COMPONENT_D3_CAMERA_PERSPECTIVE; + } + + if (component instanceof R3.D3.Camera.Orthographic.ScaledAspect) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT; + } + + if (component instanceof R3.D3.Camera.Orthographic.FixedAspect) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT; + } + + if (component instanceof R3.D3.Camera.Orthographic) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC; + } + + if (component instanceof R3.D3.Camera.Cube) { + return R3.COMPONENT_D3_CAMERA_CUBE; + } + + if (component instanceof R3.D3.Camera) { + return R3.COMPONENT_D3_CAMERA; + } + + if (component instanceof R3.D3.Broadphase) { + return R3.COMPONENT_D3_BROADPHASE; + } + + if (component instanceof R3.D3.BoneWeight) { + return R3.COMPONENT_D3_BONEWEIGHT; + } + + if (component instanceof R3.D3.Bone) { + return R3.COMPONENT_D3_BONE; + } + + if (component instanceof R3.D3.Audio) { + return R3.COMPONENT_D3_AUDIO; + } + + if (component instanceof R3.D3.Animation) { + return R3.COMPONENT_D3_ANIMATION; + } + + if (component instanceof R3.D3.Object) { + return R3.COMPONENT_D3_OBJECT; + } + + if (component instanceof R3.D3.API.Viewport.ZoomedAspect) { + return R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT; + } + + if (component instanceof R3.D3.API.Viewport.FixedAspect) { + return R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT; + } + + if (component instanceof R3.D3.API.Viewport) { + return R3.COMPONENT_D3_VIEWPORT; + } + + if (component instanceof R3.D3.API.Vertex) { + return R3.COMPONENT_D3_VERTEX; + } + + if (component instanceof R3.D3.API.Texture.Image) { + return R3.COMPONENT_D3_TEXTURE_IMAGE; + } + + if (component instanceof R3.D3.API.Texture.Cube) { + return R3.COMPONENT_D3_TEXTURE_CUBE; + } + + if (component instanceof R3.D3.API.Texture.Canvas) { + return R3.COMPONENT_D3_TEXTURE_CANVAS; + } + + if (component instanceof R3.D3.API.Texture) { + return R3.COMPONENT_D3_TEXTURE; + } + + if (component instanceof R3.D3.API.Text) { + return R3.COMPONENT_D3_TEXT; + } + + if (component instanceof R3.D3.API.Spline) { + return R3.COMPONENT_D3_SPLINE; + } + + if (component instanceof R3.D3.API.Solver) { + return R3.COMPONENT_D3_SOLVER; + } + + if (component instanceof R3.D3.API.Skeleton) { + return R3.COMPONENT_D3_SKELETON; + } + + if (component instanceof R3.D3.API.Shape.TriMesh) { + return R3.COMPONENT_D3_SHAPE_TRIMESH; + } + + if (component instanceof R3.D3.API.Shape.Sphere) { + return R3.COMPONENT_D3_SHAPE_SPHERE; + } + + if (component instanceof R3.D3.API.Shape.Plane) { + return R3.COMPONENT_D3_SHAPE_PLANE; + } + + if (component instanceof R3.D3.API.Shape.HeightMap) { + return R3.COMPONENT_D3_SHAPE_HEIGHTMAP; + } + + if (component instanceof R3.D3.API.Shape.ConvexHull.Cylinder) { + return R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER; + } + + if (component instanceof R3.D3.API.Shape.ConvexHull) { + return R3.COMPONENT_D3_SHAPE_CONVEXHULL; + } + + if (component instanceof R3.D3.API.Shape.Box) { + return R3.COMPONENT_D3_SHAPE_BOX; + } + + if (component instanceof R3.D3.API.Shape) { + return R3.COMPONENT_D3_SHAPE; + } + + if (component instanceof R3.D3.API.Shadow.Spot) { + return R3.COMPONENT_D3_SHADOW_SPOT; + } + + if (component instanceof R3.D3.API.Shadow.Directional) { + return R3.COMPONENT_D3_SHADOW_DIRECTIONAL; + } + + if (component instanceof R3.D3.API.Shadow) { + return R3.COMPONENT_D3_SHADOW; + } + + if (component instanceof R3.D3.API.Shader.Vertex) { + return R3.COMPONENT_D3_SHADER_VERTEX; + } + + if (component instanceof R3.D3.API.Shader.Fragment) { + return R3.COMPONENT_D3_SHADER_FRAGMENT; + } + + if (component instanceof R3.D3.API.Shader) { + return R3.COMPONENT_D3_SHADER; + } + + if (component instanceof R3.D3.API.Scene) { + return R3.COMPONENT_D3_SCENE; + } + + if (component instanceof R3.D3.API.RigidBody) { + return R3.COMPONENT_D3_RIGIDBODY; + } + + if (component instanceof R3.D3.API.RenderTarget.Cube) { + return R3.COMPONENT_D3_RENDERTARGET_CUBE; + } + + if (component instanceof R3.D3.API.RenderTarget) { + return R3.COMPONENT_D3_RENDERTARGET; + } + + if (component instanceof R3.D3.API.Raycaster) { + return R3.COMPONENT_D3_RAYCASTER; + } + + if (component instanceof R3.D3.API.RaycastWheel) { + return R3.COMPONENT_D3_RAYCASTWHEEL; + } + + if (component instanceof R3.D3.API.RaycastVehicle) { + return R3.COMPONENT_D3_RAYCASTVEHICLE; + } + + if (component instanceof R3.D3.API.Physics.World) { + return R3.COMPONENT_D3_PHYSICS_WORLD; + } + + if (component instanceof R3.D3.API.Pass.Render.SSAO) { + return R3.COMPONENT_D3_PASS_RENDER_SSAO; + } + + if (component instanceof R3.D3.API.Pass.Render) { + return R3.COMPONENT_D3_PASS_RENDER; + } + + if (component instanceof R3.D3.API.Pass.FXAA) { + return R3.COMPONENT_D3_PASS_FXAA; + } + + if (component instanceof R3.D3.API.Pass.Copy) { + return R3.COMPONENT_D3_PASS_COPY; + } + + if (component instanceof R3.D3.API.Pass.Bloom) { + return R3.COMPONENT_D3_PASS_BLOOM; + } + + if (component instanceof R3.D3.API.Pass) { + return R3.COMPONENT_D3_PASS; + } + + if (component instanceof R3.D3.API.Particle.Engine) { + return R3.COMPONENT_D3_PARTICLE_ENGINE; + } + + if (component instanceof R3.D3.API.Particle) { + return R3.COMPONENT_D3_PARTICLE; + } + + if (component instanceof R3.D3.API.Mesh.Skeleton) { + return R3.COMPONENT_D3_MESH_SKELETON; + } + + if (component instanceof R3.D3.API.Mesh) { + return R3.COMPONENT_D3_MESH; + } + + if (component instanceof R3.D3.API.Material.Standard) { + return R3.COMPONENT_D3_MATERIAL_STANDARD; + } + + if (component instanceof R3.D3.API.Material.Shader.Raw) { + return R3.COMPONENT_D3_MATERIAL_SHADER_RAW; + } + + if (component instanceof R3.D3.API.Material.Shader) { + return R3.COMPONENT_D3_MATERIAL_SHADER; + } + + if (component instanceof R3.D3.API.Material.Points) { + return R3.COMPONENT_D3_MATERIAL_POINTS; + } + + if (component instanceof R3.D3.API.Material.Phong) { + return R3.COMPONENT_D3_MATERIAL_PHONG; + } + + if (component instanceof R3.D3.API.Material.Basic) { + return R3.COMPONENT_D3_MATERIAL_BASIC; + } + + if (component instanceof R3.D3.API.Material) { + return R3.COMPONENT_D3_MATERIAL; + } + + if (component instanceof R3.D3.API.Light.Spot) { + return R3.COMPONENT_D3_LIGHT_SPOT; + } + + if (component instanceof R3.D3.API.Light.RectArea) { + return R3.COMPONENT_D3_LIGHT_RECTAREA; + } + + if (component instanceof R3.D3.API.Light.Point) { + return R3.COMPONENT_D3_LIGHT_POINT; + } + + if (component instanceof R3.D3.API.Light.Hemisphere) { + return R3.COMPONENT_D3_LIGHT_HEMISPHERE; + } + + if (component instanceof R3.D3.API.Light.Directional) { + return R3.COMPONENT_D3_LIGHT_DIRECTIONAL; + } + + if (component instanceof R3.D3.API.Light.Ambient) { + return R3.COMPONENT_D3_LIGHT_AMBIENT; + } + + if (component instanceof R3.D3.API.Light) { + return R3.COMPONENT_D3_LIGHT; + } + + if (component instanceof R3.D3.API.Helper) { + return R3.COMPONENT_D3_HELPER; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Wireframe) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Tube) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.TorusKnot) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Torus) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Text) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Tetrahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Sphere) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Shape) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Ring) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_RING; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Polyhedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Plane) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Parametric) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Octahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Lathe) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Icosahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Extrude) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Edges) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Dodecahedron) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Cylinder) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Cone) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Circle) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE; + } + + if (component instanceof R3.D3.API.Geometry.Normal.Box) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX; + } + + if (component instanceof R3.D3.API.Geometry.Normal) { + return R3.COMPONENT_D3_GEOMETRY_NORMAL; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Tube) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.TorusKnot) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Torus) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Text) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Tetrahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Sphere) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Shape) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Ring) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_RING; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Polyhedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Plane) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Parametric) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Octahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Lathe) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Instanced) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Icosahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Extrude) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Dodecahedron) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Cylinder) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Cone) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Circle) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE; + } + + if (component instanceof R3.D3.API.Geometry.Buffer.Box) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX; + } + + if (component instanceof R3.D3.API.Geometry.Buffer) { + return R3.COMPONENT_D3_GEOMETRY_BUFFER; + } + + if (component instanceof R3.D3.API.Geometry) { + return R3.COMPONENT_D3_GEOMETRY; + } + + if (component instanceof R3.D3.API.FrictionMaterial) { + return R3.COMPONENT_D3_FRICTIONMATERIAL; + } + + if (component instanceof R3.D3.API.FrictionContactMaterial) { + return R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL; + } + + if (component instanceof R3.D3.API.Fog.Normal) { + return R3.COMPONENT_D3_FOG_NORMAL; + } + + if (component instanceof R3.D3.API.Fog.Exp) { + return R3.COMPONENT_D3_FOG_EXP; + } + + if (component instanceof R3.D3.API.Fog) { + return R3.COMPONENT_D3_FOG; + } + + if (component instanceof R3.D3.API.Face.Graphics) { + return R3.COMPONENT_D3_FACE_GRAPHICS; + } + + if (component instanceof R3.D3.API.Face) { + return R3.COMPONENT_D3_FACE; + } + + if (component instanceof R3.D3.API.Effect.Stereo) { + return R3.COMPONENT_D3_EFFECT_STEREO; + } + + if (component instanceof R3.D3.API.Effect.Parallax) { + return R3.COMPONENT_D3_EFFECT_PARALLAX; + } + + if (component instanceof R3.D3.API.Effect.Anaglyph) { + return R3.COMPONENT_D3_EFFECT_ANAGLYPH; + } + + if (component instanceof R3.D3.API.Effect) { + return R3.COMPONENT_D3_EFFECT; + } + + if (component instanceof R3.D3.API.Composer) { + return R3.COMPONENT_D3_COMPOSER; + } + + if (component instanceof R3.D3.API.Camera.Perspective.Stereo) { + return R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO; + } + + if (component instanceof R3.D3.API.Camera.Perspective) { + return R3.COMPONENT_D3_CAMERA_PERSPECTIVE; + } + + if (component instanceof R3.D3.API.Camera.Orthographic.ScaledAspect) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT; + } + + if (component instanceof R3.D3.API.Camera.Orthographic.FixedAspect) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT; + } + + if (component instanceof R3.D3.API.Camera.Orthographic) { + return R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC; + } + + if (component instanceof R3.D3.API.Camera.Cube) { + return R3.COMPONENT_D3_CAMERA_CUBE; + } + + if (component instanceof R3.D3.API.Camera) { + return R3.COMPONENT_D3_CAMERA; + } + + if (component instanceof R3.D3.API.Broadphase) { + return R3.COMPONENT_D3_BROADPHASE; + } + + if (component instanceof R3.D3.API.BoneWeight) { + return R3.COMPONENT_D3_BONEWEIGHT; + } + + if (component instanceof R3.D3.API.Bone) { + return R3.COMPONENT_D3_BONE; + } + + if (component instanceof R3.D3.API.Audio) { + return R3.COMPONENT_D3_AUDIO; + } + + if (component instanceof R3.D3.API.Animation) { + return R3.COMPONENT_D3_ANIMATION; + } + + if (component instanceof R3.D3.API.Object) { + return R3.COMPONENT_D3_OBJECT; + } + + if (component instanceof R3.CustomCode) { + return R3.COMPONENT_CUSTOMCODE; + } + + if (component instanceof R3.Curve.Path.D2.Shape) { + return R3.COMPONENT_CURVE_PATH_D2_SHAPE; + } + + if (component instanceof R3.Curve.Path.D2) { + return R3.COMPONENT_CURVE_PATH_D2; + } + + if (component instanceof R3.Curve.Path) { + return R3.COMPONENT_CURVE_PATH; + } + + if (component instanceof R3.Curve) { + return R3.COMPONENT_CURVE; + } + + if (component instanceof R3.Controls.Touch) { + return R3.COMPONENT_CONTROLS_TOUCH; + } + + if (component instanceof R3.Controls.Mouse) { + return R3.COMPONENT_CONTROLS_MOUSE; + } + + if (component instanceof R3.Controls.Keyboard) { + return R3.COMPONENT_CONTROLS_KEYBOARD; + } + + if (component instanceof R3.Controls.D3.Orbit) { + return R3.COMPONENT_CONTROLS_D3_ORBIT; + } + + if (component instanceof R3.Controls.D3.FirstPerson) { + return R3.COMPONENT_CONTROLS_D3_FIRSTPERSON; + } + + if (component instanceof R3.Controls.D3.Editor) { + return R3.COMPONENT_CONTROLS_D3_EDITOR; + } + + if (component instanceof R3.Controls.D3) { + return R3.COMPONENT_CONTROLS_D3; + } + + if (component instanceof R3.Controls) { + return R3.COMPONENT_CONTROLS; + } + + if (component instanceof R3.Color) { + return R3.COMPONENT_COLOR; + } + + if (component instanceof R3.Clock) { + return R3.COMPONENT_CLOCK; + } + + if (component instanceof R3.Canvas) { + return R3.COMPONENT_CANVAS; + } + + if (component instanceof R3.Box3) { + return R3.COMPONENT_BOX3; + } + + if (component instanceof R3.API.Video) { + return R3.COMPONENT_VIDEO; + } + + if (component instanceof R3.API.Vector4) { + return R3.COMPONENT_VECTOR4; + } + + if (component instanceof R3.API.Vector3) { + return R3.COMPONENT_VECTOR3; + } + + if (component instanceof R3.API.Vector2) { + return R3.COMPONENT_VECTOR2; + } + + if (component instanceof R3.API.User) { + return R3.COMPONENT_USER; + } + + if (component instanceof R3.API.Stats) { + return R3.COMPONENT_STATS; + } + + if (component instanceof R3.API.Sphere) { + return R3.COMPONENT_SPHERE; + } + + if (component instanceof R3.API.Socket.Receive) { + return R3.COMPONENT_SOCKET_RECEIVE; + } + + if (component instanceof R3.API.Socket.Cast) { + return R3.COMPONENT_SOCKET_CAST; + } + + if (component instanceof R3.API.Socket) { + return R3.COMPONENT_SOCKET; + } + + if (component instanceof R3.API.Server) { + return R3.COMPONENT_SERVER; + } + + if (component instanceof R3.API.Renderer.D3.Canvas.Target) { + return R3.COMPONENT_RENDERER_D3_CANVAS_TARGET; + } + + if (component instanceof R3.API.Renderer.D3.Canvas) { + return R3.COMPONENT_RENDERER_D3_CANVAS; + } + + if (component instanceof R3.API.Renderer.D3) { + return R3.COMPONENT_RENDERER_D3; + } + + if (component instanceof R3.API.Renderer.D2) { + return R3.COMPONENT_RENDERER_D2; + } + + if (component instanceof R3.API.Renderer) { + return R3.COMPONENT_RENDERER; + } + + if (component instanceof R3.API.Query.Alerts.Timeseries) { + return R3.COMPONENT_QUERY_ALERTS_TIMESERIES; + } + + if (component instanceof R3.API.Query.Alerts.Summary) { + return R3.COMPONENT_QUERY_ALERTS_SUMMARY; + } + + if (component instanceof R3.API.Query.Alerts.List) { + return R3.COMPONENT_QUERY_ALERTS_LIST; + } + + if (component instanceof R3.API.Query.Alerts.Buckets) { + return R3.COMPONENT_QUERY_ALERTS_BUCKETS; + } + + if (component instanceof R3.API.Query.Alerts) { + return R3.COMPONENT_QUERY_ALERTS; + } + + if (component instanceof R3.API.Query) { + return R3.COMPONENT_QUERY; + } + + if (component instanceof R3.API.Quaternion.Points) { + return R3.COMPONENT_QUATERNION_POINTS; + } + + if (component instanceof R3.API.Quaternion) { + return R3.COMPONENT_QUATERNION; + } + + if (component instanceof R3.API.Project) { + return R3.COMPONENT_PROJECT; + } + + if (component instanceof R3.API.Plane) { + return R3.COMPONENT_PLANE; + } + + if (component instanceof R3.API.Mouse) { + return R3.COMPONENT_MOUSE; + } + + if (component instanceof R3.API.Matrix4) { + return R3.COMPONENT_MATRIX4; + } + + if (component instanceof R3.API.Image) { + return R3.COMPONENT_IMAGE; + } + + if (component instanceof R3.API.GUI) { + return R3.COMPONENT_GUI; + } + + if (component instanceof R3.API.Group) { + return R3.COMPONENT_GROUP; + } + + if (component instanceof R3.API.Graph.Table) { + return R3.COMPONENT_GRAPH_TABLE; + } + + if (component instanceof R3.API.Graph.Metric) { + return R3.COMPONENT_GRAPH_METRIC; + } + + if (component instanceof R3.API.Graph.Barchart.Stacked) { + return R3.COMPONENT_GRAPH_BARCHART_STACKED; + } + + if (component instanceof R3.API.Graph.Barchart) { + return R3.COMPONENT_GRAPH_BARCHART; + } + + if (component instanceof R3.API.Graph) { + return R3.COMPONENT_GRAPH; + } + + if (component instanceof R3.API.Font) { + return R3.COMPONENT_FONT; + } + + if (component instanceof R3.API.EntityManager) { + return R3.COMPONENT_ENTITYMANAGER; + } + + if (component instanceof R3.API.Entity) { + return R3.COMPONENT_ENTITY; + } + + if (component instanceof R3.API.DrawRange) { + return R3.COMPONENT_DRAWRANGE; + } + + if (component instanceof R3.API.DomElement) { + return R3.COMPONENT_DOMELEMENT; + } + + if (component instanceof R3.API.CustomCode) { + return R3.COMPONENT_CUSTOMCODE; + } + + if (component instanceof R3.API.Curve.Path.D2.Shape) { + return R3.COMPONENT_CURVE_PATH_D2_SHAPE; + } + + if (component instanceof R3.API.Curve.Path.D2) { + return R3.COMPONENT_CURVE_PATH_D2; + } + + if (component instanceof R3.API.Curve.Path) { + return R3.COMPONENT_CURVE_PATH; + } + + if (component instanceof R3.API.Curve) { + return R3.COMPONENT_CURVE; + } + + if (component instanceof R3.API.Controls.Touch) { + return R3.COMPONENT_CONTROLS_TOUCH; + } + + if (component instanceof R3.API.Controls.Mouse) { + return R3.COMPONENT_CONTROLS_MOUSE; + } + + if (component instanceof R3.API.Controls.Keyboard) { + return R3.COMPONENT_CONTROLS_KEYBOARD; + } + + if (component instanceof R3.API.Controls.D3.Orbit) { + return R3.COMPONENT_CONTROLS_D3_ORBIT; + } + + if (component instanceof R3.API.Controls.D3.FirstPerson) { + return R3.COMPONENT_CONTROLS_D3_FIRSTPERSON; + } + + if (component instanceof R3.API.Controls.D3.Editor) { + return R3.COMPONENT_CONTROLS_D3_EDITOR; + } + + if (component instanceof R3.API.Controls.D3) { + return R3.COMPONENT_CONTROLS_D3; + } + + if (component instanceof R3.API.Controls) { + return R3.COMPONENT_CONTROLS; + } + + if (component instanceof R3.API.Color) { + return R3.COMPONENT_COLOR; + } + + if (component instanceof R3.API.Clock) { + return R3.COMPONENT_CLOCK; + } + + if (component instanceof R3.API.Canvas) { + return R3.COMPONENT_CANVAS; + } + + if (component instanceof R3.API.Box3) { + return R3.COMPONENT_BOX3; + } + +}; + +R3.GetComponentInfo = function(componentType) { + + switch (componentType) { + + case R3.COMPONENT_VIDEO : return { + name : 'R3.Video', + constructor : R3.Video, + apiConstructor : R3.API.Video, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_VECTOR4 : return { + name : 'R3.Vector4', + constructor : R3.Vector4, + apiConstructor : R3.API.Vector4, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_VECTOR3 : return { + name : 'R3.Vector3', + constructor : R3.Vector3, + apiConstructor : R3.API.Vector3, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_VECTOR2 : return { + name : 'R3.Vector2', + constructor : R3.Vector2, + apiConstructor : R3.API.Vector2, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_USER : return { + name : 'R3.User', + constructor : R3.User, + apiConstructor : R3.API.User, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_STATS : return { + name : 'R3.Stats', + constructor : R3.Stats, + apiConstructor : R3.API.Stats, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_SPHERE : return { + name : 'R3.Sphere', + constructor : R3.Sphere, + apiConstructor : R3.API.Sphere, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_SOCKET_RECEIVE : return { + name : 'R3.Socket.Receive', + constructor : R3.Socket.Receive, + apiConstructor : R3.API.Socket.Receive, + runtime: R3.Runtime.SOCKETS + }; + case R3.COMPONENT_SOCKET_CAST : return { + name : 'R3.Socket.Cast', + constructor : R3.Socket.Cast, + apiConstructor : R3.API.Socket.Cast, + runtime: R3.Runtime.SOCKETS + }; + case R3.COMPONENT_SOCKET : return { + name : 'R3.Socket', + constructor : R3.Socket, + apiConstructor : R3.API.Socket, + runtime: R3.Runtime.SOCKETS + }; + case R3.COMPONENT_SERVER : return { + name : 'R3.Server', + constructor : R3.Server, + apiConstructor : R3.API.Server, + runtime: R3.Runtime.SOCKETS + }; + case R3.COMPONENT_RENDERER_D3_CANVAS_TARGET : return { + name : 'R3.Renderer.D3.Canvas.Target', + constructor : R3.Renderer.D3.Canvas.Target, + apiConstructor : R3.API.Renderer.D3.Canvas.Target, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_RENDERER_D3_CANVAS : return { + name : 'R3.Renderer.D3.Canvas', + constructor : R3.Renderer.D3.Canvas, + apiConstructor : R3.API.Renderer.D3.Canvas, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_RENDERER_D3 : return { + name : 'R3.Renderer.D3', + constructor : R3.Renderer.D3, + apiConstructor : R3.API.Renderer.D3, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_RENDERER_D2 : return { + name : 'R3.Renderer.D2', + constructor : R3.Renderer.D2, + apiConstructor : R3.API.Renderer.D2, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_RENDERER : return { + name : 'R3.Renderer', + constructor : R3.Renderer, + apiConstructor : R3.API.Renderer, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_QUERY_ALERTS_TIMESERIES : return { + name : 'R3.Query.Alerts.Timeseries', + constructor : R3.Query.Alerts.Timeseries, + apiConstructor : R3.API.Query.Alerts.Timeseries, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_SUMMARY : return { + name : 'R3.Query.Alerts.Summary', + constructor : R3.Query.Alerts.Summary, + apiConstructor : R3.API.Query.Alerts.Summary, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_LIST : return { + name : 'R3.Query.Alerts.List', + constructor : R3.Query.Alerts.List, + apiConstructor : R3.API.Query.Alerts.List, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_BUCKETS : return { + name : 'R3.Query.Alerts.Buckets', + constructor : R3.Query.Alerts.Buckets, + apiConstructor : R3.API.Query.Alerts.Buckets, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS : return { + name : 'R3.Query.Alerts', + constructor : R3.Query.Alerts, + apiConstructor : R3.API.Query.Alerts, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY : return { + name : 'R3.Query', + constructor : R3.Query, + apiConstructor : R3.API.Query, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUATERNION_POINTS : return { + name : 'R3.Quaternion.Points', + constructor : R3.Quaternion.Points, + apiConstructor : R3.API.Quaternion.Points, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUATERNION : return { + name : 'R3.Quaternion', + constructor : R3.Quaternion, + apiConstructor : R3.API.Quaternion, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_PROJECT : return { + name : 'R3.Project', + constructor : R3.Project, + apiConstructor : R3.API.Project, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_PLANE : return { + name : 'R3.Plane', + constructor : R3.Plane, + apiConstructor : R3.API.Plane, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_MOUSE : return { + name : 'R3.Mouse', + constructor : R3.Mouse, + apiConstructor : R3.API.Mouse, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_MATRIX4 : return { + name : 'R3.Matrix4', + constructor : R3.Matrix4, + apiConstructor : R3.API.Matrix4, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_IMAGE : return { + name : 'R3.Image', + constructor : R3.Image, + apiConstructor : R3.API.Image, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_GUI : return { + name : 'R3.GUI', + constructor : R3.GUI, + apiConstructor : R3.API.GUI, + runtime: R3.Runtime.GUI + }; + case R3.COMPONENT_GROUP : return { + name : 'R3.Group', + constructor : R3.Group, + apiConstructor : R3.API.Group, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_GRAPH_TABLE : return { + name : 'R3.Graph.Table', + constructor : R3.Graph.Table, + apiConstructor : R3.API.Graph.Table, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_GRAPH_METRIC : return { + name : 'R3.Graph.Metric', + constructor : R3.Graph.Metric, + apiConstructor : R3.API.Graph.Metric, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_GRAPH_BARCHART_STACKED : return { + name : 'R3.Graph.Barchart.Stacked', + constructor : R3.Graph.Barchart.Stacked, + apiConstructor : R3.API.Graph.Barchart.Stacked, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_GRAPH_BARCHART : return { + name : 'R3.Graph.Barchart', + constructor : R3.Graph.Barchart, + apiConstructor : R3.API.Graph.Barchart, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_GRAPH : return { + name : 'R3.Graph', + constructor : R3.Graph, + apiConstructor : R3.API.Graph, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_FONT : return { + name : 'R3.Font', + constructor : R3.Font, + apiConstructor : R3.API.Font, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_ENTITYMANAGER : return { + name : 'R3.EntityManager', + constructor : R3.EntityManager, + apiConstructor : R3.API.EntityManager, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_ENTITY : return { + name : 'R3.Entity', + constructor : R3.Entity, + apiConstructor : R3.API.Entity, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_DRAWRANGE : return { + name : 'R3.DrawRange', + constructor : R3.DrawRange, + apiConstructor : R3.API.DrawRange, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_DOMELEMENT : return { + name : 'R3.DomElement', + constructor : R3.DomElement, + apiConstructor : R3.API.DomElement, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT : return { + name : 'R3.D3.Viewport.ZoomedAspect', + constructor : R3.D3.Viewport.ZoomedAspect, + apiConstructor : R3.D3.API.Viewport.ZoomedAspect, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT : return { + name : 'R3.D3.Viewport.FixedAspect', + constructor : R3.D3.Viewport.FixedAspect, + apiConstructor : R3.D3.API.Viewport.FixedAspect, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_VIEWPORT : return { + name : 'R3.D3.Viewport', + constructor : R3.D3.Viewport, + apiConstructor : R3.D3.API.Viewport, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_VERTEX : return { + name : 'R3.D3.Vertex', + constructor : R3.D3.Vertex, + apiConstructor : R3.D3.API.Vertex, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_TEXTURE_IMAGE : return { + name : 'R3.D3.Texture.Image', + constructor : R3.D3.Texture.Image, + apiConstructor : R3.D3.API.Texture.Image, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_TEXTURE_CUBE : return { + name : 'R3.D3.Texture.Cube', + constructor : R3.D3.Texture.Cube, + apiConstructor : R3.D3.API.Texture.Cube, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_TEXTURE_CANVAS : return { + name : 'R3.D3.Texture.Canvas', + constructor : R3.D3.Texture.Canvas, + apiConstructor : R3.D3.API.Texture.Canvas, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_TEXTURE : return { + name : 'R3.D3.Texture', + constructor : R3.D3.Texture, + apiConstructor : R3.D3.API.Texture, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_TEXT : return { + name : 'R3.D3.Text', + constructor : R3.D3.Text, + apiConstructor : R3.D3.API.Text, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SPLINE : return { + name : 'R3.D3.Spline', + constructor : R3.D3.Spline, + apiConstructor : R3.D3.API.Spline, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_SOLVER : return { + name : 'R3.D3.Solver', + constructor : R3.D3.Solver, + apiConstructor : R3.D3.API.Solver, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SKELETON : return { + name : 'R3.D3.Skeleton', + constructor : R3.D3.Skeleton, + apiConstructor : R3.D3.API.Skeleton, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHAPE_TRIMESH : return { + name : 'R3.D3.Shape.TriMesh', + constructor : R3.D3.Shape.TriMesh, + apiConstructor : R3.D3.API.Shape.TriMesh, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_SPHERE : return { + name : 'R3.D3.Shape.Sphere', + constructor : R3.D3.Shape.Sphere, + apiConstructor : R3.D3.API.Shape.Sphere, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_PLANE : return { + name : 'R3.D3.Shape.Plane', + constructor : R3.D3.Shape.Plane, + apiConstructor : R3.D3.API.Shape.Plane, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_HEIGHTMAP : return { + name : 'R3.D3.Shape.HeightMap', + constructor : R3.D3.Shape.HeightMap, + apiConstructor : R3.D3.API.Shape.HeightMap, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER : return { + name : 'R3.D3.Shape.ConvexHull.Cylinder', + constructor : R3.D3.Shape.ConvexHull.Cylinder, + apiConstructor : R3.D3.API.Shape.ConvexHull.Cylinder, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_CONVEXHULL : return { + name : 'R3.D3.Shape.ConvexHull', + constructor : R3.D3.Shape.ConvexHull, + apiConstructor : R3.D3.API.Shape.ConvexHull, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE_BOX : return { + name : 'R3.D3.Shape.Box', + constructor : R3.D3.Shape.Box, + apiConstructor : R3.D3.API.Shape.Box, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHAPE : return { + name : 'R3.D3.Shape', + constructor : R3.D3.Shape, + apiConstructor : R3.D3.API.Shape, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_SHADOW_SPOT : return { + name : 'R3.D3.Shadow.Spot', + constructor : R3.D3.Shadow.Spot, + apiConstructor : R3.D3.API.Shadow.Spot, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHADOW_DIRECTIONAL : return { + name : 'R3.D3.Shadow.Directional', + constructor : R3.D3.Shadow.Directional, + apiConstructor : R3.D3.API.Shadow.Directional, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHADOW : return { + name : 'R3.D3.Shadow', + constructor : R3.D3.Shadow, + apiConstructor : R3.D3.API.Shadow, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHADER_VERTEX : return { + name : 'R3.D3.Shader.Vertex', + constructor : R3.D3.Shader.Vertex, + apiConstructor : R3.D3.API.Shader.Vertex, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHADER_FRAGMENT : return { + name : 'R3.D3.Shader.Fragment', + constructor : R3.D3.Shader.Fragment, + apiConstructor : R3.D3.API.Shader.Fragment, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SHADER : return { + name : 'R3.D3.Shader', + constructor : R3.D3.Shader, + apiConstructor : R3.D3.API.Shader, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_SCENE : return { + name : 'R3.D3.Scene', + constructor : R3.D3.Scene, + apiConstructor : R3.D3.API.Scene, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_RIGIDBODY : return { + name : 'R3.D3.RigidBody', + constructor : R3.D3.RigidBody, + apiConstructor : R3.D3.API.RigidBody, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_RENDERTARGET_CUBE : return { + name : 'R3.D3.RenderTarget.Cube', + constructor : R3.D3.RenderTarget.Cube, + apiConstructor : R3.D3.API.RenderTarget.Cube, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_RENDERTARGET : return { + name : 'R3.D3.RenderTarget', + constructor : R3.D3.RenderTarget, + apiConstructor : R3.D3.API.RenderTarget, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_RAYCASTER : return { + name : 'R3.D3.Raycaster', + constructor : R3.D3.Raycaster, + apiConstructor : R3.D3.API.Raycaster, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_RAYCASTWHEEL : return { + name : 'R3.D3.RaycastWheel', + constructor : R3.D3.RaycastWheel, + apiConstructor : R3.D3.API.RaycastWheel, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_RAYCASTVEHICLE : return { + name : 'R3.D3.RaycastVehicle', + constructor : R3.D3.RaycastVehicle, + apiConstructor : R3.D3.API.RaycastVehicle, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_PHYSICS_WORLD : return { + name : 'R3.D3.Physics.World', + constructor : R3.D3.Physics.World, + apiConstructor : R3.D3.API.Physics.World, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_PASS_RENDER_SSAO : return { + name : 'R3.D3.Pass.Render.SSAO', + constructor : R3.D3.Pass.Render.SSAO, + apiConstructor : R3.D3.API.Pass.Render.SSAO, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PASS_RENDER : return { + name : 'R3.D3.Pass.Render', + constructor : R3.D3.Pass.Render, + apiConstructor : R3.D3.API.Pass.Render, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PASS_FXAA : return { + name : 'R3.D3.Pass.FXAA', + constructor : R3.D3.Pass.FXAA, + apiConstructor : R3.D3.API.Pass.FXAA, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PASS_COPY : return { + name : 'R3.D3.Pass.Copy', + constructor : R3.D3.Pass.Copy, + apiConstructor : R3.D3.API.Pass.Copy, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PASS_BLOOM : return { + name : 'R3.D3.Pass.Bloom', + constructor : R3.D3.Pass.Bloom, + apiConstructor : R3.D3.API.Pass.Bloom, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PASS : return { + name : 'R3.D3.Pass', + constructor : R3.D3.Pass, + apiConstructor : R3.D3.API.Pass, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PARTICLE_ENGINE : return { + name : 'R3.D3.Particle.Engine', + constructor : R3.D3.Particle.Engine, + apiConstructor : R3.D3.API.Particle.Engine, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_PARTICLE : return { + name : 'R3.D3.Particle', + constructor : R3.D3.Particle, + apiConstructor : R3.D3.API.Particle, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MESH_SKELETON : return { + name : 'R3.D3.Mesh.Skeleton', + constructor : R3.D3.Mesh.Skeleton, + apiConstructor : R3.D3.API.Mesh.Skeleton, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MESH : return { + name : 'R3.D3.Mesh', + constructor : R3.D3.Mesh, + apiConstructor : R3.D3.API.Mesh, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_STANDARD : return { + name : 'R3.D3.Material.Standard', + constructor : R3.D3.Material.Standard, + apiConstructor : R3.D3.API.Material.Standard, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_SHADER_RAW : return { + name : 'R3.D3.Material.Shader.Raw', + constructor : R3.D3.Material.Shader.Raw, + apiConstructor : R3.D3.API.Material.Shader.Raw, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_SHADER : return { + name : 'R3.D3.Material.Shader', + constructor : R3.D3.Material.Shader, + apiConstructor : R3.D3.API.Material.Shader, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_POINTS : return { + name : 'R3.D3.Material.Points', + constructor : R3.D3.Material.Points, + apiConstructor : R3.D3.API.Material.Points, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_PHONG : return { + name : 'R3.D3.Material.Phong', + constructor : R3.D3.Material.Phong, + apiConstructor : R3.D3.API.Material.Phong, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL_BASIC : return { + name : 'R3.D3.Material.Basic', + constructor : R3.D3.Material.Basic, + apiConstructor : R3.D3.API.Material.Basic, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MATERIAL : return { + name : 'R3.D3.Material', + constructor : R3.D3.Material, + apiConstructor : R3.D3.API.Material, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_SPOT : return { + name : 'R3.D3.Light.Spot', + constructor : R3.D3.Light.Spot, + apiConstructor : R3.D3.API.Light.Spot, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_RECTAREA : return { + name : 'R3.D3.Light.RectArea', + constructor : R3.D3.Light.RectArea, + apiConstructor : R3.D3.API.Light.RectArea, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_POINT : return { + name : 'R3.D3.Light.Point', + constructor : R3.D3.Light.Point, + apiConstructor : R3.D3.API.Light.Point, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_HEMISPHERE : return { + name : 'R3.D3.Light.Hemisphere', + constructor : R3.D3.Light.Hemisphere, + apiConstructor : R3.D3.API.Light.Hemisphere, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_DIRECTIONAL : return { + name : 'R3.D3.Light.Directional', + constructor : R3.D3.Light.Directional, + apiConstructor : R3.D3.API.Light.Directional, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT_AMBIENT : return { + name : 'R3.D3.Light.Ambient', + constructor : R3.D3.Light.Ambient, + apiConstructor : R3.D3.API.Light.Ambient, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_LIGHT : return { + name : 'R3.D3.Light', + constructor : R3.D3.Light, + apiConstructor : R3.D3.API.Light, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_HELPER : return { + name : 'R3.D3.Helper', + constructor : R3.D3.Helper, + apiConstructor : R3.D3.API.Helper, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME : return { + name : 'R3.D3.Geometry.Normal.Wireframe', + constructor : R3.D3.Geometry.Normal.Wireframe, + apiConstructor : R3.D3.API.Geometry.Normal.Wireframe, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE : return { + name : 'R3.D3.Geometry.Normal.Tube', + constructor : R3.D3.Geometry.Normal.Tube, + apiConstructor : R3.D3.API.Geometry.Normal.Tube, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT : return { + name : 'R3.D3.Geometry.Normal.TorusKnot', + constructor : R3.D3.Geometry.Normal.TorusKnot, + apiConstructor : R3.D3.API.Geometry.Normal.TorusKnot, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS : return { + name : 'R3.D3.Geometry.Normal.Torus', + constructor : R3.D3.Geometry.Normal.Torus, + apiConstructor : R3.D3.API.Geometry.Normal.Torus, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT : return { + name : 'R3.D3.Geometry.Normal.Text', + constructor : R3.D3.Geometry.Normal.Text, + apiConstructor : R3.D3.API.Geometry.Normal.Text, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON : return { + name : 'R3.D3.Geometry.Normal.Tetrahedron', + constructor : R3.D3.Geometry.Normal.Tetrahedron, + apiConstructor : R3.D3.API.Geometry.Normal.Tetrahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE : return { + name : 'R3.D3.Geometry.Normal.Sphere', + constructor : R3.D3.Geometry.Normal.Sphere, + apiConstructor : R3.D3.API.Geometry.Normal.Sphere, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE : return { + name : 'R3.D3.Geometry.Normal.Shape', + constructor : R3.D3.Geometry.Normal.Shape, + apiConstructor : R3.D3.API.Geometry.Normal.Shape, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_RING : return { + name : 'R3.D3.Geometry.Normal.Ring', + constructor : R3.D3.Geometry.Normal.Ring, + apiConstructor : R3.D3.API.Geometry.Normal.Ring, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON : return { + name : 'R3.D3.Geometry.Normal.Polyhedron', + constructor : R3.D3.Geometry.Normal.Polyhedron, + apiConstructor : R3.D3.API.Geometry.Normal.Polyhedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE : return { + name : 'R3.D3.Geometry.Normal.Plane', + constructor : R3.D3.Geometry.Normal.Plane, + apiConstructor : R3.D3.API.Geometry.Normal.Plane, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC : return { + name : 'R3.D3.Geometry.Normal.Parametric', + constructor : R3.D3.Geometry.Normal.Parametric, + apiConstructor : R3.D3.API.Geometry.Normal.Parametric, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON : return { + name : 'R3.D3.Geometry.Normal.Octahedron', + constructor : R3.D3.Geometry.Normal.Octahedron, + apiConstructor : R3.D3.API.Geometry.Normal.Octahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE : return { + name : 'R3.D3.Geometry.Normal.Lathe', + constructor : R3.D3.Geometry.Normal.Lathe, + apiConstructor : R3.D3.API.Geometry.Normal.Lathe, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON : return { + name : 'R3.D3.Geometry.Normal.Icosahedron', + constructor : R3.D3.Geometry.Normal.Icosahedron, + apiConstructor : R3.D3.API.Geometry.Normal.Icosahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE : return { + name : 'R3.D3.Geometry.Normal.Extrude', + constructor : R3.D3.Geometry.Normal.Extrude, + apiConstructor : R3.D3.API.Geometry.Normal.Extrude, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES : return { + name : 'R3.D3.Geometry.Normal.Edges', + constructor : R3.D3.Geometry.Normal.Edges, + apiConstructor : R3.D3.API.Geometry.Normal.Edges, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON : return { + name : 'R3.D3.Geometry.Normal.Dodecahedron', + constructor : R3.D3.Geometry.Normal.Dodecahedron, + apiConstructor : R3.D3.API.Geometry.Normal.Dodecahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER : return { + name : 'R3.D3.Geometry.Normal.Cylinder', + constructor : R3.D3.Geometry.Normal.Cylinder, + apiConstructor : R3.D3.API.Geometry.Normal.Cylinder, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE : return { + name : 'R3.D3.Geometry.Normal.Cone', + constructor : R3.D3.Geometry.Normal.Cone, + apiConstructor : R3.D3.API.Geometry.Normal.Cone, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE : return { + name : 'R3.D3.Geometry.Normal.Circle', + constructor : R3.D3.Geometry.Normal.Circle, + apiConstructor : R3.D3.API.Geometry.Normal.Circle, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX : return { + name : 'R3.D3.Geometry.Normal.Box', + constructor : R3.D3.Geometry.Normal.Box, + apiConstructor : R3.D3.API.Geometry.Normal.Box, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_NORMAL : return { + name : 'R3.D3.Geometry.Normal', + constructor : R3.D3.Geometry.Normal, + apiConstructor : R3.D3.API.Geometry.Normal, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE : return { + name : 'R3.D3.Geometry.Buffer.Tube', + constructor : R3.D3.Geometry.Buffer.Tube, + apiConstructor : R3.D3.API.Geometry.Buffer.Tube, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT : return { + name : 'R3.D3.Geometry.Buffer.TorusKnot', + constructor : R3.D3.Geometry.Buffer.TorusKnot, + apiConstructor : R3.D3.API.Geometry.Buffer.TorusKnot, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS : return { + name : 'R3.D3.Geometry.Buffer.Torus', + constructor : R3.D3.Geometry.Buffer.Torus, + apiConstructor : R3.D3.API.Geometry.Buffer.Torus, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT : return { + name : 'R3.D3.Geometry.Buffer.Text', + constructor : R3.D3.Geometry.Buffer.Text, + apiConstructor : R3.D3.API.Geometry.Buffer.Text, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON : return { + name : 'R3.D3.Geometry.Buffer.Tetrahedron', + constructor : R3.D3.Geometry.Buffer.Tetrahedron, + apiConstructor : R3.D3.API.Geometry.Buffer.Tetrahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE : return { + name : 'R3.D3.Geometry.Buffer.Sphere', + constructor : R3.D3.Geometry.Buffer.Sphere, + apiConstructor : R3.D3.API.Geometry.Buffer.Sphere, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE : return { + name : 'R3.D3.Geometry.Buffer.Shape', + constructor : R3.D3.Geometry.Buffer.Shape, + apiConstructor : R3.D3.API.Geometry.Buffer.Shape, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_RING : return { + name : 'R3.D3.Geometry.Buffer.Ring', + constructor : R3.D3.Geometry.Buffer.Ring, + apiConstructor : R3.D3.API.Geometry.Buffer.Ring, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON : return { + name : 'R3.D3.Geometry.Buffer.Polyhedron', + constructor : R3.D3.Geometry.Buffer.Polyhedron, + apiConstructor : R3.D3.API.Geometry.Buffer.Polyhedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE : return { + name : 'R3.D3.Geometry.Buffer.Plane', + constructor : R3.D3.Geometry.Buffer.Plane, + apiConstructor : R3.D3.API.Geometry.Buffer.Plane, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC : return { + name : 'R3.D3.Geometry.Buffer.Parametric', + constructor : R3.D3.Geometry.Buffer.Parametric, + apiConstructor : R3.D3.API.Geometry.Buffer.Parametric, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON : return { + name : 'R3.D3.Geometry.Buffer.Octahedron', + constructor : R3.D3.Geometry.Buffer.Octahedron, + apiConstructor : R3.D3.API.Geometry.Buffer.Octahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE : return { + name : 'R3.D3.Geometry.Buffer.Lathe', + constructor : R3.D3.Geometry.Buffer.Lathe, + apiConstructor : R3.D3.API.Geometry.Buffer.Lathe, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED : return { + name : 'R3.D3.Geometry.Buffer.Instanced', + constructor : R3.D3.Geometry.Buffer.Instanced, + apiConstructor : R3.D3.API.Geometry.Buffer.Instanced, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON : return { + name : 'R3.D3.Geometry.Buffer.Icosahedron', + constructor : R3.D3.Geometry.Buffer.Icosahedron, + apiConstructor : R3.D3.API.Geometry.Buffer.Icosahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE : return { + name : 'R3.D3.Geometry.Buffer.Extrude', + constructor : R3.D3.Geometry.Buffer.Extrude, + apiConstructor : R3.D3.API.Geometry.Buffer.Extrude, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON : return { + name : 'R3.D3.Geometry.Buffer.Dodecahedron', + constructor : R3.D3.Geometry.Buffer.Dodecahedron, + apiConstructor : R3.D3.API.Geometry.Buffer.Dodecahedron, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER : return { + name : 'R3.D3.Geometry.Buffer.Cylinder', + constructor : R3.D3.Geometry.Buffer.Cylinder, + apiConstructor : R3.D3.API.Geometry.Buffer.Cylinder, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE : return { + name : 'R3.D3.Geometry.Buffer.Cone', + constructor : R3.D3.Geometry.Buffer.Cone, + apiConstructor : R3.D3.API.Geometry.Buffer.Cone, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE : return { + name : 'R3.D3.Geometry.Buffer.Circle', + constructor : R3.D3.Geometry.Buffer.Circle, + apiConstructor : R3.D3.API.Geometry.Buffer.Circle, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX : return { + name : 'R3.D3.Geometry.Buffer.Box', + constructor : R3.D3.Geometry.Buffer.Box, + apiConstructor : R3.D3.API.Geometry.Buffer.Box, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY_BUFFER : return { + name : 'R3.D3.Geometry.Buffer', + constructor : R3.D3.Geometry.Buffer, + apiConstructor : R3.D3.API.Geometry.Buffer, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_GEOMETRY : return { + name : 'R3.D3.Geometry', + constructor : R3.D3.Geometry, + apiConstructor : R3.D3.API.Geometry, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_FRICTIONMATERIAL : return { + name : 'R3.D3.FrictionMaterial', + constructor : R3.D3.FrictionMaterial, + apiConstructor : R3.D3.API.FrictionMaterial, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL : return { + name : 'R3.D3.FrictionContactMaterial', + constructor : R3.D3.FrictionContactMaterial, + apiConstructor : R3.D3.API.FrictionContactMaterial, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_FOG_NORMAL : return { + name : 'R3.D3.Fog.Normal', + constructor : R3.D3.Fog.Normal, + apiConstructor : R3.D3.API.Fog.Normal, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_FOG_EXP : return { + name : 'R3.D3.Fog.Exp', + constructor : R3.D3.Fog.Exp, + apiConstructor : R3.D3.API.Fog.Exp, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_FOG : return { + name : 'R3.D3.Fog', + constructor : R3.D3.Fog, + apiConstructor : R3.D3.API.Fog, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_FACE_GRAPHICS : return { + name : 'R3.D3.Face.Graphics', + constructor : R3.D3.Face.Graphics, + apiConstructor : R3.D3.API.Face.Graphics, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_FACE : return { + name : 'R3.D3.Face', + constructor : R3.D3.Face, + apiConstructor : R3.D3.API.Face, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_EFFECT_STEREO : return { + name : 'R3.D3.Effect.Stereo', + constructor : R3.D3.Effect.Stereo, + apiConstructor : R3.D3.API.Effect.Stereo, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_EFFECT_PARALLAX : return { + name : 'R3.D3.Effect.Parallax', + constructor : R3.D3.Effect.Parallax, + apiConstructor : R3.D3.API.Effect.Parallax, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_EFFECT_ANAGLYPH : return { + name : 'R3.D3.Effect.Anaglyph', + constructor : R3.D3.Effect.Anaglyph, + apiConstructor : R3.D3.API.Effect.Anaglyph, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_EFFECT : return { + name : 'R3.D3.Effect', + constructor : R3.D3.Effect, + apiConstructor : R3.D3.API.Effect, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_COMPOSER : return { + name : 'R3.D3.Composer', + constructor : R3.D3.Composer, + apiConstructor : R3.D3.API.Composer, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO : return { + name : 'R3.D3.Camera.Perspective.Stereo', + constructor : R3.D3.Camera.Perspective.Stereo, + apiConstructor : R3.D3.API.Camera.Perspective.Stereo, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_PERSPECTIVE : return { + name : 'R3.D3.Camera.Perspective', + constructor : R3.D3.Camera.Perspective, + apiConstructor : R3.D3.API.Camera.Perspective, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT : return { + name : 'R3.D3.Camera.Orthographic.ScaledAspect', + constructor : R3.D3.Camera.Orthographic.ScaledAspect, + apiConstructor : R3.D3.API.Camera.Orthographic.ScaledAspect, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT : return { + name : 'R3.D3.Camera.Orthographic.FixedAspect', + constructor : R3.D3.Camera.Orthographic.FixedAspect, + apiConstructor : R3.D3.API.Camera.Orthographic.FixedAspect, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC : return { + name : 'R3.D3.Camera.Orthographic', + constructor : R3.D3.Camera.Orthographic, + apiConstructor : R3.D3.API.Camera.Orthographic, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA_CUBE : return { + name : 'R3.D3.Camera.Cube', + constructor : R3.D3.Camera.Cube, + apiConstructor : R3.D3.API.Camera.Cube, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_CAMERA : return { + name : 'R3.D3.Camera', + constructor : R3.D3.Camera, + apiConstructor : R3.D3.API.Camera, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_BROADPHASE : return { + name : 'R3.D3.Broadphase', + constructor : R3.D3.Broadphase, + apiConstructor : R3.D3.API.Broadphase, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_D3_BONEWEIGHT : return { + name : 'R3.D3.BoneWeight', + constructor : R3.D3.BoneWeight, + apiConstructor : R3.D3.API.BoneWeight, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_BONE : return { + name : 'R3.D3.Bone', + constructor : R3.D3.Bone, + apiConstructor : R3.D3.API.Bone, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_AUDIO : return { + name : 'R3.D3.Audio', + constructor : R3.D3.Audio, + apiConstructor : R3.D3.API.Audio, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_ANIMATION : return { + name : 'R3.D3.Animation', + constructor : R3.D3.Animation, + apiConstructor : R3.D3.API.Animation, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_D3_OBJECT : return { + name : 'R3.D3.Object', + constructor : R3.D3.Object, + apiConstructor : R3.D3.API.Object, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CUSTOMCODE : return { + name : 'R3.CustomCode', + constructor : R3.CustomCode, + apiConstructor : R3.API.CustomCode, + runtime: R3.Runtime.CODER + }; + case R3.COMPONENT_CURVE_PATH_D2_SHAPE : return { + name : 'R3.Curve.Path.D2.Shape', + constructor : R3.Curve.Path.D2.Shape, + apiConstructor : R3.API.Curve.Path.D2.Shape, + runtime: R3.Runtime.PHYSICS + }; + case R3.COMPONENT_CURVE_PATH_D2 : return { + name : 'R3.Curve.Path.D2', + constructor : R3.Curve.Path.D2, + apiConstructor : R3.API.Curve.Path.D2, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CURVE_PATH : return { + name : 'R3.Curve.Path', + constructor : R3.Curve.Path, + apiConstructor : R3.API.Curve.Path, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CURVE : return { + name : 'R3.Curve', + constructor : R3.Curve, + apiConstructor : R3.API.Curve, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_TOUCH : return { + name : 'R3.Controls.Touch', + constructor : R3.Controls.Touch, + apiConstructor : R3.API.Controls.Touch, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_MOUSE : return { + name : 'R3.Controls.Mouse', + constructor : R3.Controls.Mouse, + apiConstructor : R3.API.Controls.Mouse, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_KEYBOARD : return { + name : 'R3.Controls.Keyboard', + constructor : R3.Controls.Keyboard, + apiConstructor : R3.API.Controls.Keyboard, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_D3_ORBIT : return { + name : 'R3.Controls.D3.Orbit', + constructor : R3.Controls.D3.Orbit, + apiConstructor : R3.API.Controls.D3.Orbit, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_D3_FIRSTPERSON : return { + name : 'R3.Controls.D3.FirstPerson', + constructor : R3.Controls.D3.FirstPerson, + apiConstructor : R3.API.Controls.D3.FirstPerson, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_D3_EDITOR : return { + name : 'R3.Controls.D3.Editor', + constructor : R3.Controls.D3.Editor, + apiConstructor : R3.API.Controls.D3.Editor, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS_D3 : return { + name : 'R3.Controls.D3', + constructor : R3.Controls.D3, + apiConstructor : R3.API.Controls.D3, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CONTROLS : return { + name : 'R3.Controls', + constructor : R3.Controls, + apiConstructor : R3.API.Controls, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_COLOR : return { + name : 'R3.Color', + constructor : R3.Color, + apiConstructor : R3.API.Color, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_CLOCK : return { + name : 'R3.Clock', + constructor : R3.Clock, + apiConstructor : R3.API.Clock, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_CANVAS : return { + name : 'R3.Canvas', + constructor : R3.Canvas, + apiConstructor : R3.API.Canvas, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_BOX3 : return { + name : 'R3.Box3', + constructor : R3.Box3, + apiConstructor : R3.API.Box3, + runtime: R3.Runtime.DEFAULT + }; + default : + throw new Error('Invalid component type: ' + componentType); + + } +}; diff --git a/src/r3-a-1-event.js b/src/r3-a-2-event.js similarity index 64% rename from src/r3-a-1-event.js rename to src/r3-a-2-event.js index 0e9f96e..1e67868 100644 --- a/src/r3-a-1-event.js +++ b/src/r3-a-2-event.js @@ -15,131 +15,132 @@ R3.Event.OnceSubscriptions = {}; /** * Events we can subscribe to and emit */ -R3.Event.WINDOW_RESIZE = 0x1; -R3.Event.PARENT_SCENE_CHANGE = 0x2; -R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x3; -R3.Event.INSTANCE_CLONED = 0x4; -R3.Event.LOAD_IMAGE = 0x5; -R3.Event.NEW_ENTITY = 0x6; -R3.Event.MATERIAL_TYPE_CHANGED = 0x7; -R3.Event.SAVE_COMPONENT = 0x8; -R3.Event.SAVE_COMPONENT_ERROR = 0x9; -R3.Event.COMPONENT_SAVED = 0xa; -R3.Event.LOAD_COMPONENT = 0xb; -R3.Event.LOAD_COMPONENT_ERROR = 0xc; -R3.Event.LOGGED_IN = 0xd; -R3.Event.COMPONENT_CREATED = 0xe; -R3.Event.COMPONENT_CLONED = 0xf; -R3.Event.TEXTURE_ANIMATED_CHANGE = 0x10; -R3.Event.ANIMATE_TEXTURE_INSTANCE = 0x11; -R3.Event.REMOVE_PARTICLE_ENGINE = 0x12; -R3.Event.GAME_PAUSE = 0x13; -R3.Event.SHADER_UPDATE = 0x14; -R3.Event.PLAY_AUDIO = 0x15; -R3.Event.MATERIAL_INSTANCE_UPDATED = 0x16; -R3.Event.PAUSE_AUDIO = 0x17; -R3.Event.MESH_INSTANCE_UPDATED = 0x18; -R3.Event.STOP_AUDIO = 0x19; -R3.Event.LIGHT_INSTANCE_UPDATED = 0x1a; -R3.Event.DELETE_COMPONENT = 0x1b; -R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x1c; -R3.Event.COMPONENTS_LINKED = 0x1d; -R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x1e; -R3.Event.REGISTER_UPDATE = 0x1f; -R3.Event.BUILD_GUI = 0x20; -R3.Event.REMOVE_MESH = 0x21; -R3.Event.MESH_SELECTED = 0x22; -R3.Event.MESH_DESELECTED = 0x23; -R3.Event.COMPONENT_REGISTER = 0x24; -R3.Event.IMAGE_NOT_FOUND = 0x25; -R3.Event.BLENDER_DATA_RECEIVED = 0x26; -R3.Event.IMAGE_UPLOAD_COMPLETE = 0x27; -R3.Event.REMOVE_COMPONENT = 0x28; -R3.Event.KEY_DOWN = 0x29; -R3.Event.KEY_UP = 0x2a; -R3.Event.RENDER = 0x2b; -R3.Event.EVENT_LIST = 0x2c; -R3.Event.COMPILE_SUCCESS = 0x2d; -R3.Event.COMPILE_FAILED = 0x2e; -R3.Event.TEXTURE_INSTANCE_UPDATED = 0x2f; -R3.Event.EVENT_ID_UPDATE = 0x30; -R3.Event.MATERIAL_TEXTURES_UPDATED = 0x31; -R3.Event.DELETE_COMPONENT_ERROR = 0x32; -R3.Event.COMPONENT_DELETED = 0x33; -R3.Event.COMPONENT_TYPES_FETCHED = 0x34; -R3.Event.AUDIO_ENDED = 0x35; -R3.Event.COMPONENT_LINKED = 0x36; -R3.Event.DONE_SAVING = 0x37; -R3.Event.BEFORE_RENDER = 0x38; -R3.Event.AFTER_RENDER = 0x39; -R3.Event.ARRAY_ITEM_ADDED = 0x3a; -R3.Event.INSTANCE_CREATED = 0x3b; -R3.Event.VISUALIZE = 0x3c; -R3.Event.STOP_VISUALIZE = 0x3d; -R3.Event.FETCH_COMPONENT_TYPES = 0x3e; -R3.Event.FETCH_COMPONENTS = 0x3f; -R3.Event.GET_API_URL = 0x40; -R3.Event.GET_RUNTIME = 0x41; -R3.Event.PARENT_WORLD_CHANGE = 0x42; -R3.Event.ANIMATE = 0x43; -R3.Event.ANIMATION_COMPILE_SUCCESS = 0x44; -R3.Event.ANIMATION_COMPILE_FAILED = 0x45; -R3.Event.SAVING = 0x46; -R3.Event.GAME_OVER = 0x47; -R3.Event.GAME_START = 0x48; -R3.Event.TOUCH_START = 0x49; -R3.Event.TOUCH_END = 0x4a; -R3.Event.TOUCH_MOVE = 0x4b; -R3.Event.TOUCH_CANCEL = 0x4c; -R3.Event.GET_REMOTE_API_URL = 0x4d; -R3.Event.COMPONENT_TYPES_UPDATE = 0x4e; -R3.Event.PROJECT_LOADED = 0x4f; -R3.Event.CAST_SOURCE_CHANGED = 0x50; -R3.Event.RESOLVE_DEPENDENCIES = 0x51; -R3.Event.NAME_UPDATE = 0x52; -R3.Event.CANVAS_CHANGE = 0x53; -R3.Event.AFTER_WINDOW_RESIZE = 0x54; -R3.Event.LOAD_FONT = 0x55; -R3.Event.FONT_NOT_FOUND = 0x56; -R3.Event.STOP_ALL_AUDIO = 0x57; -R3.Event.REGISTER_DEPENDENCIES = 0x58; -R3.Event.GAME_LOADED = 0x59; -R3.Event.COMPONENT_UPDATE = 0x5a; -R3.Event.LOAD_PROGRESS = 0x5b; -R3.Event.ENTITY_LOADED = 0x5c; -R3.Event.MOUSE_DOWN = 0x5d; -R3.Event.MOUSE_MOVE = 0x5e; -R3.Event.MOUSE_WHEEL = 0x5f; -R3.Event.MOUSE_UP = 0x60; -R3.Event.PARTICLE_INSTANCE_UPDATED = 0x61; -R3.Event.GAME_DATA = 0x62; -R3.Event.PAUSE_ALL_AUDIO = 0x63; -R3.Event.CONTINUE_ALL_AUDIO = 0x64; -R3.Event.MUTE_AUDIO = 0x65; -R3.Event.GAME_STARTED = 0x66; -R3.Event.GAME_PAUSED = 0x67; -R3.Event.GAME_RESUMED = 0x68; -R3.Event.CUSTOM_GAME_START = 0x69; -R3.Event.AUDIO_MUTED = 0x6a; -R3.Event.AUDIO_UNMUTED = 0x6b; -R3.Event.RECEIVE_DESTINATION_CHANGED = 0x6c; -R3.Event.SELECTION_MODE_CHANGE = 0x6d; -R3.Event.MESH_FACE_SELECTED = 0x6e; -R3.Event.MESH_FACE_DESELECTED = 0x6f; -R3.Event.BEFORE_WINDOW_RESIZE = 0x70; -R3.Event.GET_WINDOW_SIZE = 0x71; -R3.Event.GET_RENDER_CONFIGURATION = 0x72; -R3.Event.SET_ACTIVE_RENDER_CONFIGURATION = 0x73; -R3.Event.REPLACE_COMPONENT = 0x74; -R3.Event.COMPONENT_REPLACED = 0x75; -R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x76; -R3.Event.GET_DEFAULT_SCENE = 0x77; -R3.Event.GET_DEFAULT_CAMERA = 0x78; -R3.Event.GET_WEBSOCKET_CONFIG = 0x79; -R3.Event.GET_PROJECT = 0x7a; -R3.Event.GET_APPLICATION_MODE = 0x80; -R3.Event.RENDERER_SIZE_CHANGE = 0x81; -R3.Event.GET_REGISTER_FACES = 0x82; +R3.Event.WINDOW_RESIZE = 0x1; +R3.Event.PARENT_SCENE_CHANGE = 0x2; +R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x3; +R3.Event.INSTANCE_CLONED = 0x4; +R3.Event.LOAD_IMAGE = 0x5; +R3.Event.NEW_ENTITY = 0x6; +R3.Event.MATERIAL_TYPE_CHANGED = 0x7; +R3.Event.SAVE_COMPONENT = 0x8; +R3.Event.SAVE_COMPONENT_ERROR = 0x9; +R3.Event.COMPONENT_SAVED = 0xa; +R3.Event.LOAD_COMPONENT = 0xb; +R3.Event.LOAD_COMPONENT_ERROR = 0xc; +R3.Event.LOGGED_IN = 0xd; +R3.Event.COMPONENT_CREATED = 0xe; +R3.Event.COMPONENT_CLONED = 0xf; +R3.Event.TEXTURE_ANIMATED_CHANGE = 0x10; +R3.Event.ANIMATE_TEXTURE_INSTANCE = 0x11; +R3.Event.REMOVE_PARTICLE_ENGINE = 0x12; +R3.Event.GAME_PAUSE = 0x13; +R3.Event.SHADER_UPDATE = 0x14; +R3.Event.PLAY_AUDIO = 0x15; +R3.Event.MATERIAL_INSTANCE_UPDATED = 0x16; +R3.Event.PAUSE_AUDIO = 0x17; +R3.Event.MESH_INSTANCE_UPDATED = 0x18; +R3.Event.STOP_AUDIO = 0x19; +R3.Event.LIGHT_INSTANCE_UPDATED = 0x1a; +R3.Event.DELETE_COMPONENT = 0x1b; +R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x1c; +R3.Event.COMPONENTS_LINKED = 0x1d; +R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x1e; +R3.Event.REGISTER_UPDATE = 0x1f; +R3.Event.BUILD_GUI = 0x20; +R3.Event.REMOVE_MESH = 0x21; +R3.Event.MESH_SELECTED = 0x22; +R3.Event.MESH_DESELECTED = 0x23; +R3.Event.COMPONENT_REGISTER = 0x24; +R3.Event.IMAGE_NOT_FOUND = 0x25; +R3.Event.BLENDER_DATA_RECEIVED = 0x26; +R3.Event.IMAGE_UPLOAD_COMPLETE = 0x27; +R3.Event.REMOVE_COMPONENT = 0x28; +R3.Event.KEY_DOWN = 0x29; +R3.Event.KEY_UP = 0x2a; +R3.Event.RENDER = 0x2b; +R3.Event.EVENT_LIST = 0x2c; +R3.Event.COMPILE_SUCCESS = 0x2d; +R3.Event.COMPILE_FAILED = 0x2e; +R3.Event.TEXTURE_INSTANCE_UPDATED = 0x2f; +R3.Event.EVENT_ID_UPDATE = 0x30; +R3.Event.MATERIAL_TEXTURES_UPDATED = 0x31; +R3.Event.DELETE_COMPONENT_ERROR = 0x32; +R3.Event.COMPONENT_DELETED = 0x33; +R3.Event.COMPONENT_TYPES_FETCHED = 0x34; +R3.Event.AUDIO_ENDED = 0x35; +R3.Event.COMPONENT_LINKED = 0x36; +R3.Event.DONE_SAVING = 0x37; +R3.Event.BEFORE_RENDER = 0x38; +R3.Event.AFTER_RENDER = 0x39; +R3.Event.ARRAY_ITEM_ADDED = 0x3a; +R3.Event.INSTANCE_CREATED = 0x3b; +R3.Event.VISUALIZE = 0x3c; +R3.Event.STOP_VISUALIZE = 0x3d; +R3.Event.FETCH_COMPONENT_TYPES = 0x3e; +R3.Event.FETCH_COMPONENTS = 0x3f; +R3.Event.GET_API_URL = 0x40; +R3.Event.GET_RUNTIME = 0x41; +R3.Event.PARENT_WORLD_CHANGE = 0x42; +R3.Event.ANIMATE = 0x43; +R3.Event.ANIMATION_COMPILE_SUCCESS = 0x44; +R3.Event.ANIMATION_COMPILE_FAILED = 0x45; +R3.Event.SAVING = 0x46; +R3.Event.GAME_OVER = 0x47; +R3.Event.GAME_START = 0x48; +R3.Event.TOUCH_START = 0x49; +R3.Event.TOUCH_END = 0x4a; +R3.Event.TOUCH_MOVE = 0x4b; +R3.Event.TOUCH_CANCEL = 0x4c; +R3.Event.GET_REMOTE_API_URL = 0x4d; +R3.Event.COMPONENT_TYPES_UPDATE = 0x4e; +R3.Event.PROJECT_LOADED = 0x4f; +R3.Event.CAST_SOURCE_CHANGED = 0x50; +R3.Event.RESOLVE_DEPENDENCIES = 0x51; +R3.Event.NAME_UPDATE = 0x52; +R3.Event.CANVAS_CHANGE = 0x53; +R3.Event.AFTER_WINDOW_RESIZE = 0x54; +R3.Event.LOAD_FONT = 0x55; +R3.Event.FONT_NOT_FOUND = 0x56; +R3.Event.STOP_ALL_AUDIO = 0x57; +R3.Event.REGISTER_DEPENDENCIES = 0x58; +R3.Event.GAME_LOADED = 0x59; +R3.Event.COMPONENT_UPDATE = 0x5a; +R3.Event.LOAD_PROGRESS = 0x5b; +R3.Event.ENTITY_LOADED = 0x5c; +R3.Event.MOUSE_DOWN = 0x5d; +R3.Event.MOUSE_MOVE = 0x5e; +R3.Event.MOUSE_WHEEL = 0x5f; +R3.Event.MOUSE_UP = 0x60; +R3.Event.PARTICLE_INSTANCE_UPDATED = 0x61; +R3.Event.GAME_DATA = 0x62; +R3.Event.PAUSE_ALL_AUDIO = 0x63; +R3.Event.CONTINUE_ALL_AUDIO = 0x64; +R3.Event.MUTE_AUDIO = 0x65; +R3.Event.GAME_STARTED = 0x66; +R3.Event.GAME_PAUSED = 0x67; +R3.Event.GAME_RESUMED = 0x68; +R3.Event.CUSTOM_GAME_START = 0x69; +R3.Event.AUDIO_MUTED = 0x6a; +R3.Event.AUDIO_UNMUTED = 0x6b; +R3.Event.RECEIVE_DESTINATION_CHANGED = 0x6c; +R3.Event.SELECTION_MODE_CHANGE = 0x6d; +R3.Event.MESH_FACE_SELECTED = 0x6e; +R3.Event.MESH_FACE_DESELECTED = 0x6f; +R3.Event.BEFORE_WINDOW_RESIZE = 0x70; +R3.Event.GET_WINDOW_SIZE = 0x71; +R3.Event.GET_QUERY_API_URL = 0x72; +//R3.Event.SET_ACTIVE_RENDER_CONFIGURATION = 0x73; +R3.Event.REPLACE_COMPONENT = 0x74; +R3.Event.COMPONENT_REPLACED = 0x75; +R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x76; +R3.Event.GET_DEFAULT_SCENE = 0x77; +R3.Event.GET_DEFAULT_CAMERA = 0x78; +R3.Event.GET_WEBSOCKET_CONFIG = 0x79; +R3.Event.GET_PROJECT = 0x7a; +R3.Event.GET_APPLICATION_MODE = 0x80; +R3.Event.RENDERER_SIZE_CHANGE = 0x81; +R3.Event.GET_REGISTER_FACES = 0x82; +R3.Event.GET_PROJECT_CANVAS = 0x83; /** * Returns string name of event ID @@ -275,6 +276,7 @@ R3.Event.GetEventName = function(number) { case 0x80 : return 'get_application_mode'; case 0x81 : return 'renderer_size_change'; case 0x82 : return 'get_register_faces'; + case 0x83 : return 'get_project_canvas'; break; } diff --git a/src/r3-a-3-api-component.js b/src/r3-a-3-api-component.js index e537a6b..8f0f06f 100644 --- a/src/r3-a-3-api-component.js +++ b/src/r3-a-3-api-component.js @@ -25,7 +25,7 @@ R3.API.Component = function( } this.id = id; - this.componentType = this.getComponentType(); + this.componentType = R3.GetComponentType(this); if (R3.Utils.UndefinedOrNull(name)) { name = R3.Component.GetComponentFriendlyName(this.componentType) + ' (' + this.id + ')'; @@ -64,442 +64,3 @@ R3.API.Component.prototype.getFirstParent = function(constructor) { R3.API.Component.getParent = function(property, index, constructor) { return R3.D3.GetParent(this, property, index, constructor); }; - -R3.API.Component.prototype.getComponentType = function() { - - if (this instanceof R3.API.Box3) { - return R3.Component.BOX3; - } - if (this instanceof R3.API.Canvas) { - return R3.Component.CANVAS; - } - if (this instanceof R3.API.Clock) { - return R3.Component.CLOCK; - } - if (this instanceof R3.API.Controls.D3.Editor) { - return R3.Component.CONTROLS_EDITOR; - } - if (this instanceof R3.API.Controls.D3.FirstPerson) { - return R3.Component.CONTROLS_FIRST_PERSON; - } - if (this instanceof R3.API.Controls.D3.Orbit) { - return R3.Component.CONTROLS_ORBIT; - } - if (this instanceof R3.API.Controls.Keyboard) { - return R3.Component.CONTROLS_KEYBOARD; - } - if (this instanceof R3.API.Controls.Mouse) { - return R3.Component.CONTROLS_MOUSE; - } - if (this instanceof R3.API.Controls.Touch) { - return R3.Component.CONTROLS_TOUCH; - } - if (this instanceof R3.API.Curve.Path.D2.Shape) { - return R3.Component.CURVE_PATH_D2_SHAPE; - } - if (this instanceof R3.API.Curve.Path.D2) { - return R3.Component.CURVE_PATH_D2; - } - if (this instanceof R3.API.Curve.Path) { - return R3.Component.CURVE_PATH; - } - if (this instanceof R3.API.Curve) { - return R3.Component.CURVE; - } - if (this instanceof R3.API.CustomCode) { - return R3.Component.CUSTOM_CODE; - } - if (this instanceof R3.API.DomElement) { - return R3.Component.DOM_ELEMENT; - } - if (this instanceof R3.API.DrawRange) { - return R3.Component.DRAW_RANGE; - } - if (this instanceof R3.API.Entity) { - return R3.Component.ENTITY; - } - if (this instanceof R3.API.EntityManager) { - return R3.Component.ENTITY_MANAGER; - } - if (this instanceof R3.API.Group) { - return R3.Component.GROUP; - } - if (this instanceof R3.API.GUI) { - return R3.Component.GUI; - } - if (this instanceof R3.API.Image) { - return R3.Component.IMAGE; - } - if (this instanceof R3.API.Mouse) { - return R3.Component.MOUSE; - } - if (this instanceof R3.API.Plane) { - return R3.Component.PLANE; - } - if (this instanceof R3.API.Project) { - return R3.Component.PROJECT; - } - if (this instanceof R3.API.Renderer.D3.Canvas.Target) { - return R3.Component.RENDERER_D3_CANVAS_TARGET; - } - if (this instanceof R3.API.Renderer.D3.Canvas) { - return R3.Component.RENDERER_D3_CANVAS; - } - if (this instanceof R3.API.Renderer.D3.Target) { - return R3.Component.RENDERER_D3_TARGET; - } - if (this instanceof R3.API.Renderer.D3) { - return R3.Component.RENDERER_D3; - } - if (this instanceof R3.API.Renderer.D2) { - return R3.Component.RENDERER_D2; - } - if (this instanceof R3.API.Server) { - return R3.Component.SERVER; - } - if (this instanceof R3.API.Socket.Receive) { - return R3.Component.SOCKET_RECEIVE; - } - if (this instanceof R3.API.Socket.Cast) { - return R3.Component.SOCKET_CAST; - } - if (this instanceof R3.API.Sphere) { - return R3.Component.SPHERE; - } - if (this instanceof R3.API.Stats) { - return R3.Component.STATS; - } - if (this instanceof R3.API.User) { - return R3.Component.USER; - } - if (this instanceof R3.API.Video) { - return R3.Component.VIDEO; - } - if (this instanceof R3.D3.API.Animation) { - return R3.Component.ANIMATION; - } - if (this instanceof R3.D3.API.Object) { - return R3.Component.OBJECT; - } - if (this instanceof R3.D3.API.Audio) { - return R3.Component.AUDIO; - } - if (this instanceof R3.D3.API.Bone) { - return R3.Component.BONE; - } - if (this instanceof R3.D3.API.Broadphase) { - return R3.Component.BROADPHASE; - } - if (this instanceof R3.D3.API.Camera.Perspective.Stereo) { - return R3.Component.CAMERA_PERSPECTIVE_STEREO; - } - if (this instanceof R3.D3.API.Camera.Perspective) { - return R3.Component.CAMERA_PERSPECTIVE; - } - if (this instanceof R3.D3.API.Camera.Orthographic) { - return R3.Component.CAMERA_ORTHOGRAPHIC; - } - if (this instanceof R3.D3.API.Camera.Cube) { - return R3.Component.CAMERA_CUBE; - } - if (this instanceof R3.D3.API.Composer) { - return R3.Component.COMPOSER; - } - if (this instanceof R3.D3.API.Effect.Stereo) { - return R3.Component.EFFECT_STEREO; - } - if (this instanceof R3.D3.API.Effect.Parallax) { - return R3.Component.EFFECT_PARALLAX; - } - if (this instanceof R3.D3.API.Effect.Anaglyph) { - return R3.Component.EFFECT_ANAGLYPH; - } - if (this instanceof R3.D3.API.Face) { - return R3.Component.FACE; - } - if (this instanceof R3.D3.API.Fog) { - return R3.Component.FOG; - } - if (this instanceof R3.D3.API.Font) { - return R3.Component.FONT; - } - if (this instanceof R3.D3.API.FrictionContactMaterial) { - return R3.Component.FRICTION_CONTACT_MATERIAL; - } - if (this instanceof R3.D3.API.FrictionMaterial) { - return R3.Component.FRICTION_MATERIAL; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Box) { - return R3.Component.GEOMETRY_BUFFER_BOX; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Circle) { - return R3.Component.GEOMETRY_BUFFER_CIRCLE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Cone) { - return R3.Component.GEOMETRY_BUFFER_CONE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Cylinder) { - return R3.Component.GEOMETRY_BUFFER_CYLINDER; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Dodecahedron) { - return R3.Component.GEOMETRY_BUFFER_DODECAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Extrude) { - return R3.Component.GEOMETRY_BUFFER_EXTRUDE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Icosahedron) { - return R3.Component.GEOMETRY_BUFFER_ICOSAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Instanced) { - return R3.Component.GEOMETRY_BUFFER_INSTANCED; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Lathe) { - return R3.Component.GEOMETRY_BUFFER_LATHE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Octahedron) { - return R3.Component.GEOMETRY_BUFFER_OCTAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Parametric) { - return R3.Component.GEOMETRY_BUFFER_PARAMETRIC; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Plane) { - return R3.Component.GEOMETRY_BUFFER_PLANE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Polyhedron) { - return R3.Component.GEOMETRY_BUFFER_POLYHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Ring) { - return R3.Component.GEOMETRY_BUFFER_RING; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Shape) { - return R3.Component.GEOMETRY_BUFFER_SHAPE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Sphere) { - return R3.Component.GEOMETRY_BUFFER_SPHERE; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Tetrahedron) { - return R3.Component.GEOMETRY_BUFFER_TETRAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Text) { - return R3.Component.GEOMETRY_BUFFER_TEXT; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Torus) { - return R3.Component.GEOMETRY_BUFFER_TORUS; - } - if (this instanceof R3.D3.API.Geometry.Buffer.TorusKnot) { - return R3.Component.GEOMETRY_BUFFER_TORUS_KNOT; - } - if (this instanceof R3.D3.API.Geometry.Buffer.Tube) { - return R3.Component.GEOMETRY_BUFFER_TUBE; - } - if (this instanceof R3.D3.API.Geometry.Buffer) { - return R3.Component.GEOMETRY_BUFFER; - } - if (this instanceof R3.D3.API.Geometry.Normal.Box) { - return R3.Component.GEOMETRY_NORMAL_BOX; - } - if (this instanceof R3.D3.API.Geometry.Normal.Circle) { - return R3.Component.GEOMETRY_NORMAL_CIRCLE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Cone) { - return R3.Component.GEOMETRY_NORMAL_CONE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Cylinder) { - return R3.Component.GEOMETRY_NORMAL_CYLINDER; - } - if (this instanceof R3.D3.API.Geometry.Normal.Dodecahedron) { - return R3.Component.GEOMETRY_NORMAL_DODECAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Normal.Edges) { - return R3.Component.GEOMETRY_NORMAL_EDGES; - } - if (this instanceof R3.D3.API.Geometry.Normal.Extrude) { - return R3.Component.GEOMETRY_NORMAL_EXTRUDE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Icosahedron) { - return R3.Component.GEOMETRY_NORMAL_ICOSAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Normal.Lathe) { - return R3.Component.GEOMETRY_NORMAL_LATHE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Octahedron) { - return R3.Component.GEOMETRY_NORMAL_OCTAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Normal.Parametric) { - return R3.Component.GEOMETRY_NORMAL_PARAMETRIC; - } - if (this instanceof R3.D3.API.Geometry.Normal.Plane) { - return R3.Component.GEOMETRY_NORMAL_PLANE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Polyhedron) { - return R3.Component.GEOMETRY_NORMAL_POLYHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Normal.Ring) { - return R3.Component.GEOMETRY_NORMAL_RING; - } - if (this instanceof R3.D3.API.Geometry.Normal.Shape) { - return R3.Component.GEOMETRY_NORMAL_SHAPE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Sphere) { - return R3.Component.GEOMETRY_NORMAL_SPHERE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Tetrahedron) { - return R3.Component.GEOMETRY_NORMAL_TETRAHEDRON; - } - if (this instanceof R3.D3.API.Geometry.Normal.Text) { - return R3.Component.GEOMETRY_NORMAL_TEXT; - } - if (this instanceof R3.D3.API.Geometry.Normal.Torus) { - return R3.Component.GEOMETRY_NORMAL_TORUS; - } - if (this instanceof R3.D3.API.Geometry.Normal.TorusKnot) { - return R3.Component.GEOMETRY_NORMAL_TORUS_KNOT; - } - if (this instanceof R3.D3.API.Geometry.Normal.Tube) { - return R3.Component.GEOMETRY_NORMAL_TUBE; - } - if (this instanceof R3.D3.API.Geometry.Normal.Wireframe) { - return R3.Component.GEOMETRY_NORMAL_WIREFRAME; - } - if (this instanceof R3.D3.API.Geometry.Normal) { - return R3.Component.GEOMETRY_NORMAL; - } - if (this instanceof R3.D3.API.Geometry) { - return R3.Component.GEOMETRY; - } - if (this instanceof R3.D3.API.Light.Ambient) { - return R3.Component.LIGHT_AMBIENT; - } - if (this instanceof R3.D3.API.Light.Directional) { - return R3.Component.LIGHT_DIRECTIONAL; - } - if (this instanceof R3.D3.API.Light.Hemisphere) { - return R3.Component.LIGHT_HEMISPHERE; - } - if (this instanceof R3.D3.API.Light.Point) { - return R3.Component.LIGHT_POINT; - } - if (this instanceof R3.D3.API.Light.RectArea) { - return R3.Component.LIGHT_RECT_AREA; - } - if (this instanceof R3.D3.API.Light.Spot) { - return R3.Component.LIGHT_SPOT; - } - if (this instanceof R3.D3.API.Material.Basic) { - return R3.Component.MATERIAL_BASIC; - } - if (this instanceof R3.D3.API.Material.Phong) { - return R3.Component.MATERIAL_PHONG; - } - if (this instanceof R3.D3.API.Material.Points) { - return R3.Component.MATERIAL_POINTS; - } - if (this instanceof R3.D3.API.Material.Shader) { - return R3.Component.MATERIAL_SHADER; - } - if (this instanceof R3.D3.API.Material.Shader.Raw) { - return R3.Component.MATERIAL_SHADER_RAW; - } - if (this instanceof R3.D3.API.Material.Standard) { - return R3.Component.MATERIAL_STANDARD; - } - if (this instanceof R3.D3.API.Mesh) { - return R3.Component.MESH; - } - if (this instanceof R3.D3.API.Particle.Engine) { - return R3.Component.PARTICLE_ENGINE; - } - if (this instanceof R3.D3.API.Particle) { - return R3.Component.PARTICLE; - } - if (this instanceof R3.D3.API.Pass.Bloom) { - return R3.Component.PASS_BLOOM; - } - if (this instanceof R3.D3.API.Pass.FXAA) { - return R3.Component.PASS_FXAA; - } - if (this instanceof R3.D3.API.Pass.Render) { - return R3.Component.PASS_RENDER; - } - if (this instanceof R3.D3.API.Pass.SSAO) { - return R3.Component.PASS_SSAO; - } - if (this instanceof R3.D3.API.PhysicsWorld) { - return R3.Component.PHYSICS_WORLD; - } - if (this instanceof R3.D3.API.Raycaster) { - return R3.Component.RAYCASTER; - } - if (this instanceof R3.D3.API.RaycastVehicle) { - return R3.Component.RAYCAST_VEHICLE; - } - if (this instanceof R3.D3.API.RaycastWheel) { - return R3.Component.RAYCAST_WHEEL; - } - if (this instanceof R3.D3.API.RenderTarget.Cube) { - return R3.Component.RENDER_TARGET_CUBE; - } - if (this instanceof R3.D3.API.RenderTarget) { - return R3.Component.RENDER_TARGET; - } - if (this instanceof R3.D3.API.RigidBody) { - return R3.Component.RIGID_BODY; - } - if (this instanceof R3.D3.API.Scene) { - return R3.Component.SCENE; - } - if (this instanceof R3.D3.API.Shader.Vertex) { - return R3.Component.SHADER_VERTEX; - } - if (this instanceof R3.D3.API.Shader.Fragment) { - return R3.Component.SHADER_FRAGMENT; - } - if (this instanceof R3.D3.API.Shader) { - return R3.Component.SHADER; - } - if (this instanceof R3.D3.API.Shadow.Directional) { - return R3.Component.SHADOW_DIRECTIONAL; - } - if (this instanceof R3.D3.API.Shadow.Spot) { - return R3.Component.SHADOW_SPOT; - } - if (this instanceof R3.D3.API.Shadow) { - return R3.Component.SHADOW; - } - if (this instanceof R3.D3.API.Shape) { - return R3.Component.SHAPE; - } - if (this instanceof R3.D3.API.Skeleton) { - return R3.Component.SKELETON; - } - if (this instanceof R3.D3.API.Solver) { - return R3.Component.SOLVER; - } - if (this instanceof R3.D3.API.Spline) { - return R3.Component.SPLINE; - } - if (this instanceof R3.D3.API.Text) { - return R3.Component.TEXT; - } - if (this instanceof R3.D3.API.Texture.Canvas) { - return R3.Component.TEXTURE_CANVAS; - } - if (this instanceof R3.D3.API.Texture.Cube) { - return R3.Component.TEXTURE_CUBE; - } - if (this instanceof R3.D3.API.Texture.Image) { - return R3.Component.TEXTURE_IMAGE; - } - if (this instanceof R3.D3.API.Texture) { - return R3.Component.TEXTURE; - } - if (this instanceof R3.D3.API.Viewport.FixedAspect) { - return R3.Component.VIEWPORT_FIXED_ASPECT; - } - if (this instanceof R3.D3.API.Viewport.ZoomedAspect) { - return R3.Component.VIEWPORT_ZOOMED_ASPECT; - } - if (this instanceof R3.D3.API.Viewport) { - return R3.Component.VIEWPORT; - } -}; \ No newline at end of file diff --git a/src/r3-a-2-utils.js b/src/r3-a-3-utils.js similarity index 98% rename from src/r3-a-2-utils.js rename to src/r3-a-3-utils.js index 792fc4f..9e501ff 100644 --- a/src/r3-a-2-utils.js +++ b/src/r3-a-3-utils.js @@ -124,6 +124,23 @@ R3.Utils.StripImageExtension = function(imagePath) { return imagePath.replace(/(\.png$|\.gif$|\.jpeg$|\.jpg$)/,'') }; +/** + * Returns true if unloaded + * @param component + * @returns {boolean} + * @constructor + */ +R3.Utils.Unloaded = function(component) { + if ( + R3.Utils.UndefinedOrNull(component) || + R3.Utils.UndefinedOrNull(component.instance) + ) { + return true; + } + + return false; +}; + R3.Utils.BuildVectorSource = function(result, name, dimension) { if (dimension === 2) { diff --git a/src/r3-a-4-component.js b/src/r3-a-4-component.js index fc99e30..ff59dfe 100644 --- a/src/r3-a-4-component.js +++ b/src/r3-a-4-component.js @@ -1,23 +1,20 @@ /** * R3.Component is an R3.Event - * @param linkedObjects * @constructor */ -R3.Component = function( - linkedObjects -) { +R3.Component = function() { - 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(); + if (R3.Utils.UndefinedOrNull(this.linkedObjects)) { + this.linkedObjects = {}; + } + + this.upgradeToRuntime(); + + this.componentType = R3.GetComponentType(this); + + this.runtime = this.getComponentRuntime(); this.idToObject = {}; @@ -63,6 +60,57 @@ R3.Component = function( R3.Component.prototype = Object.create(R3.Event.prototype); R3.Component.prototype.constructor = R3.Component; +R3.Component.prototype.upgradeToRuntime = function() { + + var linkedObjects = { + graphics : R3.Runtime.Graphics, + physics : R3.Runtime.Physics, + coder : R3.Runtime.Coder, + gui : R3.Runtime.GUI, + stats : R3.Runtime.Stats + }; + + for (var property in this) { + + if (this.hasOwnProperty(property)) { + + if (R3.Utils.UndefinedOrNull(this[property])) { + continue; + } + + if (this[property] instanceof R3.API.Component) { + this[property] = R3.Component.ConstructFromObject(this[property]); + + if (this[property].register) { + linkedObjects[property] = this[property].prototype.constructor; + } + } + + if (this[property].isArray) + { + this[property] = this[property].reduce( + function(result, item) { + + if (item instanceof R3.API.Component) { + item = R3.Component.ConstructFromObject(item); + } + + result.push(item); + + return result; + }, + [] + ); + } + } + } + + for (property in linkedObjects) { + this.linkedObjects[property] = linkedObjects[property]; + } + +}; + /** * This function, performs standard instance creation steps for all our components, which means * Ensure we have no dependencies @@ -295,1197 +343,8 @@ 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 @@ -1495,27 +354,27 @@ R3.Component.GetComponentInfo = function(number) { */ R3.Component.GetRuntimeName = function(runtime) { - if (runtime === R3.Component.GRAPHICS_RUNTIME) { + if (runtime === R3.Runtime.GRAPHICS) { return 'Graphics'; } - if (runtime === R3.Component.PHYSICS_RUNTIME) { + if (runtime === R3.Runtime.PHYSICS) { return 'Physics'; } - if (runtime === R3.Component.GUI_RUNTIME) { + if (runtime === R3.Runtime.GUI) { return 'GUI'; } - if (runtime === R3.Component.STATISTICS_RUNTIME) { + if (runtime === R3.Runtime.STATISTICS) { return 'Statistics'; } - if (runtime === R3.Component.SOCKET_RUNTIME) { + if (runtime === R3.Runtime.SOCKETS) { return 'Sockets'; } - if (runtime === R3.Component.CODER_RUNTIME) { + if (runtime === R3.Runtime.CODER) { return 'Coder'; } @@ -1527,7 +386,7 @@ R3.Component.GetRuntimeName = function(runtime) { */ R3.Component.GetComponentName = function(componentType) { - var info = R3.Component.GetComponentInfo(componentType); + var info = R3.GetComponentInfo(componentType); if (info) { return info.name; @@ -1557,7 +416,7 @@ R3.Component.GetComponentFriendlyName = function(componentType) { */ R3.Component.GetComponentRuntime = function(componentType) { - var info = R3.Component.GetComponentInfo(componentType); + var info = R3.GetComponentInfo(componentType); if (info) { return info.runtime; @@ -1565,471 +424,12 @@ R3.Component.GetComponentRuntime = function(componentType) { return null; }; -/** - * Returns the component type based on the constructor - * @returns {number} - * @constructor - */ -R3.Component.prototype.getComponentType = function() { +R3.Component.prototype.getComponentRuntime = 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; - } + var info = R3.GetComponentInfo(this.componentType); + + return info.runtime; - console.warn('Component Type not Registered' + this); }; @@ -2038,7 +438,7 @@ R3.Component.prototype.getComponentType = function() { */ R3.Component.GetComponentConstructor = function(componentType) { - var info = R3.Component.GetComponentInfo(componentType); + var info = R3.GetComponentInfo(componentType); if (info) { return info.constructor; @@ -2047,6 +447,27 @@ R3.Component.GetComponentConstructor = function(componentType) { return null; }; +R3.Component.prototype.getComponentAPIConstructor = function() { + + var info = R3.GetComponentInfo(R3.GetComponentType(this)); + + if (info) { + return info.apiConstructor; + } else { + throw new Error('Could not get the API constructor for component type: ' + componentType); + } + +}; + +R3.Component.prototype.initialize = function(apiComponent) { + + this.getComponentAPIConstructor().call( + this, + apiComponent + ); + +}; + R3.Component.prototype.getPropertyValue = function(item) { /** @@ -2087,7 +508,7 @@ R3.Component.prototype.getPropertyValue = function(item) { */ R3.Component.prototype.toApiObject = function() { - var info = R3.Component.GetComponentInfo(this.componentType); + var info = R3.GetComponentInfo(this.componentType); var apiConstructor = info.apiConstructor; @@ -2568,7 +989,7 @@ R3.Component.GetRuntimeObject = function(info) { return runtime.graphics; - } else if (info.runtime === R3.Component.PHYSICS_RUNTIME) { + } else if (info.runtime === R3.Runtime.PHYSICS) { if (R3.Utils.UndefinedOrNull(runtime.physics)) { console.warn('no runtime physics ', info); @@ -2577,7 +998,7 @@ R3.Component.GetRuntimeObject = function(info) { return runtime.physics; - } else if (info.runtime === R3.Component.GUI_RUNTIME) { + } else if (info.runtime === R3.Runtime.GUI) { if (R3.Utils.UndefinedOrNull(runtime.gui)) { console.warn('no runtime gui ', info); @@ -2586,7 +1007,7 @@ R3.Component.GetRuntimeObject = function(info) { return runtime.gui; - } else if (info.runtime === R3.Component.SOCKET_RUNTIME) { + } else if (info.runtime === R3.Runtime.SOCKETS) { if (R3.Utils.UndefinedOrNull(runtime.sockets)) { console.warn('no runtime sockets ', info); @@ -2595,7 +1016,7 @@ R3.Component.GetRuntimeObject = function(info) { return runtime.sockets; - } else if (info.runtime === R3.Component.STATISTICS_RUNTIME) { + } else if (info.runtime === R3.Runtime.STATISTICS) { if (R3.Utils.UndefinedOrNull(runtime.statistics)) { console.warn('no runtime statistics ', info); @@ -2604,7 +1025,7 @@ R3.Component.GetRuntimeObject = function(info) { return runtime.statistics; - } else if (info.runtime === R3.Component.DEFAULT_RUNTIME) { + } else if (info.runtime === R3.Runtime.DEFAULT) { return null; @@ -2617,7 +1038,7 @@ R3.Component.GetRuntimeObject = function(info) { R3.Component.Construct = function(componentType) { - var info = R3.Component.GetComponentInfo(componentType); + var info = R3.GetComponentInfo(componentType); var componentClass = info.constructor; @@ -2635,7 +1056,7 @@ R3.Component.ConstructFromObject = function(rawComponentObject) { var runtimeComponent = null; - var info = R3.Component.GetComponentInfo(rawComponentObject.componentType); + var info = R3.GetComponentInfo(rawComponentObject.componentType); var runtime = R3.Component.GetRuntimeObject(info); diff --git a/src/r3-api-box3.js b/src/r3-api-box3.js index d067fec..68658be 100644 --- a/src/r3-api-box3.js +++ b/src/r3-api-box3.js @@ -1,26 +1,38 @@ /** * R3.API.Box3 * @param apiComponent - * @param min - * @param max * @constructor */ R3.API.Box3 = function( - apiComponent, - min, - max + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(min)) { - min = new R3.API.Vector3(); + if (R3.Utils.UndefinedOrNull(apiComponent.min)) { + apiComponent.min = new R3.API.Vector3( + { + parent : this, + register : true + }, + 0, + 0, + 0 + ); } - this.min = min; + this.min = apiComponent.min; - if (R3.Utils.UndefinedOrNull(max)) { - max = new R3.API.Vector3(1,1,1); + if (R3.Utils.UndefinedOrNull(apiComponent.max)) { + apiComponent.max = new R3.API.Vector3( + { + parent : this, + register : true + }, + 1, + 1, + 1 + ); } - this.max = max; + this.max = apiComponent.max; }; R3.API.Box3.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-canvas.js b/src/r3-api-canvas.js index af4c665..7036ec2 100644 --- a/src/r3-api-canvas.js +++ b/src/r3-api-canvas.js @@ -1,62 +1,55 @@ /** * R3.API.Canvas * @param apiComponent - * @param autoUpdateSize - * @param width - * @param height - * @param offset - * @param tabIndex - * @param texts - * @param textBaseline * @constructor */ R3.API.Canvas = function( - apiComponent, - autoUpdateSize, - width, - height, - offset, - tabIndex, - texts, - textBaseline + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(autoUpdateSize)) { - autoUpdateSize = true; + if (R3.Utils.UndefinedOrNull(apiComponent.autoUpdateSize)) { + apiComponent.autoUpdateSize = true; } - this.autoUpdateSize = autoUpdateSize; + this.autoUpdateSize = apiComponent.autoUpdateSize; - if (R3.Utils.UndefinedOrNull(width)) { - width = 512; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 512; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = 512; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 512; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(offset)) { - offset = new R3.API.Vector2(0,0); + if (R3.Utils.UndefinedOrNull(apiComponent.offset)) { + apiComponent.offset = new R3.API.Vector2( + { + parent : this, + register : true + }, + 0, + 0 + ); } - this.offset = offset; + this.offset = apiComponent.offset; - if (R3.Utils.UndefinedOrNull(tabIndex)) { - tabIndex = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.tabIndex)) { + apiComponent.tabIndex = 1; } - this.tabIndex = tabIndex; + this.tabIndex = apiComponent.tabIndex; - if (R3.Utils.UndefinedOrNull(texts)) { - texts = []; + if (R3.Utils.UndefinedOrNull(apiComponent.texts)) { + apiComponent.texts = []; } - this.texts = texts; + this.texts = apiComponent.texts; - if (R3.Utils.UndefinedOrNull(textBaseline)) { - textBaseline = 'middle'; + if (R3.Utils.UndefinedOrNull(apiComponent.textBaseline)) { + apiComponent.textBaseline = 'middle'; } - this.textBaseline = textBaseline; + this.textBaseline = apiComponent.textBaseline; }; diff --git a/src/r3-api-clock.js b/src/r3-api-clock.js index 7e8a02b..af0e9bf 100644 --- a/src/r3-api-clock.js +++ b/src/r3-api-clock.js @@ -7,7 +7,7 @@ R3.API.Clock = function( apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; }; diff --git a/src/r3-api-color.js b/src/r3-api-color.js index 785ef5d..9c23cd3 100644 --- a/src/r3-api-color.js +++ b/src/r3-api-color.js @@ -1,37 +1,35 @@ /** * API Color - * @param parent - * @param r - * @param g - * @param b - * @param a + * @param apiComponent * @constructor */ R3.API.Color = function( - r, - g, - b, - a + apiComponent ) { - if (R3.Utils.UndefinedOrNull(r)) { - r = 1; - } - this.r = r; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(g)) { - g = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.r)) { + apiComponent.r = 1; } - this.g = g; + this.r = apiComponent.r; - if (R3.Utils.UndefinedOrNull(b)) { - b = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.g)) { + apiComponent.g = 1; } - this.b = b; + this.g = apiComponent.g; - if (R3.Utils.UndefinedOrNull(a)) { - a = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.b)) { + apiComponent.b = 1; } - this.a = a; + this.b = apiComponent.b; + + if (R3.Utils.UndefinedOrNull(apiComponent.a)) { + apiComponent.a = 0; + } + this.a = apiComponent.a; }; + +R3.API.Color.prototype = Object.create(R3.API.Component.prototype); +R3.API.Color.prototype.constructor = R3.API.Color; diff --git a/src/r3-api-controls-0.js b/src/r3-api-controls-0.js index 73584ed..eb37887 100644 --- a/src/r3-api-controls-0.js +++ b/src/r3-api-controls-0.js @@ -9,16 +9,20 @@ R3.API.Controls = function( canvas ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(canvas)) { - /** - * Try to attach the controls to the parent canvas - * @type {null} - */ - canvas = this.getFirstParent(R3.API.Canvas); + if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { + R3.Event.Emit( + R3.Event.GET_PROJECT_CANVAS, + { + controls : this + }, + function(projectCanvas) { + apiComponent.canvas = projectCanvas; + } + ) } - this.canvas = canvas; + this.canvas = apiComponent.canvas; }; R3.API.Controls.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-controls-d3.js b/src/r3-api-controls-d3-0.js similarity index 53% rename from src/r3-api-controls-d3.js rename to src/r3-api-controls-d3-0.js index dc27798..1a96d0e 100644 --- a/src/r3-api-controls-d3.js +++ b/src/r3-api-controls-d3-0.js @@ -3,25 +3,20 @@ * @constructor */ R3.API.Controls.D3 = function( - apiControls, - camera + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiControls)) { - apiControls = {}; - } - R3.API.Controls.call( this, - apiControls, - apiControls.canvas + apiComponent ); - if (R3.Utils.UndefinedOrNull(camera)) { + if (R3.Utils.UndefinedOrNull(apiComponent.camera)) { var project = this.getFirstParent(R3.API.Project); - camera = project.cameras[R3.API.Project.CAMERA_INDEX_EDIT]; + apiComponent.camera = project.cameras[R3.API.Project.CAMERA_INDEX_EDIT]; } - this.camera = camera; + this.camera = apiComponent.camera; + }; R3.API.Controls.D3.prototype = Object.create(R3.API.Controls.prototype); diff --git a/src/r3-api-controls-d3-editor.js b/src/r3-api-controls-d3-editor.js index 19f93ab..d21d94d 100644 --- a/src/r3-api-controls-d3-editor.js +++ b/src/r3-api-controls-d3-editor.js @@ -1,27 +1,25 @@ /** - * @param apiControlsD3 - * @param raycaster + * R3.API.Controls.D3.Editor + * @param apiComponent * @constructor */ R3.API.Controls.D3.Editor = function( - apiControlsD3, - raycaster + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiControlsD3)) { - apiControlsD3 = {}; - } - R3.API.Controls.D3.call( this, - apiControlsD3, - apiControlsD3.camera + apiComponent ); - if (R3.Utils.UndefinedOrNull(raycaster)) { - raycaster = new R3.D3.API.Raycaster(); + if (R3.Utils.UndefinedOrNull(apiComponent.raycaster)) { + apiComponent.raycaster = new R3.D3.API.Raycaster( + { + parent : this + } + ); } - this.raycaster = raycaster; + this.raycaster = apiComponent.raycaster; }; diff --git a/src/r3-api-controls-d3-first-person.js b/src/r3-api-controls-d3-first-person.js deleted file mode 100644 index 507e3f8..0000000 --- a/src/r3-api-controls-d3-first-person.js +++ /dev/null @@ -1,121 +0,0 @@ -/** - * R3.API.Controls.D3.FirstPerson - * @param apiControlsD3 - * @param enabled - * @param movementSpeed - * @param lookSpeed - * @param lookVertical - * @param autoForward - * @param activeLook - * @param heightSpeed - * @param heightCoef - * @param heightMin - * @param heightMax - * @param constrainVertical - * @param verticalMin - * @param verticalMax - * @param autoSpeedFactor - * @constructor - */ -R3.API.Controls.D3.FirstPerson = function( - apiControlsD3, - enabled, - movementSpeed, - lookSpeed, - lookVertical, - autoForward, - activeLook, - heightSpeed, - heightCoef, - heightMin, - heightMax, - constrainVertical, - verticalMin, - verticalMax, - autoSpeedFactor -) { - - if (R3.Utils.UndefinedOrNull(apiControlsD3)) { - apiControlsD3 = {}; - } - - R3.API.Controls.D3.call( - this, - apiControlsD3, - apiControlsD3.camera - ); - - if (R3.Utils.UndefinedOrNull(enabled)) { - enabled = true; - } - this.enabled = enabled; - - if (R3.Utils.UndefinedOrNull(movementSpeed)) { - movementSpeed = 1.0; - } - this.movementSpeed = movementSpeed; - - if (R3.Utils.UndefinedOrNull(lookSpeed)) { - lookSpeed = 0.005; - } - this.lookSpeed = lookSpeed; - - if (R3.Utils.UndefinedOrNull(lookVertical)) { - lookVertical = true; - } - this.lookVertical = lookVertical; - - if (R3.Utils.UndefinedOrNull(autoForward)) { - autoForward = false; - } - this.autoForward = autoForward; - - if (R3.Utils.UndefinedOrNull(activeLook)) { - activeLook = false; - } - this.activeLook = activeLook; - - if (R3.Utils.UndefinedOrNull(heightSpeed)) { - heightSpeed = false; - } - this.heightSpeed = heightSpeed; - - if (R3.Utils.UndefinedOrNull(heightCoef)) { - heightCoef = 1.0; - } - this.heightCoef = heightCoef; - - if (R3.Utils.UndefinedOrNull(heightMin)) { - heightMin = 0.0; - } - this.heightMin = heightMin; - - if (R3.Utils.UndefinedOrNull(heightMax)) { - heightMax = 1.0; - } - this.heightMax = heightMax; - - if (R3.Utils.UndefinedOrNull(constrainVertical)) { - constrainVertical = false; - } - this.constrainVertical = constrainVertical; - - if (R3.Utils.UndefinedOrNull(verticalMin)) { - verticalMin = 0; - } - this.verticalMin = verticalMin; - - if (R3.Utils.UndefinedOrNull(verticalMax)) { - verticalMax = Math.PI; - } - this.verticalMax = verticalMax; - - if (R3.Utils.UndefinedOrNull(autoSpeedFactor)) { - autoSpeedFactor = 0; - } - this.autoSpeedFactor = autoSpeedFactor; - -}; - -R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.D3.prototype); -R3.API.Controls.D3.FirstPerson.prototype.constructor = R3.API.Controls.D3.FirstPerson; diff --git a/src/r3-api-controls-d3-firstPerson.js b/src/r3-api-controls-d3-firstPerson.js new file mode 100644 index 0000000..7267df9 --- /dev/null +++ b/src/r3-api-controls-d3-firstPerson.js @@ -0,0 +1,88 @@ +/** + * R3.API.Controls.D3.FirstPerson + * @param apiComponent + * @constructor + */ +R3.API.Controls.D3.FirstPerson = function( + apiComponent +) { + + R3.API.Controls.D3.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) { + apiComponent.enabled = true; + } + this.enabled = apiComponent.enabled; + + if (R3.Utils.UndefinedOrNull(apiComponent.movementSpeed)) { + apiComponent.movementSpeed = 1.0; + } + this.movementSpeed = apiComponent.movementSpeed; + + if (R3.Utils.UndefinedOrNull(apiComponent.lookSpeed)) { + apiComponent.lookSpeed = 0.005; + } + this.lookSpeed = apiComponent.lookSpeed; + + if (R3.Utils.UndefinedOrNull(apiComponent.lookVertical)) { + apiComponent.lookVertical = true; + } + this.lookVertical = apiComponent.lookVertical; + + if (R3.Utils.UndefinedOrNull(apiComponent.autoForward)) { + apiComponent.autoForward = false; + } + this.autoForward = apiComponent.autoForward; + + if (R3.Utils.UndefinedOrNull(apiComponent.activeLook)) { + apiComponent.activeLook = false; + } + this.activeLook = apiComponent.activeLook; + + if (R3.Utils.UndefinedOrNull(apiComponent.heightSpeed)) { + apiComponent.heightSpeed = false; + } + this.heightSpeed = apiComponent.heightSpeed; + + if (R3.Utils.UndefinedOrNull(apiComponent.heightCoef)) { + apiComponent.heightCoef = 1.0; + } + this.heightCoef = apiComponent.heightCoef; + + if (R3.Utils.UndefinedOrNull(apiComponent.heightMin)) { + apiComponent.heightMin = 0.0; + } + this.heightMin = apiComponent.heightMin; + + if (R3.Utils.UndefinedOrNull(apiComponent.heightMax)) { + apiComponent.heightMax = 1.0; + } + this.heightMax = apiComponent.heightMax; + + if (R3.Utils.UndefinedOrNull(apiComponent.constrainVertical)) { + apiComponent.constrainVertical = false; + } + this.constrainVertical = apiComponent.constrainVertical; + + if (R3.Utils.UndefinedOrNull(apiComponent.verticalMin)) { + apiComponent.verticalMin = 0; + } + this.verticalMin = apiComponent.verticalMin; + + if (R3.Utils.UndefinedOrNull(apiComponent.verticalMax)) { + apiComponent.verticalMax = Math.PI; + } + this.verticalMax = apiComponent.verticalMax; + + if (R3.Utils.UndefinedOrNull(apiComponent.autoSpeedFactor)) { + apiComponent.autoSpeedFactor = 0; + } + this.autoSpeedFactor = apiComponent.autoSpeedFactor; + +}; + +R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.D3.prototype); +R3.API.Controls.D3.FirstPerson.prototype.constructor = R3.API.Controls.D3.FirstPerson; diff --git a/src/r3-api-controls-d3-orbit.js b/src/r3-api-controls-d3-orbit.js index e861f1f..083d8a6 100644 --- a/src/r3-api-controls-d3-orbit.js +++ b/src/r3-api-controls-d3-orbit.js @@ -1,126 +1,91 @@ /** * R3.API.Controls.D3.Orbit - * @param apiControlsD3 - * @param target - * @param enabled - * @param minPolarAngle - * @param maxPolarAngle - * @param enableDamping - * @param dampingFactor - * @param enableZoom - * @param zoomSpeed - * @param enableRotate - * @param rotateSpeed - * @param enablePan - * @param keyPanSpeed - * @param autoRotate - * @param autoRotateSpeed - * @param enableKeys + * @param apiComponent * @constructor */ R3.API.Controls.D3.Orbit = function( - apiControlsD3, - target, - enabled, - minPolarAngle, - maxPolarAngle, - enableDamping, - dampingFactor, - enableZoom, - zoomSpeed, - enableRotate, - rotateSpeed, - enablePan, - keyPanSpeed, - autoRotate, - autoRotateSpeed, - enableKeys + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiControlsD3)) { - apiControlsD3 = {}; - } - R3.API.Controls.D3.call( this, - apiControlsD3, - apiControlsD3.camera + apiComponent ); - if (R3.Utils.UndefinedOrNull(target)) { - target = null; + if (R3.Utils.UndefinedOrNull(apiComponent.target)) { + apiComponent.target = null; } - this.target = target; + this.target = apiComponent.target; - if (R3.Utils.UndefinedOrNull(enabled)) { - enabled = true; + if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) { + apiComponent.enabled = true; } - this.enabled = enabled; + this.enabled = apiComponent.enabled; - if (R3.Utils.UndefinedOrNull(minPolarAngle)) { - minPolarAngle = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.minPolarAngle)) { + apiComponent.minPolarAngle = 0; } - this.minPolarAngle = minPolarAngle; + this.minPolarAngle = apiComponent.minPolarAngle; - if (R3.Utils.UndefinedOrNull(maxPolarAngle)) { - maxPolarAngle = Math.PI; + if (R3.Utils.UndefinedOrNull(apiComponent.maxPolarAngle)) { + apiComponent.maxPolarAngle = Math.PI; } - this.maxPolarAngle = maxPolarAngle; + this.maxPolarAngle = apiComponent.maxPolarAngle; - if (R3.Utils.UndefinedOrNull(enableDamping)) { - enableDamping = false; + if (R3.Utils.UndefinedOrNull(apiComponent.enableDamping)) { + apiComponent.enableDamping = false; } - this.enableDamping = enableDamping; + this.enableDamping = apiComponent.enableDamping; - if (R3.Utils.UndefinedOrNull(dampingFactor)) { - dampingFactor = 0.25; + if (R3.Utils.UndefinedOrNull(apiComponent.dampingFactor)) { + apiComponent.dampingFactor = 0.25; } - this.dampingFactor = dampingFactor; + this.dampingFactor = apiComponent.dampingFactor; - if (R3.Utils.UndefinedOrNull(enableZoom)) { - enableZoom = true; + if (R3.Utils.UndefinedOrNull(apiComponent.enableZoom)) { + apiComponent.enableZoom = true; } - this.enableZoom = enableZoom; + this.enableZoom = apiComponent.enableZoom; - if (R3.Utils.UndefinedOrNull(zoomSpeed)) { - zoomSpeed = 1.0; + if (R3.Utils.UndefinedOrNull(apiComponent.zoomSpeed)) { + apiComponent.zoomSpeed = 1.0; } - this.zoomSpeed = zoomSpeed; + this.zoomSpeed = apiComponent.zoomSpeed; - if (R3.Utils.UndefinedOrNull(enableRotate)) { - enableRotate = true; + if (R3.Utils.UndefinedOrNull(apiComponent.enableRotate)) { + apiComponent.enableRotate = true; } - this.enableRotate = enableRotate; + this.enableRotate = apiComponent.enableRotate; - if (R3.Utils.UndefinedOrNull(rotateSpeed)) { - rotateSpeed = 1.0; + if (R3.Utils.UndefinedOrNull(apiComponent.rotateSpeed)) { + apiComponent.rotateSpeed = 1.0; } - this.rotateSpeed = rotateSpeed; + this.rotateSpeed = apiComponent.rotateSpeed; - if (R3.Utils.UndefinedOrNull(enablePan)) { - enablePan = true; + if (R3.Utils.UndefinedOrNull(apiComponent.enablePan)) { + apiComponent.enablePan = true; } - this.enablePan = enablePan; + this.enablePan = apiComponent.enablePan; - if (R3.Utils.UndefinedOrNull(keyPanSpeed)) { - keyPanSpeed = 7.0; + if (R3.Utils.UndefinedOrNull(apiComponent.keyPanSpeed)) { + apiComponent.keyPanSpeed = 7.0; } - this.keyPanSpeed = keyPanSpeed; + this.keyPanSpeed = apiComponent.keyPanSpeed; - if (R3.Utils.UndefinedOrNull(autoRotate)) { - autoRotate = false; + if (R3.Utils.UndefinedOrNull(apiComponent.autoRotate)) { + apiComponent.autoRotate = false; } - this.autoRotate = autoRotate; + this.autoRotate = apiComponent.autoRotate; - if (R3.Utils.UndefinedOrNull(autoRotateSpeed)) { - autoRotateSpeed = 2.0; + if (R3.Utils.UndefinedOrNull(apiComponent.autoRotateSpeed)) { + apiComponent.autoRotateSpeed = 2.0; } - this.autoRotateSpeed = autoRotateSpeed; + this.autoRotateSpeed = apiComponent.autoRotateSpeed; - if (R3.Utils.UndefinedOrNull(enableKeys)) { - enableKeys = false; + if (R3.Utils.UndefinedOrNull(apiComponent.enableKeys)) { + apiComponent.enableKeys = false; } - this.enableKeys = enableKeys; + this.enableKeys = apiComponent.enableKeys; }; diff --git a/src/r3-api-controls-keyboard.js b/src/r3-api-controls-keyboard.js index a696c21..de6840a 100644 --- a/src/r3-api-controls-keyboard.js +++ b/src/r3-api-controls-keyboard.js @@ -1,14 +1,14 @@ /** - * @param apiControls + * R3.API.Controls.Keyboard + * @param apiComponent * @constructor */ R3.API.Controls.Keyboard = function( - apiControls + apiComponent ) { R3.API.Controls.call( this, - apiControls, - apiControls.canvas + apiComponent ); }; diff --git a/src/r3-api-controls-mouse.js b/src/r3-api-controls-mouse.js index 344b07a..f09de74 100644 --- a/src/r3-api-controls-mouse.js +++ b/src/r3-api-controls-mouse.js @@ -1,14 +1,14 @@ /** - * @param apiControls + * R3.API.Controls.Mouse + * @param apiComponent * @constructor */ R3.API.Controls.Mouse = function( - apiControls + apiComponent ) { R3.API.Controls.call( this, - apiControls, - apiControls.canvas + apiComponent ); }; diff --git a/src/r3-api-controls-touch.js b/src/r3-api-controls-touch.js index 17cf745..13fa4b3 100644 --- a/src/r3-api-controls-touch.js +++ b/src/r3-api-controls-touch.js @@ -14,10 +14,10 @@ R3.API.Controls.Touch = function( apiControls.canvas ); - if (R3.Utils.UndefinedOrNull(sensitivity)) { - sensitivity = 5; + if (R3.Utils.UndefinedOrNull(apiComponent.sensitivity)) { + apiComponent.sensitivity = 5; } - this.sensitivity = sensitivity; + this.sensitivity = apiComponent.sensitivity; }; diff --git a/src/r3-api-curve-0.js b/src/r3-api-curve-0.js index ab24bee..c180dab 100644 --- a/src/r3-api-curve-0.js +++ b/src/r3-api-curve-0.js @@ -1,20 +1,19 @@ /** * R3.API.Curve * @param apiComponent - * @param arcLenghDivisions * @constructor */ R3.API.Curve = function( - apiComponent, - arcLenghDivisions + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(arcLenghDivisions)) { - arcLenghDivisions = 200; + if (R3.Utils.UndefinedOrNull(apiComponent.arcLenghDivisions)) { + apiComponent.arcLenghDivisions = 200; } - this.arcLenghDivisions = arcLenghDivisions; + this.arcLenghDivisions = apiComponent.arcLenghDivisions; + }; R3.API.Curve.prototype = Object.create(R3.API.Curve.prototype); diff --git a/src/r3-api-curve-path-a.js b/src/r3-api-curve-path-0.js similarity index 50% rename from src/r3-api-curve-path-a.js rename to src/r3-api-curve-path-0.js index ab818db..7e34f71 100644 --- a/src/r3-api-curve-path-a.js +++ b/src/r3-api-curve-path-0.js @@ -10,10 +10,10 @@ R3.API.Curve.Path = function( curves, autoClose ) { - if (R3.Utils.UndefinedOrNull(apiCurve)) { - apiCurve = {} + if (R3.Utils.UndefinedOrNull(apiComponent.apiCurve)) { + apiComponent.apiCurve = {} } - this.apiCurve = apiCurve; + this.apiCurve = apiComponent.apiCurve; R3.API.Curve.call( this, @@ -21,15 +21,15 @@ R3.API.Curve.Path = function( apiCurve.arcLenghDivisions ); - if (R3.Utils.UndefinedOrNull(curves)) { - curves = []; + if (R3.Utils.UndefinedOrNull(apiComponent.curves)) { + apiComponent.curves = []; } - this.curves = curves; + this.curves = apiComponent.curves; - if (R3.Utils.UndefinedOrNull(autoClose)) { - autoClose = false; + if (R3.Utils.UndefinedOrNull(apiComponent.autoClose)) { + apiComponent.autoClose = false; } - this.autoClose = autoClose; + this.autoClose = apiComponent.autoClose; }; R3.API.Curve.Path.prototype = Object.create(R3.API.Curve.prototype); diff --git a/src/r3-api-curve-path-d2-a.js b/src/r3-api-curve-path-d2-0.js similarity index 61% rename from src/r3-api-curve-path-d2-a.js rename to src/r3-api-curve-path-d2-0.js index 768d612..3de4e79 100644 --- a/src/r3-api-curve-path-d2-a.js +++ b/src/r3-api-curve-path-d2-0.js @@ -9,10 +9,10 @@ R3.API.Curve.Path.D2 = function( points ) { - if (R3.Utils.UndefinedOrNull(apiCurvePath)) { - apiCurvePath = {} + if (R3.Utils.UndefinedOrNull(apiComponent.apiCurvePath)) { + apiComponent.apiCurvePath = {} } - this.apiCurvePath = apiCurvePath; + this.apiCurvePath = apiComponent.apiCurvePath; R3.API.Curve.Path.call( this, @@ -21,10 +21,10 @@ R3.API.Curve.Path.D2 = function( apiCurvePath.autoClose ); - if (R3.Utils.UndefinedOrNull(points)) { - points = []; + if (R3.Utils.UndefinedOrNull(apiComponent.points)) { + apiComponent.points = []; } - this.points = points; + this.points = apiComponent.points; }; diff --git a/src/r3-api-curve-path-d2-shape.js b/src/r3-api-curve-path-d2-shape.js index bd20af3..1591d29 100644 --- a/src/r3-api-curve-path-d2-shape.js +++ b/src/r3-api-curve-path-d2-shape.js @@ -6,8 +6,8 @@ R3.API.Curve.Path.D2.Shape = function( apiCurvePathD2 ) { - if (R3.Utils.UndefinedOrNull(apiCurvePathD2)) { - apiCurvePathD2 = {}; + if (R3.Utils.UndefinedOrNull(apiComponent.apiCurvePathD2)) { + apiComponent.apiCurvePathD2 = {}; } R3.API.Curve.Path.call( diff --git a/src/r3-api-custom-code.js b/src/r3-api-custom-code.js deleted file mode 100644 index 622b3de..0000000 --- a/src/r3-api-custom-code.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Custom Code Component - * @param apiComponent - * @param eventId - * @param code - * @constructor - */ -R3.API.CustomCode = function( - apiComponent, - eventId, - code -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(eventId)) { - eventId = R3.Event.KEY_UP; - } - this.eventId = eventId; - - if (R3.Utils.UndefinedOrNull(code)) { - code = "return null;\n//@ sourceURL=" + this.name + ".js"; - } - this.code = code; -}; - -R3.API.CustomCode.prototype = Object.create(R3.API.Component.prototype); -R3.API.CustomCode.prototype.constructor = R3.API.CustomCode; diff --git a/src/r3-api-customCode.js b/src/r3-api-customCode.js new file mode 100644 index 0000000..d8b8dec --- /dev/null +++ b/src/r3-api-customCode.js @@ -0,0 +1,24 @@ +/** + * R3.API.CustomCode + * @param apiComponent + * @constructor + */ +R3.API.CustomCode = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.eventId)) { + apiComponent.eventId = R3.Event.KEY_UP; + } + this.eventId = apiComponent.eventId; + + if (R3.Utils.UndefinedOrNull(apiComponent.code)) { + apiComponent.code = "return null;\n//@ sourceURL=" + this.name + ".js"; + } + this.code = apiComponent.code; +}; + +R3.API.CustomCode.prototype = Object.create(R3.API.Component.prototype); +R3.API.CustomCode.prototype.constructor = R3.API.CustomCode; diff --git a/src/r3-api-dom-element.js b/src/r3-api-domElement.js similarity index 54% rename from src/r3-api-dom-element.js rename to src/r3-api-domElement.js index 7d36479..5fd45a8 100644 --- a/src/r3-api-dom-element.js +++ b/src/r3-api-domElement.js @@ -1,20 +1,18 @@ /** * API DomElement * @param apiComponent - * @param domElementId * @constructor */ R3.API.DomElement = function( - apiComponent, - domElementId + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(domElementId)) { - domElementId = ''; + if (R3.Utils.UndefinedOrNull(apiComponent.domElementId)) { + apiComponent.domElementId = ''; } - this.domElementId = domElementId; + this.domElementId = apiComponent.domElementId; }; R3.API.DomElement.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-draw-range.js b/src/r3-api-draw-range.js deleted file mode 100644 index 117d324..0000000 --- a/src/r3-api-draw-range.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * R3.API.Box3 - * @constructor - * @param apiComponent - * @param start - * @param count - */ -R3.API.DrawRange = function( - apiComponent, - start, - count -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(start)) { - start = 0; - } - this.start = start; - - if (R3.Utils.UndefinedOrNull(count)) { - count = Infinity; - } - this.count = count; - -}; - -R3.API.DrawRange.prototype = Object.create(R3.API.Component.prototype); -R3.API.DrawRange.prototype.constructor = R3.API.DrawRange; diff --git a/src/r3-api-drawRange.js b/src/r3-api-drawRange.js new file mode 100644 index 0000000..f3d8d4f --- /dev/null +++ b/src/r3-api-drawRange.js @@ -0,0 +1,25 @@ +/** + * R3.API.DrawRange + * @param apiComponent + * @constructor + */ +R3.API.DrawRange = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.start)) { + apiComponent.start = 0; + } + this.start = apiComponent.start; + + if (R3.Utils.UndefinedOrNull(apiComponent.count)) { + apiComponent.count = Infinity; + } + this.count = apiComponent.count; + +}; + +R3.API.DrawRange.prototype = Object.create(R3.API.Component.prototype); +R3.API.DrawRange.prototype.constructor = R3.API.DrawRange; diff --git a/src/r3-api-entity-manager.js b/src/r3-api-entity-manager.js deleted file mode 100644 index 389131c..0000000 --- a/src/r3-api-entity-manager.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Entity API Object (for storing / loading entities to and from API) - * @constructor - * @param apiComponent - * @param entities R3.API.Entity[] - */ -R3.API.EntityManager = function( - apiComponent, - entities -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(entities)) { - entities = []; - } - this.entities = entities; -}; - -R3.API.EntityManager.prototype = Object.create(R3.API.Component.prototype); -R3.API.EntityManager.prototype.constructor = R3.API.EntityManager; diff --git a/src/r3-api-entity.js b/src/r3-api-entity.js index 49e5e55..ee9ef9b 100644 --- a/src/r3-api-entity.js +++ b/src/r3-api-entity.js @@ -1,20 +1,18 @@ /** - * Entity API Object (for storing / loading entities to and from API) + * R3.API.Entity * @param apiComponent - * @param components R3.API.Component[] * @constructor */ R3.API.Entity = function( - apiComponent, - components + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(components)) { - components = []; + if (R3.Utils.UndefinedOrNull(apiComponent.components)) { + apiComponent.components = []; } - this.components = components; + this.components = apiComponent.components; }; diff --git a/src/r3-api-entityManager.js b/src/r3-api-entityManager.js new file mode 100644 index 0000000..fd34539 --- /dev/null +++ b/src/r3-api-entityManager.js @@ -0,0 +1,19 @@ +/** + * R3.API.EntityManager + * @param apiComponent + * @constructor + */ +R3.API.EntityManager = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.entities)) { + apiComponent.entities = []; + } + this.entities = apiComponent.entities; +}; + +R3.API.EntityManager.prototype = Object.create(R3.API.Component.prototype); +R3.API.EntityManager.prototype.constructor = R3.API.EntityManager; diff --git a/src/r3-api-font.js b/src/r3-api-font.js index 00dce5f..dd622d4 100644 --- a/src/r3-api-font.js +++ b/src/r3-api-font.js @@ -1,20 +1,18 @@ /** - * R3.D3.API.Font + * R3.API.Font * @param apiComponent - * @param path - Relative to API URL * @constructor */ R3.API.Font = function( - apiComponent, - path + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(path)) { - path = ''; + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = ''; } - this.path = path; + this.path = apiComponent.path; }; diff --git a/src/r3-api-graph-0.js b/src/r3-api-graph-0.js new file mode 100644 index 0000000..cd61b04 --- /dev/null +++ b/src/r3-api-graph-0.js @@ -0,0 +1,23 @@ +/** + * R3.API.Graph + * @param apiComponent + * + * @property domElement + * + * @constructor + */ +R3.API.Graph = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; + } + this.domElement = apiComponent.domElement; + +}; + +R3.API.Graph.prototype = Object.create(R3.API.Component.prototype); +R3.API.Graph.prototype.constructor = R3.API.Graph; diff --git a/src/r3-api-graph-barchart-0.js b/src/r3-api-graph-barchart-0.js new file mode 100644 index 0000000..2e16916 --- /dev/null +++ b/src/r3-api-graph-barchart-0.js @@ -0,0 +1,18 @@ +/** + * R3.API.Graph.Barchart + * @param apiComponent + * @constructor + */ +R3.API.Graph.Barchart = function( + apiComponent +) { + + R3.API.Graph.call( + this, + apiComponent + ); + +}; + +R3.API.Graph.Barchart.prototype = Object.create(R3.API.Graph.prototype); +R3.API.Graph.Barchart.prototype.constructor = R3.API.Graph.Barchart; diff --git a/src/r3-api-graph-barchart-stacked.js b/src/r3-api-graph-barchart-stacked.js new file mode 100644 index 0000000..409c4ac --- /dev/null +++ b/src/r3-api-graph-barchart-stacked.js @@ -0,0 +1,18 @@ +/** + * R3.API.Graph.Barchart + * @param apiComponent + * @constructor + */ +R3.API.Graph.Barchart.Stacked = function( + apiComponent +) { + + R3.API.Graph.Barchart.call( + this, + apiComponent + ); + +}; + +R3.API.Graph.Barchart.prototype = Object.create(R3.API.Graph.Barchart.prototype); +R3.API.Graph.Barchart.prototype.constructor = R3.API.Graph.Barchart; diff --git a/src/r3-api-graph-metric.js b/src/r3-api-graph-metric.js new file mode 100644 index 0000000..860baef --- /dev/null +++ b/src/r3-api-graph-metric.js @@ -0,0 +1,18 @@ +/** + * R3.API.Graph.Metric + * @param apiComponent + * @constructor + */ +R3.API.Graph.Metric = function( + apiComponent +) { + + R3.API.Graph.call( + this, + apiComponent + ); + +}; + +R3.API.Graph.Metric.prototype = Object.create(R3.API.Graph.prototype); +R3.API.Graph.Metric.prototype.constructor = R3.API.Graph.Metric; diff --git a/src/r3-api-graph-table.js b/src/r3-api-graph-table.js new file mode 100644 index 0000000..637c952 --- /dev/null +++ b/src/r3-api-graph-table.js @@ -0,0 +1,18 @@ +/** + * R3.API.Graph.Table + * @param apiComponent + * @constructor + */ +R3.API.Graph.Table = function( + apiComponent +) { + + R3.API.Graph.call( + this, + apiComponent + ); + +}; + +R3.API.Graph.Table.prototype = Object.create(R3.API.Graph.prototype); +R3.API.Graph.Table.prototype.constructor = R3.API.Graph.Table; diff --git a/src/r3-api-group.js b/src/r3-api-group.js index 434385c..dcad033 100644 --- a/src/r3-api-group.js +++ b/src/r3-api-group.js @@ -1,34 +1,28 @@ /** * R3.API.Group - * @constructor * @param apiComponent - * @param start - * @param count - * @param materialIndex + * @constructor */ R3.API.Group = function( - apiComponent, - start, - count, - materialIndex + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(start)) { - start = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.start)) { + apiComponent.start = 0; } - this.start = start; + this.start = apiComponent.start; - if (R3.Utils.UndefinedOrNull(count)) { - count = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.count)) { + apiComponent.count = 0; } - this.count = count; + this.count = apiComponent.count; - if (R3.Utils.UndefinedOrNull(materialIndex)) { - materialIndex = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.materialIndex)) { + apiComponent.materialIndex = 0; } - this.materialIndex = materialIndex; + this.materialIndex = apiComponent.materialIndex; }; R3.API.Group.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-gui.js b/src/r3-api-gui.js index 7e42b17..d54ec8b 100644 --- a/src/r3-api-gui.js +++ b/src/r3-api-gui.js @@ -1,20 +1,18 @@ /** * Raw GUI API object - should always correspond with the GUI Schema * @param apiComponent - * @param domElement * @constructor */ R3.API.GUI = function( - apiComponent, - domElement + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(domElement)) { - domElement = null; + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; } - this.domElement = domElement; + this.domElement = apiComponent.domElement; }; R3.API.GUI.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-image.js b/src/r3-api-image.js index fda5580..ab60175 100644 --- a/src/r3-api-image.js +++ b/src/r3-api-image.js @@ -1,75 +1,61 @@ /** * R3.API.Image * @param apiComponent - * @param fileName - * @param extension - * @param path - * @param contentType - * @param size - * @param width - * @param height * @constructor */ R3.API.Image = function( - apiComponent, - fileName, - extension, - path, - contentType, - size, - width, - height + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(fileName)) { - fileName = R3.Utils.LowerUnderscore(name); + if (R3.Utils.UndefinedOrNull(apiComponent.fileName)) { + apiComponent.fileName = R3.Utils.LowerUnderscore(name); } - this.fileName = fileName; + this.fileName = apiComponent.fileName; - if (R3.Utils.UndefinedOrNull(extension)) { - extension = '.unknown'; + if (R3.Utils.UndefinedOrNull(apiComponent.extension)) { + apiComponent.extension = '.unknown'; } - this.extension = extension; + this.extension = apiComponent.extension; - if (R3.Utils.UndefinedOrNull(path)) { - path = '/'; + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = '/'; } - this.path = path; + this.path = apiComponent.path; - if (R3.Utils.UndefinedOrNull(contentType)) { + if (R3.Utils.UndefinedOrNull(apiComponent.contentType)) { - contentType = 'application/octet-stream'; + apiComponent.contentType = 'application/octet-stream'; if (this.extension.match(/(png)$/i)) { - contentType = 'image/png'; + apiComponent.contentType = 'image/png'; } if (this.extension.match(/(jpg|jpeg)$/i)) { - contentType = 'image/jpeg'; + apiComponent.contentType = 'image/jpeg'; } if (this.extension.match(/(gif)$/i)) { - contentType = 'image/gif'; + apiComponent.contentType = 'image/gif'; } } - this.contentType = contentType; + this.contentType = apiComponent.contentType; - if (R3.Utils.UndefinedOrNull(size)) { - size = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = 0; } - this.size = size; + this.size = apiComponent.size; - if (R3.Utils.UndefinedOrNull(width)) { - width = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 0; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 0; } - this.height = height; + this.height = apiComponent.height; }; diff --git a/src/r3-api-matrix4.js b/src/r3-api-matrix4.js index 9b8a858..855a027 100644 --- a/src/r3-api-matrix4.js +++ b/src/r3-api-matrix4.js @@ -1,89 +1,165 @@ /** - * Api Matrix 4 - * @param row0 R3.API.Vector4 - * @param row1 R3.API.Vector4 - * @param row2 R3.API.Vector4 - * @param row3 R3.API.Vector4 + * R3.API.Matrix4 + * @param apiComponent + * + * @property rows [R3.API.Vector4] + * * @constructor */ -R3.API.Matrix4 = function ApiMatrix4( - row0, - row1, - row2, - row3 +R3.API.Matrix4 = function ( + apiComponent ) { - this.rows = []; + __DEREGISTER_COMPONENT__; - if (R3.Utils.UndefinedOrNull(row0)) { - row0 = new R3.API.Vector4(1, 0, 0, 0); + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.rows)) { + + apiComponent.rows = []; + + apiComponent.rows.push( + new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 1, + y : 0, + z : 0, + w : 0 + } + ) + ); + + apiComponent.rows.push( + new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 0, + y : 1, + z : 0, + w : 0 + } + ) + ); + + apiComponent.rows.push( + new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 0, + y : 0, + z : 1, + w : 0 + } + ) + ); + + apiComponent.rows.push( + new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 0, + y : 0, + z : 0, + w : 1 + } + ) + ); } - this.rows[0] = row0; + this.rows = apiComponent.rows; - if (R3.Utils.UndefinedOrNull(row1)) { - row1 = new R3.API.Vector4(0, 1, 0, 0); - } - this.rows[1] = row1; - - if (R3.Utils.UndefinedOrNull(row2)) { - row2 = new R3.API.Vector4(0, 0, 1, 0); - } - this.rows[2] = row2; - - if (R3.Utils.UndefinedOrNull(row3)) { - row3 = new R3.API.Vector4(0, 0, 0, 1); - } - this.rows[3] = row3; - - this.temp = []; - this.temp.push( - new R3.API.Vector4() - ); - - this.temp.push( - new R3.API.Vector4() - ); - - this.temp.push( - new R3.API.Vector4() - ); - - this.temp.push( - new R3.API.Vector4() - ); - - this.forward = new R3.API.Vector4(); - this.left = new R3.API.Vector4(); - this.up = new R3.API.Vector4(); }; +R3.API.Matrix4.prototype = Object.create(R3.API.Component.prototype); +R3.API.Matrix4.prototype.constructor = R3.API.Matrix4; + R3.API.Matrix4.prototype.rotationMatrixX = function(radians) { + this.identity(); - this.rows[1] = new R3.API.Vector4(0, Math.cos(radians), -1 * Math.sin(radians), 0); - this.rows[2] = new R3.API.Vector4(0, Math.sin(radians), Math.cos(radians), 0); + + this.rows[1] = new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 0, + y : Math.cos(radians), + z : -1 * Math.sin(radians), + w : 0 + } + ); + + this.rows[2] = new R3.API.Vector4( + { + parent : this, + register : this.register, + x : 0, + y : Math.sin(radians), + z : Math.cos(radians), + w : 0 + } + ); + return this; }; R3.API.Matrix4.prototype.rotationMatrixY = function(radians) { + this.identity(); + this.rows[0] = new R3.API.Vector4( - Math.cos(radians), - 0, - Math.sin(radians), - 0 + { + parent : this, + register : this.register, + x : Math.cos(radians), + y : 0, + z : Math.sin(radians), + w : 0 + } ); + this.rows[2] = new R3.API.Vector4( - -1 * Math.sin(radians), - 0, - Math.cos(radians), - 0 + { + parent : this, + register : this.register, + x : -1 * Math.sin(radians), + y : 0, + z : Math.cos(radians), + w : 0 + } ); + return this; }; R3.API.Matrix4.prototype.rotationMatrixZ = function(radians) { + this.identity(); - this.rows[0] = new R3.API.Vector4(Math.cos(radians), -1 * Math.sin(radians), 0, 0); - this.rows[1] = new R3.API.Vector4(Math.sin(radians), Math.cos(radians), 0, 0); + + this.rows[0] = new R3.API.Vector4( + { + parent : this, + register : this.register, + x : Math.cos(radians), + y : -1 * Math.sin(radians), + z : 0, + w : 0 + } + ); + + this.rows[1] = new R3.API.Vector4( + { + parent : this, + register : this.register, + x : Math.sin(radians), + y : Math.cos(radians), + z : 0, + w : 0 + } + ); + return this; }; @@ -108,25 +184,48 @@ R3.API.Matrix4.prototype.rotateZ = function(radians, point) { R3.API.Matrix4.prototype.multiply = function(mvp) { if (mvp instanceof R3.API.Quaternion || mvp instanceof R3.API.Vector4) { return new R3.API.Quaternion( - this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w, - this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w, - this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w, - this.rows[3].x * mvp.x + this.rows[3].y * mvp.y + this.rows[3].z * mvp.z + this.rows[3].w * mvp.w + { + parent : this, + register : this.register, + x : this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z + this.rows[0].w * mvp.w, + y : this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z + this.rows[1].w * mvp.w, + z : this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + this.rows[2].w * mvp.w, + w : this.rows[3].x * mvp.x + this.rows[3].y * mvp.y + this.rows[3].z * mvp.z + this.rows[3].w * mvp.w + } ); } else if (mvp instanceof R3.API.Vector3) { return new R3.API.Vector3( - this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z, - this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z, - this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + { + parent : this, + register : this.register, + x : this.rows[0].x * mvp.x + this.rows[0].y * mvp.y + this.rows[0].z * mvp.z, + y : this.rows[1].x * mvp.x + this.rows[1].y * mvp.y + this.rows[1].z * mvp.z, + z : this.rows[2].x * mvp.x + this.rows[2].y * mvp.y + this.rows[2].z * mvp.z + } ); } }; R3.API.Matrix4.prototype.identity = function() { - this.rows = [ - new R3.API.Vector4(1, 0, 0, 0), - new R3.API.Vector4(0, 1, 0, 0), - new R3.API.Vector4(0, 0, 1, 0), - new R3.API.Vector4(0, 0, 0, 1) - ]; + + this.rows[0].x = 1; + this.rows[0].y = 0; + this.rows[0].z = 0; + this.rows[0].w = 0; + + this.rows[1].x = 0; + this.rows[1].y = 1; + this.rows[1].z = 0; + this.rows[1].w = 0; + + this.rows[2].x = 0; + this.rows[2].y = 0; + this.rows[2].z = 1; + this.rows[2].w = 0; + + this.rows[3].x = 0; + this.rows[3].y = 0; + this.rows[3].z = 0; + this.rows[3].w = 1; + }; diff --git a/src/r3-api-mouse.js b/src/r3-api-mouse.js index 117141d..8e66e94 100644 --- a/src/r3-api-mouse.js +++ b/src/r3-api-mouse.js @@ -1,27 +1,23 @@ /** * R3.API.Mouse * @param apiComponent - * @param x - * @param y * @constructor */ R3.API.Mouse = function( - apiComponent, - x, - y + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(x)) { - x = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.x)) { + apiComponent.x = 0; } - this.x = x; + this.x = apiComponent.x; - if (R3.Utils.UndefinedOrNull(y)) { - y = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.y)) { + apiComponent.y = 0; } - this.y = y; + this.y = apiComponent.y; }; diff --git a/src/r3-api-plane.js b/src/r3-api-plane.js index f5aca4a..43bce65 100644 --- a/src/r3-api-plane.js +++ b/src/r3-api-plane.js @@ -1,27 +1,31 @@ /** * R3.API.Plane * @param apiComponent - * @param normal - * @param constant * @constructor */ R3.API.Plane = function( - apiComponent, - normal, - constant + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(normal)) { - normal = new R3.API.Vector3(1,0,0); + if (R3.Utils.UndefinedOrNull(apiComponent.normal)) { + apiComponent.normal = new R3.API.Vector3( + { + register : true, + parent : this, + x : 0, + y : 0, + z : 0 + } + ); } - this.normal = normal; + this.normal = apiComponent.normal; - if (R3.Utils.UndefinedOrNull(constant)) { - constant = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.constant)) { + apiComponent.constant = 0; } - this.constant = constant; + this.constant = apiComponent.constant; }; diff --git a/src/r3-api-project.js b/src/r3-api-project.js index e1ed201..a8cf487 100644 --- a/src/r3-api-project.js +++ b/src/r3-api-project.js @@ -1,56 +1,51 @@ /** - * API Project + * R3.API.Project * @param apiComponent - * @param users - * @param isPublic - * @param entities - * @param renderers - * @param renderTargets - * @param cameras - * @param audios - * @param applicationMode + * + * @property users + * @property isPublic + * @property entities + * @property renderers + * @property renderTargets + * @property cameras + * @property controls + * @property audios + * @property applicationMode + * * @constructor */ R3.API.Project = function( - apiComponent, - users, - isPublic, - entities, - renderers, - renderTargets, - cameras, - audios, - applicationMode + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(users)) { + if (R3.Utils.UndefinedOrNull(apiComponent.users)) { throw new Error('Only registered users can create projects'); } - this.users = users; + this.users = apiComponent.users; - if (R3.Utils.UndefinedOrNull(isPublic)) { - isPublic = true; + if (R3.Utils.UndefinedOrNull(apiComponent.isPublic)) { + apiComponent.isPublic = true; } - this.isPublic = isPublic; + this.isPublic = apiComponent.isPublic; - if (R3.Utils.UndefinedOrNull(entities)) { - entities = []; + if (R3.Utils.UndefinedOrNull(apiComponent.entities)) { + apiComponent.entities = []; } - this.entities = entities; + this.entities = apiComponent.entities; - if (R3.Utils.UndefinedOrNull(renderers)) { - renderers = [new R3.API.Renderer.D3()]; + if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) { + apiComponent.renderers = [new R3.API.Renderer.D3()]; } - this.renderers = renderers; + this.renderers = apiComponent.renderers; - if (R3.Utils.UndefinedOrNull(renderTargets)) { - renderTargets = []; + if (R3.Utils.UndefinedOrNull(apiComponent.renderTargets)) { + apiComponent.renderTargets = []; } - this.renderTargets = renderTargets; + this.renderTargets = apiComponent.renderTargets; - if (R3.Utils.UndefinedOrNull(cameras)) { + if (R3.Utils.UndefinedOrNull(apiComponent.cameras)) { var editCamera = new R3.D3.API.Camera.Perspective( { name : 'Edit Camera' @@ -61,30 +56,35 @@ R3.API.Project = function( name : 'Run Camera' } ); - cameras = [editCamera, runCamera]; + apiComponent.cameras = [editCamera, runCamera]; } - this.cameras = cameras; + this.cameras = apiComponent.cameras; - if (R3.Utils.UndefinedOrNull(audios)) { - audios = []; + if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { + apiComponent.controls = []; } - this.audios = audios; + this.controls = apiComponent.controls; - if (R3.Utils.UndefinedOrNull(applicationMode)) { - applicationMode = R3.API.Project.APPLICATION_MODE_EDIT; + if (R3.Utils.UndefinedOrNull(apiComponent.audios)) { + apiComponent.audios = []; } - this.applicationMode = applicationMode; + this.audios = apiComponent.audios; + + if (R3.Utils.UndefinedOrNull(apiComponent.applicationMode)) { + apiComponent.applicationMode = R3.API.Project.APPLICATION_MODE_EDIT; + } + this.applicationMode = apiComponent.applicationMode; }; R3.API.Project.prototype = Object.create(R3.API.Component.prototype); R3.API.Project.prototype.constructor = R3.API.Project; -R3.API.Project.APPLICATION_MODE_RUN = 0x1; -R3.API.Project.APPLICATION_MODE_EDIT = 0x2; - R3.API.Project.CAMERA_INDEX_EDIT = 0x0; R3.API.Project.CAMERA_INDEX_RUN = 0x1; +R3.API.Project.APPLICATION_MODE_EDIT = R3.API.Project.CAMERA_INDEX_EDIT; +R3.API.Project.APPLICATION_MODE_RUN = R3.API.Project.CAMERA_INDEX_RUN; + R3.API.Project.RENDERER_INDEX_MAIN = 0x0; R3.API.Project.RENDER_TARGET_INDEX_NONE = -0x1; \ No newline at end of file diff --git a/src/r3-api-quaternion-a.js b/src/r3-api-quaternion-0.js similarity index 76% rename from src/r3-api-quaternion-a.js rename to src/r3-api-quaternion-0.js index 20606e3..f9a2e0d 100644 --- a/src/r3-api-quaternion-a.js +++ b/src/r3-api-quaternion-0.js @@ -1,53 +1,55 @@ /** - * Quaternion - * @param x - * @param y - * @param z - * @param w - * @param axis - * @param angle + * R3.API.Quaternion + * @param apiComponent * @constructor */ R3.API.Quaternion = function( - x, - y, - z, - w, - axis, - angle + apiComponent ) { - if (R3.Utils.UndefinedOrNull(x)) { - x = 0; - } - this.x = x; + __DEREGISTER_COMPONENT__; - if (R3.Utils.UndefinedOrNull(y)) { - y = 0; - } - this.y = y; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(z)) { - z = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.x)) { + apiComponent.x = 0; } - this.z = z; + this.x = apiComponent.x; - if (R3.Utils.UndefinedOrNull(w)) { - w = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.y)) { + apiComponent.y = 0; } - this.w = w; + this.y = apiComponent.y; - if (R3.Utils.UndefinedOrNull(axis)) { - axis = new R3.API.Vector3(); + if (R3.Utils.UndefinedOrNull(apiComponent.z)) { + apiComponent.z = 0; } - this.axis = axis; + this.z = apiComponent.z; - if (R3.Utils.UndefinedOrNull(angle)) { - angle = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.w)) { + apiComponent.w = 1; } - this.angle = angle; + this.w = apiComponent.w; + + if (R3.Utils.UndefinedOrNull(apiComponent.axis)) { + apiComponent.axis = new R3.API.Vector3( + { + parent : this, + register : this.register + } + ); + } + this.axis = apiComponent.axis; + + if (R3.Utils.UndefinedOrNull(apiComponent.angle)) { + apiComponent.angle = 0; + } + this.angle = apiComponent.angle; }; +R3.API.Quaternion.prototype = Object.create(R3.API.Component.prototype); +R3.API.Quaternion.prototype.constructor = R3.API.Quaternion; + R3.API.Quaternion.prototype.translate = function(v) { this.x += v.x; this.y += v.y; @@ -57,10 +59,7 @@ R3.API.Quaternion.prototype.translate = function(v) { R3.API.Quaternion.prototype.copy = function() { return new R3.API.Quaternion( - this.x, - this.y, - this.z, - this.w + this ); }; @@ -212,26 +211,3 @@ R3.API.Quaternion.prototype.slerp = function(quaternion, t) { return this; }; - -/** - * Returns an API quaternion from an Object quaternion - * @param objectQuaternion - * @constructor - */ -R3.API.Quaternion.FromObject = function(objectQuaternion) { - - var apiAxis = null; - - if (objectQuaternion.axis) { - apiAxis = R3.API.Vector3.FromObject(objectQuaternion.axis); - } - - return new R3.API.Quaternion( - objectQuaternion.x, - objectQuaternion.y, - objectQuaternion.z, - objectQuaternion.w, - apiAxis, - objectQuaternion.angle - ) -}; \ No newline at end of file diff --git a/src/r3-api-quaternion-points.js b/src/r3-api-quaternion-points.js index 6ed6d61..b143152 100644 --- a/src/r3-api-quaternion-points.js +++ b/src/r3-api-quaternion-points.js @@ -1,19 +1,36 @@ /** * R3.API.Quaternion.Points + * @param apiComponent * @constructor */ -R3.API.Quaternion.Points = function() { - this.vectors = []; +R3.API.Quaternion.Points = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.vectors)) { + apiComponent.vectors = []; + } + + this.vectors = apiComponent.vectors; }; +R3.API.Quaternion.Points.prototype = Object.create(R3.API.Component.prototype); +R3.API.Quaternion.Points.prototype.constructor = R3.API.Quaternion.Points; + R3.API.Quaternion.Points.prototype.add = function(vector) { if (vector instanceof R3.API.Vector3) { vector = new R3.API.Quaternion( - vector.x, - vector.y, - vector.z, - 1 + { + parent : this, + register : true, + x : vector.x, + y : vector.y, + z : vector.z, + w : 1 + } ) } @@ -44,7 +61,11 @@ R3.API.Quaternion.Points.prototype.maximizeXDistance = function(grain) { var multiplier = 0; - var rotationMatrixY = new R3.API.Matrix4().rotationMatrixY(grain); + var rotationMatrixY = new R3.API.Matrix4( + { + parent : this + } + ).rotationMatrixY(grain); var totalRadians = 0; @@ -73,7 +94,12 @@ R3.API.Quaternion.Points.prototype.maximizeXDistance = function(grain) { // console.log("distance: " + maxXDistance + " radians : " + totalRadians); - var maxRotationMatrix = new R3.API.Matrix4().rotationMatrixY(totalRadians); + var maxRotationMatrix = new R3.API.Matrix4( + { + parent : this, + register : true + } + ).rotationMatrixY(totalRadians); for (var k = 0; k < this.vectors.length; k++) { this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]); @@ -89,7 +115,12 @@ R3.API.Quaternion.Points.prototype.maximizeYDistance = function(grain) { var multiplier = 0; - var rotationMatrixX = new R3.API.Matrix4().rotationMatrixX(grain); + var rotationMatrixX = new R3.API.Matrix4( + { + parent : this, + register : true + } + ).rotationMatrixX(grain); var totalRadians = 0; @@ -117,7 +148,12 @@ R3.API.Quaternion.Points.prototype.maximizeYDistance = function(grain) { // console.log("distance: " + maxYDistance + " radians : " + totalRadians); - var maxRotationMatrix = new R3.API.Matrix4().rotationMatrixX(totalRadians); + var maxRotationMatrix = new R3.API.Matrix4( + { + parent : this, + register : true + } + ).rotationMatrixX(totalRadians); for (var k = 0; k < this.vectors.length; k++) { this.vectors[k] = maxRotationMatrix.multiply(this.vectors[k]); @@ -134,11 +170,42 @@ R3.API.Quaternion.Points.prototype.lookAt = function(at, up) { console.log("poly center : " + JSON.stringify(polyCenter)); - var lookAtMatrix = new R3.API.Matrix4().lookAt(polyCenter, at, up); + var lookAtMatrix = new R3.API.Matrix4({ + parent : this + }).lookAt(polyCenter, at, up); - lookAtMatrix.rows[0] = new R3.API.Quaternion(1, 0, 0, 0); - lookAtMatrix.rows[1] = new R3.API.Quaternion(0, 0, 1, 0); - lookAtMatrix.rows[2] = new R3.API.Quaternion(0, 1, 0, 0); + lookAtMatrix.rows[0] = new R3.API.Quaternion( + { + parent : this, + register : true, + x : 1, + y : 0, + z : 0, + w : 0 + } + ); + + lookAtMatrix.rows[1] = new R3.API.Quaternion( + { + parent : this, + register : true, + x : 0, + y : 0, + z : 1, + w : 0 + } + ); + + lookAtMatrix.rows[2] = new R3.API.Quaternion( + { + parent : this, + register : true, + x : 0, + y : 1, + z : 0, + w : 0 + } + ); console.log("look at matrix : " + JSON.stringify(lookAtMatrix, null, 2)); @@ -182,13 +249,17 @@ R3.API.Quaternion.Points.prototype.distances = function() { } return new R3.API.Vector3( - Math.abs(maxX - minX), - Math.abs(maxY - minY), - Math.abs(maxY - minZ) + { + parent : this, + x : Math.abs(maxX - minX), + y : Math.abs(maxY - minY), + z : Math.abs(maxY - minZ) + } ) }; R3.API.Quaternion.Points.prototype.average = function() { + var averageX = 0; var averageY = 0; var averageZ = 0; @@ -200,9 +271,13 @@ R3.API.Quaternion.Points.prototype.average = function() { } return new R3.API.Vector3( - averageX / this.vectors.length, - averageY / this.vectors.length, - averageZ / this.vectors.length + { + parent : this, + register : true, + x : averageX / this.vectors.length, + y : averageY / this.vectors.length, + z : averageZ / this.vectors.length + } ); }; diff --git a/src/r3-api-query-0.js b/src/r3-api-query-0.js new file mode 100644 index 0000000..0051cef --- /dev/null +++ b/src/r3-api-query-0.js @@ -0,0 +1,68 @@ +/** + * R3.API.Query + * @param apiComponent + * + * @property path + * @property start + * @property end + * @property timezone + * @property size + * @property text + * @property onData + * + * @constructor + */ +R3.API.Query = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = null; + } + this.path = apiComponent.path; + + if (R3.Utils.UndefinedOrNull(apiComponent.start)) { + apiComponent.start = 'now-7d'; + } + this.start = apiComponent.start; + + if (R3.Utils.UndefinedOrNull(apiComponent.end)) { + apiComponent.end = 'now+4h'; + } + this.end = apiComponent.end; + + if (R3.Utils.UndefinedOrNull(apiComponent.timezone)) { + apiComponent.timezone = 'Europe/Berlin'; + } + this.timezone = apiComponent.timezone; + + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = 0; + } + this.size = apiComponent.size; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{}'; + } + this.text = apiComponent.text; + + if (R3.Utils.UndefinedOrNull(apiComponent.onData)) { + apiComponent.onData = function() { + console.log('todo: implement this query onData event'); + }; + } + this.onData = apiComponent.onData; + +}; + +R3.API.Query.prototype = Object.create(R3.API.Component.prototype); +R3.API.Query.prototype.constructor = R3.API.Query; + +R3.API.Query.QUERY_SIZE = 'QUERY_SIZE'; +R3.API.Query.QUERY_START = 'QUERY_START'; +R3.API.Query.QUERY_END = 'QUERY_END'; +R3.API.Query.QUERY_TIMEZONE = 'QUERY_TIMEZONE'; +R3.API.Query.QUERY_BUCKET_FIELD = 'QUERY_BUCKET_FIELD'; + diff --git a/src/r3-api-query-alerts-0.js b/src/r3-api-query-alerts-0.js new file mode 100644 index 0000000..e5fba06 --- /dev/null +++ b/src/r3-api-query-alerts-0.js @@ -0,0 +1,24 @@ +/** + * R3.API.Query.Alerts + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts = function( + apiComponent +) { + + R3.API.Query.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = '/alerts/_search'; + } + this.path = apiComponent.path; + + +}; + +R3.API.Query.Alerts.prototype = Object.create(R3.API.Query.prototype); +R3.API.Query.Alerts.prototype.constructor = R3.API.Query.Alerts; diff --git a/src/r3-api-query-alerts-buckets.js b/src/r3-api-query-alerts-buckets.js new file mode 100644 index 0000000..402b22b --- /dev/null +++ b/src/r3-api-query-alerts-buckets.js @@ -0,0 +1,75 @@ +/** + * R3.API.Query.Alerts.Buckets + * @param apiComponent + * + * @property bucketField BUCKET_FIELD + * + * @constructor + */ +R3.API.Query.Alerts.Buckets = function( + apiComponent +) { + + R3.API.Query.Alerts.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.bucketField)) { + apiComponent.bucketField = null; + } + this.bucketField = apiComponent.bucketField; + + this.text = '{\ + "version": false,\ + "size": ' + R3.API.Query.QUERY_SIZE + ',\ + "sort": [\ + {\ + "priority": {\ + "order": "asc"\ + },\ + "acknowledged": {\ + "order": "asc"\ + },\ + "' + R3.API.Query.QUERY_BUCKET_FIELD + '": {\ + "order": "asc"\ + }\ + }\ + ],\ + "_source": {\ + "includes": ["*"]\ + },\ + "aggs": {\ + "descriptions": {\ + "terms" : { "field" : "' + R3.API.Query.QUERY_BUCKET_FIELD + '" },\ + "aggs": {\ + "priorities": {\ + "histogram": {\ + "field": "priority",\ + "interval": "1",\ + "min_doc_count": 0\ + }\ + }\ + }\ + }\ + },\ + "query": {\ + "bool": {\ + "must": [\ + {\ + "range": {\ + "timestamp": {\ + "format": "strict_date_optional_time",\ + "gte" : "' + R3.API.Query.QUERY_START + '",\ + "lt" : "' + R3.API.Query.QUERY_END + '"\ + }\ + }\ + }\ + ]\ + }\ + }\ +}'; +}; + +R3.API.Query.Alerts.Buckets.prototype = Object.create(R3.API.Query.Alerts.prototype); +R3.API.Query.Alerts.Buckets.prototype.constructor = R3.API.Query.Alerts.Buckets; diff --git a/src/r3-api-query-alerts-list.js b/src/r3-api-query-alerts-list.js new file mode 100644 index 0000000..b120bf7 --- /dev/null +++ b/src/r3-api-query-alerts-list.js @@ -0,0 +1,62 @@ +/** + * R3.API.Query.Alerts.List + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.List = function( + apiComponent +) { + + R3.API.Query.Alerts.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = 100; + } + this.size = apiComponent.size; + + this.text = '{\ + "version": false,\ + "size": ' + R3.API.Query.QUERY_SIZE + ',\ + "sort": [\ + {\ + "timestamp": {\ + "order": "desc",\ + "unmapped_type": "boolean"\ + }\ + }\ + ],\ + "_source": {\ + "includes": ["*"]\ + },\ + "aggs": {\ + "priorities": {\ + "histogram": {\ + "field": "priority",\ + "interval": "1",\ + "min_doc_count": 0\ + }\ + }\ + },\ + "query": {\ + "bool": {\ + "must": [\ + {\ + "range": {\ + "timestamp": {\ + "format": "strict_date_optional_time",\ + "gte": "' + R3.API.Query.QUERY_START + '",\ + "lt": "' + R3.API.Query.QUERY_END + '"\ + }\ + }\ + }\ + ]\ + }\ + }\ +}'; +}; + +R3.API.Query.Alerts.List.prototype = Object.create(R3.API.Query.Alerts.prototype); +R3.API.Query.Alerts.List.prototype.constructor = R3.API.Query.Alerts.List; diff --git a/src/r3-api-query-alerts-summary.js b/src/r3-api-query-alerts-summary.js new file mode 100644 index 0000000..ec36682 --- /dev/null +++ b/src/r3-api-query-alerts-summary.js @@ -0,0 +1,57 @@ +/** + * R3.API.Query.Alerts.Summary + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.Summary = function( + apiComponent +) { + + R3.API.Query.Alerts.call( + this, + apiComponent + ); + + this.text = '{\ + "version": false,\ + "size": ' + R3.API.Query.QUERY_SIZE + ',\ + "sort": [\ + {\ + "timestamp": {\ + "order": "desc",\ + "unmapped_type": "boolean"\ + }\ + }\ + ],\ + "_source": {\ + "includes": ["*"]\ + },\ + "aggs": {\ + "priorities": {\ + "histogram": {\ + "field": "priority",\ + "interval": "1",\ + "min_doc_count": 0\ + }\ + }\ + },\ + "query": {\ + "bool": {\ + "must": [\ + {\ + "range": {\ + "timestamp": {\ + "format": "strict_date_optional_time",\ + "gte": "' + R3.API.Query.QUERY_START + '",\ + "lt": "' + R3.API.Query.QUERY_END + '"\ + }\ + }\ + }\ + ]\ + }\ + }\ +}'; +}; + +R3.API.Query.Alerts.Summary.prototype = Object.create(R3.API.Query.Alerts.prototype); +R3.API.Query.Alerts.Summary.prototype.constructor = R3.API.Query.Alerts.Summary; diff --git a/src/r3-api-query-alerts-timeseries.js b/src/r3-api-query-alerts-timeseries.js new file mode 100644 index 0000000..a5d9e5c --- /dev/null +++ b/src/r3-api-query-alerts-timeseries.js @@ -0,0 +1,68 @@ +/** + * R3.API.Query.Alerts.Timeseries + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.Timeseries = function( + apiComponent +) { + + R3.API.Query.Alerts.call( + this, + apiComponent + ); + + this.text = '{\ + "version": false,\ + "size": ' + R3.API.Query.QUERY_SIZE + ',\ + "sort": [\ + {\ + "timestamp": {\ + "order": "desc",\ + "unmapped_type": "boolean"\ + }\ + }\ + ],\ + "_source": {\ + "includes": ["*"]\ + },\ + "aggs": {\ + "mins": {\ + "date_histogram": {\ + "field": "timestamp",\ + "calendar_interval": "1d",\ + "time_zone": "' + R3.API.Query.QUERY_TIMEZONE + '",\ + "min_doc_count": 0,\ + "format" : "yyyy-MM-dd"\ + },\ + "aggs": {\ + "priorities": {\ + "histogram": {\ + "field": "priority",\ + "interval": "1",\ + "min_doc_count": 0\ + }\ + }\ + }\ + }\ + },\ + "query": {\ + "bool": {\ + "must": [\ + {\ + "range": {\ + "timestamp": {\ + "format": "strict_date_optional_time",\ + "gte" : "' + R3.API.Query.QUERY_START + '",\ + "lt" : "' + R3.API.Query.QUERY_END + '"\ + }\ + }\ + }\ + ]\ + }\ + }\ +}'; +}; + +R3.API.Query.Alerts.Timeseries.prototype = Object.create(R3.API.Query.Alerts.prototype); +R3.API.Query.Alerts.Timeseries.prototype.constructor = R3.API.Query.Alerts.Timeseries; diff --git a/src/r3-api-renderer-a.js b/src/r3-api-renderer-0.js similarity index 96% rename from src/r3-api-renderer-a.js rename to src/r3-api-renderer-0.js index 0d03a3a..25b1dfc 100644 --- a/src/r3-api-renderer-a.js +++ b/src/r3-api-renderer-0.js @@ -7,7 +7,7 @@ R3.API.Renderer = function( apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; }; diff --git a/src/r3-api-renderer-d2.js b/src/r3-api-renderer-d2.js index 2e89f36..90cd66f 100644 --- a/src/r3-api-renderer-d2.js +++ b/src/r3-api-renderer-d2.js @@ -1,28 +1,28 @@ /** * R3.API.Renderer.D2 + * @param apiComponent + * + * @property canvas + * * @constructor - * @param apiRenderer - * @param canvas */ R3.API.Renderer.D2 = function( - apiRenderer, - canvas + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiRenderer)) { - apiRenderer = {}; - } - this.apiRenderer = apiRenderer; - R3.API.Renderer.call( this, - this.apiRenderer + apiComponent ); - if (R3.Utils.UndefinedOrNull(canvas)) { - canvas = new R3.API.Canvas(); + if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { + apiComponent.canvas = new R3.API.Canvas( + { + parent : this + } + ); } - this.canvas = canvas; + this.canvas = apiComponent.canvas; }; diff --git a/src/r3-api-renderer-d3-0.js b/src/r3-api-renderer-d3-0.js new file mode 100644 index 0000000..efae56e --- /dev/null +++ b/src/r3-api-renderer-d3-0.js @@ -0,0 +1,231 @@ +/** + * R3.API.Renderer.D3 + * @param apiComponent + * + * @property autoClear + * @property autoClearColor + * @property autoClearDepth + * @property autoClearStencil + * @property gammaFactor + * @property gammaInput + * @property gammaOutput + * @property maxMorphTargets + * @property maxMorphNormals + * @property physicallyCorrectLights + * @property shadowMapEnabled + * @property shadowMapAutoUpdate + * @property shadowMapNeedsUpdate + * @property shadowMapType + * @property shadowMapRenderReverseSided + * @property shadowMapRenderSingleSided + * @property sortObjects + * @property toneMapping + * @property toneMappingExposure + * @property toneMappingWhitePoint + * @property premultipliedAlpha + * @property antialias + * @property stencil + * @property preserveDrawingBuffer + * @property depth + * @property logarithmicDepthBuffer + * @property localClippingEnabled + * @property clippingPlanes + * @property clearColor + * @property viewports + * @property alpha + * @property opacity + * @property pixelRatio + * + * @constructor + */ +R3.API.Renderer.D3 = function( + apiComponent +) { + + R3.API.Renderer.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.autoClear)) { + apiComponent.autoClear = true; + } + this.autoClear = apiComponent.autoClear; + + if (R3.Utils.UndefinedOrNull(apiComponent.autoClearColor)) { + apiComponent.autoClearColor = true; + } + this.autoClearColor = apiComponent.autoClearColor; + + if (R3.Utils.UndefinedOrNull(apiComponent.autoClearDepth)) { + apiComponent.autoClearDepth = true; + } + this.autoClearDepth = apiComponent.autoClearDepth; + + if (R3.Utils.UndefinedOrNull(apiComponent.autoClearStencil)) { + apiComponent.autoClearStencil = true; + } + this.autoClearStencil = apiComponent.autoClearStencil; + + if (R3.Utils.UndefinedOrNull(apiComponent.gammaFactor)) { + apiComponent.gammaFactor = 2; + } + this.gammaFactor = apiComponent.gammaFactor; + + if (R3.Utils.UndefinedOrNull(apiComponent.gammaInput)) { + apiComponent.gammaInput = false; + } + this.gammaInput = apiComponent.gammaInput; + + if (R3.Utils.UndefinedOrNull(apiComponent.gammaOutput)) { + apiComponent.gammaOutput = false; + } + this.gammaOutput = apiComponent.gammaOutput; + + if (R3.Utils.UndefinedOrNull(apiComponent.maxMorphTargets)) { + apiComponent.maxMorphTargets = 8; + } + this.maxMorphTargets = apiComponent.maxMorphTargets; + + if (R3.Utils.UndefinedOrNull(apiComponent.maxMorphNormals)) { + apiComponent.maxMorphNormals = 4; + } + this.maxMorphNormals = apiComponent.maxMorphNormals; + + if (R3.Utils.UndefinedOrNull(apiComponent.physicallyCorrectLights)) { + apiComponent.physicallyCorrectLights = false; + } + this.physicallyCorrectLights = apiComponent.physicallyCorrectLights; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapEnabled)) { + apiComponent.shadowMapEnabled = false; + } + this.shadowMapEnabled = apiComponent.shadowMapEnabled; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapAutoUpdate)) { + apiComponent.shadowMapAutoUpdate = true; + } + this.shadowMapAutoUpdate = apiComponent.shadowMapAutoUpdate; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapNeedsUpdate)) { + apiComponent.shadowMapNeedsUpdate = false; + } + this.shadowMapNeedsUpdate = apiComponent.shadowMapNeedsUpdate; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapType)) { + apiComponent.shadowMapType = R3.API.Renderer.SHADOW_MAP_TYPE_BASIC; + } + this.shadowMapType = apiComponent.shadowMapType; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapRenderReverseSided)) { + apiComponent.shadowMapRenderReverseSided = true; + } + this.shadowMapRenderReverseSided = apiComponent.shadowMapRenderReverseSided; + + if (R3.Utils.UndefinedOrNull(apiComponent.shadowMapRenderSingleSided)) { + apiComponent.shadowMapRenderSingleSided = true; + } + this.shadowMapRenderSingleSided = apiComponent.shadowMapRenderSingleSided; + + if (R3.Utils.UndefinedOrNull(apiComponent.sortObjects)) { + apiComponent.sortObjects = true; + } + this.sortObjects = apiComponent.sortObjects; + + if (R3.Utils.UndefinedOrNull(apiComponent.toneMapping)) { + apiComponent.toneMapping = R3.API.Renderer.TONE_MAPPING_LINEAR; + } + this.toneMapping = apiComponent.toneMapping; + + if (R3.Utils.UndefinedOrNull(apiComponent.toneMappingExposure)) { + apiComponent.toneMappingExposure = 1; + } + this.toneMappingExposure = apiComponent.toneMappingExposure; + + if (R3.Utils.UndefinedOrNull(apiComponent.toneMappingWhitePoint)) { + apiComponent.toneMappingWhitePoint = 1; + } + this.toneMappingWhitePoint = apiComponent.toneMappingWhitePoint; + + if (R3.Utils.UndefinedOrNull(apiComponent.premultipliedAlpha)) { + apiComponent.premultipliedAlpha = true; + } + this.premultipliedAlpha = apiComponent.premultipliedAlpha; + + if (R3.Utils.UndefinedOrNull(apiComponent.antialias)) { + apiComponent.antialias = false; + } + this.antialias = apiComponent.antialias; + + if (R3.Utils.UndefinedOrNull(apiComponent.stencil)) { + apiComponent.stencil = true; + } + this.stencil = apiComponent.stencil; + + if (R3.Utils.UndefinedOrNull(apiComponent.preserveDrawingBuffer)) { + apiComponent.preserveDrawingBuffer = false; + } + this.preserveDrawingBuffer = apiComponent.preserveDrawingBuffer; + + if (R3.Utils.UndefinedOrNull(apiComponent.depth)) { + apiComponent.depth = true; + } + this.depth = apiComponent.depth; + + if (R3.Utils.UndefinedOrNull(apiComponent.logarithmicDepthBuffer)) { + apiComponent.logarithmicDepthBuffer = false; + } + this.logarithmicDepthBuffer = apiComponent.logarithmicDepthBuffer; + + if (R3.Utils.UndefinedOrNull(apiComponent.localClippingEnabled)) { + apiComponent.localClippingEnabled = false; + } + this.localClippingEnabled = apiComponent.localClippingEnabled; + + if (R3.Utils.UndefinedOrNull(apiComponent.clippingPlanes)) { + apiComponent.clippingPlanes = []; + } + this.clippingPlanes = apiComponent.clippingPlanes; + + if (R3.Utils.UndefinedOrNull(apiComponent.clearColor)) { + apiComponent.clearColor = new R3.API.Color( + { + parent : this, + r : 0.11, + g : 0.11, + b : 0.11 + } + ); + } + this.clearColor = apiComponent.clearColor; + + if (R3.Utils.UndefinedOrNull(apiComponent.viewports)) { + apiComponent.viewports = [ + new R3.D3.API.Viewport( + { + parent : this + } + ) + ]; + } + this.viewports = apiComponent.viewports; + + if (R3.Utils.UndefinedOrNull(apiComponent.alpha)) { + apiComponent.alpha = true; + } + this.alpha = apiComponent.alpha; + + if (R3.Utils.UndefinedOrNull(apiComponent.opacity)) { + apiComponent.opacity = 1; + } + this.opacity = apiComponent.opacity; + + if (R3.Utils.UndefinedOrNull(apiComponent.pixelRatio)) { + apiComponent.pixelRatio = window.devicePixelRatio; + } + this.pixelRatio = apiComponent.pixelRatio; + +}; + +R3.API.Renderer.D3.prototype = Object.create(R3.API.Renderer.prototype); +R3.API.Renderer.D3.prototype.constructor = R3.API.Renderer.D3; diff --git a/src/r3-api-renderer-d3-canvas-0.js b/src/r3-api-renderer-d3-canvas-0.js new file mode 100644 index 0000000..730d093 --- /dev/null +++ b/src/r3-api-renderer-d3-canvas-0.js @@ -0,0 +1,50 @@ +/** + * R3.API.Renderer.D3.Canvas + * @param apiComponent + * + * @property canvas + * + * @constructor + */ +R3.API.Renderer.D3.Canvas = function( + apiComponent +) { + + R3.API.Renderer.D3.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { + apiComponent.canvas = new R3.API.Canvas( + { + parent : this + } + ); + } + this.canvas = apiComponent.canvas; + +}; + +R3.API.Renderer.D3.Canvas.prototype = Object.create(R3.API.Renderer.D3.prototype); +R3.API.Renderer.D3.Canvas.prototype.constructor = R3.API.Renderer.D3.Canvas; + +R3.API.Renderer.D3.Canvas.prototype.getSize = function(viewport) { + + if (R3.Utils.UndefinedOrNull(viewport)) { + viewport = null; + } + + if (viewport) { + return { + width : this.canvas.width * viewport.width, + height : this.canvas.height * viewport.height + } + } + + return { + width : this.canvas.width, + height : this.canvas.height + } + +}; diff --git a/src/r3-api-renderer-d3-canvas-target.js b/src/r3-api-renderer-d3-canvas-target.js index 5d9e6aa..3d486d3 100644 --- a/src/r3-api-renderer-d3-canvas-target.js +++ b/src/r3-api-renderer-d3-canvas-target.js @@ -1,28 +1,28 @@ /** * R3.API.Renderer.D3.Canvas.Target + * @param apiComponent + * + * @property target + * * @constructor - * @param apiRendererD3Canvas - * @param target */ R3.API.Renderer.D3.Canvas.Target = function( - apiRendererD3Canvas, - target + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiRendererD3Canvas)) { - apiRendererD3Canvas = {}; - } - this.apiRendererD3Canvas = apiRendererD3Canvas; R3.API.Renderer.D3.Canvas.call( this, - this.apiRendererD3Canvas, - this.apiRendererD3Canvas.canvas + apiComponent ); - if (R3.Utils.UndefinedOrNull(target)) { - target = new R3.D3.API.RenderTarget(); + if (R3.Utils.UndefinedOrNull(apiComponent.target)) { + apiComponent.target = new R3.D3.API.RenderTarget( + { + parent : this + } + ); } - this.target = target; + this.target = apiComponent.target; }; R3.API.Renderer.D3.Canvas.Target.prototype = Object.create(R3.API.Renderer.D3.Canvas.prototype); diff --git a/src/r3-api-renderer-d3-canvas.js b/src/r3-api-renderer-d3-canvas.js deleted file mode 100644 index 7646625..0000000 --- a/src/r3-api-renderer-d3-canvas.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * R3.API.Renderer.D3.Canvas - * @param apiRendererD3 - * @param canvas - * @constructor - */ -R3.API.Renderer.D3.Canvas = function( - apiRendererD3, - canvas -) { - - if (R3.Utils.UndefinedOrNull(apiRendererD3)) { - apiRendererD3 = {}; - } - this.apiRendererD3 = apiRendererD3; - - R3.API.Renderer.D3.call( - this, - this.apiRendererD3, - this.apiRendererD3.autoClear, - this.apiRendererD3.autoClearColor, - this.apiRendererD3.autoClearDepth, - this.apiRendererD3.autoClearStencil, - this.apiRendererD3.gammaFactor, - this.apiRendererD3.gammaInput, - this.apiRendererD3.gammaOutput, - this.apiRendererD3.maxMorphTargets, - this.apiRendererD3.maxMorphNormals, - this.apiRendererD3.physicallyCorrectLights, - this.apiRendererD3.shadowMapEnabled, - this.apiRendererD3.shadowMapAutoUpdate, - this.apiRendererD3.shadowMapNeedsUpdate, - this.apiRendererD3.shadowMapType, - this.apiRendererD3.shadowMapRenderReverseSided, - this.apiRendererD3.shadowMapRenderSingleSided, - this.apiRendererD3.sortObjects, - this.apiRendererD3.toneMapping, - this.apiRendererD3.toneMappingExposure, - this.apiRendererD3.toneMappingWhitePoint, - this.apiRendererD3.premultipliedAlpha, - this.apiRendererD3.antialias, - this.apiRendererD3.stencil, - this.apiRendererD3.preserveDrawingBuffer, - this.apiRendererD3.depth, - this.apiRendererD3.logarithmicDepthBuffer, - this.apiRendererD3.localClippingEnabled, - this.apiRendererD3.clippingPlanes, - this.apiRendererD3.clearColor, - this.apiRendererD3.viewports, - this.apiRendererD3.alpha, - this.apiRendererD3.opacity, - this.apiRendererD3.pixelRatio - ); - - if (R3.Utils.UndefinedOrNull(canvas)) { - canvas = new R3.API.Canvas(); - } - this.canvas = canvas; - -}; - -R3.API.Renderer.D3.Canvas.prototype = Object.create(R3.API.Renderer.D3.prototype); -R3.API.Renderer.D3.Canvas.prototype.constructor = R3.API.Renderer.D3.Canvas; - -R3.API.Renderer.D3.Canvas.prototype.getSize = function() { - - return { - width : this.canvas.width, - height : this.canvas.height - } - -}; diff --git a/src/r3-api-renderer-d3.js b/src/r3-api-renderer-d3.js deleted file mode 100644 index f91927f..0000000 --- a/src/r3-api-renderer-d3.js +++ /dev/null @@ -1,254 +0,0 @@ -/** - * R3.API.Renderer.D3 - * @param apiRenderer - * @param autoClear - * @param autoClearColor - * @param autoClearDepth - * @param autoClearStencil - * @param gammaFactor - * @param gammaInput - * @param gammaOutput - * @param maxMorphTargets - * @param maxMorphNormals - * @param physicallyCorrectLights - * @param shadowMapEnabled - * @param shadowMapAutoUpdate - * @param shadowMapNeedsUpdate - * @param shadowMapType - * @param shadowMapRenderReverseSided - * @param shadowMapRenderSingleSided - * @param sortObjects - * @param toneMapping - * @param toneMappingExposure - * @param toneMappingWhitePoint - * @param premultipliedAlpha - * @param antialias - * @param stencil - * @param preserveDrawingBuffer - * @param depth - * @param logarithmicDepthBuffer - * @param localClippingEnabled - * @param clippingPlanes - * @param clearColor - * @param viewports - * @param alpha - * @param opacity - * @param pixelRatio - * @constructor - */ -R3.API.Renderer.D3 = function( - apiRenderer, - autoClear, - autoClearColor, - autoClearDepth, - autoClearStencil, - gammaFactor, - gammaInput, - gammaOutput, - maxMorphTargets, - maxMorphNormals, - physicallyCorrectLights, - shadowMapEnabled, - shadowMapAutoUpdate, - shadowMapNeedsUpdate, - shadowMapType, - shadowMapRenderReverseSided, - shadowMapRenderSingleSided, - sortObjects, - toneMapping, - toneMappingExposure, - toneMappingWhitePoint, - premultipliedAlpha, - antialias, - stencil, - preserveDrawingBuffer, - depth, - logarithmicDepthBuffer, - localClippingEnabled, - clippingPlanes, - clearColor, - viewports, - alpha, - opacity, - pixelRatio -) { - - if (R3.Utils.UndefinedOrNull(apiRenderer)) { - apiRenderer = {}; - } - this.apiRenderer = apiRenderer; - - R3.API.Renderer.call( - this, - this.apiRenderer - ); - - if (R3.Utils.UndefinedOrNull(autoClear)) { - autoClear = true; - } - this.autoClear = autoClear; - - if (R3.Utils.UndefinedOrNull(autoClearColor)) { - autoClearColor = true; - } - this.autoClearColor = autoClearColor; - - if (R3.Utils.UndefinedOrNull(autoClearDepth)) { - autoClearDepth = true; - } - this.autoClearDepth = autoClearDepth; - - if (R3.Utils.UndefinedOrNull(autoClearStencil)) { - autoClearStencil = true; - } - this.autoClearStencil = autoClearStencil; - - if (R3.Utils.UndefinedOrNull(gammaFactor)) { - gammaFactor = 2; - } - this.gammaFactor = gammaFactor; - - if (R3.Utils.UndefinedOrNull(gammaInput)) { - gammaInput = false; - } - this.gammaInput = gammaInput; - - if (R3.Utils.UndefinedOrNull(gammaOutput)) { - gammaOutput = false; - } - this.gammaOutput = gammaOutput; - - if (R3.Utils.UndefinedOrNull(maxMorphTargets)) { - maxMorphTargets = 8; - } - this.maxMorphTargets = maxMorphTargets; - - if (R3.Utils.UndefinedOrNull(maxMorphNormals)) { - maxMorphNormals = 4; - } - this.maxMorphNormals = maxMorphNormals; - - if (R3.Utils.UndefinedOrNull(physicallyCorrectLights)) { - physicallyCorrectLights = false; - } - this.physicallyCorrectLights = physicallyCorrectLights; - - if (R3.Utils.UndefinedOrNull(shadowMapEnabled)) { - shadowMapEnabled = false; - } - this.shadowMapEnabled = shadowMapEnabled; - - if (R3.Utils.UndefinedOrNull(shadowMapAutoUpdate)) { - shadowMapAutoUpdate = true; - } - this.shadowMapAutoUpdate = shadowMapAutoUpdate; - - if (R3.Utils.UndefinedOrNull(shadowMapNeedsUpdate)) { - shadowMapNeedsUpdate = false; - } - this.shadowMapNeedsUpdate = shadowMapNeedsUpdate; - - if (R3.Utils.UndefinedOrNull(shadowMapType)) { - shadowMapType = R3.API.Renderer.SHADOW_MAP_TYPE_BASIC; - } - this.shadowMapType = shadowMapType; - - if (R3.Utils.UndefinedOrNull(shadowMapRenderReverseSided)) { - shadowMapRenderReverseSided = true; - } - this.shadowMapRenderReverseSided = shadowMapRenderReverseSided; - - if (R3.Utils.UndefinedOrNull(shadowMapRenderSingleSided)) { - shadowMapRenderSingleSided = true; - } - this.shadowMapRenderSingleSided = shadowMapRenderSingleSided; - - if (R3.Utils.UndefinedOrNull(sortObjects)) { - sortObjects = true; - } - this.sortObjects = sortObjects; - - if (R3.Utils.UndefinedOrNull(toneMapping)) { - toneMapping = R3.API.Renderer.TONE_MAPPING_LINEAR; - } - this.toneMapping = toneMapping; - - if (R3.Utils.UndefinedOrNull(toneMappingExposure)) { - toneMappingExposure = 1; - } - this.toneMappingExposure = toneMappingExposure; - - if (R3.Utils.UndefinedOrNull(toneMappingWhitePoint)) { - toneMappingWhitePoint = 1; - } - this.toneMappingWhitePoint = toneMappingWhitePoint; - - if (R3.Utils.UndefinedOrNull(premultipliedAlpha)) { - premultipliedAlpha = true; - } - this.premultipliedAlpha = premultipliedAlpha; - - if (R3.Utils.UndefinedOrNull(antialias)) { - antialias = false; - } - this.antialias = antialias; - - if (R3.Utils.UndefinedOrNull(stencil)) { - stencil = true; - } - this.stencil = stencil; - - if (R3.Utils.UndefinedOrNull(preserveDrawingBuffer)) { - preserveDrawingBuffer = false; - } - this.preserveDrawingBuffer = preserveDrawingBuffer; - - if (R3.Utils.UndefinedOrNull(depth)) { - depth = true; - } - this.depth = depth; - - if (R3.Utils.UndefinedOrNull(logarithmicDepthBuffer)) { - logarithmicDepthBuffer = false; - } - this.logarithmicDepthBuffer = logarithmicDepthBuffer; - - if (R3.Utils.UndefinedOrNull(localClippingEnabled)) { - localClippingEnabled = false; - } - this.localClippingEnabled = localClippingEnabled; - - if (R3.Utils.UndefinedOrNull(clippingPlanes)) { - clippingPlanes = []; - } - this.clippingPlanes = clippingPlanes; - - if (R3.Utils.UndefinedOrNull(clearColor)) { - clearColor = new R3.API.Color(this, 0.11, 0.11, 0.11); - } - this.clearColor = clearColor; - - if (R3.Utils.UndefinedOrNull(viewports)) { - viewports = [new R3.D3.API.Viewport()]; - } - this.viewports = viewports; - - if (R3.Utils.UndefinedOrNull(alpha)) { - alpha = true; - } - this.alpha = alpha; - - if (R3.Utils.UndefinedOrNull(opacity)) { - opacity = 1; - } - this.opacity = opacity; - - if (R3.Utils.UndefinedOrNull(pixelRatio)) { - pixelRatio = window.devicePixelRatio; - } - this.pixelRatio = pixelRatio; - -}; - -R3.API.Renderer.D3.prototype = Object.create(R3.API.Renderer.prototype); -R3.API.Renderer.D3.prototype.constructor = R3.API.Renderer.D3; diff --git a/src/r3-api-server.js b/src/r3-api-server.js index caa7ac7..7bf0259 100644 --- a/src/r3-api-server.js +++ b/src/r3-api-server.js @@ -1,69 +1,61 @@ /** * R3.API.Server * @param apiComponent - * @param protocol - * @param context - * @param application - * @param domain - * @param ip - * @param preferIp - Set to true to use IP instead of resolving DNS at getUrl() runtime - * @param port - * @param protocols + * @property protocol + * @property context + * @property application + * @property domain + * @property ip + * @property preferIp - Set to true to use IP instead of resolving DNS at getUrl() runtime + * @property port + * @property protocols * @constructor */ R3.API.Server = function( - apiComponent, - protocol, - context, - application, - domain, - ip, - preferIp, - port, - protocols + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(protocol)) { - protocol = R3.API.Server.PROTOCOL_HTTP_SSL; + if (R3.Utils.UndefinedOrNull(apiComponent.protocol)) { + apiComponent.protocol = R3.API.Server.PROTOCOL_HTTP_SSL; } - this.protocol = protocol; + this.protocol = apiComponent.protocol; - if (R3.Utils.UndefinedOrNull(context)) { - context = null; + if (R3.Utils.UndefinedOrNull(apiComponent.context)) { + apiComponent.context = null; } - this.context = context; + this.context = apiComponent.context; - if (R3.Utils.UndefinedOrNull(application)) { - application = null; + if (R3.Utils.UndefinedOrNull(apiComponent.application)) { + apiComponent.application = null; } - this.application = application; + this.application = apiComponent.application; - if (R3.Utils.UndefinedOrNull(domain)) { - domain = null; + if (R3.Utils.UndefinedOrNull(apiComponent.domain)) { + apiComponent.domain = null; } - this.domain = domain; + this.domain = apiComponent.domain; - if (R3.Utils.UndefinedOrNull(ip)) { - ip = '127.0.0.1'; + if (R3.Utils.UndefinedOrNull(apiComponent.ip)) { + apiComponent.ip = '127.0.0.1'; } - this.ip = ip; + this.ip = apiComponent.ip; - if (R3.Utils.UndefinedOrNull(preferIp)) { - preferIp = false; + if (R3.Utils.UndefinedOrNull(apiComponent.preferIp)) { + apiComponent.preferIp = false; } - this.preferIp = preferIp; + this.preferIp = apiComponent.preferIp; - if (R3.Utils.UndefinedOrNull(port)) { - port = R3.API.Server.PORT_SECURE; + if (R3.Utils.UndefinedOrNull(apiComponent.port)) { + apiComponent.port = R3.API.Server.PORT_SECURE; } - this.port = port; + this.port = apiComponent.port; - if (R3.Utils.UndefinedOrNull(protocols)) { - protocols = []; + if (R3.Utils.UndefinedOrNull(apiComponent.protocols)) { + apiComponent.protocols = []; } - this.protocols = protocols; + this.protocols = apiComponent.protocols; }; R3.API.Server.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-socket-0.js b/src/r3-api-socket-0.js index 7039bd9..8f39efd 100644 --- a/src/r3-api-socket-0.js +++ b/src/r3-api-socket-0.js @@ -1,56 +1,55 @@ /** * R3.API.Socket * @param apiComponent - * @param roomId - * @param peerId - * @param server R3.Server + * @property roomId + * @property peerId + * @property server * @constructor */ R3.API.Socket = function( - apiComponent, - roomId, - peerId, - server + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(roomId)) { - roomId = 'room_' + R3.Utils.RandomId(); + if (R3.Utils.UndefinedOrNull(apiComponent.roomId)) { + apiComponent.roomId = 'room_' + R3.Utils.RandomId(); } - this.roomId = roomId; + this.roomId = apiComponent.roomId; - if (R3.Utils.UndefinedOrNull(peerId)) { - peerId = null; + if (R3.Utils.UndefinedOrNull(apiComponent.peerId)) { + apiComponent.peerId = null; } - this.peerId = peerId; + this.peerId = apiComponent.peerId; - if (R3.Utils.UndefinedOrNull(server)) { + if (R3.Utils.UndefinedOrNull(apiComponent.server)) { R3.Event.Emit( R3.Event.GET_WEBSOCKET_CONFIG, 'hello', function(websocketConfig) { if (websocketConfig) { - server = new R3.API.Server( - null, - null, - websocketConfig.protocol, - websocketConfig.context, - websocketConfig.application, - websocketConfig.domain + apiComponent.server = new R3.API.Server( + { + parent : this, + protocol : websocketConfig.protocol, + context : websocketConfig.context, + application : websocketConfig.application, + domain : websocketConfig.domain + } ); } else { - server = new R3.API.Server( - null, - null, - R3.API.Server.PROTOCOL_WEBSOCKET_SSL + apiComponent.server = new R3.API.Server( + { + parent : this, + protocol : R3.API.Server.PROTOCOL_WEBSOCKET_SSL + } ); } } ); } - this.server = server; + this.server = apiComponent.server; }; diff --git a/src/r3-api-socket-cast.js b/src/r3-api-socket-cast.js index a7946ad..e5a9f4c 100644 --- a/src/r3-api-socket-cast.js +++ b/src/r3-api-socket-cast.js @@ -1,45 +1,34 @@ /** * R3.API.Socket.Cast - * @param apiSocket - * @param castType - * @param source - * @param sourceProperties + * @param apiComponent + * @property castType + * @property source + * @property sourceProperties * @constructor */ R3.API.Socket.Cast = function( - apiSocket, - castType, - source, - sourceProperties + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiSocket)) { - apiSocket = {} - } - this.apiSocket = apiSocket; - R3.API.Socket.call( this, - this.apiSocket, - this.apiSocket.roomId, - this.apiSocket.peerId, - this.apiSocket.server + apiComponent ); - if (R3.Utils.UndefinedOrNull(castType)) { - castType = R3.API.Socket.Cast.CAST_TYPE_ROOM; + if (R3.Utils.UndefinedOrNull(apiComponent.castType)) { + apiComponent.castType = R3.API.Socket.Cast.CAST_TYPE_ROOM; } - this.castType = castType; + this.castType = apiComponent.castType; - if (R3.Utils.UndefinedOrNull(source)) { - source = null; + if (R3.Utils.UndefinedOrNull(apiComponent.source)) { + apiComponent.source = null; } - this.source = source; + this.source = apiComponent.source; - if (R3.Utils.UndefinedOrNull(sourceProperties)) { - sourceProperties = null; + if (R3.Utils.UndefinedOrNull(apiComponent.sourceProperties)) { + apiComponent.sourceProperties = null; } - this.sourceProperties = sourceProperties; + this.sourceProperties = apiComponent.sourceProperties; }; diff --git a/src/r3-api-socket-receive.js b/src/r3-api-socket-receive.js index f3151a7..6178850 100644 --- a/src/r3-api-socket-receive.js +++ b/src/r3-api-socket-receive.js @@ -1,45 +1,34 @@ /** * R3.API.Socket.Receive - * @param apiSocket - * @param receiveType - * @param destination - * @param destinationProperties + * @param apiComponent + * @property receiveType + * @property destination + * @property destinationProperties * @constructor */ R3.API.Socket.Receive = function( - apiSocket, - receiveType, - destination, - destinationProperties + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiSocket)) { - apiSocket = {} - } - this.apiSocket = apiSocket; - R3.API.Socket.call( this, - this.apiSocket, - this.apiSocket.roomId, - this.apiSocket.peerId, - this.apiSocket.server + apiComponent ); - if (R3.Utils.UndefinedOrNull(receiveType)) { - receiveType = R3.API.Socket.Receive.RECEIVE_TYPE_ROOM; + if (R3.Utils.UndefinedOrNull(apiComponent.receiveType)) { + apiComponent.receiveType = R3.API.Socket.Receive.RECEIVE_TYPE_ROOM; } - this.receiveType = receiveType; + this.receiveType = apiComponent.receiveType; - if (R3.Utils.UndefinedOrNull(destination)) { - destination = null; + if (R3.Utils.UndefinedOrNull(apiComponent.destination)) { + apiComponent.destination = null; } - this.destination = destination; + this.destination = apiComponent.destination; - if (R3.Utils.UndefinedOrNull(destinationProperties)) { - destinationProperties = null; + if (R3.Utils.UndefinedOrNull(apiComponent.destinationProperties)) { + apiComponent.destinationProperties = null; } - this.destinationProperties = destinationProperties; + this.destinationProperties = apiComponent.destinationProperties; }; diff --git a/src/r3-api-sphere.js b/src/r3-api-sphere.js index 53be1e5..33c059c 100644 --- a/src/r3-api-sphere.js +++ b/src/r3-api-sphere.js @@ -1,27 +1,34 @@ /** * R3.API.Sphere - * @constructor * @param apiComponent - * @param center - * @param radius + * + * @property center + * @property radius + * + * @constructor */ R3.API.Sphere = function( - apiComponent, - center, - radius + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(center)) { - center = new R3.API.Vector3(0,0,0); + if (R3.Utils.UndefinedOrNull(apiComponent.center)) { + apiComponent.center = new R3.API.Vector3( + { + parent : this, + x : 0, + y : 0, + z : 0 + } + ); } - this.center = center; + this.center = apiComponent.center; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; }; R3.API.Sphere.prototype = Object.create(R3.API.Sphere.prototype); diff --git a/src/r3-api-stats.js b/src/r3-api-stats.js index 762b4c0..8f8d284 100644 --- a/src/r3-api-stats.js +++ b/src/r3-api-stats.js @@ -1,20 +1,21 @@ /** * Raw Stats API object - should always correspond with the Stats Schema * @param apiComponent - * @param domElement + * + * @property domElement + * * @constructor */ R3.API.Stats = function( - apiComponent, - domElement + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(domElement)) { - domElement = null; + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; } - this.domElement = domElement; + this.domElement = apiComponent.domElement; }; diff --git a/src/r3-api-user.js b/src/r3-api-user.js index ce78fa6..3b1418d 100644 --- a/src/r3-api-user.js +++ b/src/r3-api-user.js @@ -1,69 +1,63 @@ /** - * API User + * R3.API.User * @param apiComponent - * @param googleId - * @param fullName - * @param givenName - * @param familyName - * @param imageUrl - * @param email - * @param uploadFolder - * @param idToken + * + * @property googleId + * @property fullName + * @property givenName + * @property familyName + * @property imageUrl + * @property email + * @property uploadFolder + * @property idToken + * * @constructor */ R3.API.User = function( - apiComponent, - googleId, - fullName, - givenName, - familyName, - imageUrl, - email, - uploadFolder, - idToken + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(googleId)) { + if (R3.Utils.UndefinedOrNull(apiComponent.googleId)) { throw new Error('invalid user - no google ID'); } - this.googleId = googleId; + this.googleId = apiComponent.googleId; - if (R3.Utils.UndefinedOrNull(fullName)) { - fullName = 'unknown full name'; + if (R3.Utils.UndefinedOrNull(apiComponent.fullName)) { + apiComponent.fullName = 'unknown full name'; } - this.fullName = fullName; + this.fullName = apiComponent.fullName; - if (R3.Utils.UndefinedOrNull(givenName)) { - givenName = 'unknown given name'; + if (R3.Utils.UndefinedOrNull(apiComponent.givenName)) { + apiComponent.givenName = 'unknown given name'; } - this.givenName = givenName; + this.givenName = apiComponent.givenName; - if (R3.Utils.UndefinedOrNull(familyName)) { - familyName = 'unknown family name'; + if (R3.Utils.UndefinedOrNull(apiComponent.familyName)) { + apiComponent.familyName = 'unknown family name'; } - this.familyName = familyName; + this.familyName = apiComponent.familyName; - if (R3.Utils.UndefinedOrNull(imageUrl)) { - imageUrl = 'unknown image URL'; + if (R3.Utils.UndefinedOrNull(apiComponent.imageUrl)) { + apiComponent.imageUrl = 'unknown image URL'; } - this.imageUrl = imageUrl; + this.imageUrl = apiComponent.imageUrl; - if (R3.Utils.UndefinedOrNull(email)) { + if (R3.Utils.UndefinedOrNull(apiComponent.email)) { throw new Error('invalid user - no email address'); } - this.email = email; + this.email = apiComponent.email; - if (R3.Utils.UndefinedOrNull(uploadFolder)) { - uploadFolder = email.replace('/','_DS_'); + if (R3.Utils.UndefinedOrNull(apiComponent.uploadFolder)) { + apiComponent.uploadFolder = email.replace('/','_DS_'); } - this.uploadFolder = uploadFolder; + this.uploadFolder = apiComponent.uploadFolder; - if (R3.Utils.UndefinedOrNull(idToken)) { - idToken = 'unknown ID token'; + if (R3.Utils.UndefinedOrNull(apiComponent.idToken)) { + apiComponent.idToken = 'unknown ID token'; } - this.idToken = idToken; + this.idToken = apiComponent.idToken; }; diff --git a/src/r3-api-vector2.js b/src/r3-api-vector2.js index e9df043..fd68aee 100644 --- a/src/r3-api-vector2.js +++ b/src/r3-api-vector2.js @@ -1,22 +1,34 @@ /** * R3.API.Vector2 - * @param x - * @param y + * @param apiComponent + * + * @property x + * @property y + * * @constructor */ -R3.API.Vector2 = function(x, y) { +R3.API.Vector2 = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(x)) { - x = 0; - } - this.x = x; + __DEREGISTER_COMPONENT__; - if (R3.Utils.UndefinedOrNull(y)) { - y = 0; + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.x)) { + apiComponent.x = 0; } - this.y = y; + this.x = apiComponent.x; + + if (R3.Utils.UndefinedOrNull(apiComponent.y)) { + apiComponent.y = 0; + } + this.y = apiComponent.y; }; +R3.API.Vector2.prototype = Object.create(R3.API.Component.prototype); +R3.API.Vector2.prototype.constructor = R3.API.Vector2; + /** * Equals * TODO: Test diff --git a/src/r3-api-vector3.js b/src/r3-api-vector3.js index bf118a9..19b2d62 100644 --- a/src/r3-api-vector3.js +++ b/src/r3-api-vector3.js @@ -1,29 +1,41 @@ /** * R3.API.Vector3 - * @param x - * @param y - * @param z + * @param apiComponent + * + * @property x + * @property y + * @property z + * * @constructor */ -R3.API.Vector3 = function(x, y, z) { +R3.API.Vector3 = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(x)) { - x = 0; - } - this.x = x; + __DEREGISTER_COMPONENT__; - if (R3.Utils.UndefinedOrNull(y)) { - y = 0; - } - this.y = y; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(z)) { - z = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.x)) { + apiComponent.x = 0; } - this.z = z; + this.x = apiComponent.x; + + if (R3.Utils.UndefinedOrNull(apiComponent.y)) { + apiComponent.y = 0; + } + this.y = apiComponent.y; + + if (R3.Utils.UndefinedOrNull(apiComponent.z)) { + apiComponent.z = 0; + } + this.z = apiComponent.z; }; +R3.API.Vector3.prototype = Object.create(R3.API.Component.prototype); +R3.API.Vector3.prototype.constructor = R3.API.Vector3; + R3.API.Vector3.prototype.setFrom = function(vector3) { this.x = vector3.x; this.y = vector3.y; @@ -64,8 +76,9 @@ R3.API.Vector3.prototype.cross = function(v) { }; R3.API.Vector3.prototype.lookAt = function(at, up) { - var lookAtMatrix = R3.API.Matrix4.lookAt(this, at, up); - return this.multiply(lookAtMatrix); + console.warn('todo: implement R3.API.Vector3.prototype.lookAt()'); + // var lookAtMatrix = R3.API.Matrix4.lookAt(this, at, up); +// return this.multiply(lookAtMatrix); }; R3.API.Vector3.prototype.translate = function(v) { @@ -88,9 +101,7 @@ R3.API.Vector3.prototype.squared = function() { R3.API.Vector3.prototype.copy = function() { return new R3.API.Vector3( - this.x, - this.y, - this.z + this ); }; @@ -149,7 +160,7 @@ R3.API.Vector3.prototype.multiply = function(object, cross) { var a = object; var b = this; - if (R3.Utils.UndefinedOrNull(cross)) { + if (R3.Utils.UndefinedOrNull(apiComponent.cross)) { cross = false; } diff --git a/src/r3-api-vector4.js b/src/r3-api-vector4.js index da0d283..2bedf2b 100644 --- a/src/r3-api-vector4.js +++ b/src/r3-api-vector4.js @@ -1,31 +1,43 @@ /** * R3.API.Vector4 - * @param x - * @param y - * @param z - * @param w + * @param apiComponent + * + * @property x + * @property y + * @property z + * @property w + * * @constructor */ -R3.API.Vector4 = function(x, y, z, w) { +R3.API.Vector4 = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(x)) { - x = 0; - } - this.x = x; + __DEREGISTER_COMPONENT__; - if (R3.Utils.UndefinedOrNull(y)) { - y = 0; - } - this.y = y; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(z)) { - z = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.x)) { + apiComponent.x = 0; } - this.z = z; + this.x = apiComponent.x; - if (R3.Utils.UndefinedOrNull(w)) { - w = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.y)) { + apiComponent.y = 0; } - this.w = w; + this.y = apiComponent.y; + + if (R3.Utils.UndefinedOrNull(apiComponent.z)) { + apiComponent.z = 0; + } + this.z = apiComponent.z; + + if (R3.Utils.UndefinedOrNull(apiComponent.w)) { + apiComponent.w = 0; + } + this.w = apiComponent.w; }; + +R3.API.Vector4.prototype = Object.create(R3.API.Component.prototype); +R3.API.Vector4.prototype.constructor = R3.API.Vector4; diff --git a/src/r3-api-video.js b/src/r3-api-video.js index 900e483..ca3808d 100644 --- a/src/r3-api-video.js +++ b/src/r3-api-video.js @@ -1,50 +1,54 @@ /** * R3.API.Video * @param apiComponent - * @param autoUpdateSize - * @param width - * @param height - * @param offset - * @param source + * + * @property autoUpdateSize + * @property width + * @property height + * @property offset + * @property source + * * @constructor */ R3.API.Video = function( apiComponent, - autoUpdateSize, - width, - height, - offset, - source ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(autoUpdateSize)) { - autoUpdateSize = true; + if (R3.Utils.UndefinedOrNull(apiComponent.autoUpdateSize)) { + apiComponent.autoUpdateSize = true; } - this.autoUpdateSize = autoUpdateSize; + this.autoUpdateSize = apiComponent.autoUpdateSize; var size = R3.Utils.GetWindowSize(); - if (R3.Utils.UndefinedOrNull(width)) { - width = size.width; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = size.width; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = size.height; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = size.height; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(offset)) { - offset = new R3.API.Vector2(0,0); + if (R3.Utils.UndefinedOrNull(apiComponent.offset)) { + apiComponent.offset = new R3.API.Vector2( + { + parent : this, + register : true, + x : 0, + y : 0 + } + ); } - this.offset = offset; + this.offset = apiComponent.offset; - if (R3.Utils.UndefinedOrNull(source)) { - source = null; + if (R3.Utils.UndefinedOrNull(apiComponent.source)) { + apiComponent.source = null; } - this.source = source; + this.source = apiComponent.source; }; diff --git a/src/r3-box3.js b/src/r3-box3.js index 68d7554..6c54736 100644 --- a/src/r3-box3.js +++ b/src/r3-box3.js @@ -7,28 +7,9 @@ R3.Box3 = function( apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.API.Box3.call( - this, - apiComponent, - apiComponent.min, - apiComponent.max - ); - - this.min = new R3.Vector3( - this, - this.min, - ); - - this.max = new R3.Vector3( - this, - this.max - ); - - this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.Box3.prototype = Object.create(R3.Component.prototype); @@ -40,14 +21,14 @@ R3.Box3.prototype.constructor = R3.Box3; */ R3.Box3.prototype.createInstance = function() { - switch (this.componentRuntime) { - case R3.Component.GRAPHICS_RUNTIME : + switch (this.parent.runtime) { + case R3.Runtime.GRAPHICS : this.instance = this.graphics.Box3( this.min, this.max ); break; - case R3.Component.PHYSICS_RUNTIME : + case R3.Runtime.PHYSICS : this.instance = this.physics.Box3( this.min, this.max @@ -57,6 +38,8 @@ R3.Box3.prototype.createInstance = function() { throw new Error('unhandled component runtime: ' + this.componentRuntime); } + __CREATE_INSTANCE__; + }; /** @@ -79,6 +62,6 @@ R3.Box3.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-canvas.js b/src/r3-canvas.js index 3d66b44..be849ec 100644 --- a/src/r3-canvas.js +++ b/src/r3-canvas.js @@ -1,41 +1,18 @@ /** * R3.Canvas - * @param parent * @param apiComponent * @constructor */ R3.Canvas = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Canvas.call( - this, - apiComponent, - apiComponent.autoUpdateSize, - apiComponent.width, - apiComponent.height, - apiComponent.offset, - apiComponent.tabIndex, - apiComponent.texts, - apiComponent.textBaseline - ); - - this.offset = new R3.Vector2( - this, - this.offset - ); + __RUNTIME_COMPONENT__; this.context = null; - R3.Component.call( - this, - { - 'texts' : [R3.D3.Text] - } - ); + __UPGRADE_TO_RUNTIME__; + }; R3.Canvas.prototype = Object.create(R3.Component.prototype); @@ -69,7 +46,7 @@ R3.Canvas.prototype.createInstance = function() { this.instance.height = this.height; } - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -142,7 +119,7 @@ R3.Canvas.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; R3.Canvas.prototype.writeText = function() { diff --git a/src/r3-clock.js b/src/r3-clock.js index df3939d..f146cd1 100644 --- a/src/r3-clock.js +++ b/src/r3-clock.js @@ -1,25 +1,16 @@ /** * R3.Clock - * @param parent * @param apiComponent * @constructor */ R3.Clock = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.API.Clock.call( - this, - apiComponent - ); + __UPGRADE_TO_RUNTIME__; - R3.Component.call( - this, - parent - ); } ; R3.Clock.prototype = Object.create(R3.Component.prototype); @@ -32,7 +23,7 @@ R3.Clock.prototype.createInstance = function() { this.instance = this.graphics.Clock(); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -41,21 +32,22 @@ R3.Clock.prototype.createInstance = function() { */ R3.Clock.prototype.updateInstance = function(property) { - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE; }; R3.Clock.prototype.getDelta = function() { - var delta = this.instance.getDelta(); + return this.instance.getDelta(); /** * clamp the delta to 1/60 */ - if (delta > (1 / 30.0)) { - // console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time'); - delta = (1 / 30.0); - } + // if (delta > (1 / 30.0)) { + // console.warn('clipping delta - todo: do we still need this?'); + // // console.log('clipped ' + (delta - (1/30.0)) + ' seconds - essentially lost time'); + // delta = (1 / 30.0); + // } - return delta; + //return delta; }; diff --git a/src/r3-color.js b/src/r3-color.js index e63af56..7512b28 100644 --- a/src/r3-color.js +++ b/src/r3-color.js @@ -1,36 +1,21 @@ /** * R3.Color - * @param parent * @param apiComponent * @constructor */ R3.Color = function( - parent, apiComponent ) { - /** - * Color does not extend component so initialize the parent - */ - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; + __DEREGISTER_COMPONENT__; - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.API.Color.call( - this, - apiComponent.r, - apiComponent.g, - apiComponent.b, - apiComponent.a - ); + __UPGRADE_TO_RUNTIME__; - this.createInstance(); }; -R3.Color.prototype = Object.create(R3.API.Color.prototype); +R3.Color.prototype = Object.create(R3.Component.prototype); R3.Color.prototype.constructor = R3.Color; /** @@ -46,6 +31,8 @@ R3.Color.prototype.createInstance = function() { this.a ); + __CREATE_INSTANCE__; + }; /** @@ -72,20 +59,10 @@ R3.Color.prototype.updateInstance = function(property) { this.instance.a = this.a; return; } + + __UPDATE_INSTANCE__; }; -/** - * Converts runtime color to API Color - * @returns {R3.API.Color} - */ -R3.Color.prototype.toApiObject = function() { - return new R3.API.Color(this, - this.r, - this.g, - this.b, - this.a - ); -}; /** * Converts the current color to HTML hex format (ex. #ffffff) @@ -152,4 +129,4 @@ R3.Color.prototype.fromHex = function(hex) { this.instance.r = this.r; this.instance.g = this.g; this.instance.b = this.b; -}; \ No newline at end of file +}; diff --git a/src/r3-controls-0.js b/src/r3-controls-0.js index 243fbc8..a63ef04 100644 --- a/src/r3-controls-0.js +++ b/src/r3-controls-0.js @@ -1,29 +1,11 @@ /** - * R3.Controls is an R3.Component - * @param parent - * @param linkedObjects + * R3.Controls * @constructor */ -R3.Controls = function( - parent, - linkedObjects -) { +R3.Controls = function() { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - linkedObjects = {}; - } + __UPGRADE_TO_RUNTIME__; - if (this.canvas instanceof R3.API.Component) { - this.canvas = R3.Component.ConstructFromObject(this.canvas); - } - - linkedObjects.canvas = R3.Canvas; - - R3.Component.call( - this, - parent, - linkedObjects - ); }; R3.Controls.prototype = Object.create(R3.Component.prototype); @@ -37,7 +19,7 @@ R3.Controls.prototype.updateInstance = function(property) { if (property === 'canvas') { R3.Event.Emit( - R3.Event.CANVAS_CHANGE, + R3.Event.CONTROLS_CANVAS_CHANGE, { component: this } @@ -45,5 +27,5 @@ R3.Controls.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-controls-d3.js b/src/r3-controls-d3-0.js similarity index 52% rename from src/r3-controls-d3.js rename to src/r3-controls-d3-0.js index 2aebaee..2d89e2c 100644 --- a/src/r3-controls-d3.js +++ b/src/r3-controls-d3-0.js @@ -1,24 +1,10 @@ /** - * R3.Controls.D3 is an R3.Controls - * @param parent - * @param linkedObjects + * R3.Controls.D3 * @constructor */ -R3.Controls.D3 = function( - parent, - linkedObjects -) { +R3.Controls.D3 = function() { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - linkedObjects = {}; - } - linkedObjects.camera = R3.D3.Camera; - - R3.Controls.call( - this, - parent, - linkedObjects - ); + R3.Controls.call(this); }; diff --git a/src/r3-controls-d3-editor.js b/src/r3-controls-d3-editor.js index b17c45e..31d14f5 100644 --- a/src/r3-controls-d3-editor.js +++ b/src/r3-controls-d3-editor.js @@ -1,35 +1,18 @@ /** - * R3.Controls.D3.Editor is an R3.Controls.D3 - * @param parent + * R3.Controls.D3.Editor * @param apiComponent * @constructor */ R3.Controls.D3.Editor = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Controls.D3.Editor.call( - this, - apiComponent, - apiComponent.raycaster - ); - - if (this.raycaster instanceof R3.API.Component) { - this.raycaster = R3.Component.ConstructFromObject(this.raycaster); - } - - var linkedObjects = { - raycaster : R3.D3.Raycaster - }; + __RUNTIME_COMPONENT__; R3.Controls.D3.call( - this, - parent, - linkedObjects - ) + this + ); + }; /** @@ -46,7 +29,7 @@ R3.Controls.D3.Editor.prototype.createInstance = function() { this.instance = this.graphics.EditorControls(this.canvas, this.camera); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-controls-d3-first-person.js b/src/r3-controls-d3-firstPerson.js similarity index 77% rename from src/r3-controls-d3-first-person.js rename to src/r3-controls-d3-firstPerson.js index 5b66518..e7ff559 100644 --- a/src/r3-controls-d3-first-person.js +++ b/src/r3-controls-d3-firstPerson.js @@ -1,39 +1,15 @@ /** - * R3.Controls.D3.FirstPerson is an R3.Controls.D3 - * @param parent + * R3.Controls.D3.FirstPerson * @param apiComponent * @constructor */ R3.Controls.D3.FirstPerson = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.API.Controls.D3.FirstPerson.call( - this, - apiComponent, - apiComponent.enabled, - apiComponent.movementSpeed, - apiComponent.lookSpeed, - apiComponent.lookVertical, - apiComponent.autoForward, - apiComponent.activeLook, - apiComponent.heightSpeed, - apiComponent.heightCoef, - apiComponent.heightMin, - apiComponent.heightMax, - apiComponent.constrainVertical, - apiComponent.verticalMin, - apiComponent.verticalMax, - apiComponent.autoSpeedFactor - ); - - R3.Controls.D3.call( - this, - parent - ) + R3.Controls.D3.call(this); }; @@ -68,7 +44,7 @@ R3.Controls.D3.FirstPerson.prototype.createInstance = function() { this.autoSpeedFactor ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-controls-d3-orbit.js b/src/r3-controls-d3-orbit.js index ff05f7b..e3b03e5 100644 --- a/src/r3-controls-d3-orbit.js +++ b/src/r3-controls-d3-orbit.js @@ -1,49 +1,15 @@ /** - * R3.Controls.D3.Orbit is an R3.Controls.D3 - * @param parent + * R3.Controls.D3.Orbit * @param apiComponent * @constructor */ R3.Controls.D3.Orbit = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.API.Controls.D3.Orbit.call( - this, - apiComponent, - apiComponent.target, - apiComponent.enabled, - apiComponent.minPolarAngle, - apiComponent.maxPolarAngle, - apiComponent.enableDamping, - apiComponent.dampingFactor, - apiComponent.enableZoom, - apiComponent.zoomSpeed, - apiComponent.enableRotate, - apiComponent.rotateSpeed, - apiComponent.enablePan, - apiComponent.keyPanSpeed, - apiComponent.autoRotate, - apiComponent.autoRotateSpeed, - apiComponent.enableKeys - ); - - if (this.target instanceof R3.API.Component) { - this.target = R3.Component.ConstructFromObject(this.target); - } - - var linkedObjects = { - target : R3.D3.Object - }; - - R3.Controls.D3.call( - this, - parent, - linkedObjects - ) + R3.Controls.D3.call(this); }; @@ -75,7 +41,7 @@ R3.Controls.D3.Orbit.prototype.createInstance = function() { this.enableKeys ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-controls-keyboard.js b/src/r3-controls-keyboard.js index d54b4e2..38546ae 100644 --- a/src/r3-controls-keyboard.js +++ b/src/r3-controls-keyboard.js @@ -1,24 +1,16 @@ /** - * R3.Controls.Keyboard is an R3.Controls - * @param parent + * R3.Controls.Keyboard * @param apiComponent * @constructor */ R3.Controls.Keyboard = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Controls.Keyboard.call( - this, - apiComponent - ); + __RUNTIME_COMPONENT__; R3.Controls.call( - this, - parent + this ); }; @@ -35,7 +27,7 @@ R3.Controls.Keyboard.prototype.constructor = R3.Controls.Keyboard; */ R3.Controls.Keyboard.prototype.createInstance = function() { this.instance = true; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-controls-mouse.js b/src/r3-controls-mouse.js index 24c0ac7..a062f48 100644 --- a/src/r3-controls-mouse.js +++ b/src/r3-controls-mouse.js @@ -1,24 +1,16 @@ /** * R3.Controls.Mouse - * @param parent * @param apiComponent * @constructor */ R3.Controls.Mouse = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Controls.Mouse.call( - this, - apiComponent - ); + __RUNTIME_COMPONENT__; R3.Controls.call( - this, - parent + this ); }; @@ -35,7 +27,7 @@ R3.Controls.Mouse.prototype.constructor = R3.Controls.Mouse; */ R3.Controls.Mouse.prototype.createInstance = function() { this.instance = true; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-controls-touch.js b/src/r3-controls-touch.js index e64b4b8..04db511 100644 --- a/src/r3-controls-touch.js +++ b/src/r3-controls-touch.js @@ -1,25 +1,16 @@ /** - * Touch Controls - * @constructor - * @param parent + * R3.Controls.Touch * @param apiComponent + * @constructor */ R3.Controls.Touch = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Controls.Touch.call( - this, - apiComponent, - apiComponent.sensitivity - ); + __RUNTIME_COMPONENT__; R3.Controls.call( - this, - parent + this ); }; @@ -37,7 +28,7 @@ R3.Controls.Touch.prototype.constructor = R3.Controls.Touch; */ R3.Controls.Touch.prototype.createInstance = function() { this.instance = true; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-curve-0.js b/src/r3-curve-0.js new file mode 100644 index 0000000..b1b7051 --- /dev/null +++ b/src/r3-curve-0.js @@ -0,0 +1,56 @@ +/** + * R3.Curve + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Curve = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; + } + + if (inherited) { + /** + * Do not construct a runtime object of this class - the child is the runtime object + */ + } else { + + __RUNTIME_COMPONENT__; + + } + + __UPGRADE_TO_RUNTIME__; + +}; + +R3.Curve.prototype = Object.create(R3.Component.prototype); +R3.Curve.prototype.constructor = R3.Curve; + +/** + * Create Instance + */ +R3.Curve.prototype.createInstance = function() { + + this.instance = this.graphics.Curve(this.arcLenghDivisions); + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Curve.prototype.updateInstance = function(property) { + + if (property === 'arcLenghDivisions') { + this.instance.arcLenghDivisions = this.arcLenghDivisions; + return; + } + + __UPDATE_INSTANCE__; + +}; diff --git a/src/r3-curve-a.js b/src/r3-curve-a.js deleted file mode 100644 index 89ceffc..0000000 --- a/src/r3-curve-a.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * R3.Curve - * @param parent - * @param apiComponent - * @param linkedObjects - * @constructor - */ -R3.Curve = function( - parent, - apiComponent, - linkedObjects -) { - - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - - /** - * This class behaves in such a way that we can create instances from it - we define the runtime and construct - * the api object and upgrade its properties (if any) to runtime - */ - - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Curve.call( - this, - apiComponent, - apiComponent.arcLenghDivisions - ); - - } else { - - /** - * This class was inherited and Component constructor will call the child class createInstance() - * Add any more linking information to the linkedObjects object here - */ - - } - - R3.Component.call( - this, - parent, - linkedObjects - ); - -}; - -R3.Curve.prototype = Object.create(R3.Component.prototype); -R3.Curve.prototype.constructor = R3.Curve; - -/** - * Create Instance - */ -R3.Curve.prototype.createInstance = function() { - this.instance = this.graphics.Curve(this.arcLenghDivisions); - R3.Component.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.Curve.prototype.updateInstance = function(property) { - - if (property === 'arcLenghDivisions') { - this.instance.arcLenghDivisions = this.arcLenghDivisions; - return; - } - - R3.Component.prototype.updateInstance.call(this, property); -}; diff --git a/src/r3-curve-path-0.js b/src/r3-curve-path-0.js new file mode 100644 index 0000000..7452065 --- /dev/null +++ b/src/r3-curve-path-0.js @@ -0,0 +1,63 @@ +/** + * R3.Curve.Path + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Curve.Path = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; + } + + if (inherited) { + /** + * Do not construct a runtime object of this class - the child is the runtime object + */ + } else { + + __RUNTIME_COMPONENT__; + + } + + R3.Curve.call( + this, + apiComponent, + true + ) +}; + +R3.Curve.Path.prototype = Object.create(R3.Curve.prototype); +R3.Curve.Path.prototype.constructor = R3.Curve.Path; + +/** + * Creates a camera instance + * @returns {*} + */ +R3.Curve.Path.prototype.createInstance = function() { + + this.instance = this.graphics.CurvePath(this.curves, this.autoClose); + + __CREATE_INSTANCE__; +}; + +/** + * Updates the instance with the current state + */ +R3.Curve.Path.prototype.updateInstance = function(property) { + + if (property === 'curves') { + console.warn('todo: update curves'); + return; + } + + if (property === 'autoClose') { + this.instance.autoClose = this.autoClose; + return; + } + + R3.Curve.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-curve-path-a.js b/src/r3-curve-path-a.js deleted file mode 100644 index 4ea2f99..0000000 --- a/src/r3-curve-path-a.js +++ /dev/null @@ -1,100 +0,0 @@ -/** - * R3.Curve.Path - * @constructor - * @param parent - * @param apiComponent - * @param linkedObjects - */ -R3.Curve.Path = function( - parent, - apiComponent, - linkedObjects -) { - - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - - /** - * This class behaves in such a way that we can create instances from it - we define the runtime and construct - * the api object and upgrade its properties to runtime - */ - - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Curve.Path.call( - this, - apiComponent, - apiComponent.curves, - apiComponent.autoClose - ); - - this.curves = this.curves.reduce( - function(result, curve) { - - if (curve instanceof R3.API.Component) { - curve = R3.Component.ConstructFromObject(curve); - } - - result.push(curve); - - return result; - }, - [] - ); - - linkedObjects = { - curves : [R3.Curve] - }; - - } else { - - /** - * This class was inherited and Component constructor will call the child class createInstance() - * Add any more linking information to the linkedObjects object here - and pass up the inheritence chain - * so more linking information can be attached - */ - linkedObjects.curves = [R3.Curve]; - } - - /** - * Now we call the parent class but with linkedObjects - indicating that its being called from a child class - * and should not do any runtime instantiation - */ - R3.Curve.call( - this, - parent, - apiComponent, - linkedObjects - ) -}; - -R3.Curve.Path.prototype = Object.create(R3.Curve.prototype); -R3.Curve.Path.prototype.constructor = R3.Curve.Path; - -/** - * Creates a camera instance - * @returns {*} - */ -R3.Curve.Path.prototype.createInstance = function() { - - this.instance = this.graphics.CurvePath(this.curves, this.autoClose); - - R3.Component.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.Curve.Path.prototype.updateInstance = function(property) { - - if (property === 'curves') { - console.warn('todo: update curves'); - return; - } - - if (property === 'autoClose') { - this.instance.autoClose = this.autoClose; - return; - } - - R3.Curve.prototype.updateInstance.call(this, property); -}; diff --git a/src/r3-curve-path-d2-0.js b/src/r3-curve-path-d2-0.js new file mode 100644 index 0000000..76c2fa1 --- /dev/null +++ b/src/r3-curve-path-d2-0.js @@ -0,0 +1,59 @@ +/** + * R3.Curve.Path.D2 + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Curve.Path.D2 = function( + apiComponent, + inherited +) { + + + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; + } + + if (inherited) { + /** + * Do not construct a runtime object of this class - the child is the runtime object + */ + } else { + + __RUNTIME_COMPONENT__; + + } + + R3.Curve.Path.call( + this, + apiComponent, + true + ); + +}; + +R3.Curve.Path.D2.prototype = Object.create(R3.Curve.Path.prototype); +R3.Curve.Path.D2.prototype.constructor = R3.Curve.Path.D2; + +/** + * Creates a camera instance + * @returns {*} + */ +R3.Curve.Path.D2.prototype.createInstance = function() { + + this.instance = this.graphics.Path(this.points); + + __CREATE_INSTANCE__; +}; + +/** + * Updates the instance with the current state + */ +R3.Curve.Path.D2.prototype.updateInstance = function(property) { + + if (property === 'points') { + console.warn('todo: update points (and test it)'); + } + + R3.Curve.Path.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-curve-path-d2-a.js b/src/r3-curve-path-d2-a.js deleted file mode 100644 index 23dd701..0000000 --- a/src/r3-curve-path-d2-a.js +++ /dev/null @@ -1,98 +0,0 @@ -/** - * R3.Curve.Path.D2 - * @param parent - * @param apiComponent - * @param linkedObjects - * @constructor - */ -R3.Curve.Path.D2 = function( - parent, - apiComponent, - linkedObjects -) { - - - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - - /** - * This class behaves in such a way that we can create instances from it - we define the runtime and construct - * the api object and upgrade its properties to runtime - */ - - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Curve.Path.D2.call( - this, - apiComponent, - apiComponent.points - ); - - } else { - - /** - * This class was inherited and Component constructor will call the child class createInstance() - * Add any more linking information to the linkedObjects object here - - * Points aren't components so they don't get added to linkedObjects - * @type {R3.Vector2} - */ - - } - - this.points = this.points.reduce( - function(result, point) { - - /** - * Points aren't components so they don't get added to linkedObjects - * @type {R3.Vector2} - */ - point = new R3.Vector2( - this, - point - ); - - result.push(point); - - return result; - }, - [] - ); - - /** - * Now we call the parent class but with linkedObjects - indicating that its being called from a child class - * and should not do any runtime instantiation - */ - R3.Curve.Path.call( - this, - parent, - apiComponent, - linkedObjects - ); - - -}; - -R3.Curve.Path.D2.prototype = Object.create(R3.Curve.Path.prototype); -R3.Curve.Path.D2.prototype.constructor = R3.Curve.Path.D2; - -/** - * Creates a camera instance - * @returns {*} - */ -R3.Curve.Path.D2.prototype.createInstance = function() { - - this.instance = this.graphics.Path(this.points); - - R3.Component.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.Curve.Path.D2.prototype.updateInstance = function(property) { - - if (property === 'points') { - console.warn('todo: update points (and test it)'); - } - - R3.Curve.Path.prototype.updateInstance.call(this, property); -}; diff --git a/src/r3-curve-path-d2-shape.js b/src/r3-curve-path-d2-shape.js index 0a9d9fe..a027321 100644 --- a/src/r3-curve-path-d2-shape.js +++ b/src/r3-curve-path-d2-shape.js @@ -1,48 +1,35 @@ /** * R3.Curve.Path.D2.Shape - * @param parent * @param apiComponent - * @param linkedObjects + * @param inherited * @constructor */ R3.Curve.Path.D2.Shape = function( - parent, apiComponent, - linkedObjects + inherited ) { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - - /** - * This class behaves in such a way that we can create instances from it - we define the runtime and construct - * the api object and upgrade its properties to runtime - */ - - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Curve.Path.D2.Shape.call( - this, - apiComponent - ); - - } else { - - /** - * This class was inherited and Component constructor will call the child class createInstance() - * Add any more linking information to the linkedObjects object here - */ - + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; } + if (inherited) { + /** + * Do not construct a runtime object of this class - the child is the runtime object + */ + } else { + + __RUNTIME_COMPONENT__; + + } /** * Now we call the parent class but with linkedObjects - indicating that its being called from a child class * and should not do any runtime instantiation */ R3.Curve.Path.D2.call( this, - parent, apiComponent, - linkedObjects + true ) }; @@ -58,7 +45,7 @@ R3.Curve.Path.D2.Shape.prototype.createInstance = function() { this.instance = this.graphics.Shape(this.points); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-custom-code.js b/src/r3-customCode.js similarity index 89% rename from src/r3-custom-code.js rename to src/r3-customCode.js index e0113b7..7ff60bc 100644 --- a/src/r3-custom-code.js +++ b/src/r3-customCode.js @@ -1,29 +1,17 @@ /** * R3.CustomCode - * @param parent * @param apiComponent * @constructor */ R3.CustomCode = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.CustomCode.call( - this, - apiComponent, - apiComponent.eventId, - apiComponent.code, - ); + __RUNTIME_COMPONENT__; this.editor = null; - R3.Component.call( - this, - parent - ); + __UPGRADE_TO_RUNTIME__; }; R3.CustomCode.prototype = Object.create(R3.Component.prototype); @@ -43,7 +31,7 @@ R3.CustomCode.prototype.createInstance = function() { this.instance = new Function('data', "console.log('compilation failed for : " + this.name + "');").bind(this); } - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -93,7 +81,7 @@ R3.CustomCode.prototype.updateInstance = function(property) { ) } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; R3.CustomCode.prototype.launchEditor = function(){ diff --git a/src/r3-d3-api-0-object.js b/src/r3-d3-api-0-object.js index 3fc2b25..b6122fb 100644 --- a/src/r3-d3-api-0-object.js +++ b/src/r3-d3-api-0-object.js @@ -1,62 +1,93 @@ /** * R3.D3.API.Object * @param apiComponent - * @param useQuaternion - * @param position - * @param quaternion - * @param rotation - * @param scale - * @param up - * @param lookAt + * + * @property useQuaternion + * @property position + * @property quaternion + * @property rotation + * @property scale + * @property up + * @property lookAt + * * @constructor */ R3.D3.API.Object = function( - apiComponent, - useQuaternion, - position, - quaternion, - rotation, - scale, - up, - lookAt + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(useQuaternion)) { - useQuaternion = true; + if (R3.Utils.UndefinedOrNull(apiComponent.useQuaternion)) { + apiComponent.useQuaternion = false; } - this.useQuaternion = useQuaternion; + this.useQuaternion = apiComponent.useQuaternion; - if (R3.Utils.UndefinedOrNull(position)) { - position = new R3.API.Vector3(); + if (R3.Utils.UndefinedOrNull(apiComponent.position)) { + apiComponent.position = new R3.API.Vector3( + { + parent : this, + register : true + } + ); } - this.position = position; + this.position = apiComponent.position; - if (R3.Utils.UndefinedOrNull(quaternion)) { - quaternion = new R3.API.Quaternion(); + if (R3.Utils.UndefinedOrNull(apiComponent.quaternion)) { + apiComponent.quaternion = new R3.API.Quaternion( + { + parent : this, + register : true + } + ); } - this.quaternion = quaternion; + this.quaternion = apiComponent.quaternion; - if (R3.Utils.UndefinedOrNull(rotation)) { - rotation = new R3.API.Vector3(); + if (R3.Utils.UndefinedOrNull(apiComponent.rotation)) { + apiComponent.rotation = new R3.API.Vector3( + { + parent : this, + register : true + } + ); } - this.rotation = rotation; + this.rotation = apiComponent.rotation; - if (R3.Utils.UndefinedOrNull(scale)) { - scale = new R3.API.Vector3(1,1,1); + if (R3.Utils.UndefinedOrNull(apiComponent.scale)) { + apiComponent.scale = new R3.API.Vector3( + { + parent : this, + register : true, + x : 1, + y : 1, + z : 1 + } + ); } - this.scale = scale; + this.scale = apiComponent.scale; - if (R3.Utils.UndefinedOrNull(up)) { - up = new R3.API.Vector3(0,1,0); + if (R3.Utils.UndefinedOrNull(apiComponent.up)) { + apiComponent.up = new R3.API.Vector3( + { + parent : this, + register : true, + x : 0, + y : 1, + z : 0 + } + ); } - this.up = up; + this.up = apiComponent.up; - if (R3.Utils.UndefinedOrNull(lookAt)) { - lookAt = new R3.API.Vector3(); + if (R3.Utils.UndefinedOrNull(apiComponent.lookAt)) { + apiComponent.lookAt = new R3.API.Vector3( + { + parent : this, + register : true + } + ); } - this.lookAt = lookAt; + this.lookAt = apiComponent.lookAt; }; diff --git a/src/r3-d3-api-animation.js b/src/r3-d3-api-animation.js index ad454cf..d5c308c 100644 --- a/src/r3-d3-api-animation.js +++ b/src/r3-d3-api-animation.js @@ -1,75 +1,79 @@ /** * R3.D3.API.Animation * @param apiComponent - * @param rotationSpeed - * @param translationSpeed - * @param scaleSpeed - * @param rotationFn - * @param translationFn - * @param scaleFn - * @param blocking - * @param applyToMeshWhenDone + * + * @property rotationSpeed + * @property translationSpeed + * @property scaleSpeed + * @property rotationFn + * @property translationFn + * @property scaleFn + * @property blocking + * @property applyToMeshWhenDone + * @property functionType + * * @constructor */ R3.D3.API.Animation = function( apiComponent, - rotationSpeed, - translationSpeed, - scaleSpeed, - rotationFn, - translationFn, - scaleFn, - blocking, - applyToMeshWhenDone ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(rotationSpeed)) { - rotationSpeed = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.rotationSpeed)) { + apiComponent.rotationSpeed = 0; } - this.rotationSpeed = rotationSpeed; + this.rotationSpeed = apiComponent.rotationSpeed; - if (R3.Utils.UndefinedOrNull(translationSpeed)) { - translationSpeed = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.translationSpeed)) { + apiComponent.translationSpeed = 0; } - this.translationSpeed = translationSpeed; + this.translationSpeed = apiComponent.translationSpeed; - if (R3.Utils.UndefinedOrNull(scaleSpeed)) { - scaleSpeed = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.scaleSpeed)) { + apiComponent.scaleSpeed = 0; } - this.scaleSpeed = scaleSpeed; + this.scaleSpeed = apiComponent.scaleSpeed; - if (R3.Utils.UndefinedOrNull(rotationFn)) { - rotationFn = null; + if (R3.Utils.UndefinedOrNull(apiComponent.rotationFn)) { + apiComponent.rotationFn = null; } - this.rotationFn = rotationFn; + this.rotationFn = apiComponent.rotationFn; - if (R3.Utils.UndefinedOrNull(translationFn)) { - translationFn = null; + if (R3.Utils.UndefinedOrNull(apiComponent.translationFn)) { + apiComponent.translationFn = null; } - this.translationFn = translationFn; + this.translationFn = apiComponent.translationFn; - if (R3.Utils.UndefinedOrNull(scaleFn)) { - scaleFn = null; + if (R3.Utils.UndefinedOrNull(apiComponent.scaleFn)) { + apiComponent.scaleFn = null; } - this.scaleFn = scaleFn; + this.scaleFn = apiComponent.scaleFn; - if (R3.Utils.UndefinedOrNull(blocking)) { - blocking = { + if (R3.Utils.UndefinedOrNull(apiComponent.blocking)) { + apiComponent.blocking = { position : false, //positions can be blocked from accumulating and executing at once rotation : true, //rotations need to execute in order scale : false //scale can accumulate }; } - this.blocking = blocking; + this.blocking = apiComponent.blocking; - if (R3.Utils.UndefinedOrNull(applyToMeshWhenDone)) { - applyToMeshWhenDone = true; + if (R3.Utils.UndefinedOrNull(apiComponent.applyToMeshWhenDone)) { + apiComponent.applyToMeshWhenDone = true; } - this.applyToMeshWhenDone = applyToMeshWhenDone; + this.applyToMeshWhenDone = apiComponent.applyToMeshWhenDone; + + if (R3.Utils.UndefinedOrNull(apiComponent.functionType)) { + apiComponent.functionType = R3.D3.API.Animation.ANIMATION_FUNCTION_TYPE_ROTATION; + } + this.functionType = apiComponent.functionType; }; R3.D3.API.Animation.prototype = Object.create(R3.API.Component.prototype); R3.D3.API.Animation.prototype.constructor = R3.D3.API.Animation; + +R3.D3.API.Animation.ANIMATION_FUNCTION_TYPE_ROTATION = 1; +R3.D3.API.Animation.ANIMATION_FUNCTION_TYPE_TRANSLATION = 2; +R3.D3.API.Animation.ANIMATION_FUNCTION_TYPE_SCALE = 3; \ No newline at end of file diff --git a/src/r3-d3-api-audio.js b/src/r3-d3-api-audio.js index 0a64268..0c57b15 100644 --- a/src/r3-d3-api-audio.js +++ b/src/r3-d3-api-audio.js @@ -1,48 +1,57 @@ /** * R3.D3.API.Audio * @param apiComponent - * @param path - * @param loop - * @param volume - * @param cameraIndex - * @param paused + * + * @property path + * @property loop + * @property volume + * @property camera + * @property paused + * * @constructor */ R3.D3.API.Audio = function( - apiComponent, - path, - loop, - volume, - cameraIndex, - paused + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(path)) { - path = ''; + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = ''; } - this.path = path; + this.path = apiComponent.path; - if (R3.Utils.UndefinedOrNull(loop)) { - loop = false; + if (R3.Utils.UndefinedOrNull(apiComponent.loop)) { + apiComponent.loop = false; } - this.loop = loop; + this.loop = apiComponent.loop; - if (R3.Utils.UndefinedOrNull(volume)) { - volume = 0.5; + if (R3.Utils.UndefinedOrNull(apiComponent.volume)) { + apiComponent.volume = 0.5; } - this.volume = volume; + this.volume = apiComponent.volume; - if (R3.Utils.UndefinedOrNull(cameraIndex)) { - cameraIndex = R3.API.Project.CAMERA_INDEX_RUN; - } - this.cameraIndex = cameraIndex; + if (R3.Utils.UndefinedOrNull(apiComponent.camera)) { + + R3.Event.Emit( + R3.Event.GET_PROJECT, + null, + function(project) { + apiComponent.camera = project.cameras[R3.API.Project.CAMERA_INDEX_RUN]; + } + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.camera)) { + throw new Error('unhandled state : no project runtime camera for audio component'); + } - if (R3.Utils.UndefinedOrNull(paused)) { - paused = false; } - this.paused = paused; + this.camera = apiComponent.camera; + + if (R3.Utils.UndefinedOrNull(apiComponent.paused)) { + apiComponent.paused = false; + } + this.paused = apiComponent.paused; }; diff --git a/src/r3-d3-api-bone-weight.js b/src/r3-d3-api-bone-weight.js deleted file mode 100644 index f33cf77..0000000 --- a/src/r3-d3-api-bone-weight.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * R3.D3.API.BoneWeight - * @param apiComponent - * @param boneIndex - * @param weight - * @constructor - */ -R3.D3.API.BoneWeight = function( - apiComponent, - boneIndex, - weight -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(boneIndex)) { - boneIndex = 0; - } - this.boneIndex = boneIndex; - - if (R3.Utils.UndefinedOrNull(weight)) { - weight = 0; - } - this.weight = weight; -}; - -R3.D3.API.BoneWeight.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.BoneWeight.prototype.constructor = R3.D3.API.BoneWeight; diff --git a/src/r3-d3-api-bone.js b/src/r3-d3-api-bone.js index 19a58f7..a801478 100644 --- a/src/r3-d3-api-bone.js +++ b/src/r3-d3-api-bone.js @@ -1,42 +1,25 @@ /** * R3.D3.API.Bone - * @param apiD3Object - * @param childBoneIds - * @param parentBoneIds + * @param apiComponent + * + * @property children + * @property parent + * * @constructor */ R3.D3.API.Bone = function( - apiD3Object, - childBoneIds, - parentBoneIds + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiD3Object)) { - apiD3Object = {}; - } - this.apiD3Object = apiD3Object; - R3.D3.API.Object.call( this, - this.apiD3Object, - this.apiD3Object.useQuaternion, - this.apiD3Object.position, - this.apiD3Object.quaternion, - this.apiD3Object.rotation, - this.apiD3Object.scale, - this.apiD3Object.up, - this.apiD3Object.lookAt + apiComponent ); - if (R3.Utils.UndefinedOrNull(childBoneIds)) { - childBoneIds = []; + if (R3.Utils.UndefinedOrNull(apiComponent.children)) { + apiComponent.children = []; } - this.childBoneIds = childBoneIds; - - if (R3.Utils.UndefinedOrNull(parentBoneIds)) { - parentBoneIds = []; - } - this.parentBoneIds = parentBoneIds; + this.children = apiComponent.children; }; diff --git a/src/r3-d3-api-boneWeight.js b/src/r3-d3-api-boneWeight.js new file mode 100644 index 0000000..ce23dc8 --- /dev/null +++ b/src/r3-d3-api-boneWeight.js @@ -0,0 +1,29 @@ +/** + * R3.D3.API.BoneWeight + * @param apiComponent + * + * @property boneIndex + * @property weight + * + * @constructor + */ +R3.D3.API.BoneWeight = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.boneIndex)) { + apiComponent.boneIndex = 0; + } + this.boneIndex = apiComponent.boneIndex; + + if (R3.Utils.UndefinedOrNull(apiComponent.weight)) { + apiComponent.weight = 0; + } + this.weight = apiComponent.weight; + +}; + +R3.D3.API.BoneWeight.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.BoneWeight.prototype.constructor = R3.D3.API.BoneWeight; diff --git a/src/r3-d3-api-broadphase.js b/src/r3-d3-api-broadphase.js index 822cd3c..a25a73a 100644 --- a/src/r3-d3-api-broadphase.js +++ b/src/r3-d3-api-broadphase.js @@ -1,22 +1,32 @@ /** - * Raw Broadphase API object - should always correspond with the Broadphase Schema + * R3.D3.API.Broadphase * @param apiComponent - * @param broadphaseType + * + * @property broadphaseType + * * @constructor */ R3.D3.API.Broadphase = function( - apiComponent, - broadphaseType + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(broadphaseType)) { - broadphaseType = R3.D3.Broadphase.BROADPHASE_TYPE_NAIVE; + if (R3.Utils.UndefinedOrNull(apiComponent.broadphaseType)) { + apiComponent.broadphaseType = R3.D3.API.Broadphase.BROADPHASE_TYPE_NAIVE; } - this.broadphaseType = broadphaseType; + this.broadphaseType = apiComponent.broadphaseType; }; R3.D3.API.Broadphase.prototype = Object.create(R3.API.Component.prototype); R3.D3.API.Broadphase.prototype.constructor = R3.D3.API.Broadphase; + +/** + * Broadphase Types + * @type {number} + */ +R3.D3.API.Broadphase.BROADPHASE_TYPE_NAIVE = 0x1; +R3.D3.API.Broadphase.BROADPHASE_TYPE_GRID = 0x2; +R3.D3.API.Broadphase.BROADPHASE_TYPE_SAP = 0x3; + diff --git a/src/r3-d3-api-camera-0.js b/src/r3-d3-api-camera-0.js new file mode 100644 index 0000000..b29970c --- /dev/null +++ b/src/r3-d3-api-camera-0.js @@ -0,0 +1,32 @@ +/** + * R3.D3.API.Camera + * @param apiComponent + * + * @property aspect + * + * @constructor + */ +R3.D3.API.Camera = function( + apiComponent +) { + + R3.D3.API.Object.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.aspect)) { + apiComponent.aspect = R3.D3.API.Camera.ASPECT_RATIO_1_1; + } + this.aspect = apiComponent.aspect; + +}; + +R3.D3.API.Camera.prototype = Object.create(R3.D3.API.Object.prototype); +R3.D3.API.Camera.prototype.constructor = R3.D3.API.Camera; + +R3.D3.API.Camera.ASPECT_RATIO_1_1 = 1; +R3.D3.API.Camera.ASPECT_RATIO_3_2 = 3/2; +R3.D3.API.Camera.ASPECT_RATIO_4_3 = 4/3; +R3.D3.API.Camera.ASPECT_RATIO_16_9 = 16/9; +R3.D3.API.Camera.ASPECT_RATIO_16_10 = 16/10; \ No newline at end of file diff --git a/src/r3-d3-api-camera-a.js b/src/r3-d3-api-camera-a.js deleted file mode 100644 index d25ef04..0000000 --- a/src/r3-d3-api-camera-a.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * R3.D3.API.Camera - * @param apiD3Object - * @param aspect - * @constructor - */ -R3.D3.API.Camera = function( - apiD3Object, - aspect -) { - - if (R3.Utils.UndefinedOrNull(apiD3Object)) { - apiD3Object = {}; - } - this.apiD3Object = apiD3Object; - - if (R3.Utils.UndefinedOrNull(apiD3Object.position)) { - apiD3Object.position = new R3.API.Vector3( - 15, - 15, - 15 - ); - } - - R3.D3.API.Object.call( - this, - this.apiD3Object, - this.apiD3Object.useQuaternion, - this.apiD3Object.position, - this.apiD3Object.quaternion, - this.apiD3Object.rotation, - this.apiD3Object.scale, - this.apiD3Object.up, - this.apiD3Object.lookAt - ); - - if (R3.Utils.UndefinedOrNull(aspect)) { - aspect = R3.D3.API.Camera.ASPECT_RATIO_1_1; - } - this.aspect = aspect; - -}; - -R3.D3.API.Camera.prototype = Object.create(R3.D3.API.Object.prototype); -R3.D3.API.Camera.prototype.constructor = R3.D3.API.Camera; - -R3.D3.API.Camera.ASPECT_RATIO_1_1 = 1; -R3.D3.API.Camera.ASPECT_RATIO_3_2 = 3/2; -R3.D3.API.Camera.ASPECT_RATIO_4_3 = 4/3; -R3.D3.API.Camera.ASPECT_RATIO_16_9 = 16/9; -R3.D3.API.Camera.ASPECT_RATIO_16_10 = 16/10; \ No newline at end of file diff --git a/src/r3-d3-api-camera-cube.js b/src/r3-d3-api-camera-cube.js index 6440eef..ffbb84c 100644 --- a/src/r3-d3-api-camera-cube.js +++ b/src/r3-d3-api-camera-cube.js @@ -3,51 +3,52 @@ * * CubeCamera's have hardcoded fov=90 and aspect=1 * + * @param apiComponent + * + * @property near + * @property far + * @property fov + * @property cubeResolution + * @property renderTarget + * * @constructor - * @param apiD3Camera - * @param near - * @param far - * @param cubeResolution - * @param renderTarget */ R3.D3.API.Camera.Cube = function( - apiD3Camera, - near, - far, - cubeResolution, - renderTarget + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiD3Camera)) { - apiD3Camera = {}; - } - this.apiD3Camera = apiD3Camera; - R3.D3.API.Camera.call( this, - this.apiD3Camera, - this.apiD3Camera.aspect + apiComponent ); - if (R3.Utils.UndefinedOrNull(near)) { - near = 0.1; - } - this.near = near; + this.aspect = 1; - if (R3.Utils.UndefinedOrNull(far)) { - far = 2000; - } - this.far = far; + this.fov = 90; - if (R3.Utils.UndefinedOrNull(cubeResolution)) { - cubeResolution = 128; + if (R3.Utils.UndefinedOrNull(apiComponent.near)) { + apiComponent.near = 0.1; } - this.cubeResolution = cubeResolution; + this.near = apiComponent.near; - if (R3.Utils.UndefinedOrNull(renderTarget)) { - renderTarget = new R3.D3.API.RenderTarget.Cube(); + if (R3.Utils.UndefinedOrNull(apiComponent.far)) { + apiComponent.far = 2000; } - this.renderTarget = renderTarget; + this.far = apiComponent.far; + + if (R3.Utils.UndefinedOrNull(apiComponent.cubeResolution)) { + apiComponent.cubeResolution = 128; + } + this.cubeResolution = apiComponent.cubeResolution; + + if (R3.Utils.UndefinedOrNull(apiComponent.renderTarget)) { + apiComponent.renderTarget = new R3.D3.API.RenderTarget.Cube( + { + parent : this + } + ); + } + this.renderTarget = apiComponent.renderTarget; }; diff --git a/src/r3-d3-api-camera-orthographic-0.js b/src/r3-d3-api-camera-orthographic-0.js new file mode 100644 index 0000000..9b859e9 --- /dev/null +++ b/src/r3-d3-api-camera-orthographic-0.js @@ -0,0 +1,58 @@ +/** + * R3.D3.API.Camera.Orthographic + * + * Base class for Orthographic Cameras - to define an aspect ratio for the camera, use FixedAspect child class, to + * manually set the camera size, use the ScaledAspect child class + * + * @param apiComponent + * + * @property near + * @property far + * @property zoom + * + * @constructor + */ +R3.D3.API.Camera.Orthographic = function( + apiComponent +) { + + if (R3.Utils.UndefinedOrNull(apiComponent)) { + apiComponent = {}; + } + + if (R3.Utils.UndefinedOrNull(apiComponent.lookAt)) { + apiComponent.lookAt = new R3.API.Vector3( + { + parent : this, + register :true, + x : 0, + y : 0, + z : 10 + } + ); + } + + R3.D3.API.Camera.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.near)) { + apiComponent.near = 0.1; + } + this.near = apiComponent.near; + + if (R3.Utils.UndefinedOrNull(apiComponent.far)) { + apiComponent.far = 2000; + } + this.far = apiComponent.far; + + if (R3.Utils.UndefinedOrNull(apiComponent.zoom)) { + apiComponent.zoom = 1; + } + this.zoom = apiComponent.zoom; + +}; + +R3.D3.API.Camera.Orthographic.prototype = Object.create(R3.D3.API.Camera.prototype); +R3.D3.API.Camera.Orthographic.prototype.constructor = R3.D3.API.Camera.Orthographic; diff --git a/src/r3-d3-api-camera-orthographic-fixed-aspect.js b/src/r3-d3-api-camera-orthographic-fixedAspect.js similarity index 60% rename from src/r3-d3-api-camera-orthographic-fixed-aspect.js rename to src/r3-d3-api-camera-orthographic-fixedAspect.js index 5dcbe17..4a062f4 100644 --- a/src/r3-d3-api-camera-orthographic-fixed-aspect.js +++ b/src/r3-d3-api-camera-orthographic-fixedAspect.js @@ -4,24 +4,16 @@ * - This camera calculates left, right, top and bottom coordinates from the provided aspect ratio. It uses the * inherited default values for near and far values for the Z space * - * @param apiD3CameraOrthographic + * @param apiComponent * @constructor */ R3.D3.API.Camera.Orthographic.FixedAspect = function( - apiD3CameraOrthographic + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiD3CameraOrthographic)) { - apiD3CameraOrthographic = {}; - } - this.apiD3CameraOrthographic = apiD3CameraOrthographic; - R3.D3.API.Camera.Orthographic.call( this, - this.apiD3CameraOrthographic, - this.apiD3CameraOrthographic.near, - this.apiD3CameraOrthographic.far, - this.apiD3CameraOrthographic.zoom + apiComponent ); }; diff --git a/src/r3-d3-api-camera-orthographic-scaled-aspect.js b/src/r3-d3-api-camera-orthographic-scaled-aspect.js deleted file mode 100644 index 83b3fce..0000000 --- a/src/r3-d3-api-camera-orthographic-scaled-aspect.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * R3.D3.API.Camera.Orthographic.ScaledAspect - * - * This camera does not automatically adjust its left, right, top and bottom values - it assumes they have been defined - * and are correct. It uses the inherited default near and far values for the Z space. It essentially ignores aspect - * ratio (you should manage that yourself to get things looking pretty) - * - * @param apiD3CameraOrthographic - * @param left - * @param right - * @param top - * @param bottom - * @constructor - */ -R3.D3.API.Camera.Orthographic.ScaledAspect = function( - apiD3CameraOrthographic, - left, - right, - top, - bottom -) { - - if (R3.Utils.UndefinedOrNull(apiD3CameraOrthographic)) { - apiD3CameraOrthographic = {}; - } - this.apiD3CameraOrthographic = apiD3CameraOrthographic; - - R3.D3.API.Camera.Orthographic.call( - this, - this.apiD3CameraOrthographic, - this.apiD3CameraOrthographic.near, - this.apiD3CameraOrthographic.far, - this.apiD3CameraOrthographic.zoom - ); - - if (R3.Utils.UndefinedOrNull(left)) { - left = -5; - } - this.left = left; - - if (R3.Utils.UndefinedOrNull(right)) { - right = 5; - } - this.right = right; - - if (R3.Utils.UndefinedOrNull(top)) { - top = 5; - } - this.top = top; - - if (R3.Utils.UndefinedOrNull(bottom)) { - bottom = -5; - } - this.bottom = bottom; - -}; - -R3.D3.API.Camera.Orthographic.ScaledAspect.prototype = Object.create(R3.D3.API.Camera.Orthographic.prototype); -R3.D3.API.Camera.Orthographic.ScaledAspect.prototype.constructor = R3.D3.API.Camera.Orthographic.ScaledAspect; diff --git a/src/r3-d3-api-camera-orthographic-scaledAspect.js b/src/r3-d3-api-camera-orthographic-scaledAspect.js new file mode 100644 index 0000000..ad487d0 --- /dev/null +++ b/src/r3-d3-api-camera-orthographic-scaledAspect.js @@ -0,0 +1,49 @@ +/** + * R3.D3.API.Camera.Orthographic.ScaledAspect + * + * This camera does not automatically adjust its left, right, top and bottom values - it assumes they have been defined + * and are correct. It uses the inherited default near and far values for the Z space. It essentially ignores aspect + * ratio (you should manage that yourself to get things looking pretty) + * + * @param apiComponent + * + * @property left + * @property right + * @property top + * @property bottom + * + * @constructor + */ +R3.D3.API.Camera.Orthographic.ScaledAspect = function( + apiComponent +) { + + R3.D3.API.Camera.Orthographic.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.left)) { + apiComponent.left = -5; + } + this.left = apiComponent.left; + + if (R3.Utils.UndefinedOrNull(apiComponent.right)) { + apiComponent.right = 5; + } + this.right = apiComponent.right; + + if (R3.Utils.UndefinedOrNull(apiComponent.top)) { + apiComponent.top = 5; + } + this.top = apiComponent.top; + + if (R3.Utils.UndefinedOrNull(apiComponent.bottom)) { + apiComponent.bottom = -5; + } + this.bottom = apiComponent.bottom; + +}; + +R3.D3.API.Camera.Orthographic.ScaledAspect.prototype = Object.create(R3.D3.API.Camera.Orthographic.prototype); +R3.D3.API.Camera.Orthographic.ScaledAspect.prototype.constructor = R3.D3.API.Camera.Orthographic.ScaledAspect; diff --git a/src/r3-d3-api-camera-orthographic.js b/src/r3-d3-api-camera-orthographic.js deleted file mode 100644 index b34e193..0000000 --- a/src/r3-d3-api-camera-orthographic.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * R3.D3.API.Camera.Orthographic - * - * Base class for Orthographic Cameras - do define an aspect ratio for the camera, use FixedAspect child class, to - * manually set the camera size, use the ScaledAspect child class - * - * @constructor - * @param apiD3Camera - * @param near - * @param far - * @param zoom - */ -R3.D3.API.Camera.Orthographic = function( - apiD3Camera, - near, - far, - zoom -) { - - if (R3.Utils.UndefinedOrNull(apiD3Camera)) { - apiD3Camera = {}; - } - this.apiD3Camera = apiD3Camera; - - if (R3.Utils.UndefinedOrNull(this.apiD3Camera.position)) { - this.apiD3Camera.position = new R3.API.Vector3( - 0, - 0, - 10 - ); - } - - if (R3.Utils.UndefinedOrNull(this.apiD3Camera.lookAt)) { - this.apiD3Camera.lookAt = new R3.API.Vector3( - 0, - 0, - -10 - ); - } - - R3.D3.API.Camera.call( - this, - this.apiD3Camera, - this.apiD3Camera.aspect - ); - - if (R3.Utils.UndefinedOrNull(near)) { - near = 0.1; - } - this.near = near; - - if (R3.Utils.UndefinedOrNull(far)) { - far = 2000; - } - this.far = far; - - if (R3.Utils.UndefinedOrNull(zoom)) { - zoom = 1; - } - this.zoom = zoom; - -}; - -R3.D3.API.Camera.Orthographic.prototype = Object.create(R3.D3.API.Camera.prototype); -R3.D3.API.Camera.Orthographic.prototype.constructor = R3.D3.API.Camera.Orthographic; diff --git a/src/r3-d3-api-camera-perspective-0.js b/src/r3-d3-api-camera-perspective-0.js new file mode 100644 index 0000000..ae86ee0 --- /dev/null +++ b/src/r3-d3-api-camera-perspective-0.js @@ -0,0 +1,78 @@ +/** + * R3.D3.API.Camera.Perspective + * @param apiComponent + * + * @property near + * @property far + * @property fov + * @property filmGauge + * @property filmOffset + * @property focus + * @property zoom + * + * @constructor + */ +R3.D3.API.Camera.Perspective = function( + apiComponent +) { + + if (R3.Utils.UndefinedOrNull(apiComponent)) { + apiComponent = {}; + } + + if (R3.Utils.UndefinedOrNull(apiComponent.position)) { + apiComponent.position = new R3.API.Vector3( + { + parent : this, + register :true, + x : 15, + y : 15, + z : 15 + } + ); + } + + R3.D3.API.Camera.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.near)) { + apiComponent.near = 0.1; + } + this.near = apiComponent.near; + + if (R3.Utils.UndefinedOrNull(apiComponent.far)) { + apiComponent.far = 2000; + } + this.far = apiComponent.far; + + if (R3.Utils.UndefinedOrNull(apiComponent.fov)) { + apiComponent.fov = 50; + } + this.fov = apiComponent.fov; + + if (R3.Utils.UndefinedOrNull(apiComponent.filmGauge)) { + apiComponent.filmGauge = 35; + } + this.filmGauge = apiComponent.filmGauge; + + if (R3.Utils.UndefinedOrNull(apiComponent.filmOffset)) { + apiComponent.filmOffset = 0; + } + this.filmOffset = apiComponent.filmOffset; + + if (R3.Utils.UndefinedOrNull(apiComponent.focus)) { + apiComponent.focus = 10; + } + this.focus = apiComponent.focus; + + if (R3.Utils.UndefinedOrNull(apiComponent.zoom)) { + apiComponent.zoom = 1; + } + this.zoom = apiComponent.zoom; + +}; + +R3.D3.API.Camera.Perspective.prototype = Object.create(R3.D3.API.Camera.prototype); +R3.D3.API.Camera.Perspective.prototype.constructor = R3.D3.API.Camera.Perspective; diff --git a/src/r3-d3-api-camera-perspective-stereo.js b/src/r3-d3-api-camera-perspective-stereo.js index 23e5be5..98bd099 100644 --- a/src/r3-d3-api-camera-perspective-stereo.js +++ b/src/r3-d3-api-camera-perspective-stereo.js @@ -1,41 +1,18 @@ /** * R3.D3.API.Camera.Perspective.Stereo + * @param apiComponent * @constructor - * @param apiD3CameraPerspective - * @param stereoMode */ R3.D3.API.Camera.Perspective.Stereo = function( - apiD3CameraPerspective, - stereoMode + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiD3CameraPerspective)) { - apiD3CameraPerspective = {}; - } - this.apiD3CameraPerspective = apiD3CameraPerspective; - R3.D3.API.Camera.Perspective.call( this, - this.apiD3CameraPerspective, - this.apiD3CameraPerspective.near, - this.apiD3CameraPerspective.far, - this.apiD3CameraPerspective.fov, - this.apiD3CameraPerspective.filmGauge, - this.apiD3CameraPerspective.filmOffset, - this.apiD3CameraPerspective.focus, - this.apiD3CameraPerspective.zoom + apiComponent ); - if (R3.Utils.UndefinedOrNull(stereoMode)) { - stereoMode = R3.D3.API.Camera.Perspective.Stereo.STEREO_MODE_STEREO; - } - this.stereoMode = stereoMode; - }; R3.D3.API.Camera.Perspective.Stereo.prototype = Object.create(R3.D3.API.Camera.Perspective.prototype); R3.D3.API.Camera.Perspective.Stereo.prototype.constructor = R3.D3.API.Camera.Perspective.Stereo; - -R3.D3.API.Camera.Perspective.Stereo.STEREO_MODE_STEREO = 0x1; -R3.D3.API.Camera.Perspective.Stereo.STEREO_MODE_ANAGLYPH = 0x2; -R3.D3.API.Camera.Perspective.Stereo.STEREO_MODE_PARALLAX = 0x3; diff --git a/src/r3-d3-api-camera-perspective.js b/src/r3-d3-api-camera-perspective.js deleted file mode 100644 index 67cfb7d..0000000 --- a/src/r3-d3-api-camera-perspective.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * R3.D3.API.Camera.Perspective - * @constructor - * @param apiD3Camera - * @param fov - * @param near - * @param far - * @param filmGauge - * @param filmOffset - * @param focus - * @param zoom - */ -R3.D3.API.Camera.Perspective = function( - apiD3Camera, - near, - far, - fov, - filmGauge, - filmOffset, - focus, - zoom -) { - - if (R3.Utils.UndefinedOrNull(apiD3Camera)) { - apiD3Camera = {}; - } - this.apiD3Camera = apiD3Camera; - - R3.D3.API.Camera.call( - this, - this.apiD3Camera, - this.apiD3Camera.aspect - ); - - if (R3.Utils.UndefinedOrNull(near)) { - near = 0.1; - } - this.near = near; - - if (R3.Utils.UndefinedOrNull(far)) { - far = 2000; - } - this.far = far; - - if (R3.Utils.UndefinedOrNull(fov)) { - fov = 50; - } - this.fov = fov; - - if (R3.Utils.UndefinedOrNull(filmGauge)) { - filmGauge = 35; - } - this.filmGauge = filmGauge; - - if (R3.Utils.UndefinedOrNull(filmOffset)) { - filmOffset = 0; - } - this.filmOffset = filmOffset; - - if (R3.Utils.UndefinedOrNull(focus)) { - focus = 10; - } - this.focus = focus; - - if (R3.Utils.UndefinedOrNull(zoom)) { - zoom = 1; - } - this.zoom = zoom; - -}; - -R3.D3.API.Camera.Perspective.prototype = Object.create(R3.D3.API.Camera.prototype); -R3.D3.API.Camera.Perspective.prototype.constructor = R3.D3.API.Camera.Perspective; diff --git a/src/r3-d3-api-composer-render-target.js b/src/r3-d3-api-composer-render-target.js deleted file mode 100644 index 44d4f0f..0000000 --- a/src/r3-d3-api-composer-render-target.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * R3.D3.API.Composer.RenderTarget - * @param apiComposer - * @param renderTarget - * @constructor - */ -R3.D3.API.Composer.RenderTarget = function( - apiComposer, - renderTarget -) { - - if (R3.Utils.UndefinedOrNull(apiComposer)) { - apiComposer = {}; - } - this.apiComposer = apiComposer; - - R3.D3.API.Composer.call( - this, - this.apiComposer, - this.apiComposer.width, - this.apiComposer.height, - this.apiComposer.passes - ); - - if (R3.Utils.UndefinedOrNull(renderTarget)) { - - /** - * We look at the project to see if any renderTargets exist - we use the most recent created one or - * construct a new one if none exist - * @type {number|*} - */ - R3.Event.Emit( - R3.Event.GET_PROJECT, - null, - function(project) { - - if (project.renderTargets.length > 0) { - renderTarget = project.renderTargets[project.renderTargets.length - 1]; - } else { - renderTarget = new R3.D3.API.RenderTarget(); - project.renderTargets.push(renderTarget); - } - - }.bind(this) - ); - - } - this.renderTarget = renderTarget - -}; - -R3.D3.API.Composer.RenderTarget.prototype = Object.create(R3.D3.API.Composer.prototype); -R3.D3.API.Composer.RenderTarget.prototype.constructor = R3.D3.API.Composer.RenderTarget; diff --git a/src/r3-d3-api-composer-renderer.js b/src/r3-d3-api-composer-renderer.js deleted file mode 100644 index 1ea9312..0000000 --- a/src/r3-d3-api-composer-renderer.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * R3.D3.API.Composer.Renderer - * @param apiComposer - * @param renderer - * @constructor - */ -R3.D3.API.Composer.Renderer = function( - apiComposer, - renderer -) { - - if (R3.Utils.UndefinedOrNull(apiComposer)) { - apiComposer = {}; - } - this.apiComposer = apiComposer; - - R3.D3.API.Composer.call( - this, - this.apiComposer, - this.apiComposer.width, - this.apiComposer.height, - this.apiComposer.passes - ); - - if (R3.Utils.UndefinedOrNull(renderer)) { - renderer = this.getFirstParent(R3.API.Renderer.D3); - } - this.renderer = renderer; - -}; - -R3.D3.API.Composer.Renderer.prototype = Object.create(R3.D3.API.Composer.prototype); -R3.D3.API.Composer.Renderer.prototype.constructor = R3.D3.API.Composer.Renderer; diff --git a/src/r3-d3-api-composer.js b/src/r3-d3-api-composer.js index ad38e18..0301a1a 100644 --- a/src/r3-d3-api-composer.js +++ b/src/r3-d3-api-composer.js @@ -1,34 +1,66 @@ /** * R3.D3.API.Composer * @param apiComponent - * @param width - * @param height - * @param passes + * + * @property size + * @property renderer + * @property viewport + * @property renderTargetA + * @property renderTargetB + * @property passes + * * @constructor */ R3.D3.API.Composer = function( - apiComponent, - width, - height, - passes + apiComponent ) { - __API_COMPONENT_MACRO__; + __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(width)) { - width = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = new R3.API.Vector2( + { + parent : this, + register : true, + x : 512, + y : 512 + } + ); } - this.width = width; + this.size = apiComponent.size; - if (R3.Utils.UndefinedOrNull(height)) { - height = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.renderer)) { + apiComponent.renderer = this.getFirstParent(R3.API.Renderer.D3); } - this.height = height; + this.renderer = apiComponent.renderer; - if (R3.Utils.UndefinedOrNull(passes)) { - passes = []; + if (R3.Utils.UndefinedOrNull(apiComponent.viewport)) { + apiComponent.viewport = this.getFirstParent(R3.D3.API.Viewport); } - this.passes = passes; + this.viewport = apiComponent.viewport; + + if (R3.Utils.UndefinedOrNull(apiComponent.rendererTargetA)) { + apiComponent.rendererTargetA = new R3.D3.API.RenderTarget( + { + parent : this + } + ) + } + this.rendererTargetA = apiComponent.rendererTargetA; + + if (R3.Utils.UndefinedOrNull(apiComponent.renderTargetB)) { + apiComponent.renderTargetB = new R3.D3.API.RenderTarget( + { + parent : this + } + ) + } + this.renderTargetB = apiComponent.renderTargetB; + + if (R3.Utils.UndefinedOrNull(apiComponent.passes)) { + apiComponent.passes = []; + } + this.passes = apiComponent.passes; }; diff --git a/src/r3-d3-api-effect-0.js b/src/r3-d3-api-effect-0.js new file mode 100644 index 0000000..e371303 --- /dev/null +++ b/src/r3-d3-api-effect-0.js @@ -0,0 +1,41 @@ +/** + * R3.D3.API.Effect + * @param apiComponent + * + * @property renderer + * @property viewport + * @property size + * + * @constructor + */ +R3.D3.API.Effect = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.renderer)) { + apiComponent.renderer = this.getFirstParent(R3.API.Renderer.D3); + } + this.renderer = apiComponent.renderer; + + if (R3.Utils.UndefinedOrNull(apiComponent.viewport)) { + apiComponent.viewport = this.getFirstParent(R3.D3.API.Viewport); + } + this.viewport = apiComponent.viewport; + + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = new R3.API.Vector2( + { + parent : this, + x : 512, + y : 512 + } + ); + } + this.size = apiComponent.size; + +}; + +R3.D3.API.Effect.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.Effect.prototype.constructor = R3.D3.API.Effect; diff --git a/src/r3-d3-api-effect-a.js b/src/r3-d3-api-effect-a.js deleted file mode 100644 index cfc519e..0000000 --- a/src/r3-d3-api-effect-a.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * R3.D3.API.Effect - * @param apiComponent - * @param renderer - * @param width - * @param height - * @constructor - */ -R3.D3.API.Effect = function( - apiComponent, - renderer, - width, - height -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(renderer)) { - renderer = this.getFirstParent(R3.API.Renderer.D3); - } - this.renderer = renderer; - - var size = renderer.getSize(); - - if (R3.Utils.UndefinedOrNull(width)) { - width = size.width; - } - this.width = width; - - if (R3.Utils.UndefinedOrNull(height)) { - height = size.height; - } - this.height = height; - -}; - -R3.D3.API.Effect.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.Effect.prototype.constructor = R3.D3.API.Effect; diff --git a/src/r3-d3-api-effect-anaglyph.js b/src/r3-d3-api-effect-anaglyph.js index 852b46a..7dd6ce3 100644 --- a/src/r3-d3-api-effect-anaglyph.js +++ b/src/r3-d3-api-effect-anaglyph.js @@ -1,23 +1,15 @@ /** * R3.D3.API.Effect.Anaglyph + * @param apiComponent * @constructor - * @param apiEffect */ R3.D3.API.Effect.Anaglyph = function( - apiEffect + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiEffect)) { - apiEffect = {}; - } - this.apiEffect = apiEffect; - R3.D3.API.Effect.call( this, - this.apiEffect, - this.apiEffect.renderer, - this.apiEffect.width, - this.apiEffect.height + apiComponent ); }; diff --git a/src/r3-d3-api-effect-parallax.js b/src/r3-d3-api-effect-parallax.js index 5c269d5..ede135c 100644 --- a/src/r3-d3-api-effect-parallax.js +++ b/src/r3-d3-api-effect-parallax.js @@ -1,26 +1,18 @@ /** * R3.D3.API.Effect.Parallax + * @param apiComponent * @constructor - * @param apiEffect */ R3.D3.API.Effect.Parallax = function( - apiEffect + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiEffect)) { - apiEffect = {}; - } - this.apiEffect = apiEffect; - R3.D3.API.Effect.call( this, - this.apiEffect, - this.apiEffect.renderer, - this.apiEffect.width, - this.apiEffect.height + apiComponent ); }; R3.D3.API.Effect.Parallax.prototype = Object.create(R3.D3.API.Effect.prototype); -R3.D3.API.Effect.Parallax.prototype.constructor = R3.D3.API.Effect.Parallax; \ No newline at end of file +R3.D3.API.Effect.Parallax.prototype.constructor = R3.D3.API.Effect.Parallax; diff --git a/src/r3-d3-api-effect-stereo.js b/src/r3-d3-api-effect-stereo.js index e285b60..0e37d15 100644 --- a/src/r3-d3-api-effect-stereo.js +++ b/src/r3-d3-api-effect-stereo.js @@ -1,33 +1,26 @@ /** * R3.D3.API.Effect.Stereo + * @param apiComponent + * + * @property eyeSeperation + * * @constructor - * @param apiEffect - * @param eyeSeperation */ R3.D3.API.Effect.Stereo = function( - apiEffect, - eyeSeperation + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiEffect)) { - apiEffect = {}; - } - this.apiEffect = apiEffect; - R3.D3.API.Effect.call( this, - this.apiEffect, - this.apiEffect.renderer, - this.apiEffect.width, - this.apiEffect.height + apiComponent ); - if (R3.Utils.UndefinedOrNull(eyeSeperation)) { - eyeSeperation = 0.064; + if (R3.Utils.UndefinedOrNull(apiComponent.eyeSeperation)) { + apiComponent.eyeSeperation = 0.064; } - this.eyeSeperation = eyeSeperation; + this.eyeSeperation = apiComponent.eyeSeperation; }; R3.D3.API.Effect.Stereo.prototype = Object.create(R3.D3.API.Effect.prototype); -R3.D3.API.Effect.Stereo.prototype.constructor = R3.D3.API.Effect.Stereo; \ No newline at end of file +R3.D3.API.Effect.Stereo.prototype.constructor = R3.D3.API.Effect.Stereo; diff --git a/src/r3-d3-api-face-0.js b/src/r3-d3-api-face-0.js new file mode 100644 index 0000000..f616ecf --- /dev/null +++ b/src/r3-d3-api-face-0.js @@ -0,0 +1,114 @@ +/** + * R3.D3.API.Face + * @param apiComponent + * + * @property vertexIndices + * @property vertices + * @property normal + * + * @constructor + */ +R3.D3.API.Face = function( + apiComponent +) { + + __DEREGISTER_COMPONENT__; + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.vertexIndices)) { + apiComponent.vertexIndices = [0, 1, 2]; + } + this.vertexIndices = apiComponent.vertexIndices; + + if (R3.Utils.UndefinedOrNull(apiComponent.vertices)) { + apiComponent.vertices = [ + new R3.D3.API.Vertex( + { + parent : this, + register : this.register + } + ), + new R3.D3.API.Vertex( + { + parent : this, + register : this.register + } + ), + new R3.D3.API.Vertex( + { + parent : this, + register : this.register + } + ), + ]; + } + this.vertices = apiComponent.vertices; + + if (R3.Utils.UndefinedOrNull(apiComponent.normal)) { + apiComponent.normal = null; + } + this.normal = apiComponent.normal; + +}; + +R3.D3.API.Face.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.Face.prototype.constructor = R3.D3.API.Face; + +/** + * Clone a Face + * @returns {R3.D3.API.Face} + */ +R3.D3.API.Face.prototype.clone = function(){ + return new R3.D3.API.Face( + null, + this.vertexIndices, + this.vertices, + this.normal + ); +}; + +/** + * Returns true if two triangles are equal (their vertex indices match in some order) + * @param face + * @returns {boolean} + */ +R3.D3.API.Face.prototype.equals = function(face) { + return ( + ( + (this.vertexIndices[0] === face.vertexIndices[0]) && + (this.vertexIndices[1] === face.vertexIndices[1]) && + (this.vertexIndices[2] === face.vertexIndices[2]) + ) + || + ( + (this.vertexIndices[0] === face.vertexIndices[0]) && + (this.vertexIndices[1] === face.vertexIndices[2]) && + (this.vertexIndices[2] === face.vertexIndices[1]) + ) + || + ( + (this.vertexIndices[0] === face.vertexIndices[1]) && + (this.vertexIndices[1] === face.vertexIndices[0]) && + (this.vertexIndices[2] === face.vertexIndices[2]) + ) + || + ( + (this.vertexIndices[0] === face.vertexIndices[1]) && + (this.vertexIndices[1] === face.vertexIndices[2]) && + (this.vertexIndices[2] === face.vertexIndices[0]) + ) + || + ( + (this.vertexIndices[0] === face.vertexIndices[2]) && + (this.vertexIndices[1] === face.vertexIndices[0]) && + (this.vertexIndices[2] === face.vertexIndices[1]) + ) + || + ( + (this.vertexIndices[0] === face.vertexIndices[2]) && + (this.vertexIndices[1] === face.vertexIndices[1]) && + (this.vertexIndices[2] === face.vertexIndices[0]) + ) + ); +}; diff --git a/src/r3-d3-api-face-graphics.js b/src/r3-d3-api-face-graphics.js index f25edcb..772520b 100644 --- a/src/r3-d3-api-face-graphics.js +++ b/src/r3-d3-api-face-graphics.js @@ -1,53 +1,42 @@ /** * R3.D3.API.Face - * @param apiFace - * @param materialIndex - * @param uvs [[v0uv (R3.Vector2), v1uv(R3.Vector2), v2uv(R3.Vector2)]] - * @param color - * @param vertexColors + * @param apiComponent + * + * @property materialIndex + * @property uvs [[v0uv (R3.Vector2), v1uv(R3.Vector2), v2uv(R3.Vector2)]] + * @property color + * @property vertexColors + * * @constructor */ R3.D3.API.Face.Graphics = function( - apiFace, - materialIndex, - uvs, - color, - vertexColors + apiComponent ) { R3.D3.API.Face.call( this, - apiFace, - apiFace.v0index, - apiFace.v1index, - apiFace.v2index, - apiFace.vertexNormals, - apiFace.normal + apiComponent ); - if (R3.Utils.UndefinedOrNull(materialIndex)) { - materialIndex = -1; + if (R3.Utils.UndefinedOrNull(apiComponent.materialIndex)) { + apiComponent.materialIndex = -1; } - this.materialIndex = materialIndex; + this.materialIndex = apiComponent.materialIndex; - if (R3.Utils.UndefinedOrNull(uvs)) { - uvs = [[]]; + if (R3.Utils.UndefinedOrNull(apiComponent.uvs)) { + apiComponent.uvs = [[]]; } - this.uvs = uvs; + this.uvs = apiComponent.uvs; - if (R3.Utils.UndefinedOrNull(color)) { - color = new R3.API.Color(); + if (R3.Utils.UndefinedOrNull(apiComponent.color)) { + apiComponent.color = new R3.API.Color( + { + parent : this, + register : this.register + } + ); } - this.color = color; - - if (R3.Utils.UndefinedOrNull(vertexColors)) { - vertexColors = [ - new R3.API.Color(), - new R3.API.Color(), - new R3.API.Color() - ]; - } - this.vertexColors = vertexColors; + this.color = apiComponent.color; }; diff --git a/src/r3-d3-api-face.js b/src/r3-d3-api-face.js deleted file mode 100644 index 02542f8..0000000 --- a/src/r3-d3-api-face.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * R3.D3.API.Face - * @param apiComponent - * @param v0index - * @param v1index - * @param v2index - * @param vertexNormals - * @param normal - * @constructor - */ -R3.D3.API.Face = function( - apiComponent, - v0index, - v1index, - v2index, - vertexNormals, - normal -) { - - /** - * By default, we want to avoid registering faces as components - */ - if (R3.Utils.UndefinedOrNull(apiComponent)) { - apiComponent = {}; - } - - apiComponent.register = false; - - /** - * Check whether we need to register the faces - * @type {boolean} - */ - R3.Event.Emit( - R3.Event.GET_REGISTER_FACES, - null, - function(register) { - if (register) { - apiComponent.register = true; - } - } - ); - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(v0index)) { - v0index = -1; - } - this.v0index = v0index; - - if (R3.Utils.UndefinedOrNull(v1index)) { - v1index = -1; - } - this.v1index = v1index; - - if (R3.Utils.UndefinedOrNull(v2index)) { - v2index = -1; - } - this.v2index = v2index; - - if (R3.Utils.UndefinedOrNull(vertexNormals)) { - vertexNormals = []; - } - this.vertexNormals = vertexNormals; - - if (R3.Utils.UndefinedOrNull(normal)) { - normal = null; - } - this.normal = normal; - -}; - -R3.D3.API.Face.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.Face.prototype.constructor = R3.D3.API.Face; - -/** - * Clone a Face - * @returns {R3.D3.API.Face} - */ -R3.D3.API.Face.prototype.clone = function(){ - return new R3.D3.API.Face( - null, - this.v0index, - this.v1index, - this.v2index, - this.vertexNormals, - this.normal - ); -}; - -/** - * Returns true if two triangles are equal (their vertex indices match in some order) - * @param triangle - * @returns {boolean} - */ -R3.D3.API.Face.prototype.equals = function(triangle) { - return ( - ( - (this.v0index === triangle.v0index) && - (this.v1index === triangle.v1index) && - (this.v2index === triangle.v2index) - ) - || - ( - (this.v0index === triangle.v0index) && - (this.v1index === triangle.v2index) && - (this.v2index === triangle.v1index) - ) - || - ( - (this.v0index === triangle.v1index) && - (this.v1index === triangle.v0index) && - (this.v2index === triangle.v2index) - ) - || - ( - (this.v0index === triangle.v1index) && - (this.v1index === triangle.v2index) && - (this.v2index === triangle.v0index) - ) - || - ( - (this.v0index === triangle.v2index) && - (this.v1index === triangle.v0index) && - (this.v2index === triangle.v1index) - ) - || - ( - (this.v0index === triangle.v2index) && - (this.v1index === triangle.v1index) && - (this.v2index === triangle.v0index) - ) - ); -}; diff --git a/src/r3-d3-api-fog-0.js b/src/r3-d3-api-fog-0.js new file mode 100644 index 0000000..d94e81c --- /dev/null +++ b/src/r3-d3-api-fog-0.js @@ -0,0 +1,32 @@ +/** + * R3.D3.API.Fog + * @param apiComponent + * + * @property color + * + * @constructor + */ +R3.D3.API.Fog = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.color)) { + apiComponent.color = new R3.API.Color( + { + parent : this, + register : true, + r : 1, + g : 1, + b : 1, + a : 1 + } + ); + } + this.color = apiComponent.color; + +}; + +R3.D3.API.Fog.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.Fog.prototype.constructor = R3.D3.API.Fog; diff --git a/src/r3-d3-api-fog-exp.js b/src/r3-d3-api-fog-exp.js index b751d31..c961747 100644 --- a/src/r3-d3-api-fog-exp.js +++ b/src/r3-d3-api-fog-exp.js @@ -1,28 +1,36 @@ /** * R3.D3.API.Fog.Exp - * @param apiFog - * @param density + * @param apiComponent + * + * @property density + * * @constructor */ R3.D3.API.Fog.Exp = function( - apiFog, - density + apiComponent ) { - __API_COMPONENT_MACRO__; - R3.D3.API.Fog.call( this, - apiFog, - apiFog.color + apiComponent ); - if (R3.Utils.UndefinedOrNull(density)) { - density = 0.00025; + if (R3.Utils.UndefinedOrNull(apiComponent.density)) { + apiComponent.density = 0.00025; } - this.density = density; + this.density = apiComponent.density; }; R3.D3.API.Fog.Exp.prototype = Object.create(R3.D3.API.Fog.prototype); R3.D3.API.Fog.Exp.prototype.constructor = R3.D3.API.Fog.Exp; + +R3.D3.API.Fog.Exp.GUI = function() { + return { + density : { + grain : 0.00001, + min : 0, + max : 1 + } + }; +}; diff --git a/src/r3-d3-api-fog-normal.js b/src/r3-d3-api-fog-normal.js index 67fc375..cc47e95 100644 --- a/src/r3-d3-api-fog-normal.js +++ b/src/r3-d3-api-fog-normal.js @@ -1,33 +1,30 @@ /** * R3.D3.API.Fog.Normal - * @param apiFog - * @param near - * @param far + * @param apiComponent + * + * @property near + * @property far + * * @constructor */ R3.D3.API.Fog.Normal = function( - apiFog, - near, - far, + apiComponent ) { - __API_COMPONENT_MACRO__; - R3.D3.API.Fog.call( this, - apiFog, - apiFog.color + apiComponent ); - if (R3.Utils.UndefinedOrNull(near)) { - near = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.near)) { + apiComponent.near = 1; } - this.near = near; + this.near = apiComponent.near; - if (R3.Utils.UndefinedOrNull(far)) { - far = 1000; + if (R3.Utils.UndefinedOrNull(apiComponent.far)) { + apiComponent.far = 1000; } - this.far = far; + this.far = apiComponent.far; }; diff --git a/src/r3-d3-api-fog.js b/src/r3-d3-api-fog.js deleted file mode 100644 index c01faa4..0000000 --- a/src/r3-d3-api-fog.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * R3.D3.API.Fog - * @param apiComponent - * @param color - * @constructor - */ -R3.D3.API.Fog = function( - apiComponent, - color -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(color)) { - color = new R3.API.Color(this, 1, 1, 1, 1) - } - this.color = color; - -}; - -R3.D3.API.Fog.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.Fog.prototype.constructor = R3.D3.API.Fog; diff --git a/src/r3-d3-api-friction-contact-material.js b/src/r3-d3-api-friction-contact-material.js deleted file mode 100644 index 61d951d..0000000 --- a/src/r3-d3-api-friction-contact-material.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * R3.D3.API.FrictionContactMaterial - * @param apiComponent - * @param materials - * @param friction - * @param restitution - * @param contactEquationStiffness - * @param contactEquationRelaxation - * @param frictionEquationStiffness - * @param frictionEquationRelaxation - * @constructor - */ -R3.D3.API.FrictionContactMaterial = function( - apiComponent, - materials, - friction, - restitution, - contactEquationStiffness, - contactEquationRelaxation, - frictionEquationStiffness, - frictionEquationRelaxation -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(materials)) { - materials = []; - } - this.materials = materials; - - if (R3.Utils.UndefinedOrNull(friction)) { - friction = 0.3; - } - this.friction = friction; - - if (R3.Utils.UndefinedOrNull(restitution)) { - restitution = 0.3; - } - this.restitution = restitution; - - if (R3.Utils.UndefinedOrNull(contactEquationStiffness)) { - contactEquationStiffness = 1e7; - } - this.contactEquationStiffness = contactEquationStiffness; - - if (R3.Utils.UndefinedOrNull(contactEquationRelaxation)) { - contactEquationRelaxation = 3; - } - this.contactEquationRelaxation = contactEquationRelaxation; - - if (R3.Utils.UndefinedOrNull(frictionEquationStiffness)) { - frictionEquationStiffness = 1e7; - } - this.frictionEquationStiffness = frictionEquationStiffness; - - if (R3.Utils.UndefinedOrNull(frictionEquationRelaxation)) { - frictionEquationRelaxation = 3; - } - this.frictionEquationRelaxation = frictionEquationRelaxation; - -}; - -R3.D3.API.FrictionContactMaterial.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.FrictionContactMaterial.prototype.constructor = R3.D3.API.FrictionContactMaterial; diff --git a/src/r3-d3-api-friction-material.js b/src/r3-d3-api-friction-material.js deleted file mode 100644 index 9b5e770..0000000 --- a/src/r3-d3-api-friction-material.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * R3.D3.API.FrictionMaterial - * @param apiComponent - * @param friction - * @param restitution - * @constructor - */ -R3.D3.API.FrictionMaterial = function( - apiComponent, - friction, - restitution -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(friction)) { - friction = -1; - } - this.friction = friction; - - if (R3.Utils.UndefinedOrNull(restitution)) { - restitution = -1; - } - this.restitution = restitution; - -}; - -R3.D3.API.FrictionMaterial.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.FrictionMaterial.prototype.constructor = R3.D3.API.FrictionMaterial; diff --git a/src/r3-d3-api-frictionContactMaterial.js b/src/r3-d3-api-frictionContactMaterial.js new file mode 100644 index 0000000..c841b9b --- /dev/null +++ b/src/r3-d3-api-frictionContactMaterial.js @@ -0,0 +1,59 @@ +/** + * R3.D3.API.FrictionContactMaterial + * @param apiComponent + * + * @property materials + * @property friction + * @property restitution + * @property contactEquationStiffness + * @property contactEquationRelaxation + * @property frictionEquationStiffness + * @property frictionEquationRelaxation + * + * @constructor + */ +R3.D3.API.FrictionContactMaterial = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.materials)) { + apiComponent.materials = []; + } + this.materials = apiComponent.materials; + + if (R3.Utils.UndefinedOrNull(apiComponent.friction)) { + apiComponent.friction = 0.3; + } + this.friction = apiComponent.friction; + + if (R3.Utils.UndefinedOrNull(apiComponent.restitution)) { + apiComponent.restitution = 0.3; + } + this.restitution = apiComponent.restitution; + + if (R3.Utils.UndefinedOrNull(apiComponent.contactEquationStiffness)) { + apiComponent.contactEquationStiffness = 1e7; + } + this.contactEquationStiffness = apiComponent.contactEquationStiffness; + + if (R3.Utils.UndefinedOrNull(apiComponent.contactEquationRelaxation)) { + apiComponent.contactEquationRelaxation = 3; + } + this.contactEquationRelaxation = apiComponent.contactEquationRelaxation; + + if (R3.Utils.UndefinedOrNull(apiComponent.frictionEquationStiffness)) { + apiComponent.frictionEquationStiffness = 1e7; + } + this.frictionEquationStiffness = apiComponent.frictionEquationStiffness; + + if (R3.Utils.UndefinedOrNull(apiComponent.frictionEquationRelaxation)) { + apiComponent.frictionEquationRelaxation = 3; + } + this.frictionEquationRelaxation = apiComponent.frictionEquationRelaxation; + +}; + +R3.D3.API.FrictionContactMaterial.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.FrictionContactMaterial.prototype.constructor = R3.D3.API.FrictionContactMaterial; diff --git a/src/r3-d3-api-frictionMaterial.js b/src/r3-d3-api-frictionMaterial.js new file mode 100644 index 0000000..9d34f46 --- /dev/null +++ b/src/r3-d3-api-frictionMaterial.js @@ -0,0 +1,25 @@ +/** + * R3.D3.API.FrictionMaterial + * @param apiComponent + * @constructor + */ +R3.D3.API.FrictionMaterial = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.friction)) { + apiComponent.friction = -1; + } + this.friction = apiComponent.friction; + + if (R3.Utils.UndefinedOrNull(apiComponent.restitution)) { + apiComponent.restitution = -1; + } + this.restitution = apiComponent.restitution; + +}; + +R3.D3.API.FrictionMaterial.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.FrictionMaterial.prototype.constructor = R3.D3.API.FrictionMaterial; diff --git a/src/r3-d3-api-geometry-0.js b/src/r3-d3-api-geometry-0.js new file mode 100644 index 0000000..85e17ac --- /dev/null +++ b/src/r3-d3-api-geometry-0.js @@ -0,0 +1,106 @@ +/** + * R3.D3.API.Geometry + * @param apiComponent + * + * @property boundingBox + * @property boundingSphere + * @property indexed + * @property vertices + * @property faces + * + * @constructor + */ +R3.D3.API.Geometry = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.boundingBox)) { + apiComponent.boundingBox = new R3.API.Box3( + { + parent : this + } + ); + } + this.boundingBox = apiComponent.boundingBox; + + if (R3.Utils.UndefinedOrNull(apiComponent.boundingSphere)) { + apiComponent.boundingSphere = new R3.API.Sphere( + { + parent : this + } + ); + } + this.boundingSphere = apiComponent.boundingSphere; + + if (R3.Utils.UndefinedOrNull(apiComponent.indexed)) { + apiComponent.indexed = false; + } + this.indexed = apiComponent.indexed; + + /** + * We need to initialize the vertices before we initialize the faces, so we can pass vertex information to the + * face and calculate the face normal if required + */ + if (R3.Utils.UndefinedOrNull(apiComponent.vertices)) { + apiComponent.vertices = [ + new R3.API.Vertex( + { + parent : this, + register : true + } + ), + new R3.API.Vertex( + { + parent : this, + register : true + } + ), + new R3.API.Vertex( + { + parent : this, + register : true + } + ) + ]; + } + this.vertices = apiComponent.vertices; + + if (R3.Utils.UndefinedOrNull(apiComponent.faces)) { + apiComponent.faces = [ + new R3.D3.API.Face.Graphics( + { + parent : this, + register : true, + vertexIndices : [ + 0, + 1, + 2 + ], + vertices : [ + this.vertices[0], + this.vertices[1], + this.vertices[2] + ] + } + ) + ]; + } + this.faces = apiComponent.faces; + + this.faces = R3.Utils.SortFacesByMaterialIndex(this.faces); + + +}; + +R3.D3.API.Geometry.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.Geometry.prototype.constructor = R3.D3.API.Geometry; + +R3.D3.API.Geometry.prototype.updateNormals = function() { + throw new Error('Override R3.D3.API.Geometry.prototype.updateNormals in child class'); +}; + +R3.D3.API.Geometry.prototype.updatePositions = function() { + throw new Error('Override R3.D3.API.Geometry.prototype.updateNormals in child class'); +}; diff --git a/src/r3-d3-api-geometry-a.js b/src/r3-d3-api-geometry-a.js deleted file mode 100644 index 6340f76..0000000 --- a/src/r3-d3-api-geometry-a.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * R3.D3.API.Geometry - * @param apiComponent - * @param boundingBox - * @param boundingSphere - * @param faces - * @param vertices - * @constructor - */ -R3.D3.API.Geometry = function( - apiComponent, - boundingBox, - boundingSphere, - faces, - vertices -) { - - __API_COMPONENT_MACRO__; - - if (R3.Utils.UndefinedOrNull(boundingBox)) { - boundingBox = new R3.API.Box3( - { - parent : this - } - ); - } - this.boundingBox = boundingBox; - - if (R3.Utils.UndefinedOrNull(boundingSphere)) { - boundingSphere = new R3.API.Sphere( - { - parent : this - } - ); - } - this.boundingSphere = boundingSphere; - - if (R3.Utils.UndefinedOrNull(faces)) { - faces = [ - new R3.D3.API.Face( - { - parent : this - }, - 0, - 1, - 2 - ) - ]; - } - this.faces = faces; - - if (R3.Utils.UndefinedOrNull(vertices)) { - vertices = [ - new R3.API.Vector3() - ]; - } - this.vertices = vertices; -}; - -R3.D3.API.Geometry.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.Geometry.prototype.constructor = R3.D3.API.Geometry; diff --git a/src/r3-d3-api-geometry-buffer-0.js b/src/r3-d3-api-geometry-buffer-0.js new file mode 100644 index 0000000..9f0cad0 --- /dev/null +++ b/src/r3-d3-api-geometry-buffer-0.js @@ -0,0 +1,62 @@ +/** + * R3.D3.API.Geometry.Buffer + * @param apiComponent + * + * @property attributes + * @property drawRange + * @property groups + * @property index + * @property morphAttributes + * + * @constructor + */ +R3.D3.API.Geometry.Buffer = function( + apiComponent +) { + + R3.D3.API.Geometry.call( + this, + apiComponent + ); + + if (R3.Utils.UndefinedOrNull(apiComponent.attributes)) { + apiComponent.attributes = []; + } + this.attributes = apiComponent.attributes; + + if (R3.Utils.UndefinedOrNull(apiComponent.groups)) { + apiComponent.groups = []; + } + this.groups = apiComponent.groups; + + if (R3.Utils.UndefinedOrNull(apiComponent.drawRange)) { + apiComponent.drawRange = new R3.API.DrawRange( + { + parent : this + } + ) + } + this.drawRange = apiComponent.drawRange; + + if (R3.Utils.UndefinedOrNull(apiComponent.index)) { + apiComponent.index = null; + } + this.index = apiComponent.index; + + if (R3.Utils.UndefinedOrNull(apiComponent.morphAttributes)) { + apiComponent.morphAttributes = null; + } + this.morphAttributes = apiComponent.morphAttributes; + +}; + +R3.D3.API.Geometry.Buffer.prototype = Object.create(R3.D3.API.Geometry.prototype); +R3.D3.API.Geometry.Buffer.prototype.constructor = R3.D3.API.Geometry.Buffer; + +R3.D3.API.Geometry.Buffer.prototype.updateNormals = function() { + console.warn('todo: R3.D3.API.Geometry.Buffer.prototype.updateNormals'); +}; + +R3.D3.API.Geometry.Buffer.prototype.updatePositions = function() { + console.warn('todo: R3.D3.API.Geometry.Buffer.prototype.updatePositions'); +}; diff --git a/src/r3-d3-api-geometry-buffer-a.js b/src/r3-d3-api-geometry-buffer-a.js deleted file mode 100644 index f19f81d..0000000 --- a/src/r3-d3-api-geometry-buffer-a.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * R3.D3.API.Geometry.Buffer - * @param apiGeometry - * @param attributes - * @param drawRange - * @param groups - * @param index - * @param morphAttributes - * @constructor - */ -R3.D3.API.Geometry.Buffer = function( - apiGeometry, - attributes, - drawRange, - groups, - index, - morphAttributes -) { - if (R3.Utils.UndefinedOrNull(apiGeometry)) { - apiGeometry = {}; - } - this.apiGeometry = apiGeometry; - - R3.D3.API.Geometry.call( - this, - this.apiGeometry, - this.apiGeometry.boundingBox, - this.apiGeometry.boundingSphere, - this.apiGeometry.faces, - this.apiGeometry.vertices - ); - - if (R3.Utils.UndefinedOrNull(attributes)) { - attributes = []; - } - this.attributes = attributes; - - if (R3.Utils.UndefinedOrNull(groups)) { - groups = []; - } - this.groups = groups; - - if (R3.Utils.UndefinedOrNull(drawRange)) { - drawRange = new R3.API.DrawRange() - } - this.drawRange = drawRange; - - if (R3.Utils.UndefinedOrNull(index)) { - index = null; - } - this.index = index; - - if (R3.Utils.UndefinedOrNull(morphAttributes)) { - morphAttributes = null; - } - this.morphAttributes = morphAttributes; - -}; - -R3.D3.API.Geometry.Buffer.prototype = Object.create(R3.D3.API.Geometry.prototype); -R3.D3.API.Geometry.Buffer.prototype.constructor = R3.D3.API.Geometry.Buffer; diff --git a/src/r3-d3-api-geometry-buffer-box.js b/src/r3-d3-api-geometry-buffer-box.js index 075adb5..81fec58 100644 --- a/src/r3-d3-api-geometry-buffer-box.js +++ b/src/r3-d3-api-geometry-buffer-box.js @@ -1,55 +1,51 @@ /** * R3.D3.API.Geometry.Buffer.Box - * @param apiGeometryBuffer - * @param width - * @param height - * @param depth - * @param widthSegments - * @param heightSegments - * @param depthSegments + * @param apiComponent + * + * @property width + * @property height + * @property depth + * @property widthSegments + * @property heightSegments + * @property depthSegments + * * @constructor */ R3.D3.API.Geometry.Buffer.Box = function( - apiGeometryBuffer, - width, - height, - depth, - widthSegments, - heightSegments, - depthSegments + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(width)) { - width = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 1; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 1; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(depth)) { - depth = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.depth)) { + apiComponent.depth = 1; } - this.depth = depth; + this.depth = apiComponent.depth; - if (R3.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.widthSegments)) { + apiComponent.widthSegments = 1; } - this.widthSegments = widthSegments; + this.widthSegments = apiComponent.widthSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 1; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; - if (R3.Utils.UndefinedOrNull(depthSegments)) { - depthSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.depthSegments)) { + apiComponent.depthSegments = 1; } - this.depthSegments = depthSegments; + this.depthSegments = apiComponent.depthSegments; }; diff --git a/src/r3-d3-api-geometry-buffer-circle.js b/src/r3-d3-api-geometry-buffer-circle.js index 5290072..9f79cc5 100644 --- a/src/r3-d3-api-geometry-buffer-circle.js +++ b/src/r3-d3-api-geometry-buffer-circle.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Buffer.Circle - * @param apiGeometryBuffer - * @param radius - * @param segments - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property radius + * @property segments + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Circle = function( - apiGeometryBuffer, - radius, - segments, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(segments)) { - segments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.segments)) { + apiComponent.segments = 8; } - this.segments = segments; + this.segments = apiComponent.segments; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI * 2; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; R3.D3.API.Geometry.Buffer.Circle.prototype = Object.create(R3.D3.API.Geometry.Buffer.prototype); diff --git a/src/r3-d3-api-geometry-buffer-cone.js b/src/r3-d3-api-geometry-buffer-cone.js index 1475610..96a9a57 100644 --- a/src/r3-d3-api-geometry-buffer-cone.js +++ b/src/r3-d3-api-geometry-buffer-cone.js @@ -1,62 +1,57 @@ /** * R3.D3.API.Geometry.Buffer.Cone - * @param apiGeometryBuffer - * @param radius - * @param height - * @param radialSegments - * @param heightSegments - * @param openEnded - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property radius + * @property height + * @property radialSegments + * @property heightSegments + * @property openEnded + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Cone = function( - apiGeometryBuffer, - radius, - height, - radialSegments, - heightSegments, - openEnded, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(height)) { - height = 100; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 100; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.radialSegments)) { + apiComponent.radialSegments = 8; } - this.radialSegments = radialSegments; + this.radialSegments = apiComponent.radialSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 1; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; - if (R3.Utils.UndefinedOrNull(openEnded)) { - openEnded = false; + if (R3.Utils.UndefinedOrNull(apiComponent.openEnded)) { + apiComponent.openEnded = false; } - this.openEnded = openEnded; + this.openEnded = apiComponent.openEnded; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI * 2; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-buffer-cylinder.js b/src/r3-d3-api-geometry-buffer-cylinder.js index dcefebb..2f795f5 100644 --- a/src/r3-d3-api-geometry-buffer-cylinder.js +++ b/src/r3-d3-api-geometry-buffer-cylinder.js @@ -1,69 +1,63 @@ /** * R3.D3.API.Geometry.Buffer.Cylinder - * @param apiGeometryBuffer - * @param radiusTop - * @param radiusBottom - * @param height - * @param radialSegments - * @param heightSegments - * @param openEnded - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property radiusTop + * @property radiusBottom + * @property height + * @property radialSegments + * @property heightSegments + * @property openEnded + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Cylinder = function( - apiGeometryBuffer, - radiusTop, - radiusBottom, - height, - radialSegments, - heightSegments, - openEnded, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radiusTop)) { - radiusTop = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radiusTop)) { + apiComponent.radiusTop = 1; } - this.radiusTop = radiusTop; + this.radiusTop = apiComponent.radiusTop; - if (R3.Utils.UndefinedOrNull(radiusBottom)) { - radiusBottom = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radiusBottom)) { + apiComponent.radiusBottom = 1; } - this.radiusBottom = radiusBottom; + this.radiusBottom = apiComponent.radiusBottom; - if (R3.Utils.UndefinedOrNull(height)) { - height = 100; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 100; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(radialSegments)) { - radialSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.radialSegments)) { + apiComponent.radialSegments = 8; } - this.radialSegments = radialSegments; + this.radialSegments = apiComponent.radialSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 1; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; - if (R3.Utils.UndefinedOrNull(openEnded)) { - openEnded = false; + if (R3.Utils.UndefinedOrNull(apiComponent.openEnded)) { + apiComponent.openEnded = false; } - this.openEnded = openEnded; + this.openEnded = apiComponent.openEnded; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI * 2; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-buffer-dodecahedron.js b/src/r3-d3-api-geometry-buffer-dodecahedron.js index 22a652d..d3d4b98 100644 --- a/src/r3-d3-api-geometry-buffer-dodecahedron.js +++ b/src/r3-d3-api-geometry-buffer-dodecahedron.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Buffer.Dodecahedron - * @param apiGeometryBuffer - * @param radius - * @param detail + * @param apiComponent + * + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Buffer.Dodecahedron = function( - apiGeometryBuffer, - radius, - detail + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-buffer-extrude.js b/src/r3-d3-api-geometry-buffer-extrude.js index e76d2ed..50479a3 100644 --- a/src/r3-d3-api-geometry-buffer-extrude.js +++ b/src/r3-d3-api-geometry-buffer-extrude.js @@ -1,85 +1,78 @@ /** * R3.D3.API.Geometry.Buffer.Extrude - * @param apiGeometryBuffer - * @param shapes - * @param curveSegments - * @param steps - * @param amount - * @param bevelEnabled - * @param bevelThickness - * @param bevelSize - * @param bevelSegments - * @param extrudePath - * @param frames - * @param UVGenerator + * @param apiComponent + * + * @property shapes + * @property curveSegments + * @property steps + * @property amount + * @property bevelEnabled + * @property bevelThickness + * @property bevelSize + * @property bevelSegments + * @property extrudePath + * @property frames + * @property UVGenerator + * * @constructor */ R3.D3.API.Geometry.Buffer.Extrude = function( - apiGeometryBuffer, - shapes, - curveSegments, - steps, - amount, - bevelEnabled, - bevelThickness, - bevelSize, - bevelSegments, - extrudePath, - frames, - UVGenerator + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(shapes)) { - shapes = []; - } - this.shapes = shapes; + throw new Error('todo: implement shapes'); - if (R3.Utils.UndefinedOrNull(curveSegments)) { - curveSegments = 12; + if (R3.Utils.UndefinedOrNull(apiComponent.shapes)) { + apiComponent.shapes = []; } - this.curveSegments = curveSegments; + this.shapes = apiComponent.shapes; - if (R3.Utils.UndefinedOrNull(steps)) { - steps = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.curveSegments)) { + apiComponent.curveSegments = 12; } - this.steps = steps; + this.curveSegments = apiComponent.curveSegments; - if (R3.Utils.UndefinedOrNull(amount)) { - amount = 100; + if (R3.Utils.UndefinedOrNull(apiComponent.steps)) { + apiComponent.steps = 1; } - this.amount = amount; + this.steps = apiComponent.steps; - if (R3.Utils.UndefinedOrNull(bevelEnabled)) { - bevelEnabled = true; + if (R3.Utils.UndefinedOrNull(apiComponent.amount)) { + apiComponent.amount = 100; } - this.bevelEnabled = bevelEnabled; + this.amount = apiComponent.amount; - if (R3.Utils.UndefinedOrNull(bevelThickness)) { - bevelThickness = 6; + if (R3.Utils.UndefinedOrNull(apiComponent.bevelEnabled)) { + apiComponent.bevelEnabled = true; } - this.bevelThickness = bevelThickness; + this.bevelEnabled = apiComponent.bevelEnabled; - if (R3.Utils.UndefinedOrNull(bevelSegments)) { - bevelSegments = 3; + if (R3.Utils.UndefinedOrNull(apiComponent.bevelThickness)) { + apiComponent.bevelThickness = 6; } - this.bevelSegments = bevelSegments; + this.bevelThickness = apiComponent.bevelThickness; - if (R3.Utils.UndefinedOrNull(extrudePath)) { - extrudePath = null; + if (R3.Utils.UndefinedOrNull(apiComponent.bevelSegments)) { + apiComponent.bevelSegments = 3; } - this.extrudePath = extrudePath; + this.bevelSegments = apiComponent.bevelSegments; - if (R3.Utils.UndefinedOrNull(frames)) { - frames = null; + if (R3.Utils.UndefinedOrNull(apiComponent.extrudePath)) { + apiComponent.extrudePath = null; } - this.frames = frames; + this.extrudePath = apiComponent.extrudePath; - if (R3.Utils.UndefinedOrNull(UVGenerator)) { - UVGenerator = null; + if (R3.Utils.UndefinedOrNull(apiComponent.frames)) { + apiComponent.frames = null; } - this.UVGenerator = UVGenerator; + this.frames = apiComponent.frames; + + if (R3.Utils.UndefinedOrNull(apiComponent.UVGenerator)) { + apiComponent.UVGenerator = null; + } + this.UVGenerator = apiComponent.UVGenerator; }; diff --git a/src/r3-d3-api-geometry-buffer-icosahedron.js b/src/r3-d3-api-geometry-buffer-icosahedron.js index 340caf7..18fbaf1 100644 --- a/src/r3-d3-api-geometry-buffer-icosahedron.js +++ b/src/r3-d3-api-geometry-buffer-icosahedron.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Buffer.Icosahedron - * @param apiGeometryBuffer - * @param radius - * @param detail + * @param apiComponent + * + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Buffer.Icosahedron = function( - apiGeometryBuffer, - radius, - detail + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-buffer-instanced.js b/src/r3-d3-api-geometry-buffer-instanced.js index 93dca19..66773b6 100644 --- a/src/r3-d3-api-geometry-buffer-instanced.js +++ b/src/r3-d3-api-geometry-buffer-instanced.js @@ -1,20 +1,21 @@ /** * R3.D3.API.Geometry.Buffer.Instanced - * @param apiGeometryBuffer - * @param maxInstancedCount + * @param apiComponent + * + * @property maxInstancedCount + * * @constructor */ R3.D3.API.Geometry.Buffer.Instanced = function( - apiGeometryBuffer, - maxInstancedCount + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(maxInstancedCount)) { - maxInstancedCount = null; + if (R3.Utils.UndefinedOrNull(apiComponent.maxInstancedCount)) { + apiComponent.maxInstancedCount = null; } - this.maxInstancedCount = maxInstancedCount; + this.maxInstancedCount = apiComponent.maxInstancedCount; }; diff --git a/src/r3-d3-api-geometry-buffer-lathe.js b/src/r3-d3-api-geometry-buffer-lathe.js index 3e2ba7b..8e865ca 100644 --- a/src/r3-d3-api-geometry-buffer-lathe.js +++ b/src/r3-d3-api-geometry-buffer-lathe.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Buffer.Lathe - * @param apiGeometryBuffer - * @param points [R3.Vector2] (x must be larger than 0) - * @param segments - * @param phiStart - * @param phiLength + * @param apiComponent + * + * @property points [R3.Vector2] (x must be larger than 0) + * @property segments + * @property phiStart + * @property phiLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Lathe = function( - apiGeometryBuffer, - points, - segments, - phiStart, - phiLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(points)) { - points = []; + if (R3.Utils.UndefinedOrNull(apiComponent.points)) { + apiComponent.points = []; } - this.points = points; + this.points = apiComponent.points; - if (R3.Utils.UndefinedOrNull(segments)) { - segments = 12; + if (R3.Utils.UndefinedOrNull(apiComponent.segments)) { + apiComponent.segments = 12; } - this.segments = segments; + this.segments = apiComponent.segments; - if (R3.Utils.UndefinedOrNull(phiStart)) { - phiStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.phiStart)) { + apiComponent.phiStart = 0; } - this.phiStart = phiStart; + this.phiStart = apiComponent.phiStart; - if (R3.Utils.UndefinedOrNull(phiLength)) { - phiLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.phiLength)) { + apiComponent.phiLength = Math.PI * 2; } - this.phiLength = phiLength; + this.phiLength = apiComponent.phiLength; }; diff --git a/src/r3-d3-api-geometry-buffer-octahedron.js b/src/r3-d3-api-geometry-buffer-octahedron.js index b863689..5c4ac29 100644 --- a/src/r3-d3-api-geometry-buffer-octahedron.js +++ b/src/r3-d3-api-geometry-buffer-octahedron.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Buffer.Octahedron - * @param apiGeometryBuffer - * @param radius - * @param detail + * @param apiComponent + * + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Buffer.Octahedron = function( - apiGeometryBuffer, - radius, - detail + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-buffer-parametric.js b/src/r3-d3-api-geometry-buffer-parametric.js index 65c5fc5..488d627 100644 --- a/src/r3-d3-api-geometry-buffer-parametric.js +++ b/src/r3-d3-api-geometry-buffer-parametric.js @@ -1,34 +1,33 @@ /** * R3.D3.API.Geometry.Buffer.Parametric - * @param apiGeometryBuffer - * @param generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 - * @param slices - * @param stacks + * @param apiComponent + * + * @property generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 + * @property slices + * @property stacks + * * @constructor */ R3.D3.API.Geometry.Buffer.Parametric = function( - apiGeometryBuffer, - generatorFn, - slices, - stacks + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(generatorFn)) { - generatorFn = ''; + if (R3.Utils.UndefinedOrNull(apiComponent.generatorFn)) { + apiComponent.generatorFn = ''; } - this.generatorFn = generatorFn; + this.generatorFn = apiComponent.generatorFn; - if (R3.Utils.UndefinedOrNull(slices)) { - slices = 20; + if (R3.Utils.UndefinedOrNull(apiComponent.slices)) { + apiComponent.slices = 20; } - this.slices = slices; + this.slices = apiComponent.slices; - if (R3.Utils.UndefinedOrNull(stacks)) { - stacks = 20; + if (R3.Utils.UndefinedOrNull(apiComponent.stacks)) { + apiComponent.stacks = 20; } - this.stacks = stacks; + this.stacks = apiComponent.stacks; }; diff --git a/src/r3-d3-api-geometry-buffer-plane.js b/src/r3-d3-api-geometry-buffer-plane.js index 0a2d413..f12132d 100644 --- a/src/r3-d3-api-geometry-buffer-plane.js +++ b/src/r3-d3-api-geometry-buffer-plane.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Buffer.Plane - * @param apiGeometryBuffer - * @param width - * @param height - * @param widthSegments - * @param heightSegments + * @param apiComponent + * + * @property width + * @property height + * @property widthSegments + * @property heightSegments + * * @constructor */ R3.D3.API.Geometry.Buffer.Plane = function( - apiGeometryBuffer, - width, - height, - widthSegments, - heightSegments + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(width)) { - width = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 1; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 1; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.widthSegments)) { + apiComponent.widthSegments = 1; } - this.widthSegments = widthSegments; + this.widthSegments = apiComponent.widthSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 1; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; }; diff --git a/src/r3-d3-api-geometry-buffer-polyhedron.js b/src/r3-d3-api-geometry-buffer-polyhedron.js index 562a3d1..a2c0e1f 100644 --- a/src/r3-d3-api-geometry-buffer-polyhedron.js +++ b/src/r3-d3-api-geometry-buffer-polyhedron.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Buffer.Polyhedron - * @param apiGeometryBuffer - * @param vertices - * @param indices - * @param radius - * @param detail + * @param apiComponent + * + * @property vertices + * @property indices + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Buffer.Polyhedron = function( - apiGeometryBuffer, - vertices, - indices, - radius, - detail + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(vertices)) { - vertices = []; + if (R3.Utils.UndefinedOrNull(apiComponent.vertices)) { + apiComponent.vertices = []; } - this.vertices = vertices; + this.vertices = apiComponent.vertices; - if (R3.Utils.UndefinedOrNull(indices)) { - indices = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.indices)) { + apiComponent.indices = 1; } - this.indices = indices; + this.indices = apiComponent.indices; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 5; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 5; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-buffer-ring.js b/src/r3-d3-api-geometry-buffer-ring.js index d2aed7c..f7bc8f0 100644 --- a/src/r3-d3-api-geometry-buffer-ring.js +++ b/src/r3-d3-api-geometry-buffer-ring.js @@ -1,55 +1,51 @@ /** * R3.D3.API.Geometry.Buffer.Ring - * @param apiGeometryBuffer - * @param innerRadius - * @param outerRadius - * @param thetaSegments - * @param phiSegments - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property innerRadius + * @property outerRadius + * @property thetaSegments + * @property phiSegments + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Ring = function( - apiGeometryBuffer, - innerRadius, - outerRadius, - thetaSegments, - phiSegments, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(innerRadius)) { - innerRadius = 0.5; + if (R3.Utils.UndefinedOrNull(apiComponent.innerRadius)) { + apiComponent.innerRadius = 0.5; } - this.innerRadius = innerRadius; + this.innerRadius = apiComponent.innerRadius; - if (R3.Utils.UndefinedOrNull(outerRadius)) { - outerRadius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.outerRadius)) { + apiComponent.outerRadius = 1; } - this.outerRadius = outerRadius; + this.outerRadius = apiComponent.outerRadius; - if (R3.Utils.UndefinedOrNull(thetaSegments)) { - thetaSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaSegments)) { + apiComponent.thetaSegments = 8; } - this.thetaSegments = thetaSegments; + this.thetaSegments = apiComponent.thetaSegments; - if (R3.Utils.UndefinedOrNull(phiSegments)) { - phiSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.phiSegments)) { + apiComponent.phiSegments = 8; } - this.phiSegments = phiSegments; + this.phiSegments = apiComponent.phiSegments; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI * 2; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-buffer-shape.js b/src/r3-d3-api-geometry-buffer-shape.js index 339c652..c4484f3 100644 --- a/src/r3-d3-api-geometry-buffer-shape.js +++ b/src/r3-d3-api-geometry-buffer-shape.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Buffer.Shape - * @param apiGeometryBuffer - * @param shapes - * @param curveSegments + * @param apiComponent + * + * @property shapes + * @property curveSegments + * * @constructor */ R3.D3.API.Geometry.Buffer.Shape = function( - apiGeometryBuffer, - shapes, - curveSegments + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(shapes)) { - shapes = []; + if (R3.Utils.UndefinedOrNull(apiComponent.shapes)) { + apiComponent.shapes = []; } - this.shapes = shapes; + this.shapes = apiComponent.shapes; - if (R3.Utils.UndefinedOrNull(curveSegments)) { - curveSegments = 12; + if (R3.Utils.UndefinedOrNull(apiComponent.curveSegments)) { + apiComponent.curveSegments = 12; } - this.curveSegments = curveSegments; + this.curveSegments = apiComponent.curveSegments; }; diff --git a/src/r3-d3-api-geometry-buffer-sphere.js b/src/r3-d3-api-geometry-buffer-sphere.js index 7f8604e..00059ce 100644 --- a/src/r3-d3-api-geometry-buffer-sphere.js +++ b/src/r3-d3-api-geometry-buffer-sphere.js @@ -1,62 +1,57 @@ /** * R3.D3.API.Geometry.Buffer.Sphere - * @param apiGeometryBuffer - * @param radius - * @param widthSegments - * @param heightSegments - * @param phiStart - * @param phiLength - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property radius + * @property widthSegments + * @property heightSegments + * @property phiStart + * @property phiLength + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Buffer.Sphere = function( - apiGeometryBuffer, - radius, - widthSegments, - heightSegments, - phiStart, - phiLength, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.widthSegments)) { + apiComponent.widthSegments = 8; } - this.widthSegments = widthSegments; + this.widthSegments = apiComponent.widthSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 6; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 6; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; - if (R3.Utils.UndefinedOrNull(phiStart)) { - phiStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.phiStart)) { + apiComponent.phiStart = 0; } - this.phiStart = phiStart; + this.phiStart = apiComponent.phiStart; - if (R3.Utils.UndefinedOrNull(phiLength)) { - phiLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.phiLength)) { + apiComponent.phiLength = Math.PI * 2; } - this.phiLength = phiLength; + this.phiLength = apiComponent.phiLength; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-buffer-tetrahedron.js b/src/r3-d3-api-geometry-buffer-tetrahedron.js index 9a531f4..feb193d 100644 --- a/src/r3-d3-api-geometry-buffer-tetrahedron.js +++ b/src/r3-d3-api-geometry-buffer-tetrahedron.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Buffer.Tetrahedron - * @param apiGeometryBuffer - * @param radius - * @param detail + * @param apiComponent + * + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Buffer.Tetrahedron = function( - apiGeometryBuffer, - radius, - detail + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-buffer-text.js b/src/r3-d3-api-geometry-buffer-text.js index bdb91a3..9fe8d8f 100644 --- a/src/r3-d3-api-geometry-buffer-text.js +++ b/src/r3-d3-api-geometry-buffer-text.js @@ -1,76 +1,69 @@ /** * R3.D3.API.Geometry.Buffer.Text - * @param apiGeometryBuffer - * @param text - * @param font - * @param size - * @param height - * @param curveSegments - * @param bevelEnabled - * @param bevelThickness - * @param bevelSize - * @param bevelSegments + * @param apiComponent + * + * @property text + * @property font + * @property size + * @property height + * @property curveSegments + * @property bevelEnabled + * @property bevelThickness + * @property bevelSize + * @property bevelSegments + * * @constructor */ R3.D3.API.Geometry.Buffer.Text = function( - apiGeometryBuffer, - text, - font, - size, - height, - curveSegments, - bevelEnabled, - bevelThickness, - bevelSize, - bevelSegments + apiComponent ) { - __API_GEOMETRY_BUFFER_MACRO__; + __API_GEOMETRY_BUFFER__; - if (R3.Utils.UndefinedOrNull(text)) { - text = '-= returns Vector3, u and v is values between 0 and 1 - * @param slices - * @param stacks + * @param apiComponent + * + * @property generatorFn(u,v) => returns Vector3, u and v is values between 0 and 1 + * @property slices + * @property stacks + * * @constructor */ R3.D3.API.Geometry.Normal.Parametric = function( - apiGeometryNormal, - generatorFn, - slices, - stacks + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(generatorFn)) { - generatorFn = ''; + if (R3.Utils.UndefinedOrNull(apiComponent.generatorFn)) { + apiComponent.generatorFn = ''; } - this.generatorFn = generatorFn; + this.generatorFn = apiComponent.generatorFn; - if (R3.Utils.UndefinedOrNull(slices)) { - slices = 20; + if (R3.Utils.UndefinedOrNull(apiComponent.slices)) { + apiComponent.slices = 20; } - this.slices = slices; + this.slices = apiComponent.slices; - if (R3.Utils.UndefinedOrNull(stacks)) { - stacks = 20; + if (R3.Utils.UndefinedOrNull(apiComponent.stacks)) { + apiComponent.stacks = 20; } - this.stacks = stacks; + this.stacks = apiComponent.stacks; }; diff --git a/src/r3-d3-api-geometry-normal-plane.js b/src/r3-d3-api-geometry-normal-plane.js index 191e31d..a629094 100644 --- a/src/r3-d3-api-geometry-normal-plane.js +++ b/src/r3-d3-api-geometry-normal-plane.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Normal.Plane - * @param apiGeometryNormal - * @param width - * @param height - * @param widthSegments - * @param heightSegments + * @param apiComponent + * + * @property width + * @property height + * @property widthSegments + * @property heightSegments + * * @constructor */ R3.D3.API.Geometry.Normal.Plane = function( - apiGeometryNormal, - width, - height, - widthSegments, - heightSegments + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(width)) { - width = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 1; } - this.width = width; + this.width = apiComponent.width; - if (R3.Utils.UndefinedOrNull(height)) { - height = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 1; } - this.height = height; + this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.widthSegments)) { + apiComponent.widthSegments = 1; } - this.widthSegments = widthSegments; + this.widthSegments = apiComponent.widthSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 1; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; }; diff --git a/src/r3-d3-api-geometry-normal-polyhedron.js b/src/r3-d3-api-geometry-normal-polyhedron.js index 832ec82..e93f78d 100644 --- a/src/r3-d3-api-geometry-normal-polyhedron.js +++ b/src/r3-d3-api-geometry-normal-polyhedron.js @@ -1,41 +1,39 @@ /** * R3.D3.API.Geometry.Normal.Polyhedron - * @param apiGeometryNormal - * @param vertices - * @param indices - * @param radius - * @param detail + * @param apiComponent + * + * @property vertices + * @property indices + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Normal.Polyhedron = function( - apiGeometryNormal, - vertices, - indices, - radius, - detail + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(vertices)) { - vertices = []; + if (R3.Utils.UndefinedOrNull(apiComponent.vertices)) { + apiComponent.vertices = []; } - this.vertices = vertices; + this.vertices = apiComponent.vertices; - if (R3.Utils.UndefinedOrNull(indices)) { - indices = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.indices)) { + apiComponent.indices = 1; } - this.indices = indices; + this.indices = apiComponent.indices; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 5; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 5; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-normal-ring.js b/src/r3-d3-api-geometry-normal-ring.js index 8904180..82556e8 100644 --- a/src/r3-d3-api-geometry-normal-ring.js +++ b/src/r3-d3-api-geometry-normal-ring.js @@ -1,55 +1,51 @@ /** * R3.D3.API.Geometry.Normal.Ring - * @param apiGeometryNormal - * @param innerRadius - * @param outerRadius - * @param thetaSegments - * @param phiSegments - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property innerRadius + * @property outerRadius + * @property thetaSegments + * @property phiSegments + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Normal.Ring = function( - apiGeometryNormal, - innerRadius, - outerRadius, - thetaSegments, - phiSegments, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(innerRadius)) { - innerRadius = 0.5; + if (R3.Utils.UndefinedOrNull(apiComponent.innerRadius)) { + apiComponent.innerRadius = 0.5; } - this.innerRadius = innerRadius; + this.innerRadius = apiComponent.innerRadius; - if (R3.Utils.UndefinedOrNull(outerRadius)) { - outerRadius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.outerRadius)) { + apiComponent.outerRadius = 1; } - this.outerRadius = outerRadius; + this.outerRadius = apiComponent.outerRadius; - if (R3.Utils.UndefinedOrNull(thetaSegments)) { - thetaSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaSegments)) { + apiComponent.thetaSegments = 8; } - this.thetaSegments = thetaSegments; + this.thetaSegments = apiComponent.thetaSegments; - if (R3.Utils.UndefinedOrNull(phiSegments)) { - phiSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.phiSegments)) { + apiComponent.phiSegments = 8; } - this.phiSegments = phiSegments; + this.phiSegments = apiComponent.phiSegments; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI * 2; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-normal-shape.js b/src/r3-d3-api-geometry-normal-shape.js index 08cf04b..9af1db9 100644 --- a/src/r3-d3-api-geometry-normal-shape.js +++ b/src/r3-d3-api-geometry-normal-shape.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Normal.Shape - * @param apiGeometryNormal - * @param shapes - * @param curveSegments + * @param apiComponent + * + * @property shapes + * @property curveSegments + * * @constructor */ R3.D3.API.Geometry.Normal.Shape = function( - apiGeometryNormal, - shapes, - curveSegments + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(shapes)) { - shapes = []; + if (R3.Utils.UndefinedOrNull(apiComponent.shapes)) { + apiComponent.shapes = []; } - this.shapes = shapes; + this.shapes = apiComponent.shapes; - if (R3.Utils.UndefinedOrNull(curveSegments)) { - curveSegments = 12; + if (R3.Utils.UndefinedOrNull(apiComponent.curveSegments)) { + apiComponent.curveSegments = 12; } - this.curveSegments = curveSegments; + this.curveSegments = apiComponent.curveSegments; }; diff --git a/src/r3-d3-api-geometry-normal-sphere.js b/src/r3-d3-api-geometry-normal-sphere.js index 81177cf..bef21b1 100644 --- a/src/r3-d3-api-geometry-normal-sphere.js +++ b/src/r3-d3-api-geometry-normal-sphere.js @@ -1,62 +1,57 @@ /** * R3.D3.API.Geometry.Normal.Sphere - * @param apiGeometryNormal - * @param radius - * @param widthSegments - * @param heightSegments - * @param phiStart - * @param phiLength - * @param thetaStart - * @param thetaLength + * @param apiComponent + * + * @property radius + * @property widthSegments + * @property heightSegments + * @property phiStart + * @property phiLength + * @property thetaStart + * @property thetaLength + * * @constructor */ R3.D3.API.Geometry.Normal.Sphere = function( - apiGeometryNormal, - radius, - widthSegments, - heightSegments, - phiStart, - phiLength, - thetaStart, - thetaLength + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(widthSegments)) { - widthSegments = 8; + if (R3.Utils.UndefinedOrNull(apiComponent.widthSegments)) { + apiComponent.widthSegments = 8; } - this.widthSegments = widthSegments; + this.widthSegments = apiComponent.widthSegments; - if (R3.Utils.UndefinedOrNull(heightSegments)) { - heightSegments = 6; + if (R3.Utils.UndefinedOrNull(apiComponent.heightSegments)) { + apiComponent.heightSegments = 6; } - this.heightSegments = heightSegments; + this.heightSegments = apiComponent.heightSegments; - if (R3.Utils.UndefinedOrNull(phiStart)) { - phiStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.phiStart)) { + apiComponent.phiStart = 0; } - this.phiStart = phiStart; + this.phiStart = apiComponent.phiStart; - if (R3.Utils.UndefinedOrNull(phiLength)) { - phiLength = Math.PI * 2; + if (R3.Utils.UndefinedOrNull(apiComponent.phiLength)) { + apiComponent.phiLength = Math.PI * 2; } - this.phiLength = phiLength; + this.phiLength = apiComponent.phiLength; - if (R3.Utils.UndefinedOrNull(thetaStart)) { - thetaStart = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaStart)) { + apiComponent.thetaStart = 0; } - this.thetaStart = thetaStart; + this.thetaStart = apiComponent.thetaStart; - if (R3.Utils.UndefinedOrNull(thetaLength)) { - thetaLength = Math.PI; + if (R3.Utils.UndefinedOrNull(apiComponent.thetaLength)) { + apiComponent.thetaLength = Math.PI; } - this.thetaLength = thetaLength; + this.thetaLength = apiComponent.thetaLength; }; diff --git a/src/r3-d3-api-geometry-normal-tetrahedron.js b/src/r3-d3-api-geometry-normal-tetrahedron.js index 81443ca..116b855 100644 --- a/src/r3-d3-api-geometry-normal-tetrahedron.js +++ b/src/r3-d3-api-geometry-normal-tetrahedron.js @@ -1,27 +1,27 @@ /** * R3.D3.API.Geometry.Normal.Tetrahedron - * @param apiGeometryNormal - * @param radius - * @param detail + * @param apiComponent + * + * @property radius + * @property detail + * * @constructor */ R3.D3.API.Geometry.Normal.Tetrahedron = function( - apiGeometryNormal, - radius, - detail + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(radius)) { - radius = 1; + if (R3.Utils.UndefinedOrNull(apiComponent.radius)) { + apiComponent.radius = 1; } - this.radius = radius; + this.radius = apiComponent.radius; - if (R3.Utils.UndefinedOrNull(detail)) { - detail = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.detail)) { + apiComponent.detail = 0; } - this.detail = detail; + this.detail = apiComponent.detail; }; diff --git a/src/r3-d3-api-geometry-normal-text.js b/src/r3-d3-api-geometry-normal-text.js index 4fc5715..5c68acc 100644 --- a/src/r3-d3-api-geometry-normal-text.js +++ b/src/r3-d3-api-geometry-normal-text.js @@ -1,76 +1,69 @@ /** * R3.D3.API.Geometry.Normal.Text - * @param apiGeometryNormal - * @param text - * @param font - * @param size - * @param height - * @param curveSegments - * @param bevelEnabled - * @param bevelThickness - * @param bevelSize - * @param bevelSegments + * @param apiComponent + * + * @property text + * @property font + * @property size + * @property height + * @property curveSegments + * @property bevelEnabled + * @property bevelThickness + * @property bevelSize + * @property bevelSegments + * * @constructor */ R3.D3.API.Geometry.Normal.Text = function( - apiGeometryNormal, - text, - font, - size, - height, - curveSegments, - bevelEnabled, - bevelThickness, - bevelSize, - bevelSegments + apiComponent ) { - __API_GEOMETRY_NORMAL_MACRO__; + __API_GEOMETRY_NORMAL__; - if (R3.Utils.UndefinedOrNull(text)) { - text = '-= 0) { - this.instance.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); } /** - * Setup face UVs + * To add a material group to this instance - do this somewhere + * + * this.instance.addGroup( + * 0, + * this.instance.attributes.position.count, + * 0 + * ); */ - var uvs = new Float32Array( - this.faces.reduce( - function(result, face) { - - face.uvs[0].map( - function(uv) { - result.push(uv.x); - result.push(uv.y); - } - ); - - return result; - }, - [] - ) - ); - this.instance.addAttribute('uv', new THREE.BufferAttribute(uvs, 2)); - - /** - * Normals - * @type {Float32Array} - */ - var normals = new Float32Array( - this.faces.reduce( - function(result, face) { - - result.push( - face.normal.x, - face.normal.y, - face.normal.z - ); - result.push( - face.normal.x, - face.normal.y, - face.normal.z - ); - result.push( - face.normal.x, - face.normal.y, - face.normal.z - ); - return result; - }, - [] - ) - ); - this.instance.addAttribute('normal', new THREE.BufferAttribute(normals, 3 )); - - //TODO: check below i don't do this - i used to but i don't think i should - this.instance.normalizeNormals(); - this.instance.computeVertexNormals(); - - /** - * Do faces setup - */ - this.faces = R3.Utils.SortFacesByMaterialIndex(this.faces); - - /** - * Setup material groups - this means creating a new group for each material index change - * We know faces are sorted according to material index - */ - var groupIndexCounts = this.faces.reduce( - function(result, face) { - - var currentGroup = result.pop(); - - if (currentGroup.index !== face.materialIndex) { - /** - * We have a new group - */ - result.push(currentGroup); - result.push({ - index: face.materialIndex, - count: 3 - }) - } else { - currentGroup.count += 3; - result.push(currentGroup); - } - - return result; - }, - [ - { - index : 0, - count : 0 - } - ] - ); - - groupIndexCounts.reduce( - function(start, group) { - this.instance.addGroup(start, group.count, group.index); - return start + group.count; - }.bind(this), - 0 - ); R3.D3.Geometry.prototype.createInstance.call(this); @@ -315,46 +129,14 @@ R3.D3.Geometry.Buffer.prototype.updateInstance = function(property) { }; -/** - * Converts a R3.D3.Geometry.Buffer to a R3.D3.API.Geometry.Buffer - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.prototype.toApiObject = function() { - - var apiGeometry = R3.D3.Geometry.prototype.toApiObject.call(this); - - /** - * Right now we don't store attributes and index, also we don't use morphAttributes yet. - * @type {R3.D3.API.Geometry.Buffer} - */ - - var apiBufferGeometry = new R3.D3.API.Geometry.Buffer( - - apiGeometry, - null, //attributes, - this.drawRange.toApiObject(), - this.groups.map( - function(group){ - if (group instanceof R3.Group) { - return group.toApiObject(); - } else { - return group; - } - } - ), - null, //index, - null //morphAttributes - ); - - return apiBufferGeometry; - -}; - /** * Update R3.D3.Geometry.Buffer from instance */ R3.D3.Geometry.Buffer.prototype.updateFromInstance = function() { + console.warn('todo: use case for R3.D3.Geometry.Buffer.prototype.updateFromInstance()'); + return; + this.faces = []; this.vertices = []; diff --git a/src/r3-d3-geometry-buffer-box.js b/src/r3-d3-geometry-buffer-box.js index 5920e29..ad081ba 100644 --- a/src/r3-d3-geometry-buffer-box.js +++ b/src/r3-d3-geometry-buffer-box.js @@ -1,39 +1,15 @@ /** * R3.D3.Geometry.Buffer.Box - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferBox + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Box = function( - graphics, - apiGeometryBufferBox + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferBox)) { - apiGeometryBufferBox = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_BOX - }; - } - - R3.D3.API.Geometry.Buffer.Box.call( - this, - apiGeometryBufferBox, - apiGeometryBufferBox.width, - apiGeometryBufferBox.height, - apiGeometryBufferBox.depth, - apiGeometryBufferBox.widthSegments, - apiGeometryBufferBox.heightSegments, - apiGeometryBufferBox.depthSegments - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferBox - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -46,18 +22,10 @@ R3.D3.Geometry.Buffer.Box.prototype.constructor = R3.D3.Geometry.Buffer.Box; */ R3.D3.Geometry.Buffer.Box.prototype.createInstance = function() { - this.instance = new THREE.BoxBufferGeometry( - this.width, - this.height, - this.depth, - this.widthSegments, - this.heightSegments, - this.depthSegments - ); - - this.instance.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferBox(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); + }; /** @@ -73,36 +41,9 @@ R3.D3.Geometry.Buffer.Box.prototype.updateInstance = function(property) { property === 'heightSegments' || property === 'depthSegments' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Box to a R3.D3.API.Geometry.Buffer.Box - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Box.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferBox = new R3.D3.API.Geometry.Buffer.Box( - apiBufferGeometry, - this.width, - this.height, - this.depth, - this.widthSegments, - this.heightSegments, - this.depthSegments - ); - - return apiGeometryBufferBox; -}; diff --git a/src/r3-d3-geometry-buffer-circle.js b/src/r3-d3-geometry-buffer-circle.js index 9c97ded..46ce0af 100644 --- a/src/r3-d3-geometry-buffer-circle.js +++ b/src/r3-d3-geometry-buffer-circle.js @@ -1,37 +1,15 @@ /** * R3.D3.Geometry.Buffer.Circle - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferCircle + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Circle = function( - graphics, - apiGeometryBufferCircle + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferCircle)) { - apiGeometryBufferCircle = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CIRCLE - }; - } - - R3.D3.API.Geometry.Buffer.Circle.call( - this, - apiGeometryBufferCircle, - apiGeometryBufferCircle.radius, - apiGeometryBufferCircle.segments, - apiGeometryBufferCircle.thetaStart, - apiGeometryBufferCircle.thetaLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferCircle - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -44,21 +22,10 @@ R3.D3.Geometry.Buffer.Circle.prototype.constructor = R3.D3.Geometry.Buffer.Circl */ R3.D3.Geometry.Buffer.Circle.prototype.createInstance = function() { - this.instance = new THREE.CircleBufferGeometry( - this.radius, - this.segments, - this.thetaStart, - this.thetaLength - ); - - /** - * The instance doesn't have any groups associated with it - so I just create the default single material group - */ - this.toSingleMaterial(); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferCircle(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); + }; /** @@ -72,39 +39,9 @@ R3.D3.Geometry.Buffer.Circle.prototype.updateInstance = function(property) { property === 'thetaStart' || property === 'thetaLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Circle to a R3.D3.API.Geometry.Buffer.Circle - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Circle.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferCircle = new R3.D3.API.Geometry.Buffer.Circle( - apiBufferGeometry, - this.radius, - this.segments, - this.thetaStart, - this.thetaLength - ); - - return apiGeometryBufferCircle; -}; diff --git a/src/r3-d3-geometry-buffer-cone.js b/src/r3-d3-geometry-buffer-cone.js index bc11074..3fa6ed1 100644 --- a/src/r3-d3-geometry-buffer-cone.js +++ b/src/r3-d3-geometry-buffer-cone.js @@ -1,40 +1,15 @@ /** * R3.D3.Geometry.Buffer.Cone - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferCone + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Cone = function( - graphics, - apiGeometryBufferCone + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferCone)) { - apiGeometryBufferCone = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CONE - }; - } - - R3.D3.API.Geometry.Buffer.Cone.call( - this, - apiGeometryBufferCone, - apiGeometryBufferCone.radius, - apiGeometryBufferCone.height, - apiGeometryBufferCone.radialSegments, - apiGeometryBufferCone.heightSegments, - apiGeometryBufferCone.openEnded, - apiGeometryBufferCone.thetaStart, - apiGeometryBufferCone.thetaLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferCone - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -47,19 +22,10 @@ R3.D3.Geometry.Buffer.Cone.prototype.constructor = R3.D3.Geometry.Buffer.Cone; */ R3.D3.Geometry.Buffer.Cone.prototype.createInstance = function() { - this.instance = new THREE.ConeBufferGeometry( - this.radius, - this.height, - this.radialSegments, - this.heightSegments, - this.openEnded, - this.thetaStart, - this.thetaLength - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferCone(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); + }; /** @@ -76,42 +42,9 @@ R3.D3.Geometry.Buffer.Cone.prototype.updateInstance = function(property) { property === 'thetaStart' || property === 'thetaLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Cone to a R3.D3.API.Geometry.Buffer.Cone - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Cone.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferCone = new R3.D3.API.Geometry.Buffer.Cone( - apiBufferGeometry, - this.radius, - this.height, - this.radialSegments, - this.heightSegments, - this.openEnded, - this.thetaStart, - this.thetaLength - ); - - return apiGeometryBufferCone; -}; diff --git a/src/r3-d3-geometry-buffer-cylinder.js b/src/r3-d3-geometry-buffer-cylinder.js index d2d42ef..540e0e5 100644 --- a/src/r3-d3-geometry-buffer-cylinder.js +++ b/src/r3-d3-geometry-buffer-cylinder.js @@ -1,41 +1,15 @@ /** * R3.D3.Geometry.Buffer.Cylinder - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferCylinder + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Cylinder = function( - graphics, - apiGeometryBufferCylinder + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferCylinder)) { - apiGeometryBufferCylinder = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_CYLINDER - }; - } - - R3.D3.API.Geometry.Buffer.Cylinder.call( - this, - apiGeometryBufferCylinder, - apiGeometryBufferCylinder.radiusTop, - apiGeometryBufferCylinder.radiusBottom, - apiGeometryBufferCylinder.height, - apiGeometryBufferCylinder.radialSegments, - apiGeometryBufferCylinder.heightSegments, - apiGeometryBufferCylinder.openEnded, - apiGeometryBufferCylinder.thetaStart, - apiGeometryBufferCylinder.thetaLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferCylinder - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -48,20 +22,10 @@ R3.D3.Geometry.Buffer.Cylinder.prototype.constructor = R3.D3.Geometry.Buffer.Cyl */ R3.D3.Geometry.Buffer.Cylinder.prototype.createInstance = function() { - this.instance = new THREE.CylinderBufferGeometry( - this.radiusTop, - this.radiusBottom, - this.height, - this.radialSegments, - this.heightSegments, - this.openEnded, - this.thetaStart, - this.thetaLength - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferCylinder(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); + }; /** @@ -79,43 +43,9 @@ R3.D3.Geometry.Buffer.Cylinder.prototype.updateInstance = function(property) { property === 'thetaStart' || property === 'thetaLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Cylinder to a R3.D3.API.Geometry.Buffer.Cylinder - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Cylinder.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferCylinder = new R3.D3.API.Geometry.Buffer.Cylinder( - apiBufferGeometry, - this.radiusTop, - this.radiusBottom, - this.height, - this.radialSegments, - this.heightSegments, - this.openEnded, - this.thetaStart, - this.thetaLength - ); - - return apiGeometryBufferCylinder; -}; diff --git a/src/r3-d3-geometry-buffer-dodecahedron.js b/src/r3-d3-geometry-buffer-dodecahedron.js index d2b2950..722b1e0 100644 --- a/src/r3-d3-geometry-buffer-dodecahedron.js +++ b/src/r3-d3-geometry-buffer-dodecahedron.js @@ -1,36 +1,15 @@ /** * R3.D3.Geometry.Buffer.Dodecahedron - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferDodecahedron + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Dodecahedron = function( - graphics, - apiGeometryBufferDodecahedron + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferDodecahedron)) { - apiGeometryBufferDodecahedron = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_DODECAHEDRON - }; - } - - R3.D3.API.Geometry.Buffer.Dodecahedron.call( - this, - apiGeometryBufferDodecahedron, - apiGeometryBufferDodecahedron.radius, - apiGeometryBufferDodecahedron.detail - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferDodecahedron - ); - + __RUNTIME_BUFFER_COMPONENT__; }; R3.D3.Geometry.Buffer.Dodecahedron.prototype = Object.create(R3.D3.Geometry.Buffer.prototype); @@ -42,18 +21,7 @@ R3.D3.Geometry.Buffer.Dodecahedron.prototype.constructor = R3.D3.Geometry.Buffer */ R3.D3.Geometry.Buffer.Dodecahedron.prototype.createInstance = function() { - this.instance = new THREE.DodecahedronBufferGeometry( - this.radius, - this.detail - ); - - this.instance.addGroup( - 0, - this.instance.attributes.position.count, - 0 - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferDodecahedron(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -67,37 +35,9 @@ R3.D3.Geometry.Buffer.Dodecahedron.prototype.updateInstance = function(property) property === 'radius' || property === 'detail' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Dodecahedron to a R3.D3.API.Geometry.Buffer.Dodecahedron - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Dodecahedron.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferDodecahedron = new R3.D3.API.Geometry.Buffer.Dodecahedron( - apiBufferGeometry, - this.radius, - this.detail - ); - - return apiGeometryBufferDodecahedron; -}; diff --git a/src/r3-d3-geometry-buffer-extrude.js b/src/r3-d3-geometry-buffer-extrude.js index b17bcb2..3ac3382 100644 --- a/src/r3-d3-geometry-buffer-extrude.js +++ b/src/r3-d3-geometry-buffer-extrude.js @@ -1,44 +1,15 @@ /** * R3.D3.Geometry.Buffer.Extrude - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferExtrude + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Extrude = function( - graphics, - apiGeometryBufferExtrude + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferExtrude)) { - apiGeometryBufferExtrude = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_EXTRUDE - }; - } - - R3.D3.API.Geometry.Buffer.Extrude.call( - this, - apiGeometryBufferExtrude, - apiGeometryBufferExtrude.shapes, - apiGeometryBufferExtrude.curveSegments, - apiGeometryBufferExtrude.steps, - apiGeometryBufferExtrude.amount, - apiGeometryBufferExtrude.bevelEnabled, - apiGeometryBufferExtrude.bevelThickness, - apiGeometryBufferExtrude.bevelSize, - apiGeometryBufferExtrude.bevelSegments, - apiGeometryBufferExtrude.extrudePath, - apiGeometryBufferExtrude.frames, - apiGeometryBufferExtrude.UVGenerator - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferExtrude - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -51,29 +22,7 @@ R3.D3.Geometry.Buffer.Extrude.prototype.constructor = R3.D3.Geometry.Buffer.Extr */ R3.D3.Geometry.Buffer.Extrude.prototype.createInstance = function() { - if (this.shapes.length === 0) { - console.warn('shapes are not ready for this instance'); - return; - } - - this.instance = new THREE.ExtrudeBufferGeometry( - this.shapes.map( - function(shape) { - return shape.instance; - } - ), - { - curveSegments : this.curveSegments, - steps : this.steps, - amount : this.amount, - bevelEnabled : this.bevelEnabled, - bevelThickness : this.bevelThickness, - bevelSize : this.bevelSize, - bevelSegments : this.bevelSegments - } - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferExtrude(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -93,54 +42,9 @@ R3.D3.Geometry.Buffer.Extrude.prototype.updateInstance = function(property) { property === 'bevelSize' || property === 'bevelSegments' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } - console.warn('do other properties here'); - R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Extrude to a R3.D3.API.Geometry.Buffer.Extrude - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Extrude.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferExtrude = new R3.D3.API.Geometry.Buffer.Extrude( - apiBufferGeometry, - this.shapes.map( - function(shape) { - return R3.Utils.IdOrNull(shape); - } - ), - this.curveSegments, - this.steps, - this.amount, - this.bevelEnabled, - this.bevelThickness, - this.bevelSize, - this.bevelSegments, - R3.Utils.IdOrNull(this.extrudePath), - this.frames.map(function(frame){ - return R3.Utils.IdOrNull(frame); - }), - R3.Utils.IdOrNull(this.UVGenerator) - ); - - return apiGeometryBufferExtrude; -}; diff --git a/src/r3-d3-geometry-buffer-icosahedron.js b/src/r3-d3-geometry-buffer-icosahedron.js index 6a9cd15..09e1b04 100644 --- a/src/r3-d3-geometry-buffer-icosahedron.js +++ b/src/r3-d3-geometry-buffer-icosahedron.js @@ -1,35 +1,15 @@ /** * R3.D3.Geometry.Buffer.Icosahedron - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferIcosahedron + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Icosahedron = function( - graphics, - apiGeometryBufferIcosahedron + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferIcosahedron)) { - apiGeometryBufferIcosahedron = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_ICOSAHEDRON - }; - } - - R3.D3.API.Geometry.Buffer.Icosahedron.call( - this, - apiGeometryBufferIcosahedron, - apiGeometryBufferIcosahedron.radius, - apiGeometryBufferIcosahedron.detail - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferIcosahedron - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -42,18 +22,7 @@ R3.D3.Geometry.Buffer.Icosahedron.prototype.constructor = R3.D3.Geometry.Buffer. */ R3.D3.Geometry.Buffer.Icosahedron.prototype.createInstance = function() { - this.instance = new THREE.IcosahedronBufferGeometry( - this.radius, - this.detail - ); - - this.instance.addGroup( - 0, - this.instance.attributes.position.count, - 0 - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferIcosahedron(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -67,37 +36,9 @@ R3.D3.Geometry.Buffer.Icosahedron.prototype.updateInstance = function(property) property === 'radius' || property === 'detail' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Icosahedron to a R3.D3.API.Geometry.Buffer.Icosahedron - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Icosahedron.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferIcosahedron = new R3.D3.API.Geometry.Buffer.Icosahedron( - apiBufferGeometry, - this.radius, - this.detail - ); - - return apiGeometryBufferIcosahedron; -}; diff --git a/src/r3-d3-geometry-buffer-instanced.js b/src/r3-d3-geometry-buffer-instanced.js index ad4d04a..16e121c 100644 --- a/src/r3-d3-geometry-buffer-instanced.js +++ b/src/r3-d3-geometry-buffer-instanced.js @@ -1,34 +1,15 @@ /** * R3.D3.Geometry.Buffer.Instanced - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferInstanced * @constructor + * @param apiComponent */ R3.D3.Geometry.Buffer.Instanced = function( - graphics, - apiGeometryBufferInstanced + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferInstanced)) { - apiGeometryBufferInstanced = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_INSTANCED - }; - } - - R3.D3.API.Geometry.Buffer.Instanced.call( - this, - apiGeometryBufferInstanced, - apiGeometryBufferInstanced.maxInstancedCount - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferInstanced - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -41,11 +22,9 @@ R3.D3.Geometry.Buffer.Instanced.prototype.constructor = R3.D3.Geometry.Buffer.In */ R3.D3.Geometry.Buffer.Instanced.prototype.createInstance = function() { - this.instance = new THREE.InstancedBufferGeometry(); + console.warn('todo: implement this fully'); - if (R3.Utils.Defined(this.maxInstancedCount)) { - this.instance.maxInstancedCount = this.maxInstancedCount; - } + this.instance = this.graphics.GeometryBufferInstanced(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -64,19 +43,3 @@ R3.D3.Geometry.Buffer.Instanced.prototype.updateInstance = function(property) { R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Instanced to a R3.D3.API.Geometry.Buffer.Instanced - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Instanced.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferInstanced = new R3.D3.API.Geometry.Buffer.Instanced( - apiBufferGeometry, - this.maxInstancedCount - ); - - return apiGeometryBufferInstanced; -}; diff --git a/src/r3-d3-geometry-buffer-lathe.js b/src/r3-d3-geometry-buffer-lathe.js index e832bc1..d25ddd2 100644 --- a/src/r3-d3-geometry-buffer-lathe.js +++ b/src/r3-d3-geometry-buffer-lathe.js @@ -1,38 +1,16 @@ /** * R3.D3.Geometry.Buffer.Lathe - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferLathe + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Lathe = function( - graphics, - apiGeometryBufferLathe + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferLathe)) { - apiGeometryBufferLathe = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_LATHE - }; - } + __RUNTIME_BUFFER_COMPONENT__; - R3.D3.API.Geometry.Buffer.Lathe.call( - this, - apiGeometryBufferLathe, - apiGeometryBufferLathe.points, - apiGeometryBufferLathe.segments, - apiGeometryBufferLathe.phiStart, - apiGeometryBufferLathe.phiLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferLathe - ); - }; R3.D3.Geometry.Buffer.Lathe.prototype = Object.create(R3.D3.Geometry.Buffer.prototype); @@ -44,23 +22,7 @@ R3.D3.Geometry.Buffer.Lathe.prototype.constructor = R3.D3.Geometry.Buffer.Lathe; */ R3.D3.Geometry.Buffer.Lathe.prototype.createInstance = function() { - this.instance = new THREE.LatheBufferGeometry( - this.points.map( - function(point) { - return point.instance; - } - ), - this.segments, - this.phiStart, - this.phiLength - ); - - /** - * The instance doesn't have any groups associated with it - so I just create the default single material group - */ - this.toSingleMaterial(); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferLathe(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -76,43 +38,9 @@ R3.D3.Geometry.Buffer.Lathe.prototype.updateInstance = function(property) { property === 'phiStart' || property === 'phiLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Lathe to a R3.D3.API.Geometry.Buffer.Lathe - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Lathe.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferLathe = new R3.D3.API.Geometry.Buffer.Lathe( - apiBufferGeometry, - this.points.map( - function(point) { - return point.toApiObject(); - } - ), - this.segments, - this.phiStart, - this.phiLength - ); - - return apiGeometryBufferLathe; -}; diff --git a/src/r3-d3-geometry-buffer-octahedron.js b/src/r3-d3-geometry-buffer-octahedron.js index 4030c07..5fdb7c2 100644 --- a/src/r3-d3-geometry-buffer-octahedron.js +++ b/src/r3-d3-geometry-buffer-octahedron.js @@ -1,35 +1,15 @@ /** * R3.D3.Geometry.Buffer.Octahedron - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferOctahedron * @constructor + * @param apiComponent */ R3.D3.Geometry.Buffer.Octahedron = function( - graphics, - apiGeometryBufferOctahedron + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferOctahedron)) { - apiGeometryBufferOctahedron = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_OCTAHEDRON - }; - } - - R3.D3.API.Geometry.Buffer.Octahedron.call( - this, - apiGeometryBufferOctahedron, - apiGeometryBufferOctahedron.radius, - apiGeometryBufferOctahedron.detail - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferOctahedron - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -42,18 +22,7 @@ R3.D3.Geometry.Buffer.Octahedron.prototype.constructor = R3.D3.Geometry.Buffer.O */ R3.D3.Geometry.Buffer.Octahedron.prototype.createInstance = function() { - this.instance = new THREE.OctahedronBufferGeometry( - this.radius, - this.detail - ); - - this.instance.addGroup( - 0, - this.instance.attributes.position.count, - 0 - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferOctahedron(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -67,37 +36,9 @@ R3.D3.Geometry.Buffer.Octahedron.prototype.updateInstance = function(property) { property === 'radius' || property === 'detail' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Octahedron to a R3.D3.API.Geometry.Buffer.Octahedron - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Octahedron.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferOctahedron = new R3.D3.API.Geometry.Buffer.Octahedron( - apiBufferGeometry, - this.radius, - this.detail - ); - - return apiGeometryBufferOctahedron; -}; diff --git a/src/r3-d3-geometry-buffer-parametric.js b/src/r3-d3-geometry-buffer-parametric.js index 1d82c5b..18e25ac 100644 --- a/src/r3-d3-geometry-buffer-parametric.js +++ b/src/r3-d3-geometry-buffer-parametric.js @@ -1,36 +1,15 @@ /** * R3.D3.Geometry.Buffer.Parametric - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferParametric + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Parametric = function( - graphics, - apiGeometryBufferParametric + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferParametric)) { - apiGeometryBufferParametric = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PARAMETRIC - }; - } - - R3.D3.API.Geometry.Buffer.Parametric.call( - this, - apiGeometryBufferParametric, - apiGeometryBufferParametric.generatorFn, - apiGeometryBufferParametric.slices, - apiGeometryBufferParametric.stacks - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferParametric - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -43,19 +22,7 @@ R3.D3.Geometry.Buffer.Parametric.prototype.constructor = R3.D3.Geometry.Buffer.P */ R3.D3.Geometry.Buffer.Parametric.prototype.createInstance = function() { - this.instance = new THREE.ParametricBufferGeometry( - new Function('u', 'v', this.generatorFn).bind(this), - this.slices, - this.stacks - ); - - this.instance.addGroup( - 0, - this.instance.attributes.position.count, - 0 - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferParametric(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -70,38 +37,9 @@ R3.D3.Geometry.Buffer.Parametric.prototype.updateInstance = function(property) { property === 'slices' || property === 'stacks' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Parametric to a R3.D3.API.Geometry.Buffer.Parametric - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Parametric.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferParametric = new R3.D3.API.Geometry.Buffer.Parametric( - apiBufferGeometry, - this.generatorFn, - this.slices, - this.stacks - ); - - return apiGeometryBufferParametric; -}; diff --git a/src/r3-d3-geometry-buffer-plane.js b/src/r3-d3-geometry-buffer-plane.js index 3c60910..eb6f7ea 100644 --- a/src/r3-d3-geometry-buffer-plane.js +++ b/src/r3-d3-geometry-buffer-plane.js @@ -1,37 +1,15 @@ /** * R3.D3.Geometry.Buffer.Plane - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferPlane + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Plane = function( - graphics, - apiGeometryBufferPlane + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferPlane)) { - apiGeometryBufferPlane = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_PLANE - }; - } - - R3.D3.API.Geometry.Buffer.Plane.call( - this, - apiGeometryBufferPlane, - apiGeometryBufferPlane.width, - apiGeometryBufferPlane.height, - apiGeometryBufferPlane.widthSegments, - apiGeometryBufferPlane.heightSegments - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferPlane - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -44,14 +22,7 @@ R3.D3.Geometry.Buffer.Plane.prototype.constructor = R3.D3.Geometry.Buffer.Plane; */ R3.D3.Geometry.Buffer.Plane.prototype.createInstance = function() { - this.instance = new THREE.PlaneBufferGeometry( - this.width, - this.height, - this.widthSegments, - this.heightSegments - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferPlane(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -67,34 +38,9 @@ R3.D3.Geometry.Buffer.Plane.prototype.updateInstance = function(property) { property === 'widthSegments' || property === 'heightSegments' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Plane to a R3.D3.API.Geometry.Buffer.Plane - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Plane.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferPlane = new R3.D3.API.Geometry.Buffer.Plane( - apiBufferGeometry, - this.width, - this.height, - this.widthSegments, - this.heightSegments - ); - - return apiGeometryBufferPlane; -}; diff --git a/src/r3-d3-geometry-buffer-polyhedron.js b/src/r3-d3-geometry-buffer-polyhedron.js index 50b9b7e..ed543a5 100644 --- a/src/r3-d3-geometry-buffer-polyhedron.js +++ b/src/r3-d3-geometry-buffer-polyhedron.js @@ -1,37 +1,15 @@ /** * R3.D3.Geometry.Buffer.Polyhedron - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferPolyhedron + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Polyhedron = function( - graphics, - apiGeometryBufferPolyhedron + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferPolyhedron)) { - apiGeometryBufferPolyhedron = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_POLYHEDRON - }; - } - - R3.D3.API.Geometry.Buffer.Polyhedron.call( - this, - apiGeometryBufferPolyhedron, - apiGeometryBufferPolyhedron.vertices, - apiGeometryBufferPolyhedron.indices, - apiGeometryBufferPolyhedron.radius, - apiGeometryBufferPolyhedron.detail - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferPolyhedron - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -44,22 +22,7 @@ R3.D3.Geometry.Buffer.Polyhedron.prototype.constructor = R3.D3.Geometry.Buffer.P */ R3.D3.Geometry.Buffer.Polyhedron.prototype.createInstance = function() { - this.instance = new THREE.PolyhedronBufferGeometry( - this.vertices.map( - function(vertex) { - return vertex.position.instance; - } - ), - this.indices.map( - function(index) { - return index.instance; - } - ), - this.radius, - this.detail - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferPolyhedron(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -75,42 +38,9 @@ R3.D3.Geometry.Buffer.Polyhedron.prototype.updateInstance = function(property) { property === 'radius' || property === 'detail' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Polyhedron to a R3.D3.API.Geometry.Buffer.Polyhedron - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Polyhedron.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferPolyhedron = new R3.D3.API.Geometry.Buffer.Polyhedron( - apiBufferGeometry, - this.vertices.map( - function(vertex){ - return vertex.toApiObject(); - } - ), - this.indices.map( - function(index){ - return index.toApiObject(); - } - ), - this.radius, - this.detail - ); - - return apiGeometryBufferPolyhedron; -}; diff --git a/src/r3-d3-geometry-buffer-ring.js b/src/r3-d3-geometry-buffer-ring.js index 5a92ed7..439cd4c 100644 --- a/src/r3-d3-geometry-buffer-ring.js +++ b/src/r3-d3-geometry-buffer-ring.js @@ -1,39 +1,15 @@ /** * R3.D3.Geometry.Buffer.Ring - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferRing + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Ring = function( - graphics, - apiGeometryBufferRing + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferRing)) { - apiGeometryBufferRing = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_RING - }; - } - - R3.D3.API.Geometry.Buffer.Ring.call( - this, - apiGeometryBufferRing, - apiGeometryBufferRing.innerRadius, - apiGeometryBufferRing.outerRadius, - apiGeometryBufferRing.thetaSegments, - apiGeometryBufferRing.phiSegments, - apiGeometryBufferRing.thetaStart, - apiGeometryBufferRing.thetaLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferRing - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -46,16 +22,7 @@ R3.D3.Geometry.Buffer.Ring.prototype.constructor = R3.D3.Geometry.Buffer.Ring; */ R3.D3.Geometry.Buffer.Ring.prototype.createInstance = function() { - this.instance = new THREE.RingBufferGeometry( - this.innerRadius, - this.outerRadius, - this.thetaSegments, - this.phiSegments, - this.thetaStart, - this.thetaLength - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferRing(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -73,41 +40,9 @@ R3.D3.Geometry.Buffer.Ring.prototype.updateInstance = function(property) { property === 'thetaStart' || property === 'thetaLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Ring to a R3.D3.API.Geometry.Buffer.Ring - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Ring.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferRing = new R3.D3.API.Geometry.Buffer.Ring( - apiBufferGeometry, - this.innerRadius, - this.outerRadius, - this.thetaSegments, - this.phiSegments, - this.thetaStart, - this.thetaLength - ); - - return apiGeometryBufferRing; -}; diff --git a/src/r3-d3-geometry-buffer-shape.js b/src/r3-d3-geometry-buffer-shape.js index f0ac1fe..272f4fb 100644 --- a/src/r3-d3-geometry-buffer-shape.js +++ b/src/r3-d3-geometry-buffer-shape.js @@ -1,35 +1,15 @@ /** * R3.D3.Geometry.Buffer.Shape - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferShape + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Shape = function( - graphics, - apiGeometryBufferShape + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferShape)) { - apiGeometryBufferShape = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SHAPE - }; - } - - R3.D3.API.Geometry.Buffer.Shape.call( - this, - apiGeometryBufferShape, - apiGeometryBufferShape.shapes, - apiGeometryBufferShape.curveSegments - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferShape - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -42,21 +22,7 @@ R3.D3.Geometry.Buffer.Shape.prototype.constructor = R3.D3.Geometry.Buffer.Shape; */ R3.D3.Geometry.Buffer.Shape.prototype.createInstance = function() { - if (this.shapes.length === 0) { - console.warn('shapes are not ready for this instance'); - return; - } - - this.instance = new THREE.ShapeBufferGeometry( - this.shapes.map( - function(shape) { - return shape.instance; - } - ), - this.curveSegments - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferShape(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -70,43 +36,9 @@ R3.D3.Geometry.Buffer.Shape.prototype.updateInstance = function(property) { property === 'shapes' || property === 'curveSegments' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } - console.warn('do other properties here'); - R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Shape to a R3.D3.API.Geometry.Buffer.Shape - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Shape.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferShape = new R3.D3.API.Geometry.Buffer.Shape( - apiBufferGeometry, - this.shapes.map( - function(shape) { - return R3.Utils.IdOrNull(shape); - } - ), - this.curveSegments - ); - - return apiGeometryBufferShape; -}; diff --git a/src/r3-d3-geometry-buffer-sphere.js b/src/r3-d3-geometry-buffer-sphere.js index c737c37..aa06e22 100644 --- a/src/r3-d3-geometry-buffer-sphere.js +++ b/src/r3-d3-geometry-buffer-sphere.js @@ -1,40 +1,15 @@ /** * R3.D3.Geometry.Buffer.Sphere - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferSphere + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Sphere = function( - graphics, - apiGeometryBufferSphere + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferSphere)) { - apiGeometryBufferSphere = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_SPHERE - }; - } - - R3.D3.API.Geometry.Buffer.Sphere.call( - this, - apiGeometryBufferSphere, - apiGeometryBufferSphere.radius, - apiGeometryBufferSphere.widthSegments, - apiGeometryBufferSphere.heightSegments, - apiGeometryBufferSphere.phiStart, - apiGeometryBufferSphere.phiLength, - apiGeometryBufferSphere.thetaStart, - apiGeometryBufferSphere.thetaLength - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferSphere - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -47,17 +22,7 @@ R3.D3.Geometry.Buffer.Sphere.prototype.constructor = R3.D3.Geometry.Buffer.Spher */ R3.D3.Geometry.Buffer.Sphere.prototype.createInstance = function() { - this.instance = new THREE.SphereBufferGeometry( - this.radius, - this.widthSegments, - this.heightSegments, - this.phiStart, - this.phiLength, - this.thetaStart, - this.thetaLength - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferSphere(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -76,42 +41,9 @@ R3.D3.Geometry.Buffer.Sphere.prototype.updateInstance = function(property) { property === 'thetaStart' || property === 'thetaLength' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Sphere to a R3.D3.API.Geometry.Buffer.Sphere - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Sphere.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferSphere = new R3.D3.API.Geometry.Buffer.Sphere( - apiBufferGeometry, - this.radius, - this.widthSegments, - this.heightSegments, - this.phiStart, - this.phiLength, - this.thetaStart, - this.thetaLength - ); - - return apiGeometryBufferSphere; -}; diff --git a/src/r3-d3-geometry-buffer-tetrahedron.js b/src/r3-d3-geometry-buffer-tetrahedron.js index 1a629f1..e65fea8 100644 --- a/src/r3-d3-geometry-buffer-tetrahedron.js +++ b/src/r3-d3-geometry-buffer-tetrahedron.js @@ -1,35 +1,15 @@ /** * R3.D3.Geometry.Buffer.Tetrahedron - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferTetrahedron + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Tetrahedron = function( - graphics, - apiGeometryBufferTetrahedron + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferTetrahedron)) { - apiGeometryBufferTetrahedron = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TETRAHEDRON - }; - } - - R3.D3.API.Geometry.Buffer.Tetrahedron.call( - this, - apiGeometryBufferTetrahedron, - apiGeometryBufferTetrahedron.radius, - apiGeometryBufferTetrahedron.detail - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferTetrahedron - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -42,18 +22,7 @@ R3.D3.Geometry.Buffer.Tetrahedron.prototype.constructor = R3.D3.Geometry.Buffer. */ R3.D3.Geometry.Buffer.Tetrahedron.prototype.createInstance = function() { - this.instance = new THREE.TetrahedronBufferGeometry( - this.radius, - this.detail - ); - - this.instance.addGroup( - 0, - this.instance.attributes.position.count, - 0 - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferTetrahedron(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -67,37 +36,9 @@ R3.D3.Geometry.Buffer.Tetrahedron.prototype.updateInstance = function(property) property === 'radius' || property === 'detail' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Tetrahedron to a R3.D3.API.Geometry.Buffer.Tetrahedron - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Tetrahedron.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferTetrahedron = new R3.D3.API.Geometry.Buffer.Tetrahedron( - apiBufferGeometry, - this.radius, - this.detail - ); - - return apiGeometryBufferTetrahedron; -}; diff --git a/src/r3-d3-geometry-buffer-text.js b/src/r3-d3-geometry-buffer-text.js index dc75ce4..02a4eb2 100644 --- a/src/r3-d3-geometry-buffer-text.js +++ b/src/r3-d3-geometry-buffer-text.js @@ -1,42 +1,15 @@ /** * R3.D3.Geometry.Buffer.Text - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferText + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Text = function( - graphics, - apiGeometryBufferText + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferText)) { - apiGeometryBufferText = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TEXT - }; - } - - R3.D3.API.Geometry.Buffer.Text.call( - this, - apiGeometryBufferText, - apiGeometryBufferText.text, - apiGeometryBufferText.font, - apiGeometryBufferText.size, - apiGeometryBufferText.height, - apiGeometryBufferText.curveSegments, - apiGeometryBufferText.bevelEnabled, - apiGeometryBufferText.bevelThickness, - apiGeometryBufferText.bevelSize, - apiGeometryBufferText.bevelSegments - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferText - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -49,27 +22,7 @@ R3.D3.Geometry.Buffer.Text.prototype.constructor = R3.D3.Geometry.Buffer.Text; */ R3.D3.Geometry.Buffer.Text.prototype.createInstance = function() { - if (!this.font || !this.font.instance) { - console.warn('font not ready for this instance'); - return; - } - - this.instance = new THREE.TextBufferGeometry( - this.text, - { - font : this.font.instance, - size : this.size, - curveSegments : this.curveSegments, - steps : this.steps, - amount : this.amount, - bevelEnabled : this.bevelEnabled, - bevelThickness : this.bevelThickness, - bevelSize : this.bevelSize, - bevelSegments : this.bevelSegments - } - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferText(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -90,25 +43,7 @@ R3.D3.Geometry.Buffer.Text.prototype.updateInstance = function(property) { property === 'bevelSize' || property === 'bevelSegments' ) { - - /** - * Could be that the instance does not exist - because font was not ready - */ - if (this.instance) { - this.instance.dispose(); - } - - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } @@ -116,27 +51,3 @@ R3.D3.Geometry.Buffer.Text.prototype.updateInstance = function(property) { R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Text to a R3.D3.API.Geometry.Buffer.Text - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Text.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferText = new R3.D3.API.Geometry.Buffer.Text( - apiBufferGeometry, - this.text, - R3.Utils.IdOrNull(this.font), - this.size, - this.height, - this.curveSegments, - this.bevelEnabled, - this.bevelThickness, - this.bevelSize, - this.bevelSegments - ); - - return apiGeometryBufferText; -}; diff --git a/src/r3-d3-geometry-buffer-torus-knot.js b/src/r3-d3-geometry-buffer-torus-knot.js deleted file mode 100644 index 8c3d561..0000000 --- a/src/r3-d3-geometry-buffer-torus-knot.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - * R3.D3.Geometry.Buffer.TorusKnot - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferTorusKnot - * @constructor - */ -R3.D3.Geometry.Buffer.TorusKnot = function( - graphics, - apiGeometryBufferTorusKnot -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiGeometryBufferTorusKnot)) { - apiGeometryBufferTorusKnot = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS_KNOT - }; - } - - R3.D3.API.Geometry.Buffer.TorusKnot.call( - this, - apiGeometryBufferTorusKnot, - apiGeometryBufferTorusKnot.radius, - apiGeometryBufferTorusKnot.tube, - apiGeometryBufferTorusKnot.radialSegments, - apiGeometryBufferTorusKnot.tubularSegments, - apiGeometryBufferTorusKnot.p, - apiGeometryBufferTorusKnot.q - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferTorusKnot - ); - -}; - -R3.D3.Geometry.Buffer.TorusKnot.prototype = Object.create(R3.D3.Geometry.Buffer.prototype); -R3.D3.Geometry.Buffer.TorusKnot.prototype.constructor = R3.D3.Geometry.Buffer.TorusKnot; - -/** - * Creates a light instance - * @returns {*} - */ -R3.D3.Geometry.Buffer.TorusKnot.prototype.createInstance = function() { - - this.instance = new THREE.TorusKnotBufferGeometry( - this.radius, - this.tube, - this.radialSegments, - this.tubularSegments, - this.p, - this.q - ); - - this.computeVertexNormals(); - - R3.D3.Geometry.Buffer.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Geometry.Buffer.TorusKnot.prototype.updateInstance = function(property) { - - if ( - property === 'radius' || - property === 'tube' || - property === 'radialSegments' || - property === 'tubularSegments' || - property === 'p' || - property === 'q' - ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - - return; - } - - R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Geometry.Buffer.TorusKnot to a R3.D3.API.Geometry.Buffer.TorusKnot - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.TorusKnot.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferTorusKnot = new R3.D3.API.Geometry.Buffer.TorusKnot( - apiBufferGeometry, - this.radius, - this.tube, - this.radialSegments, - this.tubularSegments, - this.p, - this.q - ); - - return apiGeometryBufferTorusKnot; -}; diff --git a/src/r3-d3-geometry-buffer-torus.js b/src/r3-d3-geometry-buffer-torus.js index d56fcb4..1bdacf8 100644 --- a/src/r3-d3-geometry-buffer-torus.js +++ b/src/r3-d3-geometry-buffer-torus.js @@ -1,38 +1,15 @@ /** * R3.D3.Geometry.Buffer.Torus - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferTorus + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Torus = function( - graphics, - apiGeometryBufferTorus + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferTorus)) { - apiGeometryBufferTorus = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TORUS - }; - } - - R3.D3.API.Geometry.Buffer.Torus.call( - this, - apiGeometryBufferTorus, - apiGeometryBufferTorus.radius, - apiGeometryBufferTorus.tube, - apiGeometryBufferTorus.radialSegments, - apiGeometryBufferTorus.tubularSegments, - apiGeometryBufferTorus.arc - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferTorus - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -45,15 +22,7 @@ R3.D3.Geometry.Buffer.Torus.prototype.constructor = R3.D3.Geometry.Buffer.Torus; */ R3.D3.Geometry.Buffer.Torus.prototype.createInstance = function() { - this.instance = new THREE.TorusBufferGeometry( - this.radius, - this.tube, - this.radialSegments, - this.tubularSegments, - this.arc - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferTorus(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -70,40 +39,9 @@ R3.D3.Geometry.Buffer.Torus.prototype.updateInstance = function(property) { property === 'tubularSegments' || property === 'arc' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Torus to a R3.D3.API.Geometry.Buffer.Torus - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Torus.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferTorus = new R3.D3.API.Geometry.Buffer.Torus( - apiBufferGeometry, - this.radius, - this.tube, - this.radialSegments, - this.tubularSegments, - this.arc - ); - - return apiGeometryBufferTorus; -}; diff --git a/src/r3-d3-geometry-buffer-torusKnot.js b/src/r3-d3-geometry-buffer-torusKnot.js new file mode 100644 index 0000000..3ffd406 --- /dev/null +++ b/src/r3-d3-geometry-buffer-torusKnot.js @@ -0,0 +1,48 @@ +/** + * R3.D3.Geometry.Buffer.TorusKnot + * @param apiComponent + * @constructor + */ +R3.D3.Geometry.Buffer.TorusKnot = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + __RUNTIME_BUFFER_COMPONENT__; + +}; + +R3.D3.Geometry.Buffer.TorusKnot.prototype = Object.create(R3.D3.Geometry.Buffer.prototype); +R3.D3.Geometry.Buffer.TorusKnot.prototype.constructor = R3.D3.Geometry.Buffer.TorusKnot; + +/** + * Creates a light instance + * @returns {*} + */ +R3.D3.Geometry.Buffer.TorusKnot.prototype.createInstance = function() { + + this.instance = this.graphics.GeometryBufferTorusKnot(this); + + R3.D3.Geometry.Buffer.prototype.createInstance.call(this); +}; + +/** + * Updates the instance with the current state + */ +R3.D3.Geometry.Buffer.TorusKnot.prototype.updateInstance = function(property) { + + if ( + property === 'radius' || + property === 'tube' || + property === 'radialSegments' || + property === 'tubularSegments' || + property === 'p' || + property === 'q' + ) { + this.instance = this.createInstance(); + return; + } + + R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-d3-geometry-buffer-tube.js b/src/r3-d3-geometry-buffer-tube.js index a379d15..1c7122c 100644 --- a/src/r3-d3-geometry-buffer-tube.js +++ b/src/r3-d3-geometry-buffer-tube.js @@ -1,38 +1,15 @@ /** * R3.D3.Geometry.Buffer.Tube - * @param graphics R3.Runtime.Graphics - * @param apiGeometryBufferTube + * @param apiComponent * @constructor */ R3.D3.Geometry.Buffer.Tube = function( - graphics, - apiGeometryBufferTube + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiGeometryBufferTube)) { - apiGeometryBufferTube = { - geometryType : R3.D3.API.Geometry.GEOMETRY_TYPE_BUFFER_TUBE - }; - } - - R3.D3.API.Geometry.Buffer.Tube.call( - this, - apiGeometryBufferTube, - apiGeometryBufferTube.path, - apiGeometryBufferTube.tubularSegments, - apiGeometryBufferTube.radius, - apiGeometryBufferTube.radialSegments, - apiGeometryBufferTube.closed - ); - - R3.D3.Geometry.Buffer.call( - this, - this.graphics, - apiGeometryBufferTube - ); + __RUNTIME_BUFFER_COMPONENT__; }; @@ -45,15 +22,7 @@ R3.D3.Geometry.Buffer.Tube.prototype.constructor = R3.D3.Geometry.Buffer.Tube; */ R3.D3.Geometry.Buffer.Tube.prototype.createInstance = function() { - this.instance = new THREE.TubeBufferGeometry( - this.path.instance, - this.tubularSegments, - this.radius, - this.radialSegments, - this.closed - ); - - this.computeVertexNormals(); + this.instance = this.graphics.GeometryBufferTube(this); R3.D3.Geometry.Buffer.prototype.createInstance.call(this); }; @@ -70,40 +39,9 @@ R3.D3.Geometry.Buffer.Tube.prototype.updateInstance = function(property) { property === 'radialSegments' || property === 'closed' ) { - this.instance.dispose(); - this.createInstance(); - - if (this.parentMesh && this.parentMesh.instance) { - this.parentMesh.instance.geometry = this.instance; - - if (this.parentMesh.helper) { - this.parentMesh.removeHelper(); - this.parentMesh.createHelper(); - } - } - + this.instance = this.createInstance(); return; } R3.D3.Geometry.Buffer.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Geometry.Buffer.Tube to a R3.D3.API.Geometry.Buffer.Tube - * @returns {R3.D3.API.Geometry.Buffer} - */ -R3.D3.Geometry.Buffer.Tube.prototype.toApiObject = function() { - - var apiBufferGeometry = R3.D3.Geometry.Buffer.prototype.toApiObject.call(this); - - var apiGeometryBufferTube = new R3.D3.API.Geometry.Buffer.Tube( - apiBufferGeometry, - R3.Utils.IdOrNull(this.path), - this.tubularSegments, - this.radius, - this.radialSegments, - this.closed - ); - - return apiGeometryBufferTube; -}; diff --git a/src/r3-d3-geometry-normal-a.js b/src/r3-d3-geometry-normal-0.js similarity index 97% rename from src/r3-d3-geometry-normal-a.js rename to src/r3-d3-geometry-normal-0.js index 1ea5516..f1d701e 100644 --- a/src/r3-d3-geometry-normal-a.js +++ b/src/r3-d3-geometry-normal-0.js @@ -508,4 +508,12 @@ R3.D3.Geometry.Normal.prototype.invertWindingOrder = function() { this.instance.normalsNeedUpdate = true; } -}; \ No newline at end of file +}; + +R3.D3.API.Geometry.Normal.prototype.updateNormals = function() { + console.warn('todo: R3.D3.API.Geometry.Normal.prototype.updateNormals'); +}; + +R3.D3.API.Geometry.Normal.prototype.updatePositions = function() { + console.warn('todo: R3.D3.API.Geometry.Normal.prototype.updatePositions'); +}; diff --git a/src/r3-d3-geometry-normal-torus-knot.js b/src/r3-d3-geometry-normal-torusKnot.js similarity index 100% rename from src/r3-d3-geometry-normal-torus-knot.js rename to src/r3-d3-geometry-normal-torusKnot.js diff --git a/src/r3-d3-helper.js b/src/r3-d3-helper.js index b602128..5a25740 100644 --- a/src/r3-d3-helper.js +++ b/src/r3-d3-helper.js @@ -1,142 +1,34 @@ /** - * Helpers for displaying outlines or making 'invisible' scene objects visible - * @param graphics R3.Runtime.Graphics - * @param id - * @param name - * @param object - * @param helperType - * @param parent + * R3.D3.Helper + * @param apiComponent * @constructor */ R3.D3.Helper = function( - graphics, - id, - name, - object, - helperType, - parent + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(id)) { - id = R3.Utils.RandomId(); - } - this.id = id; + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(name)) { - name = 'Helper (' + id + ')'; - } - this.name = name; + __UPGRADE_TO_RUNTIME__; - if (R3.Utils.UndefinedOrNull(object)) { - console.warn('Cannot create a helper for an Object which does not exist'); - throw new Error('Cannot create a helper for an Object which does not exist'); - } - this.object = object; - - if (R3.Utils.UndefinedOrNull(helperType)) { - - helperType = R3.D3.Helper.HELPER_TYPE_NONE; - - if ( - object instanceof R3.D3.Mesh && - object.meshType !== R3.D3.API.Object.OBJECT_TYPE_MESH_CURVE - ) { - helperType = R3.D3.Helper.HELPER_TYPE_EDGES; - } - - if (object instanceof R3.D3.Light) { - if (object.lightType === R3.D3.API.Light.LIGHT_TYPE_DIRECTIONAL) { - helperType = R3.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT; - } - - if (object.lightType === R3.D3.API.Light.LIGHT_TYPE_POINT) { - helperType = R3.D3.Helper.HELPER_TYPE_POINT_LIGHT; - } - - if (object.lightType === R3.D3.API.Light.LIGHT_TYPE_SPOT) { - helperType = R3.D3.Helper.HELPER_TYPE_SPOT_LIGHT; - } - } - - if (object instanceof R3.D3.Skeleton) { - helperType = R3.D3.Helper.HELPER_TYPE_SKELETON; - } - } - this.helperType = helperType; - - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; - - this.createInstance(); - /** - * A helper as a component - does this make sense at all? - */ - // R3.Component.call( - // this, - // R3.Component.HELPER - // ); }; R3.D3.Helper.prototype = Object.create(R3.Component.prototype); R3.D3.Helper.prototype.constructor = R3.D3.Helper; -/** - * Helper types - * @type {string} - */ -R3.D3.Helper.HELPER_TYPE_NONE = 0x0; -R3.D3.Helper.HELPER_TYPE_EDGES = 0x1; -R3.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT = 0x2; -R3.D3.Helper.HELPER_TYPE_SPOT_LIGHT = 0x3; -R3.D3.Helper.HELPER_TYPE_POINT_LIGHT = 0x4; -R3.D3.Helper.HELPER_TYPE_WIREFRAME = 0x5; -R3.D3.Helper.HELPER_TYPE_SKELETON = 0x6; - /** * Creates a helper instance */ R3.D3.Helper.prototype.createInstance = function() { - if (this.helperType === R3.D3.Helper.HELPER_TYPE_EDGES) { - this.instance = new THREE.LineSegments( - new THREE.EdgesGeometry( - this.object.instance.geometry - ), - new THREE.LineBasicMaterial( - { - color:0x00ff00, - linewidth:2 - } - ) - ); + this.instance = this.graphics.Helper(this); - this.updateInstance(); - } - - if (this.helperType === R3.D3.Helper.HELPER_TYPE_DIRECTIONAL_LIGHT) { - this.instance = new THREE.DirectionalLightHelper(this.object.instance); - } - - if (this.helperType === R3.D3.Helper.HELPER_TYPE_POINT_LIGHT) { - this.instance = new THREE.PointLightHelper(this.object.instance, 1); - } - - if (this.helperType === R3.D3.Helper.HELPER_TYPE_SPOT_LIGHT) { - this.instance = new THREE.SpotLightHelper(this.object.instance); - } - - if (this.helperType === R3.D3.Helper.HELPER_TYPE_WIREFRAME) { - this.instance = new THREE.WireframeGeometry(this.object.instance, 0x00FF00); - } - - if (this.helperType === R3.D3.Helper.HELPER_TYPE_SKELETON) { - this.instance = new THREE.SkeletonHelper(this.object.instance); + if (R3.Utils.UndefinedOrNull(this.instance)) { + console.warn('No helper exists for ' + this.parent); + this.instance = true; } + __CREATE_INSTANCE__; }; /** @@ -144,16 +36,6 @@ R3.D3.Helper.prototype.createInstance = function() { */ R3.D3.Helper.prototype.updateInstance = function() { - this.instance.position.copy(this.object.instance.position); - this.instance.scale.copy(this.object.instance.scale); - this.instance.quaternion.copy(this.object.instance.quaternion); + __UPDATE_INSTANCE__; - if (this.object.parentMesh && this.object.parentMesh.instance) { - this.object.parentMesh.instance.add(this.instance); - - this.instance.applyMatrix(this.object.instance.matrix); - this.instance.updateMatrix(); - - this.instance.updateMatrixWorld(); - } }; diff --git a/src/r3-d3-light-0.js b/src/r3-d3-light-0.js new file mode 100644 index 0000000..e9bcd52 --- /dev/null +++ b/src/r3-d3-light-0.js @@ -0,0 +1,36 @@ +/** + * R3.D3.Light + * @param inherited + * @constructor + */ +R3.D3.Light = function( + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.D3.Light should not be instantiated directly'); + } + + __UPGRADE_TO_RUNTIME__; + +}; + +R3.D3.Light.prototype = Object.create(R3.Component.prototype); +R3.D3.Light.prototype.constructor = R3.D3.Light; + +/** + * Updates the instance with the current state + */ +R3.D3.Light.prototype.updateInstance = function(property) { + + if (property === 'color') { + this.instance.color.set(this.color.toHex()); + } + + if (property === 'intensity') { + this.instance.intensity = this.intensity; + } + + __UPDATE_INSTANCE__; + +}; diff --git a/src/r3-d3-light-a.js b/src/r3-d3-light-a.js deleted file mode 100644 index de92b22..0000000 --- a/src/r3-d3-light-a.js +++ /dev/null @@ -1,130 +0,0 @@ -/** - * R3.D3.Light - * @param graphics R3.Runtime.Graphics - * @param apiLight R3.D3.API.Light - * @constructor - */ -R3.D3.Light = function( - graphics, - apiLight -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiLight)) { - apiLight = {}; - } - - R3.D3.API.Light.call( - this, - apiLight.id, - apiLight.name, - apiLight.lightType, - apiLight.color, - apiLight.intensity, - apiLight.parentScene, - apiLight.parent - ); - - this.color = new R3.Color( - this.graphics, - this.color, - this - ); - - var linkedObjects = { - parentScene : R3.D3.Scene - }; - - switch (apiLight.lightType) { - - case R3.D3.API.Light.LIGHT_TYPE_DIRECTIONAL : - case R3.D3.API.Light.LIGHT_TYPE_SPOT : - linkedObjects.shadow = R3.D3.Shadow; - linkedObjects.target = R3.Component; - break; - case R3.D3.API.Light.LIGHT_TYPE_POINT : - linkedObjects.shadow = R3.D3.Shadow; - break; - case R3.D3.API.Light.LIGHT_TYPE_RECT_AREA : - linkedObjects.target = R3.Component; - break; - default: - break; - } - - R3.Component.call( - this, - linkedObjects - ); - -}; - -R3.D3.Light.prototype = Object.create(R3.Component.prototype); -R3.D3.Light.prototype.constructor = R3.D3.Light; - -/** - * Creates a light instance - * @returns {*} - */ -R3.D3.Light.prototype.createInstance = function() { - - if (!this.instance) { - console.warn('call the specific light createInstance first before calling its parent'); - return; - } - - this.instance.color.set(this.color.toHex()); - - this.instance.intensity = this.intensity; - - R3.Component.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Light.prototype.updateInstance = function(property) { - - if (R3.Utils.UndefinedOrNull(property)) { - console.warn('no property for light: ' + this.name); - } - - if (property === 'lightType') { - var componentType = R3.D3.API.Light.GetComponentType(this.lightType); - this.replace(componentType); - return; - } - - if (property === 'color') { - this.instance.color.set(this.color.toHex()); - } - - if (property === 'intensity') { - this.instance.intensity = this.intensity; - } - - if (property === 'parentScene') { - console.warn('todo: implement parentScene change for light') - } - - R3.Component.prototype.updateInstance.call(this, property); - -}; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.prototype.toApiObject = function() { - return new R3.D3.API.Light( - this.id, - this.name, - this.lightType, - this.color.toApiObject(), - this.intensity, - R3.Utils.IdOrNull(this.parentScene), - R3.Utils.IdOrNull(this.parent) - ); -}; diff --git a/src/r3-d3-light-ambient.js b/src/r3-d3-light-ambient.js index d113c2e..a984e07 100644 --- a/src/r3-d3-light-ambient.js +++ b/src/r3-d3-light-ambient.js @@ -1,33 +1,18 @@ /** * R3.D3.Light.Ambient - * @param graphics R3.Runtime.Graphics - * @param apiAmbientLight + * @param apiComponent * @constructor */ R3.D3.Light.Ambient = function( - graphics, - apiAmbientLight + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiAmbientLight)) { - apiAmbientLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_AMBIENT - }; - } - - R3.D3.API.Light.Ambient.call( - this, - apiAmbientLight - ); + __RUNTIME_COMPONENT__; R3.D3.Light.call( this, - this.graphics, - apiAmbientLight - ); + true + ) }; @@ -40,9 +25,10 @@ R3.D3.Light.Ambient.prototype.constructor = R3.D3.Light.Ambient; */ R3.D3.Light.Ambient.prototype.createInstance = function() { - this.instance = new THREE.AmbientLight(); + this.instance = this.graphics.LightAmbient(this); + + __CREATE_INSTANCE__; - R3.D3.Light.prototype.createInstance.call(this); }; /** @@ -51,14 +37,3 @@ R3.D3.Light.Ambient.prototype.createInstance = function() { R3.D3.Light.Ambient.prototype.updateInstance = function(property) { R3.D3.Light.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.Ambient.prototype.toApiObject = function() { - - var apiLight = R3.D3.Light.prototype.toApiObject.call(this); - - return apiLight; -}; diff --git a/src/r3-d3-light-directional.js b/src/r3-d3-light-directional.js index a51305f..8e61e95 100644 --- a/src/r3-d3-light-directional.js +++ b/src/r3-d3-light-directional.js @@ -1,51 +1,19 @@ /** * R3.D3.Light.Directional - * @param graphics R3.Runtime.Graphics - * @param apiDirectionalLight + * @param apiComponent * @constructor */ R3.D3.Light.Directional = function( - graphics, - apiDirectionalLight + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiDirectionalLight)) { - apiDirectionalLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_DIRECTIONAL - }; - } - - R3.D3.API.Light.Directional.call( - this, - apiDirectionalLight, - apiDirectionalLight.castShadow, - apiDirectionalLight.position, - apiDirectionalLight.shadow, - apiDirectionalLight.target - ); - - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - if (this.shadow instanceof R3.D3.API.Shadow.Directional) { - this.shadow = new R3.D3.Shadow.Directional( - this.graphics, - this.shadow - ) - } + __RUNTIME_COMPONENT__; R3.D3.Light.call( this, - this.graphics, - apiDirectionalLight + true ); - + }; R3.D3.Light.Directional.prototype = Object.create(R3.D3.Light.prototype); @@ -57,67 +25,16 @@ R3.D3.Light.Directional.prototype.constructor = R3.D3.Light.Directional; */ R3.D3.Light.Directional.prototype.createInstance = function() { - this.instance = new THREE.DirectionalLight(); + this.instance = this.graphics.LightDirectional(this); - this.instance.castShadow = this.castShadow; + __CREATE_INSTANCE__; - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; - - /** - * Shadows work a little different - they are created internally by - * threejs - so we do it the other way around - we create our shadow object, - * and assign its properties from the one provided by threejs. - * - * If we already have a shadow object - it was loaded from the API, so we assign - * to our new shadow object the values from it. - * - * If we don't, we create a new one, and update it with the defaults from threejs - */ - - if (this.shadow === null) { - - /** - * This component is created during runtime - */ - this.shadow = new R3.D3.Shadow.Directional(this.graphics); - - this.shadow.instance = this.instance.shadow; - - this.shadow.updateFromInstance(); - - } else { - /** - * This component loaded from the API - update the instance with our settings - */ - this.shadow.instance = this.instance.shadow; - - this.shadow.updateInstance('camera'); - this.shadow.updateInstance('bias'); - this.shadow.updateInstance('mapSize'); - this.shadow.updateInstance('radius'); - } - - /** - * The directional light points to target - target has to update its matrix world so needs to be added to the scene - */ - if (this.target && this.target.instance) { - - this.instance.target = this.target.instance; - - if (this.parentScene && this.parentScene.instance) { - this.parentScene.addObject(this.target); - } - } - - R3.D3.Light.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ -R3.D3.Light.Directional.prototype.updateInstance = function(property, oldTarget) { +R3.D3.Light.Directional.prototype.updateInstance = function(property) { if (property === 'castShadow') { this.instance.castShadow = this.castShadow; @@ -132,46 +49,22 @@ R3.D3.Light.Directional.prototype.updateInstance = function(property, oldTarget) } if (property === 'shadow') { - console.warn('experimental shadow change'); - if (this.shadow && this.shadow.instance) { - this.instance.shadow = this.shadow.instance; + console.warn('R3.D3.Light.Directional.prototype.shadow is read-only'); + + if (R3.Utils.UndefinedOrNull(this.shadow)) { + console.warn('If you store this object now - the shadow component will be created new on next reload') } + return; } if (property === 'target') { - - console.warn('experimental target change'); - - if (typeof oldTarget === 'undefined') { - console.warn('oldTarget undefined'); - } - - if (oldTarget) { - if (this.parentScene) { - this.parentScene.removeObject(oldTarget); - this.parentScene.addObject(this.target); - } - } - + /** + * todo : some target validation + */ + this.instance.target = this.target.instance; return; } R3.D3.Light.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.Directional.prototype.toApiObject = function() { - - var apiDirectionalLight = R3.D3.Light.prototype.toApiObject.call(this); - - apiDirectionalLight.castShadow = this.castShadow; - apiDirectionalLight.position = this.position.toApiObject(); - apiDirectionalLight.shadow = R3.Utils.IdOrNull(this.shadow); - apiDirectionalLight.target = R3.Utils.IdOrNull(this.target); - - return apiDirectionalLight; -}; diff --git a/src/r3-d3-light-hemisphere.js b/src/r3-d3-light-hemisphere.js index 5d12886..e5b2f46 100644 --- a/src/r3-d3-light-hemisphere.js +++ b/src/r3-d3-light-hemisphere.js @@ -1,46 +1,17 @@ /** * R3.D3.Light.Directional - * @param graphics R3.Runtime.Graphics - * @param apiHemisphereLight + * @param apiComponent * @constructor */ R3.D3.Light.Hemisphere = function( - graphics, - apiHemisphereLight + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiHemisphereLight)) { - apiHemisphereLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_HEMISPHERE - }; - } - - R3.D3.API.Light.Hemisphere.call( - this, - apiHemisphereLight, - apiHemisphereLight.position, - apiHemisphereLight.groundColor - ); - - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - this.groundColor = new R3.Color( - this.graphics, - this.groundColor, - this - ); + __RUNTIME_COMPONENT__; R3.D3.Light.call( this, - this.graphics, - apiHemisphereLight + true ); }; @@ -54,21 +25,16 @@ R3.D3.Light.Hemisphere.prototype.constructor = R3.D3.Light.Hemisphere; */ R3.D3.Light.Hemisphere.prototype.createInstance = function() { - this.instance = new THREE.HemisphereLight(); + this.instance = this.graphics.LightHemisphere(this); - this.instance.castShadow = this.castShadow; + __CREATE_INSTANCE__; - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; - - R3.D3.Light.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ -R3.D3.Light.Hemisphere.prototype.updateInstance = function(property, oldTarget) { +R3.D3.Light.Hemisphere.prototype.updateInstance = function(property) { if (property === 'position') { this.instance.position.x = this.position.x; @@ -84,17 +50,3 @@ R3.D3.Light.Hemisphere.prototype.updateInstance = function(property, oldTarget) R3.D3.Light.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.Hemisphere.prototype.toApiObject = function() { - - var apiHemisphereLight = R3.D3.Light.prototype.toApiObject.call(this); - - apiHemisphereLight.position = this.position.toApiObject(); - apiHemisphereLight.groundColor = this.groundColor.toApiObject(); - - return apiHemisphereLight; -}; diff --git a/src/r3-d3-light-point.js b/src/r3-d3-light-point.js index de5eb40..4b5fa12 100644 --- a/src/r3-d3-light-point.js +++ b/src/r3-d3-light-point.js @@ -1,50 +1,17 @@ /** * R3.D3.Light.Point - * @param graphics R3.Runtime.Graphics - * @param apiPointLight + * @param apiComponent * @constructor */ R3.D3.Light.Point = function( - graphics, - apiPointLight + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiPointLight)) { - apiPointLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_POINT - }; - } - - R3.D3.API.Light.Point.call( - this, - apiPointLight, - apiPointLight.position, - apiPointLight.decay, - apiPointLight.distance, - apiPointLight.power, - apiPointLight.shadow - ); - - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - if (this.shadow instanceof R3.D3.API.Shadow) { - this.shadow = new R3.D3.Shadow( - this.graphics, - this.shadow - ) - } + __RUNTIME_COMPONENT__; R3.D3.Light.call( this, - this.graphics, - apiPointLight + true ); }; @@ -58,41 +25,10 @@ R3.D3.Light.Point.prototype.constructor = R3.D3.Light.Point; */ R3.D3.Light.Point.prototype.createInstance = function() { - this.instance = new THREE.PointLight(); + this.instance = this.graphics.LightPoint(this); - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; + __CREATE_INSTANCE__; - this.instance.decay = this.decay; - this.instance.distance = this.distance; - this.instance.power = this.power; - - if (this.shadow === null) { - - /** - * This component is created during runtime - */ - this.shadow = new R3.D3.Shadow(this.graphics); - - this.shadow.instance = this.instance.shadow; - - this.shadow.updateFromInstance(); - - } else { - /** - * This component loaded from the API - update the instance with our settings - */ - this.shadow.instance = this.instance.shadow; - - this.shadow.updateInstance('camera'); - this.shadow.updateInstance('bias'); - this.shadow.updateInstance('mapSize'); - this.shadow.updateInstance('radius'); - } - - - R3.D3.Light.prototype.createInstance.call(this); }; /** @@ -122,30 +58,21 @@ R3.D3.Light.Point.prototype.updateInstance = function(property) { return; } + if (property === 'castShadow') { + this.instance.castShadow = this.castShadow; + return; + } + if (property === 'shadow') { - console.warn('experimental shadow change'); - if (this.shadow && this.shadow.instance) { - this.instance.shadow = this.shadow.instance; + + console.warn('R3.D3.Light.Point.prototype.shadow is read-only'); + + if (R3.Utils.UndefinedOrNull(this.shadow)) { + console.warn('If you store this object now - the shadow component will be created new on next reload') } + return; } R3.D3.Light.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.Point.prototype.toApiObject = function() { - - var apiPointLight = R3.D3.Light.prototype.toApiObject.call(this); - - apiPointLight.position = this.position.toApiObject(); - apiPointLight.decay = this.decay; - apiPointLight.distance = this.distance; - apiPointLight.power = this.power; - apiPointLight.shadow = R3.Utils.IdOrNull(this.shadow); - - return apiPointLight; -}; diff --git a/src/r3-d3-light-rect-area.js b/src/r3-d3-light-rect-area.js deleted file mode 100644 index b3c9484..0000000 --- a/src/r3-d3-light-rect-area.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * R3.D3.Light.RectArea - * @param graphics R3.Runtime.Graphics - * @param apiRectAreaLight - * @constructor - */ -R3.D3.Light.RectArea = function( - graphics, - apiRectAreaLight -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiRectAreaLight)) { - apiRectAreaLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_RECT_AREA - }; - } - - R3.D3.API.Light.RectArea.call( - this, - apiRectAreaLight, - apiRectAreaLight.position, - apiRectAreaLight.castShadow, - apiRectAreaLight.decay, - apiRectAreaLight.distance, - apiRectAreaLight.width, - apiRectAreaLight.height, - apiRectAreaLight.target - ); - - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - R3.D3.Light.call( - this, - this.graphics, - apiRectAreaLight - ); - -}; - -R3.D3.Light.RectArea.prototype = Object.create(R3.D3.Light.prototype); -R3.D3.Light.RectArea.prototype.constructor = R3.D3.Light.RectArea; - -/** - * Creates a light instance - * @returns {*} - */ -R3.D3.Light.RectArea.prototype.createInstance = function() { - - this.instance = new THREE.RectAreaLight(); - - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; - - //TODO: not yet implemented - //this.instance.castShadow = this.castShadow; - //this.instance.decay = this.decay; - //this.instance.distance = this.distance; - - this.instance.width = this.width; - this.instance.height = this.height; - - if (this.target && this.target.instance) { - this.instance.target = this.target.instance; - - if (this.parentScene && this.parentScene.instance) { - this.parentScene.addObject(this.target); - } - } - R3.D3.Light.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Light.RectArea.prototype.updateInstance = function(property, oldTarget) { - - if (property === 'castShadow') { - console.warn('not yet implemented : castShadow'); - // this.instance.castShadow = this.castShadow; - return; - } - - if (property === 'position') { - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; - return; - } - - if (property === 'decay') { - console.warn('not yet implemented : decay'); - // this.instance.decay = this.decay; - return; - } - - if (property === 'distance') { - console.warn('not yet implemented : distance'); - // this.instance.distance = this.distance; - return; - } - - if (property === 'width') { - this.instance.width = this.width; - return; - } - - if (property === 'height') { - this.instance.height = this.height; - return; - } - - if (property === 'target') { - - if (typeof oldTarget === 'undefined') { - console.warn('oldTarget undefined'); - } - - if (oldTarget) { - if (this.parentScene) { - this.parentScene.removeObject(oldTarget); - this.parentScene.addObject(this.target); - } - } - - return; - } - - R3.D3.Light.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.RectArea.prototype.toApiObject = function() { - - var apiRectAreaLight = R3.D3.Light.prototype.toApiObject.call(this); - - apiRectAreaLight.position = this.position.toApiObject(); - apiRectAreaLight.castShadow = this.castShadow; - apiRectAreaLight.decay = this.decay; - apiRectAreaLight.distance = this.distance; - apiRectAreaLight.width = this.width; - apiRectAreaLight.height = this.height; - apiRectAreaLight.target = R3.Utils.IdOrNull(this.target); - - return apiRectAreaLight; -}; diff --git a/src/r3-d3-light-rectArea.js b/src/r3-d3-light-rectArea.js new file mode 100644 index 0000000..377b6cf --- /dev/null +++ b/src/r3-d3-light-rectArea.js @@ -0,0 +1,62 @@ +/** + * R3.D3.Light.RectArea + * @param apiComponent + * @constructor + */ +R3.D3.Light.RectArea = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.D3.Light.call( + this, + true + ); + +}; + +R3.D3.Light.RectArea.prototype = Object.create(R3.D3.Light.prototype); +R3.D3.Light.RectArea.prototype.constructor = R3.D3.Light.RectArea; + +/** + * Creates a light instance + * @returns {*} + */ +R3.D3.Light.RectArea.prototype.createInstance = function() { + + this.instance = this.graphics.LightRectArea(); + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.D3.Light.RectArea.prototype.updateInstance = function(property) { + + if (property === 'position') { + this.instance.position.x = this.position.x; + this.instance.position.y = this.position.y; + this.instance.position.z = this.position.z; + return; + } + + if (property === 'width') { + this.instance.width = this.width; + return; + } + + if (property === 'height') { + this.instance.height = this.height; + return; + } + + if (property === 'lookAt') { + this.instance.lookAt(this.lookAt.instance); + return; + } + + R3.D3.Light.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-d3-light-spot.js b/src/r3-d3-light-spot.js index 3eb3447..003cdf4 100644 --- a/src/r3-d3-light-spot.js +++ b/src/r3-d3-light-spot.js @@ -1,54 +1,17 @@ /** * R3.D3.Light.Spot - * @param graphics R3.Runtime.Graphics - * @param apiSpotLight + * @param apiComponent * @constructor */ R3.D3.Light.Spot = function( - graphics, - apiSpotLight + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiSpotLight)) { - apiSpotLight = { - lightType : R3.D3.API.Light.LIGHT_TYPE_SPOT - }; - } - - R3.D3.API.Light.Spot.call( - this, - apiSpotLight, - apiSpotLight.position, - apiSpotLight.angle, - apiSpotLight.castShadow, - apiSpotLight.decay, - apiSpotLight.distance, - apiSpotLight.penumbra, - apiSpotLight.power, - apiSpotLight.shadow, - apiSpotLight.target - ); - - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - if (this.shadow instanceof R3.D3.API.Shadow.Spot) { - this.shadow = new R3.D3.Shadow.Spot( - this.graphics, - this.shadow - ) - } + __RUNTIME_COMPONENT__; R3.D3.Light.call( this, - this.graphics, - apiSpotLight + true ); }; @@ -62,51 +25,10 @@ R3.D3.Light.Spot.prototype.constructor = R3.D3.Light.Spot; */ R3.D3.Light.Spot.prototype.createInstance = function() { - this.instance = new THREE.SpotLight(); + this.instance = this.graphics.LightSpot(this); - this.instance.position.x = this.position.x; - this.instance.position.y = this.position.y; - this.instance.position.z = this.position.z; + __CREATE_INSTANCE__; - this.instance.angle = this.angle; - this.instance.castShadow = this.castShadow; - this.instance.decay = this.decay; - this.instance.distance = this.distance; - this.instance.penumbra = this.penumbra; - this.instance.power = this.power; - - if (this.shadow === null) { - - /** - * This component is created during runtime - */ - this.shadow = new R3.D3.Shadow.Spot(this.graphics); - - this.shadow.instance = this.instance.shadow; - - this.shadow.updateFromInstance(); - - } else { - /** - * This component loaded from the API - update the instance with our settings - */ - this.shadow.instance = this.instance.shadow; - - this.shadow.updateInstance('camera'); - this.shadow.updateInstance('bias'); - this.shadow.updateInstance('mapSize'); - this.shadow.updateInstance('radius'); - } - - if (this.target && this.target.instance) { - this.instance.target = this.target.instance; - - if (this.parentScene && this.parentScene.instance) { - this.parentScene.addObject(this.target); - } - } - - R3.D3.Light.prototype.createInstance.call(this); }; /** @@ -146,63 +68,33 @@ R3.D3.Light.Spot.prototype.updateInstance = function(property, oldTarget) { return; } - if (property === 'power') { - this.instance.power = this.power; - return; - } - if (property === 'shadow') { - console.warn('experimental shadow change'); - if (this.shadow && this.shadow.instance) { - this.instance.shadow = this.shadow.instance; + + console.warn('R3.D3.Light.Spot.prototype.shadow is read-only'); + + if (R3.Utils.UndefinedOrNull(this.shadow)) { + console.warn('If you store this object now - the shadow component will be created new on next reload') } + return; } if (property === 'target') { - if (typeof oldTarget === 'undefined') { - console.warn('oldTarget undefined'); + if (R3.Utils.UndefinedOrNull(this.target)) { + console.warn('If you store this object now - the light will point to the origin on next load'); + return } - if (oldTarget) { - if (this.parentScene) { - this.parentScene.removeObject(oldTarget); - } + if (R3.Utils.Unloaded(this.target)) { + console.warn('The target selected is not valid or not loaded - if you save now the light will point to the origin on next load'); + this.target = null; + return; } - if (this.target.instance) { - this.instance.target = this.target.instance; - } - - this.parentScene.addObject(this.target); - + this.instance.target = this.target.instance; return; } R3.D3.Light.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Light to a R3.D3.API.Light - * @returns {R3.D3.API.Light} - */ -R3.D3.Light.Spot.prototype.toApiObject = function() { - - var apiLight = R3.D3.Light.prototype.toApiObject.call(this); - - var apiSpotLight = new R3.D3.API.Light.Spot( - apiLight, - this.position.toApiObject(), - this.angle, - this.castShadow, - this.decay, - this.distance, - this.penumbra, - this.power, - R3.Utils.IdOrNull(this.shadow), - R3.Utils.IdOrNull(this.target) - ); - - return apiSpotLight; -}; diff --git a/src/r3-d3-material-a.js b/src/r3-d3-material-0.js similarity index 80% rename from src/r3-d3-material-a.js rename to src/r3-d3-material-0.js index 21394f9..868230a 100644 --- a/src/r3-d3-material-a.js +++ b/src/r3-d3-material-0.js @@ -7,164 +7,26 @@ * @constructor * @returns {R3.D3.Material} */ +/** + * R3.D3.Material + * @param inherited + * @constructor + */ R3.D3.Material = function( - graphics, - apiMaterial + inherited ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiMaterial)) { - apiMaterial = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_NONE - }; + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.D3.Material should not be instantiated directly'); } - R3.D3.API.Material.call( - this, - apiMaterial.id, - apiMaterial.name, - apiMaterial.materialType, - apiMaterial.parent, - apiMaterial.parentMeshes, - apiMaterial.alphaTest, - apiMaterial.blendDst, - apiMaterial.blendDstAlpha, - apiMaterial.blendEquation, - apiMaterial.blendEquationAlpha, - apiMaterial.blending, - apiMaterial.blendSrc, - apiMaterial.blendSrcAlpha, - apiMaterial.clipIntersection, - apiMaterial.clippingPlanes, - apiMaterial.clipShadows, - apiMaterial.colorWrite, - apiMaterial.customDepthMaterial, - apiMaterial.customDistanceMaterial, - apiMaterial.defines, - apiMaterial.depthFunc, - apiMaterial.depthTest, - apiMaterial.depthWrite, - apiMaterial.fog, - apiMaterial.lights, - apiMaterial.opacity, - apiMaterial.overdraw, - apiMaterial.polygonOffset, - apiMaterial.polygonOffsetFactor, - apiMaterial.polygonOffsetUnits, - apiMaterial.precision, - apiMaterial.premultipliedAlpha, - apiMaterial.dithering, - apiMaterial.flatShading, - apiMaterial.side, - apiMaterial.transparent, - apiMaterial.vertexColors, - apiMaterial.visible - ); - - var linkedObjects = {}; - - switch (this.materialType) { - case R3.D3.API.Material.MATERIAL_TYPE_STANDARD : - linkedObjects.alphaMap = R3.D3.Texture; - linkedObjects.aoMap = R3.D3.Texture; - linkedObjects.bumpMap = R3.D3.Texture; - linkedObjects.diffuseMap = R3.D3.Texture; - linkedObjects.displacementMap = R3.D3.Texture; - linkedObjects.emissiveMap = R3.D3.Texture; - linkedObjects.envMap = R3.D3.Texture; - linkedObjects.lightMap = R3.D3.Texture; - linkedObjects.metalnessMap = R3.D3.Texture; - linkedObjects.normalMap = R3.D3.Texture; - linkedObjects.roughnessMap = R3.D3.Texture; - break; - case R3.D3.API.Material.MATERIAL_TYPE_BASIC : - linkedObjects.alphaMap = R3.D3.Texture; - linkedObjects.aoMap = R3.D3.Texture; - linkedObjects.diffuseMap = R3.D3.Texture; - linkedObjects.envMap = R3.D3.Texture; - linkedObjects.lightMap = R3.D3.Texture; - linkedObjects.specularMap = R3.D3.Texture; - break; - case R3.D3.API.Material.MATERIAL_TYPE_PHONG : - linkedObjects.alphaMap = R3.D3.Texture; - linkedObjects.aoMap = R3.D3.Texture; - linkedObjects.bumpMap = R3.D3.Texture; - linkedObjects.diffuseMap = R3.D3.Texture; - linkedObjects.displacementMap = R3.D3.Texture; - linkedObjects.emissiveMap = R3.D3.Texture; - linkedObjects.envMap = R3.D3.Texture; - linkedObjects.lightMap = R3.D3.Texture; - linkedObjects.normalMap = R3.D3.Texture; - linkedObjects.specularMap = R3.D3.Texture; - break; - case R3.D3.API.Material.MATERIAL_TYPE_SHADER : - case R3.D3.API.Material.MATERIAL_TYPE_SHADER_RAW : - linkedObjects.vertexShader = R3.D3.Shader.Vertex; - linkedObjects.fragmentShader = R3.D3.Shader.Fragment; - break; - case R3.D3.API.Material.MATERIAL_TYPE_POINTS : - linkedObjects.diffuseMap = R3.D3.Texture; - break; - default : - throw new Error('unhandled material type: ' + this.materialType); - - } - - R3.Component.call( - this, - linkedObjects - ); + __UPGRADE_TO_RUNTIME__; + }; R3.D3.Material.prototype = Object.create(R3.Component.prototype); R3.D3.Material.prototype.constructor = R3.D3.Material; -R3.D3.Material.prototype.createInstance = function() { - - if (R3.Utils.UndefinedOrNull(this.instance)) { - console.warn('the child createInstance has to be called first'); - return; - } - - this.instance.alphaTest = this.alphaTest; - this.instance.blendDst = this.blendDst; - this.instance.blendDstAlpha = this.blendDstAlpha; - this.instance.blendEquation = this.blendEquation; - this.instance.blendEquationAlpha = this.blendEquationAlpha; - this.instance.blending = this.blending; - this.instance.blendSrc = this.blendSrc; - this.instance.blendSrcAlpha = this.blendSrcAlpha; - this.instance.clipIntersection = this.clipIntersection; - this.instance.clippingPlanes = this.clippingPlanes; - this.instance.clipShadows = this.clipShadows; - this.instance.colorWrite = this.colorWrite; - this.instance.customDepthMaterial = this.customDepthMaterial; - this.instance.customDistanceMaterial = this.customDistanceMaterial; - this.instance.defines = this.defines; - this.instance.depthFunc = this.depthFunc; - this.instance.depthTest = this.depthTest; - this.instance.depthWrite = this.depthWrite; - this.instance.fog = this.fog; - this.instance.lights = this.lights; - this.instance.opacity = this.opacity; - this.instance.overdraw = this.overdraw; - this.instance.polygonOffset = this.polygonOffset; - this.instance.polygonOffsetFactor = this.polygonOffsetFactor; - this.instance.polygonOffsetUnits = this.polygonOffsetUnits; - this.instance.precision = this.precision; - this.instance.premultipliedAlpha = this.premultipliedAlpha; - this.instance.dithering = this.dithering; - this.instance.flatShading = this.flatShading; - this.instance.side = this.side; - this.instance.transparent = this.transparent; - this.instance.vertexColors = this.vertexColors; - this.instance.visible = this.visible; - - R3.Component.prototype.createInstance.call(this); - -}; R3.D3.Material.prototype.updateInstance = function(property) { @@ -182,11 +44,6 @@ R3.D3.Material.prototype.updateInstance = function(property) { return; } - if (property === 'parentMeshes') { - console.warn('parent meshes are read-only'); - return; - } - if (property === 'alphaTest') { this.instance.alphaTest = this.alphaTest; this.instance.needsUpdate = true; @@ -248,16 +105,6 @@ R3.D3.Material.prototype.updateInstance = function(property) { return; } - if (property === 'customDepthMaterial') { - console.warn('todo: implement custom depth material update'); - return; - } - - if (property === 'customDistanceMaterial') { - console.warn('todo: implement custom distance material update'); - return; - } - if (property === 'defines') { this.instance.defines = this.defines; this.instance.needsUpdate = true; @@ -279,6 +126,17 @@ R3.D3.Material.prototype.updateInstance = function(property) { return; } + if (property === 'dithering') { + this.instance.dithering = this.dithering; + console.log('not sure about dithering needsupdate - cannot detect any changes until now'); + return; + } + + if (property === 'flatShading') { + this.instance.flatShading = this.flatShading; + retiurn; + } + if (property === 'fog') { this.instance.fog = this.fog; return; @@ -286,6 +144,7 @@ R3.D3.Material.prototype.updateInstance = function(property) { if (property === 'lights') { this.instance.lights = this.lights; + return; } if (property === 'opacity') { @@ -323,20 +182,46 @@ R3.D3.Material.prototype.updateInstance = function(property) { return; } - if (property === 'dithering') { - this.instance.dithering = this.dithering; - console.log('not sure about needsupdate - cannot detect any changes until now'); - } - - if (property === 'flatShading') { - this.instance.flatShading = this.flatShading; - } - if (property === 'side') { this.instance.side = this.side; return; } + if (property === 'stencilWrite') { + this.instance.stencilWrite = this.stencilWrite; + return; + } + + if (property === 'stencilFunc') { + this.instance.stencilFunc = this.stencilFunc; + return; + } + + if (property === 'stencilRef') { + this.instance.stencilRef = this.stencilRef; + return; + } + + if (property === 'stencilMask') { + this.instance.stencilMask = this.stencilMask; + return; + } + + if (property === 'stencilFail') { + this.instance.stencilFail = this.stencilFail; + return; + } + + if (property === 'stencilZFail') { + this.instance.stencilZFail = this.stencilZFail; + return; + } + + if (property === 'stencilZPass') { + this.instance.stencilZPass = this.stencilZPass; + return; + } + if (property === 'transparent') { this.instance.transparent = this.transparent; return; @@ -361,62 +246,7 @@ R3.D3.Material.prototype.updateInstance = function(property) { this.instance.needsUpdate = true; this.needsUpdate = false; - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Material to a R3.D3.API.Material - * @returns {R3.D3.API.Material} - */ -R3.D3.Material.prototype.toApiObject = function() { - - var apiMaterial = new R3.D3.API.Material( - this.id, - this.name, - this.materialType, - R3.Utils.IdOrNull(this.parent), - this.parentMeshes.map( - function(mesh) { - return R3.Utils.IdOrNull(mesh); - } - ), - this.alphaTest, - this.blendDst, - this.blendDstAlpha, - this.blendEquation, - this.blendEquationAlpha, - this.blending, - this.blendSrc, - this.blendSrcAlpha, - this.clipIntersection, - this.clippingPlanes, - this.clipShadows, - this.colorWrite, - this.customDepthMaterial, - this.customDistanceMaterial, - this.defines, - this.depthFunc, - this.depthTest, - this.depthWrite, - this.fog, - this.lights, - this.opacity, - this.overdraw, - this.polygonOffset, - this.polygonOffsetFactor, - this.polygonOffsetUnits, - this.precision, - this.premultipliedAlpha, - this.dithering, - this.flatShading, - this.side, - this.transparent, - this.vertexColors, - this.visible - ); - - return apiMaterial; - + __UPDATE_INSTANCE__; }; R3.D3.Material.prototype.assignTexture = function(instanceProperty, property) { @@ -449,6 +279,54 @@ R3.D3.Material.prototype.getTextures = function() { }; +/* +switch (this.materialType) { + case R3.D3.API.Material.MATERIAL_TYPE_STANDARD : + linkedObjects.alphaMap = R3.D3.Texture; + linkedObjects.aoMap = R3.D3.Texture; + linkedObjects.bumpMap = R3.D3.Texture; + linkedObjects.diffuseMap = R3.D3.Texture; + linkedObjects.displacementMap = R3.D3.Texture; + linkedObjects.emissiveMap = R3.D3.Texture; + linkedObjects.envMap = R3.D3.Texture; + linkedObjects.lightMap = R3.D3.Texture; + linkedObjects.metalnessMap = R3.D3.Texture; + linkedObjects.normalMap = R3.D3.Texture; + linkedObjects.roughnessMap = R3.D3.Texture; + break; + case R3.D3.API.Material.MATERIAL_TYPE_BASIC : + linkedObjects.alphaMap = R3.D3.Texture; + linkedObjects.aoMap = R3.D3.Texture; + linkedObjects.diffuseMap = R3.D3.Texture; + linkedObjects.envMap = R3.D3.Texture; + linkedObjects.lightMap = R3.D3.Texture; + linkedObjects.specularMap = R3.D3.Texture; + break; + case R3.D3.API.Material.MATERIAL_TYPE_PHONG : + linkedObjects.alphaMap = R3.D3.Texture; + linkedObjects.aoMap = R3.D3.Texture; + linkedObjects.bumpMap = R3.D3.Texture; + linkedObjects.diffuseMap = R3.D3.Texture; + linkedObjects.displacementMap = R3.D3.Texture; + linkedObjects.emissiveMap = R3.D3.Texture; + linkedObjects.envMap = R3.D3.Texture; + linkedObjects.lightMap = R3.D3.Texture; + linkedObjects.normalMap = R3.D3.Texture; + linkedObjects.specularMap = R3.D3.Texture; + break; + case R3.D3.API.Material.MATERIAL_TYPE_SHADER : + case R3.D3.API.Material.MATERIAL_TYPE_SHADER_RAW : + linkedObjects.vertexShader = R3.D3.Shader.Vertex; + linkedObjects.fragmentShader = R3.D3.Shader.Fragment; + break; + case R3.D3.API.Material.MATERIAL_TYPE_POINTS : + linkedObjects.diffuseMap = R3.D3.Texture; + break; + default : + throw new Error('unhandled material type: ' + this.materialType); + +} +*/ // // // @@ -1058,7 +936,7 @@ R3.D3.Material.prototype.getTextures = function() { // // this.updateTextures(); // -// R3.Component.prototype.createInstance.call(this); +// __CREATE_INSTANCE__; // }; /** diff --git a/src/r3-d3-material-basic.js b/src/r3-d3-material-basic.js index e6dcc96..0488935 100644 --- a/src/r3-d3-material-basic.js +++ b/src/r3-d3-material-basic.js @@ -1,79 +1,17 @@ /** * R3.D3.Material.Basic - * @param graphics - * @param apiMaterialBasic + * @param apiComponent * @constructor */ R3.D3.Material.Basic = function( - graphics, - apiMaterialBasic + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiMaterialBasic)) { - apiMaterialBasic = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_BASIC - }; - } - - R3.D3.API.Material.Basic.call( - this, - apiMaterialBasic, - apiMaterialBasic.alphaMap, - apiMaterialBasic.aoMap, - apiMaterialBasic.aoMapIntensity, - apiMaterialBasic.color, - apiMaterialBasic.combine, - apiMaterialBasic.envMap, - apiMaterialBasic.lightMap, - apiMaterialBasic.lightMapIntensity, - apiMaterialBasic.diffuseMap, - apiMaterialBasic.morphTargets, - apiMaterialBasic.reflectivity, - apiMaterialBasic.refractionRatio, - apiMaterialBasic.skinning, - apiMaterialBasic.specularMap, - apiMaterialBasic.wireframe, - apiMaterialBasic.wireframeLinecap, - apiMaterialBasic.wireframeLinejoin, - apiMaterialBasic.wireframeLinewidth - ); - - if (this.alphaMap instanceof R3.D3.API.Texture) { - this.alphaMap = R3.Component.ConstructFromObject(this.alphaMap); - } - - if (this.aoMap instanceof R3.D3.API.Texture) { - this.aoMap = R3.Component.ConstructFromObject(this.aoMap); - } - - this.color = new R3.Color( - this.graphics, - this.color, - this - ); - - if (this.envMap instanceof R3.D3.API.Texture) { - this.envMap = R3.Component.ConstructFromObject(this.envMap); - } - - if (this.lightMap instanceof R3.D3.API.Texture) { - this.lightMap = R3.Component.ConstructFromObject(this.lightMap); - } - - if (this.diffuseMap instanceof R3.D3.API.Texture) { - this.diffuseMap = R3.Component.ConstructFromObject(this.diffuseMap); - } - - if (this.specularMap instanceof R3.D3.API.Texture) { - this.specularMap = R3.Component.ConstructFromObject(this.specularMap); - } + __RUNTIME_COMPONENT__; R3.D3.Material.call( this, - this.graphics, - this + true ); }; @@ -87,29 +25,10 @@ R3.D3.Material.Basic.prototype.constructor = R3.D3.Material.Basic; */ R3.D3.Material.Basic.prototype.createInstance = function() { - this.instance = new THREE.MeshBasicMaterial( - { - alphaMap : this.alphaMap ? this.alphaMap.instance : null, - aoMap : this.aoMap ? this.aoMap.instance : null, - aoMapIntensity : this.aoMapIntensity, - color : this.color.instance, - envMap : this.envMap ? this.envMap.instance : null, - lightMap : this.lightMap ? this.lightMap.instance : null, - lightMapIntensity : this.lightMapIntensity, - map : this.diffuseMap ? this.diffuseMap.instance : null, - morphTargets : this.morphTargets, - reflectivity : this.reflectivity, - refractionRatio : this.refractionRatio, - skinning : this.skinning, - specularMap : this.specularMap ? this.specularMap.instance : null, - wireframe : this.wireframe, - wireframeLinecap : this.wireframeLinecap, - wireframeLinejoin : this.wireframeLinejoin, - wireframeLinewidth : this.wireframeLinewidth - } - ); - - R3.D3.Material.prototype.createInstance.call(this); + this.instance = this.graphics.MaterialBasic(this); + + __CREATE_INSTANCE__; + }; /** @@ -210,36 +129,3 @@ R3.D3.Material.Basic.prototype.updateInstance = function(property) { R3.D3.Material.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Material.Basic to a R3.D3.API.Material.Basic - * @returns {R3.D3.API.Material.Basic} - */ -R3.D3.Material.Basic.prototype.toApiObject = function() { - - var apiMaterial = R3.D3.Material.prototype.toApiObject.call(this); - - var apiMaterialBasic = new R3.D3.API.Material.Basic( - apiMaterial, - R3.Utils.IdOrNull(this.alphaMap), - R3.Utils.IdOrNull(this.aoMap), - this.aoMapIntensity, - this.color.toApiObject(), - this.combine, - R3.Utils.IdOrNull(this.envMap), - R3.Utils.IdOrNull(this.lightMap), - this.lightMapIntensity, - R3.Utils.IdOrNull(this.diffuseMap), - this.morphTargets, - this.reflectivity, - this.refractionRatio, - this.skinning, - R3.Utils.IdOrNull(this.specularMap), - this.wireframe, - this.wireframeLinecap, - this.wireframeLinejoin, - this.wireframeLinewidth - ); - - return apiMaterialBasic; -}; diff --git a/src/r3-d3-material-phong.js b/src/r3-d3-material-phong.js index fa50920..7936c57 100644 --- a/src/r3-d3-material-phong.js +++ b/src/r3-d3-material-phong.js @@ -1,120 +1,17 @@ /** * R3.D3.Material.Phong - * @param graphics - * @param apiMaterialPhong + * @param apiComponent * @constructor */ R3.D3.Material.Phong = function( - graphics, - apiMaterialPhong + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiMaterialPhong)) { - apiMaterialPhong = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_PHONG - }; - } + __RUNTIME_COMPONENT__; - R3.D3.API.Material.Phong.call( - this, - apiMaterialPhong, - apiMaterialPhong.alphaMap, - apiMaterialPhong.aoMap, - apiMaterialPhong.aoMapIntensity, - apiMaterialPhong.bumpMap, - apiMaterialPhong.bumpScale, - apiMaterialPhong.color, - apiMaterialPhong.combine, - apiMaterialPhong.displacementMap, - apiMaterialPhong.displacementScale, - apiMaterialPhong.displacementBias, - apiMaterialPhong.emissive, - apiMaterialPhong.emissiveMap, - apiMaterialPhong.emissiveIntensity, - apiMaterialPhong.envMap, - apiMaterialPhong.lightMap, - apiMaterialPhong.lightMapIntensity, - apiMaterialPhong.diffuseMap, - apiMaterialPhong.morphNormals, - apiMaterialPhong.morphTargets, - apiMaterialPhong.normalMap, - apiMaterialPhong.normalScale, - apiMaterialPhong.reflectivity, - apiMaterialPhong.refractionRatio, - apiMaterialPhong.shininess, - apiMaterialPhong.skinning, - apiMaterialPhong.specular, - apiMaterialPhong.specularMap, - apiMaterialPhong.wireframe, - apiMaterialPhong.wireframeLinecap, - apiMaterialPhong.wireframeLinejoin, - apiMaterialPhong.wireframeLinewidth - ); - - if (this.alphaMap instanceof R3.D3.API.Texture) { - this.alphaMap = R3.Component.ConstructFromObject(this.alphaMap); - } - - if (this.aoMap instanceof R3.D3.API.Texture) { - this.aoMap = R3.Component.ConstructFromObject(this.aoMap); - } - - if (this.bumpMap instanceof R3.D3.API.Texture) { - this.bumpMap = R3.Component.ConstructFromObject(this.bumpMap); - } - - this.color = new R3.Color( - this.graphics, - this.color, - this - ); - - if (this.displacementMap instanceof R3.D3.API.Texture) { - this.displacementMap = R3.Component.ConstructFromObject(this.displacementMap); - } - - this.emissive = new R3.Color( - this.graphics, - this.emissive, - this - ); - - if (this.emissiveMap instanceof R3.D3.API.Texture) { - this.emissiveMap = R3.Component.ConstructFromObject(this.emissiveMap); - } - - if (this.envMap instanceof R3.D3.API.Texture) { - this.envMap = R3.Component.ConstructFromObject(this.envMap); - } - - if (this.lightMap instanceof R3.D3.API.Texture) { - this.lightMap = R3.Component.ConstructFromObject(this.lightMap); - } - - if (this.diffuseMap instanceof R3.D3.API.Texture) { - this.diffuseMap = R3.Component.ConstructFromObject(this.diffuseMap); - } - - if (this.normalMap instanceof R3.D3.API.Texture) { - this.normalMap = R3.Component.ConstructFromObject(this.normalMap); - } - - this.specular = new R3.Color( - this.graphics, - this.specular, - this - ); - - if (this.specularMap instanceof R3.D3.API.Texture) { - this.specularMap = R3.Component.ConstructFromObject(this.specularMap); - } - R3.D3.Material.call( this, - this.graphics, - this + true ); }; @@ -128,43 +25,9 @@ R3.D3.Material.Phong.prototype.constructor = R3.D3.Material.Phong; */ R3.D3.Material.Phong.prototype.createInstance = function() { - this.instance = new THREE.MeshPhongMaterial( - { - alphaMap : this.alphaMap ? this.alphaMap.instance : null, - aoMap : this.aoMap ? this.aoMap.instance : null, - aoMapIntensity : this.aoMapIntensity, - bumpMap : this.bumpMap ? this.bumpMap.instance : null, - bumpScale : this.bumpScale, - color : this.color.instance, - combine : this.combine, - displacementMap : this.displacementMap ? this.displacementMap.instance : null, - displacementScale : this.displacementScale, - displacementBias : this.displacementBias, - emissive : this.emissive.instance, - emissiveMap : this.emissiveMap ? this.emissiveMap.instance : null, - emissiveIntensity : this.emissiveIntensity, - envMap : this.envMap ? this.envMap.instance : null, - lightMap : this.lightMap ? this.lightMap.instance : null, - lightMapIntensity : this.lightMapIntensity, - map : this.diffuseMap ? this.diffuseMap.instance : null, - morphNormals : this.morphNormals, - morphTargets : this.morphTargets, - normalMap : this.normalMap ? this.normalMap.instance : null, - normalScale : this.normalScale, - reflectivity : this.reflectivity, - refractionRatio : this.refractionRatio, - shininess : this.shininess, - skinning : this.skinning, - specular : this.specular.instance, - specularMap : this.specularMap ? this.specularMap.instance : null, - wireframe : this.wireframe, - wireframeLinecap : this.wireframeLinecap, - wireframeLinejoin : this.wireframeLinejoin, - wireframeLinewidth : this.wireframeLinewidth - } - ); + this.instance = this.graphics.MaterialPhong(this); - R3.D3.Material.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -204,7 +67,6 @@ R3.D3.Material.Phong.prototype.updateInstance = function(property) { if (property === 'combine') { this.instance.combine = this.combine; - this.instance.needsUpdate = true; return; } @@ -330,49 +192,3 @@ R3.D3.Material.Phong.prototype.updateInstance = function(property) { R3.D3.Material.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Material.Phong to a R3.D3.API.Material.Phong - * @returns {R3.D3.API.Material.Phong} - */ -R3.D3.Material.Phong.prototype.toApiObject = function() { - - var apiMaterial = R3.D3.Material.prototype.toApiObject.call(this); - - var apiMaterialPhong = new R3.D3.API.Material.Phong( - apiMaterial, - R3.Utils.IdOrNull(this.alphaMap), - R3.Utils.IdOrNull(this.aoMap), - this.aoMapIntensity, - R3.Utils.IdOrNull(this.bumpMap), - this.bumpScale, - this.color.toApiObject(), - this.combine, - R3.Utils.IdOrNull(this.displacementMap), - this.displacementScale, - this.displacementBias, - this.emissive.toApiObject(), - R3.Utils.IdOrNull(this.emissiveMap), - this.emissiveIntensity, - R3.Utils.IdOrNull(this.envMap), - R3.Utils.IdOrNull(this.lightMap), - this.lightMapIntensity, - R3.Utils.IdOrNull(this.diffuseMap), - this.morphNormals, - this.morphTargets, - R3.Utils.IdOrNull(this.normalMap), - this.normalScale, - this.reflectivity, - this.refractionRatio, - this.shininess, - this.skinning, - this.specular.toApiObject(), - R3.Utils.IdOrNull(this.specularMap), - this.wireframe, - this.wireframeLinecap, - this.wireframeLinejoin, - this.wireframeLinewidth - ); - - return apiMaterialPhong; -}; diff --git a/src/r3-d3-material-points.js b/src/r3-d3-material-points.js index f8a25ab..de80067 100644 --- a/src/r3-d3-material-points.js +++ b/src/r3-d3-material-points.js @@ -1,45 +1,17 @@ /** * R3.D3.Material.Points - * @param graphics - * @param apiMaterialPoints + * @param apiComponent * @constructor */ R3.D3.Material.Points = function( - graphics, - apiMaterialPoints + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiMaterialPoints)) { - apiMaterialPoints = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_POINTS - }; - } - - R3.D3.API.Material.Points.call( - this, - apiMaterialPoints, - apiMaterialPoints.color, - apiMaterialPoints.diffuseMap, - apiMaterialPoints.size, - apiMaterialPoints.sizeAttenuation - ); - - this.color = new R3.Color( - this.graphics, - this.color, - this - ); - - if (this.diffuseMap instanceof R3.D3.API.Texture) { - this.diffuseMap = R3.Component.ConstructFromObject(this.diffuseMap); - } + __RUNTIME_COMPONENT__; R3.D3.Material.call( this, - this.graphics, - this + true ); }; @@ -53,16 +25,10 @@ R3.D3.Material.Points.prototype.constructor = R3.D3.Material.Points; */ R3.D3.Material.Points.prototype.createInstance = function() { - this.instance = new THREE.PointsMaterial( - { - color : this.color.instance, - map : this.diffuseMap ? this.diffuseMap.instance : null, - size : this.size, - sizeAttenuation : this.sizeAttenuation - } - ); + this.instance = this.graphics.MaterialPoints(this); - R3.D3.Material.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }; /** @@ -80,6 +46,11 @@ R3.D3.Material.Points.prototype.updateInstance = function(property) { return; } + if (property === 'morphTargets') { + this.instance.morphTargets = this.morphTargets; + return; + } + if (property === 'size') { this.instance.size = this.size; return; @@ -87,28 +58,8 @@ R3.D3.Material.Points.prototype.updateInstance = function(property) { if (property === 'sizeAttenuation') { this.instance.sizeAttenuation = this.sizeAttenuation; - this.instance.needsUpdate = true; return; } R3.D3.Material.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Material.Points to a R3.D3.API.Material.Points - * @returns {R3.D3.API.Material.Points} - */ -R3.D3.Material.Points.prototype.toApiObject = function() { - - var apiMaterial = R3.D3.Material.prototype.toApiObject.call(this); - - var apiMaterialPoints = new R3.D3.API.Material.Points( - apiMaterial, - this.color.toApiObject(), - R3.Utils.IdOrNull(this.diffuseMap), - this.size, - this.sizeAttenuation - ); - - return apiMaterialPoints; -}; diff --git a/src/r3-d3-material-shader-0.js b/src/r3-d3-material-shader-0.js new file mode 100644 index 0000000..01711f3 --- /dev/null +++ b/src/r3-d3-material-shader-0.js @@ -0,0 +1,153 @@ +/** + * R3.D3.Material.Shader + * @param apiComponent + * @param inherited + * @constructor + */ +R3.D3.Material.Shader = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + + __RUNTIME_COMPONENT__; + + } + + R3.D3.Material.call( + this, + true + ); + +}; + +R3.D3.Material.Shader.prototype = Object.create(R3.D3.Material.prototype); +R3.D3.Material.Shader.prototype.constructor = R3.D3.Material.Shader; + +R3.D3.Material.Shader.prototype.commonInstance = function() { +}; + +/** + * Creates an instance of our texture object + * @returns {*} + */ +R3.D3.Material.Shader.prototype.createInstance = function() { + + this.instance = this.graphics.MaterialShader(this); + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.D3.Material.Shader.prototype.updateInstance = function(property) { + + if (!this.instance) { + + if ( + property === 'vertexShader' || + property === 'fragmentShader' + ) { + this.createInstance(); + } + + /** + * If we don't return here - we risk storing this incomplete type with the entity.. + */ + + return; + } + + if (property === 'clipping') { + this.instance.clipping = this.clipping; + return; + } + + if (property === 'defaultAttributeValues') { + this.instance.defaultAttributeValues = this.defaultAttributeValues; + return; + } + + if (property === 'defines') { + this.instance.defines = this.defines; + return; + } + + if (property === 'extensions') { + this.instance.extensions = this.extensions; + return; + } + + if (property === 'fragmentShader') { + + if (this.fragmentShader && this.fragmentShader.instance) { + this.instance.fragmentShader = this.fragmentShader.instance; + this.instance.needsUpdate = true; + } else { + console.warn('fragment shader for material has been removed or not linked - using last valid fragment shader'); + } + return; + } + + if (property === 'index0AttributeName') { + this.instance.index0AttributeName = this.index0AttributeName; + return; + } + + if (property === 'linewidth') { + this.instance.linewidth = this.linewidth; + return; + } + + if (property === 'morphTargets') { + this.instance.morphTargets = this.morphTargets; + return; + } + + if (property === 'morphNormals') { + this.instance.morphNormals = this.morphNormals; + return; + } + + if (property === 'program') { + console.warn('program is read only'); + return; + } + + if (property === 'skinning') { + this.instance.skinning = this.skinning; + return; + } + + if (property === 'uniforms') { + this.instance.uniforms = this.uniforms; + return; + } + + if (property === 'vertexShader') { + + if (this.vertexShader && this.vertexShader.instance) { + this.instance.vertexShader = this.vertexShader.instance; + this.instance.needsUpdate = true; + } else { + console.warn('vertex shader for material has been removed or not linked - using last valid vertex shader'); + } + + return; + } + + if (property === 'wireframe') { + this.instance.wireframe = this.wireframe; + return; + } + + if (property === 'wireframeLinewidth') { + this.instance.wireframeLinewidth = this.wireframeLinewidth; + return; + } + + R3.D3.Material.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-d3-material-shader-a.js b/src/r3-d3-material-shader-a.js deleted file mode 100644 index 02e1fb5..0000000 --- a/src/r3-d3-material-shader-a.js +++ /dev/null @@ -1,263 +0,0 @@ -/** - * R3.D3.Material.Shader - * @param graphics - * @param apiMaterialShader - * @constructor - */ -R3.D3.Material.Shader = function( - graphics, - apiMaterialShader -) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiMaterialShader)) { - apiMaterialShader = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_SHADER - }; - } - - R3.D3.API.Material.Shader.call( - this, - apiMaterialShader, - apiMaterialShader.clipping, - apiMaterialShader.defaultAttributeValues, - apiMaterialShader.extensions, - apiMaterialShader.fog, - apiMaterialShader.fragmentShader, - apiMaterialShader.index0AttributeName, - apiMaterialShader.linewidth, - apiMaterialShader.morphTargets, - apiMaterialShader.morphNormals, - apiMaterialShader.program, - apiMaterialShader.skinning, - apiMaterialShader.uniforms, - apiMaterialShader.vertexColors, - apiMaterialShader.vertexShader, - apiMaterialShader.wireframe, - apiMaterialShader.wireframeLinewidth - ); - - this.vertexColors = true; - - R3.D3.Material.call( - this, - this.graphics, - this - ); - -}; - -R3.D3.Material.Shader.prototype = Object.create(R3.D3.Material.prototype); -R3.D3.Material.Shader.prototype.constructor = R3.D3.Material.Shader; - -R3.D3.Material.Shader.prototype.commonInstance = function() { -}; - -/** - * Creates an instance of our texture object - * @returns {*} - */ -R3.D3.Material.Shader.prototype.createInstance = function() { - - if (this.instance) { - - /** - * We already have an instance from Child Class - */ - - } else { - - if ( - R3.Utils.UndefinedOrNull(this.vertexShader) || - R3.Utils.UndefinedOrNull(this.vertexShader.instance) - ) { - console.warn('shader material ' + this.name + 'not ready for instance - needs a vertex shader'); - return; - } - - if ( - R3.Utils.UndefinedOrNull(this.fragmentShader) || - R3.Utils.UndefinedOrNull(this.fragmentShader.instance) - ) { - console.warn('shader material ' + this.name + 'not ready for instance - needs a fragment shader'); - return; - } - - this.instance = new THREE.ShaderMaterial( - { - clipping : this.clipping, - defaultAttributeValues : this.defaultAttributeValues, - extensions : this.extensions, - fog : this.fog, - fragmentShader : this.fragmentShader.instance, - linewidth : this.linewidth, - morphTargets : this.morphTargets, - morphNormals : this.morphNormals, - skinning : this.skinning, - uniforms : this.uniforms, - vertexColors : this.vertexColors, - vertexShader : this.vertexShader.instance, - wireframe : this.wireframe, - wireframeLinewidth : this.wireframeLinewidth - } - ); - } - - if (R3.Utils.Defined(this.index0AttributeName)) { - this.instance.index0AttributeName = this.index0AttributeName; - } - - console.log('shader material instance created'); - - R3.D3.Material.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Material.Shader.prototype.updateInstance = function(property) { - - if (!this.instance) { - - if ( - property === 'vertexShader' || - property === 'fragmentShader' - ) { - this.createInstance(); - } - - /** - * If we don't return here - we risk storing this incomplete type with the entity.. - */ - - return; - } - - if (property === 'clipping') { - this.instance.clipping = this.clipping; - return; - } - - if (property === 'defaultAttributeValues') { - this.instance.defaultAttributeValues = this.defaultAttributeValues; - return; - } - - if (property === 'extensions') { - this.instance.extensions = this.extensions; - return; - } - - if (property === 'fog') { - this.instance.fog = this.fog; - return; - } - - if (property === 'fragmentShader') { - - if (this.fragmentShader && this.fragmentShader.instance) { - this.instance.fragmentShader = this.fragmentShader.instance; - this.instance.needsUpdate = true; - } else { - console.warn('fragment shader for material has been removed or not linked - using last valid fragment shader'); - } - return; - } - - if (property === 'index0AttributeName') { - this.instance.index0AttributeName = this.index0AttributeName; - return; - } - - if (property === 'linewidth') { - this.instance.linewidth = this.linewidth; - return; - } - - if (property === 'morphNormals') { - this.instance.morphNormals = this.morphNormals; - return; - } - - if (property === 'morphTargets') { - this.instance.morphTargets = this.morphTargets; - return; - } - - if (property === 'program') { - console.warn('program is read only'); - this.program = this.instance.program; - } - - if (property === 'skinning') { - this.instance.skinning = this.skinning; - return; - } - - if (property === 'uniforms') { - this.instance.uniforms = this.uniforms; - return; - } - - if (property === 'vertexShader') { - - if (this.vertexShader && this.vertexShader.instance) { - this.instance.vertexShader = this.vertexShader.instance; - this.instance.needsUpdate = true; - } else { - console.warn('vertex shader for material has been removed or not linked - using last valid vertex shader'); - } - - return; - } - - if (property === 'vertexColors') { - this.instance.vertexColors = this.vertexColors; - this.instance.needsUpdate = true; - return; - } - - if (property === 'wireframe') { - this.instance.wireframe = this.wireframe; - return; - } - - if (property === 'wireframeLinewidth') { - this.instance.wireframeLinewidth = this.wireframeLinewidth; - return; - } - - R3.D3.Material.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Material.Shader to a R3.D3.API.Material.Shader - * @returns {R3.D3.API.Material.Shader} - */ -R3.D3.Material.Shader.prototype.toApiObject = function() { - - var apiMaterial = R3.D3.Material.prototype.toApiObject.call(this); - - var apiMaterialShader = new R3.D3.API.Material.Shader( - apiMaterial, - this.clipping, - this.defaultAttributeValues, - this.extensions, - this.fog, - R3.Utils.IdOrNull(this.fragmentShader), - this.index0AttributeName, - this.linewidth, - this.morphTargets, - this.morphNormals, - null, - this.skinning, - this.uniforms, - this.vertexColors, - R3.Utils.IdOrNull(this.vertexShader), - this.wireframe, - this.wireframeLinewidth - ); - - return apiMaterialShader; -}; diff --git a/src/r3-d3-material-shader-raw.js b/src/r3-d3-material-shader-raw.js index ebeb6fa..66f2e36 100644 --- a/src/r3-d3-material-shader-raw.js +++ b/src/r3-d3-material-shader-raw.js @@ -1,31 +1,18 @@ /** * R3.D3.Material.Shader.Raw - * @param graphics - * @param apiMaterialShaderRaw + * @param apiComponent * @constructor */ R3.D3.Material.Shader.Raw = function( - graphics, - apiMaterialShaderRaw + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiMaterialShaderRaw)) { - apiMaterialShaderRaw = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_SHADER_RAW - }; - } - - R3.D3.API.Material.Shader.Raw.call( - this, - apiMaterialShaderRaw - ); + __RUNTIME_COMPONENT__; R3.D3.Material.Shader.call( this, - this.graphics, - this + apiComponent, + true ); }; @@ -39,62 +26,17 @@ R3.D3.Material.Shader.Raw.prototype.constructor = R3.D3.Material.Shader.Raw; */ R3.D3.Material.Shader.Raw.prototype.createInstance = function() { - if ( - R3.Utils.UndefinedOrNull(this.vertexShader) || - R3.Utils.UndefinedOrNull(this.vertexShader.instance) - ) { - console.warn('shader material ' + this.name + 'not ready for instance - needs a vertex shader'); - return; - } + this.instance = this.graphics.MaterialShaderRaw(this); - if ( - R3.Utils.UndefinedOrNull(this.fragmentShader) || - R3.Utils.UndefinedOrNull(this.fragmentShader.instance) - ) { - console.warn('shader material ' + this.name + 'not ready for instance - needs a fragment shader'); - return; - } + __CREATE_INSTANCE__; - this.instance = new THREE.RawShaderMaterial( - { - clipping : this.clipping, - defaultAttributeValues : this.defaultAttributeValues, - extensions : this.extensions, - fog : this.fog, - fragmentShader : this.fragmentShader.instance, - linewidth : this.linewidth, - morphTargets : this.morphTargets, - morphNormals : this.morphNormals, - skinning : this.skinning, - uniforms : this.uniforms, - vertexColors : this.vertexColors, - vertexShader : this.vertexShader.instance, - wireframe : this.wireframe, - wireframeLinewidth : this.wireframeLinewidth - } - ); - - R3.D3.Material.Shader.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ R3.D3.Material.Shader.Raw.prototype.updateInstance = function(property) { + R3.D3.Material.Shader.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Material.Shader.Raw to a R3.D3.API.Material.Shader.Raw - * @returns {R3.D3.API.Material.Shader.Raw} - */ -R3.D3.Material.Shader.Raw.prototype.toApiObject = function() { - - var apiMaterialShader = R3.D3.Material.Shader.prototype.toApiObject.call(this); - - var apiMaterialShaderRaw = new R3.D3.API.Material.Shader.Raw( - apiMaterialShader - ); - - return apiMaterialShaderRaw; + }; diff --git a/src/r3-d3-material-standard.js b/src/r3-d3-material-standard.js index 925c84c..3b8ffdf 100644 --- a/src/r3-d3-material-standard.js +++ b/src/r3-d3-material-standard.js @@ -1,120 +1,20 @@ /** * R3.D3.Material.Standard - * @param graphics - * @param apiMaterialStandard + * @param apiComponent * @constructor */ R3.D3.Material.Standard = function( - graphics, - apiMaterialStandard + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiMaterialStandard)) { - apiMaterialStandard = { - materialType : R3.D3.API.Material.MATERIAL_TYPE_STANDARD - }; - } + __RUNTIME_COMPONENT__; - R3.D3.API.Material.Standard.call( + R3.D3.Material.Shader.call( this, - apiMaterialStandard, - apiMaterialStandard.alphaMap, - apiMaterialStandard.aoMap, - apiMaterialStandard.aoMapIntensity, - apiMaterialStandard.bumpMap, - apiMaterialStandard.bumpScale, - apiMaterialStandard.color, - apiMaterialStandard.displacementMap, - apiMaterialStandard.displacementScale, - apiMaterialStandard.displacementBias, - apiMaterialStandard.emissive, - apiMaterialStandard.emissiveMap, - apiMaterialStandard.emissiveIntensity, - apiMaterialStandard.envMap, - apiMaterialStandard.envMapIntensity, - apiMaterialStandard.lightMap, - apiMaterialStandard.lightMapIntensity, - apiMaterialStandard.diffuseMap, - apiMaterialStandard.metalness, - apiMaterialStandard.metalnessMap, - apiMaterialStandard.morphNormals, - apiMaterialStandard.morphTargets, - apiMaterialStandard.normalMap, - apiMaterialStandard.normalScale, - apiMaterialStandard.refractionRatio, - apiMaterialStandard.roughness, - apiMaterialStandard.roughnessMap, - apiMaterialStandard.skinning, - apiMaterialStandard.wireframe, - apiMaterialStandard.wireframeLinecap, - apiMaterialStandard.wireframeLinejoin, - apiMaterialStandard.wireframeLinewidth + apiComponent, + true ); - if (this.alphaMap instanceof R3.D3.API.Texture) { - this.alphaMap = R3.Component.ConstructFromObject(this.alphaMap); - } - - if (this.aoMap instanceof R3.D3.API.Texture) { - this.aoMap = R3.Component.ConstructFromObject(this.aoMap); - } - - if (this.bumpMap instanceof R3.D3.API.Texture) { - this.bumpMap = R3.Component.ConstructFromObject(this.bumpMap); - } - - - this.color = new R3.Color( - this.graphics, - this.color, - this - ); - - if (this.displacementMap instanceof R3.D3.API.Texture) { - this.displacementMap = R3.Component.ConstructFromObject(this.displacementMap); - } - - this.emissive = new R3.Color( - this.graphics, - this.emissive, - this - ); - - if (this.emissiveMap instanceof R3.D3.API.Texture) { - this.emissiveMap = R3.Component.ConstructFromObject(this.emissiveMap); - } - - if (this.envMap instanceof R3.D3.API.Texture) { - this.envMap = R3.Component.ConstructFromObject(this.envMap); - } - - if (this.lightMap instanceof R3.D3.API.Texture) { - this.lightMap = R3.Component.ConstructFromObject(this.lightMap); - } - - if (this.diffuseMap instanceof R3.D3.API.Texture) { - this.diffuseMap = R3.Component.ConstructFromObject(this.diffuseMap); - } - - if (this.metalnessMap instanceof R3.D3.API.Texture) { - this.metalnessMap = R3.Component.ConstructFromObject(this.metalnessMap); - } - - if (this.normalMap instanceof R3.D3.API.Texture) { - this.normalMap = R3.Component.ConstructFromObject(this.normalMap); - } - - if (this.roughnessMap instanceof R3.D3.API.Texture) { - this.roughnessMap = R3.Component.ConstructFromObject(this.roughnessMap); - } - - R3.D3.Material.call( - this, - this.graphics, - this - ); }; @@ -127,43 +27,10 @@ R3.D3.Material.Standard.prototype.constructor = R3.D3.Material.Standard; */ R3.D3.Material.Standard.prototype.createInstance = function() { - this.instance = new THREE.MeshStandardMaterial( - { - alphaMap : this.alphaMap ? this.alphaMap.instance : null, - aoMap : this.aoMap ? this.aoMap.instance : null, - aoMapIntensity : this.aoMapIntensity, - bumpMap : this.bumpMap ? this.bumpMap.instance : null, - bumpScale : this.bumpScale, - color : this.color.instance, - displacementMap : this.displacementMap ? this.displacementMap.instance : null, - displacementScale : this.displacementScale, - displacementBias : this.displacementBias, - emissive : this.emissive.instance, - emissiveMap : this.emissiveMap ? this.emissiveMap.instance : null, - emissiveIntensity : this.emissiveIntensity, - envMap : this.envMap ? this.envMap.instance : null, - envMapIntensity : this.envMapIntensity, - lightMap : this.lightMap ? this.lightMap.instance : null, - lightMapIntensity : this.lightMapIntensity, - map : this.diffuseMap ? this.diffuseMap.instance : null, - metalness : this.metalness, - metalnessMap : this.metalnessMap ? this.metalnessMap.instance : null, - morphNormals : this.morphNormals, - morphTargets : this.morphTargets, - normalMap : this.normalMap ? this.normalMap.instance : null, - normalScale : this.normalScale, - refractionRatio : this.refractionRatio, - roughness : this.roughness, - roughnessMap : this.roughnessMap ? this.roughnessMap.instance : null, - skinning : this.skinning, - wireframe : this.wireframe, - wireframeLinecap : this.wireframeLinecap, - wireframeLinejoin : this.wireframeLinejoin, - wireframeLinewidth : this.wireframeLinewidth - } - ); - - R3.D3.Material.prototype.createInstance.call(this); + this.instance = this.graphics.MaterialStandard(this); + + __CREATE_INSTANCE__; + }; /** @@ -328,49 +195,3 @@ R3.D3.Material.Standard.prototype.updateInstance = function(property) { R3.D3.Material.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Material.Standard to a R3.D3.API.Material.Standard - * @returns {R3.D3.API.Material.Standard} - */ -R3.D3.Material.Standard.prototype.toApiObject = function() { - - var apiMaterial = R3.D3.Material.prototype.toApiObject.call(this); - - var apiMaterialStandard = new R3.D3.API.Material.Standard( - apiMaterial, - R3.Utils.IdOrNull(this.alphaMap), - R3.Utils.IdOrNull(this.aoMap), - this.aoMapIntensity, - R3.Utils.IdOrNull(this.bumpMap), - this.bumpScale, - this.color.toApiObject(), - R3.Utils.IdOrNull(this.displacementMap), - this.displacementScale, - this.displacementBias, - this.emissive.toApiObject(), - R3.Utils.IdOrNull(this.emissiveMap), - this.emissiveIntensity, - R3.Utils.IdOrNull(this.envMap), - this.envMapIntensity, - R3.Utils.IdOrNull(this.lightMap), - this.lightMapIntensity, - R3.Utils.IdOrNull(this.diffuseMap), - this.metalness, - R3.Utils.IdOrNull(this.metalnessMap), - this.morphNormals, - this.morphTargets, - R3.Utils.IdOrNull(this.normalMap), - this.normalScale, - this.refractionRatio, - this.roughness, - R3.Utils.IdOrNull(this.roughnessMap), - this.skinning, - this.wireframe, - this.wireframeLinecap, - this.wireframeLinejoin, - this.wireframeLinewidth - ); - - return apiMaterialStandard; -}; diff --git a/src/r3-d3-mesh-0.js b/src/r3-d3-mesh-0.js index b4852f6..eb17b28 100644 --- a/src/r3-d3-mesh-0.js +++ b/src/r3-d3-mesh-0.js @@ -1,96 +1,24 @@ /** * R3.D3.Mesh - * @param graphics R3.Runtime.Graphics - * @param apiD3ObjectMesh R3.D3.API.Mesh - * @property geometry + * @param apiComponent + * @param inherited * @constructor */ R3.D3.Mesh = function( - graphics, - apiD3ObjectMesh + apiComponent, + inherited ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiD3ObjectMesh)) { - apiD3ObjectMesh = { - objectType: R3.D3.API.Object.OBJECT_TYPE_MESH - }; + if (R3.Utils.UndefinedOrNull(inherited)) { + __RUNTIME_COMPONENT__; } - linkedObjects.parentMesh = R3.D3.Mesh; - linkedObjects.parentScene = R3.D3.Scene; - linkedObjects.materials = [R3.D3.Material]; - linkedObjects.geometry = R3.D3.Geometry; - linkedObjects.skeleton = R3.D3.Skeleton; - - R3.D3.API.Mesh.call( - this, - apiD3ObjectMesh, - apiD3ObjectMesh.geometry, - apiD3ObjectMesh.materials, - apiD3ObjectMesh.parentMesh, - apiD3ObjectMesh.parentScene, - apiD3ObjectMesh.excludeFromEnvironmentMapMap, - apiD3ObjectMesh.skeleton, - apiD3ObjectMesh.renderOrder, - apiD3ObjectMesh.visible, - apiD3ObjectMesh.castShadow, - apiD3ObjectMesh.receiveShadow, - apiD3ObjectMesh.drawMode, - apiD3ObjectMesh.morphTargetInfluences, - apiD3ObjectMesh.morphTargetDictionary, - apiD3ObjectMesh.cloneDirection - ); - - if ( - R3.Utils.Defined(this.geometry) && - R3.Utils.Defined(this.geometry.componentType) && - !(this.geometry instanceof R3.D3.Geometry) - ) { - this.geometry = R3.Component.ConstructFromObject(this.geometry); - } - - this.materials = this.materials.map( - function(material) { - - if ( - R3.Utils.Defined(material.componentType) && - !(material instanceof R3.D3.Material) - ) { - return R3.Component.ConstructFromObject(material); - } else { - return material; - } - - }.bind(this) - ); - - if ( - R3.Utils.Defined(this.skeleton) && - R3.Utils.Defined(this.skeleton.componentType) && - !(this.skeleton instanceof R3.D3.Skeleton) - ) { - this.skeleton = R3.Component.ConstructFromObject(this.skeleton); - } - - this.cloneDirection = new R3.Vector3( - this.graphics, - this.cloneDirection, - this - ); - - /** - * Runtime meshes have helpers too - * @type {null} - */ - this.helper = null; - R3.D3.Object.call( this, - this.graphics, - this + apiComponent, + true ); + }; R3.D3.Mesh.prototype = Object.create(R3.D3.Object.prototype); @@ -101,83 +29,10 @@ R3.D3.Mesh.prototype.constructor = R3.D3.Mesh; */ R3.D3.Mesh.prototype.createInstance = function() { - this.updateInstance('rotation'); - this.updateInstance('scale'); - this.updateInstance('position'); + this.instance = this.graphics.Mesh(this); - if ( - R3.Utils.UndefinedOrNull(this.geometry) || - R3.Utils.UndefinedOrNull(this.geometry.instance) - ) { - console.warn('geometry not ready for this mesh ' + this.name); - return; - } + __CREATE_INSTANCE__; - this.geometry.parentMesh = this; - this.geometry.updateInstance('parentMesh'); - - var materialInstances = R3.Utils.GetArrayInstances(this.materials); - - if ( - R3.Utils.UndefinedOrNull(materialInstances) - ) { - console.warn('materials not ready for this mesh ' + this.name); - return; - } - - if (this.skeleton) { - - this.instance = new THREE.SkinnedMesh( - this.geometry.instance, - materialInstances - ); - - this.instance.add(this.skeleton.rootBoneInstance); - this.instance.bind(this.skeleton.instance); - - } else { - this.instance = new THREE.Mesh( - this.geometry.instance, - materialInstances - ); - } - - this.instance.name = this.name; - - if (R3.Utils.Defined(this.parentMesh)) { - - if (R3.Utils.UndefinedOrNull(this.parentMesh.instance)) { - console.warn('parent mesh not linked at time of create instance'); - } else { - this.parentMesh.add(this.instance, this); - } - - } - - if ( - R3.Utils.Defined(this.parentScene) && - R3.Utils.Defined(this.parentScene.instance) - ) { - this.parentScene.addObject(this); - } - - this.instance.renderOrder = this.renderOrder; - - this.instance.visible = this.visible; - - this.instance.castShadow = this.castShadow; - - this.instance.receiveShadow = this.receiveShadow; - - this.instance.drawMode = this.drawMode; - - /** - * The rest we update from the instance - */ - this.morphTargetInfluences = this.instance.morphTargetInfluences; - this.morphTargetDictionary = this.instance.morphTargetDictionary; - - R3.D3.Object.prototype.createInstance.call(this); }; /** @@ -185,10 +40,6 @@ R3.D3.Mesh.prototype.createInstance = function() { */ R3.D3.Mesh.prototype.updateInstance = function(property) { - if (R3.Utils.UndefinedOrNull(property)) { - console.warn('unknown mesh property update'); - } - if (property === 'geometry') { if (R3.Utils.Defined(this.geometry)) { @@ -249,11 +100,6 @@ R3.D3.Mesh.prototype.updateInstance = function(property) { return; } - if (R3.Utils.UndefinedOrNull(this.instance)) { - console.warn('mesh instance not ready - needs a material and geometry'); - return; - } - if (property === 'name') { this.instance.name = this.name; return; @@ -402,42 +248,6 @@ R3.D3.Mesh.prototype.updateInstance = function(property) { } }; - -/** - * Converts a R3.D3.Mesh to a R3.D3.API.Mesh - * TODO: morph stuff - * @returns {R3.D3.API.Mesh} - */ -R3.D3.Mesh.prototype.toApiObject = function() { - - var apiD3Object = R3.D3.Object.prototype.toApiObject.call(this); - - var apiMesh = new R3.D3.API.Mesh( - apiD3Object, - - R3.Utils.IdOrNull(this.geometry), - this.materials.map( - function(material) { - return R3.Utils.IdOrNull(material) - } - ), - R3.Utils.IdOrNull(this.parentMesh), - R3.Utils.IdOrNull(this.parentScene), - this.excludeFromEnvironmentMapMap, - R3.Utils.IdOrNull(this.skeleton), - this.renderOrder, - this.visible, - this.castShadow, - this.receiveShadow, - this.drawMode, - null,//morphTargetInfluences, - null,//morphTargetDictionary - this.cloneDirection.toApiObject() - ); - - return apiMesh; -}; - R3.D3.Mesh.prototype.clone = function() { var name = this.name + '(' + this.cloneNumber + ')'; diff --git a/src/r3-d3-mesh-skeleton.js b/src/r3-d3-mesh-skeleton.js new file mode 100644 index 0000000..61b1882 --- /dev/null +++ b/src/r3-d3-mesh-skeleton.js @@ -0,0 +1,52 @@ +/** + * R3.D3.Mesh + * @param apiComponent + * @constructor + */ +R3.D3.Mesh.Skeleton = function( + apiComponent +) { + + + __RUNTIME_COMPONENT__; + + R3.D3.Mesh.call( + this, + apiComponent, + true + ); + +}; + +R3.D3.Mesh.Skeleton.prototype = Object.create(R3.D3.Mesh.prototype); +R3.D3.Mesh.Skeleton.prototype.constructor = R3.D3.Mesh.Skeleton; + +/** + * Creates a mesh instance or updates it + */ +R3.D3.Mesh.Skeleton.prototype.createInstance = function() { + + this.instance = this.graphics.MeshSkeleton(this); + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the mesh instance + */ +R3.D3.Mesh.Skeleton.prototype.updateInstance = function(property) { + + if (property === 'skeleton') { + throw new Error('todo: skeleton update'); + } + + R3.D3.Mesh.prototype.updateInstance.call(this, property); + +}; + +R3.D3.Mesh.Skeleton.prototype.clone = function() { + + throw new Error('todo: R3.D3.Mesh.Skeleton.prototype.clone()'); + +}; \ No newline at end of file diff --git a/src/r3-d3-particle.js b/src/r3-d3-particle-0.js similarity index 98% rename from src/r3-d3-particle.js rename to src/r3-d3-particle-0.js index 19108f2..a1103ca 100644 --- a/src/r3-d3-particle.js +++ b/src/r3-d3-particle-0.js @@ -102,7 +102,7 @@ R3.D3.Particle.prototype.createInstance = function() { this.instance = this.mesh.instance; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -147,7 +147,7 @@ R3.D3.Particle.prototype.updateInstance = function(property) { } } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-particle-engine.js b/src/r3-d3-particle-engine.js index 45f3514..4d5b5bf 100644 --- a/src/r3-d3-particle-engine.js +++ b/src/r3-d3-particle-engine.js @@ -94,7 +94,7 @@ R3.D3.ParticleEngine.prototype.createInstance = function() { // this.templateParticle.scale.z = this.scale.z; // } - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -126,7 +126,7 @@ R3.D3.ParticleEngine.prototype.updateInstance = function(property) { this.templateParticle.direction.updateInstance('direction', true); } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; R3.D3.ParticleEngine.prototype.remove = function() { diff --git a/src/r3-d3-pass-0.js b/src/r3-d3-pass-0.js index 3aff256..e09f8d8 100644 --- a/src/r3-d3-pass-0.js +++ b/src/r3-d3-pass-0.js @@ -1,69 +1,42 @@ /** * R3.D3.Pass - * @param graphics R3.Runtime.Graphics - * @param apiPass R3.D3.API.Pass - * @property passType + * @param inherited * @constructor */ R3.D3.Pass = function( - graphics, - apiPass + inherited ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiPass)) { - apiPass = { - passType : R3.D3.API.Pass.PASS_TYPE_NONE - } + /** + * This class is intended to be inherited only + */ + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('This class can only be inherited'); } - R3.D3.API.Pass.call( - this, - apiPass.id, - apiPass.name, - apiPass.passType, - apiPass.parent, - apiPass.renderToScreen - ); + __UPGRADE_TO_RUNTIME__; - var linkedObjects = {}; - - switch (this.passType) { - case R3.D3.API.Pass.PASS_TYPE_RENDER: - case R3.D3.API.Pass.PASS_TYPE_SSAO: - linkedObjects.scene = R3.D3.Scene; - linkedObjects.camera = R3.D3.Camera; - break; - default : - break; - } - - R3.Component.call( - this, - linkedObjects - ); }; R3.D3.Pass.prototype = Object.create(R3.Component.prototype); R3.D3.Pass.prototype.constructor = R3.D3.Pass; - /** - * Create Pass instance + * This class has no instance but shares functionality will all passes * @returns {*} */ R3.D3.Pass.prototype.createInstance = function() { if (R3.Utils.UndefinedOrNull(this.instance)) { - console.warn('no instance - call the child createInstance() first'); - return; + throw new Error('No R3.D3.Pass.prototype.instance - call the child createInstance() first'); } - this.instance.renderToScreen = this.renderToScreen; + this.instance.enabled = this.enabled; + this.instance.needsSwap = this.needsSwap; + this.instance.clear = this.clear; + this.instance.renderToScreen = this.renderToScreen; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; @@ -72,43 +45,25 @@ R3.D3.Pass.prototype.createInstance = function() { */ R3.D3.Pass.prototype.updateInstance = function(property) { + if (property === 'enabled') { + this.instance.enabled = this.enabled; + return; + } - if (property === 'passType') { - - var componentType = R3.D3.API.Pass.GetComponentType(this.passType); - - this.replace(componentType); + if (property === 'needsSwap') { + this.instance.needsSwap = this.needsSwap; + return; + } + if (property === 'clear') { + this.instance.clear = this.clear; return; } if (property === 'renderToScreen') { this.instance.renderToScreen = this.renderToScreen; + return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Not all passes have setSize, but this is just a safety function in case someone calls setSize on a pass component - * @param property - */ -R3.D3.Pass.prototype.setSize = function(property) { -}; - -/** - * R3.D3.Pass to R3.D3.API.Pass - * @returns {R3.D3.API.Pass} - */ -R3.D3.Pass.prototype.toApiObject = function() { - - var apiPass = new R3.D3.API.Pass( - this.id, - this.name, - this.passType, - R3.Utils.IdOrNull(this.parent), - this.renderToScreen - ); - - return apiPass; + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-pass-bloom.js b/src/r3-d3-pass-bloom.js index b98bfce..597d5ff 100644 --- a/src/r3-d3-pass-bloom.js +++ b/src/r3-d3-pass-bloom.js @@ -1,39 +1,15 @@ /** * R3.D3.Pass.Bloom - * @param graphics R3.Runtime.Graphics - * @param apiPassBloom R3.D3.API.Pass.Bloom + * @param apiComponent * @constructor */ R3.D3.Pass.Bloom = function( - graphics, - apiPassBloom + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiPassBloom)) { - apiPassBloom = { - passType : R3.D3.API.Pass.PASS_TYPE_BLOOM - }; - } - - R3.D3.API.Pass.Bloom.call( - this, - apiPassBloom, - apiPassBloom.autoUpdateSize, - apiPassBloom.width, - apiPassBloom.height, - apiPassBloom.strength, - apiPassBloom.radius, - apiPassBloom.threshold - ); - - R3.D3.Pass.call( - this, - this.graphics, - this - ); + R3.D3.Pass.call(this, true); }; R3.D3.Pass.Bloom.prototype = Object.create(R3.D3.Pass.prototype); @@ -45,23 +21,30 @@ R3.D3.Pass.Bloom.prototype.constructor = R3.D3.Pass.Bloom; */ R3.D3.Pass.Bloom.prototype.createInstance = function() { + if (this.autoUpdateSize) { - R3.Utils.UpdateWindowSize(this); + + if (R3.Utils.Unloaded(this.renderer)) { + throw new Error('Renderer not loaded but R3.D3.Pass.Bloom.prototype.autoUpdateSize is set - problem with storage or linking system'); + } + + if (R3.Utils.Unloaded(this.viewport)) { + throw new Error('Viewport not loaded but R3.D3.Pass.Bloom.prototype.autoUpdateSize is set - problem with storage or linking system'); + } + + this.setSize(); + } - this.instance = new THREE.UnrealBloomPass( - new THREE.Vector2( - this.width, - this.height - ), + this.instance = new this.graphics.PassBloom( + this.size, this.strength, this.radius, this.threshold ); - console.log('Constructed a bloom pass instance'); - R3.D3.Pass.prototype.createInstance.call(this); + }; /** @@ -70,34 +53,44 @@ R3.D3.Pass.Bloom.prototype.createInstance = function() { R3.D3.Pass.Bloom.prototype.updateInstance = function(property) { if ( - property === 'width' || - property === 'height' || - property === 'autoUpdateSize' + property === 'autoUpdateSize' || + property === 'renderer' || + property === 'viewport' + ) { + if (this.autoUpdateSize) { - R3.Utils.UpdateWindowSize(this); + + this.setSize(); + + this.graphics.updateInstance(this, 'size'); + + return; + } - this.instance.setSize( - this.width, - this.height - ); + return; + + } + + if (property === 'size') { + + if (this.autoUpdateSize) { + console.warn('Modifying the width and height while R3.D3.Pass.Bloom.prototype.autoUpdateSize is set has no effect'); + return; + } + + this.graphics.updateInstance(this, 'size'); return; } - if (property === 'strength') { - this.instance.strength = this.strength; - return; - } - - if (property === 'radius') { - this.instance.radius = this.radius; - return; - } - - if (property === 'threshold') { - this.instance.threshold = this.threshold; + if ( + property === 'strength' || + property === 'radius' || + property === 'threshold' + ) { + this.graphics.updateInstance(this, property); return; } @@ -107,32 +100,22 @@ R3.D3.Pass.Bloom.prototype.updateInstance = function(property) { /** * Convenience function to set size - * @param width - * @param height */ -R3.D3.Pass.Bloom.prototype.setSize = function(width, height) { - this.width = width; - this.height = height; - this.updateInstance('width'); -}; - -/** - * R3.D3.Pass.Bloom to R3.D3.API.Pass.Bloom - * @returns {R3.D3.API.Pass.Bloom} - */ -R3.D3.Pass.Bloom.prototype.toApiObject = function() { - - var apiPass = R3.D3.Pass.prototype.toApiObject.call(this); - - var apiBloomPass = new R3.D3.API.Pass.Bloom( - apiPass, - this.autoUpdateSize, - this.width, - this.height, - this.strength, - this.radius, - this.threshold - ); - - return apiBloomPass; +R3.D3.Pass.Bloom.prototype.setSize = function() { + + if (R3.Utils.Unloaded(this.renderer)) { + console.warn('R3.D3.Pass.Render.Bloom.prototype.renderer unloaded'); + return; + } + + if (R3.Utils.Unloaded(this.viewport)) { + console.warn('R3.D3.Pass.Render.Bloom.prototype.viewport unloaded'); + return; + } + + var size = this.renderer.getSize(this.viewport); + + this.size.x = size.width; + this.size.y = size.height; + }; diff --git a/src/r3-d3-pass-copy.js b/src/r3-d3-pass-copy.js new file mode 100644 index 0000000..936d24f --- /dev/null +++ b/src/r3-d3-pass-copy.js @@ -0,0 +1,36 @@ +/** + * R3.D3.Pass.Copy + * @param apiComponent + * @constructor + */ +R3.D3.Pass.Copy = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.D3.Pass.call(this, true); + +}; + +R3.D3.Pass.Copy.prototype = Object.create(R3.D3.Pass.prototype); +R3.D3.Pass.Copy.prototype.constructor = R3.D3.Pass.Copy; + +/** + * Create Pass.Copy instance + * @returns {*} + */ +R3.D3.Pass.Copy.prototype.createInstance = function() { + + R3.D3.Pass.prototype.createInstance.call(this); + +}; + +/** + * Update Pass.Copy instance + */ +R3.D3.Pass.Copy.prototype.updateInstance = function(property) { + + R3.D3.Pass.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-d3-pass-fxaa.js b/src/r3-d3-pass-fxaa.js index 67617c1..63f7c1b 100644 --- a/src/r3-d3-pass-fxaa.js +++ b/src/r3-d3-pass-fxaa.js @@ -1,36 +1,16 @@ /** * R3.D3.Pass.FXAA - * @param graphics R3.Runtime.Graphics - * @param apiPassFXAA R3.D3.API.Pass.FXAA + * @param apiComponent * @constructor */ R3.D3.Pass.FXAA = function( - graphics, - apiPassFXAA + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiPassFXAA)) { - apiPassFXAA = { - passType : R3.D3.API.Pass.PASS_TYPE_FXAA - }; - } + R3.D3.Pass.call(this, true); - R3.D3.API.Pass.FXAA.call( - this, - apiPassFXAA, - apiPassFXAA.autoUpdateSize, - apiPassFXAA.width, - apiPassFXAA.height - ); - - R3.D3.Pass.call( - this, - this.graphics, - this - ); }; R3.D3.Pass.FXAA.prototype = Object.create(R3.D3.Pass.prototype); @@ -42,20 +22,19 @@ R3.D3.Pass.FXAA.prototype.constructor = R3.D3.Pass.FXAA; */ R3.D3.Pass.FXAA.prototype.createInstance = function() { - this.instance = new THREE.ShaderPass(THREE.FXAAShader); - if (this.autoUpdateSize) { - R3.Utils.UpdateWindowSize(this); + + this.setSize(); + } - this.instance.uniforms['resolution'].value.set( - 1 / this.width, - 1 / this.height + this.instance = this.graphics.PassFXAA( + this.width, + this.height ); - console.log('Constructed an FXAA pass instance'); - R3.D3.Pass.prototype.createInstance.call(this); + }; /** @@ -64,18 +43,38 @@ R3.D3.Pass.FXAA.prototype.createInstance = function() { R3.D3.Pass.FXAA.prototype.updateInstance = function(property) { if ( - property === 'width' || - property === 'height' || - property === 'autoUpdateSize' + property === 'autoUpdateSize' || + property === 'renderer' || + property === 'viewport' + ) { + if (this.autoUpdateSize) { - R3.Utils.UpdateWindowSize(this); + + this.setSize(); + + this.graphics.updateInstance(this, 'size'); + + return; + } - this.instance.uniforms['resolution'].value.set( - 1 / this.width, - 1 / this.height - ); + return; + + } + + if ( + property === 'width' || + property === 'height' + ) { + + if (this.autoUpdateSize) { + console.warn('Modifying the width and height while R3.D3.Pass.FXAA.prototype.autoUpdateSize is set has no effect'); + return; + } + + this.graphics.updateInstance(this, 'size'); + return; } @@ -85,29 +84,23 @@ R3.D3.Pass.FXAA.prototype.updateInstance = function(property) { /** * Convenience function to set size - * @param width - * @param height */ -R3.D3.Pass.FXAA.prototype.setSize = function(width, height) { - this.width = width; - this.height = height; - this.updateInstance('width'); +R3.D3.Pass.FXAA.prototype.setSize = function() { + + if (R3.Utils.Unloaded(this.renderer)) { + console.warn('R3.D3.Pass.Render.FXAA.prototype.renderer unloaded'); + return; + } + + if (R3.Utils.Unloaded(this.viewport)) { + console.warn('R3.D3.Pass.Render.FXAA.prototype.viewport unloaded'); + return; + } + + var size = this.renderer.getSize(this.viewport); + + this.width = size.width; + this.height = size.height; + }; -/** - * R3.D3.Pass.FXAA to R3.D3.API.Pass.FXAA - * @returns {R3.D3.API.Pass.FXAA} - */ -R3.D3.Pass.FXAA.prototype.toApiObject = function() { - - var apiPass = R3.D3.Pass.prototype.toApiObject.call(this); - - var apiFXAAPass = new R3.D3.API.Pass.FXAA( - apiPass, - this.autoUpdateSize, - this.width, - this.height - ); - - return apiFXAAPass; -}; diff --git a/src/r3-d3-pass-render-0.js b/src/r3-d3-pass-render-0.js new file mode 100644 index 0000000..3ea82c7 --- /dev/null +++ b/src/r3-d3-pass-render-0.js @@ -0,0 +1,76 @@ +/** + * R3.D3.Pass.Render + * @param apiComponent + * @param inherited + * @constructor + */ +R3.D3.Pass.Render = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + + __RUNTIME_COMPONENT__; + + } + + R3.D3.Pass.call(this, true); + +}; + +R3.D3.Pass.Render.prototype = Object.create(R3.D3.Pass.prototype); +R3.D3.Pass.Render.prototype.constructor = R3.D3.Pass.Render; + +/** + * Create Pass.Render instance + * @returns {*} + */ +R3.D3.Pass.Render.prototype.createInstance = function() { + + if (R3.Utils.Unloaded(this.scene)) { + throw new Error('R3.D3.Pass.Render.prototype.scene not ready - loading or linking error'); + } + + if (R3.Utils.Unloaded(this.camera)) { + throw new Error('R3.D3.Pass.Render.prototype.camera not ready - loading or linking error'); + } + + this.instance = this.graphics.PassRender( + this.scene, + this.camera + ); + + R3.D3.Pass.prototype.createInstance.call(this); +}; + +/** + * Update Pass.Render instance + */ +R3.D3.Pass.Render.prototype.updateInstance = function(property) { + + if (property === 'scene') { + + if (R3.Utils.Unloaded(this.scene)) { + throw new Error('R3.D3.Pass.Render.prototype.scene cannot be undefined'); + } + + this.instance.scene = this.scene.instance; + + return; + } + + if (property === 'camera') { + + if (R3.Utils.Unloaded(this.camera)) { + throw new Error('R3.D3.Pass.Render.prototype.camera cannot be undefined'); + } + + this.instance.camera = this.camera.instance; + + return; + } + + R3.D3.Pass.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-d3-pass-render-ssao.js b/src/r3-d3-pass-render-ssao.js new file mode 100644 index 0000000..8de3740 --- /dev/null +++ b/src/r3-d3-pass-render-ssao.js @@ -0,0 +1,135 @@ +/** + * R3.D3.Pass.Render.SSAO + * @param apiComponent + * @constructor + */ +R3.D3.Pass.Render.SSAO = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.D3.Pass.Render.call( + this, + apiComponent, + true + ); + +}; + +R3.D3.Pass.Render.SSAO.prototype = Object.create(R3.D3.Pass.Render.prototype); +R3.D3.Pass.Render.SSAO.prototype.constructor = R3.D3.Pass.Render.SSAO; + +/** + * Create Pass.SSAO instance + * @returns {*} + */ +R3.D3.Pass.Render.SSAO.prototype.createInstance = function() { + + if (R3.Utils.Unloaded(this.scene)) { + throw new Error('R3.D3.Pass.Render.SSAO.prototype.scene not ready - loading or linking error'); + } + + if (R3.Utils.Unloaded(this.camera)) { + throw new Error('R3.D3.Pass.Render.SSAO.prototype.camera not ready - loading or linking error'); + } + + if (this.autoUpdateSize) { + + this.setSize(); + + } + + this.instance = this.graphics.PassSSAO( + this.scene, + this.camera, + this.size, + this.radius, + this.onlyAO, + this.aoClamp, + this.lumInfluence + ); + + R3.D3.Pass.prototype.createInstance.call(this); +}; + +/** + * Update Pass.SSAO instance + */ +R3.D3.Pass.Render.SSAO.prototype.updateInstance = function(property) { + + if ( + property === 'scene' || + property === 'camera' + + ) { + R3.D3.Pass.Render.prototype.updateInstance.call(this, property); + return; + } + + if ( + property === 'radius' || + property === 'onlyAO' || + property === 'radius' || + property === 'lumInfluence' + ) { + this.graphics.updateInstance(this, property); + } + + if ( + property === 'autoUpdateSize' || + property === 'renderer' || + property === 'viewport' + + ) { + + if (this.autoUpdateSize) { + + this.setSize(); + + this.graphics.updateInstance(this, 'size'); + + return; + + } + + return; + + } + + if (property === 'size') { + + if (this.autoUpdateSize) { + console.warn('Modifying the width and height while R3.D3.Pass.Render.SSAO.prototype.autoUpdateSize is set has no effect'); + return; + } + + this.graphics.updateInstance(this, 'size'); + + return; + } + + R3.D3.Pass.prototype.updateInstance.call(this, property); +}; + +/** + * Convenience function to set size + */ +R3.D3.Pass.Render.SSAO.prototype.setSize = function() { + + if (R3.Utils.Unloaded(this.renderer)) { + console.warn('R3.D3.Pass.Render.SSAO.prototype.renderer unloaded'); + return; + } + + if (R3.Utils.Unloaded(this.viewport)) { + console.warn('R3.D3.Pass.Render.SSAO.prototype.viewport unloaded'); + return; + } + + var size = this.renderer.getSize(this.viewport); + + this.size.x = size.width; + this.size.y = size.height; + +}; \ No newline at end of file diff --git a/src/r3-d3-pass-render.js b/src/r3-d3-pass-render.js deleted file mode 100644 index 57fe8be..0000000 --- a/src/r3-d3-pass-render.js +++ /dev/null @@ -1,130 +0,0 @@ -/** - * R3.D3.Pass.Render - * @param graphics R3.Runtime.Graphics - * @param apiPassRender R3.D3.API.Pass.Render - * @constructor - */ -R3.D3.Pass.Render = function( - graphics, - apiPassRender -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiPassRender)) { - apiPassRender = { - passType : R3.D3.API.Pass.PASS_TYPE_RENDER - }; - } - - R3.D3.API.Pass.Render.call( - this, - apiPassRender, - apiPassRender.scene, - apiPassRender.camera - ); - - if (this.scene instanceof R3.D3.API.Scene) { - this.scene = new R3.D3.Scene( - this.graphics, - this.scene - ) - } - - if (this.camera instanceof R3.D3.API.Camera) { - this.camera = new R3.D3.Camera( - this.graphics, - this.camera - ) - } - - R3.D3.Pass.call( - this, - this.graphics, - this - ); -}; - -R3.D3.Pass.Render.prototype = Object.create(R3.D3.Pass.prototype); -R3.D3.Pass.Render.prototype.constructor = R3.D3.Pass.Render; - -/** - * Create Pass.Render instance - * @returns {*} - */ -R3.D3.Pass.Render.prototype.createInstance = function() { - - if (R3.Utils.UndefinedOrNull(this.scene) || - R3.Utils.UndefinedOrNull(this.scene.instance) - ) { - console.warn('scene not ready'); - return; - } - - if (R3.Utils.UndefinedOrNull(this.camera) || - R3.Utils.UndefinedOrNull(this.camera.instance) - ) { - console.warn('camera not ready'); - return; - } - - this.instance = new THREE.RenderPass( - this.scene.instance, - this.camera.instance - ); - - console.log('Constructed a render pass instance'); - - R3.D3.Pass.prototype.createInstance.call(this); -}; - -/** - * Update Pass.Render instance - */ -R3.D3.Pass.Render.prototype.updateInstance = function(property) { - - if (property === 'scene') { - if (R3.Utils.UndefinedOrNull(this.instance)) { - this.createInstance(); - } - - if (this.instance && this.scene.instance) { - this.instance.scene = this.scene.instance; - } - - return; - } - - if (property === 'camera') { - if (R3.Utils.UndefinedOrNull(this.instance)) { - this.createInstance(); - } - - if (this.instance && this.camera.instance) { - this.instance.camera = this.camera.instance; - } - - return; - } - - R3.D3.Pass.prototype.updateInstance.call(this, property); - -}; - -/** - * R3.D3.Pass.Render to R3.D3.API.Pass.Render - * @returns {R3.D3.API.Pass.Render} - */ -R3.D3.Pass.Render.prototype.toApiObject = function() { - - var apiPass = R3.D3.Pass.prototype.toApiObject.call(this); - - var apiRenderPass = new R3.D3.API.Pass.Render( - apiPass, - R3.Utils.IdOrNull(this.scene), - R3.Utils.IdOrNull(this.camera) - ); - - return apiRenderPass; -}; diff --git a/src/r3-d3-pass-ssao.js b/src/r3-d3-pass-ssao.js deleted file mode 100644 index 85c9f00..0000000 --- a/src/r3-d3-pass-ssao.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * R3.D3.Pass.SSAO - * @param graphics R3.Runtime.Graphics - * @param apiPassSSAO R3.D3.API.Pass.SSAO - * @constructor - */ -R3.D3.Pass.SSAO = function( - graphics, - apiPassSSAO -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiPassSSAO)) { - apiPassSSAO = { - passType : R3.D3.API.Pass.PASS_TYPE_SSAO - }; - } - - R3.D3.API.Pass.SSAO.call( - this, - apiPassSSAO, - apiPassSSAO.scene, - apiPassSSAO.camera, - apiPassSSAO.radius, - apiPassSSAO.onlyAO, - apiPassSSAO.aoClamp, - apiPassSSAO.lumInfluence - ); - - if (this.scene instanceof R3.D3.API.Scene) { - this.scene = new R3.D3.Scene( - this.graphics, - this.scene - ) - } - - if (this.camera instanceof R3.D3.API.Camera) { - this.camera = new R3.D3.Camera( - this.graphics, - this.camera - ) - } - - R3.D3.Pass.call( - this, - this.graphics, - this - ); -}; - -R3.D3.Pass.SSAO.prototype = Object.create(R3.D3.Pass.prototype); -R3.D3.Pass.SSAO.prototype.constructor = R3.D3.Pass.SSAO; - -/** - * Create Pass.SSAO instance - * @returns {*} - */ -R3.D3.Pass.SSAO.prototype.createInstance = function() { - - if (R3.Utils.UndefinedOrNull(this.scene) || - R3.Utils.UndefinedOrNull(this.scene.instance) - ) { - console.warn('scene not ready'); - return; - } - - if (R3.Utils.UndefinedOrNull(this.camera) || - R3.Utils.UndefinedOrNull(this.camera.instance) - ) { - console.warn('camera not ready'); - return; - } - - this.instance = new THREE.SSAOPass( - this.scene.instance, - this.camera.instance - ); - - this.instance.radius = this.radius; - - this.instance.onlyAO = this.onlyAO; - - this.instance.aoClamp = this.aoClamp; - - this.instance.lumInfluence = this.lumInfluence; - - console.log('Constructed an SSAO pass instance'); - - R3.D3.Pass.prototype.createInstance.call(this); -}; - -/** - * Update Pass.SSAO instance - */ -R3.D3.Pass.SSAO.prototype.updateInstance = function(property) { - - if (property === 'scene') { - if (R3.Utils.UndefinedOrNull(this.instance)) { - this.createInstance(); - } - return; - } - - if (property === 'camera') { - if (R3.Utils.UndefinedOrNull(this.instance)) { - this.createInstance(); - } - return; - } - - if (!this.instance) { - return; - } - - if (property === 'radius') { - this.instance.radius = this.radius; - return; - } - - if (property === 'onlyAO') { - this.instance.onlyAO = this.onlyAO; - return; - } - - if (property === 'aoClamp') { - this.instance.aoClamp = this.aoClamp; - return; - } - - if (property === 'lumInfluence') { - this.instance.lumInfluence = this.lumInfluence; - return; - } - - R3.D3.Pass.prototype.updateInstance.call(this, property); - -}; - -/** - * R3.D3.Pass.SSAO to R3.D3.API.Pass.SSAO - * @returns {R3.D3.API.Pass.SSAO} - */ -R3.D3.Pass.SSAO.prototype.toApiObject = function() { - - var apiPass = R3.D3.Pass.prototype.toApiObject.call(this); - - var apiSSAOPass = new R3.D3.API.Pass.SSAO( - apiPass, - R3.Utils.IdOrNull(this.scene), - R3.Utils.IdOrNull(this.camera), - this.radius, - this.onlyAO, - this.aoClamp, - this.lumInfluence - ); - - return apiSSAOPass; -}; diff --git a/src/r3-d3-physics-world.js b/src/r3-d3-physics-world.js index 701cb5d..a8581fe 100644 --- a/src/r3-d3-physics-world.js +++ b/src/r3-d3-physics-world.js @@ -167,7 +167,7 @@ R3.D3.PhysicsWorld.prototype.createInstance = function() { this.instance.defaultContactMaterial.frictionEquationStiffness = this.defaultContactMaterial.frictionEquationStiffness; this.instance.defaultContactMaterial.frictionEquationRelaxation = this.defaultContactMaterial.frictionEquationRelaxation; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; R3.D3.PhysicsWorld.prototype.addRigidBody = function(rigidBody) { @@ -259,7 +259,7 @@ R3.D3.PhysicsWorld.prototype.updateInstance = function(property) { this.instance.defaultContactMaterial.frictionEquationStiffness = this.defaultContactMaterial.frictionEquationStiffness; this.instance.defaultContactMaterial.frictionEquationRelaxation = this.defaultContactMaterial.frictionEquationRelaxation; - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-raycast-vehicle.js b/src/r3-d3-raycastVehicle.js similarity index 97% rename from src/r3-d3-raycast-vehicle.js rename to src/r3-d3-raycastVehicle.js index b85d1ad..0967f95 100644 --- a/src/r3-d3-raycast-vehicle.js +++ b/src/r3-d3-raycastVehicle.js @@ -121,7 +121,7 @@ R3.D3.RaycastVehicle.prototype.createInstance = function() { this.instance.addToWorld(this.parentPhysicsWorld.instance); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; @@ -129,7 +129,7 @@ R3.D3.RaycastVehicle.prototype.updateInstance = function(property) { // this.instance.chassisBody = this.chassis.instance; //TODO: add / remove wheels? console.log('TODO: update raycast vehicle instance'); - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-raycast-wheel.js b/src/r3-d3-raycastWheel.js similarity index 98% rename from src/r3-d3-raycast-wheel.js rename to src/r3-d3-raycastWheel.js index e81e0e0..15db839 100644 --- a/src/r3-d3-raycast-wheel.js +++ b/src/r3-d3-raycastWheel.js @@ -90,7 +90,7 @@ R3.D3.RaycastWheel.prototype.createInstance = function() { useCustomSlidingRotationalSpeed: this.useCustomSlidingRotationalSpeed }; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; R3.D3.RaycastWheel.prototype.updateInstance = function() { diff --git a/src/r3-d3-raycaster.js b/src/r3-d3-raycaster.js index 35affdb..fe4555c 100644 --- a/src/r3-d3-raycaster.js +++ b/src/r3-d3-raycaster.js @@ -1,43 +1,22 @@ /** - * Raycaster for R3.D3 - * @param graphics R3.Runtime.Graphics - * @param apiRaycaster + * R3.D3.Raycaster + * @param apiComponent * @constructor */ R3.D3.Raycaster = function( - graphics, - apiRaycaster + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiRaycaster)) { - apiRaycaster = {}; - } + __RUNTIME_COMPONENT__; R3.D3.API.Raycaster.call( this, - apiRaycaster.id, - apiRaycaster.name, - apiRaycaster.parent, - apiRaycaster.position, - apiRaycaster.direction + apiComponent, + apiComponent.position, + apiComponent.direction ); - this.position = new R3.Vector3( - this.graphics, - this.position, - this - ); - - this.direction = new R3.Vector3( - this.graphics, - this.direction, - this - ); - - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.D3.Raycaster.prototype = Object.create(R3.Component.prototype); @@ -48,18 +27,19 @@ R3.D3.Raycaster.prototype.constructor = R3.D3.Raycaster; */ R3.D3.Raycaster.prototype.createInstance = function() { - this.instance = new THREE.Raycaster(); - this.instance.set( - this.position.instance, - this.direction.instance + this.instance = this.graphics.Raycaster( + this.position, + this.direction ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; R3.D3.Raycaster.prototype.updateInstance = function(property) { - if (property === 'position') { + if ( + property === 'position' + ) { this.position.instance.x = this.position.x; this.position.instance.y = this.position.y; this.position.instance.z = this.position.z; @@ -75,17 +55,7 @@ R3.D3.Raycaster.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -R3.D3.Raycaster.prototype.toApiObject = function() { - return new R3.D3.API.Raycaster( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.position.toApiObject(), - this.direction.toApiObject() - ) + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-render-target-a.js b/src/r3-d3-renderTarget-0.js similarity index 97% rename from src/r3-d3-render-target-a.js rename to src/r3-d3-renderTarget-0.js index a0198b2..6cd4733 100644 --- a/src/r3-d3-render-target-a.js +++ b/src/r3-d3-renderTarget-0.js @@ -98,7 +98,7 @@ R3.D3.RenderTarget.prototype.createInstance = function() { this.instance.scissorTest = this.scissorTest.instance; this.instance.viewport = this.viewport.instance; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -154,6 +154,6 @@ R3.D3.RenderTarget.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-render-target-cube.js b/src/r3-d3-renderTarget-cube.js similarity index 100% rename from src/r3-d3-render-target-cube.js rename to src/r3-d3-renderTarget-cube.js diff --git a/src/r3-d3-rigid-body.js b/src/r3-d3-rigidBody.js similarity index 98% rename from src/r3-d3-rigid-body.js rename to src/r3-d3-rigidBody.js index ad75fbf..0dacc37 100644 --- a/src/r3-d3-rigid-body.js +++ b/src/r3-d3-rigidBody.js @@ -149,7 +149,7 @@ R3.D3.RigidBody.prototype.createInstance = function() { }.bind(this) ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -200,7 +200,7 @@ R3.D3.RigidBody.prototype.updateInstance = function() { this.instance.fixedRotation = this.fixedRotation; this.instance.kinematic = this.kinematic; - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; R3.D3.RigidBody.prototype.setFromParentMesh = function() { diff --git a/src/r3-d3-scene.js b/src/r3-d3-scene.js index 5a1ce71..abd269c 100644 --- a/src/r3-d3-scene.js +++ b/src/r3-d3-scene.js @@ -191,7 +191,7 @@ R3.D3.Scene.prototype.createInstance = function() { this.drawAxis(); } - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; @@ -296,7 +296,7 @@ R3.D3.Scene.prototype.updateInstance = function(property) { } } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-shader-a.js b/src/r3-d3-shader-0.js similarity index 94% rename from src/r3-d3-shader-a.js rename to src/r3-d3-shader-0.js index 49f4ba9..7b9c9da 100644 --- a/src/r3-d3-shader-a.js +++ b/src/r3-d3-shader-0.js @@ -50,7 +50,7 @@ R3.D3.Shader.prototype.createInstance = function() { * GLSL code */ - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -78,7 +78,7 @@ R3.D3.Shader.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-shadow-0.js b/src/r3-d3-shadow-0.js new file mode 100644 index 0000000..2124e13 --- /dev/null +++ b/src/r3-d3-shadow-0.js @@ -0,0 +1,82 @@ +/** + * R3.D3.Shadow + * + * - R3.D3.Shadow components are not intended to be created directly + * + * https://threejs.org/docs/#api/en/lights/shadows/SpotLightShadow + * - "This is used internally by SpotLights for calculating shadows." + * + * https://threejs.org/docs/#api/en/lights/shadows/DirectionalLightShadow + * - "This is not intended to be called directly - it is called internally by DirectionalLight." + * + * - For this reason - we create them as normal components - but instead of creating their instances, they get + * assigned to them through parent objects at create instance time, and the runtime shadow object gets updated + * accordingly + * + * - We also don't create Shadow objects at API level unless they come from the API - this way we know whether or + * not we need to update the shadow with our information or update our information with the shadow information + * + * @param inherited + * + * @constructor + */ +R3.D3.Shadow = function( + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.D3.Shadow should not be instantiated directly'); + } + + __UPGRADE_TO_RUNTIME__; +}; + +R3.D3.Shadow.prototype = Object.create(R3.Component.prototype); +R3.D3.Shadow.prototype.constructor = R3.D3.Shadow; + +/** + * Updates the instance with the current state + */ +R3.D3.Shadow.prototype.updateInstance = function(property) { + + if (property === 'camera') { + this.instance.camera = this.camera.instance; + return; + } + + if (property === 'bias') { + this.instance.bias = this.bias; + return; + } + + if (property === 'mapSize') { + this.instance.mapSize.x = this.mapSize.x; + this.instance.mapSize.y = this.mapSize.y; + return; + } + + if (property === 'radius') { + this.instance.radius = this.radius; + return; + } + + __UPDATE_INSTANCE__; + +}; + +/** + * Until this can be moved into a more generic way into R3.Component - we do it this way for now + */ +R3.D3.Shadow.prototype.updateInstanceAll = function() { + this.updateInstance('camera'); + this.updateInstance('bias'); + this.updateInstance('mapSize'); + this.updateInstance('radius'); +}; + +R3.D3.Shadow.prototype.updateFromInstanceAll = function() { + this.updateFromInstance('camera'); + this.updateFromInstance('bias'); + this.updateFromInstance('mapSize'); + this.updateFromInstance('radius'); +}; \ No newline at end of file diff --git a/src/r3-d3-shadow-a.js b/src/r3-d3-shadow-a.js deleted file mode 100644 index ce09690..0000000 --- a/src/r3-d3-shadow-a.js +++ /dev/null @@ -1,136 +0,0 @@ -/** - * R3.D3.Shadow - * @param graphics R3.Runtime.Graphics - * @param apiShadow R3.D3.API.Shadow - * @constructor - */ -R3.D3.Shadow = function( - graphics, - apiShadow -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiShadow)) { - apiShadow = { - shadowType : R3.D3.API.Shadow.SHADOW_TYPE_NORMAL - }; - } - - R3.D3.API.Shadow.call( - this, - apiShadow.id, - apiShadow.name, - apiShadow.shadowType, - apiShadow.camera, - apiShadow.bias, - apiShadow.mapSize, - apiShadow.radius, - apiShadow.parent - ); - - if (this.camera instanceof R3.D3.API.Camera.Perspective) { - this.camera = new R3.D3.Camera.Perspective( - this.graphics, - this.camera - ) - } - - this.mapSize = new R3.Vector2( - this.graphics, - this.mapSize, - this - ); - - R3.Component.call( - this, - { - camera : R3.D3.Camera - } - ); -}; - -R3.D3.Shadow.prototype = Object.create(R3.Component.prototype); -R3.D3.Shadow.prototype.constructor = R3.D3.Shadow; - -/** - * Creates a light instance - * @returns {*} - */ -R3.D3.Shadow.prototype.createInstance = function() { - - /** - * Shadow objects are not responsible for creating their instances right now - - * They are implicitly created through threejs light instances. This means, - * they only update their instances. - * @type {Object} - */ - this.instance = {}; - - R3.Component.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Shadow.prototype.updateInstance = function(property) { - - if (typeof this.instance !== 'object') { - console.warn('this shadow instance is not ready for an update: ' + this.name); - return; - } - - if (R3.Utils.UndefinedOrNull(property)) { - console.warn('no property for light: ' + this.name); - } - - if (property === 'shadowType') { - console.warn('changing shadowType has no effect'); - } - - if (property === 'camera') { - this.instance.camera = this.camera.instance; - } - - if (property === 'bias') { - this.instance.bias = this.bias; - } - - if (property === 'mapSize') { - this.instance.mapSize.x = this.mapSize.x; - this.instance.mapSize.y = this.mapSize.y; - } - - if (property === 'radius') { - this.instance.radius = this.radius; - } - - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Shadow to a R3.D3.API.Shadow - * @returns {R3.D3.API.Shadow} - */ -R3.D3.Shadow.prototype.toApiObject = function() { - return new R3.D3.API.Shadow( - this.id, - this.name, - this.shadowType, - R3.Utils.IdOrNull(this.camera), - this.bias, - this.mapSize.toApiObject(), - this.radius, - R3.Utils.IdOrNull(this.parent) - ); -}; - -R3.D3.Shadow.prototype.updateFromInstance = function() { - this.bias = this.instance.bias; - this.mapSize.x = this.instance.mapSize.x; - this.mapSize.y = this.instance.mapSize.y; - this.radius = this.instance.radius; - this.camera.instance = this.instance.camera; - this.camera.updateFromInstance(); -}; \ No newline at end of file diff --git a/src/r3-d3-shadow-directional.js b/src/r3-d3-shadow-directional.js index 67877b5..0d4f7fb 100644 --- a/src/r3-d3-shadow-directional.js +++ b/src/r3-d3-shadow-directional.js @@ -1,39 +1,31 @@ /** * R3.D3.Shadow.Directional - * @param graphics R3.Runtime.Graphics - * @param apiDirectionalShadow + * + * - R3.D3.Shadow components are not intended to be created directly + * + * https://threejs.org/docs/#api/en/lights/shadows/SpotLightShadow + * - "This is used internally by SpotLights for calculating shadows." + * + * https://threejs.org/docs/#api/en/lights/shadows/DirectionalLightShadow + * - "This is not intended to be called directly - it is called internally by DirectionalLight." + * + * - For this reason - we create them as normal components - but instead of creating their instances, they get + * assigned to them through parent objects at create instance time, and the runtime shadow object gets updated + * accordingly + * + * @param apiComponent + * * @constructor */ R3.D3.Shadow.Directional = function( - graphics, - apiDirectionalShadow + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiDirectionalShadow)) { - apiDirectionalShadow = { - shadowType : R3.D3.API.Shadow.SHADOW_TYPE_DIRECTIONAL - }; - } - - R3.D3.API.Shadow.Directional.call( - this, - apiDirectionalShadow - ); - - if (this.camera instanceof R3.D3.API.Camera.Orthographic) { - this.camera = new R3.D3.Camera.Orthographic( - this.graphics, - this.camera - ) - } + __RUNTIME_COMPONENT__; R3.D3.Shadow.call( this, - this.graphics, - this + true ); }; @@ -47,9 +39,10 @@ R3.D3.Shadow.Directional.prototype.constructor = R3.D3.Shadow.Directional; */ R3.D3.Shadow.Directional.prototype.createInstance = function() { - this.instance = {}; + this.instance = true; + + __CREATE_INSTANCE__; - R3.D3.Shadow.prototype.createInstance.call(this); }; /** @@ -57,34 +50,6 @@ R3.D3.Shadow.Directional.prototype.createInstance = function() { */ R3.D3.Shadow.Directional.prototype.updateInstance = function(property) { - if (property === 'camera') { - - //console.warn('todo: updateInstance for directional shadow camera instance'); - - return; - } - R3.D3.Shadow.prototype.updateInstance.call(this, property); + }; - -/** - * Converts a R3.D3.Shadow to a R3.D3.API.Shadow - * @returns {R3.D3.API.Shadow} - */ -R3.D3.Shadow.Directional.prototype.toApiObject = function() { - - var apiShadow = R3.D3.Shadow.prototype.toApiObject.call(this); - - var apiDirectionalShadow = new R3.D3.API.Shadow.Directional( - apiShadow - ); - - return apiDirectionalShadow; -}; - -R3.D3.Shadow.Directional.prototype.updateFromInstance = function() { - - - R3.D3.Shadow.prototype.updateFromInstance.call(this); - -}; \ No newline at end of file diff --git a/src/r3-d3-shadow-spot.js b/src/r3-d3-shadow-spot.js index b28a014..9e7c265 100644 --- a/src/r3-d3-shadow-spot.js +++ b/src/r3-d3-shadow-spot.js @@ -1,39 +1,31 @@ /** * R3.D3.Shadow.Spot - * @param graphics R3.Runtime.Graphics - * @param apiSpotShadow + * + * - R3.D3.Shadow components are not intended to be created directly + * + * https://threejs.org/docs/#api/en/lights/shadows/SpotLightShadow + * - "This is used internally by SpotLights for calculating shadows." + * + * https://threejs.org/docs/#api/en/lights/shadows/DirectionalLightShadow + * - "This is not intended to be called directly - it is called internally by DirectionalLight." + * + * - For this reason - we create them as normal components - but instead of creating their instances, they get + * assigned to them through parent objects at create instance time, and the runtime shadow object gets updated + * accordingly + * + * @param apiComponent + * * @constructor */ R3.D3.Shadow.Spot = function( - graphics, - apiSpotShadow + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiSpotShadow)) { - apiSpotShadow = { - shadowType : R3.D3.API.Shadow.SHADOW_TYPE_SPOT - }; - } - - R3.D3.API.Shadow.Spot.call( - this, - apiSpotShadow - ); - - if (this.camera instanceof R3.D3.API.Camera.Perspective) { - this.camera = new R3.D3.Camera.Perspective( - this.graphics, - this.camera - ) - } + __RUNTIME_COMPONENT__; R3.D3.Shadow.call( this, - this.graphics, - apiSpotShadow + true ); }; @@ -47,9 +39,10 @@ R3.D3.Shadow.Spot.prototype.constructor = R3.D3.Shadow.Spot; */ R3.D3.Shadow.Spot.prototype.createInstance = function() { - this.instance = {}; + this.instance = true; + + __CREATE_INSTANCE__; - R3.D3.Shadow.prototype.createInstance.call(this); }; /** @@ -57,27 +50,5 @@ R3.D3.Shadow.Spot.prototype.createInstance = function() { */ R3.D3.Shadow.Spot.prototype.updateInstance = function(property) { - if (property === 'camera') { - - console.warn('todo: updateInstance for spot shadow camera instance'); - - return; - } - R3.D3.Shadow.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.D3.Shadow to a R3.D3.API.Shadow - * @returns {R3.D3.API.Shadow} - */ -R3.D3.Shadow.Spot.prototype.toApiObject = function() { - - var apiShadow = R3.D3.Shadow.prototype.toApiObject.call(this); - - var apiSpotShadow = new R3.D3.API.Shadow.Spot( - apiShadow - ); - - return apiSpotShadow; -}; diff --git a/src/r3-d3-shape-0.js b/src/r3-d3-shape-0.js index 4853441..51bc583 100644 --- a/src/r3-d3-shape-0.js +++ b/src/r3-d3-shape-0.js @@ -48,7 +48,7 @@ R3.D3.Shape.prototype.constructor = R3.D3.Shape; * Creates a shape instance or updates it */ R3.D3.Shape.prototype.createInstance = function() { - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -56,7 +56,7 @@ R3.D3.Shape.prototype.createInstance = function() { */ R3.D3.Shape.prototype.updateInstance = function(property) { throw new Error('Do not instantiate this class directly - use a child class instead'); - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-shape-convex-hull-0.js b/src/r3-d3-shape-convexHull-0.js similarity index 100% rename from src/r3-d3-shape-convex-hull-0.js rename to src/r3-d3-shape-convexHull-0.js diff --git a/src/r3-d3-shape-convex-hull-cylinder.js b/src/r3-d3-shape-convexHull-cylinder.js similarity index 100% rename from src/r3-d3-shape-convex-hull-cylinder.js rename to src/r3-d3-shape-convexHull-cylinder.js diff --git a/src/r3-d3-shape-height-map.js b/src/r3-d3-shape-heightMap.js similarity index 100% rename from src/r3-d3-shape-height-map.js rename to src/r3-d3-shape-heightMap.js diff --git a/src/r3-d3-shape-tri-mesh.js b/src/r3-d3-shape-triMesh.js similarity index 100% rename from src/r3-d3-shape-tri-mesh.js rename to src/r3-d3-shape-triMesh.js diff --git a/src/r3-d3-skeleton.js b/src/r3-d3-skeleton.js index 40cff25..b919bfd 100644 --- a/src/r3-d3-skeleton.js +++ b/src/r3-d3-skeleton.js @@ -163,14 +163,14 @@ R3.D3.Skeleton.prototype.createInstance = function(update) { this.instance.calculateInverses(); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** * Updates the instance */ R3.D3.Skeleton.prototype.updateInstance = function(property) { - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-solver.js b/src/r3-d3-solver.js index 4bdc89a..a9097e7 100644 --- a/src/r3-d3-solver.js +++ b/src/r3-d3-solver.js @@ -49,7 +49,7 @@ R3.D3.Solver.prototype.createInstance = function() { this.instance.tolerance = this.tolerance; this.instance.iterations = this.iterations; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -72,7 +72,7 @@ R3.D3.Solver.prototype.updateInstance = function(property) { this.instance.iterations = this.iterations; this.instance.tolerance = this.tolerance; - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-spline.js b/src/r3-d3-spline.js index 1694dd1..d22c167 100644 --- a/src/r3-d3-spline.js +++ b/src/r3-d3-spline.js @@ -61,7 +61,7 @@ R3.D3.Spline.prototype.createInstance = function() { this.instance = THREE.CatmullRomCurve3(vertices); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -86,7 +86,7 @@ R3.D3.Spline.prototype.updateInstance = function(property) { this.instance = new THREE.CatmullRomCurve3(vertices); - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-text.js b/src/r3-d3-text.js index 284f9d5..da085cb 100644 --- a/src/r3-d3-text.js +++ b/src/r3-d3-text.js @@ -48,7 +48,7 @@ R3.D3.Text.prototype.createInstance = function() { this.instance = true; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -94,7 +94,7 @@ R3.D3.Text.prototype.updateInstance = function(property) { } } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-texture-a.js b/src/r3-d3-texture-0.js similarity index 98% rename from src/r3-d3-texture-a.js rename to src/r3-d3-texture-0.js index 002dd74..417de93 100644 --- a/src/r3-d3-texture-a.js +++ b/src/r3-d3-texture-0.js @@ -167,7 +167,7 @@ R3.D3.Texture.prototype.createInstance = function() { */ this.applyToInstance(); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -306,7 +306,7 @@ R3.D3.Texture.prototype.updateInstance = function(property) { this.instance.needsUpdate = true; this.version = this.instance.version; - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; /** diff --git a/src/r3-d3-vertex.js b/src/r3-d3-vertex.js index a709b10..d336d55 100644 --- a/src/r3-d3-vertex.js +++ b/src/r3-d3-vertex.js @@ -1,59 +1,39 @@ /** * R3.D3.Vertex - * @param implementation - * @param apiVertex + * @param apiComponent * @constructor */ R3.D3.Vertex = function Vertex( - implementation, - apiVertex + apiComponent ) { - this.implementation = implementation; - this.implementation.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiVertex)) { - apiVertex = {}; - } + __RUNTIME_COMPONENT__; - R3.D3.API.Vertex.call( - this, - apiVertex.position, - apiVertex.boneWeights - ); - - this.position = new R3.Vector3( - this.implementation, - this.position, - this - ); - - this.boneWeights = this.boneWeights.map( - function(boneWeight) { - return new R3.Vector4( - this.implementation, - boneWeight - ) - }.bind(this) - ); + __UPGRADE_TO_RUNTIME__; }; R3.D3.Vertex.prototype = Object.create(R3.Component.prototype); R3.D3.Vertex.prototype.constructor = R3.D3.Vertex; -/** - * Converts a R3.D3.Vertex to R3.D3.API.Vertex - * @returns {R3.D3.API.Vertex} - */ -R3.D3.Vertex.prototype.toApiObject = function() { +R3.D3.Vertex.prototype.createInstance = function() { - return new R3.D3.API.Vertex( - this.position.toApiObject(), - this.boneWeights.map( - function(boneWeight){ - return boneWeight.toApiObject(); - } - ) - ); + __CREATE_INSTANCE__; + +}; + +R3.D3.Vertex.prototype.updateInstance = function(property) { + + if (property === 'position') { + this.parent.updatePositions(); + return; + } + + if (property === 'normal') { + this.parent.updateNormals(); + return; + } + + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-viewport.js b/src/r3-d3-viewport-0.js similarity index 97% rename from src/r3-d3-viewport.js rename to src/r3-d3-viewport-0.js index 09fb115..ee82efc 100644 --- a/src/r3-d3-viewport.js +++ b/src/r3-d3-viewport-0.js @@ -48,7 +48,7 @@ R3.D3.Viewport.prototype.createInstance = function() { this.height ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** diff --git a/src/r3-d3-viewport-fixedAspect.js b/src/r3-d3-viewport-fixedAspect.js new file mode 100644 index 0000000..a881d6b --- /dev/null +++ b/src/r3-d3-viewport-fixedAspect.js @@ -0,0 +1,55 @@ +/** + * R3.D3.Viewport.fixedAspect + * @param apiComponent + */ +R3.D3.Viewport.fixedAspect = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.D3.Viewport.call( + this, + true + ) + +}; + +R3.D3.Viewport.fixedAspect.prototype = Object.create(R3.D3.Viewport.prototype); +R3.D3.Viewport.fixedAspect.prototype.constructor = R3.D3.Viewport.fixedAspect; + +/** + * + * @returns {boolean} + */ +R3.D3.Viewport.fixedAspect.prototype.createInstance = function() { + throw new Error('todo viewport'); + // this.instance = new THREE.Vector4( + // this.x, + // this.y, + // this.width, + // this.height + // ); + // + // __CREATE_INSTANCE__; +}; + +/** + * + */ +R3.D3.Viewport.fixedAspect.prototype.updateInstance = function(property) { + throw new Error('todo viewport'); + // + // if ( + // property === 'x' || + // property === 'y' || + // property === 'width' || + // property === 'height' + // ) { + // this.instance.x = this.x; + // this.instance.y = this.y; + // this.instance.z = this.width; + // this.instance.w = this.height; + // } + +}; diff --git a/src/r3-d3-viewport-zoomedAspect.js b/src/r3-d3-viewport-zoomedAspect.js new file mode 100644 index 0000000..a881d6b --- /dev/null +++ b/src/r3-d3-viewport-zoomedAspect.js @@ -0,0 +1,55 @@ +/** + * R3.D3.Viewport.fixedAspect + * @param apiComponent + */ +R3.D3.Viewport.fixedAspect = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.D3.Viewport.call( + this, + true + ) + +}; + +R3.D3.Viewport.fixedAspect.prototype = Object.create(R3.D3.Viewport.prototype); +R3.D3.Viewport.fixedAspect.prototype.constructor = R3.D3.Viewport.fixedAspect; + +/** + * + * @returns {boolean} + */ +R3.D3.Viewport.fixedAspect.prototype.createInstance = function() { + throw new Error('todo viewport'); + // this.instance = new THREE.Vector4( + // this.x, + // this.y, + // this.width, + // this.height + // ); + // + // __CREATE_INSTANCE__; +}; + +/** + * + */ +R3.D3.Viewport.fixedAspect.prototype.updateInstance = function(property) { + throw new Error('todo viewport'); + // + // if ( + // property === 'x' || + // property === 'y' || + // property === 'width' || + // property === 'height' + // ) { + // this.instance.x = this.x; + // this.instance.y = this.y; + // this.instance.z = this.width; + // this.instance.w = this.height; + // } + +}; diff --git a/src/r3-dom-element.js b/src/r3-domElement.js similarity index 63% rename from src/r3-dom-element.js rename to src/r3-domElement.js index 8706d17..484a883 100644 --- a/src/r3-dom-element.js +++ b/src/r3-domElement.js @@ -1,25 +1,17 @@ /** - * Runtime domElement for updating instance objects - * @param apiDomElement R3.API.DomElement + * R3.DomElement + * @param apiComponent * @constructor */ -R3.DomElement = function(apiDomElement) { +R3.DomElement = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(apiDomElement)) { - apiDomElement = {}; - } - - R3.API.DomElement.call( - this, - apiDomElement.id, - apiDomElement.name, - apiDomElement.domElementId, - apiDomElement.parent - ); + __RUNTIME_COMPONENT__; this.fullscreen = false; - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.DomElement.prototype = Object.create(R3.Component.prototype); @@ -30,33 +22,26 @@ R3.DomElement.prototype.constructor = R3.DomElement; * @returns {*} */ R3.DomElement.prototype.createInstance = function() { + this.instance = document.getElementById(this.domElementId); - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; /** * Updates instance domElement */ R3.DomElement.prototype.updateInstance = function(property) { + if (property === 'domElementId') { this.createInstance() } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; + }; -/** - * Converts runtime DomElement to API DomElement - * @returns {R3.API.DomElement} - */ -R3.DomElement.prototype.toApiObject = function() { - return new R3.API.DomElement( - this.id, - this.name, - this.domElementId, - R3.Utils.IdOrNull(this.parent) - ); -}; /** * Appends domInstance to DOM instance @@ -106,14 +91,3 @@ R3.DomElement.prototype.exitFullscreen = function(event) { this.fullscreen = false; }; - -R3.DomElement.FromObject = function(objectDom) { - - var apiDomElement = R3.API.DomElement.FromObject(objectDom); - - var domElement = new R3.DomElement( - apiDomElement - ); - - return domElement; -}; \ No newline at end of file diff --git a/src/r3-draw-range.js b/src/r3-draw-range.js deleted file mode 100644 index 5ced0fe..0000000 --- a/src/r3-draw-range.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * R3.DrawRange - * @param implementation - * @param apiDrawRange - * @param parentGeometry - * @constructor - */ -R3.DrawRange = function( - implementation, - apiDrawRange, - parentGeometry -) { - - this.implementation = implementation; - this.implementation.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiDrawRange)) { - apiDrawRange = {}; - } - - if (R3.Utils.UndefinedOrNull(parentGeometry)) { - parentGeometry = null; - } - this.parentGeometry = parentGeometry; - - /** - * Mongo doesn't store Infinity - */ - if (apiDrawRange.count === null) { - apiDrawRange.count = Infinity; - } - - R3.API.DrawRange.call( - this, - apiDrawRange.id, - apiDrawRange.name, - apiDrawRange.parent, - apiDrawRange.start, - apiDrawRange.count - ); - - this.createInstance(); -}; - -R3.DrawRange.prototype = Object.create(R3.Component.prototype); -R3.DrawRange.prototype.constructor = R3.DrawRange; - -/** - * Creates an instance R3.DrawRange - * @returns {*} - */ -R3.DrawRange.prototype.createInstance = function() { - - this.instance = { - start : this.start, - count : this.count - } - -}; - -/** - * Updates R3.DrawRange instance - * @param property - */ -R3.DrawRange.prototype.updateInstance = function(property) { - - console.warn('update the geometry instead'); - - if (property === 'start') { - } - - if (property === 'count') { - } - -}; - -/** - * R3.DrawRange to R3.API.DrawRange - * @returns {R3.API.DrawRange} - */ -R3.DrawRange.prototype.toApiObject = function() { - return new R3.API.DrawRange( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.start, - this.count - ); -}; diff --git a/src/r3-drawRange.js b/src/r3-drawRange.js new file mode 100644 index 0000000..da54156 --- /dev/null +++ b/src/r3-drawRange.js @@ -0,0 +1,53 @@ +/** + * R3.DrawRange + * @param apiComponent + * @constructor + */ +R3.DrawRange = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + __UPGRADE_TO_RUNTIME__; +}; + +R3.DrawRange.prototype = Object.create(R3.Component.prototype); +R3.DrawRange.prototype.constructor = R3.DrawRange; + +/** + * Creates an instance R3.DrawRange + * @returns {*} + */ +R3.DrawRange.prototype.createInstance = function() { + + this.instance = { + start : this.start, + count : this.count + }; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates R3.DrawRange instance + * @param property + */ +R3.DrawRange.prototype.updateInstance = function(property) { + + console.warn('update the geometry instead'); + + if (property === 'start') { + console.warn('todo: update start'); + return; + } + + if (property === 'count') { + console.warn('todo: update count'); + return; + } + + __UPDATE_INSTANCE__; + +}; diff --git a/src/r3-entity.js b/src/r3-entity.js index 9f25715..678a3a5 100644 --- a/src/r3-entity.js +++ b/src/r3-entity.js @@ -1,22 +1,13 @@ /** - * Runtime Entity - * @param apiEntity R3.D3.API.Entity + * R3.Entity + * @param apiComponent * @constructor */ R3.Entity = function( - apiEntity + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiEntity)) { - apiEntity = {}; - } - R3.API.Entity.call( - this, - apiEntity.id, - apiEntity.name, - apiEntity.components, - apiEntity.parent - ); + __RUNTIME_COMPONENT__; this.instanceCreatedEventSubscription = this.subscribe( R3.Event.INSTANCE_CREATED, @@ -30,31 +21,48 @@ R3.Entity = function( this.idRegister = {}; - var components = []; - - this.components.map( - function(component) { - if (component instanceof R3.API.Component) { - components.push(R3.Component.ConstructFromObject(component)); - } else { - components.push(component) - } - } - ); - - this.components = components; - - R3.Component.call( - this, - { - 'components' : [R3.Component] - } - ); + __UPGRADE_TO_RUNTIME__; }; R3.Entity.prototype = Object.create(R3.Component.prototype); R3.Entity.prototype.constructor = R3.Entity; +R3.Entity.prototype.createInstance = function() { + + this.components.map( + function(component) { + component.parent = this; + + Object.keys(component.idToObject).map( + function(componentId) { + R3.Utils.PushUnique(this.components, component.idToObject[componentId]); + component.idToObject[componentId].parent = this; + }.bind(this) + ); + + }.bind(this) + ); + + this.buildIdRegister(); + + this.instance = true; + + __CREATE_INSTANCE__; +}; + +R3.Entity.prototype.updateInstance = function(property) { + + if (property === 'components') { + + this.buildIdRegister(); + + return; + } + + __UPDATE_INSTANCE__; + +}; + /** * Links a component to its parent entity */ @@ -87,32 +95,6 @@ R3.Entity.prototype.removeComponentEvent = function(data) { } }; -/** - * Creates an entity instance - */ -R3.Entity.prototype.createInstance = function() { - - this.components.map( - function(component) { - component.parent = this; - - Object.keys(component.idToObject).map( - function(componentId) { - R3.Utils.PushUnique(this.components, component.idToObject[componentId]); - component.idToObject[componentId].parent = this; - }.bind(this) - ); - - }.bind(this) - ); - - this.buildIdRegister(); - - this.instance = true; - - R3.Component.prototype.createInstance.call(this); -}; - /** * Adds a component to this entity through the instance (should notify the entity manager instance) * @param component @@ -212,25 +194,6 @@ R3.Entity.prototype.queryComponents = function(componentType) { return this.idRegister[componentType] || []; }; -/** - * Returns true when this entity has a certain component, false otherwise - * @param constructor - */ -// R3.Entity.prototype.hasComponent = function(constructor) { -// -// var has = this.components.reduce( -// function(result, component) { -// if (component instanceof constructor) { -// result = true; -// } -// return result; -// }, -// false -// ); -// -// return has; -// }; - R3.Entity.prototype.buildIdRegister = function() { console.log('updating id register for entity : ' + this.name); @@ -251,43 +214,6 @@ R3.Entity.prototype.buildIdRegister = function() { console.log('done updating idRegister'); }; -/** - * Updates an entity instance - */ -R3.Entity.prototype.updateInstance = function(property) { - - if (property === 'components') { - - this.buildIdRegister(); - - return; - } - - R3.Component.prototype.updateInstance.call(this, property); - -}; - -/** - * Converts a R3.Entity to R3.API.Entity - * @returns {R3.API.Entity} - */ -R3.Entity.prototype.toApiObject = function() { - - var apiComponents = this.components.map( - function(component) { - return R3.Utils.IdOrNull(component); - } - ); - - return new R3.API.Entity( - this.id, - this.name, - apiComponents, - R3.Utils.IdOrNull(this.parent) - ); - -}; - /** * Cleanup our subscriptions first */ @@ -297,4 +223,4 @@ R3.Entity.prototype.remove = function() { this.removeComponentSubscription.remove(); R3.Component.prototype.remove.call(this); -}; \ No newline at end of file +}; diff --git a/src/r3-entity-manager.js b/src/r3-entityManager.js similarity index 94% rename from src/r3-entity-manager.js rename to src/r3-entityManager.js index 8b5f817..0c86a9e 100644 --- a/src/r3-entity-manager.js +++ b/src/r3-entityManager.js @@ -1,21 +1,13 @@ /** * R3.EntityManager + * @param apiComponent * @constructor */ -R3.EntityManager = function(apiEntityManager) { +R3.EntityManager = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(apiEntityManager)) { - apiEntityManager = {}; - } - - R3.API.EntityManager.call( - this, - apiEntityManager.id, - apiEntityManager.name, - apiEntityManager.entities, - apiEntityManager.defaultEntity, - apiEntityManager.parent - ); + __RUNTIME_COMPONENT__; /** * The 'register' array is a register of each component currently loaded - when the linking @@ -46,25 +38,24 @@ R3.EntityManager = function(apiEntityManager) { this.entityLoaded.bind(this) ); - R3.Component.call( - this, - { - 'entities' : [R3.Entity], - 'defaultEntity' : R3.Entity - } - ); + __UPGRADE_TO_RUNTIME__; }; R3.EntityManager.prototype = Object.create(R3.Component.prototype); R3.EntityManager.prototype.constructor = R3.EntityManager; R3.EntityManager.prototype.createInstance = function() { + this.instance = R3.EntityManager.Instance; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; R3.EntityManager.prototype.updateInstance = function() { - console.log('todo: entitymanager updateInstance()') + + __UPDATE_INSTANCE__; + }; R3.EntityManager.prototype.instanceCreated = function(data) { diff --git a/src/r3-font.js b/src/r3-font.js index 0717db4..85f5992 100644 --- a/src/r3-font.js +++ b/src/r3-font.js @@ -7,15 +7,10 @@ R3.Font = function( apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; + __RUNTIME_COMPONENT__; - R3.D3.API.Font.call( - this, - apiComponent, - apiComponent.path - ); + __UPGRADE_TO_RUNTIME__; - R3.Component.call(this); }; R3.Font.prototype = Object.create(R3.Component.prototype); @@ -38,12 +33,17 @@ R3.Font.prototype.createInstance = function() { console.log('font instance loaded'); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }.bind(this), function(error) { + console.error(error); + this.instance = null; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }.bind(this) ); @@ -58,5 +58,5 @@ R3.Font.prototype.updateInstance = function(property) { this.createInstance(); } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-graph-0.js b/src/r3-graph-0.js new file mode 100644 index 0000000..080b36e --- /dev/null +++ b/src/r3-graph-0.js @@ -0,0 +1,32 @@ +/** + * R3.Graph + * @param inherited + * @constructor + */ +R3.Graph = function( + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.Graph should not be instantiated directly'); + } + + __UPGRADE_TO_RUNTIME__; + +}; + +R3.Graph.prototype = Object.create(R3.Component.prototype); +R3.Graph.prototype.constructor = R3.Graph; + +/** + * Updates the instance with the current state + */ +R3.Graph.prototype.updateInstance = function(property) { + + if (property === 'domElement') { + console.warn('todo: update graph domElement'); + return; + } + + __UPDATE_INSTANCE__; +}; diff --git a/src/r3-graph-barchart-0.js b/src/r3-graph-barchart-0.js new file mode 100644 index 0000000..ba3042b --- /dev/null +++ b/src/r3-graph-barchart-0.js @@ -0,0 +1,42 @@ +/** + * R3.Graph.Barchart + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Graph.Barchart = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + __RUNTIME_COMPONENT__; + } + + R3.Graph.call( + this, + true + ); + +}; + +R3.Graph.Barchart.prototype = Object.create(R3.Graph.prototype); +R3.Graph.Barchart.prototype.constructor = R3.Graph.Barchart; + +/** + * Updates the instance with the current state + */ +R3.Graph.Barchart.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Graph.Barchart.prototype.updateInstance = function(property) { + + R3.Graph.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-graph-barchart-stacked.js b/src/r3-graph-barchart-stacked.js new file mode 100644 index 0000000..60b945a --- /dev/null +++ b/src/r3-graph-barchart-stacked.js @@ -0,0 +1,42 @@ +/** + * R3.Graph.Barchart.Stacked + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Graph.Barchart.Stacked = function( + apiComponent, + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + __RUNTIME_COMPONENT__; + } + + R3.Graph.call( + this, + true + ); + +}; + +R3.Graph.Barchart.Stacked.prototype = Object.create(R3.Graph.Barchart.prototype); +R3.Graph.Barchart.Stacked.prototype.constructor = R3.Graph.Barchart.Stacked; + +/** + * Updates the instance with the current state + */ +R3.Graph.Barchart.Stacked.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Graph.Barchart.Stacked.prototype.updateInstance = function(property) { + + R3.Graph.Barchart.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-graph-metric.js b/src/r3-graph-metric.js new file mode 100644 index 0000000..cb90703 --- /dev/null +++ b/src/r3-graph-metric.js @@ -0,0 +1,38 @@ +/** + * R3.Graph.Metric + * @param apiComponent + * @constructor + */ +R3.Graph.Metric = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Graph.call( + this, + true + ); + +}; + +R3.Graph.Metric.prototype = Object.create(R3.Component.prototype); +R3.Graph.Metric.prototype.constructor = R3.Graph.Metric; + +/** + * Updates the instance with the current state + */ +R3.Graph.Metric.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Graph.Metric.prototype.updateInstance = function(property) { + + R3.Graph.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-graph-table.js b/src/r3-graph-table.js new file mode 100644 index 0000000..796c65f --- /dev/null +++ b/src/r3-graph-table.js @@ -0,0 +1,38 @@ +/** + * R3.Graph.Table + * @param apiComponent + * @constructor + */ +R3.Graph.Table = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Graph.call( + this, + true + ); + +}; + +R3.Graph.Table.prototype = Object.create(R3.Component.prototype); +R3.Graph.Table.prototype.constructor = R3.Graph.Table; + +/** + * Updates the instance with the current state + */ +R3.Graph.Table.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Graph.Table.prototype.updateInstance = function(property) { + + R3.Graph.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-group.js b/src/r3-group.js index 5c3a9de..e11d82b 100644 --- a/src/r3-group.js +++ b/src/r3-group.js @@ -1,39 +1,15 @@ /** * R3.Group - * @param implementation - * @param apiGroup - * @param parentGeometry + * @param apiComponent * @constructor */ R3.Group = function( - implementation, - apiGroup, - parentGeometry + apiComponent ) { - this.implementation = implementation; - this.implementation.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(parentGeometry)) { - parentGeometry = null; - } - this.parentGeometry = parentGeometry; - - if (R3.Utils.UndefinedOrNull(apiGroup)) { - apiGroup = {}; - } - - R3.API.Group.call( - this, - apiGroup.id, - apiGroup.name, - apiGroup.parent, - apiGroup.start, - apiGroup.count, - apiGroup.materialIndex - ); - - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.Group.prototype = Object.create(R3.Component.prototype); @@ -51,7 +27,7 @@ R3.Group.prototype.createInstance = function() { materialIndex : this.materialIndex }; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; @@ -78,20 +54,5 @@ R3.Group.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * R3.Group to R3.API.Group - * @returns {R3.API.Group} - */ -R3.Group.prototype.toApiObject = function() { - return new R3.API.Group( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.start, - this.count, - this.materialIndex - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-gui.js b/src/r3-gui.js index 335b90e..c24ccbc 100644 --- a/src/r3-gui.js +++ b/src/r3-gui.js @@ -1,34 +1,16 @@ /** * GUI component - * @param guiRuntime - * @param apiGUI + * @param apiComponent * @constructor */ R3.GUI = function( - guiRuntime, - apiGUI + apiComponent ) { - this.guiRuntime = guiRuntime; - this.guiRuntime.isNotDatGuiThrow(); - if (R3.Utils.UndefinedOrNull(apiGUI)) { - apiGUI = {}; - } + __RUNTIME_COMPONENT__; + + __UPGRADE_TO_RUNTIME__; - R3.API.GUI.call( - this, - apiGUI.id, - apiGUI.name, - apiGUI.domElement, - apiGUI.parent - ); - - R3.Component.call( - this, - { - 'domElement': R3.DomElement - } - ); }; R3.GUI.prototype = Object.create(R3.Component.prototype); @@ -38,47 +20,24 @@ R3.GUI.prototype.constructor = R3.GUI; * Creates a helper instance */ R3.GUI.prototype.createInstance = function() { + this.instance = new this.guiRuntime.instance( { autoPlace: false } ); - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; /** * Updates the instance with the current state */ R3.GUI.prototype.updateInstance = function(property) { - console.log('todo: implement gui update instance:' + property); -}; -/** - * Converts a R3.GUI to a new R3.API.GUI - * @returns {R3.API.GUI} - */ -R3.GUI.prototype.toApiObject = function() { + if (property === 'domElement') { + console.warn('todo: update domElement for gui'); + return; + } - return new R3.API.GUI( - this.id, - this.name, - R3.Utils.IdOrNull(this.domElement), - R3.Utils.IdOrNull(this.parent) - ); - -}; - -/** - * Converts from an Object GUI to a R3.GUI - * @param guiRuntime R3.Runtime.GUI - * @param objectGUI Object - * @returns {R3.GUI} - * @constructor - */ -R3.GUI.FromObject = function(guiRuntime, objectGUI) { - - var apiGUI = R3.API.GUI.FromObject(objectGUI); - - return new R3.GUI( - guiRuntime, - apiGUI - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-image.js b/src/r3-image.js index 8369a66..2322c07 100644 --- a/src/r3-image.js +++ b/src/r3-image.js @@ -1,37 +1,16 @@ /** - * Image + * R3.Image + * @param apiComponent * @constructor - * @param apiImage */ R3.Image = function( - apiImage + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiImage)) { - apiImage = {}; - } + __RUNTIME_COMPONENT__; - R3.API.Image.call( - this, - apiImage.id, - apiImage.name, - apiImage.parent, - apiImage.parentTexture, - apiImage.fileName, - apiImage.extension, - apiImage.path, - apiImage.contentType, - apiImage.size, - apiImage.width, - apiImage.height - ); + __UPGRADE_TO_RUNTIME__; - R3.Component.call( - this, - { - parentTexture : R3.D3.Texture - } - ); }; R3.Image.prototype = Object.create(R3.Component.prototype); @@ -54,12 +33,17 @@ R3.Image.prototype.createInstance = function() { this.width = this.instance.width; this.height = this.instance.height; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }.bind(this), function(error) { + console.error(error); + this.instance = null; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }.bind(this) ); @@ -98,7 +82,7 @@ R3.Image.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; R3.Image.prototype.updateFromRawObject = function(rawObject) { @@ -113,29 +97,6 @@ R3.Image.prototype.updateFromRawObject = function(rawObject) { this.height = rawObject.height; }; -/** - * - * @returns {R3.API.Image} - */ -R3.Image.prototype.toApiObject = function() { - - var apiImage = new R3.API.Image( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - R3.Utils.IdOrNull(this.parentTexture), - this.fileName, - this.extension, - this.path, - this.contentType, - this.size, - this.width, - this.height - ); - - return apiImage; -}; - /** * Updates R3.Image from instance */ @@ -158,10 +119,10 @@ R3.Image.prototype.getPixelData = function() { context.drawImage(this.instance, 0, 0, canvas.width, canvas.height); - var imageData = context.getImageData(0, 0, this.width, this.height); - var pixels = imageData.data; + var imageData = context.getImageData(0, 0, this.width, this.height); + + return imageData.data; - return pixels; }; /** @@ -202,4 +163,4 @@ R3.Image.prototype.getHeightData = function() { } return data; -}; \ No newline at end of file +}; diff --git a/src/r3-matrix-4.js b/src/r3-matrix4.js similarity index 65% rename from src/r3-matrix-4.js rename to src/r3-matrix4.js index 87e0384..76d32ad 100644 --- a/src/r3-matrix-4.js +++ b/src/r3-matrix4.js @@ -1,64 +1,21 @@ /** - * Runtime Matrix4 - * @param parent - * @param apiMatrix4 + * R3.Matrix4 + * @param apiComponent * @constructor */ R3.Matrix4 = function( - parent, - apiMatrix4 + apiComponent ) { - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; - - if (R3.Utils.UndefinedOrNull(apiMatrix4)) { - apiMatrix4 = {}; - } - this.apiMatrix4 = apiMatrix4; - - R3.API.Matrix4.call( - this, - apiMatrix4.rows[0], - apiMatrix4.rows[1], - apiMatrix4.rows[2], - apiMatrix4.rows[3] - ); - - this.rows = this.rows.reduce( - function(result, row) { - - result.push( - new R3.Vector4( - this.parent, - row - ) - ); - - return result; - }.bind(this), - [] - ); - - this.graphics = null; - this.physics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - this.physics = runtime.physics; - }.bind(this) - ); + __RUNTIME_COMPONENT__; this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - this.createInstance(); + __UPGRADE_TO_RUNTIME__; + }; -R3.Matrix4.prototype = Object.create(R3.API.Matrix4.prototype); +R3.Matrix4.prototype = Object.create(R3.Component.prototype); R3.Matrix4.prototype.constructor = R3.Matrix4; /** @@ -67,18 +24,21 @@ R3.Matrix4.prototype.constructor = R3.Matrix4; R3.Matrix4.prototype.createInstance = function() { switch (this.componentRuntime) { - case R3.Component.GRAPHICS_RUNTIME : + case R3.Runtime.GRAPHICS : this.instance = this.graphics.Matrix4( this.rows ); break; default : - case R3.Component.PHYSICS_RUNTIME : + case R3.Runtime.PHYSICS : this.instance = this.physics.Matrix4( this.rows ); break; } + + __CREATE_INSTANCE__; + }; /** @@ -106,21 +66,8 @@ R3.Matrix4.prototype.updateInstance = function(property) { this.rows[3].w ); } - -}; -/** - * R3.Matrix4 to R3.API.Matrix4 - * @returns {*} - */ -R3.Matrix4.prototype.toApiObject = function() { - - return new R3.API.Matrix4( - this.rows[0].toApiObject(), - this.rows[1].toApiObject(), - this.rows[2].toApiObject(), - this.rows[3].toApiObject() - ); + __UPDATE_INSTANCE__; }; @@ -187,24 +134,9 @@ R3.Matrix4.prototype.lookAt = function(position, target, up) { * Identity */ R3.Matrix4.prototype.identity = function() { - this.rows = [ - new R3.Vector4( - this.parent, - new R3.API.Vector4(1,0,0,0) - ), - new R3.Vector4( - this.parent, - new R3.API.Vector4(0,1,0,0) - ), - new R3.Vector4( - this.parent, - new R3.API.Vector4(0,0,1,0) - ), - new R3.Vector4( - this.parent, - new R3.API.Vector4(0,0,0,1) - ) - ]; + + R3.API.Matrix4.prototype.identity.call(this); + }; /** diff --git a/src/r3-mouse.js b/src/r3-mouse.js index ae61a37..3d04cab 100644 --- a/src/r3-mouse.js +++ b/src/r3-mouse.js @@ -1,25 +1,15 @@ /** - * Runtime Mouse - * @param apiMouse - * @returns {R3.Mouse} + * R3.Mouse + * @param apiComponent * @constructor */ -R3.Mouse = function(apiMouse) { +R3.Mouse = function( + apiComponent +) { - if (R3.Utils.UndefinedOrNull(apiMouse)){ - apiMouse = {}; - } + __RUNTIME_COMPONENT__; - R3.API.Mouse.call( - this, - apiMouse.id, - apiMouse.name, - apiMouse.parent, - apiMouse.x, - apiMouse.y - ); - - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.Mouse.prototype = Object.create(R3.Component.prototype); @@ -29,8 +19,11 @@ R3.Mouse.prototype.constructor = R3.Mouse; * createInstance */ R3.Mouse.prototype.createInstance = function() { + this.instance = {}; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; /** @@ -39,29 +32,16 @@ R3.Mouse.prototype.createInstance = function() { */ R3.Mouse.prototype.updateInstance = function(property) { - if ( - property === 'x' || - property === 'y' - ) { + if (property === 'x') { this.instance.x = this.x; + return; + } + + if (property === 'y') { this.instance.y = this.y; return; } - R3.Component.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; - -/** - * Converts R3.Mouse vector to R3.API.Mouse - * @returns {R3.API.Mouse} - */ -R3.Mouse.prototype.toApiObject = function() { - return new R3.API.Mouse( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.x, - this.y - ); -}; diff --git a/src/r3-plane.js b/src/r3-plane.js index b806e6f..81a0c11 100644 --- a/src/r3-plane.js +++ b/src/r3-plane.js @@ -1,37 +1,16 @@ /** - * Creates a Plane object - * @param graphics R3.Runtime.Graphics - * @param apiPlane R3.API.Plane + * R3.Plane + * @param apiComponent * @constructor */ R3.Plane = function( - graphics, - apiPlane + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiPlane)) { - apiPlane = {}; - } + __UPGRADE_TO_RUNTIME__; - R3.API.Plane.call( - this, - apiPlane.id, - apiPlane.name, - apiPlane.normal, - apiPlane.constant, - apiPlane.parent - ); - - this.normal = new R3.Vector3( - this.graphics, - this.normal, - this - ); - - R3.Component.call(this); }; R3.Plane.prototype = Object.create(R3.Component.prototype); @@ -39,12 +18,13 @@ R3.Plane.prototype.constructor = R3.Plane; R3.Plane.prototype.createInstance = function() { - this.instance = new THREE.Plane( - this.normal.instance, + this.instance = this.graphics.Plane( + this.normal, this.constant ); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }; /** @@ -65,37 +45,6 @@ R3.Plane.prototype.updateInstance = function(property) { this.instance.constant = this.constant; } - R3.D3.Texture.prototype.updateInstance.call(this, property); + __UPDATE_INSTANCE__; }; - -/** - * Converts a R3.Plane to a new R3.API.Plane - * @returns {R3.API.Plane} - */ -R3.Plane.prototype.toApiObject = function() { - - return new R3.API.Plane( - this.id, - this.name, - this.normal.toApiObject(), - this.constant, - R3.Utils.IdOrNull(this.parent) - ); - -}; - -/** - * Converts from an Object Plane to a R3.Plane - * @param graphics R3.Runtime.Graphics - * @param objectPlane Object - * @returns {R3.Plane} - * @constructor - */ -R3.Plane.FromObject = function(graphics, objectPlane) { - var apiPlane = R3.API.Plane.FromObject(objectPlane); - return new R3.Plane( - graphics, - apiPlane - ); -}; diff --git a/src/r3-project.js b/src/r3-project.js index 52f0880..241bfe5 100644 --- a/src/r3-project.js +++ b/src/r3-project.js @@ -1,109 +1,26 @@ /** * R3.Project - * @param apiProject R3.API.Project + * @param apiComponent * @constructor */ R3.Project = function( - apiProject + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiProject)) { - apiProject = {}; - } + __RUNTIME_COMPONENT__; - R3.API.Project.call( - this, - apiProject.id, - apiProject.name, - apiProject.parent, - apiProject.users, - apiProject.isPublic, - apiProject.entities, - apiProject.renderers, - apiProject.cameras, - apiProject.cameraIndex, - apiProject.controls, - apiProject.mode - ); - - this.users = this.users.map( - function(result, user) { - - if (user instanceof R3.API.User) { - user = R3.Component.ConstructFromObject(user); - } - - result.push(user); - - return result; - }, - [] - ); - - this.entities = this.entities.reduce( - function(result, entity) { - - if (entity instanceof R3.API.Entity) { - entity = R3.Component.ConstructFromObject(entity); - } - - result.push(entity); - - return result; - }, - [] - ); - - this.renderers = this.renderers.reduce( - function(result, renderer) { - - if (renderer instanceof R3.API.Renderer) { - renderer = R3.Component.ConstructFromObject(renderer); - } - - result.push(renderer); - - return result; - }, - [] - ); - - this.cameras = this.cameras.reduce( - function(result, camera) { - - if (camera instanceof R3.D3.API.Camera) { - camera = R3.Component.ConstructFromObject(camera); - } - - result.push(camera); - - return result; - }, - [] - ); - - if (this.controls instanceof R3.API.Controls) { - this.controls = R3.Component.ConstructFromObject(this.controls); - } - - R3.Component.call( - this, - { - 'users' : R3.User, - 'entities' : [R3.Entity], - 'renderer' : [R3.Renderer], - 'cameras' : [R3.D3.Camera], - 'controls' : R3.Controls.D3 - } - ); + __UPGRADE_TO_RUNTIME__; }; R3.Project.prototype = Object.create(R3.Component.prototype); R3.Project.prototype.constructor = R3.Project; R3.Project.prototype.createInstance = function() { + this.instance = true; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; /** @@ -111,10 +28,6 @@ R3.Project.prototype.createInstance = function() { */ R3.Project.prototype.updateInstance = function(property) { - if (property === 'name') { - console.log('todo: project name update'); - } - if (property === 'users') { console.log('todo: project users update'); } @@ -127,66 +40,26 @@ R3.Project.prototype.updateInstance = function(property) { console.log('todo: project entities update'); } - if (property === 'renderer') { + if (property === 'renderers') { console.log('todo: project renderer update'); } + if (property === 'renderTargets') { + console.log('todo: project renderTargets update'); + } + if (property === 'cameras') { console.log('todo: project cameras update'); } - if (property === 'cameraIndex') { - console.log('todo: project cameraIndex update'); - } - if (property === 'controls') { console.log('todo: project controls update'); } - if (property === 'mode') { - console.log('todo: project mode update'); + if (property === 'applicationMode') { + console.log('todo: project applicationMode update'); } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.Project to a new R3.API.Project - * @returns {R3.API.Project} - */ -R3.Project.prototype.toApiObject = function() { - return new R3.API.Project( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.users.reduce( - function(result, user) { - result.push(R3.Utils.IdOrNull(user)); - }, - [] - ), - this.isPublic, - this.entities.reduce( - function(result, entity) { - result.push(R3.Utils.IdOrNull(entity)); - }, - [] - ), - this.renderers.reduce( - function(result, renderer) { - result.push(R3.Utils.IdOrNull(renderer)); - }, - [] - ), - this.cameras.reduce( - function(result, camera) { - result.push(R3.Utils.IdOrNull(camera)); - }, - [] - ), - this.cameraIndex, - R3.Utils.IdOrNull(this.controls), - this.mode - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-quaternion-0.js b/src/r3-quaternion-0.js new file mode 100644 index 0000000..9e6405f --- /dev/null +++ b/src/r3-quaternion-0.js @@ -0,0 +1,124 @@ +/** + * R3.Quaternion + * @param apiComponent + * @constructor + */ +R3.Quaternion = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + Object.defineProperty( + this, + 'angle', + R3.Utils.LimitToPI('angle', this.angle) + ); + + __UPGRADE_TO_RUNTIME__; + + this.createInstance(); +}; + +R3.Quaternion.prototype = Object.create(R3.Component.prototype); +R3.Quaternion.prototype.constructor = R3.Quaternion; + +/** + * Creates an instance quaternion + * @returns {*} + */ +R3.Quaternion.prototype.createInstance = function() { + + if (this.parent.runtime === R3.Runtime.GRAPHICS) { + this.instance = new this.graphics.Quaternion( + this.x, + this.y, + this.z, + this.w + ); + } + + if (this.parent.runtime === R3.Runtime.PHYSICS) { + this.instance = new this.physics.Quaternion( + this.x, + this.y, + this.z, + this.w + ); + } + + __CREATE_INSTANCE__; +}; + +/** + * Updates the instance vector, calls updateInstance on the parent object + */ +R3.Quaternion.prototype.updateInstance = function(property) { + + if (property === 'x') { + this.instance.x = this.x; + return; + } + + if (property === 'y') { + this.instance.y = this.y; + return; + } + + if (property === 'z') { + this.instance.z = this.z; + return; + } + + if (property === 'w') { + this.instance.w = this.w; + return; + } + + if (property === 'axis') { + console.warn('todo: axis update'); + return; + } + + if (property === 'angle') { + console.warn('todo: angle update'); + return; + } + + __UPDATE_INSTANCE__; + +}; + + +/** + * Checks if quaternion is equal to another quaternion + * @param quaternion + * @returns {boolean} + */ +R3.Quaternion.prototype.equals = function(quaternion) { + + return ( + this.x === quaternion.x && + this.y === quaternion.y && + this.z === quaternion.z && + this.w === quaternion.w && + this.axis.equals(quaternion.axis) && + this.angle === quaternion.angle + ); + +}; + +R3.Quaternion.prototype.setFrom = function(quaternion) { + + this.x = quaternion.x; + this.y = quaternion.y; + this.z = quaternion.z; + this.w = quaternion.w; + this.axis.setFrom(quaternion.axis); + this.angle = quaternion.angle; + +}; + +R3.Quaternion.prototype.copy = function() { + R3.API.Quaternion.prototype.copy.call(this); +}; diff --git a/src/r3-quaternion-points.js b/src/r3-quaternion-points.js new file mode 100644 index 0000000..1fd734f --- /dev/null +++ b/src/r3-quaternion-points.js @@ -0,0 +1,41 @@ +/** + * R3.Quaternion.Points + * @param apiComponent + * @constructor + */ +R3.Quaternion.Points = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + __UPGRADE_TO_RUNTIME__; + +}; + +R3.Quaternion.Points.prototype = Object.create(R3.API.Component.prototype); +R3.Quaternion.Points.prototype.constructor = R3.Quaternion.Points; + +/** + * Creates an instance quaternion + * @returns {*} + */ +R3.Quaternion.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance vector, calls updateInstance on the parent object + */ +R3.Quaternion.prototype.updateInstance = function(property) { + + if (property === 'vectors') { + console.warn('todo: vectors update'); + return; + } + + __UPDATE_INSTANCE__; + +}; diff --git a/src/r3-quaternion.js b/src/r3-quaternion.js deleted file mode 100644 index 8f48bf2..0000000 --- a/src/r3-quaternion.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Runtime quaternion for updating instance objects - * @param parent - * @param apiQuaternion R3.API.Quaternion - * @constructor - */ -R3.Quaternion = function( - parent, - apiQuaternion -) { - - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; - - if (R3.Utils.UndefinedOrNull(apiQuaternion)) { - apiQuaternion = {}; - } - this.apiQuaternion = apiQuaternion; - - R3.API.Quaternion.call( - this, - this.apiQuaternion.x, - this.apiQuaternion.y, - this.apiQuaternion.z, - this.apiQuaternion.w, - this.apiQuaternion.axis, - this.apiQuaternion.angle - ); - - this.axis = new R3.Vector3( - this.parent, - this.axis - ); - - Object.defineProperty( - this, - 'angle', - R3.Utils.LimitToPI('angle', this.angle) - ); - - this.graphics = null; - this.physics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - this.physics = runtime.physics; - }.bind(this) - ); - - this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - - this.createInstance(); -}; - -R3.Quaternion.prototype = Object.create(R3.API.Quaternion.prototype); -R3.Quaternion.prototype.constructor = R3.Quaternion; - -/** - * Creates an instance quaternion - * @returns {*} - */ -R3.Quaternion.prototype.createInstance = function() { - - if (this.graphics) { - this.instance = new this.graphics.Quaternion( - this.x, - this.y, - this.z, - this.w - ); - } - - if (this.physics) { - this.instance = new this.physics.Quaternion( - this.x, - this.y, - this.z, - this.w - ); - } -}; - -/** - * Updates the instance vector, calls updateInstance on the parent object - */ -R3.Quaternion.prototype.updateInstance = function(property) { - - if (property === 'x') { - this.instance.x = this.x; - } - - if (property === 'y') { - this.instance.y = this.y; - } - - if (property === 'z') { - this.instance.z = this.z; - } - - if (property === 'w') { - this.instance.w = this.w; - } - -}; - -/** - * Converts runtime quaternion to API quaternion - * @returns {*} - */ -R3.Quaternion.prototype.toApiObject = function() { - return new R3.API.Quaternion( - this.x, - this.y, - this.z, - this.w, - this.axis.toApiObject(), - this.angle - ); -}; - -/** - * Checks if quaternion is equal to another quaternion - * @param quaternion - * @returns {boolean} - */ -R3.Quaternion.prototype.equals = function(quaternion) { - - return ( - this.x === quaternion.x && - this.y === quaternion.y && - this.z === quaternion.z && - this.w === quaternion.w && - this.axis.equals(quaternion.axis) && - this.angle === quaternion.angle - ); - -}; - -R3.Quaternion.prototype.setFrom = function(quaternion) { - this.x = quaternion.x; - this.y = quaternion.y; - this.z = quaternion.z; - this.w = quaternion.w; - this.axis.setFrom(quaternion.axis); - this.angle = quaternion.angle; -}; - -R3.Quaternion.prototype.copy = function(quaternion) { - console.log('todo quaternion copy'); -}; \ No newline at end of file diff --git a/src/r3-query-0.js b/src/r3-query-0.js new file mode 100644 index 0000000..af09a05 --- /dev/null +++ b/src/r3-query-0.js @@ -0,0 +1,52 @@ +/** + * R3.Query + * @param inherited + * @constructor + */ +R3.Query = function( + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.Query should not be instantiated directly'); + } + + __UPGRADE_TO_RUNTIME__; + +}; + +R3.Query.prototype = Object.create(R3.Component.prototype); +R3.Query.prototype.constructor = R3.Query; + +/** + * Updates the instance with the current state + */ +R3.Query.prototype.updateInstance = function(property) { + + if (property === 'path') { + console.warn('todo: update query path'); + return; + } + + if (property === 'start') { + console.warn('todo: update query start'); + return; + } + + if (property === 'end') { + console.warn('todo: update query end'); + return; + } + + if (property === 'size') { + console.warn('todo: update query size'); + return; + } + + if (property === 'text') { + console.warn('todo: update query text'); + return; + } + + __UPDATE_INSTANCE__; +}; diff --git a/src/r3-query-alerts-0.js b/src/r3-query-alerts-0.js new file mode 100644 index 0000000..f2d8587 --- /dev/null +++ b/src/r3-query-alerts-0.js @@ -0,0 +1,31 @@ +/** + * R3.Query.Alerts + * @param inherited + * @constructor + */ +R3.Query.Alerts = function( + inherited +) { + + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('R3.Query.Alerts should not be instantiated directly'); + } + + R3.Query.call( + this, + true + ); + +}; + +R3.Query.Alerts.prototype = Object.create(R3.Component.prototype); +R3.Query.Alerts.prototype.constructor = R3.Query.Alerts; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.prototype.updateInstance = function(property) { + + R3.Query.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-alerts-buckets.js b/src/r3-query-alerts-buckets.js new file mode 100644 index 0000000..d24bedb --- /dev/null +++ b/src/r3-query-alerts-buckets.js @@ -0,0 +1,38 @@ +/** + * R3.Query.Alerts.Buckets + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.Buckets = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.call( + this, + true + ); + +}; + +R3.Query.Alerts.Buckets.prototype = Object.create(R3.Query.Alerts.prototype); +R3.Query.Alerts.Buckets.prototype.constructor = R3.Query.Alerts.Buckets; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Buckets.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Buckets.prototype.updateInstance = function(property) { + + R3.Query.Alerts.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-alerts-list.js b/src/r3-query-alerts-list.js new file mode 100644 index 0000000..bd313aa --- /dev/null +++ b/src/r3-query-alerts-list.js @@ -0,0 +1,38 @@ +/** + * R3.Query.Alerts.List + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.List = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.call( + this, + true + ); + +}; + +R3.Query.Alerts.List.prototype = Object.create(R3.Query.Alerts.prototype); +R3.Query.Alerts.List.prototype.constructor = R3.Query.Alerts.List; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.List.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.List.prototype.updateInstance = function(property) { + + R3.Query.Alerts.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-alerts-summary.js b/src/r3-query-alerts-summary.js new file mode 100644 index 0000000..659a9e6 --- /dev/null +++ b/src/r3-query-alerts-summary.js @@ -0,0 +1,38 @@ +/** + * R3.Query.Alerts.Summary + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.Summary = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.call( + this, + true + ); + +}; + +R3.Query.Alerts.Summary.prototype = Object.create(R3.Query.Alerts.prototype); +R3.Query.Alerts.Summary.prototype.constructor = R3.Query.Alerts.Summary; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Summary.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Summary.prototype.updateInstance = function(property) { + + R3.Query.Alerts.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-alerts-timeseries.js b/src/r3-query-alerts-timeseries.js new file mode 100644 index 0000000..0affbaa --- /dev/null +++ b/src/r3-query-alerts-timeseries.js @@ -0,0 +1,38 @@ +/** + * R3.Query.Alerts.Timeseries + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.Timeseries = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.call( + this, + true + ); + +}; + +R3.Query.Alerts.Timeseries.prototype = Object.create(R3.Query.Alerts.prototype); +R3.Query.Alerts.Timeseries.prototype.constructor = R3.Query.Alerts.Timeseries; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Timeseries.prototype.createInstance = function() { + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.Timeseries.prototype.updateInstance = function(property) { + + R3.Query.Alerts.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-renderer-0.js b/src/r3-renderer-0.js new file mode 100644 index 0000000..e9dbfcc --- /dev/null +++ b/src/r3-renderer-0.js @@ -0,0 +1,21 @@ +/** + * R3.Renderer + * @constructor + */ +R3.Renderer = function() { + + __UPGRADE_TO_RUNTIME; + +}; + +R3.Renderer.prototype = Object.create(R3.Component.prototype); +R3.Renderer.prototype.constructor = R3.Renderer; + +/** + * Update Renderer Instance + */ +R3.Renderer.prototype.updateInstance = function(property) { + + __UPDATE_INSTANCE__; + +}; diff --git a/src/r3-renderer-a.js b/src/r3-renderer-a.js deleted file mode 100644 index 396bedb..0000000 --- a/src/r3-renderer-a.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * R3.Renderer - * @param parent - * @param linkedObjects - * @constructor - */ -R3.Renderer = function( - parent, - linkedObjects -) { - - R3.Component.call( - this, - parent, - linkedObjects - ); - -}; - -R3.Renderer.prototype = Object.create(R3.Component.prototype); -R3.Renderer.prototype.constructor = R3.Renderer; - -/** - * Update Renderer Instance - */ -R3.Renderer.prototype.updateInstance = function(property) { - - if (!property) { - throw new Error('no renderer property'); - } - - if (!this.instance) { - throw new Error('no renderer instance'); - } - - if (property === 'size') { - - this.width = this.target.width; - this.height = this.target.height; - - /** - * Emit a resize event so other objects like effects and composers can update their sizes - */ - R3.Event.Emit( - R3.Event.RENDERER_SIZE_CHANGE, - this - ); - /** - * TODO: Allow other objects like effects and composers to update their size if it was using this render target - */ - console.warn('TODO: Allow other objects like effects and composers to update their size if it was using this render target'); - //R3.Event.Emit(R3.Event.RENDER_TARGET_CHANGE, this.renderTarget); - } - - R3.Component.prototype.updateInstance.call(this, property); -}; diff --git a/src/r3-renderer-d2.js b/src/r3-renderer-d2.js index 4fd46b2..ed72b4f 100644 --- a/src/r3-renderer-d2.js +++ b/src/r3-renderer-d2.js @@ -1,33 +1,15 @@ /** * R3.Renderer.D2 - * @param graphics - * @param apiRendererD2 R3.API.Renderer.D2 + * @param apiComponent * @constructor */ R3.Renderer.D2 = function( - graphics, - apiRendererD2 + apiComponent ) { - if (R3.Utils.UndefinedOrNull(graphics)) { - graphics = null; - } - this.graphics = graphics; - - if (R3.Utils.UndefinedOrNull(apiRendererD2)) { - apiRendererD2 = { - rendererType : R3.API.Renderer.RENDERER_TYPE_2D - }; - } - - R3.API.Renderer.D2.call( - this, - apiRendererD2 - ); + __RUNTIME_COMPONENT__; R3.Renderer.call( - this, - this.graphics, this ); @@ -42,17 +24,10 @@ R3.Renderer.D2.prototype.constructor = R3.Renderer.D2; */ R3.Renderer.D2.prototype.createInstance = function() { - if ( - R3.Utils.UndefinedOrNull(this.canvas) || - R3.Utils.UndefinedOrNull(this.canvas.instance) - ) { - console.warn('no canvas instance'); - return; - } - this.instance = true; - R3.Renderer.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }; /** @@ -60,12 +35,9 @@ R3.Renderer.D2.prototype.createInstance = function() { */ R3.Renderer.D2.prototype.updateInstance = function(property) { - if (!property) { - throw new Error('no renderer property'); - } - - if (!this.instance) { - throw new Error('no renderer instance'); + if (property === 'canvas') { + console.warn('todo: D2 canvas update'); + return; } R3.Renderer.prototype.updateInstance.call(this, property); diff --git a/src/r3-renderer-d3.js b/src/r3-renderer-d3-0.js similarity index 84% rename from src/r3-renderer-d3.js rename to src/r3-renderer-d3-0.js index 0795f6f..e4d47e2 100644 --- a/src/r3-renderer-d3.js +++ b/src/r3-renderer-d3-0.js @@ -1,56 +1,18 @@ /** * R3.Renderer.D3 - * @param parent - * @param linkedObjects + * @param inherited * @constructor */ R3.Renderer.D3 = function( - parent, - linkedObjects + inherited ) { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - linkedObjects = {} + if (R3.Utils.UndefinedOrNull(inherited)) { + throw new Error('This class cannot be instantiated directly - use R3.Renderer.D3.Canvas or R3.Renderer.D3.Canvas.Target'); } - this.clippingPlanes = this.clippingPlanes.reduce( - function(result, clippingPlane) { - - if (clippingPlane instanceof R3.API.Plane) { - clippingPlane = R3.Component.ConstructFromObject(clippingPlane); - } - - result.push(clippingPlane); - return result; - }, - [] - ); - - this.viewports = this.viewports.reduce( - function(result, viewport) { - - if (viewport instanceof R3.D3.API.Viewport) { - viewport = R3.Component.ConstructFromObject(viewport); - } - - result.push(viewport); - return result; - }, - [] - ); - - linkedObjects.clippingPlanes = [R3.Plane]; - linkedObjects.viewports = [R3.D3.Viewport]; - - this.clearColor = new R3.Color( - parent, - this.clearColor - ); - R3.Renderer.call( - this, - parent, - linkedObjects + this ); }; @@ -59,7 +21,7 @@ R3.Renderer.D3.prototype = Object.create(R3.Renderer.prototype); R3.Renderer.D3.prototype.constructor = R3.Renderer.D3; /** - * Create R3.Renderer.D3 Instance + * Even though this class cannot be instantiated directly - it can do common tasks for its children * @returns {*} */ R3.Renderer.D3.prototype.createInstance = function() { @@ -95,7 +57,7 @@ R3.Renderer.D3.prototype.createInstance = function() { this.updateInstance('opacity'); this.updateInstance('pixelRatio'); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; diff --git a/src/r3-renderer-d3-canvas.js b/src/r3-renderer-d3-canvas-0.js similarity index 76% rename from src/r3-renderer-d3-canvas.js rename to src/r3-renderer-d3-canvas-0.js index cf4720e..23facb7 100644 --- a/src/r3-renderer-d3-canvas.js +++ b/src/r3-renderer-d3-canvas-0.js @@ -1,39 +1,25 @@ /** * R3.Renderer.D3.Canvas - * @param parent * @param apiComponent - * @param linkedObjects + * @param inherited * @constructor */ R3.Renderer.D3.Canvas = function( - parent, apiComponent, - linkedObjects + inherited ) { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - - linkedObjects = {}; - - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Renderer.D3.Canvas.call( - this, - apiComponent, - apiComponent.canvas - ); + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; } - - if (this.canvas instanceof R3.API.Canvas) { - this.canvas = R3.Component.ConstructFromObject(this.canvas); + + if (!inherited) { + __RUNTIME_COMPONENT__; } - - linkedObjects.canvas = R3.Canvas; - - R3.Component.call( + + R3.Renderer.D3.call( this, - parent, - linkedObjects + true ); }; diff --git a/src/r3-renderer-d3-canvas-target.js b/src/r3-renderer-d3-canvas-target.js index c0e301b..5884a14 100644 --- a/src/r3-renderer-d3-canvas-target.js +++ b/src/r3-renderer-d3-canvas-target.js @@ -1,35 +1,17 @@ /** * R3.Renderer.D3.Canvas.Target - * @param parent * @param apiComponent * @constructor */ R3.Renderer.D3.Canvas.Target = function( - parent, apiComponent ) { - __RUNTIME_COMPONENT_MACRO__; - - R3.API.Renderer.D3.Canvas.Target.call( - this, - apiComponent, - apiComponent.target - ); - - if (this.target instanceof R3.D3.API.RenderTarget) { - this.target = R3.Component.ConstructFromObject(this.target); - } - - var linkedObjects = { - target : R3.D3.RenderTarget - }; + __RUNTIME_COMPONENT__; R3.Renderer.D3.Canvas.call( this, - parent, - apiComponent, - linkedObjects + true ); }; @@ -119,4 +101,4 @@ R3.Renderer.D3.Canvas.Target.prototype.updateInstance = function(property) { */ R3.Renderer.D3.Canvas.Target.prototype.getSize = function() { return R3.API.Renderer.D3.Canvas.Target.prototype.getSize.call(this); -}; \ No newline at end of file +}; diff --git a/src/r3-runtime-0.js b/src/r3-runtime-0.js new file mode 100644 index 0000000..2303bf1 --- /dev/null +++ b/src/r3-runtime-0.js @@ -0,0 +1,18 @@ +/** + * R3.Runtime + * + * All Runtimes should extend this + * + * @constructor + */ +R3.Runtime = function() { + +}; + +R3.Runtime.GRAPHICS = 0x1; +R3.Runtime.PHYSICS = 0x2; +R3.Runtime.SOCKETS = 0x3; +R3.Runtime.STATISTICS = 0x4; +R3.Runtime.DEFAULT = 0x5; +R3.Runtime.GUI = 0x6; +R3.Runtime.CODER = 0x7; \ No newline at end of file diff --git a/src/r3-runtime-coder.js b/src/r3-runtime-coder-0.js similarity index 100% rename from src/r3-runtime-coder.js rename to src/r3-runtime-coder-0.js diff --git a/src/r3-runtime-graphics-0.js b/src/r3-runtime-graphics-0.js new file mode 100644 index 0000000..bdb1f70 --- /dev/null +++ b/src/r3-runtime-graphics-0.js @@ -0,0 +1,496 @@ +/** + * R3.Runtime.Graphics + * @constructor + */ +R3.Runtime.Graphics = function() { + + R3.Runtime.call(this); + +}; + +R3.Runtime.Graphics.prototype = Object.create(R3.Runtime.prototype); +R3.Runtime.Graphics.prototype.constructor = R3.Runtime.Graphics; + +R3.Runtime.Graphics.prototype.Vector2 = function(x,y) { + console.warn('override Vector2 in child class'); +}; + +R3.Runtime.Graphics.prototype.Vector3 = function(x,y,z) { + console.warn('override Vector3 in child class'); +}; + +R3.Runtime.Graphics.prototype.Vector4 = function(x,y,z,w) { + console.warn('override Vector4 in child class'); +}; + +R3.Runtime.Graphics.prototype.Box3 = function(x,y,z) { + console.warn('override Box3 in child class'); +}; + +R3.Runtime.Graphics.prototype.Color = function(r,g,b,a) { + console.warn('override Color in child class'); +}; + +R3.Runtime.Graphics.prototype.Matrix4 = function(rows) { + console.warn('override Matrix4 in child class'); +}; + +R3.Runtime.Graphics.prototype.Quaternion = function(x, y, z, w) { + console.warn('override Quaternion in child class'); +}; + +R3.Runtime.Graphics.prototype.Clock = function() { + console.warn('override Clock in child class'); +}; + +R3.Runtime.Graphics.prototype.EditorControls = function(canvas, camera) { + console.warn('override EditorControls in child class'); +}; + +R3.Runtime.Graphics.prototype.OrbitControls = function(canvas, camera) { + console.warn('override OrbitControls in child class'); +}; + +R3.Runtime.Graphics.prototype.FirstPersonControls = function(canvas, camera) { + console.warn('override FirstPersonControls in child class'); +}; + +R3.Runtime.Graphics.prototype.Curve = function(arcLenghDivisions) { + console.warn('override Curve in child class'); +}; + +R3.Runtime.Graphics.prototype.CurvePath = function(curves, autoClose) { + console.warn('override CurvePath in child class'); +}; + +R3.Runtime.Graphics.prototype.Path = function(points) { + console.warn('override Path in child class'); +}; + +R3.Runtime.Graphics.prototype.Shape = function(points) { + console.warn('override Shape in child class'); +}; + +R3.Runtime.Graphics.prototype.Audio = function( + path, + loop, + volume, + camera, +) { + console.warn('override Audio in child class'); +}; + +R3.Runtime.Graphics.prototype.Bone = function( + position, + rotation, + scale, + quaternion, + lookAt, + up +) { + console.warn('override Bone in child class'); +}; + +R3.Runtime.Graphics.prototype.CubeCamera = function(near, far, cubeResolution) { + console.warn('override CubeCamera in child class'); +}; + +R3.Runtime.Graphics.prototype.OrthographicCamera = function( + left, + right, + top, + bottom, + near, + far +) { + console.warn('override OrthographicCamera in child class'); +}; + +R3.Runtime.Graphics.prototype.PerspectiveCamera = function( + fov, + aspect, + near, + far +) { + console.warn('override PerspectiveCamera in child class'); +}; + +R3.Runtime.Graphics.prototype.StereoCamera = function( + fov, + aspect, + near, + far +) { + console.warn('override StereoCamera in child class'); +}; + +R3.Runtime.Graphics.prototype.RenderTarget = function( + width, + height, + wrapS, + wrapT, + magFilter, + minFilter, + format, + type, + anisotropy, + encoding, + depthBuffer, + stencilBuffer +) { + console.warn('override RenderTarget in child class'); +}; + +R3.Runtime.Graphics.prototype.Composer = function( + renderer, + renderTarget, + passes, + size +) { + console.warn('override Composer in child class'); +}; + +R3.Runtime.Graphics.prototype.Renderer3D = function( + canvas, + alpha, + premultipliedAlpha, + antialias, + stencil, + preserveDrawingBuffer, + depth, + logarithmicDepthBuffer +) { + console.warn('override Renderer3D in child class'); +}; + +R3.Runtime.Graphics.prototype.AnaglyphEffect = function( + renderer +) { + console.warn('override AnaglyphEffect in child class'); +}; + +R3.Runtime.Graphics.prototype.ParallaxEffect = function( + renderer +) { + console.warn('override ParallaxEffect in child class'); +}; + +R3.Runtime.Graphics.prototype.StereoEffect = function( + renderer +) { + console.warn('override StereoEffect in child class'); +}; + +R3.Runtime.Graphics.prototype.Face = function( + runtimeObject +) { + console.warn('override Face in child class'); +}; + +R3.Runtime.Graphics.prototype.FogExp = function( + color, + density +) { + console.warn('override R3.Runtime.Graphics.prototype.FogExp in child class'); +}; + +R3.Runtime.Graphics.prototype.Fog = function( + color, + near, + far +) { + console.warn('override R3.Runtime.Graphics.prototype.Fog in child class'); +}; + +R3.Runtime.Graphics.prototype.Raycaster = function( + position, + direction +) { + console.warn('override R3.Runtime.Graphics.prototype.Raycaster in child class'); +}; + +R3.Runtime.Graphics.prototype.Plane = function( + normal, + constant +) { + console.warn('override R3.Runtime.Graphics.prototype.Plane in child class'); +}; + +R3.Runtime.Graphics.prototype.Sphere = function( + center, + radius +) { + console.warn('override R3.Runtime.Graphics.prototype.Sphere in child class'); +}; + +R3.Runtime.Graphics.prototype.PassFXAA = function ( + width, + height +) { + console.warn('override R3.Runtime.Graphics.prototype.PassFXAA in child class'); +}; + +R3.Runtime.Graphics.prototype.PassBloom = function ( + size, + strength, + radius, + threshold +) { + console.warn('override R3.Runtime.Graphics.prototype.PassBloom in child class'); +}; + +R3.Runtime.Graphics.prototype.PassCopy = function () { + console.warn('override R3.Runtime.Graphics.prototype.PassCopy in child class'); +}; + +R3.Runtime.Graphics.prototype.PassRender = function ( + scene, + camera +) { + console.warn('override R3.Runtime.Graphics.prototype.PassRender in child class'); +}; + +R3.Runtime.Graphics.prototype.PassSSAO = function ( + scene, + camera, + size, + radius, + onlyAO, + aoClamp, + lumInfluence +) { + console.warn('override R3.Runtime.Graphics.prototype.PassSSAO in child class'); +}; + +R3.Runtime.Graphics.prototype.Geometry = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.Geometry in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBuffer = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBuffer in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferBox = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferBox in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferCircle = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferCircle in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferCone = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferCone in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferCylinder = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferCylinder in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferDodecahedron = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferDodecahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferExtrude = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferExtrude in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferIcosahedron = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferIcosahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferInstanced = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferInstanced in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferLathe = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferLathe in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferOctahedron = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferOctahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferSphere = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferOctahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferParametric = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferOctahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferPlane = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferOctahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferPolyhedron = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferOctahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferRing = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferRing in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferShape = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferShape in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferText = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferText in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferTetrahedron = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferTetrahedron in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferTorus = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferTorus in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferTorusKnot = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferTorusKnot in child class'); +}; + +R3.Runtime.Graphics.prototype.GeometryBufferTube = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.GeometryBufferTube in child class'); +}; + +R3.Runtime.Graphics.prototype.Helper = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.Helper in child class'); +}; + +R3.Runtime.Graphics.prototype.LightAmbient = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightAmbient in child class'); +}; + +R3.Runtime.Graphics.prototype.LightDirectional = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightDirectional in child class'); +}; + +R3.Runtime.Graphics.prototype.LightHemisphere = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightHemisphere in child class'); +}; + +R3.Runtime.Graphics.prototype.LightPoint = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightPoint in child class'); +}; + +R3.Runtime.Graphics.prototype.LightRectArea = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightRectArea in child class'); +}; + +R3.Runtime.Graphics.prototype.LightSpot = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.LightSpot in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialBasic = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialBasic in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialPhong = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialPhong in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialPoints = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialPoints in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialShader = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialShader in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialShaderRaw = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialShaderRaw in child class'); +}; + +R3.Runtime.Graphics.prototype.MaterialStandard = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MaterialStandard in child class'); +}; + +R3.Runtime.Graphics.prototype.Mesh = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.Mesh in child class'); +}; + +R3.Runtime.Graphics.prototype.MeshSkeleton = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MeshSkeleton in child class'); +}; + + +R3.Runtime.Graphics.prototype.updateInstance = function (runtimeObject, property) { + console.warn('override R3.Runtime.Graphics.prototype.updateInstance in child class'); +}; \ No newline at end of file diff --git a/src/r3-runtime-graphics-three.js b/src/r3-runtime-graphics-three.js index 2921989..8928ce8 100644 --- a/src/r3-runtime-graphics-three.js +++ b/src/r3-runtime-graphics-three.js @@ -266,20 +266,18 @@ R3.Runtime.Graphics.Three.prototype.Shape = function(points) { /** * Returns an Audio object - this object still has to load so don't do anything with it yet - * @param component * @param path * @param loop * @param volume - * @param cameraIndex + * @param camera * @returns {boolean|*} * @constructor */ R3.Runtime.Graphics.Three.prototype.Audio = function( - component, path, loop, volume, - cameraIndex + camera ) { /** @@ -296,13 +294,6 @@ R3.Runtime.Graphics.Three.prototype.Audio = function( null, function(project) { - var camera = project.cameras[cameraIndex]; - - if (R3.Utils.UndefinedOrNull(camera) || - R3.Utils.UndefinedOrNull(camera.instance)) { - throw new Error('Camera not ready for audio'); - } - R3.Event.Emit( R3.Event.GET_API_URL, null, @@ -344,7 +335,7 @@ R3.Runtime.Graphics.Three.prototype.Audio = function( audio.setLoop(loop); audio.setVolume(volume); - R3.Component.prototype.createInstance.call(component); + __CREATE_INSTANCE__; } ); } catch (error) { @@ -361,8 +352,26 @@ R3.Runtime.Graphics.Three.prototype.Audio = function( }; -R3.Runtime.Graphics.Three.prototype.Bone = function() { - return new THREE.Bone(); +R3.Runtime.Graphics.Three.prototype.Bone = function( + position, + rotation, + scale, + quaternion, + lookAt, + up +) { + console.warn('todo: test bones'); + + var instance = new THREE.Bone(); + + instance.position = position.instance; + instance.rotation = rotation.instance; + instance.scale = scale.instance; + instance.quaternion = quaternion.instance; + instance.lookAt = lookAt.instance; + instance.up = up.instance; + + return instance; }; R3.Runtime.Graphics.Three.prototype.CubeCamera = function(near, far, cubeResolution) { @@ -411,8 +420,7 @@ R3.Runtime.Graphics.Three.prototype.StereoCamera = function( fov, aspect, near, - far, - stereoMode + far ) { console.warn('TODO: implement stereo camera again'); @@ -552,51 +560,41 @@ R3.Runtime.Graphics.Three.prototype.ParallaxEffect = function( }; R3.Runtime.Graphics.Three.prototype.StereoEffect = function( - renderer + renderer, + eyeSeperation ) { - new THREE.StereoEffect( + var instance = THREE.StereoEffect( renderer.instance ); + + instance.setEyeSeparation( + eyeSeperation + ); + + return instance; }; R3.Runtime.Graphics.Three.prototype.Face = function( - v0index, - v1index, - v2index, - normal, - color, - materialIndex, - vertexColors + runtimeObject ) { + var face = new THREE.Face3( - v0index, - v1index, - v2index + runtimeObject.vertexIndices[0], + runtimeObject.vertexIndices[1], + runtimeObject.vertexIndices[2] ); - if (normal) { - face.normal = new THREE.Vector3( - normal.x, - normal.y, - normal.z - ); - } + face.normal = runtimeObject.normal.instance; - if (color) { - face.color = new THREE.Color( - color.r, - color.g, - color.b - ) - } + face.color = runtimeObject.color.instance; if (materialIndex > -1) { face.materialIndex = materialIndex; } - vertexColors.map( - function(vertexColor, index) { - face.vertexColors[index] = new THREE.Color(vertexColor.r, vertexColor.g, vertexColor.b); + runtimeObject.vertices.map( + function(vertex, index) { + face.vertexColors[index] = vertex.color.instance; } ); @@ -624,27 +622,1052 @@ R3.Runtime.Graphics.Three.prototype.Fog = function( ); }; + +R3.Runtime.Graphics.Three.prototype.Raycaster = function( + position, + direction +) { + var instance = new THREE.Raycaster(); + instance.set( + position.instance, + direction.instance + ); + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.Plane = function( + normal, + constant +) { + return new THREE.Plane( + normal.instance, + constant + ); +}; + +R3.Runtime.Graphics.Three.prototype.Sphere = function( + center, + radius +) { + return new THREE.Sphere( + center.instance, + radius + ); +}; + +R3.Runtime.Graphics.Three.prototype.PassFXAA = function ( + width, + height +) { + var instance = new THREE.ShaderPass(THREE.FXAAShader); + + instance.uniforms['resolution'].value.set( + 1 / width, + 1 / height + ); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.PassBloom = function ( + size, + strength, + radius, + threshold +) { + return new THREE.BloomPass( + size.instance, + strength, + radius, + threshold + ); + +}; + +R3.Runtime.Graphics.Three.prototype.PassCopy = function () { + return new THREE.ShaderPass(THREE.CopyShader); +}; + +R3.Runtime.Graphics.Three.prototype.PassRender = function ( + scene, + camera +) { + return new THREE.RenderPass( + scene.instance, + camera.instance + ); +}; + +R3.Runtime.Graphics.Three.prototype.PassSSAO = function ( + scene, + camera, + size, + radius, + onlyAO, + aoClamp, + lumInfluence +) { + var instance = new THREE.SSAOPass( + scene.instance, + camera.instance, + size.x, + size.y + ); + + instance.radius = radius; + + instance.onlyAO = onlyAO; + + instance.aoClamp = aoClamp; + + instance.lumInfluence = lumInfluence; + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.Geometry = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.Geometry in child class'); + + var instance = new THREE.Geometry(); + + runtimeObject.vertices.map( + function(vertex) { + instance.vertices.push(vertex.instance); + } + ); + + + + instance.computeBoundingBox(); + + instance.computeBoundingSphere(); + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBuffer = function ( + runtimeObject +) { + var instance = new THREE.BufferGeometry(); + + /** + * Setup mesh vertices positions + * @type {Float32Array} + */ + this.updateInstance(runtimeObject, 'positions', instance); + + this.updateInstance(runtimeObject, 'vertexColors', instance); + + this.updateInstance(runtimeObject, 'uvs', instance); + + this.updateInstance(runtimeObject, 'normals', instance); + + instance.setDrawRange( + runtimeObject.drawRange.start, + runtimeObject.drawRange.count + ); + + runtimeObject.groups.map( + function(group) { + instance.addGroup( + group.start, + group.count, + group.materialIndex + ) + } + ); + + /** + * Setup material groups - this means creating a new group for each material index change + * We know faces are sorted according to material index + */ + var groupIndexCounts = runtimeObject.faces.reduce( + + function(result, face) { + + var currentGroup = result.pop(); + + if (currentGroup.index !== face.materialIndex) { + /** + * We have a new group + */ + result.push(currentGroup); + result.push({ + index: face.materialIndex, + count: 3 + }) + } else { + currentGroup.count += 3; + result.push(currentGroup); + } + + return result; + }, + [ + { + index : 0, + count : 0 + } + ] + ); + + groupIndexCounts.reduce( + function(result, group) { + instance.addGroup(result, group.count, group.index); + return result + group.count; + }, + 0 + ); + +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferBox = function ( + runtimeObject +) { + + var instance = new THREE.BoxBufferGeometry( + runtimeObject.width, + runtimeObject.height, + runtimeObject.depth, + runtimeObject.widthSegments, + runtimeObject.heightSegments, + runtimeObject.depthSegments + ); + + instance.computeVertexNormals(); + + return instance; +}; + + +R3.Runtime.Graphics.Three.prototype.GeometryBufferCircle = function ( + runtimeObject +) { + + var instance = new THREE.CircleBufferGeometry( + runtimeObject.radius, + runtimeObject.segments, + runtimeObject.thetaStart, + runtimeObject.thetaLength + ); + + instance.computeVertexNormals(); + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferCone = function ( + runtimeObject +) { + var instance = new THREE.ConeBufferGeometry( + runtimeObject.radius, + runtimeObject.height, + runtimeObject.radialSegments, + runtimeObject.heightSegments, + runtimeObject.openEnded, + runtimeObject.thetaStart, + runtimeObject.thetaLength + ); + + instance.computeVertexNormals(); + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferCylinder = function ( + runtimeObject +) { + var instance = new THREE.CylinderBufferGeometry( + runtimeObject.radiusTop, + runtimeObject.radiusBottom, + runtimeObject.height, + runtimeObject.radialSegments, + runtimeObject.heightSegments, + runtimeObject.openEnded, + runtimeObject.thetaStart, + runtimeObject.thetaLength + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferDodecahedron = function ( + runtimeObject +) { + var instance = new THREE.DodecahedronBufferGeometry( + runtimeObject.radius, + runtimeObject.detail + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferExtrude = function ( + runtimeObject +) { + var instance = new THREE.ExtrudeBufferGeometry( + runtimeObject.shapes.map( + function(shape) { + return shape.instance; + } + ), + { + curveSegments : runtimeObject.curveSegments, + steps : runtimeObject.steps, + amount : runtimeObject.amount, + bevelEnabled : runtimeObject.bevelEnabled, + bevelThickness : runtimeObject.bevelThickness, + bevelSize : runtimeObject.bevelSize, + bevelSegments : runtimeObject.bevelSegments + } + ); + + instance.computeVertexNormals(); + + return instance; +}; + + +R3.Runtime.Graphics.Three.prototype.GeometryBufferIcosahedron = function ( + runtimeObject +) { + + var instance = new THREE.IcosahedronBufferGeometry( + runtimeObject.radius, + runtimeObject.detail + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferInstanced = function ( + runtimeObject +) { + var instance = new THREE.InstancedBufferGeometry(); + + instance.maxInstancedCount = runtimeObject.maxInstancedCount; + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferLathe = function ( + runtimeObject +) { + var instance = new THREE.LatheBufferGeometry( + runtimeObject.points.map( + function(point) { + return point.instance; + } + ), + runtimeObject.segments, + runtimeObject.phiStart, + runtimeObject.phiLength + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferOctahedron = function ( + runtimeObject +) { + var instance = new THREE.OctahedronBufferGeometry( + runtimeObject.radius, + runtimeObject.detail + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferSphere = function ( + runtimeObject +) { + var instance = new THREE.SphereBufferGeometry( + runtimeObject.radius, + runtimeObject.widthSegments, + runtimeObject.heightSegments, + runtimeObject.phiStart, + runtimeObject.phiLength, + runtimeObject.thetaStart, + runtimeObject.thetaLength + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferParametric = function ( + runtimeObject +) { + var instance = new THREE.ParametricBufferGeometry( + new Function('u', 'v', runtimeObject.generatorFn).bind(runtimeObject), + runtimeObject.slices, + runtimeObject.stacks + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferPlane = function ( + runtimeObject +) { + var instance = new THREE.PlaneBufferGeometry( + runtimeObject.width, + runtimeObject.height, + runtimeObject.widthSegments, + runtimeObject.heightSegments + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferPolyhedron = function ( + runtimeObject +) { + var instance = new THREE.PolyhedronBufferGeometry( + runtimeObject.vertices.map( + function(vertex) { + return vertex.position.instance; + } + ), + runtimeObject.indices.map( + function(index) { + return index.instance; + } + ), + runtimeObject.radius, + runtimeObject.detail + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferRing = function ( + runtimeObject +) { + var instance = new THREE.RingBufferGeometry( + runtimeObject.innerRadius, + runtimeObject.outerRadius, + runtimeObject.thetaSegments, + runtimeObject.phiSegments, + runtimeObject.thetaStart, + runtimeObject.thetaLength + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferShape = function ( + runtimeObject +) { + var instance = new THREE.ShapeBufferGeometry( + runtimeObject.shapes.map( + function(shape) { + return shape.instance; + } + ), + runtimeObject.curveSegments + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferTetrahedron = function ( + runtimeObject +) { + var instance = new THREE.TetrahedronBufferGeometry( + runtimeObject.radius, + runtimeObject.detail + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferText = function ( + runtimeObject +) { + var instance = new THREE.TextBufferGeometry( + runtimeObject.text, + { + font : runtimeObject.font.instance, + size : runtimeObject.size, + curveSegments : runtimeObject.curveSegments, + steps : runtimeObject.steps, + amount : runtimeObject.amount, + bevelEnabled : runtimeObject.bevelEnabled, + bevelThickness : runtimeObject.bevelThickness, + bevelSize : runtimeObject.bevelSize, + bevelSegments : runtimeObject.bevelSegments + } + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferTorus = function ( + runtimeObject +) { + var instance = new THREE.TorusBufferGeometry( + runtimeObject.radius, + runtimeObject.tube, + runtimeObject.radialSegments, + runtimeObject.tubularSegments, + runtimeObject.arc + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferTorusKnot = function ( + runtimeObject +) { + var instance = new THREE.TorusKnotBufferGeometry( + runtimeObject.radius, + runtimeObject.tube, + runtimeObject.radialSegments, + runtimeObject.tubularSegments, + runtimeObject.p, + runtimeObject.q + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.GeometryBufferTube = function ( + runtimeObject +) { + var instance = new THREE.TubeBufferGeometry( + runtimeObject.path.instance, + runtimeObject.tubularSegments, + runtimeObject.radius, + runtimeObject.radialSegments, + runtimeObject.closed + ); + + instance.computeVertexNormals(); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.Helper = function ( + runtimeObject +) { + + var object = runtimeObject.parent; + + var instance = null; + + if (object instanceof R3.D3.Mesh) { + var wireframe = new THREE.WireframeGeometry(this.object.instance.geometry); + instance = new THREE.LineSegments( wireframe ); + instance.material.depthTest = false; + instance.material.opacity = 0.25; + instance.material.transparent = true; + } + + if (object instanceof R3.D3.Light.Directional) { + instance = new THREE.DirectionalLightHelper(this.object.instance); + } + + if (object instanceof R3.D3.Light.Point) { + instance = new THREE.PointLightHelper(this.object.instance); + } + + if (object instanceof R3.D3.Light.Spot) { + instance = new THREE.SpotLightHelper(this.object.instance); + } + + if (object instanceof R3.D3.Skeleton) { + instance = new THREE.SkeletonHelper(this.object.instance); + } + + return instance; +}; + + +R3.Runtime.Graphics.Three.prototype.LightAmbient = function ( + runtimeObject +) { + return new THREE.AmbientLight( + runtimeObject.color.toHex(), + runtimeObject.intensity + ); +}; + +R3.Runtime.Graphics.Three.prototype.LightDirectional = function ( + runtimeObject +) { + var instance = new THREE.DirectionalLight( + runtimeObject.color.toHex(), + runtimeObject.intensity + ); + + instance.castShadow = runtimeObject.castShadow; + + instance.position = runtimeObject.position.instance; + + /** + * Shadows work different - their instances are created internally by three.js and we need to + * assign them to our shadow runtime at creation of the light instance, and update them accordingly + * + * See comment at R3.D3.Shadow + */ + if (runtimeObject.shadow === null) { + /** + * This object was created at runtime - so initialize it properly + */ + runtimeObject.shadow = new R3.D3.Shadow.Directional(); + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateFromInstanceAll(); + } else { + /** + * This object came from the API - so update the instance with saved settings + */ + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateInstanceAll(); + } + + /** + * Assign our target + */ + instance.target = runtimeObject.target.instance; + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.LightHemisphere = function ( + runtimeObject +) { + var instance = new THREE.HemisphereLight( + runtimeObject.color.toHex(), + runtimeObject.groundColor.toHex(), + runtimeObject.intensity + ); + + instance.position = runtimeObject.position.instance; + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.LightPoint = function ( + runtimeObject +) { + + var instance = new THREE.PointLight( + runtimeObject.color.toHex(), + runtimeObject.intensity, + runtimeObject.distance, + runtimeObject.decay + ); + + instance.castShadow = runtimeObject.castShadow; + instance.position = runtimeObject.position.instance; + instance.power = runtimeObject.power; + + /** + * Shadows work different - their instances are created internally by three.js and we need to + * assign them to our shadow runtime at creation of the light instance, and update them accordingly + * + * See comment at R3.D3.Shadow + */ + if (runtimeObject.shadow === null) { + /** + * This object was created at runtime - so initialize it properly + */ + runtimeObject.shadow = new R3.D3.Shadow.Directional(); + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateFromInstanceAll(); + } else { + /** + * This object came from the API - so update the instance with saved settings + */ + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateInstanceAll(); + } + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.LightRectArea = function ( + runtimeObject +) { + var instance = new THREE.RectAreaLight( + runtimeObject.color.toHex(), + runtimeObject.intensity, + runtimeObject.width, + runtimeObject.height + ); + + instance.position = runtimeObject.position.instance; + + instance.lookAt(runtimeObject.lookAt.instance); + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.LightSpot = function ( + runtimeObject +) { + var instance = new THREE.SpotLight( + runtimeObject.color.toHex(), + runtimeObject.intensity, + runtimeObject.distance, + runtimeObject.angle, + runtimeObject.penumbra, + runtimeObject.decay + ); + + instance.castShadow = runtimeObject.castShadow; + instance.position = runtimeObject.position.instance; + + /** + * Shadows work different - their instances are created internally by three.js and we need to + * assign them to our shadow runtime at creation of the light instance, and update them accordingly + * + * See comment at R3.D3.Shadow + */ + if (runtimeObject.shadow === null) { + /** + * This object was created at runtime - so initialize it properly + */ + runtimeObject.shadow = new R3.D3.Shadow.Directional(); + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateFromInstanceAll(); + } else { + /** + * This object came from the API - so update the instance with saved settings + */ + runtimeObject.shadow.instance = instance.shadow; + runtimeObject.shadow.updateInstanceAll(); + } + + instance.target = this.target.instance; + + return instance; +}; + +R3.Runtime.Graphics.Three.prototype.getMaterialParams = function( + runtimeObject +) { + return { + alphaTest : runtimeObject.alphaTest, + blendDst : runtimeObject.blendDst, + blendDstAlpha : runtimeObject.blendDstAlpha, + blendEquation : runtimeObject.blendEquation, + blendEquationAlpha : runtimeObject.blendEquationAlpha, + blending : runtimeObject.blending, + blendSrc : runtimeObject.blendSrc, + blendSrcAlpha : runtimeObject.blendSrcAlpha, + clipIntersection : runtimeObject.clipIntersection, + clippingPlanes : runtimeObject.clippingPlanes, + clipShadows : runtimeObject.clipShadows, + colorWrite : runtimeObject.colorWrite, + defines : runtimeObject.defines, + depthFunc : runtimeObject.depthFunc, + depthTest : runtimeObject.depthTest, + depthWrite : runtimeObject.depthWrite, + dithering : runtimeObject.dithering, + flatShading : runtimeObject.flatShading, + fog : runtimeObject.fog, + lights : runtimeObject.lights, + opacity : runtimeObject.opacity, + overdraw : runtimeObject.overdraw, + polygonOffset : runtimeObject.polygonOffset, + polygonOffsetFactor : runtimeObject.polygonOffsetFactor, + polygonOffsetUnits : runtimeObject.polygonOffsetUnits, + precision : runtimeObject.precision, + premultipliedAlpha : runtimeObject.premultipliedAlpha, + side : runtimeObject.side, + stencilWrite : runtimeObject.stencilWrite, + stencilFunc : runtimeObject.stencilFunc, + stencilRef : runtimeObject.stencilRef, + stencilMask : runtimeObject.stencilMask, + stencilFail : runtimeObject.stencilFail, + stencilZFail : runtimeObject.stencilZFail, + stencilZPass : runtimeObject.stencilZPass, + transparent : runtimeObject.transparent, + vertexColors : runtimeObject.vertexColors, + visible : runtimeObject.visible + } +}; + +R3.Runtime.Graphics.Three.prototype.MaterialBasic = function ( + runtimeObject +) { + + var params = this.getMaterialParams(runtimeObject); + + params.alphaMap = runtimeObject.alphaMap ? runtimeObject.alphaMap.instance : null; + params.aoMap = runtimeObject.aoMap ? runtimeObject.aoMap.instance : null; + params.aoMapIntensity = runtimeObject.aoMapIntensity; + params.color = runtimeObject.color.instance; + params.envMap = runtimeObject.envMap ? runtimeObject.envMap.instance : null; + params.lightMap = runtimeObject.lightMap ? runtimeObject.lightMap.instance : null; + params.lightMapIntensity = runtimeObject.lightMapIntensity; + params.map = runtimeObject.diffuseMap ? runtimeObject.diffuseMap.instance : null; + params.morphTargets = runtimeObject.morphTargets; + params.reflectivity = runtimeObject.reflectivity; + params.refractionRatio = runtimeObject.refractionRatio; + params.skinning = runtimeObject.skinning; + params.specularMap = runtimeObject.specularMap ? runtimeObject.specularMap.instance : null; + params.wireframe = runtimeObject.wireframe; + params.wireframeLinecap = runtimeObject.wireframeLinecap; + params.wireframeLinejoin = runtimeObject.wireframeLinejoin; + params.wireframeLinewidth = runtimeObject.wireframeLinewidth; + + return new THREE.MeshBasicMaterial(params); + +}; + +R3.Runtime.Graphics.Three.prototype.MaterialPhong = function ( + runtimeObject +) { + var params = this.getMaterialParams(runtimeObject); + + params.alphaMap = runtimeObject.alphaMap ? this.alphaMap.instance : null; + params.aoMap = runtimeObject.aoMap ? this.aoMap.instance : null; + params.aoMapIntensity = runtimeObject.aoMapIntensity; + params.bumpMap = runtimeObject.bumpMap ? this.bumpMap.instance : null; + params.bumpScale = runtimeObject.bumpScale; + params.color = runtimeObject.color.instance; + params.combine = runtimeObject.combine; + params.displacementMap = runtimeObject.displacementMap ? this.displacementMap.instance : null; + params.displacementScale = runtimeObject.displacementScale; + params.displacementBias = runtimeObject.displacementBias; + params.emissive = runtimeObject.emissive.instance; + params.emissiveMap = runtimeObject.emissiveMap ? this.emissiveMap.instance : null; + params.emissiveIntensity = runtimeObject.emissiveIntensity; + params.envMap = runtimeObject.envMap ? this.envMap.instance : null; + params.lightMap = runtimeObject.lightMap ? this.lightMap.instance : null; + params.lightMapIntensity = runtimeObject.lightMapIntensity; + params.map = runtimeObject.diffuseMap ? this.diffuseMap.instance : null; + params.morphNormals = runtimeObject.morphNormals; + params.morphTargets = runtimeObject.morphTargets; + params.normalMap = runtimeObject.normalMap ? this.normalMap.instance : null; + params.normalScale = runtimeObject.normalScale; + params.reflectivity = runtimeObject.reflectivity; + params.refractionRatio = runtimeObject.refractionRatio; + params.shininess = runtimeObject.shininess; + params.skinning = runtimeObject.skinning; + params.specular = runtimeObject.specular.instance; + params.specularMap = runtimeObject.specularMap ? this.specularMap.instance : null; + params.wireframe = runtimeObject.wireframe; + params.wireframeLinecap = runtimeObject.wireframeLinecap; + params.wireframeLinejoin = runtimeObject.wireframeLinejoin; + params.wireframeLinewidth = runtimeObject.wireframeLinewidth; + + return new THREE.MeshPhongMaterial(params); +}; + +R3.Runtime.Graphics.Three.prototype.MaterialPoints = function ( + runtimeObject +) { + + var params = this.getMaterialParams(runtimeObject); + + params.color = runtimeObject.color.instance; + params.map = runtimeObject.diffuseMap ? this.diffuseMap.instance : null; + params.morphTargets = runtimeObject.morphTargets; + params.size = runtimeObject.size; + params.sizeAttenuation = runtimeObject.sizeAttenuation; + + return new THREE.PointsMaterial(params); + +}; + +R3.Runtime.Graphics.Three.prototype.MaterialShader = function ( + runtimeObject +) { + var params = this.getMaterialParams(runtimeObject); + + params.clipping = runtimeObject.clipping; + params.defaultAttributeValues = runtimeObject.defaultAttributeValues; + params.defines = runtimeObject.defines; + params.extensions = runtimeObject.extensions; + params.fragmentShader = runtimeObject.fragmentShader.instance; + params.index0AttributeName = runtimeObject.index0AttributeName; + params.linewidth = runtimeObject.linewidth; + params.morphTargets = runtimeObject.morphTargets; + params.morphNormals = runtimeObject.morphNormals; + params.program = runtimeObject.program; + params.skinning = runtimeObject.skinning; + params.uniforms = runtimeObject.uniforms; + params.vertexShader = runtimeObject.vertexShader.instance; + params.wireframe = runtimeObject.wireframe; + params.wireframeLinewidth = runtimeObject.wireframeLinewidth; + + return new THREE.ShaderMaterial(params); +}; + +R3.Runtime.Graphics.Three.prototype.MaterialShaderRaw = function ( + runtimeObject +) { + var params = this.getMaterialParams(runtimeObject); + + params.clipping = runtimeObject.clipping; + params.defaultAttributeValues = runtimeObject.defaultAttributeValues; + params.defines = runtimeObject.defines; + params.extensions = runtimeObject.extensions; + params.fragmentShader = runtimeObject.fragmentShader.instance; + params.index0AttributeName = runtimeObject.index0AttributeName; + params.linewidth = runtimeObject.linewidth; + params.morphTargets = runtimeObject.morphTargets; + params.morphNormals = runtimeObject.morphNormals; + params.program = runtimeObject.program; + params.skinning = runtimeObject.skinning; + params.uniforms = runtimeObject.uniforms; + params.vertexShader = runtimeObject.vertexShader.instance; + params.wireframe = runtimeObject.wireframe; + params.wireframeLinewidth = runtimeObject.wireframeLinewidth; + + return new THREE.RawShaderMaterial(params); +}; + +R3.Runtime.Graphics.Three.prototype.MaterialStandard = function ( + runtimeObject +) { + var params = this.getMaterialParams(runtimeObject); + + params.alphaMap = runtimeObject.alphaMap ? this.alphaMap.instance : null; + params.aoMap = runtimeObject.aoMap ? this.aoMap.instance : null; + params.aoMapIntensity = runtimeObject.aoMapIntensity; + params.bumpMap = runtimeObject.bumpMap ? this.bumpMap.instance : null; + params.bumpScale = runtimeObject.bumpScale; + params.color = runtimeObject.color.instance; + params.displacementMap = runtimeObject.displacementMap ? this.displacementMap.instance : null; + params.displacementScale = runtimeObject.displacementScale; + params.displacementBias = runtimeObject.displacementBias; + params.emissive = runtimeObject.emissive.instance; + params.emissiveMap = runtimeObject.emissiveMap ? this.emissiveMap.instance : null; + params.emissiveIntensity = runtimeObject.emissiveIntensity; + params.envMap = runtimeObject.envMap ? this.envMap.instance : null; + params.envMapIntensity = runtimeObject.envMapIntensity; + params.lightMap = runtimeObject.lightMap ? this.lightMap.instance : null; + params.lightMapIntensity = runtimeObject.lightMapIntensity; + params.map = runtimeObject.diffuseMap ? this.diffuseMap.instance : null; + params.metalness = runtimeObject.metalness; + params.metalnessMap = runtimeObject.metalnessMap ? this.metalnessMap.instance : null; + params.morphNormals = runtimeObject.morphNormals; + params.morphTargets = runtimeObject.morphTargets; + params.normalMap = runtimeObject.normalMap ? this.normalMap.instance : null; + params.normalScale = runtimeObject.normalScale; + params.refractionRatio = runtimeObject.refractionRatio; + params.roughness = runtimeObject.roughness; + params.roughnessMap = runtimeObject.roughnessMap ? this.roughnessMap.instance : null; + params.skinning = runtimeObject.skinning; + params.wireframe = runtimeObject.wireframe; + params.wireframeLinecap = runtimeObject.wireframeLinecap; + params.wireframeLinejoin = runtimeObject.wireframeLinejoin; + params.wireframeLinewidth = runtimeObject.wireframeLinewidth; + + return new THREE.MeshStandardMaterial(params); +}; + +R3.Runtime.Graphics.Three.prototype.Mesh = function ( + runtimeObject +) { + + var geometry = null; + var materials = null; + + if (!R3.Utils.Unloaded(runtimeObject.geometry)) { + geometry = runtimeObject.geometry.instance; + } + + if (!R3.Utils.Unloaded(runtimeObject.material)) { + materials = R3.Utils.GetArrayInstances(runtimeObject.materials); + } + + var instance = new THREE.Mesh( + geometry, + materials + ); + + instance.position = runtimeObject.position.instance; + instance.rotation = runtimeObject.rotation.instance; + instance.scale = runtimeObject.scale.instance; + instance.name = runtimeObject.name; + instance.renderOrder = runtimeObject.renderOrder; + instance.visible = runtimeObject.visible; + instance.castShadow = runtimeObject.castShadow; + instance.receiveShadow = runtimeObject.receiveShadow; + instance.drawMode = runtimeObject.drawMode; + + return instance; + +}; + +R3.Runtime.Graphics.Three.prototype.MeshSkeleton = function ( + runtimeObject +) { + throw new Error('todo: implement R3.Runtime.Graphics.Three.prototype.MeshSkeleton'); +}; + /** * R3.Runtime.Graphics.Three.prototype.updateInstance * @param runtimeObject * @param property + * @param instance - if provided, use this as the instance object instead of using the runtimeObject instance */ -R3.Runtime.Graphics.Three.prototype.updateInstance = function (runtimeObject, property) { +R3.Runtime.Graphics.Three.prototype.updateInstance = function (runtimeObject, property, instance) { - var instance = runtimeObject.instance; + if (R3.Utils.UndefinedOrNull(instance)) { + instance = runtimeObject.instance; + } if (R3.Utils.UndefinedOrNull(instance)) { throw new Error('no instance available for update'); } - if (instance instanceof THREE.FogExp2) { + if (runtimeObject instanceof R3.D3.Fog.Exp) { + if (property === 'density') { instance[property] = runtimeObject[property]; return; } + } - if (instance instanceof THREE.Fog) { + if (runtimeObject instanceof R3.D3.Fog.Normal) { + if ( property === 'near' || property === 'far' @@ -652,6 +1675,333 @@ R3.Runtime.Graphics.Three.prototype.updateInstance = function (runtimeObject, pr instance[property] = runtimeObject[property]; return; } + } + if (runtimeObject instanceof R3.D3.Fog) { + + if ( + property === 'color' + ) { + runtimeObject.color.instance.setRGB( + runtimeObject.color.r, + runtimeObject.color.g, + runtimeObject.color.b + ); + instance.color = runtimeObject.color.instance; + return; + } + + } + + + if (runtimeObject instanceof R3.D3.Pass.FXAA) { + + if ( + property === 'size' + ) { + + instance.uniforms['resolution'].value.set( + 1 / runtimeObject.width, + 1 / runtimeObject.height + ); + + return; + } + } + + if (runtimeObject instanceof R3.D3.Pass.Bloom) { + + if ( + property === 'size' + ) { + + instance.setSize( + runtimeObject.size.x, + runtimeObject.size.y + ); + + return; + } + + if (property === 'strength') { + instance.strength = runtimeObject.strength; + return; + } + + if (property === 'radius') { + instance.radius = runtimeObject.radius; + return; + } + + if (property === 'threshold') { + instance.threshold = runtimeObject.threshold; + return; + } + } + + if (runtimeObject instanceof R3.D3.Pass.Render.SSAO) { + + if (property === 'size') { + instance.width = runtimeObject.size.x; + instance.height = runtimeObject.size.y; + return; + } + + if (property === 'radius') { + instance.radius = runtimeObject.radius; + return; + } + + if (property === 'onlyAO') { + instance.onlyAO = runtimeObject.onlyAO; + return; + } + + if (property === 'aoClamp') { + instance.aoClamp = runtimeObject.aoClamp; + return; + } + + if (property === 'lumInfluence') { + instance.lumInfluence = runtimeObject.lumInfluence; + return; + } + + } + + if (runtimeObject instanceof R3.D3.Composer) { + + if (property === 'size') { + + instance.setSize( + runtimeObject.width, + runtimeObject.height + ); + + return; + } + + } + + if (runtimeObject instanceof R3.D3.Effect) { + + if (property === 'size') { + + instance.setSize( + runtimeObject.size.x, + runtimeObject.size.y + ); + + return; + } + + } + + + if (runtimeObject instanceof R3.D3.Effect.Stereo) { + + if (property === 'eyeSeperation') { + + instance.setEyeSeparation(runtimeObject.eyeSeperation); + + return; + } + + } + + if (runtimeObject instanceof R3.D3.Geometry.Buffer) { + + function disposeArray() { + this.array = null; + } + + if (property === 'positions') { + + var vertices = null; + + if (runtimeObject.indexed) { + + vertices = runtimeObject.vertices.reduce( + function(result, vertex) { + + result.push(vertex.position.x); + result.push(vertex.position.y); + result.push(vertex.position.z); + + return result; + }, + [] + ); + + var indices = runtimeObject.faces.reduce( + function (result, face) { + + result.push(face.vertexIndices[0]); + result.push(face.vertexIndices[1]); + result.push(face.vertexIndices[2]); + + return result; + }, + [] + ); + + instance.setIndex(indices); + + } else { + + /** + * Setup mesh vertices positions + * @type {Float32Array} + */ + vertices = runtimeObject.faces.reduce( + function (result, face) { + + result.push(runtimeObject.vertices[face.vertexIndices[0]].position.x); + result.push(runtimeObject.vertices[face.vertexIndices[0]].position.y); + result.push(runtimeObject.vertices[face.vertexIndices[0]].position.z); + result.push(runtimeObject.vertices[face.vertexIndices[1]].position.x); + result.push(runtimeObject.vertices[face.vertexIndices[1]].position.y); + result.push(runtimeObject.vertices[face.vertexIndices[1]].position.z); + result.push(runtimeObject.vertices[face.vertexIndices[2]].position.x); + result.push(runtimeObject.vertices[face.vertexIndices[2]].position.y); + result.push(runtimeObject.vertices[face.vertexIndices[2]].position.z); + + return result; + + }.bind(this), + [] + ); + } + + instance.addAttribute( 'position', new THREE.Float32BufferAttribute(vertices, 3)).onUpload(disposeArray); + + } + + if (property === 'vertexColors') { + + var colors = null; + + if (runtimeObject.indexed) { + colors = runtimeObject.vertices.reduce( + function(result, vertex){ + + result.push( + vertex.color.r, + vertex.color.g, + vertex.color.b + ); + + return result; + + }, + [] + ); + } else { + colors = runtimeObject.faces.reduce( + function (result, face) { + + result.push(runtimeObject.vertices[face.vertexIndices[0]].color.r); + result.push(runtimeObject.vertices[face.vertexIndices[0]].color.g); + result.push(runtimeObject.vertices[face.vertexIndices[0]].color.b); + result.push(runtimeObject.vertices[face.vertexIndices[1]].color.r); + result.push(runtimeObject.vertices[face.vertexIndices[1]].color.g); + result.push(runtimeObject.vertices[face.vertexIndices[1]].color.b); + result.push(runtimeObject.vertices[face.vertexIndices[2]].color.r); + result.push(runtimeObject.vertices[face.vertexIndices[2]].color.g); + result.push(runtimeObject.vertices[face.vertexIndices[2]].color.b); + + return result; + + }.bind(this), + [] + ); + } + + if (colors.length > 0) { + instance.addAttribute( 'color', new THREE.Float32BufferAttribute(colors, 3)).onUpload(disposeArray); + } + } + + if (property === 'uvs') { + + var uvs = null; + + if (runtimeObject.indexed) { + uvs = runtimeObject.vertices.reduce( + function(result, vertex) { + + result.push(vertex.uvs[0].x); + result.push(vertex.uvs[0].y); + + return result; + }, + [] + ); + } else { + uvs = runtimeObject.faces.reduce( + function(result, face) { + + result.push(runtimeObject.vertices[face.vertexIndices[0]].uvs[0].x); + result.push(runtimeObject.vertices[face.vertexIndices[0]].uvs[0].y); + result.push(runtimeObject.vertices[face.vertexIndices[1]].uvs[0].x); + result.push(runtimeObject.vertices[face.vertexIndices[1]].uvs[0].y); + result.push(runtimeObject.vertices[face.vertexIndices[2]].uvs[0].x); + result.push(runtimeObject.vertices[face.vertexIndices[2]].uvs[0].y); + + return result; + }, + [] + ); + } + + instance.addAttribute( 'uv', new THREE.Float32BufferAttribute(uvs, 2)).onUpload(disposeArray); + + } + + if (property === 'normals') { + + var normals = null; + + if (runtimeObject.indexed) { + normals = runtimeObject.vertices.reduce( + function(result, vertex) { + + result.push(vertex.normal.x); + result.push(vertex.normal.y); + result.push(vertex.normal.z); + + return result; + + }, + [] + ); + } else { + normals = runtimeObject.vertices.reduce( + function(result, face) { + + result.push(runtimeObject.vertices[face.vertexIndices[0]].normal.x); + result.push(runtimeObject.vertices[face.vertexIndices[0]].normal.y); + result.push(runtimeObject.vertices[face.vertexIndices[0]].normal.z); + result.push(runtimeObject.vertices[face.vertexIndices[1]].normal.x); + result.push(runtimeObject.vertices[face.vertexIndices[1]].normal.y); + result.push(runtimeObject.vertices[face.vertexIndices[1]].normal.z); + result.push(runtimeObject.vertices[face.vertexIndices[2]].normal.x); + result.push(runtimeObject.vertices[face.vertexIndices[2]].normal.y); + result.push(runtimeObject.vertices[face.vertexIndices[2]].normal.z); + + return result; + + }, + [] + ); + } + + instance.addAttribute( 'normal', new THREE.Float32BufferAttribute(normals, 3)).onUpload(disposeArray); + + } + + } + + }; \ No newline at end of file diff --git a/src/r3-runtime-graphics.js b/src/r3-runtime-graphics.js deleted file mode 100644 index c482d92..0000000 --- a/src/r3-runtime-graphics.js +++ /dev/null @@ -1,209 +0,0 @@ -/** - * R3.Runtime.Graphics - * @constructor - */ -R3.Runtime.Graphics = function() { - - R3.Runtime.call(this); - -}; - -R3.Runtime.Graphics.prototype = Object.create(R3.Runtime.prototype); -R3.Runtime.Graphics.prototype.constructor = R3.Runtime.Graphics; - -R3.Runtime.Graphics.prototype.Vector2 = function(x,y) { - console.warn('override Vector2 in child class'); -}; - -R3.Runtime.Graphics.prototype.Vector3 = function(x,y,z) { - console.warn('override Vector3 in child class'); -}; - -R3.Runtime.Graphics.prototype.Vector4 = function(x,y,z,w) { - console.warn('override Vector4 in child class'); -}; - -R3.Runtime.Graphics.prototype.Box3 = function(x,y,z) { - console.warn('override Box3 in child class'); -}; - -R3.Runtime.Graphics.prototype.Color = function(r,g,b,a) { - console.warn('override Color in child class'); -}; - -R3.Runtime.Graphics.prototype.Matrix4 = function(rows) { - console.warn('override Matrix4 in child class'); -}; - -R3.Runtime.Graphics.prototype.Quaternion = function(x, y, z, w) { - console.warn('override Quaternion in child class'); -}; - -R3.Runtime.Graphics.prototype.Clock = function() { - console.warn('override Clock in child class'); -}; - -R3.Runtime.Graphics.prototype.EditorControls = function(canvas, camera) { - console.warn('override EditorControls in child class'); -}; - -R3.Runtime.Graphics.prototype.OrbitControls = function(canvas, camera) { - console.warn('override OrbitControls in child class'); -}; - -R3.Runtime.Graphics.prototype.FirstPersonControls = function(canvas, camera) { - console.warn('override FirstPersonControls in child class'); -}; - -R3.Runtime.Graphics.prototype.Curve = function(arcLenghDivisions) { - console.warn('override Curve in child class'); -}; - -R3.Runtime.Graphics.prototype.CurvePath = function(curves, autoClose) { - console.warn('override CurvePath in child class'); -}; - -R3.Runtime.Graphics.prototype.Path = function(points) { - console.warn('override Path in child class'); -}; - -R3.Runtime.Graphics.prototype.Shape = function(points) { - console.warn('override Shape in child class'); -}; - -R3.Runtime.Graphics.prototype.Audio = function( - component, - path, - loop, - volume, - cameraIndex -) { - console.warn('override Audio in child class'); -}; - -R3.Runtime.Graphics.prototype.Bone = function() { - console.warn('override Bone in child class'); -}; - -R3.Runtime.Graphics.prototype.CubeCamera = function(near, far, cubeResolution) { - console.warn('override CubeCamera in child class'); -}; - -R3.Runtime.Graphics.prototype.OrthographicCamera = function( - left, - right, - top, - bottom, - near, - far -) { - console.warn('override OrthographicCamera in child class'); -}; - -R3.Runtime.Graphics.prototype.PerspectiveCamera = function( - fov, - aspect, - near, - far -) { - console.warn('override PerspectiveCamera in child class'); -}; - -R3.Runtime.Graphics.prototype.StereoCamera = function( - fov, - aspect, - near, - far, - stereoMode -) { - console.warn('override StereoCamera in child class'); -}; - -R3.Runtime.Graphics.prototype.RenderTarget = function( - width, - height, - wrapS, - wrapT, - magFilter, - minFilter, - format, - type, - anisotropy, - encoding, - depthBuffer, - stencilBuffer -) { - console.warn('override RenderTarget in child class'); -}; - -R3.Runtime.Graphics.prototype.Composer = function( - renderer, - renderTarget, - passes, - size -) { - console.warn('override Composer in child class'); -}; - -R3.Runtime.Graphics.prototype.Renderer3D = function( - canvas, - alpha, - premultipliedAlpha, - antialias, - stencil, - preserveDrawingBuffer, - depth, - logarithmicDepthBuffer -) { - console.warn('override Renderer3D in child class'); -}; - -R3.Runtime.Graphics.prototype.AnaglyphEffect = function( - renderer -) { - console.warn('override AnaglyphEffect in child class'); -}; - -R3.Runtime.Graphics.prototype.ParallaxEffect = function( - renderer -) { - console.warn('override ParallaxEffect in child class'); -}; - -R3.Runtime.Graphics.prototype.StereoEffect = function( - renderer -) { - console.warn('override StereoEffect in child class'); -}; - -R3.Runtime.Graphics.prototype.Face = function( - v0index, - v1index, - v2index, - normal, - color, - materialIndex, - vertexColors -) { - console.warn('override Face in child class'); -}; - -R3.Runtime.Graphics.prototype.FogExp = function( - color, - density -) { - console.warn('override R3.Runtime.Graphics.prototype.FogExp in child class'); -}; - -R3.Runtime.Graphics.prototype.Fog = function( - color, - near, - far -) { - console.warn('override R3.Runtime.Graphics.prototype.Fog in child class'); -}; - -R3.Runtime.Graphics.prototype.updateInstance = function (runtimeObject, property) { - console.warn('override R3.Runtime.Graphics.prototype.updateInstance in child class'); -}; - diff --git a/src/r3-runtime-gui.js b/src/r3-runtime-gui-0.js similarity index 100% rename from src/r3-runtime-gui.js rename to src/r3-runtime-gui-0.js diff --git a/src/r3-runtime-physics.js b/src/r3-runtime-physics-0.js similarity index 80% rename from src/r3-runtime-physics.js rename to src/r3-runtime-physics-0.js index f6aea65..43d1440 100644 --- a/src/r3-runtime-physics.js +++ b/src/r3-runtime-physics-0.js @@ -31,6 +31,12 @@ R3.Runtime.Physics.prototype.Box3 = function(rows) { console.warn('override Box3 in child class'); }; +R3.Runtime.Physics.prototype.Face = function( + runtimeObject +) { + console.warn('override R3.Runtime.Physics.prototype.Face in child class'); +}; + R3.Runtime.Physics.prototype.Quaternion = function(x,y,z,w) { console.log('override Quaternion in child class') }; @@ -44,6 +50,9 @@ R3.Runtime.Physics.prototype.ContactMaterial = function( restitution, contactEquationStiffness, materials, + contactEquationRelaxation, + frictionEquationStiffness, + frictionEquationRelaxation ) { console.log('override R3.Runtime.Physics.prototype.ContactMaterial in child class'); }; @@ -56,6 +65,13 @@ R3.Runtime.Physics.prototype.Material = function( console.log('override R3.Runtime.Physics.prototype.Material in child class') }; +R3.Runtime.Physics.prototype.Sphere = function( + center, + radius +) { + console.warn('override R3.Runtime.Physics.prototype.Sphere in child class'); +}; + R3.Runtime.Physics.prototype.updateInstance = function(runtimeObject, property) { console.log('override R3.Runtime.Physics.prototype.updateInstance in child class'); }; \ No newline at end of file diff --git a/src/r3-runtime-physics-cannon.js b/src/r3-runtime-physics-cannon.js index c970b63..b6724fe 100644 --- a/src/r3-runtime-physics-cannon.js +++ b/src/r3-runtime-physics-cannon.js @@ -64,18 +64,24 @@ R3.Runtime.Physics.Cannon.prototype.ContactMaterial = function( restitution, contactEquationStiffness, materials, + contactEquationRelaxation, + frictionEquationStiffness, + frictionEquationRelaxation ) { var instance = new CANNON.ContactMaterial( null, null, { - friction: this.friction, - restitution: this.restitution, - contactEquationStiffness: this.contactEquationStiffness + friction: friction, + restitution: restitution, + contactEquationStiffness: contactEquationStiffness, + contactEquationRelaxation: contactEquationRelaxation, + frictionEquationStiffness: frictionEquationStiffness, + frictionEquationRelaxation: frictionEquationRelaxation, } ); - instance.materials = this.materials.map( + instance.materials = materials.map( function(material){ return material.instance; } @@ -84,6 +90,12 @@ R3.Runtime.Physics.Cannon.prototype.ContactMaterial = function( return instance; }; +R3.Runtime.Physics.Cannon.prototype.Face = function( + runtimeObject +) { + console.warn('todo: R3.Runtime.Physics.Cannon.prototype.Face'); +}; + R3.Runtime.Physics.Cannon.prototype.Material = function( name, friction, @@ -99,6 +111,13 @@ R3.Runtime.Physics.Cannon.prototype.Material = function( return instance; }; +R3.Runtime.Physics.Cannon.prototype.Sphere = function( + center, + radius +) { + console.warn('todo: implement R3.Runtime.Physics.Cannon.prototype.Sphere'); +}; + R3.Runtime.Physics.Cannon.prototype.updateInstance = function(runtimeObject, property) { var instance = runtimeObject.instance; diff --git a/src/r3-runtime-sockets.js b/src/r3-runtime-sockets-0.js similarity index 100% rename from src/r3-runtime-sockets.js rename to src/r3-runtime-sockets-0.js diff --git a/src/r3-runtime-statistics.js b/src/r3-runtime-statistics-0.js similarity index 100% rename from src/r3-runtime-statistics.js rename to src/r3-runtime-statistics-0.js diff --git a/src/r3-runtime.js b/src/r3-runtime.js deleted file mode 100644 index 8a1f3e1..0000000 --- a/src/r3-runtime.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * R3.Runtime - * - * All Runtimes should extend this - * - * @constructor - */ -R3.Runtime = function() { - -}; diff --git a/src/r3-server.js b/src/r3-server.js index 4d88379..023a04a 100644 --- a/src/r3-server.js +++ b/src/r3-server.js @@ -1,34 +1,17 @@ /** * R3.Server - * @param apiServer R3.API.Server + * @param apiComponent * @constructor */ R3.Server = function( - apiServer + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiServer)) { - apiServer = {}; - } - - R3.API.Server.call( - this, - apiServer.id, - apiServer.name, - apiServer.protocol, - apiServer.context, - apiServer.application, - apiServer.domain, - apiServer.ip, - apiServer.preferIp, - apiServer.port, - apiServer.protocols, - apiServer.parent - ); + __RUNTIME_COMPONENT__; this.connected = false; - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.Server.prototype = Object.create(R3.Component.prototype); @@ -38,7 +21,7 @@ R3.Server.prototype.createInstance = function() { this.instance = true; - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -48,59 +31,45 @@ R3.Server.prototype.updateInstance = function(property) { if (property === 'protocol') { console.log('todo: server protocol update'); + return; } if (property === 'context') { console.log('todo: server context update'); + return; } if (property === 'application') { console.log('todo: server application update'); + return; } if (property === 'domain') { console.log('todo: server domain update'); + return; } if (property === 'ip') { console.log('todo: server ip update'); + return; } if (property === 'preferIp') { console.log('todo: server preferIp update'); + return; } if (property === 'port') { console.log('todo: server port update'); + return; } if (property === 'protocols') { console.log('todo: server protocols update'); + return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.Server to a new R3.API.Server - * @returns {R3.API.Server} - */ -R3.Server.prototype.toApiObject = function() { - - return new R3.API.Server( - this.id, - this.name, - this.protocol, - this.context, - this.application, - this.domain, - this.ip, - this.preferIp, - this.port, - this.protocols, - R3.Utils.IdOrNull(this.parent) - ); - + __UPDATE_INSTANCE__; }; R3.Server.prototype.getURL = function() { @@ -111,4 +80,4 @@ R3.Server.prototype.getURL = function() { return this.protocol + '://' + this.context + '-' + this.application + '.' + this.domain + ':' + this.port } -}; \ No newline at end of file +}; diff --git a/src/r3-socket-0.js b/src/r3-socket-0.js index 453ae61..bc6e151 100644 --- a/src/r3-socket-0.js +++ b/src/r3-socket-0.js @@ -1,64 +1,35 @@ /** * Creates a Socket object - * @param socket R3.Socket - * @param apiSocket R3.API.Socket - * @property socketType + * @param inherited + * @property roomId + * @property peerId + * @property server * @constructor */ R3.Socket = function( - socket, - apiSocket + inherited ) { - this.socket = socket; - this.socket.isNotWebSocketThrow(); - - if (R3.Utils.UndefinedOrNull(apiSocket)) { - apiSocket = {}; + if (R3.Utils.UndefinedOrNull(inherited)) { + inherited = false; } - R3.API.Socket.call( - this, - apiSocket.id, - apiSocket.name, - apiSocket.socketType, - apiSocket.roomId, - apiSocket.peerId, - apiSocket.server, - apiSocket.parent - ); - - if (this.server instanceof R3.API.Server) { - this.server = new R3.Server(this.server); + if (!inherited) { + throw new Error('R3.Socket cannot be instantiated directly - use R3.Socket.Cast or R3.Socket.Receive'); } this.connected = false; - var linkedObjects = { - server : R3.Server - }; - - switch (this.socketType) { - case R3.API.Socket.SOCKET_TYPE_CAST : - linkedObjects.source = R3.Component; - break; - case R3.API.Socket.SOCKET_TYPE_RECEIVE: - linkedObjects.destination = R3.Component; - break; - default: - break; - } - - R3.Component.call( - this, - linkedObjects - ); + __UPGRADE_TO_RUNTIME__; }; R3.Socket.prototype = Object.create(R3.Component.prototype); R3.Socket.prototype.constructor = R3.Socket; +/** + * This class cannot be instantiated directly - it does have common functionality though for its children classes + */ R3.Socket.prototype.createInstance = function() { this.instance = new WebSocket(this.server.getURL()); @@ -73,7 +44,7 @@ R3.Socket.prototype.createInstance = function() { console.log('Message from server ', event.data); }); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** @@ -81,37 +52,20 @@ R3.Socket.prototype.createInstance = function() { */ R3.Socket.prototype.updateInstance = function(property) { - if (property === 'socketType') { - console.log('todo: implement socket socketType update'); - } - if (property === 'roomId') { console.log('todo: implement socket roomId update'); + return; } if (property === 'peerId') { console.log('todo: implement socket peerId update'); + return; } if (property === 'server') { console.log('todo: implement socket server update'); + return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.Socket to a new R3.API.Socket - * @returns {R3.API.Socket} - */ -R3.Socket.prototype.toApiObject = function() { - return new R3.API.Socket( - this.id, - this.name, - this.socketType, - this.roomId, - this.peerId, - R3.Utils.IdOrNull(this.server), - R3.Utils.IdOrNull(this.parent) - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-socket-cast.js b/src/r3-socket-cast.js index fec1cce..64aa37e 100644 --- a/src/r3-socket-cast.js +++ b/src/r3-socket-cast.js @@ -1,35 +1,20 @@ /** * R3.Socket.Cast - * @param socket R3.Socket - * @param apiSocketCast + * @param apiComponent + * @property castType + * @property source + * @property sourceProperties * @constructor */ R3.Socket.Cast = function( - socket, - apiSocketCast + apiComponent ) { - this.socket = socket; - this.socket.isNotWebSocketThrow(); - - if (R3.Utils.UndefinedOrNull(apiSocketCast)) { - apiSocketCast = { - socketType : R3.API.Socket.SOCKET_TYPE_CAST - }; - } - - R3.API.Socket.Cast.call( - this, - apiSocketCast, - apiSocketCast.castType, - apiSocketCast.source, - apiSocketCast.sourceProperties - ); + __RUNTIME_COMPONENT__; R3.Socket.call( this, - socket, - apiSocketCast + true ); }; @@ -47,9 +32,13 @@ R3.Socket.Cast.prototype.updateInstance = function(property) { if (property === 'castType') { console.log('todo: implement castType update'); + return; } if (property === 'source') { + console.log('todo: implement source update'); + return; + if (this.source !== null) { this.sourceProperties = R3.Utils.ObjectPropertiesAsBoolean(this.source); } else { @@ -66,25 +55,8 @@ R3.Socket.Cast.prototype.updateInstance = function(property) { if (property === 'sourceProperties') { console.log('todo: implement sourceProperties update'); + return; } R3.Socket.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.Socket.Cast to a new R3.API.Socket.Cast - * @returns {R3.API.Socket.Cast} - */ -R3.Socket.Cast.prototype.toApiObject = function() { - - var apiSocket = new R3.Socket.prototype.toApiObject.call(this); - - var apiSocketCast = new R3.API.Socket.Cast( - apiSocket, - this.castType, - R3.Utils.IdOrNull(this.source), - this.sourceProperties - ); - - return apiSocketCast; -}; diff --git a/src/r3-socket-receive.js b/src/r3-socket-receive.js index 6e7a673..f2af35e 100644 --- a/src/r3-socket-receive.js +++ b/src/r3-socket-receive.js @@ -1,35 +1,20 @@ /** * R3.Socket.Receive - * @param socket R3.Socket - * @param apiSocketReceive R3.API.Socket.Receive + * @param apiComponent + * @property receiveType + * @property destination + * @property destinationProperties * @constructor */ R3.Socket.Receive = function( - socket, - apiSocketReceive + apiComponent ) { - this.socket = socket; - this.socket.isNotWebSocketThrow(); - - if (R3.Utils.UndefinedOrNull(apiSocketReceive)) { - apiSocketReceive = { - socketType : R3.API.Socket.SOCKET_TYPE_RECEIVE - }; - } - - R3.API.Socket.Receive.call( - this, - apiSocketReceive, - apiSocketReceive.receiveType, - apiSocketReceive.destination, - apiSocketReceive.destinationProperties - ); + __RUNTIME_COMPONENT__; R3.Socket.call( this, - socket, - apiSocketReceive + true ); }; @@ -48,10 +33,14 @@ R3.Socket.Receive.prototype.updateInstance = function(property) { if (property === 'receiveType') { console.log('todo: implement receiveType update'); + return; } if (property === 'destination') { + console.log('todo: implement destination update'); + return; + if (this.destination !== null) { this.destinationProperties = R3.Utils.ObjectPropertiesAsBoolean(this.destination); } else { @@ -68,26 +57,8 @@ R3.Socket.Receive.prototype.updateInstance = function(property) { if (property === 'destinationProperties') { console.log('todo: implement destinationProperties update'); + return; } R3.Socket.prototype.updateInstance.call(this, property); }; - -/** - * Converts a R3.Socket.Receive to a new R3.API.Socket.Receive - * @returns {R3.API.Socket.Receive} - */ -R3.Socket.Receive.prototype.toApiObject = function() { - - var apiSocket = new R3.Socket.prototype.toApiObject.call(this); - - var apiSocketReceive = new R3.API.Socket.Receive( - apiSocket, - this.receiveType, - R3.Utils.IdOrNull(this.destination), - this.destinationProperties - ); - - return apiSocketReceive; - -}; diff --git a/src/r3-sphere.js b/src/r3-sphere.js index 19e296f..3cf9dd1 100644 --- a/src/r3-sphere.js +++ b/src/r3-sphere.js @@ -1,44 +1,22 @@ /** * R3.Sphere - * @param implementation - * @param apiSphere - * @param parentObject + * @param apiComponent + * + * @property center + * @property radius + * * @constructor */ R3.Sphere = function( - implementation, - apiSphere, - parentObject + apiComponent ) { - this.implementation = implementation; - this.implementation.isNotThreeThrow(); + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(parentObject)) { - parentObject = null; - } - this.parentObject = parentObject; - - if (R3.Utils.UndefinedOrNull(apiSphere)) { - apiSphere = {}; - } - - R3.API.Sphere.call( - this, - apiSphere.center, - apiSphere.radius - ); - - this.center = new R3.Vector3( - this.implementation, - this.center, - this - ); - - this.createInstance(); + __UPGRADE_TO_RUNTIME__; }; -R3.Sphere.prototype = Object.create(R3.API.Sphere.prototype); +R3.Sphere.prototype = Object.create(R3.Component.prototype); R3.Sphere.prototype.constructor = R3.Sphere; /** @@ -47,10 +25,21 @@ R3.Sphere.prototype.constructor = R3.Sphere; */ R3.Sphere.prototype.createInstance = function() { - this.instance = new THREE.Sphere( - this.center.instance, - this.radius - ); + if (this.parent.runtime === R3.Runtime.PHYSICS) { + this.instance = this.physics.Sphere( + this.center, + this.radius + ); + } + + if (this.parent.runtime === R3.Runtime.GRAPHICS) { + this.instance = this.graphics.Sphere( + this.center, + this.radius + ); + } + + __CREATE_INSTANCE__; }; @@ -72,15 +61,6 @@ R3.Sphere.prototype.updateInstance = function(property) { return; } -}; + __UPDATE_INSTANCE__; -/** - * R3.Sphere to R3.API.Sphere - * @returns {R3.API.Sphere} - */ -R3.Sphere.prototype.toApiObject = function() { - return new R3.API.Sphere( - this.center.toApiObject(), - this.radius - ); }; diff --git a/src/r3-stats.js b/src/r3-stats.js index eed7636..694a7c8 100644 --- a/src/r3-stats.js +++ b/src/r3-stats.js @@ -1,34 +1,18 @@ /** - * Stats component for displaying some render statistics (framerate, memory consumption, etc) - * @param statisticsRuntime - * @param apiStats + * R3.Stats + * @param apiComponent + * + * @property domElement + * * @constructor */ R3.Stats = function( - statisticsRuntime, - apiStats + apiComponent ) { - this.stats = statisticsRuntime; - this.stats.isNotStatsThrow(); - if (R3.Utils.UndefinedOrNull(apiStats)) { - apiStats = {}; - } + __RUNTIME_COMPONENT__; - R3.API.Stats.call( - this, - apiStats.id, - apiStats.name, - apiStats.domElement, - apiStats.parent - ); - - R3.Component.call( - this, - { - 'domElement': R3.DomElement - } - ); + __UPGRADE_TO_RUNTIME__; }; R3.Stats.prototype = Object.create(R3.Component.prototype); @@ -45,47 +29,20 @@ R3.Stats.prototype.createInstance = function() { this.domElement.instance.parentElement.appendChild(this.instance.dom); - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; }; /** * Updates the instance with the current state */ -R3.Stats.prototype.updateInstance = function() { - this.instance = new this.stats(); -}; +R3.Stats.prototype.updateInstance = function(property) { + if (property === 'domElement') { + console.warn('todo: update domElement change for stats'); + return; + } -/** - * Converts a R3.Stats to a new R3.API.Stats - * @returns {R3.API.Stats} - */ -R3.Stats.prototype.toApiObject = function() { - - return new R3.API.Stats( - this.id, - this.name, - R3.Utils.IdOrNull(this.domElement), - R3.Utils.IdOrNull(this.parent) - ); - -}; - -/** - * Converts from an Object Stats to a R3.Stats - * @param statisticsRuntime R3.Runtime.Statistics - * @param objectStats Object - * @returns {R3.Stats} - * @constructor - */ -R3.Stats.FromObject = function(statisticsRuntime, objectStats) { - - var apiStats = R3.API.Stats.FromObject(objectStats); - - return new R3.Stats( - statisticsRuntime, - apiStats - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-system-0.js b/src/r3-system-0.js index 0fac28b..5ea585c 100644 --- a/src/r3-system-0.js +++ b/src/r3-system-0.js @@ -6,65 +6,24 @@ R3.System = function( apiSystem ) { - - if (R3.Utils.UndefinedOrNull(apiSystem)) { - apiSystem = {}; - } - - R3.API.System.call( - this, - apiSystem.id, - apiSystem.name, - apiSystem.systemType, - apiSystem.parent - ); - this.started = false; - - this.paused = false; - - var linkedObjects = {}; - - if (apiSystem.systemType === R3.System.SYSTEM_TYPE_INPUT) { - linkedObjects.mouseControls = [R3.Controls.Mouse]; - linkedObjects.keyboardControls = [R3.Controls.Keyboard]; - linkedObjects.touchControls = [R3.Controls.Touch]; - linkedObjects.editorControls = [R3.Controls.D3.Editor]; - } - - if (apiSystem.systemType === R3.System.SYSTEM_TYPE_AUDIO) { - linkedObjects.audioComponents = [R3.D3.Audio]; - } - - R3.Component.call( - this, - linkedObjects - ); - }; -R3.System.prototype = Object.create(R3.Component.prototype); -R3.System.prototype.constructor = R3.System; - -R3.System.SYSTEM_TYPE_NONE = 0x0; -R3.System.SYSTEM_TYPE_RENDER = 0x1; -R3.System.SYSTEM_TYPE_ANIMATION = 0x2; -R3.System.SYSTEM_TYPE_INPUT = 0x4; -R3.System.SYSTEM_TYPE_STORAGE = 0x8; -R3.System.SYSTEM_TYPE_GUI = 0x10; -R3.System.SYSTEM_TYPE_PHYSICS = 0x20; -R3.System.SYSTEM_TYPE_LINKING = 0x40; -R3.System.SYSTEM_TYPE_CUSTOM = 0x80; -R3.System.SYSTEM_TYPE_VISUALIZATION = 0x100; -R3.System.SYSTEM_TYPE_PARTICLE = 0x200; -R3.System.SYSTEM_TYPE_AUDIO = 0x400; -R3.System.SYSTEM_TYPE_SOCKET = 0x800; -R3.System.SYSTEM_TYPE_ALL = 0xFFFF; - -R3.System.prototype.createInstance = function() { - this.instance = true; - R3.Component.prototype.createInstance.call(this); -}; +R3.System.SYSTEM_TYPE_NONE = 0x0; +R3.System.SYSTEM_TYPE_RENDER = 0x1; +R3.System.SYSTEM_TYPE_ANIMATION = 0x2; +R3.System.SYSTEM_TYPE_INPUT = 0x4; +R3.System.SYSTEM_TYPE_STORAGE = 0x8; +R3.System.SYSTEM_TYPE_GUI = 0xf; +R3.System.SYSTEM_TYPE_PHYSICS = 0x10; +R3.System.SYSTEM_TYPE_LINKING = 0x12; +R3.System.SYSTEM_TYPE_CUSTOM = 0x14; +R3.System.SYSTEM_TYPE_VISUALIZATION = 0x18; +R3.System.SYSTEM_TYPE_PARTICLE = 0x1f; +R3.System.SYSTEM_TYPE_AUDIO = 0x20; +R3.System.SYSTEM_TYPE_SOCKET = 0x21; +R3.System.SYSTEM_TYPE_QUERY = 0x22; +R3.System.SYSTEM_TYPE_ALL = 0xff; /** * @callback @@ -72,7 +31,6 @@ R3.System.prototype.createInstance = function() { */ R3.System.prototype.start = function() { this.started = true; -// console.log('starting ' + this.name); }; /** @@ -81,21 +39,8 @@ R3.System.prototype.start = function() { */ R3.System.prototype.stop = function() { this.started = false; -// console.log('stopping ' + this.name); }; -/** - * Converts runtime vector to API Vector - * @returns {R3.API.System} - */ -R3.System.prototype.toApiObject = function() { - return new R3.API.System( - this.id, - this.name, - this.systemType, - R3.Utils.IdOrNull(this.parent) - ); -}; R3.System.prototype.restart = function() { console.log('restarting system : ' + this.name); diff --git a/src/r3-system-query.js b/src/r3-system-query.js new file mode 100644 index 0000000..8143ddd --- /dev/null +++ b/src/r3-system-query.js @@ -0,0 +1,81 @@ +/** + * R3.System.Query + * @constructor + */ +R3.System.Query = function() { + this.querySubscription = null; +}; + +R3.System.Query.prototype = Object.create(R3.System.prototype); +R3.System.Query.prototype.constructor = R3.System.Query; + +R3.System.Query.prototype.start = function() { + + this.querySubscription = R3.Event.Subscribe( + R3.Event.QUERY, + this.query + ); + + R3.System.prototype.start.call(this); + +}; + + +/** + * + * @param query R3.Query + */ +R3.System.Query.prototype.query = function(query) { + + R3.Event.Emit( + R3.Event.GET_USER, + null, + function(user) { + R3.Event.Emit( + R3.Event.GET_API_URL, + null, + function(data) { + + query.data.size = query.size; + + var queryText = JSON.stringify(query); + + queryText = queryText.replace('QUERY_START', query.start); + queryText = queryText.replace('QUERY_END', query.end); + + if (typeof XMLHttpRequest === 'undefined') { + console.log('Implement server side delete here'); + return; + } + + var xhr = new XMLHttpRequest(); + + xhr.open( + 'POST', + data.queryApiUrl + query.path + ); + + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.setRequestHeader("x-api-authorization", data.passwoid); + xhr.setRequestHeader('x-api-user-token', user.apiToken); + + xhr.onload = function (event) { + query.parse(JSON.parse(event.target.responseText)); + }; + + xhr.send(queryText); + } + ); + } + ); +}; + +R3.System.Query.prototype.stop = function() { + + this.querySubscription.remove(); + + R3.System.prototype.stop.call(this); + +}; + diff --git a/src/r3-user.js b/src/r3-user.js index ff8c03f..ca32109 100644 --- a/src/r3-user.js +++ b/src/r3-user.js @@ -1,40 +1,37 @@ /** * R3.User - * @param apiUser R3.API.User + * @param apiComponent + * + * @property googleId + * @property fullName + * @property givenName + * @property familyName + * @property imageUrl + * @property email + * @property uploadFolder + * @property idToken + * * @constructor */ R3.User = function( - apiUser + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiUser)) { - apiUser = {}; - } + __RUNTIME_COMPONENT__; - R3.API.User.call( - this, - apiUser.id, - apiUser.name, - apiUser.parent, - apiUser.googleId, - apiUser.fullName, - apiUser.givenName, - apiUser.familyName, - apiUser.imageUrl, - apiUser.email, - apiUser.uploadFolder, - apiUser.idToken - ); + __UPGRADE_TO_RUNTIME__; - R3.Component.call(this); }; R3.User.prototype = Object.create(R3.Component.prototype); R3.User.prototype.constructor = R3.User; R3.User.prototype.createInstance = function() { + this.instance = true; - R3.Component.prototype.createInstance.call(this); + + __CREATE_INSTANCE__; + }; /** @@ -44,62 +41,49 @@ R3.User.prototype.updateInstance = function(property) { if (property === 'name') { console.log('todo: user name update'); + return; } if (property === 'googleId') { console.log('todo: user googleId update'); + return; } if (property === 'fullName') { console.log('todo: user fullName update'); + return; } if (property === 'givenName') { console.log('todo: user givenName update'); + return; } if (property === 'familyName') { console.log('todo: user familyName update'); + return; } if (property === 'imageUrl') { console.log('todo: user imageUrl update'); + return; } if (property === 'email') { console.log('todo: user email update'); + return; } if (property === 'uploadFolder') { console.log('todo: user uploadFolder update'); + return; } if (property === 'idToken') { console.log('todo: user idToken update'); + return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.User to a new R3.API.User - * @returns {R3.API.User} - */ -R3.User.prototype.toApiObject = function() { - - return new R3.API.User( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.googleId, - this.fullName, - this.givenName, - this.familyName, - this.imageUrl, - this.email, - this.uploadFolder, - this.idToken - - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-vector2.js b/src/r3-vector2.js index b45f119..a08143a 100644 --- a/src/r3-vector2.js +++ b/src/r3-vector2.js @@ -1,46 +1,23 @@ /** - * Runtime vector2 for updating instance objects + * R3.Vector2 + * @param apiComponent + * + * @property x + * @property y + * * @constructor - * @param parent - * @param apiVector2 */ R3.Vector2 = function( - parent, - apiVector2 + apiComponent ) { - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; - if (R3.Utils.UndefinedOrNull(apiVector2)) { - apiVector2 = {}; - } - this.apiVector2 = apiVector2; + __RUNTIME_COMPONENT__; - R3.API.Vector2.call( - this, - apiVector2.x, - apiVector2.y - ); + __UPGRADE_TO_RUNTIME__; - this.graphics = null; - this.physics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - this.physics = runtime.physics; - }.bind(this) - ); - - this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - - this.createInstance(); }; -R3.Vector2.prototype = Object.create(R3.API.Vector2.prototype); +R3.Vector2.prototype = Object.create(R3.Component.prototype); R3.Vector2.prototype.constructor = R3.Vector2; /** @@ -49,15 +26,15 @@ R3.Vector2.prototype.constructor = R3.Vector2; */ R3.Vector2.prototype.createInstance = function() { - switch (this.componentRuntime) { - case R3.Component.GRAPHICS_RUNTIME : + switch (this.parent.runtime) { + case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector2( this.x, this.y ); break; - case R3.Component.PHYSICS_RUNTIME : - this.instance = this.physics.Vector3( + case R3.Runtime.PHYSICS : + this.instance = this.physics.Vector2( this.x, this.y ); @@ -66,6 +43,8 @@ R3.Vector2.prototype.createInstance = function() { throw new Error('unhandled component runtime: ' + this.componentRuntime); } + __CREATE_INSTANCE__; + }; /** @@ -75,23 +54,16 @@ R3.Vector2.prototype.updateInstance = function(property) { if (property === 'x') { this.instance.x = this.x; + return; } if (property === 'y') { this.instance.y = this.y; + return; } -}; + __UPDATE_INSTANCE__; -/** - * Converts runtime vector to API Vector - * @returns {R3.API.Vector2} - */ -R3.Vector2.prototype.toApiObject = function() { - return new R3.API.Vector2( - this.x, - this.y - ) }; /** @@ -103,9 +75,7 @@ R3.Vector2.prototype.toApiObject = function() { R3.Vector2.prototype.clone = function(v) { return new R3.Vector2( - this.parent, - this.x, - this.y + this ); }; diff --git a/src/r3-vector3.js b/src/r3-vector3.js index d24ce58..64374c6 100644 --- a/src/r3-vector3.js +++ b/src/r3-vector3.js @@ -1,48 +1,24 @@ /** * R3.Vector3 - * @param parent - * @param apiVector + * @param apiComponent + * + * @property x + * @property y + * @property z + * * @constructor */ R3.Vector3 = function( - parent, - apiVector3 + apiComponent ) { - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiVector3)) { - apiVector3 = {}; - } - this.apiVector3 = apiVector3; + __UPGRADE_TO_RUNTIME__; - R3.API.Vector3.call( - this, - apiVector3.x, - apiVector3.y, - apiVector3.z - ); - - this.graphics = null; - this.physics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - this.physics = runtime.physics; - }.bind(this) - ); - - this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - - this.createInstance(); }; -R3.Vector3.prototype = Object.create(R3.API.Vector3.prototype); +R3.Vector3.prototype = Object.create(R3.Component.prototype); R3.Vector3.prototype.constructor = R3.Vector3; /** @@ -51,15 +27,15 @@ R3.Vector3.prototype.constructor = R3.Vector3; */ R3.Vector3.prototype.createInstance = function() { - switch (this.componentRuntime) { - case R3.Component.GRAPHICS_RUNTIME : + switch (this.parent.runtime) { + case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector3( this.x, this.y, this.z ); break; - case R3.Component.PHYSICS_RUNTIME : + case R3.Runtime.PHYSICS : this.instance = this.physics.Vector3( this.x, this.y, @@ -69,6 +45,8 @@ R3.Vector3.prototype.createInstance = function() { default: throw new Error('unhandled component runtime: ' + this.componentRuntime); } + + __CREATE_INSTANCE__; }; /** @@ -78,27 +56,21 @@ R3.Vector3.prototype.updateInstance = function(property) { if (property === 'x') { this.instance.x = this.x; + return; } if (property === 'y') { this.instance.y = this.y; + return; } if (property === 'z') { this.instance.z = this.z; + return; } -}; + __UPDATE_INSTANCE__; -/** - * Converts runtime vector to API Vector - */ -R3.Vector3.prototype.toApiObject = function() { - return new R3.API.Vector3( - this.x, - this.y, - this.z - ); }; /** @@ -106,12 +78,7 @@ R3.Vector3.prototype.toApiObject = function() { * @returns {R3.Vector3|R3.Vector3|R3.Vector3} */ R3.Vector3.prototype.clone = function() { - return new R3.Vector3( - this.parent, - this.x, - this.y, - this.z - ) + return new R3.Vector3(this); }; /** @@ -119,12 +86,14 @@ R3.Vector3.prototype.clone = function() { * @returns {R3.Vector3} */ R3.Vector3.prototype.negativeCopy = function() { - return new R3.Vector3( - this.parent, - -this.x, - -this.y, - -this.z - ) + + var vector3 = new R3.Vector3(this); + + vector3.x *= -1; + vector3.y *= -1; + vector3.z *= -1; + + return vector3; }; /** @@ -134,6 +103,9 @@ R3.Vector3.prototype.negativeCopy = function() { */ R3.Vector3.prototype.applyAxisAngle = function(axis, angle) { + console.warn('todo: do nor rely on graphics instance'); + return; + this.instance.applyAxisAngle( new THREE.Vector3( axis.x, diff --git a/src/r3-vector4.js b/src/r3-vector4.js index ca9a988..2eb0827 100644 --- a/src/r3-vector4.js +++ b/src/r3-vector4.js @@ -1,49 +1,25 @@ /** - * Runtime apiVector4 for updating instance objects + * R3.Vector4 + * @param apiComponent + * + * @property x + * @property y + * @property z + * @property w + * * @constructor - * @param parent - * @param apiVector4 */ R3.Vector4 = function( - parent, - apiVector4 + apiComponent ) { - if (R3.Utils.UndefinedOrNull(parent)) { - parent = null; - } - this.parent = parent; + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiVector4)) { - apiVector4 = {}; - } - this.apiVector4 = apiVector4; + __UPGRADE_TO_RUNTIME__; - R3.API.Vector4.call( - this, - apiVector4.x, - apiVector4.y, - apiVector4.z, - apiVector4.w - ); - - this.graphics = null; - this.physics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - this.physics = runtime.physics; - }.bind(this) - ); - - this.componentRuntime = R3.Component.GetComponentRuntime(this.parent); - - this.createInstance(); }; -R3.Vector4.prototype = Object.create(R3.API.Vector4.prototype); +R3.Vector4.prototype = Object.create(R3.Component.prototype); R3.Vector4.prototype.constructor = R3.Vector4; /** @@ -51,8 +27,9 @@ R3.Vector4.prototype.constructor = R3.Vector4; * @returns {*} */ R3.Vector4.prototype.createInstance = function() { - switch (this.componentRuntime) { - case R3.Component.GRAPHICS_RUNTIME : + + switch (this.parent.runtime) { + case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector4( this.x, this.y, @@ -60,7 +37,7 @@ R3.Vector4.prototype.createInstance = function() { this.w ); break; - case R3.Component.PHYSICS_RUNTIME : + case R3.Runtime.PHYSICS : this.instance = this.physics.Vector4( this.x, this.y, @@ -71,6 +48,9 @@ R3.Vector4.prototype.createInstance = function() { default: throw new Error('unhandled component runtime: ' + this.componentRuntime); } + + __CREATE_INSTANCE__; + }; /** @@ -80,29 +60,23 @@ R3.Vector4.prototype.updateInstance = function(property) { if (property === 'x') { this.instance.x = this.x; + return; } if (property === 'y') { this.instance.y = this.y; + return; } if (property === 'z') { this.instance.z = this.z; + return; } if (property === 'w') { this.instance.w = this.w; + return; } -}; -/** - * Converts runtime vector to API Vector - */ -R3.Vector4.prototype.toApiObject = function() { - return { - x : this.x, - y : this.y, - z : this.z, - w : this.w - } + __UPDATE_INSTANCE__; }; diff --git a/src/r3-video.js b/src/r3-video.js index 9e0bb16..90b7f37 100644 --- a/src/r3-video.js +++ b/src/r3-video.js @@ -1,39 +1,21 @@ /** - * Video object - * @param graphics - * @param apiVideo - * @returns {R3.Video} + * R3.Video + * @param apiComponent + * + * @property autoUpdateSize + * @property width + * @property height + * @property offset + * @property source + * * @constructor */ R3.Video = function( - graphics, - apiVideo + apiComponent ) { - this.graphics = graphics; + __RUNTIME_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiVideo)) { - apiVideo = {}; - } - - R3.API.Video.call( - this, - apiVideo.id, - apiVideo.name, - apiVideo.parent, - apiVideo.autoUpdateSize, - apiVideo.width, - apiVideo.height, - apiVideo.offset, - apiVideo.source - ); - - this.offset = new R3.Vector2( - this.graphics, - this.offset, - this - ); - - R3.Component.call(this); + __UPGRADE_TO_RUNTIME__; }; R3.Video.prototype = Object.create(R3.Component.prototype); @@ -81,7 +63,8 @@ R3.Video.prototype.createInstance = function() { this.instance.setAttribute('src', this.source); } - R3.Component.prototype.createInstance.call(this); + __CREATE_INSTANCE__; + }; /** @@ -89,10 +72,6 @@ R3.Video.prototype.createInstance = function() { */ R3.Video.prototype.updateInstance = function(property) { - if (R3.Utils.UndefinedOrNull(property)) { - console.warn('unknown property update for Video: ' + property); - } - if (property === 'id') { this.instance.setAttribute('id', this.id); return; @@ -141,22 +120,5 @@ R3.Video.prototype.updateInstance = function(property) { return; } - R3.Component.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.Video to a R3.API.Video - * @returns {R3.API.Video} - */ -R3.Video.prototype.toApiObject = function() { - return new R3.API.Video( - this.id, - this.name, - R3.Utils.IdOrNull(this.parent), - this.autoUpdateSize, - this.width, - this.height, - this.offset.toApiObject(), - this.source - ); + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-poly-vertex.js b/todo/r3-d3-polyVertex.js similarity index 100% rename from src/r3-d3-poly-vertex.js rename to todo/r3-d3-polyVertex.js diff --git a/src/r3-d3-triangle-edge.js b/todo/r3-d3-triangleEdge.js similarity index 100% rename from src/r3-d3-triangle-edge.js rename to todo/r3-d3-triangleEdge.js diff --git a/todo/soc-a.js b/todo/soc-a.js new file mode 100644 index 0000000..27bd71f --- /dev/null +++ b/todo/soc-a.js @@ -0,0 +1,8 @@ +console.log('Loading SOC Library compiled on : __DATE__'); + +/** + * SOC + * @constructor + */ +function SOC () { +} diff --git a/todo/soc-graph-barchart-stacked.js b/todo/soc-graph-barchart-stacked.js new file mode 100644 index 0000000..e69de29 diff --git a/todo/soc-graph-barchart.js b/todo/soc-graph-barchart.js new file mode 100644 index 0000000..e69de29 diff --git a/todo/soc-graph-counter.js b/todo/soc-graph-counter.js new file mode 100644 index 0000000..12f064b --- /dev/null +++ b/todo/soc-graph-counter.js @@ -0,0 +1,33 @@ + + +SOC.Query.WorldMapDashboard = function() { + google.charts.load('current', { + 'packages':['geochart'], + // Note: you will need to get a mapsApiKey for your project. + // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings + 'mapsApiKey': 'AIzaSyBvsr1U4CzWk9_t4prYNCuRWwe8HFLY8IM' + }); + google.charts.setOnLoadCallback(drawRegionsMap); + + function drawRegionsMap() { + var data = google.visualization.arrayToDataTable([ + ['Country', 'Popularity'], + ['Germany', 200], + ['United States', 300], + ['Brazil', 400], + ['Canada', 500], + ['France', 600], + ['RU', 700] + ]); + + var options = {}; + + var chart = new google.visualization.GeoChart(document.getElementById('div-access')); + + chart.draw(data, options); + + document.getElementById('div-access').getElementsByTagName('div')[0].style.position = 'absolute'; + } + + +}; diff --git a/todo/soc-graph-table.js b/todo/soc-graph-table.js new file mode 100644 index 0000000..12f064b --- /dev/null +++ b/todo/soc-graph-table.js @@ -0,0 +1,33 @@ + + +SOC.Query.WorldMapDashboard = function() { + google.charts.load('current', { + 'packages':['geochart'], + // Note: you will need to get a mapsApiKey for your project. + // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings + 'mapsApiKey': 'AIzaSyBvsr1U4CzWk9_t4prYNCuRWwe8HFLY8IM' + }); + google.charts.setOnLoadCallback(drawRegionsMap); + + function drawRegionsMap() { + var data = google.visualization.arrayToDataTable([ + ['Country', 'Popularity'], + ['Germany', 200], + ['United States', 300], + ['Brazil', 400], + ['Canada', 500], + ['France', 600], + ['RU', 700] + ]); + + var options = {}; + + var chart = new google.visualization.GeoChart(document.getElementById('div-access')); + + chart.draw(data, options); + + document.getElementById('div-access').getElementsByTagName('div')[0].style.position = 'absolute'; + } + + +}; diff --git a/todo/soc-graph-world.js b/todo/soc-graph-world.js new file mode 100644 index 0000000..12f064b --- /dev/null +++ b/todo/soc-graph-world.js @@ -0,0 +1,33 @@ + + +SOC.Query.WorldMapDashboard = function() { + google.charts.load('current', { + 'packages':['geochart'], + // Note: you will need to get a mapsApiKey for your project. + // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings + 'mapsApiKey': 'AIzaSyBvsr1U4CzWk9_t4prYNCuRWwe8HFLY8IM' + }); + google.charts.setOnLoadCallback(drawRegionsMap); + + function drawRegionsMap() { + var data = google.visualization.arrayToDataTable([ + ['Country', 'Popularity'], + ['Germany', 200], + ['United States', 300], + ['Brazil', 400], + ['Canada', 500], + ['France', 600], + ['RU', 700] + ]); + + var options = {}; + + var chart = new google.visualization.GeoChart(document.getElementById('div-access')); + + chart.draw(data, options); + + document.getElementById('div-access').getElementsByTagName('div')[0].style.position = 'absolute'; + } + + +}; diff --git a/todo/soc-graph.js b/todo/soc-graph.js new file mode 100644 index 0000000..5adf3a0 --- /dev/null +++ b/todo/soc-graph.js @@ -0,0 +1,2 @@ +function SOC.Graph() { +} diff --git a/todo/soc-query-alert-dashboard.js b/todo/soc-query-alert-dashboard.js new file mode 100644 index 0000000..bff2796 --- /dev/null +++ b/todo/soc-query-alert-dashboard.js @@ -0,0 +1,66 @@ +/** + * @param options + * @constructor + */ +SOC.Query.AlertDashboard = function( + options +) { + + if (!options) { + options = {}; + } + + if (!options.path) { + options.path = '/alerts/_search'; + } + + if (!options.query) { + options.query = { + "version": false, + "size": 0, + "sort": [ + { + "timestamp": { + "order": "desc", + "unmapped_type": "boolean" + } + } + ], + "_source": { + "includes": ["*"] + }, + "aggs": { + "priorities": { + "histogram": { + "field": "priority", + "interval": "1", + "min_doc_count": 0 + } + } + }, + "query": { + "bool": { + "must": [ + { + "range": { + "timestamp": { + "format": "strict_date_optional_time", + "gte": "%QUERY_START", + "lt": "%QUERY_END" + } + } + } + ] + } + } + }; + } + + SOC.Query.call( + this, + options + ); +}; + +SOC.Query.AlertDashboard.prototype = Object.create(SOC.Query.prototype); +SOC.Query.AlertDashboard.prototype.constructor = SOC.Query; diff --git a/todo/soc-query-alert-list.js b/todo/soc-query-alert-list.js new file mode 100644 index 0000000..3aac9a4 --- /dev/null +++ b/todo/soc-query-alert-list.js @@ -0,0 +1,79 @@ + + + +/** + * @param options + * @constructor + */ +SOC.Query.AlertList = function( + options +) { + + if (!options) { + options = {}; + } + + if (!options.path) { + options.path = '/alerts/_search'; + } + + if (!options.query) { + options.query = { + "version": false, + "size": 200, + "sort": [ + { + "priority": { + "order": "asc", + "unmapped_type": "boolean" + }, + "alert_type.keyword": { + "order": "asc", + "unmapped_type": "boolean" + } + } + ], + "_source": { + "includes": ["*"] + }, + "query": { + "bool": { + "must": [ + { + "range": { + "timestamp": { + "format": "strict_date_optional_time", + "gte": "%QUERY_START", + "lt": "%QUERY_END" + } + } + } + ] + } + } + } + } + + SOC.Query.call( + this, + options + ); +}; + +SOC.Query.AlertList.prototype = Object.create(SOC.Query.prototype); +SOC.Query.AlertList.prototype.constructor = SOC.Query; + +SOC.Query.AlertList.prototype.draw = function(divId, data) { + + google.charts.load( + 'current', + { + 'packages': ['table'] + } + ); + + google.charts.setOnLoadCallback( + this.drawTable(divId, data) + ); + +}; diff --git a/todo/soc-query.js b/todo/soc-query.js new file mode 100644 index 0000000..8a83bcd --- /dev/null +++ b/todo/soc-query.js @@ -0,0 +1,104 @@ +SOC.Query = function (options) { + + if (options && options.path) { + this.path = options.path; + } else { + this.path = null; + } + + if (options && options.queryStart) { + this.queryStart = options.queryStart; + } else { + this.queryStart = 'now-7d'; + } + + if (options && options.queryEnd) { + this.queryEnd = options.queryEnd; + } else { + this.queryEnd = 'now+4h'; + } + + if (options && options.query) { + this.query = options.query; + } else { + this.query = null; + } + + if (options && options.onData) { + this.onData = options.onData; + } else { + this.onData = function() { + throw new Error( + "You should specify a onData function in the constructor to your query, ex. SOC.Query.SomeQuery({onData : myCallbackFunction})" + ) + }; + } + + this.run(); + +}; + +SOC.Query.prototype = Object.create(SOC.prototype); +SOC.Query.prototype.constructor = SOC; + +SOC.Query.prototype.run = function() { + + if (this.path === null) { + throw new Error('query path must be set'); + } + + if (this.query === null) { + throw new Error('query must be set'); + } + + var xhr = new XMLHttpRequest(); + + xhr.open( + 'POST', + this.apiUrl + this.path, + true + ); + + xhr.onload = function(event){ + console.log('loaded'); + this.onData(JSON.parse(event.target.responseText)); + }.bind(this); + + xhr.onerror = function(event) { + throw new Error('An error occured during query execution'); + }; + + xhr.setRequestHeader( + 'Content-Type', + 'application/json' + ); + + var queryText = JSON.stringify(this.query); + + queryText = queryText.replace('%QUERY_START', this.queryStart); + queryText = queryText.replace('%QUERY_END', this.queryEnd); + + xhr.send( + queryText + ); +}; + +SOC.Query.prototype.drawTable = function(divId, data) { + + return function() { + + var dataTable = new google.visualization.DataTable(); + + data.columns.map( + function(column) { + dataTable.addColumn(column.type, column.name); + } + ); + + dataTable.addRows(data.rows); + + var table = new google.visualization.Table(document.getElementById(divId)); + + table.draw(dataTable, {showRowNumber: true, width: '100%', height: '100%'}); + } +};