1 回答
TA贡献1813条经验 获得超2个赞
可以的,在 Forge Viewer 里头有很多方法可以做到这点,这边我会以 AutoCam.goToView() 来示范,以下样例假设相机的新位置是 ( x1, y1, z1 ):
// 获取当前相机信息
const currentView = viewer.autocam.getCurrentView();
cosnt eye = viewer.navigation.getEyeVector();
const eyeDir = viewVec.normalize();
const distance = eye.length(); //!<<< 相机与焦点的距离
const newPosition = new THREE.Vector3( x1, y1, z1 ); //!<<< 相机的新位置
const target = eye.add( newPosition ); //!<<< 计算新焦点位置
// 产生新相机信息
const newView = {
position: newPosition.clone(), //!<<< 相机的新位置
up: currentView.up.clone(),
center: target.clone(), //!<<< 相机的新焦点
pivot: target.clone(), //!<<< 相机的新环绕(Orbit)中心
fov: currentView.fov,
worldUp: currentView.worldUp.clone(),
isOrtho: (currentView.isOrtho === false)
};
// 将信息更新到相机上
viewer.autocam.goToView( newView );
以上希望对你帮助~
添加回答
举报
