diff --git a/src/renderer/src/studio/SceneStudio.tsx b/src/renderer/src/studio/SceneStudio.tsx index 5d44dbcda..6cfeefaa3 100644 --- a/src/renderer/src/studio/SceneStudio.tsx +++ b/src/renderer/src/studio/SceneStudio.tsx @@ -1,4 +1,6 @@ +import { ChevronLeft, ChevronRight } from 'lucide-react' import { useEffect, useMemo, useState } from 'react' +import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { ScrollArea } from '@/components/ui/scroll-area' import { cn } from '@/lib/utils' @@ -29,9 +31,15 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce const images = useMemo(() => new BridgeAssets(client, setWaiting), [client]) const models = useMemo(() => new BlockModels(images), [images]) const entries = useSceneEntries(client, view.id, packRevision, tell) - const [chosen, setChosen] = useState(null) - const entry = entries.find((candidate) => candidate.key === chosen) ?? entries[0] ?? null - const { scene, mesh, building } = useSceneMesh(client, view.id, entry, packRevision, models, images, tell) + const [chosen, setChosen] = useState<{ key: string; variant: number } | null>(null) + const entry = entries.find((candidate) => candidate.key === chosen?.key) ?? entries[0] ?? null + const variant = entry !== null && chosen?.key === entry.key ? Math.min(chosen.variant, entry.variants - 1) : 0 + const { scene, mesh, building } = useSceneMesh(client, view.id, entry, variant, packRevision, models, images, tell) + const chooseVariant = (next: number): void => { + if (entry !== null) { + setChosen({ key: entry.key, variant: (next + entry.variants) % entry.variants }) + } + } useEffect(() => onSummary(entry === null || scene === null ? null : summaryOf(entry, scene)), [entry, scene, onSummary]) useEffect(() => () => onSummary(null), [onSummary]) @@ -40,6 +48,19 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce <>
+ {entry !== null && entry.variants > 1 && ( +
+ + + Variant {variant + 1} of {entry.variants} + + +
+ )} {building && entry !== null && (
{waiting ?? `Building ${entry.name}`} @@ -47,7 +68,7 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce )}
@@ -80,6 +101,7 @@ function useSceneMesh( client: BridgeClient, viewId: string, entry: SceneEntry | null, + variant: number, packRevision: number, models: BlockModels, images: BridgeAssets, @@ -97,7 +119,7 @@ function useSceneMesh( const stop = new AbortController() setBuilding(true) client - .scene(viewId, key, 0, stop.signal) + .scene(viewId, key, variant, stop.signal) .then(async (found) => { const built = await buildSceneMesh(found, models, images) if (stop.signal.aborted) { @@ -113,7 +135,7 @@ function useSceneMesh( .catch((failure: Error) => !stop.signal.aborted && tell(failure.message)) .finally(() => !stop.signal.aborted && setBuilding(false)) return () => stop.abort() - }, [client, viewId, key, packRevision, models, images, tell]) + }, [client, viewId, key, variant, packRevision, models, images, tell]) useEffect(() => () => disposeMesh(mesh), [mesh]) diff --git a/src/renderer/src/studio/ViewList.tsx b/src/renderer/src/studio/ViewList.tsx index 001416f8d..e4dbf7e50 100644 --- a/src/renderer/src/studio/ViewList.tsx +++ b/src/renderer/src/studio/ViewList.tsx @@ -1,4 +1,4 @@ -import { Box, Gem, Map as MapIcon, Mountain, Sprout, Trees, Waves, type LucideIcon } from 'lucide-react' +import { Box, Gem, Map as MapIcon, Mountain, Shapes, Sprout, Trees, Waves, type LucideIcon } from 'lucide-react' import { Kbd } from '@/components/ui/kbd' import { ScrollArea } from '@/components/ui/scroll-area' import { cn } from '@/lib/utils' @@ -12,7 +12,8 @@ const VIEW_ICONS: Record = { landBiomes: Sprout, seaBiomes: Waves, caveBiomes: Gem, - 'iris:objects': Box + 'iris:objects': Box, + 'iris:objects/procedural': Shapes } interface ViewListProps {