In angular the SceneLoader.ImportMeshAsync have not any response

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) => {
}, (error) => {

engine.runRenderLoop(() => {

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.

What browser are you using?

It feels like XMLHttpRequest.DONE in your browser is, for some reason, wrong? (i.e. not 4)

This line, though a bit cryptic, should work the same, if you have XMLHttpRequest.DONE defined correctly or not at all

1 Like

My browser is chrome. And I print the XMLHttpRequest.DONE,it is a function!
Should I declare the type anywhere?

This should not be a function. No idea what defines it, but this is incorrect. This is the standard value:


Check a different browser tab and see if it is still a function.

1 Like

O, I find the problem. Because the zone patch the XMLHttpRequest, and all the attribute has been changed.

I think this is the problem of zone in angular.

So I submit a issue to the zone in github.


1 Like

They should never change system variables. I wonder what is the reasoning behind this…

Glad you could find the issue!