I load the model on local environment it take 958 millisecond to load and same model on stage take 1 min to load and the glb file size is 857kb

i facing a issue related slow loading of model suggest me something thanks in advance

1 Like

Hi,
I believe we would need to see a PG and the model? There are a number of ways to speed-up the loading (and a number of reasons why it would display or load only very slowly)…but this really depends on what it is? Eventually the model itself might also requires to go through some optimization. But without seeing anything, all that could be said here would be just based on ‘assumptions’.

https://editor.sw.fit/fde/de/easy/EL-6820-3828/c7fd9e70-9b8a-4683-958c-4333eaf9715dllnnnnnn0-431-1/64040eac881187846afe87a3a5fb2b49?sessionId=ac9e0a3ac604ebfe234b7960e1bba459
there is website link
EL-6820-3828.zip (667.7 KB) that is glb file
CreateScene(scene: Scene, canvas: HTMLCanvasElement) {
this.light = new HemisphericLight(“light”, new Vector3(0, 1, 0), this.scene);
this.light.parent = this.camera
const envTexture = CubeTexture.CreateFromPrefilteredData(“./assets/environment/environmentSpecular.env”, scene)
scene.environmentTexture = envTexture;
// scene.createDefaultSkybox(envTexture);
// scene.environmentIntensity = 0.2;
var blur = 0.8;
var myskybox = scene.createDefaultSkybox(envTexture, true, 10000, blur);
this.createCup()
scene.clearCachedVertexData();
scene.cleanCachedTextureBuffer();

return scene;

}

startTime = performance.now();
async createCup():Promise {
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';
await SceneLoader.ImportMeshAsync("",
  // "./assets/models/", 
  self.modalPath,
  "",
   this.scene, (evt)=>{
  // const loadedStatus = ((evt.loaded*100)/evt.total).toFixed();
  // this.loadingScreen.updateLoadStatus(loadedStatus)
  } ).then((frame) => {
   
    this.scene.createDefaultCamera(true, true, true);
    this.meshes = frame.meshes;
    console.log(this.meshes);
    this.animationgroups = frame.animationGroups;

   if(this.animationgroups.length !== 0){
      // this.modelAnimation();
  //  this.newAnimation(this.engine);
  //  this.modelAnimation()
  this.ifanimatedproduct = true;
  this.animationgroups[0].stop();
   }
   const endTime = performance.now();
   const loadTime = endTime - this.startTime;
   
   // Output the load time to the console
   console.log('Model load time: ' + loadTime + ' milliseconds');
    this.updateMaskedArea();
    if (this.selectedPaper) {
      this.showPaperColorOption(this.selectedPaper);
    }
    this.setcameraposition(this.scene);

  });
  this.engine.hideLoadingUI();

}
loadComponent(engine: Engine) {
console.info(this.threedpreview.nativeElement, this.loaderRef.nativeElement, this.loadingBarRef.nativeElement, this.percentLoadedRef.nativeElement)
const loaderElement = this.loaderRef.nativeElement;
const loadingBarElement = this.loadingBarRef.nativeElement;
const percentLoadedElement = this.percentLoadedRef.nativeElement;

var canvas = this.threedpreview.nativeElement
// const context = canvas.getContext('2d');
//context.clearRect(0, 0, canvas.width, canvas.height);


var w = this.productDetail.Width + this.productDetail.Bleed * 2;
var h = this.productDetail.Height + this.productDetail.Bleed * 2;
var calculateCanvas = this.utilityService.calculateEditingArea(w, h, 0, 0);
//this.arrPaper = this.productDetail.
this.ppi = calculateCanvas.pixelPerUnit;

var settingsJSon = JSON.parse(this.productDetail.settings);


this.engine = new Engine(this.threedpreview.nativeElement, true);
this.loadingScreen = new CustomLoadingScreen(loaderElement, loadingBarElement, percentLoadedElement);
this.engine.loadingScreen =  this.loadingScreen;
this.engine.displayLoadingUI();
this.scene = new Scene(this.engine);
this.createcamera();
this.CreateScene(this.scene, this.threedpreview.nativeElement);

this.engine.runRenderLoop(() => {
  this.engine.resize();
  this.scene.render();

});

window.addEventListener("resize", function () {
  console.log('resized window');
engine.resize();

});
} that is my code

Thanks for the info. That’s a lot more than I expected when reading the title of your post. Are you sure it’s the model import causing that huge difference in loading time? Honestly, one would need to check on all this and without the PG, it’s not really ‘convenient’, so to say. I guess a start would be to just load the model async in a PG to see what happens. Sadly, I’m out of time to investigate this right now (sorry :pray:) so I hope someone else will kick-in and have enough time to go through it. May be wait a bit for the Team (though they might request a PG). I’ll check back later today when I’m done with my own assignments :sweat_smile: Sorry for the wait and meanwhile, have a great day :sunglasses:
BtW: The site looks real cool :+1:

On my computer’s browser(edge 114) this page keeps growing in memory, 100% cpu usage. Finally the page crashes.

Yep Playground please :slight_smile: It’s always one of the first things we ask for because it helps isolate the problem from local factors :slight_smile:

why are you constantly calling resize() in the render loop? That cant be a good thing to do.?

Also, are you comparing local load times to load times on an actual deployment? Requests times are obviously then subject to the said server speed and your ISP speed


without calling resize() in renderloop it is stretch the model
this.engine.runRenderLoop(() => {
// this.engine.resize();
this.scene.render();

});


after calling resize() in renderloop i got proper model

is there other method to call resize please suggest me thanks in advance

you can call resize , its a valid function , i didnt say never call it, i mentioned having it called in the render loop is probably not good since it is then resizing every single frame. I could be wrong here , perhaps the engine handles this gracefully but my suspicions are it is not good. Normally you would add some listener to the page for resizing and then call engine resize only once each time it is required to run , no more.

I also cant access your website link , same as @qq2315137135 mentioned … the page just crashes.

Resize doesn’t do anything if the canvas size hasn’t changed: Babylon.js/packages/dev/core/src/Engines/thinEngine.ts at master · BabylonJS/Babylon.js · GitHub, but it’s good practice anyway to only call it when the canvas is resized. You can see an example here: Getting Started - Chapter 1 - Setup Your First Web App | Babylon.js Documentation (babylonjs.com)

1 Like

Hi, Just passed by looking back at this topic. Still no PG to show? :cry:
Or did you figure it out by yourself?

Anyways, adding on top of the comments of others and with regards to

this is abnormal. Also looking at some of your init lines of codes (which I’m not sure what they are supposed to do just exactly without having the context, like this part :

// const context = canvas.getContext('2d');
//context.clearRect(0, 0, canvas.width, canvas.height);
var w = this.productDetail.Width + this.productDetail.Bleed * 2;
var h = this.productDetail.Height + this.productDetail.Bleed * 2;
var calculateCanvas = this.utilityService.calculateEditingArea(w, h, 0, 0);
//this.arrPaper = this.productDetail.
this.ppi = calculateCanvas.pixelPerUnit;

this all gives me the feeling that your entire approach may just not be correct. Obviously meshes shouldn’t need a resize, a clear or a new render of the canvas to render correctly.