如何将多个3D对象添加到一个ModelViewer
如何在ModelViewer中添加多个3D对象。 我尝试了这 https://github.com/google/model-viewer/issues/482#issuecomment-551268896 但这无效。
代码
<model-viewer>
<model-node src="a.glb"></model-node>
<model-node src="b.glb"></model-node>
</model-viewer>
how to add multiple 3d objects in a modelviewer.
I tried this https://github.com/google/model-viewer/issues/482#issuecomment-551268896
but it didn't work.
code
<model-viewer>
<model-node src="a.glb"></model-node>
<model-node src="b.glb"></model-node>
</model-viewer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将多个模型节点添加到单个
&lt; model-viewer&gt;
的功能仅是概念化的,尚未实现。如您链接到的GitHub帖子所述:
本Github问题中的对话继续描述多个实现建议,如果它们要合并该功能。
如果您想创建一个使用多个模型的场景,则需要使用一个库,例如 triph.js < /a>直到他们熨除了此拟议功能的细节。
如果使用reactjs,则可以使用 gltfjsx ,这显着简化了与导入模型的过程多个网格节点。它使用React-three/drei为您构建一个组件,并为您的组件中的每个网格节点分开。
这是Gltfjsx生成的组件的一个示例:
现在可以在任何地方使用此组件来包括您的3D模型。
The feature of adding multiple model nodes into a single
<model-viewer>
was only conceptualized, and has not been implemented.As stated by the Github post that you linked to:
The conversation in this Github issue goes on to describe multiple implementation suggestions if they were to incorporate the feature.
If you're looking to create a scene with multiple models, you're going to need to use a library such as three.js until they've ironed out the details of this proposed feature.
If you use ReactJS, you can use gltfjsx, which significantly simplifies the process of importing a model with multiple mesh nodes. It builds a component for you using react-three/drei, and separates out each mesh node in the component for you.
Here's an example of a component generated with gltfjsx:
This component can now be used anywhere to include your 3d model.