Skip to content

Commit 8e2bdde

Browse files
committed
fix: sky grid invisible due to theme init ordering
SkyGridRenderer read palette.skyGrid at construction time, before themeStore.load() applied CSS vars to :root. The empty string parsed as fully transparent, making the grid invisible. Store the line material and add refreshColors() to re-read from palette. Called after theme load and on every theme change.
1 parent 61435ff commit 8e2bdde

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,11 @@ export class App {
728728

729729
// --- Load persisted settings from localStorage ---
730730
themeStore.load();
731+
this.skyGridRenderer.refreshColors();
731732
themeStore.onThemeChange = () => {
732733
if (!uiStore.showSkybox) this.scene3d.background = new THREE.Color(palette.bg);
733734
this.scene2d.background = new THREE.Color(palette.bg);
735+
this.skyGridRenderer.refreshColors();
734736
};
735737
settingsStore.load();
736738
uiStore.loadToggles();

src/scene/sky-grid-renderer.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const AZ_LABEL_ANGLES = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330];
1919
*/
2020
export class SkyGridRenderer {
2121
private group = new THREE.Group();
22+
private lineMat: THREE.LineBasicMaterial;
2223

2324
// Elevation rings
2425
private ringAttrs: THREE.BufferAttribute[] = [];
@@ -42,7 +43,7 @@ export class SkyGridRenderer {
4243

4344
constructor(scene: THREE.Scene, private overlay: HTMLElement) {
4445
const gridColor = parseRgba(palette.skyGrid);
45-
const lineMat = new THREE.LineBasicMaterial({
46+
this.lineMat = new THREE.LineBasicMaterial({
4647
color: new THREE.Color(gridColor.r, gridColor.g, gridColor.b),
4748
transparent: true,
4849
opacity: gridColor.a,
@@ -56,7 +57,7 @@ export class SkyGridRenderer {
5657
attr.setUsage(THREE.DynamicDrawUsage);
5758
const geo = new THREE.BufferGeometry();
5859
geo.setAttribute('position', attr);
59-
const ring = new THREE.LineLoop(geo, lineMat);
60+
const ring = new THREE.LineLoop(geo, this.lineMat);
6061
ring.frustumCulled = false;
6162
ring.renderOrder = 900;
6263
this.group.add(ring);
@@ -70,7 +71,7 @@ export class SkyGridRenderer {
7071
this.azPosAttr.setUsage(THREE.DynamicDrawUsage);
7172
const azGeo = new THREE.BufferGeometry();
7273
azGeo.setAttribute('position', this.azPosAttr);
73-
const azLines = new THREE.LineSegments(azGeo, lineMat);
74+
const azLines = new THREE.LineSegments(azGeo, this.lineMat);
7475
azLines.frustumCulled = false;
7576
azLines.renderOrder = 900;
7677
this.group.add(azLines);
@@ -263,6 +264,14 @@ export class SkyGridRenderer {
263264
}
264265
}
265266

267+
/** Re-read grid line color from palette (call after theme load/change). */
268+
refreshColors() {
269+
const c = parseRgba(palette.skyGrid);
270+
this.lineMat.color.setRGB(c.r, c.g, c.b);
271+
this.lineMat.opacity = c.a;
272+
this.lineMat.needsUpdate = true;
273+
}
274+
266275
setVisible(v: boolean) {
267276
this.group.visible = v;
268277
if (!v) {

0 commit comments

Comments
 (0)