简体   繁体   English

如何在正交渲染中更正不透明对象的排序顺序

[英]How to correct sort order for opaque objects in orthographic rendering

In THREE.js, When viewing a grid of cubes through an off-axis OrthographicCamera, once the camera rotates enough that the objects ought to occlude one another, it appears that the rendering order of the objects is not based on their position in space, but rather the order in which they were created. 在THREE.js中,当通过离轴的OrthographicCamera查看多维数据集的网格时,一旦摄像机旋转足够多的对象应该相互遮挡,似乎对象的渲染顺序就不是基于它们在空间中的位置,而是它们的创建顺序。

I have attemnpted to set THREE.WebGLRenderer( { antialias: true, sortObjects: false } ); 我已经尝试设置THREE.WebGLRenderer( { antialias: true, sortObjects: false } ); but that doesn't appear to address the issue. 但这似乎无法解决问题。

Here's an animated fiddle to see this bizarre Escher-esque effect: http://jsfiddle.net/rfbvdmxn/2/ 这是一个动画的小提琴,可以看到这种奇怪的Escher风格的效果: http : //jsfiddle.net/rfbvdmxn/2/

Here's the scene just before the objects overlap: 这是对象重叠之前的场景: 离轴正交渲染

As I continue to rotate the camera in the same direction and the objects overlap, you can see that the backmost objects (from the camera's perspective) end up occluding the frontmost objects: 当我继续沿相同方向旋转相机并且对象重叠时,您可以看到(从相机的角度来看)最后面的对象最终遮挡了最前面的对象:

在此处输入图片说明

What's going on here, and more importantly how do I correct this? 这是怎么回事,更重要的是我该如何纠正?

The problem is that you've mixed the constructor parameters top and bottom of OrthographicCamera . 问题在于您混合了OrthographicCamera的构造函数参数的topbottom If I change the sign of both arguments, sorting looks okay. 如果我更改两个参数的符号,排序看起来还可以。 Besides, the MeshNormalMaterial now produces a correct visual output. 此外, MeshNormalMaterial现在可以产生正确的视觉输出。

var camera = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -1000, 2000);

Demo: http://jsfiddle.net/rfbvdmxn/42/ 演示: http//jsfiddle.net/rfbvdmxn/42/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM