diff --git a/src/index.ts b/src/index.ts index 681bd66..50c03c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,9 +7,8 @@ import appinfo from './appinfo.json'; import hud from './hud'; async function loadConfig () { - const baseUrl = './'; - const response = await axios.get(`${baseUrl}config.json`); let config = defaultConfig; + const response = await axios.get(`${config.baseUrl}config.json`); if (response.data) { config = { ...defaultConfig, ...response.data, appInfo: appinfo }; } diff --git a/src/viewer/Earth.ts b/src/viewer/Earth.ts index 0ba6c3f..af2783f 100644 --- a/src/viewer/Earth.ts +++ b/src/viewer/Earth.ts @@ -95,15 +95,16 @@ class Earth implements SceneComponent { async init (scene: SatelliteOrbitScene, context: ViewerContext) { if (context.config) { this.baseUrl = context.config.baseUrl; + this.baseUrl = this.baseUrl.endsWith('/') ? this.baseUrl : `${this.baseUrl}/`; } this.group = new Group(); - const basePath = `${this.baseUrl}images`; - const dayTexture = await this.loadTexture(`${basePath}/earth-blue-marble.jpg`); - const nightTexture = await this.loadTexture(`${basePath}/nightearth-4096.png`); - const bumpTexture = await this.loadTexture(`${basePath}/8081_earthbump4k.jpg`); - const earthSpecularMap = await this.loadTexture(`${basePath}/earth-water.png`); + this.basePath = `${this.baseUrl}images`; + const dayTexture = await this.loadTexture(`${this.basePath}/earth-blue-marble.jpg`); + const nightTexture = await this.loadTexture(`${this.basePath}/nightearth-4096.png`); + const bumpTexture = await this.loadTexture(`${this.basePath}/8081_earthbump4k.jpg`); + const earthSpecularMap = await this.loadTexture(`${this.basePath}/earth-water.png`); const dayMaterial = new MeshPhongMaterial({ map: dayTexture, diff --git a/src/viewer/ShaderStore.ts b/src/viewer/ShaderStore.ts index 6a8d58f..2b16eff 100644 --- a/src/viewer/ShaderStore.ts +++ b/src/viewer/ShaderStore.ts @@ -19,6 +19,7 @@ class ShaderStore { shaderData: Record = {}; constructor (appBaseUrl = '') { + appBaseUrl = appBaseUrl.endsWith('/') ? appBaseUrl : `${appBaseUrl}/`; this.baseUrl = `${appBaseUrl}${this.basePath}`; }