My enviroement is angular8, and the babylonjs is ok ,and it can create sphere and run ok.
But when I use the SceneLoader.ImportMeshAsync to import mesh of localhost, it is not work. I debug the progress is finished, however, the promise have not any response.
And the code is on below:
ngOnInit() {
var canvas: any = document.getElementById("renderCanvas");
var engine: Engine = new Engine(canvas, true);
var scene: Scene = createScene(engine, canvas);
var camera: ArcRotateCamera = createCamera(scene, canvas);
var building = createBuilding(scene); // the buiding is sphere
SceneLoader.ImportMeshAsync(null, "./assets/mesh/", "2f.gltf", scene, (progress) => {console.log(progress)}).then((result) => {
console.log('hello');
}, (error) => {
console.log('world');
console.log(error);
});
engine.runRenderLoop(() => {
scene.render();
});
}
so, I test the code in javascript environment, and it is work.
I think maybe the npm package has bug.
At last, I find the problem. On the line 143259 of node_modules/babylonjs/babylon.max.js. The if condition is false.
I modify as below:
// if (request.readyState === (XMLHttpRequest.DONE || 4)) {
if (request.readyState === XMLHttpRequest.DONE || request.readyState === 4) { // [debug]
I hope offical to modify it. Now, I just load the babylon.max.js in angular.json, but can not import the babylonjs in the .ts file.