简体   繁体   中英

How to draw a curve in A-frame?

I'm getting started with A-Frame and this is a very basic question. I checked a number of examples to draw a line and then a curve in A-Frame but they don't show up in the scene. I have a plane there that shows up correctly.

I can use document.querySelector('a-plane').object3D; to get the plane but document.querySelector('a-curve').object3D; returns undefined.

Here is a code sample:

<!DOCTYPE html>
<html>
  <head>
    <title>A-frame room</title>
    <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
  </head>
  <body>
    <a-scene>
        <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4">   </a-plane>
        <a-sky color="#ffffff"></a-sky>
        <a-curve type="CatmullRom" curve="closed:true" visible="true">
            <a-curve-point id="checkpoint1" position="0 0 -4" visible="true"></a-curve-point>
            <a-curve-point id="checkpoint2" position="0 10 -4" visible="true"></a-curve-point>
            <a-curve-point id="checkpoint3" position="0 10 -8" visible="true"></a-curve-point>
            <a-curve-point id="checkpoint4" position="0 0 -8" visible="true"></a-curve-point>
        </a-curve>
    </a-scene>
  </body>
</html>

You need to import the JS component that provides <a-curve> . It's a community component.

https://www.npmjs.com/package/aframe-curve-component

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM