I want to place some three.js object in the Viewer, having the estimated coordinates of this object in the Revit model. How can I convert these coordinates to Viewer coordinates to place an object?
Since Forge viewer will apply a global offset to the loaded model to avoid the floating issue of the coordinates by default, you have to subtract it from coordinates of your owned three.js object in the Revit space.
// To obtain the global offset
const globalOffset = viewer.model.getData().globalOffset;
const ptInRvt = new THREE.Vector3( 10, 5 ,0 );
// Apply the offset
const offsetPt = ptInRvt.clone().sub( globalOffset );
If there are some reasons, your global offset is zero. You can offset it with the placement offset as well
// placement offset
const offsetMatrix = viewer.model.getData().placementWithOffset;
const ptInRvt = new THREE.Vector3( 10, 5 ,0 );
const offsetPt = ptInRvt.applyMatrix4( offsetMatrix );
Hope it helps.