在移动VR中锻造视角(Forge view angle in mobile VR)

编程入门 行业动态 更新时间:2024-10-28 04:26:18
在移动VR中锻造视角(Forge view angle in mobile VR)

当在手机上启动VR工具并直接在前方观看时,我想让视图在屏幕中央显示整个模型。 视角应该略微倾斜,所以我可以看到整个建筑楼层。 目前它是直接向前,这使您看不到整个模型的视图。 我怎么能实现这个目标?

例如,在此Autodesk示例中,当您输入VR时,模型位于中心。

http://viewervr.herokuapp.com/

目前的代码,与我试图调整相机位置

document.getElementById("toolbar-vrTool").addEventListener("click", function () { let _navapi = viewer.navigation; let _camera = _navapi.getCamera(); let xValue = viewer.getCamera().position.x; let yValue = viewer.getCamera().position.y; let zValue = viewer.getCamera().position.z; zValue = zValue * 0.5; yValue = (zValue * 0.7071) * -1; _camera.position.set(xValue, yValue, zValue); });

目前来看

查看我想要的

When starting VR tool on mobile and watching directly ahead, I would like to have the view to show the whole model in the center of the screen. The view should be at a slight angle, so I could see the whole building floor. Currently it is directly ahead, which leaves you with a view where you cannot see the whole model. How could I achieve this?

For example, in this Autodesk example, the model is in the center when you enter VR.

http://viewervr.herokuapp.com/

Current code, with what I am trying to adjust the camera position

document.getElementById("toolbar-vrTool").addEventListener("click", function () { let _navapi = viewer.navigation; let _camera = _navapi.getCamera(); let xValue = viewer.getCamera().position.x; let yValue = viewer.getCamera().position.y; let zValue = viewer.getCamera().position.z; zValue = zValue * 0.5; yValue = (zValue * 0.7071) * -1; _camera.position.set(xValue, yValue, zValue); });

Current view

View I would like to have

最满意答案

有一个名为fitToView()的函数可以完全按照您的意愿执行。 但是在使用之前,您需要等待几何体完全加载。 我还在下面的示例中添加了对setHomeViewFrom()的调用,将Home位置重置为fitToView()位置结果以供稍后导航。

oViewer.addEventListener (Autodesk.Viewing.GEOMETRY_LOADED_EVENT, onViewerGeometryLoaded) ; function onViewerGeometryLoaded () { oViewer.removeEventListener (Autodesk.Viewing.GEOMETRY_LOADED_EVENT, onViewerGeometryLoaded) ; oViewer.fitToView (true) ; setTimeout (function () { oViewer.autocam.setHomeViewFrom (oViewer.navigation.getCamera ()) ; }, 1000) ; }

There is a function named fitToView() which will do exactly what you want. But you need to wait for the geometry to be fully loaded before using it. I also added a call to setHomeViewFrom() in the example below to reset the Home position to the fitToView() position result for later navigation.

oViewer.addEventListener (Autodesk.Viewing.GEOMETRY_LOADED_EVENT, onViewerGeometryLoaded) ; function onViewerGeometryLoaded () { oViewer.removeEventListener (Autodesk.Viewing.GEOMETRY_LOADED_EVENT, onViewerGeometryLoaded) ; oViewer.fitToView (true) ; setTimeout (function () { oViewer.autocam.setHomeViewFrom (oViewer.navigation.getCamera ()) ; }, 1000) ; }

更多推荐

本文发布于:2023-04-28 08:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1331376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视角   Forge   VR   mobile   angle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!