From 96ea8c1f6a8c18a44d8a08c6b8a808b7f1594537 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Fri, 11 May 2018 19:03:24 +0200 Subject: [PATCH] configuration modes --- src/r3-api-render-configuration.js | 12 +++++++++++- src/r3-ar.js | 15 +++++++++++++++ src/r3-render-configuration.js | 15 +++++++++++++-- src/r3-system-gui.js | 11 +++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/r3-api-render-configuration.js b/src/r3-api-render-configuration.js index 09aec02..8fc7921 100644 --- a/src/r3-api-render-configuration.js +++ b/src/r3-api-render-configuration.js @@ -14,6 +14,7 @@ * @param activeRenderer * @param enableComposer * @param enableEffect + * @param defaultMode * @constructor */ R3.API.RenderConfiguration = function ( @@ -30,7 +31,8 @@ R3.API.RenderConfiguration = function ( activeComposer, activeEffect, enableComposer, - enableEffect + enableEffect, + defaultMode ) { if (R3.Utils.UndefinedOrNull(id)) { id = R3.Utils.RandomId(); @@ -100,6 +102,11 @@ 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, R3.Component.RENDER_CONFIGURATION, @@ -122,3 +129,6 @@ 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-ar.js b/src/r3-ar.js index fca8738..9f17127 100644 --- a/src/r3-ar.js +++ b/src/r3-ar.js @@ -152,6 +152,19 @@ R3.AR.prototype.createInstance = function() { arComponent.camera.instance.projectionMatrix.copy(projectionMatrix); + arComponent.camera.updateFromInstance(); + + arComponent.camera.instance.fov = arComponent.camera.fov; + arComponent.camera.instance.near = arComponent.camera.near; + arComponent.camera.instance.far = arComponent.camera.far; + arComponent.camera.instance.filmGauge = arComponent.camera.filmGauge; + arComponent.camera.instance.filmOffset = arComponent.camera.filmOffset; + arComponent.camera.instance.focus = arComponent.camera.focus; + arComponent.camera.instance.zoom = arComponent.camera.zoom; + arComponent.camera.instance.aspect = arComponent.camera.aspect; + arComponent.camera.instance.updateProjectionMatrix(); + + } } @@ -219,6 +232,8 @@ R3.AR.prototype.createInstance = function() { this.videoScene.camera = this.videoCamera; + arScene.videoScene.children[0].material.map.flipY = true; + /** * Also update the video texture before render */ diff --git a/src/r3-render-configuration.js b/src/r3-render-configuration.js index f38b154..2758266 100644 --- a/src/r3-render-configuration.js +++ b/src/r3-render-configuration.js @@ -31,7 +31,8 @@ R3.RenderConfiguration = function ( apiRenderConfiguration.activeComposer, apiRenderConfiguration.activeEffect, apiRenderConfiguration.enableComposer, - apiRenderConfiguration.enableEffect + apiRenderConfiguration.enableEffect, + apiRenderConfiguration.defaultMode ); this.logicalSize = new R3.Vector2( @@ -226,6 +227,15 @@ R3.RenderConfiguration.prototype.updateInstance = function(property) { return; } + if ( + property === 'defaultMode' + ) { + console.log('todo: defaultMode change'); + return; + } + + R3.Component.prototype.updateInstance.call(this, property); + }; /** @@ -252,7 +262,8 @@ R3.RenderConfiguration.prototype.toApiObject = function() { R3.Utils.IdOrNull(this.activeComposer), R3.Utils.IdOrNull(this.activeEffect), this.enableComposer, - this.enableEffect + this.enableEffect, + this.defaultMode ); return apiRenderConfiguration; diff --git a/src/r3-system-gui.js b/src/r3-system-gui.js index 6961912..50b7b0d 100644 --- a/src/r3-system-gui.js +++ b/src/r3-system-gui.js @@ -940,6 +940,17 @@ R3.System.GUI.prototype.buildControl = function(folder, componentTemplate, prope } ) ); + } else if (property === 'defaultMode') { + controllers.push( + folder.add( + object, + property, + { + 'in game' : R3.API.RenderConfiguration.DEFAULT_MODE_IN_GAME, + 'edit' : R3.API.RenderConfiguration.DEFAULT_MODE_EDIT + } + ) + ); } else if (property === 'aspectRatioMode') { controllers.push( folder.add(