On stage model load very slow

when i use Sceneload.Importmesh model load instant on the stage and when use Sceneload.AsyncImportmesh the loading of model goes slow
createCup(){
var self = this;

self.meshUrl = this.productDetail.productCode + ".glb"
self.modalPath = environment[global.env].RESOURCE_URL_AMAZON + environment[global.env].RESOURCE_CONTAINER + environment[global.env].oemCode + "/preview/" + this.productDetail.productCode + '.glb';
Promise.all([
SceneLoader.ImportMeshAsync(null,
// "./assets/models/", 
self.modalPath,

null,
self.scene).then(function (frame) {
self.scene.createDefaultCamera(true, true, true);
self.meshes = frame.meshes;
console.log(self.meshes);
self.animationgroups = frame.animationGroups;
})
])

.then(() => {
           
            if(self.animationgroups.length !== 0){
          self.ifanimatedproduct = true;
          self.animationgroups[0].stop();
          }
          
              self.updateMaskedArea();
          if (self.selectedPaper) {
            self.showPaperColorOption(self.selectedPaper);
          }
          self.setcameraposition(self.scene);
      })

If you want to find the difference between
BABYLON.SceneLoader.ImportMesh and BABYLON.SceneLoader.ImportMeshAsync

  1. If you import a piece of code from within your own project, you won’t be able to tell if the problem is in the before or after code. so reproduce using in PlayGround
  2. Or as your self confirmation without any other conditions purely by importing without any conditions to check the speed

It may be slightly slowed down by logic or ordering within the project, but If it becomes very slow, as you say, that would be a problem.

1 Like

The problem is that when I am loading the import mesh on the stage, the model is loading instantly.
SceneLoader.ImportMesh(null,
// “./assets/models/”,
self.modalPath,
null,
self.scene,(function (frame, paticlesystems, skeleton, animationGroups) {
self.scene.createDefaultCamera(true, true, true);
self.meshes = frame;
console.log(self.meshes);
self.animationgroups = animationGroups;
}) this much of code

and when i call these functions inside of import mesh than it goes slow and take 30 second and glb file size is 857kb
if(self.animationgroups.length !== 0){
self.ifanimatedproduct = true;
self.animationgroups[0].stop();
}

              self.updateMaskedArea();
          if (self.selectedPaper) {
            self.showPaperColorOption(self.selectedPaper);
          }
          self.setcameraposition(self.scene);

Try eliminating the culprits one by one
The above implies that synchronous and asynchronous loading are basically the same, right?
If so, it’s the following code that makes the difference

if(self.animationgroups.length !== 0){
self.ifanimatedproduct = true;
self.animationgroups[0].stop();
}

maybe checked this

  1. Check when self.animationgroups: undefined
  2. Check self.updateMaskedArea()
  3. Check self.showPaperColorOption(self.selectedPaper)
  4. Check self.setcameraposition(self.scene)

It sounds obvious, but
There may be some form of duplication of effort or slowdown due to empty values in what is called inside the following functions.

Other things

  1. check model(common causes is it)
  2. you using library( react.js , next.js …) did you do scenes and engines dispose correctly?

This is my guess from what you have provided and you may have already found the answer Inside your project

2 Likes

Would be great if you could share a playground :slight_smile:

As the only difference is

It sounds really strange it would be related to only this call and I suspect your process:
image

to be the slow one.

2 Likes

thanks but i solve the problem

1 Like

For the insight of other users looking at this topic, may we ask you to provide just a small explanation towards how you fixed the issue on your own (congrats :clap:)? And then, could I also ask you to kindly mark your post/finding as ‘the solution’ in order to avoid people trying to solve an issue that is no longer an issue :relieved:
Glad you found your way around it and meanwhile, have a great day :sunglasses:

1 Like