From dad1bb2d9e7f476b69c83d0366ce314c0f0084cd Mon Sep 17 00:00:00 2001 From: Mr F Date: Fri, 22 Jan 2016 13:23:06 +0300 Subject: [PATCH 1/4] change stuff back 1 --- src/framework/application.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/framework/application.js b/src/framework/application.js index 30cf82d92a9..11ce33de34a 100644 --- a/src/framework/application.js +++ b/src/framework/application.js @@ -58,11 +58,13 @@ pc.extend(pc, function () { this._audioManager = new pc.SoundManager(); this.loader = new pc.ResourceLoader(); - this.scene = null; + this.scene = new pc.Scene(); this.root = new pc.Entity(this); this.root._enabledInHierarchy = true; this.assets = new pc.AssetRegistry(this.loader); this.renderer = new pc.ForwardRenderer(this.graphicsDevice); + this.lightMapper = new pc.LightMapper(this.graphicsDevice, this.root, this.scene, this.renderer, this.assets); + this.once('preRender', this._firstBake, this); this.keyboard = options.keyboard || null; this.mouse = options.mouse || null; @@ -981,6 +983,10 @@ pc.extend(pc, function () { this._skyboxLast = null; }, + _firstBake: function() { + this.lightMapper.bake(); + }, + /** * @function * @name pc.Application#destroy From 7b325a6537ea2a60d099e0657c58ff8c77ceb3be Mon Sep 17 00:00:00 2001 From: Mr F Date: Fri, 22 Jan 2016 13:24:03 +0300 Subject: [PATCH 2/4] change stuff back 2 --- build/dependencies.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/build/dependencies.txt b/build/dependencies.txt index 3831702c319..c0aba6f8477 100644 --- a/build/dependencies.txt +++ b/build/dependencies.txt @@ -169,3 +169,4 @@ ../src/core/promise.js ../src/backwards-compatibility.js ../src/scene/immediate.js +../src/scene/light-mapper.js From 608959c596d5c3d99940cec60aad4b917206b3b3 Mon Sep 17 00:00:00 2001 From: Mr F Date: Fri, 22 Jan 2016 14:31:18 +0300 Subject: [PATCH 3/4] fix scene creation assuming scene is only created once --- src/framework/application.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/framework/application.js b/src/framework/application.js index 11ce33de34a..7efdc05dbe7 100644 --- a/src/framework/application.js +++ b/src/framework/application.js @@ -346,15 +346,6 @@ pc.extend(pc, function () { loadScene: function (url, callback) { var self = this; - var first = true; - - // If there is an existing scene destroy it - if (this.scene) { - first = false; - this.scene.root.destroy(); - this.scene.destroy(); - this.scene = null; - } var handler = this.loader.getHandler("scene"); @@ -380,14 +371,6 @@ pc.extend(pc, function () { self.systems.rigidbody.setGravity(scene._gravity.x, scene._gravity.y, scene._gravity.z); } - if (!first) { - // if this is not the initial scene - // we need to run component initialization - // first scene is initialized in app.start() - pc.ComponentSystem.initialize(scene.root); - pc.ComponentSystem.postInitialize(scene.root); - } - if (callback) { callback(null, scene); } @@ -541,12 +524,6 @@ pc.extend(pc, function () { target: this }); - if (!this.scene) { - this.scene = new pc.Scene(); - this.scene.root = new pc.Entity(); - this.root.addChild(this.scene.root); - } - if (!this._librariesLoaded) { this.onLibrariesLoaded(); } @@ -598,11 +575,6 @@ pc.extend(pc, function () { render: function () { this.stats.frame.renderStart = pc.now(); - if (!this.scene) { - this.stats.frame.renderTime = 0; - return; - } - this.fire("preRender", null); var cameras = this.systems.camera.cameras; @@ -928,9 +900,6 @@ pc.extend(pc, function () { this.systems.rigidbody.setGravity(gravity[0], gravity[1], gravity[2]); } - if (! this.scene) - return; - this.scene.applySettings(settings); if (settings.render.skybox && this._skyboxLast !== settings.render.skybox) { From 6c648a44f8c1a5dddbb219b84e070d95ecd5c180 Mon Sep 17 00:00:00 2001 From: Mr F Date: Fri, 22 Jan 2016 14:47:20 +0300 Subject: [PATCH 4/4] preRender -> prerender --- src/framework/application.js | 4 ++-- src/scene/immediate.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/framework/application.js b/src/framework/application.js index 7efdc05dbe7..fb778cd3a61 100644 --- a/src/framework/application.js +++ b/src/framework/application.js @@ -64,7 +64,7 @@ pc.extend(pc, function () { this.assets = new pc.AssetRegistry(this.loader); this.renderer = new pc.ForwardRenderer(this.graphicsDevice); this.lightMapper = new pc.LightMapper(this.graphicsDevice, this.root, this.scene, this.renderer, this.assets); - this.once('preRender', this._firstBake, this); + this.once('prerender', this._firstBake, this); this.keyboard = options.keyboard || null; this.mouse = options.mouse || null; @@ -575,7 +575,7 @@ pc.extend(pc, function () { render: function () { this.stats.frame.renderStart = pc.now(); - this.fire("preRender", null); + this.fire("prerender", null); var cameras = this.systems.camera.cameras; var camera = null; diff --git a/src/scene/immediate.js b/src/scene/immediate.js index 30274595302..187011b647b 100644 --- a/src/scene/immediate.js +++ b/src/scene/immediate.js @@ -89,7 +89,7 @@ pc.extend(pc.Application.prototype, function () { { semantic: pc.SEMANTIC_POSITION, components: 3, type: pc.ELEMENTTYPE_FLOAT32 }, { semantic: pc.SEMANTIC_COLOR, components: 4, type: pc.ELEMENTTYPE_UINT8, normalize: true } ]); - this.on('preRender', this._preRenderImmediate, this); + this.on('prerender', this._preRenderImmediate, this); } if (!lineBatches[batchId]) { // Init used batch once