Files
feuerwerk/todo-notes/done/unreferenced-image-files.md
T
root 88ec367ab0 Offer the pictures the server already holds when adding a texture
"+ → Texture" opened the machine's file dialog, so a picture that was uploaded once
but lost its asset – an undone import, a deleted asset – was unreachable from the
editor while still sitting on the server. Nothing collects those files, by design.

It now opens a grid of every picture the server holds, with thumbnails: pick one and
"Use image" makes a texture asset on that file, "Upload…" is the way in for bytes the
server does not have yet and lands in the same import as a drop. A tile captioned with
an asset name is one this project already wears – picking it selects that asset instead
of making a second one, since two assets on one file would fight over `filter`.

- `GET ?r=textures` now reports `width`/`height`; a texture asset holds the pixel size,
  and reading it off the GPU texture would tie the asset's correctness to load timing.
- `TextureLibrary.load(file)` loads without touching `scaleMode` – a thumbnail must not
  restage the filter of a picture the scene is drawing with.
- The grid geometry lives in `texture/imageGrid.ts` as pure functions; inside the widget
  no test could reach it.
- The part after an upload is now one function shared by the drop import and the picker,
  so "one file = one asset" is stated in a single place.

12 new E2E checks; the strongest one undoes an import, leaving the file on the server
with no asset naming it, and picks exactly that file back out of the dialog.
2026-09-09 15:55:15 +02:00

2.5 KiB
Raw Blame History

Zitat aus der readme: "Unreferenced image files are never collected."

Ich würde sagen dass soll vorerst auch so bleiben.

Was passt: drag and drop file in den editor => textur wird hochgeladen und passende asset wird erstellt => das soll so bleiben, das passt

Was wir auch haben aber ändern: klickt man auf das + => Texture, dann öffnet sich der File System Browser.

Anstelle des file system browser => ein dialog mit allen images die am server existieren.

  • auswählen => ok, dann wird es wiederverwendet => dialog schließt sich => texture asset mit ausgewählten image wird erstellt.
  • oder hochladen button => file system browser => OK => dialog schließt sich => texture asset mit hochgeladenen image wird erstellt (im prinzip das was wir jetzt auch haben)

Umgesetzt (2026-09-09). Der Weg ueber + → Texture oeffnet jetzt einen Bild-Dialog statt des File-Browsers; Drag&Drop und Ctrl+V bleiben unveraendert, und gesammelt wird weiterhin nichts.

Der Dialog (src/editor/texture/ImagePicker.ts) zeigt jede Datei, die der Server haelt, als Kachel mit Vorschaubild. Auswaehlen und Use image legt ein Texture-Asset auf diese Datei an — ohne Upload, die Bytes liegen ja schon da. Upload… oeffnet den File-Browser und muendet in genau denselben Import wie ein Drop. Doppelklick auf eine Kachel ist die Kurzform von Use image.

Kacheln, die das Projekt schon traegt, sind mit dem Asset-Namen beschriftet (statt mit der Pixelgroesse); eine davon zu waehlen legt kein zweites Asset an, sondern selektiert das vorhandene — zwei Assets auf einer Datei wuerden sich sonst ueber filter streiten.

Zwei Aenderungen, die dazu noetig waren:

  • GET ?r=textures liefert jetzt auch width/height (aus dem Datei-Header). Ein Texture-Asset haelt die Pixelgroesse, und der Dialog haette sie sonst nur ueber das geladene Vorschaubild gehabt — dann haenge die Richtigkeit des Assets am Ladezustand der GPU-Textur.
  • TextureLibrary.load(file) neben get(ref): laedt, ohne den scaleMode anzufassen. Ein Vorschaubild darf den Filter eines Bildes nicht umstellen, das die Szene gerade zeichnet.

Belegt (tools/e2e/12-textures.mjs, Block 19e): ein zweites Bild wird eingefuegt, das Asset per Undo wieder entfernt — die Datei bleibt auf dem Server, das Projekt kennt sie nicht mehr. Genau die taucht dann im Dialog auf, ist nicht als "im Projekt" markiert, und ueber Use image entsteht daraus wieder ein Asset mit 24 × 24 aus dem Server-Datensatz. Zusaetzlich geprueft: der Dialog zeigt exakt die Dateiliste von GET ?r=textures.