auto-git:

[add] src/spline-corridor/bundled-spline-corridor-model-loader.ts
This commit is contained in:
2026-05-13 03:37:42 +02:00
parent 1736163bc5
commit 93764ff2cb

View File

@@ -0,0 +1,35 @@
import { Group } from "three";
import { createConfiguredGltfLoader } from "../assets/gltf-model-import";
const bundledSplineCorridorTemplatePromises = new Map<string, Promise<Group>>();
function getErrorDetail(error: unknown): string {
return error instanceof Error && error.message.trim().length > 0
? error.message.trim()
: "Unknown error.";
}
export function loadBundledSplineCorridorModelTemplate(
bundledPath: string
): Promise<Group> {
const cachedTemplatePromise =
bundledSplineCorridorTemplatePromises.get(bundledPath);
if (cachedTemplatePromise !== undefined) {
return cachedTemplatePromise;
}
const templatePromise = createConfiguredGltfLoader()
.loadAsync(bundledPath)
.then((gltf) => gltf.scene)
.catch((error: unknown) => {
bundledSplineCorridorTemplatePromises.delete(bundledPath);
throw new Error(
`Bundled spline corridor model failed to load from ${bundledPath}: ${getErrorDetail(error)}`
);
});
bundledSplineCorridorTemplatePromises.set(bundledPath, templatePromise);
return templatePromise;
}