如何在 Autodesk Forge Viewer 中获取和恢复当前设置

How to get and restore current Settings in Autodesk Forge Viewer

我需要 store/restore 设置面板的值。我该怎么做?

我用了下面的但是没有成功

在我的场景中,我更改了Ghost hidden objectsDisplay Unit,然后:

let current_profile = NOP_VIEWER.profileManager.getProfileOrDefault();
let profile = new Autodesk.Viewing.Profile(current_profile);

之后又把Ghost隐藏对象和Display Unit换了一些,然后:

NOP_VIEWER.setProfile(profile);

解决方案是使用 viewer.getState():

存储设置:

let current_state = NOP_VIEWER.getState();
let render_options = current_state.renderOptions;

恢复设置:

let state = {renderOptions: render_options}
NOP_VIEWER.restoreState(state);

更多信息:https://autodeskviewer.com/viewers/latest/docs/tutorial-viewer_state.html