From bfed32cd48c15cfb6e24549bb2322d2108c8b0c6 Mon Sep 17 00:00:00 2001 From: cybafelo Date: Tue, 15 Oct 2019 22:21:34 +0200 Subject: [PATCH] stable load --- {src => bak}/r3-api-controls-d3-editor.js | 0 {src => bak}/r3-controls-d3-editor.js | 5 +- bak/r3-d3-composer-render-target.js | 4 +- bak/r3-d3-composer-renderer.js | 4 +- gulpfile.js | 152 +- src/build_component_lists.php | 73 +- src/build_events.php | 81 + src/r3-a-1-component-info.js | 2691 +++++++++++++++-- src/r3-a-2-event-0.js | 282 ++ src/r3-a-2-event-1.js | 232 ++ src/r3-a-2-event.js | 502 --- src/r3-a-3-api-component.js | 5 +- src/r3-a-3-utils.js | 100 + src/r3-a-4-component.js | 1034 ++++--- src/r3-api-canvas.js | 13 +- src/r3-api-controls-0.js | 21 +- src/r3-api-controls-d3-0.js | 17 +- src/r3-api-controls-d3-firstPerson.js | 14 +- src/r3-api-controls-d3-orbit.js | 14 +- src/r3-api-controls-keyboard.js | 3 + src/r3-api-controls-mouse.js | 3 + src/r3-api-controls-touch.js | 21 +- src/r3-api-domElement.js | 1 + src/r3-api-entityManager.js | 19 - src/r3-api-graph-0.js | 6 +- src/r3-api-graph-barchart-0.js | 8 +- src/r3-api-graph-barchart-stacked.js | 11 +- src/r3-api-graph-metric.js | 7 +- src/r3-api-graph-table.js | 17 +- src/r3-api-mouse.js | 17 +- src/r3-api-project-0.js | 57 + src/r3-api-project-d2.js | 65 + src/r3-api-project-d3.js | 142 + src/r3-api-project.js | 90 - src/r3-api-quaternion-0.js | 3 +- src/r3-api-query-0.js | 28 +- src/r3-api-query-alerts-0.js | 11 +- src/r3-api-query-alerts-buckets.js | 136 +- src/r3-api-query-alerts-firstTimeLogin-0.js | 67 + ...uery-alerts-firstTimeLogin-applications.js | 27 + ...api-query-alerts-firstTimeLogin-devices.js | 27 + src/r3-api-query-alerts-firstTimeLogin-vpn.js | 27 + src/r3-api-query-alerts-list.js | 106 +- src/r3-api-query-alerts-summary.js | 94 +- src/r3-api-query-alerts-timeseries.js | 107 +- src/r3-api-query-devices-0.js | 65 + src/r3-api-query-devices-known.js | 25 + src/r3-api-query-devices-unknown.js | 25 + src/r3-api-query-logins-0.js | 65 + src/r3-api-query-logins-applications.js | 27 + src/r3-api-query-logins-devices.js | 27 + src/r3-api-query-logins-vpn.js | 27 + src/r3-api-renderer-0.js | 4 +- src/r3-api-renderer-d2.js | 13 +- src/r3-api-renderer-d3-0.js | 27 +- src/r3-api-renderer-d3-canvas-0.js | 13 +- src/r3-canvas.js | 22 +- src/r3-clock.js | 10 - src/r3-controls-0.js | 8 +- src/r3-controls-d3-0.js | 18 +- src/r3-controls-d3-firstPerson.js | 29 +- src/r3-controls-d3-orbit.js | 32 +- src/r3-controls-keyboard.js | 3 +- src/r3-controls-mouse.js | 3 +- src/r3-controls-touch.js | 3 +- src/r3-curve-path-d2-shape.js | 2 +- src/r3-d3-api-0-object.js | 8 +- src/r3-d3-api-camera-cube.js | 17 +- src/r3-d3-api-camera-orthographic-0.js | 18 +- ...-d3-api-camera-orthographic-fixedAspect.js | 2 + ...d3-api-camera-orthographic-scaledAspect.js | 10 +- src/r3-d3-api-camera-perspective-0.js | 18 +- src/r3-d3-api-camera-perspective-stereo.js | 2 + src/r3-d3-api-fog-0.js | 1 + ...icle-0.js => r3-d3-api-mesh-particle-0.js} | 104 +- ...e.js => r3-d3-api-mesh-particle-engine.js} | 51 +- ...ics-world.js => r3-d3-api-physicsWorld.js} | 0 src/r3-d3-api-raycaster.js | 14 +- src/r3-d3-api-renderTarget-0.js | 57 +- src/r3-d3-api-scene.js | 40 +- src/r3-d3-api-viewport-0.js | 33 +- src/r3-d3-api-viewport-fixedAspect.js | 21 +- src/r3-d3-api-viewport-zoomedAspect.js | 27 +- src/r3-d3-api-y-object.js | 8 +- src/r3-d3-camera-0.js | 22 +- src/r3-d3-camera-cube.js | 1 + src/r3-d3-camera-orthographic-0.js | 13 +- src/r3-d3-camera-orthographic-fixedAspect.js | 6 +- src/r3-d3-camera-orthographic-scaledAspect.js | 6 +- src/r3-d3-camera-perspective-0.js | 38 +- src/r3-d3-camera-perspective-stereo.js | 1 + src/r3-d3-fog-0.js | 7 +- src/r3-d3-fog-exp.js | 5 +- src/r3-d3-fog-normal.js | 6 +- src/r3-d3-material-0.js | 62 +- ...particle-0.js => r3-d3-mesh-particle-0.js} | 179 +- src/r3-d3-mesh-particle-engine.js | 192 ++ src/r3-d3-particle-engine.js | 272 -- ...physics-world.js => r3-d3-physicsWorld.js} | 0 src/r3-d3-raycaster.js | 15 +- src/r3-d3-renderTarget-0.js | 62 +- src/r3-d3-scene.js | 234 +- src/r3-d3-shape-0.js | 4 +- src/r3-d3-texture-0.js | 10 +- src/r3-d3-viewport-0.js | 95 +- src/r3-d3-viewport-fixedAspect.js | 45 +- src/r3-d3-viewport-zoomedAspect.js | 45 +- src/r3-entity.js | 345 +-- src/r3-entityManager.js | 262 +- src/r3-graph-0.js | 6 +- src/r3-graph-barchart-0.js | 8 +- src/r3-graph-barchart-stacked.js | 23 +- src/r3-graph-metric.js | 25 +- src/r3-graph-table.js | 14 +- src/r3-mouse.js | 12 +- src/{r3-project.js => r3-project-0.js} | 42 +- src/r3-project-d2.js | 48 + src/r3-project-d3.js | 111 + src/r3-quaternion-0.js | 38 +- src/r3-quaternion-points.js | 4 +- src/r3-query-0.js | 8 +- src/r3-query-alerts-0.js | 6 +- src/r3-query-alerts-buckets.js | 95 + src/r3-query-alerts-firstTimeLogin-0.js | 46 + ...uery-alerts-firstTimeLogin-applications.js | 84 + src/r3-query-alerts-firstTimeLogin-devices.js | 93 + src/r3-query-alerts-firstTimeLogin-vpn.js | 89 + src/r3-query-alerts-list.js | 44 + src/r3-query-alerts-summary.js | 14 + src/r3-query-alerts-timeseries.js | 103 + src/r3-query-devices-0.js | 29 + src/r3-query-devices-known.js | 84 + src/r3-query-devices-unknown.js | 85 + src/r3-query-logins-0.js | 31 + src/r3-query-logins-applications.js | 73 + src/r3-query-logins-devices.js | 85 + src/r3-query-logins-vpn.js | 79 + src/r3-renderer-0.js | 8 +- src/r3-renderer-d2.js | 11 +- src/r3-renderer-d3-0.js | 21 +- src/r3-renderer-d3-canvas-0.js | 19 +- src/r3-renderer-d3-canvas-target.js | 16 +- src/r3-runtime-graphics-0.js | 19 +- src/r3-runtime-graphics-chart.js | 66 + src/r3-runtime-graphics-custom.js | 34 + src/r3-runtime-graphics-google.js | 51 + src/r3-runtime-graphics-pixi.js | 40 + src/r3-runtime-graphics-three.js | 451 ++- src/r3-system-gui.js | 165 +- src/r3-system-input.js | 532 +--- src/r3-system-linking.js | 6 +- src/r3-system-query.js | 66 +- src/r3-system-render.js | 743 ++--- src/r3-system-storage.js | 277 +- src/r3-vector2.js | 6 +- src/r3-vector3.js | 6 +- src/r3-vector4.js | 6 +- todo/soc-query-alert-list.js | 4 +- todo/soc-query.js | 12 - 159 files changed, 8702 insertions(+), 4386 deletions(-) rename {src => bak}/r3-api-controls-d3-editor.js (100%) rename {src => bak}/r3-controls-d3-editor.js (89%) create mode 100755 src/build_events.php create mode 100644 src/r3-a-2-event-0.js create mode 100644 src/r3-a-2-event-1.js delete mode 100644 src/r3-a-2-event.js delete mode 100644 src/r3-api-entityManager.js create mode 100644 src/r3-api-project-0.js create mode 100644 src/r3-api-project-d2.js create mode 100644 src/r3-api-project-d3.js delete mode 100644 src/r3-api-project.js create mode 100644 src/r3-api-query-alerts-firstTimeLogin-0.js create mode 100644 src/r3-api-query-alerts-firstTimeLogin-applications.js create mode 100644 src/r3-api-query-alerts-firstTimeLogin-devices.js create mode 100644 src/r3-api-query-alerts-firstTimeLogin-vpn.js create mode 100644 src/r3-api-query-devices-0.js create mode 100644 src/r3-api-query-devices-known.js create mode 100644 src/r3-api-query-devices-unknown.js create mode 100644 src/r3-api-query-logins-0.js create mode 100644 src/r3-api-query-logins-applications.js create mode 100644 src/r3-api-query-logins-devices.js create mode 100644 src/r3-api-query-logins-vpn.js rename src/{r3-d3-api-particle-0.js => r3-d3-api-mesh-particle-0.js} (57%) rename src/{r3-d3-api-particle-engine.js => r3-d3-api-mesh-particle-engine.js} (51%) rename src/{r3-d3-api-physics-world.js => r3-d3-api-physicsWorld.js} (100%) rename src/{r3-d3-particle-0.js => r3-d3-mesh-particle-0.js} (55%) create mode 100644 src/r3-d3-mesh-particle-engine.js delete mode 100644 src/r3-d3-particle-engine.js rename src/{r3-d3-physics-world.js => r3-d3-physicsWorld.js} (100%) rename src/{r3-project.js => r3-project-0.js} (57%) create mode 100644 src/r3-project-d2.js create mode 100644 src/r3-project-d3.js create mode 100644 src/r3-query-alerts-firstTimeLogin-0.js create mode 100644 src/r3-query-alerts-firstTimeLogin-applications.js create mode 100644 src/r3-query-alerts-firstTimeLogin-devices.js create mode 100644 src/r3-query-alerts-firstTimeLogin-vpn.js create mode 100644 src/r3-query-devices-0.js create mode 100644 src/r3-query-devices-known.js create mode 100644 src/r3-query-devices-unknown.js create mode 100644 src/r3-query-logins-0.js create mode 100644 src/r3-query-logins-applications.js create mode 100644 src/r3-query-logins-devices.js create mode 100644 src/r3-query-logins-vpn.js create mode 100644 src/r3-runtime-graphics-chart.js create mode 100644 src/r3-runtime-graphics-custom.js create mode 100644 src/r3-runtime-graphics-google.js create mode 100644 src/r3-runtime-graphics-pixi.js diff --git a/src/r3-api-controls-d3-editor.js b/bak/r3-api-controls-d3-editor.js similarity index 100% rename from src/r3-api-controls-d3-editor.js rename to bak/r3-api-controls-d3-editor.js diff --git a/src/r3-controls-d3-editor.js b/bak/r3-controls-d3-editor.js similarity index 89% rename from src/r3-controls-d3-editor.js rename to bak/r3-controls-d3-editor.js index 31d14f5..050fd84 100644 --- a/src/r3-controls-d3-editor.js +++ b/bak/r3-controls-d3-editor.js @@ -10,7 +10,8 @@ R3.Controls.D3.Editor = function( __RUNTIME_COMPONENT__; R3.Controls.D3.call( - this + this, + true ); }; @@ -27,7 +28,7 @@ R3.Controls.D3.Editor.prototype.constructor = R3.Controls.D3.Editor; */ R3.Controls.D3.Editor.prototype.createInstance = function() { - this.instance = this.graphics.EditorControls(this.canvas, this.camera); + this.instance = this.graphics.EditorControls(this); __CREATE_INSTANCE__; }; diff --git a/bak/r3-d3-composer-render-target.js b/bak/r3-d3-composer-render-target.js index 899ac73..e454975 100644 --- a/bak/r3-d3-composer-render-target.js +++ b/bak/r3-d3-composer-render-target.js @@ -19,13 +19,13 @@ R3.D3.Composer.RenderTarget = function( this.renderTarget = R3.Component.ConstructFromObject(this.renderTarget); } - var linkedObjects = { + var linkedComponents = { renderTarget : R3.D3.RenderTarget }; R3.D3.Composer.call( this, - linkedObjects + linkedComponents ); }; diff --git a/bak/r3-d3-composer-renderer.js b/bak/r3-d3-composer-renderer.js index 0770102..3dc5738 100644 --- a/bak/r3-d3-composer-renderer.js +++ b/bak/r3-d3-composer-renderer.js @@ -19,13 +19,13 @@ R3.D3.Composer.Renderer = function( this.renderer = R3.Component.ConstructFromObject(this.renderer); } - var linkedObjects = { + var linkedComponents = { renderer : R3.Renderer.D3 }; R3.D3.Composer.call( this, - linkedObjects + linkedComponents ); }; diff --git a/gulpfile.js b/gulpfile.js index ca21304..65298df 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,20 +7,25 @@ var replace = require('gulp-string-replace'); gulp.task('build', build); gulp.task('monitor', monitor); +//__API_COMPONENT__ var code = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; code += '\t\tapiComponent = {};\n'; code += '\t}\n'; -code += '\tthis.apiComponent = apiComponent;\n'; code += '\n'; code += '\tR3.API.Component.call(\n'; code += '\t\tthis,\n'; -code += '\t\tthis.apiComponent.parent,\n'; -code += '\t\tthis.apiComponent.id,\n'; -code += '\t\tthis.apiComponent.name,\n'; -code += '\t\tthis.apiComponent.register,\n'; -code += '\t\tthis.apiComponent.selected\n'; +code += '\t\tapiComponent.parent,\n'; +code += '\t\tapiComponent.id,\n'; +code += '\t\tapiComponent.name,\n'; +code += '\t\tapiComponent.register,\n'; +code += '\t\tapiComponent.selected\n'; code += '\t)'; +//__DEFINE_API_COMPONENT__ +var code1 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; +code1 += '\t\tapiComponent = {};\n'; +code1 += '\t}\n'; + var code2 = 'R3.D3.API.Geometry.Buffer.call(\n'; code2 += '\t\tthis,\n'; code2 += '\t\tapiComponent\n'; @@ -39,41 +44,46 @@ code4 += '\t)'; var code5 = 'if (R3.Utils.UndefinedOrNull(apiTexture)) {\n'; code5 += '\t\tapiTexture = {};\n'; code5 += '\t}\n'; -code5 += '\tthis.apiTexture = apiTexture;\n'; code5 += '\n'; code5 += '\tR3.D3.API.Texture.call(\n'; code5 += '\t\tthis,\n'; -code5 += '\t\tthis.apiTexture,\n'; -code5 += '\t\tthis.apiTexture.parentMaterials,\n'; -code5 += '\t\tthis.apiTexture.mipmaps,\n'; -code5 += '\t\tthis.apiTexture.mapping,\n'; -code5 += '\t\tthis.apiTexture.wrapS,\n'; -code5 += '\t\tthis.apiTexture.wrapT,\n'; -code5 += '\t\tthis.apiTexture.magFilter,\n'; -code5 += '\t\tthis.apiTexture.minFilter,\n'; -code5 += '\t\tthis.apiTexture.anisotropy,\n'; -code5 += '\t\tthis.apiTexture.format,\n'; -code5 += '\t\tthis.apiTexture.storageType,\n'; -code5 += '\t\tthis.apiTexture.offset,\n'; -code5 += '\t\tthis.apiTexture.repeat,\n'; -code5 += '\t\tthis.apiTexture.rotation,\n'; -code5 += '\t\tthis.apiTexture.center,\n'; -code5 += '\t\tthis.apiTexture.matrixAutoUpdate,\n'; -code5 += '\t\tthis.apiTexture.generateMipMaps,\n'; -code5 += '\t\tthis.apiTexture.premultiplyAlpha,\n'; -code5 += '\t\tthis.apiTexture.flipY,\n'; -code5 += '\t\tthis.apiTexture.unpackAlignment,\n'; -code5 += '\t\tthis.apiTexture.encoding,\n'; -code5 += '\t\tthis.apiTexture.version,\n'; -code5 += '\t\tthis.apiTexture.animated,\n'; -code5 += '\t\tthis.apiTexture.reverseAnimation,\n'; -code5 += '\t\tthis.apiTexture.forward\n'; +code5 += '\t\tapiTexture,\n'; +code5 += '\t\tapiTexture.parentMaterials,\n'; +code5 += '\t\tapiTexture.mipmaps,\n'; +code5 += '\t\tapiTexture.mapping,\n'; +code5 += '\t\tapiTexture.wrapS,\n'; +code5 += '\t\tapiTexture.wrapT,\n'; +code5 += '\t\tapiTexture.magFilter,\n'; +code5 += '\t\tapiTexture.minFilter,\n'; +code5 += '\t\tapiTexture.anisotropy,\n'; +code5 += '\t\tapiTexture.format,\n'; +code5 += '\t\tapiTexture.storageType,\n'; +code5 += '\t\tapiTexture.offset,\n'; +code5 += '\t\tapiTexture.repeat,\n'; +code5 += '\t\tapiTexture.rotation,\n'; +code5 += '\t\tapiTexture.center,\n'; +code5 += '\t\tapiTexture.matrixAutoUpdate,\n'; +code5 += '\t\tapiTexture.generateMipMaps,\n'; +code5 += '\t\tapiTexture.premultiplyAlpha,\n'; +code5 += '\t\tapiTexture.flipY,\n'; +code5 += '\t\tapiTexture.unpackAlignment,\n'; +code5 += '\t\tapiTexture.encoding,\n'; +code5 += '\t\tapiTexture.version,\n'; +code5 += '\t\tapiTexture.animated,\n'; +code5 += '\t\tapiTexture.reverseAnimation,\n'; +code5 += '\t\tapiTexture.forward\n'; code5 += '\t)'; +//__RUNTIME_COMPONENT__ var code6 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; code6 += '\t\tapiComponent = {};\n'; code6 += '\t}\n'; -code6 += '\tthis.apiComponent = apiComponent;\n'; +code6 += '\n'; +code6 += '\tif (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n'; +code6 += '\t\tthis.linkedComponents = {};\n'; +code6 += '\t}\n'; +code6 += '\n'; +code6 += '\tthis.initialize(apiComponent)\n'; code6 += '\n'; code6 += '\tthis.graphics\t= null;\n'; code6 += '\tthis.physics\t= null;\n'; @@ -83,17 +93,48 @@ code6 += '\tthis.stats\t\t= null;\n'; code6 += '\n'; code6 += '\tR3.Event.Emit(\n'; code6 += '\t\tR3.Event.GET_RUNTIME,\n'; +code6 += '\t\tthis,\n'; code6 += '\t\tfunction(runtime) {\n'; +code6 += '\t\t\tif (R3.Utils.UndefinedOrNull(runtime)) {\n'; +code6 += '\t\t\t\treturn;\n'; +code6 += '\t\t\t}\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\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);\n'; -code6 += '\n'; -code6 += '\tthis.initialize(apiComponent)'; +code6 += '\t)'; +//__RUNTIME_COMPONENT_INHERITABLE__ +var code14 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; +code14 += '\t\t\tapiComponent = {};\n'; +code14 += '\t\t}\n'; +code14 += '\n'; +code14 += '\t\tthis.initialize(apiComponent)\n'; +code14 += '\n'; +code14 += '\t\tthis.graphics\t= null;\n'; +code14 += '\t\tthis.physics\t= null;\n'; +code14 += '\t\tthis.coder\t\t= null;\n'; +code14 += '\t\tthis.gui\t\t= null;\n'; +code14 += '\t\tthis.stats\t\t= null;\n'; +code14 += '\n'; +code14 += '\t\tR3.Event.Emit(\n'; +code14 += '\t\t\tR3.Event.GET_RUNTIME,\n'; +code14 += '\t\t\tthis,\n'; +code14 += '\t\t\tfunction(runtime) {\n'; +code14 += '\t\t\t\tif (R3.Utils.UndefinedOrNull(runtime)) {\n'; +code14 += '\t\t\t\t\treturn;\n'; +code14 += '\t\t\t\t}\n'; +code14 += '\t\t\t\tthis.graphics\t= runtime.graphics;\n'; +code14 += '\t\t\t\tthis.physics\t= runtime.physics;\n'; +code14 += '\t\t\t\tthis.coder\t\t= runtime.coder;\n'; +code14 += '\t\t\t\tthis.gui\t\t= runtime.gui;\n'; +code14 += '\t\t\t\tthis.stats\t\t= runtime.stats;\n'; +code14 += '\t\t\t}.bind(this)\n'; +code14 += '\t\t)'; + +//__DEREGISTER_COMPONENT__ var code7 = 'if (R3.Utils.UndefinedOrNull(apiComponent)) {\n'; code7 += '\t\tapiComponent = {};\n'; code7 += '\t}\n'; @@ -106,12 +147,14 @@ 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\tif (R3.Utils.UndefinedOrNull(register)) {\n'; +code7 += '\t\t\t\treturn;\n'; code7 += '\t\t\t}\n'; +code7 += '\t\t\tapiComponent.register = register;\n'; code7 += '\t\t}\n'; code7 += '\t)'; +//__UPGRADE_TO_RUNTIME__ var code8 = 'R3.Component.call(this)'; var code9 = 'R3.Component.prototype.createInstance.call(this)'; @@ -123,12 +166,31 @@ code11 += '\t\tthis,\n'; code11 += '\t\ttrue\n'; code11 += '\t);'; +//__INHERIT_ONLY__ +var code12 = 'if (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n'; +code12 += '\t\tthis.linkedComponents = {};\n'; +code12 += '\t}\n'; +code12 += '\t\n'; +code12 += '\tif (inherited !== true && inherited !== false) {\n'; +code12 += '\t\tthrow new Error(R3.GetComponentName(this) + " should not be instantiated directly");\n'; +code12 += '\t}'; + +//__INHERIT_AND_INSTANTIATE__ +var code13 = 'if (R3.Utils.UndefinedOrNull(this.linkedComponents)) {\n'; +code13 += '\t\tthis.linkedComponents = {};\n'; +code13 += '\t}\n'; +code13 += '\t\n'; +code13 += '\tif (R3.Utils.UndefinedOrNull(inherited)) {\n\n'; +code13 += '\t\t' + code14+ '\n'; +code13 += '\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__', code)) + .pipe(replace('__DEFINE_API_COMPONENT__', code1)) .pipe(replace('__API_GEOMETRY_BUFFER__', code2)) .pipe(replace('__API_GEOMETRY_NORMAL__', code3)) .pipe(replace('__API_MATERIAL__', code4)) @@ -139,12 +201,14 @@ function build() { .pipe(replace('__CREATE_INSTANCE__', code9)) .pipe(replace('__UPDATE_INSTANCE__', code10)) .pipe(replace('__RUNTIME_BUFFER_COMPONENT__', code11)) - .pipe(minify({ - ext:{ - src:'.js', - min:'-min.js' - } - })) + .pipe(replace('__INHERIT_ONLY__', code12)) + .pipe(replace('__INHERIT_AND_INSTANTIATE__', code13)) +// .pipe(minify({ +// ext:{ +// src:'.js', +// min:'-min.js' +// } +// })) .pipe(gulp.dest('./build/')); } diff --git a/src/build_component_lists.php b/src/build_component_lists.php index aa6ded0..4d92269 100755 --- a/src/build_component_lists.php +++ b/src/build_component_lists.php @@ -3,10 +3,10 @@ $files = scandir('.', SCANDIR_SORT_DESCENDING); -$statement = "/**\ - * R3.GetComponentType\ - * @returns {number}\ - * @constructor\ +$statement = "/** + * R3.GetComponentType + * @param component + * @returns {number} */\n"; $statement .= "R3.GetComponentType = function(component) {\n\n"; @@ -24,6 +24,7 @@ foreach ($files as $file) { if ( !preg_match('/r3\-system/', $file) && + !preg_match('/entityManager/', $file) && !preg_match('/r3\-runtime/', $file) && !preg_match('/r3\-z\./', $file) && !preg_match('/^r3\-a\-.*/', $file) && @@ -36,6 +37,7 @@ foreach ($files as $file) { $file = str_replace('api.y.', '', $file); $file = str_replace('api.z.', '', $file); $file = str_replace('api', 'API', $file); + $file = str_replace('vpn', 'VPN', $file); $file = str_replace('gui', 'GUI', $file); $file = str_replace('ssao', 'SSAO', $file); $file = str_replace('fxaa', 'FXAA', $file); @@ -96,6 +98,37 @@ $componentDefines .= 'R3.MAX_COMPONENTS = 0x' . dechex($i) . ";\n\n"; $getComponentInfo = "R3.GetComponentInfo = function(componentType) {\n\n\tswitch (componentType) {\n\n"; +$getApiConstructor = "/** + * R3.GetAPIConstructor + * @param runtimeComponent + * @returns constructor + */\n"; + +$getApiConstructor .= "R3.GetAPIConstructor = function(runtimeComponent) {\n\n"; + +$getName = "/** + * R3.GetComponentName + * @param runtimeComponent + * @returns string + */\n"; +$getName .= "R3.GetComponentName = function(runtimeComponent) {\n\n"; + +$getConstructor = "/** + * R3.GetConstructor + * @param apiComponent + * @returns constructor + */\n"; + +$getConstructor .= "R3.GetConstructor = function(apiComponent) {\n\n"; + +$getConstructorFromComponentType = "/** + * R3.GetConstructorFromComponentType + * @param componentType + * @returns constructor + */\n"; + +$getConstructorFromComponentType .= "R3.GetConstructorFromComponentType = function(componentType) {\n\n"; +$getConstructorFromComponentType .= "\tswitch (componentType) {\n\n"; foreach ($componentTypes as $componentType) { @@ -106,9 +139,14 @@ foreach ($componentTypes as $componentType) { $name = $components[$componentType]; + $getApiConstructor .= "\tif (runtimeComponent instanceof " . $name . "){\n\t\treturn " . $apiComponents[$componentType] . ";\n\t}\n"; + $getName .= "\tif (runtimeComponent instanceof " . $name . "){\n\t\treturn '" . $name . "';\n\t}\n"; + $getConstructor .= "\tif (apiComponent instanceof " . $apiComponents[$componentType] . "){\n\t\treturn " . $name . ";\n\t}\n"; + $getConstructorFromComponentType .= "\t\tcase " . $componentType . ": return " . $name . ";\n"; + $runtime = 'R3.Runtime.DEFAULT'; - if (preg_match('/Render|Color|Controls|Curve|Image|Video|Camera|Composer|Effect|Graphics|Fog|Geometry|Light|Material|Mesh|Particle|Pass|Raycaster|Scene|Shader|Shadow|Skeleton|Text|Viewport|Object|Bone/', $name)) { + if (preg_match('/Bone|Camera|Canvas|Clock|Color|Composer|Controls|Curve|Effect|Fog|Geometry|Graphics|Image|Light|Material|Mesh|Mouse|Object|Particle|Pass|Raycaster|Render|Scene|Shader|Shadow|Skeleton|Text|Video|Viewport/', $name)) { $runtime = 'R3.Runtime.GRAPHICS'; } @@ -124,7 +162,7 @@ foreach ($componentTypes as $componentType) { $runtime = 'R3.Runtime.SOCKETS'; } - if (preg_match('/Friction|Physics|Vehicle|Wheel|Rigid|Shape|Solver|Broadphase/', $name)) { + if (preg_match('/Broadphase|Friction|Physics|Rigid|Shape|Solver|Vehicle|Wheel/', $name)) { $runtime = 'R3.Runtime.PHYSICS'; } @@ -138,15 +176,32 @@ foreach ($componentTypes as $componentType) { $getComponentInfo .= "\t\tdefault : \n"; $getComponentInfo .= "\t\t\tthrow new Error('Invalid component type: ' + componentType);\n\n"; - $getComponentInfo .= "\t}\n"; +$getComponentInfo .= "};\n\n"; + +$getApiConstructor .= "\tthrow new Error('Invalid Runtime Constructor : ' + runtimeConstructor);\n\n"; +$getApiConstructor .= "};\n\n"; + +$getConstructor .= "\tthrow new Error('Invalid API Constructor : ' + apiConstructor);\n\n"; +$getConstructor .= "};\n\n"; + +$getConstructorFromComponentType .= "\t\tdefault : \n"; +$getConstructorFromComponentType .= "\t\t\tthrow new Error('Invalid componentType : ' + componentType);\n\n"; +$getConstructorFromComponentType .= "\t}\n"; +$getConstructorFromComponentType .= "};\n\n"; + +$getName .= "\tthrow new Error('Invalid Runtime Constructor : ' + runtimeConstructor);\n\n"; +$getName .= "};\n"; -$getComponentInfo .= "};\n"; echo $componentDefines; echo $statement; echo $getComponentInfo; +echo $getApiConstructor; +echo $getConstructor; +echo $getConstructorFromComponentType; +echo $getName; -file_put_contents('r3-a-1-component-info.js', $componentDefines . $statement . $getComponentInfo); +file_put_contents('r3-a-1-component-info.js', $componentDefines . $statement . $getComponentInfo . $getApiConstructor . $getConstructor . $getConstructorFromComponentType . $getName); ?> diff --git a/src/build_events.php b/src/build_events.php new file mode 100755 index 0000000..51203d7 --- /dev/null +++ b/src/build_events.php @@ -0,0 +1,81 @@ +#!/usr/bin/php + \ No newline at end of file diff --git a/src/r3-a-1-component-info.js b/src/r3-a-1-component-info.js index d2f3fec..bc694fa 100644 --- a/src/r3-a-1-component-info.js +++ b/src/r3-a-1-component-info.js @@ -14,184 +14,195 @@ 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.COMPONENT_QUERY_LOGINS_VPN = 0x11; +R3.COMPONENT_QUERY_LOGINS_DEVICES = 0x12; +R3.COMPONENT_QUERY_LOGINS_APPLICATIONS = 0x13; +R3.COMPONENT_QUERY_LOGINS = 0x14; +R3.COMPONENT_QUERY_DEVICES_UNKNOWN = 0x15; +R3.COMPONENT_QUERY_DEVICES_KNOWN = 0x16; +R3.COMPONENT_QUERY_DEVICES = 0x17; +R3.COMPONENT_QUERY_ALERTS_TIMESERIES = 0x18; +R3.COMPONENT_QUERY_ALERTS_SUMMARY = 0x19; +R3.COMPONENT_QUERY_ALERTS_LIST = 0x1a; +R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_VPN = 0x1b; +R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_DEVICES = 0x1c; +R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_APPLICATIONS = 0x1d; +R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN = 0x1e; +R3.COMPONENT_QUERY_ALERTS_BUCKETS = 0x1f; +R3.COMPONENT_QUERY_ALERTS = 0x20; +R3.COMPONENT_QUERY = 0x21; +R3.COMPONENT_QUATERNION_POINTS = 0x22; +R3.COMPONENT_QUATERNION = 0x23; +R3.COMPONENT_PROJECT_D3 = 0x24; +R3.COMPONENT_PROJECT_D2 = 0x25; +R3.COMPONENT_PROJECT = 0x26; +R3.COMPONENT_PLANE = 0x27; +R3.COMPONENT_MOUSE = 0x28; +R3.COMPONENT_MATRIX4 = 0x29; +R3.COMPONENT_IMAGE = 0x2a; +R3.COMPONENT_GUI = 0x2b; +R3.COMPONENT_GROUP = 0x2c; +R3.COMPONENT_GRAPH_TABLE = 0x2d; +R3.COMPONENT_GRAPH_METRIC = 0x2e; +R3.COMPONENT_GRAPH_BARCHART_STACKED = 0x2f; +R3.COMPONENT_GRAPH_BARCHART = 0x30; +R3.COMPONENT_GRAPH = 0x31; +R3.COMPONENT_FONT = 0x32; +R3.COMPONENT_ENTITY = 0x33; +R3.COMPONENT_DRAWRANGE = 0x34; +R3.COMPONENT_DOMELEMENT = 0x35; +R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT = 0x36; +R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT = 0x37; +R3.COMPONENT_D3_VIEWPORT = 0x38; +R3.COMPONENT_D3_VERTEX = 0x39; +R3.COMPONENT_D3_TEXTURE_IMAGE = 0x3a; +R3.COMPONENT_D3_TEXTURE_CUBE = 0x3b; +R3.COMPONENT_D3_TEXTURE_CANVAS = 0x3c; +R3.COMPONENT_D3_TEXTURE = 0x3d; +R3.COMPONENT_D3_TEXT = 0x3e; +R3.COMPONENT_D3_SPLINE = 0x3f; +R3.COMPONENT_D3_SOLVER = 0x40; +R3.COMPONENT_D3_SKELETON = 0x41; +R3.COMPONENT_D3_SHAPE_TRIMESH = 0x42; +R3.COMPONENT_D3_SHAPE_SPHERE = 0x43; +R3.COMPONENT_D3_SHAPE_PLANE = 0x44; +R3.COMPONENT_D3_SHAPE_HEIGHTMAP = 0x45; +R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER = 0x46; +R3.COMPONENT_D3_SHAPE_CONVEXHULL = 0x47; +R3.COMPONENT_D3_SHAPE_BOX = 0x48; +R3.COMPONENT_D3_SHAPE = 0x49; +R3.COMPONENT_D3_SHADOW_SPOT = 0x4a; +R3.COMPONENT_D3_SHADOW_DIRECTIONAL = 0x4b; +R3.COMPONENT_D3_SHADOW = 0x4c; +R3.COMPONENT_D3_SHADER_VERTEX = 0x4d; +R3.COMPONENT_D3_SHADER_FRAGMENT = 0x4e; +R3.COMPONENT_D3_SHADER = 0x4f; +R3.COMPONENT_D3_SCENE = 0x50; +R3.COMPONENT_D3_RIGIDBODY = 0x51; +R3.COMPONENT_D3_RENDERTARGET_CUBE = 0x52; +R3.COMPONENT_D3_RENDERTARGET = 0x53; +R3.COMPONENT_D3_RAYCASTER = 0x54; +R3.COMPONENT_D3_RAYCASTWHEEL = 0x55; +R3.COMPONENT_D3_RAYCASTVEHICLE = 0x56; +R3.COMPONENT_D3_PHYSICSWORLD = 0x57; +R3.COMPONENT_D3_PASS_RENDER_SSAO = 0x58; +R3.COMPONENT_D3_PASS_RENDER = 0x59; +R3.COMPONENT_D3_PASS_FXAA = 0x5a; +R3.COMPONENT_D3_PASS_COPY = 0x5b; +R3.COMPONENT_D3_PASS_BLOOM = 0x5c; +R3.COMPONENT_D3_PASS = 0x5d; +R3.COMPONENT_D3_MESH_SKELETON = 0x5e; +R3.COMPONENT_D3_MESH_PARTICLE_ENGINE = 0x5f; +R3.COMPONENT_D3_MESH_PARTICLE = 0x60; +R3.COMPONENT_D3_MESH = 0x61; +R3.COMPONENT_D3_MATERIAL_STANDARD = 0x62; +R3.COMPONENT_D3_MATERIAL_SHADER_RAW = 0x63; +R3.COMPONENT_D3_MATERIAL_SHADER = 0x64; +R3.COMPONENT_D3_MATERIAL_POINTS = 0x65; +R3.COMPONENT_D3_MATERIAL_PHONG = 0x66; +R3.COMPONENT_D3_MATERIAL_BASIC = 0x67; +R3.COMPONENT_D3_MATERIAL = 0x68; +R3.COMPONENT_D3_LIGHT_SPOT = 0x69; +R3.COMPONENT_D3_LIGHT_RECTAREA = 0x6a; +R3.COMPONENT_D3_LIGHT_POINT = 0x6b; +R3.COMPONENT_D3_LIGHT_HEMISPHERE = 0x6c; +R3.COMPONENT_D3_LIGHT_DIRECTIONAL = 0x6d; +R3.COMPONENT_D3_LIGHT_AMBIENT = 0x6e; +R3.COMPONENT_D3_LIGHT = 0x6f; +R3.COMPONENT_D3_HELPER = 0x70; +R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME = 0x71; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE = 0x72; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT = 0x73; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS = 0x74; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT = 0x75; +R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON = 0x76; +R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE = 0x77; +R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE = 0x78; +R3.COMPONENT_D3_GEOMETRY_NORMAL_RING = 0x79; +R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON = 0x7a; +R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE = 0x7b; +R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC = 0x7c; +R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON = 0x7d; +R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE = 0x7e; +R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON = 0x7f; +R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE = 0x80; +R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES = 0x81; +R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON = 0x82; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER = 0x83; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE = 0x84; +R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE = 0x85; +R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX = 0x86; +R3.COMPONENT_D3_GEOMETRY_NORMAL = 0x87; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE = 0x88; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT = 0x89; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS = 0x8a; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT = 0x8b; +R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON = 0x8c; +R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE = 0x8d; +R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE = 0x8e; +R3.COMPONENT_D3_GEOMETRY_BUFFER_RING = 0x8f; +R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON = 0x90; +R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE = 0x91; +R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC = 0x92; +R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON = 0x93; +R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE = 0x94; +R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED = 0x95; +R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON = 0x96; +R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE = 0x97; +R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON = 0x98; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER = 0x99; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE = 0x9a; +R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE = 0x9b; +R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX = 0x9c; +R3.COMPONENT_D3_GEOMETRY_BUFFER = 0x9d; +R3.COMPONENT_D3_GEOMETRY = 0x9e; +R3.COMPONENT_D3_FRICTIONMATERIAL = 0x9f; +R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL = 0xa0; +R3.COMPONENT_D3_FOG_NORMAL = 0xa1; +R3.COMPONENT_D3_FOG_EXP = 0xa2; +R3.COMPONENT_D3_FOG = 0xa3; +R3.COMPONENT_D3_FACE_GRAPHICS = 0xa4; +R3.COMPONENT_D3_FACE = 0xa5; +R3.COMPONENT_D3_EFFECT_STEREO = 0xa6; +R3.COMPONENT_D3_EFFECT_PARALLAX = 0xa7; +R3.COMPONENT_D3_EFFECT_ANAGLYPH = 0xa8; +R3.COMPONENT_D3_EFFECT = 0xa9; +R3.COMPONENT_D3_COMPOSER = 0xaa; +R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO = 0xab; +R3.COMPONENT_D3_CAMERA_PERSPECTIVE = 0xac; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT = 0xad; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT = 0xae; +R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC = 0xaf; +R3.COMPONENT_D3_CAMERA_CUBE = 0xb0; +R3.COMPONENT_D3_CAMERA = 0xb1; +R3.COMPONENT_D3_BROADPHASE = 0xb2; +R3.COMPONENT_D3_BONEWEIGHT = 0xb3; +R3.COMPONENT_D3_BONE = 0xb4; +R3.COMPONENT_D3_AUDIO = 0xb5; +R3.COMPONENT_D3_ANIMATION = 0xb6; +R3.COMPONENT_D3_OBJECT = 0xb7; +R3.COMPONENT_CUSTOMCODE = 0xb8; +R3.COMPONENT_CURVE_PATH_D2_SHAPE = 0xb9; +R3.COMPONENT_CURVE_PATH_D2 = 0xba; +R3.COMPONENT_CURVE_PATH = 0xbb; +R3.COMPONENT_CURVE = 0xbc; +R3.COMPONENT_CONTROLS_TOUCH = 0xbd; +R3.COMPONENT_CONTROLS_MOUSE = 0xbe; +R3.COMPONENT_CONTROLS_KEYBOARD = 0xbf; +R3.COMPONENT_CONTROLS_D3_ORBIT = 0xc0; +R3.COMPONENT_CONTROLS_D3_FIRSTPERSON = 0xc1; +R3.COMPONENT_CONTROLS_D3 = 0xc2; +R3.COMPONENT_CONTROLS = 0xc3; +R3.COMPONENT_COLOR = 0xc4; +R3.COMPONENT_CLOCK = 0xc5; +R3.COMPONENT_CANVAS = 0xc6; +R3.COMPONENT_BOX3 = 0xc7; +R3.MAX_COMPONENTS = 0xc8; -/**\ - * R3.GetComponentType\ - * @returns {number}\ - * @constructor\ +/** + * R3.GetComponentType + * @param component + * @returns {number} */ R3.GetComponentType = function(component) { @@ -259,6 +270,34 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_RENDERER; } + if (component instanceof R3.Query.Logins.VPN) { + return R3.COMPONENT_QUERY_LOGINS_VPN; + } + + if (component instanceof R3.Query.Logins.Devices) { + return R3.COMPONENT_QUERY_LOGINS_DEVICES; + } + + if (component instanceof R3.Query.Logins.Applications) { + return R3.COMPONENT_QUERY_LOGINS_APPLICATIONS; + } + + if (component instanceof R3.Query.Logins) { + return R3.COMPONENT_QUERY_LOGINS; + } + + if (component instanceof R3.Query.Devices.Unknown) { + return R3.COMPONENT_QUERY_DEVICES_UNKNOWN; + } + + if (component instanceof R3.Query.Devices.Known) { + return R3.COMPONENT_QUERY_DEVICES_KNOWN; + } + + if (component instanceof R3.Query.Devices) { + return R3.COMPONENT_QUERY_DEVICES; + } + if (component instanceof R3.Query.Alerts.Timeseries) { return R3.COMPONENT_QUERY_ALERTS_TIMESERIES; } @@ -271,6 +310,22 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_QUERY_ALERTS_LIST; } + if (component instanceof R3.Query.Alerts.FirstTimeLogin.VPN) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_VPN; + } + + if (component instanceof R3.Query.Alerts.FirstTimeLogin.Devices) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_DEVICES; + } + + if (component instanceof R3.Query.Alerts.FirstTimeLogin.Applications) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_APPLICATIONS; + } + + if (component instanceof R3.Query.Alerts.FirstTimeLogin) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN; + } + if (component instanceof R3.Query.Alerts.Buckets) { return R3.COMPONENT_QUERY_ALERTS_BUCKETS; } @@ -291,6 +346,14 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_QUATERNION; } + if (component instanceof R3.Project.D3) { + return R3.COMPONENT_PROJECT_D3; + } + + if (component instanceof R3.Project.D2) { + return R3.COMPONENT_PROJECT_D2; + } + if (component instanceof R3.Project) { return R3.COMPONENT_PROJECT; } @@ -343,10 +406,6 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_FONT; } - if (component instanceof R3.EntityManager) { - return R3.COMPONENT_ENTITYMANAGER; - } - if (component instanceof R3.Entity) { return R3.COMPONENT_ENTITY; } @@ -491,8 +550,8 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_D3_RAYCASTVEHICLE; } - if (component instanceof R3.D3.Physics.World) { - return R3.COMPONENT_D3_PHYSICS_WORLD; + if (component instanceof R3.D3.PhysicsWorld) { + return R3.COMPONENT_D3_PHYSICSWORLD; } if (component instanceof R3.D3.Pass.Render.SSAO) { @@ -519,18 +578,18 @@ R3.GetComponentType = function(component) { 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.Particle.Engine) { + return R3.COMPONENT_D3_MESH_PARTICLE_ENGINE; + } + + if (component instanceof R3.D3.Mesh.Particle) { + return R3.COMPONENT_D3_MESH_PARTICLE; + } + if (component instanceof R3.D3.Mesh) { return R3.COMPONENT_D3_MESH; } @@ -1011,8 +1070,8 @@ R3.GetComponentType = function(component) { 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.PhysicsWorld) { + return R3.COMPONENT_D3_PHYSICSWORLD; } if (component instanceof R3.D3.API.Pass.Render.SSAO) { @@ -1039,18 +1098,18 @@ R3.GetComponentType = function(component) { 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.Particle.Engine) { + return R3.COMPONENT_D3_MESH_PARTICLE_ENGINE; + } + + if (component instanceof R3.D3.API.Mesh.Particle) { + return R3.COMPONENT_D3_MESH_PARTICLE; + } + if (component instanceof R3.D3.API.Mesh) { return R3.COMPONENT_D3_MESH; } @@ -1439,10 +1498,6 @@ R3.GetComponentType = function(component) { 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; } @@ -1531,6 +1586,34 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_RENDERER; } + if (component instanceof R3.API.Query.Logins.VPN) { + return R3.COMPONENT_QUERY_LOGINS_VPN; + } + + if (component instanceof R3.API.Query.Logins.Devices) { + return R3.COMPONENT_QUERY_LOGINS_DEVICES; + } + + if (component instanceof R3.API.Query.Logins.Applications) { + return R3.COMPONENT_QUERY_LOGINS_APPLICATIONS; + } + + if (component instanceof R3.API.Query.Logins) { + return R3.COMPONENT_QUERY_LOGINS; + } + + if (component instanceof R3.API.Query.Devices.Unknown) { + return R3.COMPONENT_QUERY_DEVICES_UNKNOWN; + } + + if (component instanceof R3.API.Query.Devices.Known) { + return R3.COMPONENT_QUERY_DEVICES_KNOWN; + } + + if (component instanceof R3.API.Query.Devices) { + return R3.COMPONENT_QUERY_DEVICES; + } + if (component instanceof R3.API.Query.Alerts.Timeseries) { return R3.COMPONENT_QUERY_ALERTS_TIMESERIES; } @@ -1543,6 +1626,22 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_QUERY_ALERTS_LIST; } + if (component instanceof R3.API.Query.Alerts.FirstTimeLogin.VPN) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_VPN; + } + + if (component instanceof R3.API.Query.Alerts.FirstTimeLogin.Devices) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_DEVICES; + } + + if (component instanceof R3.API.Query.Alerts.FirstTimeLogin.Applications) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_APPLICATIONS; + } + + if (component instanceof R3.API.Query.Alerts.FirstTimeLogin) { + return R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN; + } + if (component instanceof R3.API.Query.Alerts.Buckets) { return R3.COMPONENT_QUERY_ALERTS_BUCKETS; } @@ -1563,6 +1662,14 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_QUATERNION; } + if (component instanceof R3.API.Project.D3) { + return R3.COMPONENT_PROJECT_D3; + } + + if (component instanceof R3.API.Project.D2) { + return R3.COMPONENT_PROJECT_D2; + } + if (component instanceof R3.API.Project) { return R3.COMPONENT_PROJECT; } @@ -1615,10 +1722,6 @@ R3.GetComponentType = function(component) { return R3.COMPONENT_FONT; } - if (component instanceof R3.API.EntityManager) { - return R3.COMPONENT_ENTITYMANAGER; - } - if (component instanceof R3.API.Entity) { return R3.COMPONENT_ENTITY; } @@ -1671,10 +1774,6 @@ R3.GetComponentType = function(component) { 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; } @@ -1801,6 +1900,48 @@ R3.GetComponentInfo = function(componentType) { apiConstructor : R3.API.Renderer, runtime: R3.Runtime.GRAPHICS }; + case R3.COMPONENT_QUERY_LOGINS_VPN : return { + name : 'R3.Query.Logins.VPN', + constructor : R3.Query.Logins.VPN, + apiConstructor : R3.API.Query.Logins.VPN, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_LOGINS_DEVICES : return { + name : 'R3.Query.Logins.Devices', + constructor : R3.Query.Logins.Devices, + apiConstructor : R3.API.Query.Logins.Devices, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_LOGINS_APPLICATIONS : return { + name : 'R3.Query.Logins.Applications', + constructor : R3.Query.Logins.Applications, + apiConstructor : R3.API.Query.Logins.Applications, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_LOGINS : return { + name : 'R3.Query.Logins', + constructor : R3.Query.Logins, + apiConstructor : R3.API.Query.Logins, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_DEVICES_UNKNOWN : return { + name : 'R3.Query.Devices.Unknown', + constructor : R3.Query.Devices.Unknown, + apiConstructor : R3.API.Query.Devices.Unknown, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_DEVICES_KNOWN : return { + name : 'R3.Query.Devices.Known', + constructor : R3.Query.Devices.Known, + apiConstructor : R3.API.Query.Devices.Known, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_DEVICES : return { + name : 'R3.Query.Devices', + constructor : R3.Query.Devices, + apiConstructor : R3.API.Query.Devices, + runtime: R3.Runtime.DEFAULT + }; case R3.COMPONENT_QUERY_ALERTS_TIMESERIES : return { name : 'R3.Query.Alerts.Timeseries', constructor : R3.Query.Alerts.Timeseries, @@ -1819,6 +1960,30 @@ R3.GetComponentInfo = function(componentType) { apiConstructor : R3.API.Query.Alerts.List, runtime: R3.Runtime.DEFAULT }; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_VPN : return { + name : 'R3.Query.Alerts.FirstTimeLogin.VPN', + constructor : R3.Query.Alerts.FirstTimeLogin.VPN, + apiConstructor : R3.API.Query.Alerts.FirstTimeLogin.VPN, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_DEVICES : return { + name : 'R3.Query.Alerts.FirstTimeLogin.Devices', + constructor : R3.Query.Alerts.FirstTimeLogin.Devices, + apiConstructor : R3.API.Query.Alerts.FirstTimeLogin.Devices, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_APPLICATIONS : return { + name : 'R3.Query.Alerts.FirstTimeLogin.Applications', + constructor : R3.Query.Alerts.FirstTimeLogin.Applications, + apiConstructor : R3.API.Query.Alerts.FirstTimeLogin.Applications, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN : return { + name : 'R3.Query.Alerts.FirstTimeLogin', + constructor : R3.Query.Alerts.FirstTimeLogin, + apiConstructor : R3.API.Query.Alerts.FirstTimeLogin, + runtime: R3.Runtime.DEFAULT + }; case R3.COMPONENT_QUERY_ALERTS_BUCKETS : return { name : 'R3.Query.Alerts.Buckets', constructor : R3.Query.Alerts.Buckets, @@ -1849,6 +2014,18 @@ R3.GetComponentInfo = function(componentType) { apiConstructor : R3.API.Quaternion, runtime: R3.Runtime.DEFAULT }; + case R3.COMPONENT_PROJECT_D3 : return { + name : 'R3.Project.D3', + constructor : R3.Project.D3, + apiConstructor : R3.API.Project.D3, + runtime: R3.Runtime.DEFAULT + }; + case R3.COMPONENT_PROJECT_D2 : return { + name : 'R3.Project.D2', + constructor : R3.Project.D2, + apiConstructor : R3.API.Project.D2, + runtime: R3.Runtime.DEFAULT + }; case R3.COMPONENT_PROJECT : return { name : 'R3.Project', constructor : R3.Project, @@ -1865,7 +2042,7 @@ R3.GetComponentInfo = function(componentType) { name : 'R3.Mouse', constructor : R3.Mouse, apiConstructor : R3.API.Mouse, - runtime: R3.Runtime.DEFAULT + runtime: R3.Runtime.GRAPHICS }; case R3.COMPONENT_MATRIX4 : return { name : 'R3.Matrix4', @@ -1927,12 +2104,6 @@ R3.GetComponentInfo = function(componentType) { 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, @@ -2149,10 +2320,10 @@ R3.GetComponentInfo = function(componentType) { 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, + case R3.COMPONENT_D3_PHYSICSWORLD : return { + name : 'R3.D3.PhysicsWorld', + constructor : R3.D3.PhysicsWorld, + apiConstructor : R3.D3.API.PhysicsWorld, runtime: R3.Runtime.PHYSICS }; case R3.COMPONENT_D3_PASS_RENDER_SSAO : return { @@ -2191,24 +2362,24 @@ R3.GetComponentInfo = function(componentType) { 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_PARTICLE_ENGINE : return { + name : 'R3.D3.Mesh.Particle.Engine', + constructor : R3.D3.Mesh.Particle.Engine, + apiConstructor : R3.D3.API.Mesh.Particle.Engine, + runtime: R3.Runtime.GRAPHICS + }; + case R3.COMPONENT_D3_MESH_PARTICLE : return { + name : 'R3.D3.Mesh.Particle', + constructor : R3.D3.Mesh.Particle, + apiConstructor : R3.D3.API.Mesh.Particle, + runtime: R3.Runtime.GRAPHICS + }; case R3.COMPONENT_D3_MESH : return { name : 'R3.D3.Mesh', constructor : R3.D3.Mesh, @@ -2791,12 +2962,6 @@ R3.GetComponentInfo = function(componentType) { 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, @@ -2819,13 +2984,13 @@ R3.GetComponentInfo = function(componentType) { name : 'R3.Clock', constructor : R3.Clock, apiConstructor : R3.API.Clock, - runtime: R3.Runtime.DEFAULT + runtime: R3.Runtime.GRAPHICS }; case R3.COMPONENT_CANVAS : return { name : 'R3.Canvas', constructor : R3.Canvas, apiConstructor : R3.API.Canvas, - runtime: R3.Runtime.DEFAULT + runtime: R3.Runtime.GRAPHICS }; case R3.COMPONENT_BOX3 : return { name : 'R3.Box3', @@ -2838,3 +3003,2041 @@ R3.GetComponentInfo = function(componentType) { } }; + +/** + * R3.GetAPIConstructor + * @param runtimeComponent + * @returns constructor + */ +R3.GetAPIConstructor = function(runtimeComponent) { + + if (runtimeComponent instanceof R3.Video){ + return R3.API.Video; + } + if (runtimeComponent instanceof R3.Vector4){ + return R3.API.Vector4; + } + if (runtimeComponent instanceof R3.Vector3){ + return R3.API.Vector3; + } + if (runtimeComponent instanceof R3.Vector2){ + return R3.API.Vector2; + } + if (runtimeComponent instanceof R3.User){ + return R3.API.User; + } + if (runtimeComponent instanceof R3.Stats){ + return R3.API.Stats; + } + if (runtimeComponent instanceof R3.Sphere){ + return R3.API.Sphere; + } + if (runtimeComponent instanceof R3.Socket.Receive){ + return R3.API.Socket.Receive; + } + if (runtimeComponent instanceof R3.Socket.Cast){ + return R3.API.Socket.Cast; + } + if (runtimeComponent instanceof R3.Socket){ + return R3.API.Socket; + } + if (runtimeComponent instanceof R3.Server){ + return R3.API.Server; + } + if (runtimeComponent instanceof R3.Renderer.D3.Canvas.Target){ + return R3.API.Renderer.D3.Canvas.Target; + } + if (runtimeComponent instanceof R3.Renderer.D3.Canvas){ + return R3.API.Renderer.D3.Canvas; + } + if (runtimeComponent instanceof R3.Renderer.D3){ + return R3.API.Renderer.D3; + } + if (runtimeComponent instanceof R3.Renderer.D2){ + return R3.API.Renderer.D2; + } + if (runtimeComponent instanceof R3.Renderer){ + return R3.API.Renderer; + } + if (runtimeComponent instanceof R3.Query.Logins.VPN){ + return R3.API.Query.Logins.VPN; + } + if (runtimeComponent instanceof R3.Query.Logins.Devices){ + return R3.API.Query.Logins.Devices; + } + if (runtimeComponent instanceof R3.Query.Logins.Applications){ + return R3.API.Query.Logins.Applications; + } + if (runtimeComponent instanceof R3.Query.Logins){ + return R3.API.Query.Logins; + } + if (runtimeComponent instanceof R3.Query.Devices.Unknown){ + return R3.API.Query.Devices.Unknown; + } + if (runtimeComponent instanceof R3.Query.Devices.Known){ + return R3.API.Query.Devices.Known; + } + if (runtimeComponent instanceof R3.Query.Devices){ + return R3.API.Query.Devices; + } + if (runtimeComponent instanceof R3.Query.Alerts.Timeseries){ + return R3.API.Query.Alerts.Timeseries; + } + if (runtimeComponent instanceof R3.Query.Alerts.Summary){ + return R3.API.Query.Alerts.Summary; + } + if (runtimeComponent instanceof R3.Query.Alerts.List){ + return R3.API.Query.Alerts.List; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.VPN){ + return R3.API.Query.Alerts.FirstTimeLogin.VPN; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.Devices){ + return R3.API.Query.Alerts.FirstTimeLogin.Devices; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.Applications){ + return R3.API.Query.Alerts.FirstTimeLogin.Applications; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin){ + return R3.API.Query.Alerts.FirstTimeLogin; + } + if (runtimeComponent instanceof R3.Query.Alerts.Buckets){ + return R3.API.Query.Alerts.Buckets; + } + if (runtimeComponent instanceof R3.Query.Alerts){ + return R3.API.Query.Alerts; + } + if (runtimeComponent instanceof R3.Query){ + return R3.API.Query; + } + if (runtimeComponent instanceof R3.Quaternion.Points){ + return R3.API.Quaternion.Points; + } + if (runtimeComponent instanceof R3.Quaternion){ + return R3.API.Quaternion; + } + if (runtimeComponent instanceof R3.Project.D3){ + return R3.API.Project.D3; + } + if (runtimeComponent instanceof R3.Project.D2){ + return R3.API.Project.D2; + } + if (runtimeComponent instanceof R3.Project){ + return R3.API.Project; + } + if (runtimeComponent instanceof R3.Plane){ + return R3.API.Plane; + } + if (runtimeComponent instanceof R3.Mouse){ + return R3.API.Mouse; + } + if (runtimeComponent instanceof R3.Matrix4){ + return R3.API.Matrix4; + } + if (runtimeComponent instanceof R3.Image){ + return R3.API.Image; + } + if (runtimeComponent instanceof R3.GUI){ + return R3.API.GUI; + } + if (runtimeComponent instanceof R3.Group){ + return R3.API.Group; + } + if (runtimeComponent instanceof R3.Graph.Table){ + return R3.API.Graph.Table; + } + if (runtimeComponent instanceof R3.Graph.Metric){ + return R3.API.Graph.Metric; + } + if (runtimeComponent instanceof R3.Graph.Barchart.Stacked){ + return R3.API.Graph.Barchart.Stacked; + } + if (runtimeComponent instanceof R3.Graph.Barchart){ + return R3.API.Graph.Barchart; + } + if (runtimeComponent instanceof R3.Graph){ + return R3.API.Graph; + } + if (runtimeComponent instanceof R3.Font){ + return R3.API.Font; + } + if (runtimeComponent instanceof R3.Entity){ + return R3.API.Entity; + } + if (runtimeComponent instanceof R3.DrawRange){ + return R3.API.DrawRange; + } + if (runtimeComponent instanceof R3.DomElement){ + return R3.API.DomElement; + } + if (runtimeComponent instanceof R3.D3.Viewport.ZoomedAspect){ + return R3.D3.API.Viewport.ZoomedAspect; + } + if (runtimeComponent instanceof R3.D3.Viewport.FixedAspect){ + return R3.D3.API.Viewport.FixedAspect; + } + if (runtimeComponent instanceof R3.D3.Viewport){ + return R3.D3.API.Viewport; + } + if (runtimeComponent instanceof R3.D3.Vertex){ + return R3.D3.API.Vertex; + } + if (runtimeComponent instanceof R3.D3.Texture.Image){ + return R3.D3.API.Texture.Image; + } + if (runtimeComponent instanceof R3.D3.Texture.Cube){ + return R3.D3.API.Texture.Cube; + } + if (runtimeComponent instanceof R3.D3.Texture.Canvas){ + return R3.D3.API.Texture.Canvas; + } + if (runtimeComponent instanceof R3.D3.Texture){ + return R3.D3.API.Texture; + } + if (runtimeComponent instanceof R3.D3.Text){ + return R3.D3.API.Text; + } + if (runtimeComponent instanceof R3.D3.Spline){ + return R3.D3.API.Spline; + } + if (runtimeComponent instanceof R3.D3.Solver){ + return R3.D3.API.Solver; + } + if (runtimeComponent instanceof R3.D3.Skeleton){ + return R3.D3.API.Skeleton; + } + if (runtimeComponent instanceof R3.D3.Shape.TriMesh){ + return R3.D3.API.Shape.TriMesh; + } + if (runtimeComponent instanceof R3.D3.Shape.Sphere){ + return R3.D3.API.Shape.Sphere; + } + if (runtimeComponent instanceof R3.D3.Shape.Plane){ + return R3.D3.API.Shape.Plane; + } + if (runtimeComponent instanceof R3.D3.Shape.HeightMap){ + return R3.D3.API.Shape.HeightMap; + } + if (runtimeComponent instanceof R3.D3.Shape.ConvexHull.Cylinder){ + return R3.D3.API.Shape.ConvexHull.Cylinder; + } + if (runtimeComponent instanceof R3.D3.Shape.ConvexHull){ + return R3.D3.API.Shape.ConvexHull; + } + if (runtimeComponent instanceof R3.D3.Shape.Box){ + return R3.D3.API.Shape.Box; + } + if (runtimeComponent instanceof R3.D3.Shape){ + return R3.D3.API.Shape; + } + if (runtimeComponent instanceof R3.D3.Shadow.Spot){ + return R3.D3.API.Shadow.Spot; + } + if (runtimeComponent instanceof R3.D3.Shadow.Directional){ + return R3.D3.API.Shadow.Directional; + } + if (runtimeComponent instanceof R3.D3.Shadow){ + return R3.D3.API.Shadow; + } + if (runtimeComponent instanceof R3.D3.Shader.Vertex){ + return R3.D3.API.Shader.Vertex; + } + if (runtimeComponent instanceof R3.D3.Shader.Fragment){ + return R3.D3.API.Shader.Fragment; + } + if (runtimeComponent instanceof R3.D3.Shader){ + return R3.D3.API.Shader; + } + if (runtimeComponent instanceof R3.D3.Scene){ + return R3.D3.API.Scene; + } + if (runtimeComponent instanceof R3.D3.RigidBody){ + return R3.D3.API.RigidBody; + } + if (runtimeComponent instanceof R3.D3.RenderTarget.Cube){ + return R3.D3.API.RenderTarget.Cube; + } + if (runtimeComponent instanceof R3.D3.RenderTarget){ + return R3.D3.API.RenderTarget; + } + if (runtimeComponent instanceof R3.D3.Raycaster){ + return R3.D3.API.Raycaster; + } + if (runtimeComponent instanceof R3.D3.RaycastWheel){ + return R3.D3.API.RaycastWheel; + } + if (runtimeComponent instanceof R3.D3.RaycastVehicle){ + return R3.D3.API.RaycastVehicle; + } + if (runtimeComponent instanceof R3.D3.PhysicsWorld){ + return R3.D3.API.PhysicsWorld; + } + if (runtimeComponent instanceof R3.D3.Pass.Render.SSAO){ + return R3.D3.API.Pass.Render.SSAO; + } + if (runtimeComponent instanceof R3.D3.Pass.Render){ + return R3.D3.API.Pass.Render; + } + if (runtimeComponent instanceof R3.D3.Pass.FXAA){ + return R3.D3.API.Pass.FXAA; + } + if (runtimeComponent instanceof R3.D3.Pass.Copy){ + return R3.D3.API.Pass.Copy; + } + if (runtimeComponent instanceof R3.D3.Pass.Bloom){ + return R3.D3.API.Pass.Bloom; + } + if (runtimeComponent instanceof R3.D3.Pass){ + return R3.D3.API.Pass; + } + if (runtimeComponent instanceof R3.D3.Mesh.Skeleton){ + return R3.D3.API.Mesh.Skeleton; + } + if (runtimeComponent instanceof R3.D3.Mesh.Particle.Engine){ + return R3.D3.API.Mesh.Particle.Engine; + } + if (runtimeComponent instanceof R3.D3.Mesh.Particle){ + return R3.D3.API.Mesh.Particle; + } + if (runtimeComponent instanceof R3.D3.Mesh){ + return R3.D3.API.Mesh; + } + if (runtimeComponent instanceof R3.D3.Material.Standard){ + return R3.D3.API.Material.Standard; + } + if (runtimeComponent instanceof R3.D3.Material.Shader.Raw){ + return R3.D3.API.Material.Shader.Raw; + } + if (runtimeComponent instanceof R3.D3.Material.Shader){ + return R3.D3.API.Material.Shader; + } + if (runtimeComponent instanceof R3.D3.Material.Points){ + return R3.D3.API.Material.Points; + } + if (runtimeComponent instanceof R3.D3.Material.Phong){ + return R3.D3.API.Material.Phong; + } + if (runtimeComponent instanceof R3.D3.Material.Basic){ + return R3.D3.API.Material.Basic; + } + if (runtimeComponent instanceof R3.D3.Material){ + return R3.D3.API.Material; + } + if (runtimeComponent instanceof R3.D3.Light.Spot){ + return R3.D3.API.Light.Spot; + } + if (runtimeComponent instanceof R3.D3.Light.RectArea){ + return R3.D3.API.Light.RectArea; + } + if (runtimeComponent instanceof R3.D3.Light.Point){ + return R3.D3.API.Light.Point; + } + if (runtimeComponent instanceof R3.D3.Light.Hemisphere){ + return R3.D3.API.Light.Hemisphere; + } + if (runtimeComponent instanceof R3.D3.Light.Directional){ + return R3.D3.API.Light.Directional; + } + if (runtimeComponent instanceof R3.D3.Light.Ambient){ + return R3.D3.API.Light.Ambient; + } + if (runtimeComponent instanceof R3.D3.Light){ + return R3.D3.API.Light; + } + if (runtimeComponent instanceof R3.D3.Helper){ + return R3.D3.API.Helper; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Wireframe){ + return R3.D3.API.Geometry.Normal.Wireframe; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Tube){ + return R3.D3.API.Geometry.Normal.Tube; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.TorusKnot){ + return R3.D3.API.Geometry.Normal.TorusKnot; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Torus){ + return R3.D3.API.Geometry.Normal.Torus; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Text){ + return R3.D3.API.Geometry.Normal.Text; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Tetrahedron){ + return R3.D3.API.Geometry.Normal.Tetrahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Sphere){ + return R3.D3.API.Geometry.Normal.Sphere; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Shape){ + return R3.D3.API.Geometry.Normal.Shape; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Ring){ + return R3.D3.API.Geometry.Normal.Ring; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Polyhedron){ + return R3.D3.API.Geometry.Normal.Polyhedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Plane){ + return R3.D3.API.Geometry.Normal.Plane; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Parametric){ + return R3.D3.API.Geometry.Normal.Parametric; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Octahedron){ + return R3.D3.API.Geometry.Normal.Octahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Lathe){ + return R3.D3.API.Geometry.Normal.Lathe; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Icosahedron){ + return R3.D3.API.Geometry.Normal.Icosahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Extrude){ + return R3.D3.API.Geometry.Normal.Extrude; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Edges){ + return R3.D3.API.Geometry.Normal.Edges; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Dodecahedron){ + return R3.D3.API.Geometry.Normal.Dodecahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Cylinder){ + return R3.D3.API.Geometry.Normal.Cylinder; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Cone){ + return R3.D3.API.Geometry.Normal.Cone; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Circle){ + return R3.D3.API.Geometry.Normal.Circle; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Box){ + return R3.D3.API.Geometry.Normal.Box; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal){ + return R3.D3.API.Geometry.Normal; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Tube){ + return R3.D3.API.Geometry.Buffer.Tube; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.TorusKnot){ + return R3.D3.API.Geometry.Buffer.TorusKnot; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Torus){ + return R3.D3.API.Geometry.Buffer.Torus; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Text){ + return R3.D3.API.Geometry.Buffer.Text; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Tetrahedron){ + return R3.D3.API.Geometry.Buffer.Tetrahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Sphere){ + return R3.D3.API.Geometry.Buffer.Sphere; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Shape){ + return R3.D3.API.Geometry.Buffer.Shape; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Ring){ + return R3.D3.API.Geometry.Buffer.Ring; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Polyhedron){ + return R3.D3.API.Geometry.Buffer.Polyhedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Plane){ + return R3.D3.API.Geometry.Buffer.Plane; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Parametric){ + return R3.D3.API.Geometry.Buffer.Parametric; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Octahedron){ + return R3.D3.API.Geometry.Buffer.Octahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Lathe){ + return R3.D3.API.Geometry.Buffer.Lathe; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Instanced){ + return R3.D3.API.Geometry.Buffer.Instanced; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Icosahedron){ + return R3.D3.API.Geometry.Buffer.Icosahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Extrude){ + return R3.D3.API.Geometry.Buffer.Extrude; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Dodecahedron){ + return R3.D3.API.Geometry.Buffer.Dodecahedron; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Cylinder){ + return R3.D3.API.Geometry.Buffer.Cylinder; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Cone){ + return R3.D3.API.Geometry.Buffer.Cone; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Circle){ + return R3.D3.API.Geometry.Buffer.Circle; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Box){ + return R3.D3.API.Geometry.Buffer.Box; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer){ + return R3.D3.API.Geometry.Buffer; + } + if (runtimeComponent instanceof R3.D3.Geometry){ + return R3.D3.API.Geometry; + } + if (runtimeComponent instanceof R3.D3.FrictionMaterial){ + return R3.D3.API.FrictionMaterial; + } + if (runtimeComponent instanceof R3.D3.FrictionContactMaterial){ + return R3.D3.API.FrictionContactMaterial; + } + if (runtimeComponent instanceof R3.D3.Fog.Normal){ + return R3.D3.API.Fog.Normal; + } + if (runtimeComponent instanceof R3.D3.Fog.Exp){ + return R3.D3.API.Fog.Exp; + } + if (runtimeComponent instanceof R3.D3.Fog){ + return R3.D3.API.Fog; + } + if (runtimeComponent instanceof R3.D3.Face.Graphics){ + return R3.D3.API.Face.Graphics; + } + if (runtimeComponent instanceof R3.D3.Face){ + return R3.D3.API.Face; + } + if (runtimeComponent instanceof R3.D3.Effect.Stereo){ + return R3.D3.API.Effect.Stereo; + } + if (runtimeComponent instanceof R3.D3.Effect.Parallax){ + return R3.D3.API.Effect.Parallax; + } + if (runtimeComponent instanceof R3.D3.Effect.Anaglyph){ + return R3.D3.API.Effect.Anaglyph; + } + if (runtimeComponent instanceof R3.D3.Effect){ + return R3.D3.API.Effect; + } + if (runtimeComponent instanceof R3.D3.Composer){ + return R3.D3.API.Composer; + } + if (runtimeComponent instanceof R3.D3.Camera.Perspective.Stereo){ + return R3.D3.API.Camera.Perspective.Stereo; + } + if (runtimeComponent instanceof R3.D3.Camera.Perspective){ + return R3.D3.API.Camera.Perspective; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic.ScaledAspect){ + return R3.D3.API.Camera.Orthographic.ScaledAspect; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic.FixedAspect){ + return R3.D3.API.Camera.Orthographic.FixedAspect; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic){ + return R3.D3.API.Camera.Orthographic; + } + if (runtimeComponent instanceof R3.D3.Camera.Cube){ + return R3.D3.API.Camera.Cube; + } + if (runtimeComponent instanceof R3.D3.Camera){ + return R3.D3.API.Camera; + } + if (runtimeComponent instanceof R3.D3.Broadphase){ + return R3.D3.API.Broadphase; + } + if (runtimeComponent instanceof R3.D3.BoneWeight){ + return R3.D3.API.BoneWeight; + } + if (runtimeComponent instanceof R3.D3.Bone){ + return R3.D3.API.Bone; + } + if (runtimeComponent instanceof R3.D3.Audio){ + return R3.D3.API.Audio; + } + if (runtimeComponent instanceof R3.D3.Animation){ + return R3.D3.API.Animation; + } + if (runtimeComponent instanceof R3.D3.Object){ + return R3.D3.API.Object; + } + if (runtimeComponent instanceof R3.CustomCode){ + return R3.API.CustomCode; + } + if (runtimeComponent instanceof R3.Curve.Path.D2.Shape){ + return R3.API.Curve.Path.D2.Shape; + } + if (runtimeComponent instanceof R3.Curve.Path.D2){ + return R3.API.Curve.Path.D2; + } + if (runtimeComponent instanceof R3.Curve.Path){ + return R3.API.Curve.Path; + } + if (runtimeComponent instanceof R3.Curve){ + return R3.API.Curve; + } + if (runtimeComponent instanceof R3.Controls.Touch){ + return R3.API.Controls.Touch; + } + if (runtimeComponent instanceof R3.Controls.Mouse){ + return R3.API.Controls.Mouse; + } + if (runtimeComponent instanceof R3.Controls.Keyboard){ + return R3.API.Controls.Keyboard; + } + if (runtimeComponent instanceof R3.Controls.D3.Orbit){ + return R3.API.Controls.D3.Orbit; + } + if (runtimeComponent instanceof R3.Controls.D3.FirstPerson){ + return R3.API.Controls.D3.FirstPerson; + } + if (runtimeComponent instanceof R3.Controls.D3){ + return R3.API.Controls.D3; + } + if (runtimeComponent instanceof R3.Controls){ + return R3.API.Controls; + } + if (runtimeComponent instanceof R3.Color){ + return R3.API.Color; + } + if (runtimeComponent instanceof R3.Clock){ + return R3.API.Clock; + } + if (runtimeComponent instanceof R3.Canvas){ + return R3.API.Canvas; + } + if (runtimeComponent instanceof R3.Box3){ + return R3.API.Box3; + } + throw new Error('Invalid Runtime Constructor : ' + runtimeConstructor); + +}; + +/** + * R3.GetConstructor + * @param apiComponent + * @returns constructor + */ +R3.GetConstructor = function(apiComponent) { + + if (apiComponent instanceof R3.API.Video){ + return R3.Video; + } + if (apiComponent instanceof R3.API.Vector4){ + return R3.Vector4; + } + if (apiComponent instanceof R3.API.Vector3){ + return R3.Vector3; + } + if (apiComponent instanceof R3.API.Vector2){ + return R3.Vector2; + } + if (apiComponent instanceof R3.API.User){ + return R3.User; + } + if (apiComponent instanceof R3.API.Stats){ + return R3.Stats; + } + if (apiComponent instanceof R3.API.Sphere){ + return R3.Sphere; + } + if (apiComponent instanceof R3.API.Socket.Receive){ + return R3.Socket.Receive; + } + if (apiComponent instanceof R3.API.Socket.Cast){ + return R3.Socket.Cast; + } + if (apiComponent instanceof R3.API.Socket){ + return R3.Socket; + } + if (apiComponent instanceof R3.API.Server){ + return R3.Server; + } + if (apiComponent instanceof R3.API.Renderer.D3.Canvas.Target){ + return R3.Renderer.D3.Canvas.Target; + } + if (apiComponent instanceof R3.API.Renderer.D3.Canvas){ + return R3.Renderer.D3.Canvas; + } + if (apiComponent instanceof R3.API.Renderer.D3){ + return R3.Renderer.D3; + } + if (apiComponent instanceof R3.API.Renderer.D2){ + return R3.Renderer.D2; + } + if (apiComponent instanceof R3.API.Renderer){ + return R3.Renderer; + } + if (apiComponent instanceof R3.API.Query.Logins.VPN){ + return R3.Query.Logins.VPN; + } + if (apiComponent instanceof R3.API.Query.Logins.Devices){ + return R3.Query.Logins.Devices; + } + if (apiComponent instanceof R3.API.Query.Logins.Applications){ + return R3.Query.Logins.Applications; + } + if (apiComponent instanceof R3.API.Query.Logins){ + return R3.Query.Logins; + } + if (apiComponent instanceof R3.API.Query.Devices.Unknown){ + return R3.Query.Devices.Unknown; + } + if (apiComponent instanceof R3.API.Query.Devices.Known){ + return R3.Query.Devices.Known; + } + if (apiComponent instanceof R3.API.Query.Devices){ + return R3.Query.Devices; + } + if (apiComponent instanceof R3.API.Query.Alerts.Timeseries){ + return R3.Query.Alerts.Timeseries; + } + if (apiComponent instanceof R3.API.Query.Alerts.Summary){ + return R3.Query.Alerts.Summary; + } + if (apiComponent instanceof R3.API.Query.Alerts.List){ + return R3.Query.Alerts.List; + } + if (apiComponent instanceof R3.API.Query.Alerts.FirstTimeLogin.VPN){ + return R3.Query.Alerts.FirstTimeLogin.VPN; + } + if (apiComponent instanceof R3.API.Query.Alerts.FirstTimeLogin.Devices){ + return R3.Query.Alerts.FirstTimeLogin.Devices; + } + if (apiComponent instanceof R3.API.Query.Alerts.FirstTimeLogin.Applications){ + return R3.Query.Alerts.FirstTimeLogin.Applications; + } + if (apiComponent instanceof R3.API.Query.Alerts.FirstTimeLogin){ + return R3.Query.Alerts.FirstTimeLogin; + } + if (apiComponent instanceof R3.API.Query.Alerts.Buckets){ + return R3.Query.Alerts.Buckets; + } + if (apiComponent instanceof R3.API.Query.Alerts){ + return R3.Query.Alerts; + } + if (apiComponent instanceof R3.API.Query){ + return R3.Query; + } + if (apiComponent instanceof R3.API.Quaternion.Points){ + return R3.Quaternion.Points; + } + if (apiComponent instanceof R3.API.Quaternion){ + return R3.Quaternion; + } + if (apiComponent instanceof R3.API.Project.D3){ + return R3.Project.D3; + } + if (apiComponent instanceof R3.API.Project.D2){ + return R3.Project.D2; + } + if (apiComponent instanceof R3.API.Project){ + return R3.Project; + } + if (apiComponent instanceof R3.API.Plane){ + return R3.Plane; + } + if (apiComponent instanceof R3.API.Mouse){ + return R3.Mouse; + } + if (apiComponent instanceof R3.API.Matrix4){ + return R3.Matrix4; + } + if (apiComponent instanceof R3.API.Image){ + return R3.Image; + } + if (apiComponent instanceof R3.API.GUI){ + return R3.GUI; + } + if (apiComponent instanceof R3.API.Group){ + return R3.Group; + } + if (apiComponent instanceof R3.API.Graph.Table){ + return R3.Graph.Table; + } + if (apiComponent instanceof R3.API.Graph.Metric){ + return R3.Graph.Metric; + } + if (apiComponent instanceof R3.API.Graph.Barchart.Stacked){ + return R3.Graph.Barchart.Stacked; + } + if (apiComponent instanceof R3.API.Graph.Barchart){ + return R3.Graph.Barchart; + } + if (apiComponent instanceof R3.API.Graph){ + return R3.Graph; + } + if (apiComponent instanceof R3.API.Font){ + return R3.Font; + } + if (apiComponent instanceof R3.API.Entity){ + return R3.Entity; + } + if (apiComponent instanceof R3.API.DrawRange){ + return R3.DrawRange; + } + if (apiComponent instanceof R3.API.DomElement){ + return R3.DomElement; + } + if (apiComponent instanceof R3.D3.API.Viewport.ZoomedAspect){ + return R3.D3.Viewport.ZoomedAspect; + } + if (apiComponent instanceof R3.D3.API.Viewport.FixedAspect){ + return R3.D3.Viewport.FixedAspect; + } + if (apiComponent instanceof R3.D3.API.Viewport){ + return R3.D3.Viewport; + } + if (apiComponent instanceof R3.D3.API.Vertex){ + return R3.D3.Vertex; + } + if (apiComponent instanceof R3.D3.API.Texture.Image){ + return R3.D3.Texture.Image; + } + if (apiComponent instanceof R3.D3.API.Texture.Cube){ + return R3.D3.Texture.Cube; + } + if (apiComponent instanceof R3.D3.API.Texture.Canvas){ + return R3.D3.Texture.Canvas; + } + if (apiComponent instanceof R3.D3.API.Texture){ + return R3.D3.Texture; + } + if (apiComponent instanceof R3.D3.API.Text){ + return R3.D3.Text; + } + if (apiComponent instanceof R3.D3.API.Spline){ + return R3.D3.Spline; + } + if (apiComponent instanceof R3.D3.API.Solver){ + return R3.D3.Solver; + } + if (apiComponent instanceof R3.D3.API.Skeleton){ + return R3.D3.Skeleton; + } + if (apiComponent instanceof R3.D3.API.Shape.TriMesh){ + return R3.D3.Shape.TriMesh; + } + if (apiComponent instanceof R3.D3.API.Shape.Sphere){ + return R3.D3.Shape.Sphere; + } + if (apiComponent instanceof R3.D3.API.Shape.Plane){ + return R3.D3.Shape.Plane; + } + if (apiComponent instanceof R3.D3.API.Shape.HeightMap){ + return R3.D3.Shape.HeightMap; + } + if (apiComponent instanceof R3.D3.API.Shape.ConvexHull.Cylinder){ + return R3.D3.Shape.ConvexHull.Cylinder; + } + if (apiComponent instanceof R3.D3.API.Shape.ConvexHull){ + return R3.D3.Shape.ConvexHull; + } + if (apiComponent instanceof R3.D3.API.Shape.Box){ + return R3.D3.Shape.Box; + } + if (apiComponent instanceof R3.D3.API.Shape){ + return R3.D3.Shape; + } + if (apiComponent instanceof R3.D3.API.Shadow.Spot){ + return R3.D3.Shadow.Spot; + } + if (apiComponent instanceof R3.D3.API.Shadow.Directional){ + return R3.D3.Shadow.Directional; + } + if (apiComponent instanceof R3.D3.API.Shadow){ + return R3.D3.Shadow; + } + if (apiComponent instanceof R3.D3.API.Shader.Vertex){ + return R3.D3.Shader.Vertex; + } + if (apiComponent instanceof R3.D3.API.Shader.Fragment){ + return R3.D3.Shader.Fragment; + } + if (apiComponent instanceof R3.D3.API.Shader){ + return R3.D3.Shader; + } + if (apiComponent instanceof R3.D3.API.Scene){ + return R3.D3.Scene; + } + if (apiComponent instanceof R3.D3.API.RigidBody){ + return R3.D3.RigidBody; + } + if (apiComponent instanceof R3.D3.API.RenderTarget.Cube){ + return R3.D3.RenderTarget.Cube; + } + if (apiComponent instanceof R3.D3.API.RenderTarget){ + return R3.D3.RenderTarget; + } + if (apiComponent instanceof R3.D3.API.Raycaster){ + return R3.D3.Raycaster; + } + if (apiComponent instanceof R3.D3.API.RaycastWheel){ + return R3.D3.RaycastWheel; + } + if (apiComponent instanceof R3.D3.API.RaycastVehicle){ + return R3.D3.RaycastVehicle; + } + if (apiComponent instanceof R3.D3.API.PhysicsWorld){ + return R3.D3.PhysicsWorld; + } + if (apiComponent instanceof R3.D3.API.Pass.Render.SSAO){ + return R3.D3.Pass.Render.SSAO; + } + if (apiComponent instanceof R3.D3.API.Pass.Render){ + return R3.D3.Pass.Render; + } + if (apiComponent instanceof R3.D3.API.Pass.FXAA){ + return R3.D3.Pass.FXAA; + } + if (apiComponent instanceof R3.D3.API.Pass.Copy){ + return R3.D3.Pass.Copy; + } + if (apiComponent instanceof R3.D3.API.Pass.Bloom){ + return R3.D3.Pass.Bloom; + } + if (apiComponent instanceof R3.D3.API.Pass){ + return R3.D3.Pass; + } + if (apiComponent instanceof R3.D3.API.Mesh.Skeleton){ + return R3.D3.Mesh.Skeleton; + } + if (apiComponent instanceof R3.D3.API.Mesh.Particle.Engine){ + return R3.D3.Mesh.Particle.Engine; + } + if (apiComponent instanceof R3.D3.API.Mesh.Particle){ + return R3.D3.Mesh.Particle; + } + if (apiComponent instanceof R3.D3.API.Mesh){ + return R3.D3.Mesh; + } + if (apiComponent instanceof R3.D3.API.Material.Standard){ + return R3.D3.Material.Standard; + } + if (apiComponent instanceof R3.D3.API.Material.Shader.Raw){ + return R3.D3.Material.Shader.Raw; + } + if (apiComponent instanceof R3.D3.API.Material.Shader){ + return R3.D3.Material.Shader; + } + if (apiComponent instanceof R3.D3.API.Material.Points){ + return R3.D3.Material.Points; + } + if (apiComponent instanceof R3.D3.API.Material.Phong){ + return R3.D3.Material.Phong; + } + if (apiComponent instanceof R3.D3.API.Material.Basic){ + return R3.D3.Material.Basic; + } + if (apiComponent instanceof R3.D3.API.Material){ + return R3.D3.Material; + } + if (apiComponent instanceof R3.D3.API.Light.Spot){ + return R3.D3.Light.Spot; + } + if (apiComponent instanceof R3.D3.API.Light.RectArea){ + return R3.D3.Light.RectArea; + } + if (apiComponent instanceof R3.D3.API.Light.Point){ + return R3.D3.Light.Point; + } + if (apiComponent instanceof R3.D3.API.Light.Hemisphere){ + return R3.D3.Light.Hemisphere; + } + if (apiComponent instanceof R3.D3.API.Light.Directional){ + return R3.D3.Light.Directional; + } + if (apiComponent instanceof R3.D3.API.Light.Ambient){ + return R3.D3.Light.Ambient; + } + if (apiComponent instanceof R3.D3.API.Light){ + return R3.D3.Light; + } + if (apiComponent instanceof R3.D3.API.Helper){ + return R3.D3.Helper; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Wireframe){ + return R3.D3.Geometry.Normal.Wireframe; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Tube){ + return R3.D3.Geometry.Normal.Tube; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.TorusKnot){ + return R3.D3.Geometry.Normal.TorusKnot; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Torus){ + return R3.D3.Geometry.Normal.Torus; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Text){ + return R3.D3.Geometry.Normal.Text; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Tetrahedron){ + return R3.D3.Geometry.Normal.Tetrahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Sphere){ + return R3.D3.Geometry.Normal.Sphere; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Shape){ + return R3.D3.Geometry.Normal.Shape; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Ring){ + return R3.D3.Geometry.Normal.Ring; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Polyhedron){ + return R3.D3.Geometry.Normal.Polyhedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Plane){ + return R3.D3.Geometry.Normal.Plane; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Parametric){ + return R3.D3.Geometry.Normal.Parametric; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Octahedron){ + return R3.D3.Geometry.Normal.Octahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Lathe){ + return R3.D3.Geometry.Normal.Lathe; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Icosahedron){ + return R3.D3.Geometry.Normal.Icosahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Extrude){ + return R3.D3.Geometry.Normal.Extrude; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Edges){ + return R3.D3.Geometry.Normal.Edges; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Dodecahedron){ + return R3.D3.Geometry.Normal.Dodecahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Cylinder){ + return R3.D3.Geometry.Normal.Cylinder; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Cone){ + return R3.D3.Geometry.Normal.Cone; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Circle){ + return R3.D3.Geometry.Normal.Circle; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal.Box){ + return R3.D3.Geometry.Normal.Box; + } + if (apiComponent instanceof R3.D3.API.Geometry.Normal){ + return R3.D3.Geometry.Normal; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Tube){ + return R3.D3.Geometry.Buffer.Tube; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.TorusKnot){ + return R3.D3.Geometry.Buffer.TorusKnot; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Torus){ + return R3.D3.Geometry.Buffer.Torus; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Text){ + return R3.D3.Geometry.Buffer.Text; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Tetrahedron){ + return R3.D3.Geometry.Buffer.Tetrahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Sphere){ + return R3.D3.Geometry.Buffer.Sphere; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Shape){ + return R3.D3.Geometry.Buffer.Shape; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Ring){ + return R3.D3.Geometry.Buffer.Ring; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Polyhedron){ + return R3.D3.Geometry.Buffer.Polyhedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Plane){ + return R3.D3.Geometry.Buffer.Plane; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Parametric){ + return R3.D3.Geometry.Buffer.Parametric; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Octahedron){ + return R3.D3.Geometry.Buffer.Octahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Lathe){ + return R3.D3.Geometry.Buffer.Lathe; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Instanced){ + return R3.D3.Geometry.Buffer.Instanced; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Icosahedron){ + return R3.D3.Geometry.Buffer.Icosahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Extrude){ + return R3.D3.Geometry.Buffer.Extrude; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Dodecahedron){ + return R3.D3.Geometry.Buffer.Dodecahedron; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Cylinder){ + return R3.D3.Geometry.Buffer.Cylinder; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Cone){ + return R3.D3.Geometry.Buffer.Cone; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Circle){ + return R3.D3.Geometry.Buffer.Circle; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer.Box){ + return R3.D3.Geometry.Buffer.Box; + } + if (apiComponent instanceof R3.D3.API.Geometry.Buffer){ + return R3.D3.Geometry.Buffer; + } + if (apiComponent instanceof R3.D3.API.Geometry){ + return R3.D3.Geometry; + } + if (apiComponent instanceof R3.D3.API.FrictionMaterial){ + return R3.D3.FrictionMaterial; + } + if (apiComponent instanceof R3.D3.API.FrictionContactMaterial){ + return R3.D3.FrictionContactMaterial; + } + if (apiComponent instanceof R3.D3.API.Fog.Normal){ + return R3.D3.Fog.Normal; + } + if (apiComponent instanceof R3.D3.API.Fog.Exp){ + return R3.D3.Fog.Exp; + } + if (apiComponent instanceof R3.D3.API.Fog){ + return R3.D3.Fog; + } + if (apiComponent instanceof R3.D3.API.Face.Graphics){ + return R3.D3.Face.Graphics; + } + if (apiComponent instanceof R3.D3.API.Face){ + return R3.D3.Face; + } + if (apiComponent instanceof R3.D3.API.Effect.Stereo){ + return R3.D3.Effect.Stereo; + } + if (apiComponent instanceof R3.D3.API.Effect.Parallax){ + return R3.D3.Effect.Parallax; + } + if (apiComponent instanceof R3.D3.API.Effect.Anaglyph){ + return R3.D3.Effect.Anaglyph; + } + if (apiComponent instanceof R3.D3.API.Effect){ + return R3.D3.Effect; + } + if (apiComponent instanceof R3.D3.API.Composer){ + return R3.D3.Composer; + } + if (apiComponent instanceof R3.D3.API.Camera.Perspective.Stereo){ + return R3.D3.Camera.Perspective.Stereo; + } + if (apiComponent instanceof R3.D3.API.Camera.Perspective){ + return R3.D3.Camera.Perspective; + } + if (apiComponent instanceof R3.D3.API.Camera.Orthographic.ScaledAspect){ + return R3.D3.Camera.Orthographic.ScaledAspect; + } + if (apiComponent instanceof R3.D3.API.Camera.Orthographic.FixedAspect){ + return R3.D3.Camera.Orthographic.FixedAspect; + } + if (apiComponent instanceof R3.D3.API.Camera.Orthographic){ + return R3.D3.Camera.Orthographic; + } + if (apiComponent instanceof R3.D3.API.Camera.Cube){ + return R3.D3.Camera.Cube; + } + if (apiComponent instanceof R3.D3.API.Camera){ + return R3.D3.Camera; + } + if (apiComponent instanceof R3.D3.API.Broadphase){ + return R3.D3.Broadphase; + } + if (apiComponent instanceof R3.D3.API.BoneWeight){ + return R3.D3.BoneWeight; + } + if (apiComponent instanceof R3.D3.API.Bone){ + return R3.D3.Bone; + } + if (apiComponent instanceof R3.D3.API.Audio){ + return R3.D3.Audio; + } + if (apiComponent instanceof R3.D3.API.Animation){ + return R3.D3.Animation; + } + if (apiComponent instanceof R3.D3.API.Object){ + return R3.D3.Object; + } + if (apiComponent instanceof R3.API.CustomCode){ + return R3.CustomCode; + } + if (apiComponent instanceof R3.API.Curve.Path.D2.Shape){ + return R3.Curve.Path.D2.Shape; + } + if (apiComponent instanceof R3.API.Curve.Path.D2){ + return R3.Curve.Path.D2; + } + if (apiComponent instanceof R3.API.Curve.Path){ + return R3.Curve.Path; + } + if (apiComponent instanceof R3.API.Curve){ + return R3.Curve; + } + if (apiComponent instanceof R3.API.Controls.Touch){ + return R3.Controls.Touch; + } + if (apiComponent instanceof R3.API.Controls.Mouse){ + return R3.Controls.Mouse; + } + if (apiComponent instanceof R3.API.Controls.Keyboard){ + return R3.Controls.Keyboard; + } + if (apiComponent instanceof R3.API.Controls.D3.Orbit){ + return R3.Controls.D3.Orbit; + } + if (apiComponent instanceof R3.API.Controls.D3.FirstPerson){ + return R3.Controls.D3.FirstPerson; + } + if (apiComponent instanceof R3.API.Controls.D3){ + return R3.Controls.D3; + } + if (apiComponent instanceof R3.API.Controls){ + return R3.Controls; + } + if (apiComponent instanceof R3.API.Color){ + return R3.Color; + } + if (apiComponent instanceof R3.API.Clock){ + return R3.Clock; + } + if (apiComponent instanceof R3.API.Canvas){ + return R3.Canvas; + } + if (apiComponent instanceof R3.API.Box3){ + return R3.Box3; + } + throw new Error('Invalid API Constructor : ' + apiConstructor); + +}; + +/** + * R3.GetConstructorFromComponentType + * @param componentType + * @returns constructor + */ +R3.GetConstructorFromComponentType = function(componentType) { + + switch (componentType) { + + case R3.COMPONENT_VIDEO: return R3.Video; + case R3.COMPONENT_VECTOR4: return R3.Vector4; + case R3.COMPONENT_VECTOR3: return R3.Vector3; + case R3.COMPONENT_VECTOR2: return R3.Vector2; + case R3.COMPONENT_USER: return R3.User; + case R3.COMPONENT_STATS: return R3.Stats; + case R3.COMPONENT_SPHERE: return R3.Sphere; + case R3.COMPONENT_SOCKET_RECEIVE: return R3.Socket.Receive; + case R3.COMPONENT_SOCKET_CAST: return R3.Socket.Cast; + case R3.COMPONENT_SOCKET: return R3.Socket; + case R3.COMPONENT_SERVER: return R3.Server; + case R3.COMPONENT_RENDERER_D3_CANVAS_TARGET: return R3.Renderer.D3.Canvas.Target; + case R3.COMPONENT_RENDERER_D3_CANVAS: return R3.Renderer.D3.Canvas; + case R3.COMPONENT_RENDERER_D3: return R3.Renderer.D3; + case R3.COMPONENT_RENDERER_D2: return R3.Renderer.D2; + case R3.COMPONENT_RENDERER: return R3.Renderer; + case R3.COMPONENT_QUERY_LOGINS_VPN: return R3.Query.Logins.VPN; + case R3.COMPONENT_QUERY_LOGINS_DEVICES: return R3.Query.Logins.Devices; + case R3.COMPONENT_QUERY_LOGINS_APPLICATIONS: return R3.Query.Logins.Applications; + case R3.COMPONENT_QUERY_LOGINS: return R3.Query.Logins; + case R3.COMPONENT_QUERY_DEVICES_UNKNOWN: return R3.Query.Devices.Unknown; + case R3.COMPONENT_QUERY_DEVICES_KNOWN: return R3.Query.Devices.Known; + case R3.COMPONENT_QUERY_DEVICES: return R3.Query.Devices; + case R3.COMPONENT_QUERY_ALERTS_TIMESERIES: return R3.Query.Alerts.Timeseries; + case R3.COMPONENT_QUERY_ALERTS_SUMMARY: return R3.Query.Alerts.Summary; + case R3.COMPONENT_QUERY_ALERTS_LIST: return R3.Query.Alerts.List; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_VPN: return R3.Query.Alerts.FirstTimeLogin.VPN; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_DEVICES: return R3.Query.Alerts.FirstTimeLogin.Devices; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN_APPLICATIONS: return R3.Query.Alerts.FirstTimeLogin.Applications; + case R3.COMPONENT_QUERY_ALERTS_FIRSTTIMELOGIN: return R3.Query.Alerts.FirstTimeLogin; + case R3.COMPONENT_QUERY_ALERTS_BUCKETS: return R3.Query.Alerts.Buckets; + case R3.COMPONENT_QUERY_ALERTS: return R3.Query.Alerts; + case R3.COMPONENT_QUERY: return R3.Query; + case R3.COMPONENT_QUATERNION_POINTS: return R3.Quaternion.Points; + case R3.COMPONENT_QUATERNION: return R3.Quaternion; + case R3.COMPONENT_PROJECT_D3: return R3.Project.D3; + case R3.COMPONENT_PROJECT_D2: return R3.Project.D2; + case R3.COMPONENT_PROJECT: return R3.Project; + case R3.COMPONENT_PLANE: return R3.Plane; + case R3.COMPONENT_MOUSE: return R3.Mouse; + case R3.COMPONENT_MATRIX4: return R3.Matrix4; + case R3.COMPONENT_IMAGE: return R3.Image; + case R3.COMPONENT_GUI: return R3.GUI; + case R3.COMPONENT_GROUP: return R3.Group; + case R3.COMPONENT_GRAPH_TABLE: return R3.Graph.Table; + case R3.COMPONENT_GRAPH_METRIC: return R3.Graph.Metric; + case R3.COMPONENT_GRAPH_BARCHART_STACKED: return R3.Graph.Barchart.Stacked; + case R3.COMPONENT_GRAPH_BARCHART: return R3.Graph.Barchart; + case R3.COMPONENT_GRAPH: return R3.Graph; + case R3.COMPONENT_FONT: return R3.Font; + case R3.COMPONENT_ENTITY: return R3.Entity; + case R3.COMPONENT_DRAWRANGE: return R3.DrawRange; + case R3.COMPONENT_DOMELEMENT: return R3.DomElement; + case R3.COMPONENT_D3_VIEWPORT_ZOOMEDASPECT: return R3.D3.Viewport.ZoomedAspect; + case R3.COMPONENT_D3_VIEWPORT_FIXEDASPECT: return R3.D3.Viewport.FixedAspect; + case R3.COMPONENT_D3_VIEWPORT: return R3.D3.Viewport; + case R3.COMPONENT_D3_VERTEX: return R3.D3.Vertex; + case R3.COMPONENT_D3_TEXTURE_IMAGE: return R3.D3.Texture.Image; + case R3.COMPONENT_D3_TEXTURE_CUBE: return R3.D3.Texture.Cube; + case R3.COMPONENT_D3_TEXTURE_CANVAS: return R3.D3.Texture.Canvas; + case R3.COMPONENT_D3_TEXTURE: return R3.D3.Texture; + case R3.COMPONENT_D3_TEXT: return R3.D3.Text; + case R3.COMPONENT_D3_SPLINE: return R3.D3.Spline; + case R3.COMPONENT_D3_SOLVER: return R3.D3.Solver; + case R3.COMPONENT_D3_SKELETON: return R3.D3.Skeleton; + case R3.COMPONENT_D3_SHAPE_TRIMESH: return R3.D3.Shape.TriMesh; + case R3.COMPONENT_D3_SHAPE_SPHERE: return R3.D3.Shape.Sphere; + case R3.COMPONENT_D3_SHAPE_PLANE: return R3.D3.Shape.Plane; + case R3.COMPONENT_D3_SHAPE_HEIGHTMAP: return R3.D3.Shape.HeightMap; + case R3.COMPONENT_D3_SHAPE_CONVEXHULL_CYLINDER: return R3.D3.Shape.ConvexHull.Cylinder; + case R3.COMPONENT_D3_SHAPE_CONVEXHULL: return R3.D3.Shape.ConvexHull; + case R3.COMPONENT_D3_SHAPE_BOX: return R3.D3.Shape.Box; + case R3.COMPONENT_D3_SHAPE: return R3.D3.Shape; + case R3.COMPONENT_D3_SHADOW_SPOT: return R3.D3.Shadow.Spot; + case R3.COMPONENT_D3_SHADOW_DIRECTIONAL: return R3.D3.Shadow.Directional; + case R3.COMPONENT_D3_SHADOW: return R3.D3.Shadow; + case R3.COMPONENT_D3_SHADER_VERTEX: return R3.D3.Shader.Vertex; + case R3.COMPONENT_D3_SHADER_FRAGMENT: return R3.D3.Shader.Fragment; + case R3.COMPONENT_D3_SHADER: return R3.D3.Shader; + case R3.COMPONENT_D3_SCENE: return R3.D3.Scene; + case R3.COMPONENT_D3_RIGIDBODY: return R3.D3.RigidBody; + case R3.COMPONENT_D3_RENDERTARGET_CUBE: return R3.D3.RenderTarget.Cube; + case R3.COMPONENT_D3_RENDERTARGET: return R3.D3.RenderTarget; + case R3.COMPONENT_D3_RAYCASTER: return R3.D3.Raycaster; + case R3.COMPONENT_D3_RAYCASTWHEEL: return R3.D3.RaycastWheel; + case R3.COMPONENT_D3_RAYCASTVEHICLE: return R3.D3.RaycastVehicle; + case R3.COMPONENT_D3_PHYSICSWORLD: return R3.D3.PhysicsWorld; + case R3.COMPONENT_D3_PASS_RENDER_SSAO: return R3.D3.Pass.Render.SSAO; + case R3.COMPONENT_D3_PASS_RENDER: return R3.D3.Pass.Render; + case R3.COMPONENT_D3_PASS_FXAA: return R3.D3.Pass.FXAA; + case R3.COMPONENT_D3_PASS_COPY: return R3.D3.Pass.Copy; + case R3.COMPONENT_D3_PASS_BLOOM: return R3.D3.Pass.Bloom; + case R3.COMPONENT_D3_PASS: return R3.D3.Pass; + case R3.COMPONENT_D3_MESH_SKELETON: return R3.D3.Mesh.Skeleton; + case R3.COMPONENT_D3_MESH_PARTICLE_ENGINE: return R3.D3.Mesh.Particle.Engine; + case R3.COMPONENT_D3_MESH_PARTICLE: return R3.D3.Mesh.Particle; + case R3.COMPONENT_D3_MESH: return R3.D3.Mesh; + case R3.COMPONENT_D3_MATERIAL_STANDARD: return R3.D3.Material.Standard; + case R3.COMPONENT_D3_MATERIAL_SHADER_RAW: return R3.D3.Material.Shader.Raw; + case R3.COMPONENT_D3_MATERIAL_SHADER: return R3.D3.Material.Shader; + case R3.COMPONENT_D3_MATERIAL_POINTS: return R3.D3.Material.Points; + case R3.COMPONENT_D3_MATERIAL_PHONG: return R3.D3.Material.Phong; + case R3.COMPONENT_D3_MATERIAL_BASIC: return R3.D3.Material.Basic; + case R3.COMPONENT_D3_MATERIAL: return R3.D3.Material; + case R3.COMPONENT_D3_LIGHT_SPOT: return R3.D3.Light.Spot; + case R3.COMPONENT_D3_LIGHT_RECTAREA: return R3.D3.Light.RectArea; + case R3.COMPONENT_D3_LIGHT_POINT: return R3.D3.Light.Point; + case R3.COMPONENT_D3_LIGHT_HEMISPHERE: return R3.D3.Light.Hemisphere; + case R3.COMPONENT_D3_LIGHT_DIRECTIONAL: return R3.D3.Light.Directional; + case R3.COMPONENT_D3_LIGHT_AMBIENT: return R3.D3.Light.Ambient; + case R3.COMPONENT_D3_LIGHT: return R3.D3.Light; + case R3.COMPONENT_D3_HELPER: return R3.D3.Helper; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_WIREFRAME: return R3.D3.Geometry.Normal.Wireframe; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TUBE: return R3.D3.Geometry.Normal.Tube; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUSKNOT: return R3.D3.Geometry.Normal.TorusKnot; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TORUS: return R3.D3.Geometry.Normal.Torus; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TEXT: return R3.D3.Geometry.Normal.Text; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_TETRAHEDRON: return R3.D3.Geometry.Normal.Tetrahedron; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_SPHERE: return R3.D3.Geometry.Normal.Sphere; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_SHAPE: return R3.D3.Geometry.Normal.Shape; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_RING: return R3.D3.Geometry.Normal.Ring; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_POLYHEDRON: return R3.D3.Geometry.Normal.Polyhedron; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_PLANE: return R3.D3.Geometry.Normal.Plane; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_PARAMETRIC: return R3.D3.Geometry.Normal.Parametric; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_OCTAHEDRON: return R3.D3.Geometry.Normal.Octahedron; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_LATHE: return R3.D3.Geometry.Normal.Lathe; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_ICOSAHEDRON: return R3.D3.Geometry.Normal.Icosahedron; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_EXTRUDE: return R3.D3.Geometry.Normal.Extrude; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_EDGES: return R3.D3.Geometry.Normal.Edges; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_DODECAHEDRON: return R3.D3.Geometry.Normal.Dodecahedron; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CYLINDER: return R3.D3.Geometry.Normal.Cylinder; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CONE: return R3.D3.Geometry.Normal.Cone; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_CIRCLE: return R3.D3.Geometry.Normal.Circle; + case R3.COMPONENT_D3_GEOMETRY_NORMAL_BOX: return R3.D3.Geometry.Normal.Box; + case R3.COMPONENT_D3_GEOMETRY_NORMAL: return R3.D3.Geometry.Normal; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TUBE: return R3.D3.Geometry.Buffer.Tube; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUSKNOT: return R3.D3.Geometry.Buffer.TorusKnot; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TORUS: return R3.D3.Geometry.Buffer.Torus; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TEXT: return R3.D3.Geometry.Buffer.Text; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_TETRAHEDRON: return R3.D3.Geometry.Buffer.Tetrahedron; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_SPHERE: return R3.D3.Geometry.Buffer.Sphere; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_SHAPE: return R3.D3.Geometry.Buffer.Shape; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_RING: return R3.D3.Geometry.Buffer.Ring; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_POLYHEDRON: return R3.D3.Geometry.Buffer.Polyhedron; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_PLANE: return R3.D3.Geometry.Buffer.Plane; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_PARAMETRIC: return R3.D3.Geometry.Buffer.Parametric; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_OCTAHEDRON: return R3.D3.Geometry.Buffer.Octahedron; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_LATHE: return R3.D3.Geometry.Buffer.Lathe; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_INSTANCED: return R3.D3.Geometry.Buffer.Instanced; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_ICOSAHEDRON: return R3.D3.Geometry.Buffer.Icosahedron; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_EXTRUDE: return R3.D3.Geometry.Buffer.Extrude; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_DODECAHEDRON: return R3.D3.Geometry.Buffer.Dodecahedron; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CYLINDER: return R3.D3.Geometry.Buffer.Cylinder; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CONE: return R3.D3.Geometry.Buffer.Cone; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_CIRCLE: return R3.D3.Geometry.Buffer.Circle; + case R3.COMPONENT_D3_GEOMETRY_BUFFER_BOX: return R3.D3.Geometry.Buffer.Box; + case R3.COMPONENT_D3_GEOMETRY_BUFFER: return R3.D3.Geometry.Buffer; + case R3.COMPONENT_D3_GEOMETRY: return R3.D3.Geometry; + case R3.COMPONENT_D3_FRICTIONMATERIAL: return R3.D3.FrictionMaterial; + case R3.COMPONENT_D3_FRICTIONCONTACTMATERIAL: return R3.D3.FrictionContactMaterial; + case R3.COMPONENT_D3_FOG_NORMAL: return R3.D3.Fog.Normal; + case R3.COMPONENT_D3_FOG_EXP: return R3.D3.Fog.Exp; + case R3.COMPONENT_D3_FOG: return R3.D3.Fog; + case R3.COMPONENT_D3_FACE_GRAPHICS: return R3.D3.Face.Graphics; + case R3.COMPONENT_D3_FACE: return R3.D3.Face; + case R3.COMPONENT_D3_EFFECT_STEREO: return R3.D3.Effect.Stereo; + case R3.COMPONENT_D3_EFFECT_PARALLAX: return R3.D3.Effect.Parallax; + case R3.COMPONENT_D3_EFFECT_ANAGLYPH: return R3.D3.Effect.Anaglyph; + case R3.COMPONENT_D3_EFFECT: return R3.D3.Effect; + case R3.COMPONENT_D3_COMPOSER: return R3.D3.Composer; + case R3.COMPONENT_D3_CAMERA_PERSPECTIVE_STEREO: return R3.D3.Camera.Perspective.Stereo; + case R3.COMPONENT_D3_CAMERA_PERSPECTIVE: return R3.D3.Camera.Perspective; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_SCALEDASPECT: return R3.D3.Camera.Orthographic.ScaledAspect; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC_FIXEDASPECT: return R3.D3.Camera.Orthographic.FixedAspect; + case R3.COMPONENT_D3_CAMERA_ORTHOGRAPHIC: return R3.D3.Camera.Orthographic; + case R3.COMPONENT_D3_CAMERA_CUBE: return R3.D3.Camera.Cube; + case R3.COMPONENT_D3_CAMERA: return R3.D3.Camera; + case R3.COMPONENT_D3_BROADPHASE: return R3.D3.Broadphase; + case R3.COMPONENT_D3_BONEWEIGHT: return R3.D3.BoneWeight; + case R3.COMPONENT_D3_BONE: return R3.D3.Bone; + case R3.COMPONENT_D3_AUDIO: return R3.D3.Audio; + case R3.COMPONENT_D3_ANIMATION: return R3.D3.Animation; + case R3.COMPONENT_D3_OBJECT: return R3.D3.Object; + case R3.COMPONENT_CUSTOMCODE: return R3.CustomCode; + case R3.COMPONENT_CURVE_PATH_D2_SHAPE: return R3.Curve.Path.D2.Shape; + case R3.COMPONENT_CURVE_PATH_D2: return R3.Curve.Path.D2; + case R3.COMPONENT_CURVE_PATH: return R3.Curve.Path; + case R3.COMPONENT_CURVE: return R3.Curve; + case R3.COMPONENT_CONTROLS_TOUCH: return R3.Controls.Touch; + case R3.COMPONENT_CONTROLS_MOUSE: return R3.Controls.Mouse; + case R3.COMPONENT_CONTROLS_KEYBOARD: return R3.Controls.Keyboard; + case R3.COMPONENT_CONTROLS_D3_ORBIT: return R3.Controls.D3.Orbit; + case R3.COMPONENT_CONTROLS_D3_FIRSTPERSON: return R3.Controls.D3.FirstPerson; + case R3.COMPONENT_CONTROLS_D3: return R3.Controls.D3; + case R3.COMPONENT_CONTROLS: return R3.Controls; + case R3.COMPONENT_COLOR: return R3.Color; + case R3.COMPONENT_CLOCK: return R3.Clock; + case R3.COMPONENT_CANVAS: return R3.Canvas; + case R3.COMPONENT_BOX3: return R3.Box3; + default : + throw new Error('Invalid componentType : ' + componentType); + + } +}; + +/** + * R3.GetComponentName + * @param runtimeComponent + * @returns string + */ +R3.GetComponentName = function(runtimeComponent) { + + if (runtimeComponent instanceof R3.Video){ + return 'R3.Video'; + } + if (runtimeComponent instanceof R3.Vector4){ + return 'R3.Vector4'; + } + if (runtimeComponent instanceof R3.Vector3){ + return 'R3.Vector3'; + } + if (runtimeComponent instanceof R3.Vector2){ + return 'R3.Vector2'; + } + if (runtimeComponent instanceof R3.User){ + return 'R3.User'; + } + if (runtimeComponent instanceof R3.Stats){ + return 'R3.Stats'; + } + if (runtimeComponent instanceof R3.Sphere){ + return 'R3.Sphere'; + } + if (runtimeComponent instanceof R3.Socket.Receive){ + return 'R3.Socket.Receive'; + } + if (runtimeComponent instanceof R3.Socket.Cast){ + return 'R3.Socket.Cast'; + } + if (runtimeComponent instanceof R3.Socket){ + return 'R3.Socket'; + } + if (runtimeComponent instanceof R3.Server){ + return 'R3.Server'; + } + if (runtimeComponent instanceof R3.Renderer.D3.Canvas.Target){ + return 'R3.Renderer.D3.Canvas.Target'; + } + if (runtimeComponent instanceof R3.Renderer.D3.Canvas){ + return 'R3.Renderer.D3.Canvas'; + } + if (runtimeComponent instanceof R3.Renderer.D3){ + return 'R3.Renderer.D3'; + } + if (runtimeComponent instanceof R3.Renderer.D2){ + return 'R3.Renderer.D2'; + } + if (runtimeComponent instanceof R3.Renderer){ + return 'R3.Renderer'; + } + if (runtimeComponent instanceof R3.Query.Logins.VPN){ + return 'R3.Query.Logins.VPN'; + } + if (runtimeComponent instanceof R3.Query.Logins.Devices){ + return 'R3.Query.Logins.Devices'; + } + if (runtimeComponent instanceof R3.Query.Logins.Applications){ + return 'R3.Query.Logins.Applications'; + } + if (runtimeComponent instanceof R3.Query.Logins){ + return 'R3.Query.Logins'; + } + if (runtimeComponent instanceof R3.Query.Devices.Unknown){ + return 'R3.Query.Devices.Unknown'; + } + if (runtimeComponent instanceof R3.Query.Devices.Known){ + return 'R3.Query.Devices.Known'; + } + if (runtimeComponent instanceof R3.Query.Devices){ + return 'R3.Query.Devices'; + } + if (runtimeComponent instanceof R3.Query.Alerts.Timeseries){ + return 'R3.Query.Alerts.Timeseries'; + } + if (runtimeComponent instanceof R3.Query.Alerts.Summary){ + return 'R3.Query.Alerts.Summary'; + } + if (runtimeComponent instanceof R3.Query.Alerts.List){ + return 'R3.Query.Alerts.List'; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.VPN){ + return 'R3.Query.Alerts.FirstTimeLogin.VPN'; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.Devices){ + return 'R3.Query.Alerts.FirstTimeLogin.Devices'; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin.Applications){ + return 'R3.Query.Alerts.FirstTimeLogin.Applications'; + } + if (runtimeComponent instanceof R3.Query.Alerts.FirstTimeLogin){ + return 'R3.Query.Alerts.FirstTimeLogin'; + } + if (runtimeComponent instanceof R3.Query.Alerts.Buckets){ + return 'R3.Query.Alerts.Buckets'; + } + if (runtimeComponent instanceof R3.Query.Alerts){ + return 'R3.Query.Alerts'; + } + if (runtimeComponent instanceof R3.Query){ + return 'R3.Query'; + } + if (runtimeComponent instanceof R3.Quaternion.Points){ + return 'R3.Quaternion.Points'; + } + if (runtimeComponent instanceof R3.Quaternion){ + return 'R3.Quaternion'; + } + if (runtimeComponent instanceof R3.Project.D3){ + return 'R3.Project.D3'; + } + if (runtimeComponent instanceof R3.Project.D2){ + return 'R3.Project.D2'; + } + if (runtimeComponent instanceof R3.Project){ + return 'R3.Project'; + } + if (runtimeComponent instanceof R3.Plane){ + return 'R3.Plane'; + } + if (runtimeComponent instanceof R3.Mouse){ + return 'R3.Mouse'; + } + if (runtimeComponent instanceof R3.Matrix4){ + return 'R3.Matrix4'; + } + if (runtimeComponent instanceof R3.Image){ + return 'R3.Image'; + } + if (runtimeComponent instanceof R3.GUI){ + return 'R3.GUI'; + } + if (runtimeComponent instanceof R3.Group){ + return 'R3.Group'; + } + if (runtimeComponent instanceof R3.Graph.Table){ + return 'R3.Graph.Table'; + } + if (runtimeComponent instanceof R3.Graph.Metric){ + return 'R3.Graph.Metric'; + } + if (runtimeComponent instanceof R3.Graph.Barchart.Stacked){ + return 'R3.Graph.Barchart.Stacked'; + } + if (runtimeComponent instanceof R3.Graph.Barchart){ + return 'R3.Graph.Barchart'; + } + if (runtimeComponent instanceof R3.Graph){ + return 'R3.Graph'; + } + if (runtimeComponent instanceof R3.Font){ + return 'R3.Font'; + } + if (runtimeComponent instanceof R3.Entity){ + return 'R3.Entity'; + } + if (runtimeComponent instanceof R3.DrawRange){ + return 'R3.DrawRange'; + } + if (runtimeComponent instanceof R3.DomElement){ + return 'R3.DomElement'; + } + if (runtimeComponent instanceof R3.D3.Viewport.ZoomedAspect){ + return 'R3.D3.Viewport.ZoomedAspect'; + } + if (runtimeComponent instanceof R3.D3.Viewport.FixedAspect){ + return 'R3.D3.Viewport.FixedAspect'; + } + if (runtimeComponent instanceof R3.D3.Viewport){ + return 'R3.D3.Viewport'; + } + if (runtimeComponent instanceof R3.D3.Vertex){ + return 'R3.D3.Vertex'; + } + if (runtimeComponent instanceof R3.D3.Texture.Image){ + return 'R3.D3.Texture.Image'; + } + if (runtimeComponent instanceof R3.D3.Texture.Cube){ + return 'R3.D3.Texture.Cube'; + } + if (runtimeComponent instanceof R3.D3.Texture.Canvas){ + return 'R3.D3.Texture.Canvas'; + } + if (runtimeComponent instanceof R3.D3.Texture){ + return 'R3.D3.Texture'; + } + if (runtimeComponent instanceof R3.D3.Text){ + return 'R3.D3.Text'; + } + if (runtimeComponent instanceof R3.D3.Spline){ + return 'R3.D3.Spline'; + } + if (runtimeComponent instanceof R3.D3.Solver){ + return 'R3.D3.Solver'; + } + if (runtimeComponent instanceof R3.D3.Skeleton){ + return 'R3.D3.Skeleton'; + } + if (runtimeComponent instanceof R3.D3.Shape.TriMesh){ + return 'R3.D3.Shape.TriMesh'; + } + if (runtimeComponent instanceof R3.D3.Shape.Sphere){ + return 'R3.D3.Shape.Sphere'; + } + if (runtimeComponent instanceof R3.D3.Shape.Plane){ + return 'R3.D3.Shape.Plane'; + } + if (runtimeComponent instanceof R3.D3.Shape.HeightMap){ + return 'R3.D3.Shape.HeightMap'; + } + if (runtimeComponent instanceof R3.D3.Shape.ConvexHull.Cylinder){ + return 'R3.D3.Shape.ConvexHull.Cylinder'; + } + if (runtimeComponent instanceof R3.D3.Shape.ConvexHull){ + return 'R3.D3.Shape.ConvexHull'; + } + if (runtimeComponent instanceof R3.D3.Shape.Box){ + return 'R3.D3.Shape.Box'; + } + if (runtimeComponent instanceof R3.D3.Shape){ + return 'R3.D3.Shape'; + } + if (runtimeComponent instanceof R3.D3.Shadow.Spot){ + return 'R3.D3.Shadow.Spot'; + } + if (runtimeComponent instanceof R3.D3.Shadow.Directional){ + return 'R3.D3.Shadow.Directional'; + } + if (runtimeComponent instanceof R3.D3.Shadow){ + return 'R3.D3.Shadow'; + } + if (runtimeComponent instanceof R3.D3.Shader.Vertex){ + return 'R3.D3.Shader.Vertex'; + } + if (runtimeComponent instanceof R3.D3.Shader.Fragment){ + return 'R3.D3.Shader.Fragment'; + } + if (runtimeComponent instanceof R3.D3.Shader){ + return 'R3.D3.Shader'; + } + if (runtimeComponent instanceof R3.D3.Scene){ + return 'R3.D3.Scene'; + } + if (runtimeComponent instanceof R3.D3.RigidBody){ + return 'R3.D3.RigidBody'; + } + if (runtimeComponent instanceof R3.D3.RenderTarget.Cube){ + return 'R3.D3.RenderTarget.Cube'; + } + if (runtimeComponent instanceof R3.D3.RenderTarget){ + return 'R3.D3.RenderTarget'; + } + if (runtimeComponent instanceof R3.D3.Raycaster){ + return 'R3.D3.Raycaster'; + } + if (runtimeComponent instanceof R3.D3.RaycastWheel){ + return 'R3.D3.RaycastWheel'; + } + if (runtimeComponent instanceof R3.D3.RaycastVehicle){ + return 'R3.D3.RaycastVehicle'; + } + if (runtimeComponent instanceof R3.D3.PhysicsWorld){ + return 'R3.D3.PhysicsWorld'; + } + if (runtimeComponent instanceof R3.D3.Pass.Render.SSAO){ + return 'R3.D3.Pass.Render.SSAO'; + } + if (runtimeComponent instanceof R3.D3.Pass.Render){ + return 'R3.D3.Pass.Render'; + } + if (runtimeComponent instanceof R3.D3.Pass.FXAA){ + return 'R3.D3.Pass.FXAA'; + } + if (runtimeComponent instanceof R3.D3.Pass.Copy){ + return 'R3.D3.Pass.Copy'; + } + if (runtimeComponent instanceof R3.D3.Pass.Bloom){ + return 'R3.D3.Pass.Bloom'; + } + if (runtimeComponent instanceof R3.D3.Pass){ + return 'R3.D3.Pass'; + } + if (runtimeComponent instanceof R3.D3.Mesh.Skeleton){ + return 'R3.D3.Mesh.Skeleton'; + } + if (runtimeComponent instanceof R3.D3.Mesh.Particle.Engine){ + return 'R3.D3.Mesh.Particle.Engine'; + } + if (runtimeComponent instanceof R3.D3.Mesh.Particle){ + return 'R3.D3.Mesh.Particle'; + } + if (runtimeComponent instanceof R3.D3.Mesh){ + return 'R3.D3.Mesh'; + } + if (runtimeComponent instanceof R3.D3.Material.Standard){ + return 'R3.D3.Material.Standard'; + } + if (runtimeComponent instanceof R3.D3.Material.Shader.Raw){ + return 'R3.D3.Material.Shader.Raw'; + } + if (runtimeComponent instanceof R3.D3.Material.Shader){ + return 'R3.D3.Material.Shader'; + } + if (runtimeComponent instanceof R3.D3.Material.Points){ + return 'R3.D3.Material.Points'; + } + if (runtimeComponent instanceof R3.D3.Material.Phong){ + return 'R3.D3.Material.Phong'; + } + if (runtimeComponent instanceof R3.D3.Material.Basic){ + return 'R3.D3.Material.Basic'; + } + if (runtimeComponent instanceof R3.D3.Material){ + return 'R3.D3.Material'; + } + if (runtimeComponent instanceof R3.D3.Light.Spot){ + return 'R3.D3.Light.Spot'; + } + if (runtimeComponent instanceof R3.D3.Light.RectArea){ + return 'R3.D3.Light.RectArea'; + } + if (runtimeComponent instanceof R3.D3.Light.Point){ + return 'R3.D3.Light.Point'; + } + if (runtimeComponent instanceof R3.D3.Light.Hemisphere){ + return 'R3.D3.Light.Hemisphere'; + } + if (runtimeComponent instanceof R3.D3.Light.Directional){ + return 'R3.D3.Light.Directional'; + } + if (runtimeComponent instanceof R3.D3.Light.Ambient){ + return 'R3.D3.Light.Ambient'; + } + if (runtimeComponent instanceof R3.D3.Light){ + return 'R3.D3.Light'; + } + if (runtimeComponent instanceof R3.D3.Helper){ + return 'R3.D3.Helper'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Wireframe){ + return 'R3.D3.Geometry.Normal.Wireframe'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Tube){ + return 'R3.D3.Geometry.Normal.Tube'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.TorusKnot){ + return 'R3.D3.Geometry.Normal.TorusKnot'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Torus){ + return 'R3.D3.Geometry.Normal.Torus'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Text){ + return 'R3.D3.Geometry.Normal.Text'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Tetrahedron){ + return 'R3.D3.Geometry.Normal.Tetrahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Sphere){ + return 'R3.D3.Geometry.Normal.Sphere'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Shape){ + return 'R3.D3.Geometry.Normal.Shape'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Ring){ + return 'R3.D3.Geometry.Normal.Ring'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Polyhedron){ + return 'R3.D3.Geometry.Normal.Polyhedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Plane){ + return 'R3.D3.Geometry.Normal.Plane'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Parametric){ + return 'R3.D3.Geometry.Normal.Parametric'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Octahedron){ + return 'R3.D3.Geometry.Normal.Octahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Lathe){ + return 'R3.D3.Geometry.Normal.Lathe'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Icosahedron){ + return 'R3.D3.Geometry.Normal.Icosahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Extrude){ + return 'R3.D3.Geometry.Normal.Extrude'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Edges){ + return 'R3.D3.Geometry.Normal.Edges'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Dodecahedron){ + return 'R3.D3.Geometry.Normal.Dodecahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Cylinder){ + return 'R3.D3.Geometry.Normal.Cylinder'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Cone){ + return 'R3.D3.Geometry.Normal.Cone'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Circle){ + return 'R3.D3.Geometry.Normal.Circle'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal.Box){ + return 'R3.D3.Geometry.Normal.Box'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Normal){ + return 'R3.D3.Geometry.Normal'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Tube){ + return 'R3.D3.Geometry.Buffer.Tube'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.TorusKnot){ + return 'R3.D3.Geometry.Buffer.TorusKnot'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Torus){ + return 'R3.D3.Geometry.Buffer.Torus'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Text){ + return 'R3.D3.Geometry.Buffer.Text'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Tetrahedron){ + return 'R3.D3.Geometry.Buffer.Tetrahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Sphere){ + return 'R3.D3.Geometry.Buffer.Sphere'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Shape){ + return 'R3.D3.Geometry.Buffer.Shape'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Ring){ + return 'R3.D3.Geometry.Buffer.Ring'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Polyhedron){ + return 'R3.D3.Geometry.Buffer.Polyhedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Plane){ + return 'R3.D3.Geometry.Buffer.Plane'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Parametric){ + return 'R3.D3.Geometry.Buffer.Parametric'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Octahedron){ + return 'R3.D3.Geometry.Buffer.Octahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Lathe){ + return 'R3.D3.Geometry.Buffer.Lathe'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Instanced){ + return 'R3.D3.Geometry.Buffer.Instanced'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Icosahedron){ + return 'R3.D3.Geometry.Buffer.Icosahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Extrude){ + return 'R3.D3.Geometry.Buffer.Extrude'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Dodecahedron){ + return 'R3.D3.Geometry.Buffer.Dodecahedron'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Cylinder){ + return 'R3.D3.Geometry.Buffer.Cylinder'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Cone){ + return 'R3.D3.Geometry.Buffer.Cone'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Circle){ + return 'R3.D3.Geometry.Buffer.Circle'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer.Box){ + return 'R3.D3.Geometry.Buffer.Box'; + } + if (runtimeComponent instanceof R3.D3.Geometry.Buffer){ + return 'R3.D3.Geometry.Buffer'; + } + if (runtimeComponent instanceof R3.D3.Geometry){ + return 'R3.D3.Geometry'; + } + if (runtimeComponent instanceof R3.D3.FrictionMaterial){ + return 'R3.D3.FrictionMaterial'; + } + if (runtimeComponent instanceof R3.D3.FrictionContactMaterial){ + return 'R3.D3.FrictionContactMaterial'; + } + if (runtimeComponent instanceof R3.D3.Fog.Normal){ + return 'R3.D3.Fog.Normal'; + } + if (runtimeComponent instanceof R3.D3.Fog.Exp){ + return 'R3.D3.Fog.Exp'; + } + if (runtimeComponent instanceof R3.D3.Fog){ + return 'R3.D3.Fog'; + } + if (runtimeComponent instanceof R3.D3.Face.Graphics){ + return 'R3.D3.Face.Graphics'; + } + if (runtimeComponent instanceof R3.D3.Face){ + return 'R3.D3.Face'; + } + if (runtimeComponent instanceof R3.D3.Effect.Stereo){ + return 'R3.D3.Effect.Stereo'; + } + if (runtimeComponent instanceof R3.D3.Effect.Parallax){ + return 'R3.D3.Effect.Parallax'; + } + if (runtimeComponent instanceof R3.D3.Effect.Anaglyph){ + return 'R3.D3.Effect.Anaglyph'; + } + if (runtimeComponent instanceof R3.D3.Effect){ + return 'R3.D3.Effect'; + } + if (runtimeComponent instanceof R3.D3.Composer){ + return 'R3.D3.Composer'; + } + if (runtimeComponent instanceof R3.D3.Camera.Perspective.Stereo){ + return 'R3.D3.Camera.Perspective.Stereo'; + } + if (runtimeComponent instanceof R3.D3.Camera.Perspective){ + return 'R3.D3.Camera.Perspective'; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic.ScaledAspect){ + return 'R3.D3.Camera.Orthographic.ScaledAspect'; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic.FixedAspect){ + return 'R3.D3.Camera.Orthographic.FixedAspect'; + } + if (runtimeComponent instanceof R3.D3.Camera.Orthographic){ + return 'R3.D3.Camera.Orthographic'; + } + if (runtimeComponent instanceof R3.D3.Camera.Cube){ + return 'R3.D3.Camera.Cube'; + } + if (runtimeComponent instanceof R3.D3.Camera){ + return 'R3.D3.Camera'; + } + if (runtimeComponent instanceof R3.D3.Broadphase){ + return 'R3.D3.Broadphase'; + } + if (runtimeComponent instanceof R3.D3.BoneWeight){ + return 'R3.D3.BoneWeight'; + } + if (runtimeComponent instanceof R3.D3.Bone){ + return 'R3.D3.Bone'; + } + if (runtimeComponent instanceof R3.D3.Audio){ + return 'R3.D3.Audio'; + } + if (runtimeComponent instanceof R3.D3.Animation){ + return 'R3.D3.Animation'; + } + if (runtimeComponent instanceof R3.D3.Object){ + return 'R3.D3.Object'; + } + if (runtimeComponent instanceof R3.CustomCode){ + return 'R3.CustomCode'; + } + if (runtimeComponent instanceof R3.Curve.Path.D2.Shape){ + return 'R3.Curve.Path.D2.Shape'; + } + if (runtimeComponent instanceof R3.Curve.Path.D2){ + return 'R3.Curve.Path.D2'; + } + if (runtimeComponent instanceof R3.Curve.Path){ + return 'R3.Curve.Path'; + } + if (runtimeComponent instanceof R3.Curve){ + return 'R3.Curve'; + } + if (runtimeComponent instanceof R3.Controls.Touch){ + return 'R3.Controls.Touch'; + } + if (runtimeComponent instanceof R3.Controls.Mouse){ + return 'R3.Controls.Mouse'; + } + if (runtimeComponent instanceof R3.Controls.Keyboard){ + return 'R3.Controls.Keyboard'; + } + if (runtimeComponent instanceof R3.Controls.D3.Orbit){ + return 'R3.Controls.D3.Orbit'; + } + if (runtimeComponent instanceof R3.Controls.D3.FirstPerson){ + return 'R3.Controls.D3.FirstPerson'; + } + if (runtimeComponent instanceof R3.Controls.D3){ + return 'R3.Controls.D3'; + } + if (runtimeComponent instanceof R3.Controls){ + return 'R3.Controls'; + } + if (runtimeComponent instanceof R3.Color){ + return 'R3.Color'; + } + if (runtimeComponent instanceof R3.Clock){ + return 'R3.Clock'; + } + if (runtimeComponent instanceof R3.Canvas){ + return 'R3.Canvas'; + } + if (runtimeComponent instanceof R3.Box3){ + return 'R3.Box3'; + } + throw new Error('Invalid Runtime Constructor : ' + runtimeConstructor); + +}; diff --git a/src/r3-a-2-event-0.js b/src/r3-a-2-event-0.js new file mode 100644 index 0000000..c31477d --- /dev/null +++ b/src/r3-a-2-event-0.js @@ -0,0 +1,282 @@ +/** + * Event Core + * @constructor + */ +R3.Event = function() { +}; + +/** + * Some nice Events handling + * @type {{}} + */ +R3.Event.Subscriptions = {}; +R3.Event.OnceSubscriptions = {}; + +/** + * Subscribe to some events + * @param eventName + * @param callback + */ +R3.Event.prototype.subscribe = function( + eventName, + callback +) { + return R3.Event.Subscribe(eventName, callback.bind(this)); +}; + + +// /** +// * Stop listening for this event after the callback returns true +// * @param eventName +// * @param callback +// * @returns {{fn, remove: remove}} +// */ +// R3.Event.prototype.subscribeOnce = function( +// eventName, +// callback +// ) { +// throw new Error('implement first properly'); +// // var fn = callback.bind(this); +// // +// // if (R3.Event.OnceSubscriptions.hasOwnProperty(eventName)) { +// // R3.Event.OnceSubscriptions[eventName].push(fn); +// // } else { +// // R3.Event.OnceSubscriptions[eventName] = []; +// // R3.Event.OnceSubscriptions[eventName].push(fn); +// // } +// // +// // /** +// // * Return a handle to the caller to allow us to unsubscribe to this event +// // */ +// // return { +// // fn : fn, +// // remove : function() { +// // R3.Event.Subscriptions[eventName].splice( +// // R3.Event.Subscriptions[eventName].indexOf(fn), +// // 1 +// // ); +// // } +// // } +// }; + +/** + * + * @param eventName + * @param data + */ +/** + * Publish some event happened with some data + * @param eventName + * @param data + * @param clientCallback + * @param clientErrorCallback + * @returns {number} of callbacks executed + */ +R3.Event.prototype.emit = function( + eventName, + data, + clientCallback, + clientErrorCallback +) { + return R3.Event.Emit( + eventName, + data, + clientCallback, + clientErrorCallback + ); +}; + +/** + * Static method call + * @param eventName + * @param data + * @param clientCallback is executed ideally when the event completed + * @param clientErrorCallback + * @returns {number} of callbacks executed + * @constructor + */ +R3.Event.Emit = function( + eventName, + data, + clientCallback, + clientErrorCallback +) { + + var count = 0; + + if (R3.Event.Subscriptions.hasOwnProperty(eventName)) { + + if (R3.Event.Subscriptions[eventName].length === 0) { + + if (clientCallback) { + /** + * We execute the client callback immediately since there are no subscriptions to this event + */ + clientCallback(); + } + + if (clientErrorCallback) { + clientErrorCallback({ + message : 'No subscriptions for event ' + eventName + }) + } + } + + /** + * We need to execute all the callbacks, but not execute them twice, but also keep in mind they can remove + * themselves during execution + */ + // var length = R3.Event.Subscriptions[eventName].length; + // + // for (var i = 0; i < length; i++) { + // + // var object = R3.Event.Subscriptions[eventName][i]; + // + // if (object.fn && object.executed === false) { + // object.fn(data, clientCallback, clientErrorCallback); + // object.executed = true; + // } + // + // if (length !== R3.Event.Subscriptions[eventName].length) { + // /** + // * this callback removed a subscription - reset i and reset the length + // */ + // i = 0; + // length = R3.Event.Subscriptions[eventName].length; + // } + // } + // + // R3.Event.Subscriptions[eventName].map( + // function(object){ + // object.executed = false; + // } + // ) + + R3.Event.Subscriptions[eventName].map( + function(subscription) { + if (subscription) { + + try { + var result = subscription(data, clientCallback, clientErrorCallback); + } catch (error) { + + if (clientErrorCallback) { + try { + clientErrorCallback(error); + } catch (error2) { + console.error('failed to execute client callback error:', error2); + } + } + + } + + if (clientCallback) { + clientCallback(result); + } + + count++; + } + } + ) + } else { + if (clientCallback) { + /** + * We execute the client callback immediately since there are no subscriptions to this event + */ + clientCallback(); + } + + if (clientErrorCallback) { + clientErrorCallback({ + message : 'No subscriptions for event ' + eventName + }) + } + } + + return count; +}; + +/** + * Execute the functions which subscribe to this event, but don't process the client callback - the subscription function + * should execute the client callback + * @param eventName + * @param data + * @param clientCallback + * @param clientErrorCallback + * @returns {number} + * @constructor + */ +R3.Event.Async = function( + eventName, + data, + clientCallback, + clientErrorCallback +) { + + var count = 0; + + if (R3.Event.Subscriptions.hasOwnProperty(eventName)) { + R3.Event.Subscriptions[eventName].map( + function(subscription) { + if (subscription) { + subscription(data, clientCallback, clientErrorCallback); + count++; + } + } + ) + } + + return count; +}; + +R3.Event.Subscribe = function( + eventName, + fn +) { + + if (R3.Event.Subscriptions.hasOwnProperty(eventName)) { + R3.Event.Subscriptions[eventName].push(fn); + // { + // fn : fn, + // executed : false + // } + // ); + } else { + R3.Event.Subscriptions[eventName] = []; + R3.Event.Subscriptions[eventName].push(fn); + // { + // fn : fn, + // executed : false + // } + // ); + } + + /** + * Return a handle to the caller to allow us to unsubscribe to this event + */ + return { + fn : fn, + remove : function() { + + var index = R3.Event.Subscriptions[eventName].indexOf(fn); + // reduce( + // function(result, object, index) { + // if (object.fn === fn) { + // result = index; + // } + // return result; + // }, + // -1 + // ); + + if (index === -1) { + throw new Error('could not remove subscription'); + } + + R3.Event.Subscriptions[eventName].splice( + index, + 1 + ); + } + } +}; \ No newline at end of file diff --git a/src/r3-a-2-event-1.js b/src/r3-a-2-event-1.js new file mode 100644 index 0000000..5cb87e3 --- /dev/null +++ b/src/r3-a-2-event-1.js @@ -0,0 +1,232 @@ +R3.Event.AFTER_RENDER = 0x1; +R3.Event.AFTER_WINDOW_RESIZE = 0x2; +R3.Event.ANIMATE_TEXTURE_INSTANCE = 0x3; +R3.Event.ANIMATION_COMPILE_FAILED = 0x4; +R3.Event.ANIMATION_COMPILE_SUCCESS = 0x5; +R3.Event.ANIMATION_MESH_ADDED = 0x6; +R3.Event.ANIMATION_MESH_REMOVED = 0x7; +R3.Event.ARRAY_ITEM_ADDED = 0x8; +R3.Event.AUDIO_ENDED = 0x9; +R3.Event.BEFORE_RENDER = 0xa; +R3.Event.BEFORE_WINDOW_RESIZE = 0xb; +R3.Event.BLENDER_DATA_RECEIVED = 0xc; +R3.Event.BUILD_GUI = 0xd; +R3.Event.CANVAS_CHANGE = 0xe; +R3.Event.CAST_SOURCE_CHANGED = 0xf; +R3.Event.COMPILE_FAILED = 0x10; +R3.Event.COMPILE_SUCCESS = 0x11; +R3.Event.COMPONENTS_LINKED = 0x12; +R3.Event.COMPONENT_CLONED = 0x13; +R3.Event.COMPONENT_CREATED = 0x14; +R3.Event.COMPONENT_DELETED = 0x15; +R3.Event.COMPONENT_DOWNLOAD_COMPLETE = 0x16; +R3.Event.COMPONENT_LINKED = 0x17; +R3.Event.COMPONENT_REGISTER = 0x18; +R3.Event.COMPONENT_REPLACED = 0x19; +R3.Event.COMPONENT_SAVED = 0x1a; +R3.Event.COMPONENT_TYPES_UPDATE = 0x1b; +R3.Event.COMPONENT_UPDATE = 0x1c; +R3.Event.CONTINUE_ALL_AUDIO = 0x1d; +R3.Event.CONTROLS_CANVAS_CHANGE = 0x1e; +R3.Event.DELETE_COMPONENT = 0x1f; +R3.Event.DELETE_COMPONENT_ERROR = 0x20; +R3.Event.DONE_SAVING = 0x21; +R3.Event.ENGINE_FIRED_PARTICLES_ZERO = 0x22; +R3.Event.ENTITY_LOADED = 0x23; +R3.Event.EVENT_ID_UPDATE = 0x24; +R3.Event.EXCLUDE_FROM_ENVIRONMENT = 0x25; +R3.Event.FETCH_COMPONENTS = 0x26; +R3.Event.FETCH_COMPONENT_TYPES = 0x27; +R3.Event.GET_API_URL = 0x28; +R3.Event.GET_APPLICATION_MODE = 0x29; +R3.Event.GET_GRAPHICS_RUNTIME = 0x2a; +R3.Event.GET_PHYSICS_RUNTIME = 0x2b; +R3.Event.GET_PROJECT = 0x2c; +R3.Event.GET_REMOTE_API_URL = 0x2d; +R3.Event.GET_RENDER_CONFIGURATION = 0x2e; +R3.Event.GET_RUNTIME = 0x2f; +R3.Event.GET_USER = 0x30; +R3.Event.GET_WEBSOCKET_CONFIG = 0x31; +R3.Event.GET_WINDOW_SIZE = 0x32; +R3.Event.IMAGE_UPLOAD_COMPLETE = 0x33; +R3.Event.INSTANCE_CLONED = 0x34; +R3.Event.INSTANCE_CREATED = 0x35; +R3.Event.INSTANCE_DISPOSAL = 0x36; +R3.Event.KEY_DOWN = 0x37; +R3.Event.KEY_UP = 0x38; +R3.Event.LOAD_COMPONENT = 0x39; +R3.Event.LOAD_COMPONENT_ERROR = 0x3a; +R3.Event.LOAD_FONT = 0x3b; +R3.Event.LOAD_IMAGE = 0x3c; +R3.Event.LOAD_PROGRESS = 0x3d; +R3.Event.MATERIAL_TEXTURES_UPDATED = 0x3e; +R3.Event.MATERIAL_TYPE_CHANGED = 0x3f; +R3.Event.MAXIMUM_PROJECTS = 0x40; +R3.Event.MESH_DESELECTED = 0x41; +R3.Event.MESH_FACE_DESELECTED = 0x42; +R3.Event.MESH_FACE_SELECTED = 0x43; +R3.Event.MESH_SELECTED = 0x44; +R3.Event.MOUSE_DOWN = 0x45; +R3.Event.MOUSE_MOVE = 0x46; +R3.Event.MOUSE_UP = 0x47; +R3.Event.MOUSE_WHEEL = 0x48; +R3.Event.MUTE_AUDIO = 0x49; +R3.Event.NAME_UPDATE = 0x4a; +R3.Event.PARENT_SCENE_CHANGE = 0x4b; +R3.Event.PARENT_WORLD_CHANGE = 0x4c; +R3.Event.PAUSE_ALL_AUDIO = 0x4d; +R3.Event.PLAY_AUDIO = 0x4e; +R3.Event.PROJECT_LOADED = 0x4f; +R3.Event.QUERY_PARSED = 0x50; +R3.Event.RECEIVE_DESTINATION_CHANGED = 0x51; +R3.Event.REGISTER_DEPENDENCIES = 0x52; +R3.Event.REGISTER_UPDATE = 0x53; +R3.Event.REMOVE_COMPONENT = 0x54; +R3.Event.REMOVE_MESH = 0x55; +R3.Event.REMOVE_PARTICLE_ENGINE = 0x56; +R3.Event.RENDERER_SIZE_CHANGE = 0x57; +R3.Event.REPLACE_COMPONENT = 0x58; +R3.Event.RESOLVE_DEPENDENCIES = 0x59; +R3.Event.SAVE_COMPONENT = 0x5a; +R3.Event.SAVE_COMPONENT_ERROR = 0x5b; +R3.Event.SAVING = 0x5c; +R3.Event.SELECTION_MODE_CHANGE = 0x5d; +R3.Event.SET_APPLICATION_MODE = 0x5e; +R3.Event.SIGN_IN = 0x5f; +R3.Event.SIGN_OUT = 0x60; +R3.Event.STOP_ALL_AUDIO = 0x61; +R3.Event.STOP_AUDIO = 0x62; +R3.Event.STOP_VISUALIZE = 0x63; +R3.Event.TEXTURE_ANIMATED_CHANGE = 0x64; +R3.Event.TEXTURE_INSTANCE_UPDATED = 0x65; +R3.Event.TOUCH_CANCEL = 0x66; +R3.Event.TOUCH_END = 0x67; +R3.Event.TOUCH_MOVE = 0x68; +R3.Event.TOUCH_START = 0x69; +R3.Event.UNRESOLVED_DEPENDENCIES_UPDATE = 0x6a; +R3.Event.VISUALIZE = 0x6b; +R3.Event.WINDOW_RESIZE = 0x6c; +R3.Event.MAX_EVENTS = 0x6d; + +/** + * R3.Event.GetEventName + * @param eventId + * @returns {string} + * @constructor + */ +R3.Event.GetEventName = function(eventId) { + + switch(eventId) { + case 0x1 : return 'after_render'; + case 0x2 : return 'after_window_resize'; + case 0x3 : return 'animate_texture_instance'; + case 0x4 : return 'animation_compile_failed'; + case 0x5 : return 'animation_compile_success'; + case 0x6 : return 'animation_mesh_added'; + case 0x7 : return 'animation_mesh_removed'; + case 0x8 : return 'array_item_added'; + case 0x9 : return 'audio_ended'; + case 0xa : return 'before_render'; + case 0xb : return 'before_window_resize'; + case 0xc : return 'blender_data_received'; + case 0xd : return 'build_gui'; + case 0xe : return 'canvas_change'; + case 0xf : return 'cast_source_changed'; + case 0x10 : return 'compile_failed'; + case 0x11 : return 'compile_success'; + case 0x12 : return 'components_linked'; + case 0x13 : return 'component_cloned'; + case 0x14 : return 'component_created'; + case 0x15 : return 'component_deleted'; + case 0x16 : return 'component_download_complete'; + case 0x17 : return 'component_linked'; + case 0x18 : return 'component_register'; + case 0x19 : return 'component_replaced'; + case 0x1a : return 'component_saved'; + case 0x1b : return 'component_types_update'; + case 0x1c : return 'component_update'; + case 0x1d : return 'continue_all_audio'; + case 0x1e : return 'controls_canvas_change'; + case 0x1f : return 'delete_component'; + case 0x20 : return 'delete_component_error'; + case 0x21 : return 'done_saving'; + case 0x22 : return 'engine_fired_particles_zero'; + case 0x23 : return 'entity_loaded'; + case 0x24 : return 'event_id_update'; + case 0x25 : return 'exclude_from_environment'; + case 0x26 : return 'fetch_components'; + case 0x27 : return 'fetch_component_types'; + case 0x28 : return 'get_api_url'; + case 0x29 : return 'get_application_mode'; + case 0x2a : return 'get_graphics_runtime'; + case 0x2b : return 'get_physics_runtime'; + case 0x2c : return 'get_project'; + case 0x2d : return 'get_remote_api_url'; + case 0x2e : return 'get_render_configuration'; + case 0x2f : return 'get_runtime'; + case 0x30 : return 'get_user'; + case 0x31 : return 'get_websocket_config'; + case 0x32 : return 'get_window_size'; + case 0x33 : return 'image_upload_complete'; + case 0x34 : return 'instance_cloned'; + case 0x35 : return 'instance_created'; + case 0x36 : return 'instance_disposal'; + case 0x37 : return 'key_down'; + case 0x38 : return 'key_up'; + case 0x39 : return 'load_component'; + case 0x3a : return 'load_component_error'; + case 0x3b : return 'load_font'; + case 0x3c : return 'load_image'; + case 0x3d : return 'load_progress'; + case 0x3e : return 'material_textures_updated'; + case 0x3f : return 'material_type_changed'; + case 0x40 : return 'maximum_projects'; + case 0x41 : return 'mesh_deselected'; + case 0x42 : return 'mesh_face_deselected'; + case 0x43 : return 'mesh_face_selected'; + case 0x44 : return 'mesh_selected'; + case 0x45 : return 'mouse_down'; + case 0x46 : return 'mouse_move'; + case 0x47 : return 'mouse_up'; + case 0x48 : return 'mouse_wheel'; + case 0x49 : return 'mute_audio'; + case 0x4a : return 'name_update'; + case 0x4b : return 'parent_scene_change'; + case 0x4c : return 'parent_world_change'; + case 0x4d : return 'pause_all_audio'; + case 0x4e : return 'play_audio'; + case 0x4f : return 'project_loaded'; + case 0x50 : return 'query_parsed'; + case 0x51 : return 'receive_destination_changed'; + case 0x52 : return 'register_dependencies'; + case 0x53 : return 'register_update'; + case 0x54 : return 'remove_component'; + case 0x55 : return 'remove_mesh'; + case 0x56 : return 'remove_particle_engine'; + case 0x57 : return 'renderer_size_change'; + case 0x58 : return 'replace_component'; + case 0x59 : return 'resolve_dependencies'; + case 0x5a : return 'save_component'; + case 0x5b : return 'save_component_error'; + case 0x5c : return 'saving'; + case 0x5d : return 'selection_mode_change'; + case 0x5e : return 'set_application_mode'; + case 0x5f : return 'sign_in'; + case 0x60 : return 'sign_out'; + case 0x61 : return 'stop_all_audio'; + case 0x62 : return 'stop_audio'; + case 0x63 : return 'stop_visualize'; + case 0x64 : return 'texture_animated_change'; + case 0x65 : return 'texture_instance_updated'; + case 0x66 : return 'touch_cancel'; + case 0x67 : return 'touch_end'; + case 0x68 : return 'touch_move'; + case 0x69 : return 'touch_start'; + case 0x6a : return 'unresolved_dependencies_update'; + case 0x6b : return 'visualize'; + case 0x6c : return 'window_resize'; + default : + throw new Error('Event type not defined : ' + eventId); + } + +}; diff --git a/src/r3-a-2-event.js b/src/r3-a-2-event.js deleted file mode 100644 index 1e67868..0000000 --- a/src/r3-a-2-event.js +++ /dev/null @@ -1,502 +0,0 @@ -/** - * Event Core - * @constructor - */ -R3.Event = function() { -}; - -/** - * Some nice Events handling - * @type {{}} - */ -R3.Event.Subscriptions = {}; -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_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 - * @param number - * @returns {*} - * @constructor - */ -R3.Event.GetEventName = function(number) { - - switch(number) { - case 0x1 : return 'window_resize'; - case 0x2 : return 'parent_scene_change'; - case 0x3 : return 'unused'; - case 0x4 : return 'instance_cloned'; - case 0x5 : return 'load_image'; - case 0x6 : return 'new_entity'; - case 0x7 : return 'material_type_changed'; - case 0x8 : return 'save_component'; - case 0x9 : return 'save_component_error'; - case 0xa : return 'component_saved'; - case 0xb : return 'load_component'; - case 0xc : return 'load_component_error'; - case 0xd : return 'logged_in'; - case 0xe : return 'component_created'; - case 0xf : return 'component_cloned'; - case 0x10 : return 'texture_animated_change'; - case 0x11 : return 'animate_texture_instance'; - case 0x12 : return 'remove_particle_engine'; - case 0x13 : return 'pause'; - case 0x14 : return 'shader_update'; - case 0x15 : return 'play_audio'; - case 0x16 : return 'material_instance_updated'; - case 0x17 : return 'pause_audio'; - case 0x18 : return 'mesh_instance_updated'; - case 0x19 : return 'stop_audio'; - case 0x1a : return 'light_instance_updated'; - case 0x1b : return 'delete_component'; - case 0x1c : return 'component_download_complete'; - case 0x1d : return 'components_linked'; - case 0x1e : return 'unresolved_dependencies_update'; - case 0x1f : return 'register_update'; - case 0x20 : return 'build_gui'; - case 0x21 : return 'remove_mesh'; - case 0x22 : return 'mesh_selected'; - case 0x23 : return 'mesh_deselected'; - case 0x24 : return 'component_register'; - case 0x25 : return 'image_not_found'; - case 0x26 : return 'blender_data_received'; - case 0x27 : return 'image_upload_complete'; - case 0x28 : return 'remove_component'; - case 0x29 : return 'key_down'; - case 0x2a : return 'key_up'; - case 0x2b : return 'render'; - case 0x2c : return 'event_list'; - case 0x2d : return 'compile_success'; - case 0x2e : return 'compile_failed'; - case 0x2f : return 'texture_image_updated'; - case 0x30 : return 'event_id_update'; - case 0x31 : return 'material_textures_updated'; - case 0x32 : return 'delete_component_error'; - case 0x33 : return 'component_deleted'; - case 0x34 : return 'component_types_updated'; - case 0x35 : return 'audio_ended'; - case 0x36 : return 'component_linked'; - case 0x37 : return 'done_saving'; - case 0x38 : return 'before_render'; - case 0x39 : return 'after_render'; - case 0x3a : return 'array_item_added'; - case 0x3b : return 'instance_created'; - case 0x3c : return 'visualize'; - case 0x3d : return 'stop_visualize'; - case 0x3e : return 'fetch_component_types'; - case 0x3f : return 'fetch_components'; - case 0x40 : return 'get_api_url'; - case 0x41 : return 'get_runtime'; - case 0x42 : return 'parent_world_change'; - case 0x43 : return 'animate'; - case 0x44 : return 'animation_compile_success'; - case 0x45 : return 'animation_compile_failed'; - case 0x46 : return 'saving'; - case 0x47 : return 'game_over'; - case 0x48 : return 'game_start'; - case 0x49 : return 'touch_start'; - case 0x4a : return 'touch_end'; - case 0x4b : return 'touch_move'; - case 0x4c : return 'touch_cancel'; - case 0x4d : return 'get_remote_api_url'; - case 0x4e : return 'component_types_update'; - case 0x4f : return 'project_loaded'; - case 0x50 : return 'cast_source_changed'; - case 0x51 : return 'resolve_dependencies';; - case 0x52 : return 'name_update'; - case 0x53 : return 'dom_element_change'; - case 0x54 : return 'after_window_resize'; - case 0x55 : return 'load_font'; - case 0x56 : return 'font_not_found'; - case 0x57 : return 'stop_all_audio'; - case 0x58 : return 'register_dependencies'; - case 0x59 : return 'game_loaded'; - case 0x5a : return 'component_update'; - case 0x5b : return 'load_progress'; - case 0x5c : return 'entity_loaded'; - case 0x5d : return 'mouse_down'; - case 0x5e : return 'mouse_move'; - case 0x5f : return 'mouse_wheel'; - case 0x60 : return 'mouse_up'; - case 0x61 : return 'particle_instance_updated'; - case 0x62 : return 'game_data'; - case 0x63 : return 'pause_all_audio'; - case 0x64 : return 'continue_all_audio'; - case 0x65 : return 'mute_audio'; - case 0x66 : return 'game_started'; - case 0x67 : return 'game_paused'; - case 0x68 : return 'game_resumed'; - case 0x69 : return 'custom_game_start'; - case 0x6a : return 'audio_muted'; - case 0x6b : return 'audio_unmuted'; - case 0x6c : return 'receive_destination_changed'; - case 0x6d : return 'selection_mode_change'; - case 0x6e : return 'mesh_face_selected'; - case 0x6f : return 'mesh_face_deselected'; - case 0x70 : return 'before_window_resize'; - case 0x71 : return 'get_window_size'; - case 0x72 : return 'get_render_configuration'; - case 0x73 : return 'set_active_render_configuration'; - case 0x74 : return 'replace_component'; - case 0x75 : return 'component_replaced'; - case 0x76 : return 'engine_fired_particles_zero'; - case 0x77 : return 'get_default_scene'; - case 0x78 : return 'get_default_camera'; - case 0x79 : return 'get_websocket_config'; - case 0x7a : return 'get_project'; - 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; - } - - throw new error('unknown event id: ' + number ); -}; - -/** - * Subscribe to some events - * @param eventName - * @param callback - */ -R3.Event.prototype.subscribe = function( - eventName, - callback -) { - return R3.Event.Subscribe(eventName, callback.bind(this)); -}; - - -// /** -// * Stop listening for this event after the callback returns true -// * @param eventName -// * @param callback -// * @returns {{fn, remove: remove}} -// */ -// R3.Event.prototype.subscribeOnce = function( -// eventName, -// callback -// ) { -// throw new Error('implement first properly'); -// // var fn = callback.bind(this); -// // -// // if (R3.Event.OnceSubscriptions.hasOwnProperty(eventName)) { -// // R3.Event.OnceSubscriptions[eventName].push(fn); -// // } else { -// // R3.Event.OnceSubscriptions[eventName] = []; -// // R3.Event.OnceSubscriptions[eventName].push(fn); -// // } -// // -// // /** -// // * Return a handle to the caller to allow us to unsubscribe to this event -// // */ -// // return { -// // fn : fn, -// // remove : function() { -// // R3.Event.Subscriptions[eventName].splice( -// // R3.Event.Subscriptions[eventName].indexOf(fn), -// // 1 -// // ); -// // } -// // } -// }; - -/** - * - * @param eventName - * @param data - */ -/** - * Publish some event happened with some data - * @param eventName - * @param data - * @param clientCallback - * @param clientErrorCallback - * @returns {number} of callbacks executed - */ -R3.Event.prototype.emit = function( - eventName, - data, - clientCallback, - clientErrorCallback -) { - return R3.Event.Emit( - eventName, - data, - clientCallback, - clientErrorCallback - ); -}; - -/** - * Static method call - * @param eventName - * @param data - * @param clientCallback is executed ideally when the event completed - * @param clientErrorCallback - * @returns {number} of callbacks executed - * @constructor - */ -R3.Event.Emit = function( - eventName, - data, - clientCallback, - clientErrorCallback -) { - - var count = 0; - - if (R3.Event.Subscriptions.hasOwnProperty(eventName)) { - - if (R3.Event.Subscriptions[eventName].length === 0) { - - if (clientCallback) { - /** - * We execute the client callback immediately since there are no subscriptions to this event - */ - clientCallback(); - } - - if (clientErrorCallback) { - clientErrorCallback({ - message : 'No subscriptions for event ' + eventName - }) - } - } - - /** - * We need to execute all the callbacks, but not execute them twice, but also keep in mind they can remove - * themselves during execution - */ - // var length = R3.Event.Subscriptions[eventName].length; - // - // for (var i = 0; i < length; i++) { - // - // var object = R3.Event.Subscriptions[eventName][i]; - // - // if (object.fn && object.executed === false) { - // object.fn(data, clientCallback, clientErrorCallback); - // object.executed = true; - // } - // - // if (length !== R3.Event.Subscriptions[eventName].length) { - // /** - // * this callback removed a subscription - reset i and reset the length - // */ - // i = 0; - // length = R3.Event.Subscriptions[eventName].length; - // } - // } - // - // R3.Event.Subscriptions[eventName].map( - // function(object){ - // object.executed = false; - // } - // ) - - R3.Event.Subscriptions[eventName].map( - function(callback) { - if (callback) { - callback(data, clientCallback, clientErrorCallback); - count++; - } - } - ) - } else { - if (clientCallback) { - /** - * We execute the client callback immediately since there are no subscriptions to this event - */ - clientCallback(); - } - - if (clientErrorCallback) { - clientErrorCallback({ - message : 'No subscriptions for event ' + eventName - }) - } - } - - return count; -}; - -R3.Event.Subscribe = function( - eventName, - fn -) { - - if (R3.Event.Subscriptions.hasOwnProperty(eventName)) { - R3.Event.Subscriptions[eventName].push(fn); - // { - // fn : fn, - // executed : false - // } - // ); - } else { - R3.Event.Subscriptions[eventName] = []; - R3.Event.Subscriptions[eventName].push(fn); - // { - // fn : fn, - // executed : false - // } - // ); - } - - /** - * Return a handle to the caller to allow us to unsubscribe to this event - */ - return { - fn : fn, - remove : function() { - - var index = R3.Event.Subscriptions[eventName].indexOf(fn); - // reduce( - // function(result, object, index) { - // if (object.fn === fn) { - // result = index; - // } - // return result; - // }, - // -1 - // ); - - if (index === -1) { - throw new Error('could not remove subscription'); - } - - R3.Event.Subscriptions[eventName].splice( - index, - 1 - ); - } - } -}; \ No newline at end of file diff --git a/src/r3-a-3-api-component.js b/src/r3-a-3-api-component.js index 8f0f06f..1fc2328 100644 --- a/src/r3-a-3-api-component.js +++ b/src/r3-a-3-api-component.js @@ -41,6 +41,7 @@ R3.API.Component = function( selected = false; } this.selected = selected; + }; R3.API.Component.prototype.constructor = R3.API.Component; @@ -51,7 +52,7 @@ R3.API.Component.prototype.constructor = R3.API.Component; * @returns {*} */ R3.API.Component.prototype.getFirstParent = function(constructor) { - return R3.D3.GetFirstParent(this, constructor); + return R3.Utils.GetFirstParent(this, constructor); }; /** @@ -62,5 +63,5 @@ R3.API.Component.prototype.getFirstParent = function(constructor) { * @returns {*} */ R3.API.Component.getParent = function(property, index, constructor) { - return R3.D3.GetParent(this, property, index, constructor); + return R3.Utils.GetParent(this, property, index, constructor); }; diff --git a/src/r3-a-3-utils.js b/src/r3-a-3-utils.js index 9e501ff..7e67f95 100644 --- a/src/r3-a-3-utils.js +++ b/src/r3-a-3-utils.js @@ -25,6 +25,106 @@ R3.Utils.GetFirstParent = function(object, constructor) { }; +R3.Utils.GetParentProject = function(component) { + + if (R3.Utils.UndefinedOrNull(component.parent)) { + throw new Error('Parent not found'); + } + + if (component.parent instanceof R3.Project) { + return component.parent; + } + + return R3.Utils.GetParentProject(component.parent); +}; + +R3.Utils.GetParents = function(component, parents) { + + if (R3.Utils.UndefinedOrNull(parents)) { + parents = []; + } + + if (R3.Utils.UndefinedOrNull(component.parent)) { + return parents; + } + + parents.push(component.parent); + + return R3.Utils.GetParents(component.parent, parents); + +}; + +/** + * @return {boolean} + */ +R3.Utils.Instance = function(component) { + return R3.Utils.Defined(component) && R3.Utils.Defined(component.instance); +}; + +/** + * R3.Utils.RemoveFromSelect + * @param select + * @param id + * @returns {boolean} + * @constructor + */ +R3.Utils.RemoveFromSelect = function(select, id) { + + var i; + + for (i = 0; i < select.options.length; i++) { + if (select.options[i].value === id) { + select.remove(i); + return true; + } + } + return false; +}; + +/** + * R3.Utils.GetSelectIndex + * + * Get the select index of given id + * + * @param select + * @param id + * @returns {null|number} + * @constructor + */ +R3.Utils.SetSelectIndex = function(select, id) { + + var i; + + for (i = 0; i < select.options.length; i++) { + if (select.options[i].value === id) { + select.selectedIndex = i; + } + } + return null; +}; + +R3.Utils.SortSelect = function(select) { + + var tmp = []; + var i; + + for (i = 1; i < select.options.length; i++) { + tmp[i-1] = []; + tmp[i-1][0] = select.options[i].text; + tmp[i-1][1] = select.options[i].value; + } + + tmp.sort(); + + select.options = [select.options[0]]; + + for (i = 0; i < tmp.length; i++) { + select.options[i+1] = new Option(tmp[i][0], tmp[i][1]); + } + + return; +}; + /** * Gets the parent of object whith property of optional type constructor. If index is specified, get the parent of the * object with property[index] - which means the property should be an array diff --git a/src/r3-a-4-component.js b/src/r3-a-4-component.js index ff59dfe..f18509f 100644 --- a/src/r3-a-4-component.js +++ b/src/r3-a-4-component.js @@ -6,107 +6,547 @@ R3.Component = function() { R3.Event.call(this); - if (R3.Utils.UndefinedOrNull(this.linkedObjects)) { - this.linkedObjects = {}; + if (R3.Utils.UndefinedOrNull(this.linkedComponents)) { + this.linkedComponents = {}; } - this.upgradeToRuntime(); - - this.componentType = R3.GetComponentType(this); - - this.runtime = this.getComponentRuntime(); - - this.idToObject = {}; - - this.building = false; + this.dependencies = []; this.loaded = false; - this.linked = false; + /** + * Use below event subscriptions event to manage this component's idToObject + * @type {null} + */ + this.idToObject = {}; - this.cloneNumber = 0; + this.removeComponentSubscription = R3.Event.Subscribe( + R3.Event.REMOVE_COMPONENT, + this.removeComponent.bind(this) + ); - this.isClone = false; + this.instanceCreatedSubscription = R3.Event.Subscribe( + R3.Event.INSTANCE_CREATED, + this.instanceCreated.bind(this) + ); - this.generateNewImageIds = false; + this.buildVectoredComponents(); - this.dependencies = this.getDependencies(); + this.buildLinkedComponents(); - if (this.register) { - this.emit( - R3.Event.COMPONENT_REGISTER, - { - component : this - } - ); - } + /** + * At this point we can can *NOT* be sure that this component is fully linked, loaded, and ready to go. + * builtLinkedComponents could be in the process of asynchronously stalling while waiting for some components to + * finish loading. - If you need to be sure all components are linked, loaded and ready to go - the entry point is + * this.performInstanceCreation() + */ - if (this.dependencies.length === 0) { - this.performInstanceCreation(); + // this.linked = false; + // this.building = false; - } else { - this.emit( - R3.Event.REGISTER_DEPENDENCIES, - { - component : this - } - ); - } +// +// this.cloneNumber = 0; + +// this.isClone = false; + +// this.generateNewImageIds = false; + + // if (this.register) { + // this.emit( + // R3.Event.COMPONENT_REGISTER, + // { + // component : this + // } + // ); + // } + // + // if (this.dependencies.length === 0) { + // + // this.performInstanceCreation(); + // + // } else { + // this.emit( + // R3.Event.REGISTER_DEPENDENCIES, + // { + // component : this + // } + // ); + // } }; R3.Component.prototype = Object.create(R3.Event.prototype); R3.Component.prototype.constructor = R3.Component; -R3.Component.prototype.upgradeToRuntime = function() { +/** + * TODO: don't remove components which are still in use elsewhere - this is important to prevent 'register out + * of sync' messages + */ +R3.Component.prototype.remove = function() { - var linkedObjects = { - graphics : R3.Runtime.Graphics, - physics : R3.Runtime.Physics, - coder : R3.Runtime.Coder, - gui : R3.Runtime.GUI, - stats : R3.Runtime.Stats - }; + Object.keys(this.idToObject).map( + function(componentId){ - for (var property in this) { + R3.Event.Emit( + R3.Event.REMOVE_COMPONENT, + { + component : this.idToObject[componentId] + } + ); - if (this.hasOwnProperty(property)) { + }.bind(this) + ); + + R3.Event.Emit( + R3.Event.INSTANCE_DISPOSAL + ); + + delete this; + +}; + +R3.Component.prototype.removeComponent = function(data) { + + var component = data.component; + + /** + * We don't care about colors and vectors etc. for now + */ + if ( + component instanceof R3.Color || + component instanceof R3.Vector2 || + component instanceof R3.Vector3 || + component instanceof R3.Vector4 || + component instanceof R3.Matrix4 || + component instanceof R3.Quaternion + ) { + if (R3.Utils.Defined(this.idToObject[component.id])) { + delete this.idToObject[component.id]; + } + } + + /** + * Remove this component from our idToObject + */ + if (R3.Utils.Defined(this.idToObject[component.id])) { + + /** + * This is an interesting object for us - it could live in our linkedComponents + */ + for (var property in this.linkedComponents) { + if (this.linkedComponents.hasOwnProperty(property)) { + + if (this[property] instanceof Array) { + + this[property] = this[property].reduce( + function(result, object) { + if (object === component) { + /** + * No longer store this element + */ + } else { + result.push(object) + } + return result; + }, + [] + ); + + continue; + } + + if (this[property] === component) { + this[property] = null; + } + } + } + + /** + * Finally remove it from our idToObject + */ + delete this.idToObject[component.id]; + } + +}; + +/** + * R3.Component.prototype.instanceCreated + * Traverse all the parents of the component - if we are the parent of this component, add it to the idToObject + * object of this component. Then scan all the properties of this component, if one of them is this new component, + * also add it. + * @param data + */ +R3.Component.prototype.instanceCreated = function(data) { + + /** + * Ignore components already in our idToObject + */ + if (R3.Utils.Defined(this.idToObject[data.component.id])) { + return; + } + + /** + * Save a reference to ourselves + */ + if (data.component === this) { + this.idToObject[this.id] = this; + } + + /** + * Ignore components with no parent + */ + if (data.component.parent === null) { + return; + } + + /** + * Now discover the parents + */ + var parents = R3.Utils.GetParents(data.component); + + parents.map( + function(parent) { + if (parent === this) { + this.idToObject[data.component.id] = data.component; + } + }.bind(this) + ); + + /** + * Add all objects in our linkedComponents + */ + for (var property in this.linkedComponents) { + if (this.linkedComponents.hasOwnProperty(property)) { + + if (this[property] instanceof Array) { + + this[property].map( + function(object) { + if (object === data.component) { + this.idToObject[data.component.id] = data.component; + } + }.bind(this) + ); - if (R3.Utils.UndefinedOrNull(this[property])) { continue; } - if (this[property] instanceof R3.API.Component) { - this[property] = R3.Component.ConstructFromObject(this[property]); + if (this[property] === data.component) { + this.idToObject[data.component.id] = data.component; + } + } + } +}; - if (this[property].register) { - linkedObjects[property] = this[property].prototype.constructor; - } +R3.Component.prototype.buildVectoredComponents = function() { + for (var property in this) { + if (this.hasOwnProperty(property)) { + + if (property === 'parent') { + continue; } - if (this[property].isArray) - { - this[property] = this[property].reduce( - function(result, item) { + if ( + this[property] instanceof R3.API.Vector2 || + this[property] instanceof R3.API.Vector3 || + this[property] instanceof R3.API.Vector4 || + this[property] instanceof R3.API.Quaternion || + this[property] instanceof R3.API.Matrix4 || + this[property] instanceof R3.API.Color + ) { + var constructor = R3.GetConstructor(this[property]); + this[property] = new constructor(this[property]); + } + } + } +}; - if (item instanceof R3.API.Component) { - item = R3.Component.ConstructFromObject(item); - } +R3.Component.prototype.buildLinkedComponents = function() { - result.push(item); + /** + * Sanity Check + */ + if (R3.Utils.UndefinedOrNull(this.linkedComponents)) { + throw new Error(this.name + ' linkedComponents does not exist - this cannot happen'); + } - return result; - }, - [] - ); + /** + * By the time this function executes, we need to be sure we have the final list of this.linkedComponents + */ + for (var property in this.linkedComponents) { + + if (this.linkedComponents.hasOwnProperty(property)) { + + if (this.hasOwnProperty(property)) { + + /** + * Ignore null or undefined properties + */ + if (R3.Utils.UndefinedOrNull(this[property])) { + continue; + } + + /** + * Ignore properties which are already upgraded to runtime + */ + if (this[property] instanceof R3.Component) { + continue; + } + + /** + * Process Arrays first since they could also be considered as Objects + */ + if (this[property] instanceof Array) { + + /** + * We don't care about empty arrays + */ + if (this[property].length === 0) { + continue; + } + + /** + * Sanity check again - ensure our linked property is also an array and an array of length 1 + */ + var componentName = null; + + if (!(this.linkedComponents[property] instanceof Array)) { + componentName = R3.GetComponentName(this); + throw new Error(componentName + '.' + property + ' and ' + componentName + '.linkedComponents.' + property + ' type mismatch'); + } + + if (this.linkedComponents[property].length !== 1) { + componentName = R3.GetComponentName(this); + throw new Error(componentName + '.linkedObjects size should be 1'); + } + + /** + * Construct the runtime object if it is loaded + * The constructor *is NOT* the constructor of the 'linkedComponent' property - its the constructor of + * property + */ + + this[property] = this[property].reduce( + function (component, _property) { + + return function (result, item, index) { + + if (typeof item === 'string') { + + /** + * This object is not loaded yet - we should notify (a storage system perhaps) that it should be loaded and add it as a dependency + */ + var dependencyString = R3.GetComponentName(component) + '.' + _property + '[' + index + ']' + '(' + item + ')'; + R3.Utils.PushUnique(component.dependencies, dependencyString); + + R3.Event.Async( + R3.Event.LOAD_COMPONENT, + { + componentId: item, + }, + function (__component, __property, __index, __id, __dependencyString) { + return function (data) { + + if (R3.Utils.UndefinedOrNull(__component[__property])) { + throw new Error('The component took too long to load and the component property was damaged: ' + R3.GetComponentName(__component) + '.' + __property); + } + + if (R3.Utils.UndefinedOrNull(__component[__property][__index])) { + throw new Error('The component took too long to load and the component property was damaged inside: ' + R3.GetComponentName(__component) + '.' + __property + '[' + __index + ']'); + } + + if (__component[__property][__index] !== __id) { + throw new Error('The component loaded however it no longer exists as an id: ' + R3.GetComponentName(__component) + '.' + __property + '[' + __index + '] !==' + __id); + } + + __component[__property][__index] = data.component; + + var deleteIndex = __component.dependencies.indexOf(__dependencyString); + + if (deleteIndex === -1) { + throw new Error('The dependency ' + __dependencyString + ' was removed during the time that the component was loading'); + } + + __component.dependencies = __component.dependencies.splice(deleteIndex, 1); + + if (__component.dependencies.length === 0) { + + __component.performInstanceCreation(); + + } + + } + }(this, _property, index, item, dependencyString), + function (component, __property) { + return function (error) { + console.error('Failed to load ' + R3.GetComponentName(component) + '.' + __property + ' because of ' + error); + }; + }(this, _property) + ); + + result.push(item); + return result; + + } + + /** + * Now check if this item is already a Component - if so, ignore it + */ + if (item instanceof R3.Component) { + result.push(item); + return result; + } + + /** + * Now check if it is an API Component - if so - upgrade it to runtime + * All runtime objects call their API constructor implicitly - so no need to call the api constructor + */ + var constructor = null; + + if (item instanceof R3.API.Component) { + + /** + * We have the possibility that this component has already been fully constructed + */ + var constructed = R3.EntityManager.Instance.findComponentById(item.id); + if (constructed) { + result.push(constructed); + } else { + constructor = R3.GetConstructor(item); + result.push(new constructor(item)); + } + + return result; + } + + /** + * This is a problem - we need to know the component type of this object because + * we cannot figure out what type of component this is from the linkedObjects property - + * since the linkedObjects[property] could be a pure virtual class + */ + if (item instanceof Object) { + + var componentType = item.componentType; + + if (R3.Utils.UndefinedOrNull(componentType)) { + throw new Error('You need to specify the component type if you want to pass in a pure Object') + } + + constructor = R3.GetConstructorFromComponentType(componentType); + result.push(new constructor(item)); + return result; + } + + throw new Error('Unhandled situation - could not process : ' + R3.GetComponentName(component) + '.' + _property + '[' + index + ']'); + + }; + }(this, property), + [] + ); + + continue; + } + + /** + * Check if this is a straight-forward load of a component + */ + if (typeof this[property] === 'string') { + + /** + * This object is not loaded yet - we should notify (a storage system perhaps) that it should be loaded and add it as a dependency + */ + var dependencyString = R3.GetComponentName(component) + '.' + _property + '(' + this[property] + ')'; + R3.Utils.PushUnique(this.dependencies, dependencyString); + + R3.Event.Async( + R3.Event.LOAD_COMPONENT, + { + componentId: this[property], + }, + function (component, _property, _id, _dependencyString) { + return function (data) { + + if (R3.Utils.UndefinedOrNull(component[_property])) { + throw new Error('The component took too long to load and the component property was damaged: ' + R3.GetComponentName(component) + '.' + _property); + } + + if (component[_property] !== _id) { + throw new Error('The component loaded however it no longer exists as an id: ' + R3.GetComponentName(component) + '.' + _property + ' !==' + _id); + } + + component[_property] = data.component; + + var deleteIndex = component.dependencies.indexOf(_dependencyString); + + if (deleteIndex === -1) { + throw new Error('The dependency ' + _dependencyString + ' was removed during the time that the component was loading'); + } + + component.dependencies = component.dependencies.splice(deleteIndex, 1); + + if (component.dependencies.length === 0) { + component.performInstanceCreation(); + } + + } + }(this, property, this[property], dependencyString), + function (component, _property) { + return function (error) { + console.error('Failed to load ' + R3.GetComponentName(component) + '.' + _property + ' because of ' + error); + }; + }(this, property) + ); + + continue; + } + + var Constructor = null; + + /** + * Check if this is an API Component which needs to upgrade to a Runtime Component + * All runtime objects call their API constructor implicitly - so no need to call the api constructor + */ + if (this[property] instanceof R3.API.Component) { + + /** + * We have the possibility that this component has already been fully constructed + */ + var Constructed = R3.EntityManager.Instance.findComponentById(this[property].id); + if (Constructed) { + this[property] = Constructed; + } else { + Constructor = R3.GetConstructor(this[property]); + this[property] = new Constructor(this[property]); + } + + continue; + } + + /** + * If this is a normal Object, we need to know the componentType since linkedObjects[property] can be + * a pure virtual class + */ + if (this[property] instanceof Object) { + var componentType = this[property].componentType; + + if (R3.Utils.UndefinedOrNull(componentType)) { + throw new Error('You need to specify the component type if you want to pass in a pure Object') + } + + Constructor = R3.GetConstructorFromComponentType(componentType); + this[property] = new Constructor(this[property]); + continue; + } + + throw new Error('Unhandled situation - property is neither string, nor array nor object'); } } } - for (property in linkedObjects) { - this.linkedObjects[property] = linkedObjects[property]; + if (this.dependencies.length === 0) { + this.performInstanceCreation(); } }; @@ -122,125 +562,46 @@ R3.Component.prototype.upgradeToRuntime = function() { */ R3.Component.prototype.performInstanceCreation = function() { - var dependencies = true; - - if (R3.Utils.UndefinedOrNull(this.dependencies)) { - dependencies = false; - } - - if (this.dependencies && this.dependencies instanceof Array && this.dependencies.length === 0) { - dependencies = false; - } - - if (dependencies) { - throw new Error('performInstanceCreation called while this object still has dependencies'); - } + this.linked = true; delete this.dependencies; - /** - * Build ID to object should run through all sub components - - * if one is found which is not linked, this component is not linked fully - */ - this.buildIdToObject(); - - /** - * Don't try to create an instance of this object until it is fully linked - */ - if (this.linked) { - try { - this.createInstance(); - } catch (error) { - console.error(error); - } - } + this.createInstance(); }; R3.Component.prototype.createInstance = function() { - if (this.instance) { + if (R3.Utils.UndefinedOrNull(this.instance)) { + throw new Error(R3.GetComponentName(this) + ' has no instance at time of createInstance'); + } - this.loaded = true; + this.loaded = true; + R3.Event.Emit( + R3.Event.INSTANCE_CREATED, + { + component: this + } + ); + + if (this instanceof R3.Project) { R3.Event.Emit( - R3.Event.INSTANCE_CREATED, + R3.Event.PROJECT_LOADED, { - component: this + component:this } - ); - - R3.Event.Emit( - R3.Event.RESOLVE_DEPENDENCIES, - { - component: this - } - ); + ) } if (this instanceof R3.Entity) { - - if (this instanceof R3.Project) { - R3.Event.Emit( - R3.Event.PROJECT_LOADED, - { - entity:this - } - ) - } else { - R3.Event.Emit( - R3.Event.ENTITY_LOADED, - { - entity: this - } - ) - } - } -}; - -/** - * Dependencies are everything which is either a string or an object with an id which is linked to this object - * @returns {Array} - */ -R3.Component.prototype.getDependencies = function() { - - var dependencies = []; - - for (var property in this.linkedObjects) { - - if ( - this.linkedObjects.hasOwnProperty(property) && - this.hasOwnProperty(property) - ){ - if (typeof this[property] === 'string') { - R3.Utils.PushUnique(dependencies, this[property]); - } - - if (this[property] instanceof Array) { - this[property].map( - function(arrayProperty) { - - if (typeof arrayProperty === 'string') { - R3.Utils.PushUnique(dependencies, arrayProperty); - } - - if (arrayProperty && - arrayProperty instanceof R3.Component - ) { - R3.Utils.PushUnique(dependencies, arrayProperty.id); - } - } - ); - } - - if (this[property] && - this[property] instanceof R3.Component - ) { - R3.Utils.PushUnique(dependencies, this[property].id); + R3.Event.Emit( + R3.Event.ENTITY_LOADED, + { + component: this } - } + ) } - return dependencies; }; R3.Component.prototype.updateInstance = function(property) { @@ -318,34 +679,10 @@ R3.Component.prototype.updateFromInstance = function(property) { this[property] = this.instance[property]; }; -/** - * Wrapper for R3.Utils.GetFirstParent - * @param constructor - * @returns {*} - */ -R3.Component.prototype.getFirstParent = function(constructor) { - return R3.D3.GetFirstParent(this, constructor); -}; - -/** - * Wrapper for R3.Utils.GetParent - * @param property - * @param index - * @param constructor - * @returns {*} - */ -R3.Component.getParent = function(property, index, constructor) { - return R3.D3.GetParent(this, property, index, constructor); -}; - - R3.Component.prototype.toString = function() { return this.id; }; - - - /** * Returns the runtime friendly name * @param runtime @@ -381,20 +718,6 @@ R3.Component.GetRuntimeName = function(runtime) { return 'Default'; }; -/** - * @return {string} - */ -R3.Component.GetComponentName = function(componentType) { - - var info = R3.GetComponentInfo(componentType); - - if (info) { - return info.name; - } - - return 'unused'; -}; - /** * Gets a friendly name for the component * @param componentType @@ -403,10 +726,11 @@ R3.Component.GetComponentName = function(componentType) { */ R3.Component.GetComponentFriendlyName = function(componentType) { - var name = R3.Component.GetComponentName(componentType); + var name = R3.GetComponentInfo(componentType).name; name = name.replace('R3.D3.',''); - name = name.replace('.', ' '); + name = name.replace('R3.',''); + name = name.replace(/\./g, ' '); return name; }; @@ -414,54 +738,30 @@ R3.Component.GetComponentFriendlyName = function(componentType) { /** * @return {null || Object} */ -R3.Component.GetComponentRuntime = function(componentType) { - - var info = R3.GetComponentInfo(componentType); - - if (info) { - return info.runtime; - } - return null; -}; - -R3.Component.prototype.getComponentRuntime = function() { - - var info = R3.GetComponentInfo(this.componentType); - - return info.runtime; - -}; - - -/** - * @return {null || Object} - */ -R3.Component.GetComponentConstructor = function(componentType) { - - var info = R3.GetComponentInfo(componentType); - - if (info) { - return info.constructor; - } - - 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.GetComponentRuntime = function(component) { + return R3.GetComponentInfo(component.componentType).runtime; }; R3.Component.prototype.initialize = function(apiComponent) { - this.getComponentAPIConstructor().call( + if (apiComponent instanceof R3.API.Component) { + + /** + * The API Constructor has already been called - lets not duplicate work and copy the properties over + */ + for (var property in apiComponent) { + if (apiComponent.hasOwnProperty(property)) { + this[property] = apiComponent[property]; + } + } + + return; + } + + var apiConstructor = R3.GetAPIConstructor(this); + + apiConstructor.call( this, apiComponent ); @@ -591,8 +891,6 @@ R3.Component.prototype.getChildrenComponents = function() { var components = []; - this.buildIdToObject(); - Object.keys(this.idToObject).map( function(objectId) { if (this.id !== objectId) { @@ -603,116 +901,116 @@ R3.Component.prototype.getChildrenComponents = function() { return components; }; - -R3.Component.prototype.processComponent = function(object) { - if (object instanceof R3.Component) { - - object.buildIdToObject(); - - if (!object.linked) { - this.linked = false; - } - - var idToObject = object.idToObject; - - for (var objectProperty in idToObject) { - if (idToObject.hasOwnProperty(objectProperty)) { - this.idToObject[objectProperty] = idToObject[objectProperty]; - } - } - - if (object.id) { - this.idToObject[object.id] = object; - } else { - console.warn('Object with no ID passed: ' + object) - } - - } else if (typeof object === 'string') { - this.linked = false; - } else { - console.warn('Unhandled type of object: ', object); - } -}; +// +// R3.Component.prototype.processComponent = function(object) { +// if (object instanceof R3.Component) { +// +// object.buildIdToObject(); +// +// if (!object.linked) { +// this.linked = false; +// } +// +// var idToObject = object.idToObject; +// +// for (var objectProperty in idToObject) { +// if (idToObject.hasOwnProperty(objectProperty)) { +// this.idToObject[objectProperty] = idToObject[objectProperty]; +// } +// } +// +// if (object.id) { +// this.idToObject[object.id] = object; +// } else { +// console.warn('Object with no ID passed: ' + object) +// } +// +// } else if (typeof object === 'string') { +// this.linked = false; +// } else { +// console.warn('Unhandled type of object: ', object); +// } +// }; /** * This function - builds an 'id to object' object - which contains the ids which point directly * to its corresponding object, for all the objects contained inside this object */ -R3.Component.prototype.buildIdToObject = function() { - - if (this.building) { - return; - } - - /** - * If this component 'building' flag is true - it is in the process of building idToObject up the callstack and the - * caller should know to not try to build idToObject again (prevent infinite recursion) - */ - this.building = true; - - /** - * If any child component is not fully linked, this component will show as not linked - * @type {boolean} - */ - this.linked = true; - - this.idToObject = {}; - - for (var property in this.linkedObjects) { - if ( - this.linkedObjects.hasOwnProperty(property) && - this.hasOwnProperty(property) && - this[property] && - property.indexOf('parent') !== 0 - ) { - - if (this.linkedObjects[property] instanceof Array) { - - /** - * Remove null objects (can happen) - */ - this[property] = this[property].filter( - function(object) { - if (object === null) { - console.log('null object found and removed'); - return false; - } - return true; - } - ); - - this[property].map( - function(object) { - this.processComponent(object); - }.bind(this) - ); - - } else { - this.processComponent(this[property]); - } - } - } - - if (this instanceof R3.D3.Scene) { - if (!this.storeClones) { - this.clones.map( - function(clone) { - if (this.idToObject.hasOwnProperty(clone.id)) { - delete this.idToObject[clone.id]; - } - }.bind(this) - ) - } - } - - this.idToObject[this.id] = this; - - this.building = false; -}; +// R3.Component.prototype.buildIdToObject = function() { +// +// if (this.building) { +// return; +// } +// +// /** +// * If this component 'building' flag is true - it is in the process of building idToObject up the callstack and the +// * caller should know to not try to build idToObject again (prevent infinite recursion) +// */ +// this.building = true; +// +// /** +// * If any child component is not fully linked, this component will show as not linked +// * @type {boolean} +// */ +// this.linked = true; +// +// this.idToObject = {}; +// +// for (var property in this.linkedComponents) { +// if ( +// this.linkedComponents.hasOwnProperty(property) && +// this.hasOwnProperty(property) && +// this[property] && +// property.indexOf('parent') !== 0 +// ) { +// +// if (this.linkedComponents[property] instanceof Array) { +// +// /** +// * Remove null objects (can happen) +// */ +// this[property] = this[property].filter( +// function(object) { +// if (object === null) { +// console.log('null object found and removed'); +// return false; +// } +// return true; +// } +// ); +// +// this[property].map( +// function(object) { +// this.processComponent(object); +// }.bind(this) +// ); +// +// } else { +// this.processComponent(this[property]); +// } +// } +// } +// +// if (this instanceof R3.D3.Scene) { +// if (!this.storeClones) { +// this.clones.map( +// function(clone) { +// if (this.idToObject.hasOwnProperty(clone.id)) { +// delete this.idToObject[clone.id]; +// } +// }.bind(this) +// ) +// } +// } +// +// this.idToObject[this.id] = this; +// +// this.building = false; +// }; R3.Component.prototype.generateNewIds = function() { - this.buildIdToObject(); + // this.buildIdToObject(); var codeComponents = R3.EntityManager.Instance.queryComponents(R3.Component.CUSTOM_CODE); @@ -741,26 +1039,7 @@ R3.Component.prototype.generateNewIds = function() { }; -/** - * TODO: don't remove components which are still in use elsewhere - this is important to prevent 'register out - * of sync' messages - */ -R3.Component.prototype.remove = function() { - this.buildIdToObject(); - - Object.keys(this.idToObject).map( - function(componentId){ - R3.Event.Emit( - R3.Event.REMOVE_COMPONENT, - { - component : this.idToObject[componentId] - } - ) - }.bind(this) - ); - -}; R3.Component.prototype.replace = function(componentType) { @@ -849,8 +1128,6 @@ R3.Component.prototype.save = function(remote) { var saved = []; var failed = []; - this.buildIdToObject(); - if (this.saveSubscription || this.saveErrorSubscription) { console.warn('another save is in progress'); return; @@ -1054,17 +1331,8 @@ R3.Component.Construct = function(componentType) { R3.Component.ConstructFromObject = function(rawComponentObject) { - var runtimeComponent = null; - var info = R3.GetComponentInfo(rawComponentObject.componentType); - var runtime = R3.Component.GetRuntimeObject(info); + return new info.constructor(rawComponentObject); - if (runtime) { - runtimeComponent = new info.constructor(runtime, rawComponentObject); - } else { - runtimeComponent = new info.constructor(rawComponentObject); - } - - return runtimeComponent; }; diff --git a/src/r3-api-canvas.js b/src/r3-api-canvas.js index 7036ec2..ebd11ec 100644 --- a/src/r3-api-canvas.js +++ b/src/r3-api-canvas.js @@ -15,12 +15,12 @@ R3.API.Canvas = function( this.autoUpdateSize = apiComponent.autoUpdateSize; if (R3.Utils.UndefinedOrNull(apiComponent.width)) { - apiComponent.width = 512; + apiComponent.width = 450; } this.width = apiComponent.width; if (R3.Utils.UndefinedOrNull(apiComponent.height)) { - apiComponent.height = 512; + apiComponent.height = 450; } this.height = apiComponent.height; @@ -28,10 +28,11 @@ R3.API.Canvas = function( apiComponent.offset = new R3.API.Vector2( { parent : this, - register : true - }, - 0, - 0 + register : true, + name : this.name + ' - Offset', + x : 0, + y : 0 + } ); } this.offset = apiComponent.offset; diff --git a/src/r3-api-controls-0.js b/src/r3-api-controls-0.js index eb37887..dd395e3 100644 --- a/src/r3-api-controls-0.js +++ b/src/r3-api-controls-0.js @@ -1,28 +1,23 @@ /** * R3.API.Controls * @param apiComponent - * @param canvas + * + * @property canvas + * * @constructor */ R3.API.Controls = function( - apiComponent, - canvas + apiComponent ) { - __API_COMPONENT__; + __DEFINE_API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { - R3.Event.Emit( - R3.Event.GET_PROJECT_CANVAS, - { - controls : this - }, - function(projectCanvas) { - apiComponent.canvas = projectCanvas; - } - ) + apiComponent.canvas = null; } this.canvas = apiComponent.canvas; + + this.previousCanvas = this.canvas; }; R3.API.Controls.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-controls-d3-0.js b/src/r3-api-controls-d3-0.js index 1a96d0e..36578e1 100644 --- a/src/r3-api-controls-d3-0.js +++ b/src/r3-api-controls-d3-0.js @@ -1,22 +1,33 @@ /** - * Raw Controls API object + * R3.API.Controls.D3 + * @param apiComponent + * + * @property camera + * @property enabled + * * @constructor */ R3.API.Controls.D3 = function( apiComponent ) { + __DEFINE_API_COMPONENT__ + R3.API.Controls.call( this, apiComponent ); if (R3.Utils.UndefinedOrNull(apiComponent.camera)) { - var project = this.getFirstParent(R3.API.Project); - apiComponent.camera = project.cameras[R3.API.Project.CAMERA_INDEX_EDIT]; + apiComponent.camera = null; } this.camera = apiComponent.camera; + if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) { + apiComponent.enabled = true; + } + this.enabled = apiComponent.enabled; + }; R3.API.Controls.D3.prototype = Object.create(R3.API.Controls.prototype); diff --git a/src/r3-api-controls-d3-firstPerson.js b/src/r3-api-controls-d3-firstPerson.js index 7267df9..c28ca34 100644 --- a/src/r3-api-controls-d3-firstPerson.js +++ b/src/r3-api-controls-d3-firstPerson.js @@ -7,15 +7,7 @@ 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; + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.movementSpeed)) { apiComponent.movementSpeed = 1.0; @@ -82,6 +74,10 @@ R3.API.Controls.D3.FirstPerson = function( } this.autoSpeedFactor = apiComponent.autoSpeedFactor; + R3.API.Controls.D3.call( + this, + apiComponent + ); }; R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.D3.prototype); diff --git a/src/r3-api-controls-d3-orbit.js b/src/r3-api-controls-d3-orbit.js index 083d8a6..542386e 100644 --- a/src/r3-api-controls-d3-orbit.js +++ b/src/r3-api-controls-d3-orbit.js @@ -7,21 +7,13 @@ R3.API.Controls.D3.Orbit = function( apiComponent ) { - R3.API.Controls.D3.call( - this, - apiComponent - ); + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.target)) { apiComponent.target = null; } this.target = apiComponent.target; - if (R3.Utils.UndefinedOrNull(apiComponent.enabled)) { - apiComponent.enabled = true; - } - this.enabled = apiComponent.enabled; - if (R3.Utils.UndefinedOrNull(apiComponent.minPolarAngle)) { apiComponent.minPolarAngle = 0; } @@ -87,6 +79,10 @@ R3.API.Controls.D3.Orbit = function( } this.enableKeys = apiComponent.enableKeys; + R3.API.Controls.D3.call( + this, + apiComponent + ); }; R3.API.Controls.D3.Orbit.prototype = Object.create(R3.API.Controls.D3.prototype); diff --git a/src/r3-api-controls-keyboard.js b/src/r3-api-controls-keyboard.js index de6840a..653b390 100644 --- a/src/r3-api-controls-keyboard.js +++ b/src/r3-api-controls-keyboard.js @@ -6,6 +6,9 @@ R3.API.Controls.Keyboard = function( apiComponent ) { + + __API_COMPONENT__; + R3.API.Controls.call( this, apiComponent diff --git a/src/r3-api-controls-mouse.js b/src/r3-api-controls-mouse.js index f09de74..d94f5b5 100644 --- a/src/r3-api-controls-mouse.js +++ b/src/r3-api-controls-mouse.js @@ -6,6 +6,9 @@ R3.API.Controls.Mouse = function( apiComponent ) { + + __API_COMPONENT__; + R3.API.Controls.call( this, apiComponent diff --git a/src/r3-api-controls-touch.js b/src/r3-api-controls-touch.js index 13fa4b3..142af6c 100644 --- a/src/r3-api-controls-touch.js +++ b/src/r3-api-controls-touch.js @@ -1,24 +1,27 @@ /** - * @param apiControls - * @param sensitivity + * R3.API.Controls.Touch + * @param apiComponent + * + * @property sensitivity + * * @constructor */ R3.API.Controls.Touch = function( - apiControls, - sensitivity + apiComponent ) { - R3.API.Controls.call( - this, - apiControls, - apiControls.canvas - ); + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.sensitivity)) { apiComponent.sensitivity = 5; } this.sensitivity = apiComponent.sensitivity; + R3.API.Controls.call( + this, + apiComponent + ); + }; R3.API.Controls.Touch.prototype = Object.create(R3.API.Controls.prototype); diff --git a/src/r3-api-domElement.js b/src/r3-api-domElement.js index 5fd45a8..5de3245 100644 --- a/src/r3-api-domElement.js +++ b/src/r3-api-domElement.js @@ -13,6 +13,7 @@ R3.API.DomElement = function( apiComponent.domElementId = ''; } this.domElementId = apiComponent.domElementId; + }; R3.API.DomElement.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-entityManager.js b/src/r3-api-entityManager.js deleted file mode 100644 index fd34539..0000000 --- a/src/r3-api-entityManager.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * 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-graph-0.js b/src/r3-api-graph-0.js index cd61b04..50be83b 100644 --- a/src/r3-api-graph-0.js +++ b/src/r3-api-graph-0.js @@ -12,10 +12,10 @@ R3.API.Graph = function( __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { - apiComponent.domElement = null; + if (R3.Utils.UndefinedOrNull(apiComponent.query)) { + apiComponent.query = null; } - this.domElement = apiComponent.domElement; + this.query = apiComponent.query; }; diff --git a/src/r3-api-graph-barchart-0.js b/src/r3-api-graph-barchart-0.js index 2e16916..b52d9b5 100644 --- a/src/r3-api-graph-barchart-0.js +++ b/src/r3-api-graph-barchart-0.js @@ -11,8 +11,14 @@ R3.API.Graph.Barchart = function( this, apiComponent ); - + + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; + } + this.domElement = apiComponent.domElement; + }; 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 index 409c4ac..ae5a8bb 100644 --- a/src/r3-api-graph-barchart-stacked.js +++ b/src/r3-api-graph-barchart-stacked.js @@ -11,8 +11,13 @@ R3.API.Graph.Barchart.Stacked = function( this, apiComponent ); - + + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; + } + this.domElement = apiComponent.domElement; + }; -R3.API.Graph.Barchart.prototype = Object.create(R3.API.Graph.Barchart.prototype); -R3.API.Graph.Barchart.prototype.constructor = R3.API.Graph.Barchart; +R3.API.Graph.Barchart.Stacked.prototype = Object.create(R3.API.Graph.Barchart.prototype); +R3.API.Graph.Barchart.Stacked.prototype.constructor = R3.API.Graph.Barchart.Stacked; diff --git a/src/r3-api-graph-metric.js b/src/r3-api-graph-metric.js index 860baef..5c9a63a 100644 --- a/src/r3-api-graph-metric.js +++ b/src/r3-api-graph-metric.js @@ -11,7 +11,12 @@ R3.API.Graph.Metric = function( this, apiComponent ); - + + if (R3.Utils.UndefinedOrNull(apiComponent.domElements)) { + apiComponent.domElements = []; + } + this.domElements = apiComponent.domElements; + }; R3.API.Graph.Metric.prototype = Object.create(R3.API.Graph.prototype); diff --git a/src/r3-api-graph-table.js b/src/r3-api-graph-table.js index 637c952..a0094ed 100644 --- a/src/r3-api-graph-table.js +++ b/src/r3-api-graph-table.js @@ -11,7 +11,22 @@ R3.API.Graph.Table = function( this, apiComponent ); - + + if (R3.Utils.UndefinedOrNull(apiComponent.domElement)) { + apiComponent.domElement = null; + } + this.domElement = apiComponent.domElement; + + if (R3.Utils.UndefinedOrNull(apiComponent.columns)) { + apiComponent.columns = []; + } + this.columns = apiComponent.columns; + + if (R3.Utils.UndefinedOrNull(apiComponent.rows)) { + apiComponent.rows = []; + } + this.rows = apiComponent.rows; + }; R3.API.Graph.Table.prototype = Object.create(R3.API.Graph.prototype); diff --git a/src/r3-api-mouse.js b/src/r3-api-mouse.js index 8e66e94..0680142 100644 --- a/src/r3-api-mouse.js +++ b/src/r3-api-mouse.js @@ -9,15 +9,16 @@ R3.API.Mouse = function( __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiComponent.x)) { - apiComponent.x = 0; + if (R3.Utils.UndefinedOrNull(apiComponent.position)) { + apiComponent.position = new R3.API.Vector2( + { + parent : this, + register : true, + name : this.name + ' - Position' + } + ); } - this.x = apiComponent.x; - - if (R3.Utils.UndefinedOrNull(apiComponent.y)) { - apiComponent.y = 0; - } - this.y = apiComponent.y; + this.position = apiComponent.position; }; diff --git a/src/r3-api-project-0.js b/src/r3-api-project-0.js new file mode 100644 index 0000000..9f86b12 --- /dev/null +++ b/src/r3-api-project-0.js @@ -0,0 +1,57 @@ +/** + * R3.API.Project + * @param apiComponent + * + * @property users + * @property isPublic + * @property entities + * @property controls + * @property images + * @property applicationMode + * + * @constructor + */ +R3.API.Project = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.isPublic)) { + apiComponent.isPublic = true; + } + this.isPublic = apiComponent.isPublic; + + if (R3.Utils.UndefinedOrNull(apiComponent.entities)) { + apiComponent.entities = []; + } + this.entities = apiComponent.entities; + + if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { + apiComponent.controls = [] + } + this.controls = apiComponent.controls; + + if (R3.Utils.UndefinedOrNull(apiComponent.images)) { + apiComponent.images = [] + } + this.images = apiComponent.images; + + 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.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-project-d2.js b/src/r3-api-project-d2.js new file mode 100644 index 0000000..cffb8a6 --- /dev/null +++ b/src/r3-api-project-d2.js @@ -0,0 +1,65 @@ +/** + * R3.API.Project + * @param apiComponent + * + * @property renderers + * @property controls + * + * @constructor + */ +R3.API.Project.D2 = function( + apiComponent +) { + + __API_COMPONENT__; + + if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) { + apiComponent.renderers = [ + new R3.API.Renderer.D2( + { + parent : this, + name : this.name + ' - 2D Renderer' + } + ) + ]; + } + this.renderers = apiComponent.renderers; + + if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { + apiComponent.controls = [ + new R3.API.Controls.Mouse( + { + parent : this, + name : this.name + ' - Mouse Controls', + canvas : this.renderers[0].canvas + } + ), + new R3.API.Controls.Keyboard( + { + parent : this, + name : this.name + ' - Keyboard Controls', + canvas : this.renderers[0].canvas + } + ), + new R3.API.Controls.Touch( + { + parent : this, + name : this.name + ' - Touch Controls', + canvas : this.renderers[0].canvas + } + ) + ] + } + this.controls = apiComponent.controls; + + R3.API.Project.call( + this, + apiComponent + ); + + + +}; + +R3.API.Project.D2.prototype = Object.create(R3.API.Project.prototype); +R3.API.Project.D2.prototype.constructor = R3.API.Project.D2; diff --git a/src/r3-api-project-d3.js b/src/r3-api-project-d3.js new file mode 100644 index 0000000..5f22f51 --- /dev/null +++ b/src/r3-api-project-d3.js @@ -0,0 +1,142 @@ +/** + * R3.API.Project + * @param apiComponent + * + * @property renderers + * @property renderTargets + * @property cameras + * @property controls + * @property audios + * + * @constructor + */ +R3.API.Project.D3 = function( + apiComponent +) { + + /** + * Override Controls for 3D projects + */ + __API_COMPONENT__; + + /** + * This means we need to construct the cameras first if they are not coming from the database + */ + if (R3.Utils.UndefinedOrNull(apiComponent.cameras)) { + var editCamera = new R3.D3.API.Camera.Perspective( + { + parent : this, + name : this.name + ' - Edit Camera' + } + ); + var runCamera = new R3.D3.API.Camera.Perspective( + { + parent : this, + name : this.name + ' - Run Camera' + } + ); + apiComponent.cameras = [editCamera, runCamera]; + } + this.cameras = apiComponent.cameras; + + if (R3.Utils.UndefinedOrNull(apiComponent.mouse)) { + apiComponent.mouse = new R3.API.Mouse( + { + parent: this, + name: this.name + ' - Mouse' + } + ); + } + this.mouse = apiComponent.mouse; + + if (R3.Utils.UndefinedOrNull(apiComponent.raycaster)) { + apiComponent.raycaster = new R3.D3.API.Raycaster( + { + parent: this, + name: this.name + ' - Raycaster' + } + ); + } + this.raycaster = apiComponent.raycaster; + + if (R3.Utils.UndefinedOrNull(apiComponent.clock)) { + apiComponent.clock = new R3.API.Clock( + { + parent: this, + name: this.name + ' - Clock' + } + ); + } + this.clock = apiComponent.clock; + + /** + * And we should also override here the renderers if they are not coming from the API + */ + if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) { + apiComponent.renderers = [ + new R3.API.Renderer.D3.Canvas( + { + parent : this, + name : this.name + ' - 3D Canvas Renderer' + } + ) + ]; + } + this.renderers = apiComponent.renderers; + + /** + * Now override the controls before initializing the other API properties + */ + if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { + apiComponent.controls = [ + new R3.API.Controls.Mouse( + { + parent : this, + name : this.name + ' - Mouse Controls', + canvas : this.renderers[0].canvas + } + ), + new R3.API.Controls.Keyboard( + { + parent : this, + name : this.name + ' - Keyboard Controls', + canvas : this.renderers[0].canvas + } + ), + new R3.API.Controls.Touch( + { + parent : this, + name : this.name + ' - Touch Controls', + canvas : this.renderers[0].canvas + } + ), + new R3.API.Controls.D3.Orbit( + { + parent : this, + name : this.name + ' - Orbit Controls', + camera : editCamera, + canvas : this.renderers[0].canvas + } + ) + ]; + } + + if (R3.Utils.UndefinedOrNull(apiComponent.renderTargets)) { + apiComponent.renderTargets = []; + } + this.renderTargets = apiComponent.renderTargets; + + if (R3.Utils.UndefinedOrNull(apiComponent.audios)) { + apiComponent.audios = []; + } + this.audios = apiComponent.audios; + + R3.API.Project.call( + this, + apiComponent + ); + +}; + +R3.API.Project.D3.prototype = Object.create(R3.API.Project.prototype); +R3.API.Project.D3.prototype.constructor = R3.API.Project.D3; diff --git a/src/r3-api-project.js b/src/r3-api-project.js deleted file mode 100644 index a8cf487..0000000 --- a/src/r3-api-project.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * R3.API.Project - * @param apiComponent - * - * @property users - * @property isPublic - * @property entities - * @property renderers - * @property renderTargets - * @property cameras - * @property controls - * @property audios - * @property applicationMode - * - * @constructor - */ -R3.API.Project = function( - apiComponent -) { - - __API_COMPONENT__; - - if (R3.Utils.UndefinedOrNull(apiComponent.users)) { - throw new Error('Only registered users can create projects'); - } - this.users = apiComponent.users; - - if (R3.Utils.UndefinedOrNull(apiComponent.isPublic)) { - apiComponent.isPublic = true; - } - this.isPublic = apiComponent.isPublic; - - if (R3.Utils.UndefinedOrNull(apiComponent.entities)) { - apiComponent.entities = []; - } - this.entities = apiComponent.entities; - - if (R3.Utils.UndefinedOrNull(apiComponent.renderers)) { - apiComponent.renderers = [new R3.API.Renderer.D3()]; - } - this.renderers = apiComponent.renderers; - - if (R3.Utils.UndefinedOrNull(apiComponent.renderTargets)) { - apiComponent.renderTargets = []; - } - this.renderTargets = apiComponent.renderTargets; - - if (R3.Utils.UndefinedOrNull(apiComponent.cameras)) { - var editCamera = new R3.D3.API.Camera.Perspective( - { - name : 'Edit Camera' - } - ); - var runCamera = new R3.D3.API.Camera.Perspective( - { - name : 'Run Camera' - } - ); - apiComponent.cameras = [editCamera, runCamera]; - } - this.cameras = apiComponent.cameras; - - if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { - apiComponent.controls = []; - } - this.controls = apiComponent.controls; - - if (R3.Utils.UndefinedOrNull(apiComponent.audios)) { - apiComponent.audios = []; - } - 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.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-0.js b/src/r3-api-quaternion-0.js index f9a2e0d..2784e3a 100644 --- a/src/r3-api-quaternion-0.js +++ b/src/r3-api-quaternion-0.js @@ -34,7 +34,8 @@ R3.API.Quaternion = function( if (R3.Utils.UndefinedOrNull(apiComponent.axis)) { apiComponent.axis = new R3.API.Vector3( { - parent : this, + parent : this.parent, + name : this.parent.name + ' - Quaternion Axis', register : this.register } ); diff --git a/src/r3-api-query-0.js b/src/r3-api-query-0.js index 0051cef..0cee754 100644 --- a/src/r3-api-query-0.js +++ b/src/r3-api-query-0.js @@ -8,7 +8,6 @@ * @property timezone * @property size * @property text - * @property onData * * @constructor */ @@ -24,7 +23,7 @@ R3.API.Query = function( this.path = apiComponent.path; if (R3.Utils.UndefinedOrNull(apiComponent.start)) { - apiComponent.start = 'now-7d'; + apiComponent.start = 'now-365d'; } this.start = apiComponent.start; @@ -33,13 +32,13 @@ R3.API.Query = function( } this.end = apiComponent.end; - if (R3.Utils.UndefinedOrNull(apiComponent.timezone)) { - apiComponent.timezone = 'Europe/Berlin'; + if (R3.Utils.UndefinedOrNull(apiComponent.timeZone)) { + apiComponent.timeZone = 'Europe/Berlin'; } - this.timezone = apiComponent.timezone; + this.timeZone = apiComponent.timeZone; if (R3.Utils.UndefinedOrNull(apiComponent.size)) { - apiComponent.size = 0; + apiComponent.size = 100; } this.size = apiComponent.size; @@ -48,13 +47,6 @@ R3.API.Query = function( } 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); @@ -65,4 +57,14 @@ 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'; +R3.API.Query.QUERY_LOGIN_TYPE = 'QUERY_LOGIN_TYPE'; +R3.API.Query.QUERY_ACKNOWLEDGED = 'QUERY_ACKNOWLEDGED'; +R3.API.Query.LOGIN_TYPE_ALL = 'local|remote|application|vpn'; +R3.API.Query.LOGIN_TYPE_DEVICE = 'local|remote'; +R3.API.Query.LOGIN_TYPE_APPLICATION = 'application'; +R3.API.Query.LOGIN_TYPE_VPN = 'vpn'; + +R3.API.Query.ACKNOWLEDGED_ALL = 'true|false'; +R3.API.Query.ACKNOWLEDGED_TRUE = 'true'; +R3.API.Query.ACKNOWLEDGED_FALSE = 'false'; \ No newline at end of file diff --git a/src/r3-api-query-alerts-0.js b/src/r3-api-query-alerts-0.js index e5fba06..e74e5ba 100644 --- a/src/r3-api-query-alerts-0.js +++ b/src/r3-api-query-alerts-0.js @@ -7,17 +7,18 @@ R3.API.Query.Alerts = function( apiComponent ) { - R3.API.Query.call( - this, - apiComponent - ); + __DEFINE_API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.path)) { apiComponent.path = '/alerts/_search'; } this.path = apiComponent.path; - + R3.API.Query.call( + this, + apiComponent + ); + }; R3.API.Query.Alerts.prototype = Object.create(R3.API.Query.prototype); diff --git a/src/r3-api-query-alerts-buckets.js b/src/r3-api-query-alerts-buckets.js index 402b22b..37cf915 100644 --- a/src/r3-api-query-alerts-buckets.js +++ b/src/r3-api-query-alerts-buckets.js @@ -10,66 +10,94 @@ R3.API.Query.Alerts.Buckets = function( apiComponent ) { + __DEFINE_API_COMPONENT__ + + /** + * Override default size + */ + if (R3.Utils.UndefinedOrNull(apiComponent)) { + apiComponent = { + size : 100 + }; + } + + if (R3.Utils.UndefinedOrNull(apiComponent.size)) { + apiComponent.size = 100; + } + + /** + * Override default text + */ + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "priority": {\n' + + ' "order": "asc"\n' + + ' },\n' + + ' "acknowledged": {\n' + + ' "order": "asc"\n' + + ' },\n' + + ' "' + R3.API.Query.QUERY_BUCKET_FIELD + '": {\n' + + ' "order": "asc"\n' + + ' }\n' + + ' }\n' + + ' ], \n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' }, \n' + + ' "aggs": {\n' + + ' "descriptions": {\n' + + ' "terms" : { "field" : "' + R3.API.Query.QUERY_BUCKET_FIELD + '" },\n' + + ' "aggs": {\n' + + ' "priorities": {\n' + + ' "histogram": {\n' + + ' "field": "priority",\n' + + ' "interval": "1",\n' + + ' "min_doc_count": 0\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' }, \n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte" : "' + R3.API.Query.QUERY_START + '", \n' + + ' "lt" : "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' } \n' + + '}\n'; + } + this.text = apiComponent.text; + + if (R3.Utils.UndefinedOrNull(apiComponent.bucketField)) { + apiComponent.bucketField = R3.API.Query.Alerts.Buckets.BUCKET_FIELD_ALERT_TYPE; + } + this.bucketField = apiComponent.bucketField; + 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; + +R3.API.Query.Alerts.Buckets.BUCKET_FIELD_ALERT_TYPE = 'alert_type.keyword'; +R3.API.Query.Alerts.Buckets.BUCKET_FIELD_COUNTRY = 'geo.country.keyword'; +R3.API.Query.Alerts.Buckets.BUCKET_FIELD_HOSTNAME = 'device.hostname.keyword'; +R3.API.Query.Alerts.Buckets.BUCKET_FIELD_IP_V4 = 'device.ip_v4.keyword'; +R3.API.Query.Alerts.Buckets.BUCKET_FIELD_USERNAME = 'login.username.keyword'; diff --git a/src/r3-api-query-alerts-firstTimeLogin-0.js b/src/r3-api-query-alerts-firstTimeLogin-0.js new file mode 100644 index 0000000..9d5b997 --- /dev/null +++ b/src/r3-api-query-alerts-firstTimeLogin-0.js @@ -0,0 +1,67 @@ +/** + * R3.API.Query.Alerts.FirstTimeLogin + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.FirstTimeLogin = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_ALL; + } + this.loginType = apiComponent.loginType; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "login.destination_ip.keyword": {\n' + + ' "order": "asc"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte" : "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt" : "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' },\n' + + ' {\n' + + ' "term" : { "acknowledged": "false" }\n' + + ' },\n' + + ' {\n' + + ' "term" : { "alert_type.keyword": "First Time Login" }\n' + + ' },\n' + + ' {\n' + + ' "regexp" : { "login.login_type.keyword": "' + R3.API.Query.QUERY_LOGIN_TYPE + '" }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}'; + } + this.text = apiComponent.text; + + R3.API.Query.Alerts.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Alerts.FirstTimeLogin.prototype = Object.create(R3.API.Query.Alerts.prototype); +R3.API.Query.Alerts.FirstTimeLogin.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin; diff --git a/src/r3-api-query-alerts-firstTimeLogin-applications.js b/src/r3-api-query-alerts-firstTimeLogin-applications.js new file mode 100644 index 0000000..4339b87 --- /dev/null +++ b/src/r3-api-query-alerts-firstTimeLogin-applications.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Alerts.FirstTimeLogin.Applications + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.FirstTimeLogin.Applications = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_APPLICATION; + } + + R3.API.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Alerts.FirstTimeLogin.Applications.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype); +R3.API.Query.Alerts.FirstTimeLogin.Applications.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.Applications; diff --git a/src/r3-api-query-alerts-firstTimeLogin-devices.js b/src/r3-api-query-alerts-firstTimeLogin-devices.js new file mode 100644 index 0000000..fdde334 --- /dev/null +++ b/src/r3-api-query-alerts-firstTimeLogin-devices.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Alerts.FirstTimeLogin.Devices + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.FirstTimeLogin.Devices = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_DEVICE; + } + + R3.API.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Alerts.FirstTimeLogin.Devices.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype); +R3.API.Query.Alerts.FirstTimeLogin.Devices.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.Devices; diff --git a/src/r3-api-query-alerts-firstTimeLogin-vpn.js b/src/r3-api-query-alerts-firstTimeLogin-vpn.js new file mode 100644 index 0000000..9cd2011 --- /dev/null +++ b/src/r3-api-query-alerts-firstTimeLogin-vpn.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Alerts.FirstTimeLogin.VPN + * @param apiComponent + * @constructor + */ +R3.API.Query.Alerts.FirstTimeLogin.VPN = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_VPN; + } + + R3.API.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Alerts.FirstTimeLogin.VPN.prototype = Object.create(R3.API.Query.Alerts.FirstTimeLogin.prototype); +R3.API.Query.Alerts.FirstTimeLogin.VPN.prototype.constructor = R3.API.Query.Alerts.FirstTimeLogin.VPN; diff --git a/src/r3-api-query-alerts-list.js b/src/r3-api-query-alerts-list.js index b120bf7..3daaae5 100644 --- a/src/r3-api-query-alerts-list.js +++ b/src/r3-api-query-alerts-list.js @@ -7,55 +7,73 @@ R3.API.Query.Alerts.List = function( apiComponent ) { - R3.API.Query.Alerts.call( - this, - apiComponent - ); + __DEFINE_API_COMPONENT__ + + /** + * Override default size + */ + if (R3.Utils.UndefinedOrNull(apiComponent)) { + apiComponent = { + size : 100 + }; + } 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 + '"\ - }\ - }\ - }\ - ]\ - }\ - }\ -}'; + if (R3.Utils.UndefinedOrNull(apiComponent.columns)) { + apiComponent.columns = []; + } + this.columns = apiComponent.columns; + + if (R3.Utils.UndefinedOrNull(apiComponent.rows)) { + apiComponent.rows = []; + } + this.rows = apiComponent.rows; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "priority": {\n' + + ' "order": "asc",\n' + + ' "unmapped_type": "boolean"\n' + + ' },\n' + + ' "alert_type.keyword": {\n' + + ' "order": "asc",\n' + + ' "unmapped_type": "boolean"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte": "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt": "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}'; + } + this.text = apiComponent.text; + + R3.API.Query.Alerts.call( + this, + apiComponent + ); }; R3.API.Query.Alerts.List.prototype = Object.create(R3.API.Query.Alerts.prototype); diff --git a/src/r3-api-query-alerts-summary.js b/src/r3-api-query-alerts-summary.js index ec36682..3cf2854 100644 --- a/src/r3-api-query-alerts-summary.js +++ b/src/r3-api-query-alerts-summary.js @@ -1,56 +1,70 @@ /** * R3.API.Query.Alerts.Summary * @param apiComponent + * + * @priorities + * * @constructor */ R3.API.Query.Alerts.Summary = function( apiComponent ) { + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.priorities)) { + apiComponent.priorities = []; + } + this.priorities = apiComponent.priorities; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "timestamp": {\n' + + ' "order": "desc",\n' + + ' "unmapped_type": "boolean"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "aggs": {\n' + + ' "priorities": {\n' + + ' "histogram": {\n' + + ' "field": "priority",\n' + + ' "interval": "1",\n' + + ' "min_doc_count": 0\n' + + ' }\n' + + ' }\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte": "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt": "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}\n'; + } + this.text = apiComponent.text; + 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); diff --git a/src/r3-api-query-alerts-timeseries.js b/src/r3-api-query-alerts-timeseries.js index a5d9e5c..2ca752a 100644 --- a/src/r3-api-query-alerts-timeseries.js +++ b/src/r3-api-query-alerts-timeseries.js @@ -7,61 +7,66 @@ R3.API.Query.Alerts.Timeseries = function( apiComponent ) { + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "timestamp": {\n' + + ' "order": "desc",\n' + + ' "unmapped_type": "boolean"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "aggs": {\n' + + ' "mins": {\n' + + ' "date_histogram": {\n' + + ' "field": "timestamp",\n' + + ' "calendar_interval": "1d",\n' + + ' "time_zone": "' + R3.API.Query.QUERY_TIMEZONE + '",\n' + + ' "min_doc_count": 0,\n' + + ' "format" : "yyyy-MM-dd"\n' + + ' },\n' + + ' "aggs": {\n' + + ' "priorities": {\n' + + ' "histogram": {\n' + + ' "field": "priority",\n' + + ' "interval": "1",\n' + + ' "min_doc_count": 0\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte" : "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt" : "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}\n'; + } + this.text = apiComponent.text; + 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); diff --git a/src/r3-api-query-devices-0.js b/src/r3-api-query-devices-0.js new file mode 100644 index 0000000..82e1b9c --- /dev/null +++ b/src/r3-api-query-devices-0.js @@ -0,0 +1,65 @@ +/** + * R3.API.Query.Devices + * @param apiComponent + * @constructor + */ +R3.API.Query.Devices = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = '/devices/_search'; + } + this.path = apiComponent.path; + + if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) { + apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_ALL; + } + this.acknowledged = apiComponent.acknowledged; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "ip_v4.keyword": {\n' + + ' "order": "asc"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte" : "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt" : "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' },\n' + + ' {\n' + + ' "term" : { "acknowledged": ' + R3.API.Query.QUERY_ACKNOWLEDGED + ' }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}'; + } + this.text = apiComponent.text; + + R3.API.Query.call( + this, + apiComponent + ); +}; + +R3.API.Query.Devices.prototype = Object.create(R3.API.Query.prototype); +R3.API.Query.Devices.prototype.constructor = R3.API.Query.Devices; diff --git a/src/r3-api-query-devices-known.js b/src/r3-api-query-devices-known.js new file mode 100644 index 0000000..b53cdf2 --- /dev/null +++ b/src/r3-api-query-devices-known.js @@ -0,0 +1,25 @@ +/** + * R3.API.Query.Devices.Known + * @param apiComponent + * @constructor + */ +R3.API.Query.Devices.Known = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) { + apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_TRUE; + } + this.acknowledged = apiComponent.acknowledged; + + R3.API.Query.Devices.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Devices.Known.prototype = Object.create(R3.API.Query.Devices.prototype); +R3.API.Query.Devices.Known.prototype.constructor = R3.API.Query.Devices.Known; diff --git a/src/r3-api-query-devices-unknown.js b/src/r3-api-query-devices-unknown.js new file mode 100644 index 0000000..02ee95d --- /dev/null +++ b/src/r3-api-query-devices-unknown.js @@ -0,0 +1,25 @@ +/** + * R3.API.Query.Devices.Unknown + * @param apiComponent + * @constructor + */ +R3.API.Query.Devices.Unknown = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.acknowledged)) { + apiComponent.acknowledged = R3.API.Query.ACKNOWLEDGED_FALSE; + } + this.acknowledged = apiComponent.acknowledged; + + R3.API.Query.Devices.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Devices.Unknown.prototype = Object.create(R3.API.Query.Devices.prototype); +R3.API.Query.Devices.Unknown.prototype.constructor = R3.API.Query.Devices.Unknown; diff --git a/src/r3-api-query-logins-0.js b/src/r3-api-query-logins-0.js new file mode 100644 index 0000000..cf80175 --- /dev/null +++ b/src/r3-api-query-logins-0.js @@ -0,0 +1,65 @@ +/** + * R3.API.Query.Logins + * @param apiComponent + * @constructor + */ +R3.API.Query.Logins = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__ + + if (R3.Utils.UndefinedOrNull(apiComponent.path)) { + apiComponent.path = '/logins/_search'; + } + this.path = apiComponent.path; + + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_ALL; + } + this.loginType = apiComponent.loginType; + + if (R3.Utils.UndefinedOrNull(apiComponent.text)) { + apiComponent.text = '{\n' + + ' "version": false,\n' + + ' "size": ' + R3.API.Query.QUERY_SIZE + ',\n' + + ' "sort": [\n' + + ' {\n' + + ' "timestamp": {\n' + + ' "order": "asc"\n' + + ' }\n' + + ' }\n' + + ' ],\n' + + ' "_source": {\n' + + ' "includes": ["*"]\n' + + ' },\n' + + ' "query": {\n' + + ' "bool": {\n' + + ' "must": [\n' + + ' {\n' + + ' "range": {\n' + + ' "timestamp": {\n' + + ' "format": "strict_date_optional_time",\n' + + ' "gte" : "' + R3.API.Query.QUERY_START + '",\n' + + ' "lt" : "' + R3.API.Query.QUERY_END + '"\n' + + ' }\n' + + ' }\n' + + ' },\n' + + ' {\n' + + ' "regexp" : { "login_type.keyword": "(' + R3.API.Query.QUERY_LOGIN_TYPE + ')" }\n' + + ' }\n' + + ' ]\n' + + ' }\n' + + ' }\n' + + '}'; + } + this.text = apiComponent.text; + + R3.API.Query.call( + this, + apiComponent + ); +}; + +R3.API.Query.Logins.prototype = Object.create(R3.API.Query.prototype); +R3.API.Query.Logins.prototype.constructor = R3.API.Query.Logins; diff --git a/src/r3-api-query-logins-applications.js b/src/r3-api-query-logins-applications.js new file mode 100644 index 0000000..7a8bfe7 --- /dev/null +++ b/src/r3-api-query-logins-applications.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Logins.Applications + * @param apiComponent + * @constructor + */ +R3.API.Query.Logins.Applications = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_APPLICATION; + } + + R3.API.Query.Logins.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Logins.Applications.prototype = Object.create(R3.API.Query.Logins.prototype); +R3.API.Query.Logins.Applications.prototype.constructor = R3.API.Query.Logins.Applications; diff --git a/src/r3-api-query-logins-devices.js b/src/r3-api-query-logins-devices.js new file mode 100644 index 0000000..8435e88 --- /dev/null +++ b/src/r3-api-query-logins-devices.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Logins.Devices + * @param apiComponent + * @constructor + */ +R3.API.Query.Logins.Devices = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_DEVICE; + } + + R3.API.Query.Logins.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Logins.Devices.prototype = Object.create(R3.API.Query.Logins.prototype); +R3.API.Query.Logins.Devices.prototype.constructor = R3.API.Query.Logins.Devices; diff --git a/src/r3-api-query-logins-vpn.js b/src/r3-api-query-logins-vpn.js new file mode 100644 index 0000000..b80b841 --- /dev/null +++ b/src/r3-api-query-logins-vpn.js @@ -0,0 +1,27 @@ +/** + * R3.API.Query.Logins.VPN + * @param apiComponent + * @constructor + */ +R3.API.Query.Logins.VPN = function( + apiComponent +) { + + __DEFINE_API_COMPONENT__; + + /** + * Override the loginType + */ + if (R3.Utils.UndefinedOrNull(apiComponent.loginType)) { + apiComponent.loginType = R3.API.Query.LOGIN_TYPE_VPN; + } + + R3.API.Query.Logins.call( + this, + apiComponent + ); + +}; + +R3.API.Query.Logins.VPN.prototype = Object.create(R3.API.Query.Logins.prototype); +R3.API.Query.Logins.VPN.prototype.constructor = R3.API.Query.Logins.VPN; diff --git a/src/r3-api-renderer-0.js b/src/r3-api-renderer-0.js index 25b1dfc..5ab2303 100644 --- a/src/r3-api-renderer-0.js +++ b/src/r3-api-renderer-0.js @@ -6,9 +6,7 @@ R3.API.Renderer = function( apiComponent ) { - - __API_COMPONENT__; - + __DEFINE_API_COMPONENT__ }; R3.API.Renderer.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-api-renderer-d2.js b/src/r3-api-renderer-d2.js index 90cd66f..4b70d7a 100644 --- a/src/r3-api-renderer-d2.js +++ b/src/r3-api-renderer-d2.js @@ -10,20 +10,23 @@ R3.API.Renderer.D2 = function( apiComponent ) { - R3.API.Renderer.call( - this, - apiComponent - ); + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { apiComponent.canvas = new R3.API.Canvas( { - parent : this + parent : this, + name : this.name + ' - Canvas' } ); } this.canvas = apiComponent.canvas; + R3.API.Renderer.call( + this, + apiComponent + ); + }; R3.API.Renderer.D2.prototype = Object.create(R3.API.Renderer.prototype); diff --git a/src/r3-api-renderer-d3-0.js b/src/r3-api-renderer-d3-0.js index efae56e..4489ac1 100644 --- a/src/r3-api-renderer-d3-0.js +++ b/src/r3-api-renderer-d3-0.js @@ -42,10 +42,7 @@ R3.API.Renderer.D3 = function( apiComponent ) { - R3.API.Renderer.call( - this, - apiComponent - ); + __DEFINE_API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.autoClear)) { apiComponent.autoClear = true; @@ -117,16 +114,6 @@ R3.API.Renderer.D3 = function( } 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; } @@ -191,6 +178,8 @@ R3.API.Renderer.D3 = function( apiComponent.clearColor = new R3.API.Color( { parent : this, + register : true, + name : this.name + ' - Clear Color', r : 0.11, g : 0.11, b : 0.11 @@ -201,9 +190,10 @@ R3.API.Renderer.D3 = function( if (R3.Utils.UndefinedOrNull(apiComponent.viewports)) { apiComponent.viewports = [ - new R3.D3.API.Viewport( + new R3.D3.API.Viewport.FixedAspect( { - parent : this + parent : this, + name : this.name + ' - Fixed Aspect Viewport' } ) ]; @@ -225,6 +215,11 @@ R3.API.Renderer.D3 = function( } this.pixelRatio = apiComponent.pixelRatio; + R3.API.Renderer.call( + this, + apiComponent + ); + }; R3.API.Renderer.D3.prototype = Object.create(R3.API.Renderer.prototype); diff --git a/src/r3-api-renderer-d3-canvas-0.js b/src/r3-api-renderer-d3-canvas-0.js index 730d093..6d60ecb 100644 --- a/src/r3-api-renderer-d3-canvas-0.js +++ b/src/r3-api-renderer-d3-canvas-0.js @@ -10,20 +10,23 @@ R3.API.Renderer.D3.Canvas = function( apiComponent ) { - R3.API.Renderer.D3.call( - this, - apiComponent - ); + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.canvas)) { apiComponent.canvas = new R3.API.Canvas( { - parent : this + parent : this, + name : this.name + ' - Canvas' } ); } this.canvas = apiComponent.canvas; + R3.API.Renderer.D3.call( + this, + apiComponent + ); + }; R3.API.Renderer.D3.Canvas.prototype = Object.create(R3.API.Renderer.D3.prototype); diff --git a/src/r3-canvas.js b/src/r3-canvas.js index be849ec..730a6e6 100644 --- a/src/r3-canvas.js +++ b/src/r3-canvas.js @@ -24,27 +24,7 @@ R3.Canvas.prototype.constructor = R3.Canvas; */ R3.Canvas.prototype.createInstance = function() { - this.instance = document.createElement('canvas'); - - this.instance.setAttribute('id', this.id); - - this.instance.setAttribute('tabindex', this.tabIndex); - - this.instance.setAttribute('style', 'left: ' + this.offset.x + 'px;top: ' + this.offset.y + 'px'); - - if (this.autoUpdateSize) { - /** - * Update our size from the instance size - */ - this.width = this.instance.width; - this.height = this.instance.height; - } else { - /** - * Update our instance with our size - */ - this.instance.width = this.width; - this.instance.height = this.height; - } + this.instance = this.graphics.Canvas(this); __CREATE_INSTANCE__; }; diff --git a/src/r3-clock.js b/src/r3-clock.js index f146cd1..169fc36 100644 --- a/src/r3-clock.js +++ b/src/r3-clock.js @@ -40,14 +40,4 @@ R3.Clock.prototype.getDelta = function() { return this.instance.getDelta(); - /** - * clamp the delta to 1/60 - */ - // 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; }; diff --git a/src/r3-controls-0.js b/src/r3-controls-0.js index a63ef04..3c391ab 100644 --- a/src/r3-controls-0.js +++ b/src/r3-controls-0.js @@ -2,7 +2,13 @@ * R3.Controls * @constructor */ -R3.Controls = function() { +R3.Controls = function( + inherited +) { + + __INHERIT_ONLY__ + + this.linkedComponents.canvas = R3.Canvas; __UPGRADE_TO_RUNTIME__; diff --git a/src/r3-controls-d3-0.js b/src/r3-controls-d3-0.js index 2d89e2c..9d173ec 100644 --- a/src/r3-controls-d3-0.js +++ b/src/r3-controls-d3-0.js @@ -2,9 +2,18 @@ * R3.Controls.D3 * @constructor */ -R3.Controls.D3 = function() { +R3.Controls.D3 = function( + inherited +) { - R3.Controls.call(this); + __INHERIT_ONLY__ + + this.linkedComponents.camera = R3.D3.Camera; + + R3.Controls.call( + this, + true + ); }; @@ -18,6 +27,11 @@ R3.Controls.D3.prototype.updateInstance = function(property) { return; } + if (property === 'enabled') { + this.instance.enabled = this.enabled; + return; + } + R3.Controls.prototype.updateInstance.call(this, property); }; \ No newline at end of file diff --git a/src/r3-controls-d3-firstPerson.js b/src/r3-controls-d3-firstPerson.js index e7ff559..902f4b2 100644 --- a/src/r3-controls-d3-firstPerson.js +++ b/src/r3-controls-d3-firstPerson.js @@ -9,7 +9,10 @@ R3.Controls.D3.FirstPerson = function( __RUNTIME_COMPONENT__; - R3.Controls.D3.call(this); + R3.Controls.D3.call( + this, + true + ); }; @@ -25,24 +28,7 @@ R3.Controls.D3.FirstPerson.prototype.constructor = R3.Controls.D3.FirstPerson; */ R3.Controls.D3.FirstPerson.prototype.createInstance = function() { - this.instance = this.graphics.FirstPersonControls( - this.canvas, - this.camera, - this.enabled, - this.movementSpeed, - this.lookSpeed, - this.lookVertical, - this.autoForward, - this.activeLook, - this.heightSpeed, - this.heightCoef, - this.heightMin, - this.heightMax, - this.constrainVertical, - this.verticalMin, - this.verticalMax, - this.autoSpeedFactor - ); + this.instance = this.graphics.FirstPersonControls(this); __CREATE_INSTANCE__; }; @@ -52,11 +38,6 @@ R3.Controls.D3.FirstPerson.prototype.createInstance = function() { */ R3.Controls.D3.FirstPerson.prototype.updateInstance = function(property) { - if (property === 'enabled') { - this.instance.enabled = this.enabled; - return; - } - if (property === 'movementSpeed') { this.instance.movementSpeed = this.movementSpeed; return; diff --git a/src/r3-controls-d3-orbit.js b/src/r3-controls-d3-orbit.js index e3b03e5..8b3955f 100644 --- a/src/r3-controls-d3-orbit.js +++ b/src/r3-controls-d3-orbit.js @@ -9,7 +9,12 @@ R3.Controls.D3.Orbit = function( __RUNTIME_COMPONENT__; - R3.Controls.D3.call(this); + this.linkedComponents.target = R3.D3.Object; + + R3.Controls.D3.call( + this, + true + ); }; @@ -21,25 +26,7 @@ R3.Controls.D3.Orbit.prototype.constructor = R3.Controls.D3.Orbit; */ R3.Controls.D3.Orbit.prototype.createInstance = function() { - this.instance = this.graphics.OrbitControls( - this.canvas, - this.camera, - this.target, - this.enabled, - this.minPolarAngle, - this.maxPolarAngle, - this.enableDamping, - this.dampingFactor, - this.enableZoom, - this.zoomSpeed, - this.enableRotate, - this.rotateSpeed, - this.enablePan, - this.keyPanSpeed, - this.autoRotate, - this.autoRotateSpeed, - this.enableKeys - ); + this.instance = this.graphics.OrbitControls(this); __CREATE_INSTANCE__; }; @@ -59,11 +46,6 @@ R3.Controls.D3.Orbit.prototype.updateInstance = function(property) { return; } - if (property === 'enabled') { - this.instance.enabled = this.enabled; - return; - } - if (property === 'minPolarAngle') { this.instance.minPolarAngle = this.minPolarAngle; return; diff --git a/src/r3-controls-keyboard.js b/src/r3-controls-keyboard.js index 38546ae..6f426db 100644 --- a/src/r3-controls-keyboard.js +++ b/src/r3-controls-keyboard.js @@ -10,7 +10,8 @@ R3.Controls.Keyboard = function( __RUNTIME_COMPONENT__; R3.Controls.call( - this + this, + true ); }; diff --git a/src/r3-controls-mouse.js b/src/r3-controls-mouse.js index a062f48..d6b8161 100644 --- a/src/r3-controls-mouse.js +++ b/src/r3-controls-mouse.js @@ -10,7 +10,8 @@ R3.Controls.Mouse = function( __RUNTIME_COMPONENT__; R3.Controls.call( - this + this, + true ); }; diff --git a/src/r3-controls-touch.js b/src/r3-controls-touch.js index 04db511..18c46d0 100644 --- a/src/r3-controls-touch.js +++ b/src/r3-controls-touch.js @@ -10,7 +10,8 @@ R3.Controls.Touch = function( __RUNTIME_COMPONENT__; R3.Controls.call( - this + this, + true ); }; diff --git a/src/r3-curve-path-d2-shape.js b/src/r3-curve-path-d2-shape.js index a027321..5bf155a 100644 --- a/src/r3-curve-path-d2-shape.js +++ b/src/r3-curve-path-d2-shape.js @@ -23,7 +23,7 @@ R3.Curve.Path.D2.Shape = function( } /** - * Now we call the parent class but with linkedObjects - indicating that its being called from a child class + * Now we call the parent class but with linkedComponents - indicating that its being called from a child class * and should not do any runtime instantiation */ R3.Curve.Path.D2.call( diff --git a/src/r3-d3-api-0-object.js b/src/r3-d3-api-0-object.js index b6122fb..340a33e 100644 --- a/src/r3-d3-api-0-object.js +++ b/src/r3-d3-api-0-object.js @@ -16,7 +16,7 @@ R3.D3.API.Object = function( apiComponent ) { - __API_COMPONENT__; + __DEFINE_API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.useQuaternion)) { apiComponent.useQuaternion = false; @@ -27,6 +27,7 @@ R3.D3.API.Object = function( apiComponent.position = new R3.API.Vector3( { parent : this, + name : this.name + ' - Position', register : true } ); @@ -37,6 +38,7 @@ R3.D3.API.Object = function( apiComponent.quaternion = new R3.API.Quaternion( { parent : this, + name : this.name + ' - Quaternion', register : true } ); @@ -47,6 +49,7 @@ R3.D3.API.Object = function( apiComponent.rotation = new R3.API.Vector3( { parent : this, + name : this.name + ' - Rotation', register : true } ); @@ -58,6 +61,7 @@ R3.D3.API.Object = function( { parent : this, register : true, + name : this.name + ' - Scale', x : 1, y : 1, z : 1 @@ -71,6 +75,7 @@ R3.D3.API.Object = function( { parent : this, register : true, + name : this.name + ' - Up', x : 0, y : 1, z : 0 @@ -83,6 +88,7 @@ R3.D3.API.Object = function( apiComponent.lookAt = new R3.API.Vector3( { parent : this, + name : this.name + ' - LookAt', register : true } ); diff --git a/src/r3-d3-api-camera-cube.js b/src/r3-d3-api-camera-cube.js index ffbb84c..307807c 100644 --- a/src/r3-d3-api-camera-cube.js +++ b/src/r3-d3-api-camera-cube.js @@ -17,11 +17,12 @@ R3.D3.API.Camera.Cube = function( apiComponent ) { - R3.D3.API.Camera.call( - this, - apiComponent - ); + __API_COMPONENT__; + /** + * Following two properties are hardcoded for Cube Cameras + * @type {number} + */ this.aspect = 1; this.fov = 90; @@ -44,12 +45,18 @@ R3.D3.API.Camera.Cube = function( if (R3.Utils.UndefinedOrNull(apiComponent.renderTarget)) { apiComponent.renderTarget = new R3.D3.API.RenderTarget.Cube( { - parent : this + parent : this, + name : this.name + ' - Cube RenderTarget' } ); } this.renderTarget = apiComponent.renderTarget; + R3.D3.API.Camera.call( + this, + apiComponent + ); + }; R3.D3.API.Camera.Cube.prototype = Object.create(R3.D3.API.Camera.prototype); diff --git a/src/r3-d3-api-camera-orthographic-0.js b/src/r3-d3-api-camera-orthographic-0.js index 9b859e9..d73b9c7 100644 --- a/src/r3-d3-api-camera-orthographic-0.js +++ b/src/r3-d3-api-camera-orthographic-0.js @@ -16,9 +16,10 @@ R3.D3.API.Camera.Orthographic = function( apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiComponent)) { - apiComponent = {}; - } + /** + * Override the lookAt vector for Orthographic cameras + */ + __DEFINE_API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.lookAt)) { apiComponent.lookAt = new R3.API.Vector3( @@ -31,11 +32,7 @@ R3.D3.API.Camera.Orthographic = function( } ); } - - R3.D3.API.Camera.call( - this, - apiComponent - ); + this.lookAt = apiComponent.lookAt; if (R3.Utils.UndefinedOrNull(apiComponent.near)) { apiComponent.near = 0.1; @@ -52,6 +49,11 @@ R3.D3.API.Camera.Orthographic = function( } this.zoom = apiComponent.zoom; + R3.D3.API.Camera.call( + this, + apiComponent + ); + }; R3.D3.API.Camera.Orthographic.prototype = Object.create(R3.D3.API.Camera.prototype); diff --git a/src/r3-d3-api-camera-orthographic-fixedAspect.js b/src/r3-d3-api-camera-orthographic-fixedAspect.js index 4a062f4..35612b6 100644 --- a/src/r3-d3-api-camera-orthographic-fixedAspect.js +++ b/src/r3-d3-api-camera-orthographic-fixedAspect.js @@ -11,6 +11,8 @@ R3.D3.API.Camera.Orthographic.FixedAspect = function( apiComponent ) { + __API_COMPONENT__; + R3.D3.API.Camera.Orthographic.call( this, apiComponent diff --git a/src/r3-d3-api-camera-orthographic-scaledAspect.js b/src/r3-d3-api-camera-orthographic-scaledAspect.js index ad487d0..aed5dac 100644 --- a/src/r3-d3-api-camera-orthographic-scaledAspect.js +++ b/src/r3-d3-api-camera-orthographic-scaledAspect.js @@ -18,10 +18,7 @@ R3.D3.API.Camera.Orthographic.ScaledAspect = function( apiComponent ) { - R3.D3.API.Camera.Orthographic.call( - this, - apiComponent - ); + __API_COMPONENT__; if (R3.Utils.UndefinedOrNull(apiComponent.left)) { apiComponent.left = -5; @@ -43,6 +40,11 @@ R3.D3.API.Camera.Orthographic.ScaledAspect = function( } this.bottom = apiComponent.bottom; + R3.D3.API.Camera.Orthographic.call( + this, + apiComponent + ); + }; R3.D3.API.Camera.Orthographic.ScaledAspect.prototype = Object.create(R3.D3.API.Camera.Orthographic.prototype); diff --git a/src/r3-d3-api-camera-perspective-0.js b/src/r3-d3-api-camera-perspective-0.js index ae86ee0..137cc53 100644 --- a/src/r3-d3-api-camera-perspective-0.js +++ b/src/r3-d3-api-camera-perspective-0.js @@ -16,26 +16,24 @@ R3.D3.API.Camera.Perspective = function( apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiComponent)) { - apiComponent = {}; - } + /** + * Override the position for Perspective cameras + */ + __API_COMPONENT__ if (R3.Utils.UndefinedOrNull(apiComponent.position)) { apiComponent.position = new R3.API.Vector3( { parent : this, register :true, + name : this.name + ' - Position', x : 15, y : 15, z : 15 } ); } - - R3.D3.API.Camera.call( - this, - apiComponent - ); + this.position = apiComponent.position; if (R3.Utils.UndefinedOrNull(apiComponent.near)) { apiComponent.near = 0.1; @@ -72,6 +70,10 @@ R3.D3.API.Camera.Perspective = function( } this.zoom = apiComponent.zoom; + R3.D3.API.Camera.call( + this, + apiComponent + ); }; R3.D3.API.Camera.Perspective.prototype = Object.create(R3.D3.API.Camera.prototype); diff --git a/src/r3-d3-api-camera-perspective-stereo.js b/src/r3-d3-api-camera-perspective-stereo.js index 98bd099..fbb586d 100644 --- a/src/r3-d3-api-camera-perspective-stereo.js +++ b/src/r3-d3-api-camera-perspective-stereo.js @@ -7,6 +7,8 @@ R3.D3.API.Camera.Perspective.Stereo = function( apiComponent ) { + __DEFINE_API_COMPONENT__; + R3.D3.API.Camera.Perspective.call( this, apiComponent diff --git a/src/r3-d3-api-fog-0.js b/src/r3-d3-api-fog-0.js index d94e81c..2d61844 100644 --- a/src/r3-d3-api-fog-0.js +++ b/src/r3-d3-api-fog-0.js @@ -17,6 +17,7 @@ R3.D3.API.Fog = function( { parent : this, register : true, + name : this.name + ' - Color', r : 1, g : 1, b : 1, diff --git a/src/r3-d3-api-particle-0.js b/src/r3-d3-api-mesh-particle-0.js similarity index 57% rename from src/r3-d3-api-particle-0.js rename to src/r3-d3-api-mesh-particle-0.js index 4a1dc88..663a16e 100644 --- a/src/r3-d3-api-particle-0.js +++ b/src/r3-d3-api-mesh-particle-0.js @@ -1,5 +1,5 @@ /** - * R3.D3.API.Particle + * R3.D3.API.Mesh.Particle * @param apiComponent * @param lifeTime * @param elapsed @@ -25,30 +25,8 @@ * @param rotationFn * @constructor */ -R3.D3.API.Particle = function( - apiComponent, - lifeTime, - elapsed, - mesh, - opacityType, - fadeInFactor, - fadeOutFactor, - fadeInAfter, - fadeOutAfter, - positionOffsetType, - positionOffset, - positionOffsetFn, - directionType, - direction, - directionFn, - speedType, - speed, - scaleType, - scale, - scaleFn, - rotationType, - rotation, - rotationFn +R3.D3.API.Mesh.Particle = function( + apiComponent ) { __API_COMPONENT__; @@ -69,7 +47,7 @@ R3.D3.API.Particle = function( this.mesh = apiComponent.mesh; if (R3.Utils.UndefinedOrNull(apiComponent.opacityType)) { - apiComponent.opacityType = R3.D3.API.Particle.OPACITY_TYPE_CONSTANT; + apiComponent.opacityType = R3.D3.API.Mesh.Particle.OPACITY_TYPE_CONSTANT; } this.opacityType = apiComponent.opacityType; @@ -94,7 +72,7 @@ R3.D3.API.Particle = function( this.fadeOutAfter = apiComponent.fadeOutAfter; if (R3.Utils.UndefinedOrNull(apiComponent.positionOffsetType)) { - apiComponent.positionOffsetType = R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT; + apiComponent.positionOffsetType = R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT; } this.positionOffsetType = apiComponent.positionOffsetType; @@ -109,7 +87,7 @@ R3.D3.API.Particle = function( this.positionOffsetFn = apiComponent.positionOffsetFn; if (R3.Utils.UndefinedOrNull(apiComponent.directionType)) { - apiComponent.directionType = R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT; + apiComponent.directionType = R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT; } this.directionType = apiComponent.directionType; @@ -124,7 +102,7 @@ R3.D3.API.Particle = function( this.directionFn = apiComponent.directionFn; if (R3.Utils.UndefinedOrNull(apiComponent.speedType)) { - apiComponent.speedType = R3.D3.API.Particle.SPEED_TYPE_CONSTANT; + apiComponent.speedType = R3.D3.API.Mesh.Particle.SPEED_TYPE_CONSTANT; } this.speedType = apiComponent.speedType; @@ -134,7 +112,7 @@ R3.D3.API.Particle = function( this.speed = apiComponent.speed; if (R3.Utils.UndefinedOrNull(apiComponent.scaleType)) { - apiComponent.scaleType = R3.D3.API.Particle.SCALE_TYPE_CONSTANT; + apiComponent.scaleType = R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT; } this.scaleType = apiComponent.scaleType; @@ -149,7 +127,7 @@ R3.D3.API.Particle = function( this.scaleFn = apiComponent.scaleFn; if (R3.Utils.UndefinedOrNull(apiComponent.rotationType)) { - apiComponent.rotationType = R3.D3.API.Particle.ROTATION_TYPE_CONSTANT; + apiComponent.rotationType = R3.D3.API.Mesh.Particle.ROTATION_TYPE_CONSTANT; } this.rotationType = apiComponent.rotationType; @@ -164,41 +142,41 @@ R3.D3.API.Particle = function( this.rotationFn = apiComponent.rotationFn; }; -R3.D3.API.Particle.prototype = Object.create(R3.API.Component.prototype); -R3.D3.API.Particle.prototype.constructor = R3.D3.API.Particle; +R3.D3.API.Mesh.Particle.prototype = Object.create(R3.API.Component.prototype); +R3.D3.API.Mesh.Particle.prototype.constructor = R3.D3.API.Mesh.Particle; -R3.D3.API.Particle.OPACITY_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR = 0x2; -R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR = 0x3; -R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR = 0x4; +R3.D3.API.Mesh.Particle.OPACITY_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_OUT_LINEAR = 0x2; +R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_LINEAR = 0x3; +R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR = 0x4; -R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2; -R3.D3.API.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3; +R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_RANDOM = 0x2; +R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_FUNCTION = 0x3; -R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.DIRECTION_TYPE_RANDOM = 0x2; -R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED = 0x3; -R3.D3.API.Particle.DIRECTION_TYPE_FUNCTION = 0x4; +R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM = 0x2; +R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED = 0x3; +R3.D3.API.Mesh.Particle.DIRECTION_TYPE_FUNCTION = 0x4; -R3.D3.API.Particle.SCALE_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.SCALE_TYPE_LINEAR = 0x2; -R3.D3.API.Particle.SCALE_TYPE_EXPONENTIAL = 0x3; -R3.D3.API.Particle.SCALE_TYPE_RANDOM = 0x4; -R3.D3.API.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6; -R3.D3.API.Particle.SCALE_TYPE_FUNCTION = 0x7; +R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.SCALE_TYPE_LINEAR = 0x2; +R3.D3.API.Mesh.Particle.SCALE_TYPE_EXPONENTIAL = 0x3; +R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM = 0x4; +R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y = 0x6; +R3.D3.API.Mesh.Particle.SCALE_TYPE_FUNCTION = 0x7; -R3.D3.API.Particle.SPEED_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.SPEED_TYPE_LINEAR = 0x2; -R3.D3.API.Particle.SPEED_TYPE_EXPONENTIAL = 0x3; -R3.D3.API.Particle.SPEED_TYPE_LOGARITHMIC = 0x4; -R3.D3.API.Particle.SPEED_TYPE_ONE_OVER_LOG = 0x5; -R3.D3.API.Particle.SPEED_TYPE_EXP = 0x6; -R3.D3.API.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7; +R3.D3.API.Mesh.Particle.SPEED_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.SPEED_TYPE_LINEAR = 0x2; +R3.D3.API.Mesh.Particle.SPEED_TYPE_EXPONENTIAL = 0x3; +R3.D3.API.Mesh.Particle.SPEED_TYPE_LOGARITHMIC = 0x4; +R3.D3.API.Mesh.Particle.SPEED_TYPE_ONE_OVER_LOG = 0x5; +R3.D3.API.Mesh.Particle.SPEED_TYPE_EXP = 0x6; +R3.D3.API.Mesh.Particle.SPEED_TYPE_ONE_OVER_EXP = 0x7; -R3.D3.API.Particle.ROTATION_TYPE_CONSTANT = 0x1; -R3.D3.API.Particle.ROTATION_TYPE_RANDOM = 0x2; -R3.D3.API.Particle.ROTATION_TYPE_RANDOM_X = 0x3; -R3.D3.API.Particle.ROTATION_TYPE_RANDOM_Y = 0x4; -R3.D3.API.Particle.ROTATION_TYPE_RANDOM_Z = 0x5; -R3.D3.API.Particle.ROTATION_TYPE_FUNCTION = 0x6; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_CONSTANT = 0x1; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM = 0x2; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_X = 0x3; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_Y = 0x4; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_RANDOM_Z = 0x5; +R3.D3.API.Mesh.Particle.ROTATION_TYPE_FUNCTION = 0x6; diff --git a/src/r3-d3-api-particle-engine.js b/src/r3-d3-api-mesh-particle-engine.js similarity index 51% rename from src/r3-d3-api-particle-engine.js rename to src/r3-d3-api-mesh-particle-engine.js index dda19b6..67ef93d 100644 --- a/src/r3-d3-api-particle-engine.js +++ b/src/r3-d3-api-mesh-particle-engine.js @@ -1,6 +1,6 @@ /** - * R3.D3.API.Particle.Engine - * @param apiParticle + * R3.D3.API.Mesh.Particle.Engine + * @param apiMesh.Particle * @param position * @param direction * @param enabled @@ -11,48 +11,13 @@ * @param fired * @constructor */ -R3.D3.API.Particle.Engine = function( - apiParticle, - position, - direction, - enabled, - particlesPerSecond, - frequency, - elapsed, - pulse, - fired +R3.D3.API.Mesh.Particle.Engine = function( + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiComponent.apiParticle)) { - apiComponent.apiParticle = {}; - } - this.apiParticle = apiComponent.apiParticle; - - R3.D3.API.Particle.call( + R3.D3.API.Mesh.Particle.call( this, - this.apiParticle, - this.apiParticle.lifeTime, - this.apiParticle.elapsed, - this.apiParticle.mesh, - this.apiParticle.opacityType, - this.apiParticle.fadeInFactor, - this.apiParticle.fadeOutFactor, - this.apiParticle.fadeInAfter, - this.apiParticle.fadeOutAfter, - this.apiParticle.positionOffsetType, - this.apiParticle.positionOffset, - this.apiParticle.positionOffsetFn, - this.apiParticle.directionType, - this.apiParticle.direction, - this.apiParticle.directionFn, - this.apiParticle.speedType, - this.apiParticle.speed, - this.apiParticle.scaleType, - this.apiParticle.scale, - this.apiParticle.scaleFn, - this.apiParticle.rotationType, - this.apiParticle.rotation, - this.apiParticle.rotationFn + apiComponent ); if (R3.Utils.UndefinedOrNull(apiComponent.position)) { @@ -97,5 +62,5 @@ R3.D3.API.Particle.Engine = function( }; -R3.D3.API.Particle.Engine.prototype = Object.create(R3.D3.API.Particle.prototype); -R3.D3.API.Particle.Engine.prototype.constructor = R3.D3.API.Particle.Engine; +R3.D3.API.Mesh.Particle.Engine.prototype = Object.create(R3.D3.API.Mesh.Particle.prototype); +R3.D3.API.Mesh.Particle.Engine.prototype.constructor = R3.D3.API.Mesh.Particle.Engine; diff --git a/src/r3-d3-api-physics-world.js b/src/r3-d3-api-physicsWorld.js similarity index 100% rename from src/r3-d3-api-physics-world.js rename to src/r3-d3-api-physicsWorld.js diff --git a/src/r3-d3-api-raycaster.js b/src/r3-d3-api-raycaster.js index 1ee89a8..13ce717 100644 --- a/src/r3-d3-api-raycaster.js +++ b/src/r3-d3-api-raycaster.js @@ -1,14 +1,14 @@ /** - * Raycaster for R3.D3 + * R3.D3.API.Raycaster * @param apiComponent - * @param position R3.API.Vector3 - * @param direction R3.API.Vector3 + * + * @property position + * @property direction + * * @constructor */ R3.D3.API.Raycaster = function( - apiComponent, - position, - direction + apiComponent ) { __API_COMPONENT__; @@ -17,6 +17,7 @@ R3.D3.API.Raycaster = function( apiComponent.position = new R3.API.Vector3( { parent : this, + name : this.name + ' - Position', register : true } ); @@ -27,6 +28,7 @@ R3.D3.API.Raycaster = function( apiComponent.direction = new R3.API.Vector3( { parent : this, + name : this.name + ' - Direction', register : true }, 0, diff --git a/src/r3-d3-api-renderTarget-0.js b/src/r3-d3-api-renderTarget-0.js index db441f5..107e89f 100644 --- a/src/r3-d3-api-renderTarget-0.js +++ b/src/r3-d3-api-renderTarget-0.js @@ -1,28 +1,21 @@ /** * R3.D3.API.RenderTarget * @param apiComponent - * @param width - * @param height - * @param scissor - * @param scissorTest - * @param viewport - * @param texture - * @param depthBuffer - * @param depthTexture - * @param stencilBuffer + * + * @property width + * @property height + * @property scissor + * @property scissorTest + * @property viewport + * @property texture + * @property depthBuffer + * @property depthTexture + * @property stencilBuffer + * * @constructor */ R3.D3.API.RenderTarget = function( - apiComponent, - width, - height, - scissor, - scissorTest, - viewport, - texture, - depthBuffer, - depthTexture, - stencilBuffer + apiComponent ) { __API_COMPONENT__; @@ -38,7 +31,16 @@ R3.D3.API.RenderTarget = function( this.height = apiComponent.height; if (R3.Utils.UndefinedOrNull(apiComponent.scissor)) { - apiComponent.scissor = R3.API.Vector4(0,0,1,1); + apiComponent.scissor = new R3.API.Vector4( + { + parent : this, + register : true, + x : 0, + y : 0, + z : 1, + w : 1 + } + ); } this.scissor = apiComponent.scissor; @@ -48,12 +50,23 @@ R3.D3.API.RenderTarget = function( this.scissorTest = apiComponent.scissorTest; if (R3.Utils.UndefinedOrNull(apiComponent.viewport)) { - apiComponent.viewport = R3.API.Vector4(0,0,1,1); + apiComponent.viewport = new R3.API.Vector4({ + parent : this, + register : true, + x : 0, + y : 0, + z : 1, + w : 1 + }); } this.viewport = apiComponent.viewport; if (R3.Utils.UndefinedOrNull(apiComponent.texture)) { - apiComponent.texture = new R3.D3.API.Texture(); + apiComponent.texture = new R3.D3.API.Texture( + { + parent : this + } + ); } this.texture = apiComponent.texture; diff --git a/src/r3-d3-api-scene.js b/src/r3-d3-api-scene.js index 78e6045..28b6cd0 100644 --- a/src/r3-d3-api-scene.js +++ b/src/r3-d3-api-scene.js @@ -6,7 +6,6 @@ * @property lights [] * @property textures [] * @property materials [] - * @property images * @property fog * @property showGrid * @property showAxis @@ -49,13 +48,13 @@ R3.D3.API.Scene = function( } this.materials = apiComponent.materials; - if (R3.Utils.UndefinedOrNull(apiComponent.images)) { - apiComponent.images = []; - } - this.images = apiComponent.images; - if (R3.Utils.UndefinedOrNull(apiComponent.fog)) { - apiComponent.fog = new R3.D3.API.Fog(); + apiComponent.fog = new R3.D3.API.Fog.Normal( + { + parent : this, + name : this.name + ' - Fog' + } + ); } this.fog = apiComponent.fog; @@ -75,7 +74,14 @@ R3.D3.API.Scene = function( this.gridSize = apiComponent.gridSize; if (R3.Utils.UndefinedOrNull(apiComponent.gridColor)) { - apiComponent.gridColor = new R3.API.Color(this, 0.14117641, 0.576470588, 0.882352941); + apiComponent.gridColor = new R3.API.Color({ + parent : this, + register : true, + name : this.name + ' - Grid Color', + r : 0.14117641, + g : 0.576470588, + b : 0.882352941 + }); } this.gridColor = apiComponent.gridColor; @@ -95,12 +101,22 @@ R3.D3.API.Scene = function( this.cubeCameras = apiComponent.cubeCameras; if (R3.Utils.UndefinedOrNull(apiComponent.composer)) { - apiComponent.composer = new R3.API.Composer(); + apiComponent.composer = new R3.D3.API.Composer( + { + parent : this, + name : this.name + ' - Composer' + } + ); } this.composer = apiComponent.composer; if (R3.Utils.UndefinedOrNull(apiComponent.effect)) { - apiComponent.effect = new R3.API.Effect(); + apiComponent.effect = new R3.D3.API.Effect( + { + parent : this, + name : this.name + ' - Effect' + } + ); } this.effect = apiComponent.effect; @@ -114,10 +130,6 @@ R3.D3.API.Scene = function( } this.enableEffect = apiComponent.enableEffect; - if (R3.Utils.UndefinedOrNull(apiComponent.controls)) { - apiComponent.controls = new R3.API.Controls.D3.Orbit() - } - this.controls = apiComponent.controls; }; R3.D3.API.Scene.prototype = Object.create(R3.API.Component.prototype); diff --git a/src/r3-d3-api-viewport-0.js b/src/r3-d3-api-viewport-0.js index ed78e88..ea6e27c 100644 --- a/src/r3-d3-api-viewport-0.js +++ b/src/r3-d3-api-viewport-0.js @@ -4,11 +4,11 @@ * Ignore aspect ratio and make viewport respect x,y,width and height as is * * @param apiComponent - * - * @property width - * @property height + * * @property x * @property y + * @property width + * @property height * @property scenes * * @constructor @@ -19,16 +19,6 @@ R3.D3.API.Viewport = function( __API_COMPONENT__; - if (R3.Utils.UndefinedOrNull(apiComponent.width)) { - apiComponent.width = 1; - } - this.width = apiComponent.width; - - if (R3.Utils.UndefinedOrNull(apiComponent.height)) { - apiComponent.height = 1; - } - this.height = apiComponent.height; - if (R3.Utils.UndefinedOrNull(apiComponent.x)) { apiComponent.x = 0; } @@ -39,8 +29,23 @@ R3.D3.API.Viewport = function( } this.y = apiComponent.y; + if (R3.Utils.UndefinedOrNull(apiComponent.width)) { + apiComponent.width = 1; + } + this.width = apiComponent.width; + + if (R3.Utils.UndefinedOrNull(apiComponent.height)) { + apiComponent.height = 1; + } + this.height = apiComponent.height; + if (R3.Utils.UndefinedOrNull(apiComponent.scenes)) { - apiComponent.scenes = [new R3.D3.API.Scene()]; + apiComponent.scenes = [new R3.D3.API.Scene( + { + parent : this, + name : this.name + ' - Scene' + } + )]; } this.scenes = apiComponent.scenes; diff --git a/src/r3-d3-api-viewport-fixedAspect.js b/src/r3-d3-api-viewport-fixedAspect.js index 502bfb8..e9899f2 100644 --- a/src/r3-d3-api-viewport-fixedAspect.js +++ b/src/r3-d3-api-viewport-fixedAspect.js @@ -5,28 +5,19 @@ * - entire viewport remains visible at all times * - will have empty space above or below viewport depending on canvas size (if canvas ratio != viewport ratio) * + * @param apiComponent + * + * @property aspectRatio + * * @constructor - * @param apiViewport - * @param aspectRatio */ R3.D3.API.Viewport.FixedAspect = function( - apiViewport, - aspectRatio + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiComponent.apiViewport)) { - apiComponent.apiViewport = {}; - } - this.apiViewport = apiComponent.apiViewport; - R3.D3.API.Viewport.call( this, - this.apiViewport, - this.apiViewport.width, - this.apiViewport.height, - this.apiViewport.x, - this.apiViewport.y, - this.apiViewport.scenes + apiComponent ); if (R3.Utils.UndefinedOrNull(apiComponent.aspectRatio)) { diff --git a/src/r3-d3-api-viewport-zoomedAspect.js b/src/r3-d3-api-viewport-zoomedAspect.js index fcb6e68..8a50a10 100644 --- a/src/r3-d3-api-viewport-zoomedAspect.js +++ b/src/r3-d3-api-viewport-zoomedAspect.js @@ -22,32 +22,21 @@ * similar to a VIEWPORT_TYPE_FIXED_ASPECT in the case that the entire viewport actually fits into the canvas * (when did this ever happen? wouldn't live have been great?) * + * @param apiComponent + * + * @property aspectRatio + * @property expandWidth + * @property expandHeight + * * @constructor - * @param apiViewport - * @param aspectRatio - * @param expandWidth - * @param expandHeight */ R3.D3.API.Viewport.ZoomedAspect = function( - apiViewport, - aspectRatio, - expandWidth, - expandHeight + apiComponent ) { - if (R3.Utils.UndefinedOrNull(apiComponent.apiViewport)) { - apiComponent.apiViewport = {}; - } - this.apiViewport = apiComponent.apiViewport; - R3.D3.API.Viewport.call( this, - this.apiViewport, - this.apiViewport.width, - this.apiViewport.height, - this.apiViewport.x, - this.apiViewport.y, - this.apiViewport.scenes + apiComponent ); if (R3.Utils.UndefinedOrNull(apiComponent.aspectRatio)) { diff --git a/src/r3-d3-api-y-object.js b/src/r3-d3-api-y-object.js index 6187767..ef8d1a4 100644 --- a/src/r3-d3-api-y-object.js +++ b/src/r3-d3-api-y-object.js @@ -13,13 +13,9 @@ R3.D3.Object = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { + __INHERIT_AND_INSTANTIATE__ - __RUNTIME_COMPONENT__; - - } - - __UPGRADE_TO_RUNTIME; + __UPGRADE_TO_RUNTIME__; }; diff --git a/src/r3-d3-camera-0.js b/src/r3-d3-camera-0.js index df47df4..ab91156 100644 --- a/src/r3-d3-camera-0.js +++ b/src/r3-d3-camera-0.js @@ -1,14 +1,21 @@ /** * R3.D3.Camera * - * - This class cannot be instantiated - simply pass it all through to R3.D3.Object + * - This class cannot be instantiated - simply pass it all through to R3.D3.Object - it need apiComponent to pass + * to Object * * @constructor */ -R3.D3.Camera = function() { +R3.D3.Camera = function( + apiComponent, + inherited +) { + + __INHERIT_ONLY__ R3.D3.Object.call( this, + apiComponent, true ); @@ -17,17 +24,6 @@ R3.D3.Camera = function() { R3.D3.Camera.prototype = Object.create(R3.D3.Object.prototype); R3.D3.Camera.prototype.constructor = R3.D3.Camera; -/** - * Although you cannot instatiate this directly - you can set common properties for children on 'createInstance' - */ -R3.D3.Camera.prototype.createInstance = function() { - - this.instance.aspect = this.aspect; - - __CREATE_INSTANCE__; - -}; - /** * Updates the instance with the current state */ diff --git a/src/r3-d3-camera-cube.js b/src/r3-d3-camera-cube.js index 6df2712..0cdb075 100644 --- a/src/r3-d3-camera-cube.js +++ b/src/r3-d3-camera-cube.js @@ -11,6 +11,7 @@ R3.D3.Camera.Cube = function( R3.D3.Camera.call( this, + apiComponent, true ); diff --git a/src/r3-d3-camera-orthographic-0.js b/src/r3-d3-camera-orthographic-0.js index 8c584a1..dd1428f 100644 --- a/src/r3-d3-camera-orthographic-0.js +++ b/src/r3-d3-camera-orthographic-0.js @@ -5,9 +5,18 @@ * * @constructor */ -R3.D3.Camera.Orthographic = function() { +R3.D3.Camera.Orthographic = function( + apiComponent, + inherited +) { - R3.D3.Camera.call(this); + __INHERIT_ONLY__ + + R3.D3.Camera.call( + this, + apiComponent, + true + ); }; diff --git a/src/r3-d3-camera-orthographic-fixedAspect.js b/src/r3-d3-camera-orthographic-fixedAspect.js index b319d2f..682d62e 100644 --- a/src/r3-d3-camera-orthographic-fixedAspect.js +++ b/src/r3-d3-camera-orthographic-fixedAspect.js @@ -9,7 +9,11 @@ R3.D3.Camera.Orthographic.FixedAspect = function( __RUNTIME_COMPONENT__; - R3.D3.Camera.Orthographic.call(this); + R3.D3.Camera.Orthographic.call( + this, + apiComponent, + true + ); }; diff --git a/src/r3-d3-camera-orthographic-scaledAspect.js b/src/r3-d3-camera-orthographic-scaledAspect.js index ee8b5d2..b02a13f 100644 --- a/src/r3-d3-camera-orthographic-scaledAspect.js +++ b/src/r3-d3-camera-orthographic-scaledAspect.js @@ -9,7 +9,11 @@ R3.D3.Camera.Orthographic.ScaledAspect = function( __RUNTIME_COMPONENT__; - R3.D3.Camera.Orthographic.call(this); + R3.D3.Camera.Orthographic.call( + this, + apiComponent, + true + ); }; diff --git a/src/r3-d3-camera-perspective-0.js b/src/r3-d3-camera-perspective-0.js index e2ab8e8..a6c8cba 100644 --- a/src/r3-d3-camera-perspective-0.js +++ b/src/r3-d3-camera-perspective-0.js @@ -9,15 +9,13 @@ R3.D3.Camera.Perspective = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - inherited = false; - } + __INHERIT_AND_INSTANTIATE__ - if (!inherited) { - __RUNTIME_COMPONENT__; - } - - R3.D3.Camera.call(this); + R3.D3.Camera.call( + this, + apiComponent, + true + ); }; @@ -30,19 +28,7 @@ R3.D3.Camera.Perspective.prototype.constructor = R3.D3.Camera.Perspective; */ R3.D3.Camera.Perspective.prototype.createInstance = function() { - this.instance = this.graphics.PerspectiveCamera( - this.fov, - this.aspect, - this.near, - this.far - ); - - this.instance.filmGauge = this.filmGauge; - this.instance.filmOffset = this.filmOffset; - this.instance.focus = this.focus; - this.instance.zoom = this.zoom; - - this.instance.updateProjectionMatrix(); + this.instance = this.graphics.PerspectiveCamera(this); __CREATE_INSTANCE__; @@ -53,6 +39,16 @@ R3.D3.Camera.Perspective.prototype.createInstance = function() { */ R3.D3.Camera.Perspective.prototype.updateInstance = function(property) { + if (property === 'position') { + this.instance.position.set( + this.position.x, + this.position.y, + this.position.z + ); + this.instance.updateProjectionMatrix(); + return; + } + if (property === 'near') { this.instance.near = this.near; this.instance.updateProjectionMatrix(); diff --git a/src/r3-d3-camera-perspective-stereo.js b/src/r3-d3-camera-perspective-stereo.js index 8d5af5a..3827eff 100644 --- a/src/r3-d3-camera-perspective-stereo.js +++ b/src/r3-d3-camera-perspective-stereo.js @@ -11,6 +11,7 @@ R3.D3.Camera.Perspective.Stereo = function( R3.D3.Camera.Perspective.call( this, + apiComponent, true ); diff --git a/src/r3-d3-fog-0.js b/src/r3-d3-fog-0.js index 97d4ed2..ebc9a1a 100644 --- a/src/r3-d3-fog-0.js +++ b/src/r3-d3-fog-0.js @@ -6,12 +6,7 @@ R3.D3.Fog = function( inherited ) { - /** - * This class is intended to be inherited only - */ - if (R3.Utils.UndefinedOrNull(inherited)) { - throw new Error('This class can only be inherited'); - } + __INHERIT_ONLY__ __UPGRADE_TO_RUNTIME__; diff --git a/src/r3-d3-fog-exp.js b/src/r3-d3-fog-exp.js index 9e2dbfa..81fcf00 100644 --- a/src/r3-d3-fog-exp.js +++ b/src/r3-d3-fog-exp.js @@ -20,10 +20,7 @@ R3.D3.Fog.Exp.prototype.constructor = R3.D3.Fog.Exp; R3.D3.Fog.Exp.prototype.createInstance = function() { - this.instance = this.graphics.FogExp( - this.color, - this.density - ); + this.instance = this.graphics.FogExp(this); __CREATE_INSTANCE__; }; diff --git a/src/r3-d3-fog-normal.js b/src/r3-d3-fog-normal.js index e8250fd..ec74537 100644 --- a/src/r3-d3-fog-normal.js +++ b/src/r3-d3-fog-normal.js @@ -21,11 +21,7 @@ R3.D3.Fog.Normal.prototype.constructor = R3.D3.Fog.Normal; R3.D3.Fog.Normal.prototype.createInstance = function() { - this.instance = this.graphics.Fog( - this.color, - this.near, - this.far - ); + this.instance = this.graphics.Fog(this); __CREATE_INSTANCE__; }; diff --git a/src/r3-d3-material-0.js b/src/r3-d3-material-0.js index 868230a..d40a4df 100644 --- a/src/r3-d3-material-0.js +++ b/src/r3-d3-material-0.js @@ -262,7 +262,7 @@ R3.D3.Material.prototype.getTextures = function() { var textures = []; - Object.keys(this.linkedObjects).map( + Object.keys(this.linkedComponents).map( function(property) { if (this[property] instanceof R3.D3.Texture) { textures.push( @@ -282,45 +282,45 @@ 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; + linkedComponents.alphaMap = R3.D3.Texture; + linkedComponents.aoMap = R3.D3.Texture; + linkedComponents.bumpMap = R3.D3.Texture; + linkedComponents.diffuseMap = R3.D3.Texture; + linkedComponents.displacementMap = R3.D3.Texture; + linkedComponents.emissiveMap = R3.D3.Texture; + linkedComponents.envMap = R3.D3.Texture; + linkedComponents.lightMap = R3.D3.Texture; + linkedComponents.metalnessMap = R3.D3.Texture; + linkedComponents.normalMap = R3.D3.Texture; + linkedComponents.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; + linkedComponents.alphaMap = R3.D3.Texture; + linkedComponents.aoMap = R3.D3.Texture; + linkedComponents.diffuseMap = R3.D3.Texture; + linkedComponents.envMap = R3.D3.Texture; + linkedComponents.lightMap = R3.D3.Texture; + linkedComponents.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; + linkedComponents.alphaMap = R3.D3.Texture; + linkedComponents.aoMap = R3.D3.Texture; + linkedComponents.bumpMap = R3.D3.Texture; + linkedComponents.diffuseMap = R3.D3.Texture; + linkedComponents.displacementMap = R3.D3.Texture; + linkedComponents.emissiveMap = R3.D3.Texture; + linkedComponents.envMap = R3.D3.Texture; + linkedComponents.lightMap = R3.D3.Texture; + linkedComponents.normalMap = R3.D3.Texture; + linkedComponents.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; + linkedComponents.vertexShader = R3.D3.Shader.Vertex; + linkedComponents.fragmentShader = R3.D3.Shader.Fragment; break; case R3.D3.API.Material.MATERIAL_TYPE_POINTS : - linkedObjects.diffuseMap = R3.D3.Texture; + linkedComponents.diffuseMap = R3.D3.Texture; break; default : throw new Error('unhandled material type: ' + this.materialType); diff --git a/src/r3-d3-particle-0.js b/src/r3-d3-mesh-particle-0.js similarity index 55% rename from src/r3-d3-particle-0.js rename to src/r3-d3-mesh-particle-0.js index a1103ca..dbbe982 100644 --- a/src/r3-d3-particle-0.js +++ b/src/r3-d3-mesh-particle-0.js @@ -1,114 +1,50 @@ /** - * Creates a Particle object - * @param graphics R3.Runtime.Graphics - * @param apiParticle R3.D3.API.Particle + * R3.D3.Mesh.Particle + * @param apiComponent + * @param inherited * @constructor */ -R3.D3.Particle = function( - graphics, - apiParticle +R3.D3.Mesh.Particle = function( + apiComponent, + inherited ) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiParticle)) { - apiParticle = {}; + + if (R3.Utils.UndefinedOrNull(inherited)) { + __RUNTIME_COMPONENT__; } - R3.D3.API.Particle.call( + R3.D3.Mesh.call( this, - apiParticle.id, - apiParticle.name, - apiParticle.lifeTime, - apiParticle.elapsed, - apiParticle.mesh, - apiParticle.opacityType, - apiParticle.fadeInFactor, - apiParticle.fadeOutFactor, - apiParticle.fadeInAfter, - apiParticle.fadeOutAfter, - apiParticle.positionOffsetType, - apiParticle.positionOffset, - apiParticle.positionOffsetFn, - apiParticle.directionType, - apiParticle.direction, - apiParticle.directionFn, - apiParticle.speedType, - apiParticle.speed, - apiParticle.scaleType, - apiParticle.scale, - apiParticle.scaleFn, - apiParticle.rotationType, - apiParticle.rotation, - apiParticle.rotationFn, - apiParticle.parentParticleEngine, - apiParticle.parent - ); - - if (this.mesh instanceof R3.D3.API.Mesh) { - this.mesh = new R3.D3.Mesh( - graphics, - this.mesh - ) - } - - this.positionOffset = new R3.Vector3( - graphics, - this.positionOffset, - this - ); - - this.direction = new R3.Vector3( - graphics, - this.direction, - this - ); - - this.scale = new R3.Vector3( - graphics, - this.scale, - this - ); - - this.rotation = new R3.Vector3( - graphics, - this.rotation, - this - ); - - R3.Component.call( - this, - { - mesh : R3.D3.Mesh, - parentParticleEngine : R3.D3.ParticleEngine - } + apiComponent, + true ); }; -R3.D3.Particle.prototype = Object.create(R3.Component.prototype); -R3.D3.Particle.prototype.constructor = R3.D3.Particle; +R3.D3.Mesh.Particle.prototype = Object.create(R3.D3.Mesh.prototype); +R3.D3.Mesh.Particle.prototype.constructor = R3.D3.Mesh.Particle; /** - * Particle create instance + * Mesh.Particle create instance */ -R3.D3.Particle.prototype.createInstance = function() { +R3.D3.Mesh.Particle.prototype.createInstance = function() { - if (!this.mesh) { - console.warn('no mesh to clone from - failed dependency check?'); - return - } - - this.instance = this.mesh.instance; + console.warn('todo : R3.D3.Mesh.Particle.prototype.createInstance'); + // if (!this.mesh) { + // console.warn('no mesh to clone from - failed dependency check?'); + // return + // } + // + // this.instance = this.mesh.instance; + // __CREATE_INSTANCE__; }; /** * Updates the instance with the current state */ -R3.D3.Particle.prototype.updateInstance = function(property) { +R3.D3.Mesh.Particle.prototype.updateInstance = function(property) { if (!this.instance) { this.createInstance(); @@ -154,7 +90,7 @@ R3.D3.Particle.prototype.updateInstance = function(property) { /** * Clones a particle - this only clones 3rd party instances, so we have less overhead of creating these types of objects */ -R3.D3.Particle.prototype.cloneInstance = function() { +R3.D3.Mesh.Particle.prototype.cloneInstance = function() { this.updateInstance('positionOffset'); this.updateInstance('direction'); @@ -163,13 +99,13 @@ R3.D3.Particle.prototype.cloneInstance = function() { var clone = R3.Component.prototype.cloneInstance.call(this); - clone.position = this.parentParticleEngine.position.instance.clone(); + clone.position = this.parentMesh.ParticleEngine.position.instance.clone(); clone.material = this.mesh.materials[0].instance.clone(); clone.visible = true; - if (this.positionOffsetType === R3.D3.API.Particle.POSITION_OFFSET_TYPE_CONSTANT) { + if (this.positionOffsetType === R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_CONSTANT) { clone.position.add(this.positionOffset.instance); } @@ -177,7 +113,7 @@ R3.D3.Particle.prototype.cloneInstance = function() { var addY = 1; var addZ = 1; - if (this.positionOffsetType === R3.D3.API.Particle.POSITION_OFFSET_TYPE_RANDOM) { + if (this.positionOffsetType === R3.D3.API.Mesh.Particle.POSITION_OFFSET_TYPE_RANDOM) { addX = R3.Utils.GetRandomIntInclusive(1,2); addY = R3.Utils.GetRandomIntInclusive(1,2); @@ -204,15 +140,15 @@ R3.D3.Particle.prototype.cloneInstance = function() { clone.userData.direction = this.direction.clone(); - if (this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_CONSTANT) { + if (this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_CONSTANT) { /** * Nothing to do */ } else if ( - this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM || - this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED + this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM || + this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED ) { addX = R3.Utils.GetRandomIntInclusive(1,2); @@ -241,7 +177,7 @@ R3.D3.Particle.prototype.cloneInstance = function() { clone.userData.direction.z += Math.random() * this.direction.z; } - if (this.directionType === R3.D3.API.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED) { + if (this.directionType === R3.D3.API.Mesh.Particle.DIRECTION_TYPE_RANDOM_NORMALIZED) { clone.userData.direction.normalize(); } @@ -250,13 +186,13 @@ R3.D3.Particle.prototype.cloneInstance = function() { } - if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_CONSTANT) { + if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_CONSTANT) { clone.scale.x += this.scale.x; clone.scale.y += this.scale.y; clone.scale.z += this.scale.z; } - if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_RANDOM) { + if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM) { add = R3.Utils.GetRandomIntInclusive(1,2); @@ -271,7 +207,7 @@ R3.D3.Particle.prototype.cloneInstance = function() { } } - if (this.scaleType === R3.D3.API.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) { + if (this.scaleType === R3.D3.API.Mesh.Particle.SCALE_TYPE_RANDOM_X_EQUALS_Y) { add = R3.Utils.GetRandomIntInclusive(1,2); @@ -291,14 +227,14 @@ R3.D3.Particle.prototype.cloneInstance = function() { var fadeIn = true; if ( - this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_LINEAR || - this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR + this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_LINEAR || + this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_IN_OUT_LINEAR ) { clone.material.opacity = 0; fadeIn = true; } - if (this.opacityType === R3.D3.API.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) { + if (this.opacityType === R3.D3.API.Mesh.Particle.OPACITY_TYPE_FADE_OUT_LINEAR) { clone.material.opacity = 1; fadeIn = false; } @@ -315,40 +251,3 @@ R3.D3.Particle.prototype.cloneInstance = function() { return clone; }; - -/** - * Converts a R3.D3.Particle to a new R3.D3.API.Particle - * @returns {R3.D3.API.Particle} - */ -R3.D3.Particle.prototype.toApiObject = function() { - - return new R3.D3.API.Particle( - this.id, - this.name, - this.lifeTime, - this.elapsed, - R3.Utils.IdOrNull(this.mesh), - this.opacityType, - this.fadeInFactor, - this.fadeOutFactor, - this.fadeInAfter, - this.fadeOutAfter, - this.positionOffsetType, - this.positionOffset.toApiObject(), - this.positionOffsetFn, - this.directionType, - this.direction.toApiObject(), - this.directionFn, - this.speedType, - this.speed, - this.scaleType, - this.scale.toApiObject(), - this.scaleFn, - this.rotationType, - this.rotation.toApiObject(), - this.rotationFn, - R3.Utils.IdOrNull(this.parentParticleEngine), - R3.Utils.IdOrNull(this.parent) - ); - -}; diff --git a/src/r3-d3-mesh-particle-engine.js b/src/r3-d3-mesh-particle-engine.js new file mode 100644 index 0000000..16135aa --- /dev/null +++ b/src/r3-d3-mesh-particle-engine.js @@ -0,0 +1,192 @@ +/** + * Creates a Mesh.Particle.Engine object + * @param graphics R3.Runtime.Graphics + * @param apiMesh.Particle.Engine R3.D3.API.Mesh.Particle.Engine + * @constructor + */ +R3.D3.Mesh.Particle.Engine = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + +}; + +R3.D3.Mesh.Particle.Engine.prototype = Object.create(R3.D3.Mesh.Particle.prototype); +R3.D3.Mesh.Particle.Engine.prototype.constructor = R3.D3.Mesh.Particle.Engine; + +/** + * We don't use a 3rd party particle engine right now + * @returns true + */ +R3.D3.Mesh.Particle.Engine.prototype.createInstance = function() { + + this.instance = true; + + // if (this.templateMesh.Particle) { + // + // this.templateMesh.Particle.mesh.position.x = this.position.x; + // this.templateMesh.Particle.mesh.position.y = this.position.y; + // this.templateMesh.Particle.mesh.position.z = this.position.z; + // + // this.templateMesh.Particle.direction.x = this.direction.x; + // this.templateMesh.Particle.direction.y = this.direction.y; + // this.templateMesh.Particle.direction.z = this.direction.z; + // + // this.templateMesh.Particle.scale.x = this.scale.x; + // this.templateMesh.Particle.scale.y = this.scale.y; + // this.templateMesh.Particle.scale.z = this.scale.z; + // } + + __CREATE_INSTANCE__; +}; + +/** + * Updates the instance with the current state + */ +R3.D3.Mesh.Particle.Engine.prototype.updateInstance = function(property) { + + // if (property === 'particlesPerSecond') { + // this.frequency = Number(1 / this.particlesPerSecond); + // } + // + // if (property === 'frequency') { + // this.particlesPerSecond = Math.round(1 / this.frequency); + // } + // + // if (property === 'position') { + // this.position.instance.x = this.position.x; + // this.position.instance.y = this.position.y; + // this.position.instance.z = this.position.z; + // this.templateMeshParticle.mesh.position = this.position.clone(); + // this.templateMeshParticle.mesh.updateInstance('position', true); + // } + // + // if (property === 'direction') { + // this.direction.instance.x = this.direction.x; + // this.direction.instance.y = this.direction.y; + // this.direction.instance.z = this.direction.z; + // this.templateMeshParticle.direction = this.direction.clone(); + // this.templateMeshParticle.direction.updateInstance('direction', true); + // } + + __UPDATE_INSTANCE__; +}; + +R3.D3.Mesh.Particle.Engine.prototype.remove = function() { + + // if (this.removeSubscription) { + // console.log('already another remove subscription for ' + this.name); + // return; + // } + // + // this.removeSubscription = R3.Event.Subscribe( + // R3.Event.REMOVE_PARTICLE_ENGINE, + // function(data){ + // if (data.component === this) { + // + // if (this.isClone) { + // /** + // * We only remove the things we cloned, the mesh, particle, and this + // */ + // R3.Event.Emit( + // R3.Event.REMOVE_COMPONENT, + // { + // component: this.templateMeshParticle.mesh + // } + // ); + // + // R3.Event.Emit( + // R3.Event.REMOVE_COMPONENT, + // { + // component: this.templateMeshParticle + // } + // ); + // + // R3.Event.Emit( + // R3.Event.REMOVE_COMPONENT, + // { + // component: this + // } + // ) + // } else { + // R3.Component.prototype.remove.call(this); + // } + // + // this.removeSubscription.remove(); + // + // this.removeSubscription = null; + // } + // }.bind(this) + // ); + + /** + * Below signals the particle system to continue processing the particles, but don't create more, and + * we wait for the system to signal REMOVE_PARTICLE_ENGINE so we can destroy ourselves + * @type {boolean} + */ + this.disabledForRemoval = true; +}; + +// R3.D3.Mesh.Particle.Engine.prototype.getChildrenComponents = function() { +// +// var components = []; +// +// if (this.templateMesh.Particle) { +// components.push(this.templateMesh.Particle); +// +// if (this.templateMesh.Particle.mesh) { +// components.push(this.templateMesh.Particle.mesh); +// +// if (this.templateMesh.Particle.mesh.materials && this.templateMesh.Particle.mesh.materials[0]) { +// +// components.push(this.templateMesh.Particle.mesh.materials[0]); +// +// if (this.templateMesh.Particle.mesh.materials[0].diffuseMap) { +// components.push(this.templateMesh.Particle.mesh.materials[0].diffuseMap); +// } +// } +// } +// } +// +// return components; +// }; + +R3.D3.Mesh.Particle.Engine.prototype.clone = function() { + // var mesh = this.templateMesh.Particle.mesh.clone(); + // var templateMesh.Particle = this.templateMesh.Particle.clone(); + // templateMesh.Particle.mesh = mesh; + // templateMesh.Particle.instance = mesh.instance; + // var engine = R3.Component.prototype.clone.call(this); + // engine.templateMesh.Particle = templateMesh.Particle; + // return engine; +}; + +R3.D3.Mesh.Particle.Engine.prototype.processMeshParticles = function(delta) { + // this.particles = this.particles.reduce( + // function(result, particle){ + // + // particle.position.x += particle.userData.direction.x * delta; + // particle.position.y += particle.userData.direction.y * delta; + // particle.position.z += particle.userData.direction.z * delta; + // + // particle.userData.elapsed += delta; + // if (particle.userData.elapsed > particle.userData.lifeTime) { + // particle.parent.remove(particle); + // } else { + // result.push(particle); + // } + // + // return result; + // }, + // [] + // ); +}; + +R3.D3.Mesh.Particle.Engine.prototype.createNewMeshParticle = function(camera) { + // + // var particle = this.templateMesh.Particle.clone(camera); + // + // this.particles.push(particle); + +}; diff --git a/src/r3-d3-particle-engine.js b/src/r3-d3-particle-engine.js deleted file mode 100644 index 4d5b5bf..0000000 --- a/src/r3-d3-particle-engine.js +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Creates a ParticleEngine object - * @param graphics R3.Runtime.Graphics - * @param apiParticleEngine R3.D3.API.ParticleEngine - * @constructor - */ -R3.D3.ParticleEngine = function( - graphics, - apiParticleEngine -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiParticleEngine)) { - apiParticleEngine = {}; - } - - R3.D3.API.ParticleEngine.call( - this, - apiParticleEngine.id, - apiParticleEngine.name, - apiParticleEngine.position, - apiParticleEngine.direction, - apiParticleEngine.enabled, - apiParticleEngine.templateParticle, - apiParticleEngine.particlesPerSecond, - apiParticleEngine.frequency, - apiParticleEngine.elapsed, - apiParticleEngine.camera, - apiParticleEngine.pulse, - apiParticleEngine.fired, - apiParticleEngine.parent - ); - - this.position = new R3.Vector3( - graphics, - this.position, - this - ); - - this.direction = new R3.Vector3( - graphics, - this.direction, - this - ); - - if (this.templateParticle instanceof R3.D3.API.Particle) { - this.templateParticle = new R3.D3.Particle( - graphics, - this.templateParticle - ) - } - - this.elapsed = 0; - - this.particles = []; - - this.disabledForRemoval = false; - - R3.Component.call( - this, - { - templateParticle : R3.D3.Particle, - camera : R3.D3.Camera - } - ); - -}; - -R3.D3.ParticleEngine.prototype = Object.create(R3.Component.prototype); -R3.D3.ParticleEngine.prototype.constructor = R3.D3.ParticleEngine; - -/** - * We don't use a 3rd party particle engine right now - * @returns true - */ -R3.D3.ParticleEngine.prototype.createInstance = function() { - - this.instance = true; - - // if (this.templateParticle) { - // - // this.templateParticle.mesh.position.x = this.position.x; - // this.templateParticle.mesh.position.y = this.position.y; - // this.templateParticle.mesh.position.z = this.position.z; - // - // this.templateParticle.direction.x = this.direction.x; - // this.templateParticle.direction.y = this.direction.y; - // this.templateParticle.direction.z = this.direction.z; - // - // this.templateParticle.scale.x = this.scale.x; - // this.templateParticle.scale.y = this.scale.y; - // this.templateParticle.scale.z = this.scale.z; - // } - - __CREATE_INSTANCE__; -}; - -/** - * Updates the instance with the current state - */ -R3.D3.ParticleEngine.prototype.updateInstance = function(property) { - - if (property === 'particlesPerSecond') { - this.frequency = Number(1 / this.particlesPerSecond); - } - - if (property === 'frequency') { - this.particlesPerSecond = Math.round(1 / this.frequency); - } - - if (property === 'position') { - this.position.instance.x = this.position.x; - this.position.instance.y = this.position.y; - this.position.instance.z = this.position.z; - this.templateParticle.mesh.position = this.position.clone(); - this.templateParticle.mesh.updateInstance('position', true); - } - - if (property === 'direction') { - this.direction.instance.x = this.direction.x; - this.direction.instance.y = this.direction.y; - this.direction.instance.z = this.direction.z; - this.templateParticle.direction = this.direction.clone(); - this.templateParticle.direction.updateInstance('direction', true); - } - - __UPDATE_INSTANCE__; -}; - -R3.D3.ParticleEngine.prototype.remove = function() { - - if (this.removeSubscription) { - console.log('already another remove subscription for ' + this.name); - return; - } - - this.removeSubscription = R3.Event.Subscribe( - R3.Event.REMOVE_PARTICLE_ENGINE, - function(data){ - if (data.component === this) { - - if (this.isClone) { - /** - * We only remove the things we cloned, the mesh, particle, and this - */ - R3.Event.Emit( - R3.Event.REMOVE_COMPONENT, - { - component: this.templateParticle.mesh - } - ); - - R3.Event.Emit( - R3.Event.REMOVE_COMPONENT, - { - component: this.templateParticle - } - ); - - R3.Event.Emit( - R3.Event.REMOVE_COMPONENT, - { - component: this - } - ) - } else { - R3.Component.prototype.remove.call(this); - } - - this.removeSubscription.remove(); - - this.removeSubscription = null; - } - }.bind(this) - ); - - /** - * Below signals the particle system to continue processing the particles, but don't create more, and - * we wait for the system to signal REMOVE_PARTICLE_ENGINE so we can destroy ourselves - * @type {boolean} - */ - this.disabledForRemoval = true; -}; - -// R3.D3.ParticleEngine.prototype.getChildrenComponents = function() { -// -// var components = []; -// -// if (this.templateParticle) { -// components.push(this.templateParticle); -// -// if (this.templateParticle.mesh) { -// components.push(this.templateParticle.mesh); -// -// if (this.templateParticle.mesh.materials && this.templateParticle.mesh.materials[0]) { -// -// components.push(this.templateParticle.mesh.materials[0]); -// -// if (this.templateParticle.mesh.materials[0].diffuseMap) { -// components.push(this.templateParticle.mesh.materials[0].diffuseMap); -// } -// } -// } -// } -// -// return components; -// }; - -R3.D3.ParticleEngine.prototype.clone = function() { - var mesh = this.templateParticle.mesh.clone(); - var templateParticle = this.templateParticle.clone(); - templateParticle.mesh = mesh; - templateParticle.instance = mesh.instance; - var engine = R3.Component.prototype.clone.call(this); - engine.templateParticle = templateParticle; - return engine; -}; - -R3.D3.ParticleEngine.prototype.processParticles = function(delta) { - // this.particles = this.particles.reduce( - // function(result, particle){ - // - // particle.position.x += particle.userData.direction.x * delta; - // particle.position.y += particle.userData.direction.y * delta; - // particle.position.z += particle.userData.direction.z * delta; - // - // particle.userData.elapsed += delta; - // if (particle.userData.elapsed > particle.userData.lifeTime) { - // particle.parent.remove(particle); - // } else { - // result.push(particle); - // } - // - // return result; - // }, - // [] - // ); -}; - -R3.D3.ParticleEngine.prototype.createNewParticle = function(camera) { - // - // var particle = this.templateParticle.clone(camera); - // - // this.particles.push(particle); - -}; - -/** - * Converts a R3.D3.ParticleEngine to a new R3.D3.API.ParticleEngine - * @returns {R3.D3.API.ParticleEngine} - */ -R3.D3.ParticleEngine.prototype.toApiObject = function() { - - return new R3.D3.API.ParticleEngine( - this.id, - this.name, - this.position.toApiObject(), - this.direction.toApiObject(), - this.enabled, - R3.Utils.IdOrNull(this.templateParticle), - this.particlesPerSecond, - this.frequency, - this.elapsed, - R3.Utils.IdOrNull(this.camera), - this.pulse, - this.fired, - R3.Utils.IdOrNull(this.parent) - ); - -}; diff --git a/src/r3-d3-physics-world.js b/src/r3-d3-physicsWorld.js similarity index 100% rename from src/r3-d3-physics-world.js rename to src/r3-d3-physicsWorld.js diff --git a/src/r3-d3-raycaster.js b/src/r3-d3-raycaster.js index fe4555c..f49e953 100644 --- a/src/r3-d3-raycaster.js +++ b/src/r3-d3-raycaster.js @@ -9,13 +9,6 @@ R3.D3.Raycaster = function( __RUNTIME_COMPONENT__; - R3.D3.API.Raycaster.call( - this, - apiComponent, - apiComponent.position, - apiComponent.direction - ); - __UPGRADE_TO_RUNTIME__; }; @@ -75,8 +68,8 @@ R3.D3.Raycaster.prototype.set = function( this.direction.y = direction.y; this.direction.z = direction.z; - this.position.updateInstance(); - this.direction.updateInstance(); + this.updateInstance('position'); + this.updateInstance('direction'); }; /** @@ -90,7 +83,7 @@ R3.D3.Raycaster.prototype.setDirection = function( this.direction.y = direction.y; this.direction.z = direction.z; - this.direction.updateInstance(); + this.updateInstance('direction'); }; /** @@ -104,7 +97,7 @@ R3.D3.Raycaster.prototype.setPosition = function( this.position.y = position.y; this.position.z = position.z; - this.position.updateInstance(); + this.updateInstance('position'); }; /** diff --git a/src/r3-d3-renderTarget-0.js b/src/r3-d3-renderTarget-0.js index 6cd4733..40284e5 100644 --- a/src/r3-d3-renderTarget-0.js +++ b/src/r3-d3-renderTarget-0.js @@ -1,72 +1,20 @@ /** * R3.D3.RenderTarget - * - * - This class can be used in two ways - either you can instantiate it directly, or it can be instantiated indirectly - * through its child class(es) - in the latter case, use linkedObjects to bypass API component call - * - * @param parent * @param apiComponent - * @param linkedObjects * @constructor */ R3.D3.RenderTarget = function( - parent, apiComponent, - linkedObjects + inherited ) { - if (R3.Utils.UndefinedOrNull(linkedObjects)) { - /** - * We are constructing this object 'as is' - use the API component to initialize it - */ + __INHERIT_AND_INSTANTIATE__ - R3.D3.API.RenderTarget.call( - this, - apiComponent, - apiComponent.width, - apiComponent.height, - apiComponent.scissor, - apiComponent.scissorTest, - apiComponent.viewport, - apiComponent.texture, - apiComponent.depthBuffer, - apiComponent.depthTexture, - apiComponent.stencilBuffer - ); + this.linkedComponents.texture = R3.D3.Texture; + this.linkedComponents.depthTexture = R3.D3.Texture; - linkedObjects = { - texture : R3.D3.Texture, - depthTexture : R3.D3.Texture - } + __UPGRADE_TO_RUNTIME__; - } else { - linkedObjects.texture = R3.D3.Texture; - linkedObjects.depthTexture = R3.D3.Texture; - } - - this.scissor = new R3.Vector4( - this, - this.scissor - ); - - this.viewport = new R3.Vector4( - this, - this.viewport - ); - - if (this.texture instanceof R3.API.Component) { - this.texture = R3.Component.ConstructFromObject(this.texture); - } - - if (this.depthTexture instanceof R3.API.Component) { - this.depthTexture = R3.Component.ConstructFromObject(this.depthTexture); - } - - R3.Component.call( - this, - parent, - linkedObjects - ); }; R3.D3.RenderTarget.prototype = Object.create(R3.Component.prototype); diff --git a/src/r3-d3-scene.js b/src/r3-d3-scene.js index abd269c..03aafe4 100644 --- a/src/r3-d3-scene.js +++ b/src/r3-d3-scene.js @@ -1,187 +1,44 @@ /** * R3.D3.Scene - * @param graphics - * @param apiScene R3.D3.API.Scene + * @param apiComponent * @constructor */ R3.D3.Scene = function( - graphics, - apiScene + apiComponent ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - if (R3.Utils.UndefinedOrNull(apiScene)) { - apiScene = {}; - } + __RUNTIME_COMPONENT__; - R3.D3.API.Scene.call( - this, - apiScene.id, - apiScene.name, - apiScene.meshes, - apiScene.lights, - apiScene.textures, - apiScene.materials, - apiScene.images, - apiScene.fog, - apiScene.showGrid, - apiScene.showAxis, - apiScene.gridSize, - apiScene.gridColor, - apiScene.parent - ); + this.linkedComponents.meshes = [R3.D3.Mesh]; + this.linkedComponents.lights = [R3.D3.Light]; + this.linkedComponents.textures = [R3.D3.Texture]; + this.linkedComponents.materials = [R3.D3.Material]; + this.linkedComponents.fog = R3.D3.Fog; - this.textures = this.textures.map( - function(apiTexture) { + this.helpers = []; - if (typeof apiTexture === 'string') { - return apiTexture; - } - - return new R3.D3.Texture( - this.graphics, - apiTexture - ); - - }.bind(this) - ); - - this.materials = this.materials.map( - function(apiMaterial) { - - if (typeof apiMaterial === 'string') { - return apiMaterial; - } - - return new R3.D3.Material( - this.graphics, - apiMaterial - ); - - }.bind(this) - ); - - this.images = this.images.map( - function(apiImage) { - - if (typeof apiImage === 'string') { - return apiImage; - } - - return new R3.Image( - this.graphics, - apiImage - ); - - }.bind(this) - ); - - if (this.fog instanceof R3.D3.API.Fog) { - this.fog = new R3.D3.Fog( - this.graphics, - this.fog - ) - } - - this.gridColor = new R3.Color( - this.graphics, - this.gridColor, - this - ); - - /** - * Runtime scenes have helpers (just used to store which helper belongs to which scene) - * @type {Array} - */ - this.helpers = []; - - this.clones = []; + this.clones = []; this.grid = []; this.axis = []; - this.storeClones = false; + this.storeClones = false; - this.instance = instance; + __UPGRADE_TO_RUNTIME__; - R3.Component.call( - this, - { - 'meshes' : [R3.D3.Mesh], - 'lights' : [R3.D3.Light], - 'textures' : [R3.D3.Texture], - 'materials' : [R3.D3.Material], - 'images' : [R3.Image], - 'fog' : R3.D3.Fog - } - ); }; R3.D3.Scene.prototype = Object.create(R3.Component.prototype); R3.D3.Scene.prototype.constructor = R3.D3.Scene; -R3.D3.Scene.prototype.constructFromInstance = function() { - this.loaded = true; - console.log('todo: - setup scene from instance'); -}; - /** * Creates an instance scene * @returns {THREE.Scene} */ R3.D3.Scene.prototype.createInstance = function() { - if (R3.Utils.UndefinedOrNull(this.instance)) { - this.instance = new THREE.Scene(); - } else { - this.constructFromInstance(); - return; - } - - this.instance.name = this.name; - - if (this.fog && this.fog.instance) { - this.instance.fog = this.fog.instance; - } - - this.meshes.map( - function(mesh) { - - if (R3.Utils.UndefinedOrNull(mesh)) { - throw new Error('no mesh'); - } - - if (R3.Utils.UndefinedOrNull(mesh.instance)) { - throw new Error('no mesh instance'); - } - - this.instance.add(mesh.instance); - - mesh.parentScene = this; - - }.bind(this) - ); - - this.lights.map( - function(light) { - - - if (R3.Utils.UndefinedOrNull(light)) { - throw new Error('no light'); - } - - if (R3.Utils.UndefinedOrNull(light.instance)) { - throw new Error('no light instance'); - } - - this.instance.add(light.instance); - - light.parentScene = this; - - }.bind(this) - ); + this.instance = this.graphics.Scene(this); if (this.showGrid) { this.drawGrid(); @@ -203,8 +60,10 @@ R3.D3.Scene.prototype.updateInstance = function(property) { } if (property === 'fog') { - if (this.fog && this.fog.instance !== this.instance.fog) { + if (R3.Utils.Instance(this.fog)) { this.instance.fog = this.fog.instance; + } else { + this.instance.fog = null; } } @@ -299,67 +158,6 @@ R3.D3.Scene.prototype.updateInstance = function(property) { __UPDATE_INSTANCE__; }; -/** - * Converts a R3.D3.Scene to a R3.D3.API.Scene - * @returns {R3.D3.API.Scene} - */ -R3.D3.Scene.prototype.toApiObject = function() { - - var apiMeshes = []; - - if (this.storeClones) { - this.clones.map( - function(clone) { - R3.Utils.PushUnique( - apiMeshes, - R3.Utils.IdOrNull(clone) - ); - } - ); - } - - this.meshes.map( - function(mesh) { - R3.Utils.PushUnique( - apiMeshes, - R3.Utils.IdOrNull(mesh) - ); - } - ); - - return new R3.D3.API.Scene( - this.id, - this.name, - apiMeshes, - this.lights.map( - function(light) { - return R3.Utils.IdOrNull(light); - } - ), - this.textures.map( - function(texture) { - return R3.Utils.IdOrNull(texture); - } - ), - this.materials.map( - function(material) { - return R3.Utils.IdOrNull(material); - } - ), - this.images.map( - function(image) { - return R3.Utils.IdOrNull(image); - } - ), - R3.Utils.IdOrNull(this.fog), - this.showGrid, - this.showAxis, - this.gridSize, - this.gridColor.toApiObject(), - R3.Utils.IdOrNull(this.parent) - ); -}; - /** * Adds a mesh to the scene * @param object R3.D3.Mesh diff --git a/src/r3-d3-shape-0.js b/src/r3-d3-shape-0.js index 51bc583..769976a 100644 --- a/src/r3-d3-shape-0.js +++ b/src/r3-d3-shape-0.js @@ -29,14 +29,14 @@ R3.D3.Shape = function( apiShape.parent ); - var linkedObjects = { + var linkedComponents = { frictionMaterial : R3.D3.FrictionMaterial, parentMesh : R3.D3.Mesh }; R3.Component.call( this, - linkedObjects + linkedComponents ); }; diff --git a/src/r3-d3-texture-0.js b/src/r3-d3-texture-0.js index 417de93..07cfe4b 100644 --- a/src/r3-d3-texture-0.js +++ b/src/r3-d3-texture-0.js @@ -76,19 +76,19 @@ R3.D3.Texture = function( this ); - var linkedObjects = {}; + var linkedComponents = {}; switch (apiTexture.textureType) { case R3.D3.API.Texture.TEXTURE_TYPE_NONE : break; case R3.D3.API.Texture.TEXTURE_TYPE_IMAGE : - linkedObjects.image = R3.Image; + linkedComponents.image = R3.Image; break; case R3.D3.API.Texture.TEXTURE_TYPE_CUBE : - linkedObjects.images = [R3.Image]; + linkedComponents.images = [R3.Image]; break; case R3.D3.API.Texture.TEXTURE_TYPE_CANVAS : - linkedObjects.canvas = R3.Canvas; + linkedComponents.canvas = R3.Canvas; break; default : throw new Error('Unhandled texture type : ' + this.textureType); @@ -96,7 +96,7 @@ R3.D3.Texture = function( R3.Component.call( this, - linkedObjects + linkedComponents ); }; diff --git a/src/r3-d3-viewport-0.js b/src/r3-d3-viewport-0.js index ee82efc..f8d5973 100644 --- a/src/r3-d3-viewport-0.js +++ b/src/r3-d3-viewport-0.js @@ -1,96 +1,49 @@ /** - * Viewport Runtime - * @param graphics R3.Runtime.Graphics - * @param apiViewport R3.D3.API.Viewport + * R3.D3.Viewport + * @param inherited * @constructor */ R3.D3.Viewport = function( - graphics, - apiViewport + inherited ) { - this.graphics = graphics; - this.graphics.isNotThreeThrow(); + __INHERIT_ONLY__; - if (R3.Utils.UndefinedOrNull(apiViewport)) { - apiViewport = {}; - } + this.linkedComponents.scenes = [R3.D3.Scene]; - R3.D3.API.Viewport.call( - this, - apiViewport.id, - apiViewport.name, - apiViewport.viewportType, - apiViewport.parent, - apiViewport.scenes, - apiViewport.width, - apiViewport.height, - apiViewport.x, - apiViewport.y - ); + __UPGRADE_TO_RUNTIME__; - R3.Component.call(this); }; R3.D3.Viewport.prototype = Object.create(R3.Component.prototype); R3.D3.Viewport.prototype.constructor = R3.D3.Viewport; /** - * - * @returns {boolean} - */ -R3.D3.Viewport.prototype.createInstance = function() { - - this.instance = new THREE.Vector4( - this.x, - this.y, - this.width, - this.height - ); - - __CREATE_INSTANCE__; -}; - -/** - * + * R3.D3.Viewport.prototype.updateInstance + * @param property */ R3.D3.Viewport.prototype.updateInstance = function(property) { - if ( - property === 'x' || - property === 'y' || - property === 'width' || - property === 'height' - ) { + if (property === 'x') { this.instance.x = this.x; - this.instance.y = this.y; - this.instance.z = this.width; - this.instance.w = this.height; + return; } -}; + if (property === 'y') { + this.instance.y = this.y; + return; + } -/** - * R3.D3.Viewport to R3.D3.API.Viewport - * @returns {R3.D3.API.Viewport} - */ -R3.D3.Viewport.prototype.toApiObject = function() { + if (property === 'width') { + this.instance.z = this.z; + return; + } - return new R3.D3.API.Viewport( - this.id, - this.name, - this.viewportType, - R3.Utils.IdOrNull(this.parent), - this.scenes.reduce( - function(result, scene){ - result.push(R3.Utils.IdOrNull(scene)); - }, - [] - ), - this.width, - this.height, - this.x, - this.y - ); + if (property === 'height') { + this.instance.w = this.w; + return; + } + + __UPDATE_INSTANCE__; }; diff --git a/src/r3-d3-viewport-fixedAspect.js b/src/r3-d3-viewport-fixedAspect.js index a881d6b..4245805 100644 --- a/src/r3-d3-viewport-fixedAspect.js +++ b/src/r3-d3-viewport-fixedAspect.js @@ -1,8 +1,8 @@ /** - * R3.D3.Viewport.fixedAspect + * R3.D3.Viewport.FixedAspect * @param apiComponent */ -R3.D3.Viewport.fixedAspect = function( +R3.D3.Viewport.FixedAspect = function( apiComponent ) { @@ -15,41 +15,30 @@ R3.D3.Viewport.fixedAspect = function( }; -R3.D3.Viewport.fixedAspect.prototype = Object.create(R3.D3.Viewport.prototype); -R3.D3.Viewport.fixedAspect.prototype.constructor = R3.D3.Viewport.fixedAspect; +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.createInstance = function() { + + this.instance = this.graphics.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; - // } +R3.D3.Viewport.FixedAspect.prototype.updateInstance = function(property) { + + R3.D3.Viewport.prototype.updateInstance.call(this, property); }; diff --git a/src/r3-d3-viewport-zoomedAspect.js b/src/r3-d3-viewport-zoomedAspect.js index a881d6b..f0f2a91 100644 --- a/src/r3-d3-viewport-zoomedAspect.js +++ b/src/r3-d3-viewport-zoomedAspect.js @@ -1,8 +1,8 @@ /** - * R3.D3.Viewport.fixedAspect + * R3.D3.Viewport.ZoomedAspect * @param apiComponent */ -R3.D3.Viewport.fixedAspect = function( +R3.D3.Viewport.ZoomedAspect = function( apiComponent ) { @@ -15,41 +15,30 @@ R3.D3.Viewport.fixedAspect = function( }; -R3.D3.Viewport.fixedAspect.prototype = Object.create(R3.D3.Viewport.prototype); -R3.D3.Viewport.fixedAspect.prototype.constructor = R3.D3.Viewport.fixedAspect; +R3.D3.Viewport.ZoomedAspect.prototype = Object.create(R3.D3.Viewport.prototype); +R3.D3.Viewport.ZoomedAspect.prototype.constructor = R3.D3.Viewport.ZoomedAspect; /** * * @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.ZoomedAspect.prototype.createInstance = function() { + + this.instance = this.graphics.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; - // } +R3.D3.Viewport.ZoomedAspect.prototype.updateInstance = function(property) { + + R3.D3.Viewport.prototype.updateInstance.call(this, property); }; diff --git a/src/r3-entity.js b/src/r3-entity.js index 678a3a5..36ca9ea 100644 --- a/src/r3-entity.js +++ b/src/r3-entity.js @@ -8,18 +8,18 @@ R3.Entity = function( ) { __RUNTIME_COMPONENT__; + // + // this.instanceCreatedEventSubscription = this.subscribe( + // R3.Event.INSTANCE_CREATED, + // this.instanceCreatedEvent + // ); + // + // this.removeComponentSubscription = this.subscribe( + // R3.Event.REMOVE_COMPONENT, + // this.removeComponentEvent + // ); - this.instanceCreatedEventSubscription = this.subscribe( - R3.Event.INSTANCE_CREATED, - this.instanceCreatedEvent - ); - - this.removeComponentSubscription = this.subscribe( - R3.Event.REMOVE_COMPONENT, - this.removeComponentEvent - ); - - this.idRegister = {}; + // this.idRegister = {}; __UPGRADE_TO_RUNTIME__; }; @@ -29,22 +29,22 @@ 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.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__; @@ -54,7 +54,8 @@ R3.Entity.prototype.updateInstance = function(property) { if (property === 'components') { - this.buildIdRegister(); + console.log('todo: entity components change'); + // this.buildIdRegister(); return; } @@ -63,164 +64,164 @@ R3.Entity.prototype.updateInstance = function(property) { }; -/** - * Links a component to its parent entity - */ -R3.Entity.prototype.instanceCreatedEvent = function(data) { - - if (data.component === this) { - /** - * do nothing - */ - return; - } - - - if (data.component.parent === this.id) { - this.addComponent(data.component); - } -}; - -R3.Entity.prototype.removeComponentEvent = function(data) { - - if (data.component === this) { - /** - * do nothing - */ - return; - } - - if (data.component.parent === this) { - this.removeComponent(data.component); - } -}; +// /** +// * Links a component to its parent entity +// */ +// R3.Entity.prototype.instanceCreatedEvent = function(data) { +// +// if (data.component === this) { +// /** +// * do nothing +// */ +// return; +// } +// +// +// if (data.component.parent === this.id) { +// this.addComponent(data.component); +// } +// }; +// +// R3.Entity.prototype.removeComponentEvent = function(data) { +// +// if (data.component === this) { +// /** +// * do nothing +// */ +// return; +// } +// +// if (data.component.parent === this) { +// this.removeComponent(data.component); +// } +// }; /** * Adds a component to this entity through the instance (should notify the entity manager instance) * @param component */ -R3.Entity.prototype.addComponent = function(component) { +// R3.Entity.prototype.addComponent = function(component) { +// +// component.parent = this; +// +// /** +// * Could be that this entity is not loaded and needs to be linked still +// */ +// if (this.components.indexOf(component.id) !== -1) { +// console.log('the entity still has to load'); +// return; +// } +// +// R3.Utils.PushUnique(this.components, component); +// +// if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { +// this.idRegister[component.componentType] = []; +// } +// +// R3.Utils.PushUnique(this.idRegister[component.componentType], component); +// +// component.buildIdToObject(); +// +// Object.keys(component.idToObject).map( +// function(componentId) { +// +// if (component.id !== componentId) { +// this.addComponent(component.idToObject[componentId]); +// } +// +// }.bind(this) +// ); +// }; - component.parent = this; - - /** - * Could be that this entity is not loaded and needs to be linked still - */ - if (this.components.indexOf(component.id) !== -1) { - console.log('the entity still has to load'); - return; - } - - R3.Utils.PushUnique(this.components, component); - - if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { - this.idRegister[component.componentType] = []; - } - - R3.Utils.PushUnique(this.idRegister[component.componentType], component); - - component.buildIdToObject(); - - Object.keys(component.idToObject).map( - function(componentId) { - - if (component.id !== componentId) { - this.addComponent(component.idToObject[componentId]); - } - - }.bind(this) - ); -}; - -R3.Entity.prototype.removeComponent = function(component) { - - component.parent = null; - - var index = this.components.indexOf(component); - - if (index === -1) { - console.warn('component not found in entity'); - } else { - this.components.splice(index, 1); - } - - if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { - console.warn('component type not found in entity register'); - } else { - - index = this.idRegister[component.componentType].indexOf(component); - - if (index === -1) { - console.warn('component ' + component.name + ' not found in id register of entity ' + this.name); - } else { - this.idRegister[component.componentType].splice(index, 1); - } - - /** - * Remove the hash completely if it was the last one - */ - if (this.idRegister[component.componentType].length === 0) { - delete this.idRegister[component.componentType]; - } - - } -}; +// R3.Entity.prototype.removeComponent = function(component) { +// +// component.parent = null; +// +// var index = this.components.indexOf(component); +// +// if (index === -1) { +// console.warn('component not found in entity'); +// } else { +// this.components.splice(index, 1); +// } +// +// if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { +// console.warn('component type not found in entity register'); +// } else { +// +// index = this.idRegister[component.componentType].indexOf(component); +// +// if (index === -1) { +// console.warn('component ' + component.name + ' not found in id register of entity ' + this.name); +// } else { +// this.idRegister[component.componentType].splice(index, 1); +// } +// +// /** +// * Remove the hash completely if it was the last one +// */ +// if (this.idRegister[component.componentType].length === 0) { +// delete this.idRegister[component.componentType]; +// } +// +// } +// }; /** * Returns all components of type 'constructor' - slower than queryComponents * @param constructor */ -R3.Entity.prototype.queryComponentsByConstructor = function(constructor) { - - var components = this.components.reduce( - function(result, component) { - if (component instanceof constructor) { - result.push(component); - } - return result; - }, - [] - ); - - return components; -}; +// R3.Entity.prototype.findComponentsByConstructor = function(constructor) { +// +// var components = this.components.reduce( +// function(result, component) { +// if (component instanceof constructor) { +// result.push(component); +// } +// return result; +// }, +// [] +// ); +// +// return components; +// }; /** * Returns all child components of this entity by component type (via hash reference - very fast) * @param componentType * @returns {*} */ -R3.Entity.prototype.queryComponents = function(componentType) { - return this.idRegister[componentType] || []; -}; - -R3.Entity.prototype.buildIdRegister = function() { - console.log('updating id register for entity : ' + this.name); - - this.idRegister = {}; - - this.components.map( - function(component) { - - if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { - this.idRegister[component.componentType] = []; - } - - this.idRegister[component.componentType].push(component); - - }.bind(this) - ); - - console.log('done updating idRegister'); -}; - -/** - * Cleanup our subscriptions first - */ -R3.Entity.prototype.remove = function() { - - this.instanceCreatedEventSubscription.remove(); - this.removeComponentSubscription.remove(); - - R3.Component.prototype.remove.call(this); -}; +// R3.Entity.prototype.queryComponents = function(componentType) { +// return this.idRegister[componentType] || []; +// }; +// +// R3.Entity.prototype.buildIdRegister = function() { +// console.log('updating id register for entity : ' + this.name); +// +// this.idRegister = {}; +// +// this.components.map( +// function(component) { +// +// if (R3.Utils.UndefinedOrNull(this.idRegister[component.componentType])) { +// this.idRegister[component.componentType] = []; +// } +// +// this.idRegister[component.componentType].push(component); +// +// }.bind(this) +// ); +// +// console.log('done updating idRegister'); +// }; +// +// /** +// * Cleanup our subscriptions first +// */ +// R3.Entity.prototype.remove = function() { +// +// this.instanceCreatedEventSubscription.remove(); +// this.removeComponentSubscription.remove(); +// +// R3.Component.prototype.remove.call(this); +// }; diff --git a/src/r3-entityManager.js b/src/r3-entityManager.js index 0c86a9e..4918a99 100644 --- a/src/r3-entityManager.js +++ b/src/r3-entityManager.js @@ -6,9 +6,6 @@ R3.EntityManager = function( apiComponent ) { - - __RUNTIME_COMPONENT__; - /** * The 'register' array is a register of each component currently loaded - when the linking * system starts it also loads all the current components from the entity manager @@ -18,10 +15,9 @@ R3.EntityManager = function( this.idRegister = {}; - R3.Event.Subscribe( - R3.Event.COMPONENT_REGISTER, - this.registerComponent.bind(this) - ); + this.defaultEntity = null; + + this.instanceDisposal = []; R3.Event.Subscribe( R3.Event.INSTANCE_CREATED, @@ -34,120 +30,167 @@ R3.EntityManager = function( ); R3.Event.Subscribe( - R3.Event.ENTITY_LOADED, - this.entityLoaded.bind(this) - ); + R3.Event.INSTANCE_DISPOSAL, + this.removeInstances.bind(this) + ) - __UPGRADE_TO_RUNTIME__; -}; + // R3.Event.Subscribe( + // R3.Event.ENTITY_LOADED, + // this.entityLoaded.bind(this) + // ); -R3.EntityManager.prototype = Object.create(R3.Component.prototype); -R3.EntityManager.prototype.constructor = R3.EntityManager; - -R3.EntityManager.prototype.createInstance = function() { - - this.instance = R3.EntityManager.Instance; - - __CREATE_INSTANCE__; - -}; - -R3.EntityManager.prototype.updateInstance = function() { - - __UPDATE_INSTANCE__; }; R3.EntityManager.prototype.instanceCreated = function(data) { - if (data.component instanceof R3.Entity) { - this.addEntity(data.component); - } -}; - -R3.EntityManager.prototype.entityLoaded = function(data) { - this.defaultEntity = data.entity; -}; - -R3.EntityManager.prototype.registerComponent = function(data) { - - var updated = false; + /** + * Register this component in componentType to Component register + */ if (R3.Utils.UndefinedOrNull(this.register[data.component.componentType])) { this.register[data.component.componentType] = {}; - R3.Event.Emit( - R3.Event.COMPONENT_TYPES_UPDATE, - { - componentType : data.component.componentType, - componentTypes : Object.keys(this.register) - } - ); - updated = true; } if (R3.Utils.UndefinedOrNull(this.register[data.component.componentType][data.component.id])) { this.register[data.component.componentType][data.component.id] = data.component; - updated = true; } + /** + * Register this component in the Component.id to Component register + */ if (R3.Utils.UndefinedOrNull(this.idRegister[data.component.id])) { this.idRegister[data.component.id] = data.component; - updated = true; } - if (updated) { - R3.Event.Emit( - R3.Event.REGISTER_UPDATE, - { - componentType : data.component.componentType, - components : this.register[data.component.componentType], - idRegister : this.idRegister, - register : this.register - } - ); - } }; +/** + * Removes the component from both registries (the component type to component register, and the component ID to + * component register) + * @param data + */ R3.EntityManager.prototype.removeComponent = function(data) { - var updated = true; - + /** + * Sanity Check 1 + */ if (R3.Utils.UndefinedOrNull(this.register[data.component.componentType]) || - R3.Utils.UndefinedOrNull(this.register[data.component.componentType][data.component.id]) || - R3.Utils.UndefinedOrNull(this.idRegister[data.component.id]) + R3.Utils.UndefinedOrNull(this.register[data.component.componentType][data.component.id]) ) { - console.warn('register out of sync'); - updated = false; - } else { - delete this.register[data.component.componentType][data.component.id]; - - if (R3.Utils.IsEmpty(this.register[data.component.componentType])) { - delete this.register[data.component.componentType]; - R3.Event.Emit( - R3.Event.COMPONENT_TYPES_UPDATE, - { - componentType : data.component.componentType, - componentTypes : Object.keys(this.register) - } - ); - } - - delete this.idRegister[data.component.id]; + throw new Error('EntityManager register out of sync'); } - if (updated) { - R3.Event.Emit( - R3.Event.REGISTER_UPDATE, - { - componentType : data.component.componentType, - components : this.register[data.component.componentType], - idRegister : this.idRegister, - register : this.register - } - ); + /** + * Delete the component from the componentType to Component register + */ + delete this.register[data.component.componentType][data.component.id]; + if (R3.Utils.IsEmpty(this.register[data.component.componentType])) { + delete this.register[data.component.componentType]; + } + + /** + * Sanity Check 2 + */ + if (R3.Utils.UndefinedOrNull(this.idRegister[data.component.id])){ + throw new Error('EntityManager idRegister out of sync'); + } + + /** + * Delete the component from the ID to Component register + */ + delete this.idRegister[data.component.id]; + + /** + * Now we have to be quite careful - we only have one copy left of this component - the one in data.component. + * we need a handle on all instances in this object. We need to store them to allow the 'REMOVE_COMPONENT' event + * to finish getting handled, then we need to dispose of the instance themselves. + * This gives our systems and other objects a chance to cleanly stop relying on these components at which point + * we can safely clean up our instances. + */ + + var component = data.component; + + for (var property in component) { + + if (property === 'parent') { + continue; + } + + if (component.hasOwnProperty(property)) { + if (component[property] instanceof R3.Component) { + R3.Utils.PushUnique(this.instanceDisposal, component[property].instance); + } + } } }; +R3.EntityManager.prototype.removeInstances = function(data) { + + this.instanceDisposal = this.instanceDisposal.reduce( + function(result, instance) { + if ( + R3.Utils.Defined(instance.dispose) && + typeof instance.dispose === 'function' + ) { + instance.dispose(); + } + + if (instance instanceof HTMLElement) { + instance.parentElement.removeChild(instance); + } + + return result; + }, + [] + ); + +}; + +// R3.EntityManager.prototype.entityLoaded = function(data) { +// this.defaultEntity = data.entity; +// }; + +// R3.EntityManager.prototype.registerComponent = function(data) { +// +// // var updated = false; +// +// if (R3.Utils.UndefinedOrNull(this.register[data.component.componentType])) { +// this.register[data.component.componentType] = {}; +// // R3.Event.Emit( +// // R3.Event.COMPONENT_TYPES_UPDATE, +// // { +// // componentType : data.component.componentType, +// // componentTypes : Object.keys(this.register) +// // } +// // ); +// // updated = true; +// } +// +// if (R3.Utils.UndefinedOrNull(this.register[data.component.componentType][data.component.id])) { +// this.register[data.component.componentType][data.component.id] = data.component; +// // updated = true; +// } +// +// if (R3.Utils.UndefinedOrNull(this.idRegister[data.component.id])) { +// this.idRegister[data.component.id] = data.component; +// // updated = true; +// } +// +// // if (updated) { +// // R3.Event.Emit( +// // R3.Event.REGISTER_UPDATE, +// // { +// // componentType : data.component.componentType, +// // components : this.register[data.component.componentType], +// // idRegister : this.idRegister, +// // register : this.register +// // } +// // ); +// // } +// }; + + /** * Returns an entity by ID or null * @param id @@ -344,7 +387,7 @@ R3.EntityManager.prototype.queryComponents = function(componentTypes) { * @param constructors (array of constructors, or a constructor) * @returns {*} */ -R3.EntityManager.prototype.queryComponentsByConstructor = function(constructors) { +R3.EntityManager.prototype.findComponentsByConstructor = function(constructors) { return Object.keys(this.idRegister).reduce( function(result, componentId) { if (constructors instanceof Array) { @@ -369,40 +412,3 @@ R3.EntityManager.prototype.queryComponentsByConstructor = function(constructors) [] ); }; - -/** - * Converts a R3.Entity to R3.API.Entity - * @returns {R3.API.EntityManager} - */ -R3.EntityManager.prototype.toApiObject = function() { - - var apiEntities = this.entities.map( - function(entity) { - return R3.Utils.IdOrNull(entity); - } - ); - - var apiEntityManager = new R3.API.EntityManager( - this.id, - this.name, - apiEntities, - this.defaultEntity, - R3.Utils.IdOrNull(this.parent) - ); - - return apiEntityManager; -}; - -/** - * Returns an EntityManager from an Object entity manager - * @param objectEntityManager Object - * @constructor - */ -R3.EntityManager.FromObject = function(objectEntityManager) { - - var apiEntityManager = R3.API.EntityManager.FromObject(objectEntityManager); - - var entityManager = new R3.EntityManager(apiEntityManager); - - return entityManager; -}; diff --git a/src/r3-graph-0.js b/src/r3-graph-0.js index 080b36e..465c8d2 100644 --- a/src/r3-graph-0.js +++ b/src/r3-graph-0.js @@ -7,9 +7,9 @@ R3.Graph = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - throw new Error('R3.Graph should not be instantiated directly'); - } + __INHERIT_ONLY__ + + this.linkedComponents.query = R3.Query; __UPGRADE_TO_RUNTIME__; diff --git a/src/r3-graph-barchart-0.js b/src/r3-graph-barchart-0.js index ba3042b..6d38a91 100644 --- a/src/r3-graph-barchart-0.js +++ b/src/r3-graph-barchart-0.js @@ -9,9 +9,9 @@ R3.Graph.Barchart = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - __RUNTIME_COMPONENT__; - } + __INHERIT_AND_INSTANTIATE__ + + this.linkedComponents.domElement = R3.DomElement; R3.Graph.call( this, @@ -28,6 +28,8 @@ R3.Graph.Barchart.prototype.constructor = R3.Graph.Barchart; */ R3.Graph.Barchart.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; diff --git a/src/r3-graph-barchart-stacked.js b/src/r3-graph-barchart-stacked.js index 60b945a..b83a657 100644 --- a/src/r3-graph-barchart-stacked.js +++ b/src/r3-graph-barchart-stacked.js @@ -1,20 +1,19 @@ /** * R3.Graph.Barchart.Stacked * @param apiComponent - * @param inherited * @constructor */ R3.Graph.Barchart.Stacked = function( - apiComponent, - inherited + apiComponent ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - __RUNTIME_COMPONENT__; - } + __RUNTIME_COMPONENT__; - R3.Graph.call( + this.linkedComponents.domElement = R3.DomElement; + + R3.Graph.Barchart.call( this, + apiComponent, true ); @@ -28,6 +27,8 @@ R3.Graph.Barchart.Stacked.prototype.constructor = R3.Graph.Barchart.Stacked; */ R3.Graph.Barchart.Stacked.prototype.createInstance = function() { + this.instance = this.graphics.BarchartStacked(this); + __CREATE_INSTANCE__; }; @@ -37,6 +38,14 @@ R3.Graph.Barchart.Stacked.prototype.createInstance = function() { */ R3.Graph.Barchart.Stacked.prototype.updateInstance = function(property) { + if (property === 'query') { + this.instance = this.graphics.BarchartStacked(this); + } + + if (property === 'size') { + this.chart.update(); + } + R3.Graph.Barchart.prototype.updateInstance.call(this, property); }; diff --git a/src/r3-graph-metric.js b/src/r3-graph-metric.js index cb90703..5bc1ca4 100644 --- a/src/r3-graph-metric.js +++ b/src/r3-graph-metric.js @@ -9,6 +9,8 @@ R3.Graph.Metric = function( __RUNTIME_COMPONENT__; + this.linkedComponents.domElements = [R3.DomElement]; + R3.Graph.call( this, true @@ -16,14 +18,17 @@ R3.Graph.Metric = function( }; -R3.Graph.Metric.prototype = Object.create(R3.Component.prototype); +R3.Graph.Metric.prototype = Object.create(R3.Graph.prototype); R3.Graph.Metric.prototype.constructor = R3.Graph.Metric; + /** * Updates the instance with the current state */ R3.Graph.Metric.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; @@ -33,6 +38,24 @@ R3.Graph.Metric.prototype.createInstance = function() { */ R3.Graph.Metric.prototype.updateInstance = function(property) { + if (property === 'query') { + + this.domElements.map( + function(domElement, index) { + + if (this.query instanceof R3.Query.Alerts.Summary) { + if (R3.Utils.UndefinedOrNull(this.query.priorities[index])) { + domElement.instance.innerHTML = 0; + } else { + domElement.instance.innerHTML = this.query.priorities[index]; + } + } + + }.bind(this) + ) + + } + R3.Graph.prototype.updateInstance.call(this, property); }; diff --git a/src/r3-graph-table.js b/src/r3-graph-table.js index 796c65f..ff93142 100644 --- a/src/r3-graph-table.js +++ b/src/r3-graph-table.js @@ -9,6 +9,8 @@ R3.Graph.Table = function( __RUNTIME_COMPONENT__; + this.linkedComponents.domElement = R3.DomElement; + R3.Graph.call( this, true @@ -16,7 +18,7 @@ R3.Graph.Table = function( }; -R3.Graph.Table.prototype = Object.create(R3.Component.prototype); +R3.Graph.Table.prototype = Object.create(R3.Graph.prototype); R3.Graph.Table.prototype.constructor = R3.Graph.Table; /** @@ -24,6 +26,8 @@ R3.Graph.Table.prototype.constructor = R3.Graph.Table; */ R3.Graph.Table.prototype.createInstance = function() { + this.instance = this.graphics.Table(this); + __CREATE_INSTANCE__; }; @@ -33,6 +37,14 @@ R3.Graph.Table.prototype.createInstance = function() { */ R3.Graph.Table.prototype.updateInstance = function(property) { + if ( + property === 'columns' || + property === 'rows' || + property === 'data' + ) { + this.instance = this.graphics.Table(this); + } + R3.Graph.prototype.updateInstance.call(this, property); }; diff --git a/src/r3-mouse.js b/src/r3-mouse.js index 3d04cab..901ce6f 100644 --- a/src/r3-mouse.js +++ b/src/r3-mouse.js @@ -20,7 +20,7 @@ R3.Mouse.prototype.constructor = R3.Mouse; */ R3.Mouse.prototype.createInstance = function() { - this.instance = {}; + this.instance = true; __CREATE_INSTANCE__; @@ -32,13 +32,9 @@ R3.Mouse.prototype.createInstance = function() { */ R3.Mouse.prototype.updateInstance = function(property) { - if (property === 'x') { - this.instance.x = this.x; - return; - } - - if (property === 'y') { - this.instance.y = this.y; + if (property === 'position') { + this.position.updateInstance('x'); + this.position.updateInstance('y'); return; } diff --git a/src/r3-project.js b/src/r3-project-0.js similarity index 57% rename from src/r3-project.js rename to src/r3-project-0.js index 241bfe5..f38b1b5 100644 --- a/src/r3-project.js +++ b/src/r3-project-0.js @@ -1,13 +1,17 @@ /** * R3.Project - * @param apiComponent + * @param inherited * @constructor */ R3.Project = function( - apiComponent + inherited ) { - __RUNTIME_COMPONENT__; + __INHERIT_ONLY__ + + this.linkedComponents.entities = [R3.Entity]; + this.linkedComponents.controls = [R3.Controls]; + this.linkedComponents.images = [R3.Image]; __UPGRADE_TO_RUNTIME__; }; @@ -15,49 +19,33 @@ R3.Project = function( R3.Project.prototype = Object.create(R3.Component.prototype); R3.Project.prototype.constructor = R3.Project; -R3.Project.prototype.createInstance = function() { - - this.instance = true; - - __CREATE_INSTANCE__; - -}; - /** * Updates the instance with the current state */ R3.Project.prototype.updateInstance = function(property) { - if (property === 'users') { - console.log('todo: project users update'); - } - if (property === 'isPublic') { console.log('todo: project isPublic update'); + return; } if (property === 'entities') { console.log('todo: project entities update'); - } - - 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'); + return; } if (property === 'controls') { console.log('todo: project controls update'); + return; + } + if (property === 'images') { + console.log('todo: project images update'); + return; } if (property === 'applicationMode') { console.log('todo: project applicationMode update'); + return; } __UPDATE_INSTANCE__; diff --git a/src/r3-project-d2.js b/src/r3-project-d2.js new file mode 100644 index 0000000..464aefe --- /dev/null +++ b/src/r3-project-d2.js @@ -0,0 +1,48 @@ +/** + * R3.Project.D2 + * @param apiComponent + * @constructor + */ +R3.Project.D2 = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + this.linkedComponents.renderers = [R3.Renderer.D2]; + + R3.Project.call( + this, + true + ); +}; + +R3.Project.D2.prototype = Object.create(R3.Project.prototype); +R3.Project.D2.prototype.constructor = R3.Project.D2; + +R3.Project.D2.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Project.D2.prototype.updateInstance = function(property) { + + if (property === 'renderers') { + console.log('todo: project renderer update'); + return; + } + + if (property === 'controls') { + console.log('todo: project controls update'); + return; + } + + R3.Project.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-project-d3.js b/src/r3-project-d3.js new file mode 100644 index 0000000..e634d18 --- /dev/null +++ b/src/r3-project-d3.js @@ -0,0 +1,111 @@ +/** + * R3.Project.D3 + * @param apiComponent + * @constructor + */ +R3.Project.D3 = function( + apiComponent +) { + + if (R3.EntityManager.Instance.findComponentsByConstructor(R3.Project).length >= 16) { + + R3.Event.Emit( + R3.Event.MAXIMUM_PROJECTS + ); + + throw new Error('Maximum number of open projects reached'); + } + + __RUNTIME_COMPONENT__; + + this.linkedComponents.renderers = [R3.Renderer.D3]; + this.linkedComponents.rendererTargets = [R3.D3.RenderTarget]; + this.linkedComponents.cameras = [R3.D3.Camera]; + this.linkedComponents.audios = [R3.D3.Audio]; + this.linkedComponents.mouse = R3.Mouse; + this.linkedComponents.raycaster = R3.D3.Raycaster; + this.linkedComponents.clock = R3.Clock; + + R3.Project.call( + this, + true + ); +}; + +R3.Project.D3.prototype = Object.create(R3.Project.prototype); +R3.Project.D3.prototype.constructor = R3.Project.D3; + +R3.Project.D3.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Project.D3.prototype.updateInstance = function(property) { + + if (property === 'renderers') { + console.log('todo: project renderers update'); + return; + } + + if (property === 'renderTargets') { + console.log('todo: project renderTargets update'); + return; + } + + if (property === 'cameras') { + console.log('todo: These controls override parent controls since they can contain 3D controls'); + /** + * These controls override parent controls since they can contain 3D controls - handle this + * properly here + */ + return; + } + + if (property === 'controls') { + console.log('todo: project controls update'); + return; + } + + if (property === 'audios') { + console.log('todo: project audios update'); + return; + } + + if (property === 'applicationMode') { + + this.controls.map( + function(control) { + if ( + control instanceof R3.Controls.D3.Orbit || + control instanceof R3.Controls.D3.FirstPerson + ) { + + var camera = control.camera; + + if (camera === this.cameras[R3.API.Project.CAMERA_INDEX_EDIT]) { + /** + * Disable the control for now if applicationMode is run + */ + if (this.applicationMode === R3.API.Project.APPLICATION_MODE_RUN) { + control.enabled = false; + } else { + control.enabled = true; + } + + control.updateInstance('enabled'); + + } + } + }.bind(this) + ); + return; + } + + R3.Project.prototype.updateInstance.call(this, property); +}; diff --git a/src/r3-quaternion-0.js b/src/r3-quaternion-0.js index 9e6405f..cd81e6f 100644 --- a/src/r3-quaternion-0.js +++ b/src/r3-quaternion-0.js @@ -16,8 +16,6 @@ R3.Quaternion = function( ); __UPGRADE_TO_RUNTIME__; - - this.createInstance(); }; R3.Quaternion.prototype = Object.create(R3.Component.prototype); @@ -29,25 +27,31 @@ R3.Quaternion.prototype.constructor = R3.Quaternion; */ 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 - ); - } + var runtime = R3.Component.GetComponentRuntime(this.parent); - if (this.parent.runtime === R3.Runtime.PHYSICS) { - this.instance = new this.physics.Quaternion( - this.x, - this.y, - this.z, - this.w - ); + switch (runtime) { + case R3.Runtime.GRAPHICS : + this.instance = new this.graphics.Quaternion( + this.x, + this.y, + this.z, + this.w + ); + break; + case R3.Runtime.PHYSICS : + this.instance = new this.physics.Quaternion( + this.x, + this.y, + this.z, + this.w + ); + break; + default: + throw new Error('unhandled component runtime: ' + runtime); } __CREATE_INSTANCE__; + }; /** diff --git a/src/r3-quaternion-points.js b/src/r3-quaternion-points.js index 1fd734f..4be9b52 100644 --- a/src/r3-quaternion-points.js +++ b/src/r3-quaternion-points.js @@ -20,7 +20,7 @@ R3.Quaternion.Points.prototype.constructor = R3.Quaternion.Points; * Creates an instance quaternion * @returns {*} */ -R3.Quaternion.prototype.createInstance = function() { +R3.Quaternion.Points.prototype.createInstance = function() { __CREATE_INSTANCE__; @@ -29,7 +29,7 @@ R3.Quaternion.prototype.createInstance = function() { /** * Updates the instance vector, calls updateInstance on the parent object */ -R3.Quaternion.prototype.updateInstance = function(property) { +R3.Quaternion.Points.prototype.updateInstance = function(property) { if (property === 'vectors') { console.warn('todo: vectors update'); diff --git a/src/r3-query-0.js b/src/r3-query-0.js index af09a05..e8f2627 100644 --- a/src/r3-query-0.js +++ b/src/r3-query-0.js @@ -7,9 +7,7 @@ R3.Query = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - throw new Error('R3.Query should not be instantiated directly'); - } + __INHERIT_ONLY__ __UPGRADE_TO_RUNTIME__; @@ -50,3 +48,7 @@ R3.Query.prototype.updateInstance = function(property) { __UPDATE_INSTANCE__; }; + +R3.Query.prototype.parse = function() { + console.warn('override R3.Query.prototype.parse() in child function'); +}; \ No newline at end of file diff --git a/src/r3-query-alerts-0.js b/src/r3-query-alerts-0.js index f2d8587..7394127 100644 --- a/src/r3-query-alerts-0.js +++ b/src/r3-query-alerts-0.js @@ -7,9 +7,7 @@ R3.Query.Alerts = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - throw new Error('R3.Query.Alerts should not be instantiated directly'); - } + __INHERIT_ONLY__ R3.Query.call( this, @@ -18,7 +16,7 @@ R3.Query.Alerts = function( }; -R3.Query.Alerts.prototype = Object.create(R3.Component.prototype); +R3.Query.Alerts.prototype = Object.create(R3.Query.prototype); R3.Query.Alerts.prototype.constructor = R3.Query.Alerts; /** diff --git a/src/r3-query-alerts-buckets.js b/src/r3-query-alerts-buckets.js index d24bedb..33bc2c3 100644 --- a/src/r3-query-alerts-buckets.js +++ b/src/r3-query-alerts-buckets.js @@ -24,6 +24,8 @@ R3.Query.Alerts.Buckets.prototype.constructor = R3.Query.Alerts.Buckets; */ R3.Query.Alerts.Buckets.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; @@ -36,3 +38,96 @@ R3.Query.Alerts.Buckets.prototype.updateInstance = function(property) { R3.Query.Alerts.prototype.updateInstance.call(this, property); }; + +R3.Query.Alerts.Buckets.prototype.parse = function(data) { + + this.columns = []; + + if (this.bucketField === R3.API.Query.Alerts.Buckets.BUCKET_FIELD_ALERT_TYPE) { + this.columns.push( + { + type : 'string', + name : 'Alert Type' + } + ) + } + + if (this.bucketField === R3.API.Query.Alerts.Buckets.BUCKET_FIELD_COUNTRY) { + this.columns.push( + { + type : 'string', + name : 'Country' + } + ) + } + + if (this.bucketField === R3.API.Query.Alerts.Buckets.BUCKET_FIELD_HOSTNAME) { + this.columns.push( + { + type : 'string', + name : 'Hostname' + } + ) + } + + if (this.bucketField === R3.API.Query.Alerts.Buckets.BUCKET_FIELD_IP_V4) { + this.columns.push( + { + type : 'string', + name : 'IP Address' + } + ) + } + + if (this.bucketField === R3.API.Query.Alerts.Buckets.BUCKET_FIELD_USERNAME) { + this.columns.push( + { + type : 'string', + name : 'Username' + } + ) + } + + this.columns.push( + { + type : 'number', + name : 'Critical' + }, + { + type : 'number', + name : 'High' + }, + { + type : 'number', + name : 'Medium' + }, + { + type : 'number', + name : 'Low' + } + ); + + this.rows = data.aggregations.descriptions.buckets.reduce( + function(result, bucket) { + + var key = [bucket.key]; + var priorities = bucket.priorities.buckets.reduce( + function(result, prioBucket) { + result[prioBucket.key - 1] = prioBucket.doc_count; + return result; + }, + [ + 0, + 0, + 0, + 0 + ] + ); + + result.push(key.concat(priorities)); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-alerts-firstTimeLogin-0.js b/src/r3-query-alerts-firstTimeLogin-0.js new file mode 100644 index 0000000..ca0aff5 --- /dev/null +++ b/src/r3-query-alerts-firstTimeLogin-0.js @@ -0,0 +1,46 @@ +/** + * R3.Query.Alerts.FirstTimeLogin + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Query.Alerts.FirstTimeLogin = function( + apiComponent, + inherited +) { + + __INHERIT_AND_INSTANTIATE__ + + R3.Query.Alerts.call( + this, + true + ); + +}; + +R3.Query.Alerts.FirstTimeLogin.prototype = Object.create(R3.Query.Alerts.prototype); +R3.Query.Alerts.FirstTimeLogin.prototype.constructor = R3.Query.Alerts.FirstTimeLogin; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.prototype.updateInstance = function(property) { + + R3.Query.Alerts.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Alerts.FirstTimeLogin.prototype.parse = function(data) { + console.warn('not yet implemented'); +}; diff --git a/src/r3-query-alerts-firstTimeLogin-applications.js b/src/r3-query-alerts-firstTimeLogin-applications.js new file mode 100644 index 0000000..5e47b83 --- /dev/null +++ b/src/r3-query-alerts-firstTimeLogin-applications.js @@ -0,0 +1,84 @@ +/** + * R3.Query.Alerts.FirstTimeLogin.Applications + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.FirstTimeLogin.Applications = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Alerts.FirstTimeLogin.Applications.prototype = Object.create(R3.Query.Alerts.FirstTimeLogin.prototype); +R3.Query.Alerts.FirstTimeLogin.Applications.prototype.constructor = R3.Query.Alerts.FirstTimeLogin.Applications; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.Applications.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.Applications.prototype.updateInstance = function(property) { + + R3.Query.Alerts.FirstTimeLogin.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Alerts.FirstTimeLogin.Applications.prototype.parse = function(data) { + + this.columns = [ + { + type: 'string', + name: 'User' + }, + { + type: 'string', + name: 'Application' + }, + { + type: 'datetime', + name: 'Time' + }, + ]; + + if (data.hits.hits.length === 0) { + this.rows = [ + [ + 'no data', + null, + null, + null + ] + ] + } else { + this.rows = data.hits.hits.reduce( + function (result, hit) { + var row = [ + hit._source.login.username, + hit._source.login.application, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + } + +}; diff --git a/src/r3-query-alerts-firstTimeLogin-devices.js b/src/r3-query-alerts-firstTimeLogin-devices.js new file mode 100644 index 0000000..36fc85a --- /dev/null +++ b/src/r3-query-alerts-firstTimeLogin-devices.js @@ -0,0 +1,93 @@ +/** + * R3.Query.Alerts.FirstTimeLogin.Devices + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.FirstTimeLogin.Devices = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Alerts.FirstTimeLogin.Devices.prototype = Object.create(R3.Query.Alerts.FirstTimeLogin.prototype); +R3.Query.Alerts.FirstTimeLogin.Devices.prototype.constructor = R3.Query.Alerts.FirstTimeLogin.Devices; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.Devices.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.Devices.prototype.updateInstance = function(property) { + + R3.Query.Alerts.FirstTimeLogin.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Alerts.FirstTimeLogin.Devices.prototype.parse = function(data) { + + this.columns = [ + { + type: 'string', + name: 'User' + }, + { + type: 'string', + name: 'Device' + }, + { + type: 'string', + name: 'Login Type' + }, + { + type: 'string', + name: 'Protocol' + }, + { + type: 'datetime', + name: 'Time' + }, + ]; + + if (data.hits.hits.length === 0) { + this.rows = [ + [ + 'no data', + null, + null, + null + ] + ] + } else { + this.rows = data.hits.hits.reduce( + function (result, hit) { + var row = [ + hit._source.login.username, + hit._source.login.destination_hostname, + hit._source.login.login_type, + hit._source.login.login_protocol, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + } +}; diff --git a/src/r3-query-alerts-firstTimeLogin-vpn.js b/src/r3-query-alerts-firstTimeLogin-vpn.js new file mode 100644 index 0000000..f82aa5e --- /dev/null +++ b/src/r3-query-alerts-firstTimeLogin-vpn.js @@ -0,0 +1,89 @@ +/** + * R3.Query.Alerts.FirstTimeLogin.VPN + * @param apiComponent + * @constructor + */ +R3.Query.Alerts.FirstTimeLogin.VPN = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Alerts.FirstTimeLogin.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Alerts.FirstTimeLogin.VPN.prototype = Object.create(R3.Query.Alerts.FirstTimeLogin.prototype); +R3.Query.Alerts.FirstTimeLogin.VPN.prototype.constructor = R3.Query.Alerts.FirstTimeLogin.VPN; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.VPN.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Alerts.FirstTimeLogin.VPN.prototype.updateInstance = function(property) { + + R3.Query.Alerts.FirstTimeLogin.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Alerts.FirstTimeLogin.VPN.prototype.parse = function(data) { + + this.columns = [ + { + type : 'string', + name : 'User' + }, + { + type : 'string', + name : 'User OS' + }, + { + type : 'string', + name : 'From' + }, + { + type : 'string', + name : 'VPN Server' + }, + { + type : 'string', + name : 'VPN Protocol' + }, + { + type : 'datetime', + name : 'Time' + } + ]; + + this.rows = data.hits.hits.reduce( + function (result, hit) { + + var row = [ + hit._source.login.username, + hit._source.login.source_os, + hit._source.login.source_geo?hit._source.login.source_geo.country + '(' + hit._source.login.source_geo.city + ')':hit._source.login.source_ip, + hit._source.login.destination_hostname + ' - ' + hit._source.login.destination_os, + hit._source.login.login_protocol, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-alerts-list.js b/src/r3-query-alerts-list.js index bd313aa..fd7b193 100644 --- a/src/r3-query-alerts-list.js +++ b/src/r3-query-alerts-list.js @@ -24,6 +24,8 @@ R3.Query.Alerts.List.prototype.constructor = R3.Query.Alerts.List; */ R3.Query.Alerts.List.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; @@ -36,3 +38,45 @@ R3.Query.Alerts.List.prototype.updateInstance = function(property) { R3.Query.Alerts.prototype.updateInstance.call(this, property); }; + +R3.Query.Alerts.List.prototype.parse = function(data) { + + this.columns = [ + { + type : 'datetime', + name : 'Time' + }, + { + type : 'number', + name : 'Priority' + }, + { + type : 'string', + name : 'Alert Type' + }, + { + type : 'boolean', + name : 'Acknowledged' + } + ]; + + this.rows = data.hits.hits.reduce( + function(result, hit) { + + var row = []; + row.push(new Date(hit._source.timestamp)); + row.push(hit._source.priority); + row.push(hit._source.alert_type); + row.push(hit._source.acknowledged); + // if (hit._source.acknowledged) { + // row.push({v:'ButtonName', f:''}); + // } else { + // row.push({v:'ButtonName', f:''}); + // } + result.push(row); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-alerts-summary.js b/src/r3-query-alerts-summary.js index 659a9e6..99f173e 100644 --- a/src/r3-query-alerts-summary.js +++ b/src/r3-query-alerts-summary.js @@ -24,6 +24,8 @@ R3.Query.Alerts.Summary.prototype.constructor = R3.Query.Alerts.Summary; */ R3.Query.Alerts.Summary.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; @@ -36,3 +38,15 @@ R3.Query.Alerts.Summary.prototype.updateInstance = function(property) { R3.Query.Alerts.prototype.updateInstance.call(this, property); }; + +R3.Query.Alerts.Summary.prototype.parse = function(data) { + + this.priorities = data.aggregations.priorities.buckets.reduce( + function(result, bucket) { + result.push(bucket.doc_count); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-alerts-timeseries.js b/src/r3-query-alerts-timeseries.js index 0affbaa..5f02a37 100644 --- a/src/r3-query-alerts-timeseries.js +++ b/src/r3-query-alerts-timeseries.js @@ -24,6 +24,8 @@ R3.Query.Alerts.Timeseries.prototype.constructor = R3.Query.Alerts.Timeseries; */ R3.Query.Alerts.Timeseries.prototype.createInstance = function() { + this.instance = true; + __CREATE_INSTANCE__; }; @@ -36,3 +38,104 @@ R3.Query.Alerts.Timeseries.prototype.updateInstance = function(property) { R3.Query.Alerts.prototype.updateInstance.call(this, property); }; + +R3.Query.Alerts.Timeseries.prototype.parse = function(data) { + + this.labels = data.aggregations.mins.buckets.reduce( + function(result, bucket) { + + function formatDate(date) { + var monthNames = [ + "Jan", "Feb", "Mar", + "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", + "Nov", "Dec" + ]; + + var day = date.getDate(); + var monthIndex = date.getMonth(); + var year = date.getFullYear(); + + return day + '-' + monthNames[monthIndex] + '-' + year; + } + + result.push(formatDate(new Date(bucket.key))); + return result; + }, + [] + ); + + this.datasets = data.aggregations.mins.buckets.reduce( + function(result, bucket) { + console.log('todo here'); + bucket.priorities.buckets.map( + function(prio) { + result[prio.key - 1].data.push(prio.doc_count); + } + ) + return result; + }, + [ + { + label: 'Priority 1', + backgroundColor: '#ff4c4c', + data: [] + }, + { + label: 'Priority 2', + backgroundColor: '#ffa04c', + data: [] + }, + { + label: 'Priority 3', + backgroundColor: '#fff34c', + data: [] + + }, + { + label: 'Priority 4', + backgroundColor: '#a8ff4c', + data: [] + } + ] + ) + + // for (var label in this.labels) { + // for (var p = 0; p < 4; p++) { + // + // } + // } + // + // this.dataSets = data.aggregations.mins.buckets.reduce( + // function(result, bucket) { + // result.push( + // { + // label : + // } + // ) + // return result; + // }, + // [] + // ); + // + // this.buckets = data.aggregations.mins.buckets.reduce( + // function(result, bucket) { + // result.push( + // { + // date : new Date(bucket.key), + // count : bucket.doc_count, + // priorities : bucket.priorities.buckets.reduce( + // function(result, bucket) { + // result.push(bucket.doc_count); + // return result; + // }, + // [] + // ) + // } + // ); + // return result; + // }, + // [] + // ); + +}; diff --git a/src/r3-query-devices-0.js b/src/r3-query-devices-0.js new file mode 100644 index 0000000..ec87440 --- /dev/null +++ b/src/r3-query-devices-0.js @@ -0,0 +1,29 @@ +/** + * R3.Query.Devices + * @param inherited + * @constructor + */ +R3.Query.Devices = function( + inherited +) { + + __INHERIT_AND_INSTANTIATE__ + + R3.Query.call( + this, + true + ); + +}; + +R3.Query.Devices.prototype = Object.create(R3.Query.prototype); +R3.Query.Devices.prototype.constructor = R3.Query.Devices; + +/** + * Updates the instance with the current state + */ +R3.Query.Devices.prototype.updateInstance = function(property) { + + R3.Query.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-devices-known.js b/src/r3-query-devices-known.js new file mode 100644 index 0000000..85f930e --- /dev/null +++ b/src/r3-query-devices-known.js @@ -0,0 +1,84 @@ +/** + * R3.Query.Devices.Known + * @param apiComponent + * @constructor + */ +R3.Query.Devices.Known = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Devices.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Devices.Known.prototype = Object.create(R3.Query.Devices.prototype); +R3.Query.Devices.Known.prototype.constructor = R3.Query.Devices.Known; + +/** + * Updates the instance with the current state + */ +R3.Query.Devices.Known.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Devices.Known.prototype.updateInstance = function(property) { + + R3.Query.Devices.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Devices.Known.prototype.parse = function(data) { + + this.columns = [ + { + type: 'string', + name: 'Hostname' + }, + { + type: 'string', + name: 'IP' + }, + { + type: 'string', + name: 'MAC Address' + }, + { + type: 'datetime', + name: 'Detected' + }, + ]; + + if (data.error) { + this.rows = [ + ['error', null, null, null] + ] + } else { + this.rows = data.hits.hits.reduce( + function (result, hit) { + var row = [ + hit._source.hostname, + hit._source.ip_v4, + hit._source.mac_address, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + } + +}; diff --git a/src/r3-query-devices-unknown.js b/src/r3-query-devices-unknown.js new file mode 100644 index 0000000..cf34af9 --- /dev/null +++ b/src/r3-query-devices-unknown.js @@ -0,0 +1,85 @@ +/** + * R3.Query.Devices.Unknown + * @param apiComponent + * @constructor + */ +R3.Query.Devices.Unknown = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Devices.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Devices.Unknown.prototype = Object.create(R3.Query.Devices.prototype); +R3.Query.Devices.Unknown.prototype.constructor = R3.Query.Devices.Unknown; + +/** + * Updates the instance with the current state + */ +R3.Query.Devices.Unknown.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Devices.Unknown.prototype.updateInstance = function(property) { + + R3.Query.Devices.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Devices.Unknown.prototype.parse = function(data) { + + + this.columns = [ + { + type: 'string', + name: 'Hostname' + }, + { + type: 'string', + name: 'IP' + }, + { + type: 'string', + name: 'MAC Address' + }, + { + type: 'datetime', + name: 'Detected' + }, + ]; + + if (data.error) { + this.rows = [ + ['error', null, null, null] + ] + } else { + this.rows = data.hits.hits.reduce( + function (result, hit) { + var row = [ + hit._source.hostname?hit._source.hostname:'', + hit._source.ip_v4, + hit._source.mac_address, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + } + +}; diff --git a/src/r3-query-logins-0.js b/src/r3-query-logins-0.js new file mode 100644 index 0000000..4f16580 --- /dev/null +++ b/src/r3-query-logins-0.js @@ -0,0 +1,31 @@ +/** + * R3.Query.Logins + * @param apiComponent + * @param inherited + * @constructor + */ +R3.Query.Logins = function( + apiComponent, + inherited +) { + + __INHERIT_AND_INSTANTIATE__ + + R3.Query.call( + this, + true + ); + +}; + +R3.Query.Logins.prototype = Object.create(R3.Query.prototype); +R3.Query.Logins.prototype.constructor = R3.Query.Logins; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.prototype.updateInstance = function(property) { + + R3.Query.prototype.updateInstance.call(this, property); + +}; diff --git a/src/r3-query-logins-applications.js b/src/r3-query-logins-applications.js new file mode 100644 index 0000000..e6430ba --- /dev/null +++ b/src/r3-query-logins-applications.js @@ -0,0 +1,73 @@ +/** + * R3.Query.Logins.Applications + * @param apiComponent + * @constructor + */ +R3.Query.Logins.Applications = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Logins.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Logins.Applications.prototype = Object.create(R3.Query.Logins.prototype); +R3.Query.Logins.Applications.prototype.constructor = R3.Query.Logins.Applications; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.Applications.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.Applications.prototype.updateInstance = function(property) { + + R3.Query.Logins.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Logins.Applications.prototype.parse = function(data) { + + this.columns = [ + { + type: 'string', + name: 'User' + }, + { + type: 'string', + name: 'Application' + }, + { + type: 'datetime', + name: 'Time' + }, + ]; + + this.rows = data.hits.hits.reduce( + function(result, hit) { + var row = [ + hit._source.username, + hit._source.application, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-logins-devices.js b/src/r3-query-logins-devices.js new file mode 100644 index 0000000..e3e4188 --- /dev/null +++ b/src/r3-query-logins-devices.js @@ -0,0 +1,85 @@ +/** + * R3.Query.Logins.Devices + * @param apiComponent + * @constructor + */ +R3.Query.Logins.Devices = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Logins.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Logins.Devices.prototype = Object.create(R3.Query.Logins.prototype); +R3.Query.Logins.Devices.prototype.constructor = R3.Query.Logins.Devices; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.Devices.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.Devices.prototype.updateInstance = function(property) { + + R3.Query.Logins.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Logins.Devices.prototype.parse = function(data) { + + this.columns = [ + { + type : 'string', + name : 'User' + }, + { + type : 'string', + name : 'Device' + }, + { + type : 'string', + name : 'Type' + }, + { + type : 'string', + name : 'Protocol' + }, + { + type : 'datetime', + name : 'Time' + }, + ]; + + + this.rows = data.hits.hits.reduce( + function(result, hit) { + console.log('device login : ', hit); + var row = [ + hit._source.username, + hit._source.destination_hostname, + hit._source.login_type, + hit._source.login_protocol, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + +}; diff --git a/src/r3-query-logins-vpn.js b/src/r3-query-logins-vpn.js new file mode 100644 index 0000000..642d678 --- /dev/null +++ b/src/r3-query-logins-vpn.js @@ -0,0 +1,79 @@ +/** + * R3.Query.Logins.VPN + * @param apiComponent + * @constructor + */ +R3.Query.Logins.VPN = function( + apiComponent +) { + + __RUNTIME_COMPONENT__; + + R3.Query.Logins.call( + this, + apiComponent, + true + ); + +}; + +R3.Query.Logins.VPN.prototype = Object.create(R3.Query.Logins.prototype); +R3.Query.Logins.VPN.prototype.constructor = R3.Query.Logins.VPN; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.VPN.prototype.createInstance = function() { + + this.instance = true; + + __CREATE_INSTANCE__; + +}; + +/** + * Updates the instance with the current state + */ +R3.Query.Logins.VPN.prototype.updateInstance = function(property) { + + R3.Query.Logins.prototype.updateInstance.call(this, property); + +}; + +R3.Query.Logins.VPN.prototype.parse = function(data) { + + + this.columns = [ + { + type : 'string', + name : 'User' + }, + { + type : 'string', + name : 'Country' + }, + { + type : 'string', + name : 'City' + }, + { + type : 'datetime', + name : 'Time' + } + ]; + + this.rows = data.hits.hits.reduce( + function(result, hit) { + var row = [ + hit._source.username, + hit._source.source_geo.country, + hit._source.source_geo.city, + new Date(hit._source.timestamp) + ]; + result.push(row); + return result; + }, + [] + ); + +}; diff --git a/src/r3-renderer-0.js b/src/r3-renderer-0.js index e9dbfcc..bd58725 100644 --- a/src/r3-renderer-0.js +++ b/src/r3-renderer-0.js @@ -2,9 +2,13 @@ * R3.Renderer * @constructor */ -R3.Renderer = function() { +R3.Renderer = function( + inherited +) { - __UPGRADE_TO_RUNTIME; + __INHERIT_ONLY__ + + __UPGRADE_TO_RUNTIME__; }; diff --git a/src/r3-renderer-d2.js b/src/r3-renderer-d2.js index ed72b4f..1bb7ce6 100644 --- a/src/r3-renderer-d2.js +++ b/src/r3-renderer-d2.js @@ -9,8 +9,11 @@ R3.Renderer.D2 = function( __RUNTIME_COMPONENT__; + this.linkedComponents.canvas = R3.Canvas; + R3.Renderer.call( - this + this, + true ); }; @@ -24,7 +27,11 @@ R3.Renderer.D2.prototype.constructor = R3.Renderer.D2; */ R3.Renderer.D2.prototype.createInstance = function() { - this.instance = true; + this.instance = new PIXI.Application( + { + view : this.canvas.instance + } + ); __CREATE_INSTANCE__; diff --git a/src/r3-renderer-d3-0.js b/src/r3-renderer-d3-0.js index e4d47e2..66095ef 100644 --- a/src/r3-renderer-d3-0.js +++ b/src/r3-renderer-d3-0.js @@ -7,12 +7,13 @@ R3.Renderer.D3 = function( inherited ) { - 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'); - } + __INHERIT_ONLY__ + + this.linkedComponents.viewports = [R3.D3.Viewport]; R3.Renderer.call( - this + this, + true ); }; @@ -44,8 +45,6 @@ R3.Renderer.D3.prototype.createInstance = function() { this.updateInstance('shadowMapAutoUpdate'); this.updateInstance('shadowMapNeedsUpdate'); this.updateInstance('shadowMapType'); - this.updateInstance('shadowMapRenderReverseSided'); - this.updateInstance('shadowMapRenderSingleSided'); this.updateInstance('sortObjects'); this.updateInstance('toneMapping'); this.updateInstance('toneMappingExposure'); @@ -144,16 +143,6 @@ R3.Renderer.D3.prototype.updateInstance = function(property) { return; } - if (property === 'shadowMapRenderReverseSided') { - this.instance.shadowMap.renderReverseSided = this.shadowMapRenderReverseSided; - return; - } - - if (property === 'shadowMapRenderSingleSided') { - this.instance.shadowMap.renderSingleSided = this.shadowMapRenderSingleSided; - return; - } - if (property === 'sortObjects') { this.instance.sortObjects = this.sortObjects; return; diff --git a/src/r3-renderer-d3-canvas-0.js b/src/r3-renderer-d3-canvas-0.js index 23facb7..890013c 100644 --- a/src/r3-renderer-d3-canvas-0.js +++ b/src/r3-renderer-d3-canvas-0.js @@ -9,13 +9,9 @@ R3.Renderer.D3.Canvas = function( inherited ) { - if (R3.Utils.UndefinedOrNull(inherited)) { - inherited = false; - } + __INHERIT_AND_INSTANTIATE__ - if (!inherited) { - __RUNTIME_COMPONENT__; - } + this.linkedComponents.canvas = R3.Canvas; R3.Renderer.D3.call( this, @@ -41,16 +37,7 @@ R3.Renderer.D3.Canvas.prototype.createInstance = function() { return; } - this.instance = this.graphics.Renderer3D( - this.canvas, - this.alpha, - this.premultipliedAlpha, - this.antialias, - this.stencil, - this.preserveDrawingBuffer, - this.depth, - this.logarithmicDepthBuffer - ); + this.instance = this.graphics.Renderer3D(this); R3.Renderer.D3.prototype.createInstance.call(this); }; diff --git a/src/r3-renderer-d3-canvas-target.js b/src/r3-renderer-d3-canvas-target.js index 5884a14..af49c8b 100644 --- a/src/r3-renderer-d3-canvas-target.js +++ b/src/r3-renderer-d3-canvas-target.js @@ -9,8 +9,11 @@ R3.Renderer.D3.Canvas.Target = function( __RUNTIME_COMPONENT__; + this.linkedComponents.target = R3.D3.RenderTarget; + R3.Renderer.D3.Canvas.call( this, + apiComponent, true ); @@ -44,18 +47,7 @@ R3.Renderer.D3.Canvas.Target.prototype.createInstance = function() { return; } - this.instance = this.graphics.Renderer3D( - this.canvas, - this.alpha, - this.premultipliedAlpha, - this.antialias, - this.stencil, - this.preserveDrawingBuffer, - this.depth, - this.logarithmicDepthBuffer - ); - - this.instance.setRenderTarget(this.target.instance); + this.instance = this.graphics.Renderer3D(this); /** * So we skip the canvas createInstance but call the rest of the parent class createInstances diff --git a/src/r3-runtime-graphics-0.js b/src/r3-runtime-graphics-0.js index bdb1f70..16908f4 100644 --- a/src/r3-runtime-graphics-0.js +++ b/src/r3-runtime-graphics-0.js @@ -490,7 +490,24 @@ R3.Runtime.Graphics.prototype.MeshSkeleton = function ( console.warn('override R3.Runtime.Graphics.prototype.MeshSkeleton in child class'); }; +R3.Runtime.Graphics.prototype.Table = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.Table in child class'); +}; + +R3.Runtime.Graphics.prototype.MetricNumber = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.MetricNumber in child class'); +}; + +R3.Runtime.Graphics.prototype.BarchartStacked = function ( + runtimeObject +) { + console.warn('override R3.Runtime.Graphics.prototype.BarchartStacked 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-chart.js b/src/r3-runtime-graphics-chart.js new file mode 100644 index 0000000..399cb58 --- /dev/null +++ b/src/r3-runtime-graphics-chart.js @@ -0,0 +1,66 @@ +/** + * R3.Runtime.Graphics.Chart + * @constructor + */ +R3.Runtime.Graphics.Chart = function() { + + R3.Runtime.Graphics.call( + this + ); + + this.createInstance(); +}; + +R3.Runtime.Graphics.Chart.prototype = Object.create(R3.Runtime.Graphics.prototype); +R3.Runtime.Graphics.Chart.prototype.constructor = R3.Runtime.Graphics.Chart; + +/** + * Create R3.Runtime.Graphics.Chart Instance + * @returns {*} + */ +R3.Runtime.Graphics.Chart.prototype.createInstance = function() { + this.instance = Chart; +}; + +/** + * + * @param runtimeObject + * @constructor + */ +R3.Runtime.Graphics.Chart.prototype.BarchartStacked = function(runtimeObject) { + + var ctx = document.getElementById(runtimeObject.domElement.domElementId).getContext('2d'); + + var barChartData = { + labels: runtimeObject.query.labels, + datasets: runtimeObject.query.datasets + }; + + runtimeObject.chart = new Chart(ctx, { + type: 'bar', + data: barChartData, + options: { + title: { + display: true, + text: R3.GetComponentName(runtimeObject.query) + }, + tooltips: { + mode: 'index', + intersect: false + }, + responsive: true, + maintainAspectRatio: false, + scales: { + xAxes: [{ + stacked: true, + }], + yAxes: [{ + stacked: true + }] + } + } + }); + + return true; + +}; diff --git a/src/r3-runtime-graphics-custom.js b/src/r3-runtime-graphics-custom.js new file mode 100644 index 0000000..df4eba6 --- /dev/null +++ b/src/r3-runtime-graphics-custom.js @@ -0,0 +1,34 @@ +/** + * R3.Runtime.Graphics.Custom + * @constructor + */ +R3.Runtime.Graphics.Custom = function() { + + R3.Runtime.Graphics.call( + this + ); + + this.createInstance(); +}; + +R3.Runtime.Graphics.Custom.prototype = Object.create(R3.Runtime.Graphics.prototype); +R3.Runtime.Graphics.Custom.prototype.constructor = R3.Runtime.Graphics.Custom; + +/** + * Create R3.Runtime.Graphics.Custom Instance + * @returns {*} + */ +R3.Runtime.Graphics.Custom.prototype.createInstance = function() { + this.instance = true; +}; + +/** + * + * @param runtimeObject + * @constructor + */ +R3.Runtime.Graphics.Custom.prototype.MetricNumber = function(runtimeObject) { + + document.getElementById(runtimeObject.domElement.id).innerText = runtimeObject.parsed.count; + +}; diff --git a/src/r3-runtime-graphics-google.js b/src/r3-runtime-graphics-google.js new file mode 100644 index 0000000..04e84f5 --- /dev/null +++ b/src/r3-runtime-graphics-google.js @@ -0,0 +1,51 @@ +/** + * R3.Runtime.Graphics.Google + * @constructor + */ +R3.Runtime.Graphics.Google = function() { + + R3.Runtime.Graphics.call( + this + ); + + this.createInstance(); +}; + +R3.Runtime.Graphics.Google.prototype = Object.create(R3.Runtime.Graphics.prototype); +R3.Runtime.Graphics.Google.prototype.constructor = R3.Runtime.Graphics.Google; + +/** + * Create R3.Runtime.Graphics.Google Instance + * @returns {*} + */ +R3.Runtime.Graphics.Google.prototype.createInstance = function() { + this.instance = google.charts; +}; + +R3.Runtime.Graphics.Google.prototype.Table = function(runtimeObject) { + + google.charts.load('current', {'packages':['table']}); + google.charts.setOnLoadCallback( + + function(graph) { + return function() { + var dataTable = new google.visualization.DataTable(); + + graph.columns.map( + function(column) { + dataTable.addColumn(column.type, column.name); + } + ); + + dataTable.addRows(graph.rows); + + var table = new google.visualization.Table(document.getElementById(graph.domElement.domElementId)); + + table.draw(dataTable, {showRowNumber: true, width: '100%', height: '100%'}); + } + }(runtimeObject) + + ); + + return true; +}; diff --git a/src/r3-runtime-graphics-pixi.js b/src/r3-runtime-graphics-pixi.js new file mode 100644 index 0000000..53850e5 --- /dev/null +++ b/src/r3-runtime-graphics-pixi.js @@ -0,0 +1,40 @@ +/** + * R3.Runtime.Graphics.Pixi + * @constructor + */ +R3.Runtime.Graphics.Pixi = function() { + + R3.Runtime.Graphics.call( + this + ); + + this.createInstance(); +}; + +R3.Runtime.Graphics.Pixi.prototype = Object.create(R3.Runtime.Graphics.prototype); +R3.Runtime.Graphics.Pixi.prototype.constructor = R3.Runtime.Graphics.Pixi; + +/** + * Create R3.Runtime.Graphics.Pixi Instance + * @returns {*} + */ +R3.Runtime.Graphics.Pixi.prototype.createInstance = function() { + this.instance = PIXI; +}; + +R3.Runtime.Graphics.Pixi.prototype.Canvas = function(runtimeObject) { + + var instance = document.createElement('canvas'); + + instance.setAttribute('id', runtimeObject.id); + + instance.setAttribute('tabindex', runtimeObject.tabIndex); + + instance.setAttribute('width', runtimeObject.width); + + instance.setAttribute('height', runtimeObject.height); + + instance.setAttribute('style', 'left: ' + runtimeObject.offset.x + 'px;top: ' + runtimeObject.offset.y + 'px;width:' + runtimeObject.width + 'px;height:' + runtimeObject.height + 'px'); + + return instance; +}; \ No newline at end of file diff --git a/src/r3-runtime-graphics-three.js b/src/r3-runtime-graphics-three.js index 8928ce8..1a6ef7d 100644 --- a/src/r3-runtime-graphics-three.js +++ b/src/r3-runtime-graphics-three.js @@ -22,8 +22,40 @@ R3.Runtime.Graphics.Three.prototype.createInstance = function() { this.instance = true; }; +R3.Runtime.Graphics.Three.prototype.Canvas = function(runtimeObject) { + + var instance = document.createElement('canvas'); + + instance.setAttribute('id', runtimeObject.id); + + instance.setAttribute('tabindex', runtimeObject.tabIndex); + + instance.setAttribute('width', runtimeObject.width); + + instance.setAttribute('height', runtimeObject.height); + + instance.setAttribute('style', 'left: ' + runtimeObject.offset.x + 'px;top: ' + runtimeObject.offset.y + 'px;width:' + runtimeObject.width + 'px;height:' + runtimeObject.height + 'px'); + + if (this.autoUpdateSize) { + /** + * Update our size from the instance size + */ + runtimeObject.width = instance.width; + runtimeObject.height = instance.height; + } else { + /** + * Update our instance with our size + */ + instance.width = runtimeObject.width; + instance.height = runtimeObject.height; + } + + return instance; + +}; + R3.Runtime.Graphics.Three.prototype.Vector2 = function(x,y) { - return new THREE.Vector2(x,y,z); + return new THREE.Vector2(x,y); }; R3.Runtime.Graphics.Three.prototype.Vector3 = function(x,y,z) { @@ -31,7 +63,7 @@ R3.Runtime.Graphics.Three.prototype.Vector3 = function(x,y,z) { }; R3.Runtime.Graphics.Three.prototype.Vector4 = function(x,y,z,w) { - return new THREE.Quaternion(x,y,z,w); + return new THREE.Vector4(x,y,z,w); }; R3.Runtime.Graphics.Three.prototype.Color = function(r,g,b,a) { @@ -80,126 +112,213 @@ R3.Runtime.Graphics.Three.prototype.Clock = function() { return new THREE.Clock(); }; -R3.Runtime.Graphics.Three.prototype.EditorControls = function(canvas, camera) { +// R3.Runtime.Graphics.Three.prototype.EditorControls = function(canvas, camera) { +// +// if (!canvas || !canvas.instance) { +// throw new Error('no canvas instance at time of EditorControls creation'); +// } +// +// if (!camera || !camera.instance) { +// throw new Error('no camera instance at time of EditorControls creation'); +// } +// +// return new THREE.EditorControls( +// camera.instance, +// canvas.instance +// ); +// }; - if (!canvas || !canvas.instance) { - throw new Error('no canvas instance at time of EditorControls creation'); - } +R3.Runtime.Graphics.Three.prototype.OrbitControlsInstance = function(controls) { - if (!camera || !camera.instance) { - throw new Error('no camera instance at time of EditorControls creation'); - } - - return new THREE.EditorControls( - camera.instance, - canvas.instance - ); -}; - -R3.Runtime.Graphics.Three.prototype.OrbitControls = function( - canvas, - camera, - target, - enabled, - minPolarAngle, - maxPolarAngle, - enableDamping, - dampingFactor, - enableZoom, - zoomSpeed, - enableRotate, - rotateSpeed, - enablePan, - keyPanSpeed, - autoRotate, - autoRotateSpeed, - enableKeys -) { - - if (!canvas || !canvas.instance) { - throw new Error('no canvas instance at time of OrbitControls creation'); - } - - if (!camera || !camera.instance) { - throw new Error('no camera instance at time of OrbitControls creation'); - } - - var controls = new THREE.OrbitControls( - camera.instance, - canvas.instance + controls.instance = new THREE.OrbitControls( + controls.camera.instance, + controls.canvas.instance ); - if (target && target.instance) { - controls.target = target.instance.position; - } + controls.updateInstance('enabled'); + controls.updateInstance('minPolarAngle'); + controls.updateInstance('maxPolarAngle'); + controls.updateInstance('enableDamping'); + controls.updateInstance('dampingFactor'); + controls.updateInstance('enableZoom'); + controls.updateInstance('zoomSpeed'); + controls.updateInstance('enableRotate'); + controls.updateInstance('rotateSpeed'); + controls.updateInstance('enablePan'); + controls.updateInstance('keyPanSpeed'); + controls.updateInstance('autoRotate'); + controls.updateInstance('autoRotateSpeed'); + controls.updateInstance('enableKeys'); + controls.updateInstance('target'); - controls.enabled = enabled; - controls.minPolarAngle = minPolarAngle; - controls.maxPolarAngle = maxPolarAngle; - controls.enableDamping = enableDamping; - controls.dampingFactor = dampingFactor; - controls.enableZoom = enableZoom; - controls.zoomSpeed = zoomSpeed; - controls.enableRotate = enableRotate; - controls.rotateSpeed = rotateSpeed; - controls.enablePan = enablePan; - controls.keyPanSpeed = keyPanSpeed; - controls.autoRotate = autoRotate; - controls.autoRotateSpeed = autoRotateSpeed; - controls.enableKeys = enableKeys; - - return controls; + return controls.instance; }; -R3.Runtime.Graphics.Three.prototype.FirstPersonControls = function( - canvas, - camera, - enabled, - movementSpeed, - lookSpeed, - lookVertical, - autoForward, - activeLook, - heightSpeed, - heightCoef, - heightMin, - heightMax, - constrainVertical, - verticalMin, - verticalMax, - autoSpeedFactor -) { - - if (!canvas || !canvas.instance) { - throw new Error('no canvas instance at time of OrbitControls creation'); +/** + * R3.Runtime.Graphics.Three.prototype.OrbitControls + * @param runtimeObject + * @returns {boolean|*} + * @constructor + */ +R3.Runtime.Graphics.Three.prototype.OrbitControls = function(runtimeObject) { + + if (!runtimeObject.canvas) { + throw new Error('no canvas at time of OrbitControls creation'); } - if (!camera || !camera.instance) { - throw new Error('no camera instance at time of OrbitControls creation'); + if (!runtimeObject.camera) { + throw new Error('no camera at time of OrbitControls creation'); } - var controls = new THREE.FirstPersonControls( - camera.instance, - canvas.instance + if (!runtimeObject.canvas.instance || + !runtimeObject.camera.instance + ) { + + /** + * This code below exists to solve the 'chicken/egg' problem when it comes to controls. + * Controls need a canvas instance to bind to - but they belong to canvasses - so we can't create their + * instances until the canvas instance is loaded, but the canvas would normally not load until their sub- + * components have loaded (i.e. the controls) - below code fixes this + * @type {{fn, remove}} + */ + this.createInstanceSubscription = R3.Event.Subscribe( + R3.Event.INSTANCE_CREATED, + function(controls) { + return function(data) { + + if (data.component === controls.canvas) { + + if (controls.camera.instance) { + + /** + * We are ready to construct this instance + */ + + this.OrbitControlsInstance(controls); + + this.createInstanceSubscription.remove(); + + } + } + + if (data.component === controls.camera) { + + if (controls.canvas.instance) { + /** + * We are ready to construct this instance + */ + + this.OrbitControlsInstance(controls); + + this.createInstanceSubscription.remove(); + } + + } + }.bind(this); + }(runtimeObject) + ); + + return true; + } + + return this.OrbitControlsInstance(runtimeObject); + +}; + +R3.Runtime.Graphics.Three.prototype.FirstPersonControlsInstance = function(controls) { + + controls.instance = new THREE.FirstPersonControls( + controls.camera.instance, + controls.canvas.instance ); - controls.enabled = enabled; - controls.movementSpeed = movementSpeed; - controls.lookSpeed = lookSpeed; - controls.lookVertical = lookVertical; - controls.autoForward = autoForward; - controls.activeLook = activeLook; - controls.heightSpeed = heightSpeed; - controls.heightCoef = heightCoef; - controls.heightMin = heightMin; - controls.heightMax = heightMax; - controls.constrainVertical = constrainVertical; - controls.verticalMin = verticalMin; - controls.verticalMax = verticalMax; - controls.autoSpeedFactor = autoSpeedFactor; + controls.updateInstance('enabled'); + controls.updateInstance('movementSpeed'); + controls.updateInstance('lookSpeed'); + controls.updateInstance('lookVertical'); + controls.updateInstance('autoForward'); + controls.updateInstance('activeLook'); + controls.updateInstance('heightSpeed'); + controls.updateInstance('heightCoef'); + controls.updateInstance('heightMin'); + controls.updateInstance('heightMax'); + controls.updateInstance('constrainVertical'); + controls.updateInstance('verticalMin'); + controls.updateInstance('verticalMax'); + controls.updateInstance('autoSpeedFactor'); + + return controls.instance; +}; + +/** + * R3.Runtime.Graphics.Three.prototype.FirstPersonControls + * @param runtimeObject + * @returns {boolean|*} + * @constructor + */ +R3.Runtime.Graphics.Three.prototype.FirstPersonControls = function(runtimeObject) { + + if (!runtimeObject.canvas) { + throw new Error('no canvas at time of FirstPersonControls creation'); + } + + if (!runtimeObject.camera) { + throw new Error('no camera at time of FirstPersonControls creation'); + } + + if (!runtimeObject.canvas.instance || + !runtimeObject.camera.instance + ) { + /** + * This code below exists to solve the 'chicken/egg' problem when it comes to controls. + * Controls need a canvas instance to bind to - but they belong to canvasses - so we can't create their + * instances until the canvas instance is loaded, but the canvas would normally not load until their sub- + * components have loaded (i.e. the controls) - below code fixes this + * @type {{fn, remove}} + */ + this.createInstanceSubscription = R3.Event.Subscribe( + R3.Event.INSTANCE_CREATED, + function(controls) { + return function(data) { + + if (data.component === controls.canvas) { + + if (controls.camera.instance) { + + /** + * We are ready to construct this instance + */ + + this.FirstPersonControlsInstance(controls); + + this.createInstanceSubscription.remove(); + + } + } + + if (data.component === controls.camera) { + + if (controls.canvas.instance) { + /** + * We are ready to construct this instance + */ + + this.FirstPersonControlsInstance(controls); + + this.createInstanceSubscription.remove(); + } + + } + }.bind(this); + }(runtimeObject) + ); + + return true; + } + + return this.FirstPersonControlsInstance(runtimeObject); - return controls; }; R3.Runtime.Graphics.Three.prototype.Curve = function(arcLenghDivisions) { @@ -402,18 +521,31 @@ R3.Runtime.Graphics.Three.prototype.OrthographicCamera = function( ); }; -R3.Runtime.Graphics.Three.prototype.PerspectiveCamera = function( - fov, - aspect, - near, - far -) { - return new THREE.PerspectiveCamera( - this.fov, - this.aspect, - this.near, - this.far +R3.Runtime.Graphics.Three.prototype.PerspectiveCamera = function(runtimeObject) { + + var instance = new THREE.PerspectiveCamera( + runtimeObject.fov, + runtimeObject.aspect, + runtimeObject.near, + runtimeObject.far ); + + instance.filmGauge = runtimeObject.filmGauge; + instance.filmOffset = runtimeObject.filmOffset; + instance.focus = runtimeObject.focus; + instance.zoom = runtimeObject.zoom; + + instance.position.set( + runtimeObject.position.x, + runtimeObject.position.y, + runtimeObject.position.z + ); + + instance.lookAt(0,0,0); + + instance.updateProjectionMatrix(); + + return instance; }; R3.Runtime.Graphics.Three.prototype.StereoCamera = function( @@ -517,30 +649,27 @@ R3.Runtime.Graphics.Three.prototype.Composer = function( ); }; -R3.Runtime.Graphics.Three.prototype.Renderer3D = function( - canvas, - alpha, - premultipliedAlpha, - antialias, - stencil, - preserveDrawingBuffer, - depth, - logarithmicDepthBuffer -) { +R3.Runtime.Graphics.Three.prototype.Renderer3D = function(runtimeObject){ - return new THREE.WebGLRenderer( + var instance = new THREE.WebGLRenderer( { - canvas : canvas.instance, - alpha : alpha, - premultipliedAlpha : premultipliedAlpha, - antialias : antialias, - stencil : stencil, - preserveDrawingBuffer : preserveDrawingBuffer, - depth : depth, - logarithmicDepthBuffer : logarithmicDepthBuffer + canvas : runtimeObject.canvas.instance, + alpha : runtimeObject.alpha, + premultipliedAlpha : runtimeObject.premultipliedAlpha, + antialias : runtimeObject.antialias, + stencil : runtimeObject.stencil, + preserveDrawingBuffer : runtimeObject.preserveDrawingBuffer, + depth : runtimeObject.depth, + logarithmicDepthBuffer : runtimeObject.logarithmicDepthBuffer } ); + if (R3.Utils.Defined(runtimeObject.target)) { + instance.setRenderTarget(runtimeObject.target.instance); + } + + return instance; + }; R3.Runtime.Graphics.Three.prototype.AnaglyphEffect = function( @@ -600,25 +729,18 @@ R3.Runtime.Graphics.Three.prototype.Face = function( }; -R3.Runtime.Graphics.Three.prototype.FogExp = function( - color, - density -) { +R3.Runtime.Graphics.Three.prototype.FogExp = function(runtimeObject) { return new THREE.FogExp2( - this.color.toHex(), - this.density + runtimeObject.color.toHex(), + runtimeObject.density ); }; -R3.Runtime.Graphics.Three.prototype.Fog = function( - color, - near, - far -) { +R3.Runtime.Graphics.Three.prototype.Fog = function(runtimeObject) { return new THREE.Fog( - this.color.toHex(), - this.near, - this.far + runtimeObject.color.toHex(), + runtimeObject.near, + runtimeObject.far ); }; @@ -1641,6 +1763,33 @@ R3.Runtime.Graphics.Three.prototype.MeshSkeleton = function ( throw new Error('todo: implement R3.Runtime.Graphics.Three.prototype.MeshSkeleton'); }; +R3.Runtime.Graphics.Three.prototype.Scene = function ( + runtimeObject +) { + + var instance = new THREE.Scene(); + + instance.name = runtimeObject.name; + + if (R3.Utils.Instance(runtimeObject.fog)) { + instance.fog = runtimeObject.fog.instance; + } + + runtimeObject.meshes.map( + function(mesh) { + instance.add(mesh.instance); + } + ); + + runtimeObject.lights.map( + function(light) { + instance.add(light.instance); + } + ); + + return instance; +}; + /** * R3.Runtime.Graphics.Three.prototype.updateInstance * @param runtimeObject diff --git a/src/r3-system-gui.js b/src/r3-system-gui.js index c3a62e4..c5fa065 100644 --- a/src/r3-system-gui.js +++ b/src/r3-system-gui.js @@ -497,77 +497,80 @@ R3.System.GUI.prototype.buildVectorControl = function(folder, componentTemplate, */ R3.System.GUI.prototype.buildParentSelectionControl = function(folder, componentTemplate, property) { - var type = R3.Utils.UpperCaseUnderscore(property.replace('parent','')); - - var componentType = R3.Component[type]; - - var constructor = R3.Component.GetComponentConstructor(componentType); - - var options = R3.EntityManager.Instance.queryComponentsByConstructor(constructor).reduce( - function(result, object) { - result[object.name] = object; - return result; - }, - { - 'none' : null - } - ); - - var object = componentTemplate.template; - - var affected = componentTemplate.affected; - - folder.add(object, property, options).listen().onChange( - - function(value) { - - var newComponent = null; - - if (value !== 'null') { - newComponent = R3.EntityManager.Instance.findComponentById(value); - } - - affected.map( - function(component) { - - component[property] = newComponent; - component.updateInstance(property); - - if (property === 'parentPhysicsWorld') { - R3.Event.Emit( - R3.Event.PARENT_WORLD_CHANGE, - { - originalWorld : this.initialValue, - newWorld : newComponent, - object : component - } - ) - } - - if (property === 'parentScene') { - R3.Event.Emit( - R3.Event.PARENT_SCENE_CHANGE, - { - originalScene: this.initialValue, - newScene: newComponent, - object: component - } - ); - } - - }.bind(this) - ); - - if (property === 'parent') { - R3.Event.Emit( - R3.Event.BUILD_GUI, - null - ); - } - - this.initialValue = newComponent; - } - ); + console.warn('todo : fix this'); + return; + // + // var type = R3.Utils.UpperCaseUnderscore(property.replace('parent','')); + // + // var componentType = R3.Component[type]; + // + // var constructor = R3.Component.GetComponentConstructor(componentType); + // + // var options = R3.EntityManager.Instance.findComponentsByConstructor(constructor).reduce( + // function(result, object) { + // result[object.name] = object; + // return result; + // }, + // { + // 'none' : null + // } + // ); + // + // var object = componentTemplate.template; + // + // var affected = componentTemplate.affected; + // + // folder.add(object, property, options).listen().onChange( + // + // function(value) { + // + // var newComponent = null; + // + // if (value !== 'null') { + // newComponent = R3.EntityManager.Instance.findComponentById(value); + // } + // + // affected.map( + // function(component) { + // + // component[property] = newComponent; + // component.updateInstance(property); + // + // if (property === 'parentPhysicsWorld') { + // R3.Event.Emit( + // R3.Event.PARENT_WORLD_CHANGE, + // { + // originalWorld : this.initialValue, + // newWorld : newComponent, + // object : component + // } + // ) + // } + // + // if (property === 'parentScene') { + // R3.Event.Emit( + // R3.Event.PARENT_SCENE_CHANGE, + // { + // originalScene: this.initialValue, + // newScene: newComponent, + // object: component + // } + // ); + // } + // + // }.bind(this) + // ); + // + // if (property === 'parent') { + // R3.Event.Emit( + // R3.Event.BUILD_GUI, + // null + // ); + // } + // + // this.initialValue = newComponent; + // } + // ); }; R3.System.GUI.prototype.buildArrayManagerControl = function( @@ -576,7 +579,7 @@ R3.System.GUI.prototype.buildArrayManagerControl = function( property ) { - var constructors = componentTemplate.template.linkedObjects[property]; + var constructors = componentTemplate.template.linkedComponents[property]; if (constructors instanceof Array) { /** @@ -622,7 +625,7 @@ R3.System.GUI.prototype.buildArrayManagerControl = function( var idObject = {}; - var selectionObject = R3.EntityManager.Instance.queryComponentsByConstructor(constructors).reduce( + var selectionObject = R3.EntityManager.Instance.findComponentsByConstructor(constructors).reduce( function(result, component) { result[component.name] = component; idObject[component.id] = component; @@ -796,8 +799,8 @@ R3.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, */ var constructors = null; - if (componentTemplate.template.linkedObjects && componentTemplate.template.linkedObjects[property]) { - constructors = componentTemplate.template.linkedObjects[property]; + if (componentTemplate.template.linkedComponents && componentTemplate.template.linkedComponents[property]) { + constructors = componentTemplate.template.linkedComponents[property]; } else { if (componentTemplate.template[property]) { constructors = componentTemplate.template[property].constructor; @@ -811,7 +814,7 @@ R3.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, var object = componentTemplate.template; - var objects = R3.EntityManager.Instance.queryComponentsByConstructor(constructors); + var objects = R3.EntityManager.Instance.findComponentsByConstructor(constructors); var idObject = {}; @@ -2129,7 +2132,7 @@ R3.System.GUI.prototype.buildGUI = function(data) { var name; if (R3.Utils.UndefinedOrNull(componentTemplate.template.name)) { - name = R3.Component.GetComponentName(componentTemplate.componentType) + ' (All Selected (' + componentTemplate.affected.length + '))'; + name = R3.GetComponentName(componentTemplate) + ' (All Selected (' + componentTemplate.affected.length + '))'; } else { name = componentTemplate.template.name; } @@ -2195,8 +2198,8 @@ R3.System.GUI.prototype.buildGUI = function(data) { } if ( - componentTemplate.template.linkedObjects && - componentTemplate.template.linkedObjects[templateProperty] instanceof Array + componentTemplate.template.linkedComponents && + componentTemplate.template.linkedComponents[templateProperty] instanceof Array ) { this.buildArrayManagerControl(folder, componentTemplate, templateProperty); } @@ -2214,8 +2217,8 @@ R3.System.GUI.prototype.buildGUI = function(data) { if ( componentTemplate.template[templateProperty] instanceof R3.Component || ( - componentTemplate.template.linkedObjects && - componentTemplate.template.linkedObjects[templateProperty] + componentTemplate.template.linkedComponents && + componentTemplate.template.linkedComponents[templateProperty] ) ) { this.buildSelectControl(folder, componentTemplate, templateProperty) diff --git a/src/r3-system-input.js b/src/r3-system-input.js index f1baa51..845344e 100644 --- a/src/r3-system-input.js +++ b/src/r3-system-input.js @@ -1,21 +1,23 @@ /** - * System takes care of updating all the entities (based on their component data) - * @param graphics - * @param apiSystem R3.API.System + * R3.System.Input * @constructor */ -R3.System.Input = function( - graphics, - apiSystem -) { - R3.System.call( - this, - apiSystem +R3.System.Input = function() { + + R3.System.call( + this ); this.selectAll = false; - this.editMode = false; + this.applicationMode = R3.API.Project.APPLICATION_MODE_EDIT; + + R3.Event.Emit( + R3.Event.GET_APPLICATION_MODE, + function(applicationMode) { + this.applicationMode = applicationMode; + }.bind(this) + ); this.grabMode = false; @@ -59,26 +61,15 @@ R3.System.Input = function( this.mouseWheel = this.onMouseWheel.bind(this); this.mouseUp = this.onMouseUp.bind(this); - /** - * Editor Controls - * @type {null} - */ - this.keyDownEdit = this.onKeyDownEdit.bind(this); - this.keyUpEdit = this.onKeyUpEdit.bind(this); - this.mouseDownEdit = this.onMouseDownEdit.bind(this); - this.mouseMoveEdit = this.onMouseMoveEdit.bind(this); - this.mouseWheelEdit = this.onMouseWheelEdit.bind(this); - this.mouseUpEdit = this.onMouseUpEdit.bind(this); - this.instanceCreatedSubscription = null; this.removeComponentSubscription = null; this.canvasChangeSubscription = null; this.selectionModeChangeSubscription = null; + this.beforeRenderSubscription = null; + this.applicationModeSubscription = null; this.selectionMode = R3.System.Input.SELECTION_MODE_DEFAULT; - this.mouse = new R3.Mouse(); - this.raycaster = new R3.D3.Raycaster(graphics); }; R3.System.Input.prototype = Object.create(R3.System.prototype); @@ -239,22 +230,15 @@ R3.System.Input.prototype.start = function() { /** * Normal Controls */ - this.touchControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_TOUCH); + this.touchControls = R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.Touch); - this.keyboardControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_KEYBOARD); + this.keyboardControls = R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.Keyboard); - this.mouseControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_MOUSE); + this.mouseControls = R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.Mouse); - /** - * Edit Mode Controls - */ - this.editorControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_EDITOR); + this.orbitControls = R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.D3.Orbit); - this.orbitControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_ORBIT); - - this.firstPersonControls = R3.EntityManager.Instance.queryComponents(R3.Component.CONTROLS_FIRST_PERSON); - - this.setMode(); + this.firstPersonControls = R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.D3.FirstPerson); }; /** @@ -274,28 +258,36 @@ R3.System.Input.prototype.stop = function() { this.beforeRenderSubscription.remove(); - if (this.editMode) { - this.deRegisterEditModeControls(); - } else { - this.touchControls.map( - function(touchControl){ - this.deRegisterTouchControl(touchControl); - }.bind(this) - ); + this.touchControls.map( + function(touchControl){ + this.deRegisterTouchControl(touchControl); + }.bind(this) + ); - this.keyboardControls.map( - function(keyboardControl){ - this.deRegisterKeyboardControl(keyboardControl); - }.bind(this) - ); + this.keyboardControls.map( + function(keyboardControl){ + this.deRegisterKeyboardControl(keyboardControl); + }.bind(this) + ); + + this.mouseControls.map( + function(mouseControl){ + this.deRegisterMouseControl(mouseControl); + }.bind(this) + ); + + this.orbitControls.map( + function(orbitControl) { + orbitControl.instance.dispose(); + } + ); + + this.firstPersonControls.map( + function(firstPersonControl) { + firstPersonControl.instance.dispose(); + } + ); - this.mouseControls.map( - function(mouseControl){ - this.deRegisterMouseControl(mouseControl); - }.bind(this) - ); - } - this.editorControls = []; this.firstPersonControls = []; @@ -310,30 +302,6 @@ R3.System.Input.prototype.stop = function() { }; -R3.System.Input.prototype.setMode = function() { - - /** - * De-Register everything - */ - this.deRegisterNormalModeControls(); - - this.deRegisterEditModeControls(); - - /** - * Now register the required controls - */ - if (this.editMode) { - - this.registerEditModeControls(); - - } else { - - this.registerNormalModeControls(); - - } - -}; - /** * * @param data @@ -353,73 +321,56 @@ R3.System.Input.prototype.selectionModeChange = function(data) { }; -R3.System.Input.prototype.beforeRender = function(data) { +R3.System.Input.prototype.beforeRender = function(project) { - if (this.editMode) { + if (project.applicationMode === R3.API.Project.APPLICATION_MODE_EDIT) { - this.firstPersonControls.map( + project.controls.map( function(control) { - if (control && control.instance) { - control.instance.update(data.delta); - } - } - ); - - this.orbitControls.map( - function(control) { - if (control && control.instance) { - control.instance.update(data.delta); + if ( + control instanceof R3.Controls.D3.Orbit || + control instanceof R3.Controls.D3.FirstPerson + ) { + control.instance.update(project.clock.getDelta()); } } ); + } else { - /** * We don't update anything at the moment for normal controls */ - } }; - /** - * From now on we want to track everything about a component, only from the systems that are active + * From now on we want to track everything about a component from the systems that are active * @param data */ R3.System.Input.prototype.instanceCreated = function(data) { if (data.component instanceof R3.Controls.Touch) { - - if (this.touchControls.indexOf(data.component) !== -1) { - console.warn('Touch controls already registered'); - return; - } - - this.touchControls.push(data.component); - this.setMode(); + R3.Utils.PushUnique(this.touchControls, data.component); + this.registerTouchControl(data.component); } if (data.component instanceof R3.Controls.Keyboard) { - - if (this.keyboardControls.indexOf(data.component) !== -1) { - console.warn('Keyboard controls already registered'); - return; - } - - this.keyboardControls.push(data.component); - this.setMode(); + R3.Utils.PushUnique(this.keyboardControls, data.component); + this.registerKeyboardControl(data.component); } if (data.component instanceof R3.Controls.Mouse) { + R3.Utils.PushUnique(this.mouseControls, data.component); + this.registerMouseControl(data.component); + } - if (this.mouseControls.indexOf(data.component) !== -1) { - console.warn('Mouse controls already registered'); - return; - } + if (data.component instanceof R3.Controls.D3.Orbit) { + R3.Utils.PushUnique(this.orbitControls, data.component); + } - this.mouseControls.push(data.component); - this.setMode(); + if (data.component instanceof R3.Controls.D3.FirstPerson) { + R3.Utils.PushUnique(this.firstPersonControls, data.component); } }; @@ -435,114 +386,75 @@ R3.System.Input.prototype.removeComponent = function(data) { index = this.touchControls.indexOf(data.component); - if (index === -1) { - console.warn('Failed to find the touch controls in the system - probably it was ignored - ' + data.component.name); - return; + if (index !== -1) { + + this.deRegisterTouchControl(data.component); + + this.touchControls.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Input'); } - - console.log('removing touch controls from system'); - - this.deRegisterTouchControl(data.component); - - this.touchControls.splice(index, 1); - - this.setMode(); } if (data.component instanceof R3.Controls.Keyboard) { index = this.keyboardControls.indexOf(data.component); - if (index === -1) { - console.warn('Failed to find the keyboard controls in the system - probably it was ignored - ' + data.component.name); - return; + if (index !== -1) { + + this.deRegisterKeyboardControl(data.component); + + this.keyboardControls.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Input'); } - - console.log('removing keyboard controls from system'); - - this.deRegisterKeyboardControl(data.component); - - this.keyboardControls.splice(index, 1); - - this.setMode(); } if (data.component instanceof R3.Controls.Mouse) { index = this.mouseControls.indexOf(data.component); - if (index === -1) { - console.warn('Failed to find the mouse controls in the system - probably it was ignored - ' + data.component.name); - return; + if (index !== -1) { + + this.deRegisterMouseControl(data.component); + + this.mouseControls.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Input'); } - - console.log('removing mouse controls from system'); - - this.deRegisterMouseControl(data.component); - - this.mouseControls.splice(index, 1); - - this.setMode(); - } - - if (data.component instanceof R3.Controls.D3.Editor) { - - console.log('removing editor controls from system'); - - index = this.editorControls.indexOf(data.component); - - if (index === -1) { - console.warn('Failed to find the editor controls in the system - probably it was ignored - ' + data.component.name); - return; - } - - if (data.component.instance) { - data.component.instance.dispose(); - } - - this.editorControls.splice(index, 1); - - this.setMode(); } if (data.component instanceof R3.Controls.D3.FirstPerson) { - console.log('removing first person controls from system'); - index = this.firstPersonControls.indexOf(data.component); - if (index === -1) { - console.warn('Failed to find the first person controls in the system - probably it was ignored - ' + data.component.name); - return; - } + if (index !== -1) { - if (data.component.instance) { data.component.instance.dispose(); + + this.firstPersonControls.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Input'); } - - this.firstPersonControls.splice(index, 1); - - this.setMode(); } if (data.component instanceof R3.Controls.D3.Orbit) { - console.log('removing orbit controls from system'); - index = this.orbitControls.indexOf(data.component); - if (index === -1) { - console.warn('Failed to find the orbit controls in the system - probably it was ignored - ' + data.component.name); - return; - } + if (index !== -1) { - if (data.component.instance) { data.component.instance.dispose(); - } - this.orbitControls.splice(index, 1); - - this.setMode(); + this.orbitControls.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Input'); + } } }; @@ -629,214 +541,6 @@ R3.System.Input.prototype.registerMouseControl = function(mouseControl) { ); }; -/** - * Register all normal mode controls (Touch, Keyboard and Mouse) - */ -R3.System.Input.prototype.registerNormalModeControls = function() { - - this.touchControls.map( - function(touchControl){ - this.registerTouchControl(touchControl); - }.bind(this) - ); - - this.keyboardControls.map( - function(keyboardControl){ - this.registerKeyboardControl(keyboardControl); - }.bind(this) - ); - - this.mouseControls.map( - function(mouseControl){ - this.registerMouseControl(mouseControl); - }.bind(this) - ); -}; - -/** - * Register all edit mode controls - (Editor, Firs Person and Orbit) - */ -R3.System.Input.prototype.registerEditModeControls = function() { - - /** - * Right now - all edit mode controls happen to live in the namespace R3.Controls.D3 - * They are Editor, First Person and Orbit controls - */ - - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Controls.D3).map( - - function(control) { - - if (!control.canvas || !control.canvas.instance) { - console.warn('no canvas at time of registration of controls - are you sure you know what you are doing?'); - return; - } - - control.canvas.instance.addEventListener( - 'mousedown', - this.mouseDownEdit, - true - ); - - control.canvas.instance.addEventListener( - 'mousemove', - this.mouseMoveEdit, - true - ); - - control.canvas.instance.addEventListener( - 'keydown', - this.keyDownEdit, - true - ); - - control.canvas.instance.addEventListener( - 'keyup', - this.keyUpEdit, - true - ); - - /** - * The order of creation is important here - it changes the way the DOM reacts to events - */ - this.editorControls.map( - function(editorControl) { - editorControl.createInstance(); - } - ); - - this.orbitControls.map( - function(orbitControl) { - orbitControl.createInstance(); - } - ); - - this.firstPersonControls.map( - function(firstPersonControl) { - firstPersonControl.createInstance(); - } - ); - - /** - * We append the wheel controls after so we can update our camera information - */ - control.canvas.instance.addEventListener( - 'wheel', - this.mouseWheelEdit, - true - ); - - control.canvas.instance.addEventListener( - 'mouseup', - this.mouseUpEdit, - true - ); - - }.bind(this) - ); - -}; - -/** - * Remove all normal mode event listeners - */ -R3.System.Input.prototype.deRegisterNormalModeControls = function() { - this.touchControls.map( - function(touchControl){ - this.deRegisterTouchControl(touchControl); - }.bind(this) - ); - - this.keyboardControls.map( - function(keyboardControl){ - this.deRegisterKeyboardControl(keyboardControl); - }.bind(this) - ); - - this.mouseControls.map( - function(mouseControl){ - this.deRegisterMouseControl(mouseControl); - }.bind(this) - ); -}; - -R3.System.Input.prototype.deRegisterEditModeControls = function() { - - - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Controls.D3).map( - - function(control) { - - if (!control.canvas || !control.canvas.instance) { - console.warn('no canvas at time of registration of controls - are you sure you know what you are doing?'); - return; - } - - control.canvas.instance.removeEventListener( - 'mousedown', - this.mouseDownEdit, - true - ); - - control.canvas.instance.removeEventListener( - 'mousemove', - this.mouseMoveEdit, - true - ); - - control.canvas.instance.removeEventListener( - 'keydown', - this.keyDownEdit, - true - ); - - control.canvas.instance.removeEventListener( - 'keyup', - this.keyUpEdit, - true - ); - - this.editorControls.map( - function(editorControl) { - if (editorControl.instance) { - editorControl.instance.dispose(); - } - } - ); - - this.orbitControls.map( - function(orbitControl) { - if (orbitControl.instance) { - orbitControl.instance.dispose(); - } - } - ); - - this.firstPersonControls.map( - function(firstPersonControl) { - if (firstPersonControl.instance) { - firstPersonControl.instance.dispose(); - } - } - ); - - control.canvas.instance.removeEventListener( - 'wheel', - this.mouseWheelEdit, - true - ); - - control.canvas.instance.removeEventListener( - 'mouseup', - this.mouseUpEdit, - true - ); - - }.bind(this) - ); - -}; - R3.System.Input.prototype.deRegisterTouchControl = function(touchControl) { touchControl.canvas.instance.removeEventListener( @@ -881,7 +585,6 @@ R3.System.Input.prototype.deRegisterKeyboardControl = function(keyboardControl) }; - R3.System.Input.prototype.deRegisterMouseControl = function(mouseControl) { mouseControl.canvas.instance.removeEventListener( @@ -934,19 +637,6 @@ R3.System.Input.prototype.onKeyboardKeyDown = function(event) { R3.System.Input.prototype.onTouchStart = function(event) { - if (this.playAudio) { - - // var audio = new Audio('http://live-api-v1.cybafelo.com/uploads/cybafelo/root/root/test/dummy.mp3'); - // - // try { - // audio.play(); - // } catch (error) { - // console.log('could not load dummy audio'); - // } - - this.playAudio = false; - } - this.sensitivityCounter = 0; this.touches = {}; @@ -1150,7 +840,7 @@ R3.System.Input.prototype.onKeyDownEdit = function(event) { if (event.keyCode === R3.System.Input.KEY_DELETE) { - meshes = R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Mesh); + meshes = R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Mesh); var deletedMeshes = []; @@ -1188,7 +878,7 @@ R3.System.Input.prototype.onKeyDownEdit = function(event) { if (this.selectionMode === R3.System.Input.SELECTION_MODE_MESH) { - meshes = R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Mesh); + meshes = R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Mesh); meshes.map(function(mesh) { if (this.selectAll) { @@ -1284,7 +974,7 @@ R3.System.Input.prototype.onMouseDownEdit = function(event) { if (event.button === 2) { - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Controls.D3).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.D3).map( function(control) { @@ -1408,7 +1098,7 @@ R3.System.Input.prototype.onMouseMoveEdit = function(event) { } ); - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Controls.D3).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.D3).map( function(control) { control.camera.position.x = control.camera.instance.position.x; @@ -1444,7 +1134,7 @@ R3.System.Input.prototype.onMouseUpEdit = function(event) { */ R3.System.Input.prototype.onMouseWheelEdit = function(event) { - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Controls.D3).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.Controls.D3).map( function(control) { control.camera.position.x = control.camera.instance.position.x; diff --git a/src/r3-system-linking.js b/src/r3-system-linking.js index 3c1ea0e..95b93f2 100644 --- a/src/r3-system-linking.js +++ b/src/r3-system-linking.js @@ -161,9 +161,9 @@ R3.System.Linking.prototype.start = function() { }; R3.System.Linking.prototype.link = function(component, data) { - for (var property in component.linkedObjects) { - if (component.linkedObjects.hasOwnProperty(property)) { - if (component.linkedObjects[property] instanceof Array) { + for (var property in component.linkedComponents) { + if (component.linkedComponents.hasOwnProperty(property)) { + if (component.linkedComponents[property] instanceof Array) { var linked = []; diff --git a/src/r3-system-query.js b/src/r3-system-query.js index 8143ddd..865f2df 100644 --- a/src/r3-system-query.js +++ b/src/r3-system-query.js @@ -3,6 +3,11 @@ * @constructor */ R3.System.Query = function() { + + R3.System.call( + this + ); + this.querySubscription = null; }; @@ -12,7 +17,7 @@ R3.System.Query.prototype.constructor = R3.System.Query; R3.System.Query.prototype.start = function() { this.querySubscription = R3.Event.Subscribe( - R3.Event.QUERY, + R3.Event.INSTANCE_CREATED, this.query ); @@ -22,10 +27,20 @@ R3.System.Query.prototype.start = function() { /** - * - * @param query R3.Query + * Check for query instances - then run them + * @param component */ -R3.System.Query.prototype.query = function(query) { +R3.System.Query.prototype.query = function(data) { + + var query = null; + + if (data.component instanceof R3.Query) { + query = data.component; + } + + if (R3.Utils.UndefinedOrNull(query)) { + return; + } R3.Event.Emit( R3.Event.GET_USER, @@ -36,15 +51,38 @@ R3.System.Query.prototype.query = function(query) { null, function(data) { - query.data.size = query.size; + var queryText = query.text.slice(0); - var queryText = JSON.stringify(query); + if (R3.Utils.Defined(query.size)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_SIZE, "g"), query.size); + } - queryText = queryText.replace('QUERY_START', query.start); - queryText = queryText.replace('QUERY_END', query.end); + if (R3.Utils.Defined(query.start)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_START, "g"), query.start); + } + + if (R3.Utils.Defined(query.end)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_END, "g"), query.end); + } + + if (R3.Utils.Defined(query.timeZone)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_TIMEZONE, "g"), query.timeZone); + } + + if (R3.Utils.Defined(query.bucketField)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_BUCKET_FIELD, "g"), query.bucketField); + } + + if (R3.Utils.Defined(query.loginType)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_LOGIN_TYPE, "g"), query.loginType); + } + + if (R3.Utils.Defined(query.acknowledged)) { + queryText = queryText.replace(new RegExp(R3.API.Query.QUERY_ACKNOWLEDGED, "g"), query.acknowledged); + } if (typeof XMLHttpRequest === 'undefined') { - console.log('Implement server side delete here'); + console.log('Implement server side query here'); return; } @@ -62,6 +100,16 @@ R3.System.Query.prototype.query = function(query) { xhr.onload = function (event) { query.parse(JSON.parse(event.target.responseText)); + R3.Event.Emit( + R3.Event.QUERY_PARSED, + { + query : query + } + ) + }; + + xhr.onerror = function(error) { + console.error('An error occurred during query execution: ', error); }; xhr.send(queryText); diff --git a/src/r3-system-render.js b/src/r3-system-render.js index b555387..ddd4cd7 100644 --- a/src/r3-system-render.js +++ b/src/r3-system-render.js @@ -1,46 +1,24 @@ /** - * System takes care of updating all the entities (based on their component data) - * @param apiSystem R3.API.System + * R3.System.Render * @constructor */ -R3.System.Render = function( - apiSystem -) { +R3.System.Render = function() { R3.System.call( - this, - apiSystem + this ); - this.graphics = null; - - R3.Event.Emit( - R3.Event.GET_RUNTIME, - function(runtime) { - this.graphics = runtime.graphics; - }.bind(this) - ); - - if (R3.Utils.UndefinedOrNull(this.graphics)) { - throw new Error('Need a graphics runtime in order to create a Render System'); - } - - this.project = null; - - R3.Event.Emit( - R3.Event.GET_PROJECT, - function(project) { - this.project = project; - }.bind(this) - ); - - this.clock = new R3.Clock(this.graphics); - /** - * Stores the time delta sinc the last render - * @type {null} + * Hold reference to all projects + * @type {Array} */ - this.delta = null; + this.projects = []; + + /** + * Hold reference to all statistics + * @type {Array} + */ + // this.statistics = []; /** * This hook stores a reference to the current render frame - so we can break out of the render loop if needed @@ -48,23 +26,26 @@ R3.System.Render = function( */ this.animationFrameHook = null; + // this.scenes = []; + // + // this.cameras = []; + /** * Subscribe to some important events when this system starts * @type {null} */ - this.excludeFromEnvironmentMapMapSubscription = null; - this.removeComponentSubscription = null; - this.renderSubscription = null; - this.replaceComponentSubscription = null; this.textureUpdatedSubscription = null; this.windowResizeSubscription = null; - this.statistics = []; + this.instanceCreatedSubscription = null; + + this.queryParsedSubscription = null; + }; R3.System.Render.prototype = Object.create(R3.System.prototype); @@ -75,36 +56,47 @@ R3.System.Render.prototype.constructor = R3.System.Render; */ R3.System.Render.prototype.start = function() { - R3.System.prototype.start.call(this); - - this.removeComponentSubscription = this.subscribe( + this.removeComponentSubscription = R3.Event.Subscribe( R3.Event.REMOVE_COMPONENT, - this.removeComponent + this.removeComponent.bind(this) ); - this.renderSubscription = this.subscribe( - R3.Event.RENDER, - this.render - ); - - this.replaceComponentSubscription = this.subscribe( + this.replaceComponentSubscription = R3.Event.Subscribe( R3.Event.REPLACE_COMPONENT, - this.replaceComponent + this.replaceComponent.bind(this) ); - this.textureUpdatedSubscription = this.subscribe( + this.textureUpdatedSubscription = R3.Event.Subscribe( R3.Event.TEXTURE_INSTANCE_UPDATED, - this.textureUpdated + this.textureUpdated.bind(this) ); - this.windowResizeSubscription = this.subscribe( + this.windowResizeSubscription = R3.Event.Subscribe( R3.Event.WINDOW_RESIZE, - this.windowResize + this.windowResize.bind(this) ); - this.statistics = R3.EntityManager.Instance.queryComponents(R3.Component.STATS); + this.instanceCreatedSubscription = R3.Event.Subscribe( + R3.Event.INSTANCE_CREATED, + this.instanceCreated.bind(this) + ); - this.projects = R3.EntityManager.Instance.queryComponents(R3.Component.PROJECT); + this.queryParsedSubscription = R3.Event.Subscribe( + R3.Event.QUERY_PARSED, + this.queryParsed.bind(this) + ); + + this.graphs = R3.EntityManager.Instance.findComponentsByConstructor(R3.Graph); + + // this.cameras = R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Camera); + // + // this.scenes = R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Scene); + + // this.statistics = R3.EntityManager.Instance.queryComponents(R3.COMPONENT_STATS); + + this.projects = R3.EntityManager.Instance.findComponentsByConstructor(R3.Project); + + R3.System.prototype.start.call(this); this.run(); }; @@ -113,13 +105,54 @@ R3.System.Render.prototype.run = function() { this.animationFrameHook = requestAnimationFrame( this.run.bind(this) ); - this.delta = this.clock.getDelta(); + this.render(); +}; - R3.Event.Emit( - R3.Event.RENDER, - { - delta : this.delta - } +R3.System.Render.prototype.instanceCreated = function(data) { + + if (data.component instanceof R3.Graph) { + this.graphs.push(data.component); + } + + if (data.component instanceof R3.Project) { + this.projects.push(data.component); + } + // + // if (data.component instanceof R3.D3.Scene) { + // this.scenes.push(data.component); + // } + // + // if (data.component instanceof R3.D3.Camera) { + // this.cameras.push(data.component); + // } + +}; + +R3.System.Render.prototype.queryParsed = function(data) { + + this.graphs.map( + function(graph) { + if (graph.query === data.query) { + + if (graph instanceof R3.Graph.Table) { + + if ( + R3.Utils.UndefinedOrNull(data.query.columns) || + R3.Utils.UndefinedOrNull(data.query.rows) + ) { + console.warn('The parsed query is not formatted to allow it to be used to populate table data'); + return; + } + + graph.columns = data.query.columns; + graph.rows = data.query.rows; + graph.updateInstance('data'); + return; + } + + graph.updateInstance('query'); + } + }.bind(this) ); }; @@ -136,6 +169,12 @@ R3.System.Render.prototype.windowResize = function(data) { data ); + this.graphs.map( + function(graph) { + graph.updateInstance('size'); + }.bind(this) + ); + /** * Only resize elements relevant to the current projects */ @@ -189,15 +228,13 @@ R3.System.Render.prototype.windowResize = function(data) { } ); - - - R3.EntityManager.Instance.queryComponentsByConstructor(R3.Canvas).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.Canvas).map( function(canvas) { canvas.updateInstance('autoUpdateSize'); } ); - R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Camera).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Camera).map( function(camera){ if ( camera instanceof R3.D3.Camera.Orthographic && @@ -232,7 +269,7 @@ R3.System.Render.prototype.windowResize = function(data) { R3.System.Render.prototype.textureUpdated = function(data) { - R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Material).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Material).map( function(material) { material.getTextures().map( @@ -256,7 +293,7 @@ R3.System.Render.prototype.textureUpdated = function(data) { R3.System.Render.prototype.replaceComponent = function(data) { if (data.current instanceof R3.D3.Material) { - R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Mesh).map( + R3.EntityManager.Instance.findComponentsByConstructor(R3.D3.Mesh).map( function(mesh) { var index = mesh.materials.indexOf(data.current); @@ -351,6 +388,22 @@ R3.System.Render.prototype.removeComponent = function(data) { var index; + if (data.component instanceof R3.Project) { + + index = this.projects.indexOf(data.component); + + if (index !== -1) { + + console.log('Removing ' + R3.GetComponentName(data.component) + ' from R3.System.Render'); + + this.projects.splice(index, 1); + + } else { + console.log('Failed to remove ' + R3.GetComponentName(data.component) + ' from R3.System.Render'); + } + } + + // if (data.component instanceof R3.RenderConfiguration) { // // index = this.renderConfigurations.indexOf(data.component); @@ -373,61 +426,61 @@ R3.System.Render.prototype.removeComponent = function(data) { // } // } - if (data.component instanceof R3.Renderer) { + // if (data.component instanceof R3.Renderer) { + // + // index = this.renderers.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing renderer from system'); + // + // this.renderers.splice(index, 1); + // + // } else { + // console.log('failed to find the renderer in the system : ' + data.component.name); + // } + // } + // + // if (data.component instanceof R3.D3.Composer) { + // + // index = this.composers.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing composer from system'); + // + // this.composers.splice(index, 1); + // + // } else { + // console.log('failed to find the composer in the system : ' + data.component.name); + // } + // } - index = this.renderers.indexOf(data.component); - - if (index !== -1) { - console.log('removing renderer from system'); - - this.renderers.splice(index, 1); - - } else { - console.log('failed to find the renderer in the system : ' + data.component.name); - } - } - - if (data.component instanceof R3.D3.Composer) { - - index = this.composers.indexOf(data.component); - - if (index !== -1) { - console.log('removing composer from system'); - - this.composers.splice(index, 1); - - } else { - console.log('failed to find the composer in the system : ' + data.component.name); - } - } - - if (data.component instanceof R3.Stats) { - - index = this.statistics.indexOf(data.component); - - if (index !== -1) { - console.log('removing statistics from system'); - - this.statistics.splice(index, 1); - - } else { - console.log('failed to find the statistics in the system : ' + data.component.name); - } - } - - if (data.component instanceof R3.D3.Camera.Cube) { - - index = this.cubeCameras.indexOf(data.component); - - if (index !== -1) { - console.log('removing cube camera from system'); - - this.cubeCameras.splice(index, 1); - - } else { - console.log('failed to find the cube camera in the system : ' + data.component.name); - } - } + // if (data.component instanceof R3.Stats) { + // + // index = this.statistics.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing statistics from system'); + // + // this.statistics.splice(index, 1); + // + // } else { + // console.log('failed to find the statistics in the system : ' + data.component.name); + // } + // } + // + // if (data.component instanceof R3.D3.Camera.Cube) { + // + // index = this.cubeCameras.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing cube camera from system'); + // + // this.cubeCameras.splice(index, 1); + // + // } else { + // console.log('failed to find the cube camera in the system : ' + data.component.name); + // } + // } // if (data.component instanceof R3.AR) { // @@ -443,267 +496,280 @@ R3.System.Render.prototype.removeComponent = function(data) { // } // } - if (data.component instanceof R3.D3.Mesh) { - index = this.excludedFromEnvironment.indexOf(data.component); - if (index !== -1) { - console.log('removing excluded environment mesh from system'); - this.excludedFromEnvironment.splice(index, 1); - } - } + // if (data.component instanceof R3.D3.Mesh) { + // index = this.excludedFromEnvironment.indexOf(data.component); + // if (index !== -1) { + // console.log('removing excluded environment mesh from system'); + // this.excludedFromEnvironment.splice(index, 1); + // } + // } }; /** * Render subscription script */ -R3.System.Render.prototype.render = function(data) { +R3.System.Render.prototype.render = function() { - this.statistics.map( - function(statistics) { - statistics.start(); - } - ); + // this.statistics.map( + // function(statistics) { + // statistics.start(); + // } + // ); - R3.Event.Emit( - R3.Event.BEFORE_RENDER, - data - ); + this.projects.map( + function(project) { - /** - * TODO: implement 2D rendering - */ - if (renderer instanceof R3.Renderer.D2) { - console.log('TODO: implement 2D rendering'); - return; - } + R3.Event.Emit( + R3.Event.BEFORE_RENDER, + project + ); - this.project.renderers.map( + project.renderers.map( - function(renderer) { + function(renderer) { - if (!renderer.instance) { - console.warn('renderer not ready'); - return; - } - - var size = renderer.getSize(); - - renderer.viewports.map( - function (viewport) { - - if (!viewport.instance) { - console.warn('viewport not ready'); + if (!renderer.instance) { + console.warn('renderer not ready'); return; } - renderer.setViewport( - viewport.x * size.width, - viewport.y * size.height, - viewport.width * size.width, - viewport.height * size.height - ); - - var resetAutoClear = false; - if (viewport.scenes.length > 1) { - - if (renderer.autoClear) { - resetAutoClear = true; - } - - renderer.autoClear = false; - renderer.updateInstance('autoClear'); - - renderer.clear(); + if (renderer instanceof R3.Renderer.D2) { + renderer.instance.render(); + return; } - viewport.scenes.map( + var size = renderer.getSize(); - function (scene) { + renderer.viewports.map( + function (viewport) { - if (!scene.instance) { - console.warn('scene not ready'); + if (!viewport.instance) { + console.warn('viewport not ready'); return; } - /** - * Render textures first - */ - scene.cubeCameras.map( + renderer.instance.setViewport( + viewport.x * size.width, + viewport.y * size.height, + viewport.width * size.width, + viewport.height * size.height + ); - function(cubeCamera) { + // renderer.instance.setViewport( + // viewport.x, + // viewport.y, + // viewport.width, + // viewport.height + // ); - if (!cubeCamera.instance) { - console.warn('cube camera not ready'); + var resetAutoClear = false; + + if (viewport.scenes.length > 1) { + + if (renderer.autoClear) { + resetAutoClear = true; + } + + renderer.autoClear = false; + renderer.updateInstance('autoClear'); + + renderer.clear(); + } + + viewport.scenes.map( + + function (scene) { + + if (!scene.instance) { + console.warn('scene not ready'); return; } /** - * TODO: optimize this to add / remove meshes via Events to prevent looping through - * TODO: all of them to inspect their excludeFromEnvironmentMapMap settings - * @type {T | Array} + * Render textures first */ - var meshesExcluded = scene.meshes.reduce( - function(result, mesh){ - if (mesh.excludeFromEnvironmentMapMap) { - result.push(mesh) + scene.cubeCameras.map( + + function(cubeCamera) { + + if (!cubeCamera.instance) { + console.warn('cube camera not ready'); + return; } - return result; - }, - [] + + /** + * TODO: optimize this to add / remove meshes via Events to prevent looping through + * TODO: all of them to inspect their excludeFromEnvironmentMapMap settings + * @type {T | Array} + */ + var meshesExcluded = scene.meshes.reduce( + function(result, mesh){ + if (mesh.excludeFromEnvironmentMapMap) { + result.push(mesh) + } + return result; + }, + [] + ); + + meshesExcluded.map( + function(mesh){ + mesh.visible = false; + mesh.updateInstance('visible'); + } + ); + + cubeCamera.instance.update( + renderer.instance, + scene.instance + ); + + meshesExcluded.map( + function(mesh){ + mesh.visible = true; + mesh.updateInstance('visible'); + } + ); + + }.bind(this) + ); - meshesExcluded.map( - function(mesh){ - mesh.visible = false; - mesh.updateInstance('visible'); + var camera = null; + + if (project.applicationMode === R3.API.Project.APPLICATION_MODE_EDIT) { + camera = project.cameras[scene.cameraIndexEdit]; + } else { + camera = project.cameras[scene.cameraIndexRun]; + } + + if (!camera || !camera.instance) { + console.warn('camera not ready'); + return; + } + + if (scene.enableEffect) { + + if (!scene.effect) { + console.warn('enabling an effect when no effect is specified on the scene has no effect'); + return; } - ); - cubeCamera.instance.update( - renderer.instance, - scene.instance - ); - - meshesExcluded.map( - function(mesh){ - mesh.visible = true; - mesh.updateInstance('visible'); + if (scene.enableComposer) { + console.warn('only an effect or composer can be active at any given time'); + return; } + + if (!scene.effect.ready()) { + console.warn('the effect is not ready yet: ' + scene.effect.name); + } + + if (renderer.target) { + console.warn('todo: test if rendering effect to target works'); + + if (!scene.effect.instance) { + return; + } + + scene.effect.instance.render( + scene.instance, + camera.instance, + renderer.target.instance + ); + } + + if (!scene.effect.instance) { + return; + } + + scene.effect.instance.render( + scene.instance, + camera.instance + ); + + console.warn('todo: check if have to return from effect render here'); + //return; + + } + + if (scene.enableComposer) { + + if (!scene.composer) { + console.warn('enabling a composer when no composer is specified on the scene has no effect'); + return; + } + + if (!scene.composer.ready()) { + console.warn('the composer is not ready yet: ' + scene.composer.name); + } + + scene.composer.render(); + + console.warn('todo: check if have to return from composer render here'); + //return; + } + + if (renderer.target) { + + if (!render.target.instance) { + console.warn('render target instance not ready'); + } + + renderer.instance.render( + scene.instance, + camera.instance, + renderer.target.instance + ) + } + + camera.instance.updateProjectionMatrix(); + + renderer.instance.render( + scene.instance, + camera.instance ); + /** + * end of scene + */ }.bind(this) ); - var camera = null; - - if (this.applicationMode === R3.API.Project.APPLICATION_MODE_EDIT) { - camera = this.project.cameras[scene.cameraIndexEdit]; - } else { - camera = this.project.cameras[scene.cameraIndexRun]; + /** + * Restore the autoClear for the next render loop + */ + if (resetAutoClear) { + renderer.autoClear = true; + renderer.updateInstance('autoClear'); } - if (!camera || !camera.instance) { - console.warn('camera not ready'); - return; - } - - if (scene.enableEffect) { - - if (!scene.effect) { - console.warn('enabling an effect when no effect is specified on the scene has no effect'); - return; - } - - if (scene.enableComposer) { - console.warn('only an effect or composer can be active at any given time'); - return; - } - - if (!scene.effect.ready()) { - console.warn('the effect is not ready yet: ' + scene.effect.name); - } - - if (renderer.target) { - console.warn('todo: test if rendering effect to target works'); - - if (!scene.effect.instance) { - return; - } - - scene.effect.instance.render( - scene.instance, - camera.instance, - renderer.target.instance - ); - } - - if (!scene.effect.instance) { - return; - } - - scene.effect.instance.render( - scene.instance, - camera.instance - ); - - console.warn('todo: check if have to return from effect render here'); - //return; - - } - - if (scene.enableComposer) { - - if (!scene.composer) { - console.warn('enabling a composer when no composer is specified on the scene has no effect'); - return; - } - - if (!scene.composer.ready()) { - console.warn('the composer is not ready yet: ' + scene.composer.name); - } - - scene.composer.render(); - - console.warn('todo: check if have to return from composer render here'); - //return; - } - - if (renderer.target) { - - if (!render.target.instance) { - console.warn('render target instance not ready'); - } - - renderer.instance.render( - scene.instance, - camera.instance, - renderer.target.instance - ) - } - - renderer.instance.render( - scene.instance, - camera.instance - ); - /** - * end of scene + * end of viewport */ }.bind(this) - ); /** - * Restore the autoClear for the next render loop - */ - if (resetAutoClear) { - renderer.autoClear = true; - renderer.updateInstance('autoClear'); - } - - /** - * end of viewport + * end of renderer */ }.bind(this) + + ); + + R3.Event.Emit( + R3.Event.AFTER_RENDER, + project ); - /** - * end of renderer - */ }.bind(this) - ); - R3.Event.Emit( - R3.Event.AFTER_RENDER, - data - ); - - this.statistics.map( - function(statistics) { - statistics.end(); - } - ); + // this.statistics.map( + // function(statistics) { + // statistics.end(); + // } + // ); }; /** @@ -711,28 +777,27 @@ R3.System.Render.prototype.render = function(data) { */ R3.System.Render.prototype.stop = function() { - R3.System.prototype.stop.call(this); - cancelAnimationFrame(this.animationFrameHook); - this.excludeFromEnvironmentMapMapSubscription.remove(); - - this.instanceCreatedSubscription.remove(); - this.removeComponentSubscription.remove(); - this.renderSubscription.remove(); - this.replaceComponentSubscription.remove(); this.textureUpdatedSubscription.remove(); this.windowResizeSubscription.remove(); - this.renderers = []; + this.instanceCreatedSubscription.remove(); - this.statistics = []; + this.queryParsedSubscription.remove(); + + this.graphs = []; + + // this.renderers = []; + // + // this.statistics = []; + + R3.System.prototype.stop.call(this); - this.excludedFromEnvironment = []; }; diff --git a/src/r3-system-storage.js b/src/r3-system-storage.js index e455554..0303e6e 100644 --- a/src/r3-system-storage.js +++ b/src/r3-system-storage.js @@ -1,66 +1,31 @@ /** - * Storage System takes care loading and linking components and dependencies - * @param apiSystem R3.API.System - * @param token - * @param apiUploadUrl - * @param onImageLoaded - * @param onImageProgress - * @param onImageError + * R3.System.Storage * @constructor */ -R3.System.Storage = function( - apiSystem, - token, - apiUploadUrl, - onImageLoaded, - onImageProgress, - onImageError -) { +R3.System.Storage = function() { + R3.System.call( - this, - apiSystem + this ); - if (R3.Utils.UndefinedOrNull(token)) { - token = null; - } - this.token = token; + this.loaded = []; + this.loading = []; + this.failed = []; + this.apiUserToken = 'none'; - if (R3.Utils.UndefinedOrNull(apiUploadUrl)) { - console.warn('Need an API Upload URL for a storage system'); - apiUploadUrl = ''; - } - this.apiUploadUrl = apiUploadUrl; + this.loadSubscription = null; + this.signInSubscription = null; + this.signOutSubscription = null; - if (R3.Utils.UndefinedOrNull(onImageLoaded)) { - onImageLoaded = null; - } - this.onImageLoaded = onImageLoaded; + // this.otherDependencies = []; - if (R3.Utils.UndefinedOrNull(onImageProgress)) { - onImageProgress = null; - } - this.onImageProgress = onImageProgress; - - if (R3.Utils.UndefinedOrNull(onImageError)) { - onImageError = null; - } - this.onImageError = onImageError; - - this.loaded = []; - this.loading = []; - this.failed = []; - this.otherDependencies = []; - - this.loginSubscription = null; - this.saveSubscription = null; - this.loadSubscription = null; - this.loadImageSubscription = null; - this.blenderDataSubscription = null; - this.imageUploadCompleteSubscription = null; - - this.fetchComponentTypesSubscription = null; - this.fetchComponentsSubscription = null; + // this.saveSubscription = null; + // this.loadImageSubscription = null; + // this.blenderDataSubscription = null; + // this.imageUploadCompleteSubscription = null; + // + // this.fetchComponentTypesSubscription = null; + // this.fetchComponentsSubscription = null; }; R3.System.Storage.prototype = Object.create(R3.System.prototype); @@ -68,60 +33,158 @@ R3.System.Storage.prototype.constructor = R3.System.Storage; R3.System.Storage.prototype.start = function() { + this.signInSubscription = R3.Event.Subscribe( + R3.Event.SIGN_IN, + this.signIn.bind(this) + ); + + this.signOutSubscription = R3.Event.Subscribe( + R3.Event.SIGN_OUT, + this.signOut.bind(this) + ); + + this.loadSubscription = R3.Event.Subscribe( + R3.Event.LOAD_COMPONENT, + this.load.bind(this) + ); + + // this.saveSubscription = this.subscribe( + // R3.Event.SAVE_COMPONENT, + // this.save + // ); + // + // this.loadSubscription = this.subscribe( + // R3.Event.LOAD_COMPONENT, + // this.load + // ); + // + // this.deleteSubscription = this.subscribe( + // R3.Event.DELETE_COMPONENT, + // this.delete + // ); + // + // this.loadImageSubscription = this.subscribe( + // R3.Event.LOAD_IMAGE, + // this.loadImage + // ); + // + // this.loadFontSubscription = this.subscribe( + // R3.Event.LOAD_FONT, + // this.loadFont + // ); + // + // this.blenderDataSubscription = this.subscribe( + // R3.Event.BLENDER_DATA_RECEIVED, + // this.processBlenderData + // ); + // + // this.imageUploadCompleteSubscription = this.subscribe( + // R3.Event.IMAGE_UPLOAD_COMPLETE, + // this.imageUploadComplete + // ); + // + // this.fetchComponentTypesSubscription = this.subscribe( + // R3.Event.FETCH_COMPONENT_TYPES, + // this.fetchComponentTypes + // ); + // + // this.fetchComponentsSubscription = this.subscribe( + // R3.Event.FETCH_COMPONENTS, + // this.fetchComponents + // ); + R3.System.prototype.start.call(this); - this.loginSubscription = this.subscribe( - R3.Event.LOGGED_IN, - function(data) { - this.token = data.token; - } - ); +}; - this.saveSubscription = this.subscribe( - R3.Event.SAVE_COMPONENT, - this.save - ); +R3.System.Storage.prototype.signIn = function(data, callback) { - this.loadSubscription = this.subscribe( - R3.Event.LOAD_COMPONENT, - this.load - ); + var id_token = data.user.getAuthResponse().id_token; - this.deleteSubscription = this.subscribe( - R3.Event.DELETE_COMPONENT, - this.delete + var profile = data.user.getBasicProfile(); + + var apiUrl = null; + var apiAuthorization = null; + + R3.Event.Emit( + R3.Event.GET_API_URL, + null, + function(data) { + apiUrl = data.apiUrl; + apiAuthorization = data.apiAuthorization + } ); - this.loadImageSubscription = this.subscribe( - R3.Event.LOAD_IMAGE, - this.loadImage + /** + * Now send the token to our API + */ + var xhr = new XMLHttpRequest(); + xhr.open('POST', apiUrl + '/user/signIn'); + + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.setRequestHeader("x-api-authorization", apiAuthorization); + xhr.setRequestHeader('x-api-user-token', this.apiUserToken); + + xhr.onload = function() { + + var response = JSON.parse(xhr.responseText); + + if (xhr.status === 200) { + this.apiUserToken = response.api_user_token; + } + + callback(response); + }.bind(this); + xhr.send(JSON.stringify( + { + id : profile.getId(), + id_token : id_token, + full_name : profile.getName(), + given_name : profile.getGivenName(), + family_name : profile.getFamilyName(), + image_url : profile.getImageUrl(), + email : profile.getEmail() + } + )); +}; + +R3.System.Storage.prototype.signOut = function(data, callback) { + + var apiUrl = null; + var apiAuthorization = null; + + R3.Event.Emit( + R3.Event.GET_API_URL, + null, + function(data) { + apiUrl = data.apiUrl; + apiAuthorization = data.apiAuthorization + } ); - this.loadFontSubscription = this.subscribe( - R3.Event.LOAD_FONT, - this.loadFont - ); + /** + * Now send the token to our API + */ + var xhr = new XMLHttpRequest(); + xhr.open('POST', apiUrl + '/user/signOut'); - this.blenderDataSubscription = this.subscribe( - R3.Event.BLENDER_DATA_RECEIVED, - this.processBlenderData - ); + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.setRequestHeader("x-api-authorization", apiAuthorization); + xhr.setRequestHeader('x-api-user-token', this.apiUserToken); - this.imageUploadCompleteSubscription = this.subscribe( - R3.Event.IMAGE_UPLOAD_COMPLETE, - this.imageUploadComplete - ); + xhr.onload = function() { - this.fetchComponentTypesSubscription = this.subscribe( - R3.Event.FETCH_COMPONENT_TYPES, - this.fetchComponentTypes - ); + var response = JSON.parse(xhr.responseText); - this.fetchComponentsSubscription = this.subscribe( - R3.Event.FETCH_COMPONENTS, - this.fetchComponents - ); + if (xhr.status === 200) { + this.apiUserToken = null; + } + callback(response); + }.bind(this); + xhr.send(); }; @@ -982,17 +1045,23 @@ R3.System.Storage.prototype.loadImage = function(data, callback, errorCallback) R3.System.Storage.prototype.stop = function() { + this.signInSubscription.remove(); + this.loadSubscription.remove(); + this.signOutSubscription.remove(); + + this.loaded = []; + this.failed = []; + this.loading = []; + R3.System.prototype.stop.call(this); - this.loginSubscription.remove(); - this.loadSubscription.remove(); - this.saveSubscription.remove(); - this.loadImageSubscription.remove(); - this.loadFontSubscription.remove(); - this.blenderDataSubscription.remove(); - this.imageUploadCompleteSubscription.remove(); - this.deleteSubscription.remove(); - this.fetchComponentTypesSubscription.remove(); - this.fetchComponentsSubscription.remove(); + // this.saveSubscription.remove(); + // this.loadImageSubscription.remove(); + // this.loadFontSubscription.remove(); + // this.blenderDataSubscription.remove(); + // this.imageUploadCompleteSubscription.remove(); + // this.deleteSubscription.remove(); + // this.fetchComponentTypesSubscription.remove(); + // this.fetchComponentsSubscription.remove(); }; diff --git a/src/r3-vector2.js b/src/r3-vector2.js index a08143a..88c14e7 100644 --- a/src/r3-vector2.js +++ b/src/r3-vector2.js @@ -26,7 +26,9 @@ R3.Vector2.prototype.constructor = R3.Vector2; */ R3.Vector2.prototype.createInstance = function() { - switch (this.parent.runtime) { + var runtime = R3.Component.GetComponentRuntime(this.parent); + + switch (runtime) { case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector2( this.x, @@ -40,7 +42,7 @@ R3.Vector2.prototype.createInstance = function() { ); break; default: - throw new Error('unhandled component runtime: ' + this.componentRuntime); + throw new Error('unhandled component runtime: ' + runtime); } __CREATE_INSTANCE__; diff --git a/src/r3-vector3.js b/src/r3-vector3.js index 64374c6..bc8a7ab 100644 --- a/src/r3-vector3.js +++ b/src/r3-vector3.js @@ -27,7 +27,9 @@ R3.Vector3.prototype.constructor = R3.Vector3; */ R3.Vector3.prototype.createInstance = function() { - switch (this.parent.runtime) { + var runtime = R3.Component.GetComponentRuntime(this.parent); + + switch (runtime) { case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector3( this.x, @@ -43,7 +45,7 @@ R3.Vector3.prototype.createInstance = function() { ); break; default: - throw new Error('unhandled component runtime: ' + this.componentRuntime); + throw new Error('unhandled component runtime: ' + runtime); } __CREATE_INSTANCE__; diff --git a/src/r3-vector4.js b/src/r3-vector4.js index 2eb0827..934d83d 100644 --- a/src/r3-vector4.js +++ b/src/r3-vector4.js @@ -28,7 +28,9 @@ R3.Vector4.prototype.constructor = R3.Vector4; */ R3.Vector4.prototype.createInstance = function() { - switch (this.parent.runtime) { + var runtime = R3.Component.GetComponentRuntime(this.parent); + + switch (runtime) { case R3.Runtime.GRAPHICS : this.instance = this.graphics.Vector4( this.x, @@ -46,7 +48,7 @@ R3.Vector4.prototype.createInstance = function() { ); break; default: - throw new Error('unhandled component runtime: ' + this.componentRuntime); + throw new Error('unhandled component runtime: ' + runtime); } __CREATE_INSTANCE__; diff --git a/todo/soc-query-alert-list.js b/todo/soc-query-alert-list.js index 3aac9a4..714cebe 100644 --- a/todo/soc-query-alert-list.js +++ b/todo/soc-query-alert-list.js @@ -43,8 +43,8 @@ SOC.Query.AlertList = function( "range": { "timestamp": { "format": "strict_date_optional_time", - "gte": "%QUERY_START", - "lt": "%QUERY_END" + "gte": "", + "lt": "" } } } diff --git a/todo/soc-query.js b/todo/soc-query.js index 8a83bcd..ad517c0 100644 --- a/todo/soc-query.js +++ b/todo/soc-query.js @@ -87,18 +87,6 @@ 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%'}); } };