将 2D 对象映射到 3D 空间,保持 2D 尺寸

发布于 2024-08-14 01:20:14 字数 420 浏览 3 评论 0原文

我有一个 papervision3d 球体基元,我正在将其添加到场景中。球体的大小设置为半径 285。但是,由于我的相机属性(缩放、聚焦和 z),球体以 206 像素渲染,而不是我想要的 570 像素(2 * 半径)。

将场景中任何对象的 z 设置为在 3D 空间中显示的大小与在 2D 空间中显示的大小相同:

mySphere.z = (this.camera.zoom * this.camera.focus) - Math.abs(this.camera.z) + radius;

不久前,我发现一篇关于这个问题的博客文章,其中解释说,您可以使用以下命令 当我使用几个块时,半径被替换为宽度/2。由于某种原因,这不适用于球体。

关于如何让直径为 570px 的球体显示在屏幕上有什么想法和建议吗?

谢谢。

I have a papervision3d sphere primitive that I am adding to a scene. The sphere is being sized with a radius of 285. However, because of my camera properties (zoom, focus and z) the sphere is rendering at 206px instead of 570px which is what I want (2 * radius).

A while back I found a blog post concerning this very issue and it was explained that you can set the z of any object in the scene to appear in 3D space the same size it would appear in 2D space by using the following:

mySphere.z = (this.camera.zoom * this.camera.focus) - Math.abs(this.camera.z) + radius;

The above worked when I was using several blocks, where radius was replaced with width/2. For some reason this does not work for the sphere.

Any ideas, pointers on how to get a sphere with a 570px diameter to show up on screen?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢欲 2024-08-21 01:20:14

这是不可能实现的,至少不能准确地实现。透视投影不会将球体映射到圆。看到该图像边缘的球体是如何变形的吗?
网格球体
(来源:uni-stuttgart.de

This cannot be achieved, at least not precisely. The perspective projection does not map a sphere to a circle. See how the spheres at the edges of this image are getting deformed?
grid of spheres
(source: uni-stuttgart.de)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文