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.
This commit is contained in:
root committed 2026-09-09 15:55:15 +02:00
1 parent 2f4dc843d7
commit 88ec367ab0
16 files changed
+774 -56

No files matched your search

+16 -5
View File
@@ -27,11 +27,8 @@ export class TextureLibrary {
* the last one drawn wins; upload avoids that by reusing the existing asset for a known file.
*/
get(ref: TextureRef): Texture | null {
const texture = this.loaded.get(ref.file);
if (!texture) {
this.startLoading(ref.file);
return null;
}
const texture = this.load(ref.file);
if (!texture) return null;
const mode = ref.smooth ? 'linear' : 'nearest';
if (texture.source.scaleMode !== mode) {
texture.source.scaleMode = mode;
@@ -42,6 +39,20 @@ export class TextureLibrary {
return texture;
}
/**
* The picture if it is in memory, otherwise null while it loads – without touching the scale
* mode, which belongs to whoever wears the texture. A thumbnail must not decide the filter of
* a picture the scene is drawing with.
*/
load(file: string): Texture | null {
const texture = this.loaded.get(file);
if (!texture) {
this.startLoading(file);
return null;
}
return texture;
}
/** The picture if it is in memory, without starting a load or touching the scale mode. */
peek(file: string): Texture | null {
return this.loaded.get(file) ?? null;