[babylon-loaders ESM] Can't use SceneLoader without global BABYLON (window.BABYLON)
See original GitHub issueRepro
import {
Color3,
Color4,
Engine,
HemisphericLight,
Material,
MeshBuilder,
MirrorTexture,
PBRSpecularGlossinessMaterial,
Scene,
SceneLoader,
StandardMaterial,
UniversalCamera,
Vector3,
} from "@babylonjs/core";
import 'babylonjs-loaders';
. . .
const scene = new Scene(engine);
const camera = new UniversalCamera("camera", new Vector3(0, 5, -10), scene);
camera.setTarget(Vector3.Zero());
// 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)
// });
legacy-glTF2.ts https://github.com/BabylonJS/Babylon.js/blob/eabbf0131755fecc4f9f782e3038063e4a0b55eb/packages/lts/loaders/src/legacy/legacy-glTF2.ts#L10
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My post was hidden because of the spam filter but I’ll wait and resolve it there then, thank you Raanan
Well, the solution I found was register GLTF manually since import wasn’t doing it for me