I have a markup extension for forge viewer, and i want to change the models position with coordinates in markup 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
:
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.
No, I try to change position of the model, but positions i get from markup svg.How can i do it?
Thank you very much!!