问题
I'm trying to list some elements of my building by accessing to the Three of my model.
It's working very fine on my computer but not on my Ipad or Tablet.
I'm using this code :
getInstanceTree() {
return new Promise(async (resolve, reject) => {
try {
let viewer = LevelsExtension.viewer;
viewer.getObjectTree(function (instanceTree) {
return resolve(instanceTree);
},
function (errorCode) {
return reject(errorCode);
});
} catch (ex) {
return reject(ex)
}
})
};
On mobile and Ipad, return reject(errorCode);
is call with undefined
value in the errorCode
.
How can I do that?
回答1:
An error callback with no error code might indicate that the model database (where the object tree is stored) is not yet available. At what point are you calling the getInstanceTree()
method?
The viewer triggers an event when the model database is ready - you can subscribe to it using viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, function(ev) { ... })
.
Hope that helps :)
EDIT: following up on our discussion on the gist, and for anyone running into similar problems:
When you're unable to access the object tree of a model on a mobile device, you're likely hitting memory limits of the Forge viewer, and you can try to bypass those by explicitly setting the limits to zero:
viewer = new Autodesk.Viewing.Private.GuiViewer3D(
document.getElementById('viewer'),
{ memory: { limit: 0 } }
);
来源:https://stackoverflow.com/questions/51909038/how-to-access-to-model-three-on-mobile-or-tablette