简体   繁体   中英

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.

I have attemnpted to set 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/

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 . If I change the sign of both arguments, sorting looks okay. Besides, the MeshNormalMaterial now produces a correct visual output.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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