Jump to content

Webpage crashes when loading obj file


cxiao1
 Share

Recommended Posts

Hello, 

I purchased a 3d scene in the file format of obj, as well as some texture files. The obj file has 187 MB. I tried using the following code to load the obj file (I tested my code with other obj sample files, works ok). However, after a while of loading, my webpage crashes afterwards. I uploaded the screenshot of the webpage after it crashes. 

I use babylon.2.4.js, babylon.objFileLoader.js, node.js for my web service and IIS for the server. 

I was wondering can anyone help me with this issue? 

Thank you so much!!! 

Yours Sincerely, 

Chi Xiao

var camera, scene;
    
window.addEventListener('DOMContentLoaded', function() 
{
   var canvas = document.getElementById('renderCanvas');
   var engine = new BABYLON.Engine(canvas, true);
	    	
   engine.enableOfflineSupport = false;

   BABYLON.SceneLoader.Load("http://127.0.0.1:8082/scenes/kc8/", "kc8.obj",  engine, function (newScene)
   { 
      camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 2, Math.PI / 8, 50, BABYLON.Vector3.Zero(), newScene);
      camera.attachControl(canvas, true);
    		    
      var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), newScene);
      light.diffuse = new BABYLON.Color3(1, 1, 1);
      light.specular = new BABYLON.Color3(1, 1, 1);
      light.groundColor = new BABYLON.Color3(0, 0, 0);
	    		
      engine.runRenderLoop(function() 
      {
         newScene.render();
      });
   		    	
      window.addEventListener('resize', function() 
      {
         engine.resize();
      });
   });
});

 

webpage crashes.JPG

Capture.JPG

Link to comment
Share on other sites

1 hour ago, cxiao1 said:

@max123

  • AnimatedNo
  • RiggedNo
  • VR / AR / Low-polyYes
  • GeometryPolygon mesh
  • Polygons1,252,371
  • Vertices1,600,638
  • TexturesYes
  • MaterialsYes
  • UV MappingYes
  • Unwrapped UVsMixed
  • Plugins usedNo

1.6 mil vertices could be a problem: WebGL uses unsigned shorts and bytes for indices, according to this. Which gives you around 65k vertices.

Link to comment
Share on other sites

@max123, Think that (well know) BJS checks if your WebGL is capable when loading indexes > 16 bit.  If so, limit per mesh is 16,777,216.

This could be tripping up the loader though.  There is special logic in the Blender exporter to split up meshes unless there are multiple materials for meshes > 65535.  I should also mention that BJS's definition of Vertices is likely different than whatever creates a .OBJ file.  Not sure the loader does the optimization though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...