Loading GLTF models in Nodejs

If you want to load GLB files, same as above but

import { readFile } from 'node:fs/promises';

async function loadModel(filePath : string, scene : Scene) {
    const glb = await readFile(filePath, {encoding: 'base64'});
    await SceneLoader.AppendAsync("", "data:;base64," + gltf, scene);
}

Notice the base64 stuff!

4 Likes