How to access to model three on mobile or tablette?

孤街醉人 提交于 2019-12-11 17:50:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!