scene api - getAframeElements



我使用平面图转换 api 将我的 2D 平面图转换为 3d 并将 sceneId 恢复71c8eef9-b44e-447f-a0d2-fd299318da56

我想在我的 aframe 应用程序中将其转换为 afame 组件。所以我使用getAframeElements并返回两个实体并按照您的官方示例:

const sceneEl = document.querySelector('a-scene')
io3d.scene.getAframeElements(sceneId)
  .then(elements => {
    // this will give us two elements
    // The first is the actual scene according to the scene structure hierarchy
    // The second is the camera with potential waypoints that where defined in the scene structure
    // you can leverage the waypoints using our A-Frame tour component
    elements.forEach((el) => {
      // add elements to the scene
      sceneEl.appendChild(el)
    })
    sceneEl.appendChild(element)
  })

然后它增加了框架,但什么也没发生!我一无所获。我错过了什么吗?

如果没有完整的HTML和JavaScript,很难说那里发生了什么,但是让它工作的完整代码是:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
    <script src="https://3d.io/releases/3dio-js/1.x.x/3dio.min.js"></script>
  </head>
  <body>
    <a-scene></a-scene>
    <script>
      io3d.scene.getAframeElements('71c8eef9-b44e-447f-a0d2-fd299318da56').then(elems => {
        document.querySelector('a-scene').appendChild(elems[0])
      })
    </script>
  </body>
</html>

你可以看到它在 https://aspiring-snowman.glitch.me/工作

相关内容

  • 没有找到相关文章

最新更新