Feature: tile height variation + stalagmite bottoms + live content refresh
## Tile height variation (fix) Tile tops now visibly vary (0.8–1.0) from a fixed bottom at world Y=0. Previously the top was fixed and the variation was only visible underneath. Heights are seeded by tile coordinate so they're deterministic per board. Unit y_offsets and highlight positions update to match per-tile height. ## Stalagmite tile bottoms Server: new TileBottomModel entity + migration (catalog.tile_bottom_models), content.tile_bottoms handler returns all active CDN URLs. Admin: "Tile Bottom Models" section in the Tile Model Manager page — add/toggle active/delete entries with CDN picker. Client: ContentCache fetches + disk-caches the URL pool; _try_load_tile_model picks a random URL and attaches it flipped below the tile model as a stalagmite using the existing _fit_model_to_tile scale logic. ## Live content refresh ContentCache schedules start_sync() every 5 minutes after sync_complete so card definitions, tile models, and bottom models are refreshed in the background without restarting the client. 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:
@@ -75,6 +75,59 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
<!-- ── Tile Bottoms (stalagmite undersides) ── -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-medium d-flex justify-content-between align-items-center">
|
||||
<span>Tile Bottom Models <span class="text-muted small fw-normal">(stalagmites, randomly selected per tile)</span></span>
|
||||
<button class="btn btn-sm btn-outline-primary" @onclick="OpenBottomPickerAsync">
|
||||
<i class="bi bi-plus me-1"></i>Add
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
@if (_bottomModels.Count == 0)
|
||||
{
|
||||
<div class="text-muted text-center py-3 small">No bottom models yet — upload GLBs and add them here.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-sm table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Model</th>
|
||||
<th style="width:80px">Active</th>
|
||||
<th style="width:100px"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var bottom in _bottomModels)
|
||||
{
|
||||
var b = bottom;
|
||||
<tr>
|
||||
<td class="align-middle font-monospace small text-break">
|
||||
@(b.CdnKey.Contains('/') ? b.CdnKey[(b.CdnKey.LastIndexOf('/') + 1)..] : b.CdnKey)
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<input type="checkbox" class="form-check-input" checked="@b.IsActive"
|
||||
@onchange="e => ToggleBottomActiveAsync(b, (bool)e.Value!)" />
|
||||
</td>
|
||||
<td class="align-middle text-end pe-2">
|
||||
<button class="btn btn-sm btn-outline-info py-0 me-1"
|
||||
@onclick="() => _previewUrl = b.PublicUrl" title="Preview">
|
||||
<i class="bi bi-box"></i>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-danger py-0"
|
||||
@onclick="() => DeleteBottomAsync(b)" title="Delete">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Assign / Picker Modal -->
|
||||
@if (_pickerOpen)
|
||||
{
|
||||
@@ -198,6 +251,63 @@ else
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Bottom Model Picker Modal -->
|
||||
@if (_bottomPickerOpen)
|
||||
{
|
||||
<div class="modal d-block" tabindex="-1" style="background:rgba(0,0,0,0.55)">
|
||||
<div class="modal-dialog modal-xl modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Add Tile Bottom Model</h5>
|
||||
<button type="button" class="btn-close" @onclick="() => _bottomPickerOpen = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input @bind="_bottomPickerSearch" @bind:event="oninput"
|
||||
class="form-control form-control-sm font-monospace mb-3"
|
||||
placeholder="Filter models…" />
|
||||
@if (_pickerLoading)
|
||||
{
|
||||
<div class="text-muted text-center py-4">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>Loading CDN models…
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row g-3">
|
||||
@foreach (var model in BottomPickerFiltered())
|
||||
{
|
||||
var m = model;
|
||||
var isSel = _bottomPickerSelected == m.Key;
|
||||
<div class="col-md-4">
|
||||
<div class="card h-100 @(isSel ? "border-primary" : "")"
|
||||
style="cursor:pointer" @onclick="() => _bottomPickerSelected = m.Key">
|
||||
<div class="card-body py-2 px-3">
|
||||
<div class="font-monospace small text-break">@m.ShortName</div>
|
||||
</div>
|
||||
@if (isSel)
|
||||
{
|
||||
<div class="card-footer py-1 bg-primary text-white text-center small">✓ Selected</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" @onclick="() => _bottomPickerOpen = false">Cancel</button>
|
||||
<button class="btn btn-primary"
|
||||
disabled="@(_bottomPickerSelected is null || _saving)"
|
||||
@onclick="SaveBottomAsync">
|
||||
@if (_saving) { <span class="spinner-border spinner-border-sm me-1"></span> }
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js"></script>
|
||||
|
||||
@code {
|
||||
@@ -236,6 +346,12 @@ else
|
||||
("Gateways", new[] { Affinity.GatewayLake, Affinity.GatewayHill, Affinity.GatewayForest, Affinity.GatewayField }),
|
||||
};
|
||||
|
||||
// Tile bottom models
|
||||
private List<TileBottomModel> _bottomModels = new();
|
||||
private bool _bottomPickerOpen;
|
||||
private string _bottomPickerSearch = "";
|
||||
private string? _bottomPickerSelected;
|
||||
|
||||
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadAsync();
|
||||
@@ -245,6 +361,7 @@ else
|
||||
_loading = true;
|
||||
var all = await Db.TileModelBindings.ToListAsync();
|
||||
_bindings = all.ToDictionary(b => (b.Affinity, b.Shape));
|
||||
_bottomModels = await Db.TileBottomModels.OrderBy(m => m.CdnKey).ToListAsync();
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
@@ -378,6 +495,68 @@ else
|
||||
_isError = false;
|
||||
}
|
||||
|
||||
// ── Tile Bottom Models ────────────────────────────────────────────────────
|
||||
|
||||
private async Task OpenBottomPickerAsync()
|
||||
{
|
||||
_bottomPickerSelected = null;
|
||||
_bottomPickerSearch = "";
|
||||
_bottomPickerOpen = true;
|
||||
_pickerLoading = true;
|
||||
await LoadPickerModelsAsync();
|
||||
}
|
||||
|
||||
private IEnumerable<ModelItem> BottomPickerFiltered()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_bottomPickerSearch))
|
||||
return _pickerModels;
|
||||
return _pickerModels.Where(m =>
|
||||
m.Key.Contains(_bottomPickerSearch, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private async Task SaveBottomAsync()
|
||||
{
|
||||
if (_bottomPickerSelected is null) return;
|
||||
_saving = true;
|
||||
try
|
||||
{
|
||||
var options = CdnOptionsAccessor.Value;
|
||||
var publicUrl = BuildPublicUrl(options, _bottomPickerSelected);
|
||||
var model = new TileBottomModel
|
||||
{
|
||||
CdnKey = _bottomPickerSelected,
|
||||
PublicUrl = publicUrl,
|
||||
IsActive = true,
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
Db.TileBottomModels.Add(model);
|
||||
await Db.SaveChangesAsync();
|
||||
_bottomModels.Add(model);
|
||||
_bottomModels = _bottomModels.OrderBy(m => m.CdnKey).ToList();
|
||||
_bottomPickerOpen = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_message = $"Save failed: {ex.Message}";
|
||||
_isError = true;
|
||||
}
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
private async Task ToggleBottomActiveAsync(TileBottomModel model, bool active)
|
||||
{
|
||||
model.IsActive = active;
|
||||
model.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private async Task DeleteBottomAsync(TileBottomModel model)
|
||||
{
|
||||
Db.TileBottomModels.Remove(model);
|
||||
await Db.SaveChangesAsync();
|
||||
_bottomModels.Remove(model);
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||
|
||||
private RenderFragment ModelCell(TileModelBinding? binding, Affinity affinity, TileShape shape) => __builder =>
|
||||
|
||||
Reference in New Issue
Block a user