Search code examples
aframewebvr

How do I apply cubemaps textures to cylinders in A-frame?


I am trying to apply different images to the various sides of a cylinder. I have tried using the cubemap method as described here but it is not working. Should this work at all? Or is there another way to add multiple images to this shape? It would be good to understand how to add different images to different sides of various shapes, or is this only possible with cubes? Here is what I am trying;

<html>
<head>
    <title>example</title>
    <meta name="description" content="Hello, WebVR! - A-Frame">
    <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
    <script src="https://unpkg.com/aframe-template-component@^3.1.1/dist/aframe-template-component.min.js"></script>
</head>
<body>
    <a-scene>
        <a-assets>
                 <a-cubemap id="wheel">
                    <img src="https://www.nickritchie.co.uk/samples/tyre.png">
                    <img src="https://www.nickritchie.co.uk/samples/tyre.png">
                    <img src="https://www.nickritchie.co.uk/samples/wheel.jpg">
                    <img src="https://www.nickritchie.co.uk/samples/wheel.jpg">
                    <img src="https://www.nickritchie.co.uk/samples/tyre.png">
                    <img src="https://www.nickritchie.co.uk/samples/tyre.png">
                  </a-cubemap>
                <script id="example" type="text/html">
                        <a-entity
                            geometry="primitive: cylinder; radius: 0.25; height: 2"
                            position="0 1 -4"
                            rotation="0 0 90"
                            material="envMap: #wheel">
                        </a-entity> 
                </script>
        </a-assets>
        <a-entity 
            template="src: #example">
        </a-entity>
        <a-plane 
            position="0 0 -4" 
            rotation="-90 0 0" 
            width="4"
            height="4" 
            shadow 
            color="yellow">
            </a-plane>
          <a-sky 
            color="grey">
            </a-sky>
          <a-camera>
          </a-camera>
    </a-scene>
</body>

</html>

The errors are coming from three.js, I can post here if it would help

Thanks for any help


Solution

  • Try https://github.com/bryik/aframe-cubemap-component

      <a-entity cubemap="folder: https://www.nickritchie.co.uk/samples/"></a-entity>