Reputation: 35
When I use section function in my Forge Viewer, camera feel bad. I think it could be because of default origin of coordinate. How can I set origin of the coordinate relative with my loaded and translated *.rvt model?
Upvotes: 0
Views: 568
Reputation: 9942
When you are loading a model using the loadDocumentNode, you can specify additional loading options in a 3rd parameter to the method call, including a global offset to be applied to all the loaded geometry, for example, like so:
async function loadViewable(viewer, urn, xform /* THREE.Matrix4 */, offset /* THREE.Vector3 */) {
return new Promise(function (resolve, reject) {
function onDocumentLoadSuccess(doc) {
const viewable = doc.getRoot().getDefaultGeometry();
let options = {};
if (xform) {
options.placementTransform = xform;
}
if (offset) {
options.globalOffset = offset;
}
viewer.loadDocumentNode(doc, viewable, options)
.then(resolve)
.catch(reject);
}
function onDocumentLoadFailure(code) {
reject(`Could not load document (${code}).`);
}
Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
});
}
Upvotes: 2