Skip to content

Commit d6ef1ae

Browse files
committed
refactor: streamline texture loading and splash behavior
- remove GPU sync (fenceSync/flush) in GlUtils to avoid blocking the main thread - add GlUtils.getBestTexture helper to select the highest available texture quality - stop tracking Earth hi-res flags and make useHighestQualityTexture a no-op (always load highest first) - remove splash-screen wait-for-hires gating and extend image preloading delay from 30s to 3 minutes - change SkyBox default resolution to MEDIUM and remove forced upgrade listener / pre-create texture - update texture assets (clouds8k, earthbump8k, skybox16k) and delete mars6k - adjust splash-screen tests to match new hide behavior - mark plugins-pro submodule dirty
1 parent d50c166 commit d6ef1ae

File tree

10 files changed

+28
-39
lines changed

10 files changed

+28
-39
lines changed

public/textures/clouds8k.jpg

-4.24 MB
Loading

public/textures/earthbump8k.jpg

-496 KB
Loading

public/textures/mars6k.jpg

-13.5 MB
Binary file not shown.

public/textures/skybox16k.jpg

-2.25 MB
Loading

src/app/ui/splash-screen.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { t7e, TranslationKey } from '@app/locales/keys';
22
import { getEl, hideEl, showEl } from '../../engine/utils/get-el';
3-
import { keepTrackApi } from '../../keepTrackApi';
43
import { MobileManager } from './mobileManager';
54

5+
import { EventBus } from '@app/engine/events/event-bus';
66
import { EventBusEvent } from '@app/engine/events/event-bus-events';
77
import { html } from '@app/engine/utils/development/formatter';
88
import blueMarbleJpg from '@public/img/wallpaper/blue-marble.jpg';
@@ -25,7 +25,6 @@ import satJpg from '@public/img/wallpaper/sat.jpg';
2525
import sat2Jpg from '@public/img/wallpaper/sat2.jpg';
2626
import telescopeJpg from '@public/img/wallpaper/telescope.jpg';
2727
import thuleJpg from '@public/img/wallpaper/thule.jpg';
28-
import { EventBus } from '@app/engine/events/event-bus';
2928

3029
export abstract class SplashScreen {
3130
/** An image is picked at random and then if the screen is bigger than 1080p then it loads the next one in the list */
@@ -105,15 +104,6 @@ export abstract class SplashScreen {
105104
}
106105

107106
static hideSplashScreen() {
108-
// Don't wait if we are running Jest
109-
if (keepTrackApi.getScene().earth.isUseHiRes && keepTrackApi.getScene().earth.isHiResReady !== true) {
110-
setTimeout(() => {
111-
SplashScreen.hideSplashScreen();
112-
}, 100);
113-
114-
return;
115-
}
116-
117107
MobileManager.checkMobileMode();
118108

119109
if (settingsManager.isMobileModeEnabled) {
@@ -192,13 +182,13 @@ export abstract class SplashScreen {
192182
loadingDom.style.backgroundRepeat = 'no-repeat';
193183
}
194184

195-
// Preload the rest of the images after 30 seconds
185+
// Preload the rest of the images after 3 minutes
196186
setTimeout(() => {
197187
this.splashScreenImgList_.forEach((img) => {
198188
const preloadImg = new Image();
199189

200190
preloadImg.src = img;
201191
});
202-
}, 30000);
192+
}, 3 * 60 * 1000);
203193
}
204194
}

src/engine/rendering/draw-manager/earth.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ export class Earth {
101101
[EarthCloudTextureQuality.ULTRA]: <WebGLTexture><unknown>null,
102102
};
103103
private vaoOcclusion_: WebGLVertexArrayObject;
104-
isHiResReady: boolean;
105-
isUseHiRes: boolean;
106104
/** Normalized vector pointing to the sun. */
107105
lightDirection = <vec3>[0, 0, 0];
108106
surfaceMesh: Mesh;
@@ -147,14 +145,7 @@ export class Earth {
147145
}
148146

149147
useHighestQualityTexture(): void {
150-
settingsManager.earthDayTextureQuality = EarthDayTextureQuality.HIGH;
151-
settingsManager.earthNightTextureQuality = EarthNightTextureQuality.HIGH;
152-
settingsManager.earthBumpTextureQuality = EarthBumpTextureQuality.HIGH;
153-
settingsManager.earthSpecTextureQuality = EarthSpecTextureQuality.HIGH;
154-
settingsManager.earthPoliticalTextureQuality = EarthPoliticalTextureQuality.HIGH;
155-
settingsManager.earthCloudTextureQuality = EarthCloudTextureQuality.ULTRA;
156-
157-
this.initTextures_();
148+
// Nothing to do here since we always load the highest quality first
158149
}
159150

160151
/**

src/engine/rendering/draw-manager/skybox-sphere.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { EventBus } from '@app/engine/events/event-bus';
2-
import { EventBusEvent } from '@app/engine/events/event-bus-events';
31
import { GlUtils } from '@app/engine/rendering/gl-utils';
42
import { GLSL3 } from '@app/engine/rendering/material';
53
import { Mesh } from '@app/engine/rendering/mesh';
@@ -40,7 +38,7 @@ export class SkyBoxSphere {
4038
private textureGraySkybox_: WebGLTexture;
4139
mesh: Mesh;
4240
private isLoaded_ = false;
43-
DEFAULT_RESOLUTION = MilkyWayTextureQuality.LOW;
41+
DEFAULT_RESOLUTION = MilkyWayTextureQuality.MEDIUM;
4442
MILKYWAY_SRC_BASE = 'skybox';
4543
textureMilkyWay: Record<MilkyWayTextureQuality, WebGLTexture> = {
4644
[MilkyWayTextureQuality.OFF]: <WebGLTexture><unknown>null,
@@ -226,11 +224,6 @@ export class SkyBoxSphere {
226224
});
227225
this.mesh.geometry.initVao(this.mesh.program);
228226

229-
EventBus.getInstance().on(EventBusEvent.onKeepTrackReady, () => {
230-
settingsManager.milkyWayTextureQuality = MilkyWayTextureQuality.ULTRA;
231-
this.initTextures_();
232-
});
233-
234227
this.isLoaded_ = true;
235228
}
236229

@@ -252,7 +245,6 @@ export class SkyBoxSphere {
252245
sm.milkyWayTextureQuality ??= this.DEFAULT_RESOLUTION;
253246

254247
if (sm.isDrawMilkyWay && !this.textureMilkyWay[sm.milkyWayTextureQuality] && sm.milkyWayTextureQuality !== MilkyWayTextureQuality.OFF) {
255-
this.textureMilkyWay[sm.milkyWayTextureQuality] = this.gl_.createTexture();
256248
GlUtils.initTexture(this.gl_, `${this.getSrc_(this.MILKYWAY_SRC_BASE, sm.milkyWayTextureQuality, 'jpg')}`).then((texture) => {
257249
this.textureMilkyWay[sm.milkyWayTextureQuality] = texture;
258250
this.isTexturesReady_ = true;

src/engine/rendering/gl-utils.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ export abstract class GlUtils {
109109
gl.bindTexture(gl.TEXTURE_2D, texture);
110110
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imgBitmap);
111111

112-
// eslint-disable-next-line no-sync
113-
gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
114-
gl.flush(); // don’t block
115-
116112
if (GlUtils.isPowerOf2(imgBitmap.width) && GlUtils.isPowerOf2(imgBitmap.height)) {
117113
// power of 2: generate mipmaps and set trilinear filtering + repeat
118114
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
@@ -145,6 +141,28 @@ export abstract class GlUtils {
145141
}
146142
}
147143

144+
static getBestTexture(textureMap: Record<string, WebGLTexture>): WebGLTexture {
145+
const qualityOrder = [
146+
'16k',
147+
'8k',
148+
'4k',
149+
'2k',
150+
'1k',
151+
'512',
152+
];
153+
154+
for (const quality of qualityOrder) {
155+
const texture = textureMap[quality];
156+
157+
if (texture) {
158+
return texture;
159+
}
160+
}
161+
162+
// If no texture is found, return null
163+
return null as unknown as WebGLTexture;
164+
}
165+
148166
/**
149167
* Deteremine if a number is a power of 2.
150168
*/

src/plugins-pro

test/splash-screen.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ describe('SplashScreen_class', () => {
2626

2727
// Tests that the loading screen is resized and hidden after a timeout when running on desktop
2828
it('test_hide_splash_screen_desktop', () => {
29-
keepTrackApi.getScene().earth.isUseHiRes = true;
30-
keepTrackApi.getScene().earth.isHiResReady = true;
3129
SplashScreen.hideSplashScreen();
3230
// Wait for timers to finish
3331
jest.advanceTimersByTime(1000);

0 commit comments

Comments
 (0)