From a32037a8266850bb82d8a2b06e34d9add9d97a43 Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Tue, 9 May 2017 15:44:29 +0200 Subject: [PATCH] trying to resize! --- src/game-lib-d3-editor.js | 18 +++++++++++++++++- src/game-lib-d3-game.js | 8 ++++++++ src/game-lib-d3-renderer.js | 10 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/game-lib-d3-editor.js b/src/game-lib-d3-editor.js index 758a8ea..924f396 100644 --- a/src/game-lib-d3-editor.js +++ b/src/game-lib-d3-editor.js @@ -448,10 +448,26 @@ GameLib.D3.Editor.prototype.deSelectObject = function(object) { } ); - this.selectedObjects = results.rest; if (this.onDeSelectObject) { this.onDeSelectObject(results); } }; + +GameLib.D3.Editor.prototype.setSize = function(width, height) { + + this.viewports.map( + function(viewport){ + viewport.width = width; + viewport.height = height; + viewport.updateInstance(); + } + ); + + this.renderers.map( + function(renderer) { + renderer.setSize(width, height); + } + ); +}; diff --git a/src/game-lib-d3-game.js b/src/game-lib-d3-game.js index 4d19be8..ac04532 100644 --- a/src/game-lib-d3-game.js +++ b/src/game-lib-d3-game.js @@ -417,3 +417,11 @@ GameLib.D3.Game.LoadGameFromApi = function( xhr.send(); }; + +GameLib.D3.Game.prototype.setSize = function(width, height) { + this.renderers.map( + function(renderer) { + renderer.setSize(width, height); + } + ); +}; diff --git a/src/game-lib-d3-renderer.js b/src/game-lib-d3-renderer.js index 6e32083..2a58db8 100644 --- a/src/game-lib-d3-renderer.js +++ b/src/game-lib-d3-renderer.js @@ -64,6 +64,9 @@ GameLib.D3.Renderer.prototype.createInstance = function(update) { this.height ); + instance.domElement.width = this.width; + instance.domElement.height = this.height; + instance.autoClear = this.autoClear; instance.preserveDrawingBuffer = this.preserveDrawingBuffer; @@ -112,3 +115,10 @@ GameLib.D3.Renderer.prototype.render = function() { this.instance.render(this.scene.instance, this.camera.instance); }; +GameLib.D3.Renderer.prototype.setSize = function(width, height) { + this.width = width; + this.height = height; + + this.updateInstance(); +}; +