Search code examples
aframestl-format

A-Frame Loader for STL File


I'm trying to include a STL file like a GLTF object in my A-Frame page, but I'm not making progress. I don't understand why the file doesn't work in a similar manner. Here is my code for the working page on Glitch with a GLTF file and a non-working one with the STL file. All object files are hosted on GitHub.

glitch.com/edit/#!/dramatic-hornet

(below is the non-working code excerpt copied from Glitch)

<a-scene>
   <a-assets>
     <a-asset-item id="object" src="https://github.com/rschildge/models/raw/master/NinjaSpinner.stl"></a-asset-item>
   </a-assets>

 <a-entity model="#object" position="0 0 -4" scale=".1 .1 .1"></a-entity>
 <!-- <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>-->
  <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
  <a-sky color="#ECECEC"></a-sky>
</a-scene>

Solution

  • As far as i know, a-frame's core doesn't have any loader for the .stl format.

    There is a pretty recent community-made loader, be sure to check it out. If it won't work, be sure to file an issue. If it works - give it a friendly star.


    As for models in general, the a-frame team recommends the glTF format in the docs, as it is designed for webGL.
    As for the model=.. syntax, you need to use a loader component, either the gltf-loader (like you do on glitch), or any other, but it won't work just with a model keyword