Skip to content

Commit

Permalink
Merge pull request #68 from thkruz/fix-url-issues
Browse files Browse the repository at this point in the history
fix: 🐛 fix url mismatch between code and config
  • Loading branch information
ajmas authored Jan 9, 2024
2 parents f420d32 + fa5afd0 commit 78e5023
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down
11 changes: 6 additions & 5 deletions src/viewer/Earth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/viewer/ShaderStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ShaderStore {
shaderData: Record<string, string> = {};

constructor (appBaseUrl = '') {
appBaseUrl = appBaseUrl.endsWith('/') ? appBaseUrl : `${appBaseUrl}/`;
this.baseUrl = `${appBaseUrl}${this.basePath}`;
}

Expand Down

0 comments on commit 78e5023

Please sign in to comment.