【问题标题】:scene api - getAframeElements场景 api - getAframeElements
【发布时间】:2018-04-07 06:52:39
【问题描述】:

我已经使用平面图转换 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)
  })

然后它添加到框架中,但没有任何反应!我什么都没有。 我错过了什么吗?

【问题讨论】:

    标签: aframe archilogic 3d.io


    【解决方案1】:

    如果没有完整的 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/看到它工作

    【讨论】:

    • 我发现了问题。我只是将 3dio.js 放在 aframe.js 之前,然后什么也没有发生。对不起,这是愚蠢的错误,但我认为应该有一些警告或错误显示。谢谢!
    • @KevinHu 你是对的:在 aframe 之前初始化 3dio.js 时应该有一些警告。将添加。感谢您的反馈!
    猜你喜欢
    • 2021-12-09
    • 2021-09-13
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    • 2020-09-03
    • 1970-01-01
    • 2014-04-05
    • 2015-05-19
    相关资源
    最近更新 更多