Threejs/WebGL:对于立方体来说最高效的方式? [英] Threejs/ WebGL: Most performant way for just cubes?

查看:25
本文介绍了Threejs/WebGL:对于立方体来说最高效的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Threejs 中,就使用哪些渲染方法/灯光/设置/材质而言,在 xyz 网格上为 WebGL 渲染器显示大量立方体的最佳方式是什么?立方体应该支持基于方向光接收和投射阴影——或者我可以预先计算侧面颜色,如果有帮助并且可能的话——但它们没有任何纹理或特殊旋转.谢谢!

In Threejs, what is the most performant way to display a large number of cubes on an xyz grid for the WebGL renderer, in terms of which rendering methods/ lights/ settings/ material to use? The cubes should support receiving and casting shadows based on a directionLight -- or I can precalculate the side colors if that helps and is possible -- but they don't have any texture or special rotation. Thanks!

推荐答案

请务必合并您的几何图形.它有很大帮助.多达 60 倍的代码.这是一篇解释原因的帖子.它包含一个实际显示差异的演示http://learningthreejs.com/blog/2011/10/05/performance-merging-geometry/

Be sure to merge your geometry. It helps a LOT. up to 60times more code. here is a post explaining why. It contains a demo actually showing the difference http://learningthreejs.com/blog/2011/10/05/performance-merging-geometry/

另一件事是在适用时删除重复的面孔.例如,three.js minecraft demo 从几何体中移除面.http://mrdoob.github.com/three.js/examples/webgl_geometry_minecraft.html演示和 https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_minecraft.html#L106 来源

Another things is to remove the duplicated faces when applicable. For example three.js minecraft demo remove the faces from the geometry. http://mrdoob.github.com/three.js/examples/webgl_geometry_minecraft.html for the demo and https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_minecraft.html#L106 for the source

这篇关于Threejs/WebGL:对于立方体来说最高效的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆