将 2D 对象映射到 3D 空间,保持 2D 尺寸
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是不可能实现的,至少不能准确地实现。透视投影不会将球体映射到圆。看到该图像边缘的球体是如何变形的吗?
(来源: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?
(source: uni-stuttgart.de)