英文:
Implement APS (Forge) AggregatedView with React
问题
我需要一些关于Autodesk AggregatedView Viewer的澄清。
文档提到了以下内容:React兼容性:只需设置来自React属性的节点数组,AggregatedView会负责根据需要加载和隐藏模型。
是否有人有或了解如何设置这样一个节点数组的具体示例(还有节点的类型是什么?),以及这如何可能简化在React环境中集成查看器的过程?
我看到了这篇帖子:Autodesk forge viewer, aggregatedView, React和Ts无法初始化。但对我来说,这与正常的查看器实现没有太大区别。
提前感谢!
英文:
I need some clarification on the Autodesk AggregatedView Viewer.
The documentation mentions the following: React compatibility: Just set an array of nodes from the React property and AggregatedView will take care of loading and hiding models as needed.
Does anyone have or know of a concrete example of how to set such an array of nodes (also what type of nodes?) and how this could potentially simplify viewer integration in a React environment?
I saw this post here: Autodesk forge viewer, aggregatedView,React & Ts unable to initialise. But to me this is not much different from a normal viewer implementation.
Thanks in advance!
答案1
得分: 1
抱歉,以下是您要翻译的内容:
"我担心文档中这句话有点误导。它基本上的意思是 - 与其向查看器添加或删除模型,您可以简单地使用setNodes
方法传递您想要的所有模型,查看器将处理其余部分(添加尚未加载的模型,删除加载但不在您的列表中的模型等)。
顺便说一下,“节点”基本上是代表由模型派生服务为您的模型生成的特定可视化对象。这通常是您可以从doc.getRoot().search(...)
或doc.getRoot().getDefaultGeometry()
调用中获得的对象,就像下面的代码片段中一样:
function onDocumentLoadSuccess(doc) {
viewer.loadDocumentNode(doc, doc.getRoot().getDefaultGeometry());
}
function onDocumentLoadFailure(code, message, errors) {
console.error(code, message, errors);
}
Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
"
英文:
I'm afraid this sentence in the documentation is a bit misleading. What it basically says is - instead of adding or removing models to/from the viewer, you can simply call the setNodes
method with all the models you want, and the viewer will take care of the rest (adding models that are not loaded yet, removing models that are loaded but not in your list, etc.).
Btw a "node" is basically an object representing a specific viewable that was generated by the Model Derivative service for your model. It's the object you would typically get from the doc.getRoot().search(...)
or doc.getRoot().getDefaultGeometry()
calls, like in the snippet below:
function onDocumentLoadSuccess(doc) {
viewer.loadDocumentNode(doc, doc.getRoot().getDefaultGeometry());
}
function onDocumentLoadFailure(code, message, errors) {
console.error(code, message, errors);
}
Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论