Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[babylon-loaders ESM] Can't use SceneLoader without global BABYLON (window.BABYLON)

See original GitHub issue


import {
} from "@babylonjs/core";

import 'babylonjs-loaders';

. . .

const scene = new Scene(engine);
const camera = new UniversalCamera("camera", new Vector3(0, 5, -10), scene);

// Using already imported SceneLoader doesn't work
(window as any).BABYLON.SceneLoader.Append("", __MyGltf__, scene, function () { 
    scene.meshes[0].position.set(0, 0,0)

// Replacing  import "@babylonjs/loaders/glTF"  by import  "@babylonjs/loaders/glTF" and use already imported SceneLoader doesn't show anything
// SceneLoader.Append("", __MyGltf__, scene, function () { 
//     scene.meshes[0].position.set(0, 0,0)
// });


Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

runtothedoorcommented, Jul 25, 2022

We are using our forum as a place for discussion and I will be happy to see a reproduction of your project to help you debug this. I tested my template-project and it works as expected, so it is probably a configuration issue on your side. Waiting at the forum to help further. Thanks 😃

My post was hidden because of the spam filter but I’ll wait and resolve it there then, thank you Raanan

runtothedoorcommented, Jul 26, 2022

Well, the solution I found was register GLTF manually since import wasn’t doing it for me

SceneLoader.RegisterPlugin(new GLTFFileLoader()); 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to use SceneLoader.ImportMesh to import .babylon file
Hi, I'm trying to import a .babylon file using ImportMesh() like follow: BABYLON.SceneLoader.ImportMesh(“trunk”, “”, “trunk.babylon”, this.
Read more >
Babylon JS - SceneLoader from Local File - Stack Overflow
First issue posed by OP: Browser is not loading mesh from file system. Solution: Use a web server such as Simple HTTP Server...
Read more >
Loaders are unavailable through NPM · Issue #2265 - GitHub
To register the file loader with babylon for the use with AssetsManager etc. However, there doesn't appear to be any loader code available ......
Read more >
Babylon.js 4.0 Is Here! - Windows Developer Blog
js 4.0 has officially been released. This version of Babylon.js is a major step forward in one of the world's leading WebGL-based, graphics ......
Read more >
Understanding asynchronous code in Babylon.js - Medium
Asynchronous calls are not really new to JavaScript. Every time we have a callback, we can consider that we are using some asynchronous...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found