Import a 3D Model and automatically assign and export animations
TypeScript
import manifest_json from '../../static/assets/manifest.json'
import props_manifest_json from '../../static/assets/props_manifest.json'
import { type AssetManifest } from './interfaces/AssetManifest'
import { type PropsManifest } from './interfaces/PropsManifest'
/**
* Typed access to the manifests generated by the external assets repository.
* The JSON files are imported at build time, so these shapes are checked by the compiler
* whenever the asset repository exports a new version.
*
* File paths in the manifests are relative to the assets folder. Use asset_path() to
* convert them to a path relative to the static root, which is what the rest of the app uses.
*/
export const ASSETS_FOLDER = 'assets/'
export const asset_manifest: AssetManifest = manifest_json
export const props_manifest: PropsManifest = props_manifest_json
/** Convert a manifest file path to a path relative to the static root, e.g. 'assets/human/model.glb' */
export function asset_path (manifest_file: string): string {
return `${ASSETS_FOLDER}${manifest_file}`
}