Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a-box id="boxID" position="0 2 -5" rotation="0 45 45" scale="2 2 2" src="#boxTexture">
- <a-animation attribute="position" to="0 2.2 -5" direction="alternate" dur="2000" repeat="indefinite"></a-animation>
- <!-- These animations will start when the box is looked at. -->
- <a-animation attribute="scale" begin="mouseenter" dur="300" to="2.3 2.3 2.3"></a-animation>
- <a-animation attribute="scale" begin="mouseleave" dur="300" to="2 2 2"></a-animation>
- <a-animation attribute="rotation" begin="click" dur="2000" to="360 405 45"></a-animation>
- AFRAME.registerComponent('scale-on-interact', {
- schema: {
- to: {default: '2.5 2.5 2.5'}
- },
- init: function () {
- var data = this.data;
- },
- update: function() {
- var data = this.data;
- console.log(data.color);
- // MOUSE ENTER EVENT
- this.el.addEventListener('mouseenter', function() {
- console.log("enter");
- this.setAttribute('to', data.to);
- });
- // CLICK EVENT
- this.el.addEventListener('click', function() {
- console.log("click");
- });
- // MOUSE LEAVE EVENT
- this.el.addEventListener('mouseleave', function() {
- console.log("leave");
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement