Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

5.3 KB
Raw Blame
---
import GalleryTags from "../../../components/GalleryTags.astro";
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import PageHeader from '../../../components/PageHeader.astro';
import AssetViewer from '../../../components/AssetViewer.astro';
import AssetDownloads from '../../../components/AssetDownloads.astro';
import CodeBlock from '../../../components/CodeBlock.astro';
import StatRow from '../../../components/StatRow.astro';
import EngineNote from '../../../components/EngineNote.astro';
import { bounds, number } from '../../../lib/catalog';
import { PACKS_ENABLED, SITE } from '../../../lib/config';
import { holodeck, holodeckAssetHref, holodeckAssets, holodeckPacks, holodeckScenes, type HolodeckAsset } from '../../../lib/holodeck';

export function getStaticPaths() {
  return PACKS_ENABLED ? holodeckAssets.map(asset => ({ params: { slug: asset.slug }, props: { asset } })) : [];
}
interface Props { asset: HolodeckAsset; }
const { asset } = Astro.props;
const source = await readFile(resolve('..', asset.sourcePath), 'utf8');
const scenes = holodeckScenes(asset);
// Worlds that still place an earlier version of this module; the page names them rather than implying they match.
const earlierIn = holodeckPacks.filter(pack => pack.sceneStillPlacesEarlier?.some(entry => entry.slug === asset.slug)).map(pack => pack.name);
const sceneNames = scenes.map(scene => scene.name).join(' and ');
const description = `${asset.name}: a Kiln asset from the Holodeck ${sceneNames} ${scenes.length > 1 ? 'scenes' : 'scene'}. GLB, editable Kiln source and a link to walk the scene.`;
const schema = {
  '@context': 'https://schema.org',
  '@type': '3DModel',
  name: asset.name,
  description: asset.description,
  license: 'https://creativecommons.org/publicdomain/zero/1.0/',
  url: new URL(holodeckAssetHref(asset), SITE).href,
  image: new URL(asset.poster.src, SITE).href,
  encoding: { '@type': 'MediaObject', contentUrl: asset.runtimeModelDownload.url, encodingFormat: 'model/gltf-binary', contentSize: String(asset.runtimeModelDownload.bytes) },
  isPartOf: scenes.flatMap(scene => [
    { '@type': 'CollectionPage', name: `${scene.name} asset pack`, url: new URL(scene.packHref, SITE).href },
    { '@type': 'CreativeWork', name: `${scene.name}, a walkable Holodeck scene`, url: scene.href },
  ]),
};
---
<BaseLayout title={`${asset.name} · Holodeck · Kiln`} description={description} breadcrumbs={[{label:'Gallery',href:'/gallery/'},{label:asset.name,href:holodeckAssetHref(asset)}]} card="packs" jsonLd={schema} noindex={!asset.review.ownerAccepted}>
  <div class="container py-8">
    <PageHeader>{asset.name}</PageHeader>
    <GalleryTags />
    <p class="lead mt-4">{asset.description}</p>
    <div class="mt-4 flex flex-wrap gap-x-6">
      {scenes.map(scene => <a class="text-link" href={scene.packHref}>{scene.name} pack</a>)}
      {scenes.map(scene => <a class="text-link" href={scene.href}>{scene.label} <span aria-hidden="true">↗</span></a>)}
    </div>
    {earlierIn.length > 0 && <p class="mt-2 max-w-reading text-sm text-dim">The walkable {earlierIn.join(' and ')} {earlierIn.length > 1 ? 'scenes still place' : 'scene still places'} an earlier version of this module until {earlierIn.length > 1 ? 'those worlds are' : 'that world is'} updated.</p>}
    <div class="drawing-sheet mt-8"><AssetViewer name={asset.name} modelUrl={`${asset.runtimeModelDownload.url}?revision=${encodeURIComponent(asset.revisionId)}`} poster={asset.poster.src} posterAlt={asset.poster.alt} posterWidth={asset.poster.width} posterHeight={asset.poster.height} srcsetWebp={asset.poster.srcsetWebp} srcsetAvif={asset.poster.srcsetAvif} /></div>
    <EngineNote extensions={asset.metrics.extensions} />
    <StatRow values={[{label:'Triangles',value:number(asset.metrics.triangles)},{label:'Meshes',value:asset.metrics.meshes},{label:'Materials',value:asset.metrics.materials},{label:'Dimensions (m)',value:bounds(asset.metrics.bounds)}]} />
    <AssetDownloads runtime={asset.runtimeDownload} editable={asset.editableDownload} editableLabel="Full Kiln assets (remixable)" />
    <p class="mt-3 text-sm text-dim">Runtime includes the GLB and its Kiln metadata sidecar. The editable ZIP is this final saved revision: model, exact source, editing manifest and preview. Earlier revisions are left out; the parent revision identifier is kept.</p>
    <p class="mt-3">Import the editable ZIP into Kiln’s Library, or run <code>node kiln.mjs import asset.zip</code> in an authoring workspace. Use Kiln 1.4.0 or later.</p>
    <div class="mt-5 flex flex-wrap gap-5"><a class="text-link" href={asset.runtimeModelDownload.url}>Runtime GLB</a></div>
    <dl class="mt-8 grid gap-4 text-sm"><div><dt>Collection / asset / revision</dt><dd class="break-all font-mono">{asset.collection} / {asset.assetId} / {asset.revisionId}</dd></div>{asset.parentRevision && <div><dt>Parent revision</dt><dd class="break-all font-mono">{asset.parentRevision}</dd></div>}<div><dt>Source SHA-256</dt><dd class="break-all font-mono">{asset.sourceSha256}</dd></div></dl>
    <div class="mt-8"><CodeBlock code={source} label={`${asset.name}: exact saved source`} /></div>
    <p class="mt-5 text-sm text-dim">Asset content is dedicated {holodeck.licence.spdx}. Kiln and Holodeck software keep their own licences.</p>
  </div>
</BaseLayout>