From 6508408074e73c027f2327fa21675d58b6fa526f Mon Sep 17 00:00:00 2001 From: Annie Taylor Chen Date: Thu, 28 Apr 2022 15:48:33 +0200 Subject: [PATCH] solve the routing issue for brain stem. --- src/lib/organism/BrainStem.svelte | 1 - src/lib/organism/Experience/Experience.js | 12 ++++++------ src/lib/organism/Experience/World/BrainStem.js | 12 +++++------- src/lib/organism/Experience/World/Environment.js | 12 +++++------- src/lib/organism/Experience/World/Floor.js | 9 +++------ src/lib/organism/Experience/World/Fox.js | 13 +++++-------- src/lib/organism/Experience/World/World.js | 8 ++++---- 7 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/lib/organism/BrainStem.svelte b/src/lib/organism/BrainStem.svelte index 7128a7f..36ba0de 100644 --- a/src/lib/organism/BrainStem.svelte +++ b/src/lib/organism/BrainStem.svelte @@ -16,7 +16,6 @@

Click on the debug button below for control access to make magic happen!

-

TODO: I need to fix the loading issue. If it doesn't load, refresh or reload the page!

debug
diff --git a/src/lib/organism/Experience/Experience.js b/src/lib/organism/Experience/Experience.js index 7055f2e..c4062d3 100644 --- a/src/lib/organism/Experience/Experience.js +++ b/src/lib/organism/Experience/Experience.js @@ -16,12 +16,12 @@ export default class Experience { constructor(_canvas) { - // Singleton - if(instance) - { - return instance - } - instance = this + // Singleton: note this might not work with SvelteKit with the routing + // if(instance) + // { + // return instance + // } + // instance = this // Global access window.experience = this diff --git a/src/lib/organism/Experience/World/BrainStem.js b/src/lib/organism/Experience/World/BrainStem.js index cd82fd8..99031c4 100644 --- a/src/lib/organism/Experience/World/BrainStem.js +++ b/src/lib/organism/Experience/World/BrainStem.js @@ -1,15 +1,13 @@ import * as THREE from 'three' -import Experience from '../Experience.js' export default class BrainStem { - constructor() + constructor(_experience) { - this.experience = new Experience() - this.scene = this.experience.scene - this.resources = this.experience.resources - this.time = this.experience.time - this.debug = this.experience.debug + this.scene = _experience.scene + this.resources = _experience.resources + this.time = _experience.time + this.debug = _experience.debug // Debug if(this.debug.active) diff --git a/src/lib/organism/Experience/World/Environment.js b/src/lib/organism/Experience/World/Environment.js index 48a7955..fa8849b 100644 --- a/src/lib/organism/Experience/World/Environment.js +++ b/src/lib/organism/Experience/World/Environment.js @@ -1,14 +1,12 @@ import * as THREE from 'three' -import Experience from '../Experience.js' - export default class Environment { - constructor() + constructor(_experience) { - this.experience = new Experience() - this.scene = this.experience.scene - this.resources = this.experience.resources - this.debug = this.experience.debug + + this.scene = _experience.scene + this.resources = _experience.resources + this.debug = _experience.debug // Debug if(this.debug.active) diff --git a/src/lib/organism/Experience/World/Floor.js b/src/lib/organism/Experience/World/Floor.js index f2137d9..fbb8d08 100644 --- a/src/lib/organism/Experience/World/Floor.js +++ b/src/lib/organism/Experience/World/Floor.js @@ -1,13 +1,10 @@ import * as THREE from 'three' -import Experience from '../Experience.js' - export default class Floor { - constructor() + constructor(_experience) { - this.experience = new Experience() - this.scene = this.experience.scene - this.resources = this.experience.resources + this.scene = _experience.scene + this.resources = _experience.resources this.setGeometry() this.setTextures() diff --git a/src/lib/organism/Experience/World/Fox.js b/src/lib/organism/Experience/World/Fox.js index 791cc87..6a6099a 100644 --- a/src/lib/organism/Experience/World/Fox.js +++ b/src/lib/organism/Experience/World/Fox.js @@ -1,15 +1,12 @@ import * as THREE from 'three' -import Experience from '../Experience.js' - export default class Fox { - constructor() + constructor(_experience) { - this.experience = new Experience() - this.scene = this.experience.scene - this.resources = this.experience.resources - this.time = this.experience.time - this.debug = this.experience.debug + this.scene = _experience.scene + this.resources = _experience.resources + this.time = _experience.time + this.debug = _experience.debug // Debug if(this.debug.active) diff --git a/src/lib/organism/Experience/World/World.js b/src/lib/organism/Experience/World/World.js index b79184c..0e60362 100644 --- a/src/lib/organism/Experience/World/World.js +++ b/src/lib/organism/Experience/World/World.js @@ -14,10 +14,10 @@ export default class World this.resources.on('ready', () => { // Setup - this.floor = new Floor() - this.fox = new Fox() - this.brainStem = new BrainStem() - this.environment = new Environment() + this.floor = new Floor(_experience) + this.fox = new Fox(_experience) + this.brainStem = new BrainStem(_experience) + this.environment = new Environment(_experience) }) }