mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
99.32k stars 35.12k forks source link

performance/framerate problem #1121

Closed cutama closed 12 years ago

cutama commented 12 years ago

I loaded a file (created with python obj to json converter) that has ~1 million vertices and 400K faces using json loader. I got a very bad framerate, 5 fps at max, barely can rotate it.

What is a good way/practice to handle large models?

Live link here: http://web01.gt-global.com/cu/ruvo.html

Wait for a while, around 1 min, for the file to load.

mrdoob commented 12 years ago

You may gain some fps by disabling antialias on WebGLRenderer but that's quite a big model...

cutama commented 12 years ago

Tried that but does not do much. Is this a problem with webgl or threejs?

mrdoob commented 12 years ago

Seems like the object has 4685 different materials. If you do console.log( renderer.info.render.calls ) it logs 4685, which I it's too many calls for just rendering one object (it's usually 1 call per object). Can you share the original obj?

cutama commented 12 years ago

Sure: http://web01.gt-global.com/cu/ruvo.obj http://web01.gt-global.com/cu/ruvo.mtl

I tried editing the json file and emptying the colors and materials array, but when I tried console.log( renderer.info.render.calls ), it stills output 4685. Why is this? You can see this version here: http://web01.gt-global.com/cu/ruvo2.html

Thank you very much for your help!

cutama commented 12 years ago

i installed webgl inspector and load a much smaller file: http://web01.gt-global.com/cu/tofu2.html

Found that although there is only 1 mesh (10k triangles), there are multiple drawElement calls with 200 and 30 triangles each. This might be the case for bigger models too, causing too many calls to webgl. Is this a bug?

mrdoob commented 12 years ago

Wow. That .obj crashed my whole system when trying to import it on Blender... Did you authored that file?

cutama commented 12 years ago

thank you so much for your help MrDoob! I got that file from an architectural CAD design company I am working with. I am not sure what software it was created with. Sorry about crashing your system, blender sucks for large models i guess.

mrdoob commented 12 years ago

Nope, blender can handle fairly big models. Something wrong with this one though.

Anyway, models that need to be rendered in realtime need to be done in specific ways. In this case seems like there are way too many different materials. A quick solution would be opening the model in a program, select all the objects and apply just one material to all of them.