I know this question has come up a lot, but none of the solutions I’ve seen are working for me.
I’m getting this error:
Uncaught (in promise) RuntimeError: Unable to load from ./assets/models/tree.glb: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse
at errorHandler (index.js:49172:40)
at Object.importMesh (index.js:122760:9)
at index.js:49205:27
at dataCallback (index.js:49048:7)
at index.js:16809:5
at XMLHttpRequest.onReadyStateChange (index.js:16905:17)
I’m trying to import a mesh like so:
SceneLoader.ImportMeshAsync(['tree'], './assets/models/', 'tree.glb', undefined, undefined, '.glb').then((result) => {
const tree = result.meshes[0];
tree.position = new Vector3(0, 0, 0);
});
}
Here are my imports:
import { Engine, HemisphericLight, Scene, SceneLoader, UniversalCamera, Vector3 } from '@babylonjs/core';
import { Inspector } from '@babylonjs/inspector';
import { EcsEngine } from './ecsEngine';
import { Section, TrackComponent } from './components/track.component';
import { Entity } from 'tick-knock';
import { initSystems } from './startup/systemRegistration';
import { LocomotiveComponent } from './components/locomotive.component';
import '@babylonjs/loaders/glTF';
and my package.json:
{
"name": "boxcar",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "^1.0.14"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@babylonjs/core": "^6.31.0",
"@babylonjs/inspector": "^6.31.0",
"@babylonjs/loaders": "^6.31.0",
"eslint": "^8.54.0",
"prettier": "^3.1.0",
"tick-knock": "^4.2.0"
}
}
You can find the whole repo here: GitHub - ThomasBurgess2000/boxcar at choo-choo (relevant file is src/game.ts)