Create a sprite asset from a texture's context menu

The sprite takes the whole image at its pixel size and the texture's name,
numbered like any other clash. CreateAssetCommand now accepts starting
properties; they go through the schema in execute, so an unknown key or a
bad value is refused before the project is touched, and one undo removes
the asset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-11 09:57:19 +02:00
1 parent 1e2285c545
commit 9212e61c4c
9 files changed
+137 -7

No files matched your search

+7
View File
@@ -22,6 +22,13 @@ export function texturePixelSize(project: Project, props: PropertyBag): PixelSiz
return w > 0 && h > 0 ? { w, h } : null;
}
/** A sprite wearing the texture at its own pixel size – or at the default size while that is unknown. */
export function spriteFromTexture(project: Project, textureId: string): PropertyBag {
const props: PropertyBag = { texture: textureId };
const size = texturePixelSize(project, props);
return size ? { ...props, width: size.w, height: size.h } : props;
}
/**
* What `axis` has to become for the sprite to carry the picture's proportions, leaving the
* other side where it is. Null when the other side is not a usable number.