I want to create a Babylon.js scene in Webflow, but I can only upload .glb files as .txt. I’ve seen someone use Three.js to do this, but I can’t figure out how to import my asset this way using:
The scene works fine without it. Could it be due to Vite JS? I had issues before until I discovered that I needed to add this for the Havok plugin to work in vite.config.js:
optimizeDeps: {
exclude: ['@babylonjs/havok'],
}
(I tried to exclude “@babylonjs/loaders/dynamic” too but it didn’t worked)
import * as BABYLON from 'babylonjs';
import HavokPhysics from '@babylonjs/havok';
import { registerBuiltInLoaders } from "@babylonjs/loaders/dynamic";
registerBuiltInLoaders();
And it doesn’t work even if I only add what’s in the Playground after this.
The errors in your original screenshot seemed like they were due to a mix of importing from UMD and ES6. Once you have everything importing from ES6 packages (as @labris suggested), then using registerBuiltInLoaders should work fine (and is often a better choice because it allows code splitting in yoru final bundle, where the loader code is not downloaded to the client until you actually load a model of that type). If you have everything working with import "@babylonjs/loaders/glTF" and you just switch that one part back to:
import { registerBuiltInLoaders } from "@babylonjs/loaders/dynamic";
registerBuiltInLoaders();
Do you get errors when loading a model, and if so, what are they?