简体   繁体   English

Autodesk Forge 多维数据集

[英]Autodesk Forge View Cube

I have a markup extension for forge viewer, and i want to change the models position with coordinates in markup svg.我有一个 forge 查看器的标记扩展,我想用标记 svg 中的坐标更改模型位置。 I already got the coordinates and tried to change, but nothing.我已经得到了坐标并试图改变,但没有。

i got the coordinates with this code我得到了这个代码的坐标

    let svg = document.querySelector('svg');
    let box = svg.getAttribute('viewBox').split(' ');

and tried to change position with this并试图用这个改变位置

viewer.autocam.camera.position.setX(parseFloat(box[0]));
viewer.autocam.camera.position.setY(parseFloat(box[1]));
viewer.autocam.camera.position.setZ(parseFloat(box[2]));

Your code is changing the camera's position... Are you trying to change the position of the model or that of the camera ?您的代码正在更改相机的位置...您是要更改模型位置还是相机的位置 ... ...

To change the position of the camera try navigation.setView :要更改相机的位置,请尝试navigation.setView

const position = new THREE.vector3(x,y,z)
const target = NOP_VIEWER.navigation.getTarget()
viewer.nativation.setView(position, target)

EDIT编辑

To translate (move) the entire model try translate all the fragments:要翻译(移动)整个模型,请尝试翻译所有片段:

const total = NOP_VIEWER.model.getInstanceTree().fragList.length //fragment is 0 indexed and increments by 1 so basically iterate from 0 to length -1 

//...
for (int i=0,i<total,i++){
const fragProxy = NOP_VIEWER.impl.getFragmentProxy(NOP_VIEWER.model,i);

                const position = new THREE.Vector3(
                    target.x - fragProxy.offset.x,
                    target.y - fragProxy.offset.y,
                    target.z - fragProxy.offset.z);

                fragProxy.position = position;

                fragProxy.updateAnimTransform();

}
            viewer.impl.sceneUpdated(true);

See this sample here for more details.有关更多详细信息,请参阅此处的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM