THREE.JS:以正确的z标记渲染远处的大物体,并仍然放大小物体 [英] THREE.JS: Render large, distant objects at correct z-indicies and still zoom into small objects

查看:141
本文介绍了THREE.JS:以正确的z标记渲染远处的大物体,并仍然放大小物体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景正在绘制(按比例绘制)地球,月亮和一些航天器.当月亮被地球遮住而不是消失时,它仍然是可见的(通过地球).

I've got a scene where I'm drawing(to scale) the earth, moon, and some spacecraft. When the moon is occluded by the earth, instead of disappearing, it is still visible (through the earth).

通过我的研究,我发现了这一部分问题是,我的相机的近距离设置太小(如链接的文章中所述),近距离的小值会导致Z排序中的舍入导致对非常远的物体产生混乱.

From my research I found that part of the problem is that the near settings for my camera were much too small, as detailed in the article linked, small values of near cause rounding in z-sorting to get fuddled for very distant objects.

这里的复杂性是,当相机放大时,我需要具有细颗粒的z索引,以观察太空飞船(与地球相比,半径最大为61米的物体称重)在r =~ 6.5e+06 meters).为了使物体能够按正确的顺序绘制在月球和地球的尺度上,附近必须至少为100,000 m,这时我不能看近距离的物体.

The complexity here is that I need to have fine grain z-indexes for when the camera is zoomed in, to look at a spacecraft (an object with a radius of 61 meters at most, in comparison to the earth, weighing in at r =~ 6.5e+06 meters). In order to make objects on the scale of the moon and earth to render in the correct order, the near has to be at least 100,000 m at which point I cannot look at close objects.

一种解决方案是减少使用千米的比例尺,但我不能因此而损失精度,而宁愿使用米.

One solution would be to reduce the scale to use kilometers, but I cannot afford to lose that precision, and prefer to use meters.

是否有关于如何使非常大的远距离对象以正确的z指数呈现,同时保持比例和放大小对象的能力的想法?

我的想法(我不知道如何实现):

My Ideas (which I don't know how to implement):

  • 更改z缓冲区以包括更多值和更高分辨率?
  • 将远处的对象添加到"farScene"中,该对象使用"farCamera"渲染,而"farCamera"由近摄相机上使用的相同控件控制?

推荐答案

按照@WestLangley的回答,解决方案是将选项logarithmicDepthBuffer: true添加到渲染器:

As per @WestLangley 's answer, the solution is simply to add the optionlogarithmicDepthBuffer: true to the renderer:

this.renderer = new THREE.WebGLRenderer({antialias: true, logarithmicDepthBuffer: true});

这篇关于THREE.JS:以正确的z标记渲染远处的大物体,并仍然放大小物体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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