Playground Template not loading model in html

glTF Loader Demo | Babylon.js Playground (babylonjs.com)
The skull works and uploads in the playground just fine, but when I download the playground file and try to run it I keep getting this error:
ncaught Error RuntimeError: Unable to load from scenes/skull.babylon: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

One needs a kind of localhost to open such files, otherwise there will be CORS error.


So the solution is to open the downloaded example on localhost, not from the computer file system.

3 Likes

Thank you! That helped with the html , although, my app.js code in vite now has the same problem, any suggestions?

this is the code:GitHub - AmirAce/BabylonWebsite

You need to import loaders as well

import "@babylonjs/loaders/glTF";

and make sure that your relative paths do work.
There is a lot of examples here and everywhere how to use Vite with Babylon.js

I imported the loaders as well, but its still not working, I tried to search tutorials but there is not a lot of documentation, so Im kindof confused as to what Im doing wrong, but I appreciate the help!

Here is one of the simplest Vite+Babylon templates with nice article - Getting started with Babylon.js using Vite and GitHub actions | by Viktor | Medium
Source - GitHub - sotovviktor/babylonjs-project
Another template - GitHub - paganaye/babylonjs-vite-boilerplate
Forum post - How to Vite with Babylon.js (Game Tutorial Series)

3 Likes