The below example shows using a-cursor, where a click event will rotate a box. Mouseenter & moveleave events will scale the box up and down.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<html> <head> <title>Demo a-cursor with click</title> <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> </head> <body> <a-scene> <a-assets> </a-assets> <a-box color="blue" width="1" height="1" depth="1" position="0 10 0" rotation="45 45 45" scale="1 2.5 1"> <a-animation attribute="rotation" begin="click" repeat="3" to="0 360 0"></a-animation> </a-box> <a-camera position="0 7 5"> <a-cursor color="#FF0000" /> </a-camera> </a-scene> <script type="text/javascript"> var box = document.querySelector( 'a-box'); box.addEventListener( "mouseenter", function () { box.setAttribute("scale", { x: 0.5, y: 2, z: 5.9 }); }); box.addEventListener( "mouseleave", function () { box.setAttribute("scale", { x: 1, y: 2.5, z: 1 }); }); </script> </body> </html> |