-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvr.js
59 lines (50 loc) · 1.26 KB
/
vr.js
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
51
52
53
54
55
56
57
58
LoadComponents();
function LoadComponents()
{
AFRAME.registerComponent('clickable',
{
init: function ()
{
this.el.classList.add('clickable');
},
update: function ()
{
var data = this.data; // Component property values.
var el = this.el; // Reference to the component's entity.
el.addEventListener('mouseenter', function ()
{
el.object3D.scale.set(1.2, 1.2, 1.2);
});
el.addEventListener('mouseleave', function ()
{
el.object3D.scale.set(1, 1, 1);
});
}
});
AFRAME.registerComponent('mosca',
{
schema:
{
path: {type: 'string', default: './assets/mosca.png'}
},
init: function ()
{
this.data.path = this.el.getAttribute('src');
this.el.setAttribute('src', './assets/mosca.png')
},
update: function ()
{
var data = this.data; // Component property values.
var el = this.el; // Reference to the component's entity.
el.addEventListener('click', function ()
{
el.setAttribute('src', data.path)
el.object3D.scale.set(5, 5, 5);
});
el.addEventListener('mouseleave', function ()
{
el.setAttribute('src', './assets/mosca.png')
});
}
});
}