From 8c4f1c11c94332547814a6392a62e1ffae6423a6 Mon Sep 17 00:00:00 2001 From: Senrokai Date: Tue, 29 Sep 2026 19:35:27 +0200 Subject: [PATCH] Build a body still waiting for its surface with a null map, so three stops warning on each one Since de34fff paints derived surfaces after the system is built, every body without a photograph was given map: undefined, and three's Material.setValues warns "parameter 'map' has value of undefined" for each: eleven warnings every time the Sun's system was entered, one per exoplanet in any other. The marker now starts with map: null, which three takes without a word and which the deferred paint replaces as before. In the running app, entering the Sun (38 members) now logs no console message at all. Control: undefined again fails "builds a body still waiting for its surface without three warning of an undefined map". Co-Authored-By: Claude Opus 5.5 (1M context) --- .../galaxy-system/system-orbits-renderer.spec.ts | 9 ++++++++- src/app/features/galaxy-system/system-orbits-renderer.ts | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/features/galaxy-system/system-orbits-renderer.spec.ts b/src/app/features/galaxy-system/system-orbits-renderer.spec.ts index a37df6b..0512976 100644 --- a/src/app/features/galaxy-system/system-orbits-renderer.spec.ts +++ b/src/app/features/galaxy-system/system-orbits-renderer.spec.ts @@ -1,5 +1,5 @@ import * as THREE from 'three/webgpu'; -import { describe, expect, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import { DEFAULT_EPOCH_JD, GM_SUN_AU3_PER_DAY2, TT_MINUS_UTC_DAYS, ttMinusUtSeconds } from '../../shared/astro/constants'; import { keplerRates } from '../../shared/astro/kepler'; @@ -465,6 +465,13 @@ describe('derived surfaces', () => { renderer.dispose(); }); + it('builds a body still waiting for its surface without three warning of an undefined map', () => { + const warn = vi.spyOn(console, 'warn'); + twoPlanets().dispose(); + expect(warn.mock.calls.flat().join(' ')).not.toContain("parameter 'map'"); + warn.mockRestore(); + }); + it('paints nothing once the system is left', async () => { const renderer = twoPlanets(); renderer.dispose(); diff --git a/src/app/features/galaxy-system/system-orbits-renderer.ts b/src/app/features/galaxy-system/system-orbits-renderer.ts index fdadb0f..7b209b7 100644 --- a/src/app/features/galaxy-system/system-orbits-renderer.ts +++ b/src/app/features/galaxy-system/system-orbits-renderer.ts @@ -180,7 +180,9 @@ function buildMarker( ): THREE.Mesh { const geometry = new THREE.SphereGeometry(bodyMarkerRadiusAu(radiusKm), MARKER_WIDTH_SEGMENTS, MARKER_HEIGHT_SEGMENTS); const photograph = id ? bodyTexturePath(id) : undefined; - const map = photograph ? loadCachedTexture(photograph) : undefined; + // null, not undefined, where there is none yet: three warns "parameter 'map' has value of + // undefined" for every body built so, eleven of them on entering the Sun's system. + const map = photograph ? loadCachedTexture(photograph) : null; const material = new THREE.MeshStandardMaterial({ map, color: map ? 0xffffff : colorForKind(kind),