three.js: how to control rendering order

自闭症网瘾萝莉.ら 提交于 2020-01-20 03:52:25

问题


Am using three.js

How can I control the rendering order? Let's say I have three plane geometries, and want to render them in a specific order regardless of their spatial position.

thanks


回答1:


You can set

renderer.sortObjects = false;

and the objects will be rendered in the order they were added to the scene.

Alternatively, you can leave sortObjects as true, the default, and specify for each object a value for object.renderOrder.

For more detail, see Transparent objects in Threejs

Another thing you can do is use the approach described here: How to change the zOrder of object with Threejs?

three.js r.71




回答2:


for threejs r70 and higher is renderDepth removed.




回答3:


Using object.renderDepth worked in my case. I had a glass case and bubbles inside that were transparent. The bubbles were getting lost at certain angles.

So, setting their renderDepth to a high number and playing with other elements depths in the scene fixed the issue. Hooking up a dat.gui control to the renderDepth property made it very easy to tweak what needed to be at what depth to make the scene work.

So, in my fishScene, I have gravel, tank and bubbles. I hooked up the gravel mesh with a dat.gui control and with in a few seconds, I had the depth I needed.

this.gui.add(this.fishScene.gravel, "renderDepth", 0, 200);



回答4:


i had a bunch of objects which was cloned from a for loop in random position x and y... and obj.z ++, so they would line up in line.. including obj.renderOrder ++; in the loop solved my issue.



来源:https://stackoverflow.com/questions/15514274/three-js-how-to-control-rendering-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!