Feature: model config UI + move scale/tint to CardDefinition

Reorganised model3D config into two logical levels:

Card-level (CardDefinition — "this card's visual identity"):
  ModelScale      float?   — uniform scale multiplier
  ModelTintColor  string?  — multiplicative hex tint e.g. "#FF8800"

Asset-level (CardAsset — "properties of this mesh file"):
  ModelFacingDirection  string?  — GLB export facing ("north" default)
  ModelTintMaskUrl      string?  — CDN URL for per-texel tint mask

Admin UI (CardEditor.razor):
  Basic tab: new "3D Model" row with Scale (number) + Tint Colour
  (text + live swatch preview).
  Assets tab: Model3D asset cards now show Facing Direction dropdown
  and Tint Mask URL input.

Server:
  ContentMessages: ModelScale/ModelTintColor moved to CardDefinitionDto;
  CardAssetDto retains only ModelFacingDirection + ModelTintMaskUrl.
  ContentDtoMapper updated accordingly.

Client (game_screen.gd):
  modelScale + modelTintColor now read from the definition dict;
  modelFacingDirection stays on the asset dict.

DB: migration MoveModelScaleTintToCard applied to pg-forge-01/SOR.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-16 07:25:20 -04:00
co-authored by Claude Happy
parent a3c670e9e6
commit 42a2834e03
9 changed files with 592 additions and 28 deletions
@@ -112,6 +112,26 @@ else
<label class="form-check-label" for="chkPublished">Published</label>
</div>
</div>
<div class="col-12"><h6 class="text-muted mt-2">3D Model</h6></div>
<div class="col-md-2">
<label class="form-label">Scale</label>
<input @bind="_card.ModelScale" type="number" step="0.01" min="0.01" class="form-control"
placeholder="1.0" />
<div class="form-text">Null = 1.0 (no change)</div>
</div>
<div class="col-md-3">
<label class="form-label">Tint Colour</label>
<div class="input-group">
<input @bind="_card.ModelTintColor" class="form-control" placeholder="#RRGGBB" />
@if (!string.IsNullOrWhiteSpace(_card.ModelTintColor))
{
<span class="input-group-text"
style="background:@_card.ModelTintColor; width:36px; border:1px solid #ced4da;"></span>
}
</div>
<div class="form-text">Multiplicative hex tint over the model. Null = white (no tint).</div>
</div>
</div>
}
@@ -283,6 +303,23 @@ else
</div>
<input @bind="asset.MimeType" class="form-control form-control-sm mb-2"
placeholder="MIME type (e.g. image/webp, model/gltf-binary)" />
@if (asset.AssetType == CardAssetType.Model3D)
{
<div class="row g-1 mb-2">
<div class="col">
<label class="form-label form-label-sm mb-0">Facing Direction</label>
<select @bind="asset.ModelFacingDirection" class="form-select form-select-sm">
<option value="">– Default (north) –</option>
<option value="north">North (–Z)</option>
<option value="south">South (+Z)</option>
<option value="east">East (+X)</option>
<option value="west">West (–X)</option>
</select>
</div>
</div>
<input @bind="asset.ModelTintMaskUrl" class="form-control form-control-sm mb-2"
placeholder="Tint mask URL (CDN, optional)" />
}
<div class="form-check mb-2">
<input @bind="asset.IsAiGenerated" type="checkbox"
class="form-check-input" id="ai_asset_@asset.Id" />
+4 -3
View File
@@ -92,6 +92,9 @@ public sealed record CardDefinitionDto(
DateTimeOffset? RetiredAt,
DateTimeOffset UpdatedAt,
long DefinitionVersion,
// Visual / 3D model (card-level)
float? ModelScale,
string? ModelTintColor,
// Assets
IEnumerable<CardAssetDto> Assets,
IEnumerable<CardAnimationBindingDto> AnimationBindings);
@@ -102,10 +105,8 @@ public sealed record CardAssetDto(
string CdnUrl,
string? MimeType,
bool IsAiGenerated,
// Model3D config
// Model3D config (asset/file-level)
string? ModelFacingDirection,
float? ModelScale,
string? ModelTintColor,
string? ModelTintMaskUrl);
public sealed record CardAnimationBindingDto(
@@ -46,6 +46,8 @@ internal static class ContentDtoMapper
RetiredAt: c.RetiredAt,
UpdatedAt: c.UpdatedAt,
DefinitionVersion: c.DefinitionVersion,
ModelScale: c.ModelScale,
ModelTintColor: c.ModelTintColor,
Assets: c.Assets.Select(a => new CardAssetDto(
a.Id,
a.AssetType.ToString(),
@@ -53,8 +55,6 @@ internal static class ContentDtoMapper
a.MimeType,
a.IsAiGenerated,
a.ModelFacingDirection,
a.ModelScale,
a.ModelTintColor,
a.ModelTintMaskUrl)),
AnimationBindings: c.AnimationBindings.Select(b => new CardAnimationBindingDto(
b.Id,
@@ -29,19 +29,6 @@ public sealed class CardAsset
/// </summary>
public string? ModelFacingDirection { get; set; }
/// <summary>
/// Uniform scale multiplier applied to the model root node.
/// Null or 1.0 = no scaling.
/// </summary>
public float? ModelScale { get; set; }
/// <summary>
/// CSS-style hex tint applied multiplicatively to all StandardMaterial3D
/// surfaces on the model (e.g. "#FF8800"). Null = no tint (white).
/// Lets one GLB be reused with different faction/team colours.
/// </summary>
public string? ModelTintColor { get; set; }
/// <summary>
/// CDN URL of a greyscale mask texture whose red channel controls how
/// strongly the ModelTintColor is applied per texel (0 = original, 1 = full tint).
@@ -74,6 +74,21 @@ public sealed class CardDefinition
// ── Terramorpha-only ────────────────────────────────────────────────────
public TerramorphaMode? TerramorphaMode { get; set; }
// ── Visual / 3D model overrides (card-level) ────────────────────────────
/// <summary>
/// Uniform scale applied to the Model3D asset root. Null = 1.0 (no scaling).
/// Card-level so the same GLB can be reused at different sizes across cards.
/// </summary>
public float? ModelScale { get; set; }
/// <summary>
/// CSS-style hex colour applied multiplicatively to all StandardMaterial3D
/// surfaces on the card's Model3D asset (e.g. "#FF8800"). Null = no tint.
/// Card-level because the tint is part of a card's visual identity, not the
/// shared mesh file.
/// </summary>
public string? ModelTintColor { get; set; }
// ── Ability / Effect data (JSONB) ────────────────────────────────────────
/// <summary>JSONB array of AbilityDefinition objects (ArchSpirit, Spirit, Ruin).</summary>
public string? AbilitiesJson { get; set; }
@@ -0,0 +1,457 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SOR.Database.Contexts;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
[DbContext(typeof(CatalogDbContext))]
[Migration("20260316112327_MoveModelScaleTintToCard")]
partial class MoveModelScaleTintToCard
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("catalog")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ActionName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AnimationTrackName")
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CastSoundCdnUrl")
.HasColumnType("text");
b.Property<string>("ImpactSoundCdnUrl")
.HasColumnType("text");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "ActionName")
.IsUnique();
b.ToTable("card_animation_bindings", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AssetType")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("CardDefinitionId")
.HasColumnType("uuid");
b.Property<string>("CdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("MimeType")
.HasColumnType("text");
b.Property<string>("ModelFacingDirection")
.HasColumnType("text");
b.Property<string>("ModelTintMaskUrl")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CardDefinitionId", "AssetType");
b.ToTable("card_assets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AbilitiesJson")
.HasColumnType("jsonb")
.HasColumnName("abilities");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("AttackType")
.HasColumnType("text");
b.Property<bool?>("CanAttack")
.HasColumnType("boolean");
b.Property<bool?>("CanBeAttacked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeBlocked")
.HasColumnType("boolean");
b.Property<bool?>("CanBeObstructed")
.HasColumnType("boolean");
b.Property<bool?>("CanBeSacrificed")
.HasColumnType("boolean");
b.Property<bool?>("CanDefend")
.HasColumnType("boolean");
b.Property<bool?>("CanMove")
.HasColumnType("boolean");
b.Property<bool?>("CanUseAbility")
.HasColumnType("boolean");
b.Property<string>("CardType")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("CollectorNumber")
.HasColumnType("integer");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("Damage")
.HasColumnType("integer");
b.Property<long>("DefinitionVersion")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasDefaultValue(0L);
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("EffectsJson")
.HasColumnType("jsonb")
.HasColumnName("effects");
b.Property<string[]>("Genus")
.HasColumnType("text[]");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<bool>("IsRetired")
.HasColumnType("boolean");
b.Property<int?>("MaxAttackRange")
.HasColumnType("integer");
b.Property<int?>("MaxChannelRange")
.HasColumnType("integer");
b.Property<int?>("MaxDefense")
.HasColumnType("integer");
b.Property<int?>("MaxHealth")
.HasColumnType("integer");
b.Property<int?>("MinAttackRange")
.HasColumnType("integer");
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<float?>("ModelScale")
.HasColumnType("real");
b.Property<string>("ModelTintColor")
.HasColumnType("text");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");
b.Property<string>("MovementType")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("OtherCostsJson")
.HasColumnType("jsonb")
.HasColumnName("other_costs");
b.Property<Guid?>("PreviousTierId")
.HasColumnType("uuid");
b.Property<string>("Rarity")
.IsRequired()
.HasColumnType("text");
b.Property<bool?>("RequiresLos")
.HasColumnType("boolean");
b.Property<DateTimeOffset?>("RetiredAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("SetId")
.HasColumnType("uuid");
b.Property<int>("SpCost")
.HasColumnType("integer");
b.Property<int>("StCost")
.HasColumnType("integer");
b.Property<string>("TerramorphaMode")
.HasColumnType("text");
b.Property<int?>("Tier")
.HasColumnType("integer");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Affinity");
b.HasIndex("CardType");
b.HasIndex("DefinitionVersion");
b.HasIndex("Name");
b.HasIndex("PreviousTierId");
b.HasIndex("Rarity");
b.HasIndex("SetId");
b.HasIndex("IsPublished", "SetId");
b.ToTable("card_definitions", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Code")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<DateOnly?>("ReleaseDate")
.HasColumnType("date");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.ToTable("card_sets", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CdnUploadRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ContentType")
.HasColumnType("text");
b.Property<bool>("IsAiGenerated")
.HasColumnType("boolean");
b.Property<string>("ObjectKey")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Prefix")
.IsRequired()
.HasColumnType("text");
b.Property<string>("PublicUrl")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UploadedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("IsAiGenerated");
b.HasIndex("ObjectKey")
.IsUnique();
b.HasIndex("Prefix");
b.ToTable("cdn_upload_records", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.GameAudioConfig", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Context")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsActive")
.HasColumnType("boolean");
b.Property<string>("TrackCdnUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TrackName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Context");
b.HasIndex("IsActive");
b.ToTable("game_audio_configs", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.TileModelBinding", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Affinity")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ModelCdnKey")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ModelPublicUrl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Shape")
.IsRequired()
.HasColumnType("text");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Affinity", "Shape")
.IsUnique();
b.ToTable("tile_model_bindings", "catalog");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAnimationBinding", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("AnimationBindings")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardAsset", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "CardDefinition")
.WithMany("Assets")
.HasForeignKey("CardDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CardDefinition");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.HasOne("SOR.Database.Entities.Catalog.CardDefinition", "PreviousTier")
.WithMany()
.HasForeignKey("PreviousTierId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("SOR.Database.Entities.Catalog.CardSet", "Set")
.WithMany("Cards")
.HasForeignKey("SetId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("PreviousTier");
b.Navigation("Set");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardDefinition", b =>
{
b.Navigation("AnimationBindings");
b.Navigation("Assets");
});
modelBuilder.Entity("SOR.Database.Entities.Catalog.CardSet", b =>
{
b.Navigation("Cards");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SOR.Database.Migrations.Catalog
{
/// <inheritdoc />
public partial class MoveModelScaleTintToCard : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ModelScale",
schema: "catalog",
table: "card_assets");
migrationBuilder.DropColumn(
name: "ModelTintColor",
schema: "catalog",
table: "card_assets");
migrationBuilder.AddColumn<float>(
name: "ModelScale",
schema: "catalog",
table: "card_definitions",
type: "real",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ModelTintColor",
schema: "catalog",
table: "card_definitions",
type: "text",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ModelScale",
schema: "catalog",
table: "card_definitions");
migrationBuilder.DropColumn(
name: "ModelTintColor",
schema: "catalog",
table: "card_definitions");
migrationBuilder.AddColumn<float>(
name: "ModelScale",
schema: "catalog",
table: "card_assets",
type: "real",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ModelTintColor",
schema: "catalog",
table: "card_assets",
type: "text",
nullable: true);
}
}
}
@@ -89,12 +89,6 @@ namespace SOR.Database.Migrations.Catalog
b.Property<string>("ModelFacingDirection")
.HasColumnType("text");
b.Property<float?>("ModelScale")
.HasColumnType("real");
b.Property<string>("ModelTintColor")
.HasColumnType("text");
b.Property<string>("ModelTintMaskUrl")
.HasColumnType("text");
@@ -199,6 +193,12 @@ namespace SOR.Database.Migrations.Catalog
b.Property<int?>("MinChannelRange")
.HasColumnType("integer");
b.Property<float?>("ModelScale")
.HasColumnType("real");
b.Property<string>("ModelTintColor")
.HasColumnType("text");
b.Property<int?>("MovementPoints")
.HasColumnType("integer");