[英]Render heavy model / mesh on three.js
I know this is a well known question but I was not able to find a good answer. 我知道这是一个众所周知的问题,但我找不到很好的答案。
My usage 我的用法
I use three.js to display 3D models created through drone pictures ( here an example ). 我使用three.js来显示通过无人机图片创建的3D模型( 此处为示例 )。
The problem 问题
I can't render heavy models (1M vertices, 2M faces) : Chrome or WebGl crashed. 我无法渲染沉重的模型(1M顶点,2M面):Chrome或WebGl崩溃了。
What I tried 我尝试了什么
I used Threejs.org examples for all my tests to be sure that it was not my code that didn't work. 我为所有测试使用了Threejs.org示例,以确保不是我的代码不起作用。 I made my test on a x64 Chrome with --max_old_space_size=6144 flag.
我在带有--max_old_space_size = 6144标志的x64 Chrome上进行了测试。
Possible solutions 可能的解决方案
How to reproduce 如何繁殖
For the code, I use basics examples on Threejs.org. 对于代码,我在Threejs.org上使用了基础示例。 For models :
对于型号:
Any ideas to load the big one ? 有什么主意可以加载吗? Thanks !
谢谢 !
EDIT 1 : 编辑1:
I tried to put a breakpoint in the SuccessCallback to see if the overload of RAM is during the load or after. 我试图在SuccessCallback中设置一个断点,以查看RAM的过载是在加载期间还是加载之后。 I was not able to hit the breakpoint, so the overload of RAM is before the SuccessCallback.
我无法达到断点,因此RAM的过载在SuccessCallback之前。
Then I went step by step in the ColladaLoader to find what is using so much RAM. 然后,我一步一步地在ColladaLoader中查找使用了这么多RAM的内存。 Here is the "callstack" :
这是“调用堆栈”:
Could I do any other tests to find the reason of this problem ? 我可以做其他测试以找出此问题的原因吗? Thanks
谢谢
Your textures are waaaay to big, and besides, you don't need them because your model has baked vertex colors, which includes baked lighting. 您的纹理非常大,此外,您不需要它们,因为您的模型具有烘焙的顶点颜色,其中包括烘焙的照明。 Your model therefore does not require UVs eiher.
因此,您的模型不需要UV。
Use ColladaLoader2
, and this pattern. 使用
ColladaLoader2
和这种模式。 It should work. 它应该工作。
var loader = new THREE.ColladaLoader();
loader.load( 'BigModel.dae', function ( collada ) {
var dae = collada.scene;
dae.traverse( function( child ) {
if ( child instanceof THREE.Mesh ) {
child.geometry.removeAttribute( 'uv' ); // you don't need it
child.material = new THREE.MeshBasicMaterial( { // scene lights not required
vertexColors: THREE.VertexColors // you have them, use them
} );
scene.add( child );
}
} );
} );
three.js r.86 three.js r.86
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.