In my node.js application running on a server, I have
import * as BABYLON from 'babylonjs';
import loaders from 'babylonjs-loaders';
but then I still cannot load .glb files and both dotglb and glb are false. Is there something else I need to do to activate the .gltf & .glb loaders int the node app?
Thanks,
Michael
const dotglb = BABYLON.SceneLoader.IsPluginForExtensionAvailable(".glb"); // always false
const glb = BABYLON.SceneLoader.IsPluginForExtensionAvailable("glb"); //always false
const modelContent = `data:;base64,${base64}`;
await BABYLON.SceneLoader.AppendAsync("", modelContent, scene); //fails
tri
September 4, 2022, 7:59pm
3
Hi Michael,
Usually loaders are available via the main SceneLoader module. However it looks like your code cannot access those modules for some reason
One solution that might work:
import { IspluginForExtensionAvailable, /*etc*/ } from "@babylonjs/loaders/glTF";
IsPluginForExtensionAvailable(".glb") //hopefully true?
Or
import {IspluginForExtensionAvailable} from "babylonj-s-loaders/glTF"
I think the problem is that you need to get the loaders from the object’s specific subdirectory, like obj or glTF.
The import you use may also depend on whether you need an ES6 ready package?
I hope this is a suitable fix
sebavan
September 5, 2022, 2:20pm
4
Could you try import 'babylonjs-loaders';
instead as the sideEffects should be sufficient.
cc @RaananW in case he has more ideas ?
This is how I’ve been trying [link to discussion ], but I still couldn’t figure out yet
I’m not sure if it was the case, but there’s typo in the code
change below
const modelContent = `data:;base64,${base64}`;
to
const modelContent = `data:base64,${base64}`;
I will share if I get the node server to render a model perfectly! Please share if there’s any progress in yours!
Happy coding!