// The built-in phantoms, bundled as genuine `.phantom` (HDF5) assets. They are // generated by scripts/gen-phantoms.mjs. Vite's `?url` import copies each file // into the build and gives a base-correct URL to fetch at runtime. import cubeUrl from './data/cube.phantom?url' import sphereUrl from './data/sphere.phantom?url' import { loadPhantom } from './loadPhantom.ts' import type { Phantom } from './phantomTypes.ts' export interface BuiltinPhantom { id: string label: string description: string url: string } export const BUILTIN_PHANTOMS: BuiltinPhantom[] = [ { id: 'cube', label: 'Cube', description: '10 mm cube, uniform spins', url: cubeUrl, }, { id: 'sphere', label: 'Sphere', description: '10 mm sphere, uniform spins', url: sphereUrl, }, ] export async function fetchBuiltinPhantom(b: BuiltinPhantom): Promise { const resp = await fetch(b.url) if (!resp.ok) throw new Error(`Failed to fetch phantom "${b.id}": ${resp.status}`) const buf = await resp.arrayBuffer() return loadPhantom(buf, b.label) }