Mixins - A-FRAME element

Saturday, 22 April 2017 | Written by  |

Mixins provide a way to compose and reuse commonly-used sets of component properties - thast all, what can you read on website Aframe.io

This is code from https://aframe.io/docs/0.5.0/core/mixins.html

<a-scene>
  <a-assets>
    <a-mixin id="red" material="color: red"></a-mixin>
    <a-mixin id="blue" material="color: blue"></a-mixin>
    <a-mixin id="cube" geometry="primitive: box"></a-mixin>
  </a-assets>
  <a-entity mixin="red cube"></a-entity>
  <a-entity mixin="blue cube"></a-entity>
</a-scene>

You can try use it.. The result is empty screen. 

Whe you want to see this: 

You must use this script for see right result - the position atribute is necessary: 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
  </head>
  <body>
       <a-scene>   
       
         <a-assets>
                  <a-mixin id="red" material="color: red"></a-mixin>
                  <a-mixin id="blue" material="color: blue"></a-mixin>
                  <a-mixin id="cube" geometry="primitive: box"></a-mixin>
         </a-assets>
          
            <a-entity mixin="red cube" position="3 3.4 -3"></a-entity>
            <a-entity mixin="blue cube" position="3 3.4 -1"></a-entity>
            
       </a-scene>
  <body>
</html>

 

© 2017 WebooVR by Weboo.eu. All rights reserved