使用 Sandy 3D AS3,用多个 3D 对象填充视口(精确配合)

发布于 2024-09-02 07:14:56 字数 441 浏览 0 评论 0原文

我正在使用 sandy.primitive.Box 的多个实例将图像拼接在一起。每个盒子的尺寸为 96x91,而视口为 960x273,如果我将盒子布局在 10x3 的完美网格中,这应该会完全适合。但是,我似乎无法获得确切的相机视野。我尝试了几个公式(一个用于调整“焦距”,一个用于直接调整视场)。这两个公式都会产生太窄的视场角。

// focal length
(stage.stageHeight/2) / Math.tan(cam.fov / 2 * Math.PI / 180)

// field of view
2 * Math.atan2( (stage.stageHeight/2), -cam.z ) * (180 / Math.PI)

关于同一项目的另一个问题: 我需要调整每个立方体的视角,使图像看起来处于 2D 空间(平面)中...关于计算此类“校正”的最佳方法有什么想法吗?

I'm stitching together an image using multiple instances of the sandy.primitive.Box. Each box is 96x91 while the viewport is 960x273 which should make for an exact fit if I layout the boxes in a perfect grid of 10x3. However, I can't seem to get the exact camera fieldOfView. I've tried a couple formulas (one for adjusting the "focal length" and one for adjusting the fov, directly). Both of these formulas produce a fov angle that is too narrow.

// focal length
(stage.stageHeight/2) / Math.tan(cam.fov / 2 * Math.PI / 180)

// field of view
2 * Math.atan2( (stage.stageHeight/2), -cam.z ) * (180 / Math.PI)

Another question about the same project:
I need to adjust the perspective of each cube so that the image appears to be in 2D space (flat)... Any ideas on the best method for calculating such a "correction"?

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

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

发布评论

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

评论(1

浮光之海 2024-09-09 07:14:56

在提出这个问题后不久,我意识到在确定距离时我没有考虑立方体的深度(实际上是深度的一半)。

// field of view
2 * Math.atan2( (stage.stageHeight/2), -(cam.z + (cubeDepth/2)) ) * (180 / Math.PI)

I realized shortly after posing this question that I wasn't taking into account the cubes' depth (actually, half of the depth) when determining the distance.

// field of view
2 * Math.atan2( (stage.stageHeight/2), -(cam.z + (cubeDepth/2)) ) * (180 / Math.PI)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文