Skip to content

Commit

Permalink
Merge pull request #506 from guycalledfrank/fixscenecreation
Browse files Browse the repository at this point in the history
Fix scene creation
  • Loading branch information
guycalledfrank committed Jan 22, 2016
2 parents 00dd907 + 4cfe453 commit dc9ad04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
36 changes: 2 additions & 34 deletions src/framework/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -346,16 +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;
if (this.scene.root)
this.scene.root.destroy();
this.scene.destroy();
this.scene = null;
}

var handler = this.loader.getHandler("scene");

Expand All @@ -381,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);
}
Expand Down Expand Up @@ -542,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();
}
Expand Down Expand Up @@ -599,12 +575,7 @@ 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);
this.fire("prerender", null);

var cameras = this.systems.camera.cameras;
var camera = null;
Expand Down Expand Up @@ -929,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) {
Expand Down
2 changes: 1 addition & 1 deletion src/scene/immediate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc9ad04

Please sign in to comment.