From 4b1a6c0330e50e339eb7127dee6c2f41234fb684 Mon Sep 17 00:00:00 2001 From: cybafelo Date: Thu, 18 Jul 2019 21:55:04 +0200 Subject: [PATCH] google-login --- src/r3-a-1-event.js | 2 + src/r3-a-component-a.js | 48 +-- src/r3-api-controls-0.js | 7 +- src/r3-api-controls-d3-editor.js | 2 +- src/r3-api-controls-d3-first-person.js | 2 +- src/r3-api-controls-d3-orbit.js | 2 +- src/r3-api-render-configuration.js | 31 +- src/r3-api-renderer-a.js | 12 + src/r3-api-renderer-d3.js | 15 +- src/r3-d3-api-a-object.js | 14 +- src/r3-d3-api-camera-stereo-a.js | 40 -- src/r3-d3-camera-stereo.js | 87 ---- src/r3-entity.js | 14 + src/r3-system-render.js | 526 +++++++++++-------------- 14 files changed, 304 insertions(+), 498 deletions(-) delete mode 100644 src/r3-d3-api-camera-stereo-a.js delete mode 100644 src/r3-d3-camera-stereo.js diff --git a/src/r3-a-1-event.js b/src/r3-a-1-event.js index 8e65b64..55eb946 100644 --- a/src/r3-a-1-event.js +++ b/src/r3-a-1-event.js @@ -136,6 +136,7 @@ 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; /** * Returns string name of event ID @@ -267,6 +268,7 @@ R3.Event.GetEventName = function(number) { case 0x77 : return 'get_default_scene'; case 0x78 : return 'get_default_camera'; case 0x79 : return 'get_websocket_config'; + case 0x7a : return 'get_project'; break; } diff --git a/src/r3-a-component-a.js b/src/r3-a-component-a.js index ccca8fe..2820f62 100644 --- a/src/r3-a-component-a.js +++ b/src/r3-a-component-a.js @@ -325,7 +325,7 @@ R3.Component.AUDIO = 0x55; R3.Component.SYSTEM_AUDIO = 0x56; R3.Component.SOCKET_CAST = 0x57; R3.Component.CAMERA_ORTHOGRAPHIC = 0x58; -R3.Component.CAMERA_STEREO = 0x59; +R3.Component.CAMERA_PERSPECTIVE_STEREO = 0x59; R3.Component.CAMERA_CUBE = 0x5a; R3.Component.SHADOW = 0x5b; R3.Component.RENDER_TARGET_CUBE = 0x5c; @@ -407,9 +407,10 @@ R3.Component.GEOMETRY_BUFFER_INSTANCED = 0xa1; R3.Component.MATERIAL_SHADER_RAW = 0xa2; R3.Component.MATERIAL_POINTS = 0xa3; R3.Component.VIDEO = 0xa4; -R3.Component.AR = 0xa5; +R3.Component.USER = 0xa5; +R3.Component.PROJECT = 0xa6; -R3.Component.MAX_COMPONENTS = 0xa6; +R3.Component.MAX_COMPONENTS = 0xa7; R3.Component.GRAPHICS_RUNTIME = 0x1; R3.Component.PHYSICS_RUNTIME = 0x2; @@ -418,7 +419,6 @@ R3.Component.STATISTICS_RUNTIME = 0x4; R3.Component.DEFAULT_RUNTIME = 0x5; R3.Component.GUI_RUNTIME = 0x6; R3.Component.CODER_RUNTIME = 0x7; -R3.Component.AUGMENTED_RUNTIME = 0x8; R3.Component.GetCompentTypes = function(constructor) { @@ -960,10 +960,10 @@ R3.Component.GetComponentInfo = function(number) { apiConstructor : R3.D3.API.Camera.Orthographic }; case 0x59 : return { - name : 'R3.D3.Camera.Stereo', + name : 'R3.D3.Camera.Perspective.Stereo', runtime : R3.Component.GRAPHICS_RUNTIME, - constructor : R3.D3.Camera.Stereo, - apiConstructor : R3.D3.API.Camera.Stereo + constructor : R3.D3.Camera.Perspective.Stereo, + apiConstructor : R3.D3.API.Camera.Perspective.Stereo }; case 0x5a : return { name : 'R3.D3.Camera.Cube', @@ -1416,10 +1416,16 @@ R3.Component.GetComponentInfo = function(number) { apiConstructor : R3.API.Video }; case 0xa5 : return { - name : 'R3.AR', - runtime : R3.Component.AUGMENTED_RUNTIME, - constructor : R3.AR, - apiConstructor : R3.API.AR + name : 'R3.User', + runtime : R3.Component.DEFAULT_RUNTIME, + constructor : R3.User, + apiConstructor : R3.API.User + }; + case 0xa6 : return { + name : 'R3.Project', + runtime : R3.Component.DEFAULT_RUNTIME, + constructor : R3.Project, + apiConstructor : R3.API.Project }; break; } @@ -1459,10 +1465,6 @@ R3.Component.GetRuntimeName = function(runtime) { return 'Coder'; } - if (runtime === R3.Component.AUGMENTED_RUNTIME) { - return 'Augmented'; - } - return 'Default'; }; @@ -1972,15 +1974,6 @@ R3.Component.GetRuntimeObject = function(runtimeInfo) { return runtime.statistics; - } else if (runtimeInfo === R3.Component.AUGMENTED_RUNTIME) { - - if (R3.Utils.UndefinedOrNull(runtime.augmented)) { - console.warn('no augmented runtime'); - return null; - } - - return runtime.augmented; - } else if (runtimeInfo === R3.Component.DEFAULT_RUNTIME) { } else { @@ -2010,13 +2003,6 @@ R3.Component.ConstructFromObject = function(rawComponentObject) { var runtimeComponent = null; - // if ( - // rawComponentObject.componentType === 34 && - // rawComponentObject.name.indexOf('Mesh') !== -1 - // ) { - // rawComponentObject.componentType = 7; - // } - var info = R3.Component.GetComponentInfo(rawComponentObject.componentType); var runtime = R3.Component.GetRuntimeObject(info.runtime); diff --git a/src/r3-api-controls-0.js b/src/r3-api-controls-0.js index 2e70b4a..8995ccd 100644 --- a/src/r3-api-controls-0.js +++ b/src/r3-api-controls-0.js @@ -100,8 +100,6 @@ R3.API.Controls.GetComponentType = function(controlsType) { return componentType; }; -R3.API.Controls.D3 = function() {}; - /** * Controls Type * @type {number} @@ -113,3 +111,8 @@ R3.API.Controls.CONTROLS_TYPE_MOUSE = 0x3; R3.API.Controls.CONTROLS_TYPE_EDITOR = 0x4; R3.API.Controls.CONTROLS_TYPE_FIRST_PERSON = 0x5; R3.API.Controls.CONTROLS_TYPE_ORBIT = 0x6; + + +R3.API.Controls.D3 = function() {}; +R3.API.Controls.D3.prototype = Object.create(R3.API.Controls.prototype); +R3.API.Controls.D3.prototype.constructor = R3.API.Controls.D3; \ No newline at end of file diff --git a/src/r3-api-controls-d3-editor.js b/src/r3-api-controls-d3-editor.js index 086ef11..18ed523 100644 --- a/src/r3-api-controls-d3-editor.js +++ b/src/r3-api-controls-d3-editor.js @@ -40,5 +40,5 @@ R3.API.Controls.D3.Editor = function( ); }; -R3.API.Controls.D3.Editor.prototype = Object.create(R3.API.Controls.prototype); +R3.API.Controls.D3.Editor.prototype = Object.create(R3.API.Controls.D3.prototype); R3.API.Controls.D3.Editor.prototype.constructor = R3.API.Controls.D3.Editor; diff --git a/src/r3-api-controls-d3-first-person.js b/src/r3-api-controls-d3-first-person.js index 6822d19..f8a2cb9 100644 --- a/src/r3-api-controls-d3-first-person.js +++ b/src/r3-api-controls-d3-first-person.js @@ -132,5 +132,5 @@ R3.API.Controls.D3.FirstPerson = function( ); }; -R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.prototype); +R3.API.Controls.D3.FirstPerson.prototype = Object.create(R3.API.Controls.D3.prototype); R3.API.Controls.D3.FirstPerson.prototype.constructor = R3.API.Controls.D3.FirstPerson; diff --git a/src/r3-api-controls-d3-orbit.js b/src/r3-api-controls-d3-orbit.js index 38c39a1..c6eb30f 100644 --- a/src/r3-api-controls-d3-orbit.js +++ b/src/r3-api-controls-d3-orbit.js @@ -143,5 +143,5 @@ R3.API.Controls.D3.Orbit = function( ); }; -R3.API.Controls.D3.Orbit.prototype = Object.create(R3.API.Controls.prototype); +R3.API.Controls.D3.Orbit.prototype = Object.create(R3.API.Controls.D3.prototype); R3.API.Controls.D3.Orbit.prototype.constructor = R3.API.Controls.D3.Orbit; diff --git a/src/r3-api-render-configuration.js b/src/r3-api-render-configuration.js index 8fc7921..25a4a76 100644 --- a/src/r3-api-render-configuration.js +++ b/src/r3-api-render-configuration.js @@ -21,18 +21,7 @@ R3.API.RenderConfiguration = function ( id, name, parentEntity, - logicalSize, - aspectRatio, - scaleMode, - activeCamera, - activeScene, - activeScenes, - activeRenderer, - activeComposer, - activeEffect, - enableComposer, - enableEffect, - defaultMode + ) { if (R3.Utils.UndefinedOrNull(id)) { id = R3.Utils.RandomId(); @@ -102,10 +91,7 @@ R3.API.RenderConfiguration = function ( } this.enableEffect = enableEffect; - if (R3.Utils.UndefinedOrNull(defaultMode)) { - defaultMode = R3.API.RenderConfiguration.DEFAULT_MODE_IN_GAME; - } - this.defaultMode = defaultMode; + R3.API.Component.call( this, @@ -118,17 +104,4 @@ R3.API.RenderConfiguration = function ( R3.API.RenderConfiguration.prototype = Object.create(R3.API.Component.prototype); R3.API.RenderConfiguration.prototype.constructor = R3.API.RenderConfiguration; -R3.API.RenderConfiguration.ASPECT_RATIO_NONE = 0x1; -R3.API.RenderConfiguration.ASPECT_RATIO_4_3 = 0x2; -R3.API.RenderConfiguration.ASPECT_RATIO_3_2 = 0x3; -R3.API.RenderConfiguration.ASPECT_RATIO_16_10 = 0x4; -R3.API.RenderConfiguration.ASPECT_RATIO_17_10 = 0x5; -R3.API.RenderConfiguration.ASPECT_RATIO_16_9 = 0x6; -R3.API.RenderConfiguration.SCALE_MODE_NONE = 0x1; -R3.API.RenderConfiguration.SCALE_MODE_LETTERBOX = 0x2; -R3.API.RenderConfiguration.SCALE_MODE_ZOOM_TO_BIGGER = 0x3; -R3.API.RenderConfiguration.SCALE_MODE_NON_UNIFORM = 0x4; - -R3.API.RenderConfiguration.DEFAULT_MODE_IN_GAME = 0x1; -R3.API.RenderConfiguration.DEFAULT_MODE_EDIT = 0x2; diff --git a/src/r3-api-renderer-a.js b/src/r3-api-renderer-a.js index 95dbda3..f6f201b 100644 --- a/src/r3-api-renderer-a.js +++ b/src/r3-api-renderer-a.js @@ -120,3 +120,15 @@ R3.API.Renderer.TONE_MAPPING_LINEAR = 1; R3.API.Renderer.TONE_MAPPING_REINHARD = 2; R3.API.Renderer.TONE_MAPPING_UNCHARTED_2 = 3; R3.API.Renderer.TONE_MAPPING_CINEON = 4; + +R3.API.Renderer.ASPECT_RATIO_NONE = 0x1; +R3.API.Renderer.ASPECT_RATIO_4_3 = 0x2; +R3.API.Renderer.ASPECT_RATIO_3_2 = 0x3; +R3.API.Renderer.ASPECT_RATIO_16_10 = 0x4; +R3.API.Renderer.ASPECT_RATIO_17_10 = 0x5; +R3.API.Renderer.ASPECT_RATIO_16_9 = 0x6; + +R3.API.Renderer.SCALE_MODE_NONE = 0x1; +R3.API.Renderer.SCALE_MODE_LETTERBOX = 0x2; +R3.API.Renderer.SCALE_MODE_ZOOM_TO_BIGGER = 0x3; +R3.API.Renderer.SCALE_MODE_NON_UNIFORM = 0x4; diff --git a/src/r3-api-renderer-d3.js b/src/r3-api-renderer-d3.js index 6458000..009a646 100644 --- a/src/r3-api-renderer-d3.js +++ b/src/r3-api-renderer-d3.js @@ -35,6 +35,14 @@ * @param viewports * @param alpha * @param opacity + * @param logicalSize + * @param aspectRatio + * @param scaleMode + * @param scenes + * @param composers + * @param effects + * @param enableComposer + * @param enableEffects * @constructor */ R3.API.Renderer.D3 = function ( @@ -72,7 +80,12 @@ R3.API.Renderer.D3 = function ( clearColor, viewports, alpha, - opacity + opacity, + scenes, + composers, + effect, + enableComposer, + enableEffect ) { if (R3.Utils.UndefinedOrNull(apiRenderer)) { diff --git a/src/r3-d3-api-a-object.js b/src/r3-d3-api-a-object.js index 43679fa..5c313e6 100644 --- a/src/r3-d3-api-a-object.js +++ b/src/r3-d3-api-a-object.js @@ -56,7 +56,7 @@ R3.D3.API.Object = function( case R3.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE : name = 'Camera Cube'; break; - case R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO : + case R3.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE_STEREO : name = 'Camera Stereo'; break; /** @@ -143,7 +143,7 @@ R3.D3.API.Object.GetComponentType = function(objectType) { componentType = R3.Component.CAMERA_ORTHOGRAPHIC; break; case R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO : - componentType = R3.Component.CAMERA_STEREO; + componentType = R3.Component.CAMERA_PERSPECTIVE_STEREO; break; case R3.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE : componentType = R3.Component.CAMERA_CUBE; @@ -173,11 +173,11 @@ R3.D3.API.Object.OBJECT_TYPE_NONE = 0x0; * Cameras * @type {number} */ -R3.D3.API.Object.OBJECT_TYPE_CAMERA = 0x11; -R3.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE = 0x12;//0x1; -R3.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC = 0x13;//0x2; -R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO = 0x14;//0x3; -R3.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE = 0x15;//0x4; +R3.D3.API.Object.OBJECT_TYPE_CAMERA = 0x11; +R3.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE = 0x12;//0x1; +R3.D3.API.Object.OBJECT_TYPE_CAMERA_ORTHOGRAPHIC = 0x13;//0x2; +R3.D3.API.Object.OBJECT_TYPE_CAMERA_PERSPECTIVE_STEREO = 0x14;//0x3; +R3.D3.API.Object.OBJECT_TYPE_CAMERA_CUBE = 0x15;//0x4; /** * Meshes diff --git a/src/r3-d3-api-camera-stereo-a.js b/src/r3-d3-api-camera-stereo-a.js deleted file mode 100644 index dad747a..0000000 --- a/src/r3-d3-api-camera-stereo-a.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * R3.D3.API.Camera.Stereo - * @constructor - * @param apiD3ObjectCamera - * @param stereoMode - */ -R3.D3.API.Camera.Stereo = function( - apiD3ObjectCamera, - stereoMode -) { - - if (R3.Utils.UndefinedOrNull(apiD3ObjectCamera)) { - apiD3ObjectCamera = { - objectType : R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO - }; - } - - if (R3.Utils.UndefinedOrNull(apiD3ObjectCamera.objectType)) { - apiD3ObjectCamera.objectType = R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO; - } - - - if (R3.Utils.UndefinedOrNull(stereoMode)) { - stereoMode = R3.D3.API.Camera.Stereo.STEREO_MODE_STEREO; - } - this.stereoMode = stereoMode; - - R3.D3.API.Camera.call( - this, - apiD3ObjectCamera, - apiD3ObjectCamera.aspect - ); -}; - -R3.D3.API.Camera.Stereo.prototype = Object.create(R3.D3.API.Camera.prototype); -R3.D3.API.Camera.Stereo.prototype.constructor = R3.D3.API.Camera.Stereo; - -R3.D3.API.Camera.Stereo.STEREO_MODE_STEREO = 0x1; -R3.D3.API.Camera.Stereo.STEREO_MODE_ANAGLYPH = 0x2; -R3.D3.API.Camera.Stereo.STEREO_MODE_PARALLAX = 0x3; diff --git a/src/r3-d3-camera-stereo.js b/src/r3-d3-camera-stereo.js deleted file mode 100644 index c6b7f4a..0000000 --- a/src/r3-d3-camera-stereo.js +++ /dev/null @@ -1,87 +0,0 @@ -/** - * R3.D3.Camera.Stereo - * @param graphics R3.GraphicsRuntime - * @param apiD3ObjectStereoCamera - * @constructor - */ -R3.D3.Camera.Stereo = function( - graphics, - apiD3ObjectStereoCamera -) { - - this.graphics = graphics; - this.graphics.isNotThreeThrow(); - - if (R3.Utils.UndefinedOrNull(apiD3ObjectStereoCamera)) { - apiD3ObjectStereoCamera = { - objectType : R3.D3.API.Object.OBJECT_TYPE_CAMERA_STEREO - }; - } - - R3.D3.API.Camera.Stereo.call( - this, - apiD3ObjectStereoCamera, - apiD3ObjectStereoCamera.stereoMode - ); - - R3.D3.Camera.call( - this, - this.graphics, - this - ); - -}; - -R3.D3.Camera.Stereo.prototype = Object.create(R3.D3.Camera.prototype); -R3.D3.Camera.Stereo.prototype.constructor = R3.D3.Camera.Stereo; - -/** - * Creates a camera instance - * @returns {*} - */ -R3.D3.Camera.Stereo.prototype.createInstance = function() { - - this.instance = new THREE.PerspectiveCamera(); - - var instance = new THREE.StereoCamera(); - - for (var property in instance) { - if ( - instance.hasOwnProperty(property) || - typeof instance[property] === 'function' - ) { - this.instance[property] = instance[property]; - } - } - - R3.D3.Camera.prototype.createInstance.call(this); -}; - -/** - * Updates the instance with the current state - */ -R3.D3.Camera.Stereo.prototype.updateInstance = function(property) { - - if (property === 'stereoMode') { - console.warn('todo: update stereo mode'); - return; - } - - R3.D3.Camera.prototype.updateInstance.call(this, property); -}; - -/** - * Converts a R3.D3.Camera to a R3.D3.API.Camera - * @returns {R3.D3.API.Camera} - */ -R3.D3.Camera.Stereo.prototype.toApiObject = function() { - - var apiCamera = R3.D3.Camera.prototype.toApiObject.call(this); - - var apiStereoCamera = new R3.D3.API.Camera.Stereo( - apiCamera, - this.stereoMode - ); - - return apiStereoCamera; -}; diff --git a/src/r3-entity.js b/src/r3-entity.js index f95117b..4a37aad 100644 --- a/src/r3-entity.js +++ b/src/r3-entity.js @@ -30,6 +30,20 @@ R3.Entity = function ( this.idRegister = {}; + var components = []; + + this.components.map( + function (component) { + if (component instanceof R3.API.Component) { + components.push(R3.Component.ConstructFromObject(component)); + } else { + components.push(component) + } + } + ); + + this.components = components; + R3.Component.call( this, { diff --git a/src/r3-system-render.js b/src/r3-system-render.js index f7270fb..2dc801b 100644 --- a/src/r3-system-render.js +++ b/src/r3-system-render.js @@ -5,8 +5,7 @@ * @constructor */ R3.System.Render = function( - apiSystem, - graphicsRuntime + apiSystem ) { R3.System.call( @@ -14,36 +13,68 @@ R3.System.Render = function( apiSystem ); + 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} + */ + this.delta = null; + + /** + * This hook stores a reference to the current render frame - so we can break out of the render loop if needed + * @type {null} + */ + this.animationFrameHook = null; + + /** + * Subscribe to some important events when this system starts + * @type {null} + */ + this.excludeFromEnvironmentSubscription = null; + + this.instanceCreatedSubscription = null; + + this.removeComponentSubscription = null; + this.renderSubscription = null; this.replaceComponentSubscription = null; - this.clock = new R3.Clock(graphicsRuntime); - - this.delta = null; - - this.animationFrameHook = null; - - this.activeRenderConfiguration = null; - - this.excludeFromEnvironmentSubscription = null; - - this.shaderUpdateSubscription = null; - - /** - * Images - */ this.textureUpdatedSubscription = null; - this.renderConfigurations = []; - - this.renderers = []; - - this.composers = []; + this.windowResizeSubscription = null; this.statistics = []; - this.cubeCameras = []; + this.excludedFromEnvironment = []; + + /** + * Get a handle on the project(s) + */ + this.projects = []; }; R3.System.Render.prototype = Object.create(R3.System.prototype); @@ -56,19 +87,46 @@ R3.System.Render.prototype.start = function() { R3.System.prototype.start.call(this); - this.renderConfigurations = R3.EntityManager.Instance.queryComponents(R3.Component.RENDER_CONFIGURATION); + this.excludeFromEnvironmentSubscription = this.subscribe( + R3.Event.EXCLUDE_FROM_ENVIRONMENT, + this.excludeFromEnvironmentUpdate + ); - this.renderers = R3.EntityManager.Instance.queryComponentsByConstructor(R3.Renderer); + this.instanceCreatedSubscription = this.subscribe( + R3.Event.INSTANCE_CREATED, + this.instanceCreated + ); - this.composers = R3.EntityManager.Instance.queryComponents(R3.Component.COMPOSER); + this.removeComponentSubscription = this.subscribe( + R3.Event.REMOVE_COMPONENT, + this.removeComponent + ); + + this.renderSubscription = this.subscribe( + R3.Event.RENDER, + this.render + ); + + this.replaceComponentSubscription = this.subscribe( + R3.Event.REPLACE_COMPONENT, + this.replaceComponent + ); + + this.textureUpdatedSubscription = this.subscribe( + R3.Event.TEXTURE_INSTANCE_UPDATED, + this.textureUpdated + ); + + this.windowResizeSubscription = this.subscribe( + R3.Event.WINDOW_RESIZE, + this.windowResize + ); this.statistics = R3.EntityManager.Instance.queryComponents(R3.Component.STATS); - this.cubeCameras = R3.EntityManager.Instance.queryComponents(R3.Component.CAMERA_CUBE); + this.projects = R3.EntityManager.Instance.queryComponents(R3.Component.PROJECT); - this.arComponents = R3.EntityManager.Instance.queryComponents(R3.Component.AR); - - this.excludedFromEnvironment = []; + this.excludedFromEnvironment = []; R3.EntityManager.Instance.queryComponentsByConstructor(R3.D3.Mesh).map( function(mesh) { @@ -78,89 +136,9 @@ R3.System.Render.prototype.start = function() { }.bind(this) ); - this.excludeFromEnvironmentSubscription = this.subscribe( - R3.Event.EXCLUDE_FROM_ENVIRONMENT, - this.excludeFromEnvironmentUpdate - ); - - this.instanceCreatedSubscription = R3.Event.Subscribe( - R3.Event.INSTANCE_CREATED, - this.instanceCreated.bind(this) - ); - - this.removeComponentSubscription = R3.Event.Subscribe( - R3.Event.REMOVE_COMPONENT, - this.removeComponent.bind(this) - ); - - this.replaceComponentSubscription = R3.Event.Subscribe( - R3.Event.REPLACE_COMPONENT, - this.replaceComponent.bind(this) - ); - - this.renderSubscription = this.subscribe( - R3.Event.RENDER, - this.render - ); - - this.windowResizeSubscription = this.subscribe( - R3.Event.WINDOW_RESIZE, - this.windowResize - ); - - this.textureUpdatedSubscription = this.subscribe( - R3.Event.TEXTURE_INSTANCE_UPDATED, - this.textureUpdated - ); - - this.getRenderConfigurationSubscription = this.subscribe( - R3.Event.GET_RENDER_CONFIGURATION, - this.getRenderConfiguration - ); - - this.setActiveRenderConfigurationSubscription = this.subscribe( - R3.Event.SET_ACTIVE_RENDER_CONFIGURATION, - this.setActiveRenderConfiguration - ); - - this.shaderUpdateSubscription = R3.Event.Subscribe( - R3.Event.SHADER_UPDATE, - this.shaderUpdate.bind(this) - ); - - // this.delayedInstanceEncounteredSubscription = R3.Event.Subscribe( - // R3.Event.DELAYED_INSTANCE_ENCOUNTERED, - // this.delayedInstanceEncountered.bind(this) - // ); - - // window.addEventListener( - // 'resize', - // this.nativeWindowResize, - // false - // ); - - // window.addEventListener( - // "orientationchangeend", - // this.nativeWindowResize, - // false - // ); - - // R3.Event.Emit( - // R3.Event.WINDOW_RESIZE, - // { - // width : window.screen.availWidth, - // height : window.screen.availHeight - // } - // ); - this.run(); }; -// -// R3.System.Render.prototype.delayedInstanceEncountered = function() { -// -// -// }; R3.System.Render.prototype.run = function() { @@ -177,20 +155,6 @@ R3.System.Render.prototype.run = function() { }; -// R3.System.Render.prototype.nativeWindowResize = function() { -// R3.Event.Emit( -// R3.Event.WINDOW_RESIZE, -// { -// width : window.screen.availWidth, -// height : window.screen.availHeight -// } -// ); -// }; - -R3.System.Render.prototype.getRenderConfiguration = function (data, callback) { - callback(this.activeRenderConfiguration); -}; - R3.System.Render.prototype.excludeFromEnvironmentUpdate = function (data) { if (data.component.excludeFromEnvironment) { @@ -205,23 +169,6 @@ R3.System.Render.prototype.excludeFromEnvironmentUpdate = function (data) { } }; -R3.System.Render.prototype.setActiveRenderConfiguration = function (data) { - - if (this.renderConfigurations.indexOf(data.renderConfiguration) !== -1) { - this.activeRenderConfiguration = data.renderConfiguration; - } else { - console.warn('active render configuration not found in render system'); - } - -}; - -R3.System.Render.prototype.getOffset = function (el) { - var rect = el.getBoundingClientRect(), - scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, - scrollTop = window.pageYOffset || document.documentElement.scrollTop; - return { top: rect.top + scrollTop, left: rect.left + scrollLeft } -}; - R3.System.Render.prototype.windowResize = function(data) { R3.Event.Emit( @@ -293,11 +240,11 @@ R3.System.Render.prototype.windowResize = function(data) { } ); - R3.EntityManager.Instance.queryComponentsByConstructor(R3.AR).map( - function(ar) { - ar.resize(); - } - ); + // R3.EntityManager.Instance.queryComponentsByConstructor(R3.AR).map( + // function(ar) { + // ar.resize(); + // } + // ); R3.Event.Emit( R3.Event.AFTER_WINDOW_RESIZE, @@ -305,19 +252,19 @@ R3.System.Render.prototype.windowResize = function(data) { ); }; - -R3.System.Render.prototype.shaderUpdate = function(data) { - - this.activeRenderConfiguration.activeScenes.map( - function(scene){ - this.activeRenderConfiguration.activeRenderer.instance.compile( - scene.instance, - this.activeRenderConfiguration.activeCamera.instance - ); - }.bind(this) - ); - -}; +// +// R3.System.Render.prototype.shaderUpdate = function(data) { +// +// this.activeRenderConfiguration.activeScenes.map( +// function(scene){ +// this.activeRenderConfiguration.activeRenderer.instance.compile( +// scene.instance, +// this.activeRenderConfiguration.activeCamera.instance +// ); +// }.bind(this) +// ); +// +// }; R3.System.Render.prototype.textureUpdated = function(data) { @@ -349,14 +296,14 @@ R3.System.Render.prototype.textureUpdated = function(data) { */ R3.System.Render.prototype.instanceCreated = function(data) { - if (data.component instanceof R3.RenderConfiguration) { - console.log('adding render configuration to render system'); - this.renderConfigurations.push(data.component); - - if (this.renderConfigurations.length === 1) { - this.activeRenderConfiguration = this.renderConfigurations[0]; - } - } + // if (data.component instanceof R3.RenderConfiguration) { + // console.log('adding render configuration to render system'); + // this.renderConfigurations.push(data.component); + // + // if (this.renderConfigurations.length === 1) { + // this.activeRenderConfiguration = this.renderConfigurations[0]; + // } + // } if (data.component instanceof R3.Renderer) { console.log('adding renderer to render system'); @@ -376,9 +323,9 @@ R3.System.Render.prototype.instanceCreated = function(data) { this.cubeCameras.push(data.component); } - if (data.component instanceof R3.AR) { - this.arComponents.push(data.component); - } + // if (data.component instanceof R3.AR) { + // this.arComponents.push(data.component); + // } if ( data.component instanceof R3.D3.Mesh && @@ -490,35 +437,35 @@ R3.System.Render.prototype.replaceComponent = function(data) { ); } - if ( - data.current instanceof R3.Renderer && - data.replacement instanceof R3.Renderer - ) { - data.replacement.canvas.remove(); - data.replacement.canvas = data.current.canvas; - data.current.canvas = null; - - if (this.activeRenderConfiguration.activeRenderer === data.current) { - this.activeRenderConfiguration.activeRenderer = data.replacement; - } - - if (this.activeRenderConfiguration.activeRenderer instanceof R3.Renderer.D2) { - - if (this.activeRenderConfiguration.activeCamera) { - this.activeRenderConfiguration.activeCamera.remove(); - this.activeRenderConfiguration.activeCamera = null; - } - - this.activeRenderConfiguration.activeScenes.map( - function(scene) { - scene.remove(); - } - ); - - this.activeRenderConfiguration.activeScenes = []; - } - - } + // if ( + // data.current instanceof R3.Renderer && + // data.replacement instanceof R3.Renderer + // ) { + // data.replacement.canvas.remove(); + // data.replacement.canvas = data.current.canvas; + // data.current.canvas = null; + // + // if (this.activeRenderConfiguration.activeRenderer === data.current) { + // this.activeRenderConfiguration.activeRenderer = data.replacement; + // } + // + // if (this.activeRenderConfiguration.activeRenderer instanceof R3.Renderer.D2) { + // + // if (this.activeRenderConfiguration.activeCamera) { + // this.activeRenderConfiguration.activeCamera.remove(); + // this.activeRenderConfiguration.activeCamera = null; + // } + // + // this.activeRenderConfiguration.activeScenes.map( + // function(scene) { + // scene.remove(); + // } + // ); + // + // this.activeRenderConfiguration.activeScenes = []; + // } + // + // } }; /** @@ -529,27 +476,27 @@ R3.System.Render.prototype.removeComponent = function(data) { var index; - if (data.component instanceof R3.RenderConfiguration) { - - index = this.renderConfigurations.indexOf(data.component); - - if (index !== -1) { - console.log('removing renderer configuration from system'); - - this.renderConfigurations.splice(index, 1); - - } else { - console.log('failed to find the render configuration in the system : ' + data.component.name); - } - - if (this.renderConfigurations.length === 0) { - this.activeRenderConfiguration = null; - } - - if (this.renderConfigurations.length === 1) { - this.activeRenderConfiguration = this.renderConfigurations[0]; - } - } + // if (data.component instanceof R3.RenderConfiguration) { + // + // index = this.renderConfigurations.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing renderer configuration from system'); + // + // this.renderConfigurations.splice(index, 1); + // + // } else { + // console.log('failed to find the render configuration in the system : ' + data.component.name); + // } + // + // if (this.renderConfigurations.length === 0) { + // this.activeRenderConfiguration = null; + // } + // + // if (this.renderConfigurations.length === 1) { + // this.activeRenderConfiguration = this.renderConfigurations[0]; + // } + // } if (data.component instanceof R3.Renderer) { @@ -607,19 +554,19 @@ R3.System.Render.prototype.removeComponent = function(data) { } } - if (data.component instanceof R3.AR) { - - index = this.arComponents.indexOf(data.component); - - if (index !== -1) { - console.log('removing ar component from render system'); - - this.arComponents.splice(index, 1); - - } else { - console.log('failed to find the ar component in the render system : ' + data.component.name); - } - } + // if (data.component instanceof R3.AR) { + // + // index = this.arComponents.indexOf(data.component); + // + // if (index !== -1) { + // console.log('removing ar component from render system'); + // + // this.arComponents.splice(index, 1); + // + // } else { + // console.log('failed to find the ar component in the render system : ' + data.component.name); + // } + // } if (data.component instanceof R3.D3.Mesh) { index = this.excludedFromEnvironment.indexOf(data.component); @@ -648,19 +595,40 @@ R3.System.Render.prototype.render = function(data) { data ); - var configuration = this.activeRenderConfiguration; + // var configuration = this.activeRenderConfiguration; + // + // if (!configuration) { + // return; + // } + // + // var renderer = configuration.activeRenderer; + // + // if (renderer instanceof R3.Renderer.D2) { + // return; + // } - if (!configuration) { - return; - } + this.projects.map( + function(project) { - var renderer = configuration.activeRenderer; + project.renderers.map( + function (renderer) { - if (renderer instanceof R3.Renderer.D2) { - return; - } + var scenes = renderer.scenes; + + var camera = project.cameras[project.cameraIndex]; + + var effect = renderer.effect; + + var composer = renderer.composer + } + ); + + + + } + ); + - var scenes = configuration.activeScenes; var camera = configuration.activeCamera; @@ -694,20 +662,20 @@ R3.System.Render.prototype.render = function(data) { } } - var arComponent = null; - - if (this.arComponents.length > 1) { - console.warn('only one AR component supported at this time'); - return; - } - - if (this.arComponents.length === 1) { - arComponent = this.arComponents[0]; - } - - if (arComponent) { - arComponent.instance.arScene.process(); - } + // var arComponent = null; + // + // if (this.arComponents.length > 1) { + // console.warn('only one AR component supported at this time'); + // return; + // } + // + // if (this.arComponents.length === 1) { + // arComponent = this.arComponents[0]; + // } + // + // if (arComponent) { + // arComponent.instance.arScene.process(); + // } var resetAutoClear = false; @@ -838,62 +806,24 @@ R3.System.Render.prototype.stop = function() { cancelAnimationFrame(this.animationFrameHook); + this.excludeFromEnvironmentSubscription.remove(); + this.instanceCreatedSubscription.remove(); this.removeComponentSubscription.remove(); - this.replaceComponentSubscription.remove(); - this.renderSubscription.remove(); - this.getRenderConfigurationSubscription.remove(); + this.replaceComponentSubscription.remove(); - this.setActiveRenderConfigurationSubscription.remove(); - - this.excludeFromEnvironmentSubscription.remove(); - - /** - * Images - */ this.textureUpdatedSubscription.remove(); - this.shaderUpdateSubscription.remove(); - - // this.delayedInstanceEncounteredSubscription.remove(); - - // window.removeEventListener( - // 'resize', - // this.nativeWindowResize, - // false - // ); - - // window.removeEventListener( - // 'orientationchangeend', - // this.nativeWindowResize, - // false - // ); - this.windowResizeSubscription.remove(); - this.renderers.map( - function(renderer) { - if (renderer.statistics) { - renderer.statistics.resize(); - renderer.canvas.instance.parentElement.removeChild(renderer.statistics.instance.dom); - } - } - ); - - this.renderConfigurations = []; - this.renderers = []; - this.composers = []; - this.statistics = []; - this.cubeCameras = []; - - this.arComponents = []; + this.excludedFromEnvironment = []; };