SHARE
TWEET

Untitled

a guest Jun 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <a-box id="boxID" position="0 2 -5" rotation="0 45 45" scale="2 2 2" src="#boxTexture">
  2.             <a-animation attribute="position" to="0 2.2 -5" direction="alternate" dur="2000" repeat="indefinite"></a-animation>
  3.  
  4. <!-- These animations will start when the box is looked at. -->
  5. <a-animation attribute="scale" begin="mouseenter" dur="300" to="2.3 2.3 2.3"></a-animation>
  6. <a-animation attribute="scale" begin="mouseleave" dur="300" to="2 2 2"></a-animation>
  7. <a-animation attribute="rotation" begin="click" dur="2000" to="360 405 45"></a-animation>
  8.      
  9. AFRAME.registerComponent('scale-on-interact', {
  10.     schema: {
  11.         to: {default: '2.5 2.5 2.5'}
  12.     },
  13.  
  14.     init: function () {
  15.         var data = this.data;
  16.  
  17.     },
  18.  
  19.     update: function() {
  20.         var data = this.data;
  21.         console.log(data.color);
  22.  
  23.         // MOUSE ENTER EVENT
  24.         this.el.addEventListener('mouseenter', function() {
  25.             console.log("enter");
  26.             this.setAttribute('to', data.to);
  27.         });
  28.  
  29.         // CLICK EVENT
  30.         this.el.addEventListener('click', function() {
  31.             console.log("click");
  32.         });
  33.  
  34.         // MOUSE LEAVE EVENT
  35.         this.el.addEventListener('mouseleave', function() {
  36.             console.log("leave");
  37.         });
  38.     }
  39. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top