我正在开发一个配置器,并使用 Autodesk Viewer 查看我们的 3D 模型。
有时有点滞后/慢,所以我想自己尝试托管模型,看看这是否可以提高加载速度。我在这里找到了示例 https://github.com/Autodesk-Forge/viewer-javascript-offline.sample/tree/gh-pages ,调整后我可以从公共目录成功加载我的模型。
但是,我只能在查看器初始化时设置模型。我想从反应应用程序动态加载模型。
我从这里改编了反应包装器:https://github.com/autodesk-platform-services/viewer-react-sample/blob/master/src/components/Viewer.jsx
但是只有当我在初始化中加载模型时,加载模型才有效:
this.viewer = new Autodesk.Viewing.Viewer3D(this.container);
this.viewer.start(this.props.path);
是否可以像从应用程序OSS中获取模型一样动态加载节点/模型?下面不加载模型。最终我想尝试从我自己的服务器 i.c.m 加载模型。 AggregateView / 加载多个模型。
onDocumentLoadSuccess(doc) {
this.viewer.loadDocumentNode(doc, doc.getRoot().getDefaultGeometry()),
console.log('loaded document node')
}
updateViewerState(prevProps) {
if (this.props.path && this.props.path !== prevProps.path) {
Autodesk.Viewing.Document.load(this.props.path, (doc) =>
onDocumentLoadSuccess(),
// failure
(code, message, errors) => console.error(code, message, errors),
);
}
else if (!this.props.path && this.viewer.model) {
this.viewer.unloadModel(this.viewer.model);
}
}
Document.load()
,您必须将 URN 或 URL 传递到 bubble.json
文件。loadModel()
(Viewer.start()
也使用),您必须将 URN 或 URL 传递到 *.svf
文件。这就是您需要使用的。更多信息似乎仍然或多或少正确: https://stackoverflow.com/a/39758123/4654233