three.js: how to control rendering order

前端 未结 4 589
不知归路
不知归路 2020-12-06 05:13

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 sp

相关标签:
4条回答
  • 2020-12-06 05:30

    for threejs r70 and higher is renderDepth removed.

    0 讨论(0)
  • 2020-12-06 05:36

    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);
    
    0 讨论(0)
  • 2020-12-06 05:36

    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.

    0 讨论(0)
  • 2020-12-06 05:42

    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

    0 讨论(0)
提交回复
热议问题