aframearchilogic3d.io

scene api - getAframeElements


I have use floorplan conversion api to convert my 2d floorplan to 3d and get the sceneId back 71c8eef9-b44e-447f-a0d2-fd299318da56.

I want to convert it to afame component inside my aframe application.So I use getAframeElements and get two entity back and following your official sample:

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)
  })

Then It added to aframe, but nothing happens! I got nothing. Do I miss something?


Solution

  • Hard to tell what's going on there without the full HTML and JavaScript, but the full code to get that working is:

    <!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>
    

    And you can see it working at https://aspiring-snowman.glitch.me/