-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathselection-3.html
More file actions
60 lines (54 loc) · 2.17 KB
/
selection-3.html
File metadata and controls
60 lines (54 loc) · 2.17 KB
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
59
60
<!DOCTYPE html>
<!-- Selection in desktop and Oculus Go
When in desktop:
Click, mouseenter and mouseleave on objects with the corresponding
behaviors, activated with the desktop mouse.
Thanks to 'cursor="rayOrigin:mouse"' in the scene.
When in Oculus Go:
Click, mouseenter and mouseleave on objects with the corresponding
behaviors, activated with the ray controlled with the Go control
(using the trigger to activate "click").
Thanks to the laser-controls element.
-->
<html>
<head>
<script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
<script>
AFRAME.registerComponent("event-listener", {
init: function() {
this.el.addEventListener("click", function(e) {
console.log(e.target)
e.target.setAttribute('scale', {x: 2, y: 2, z: 2});
});
this.el.addEventListener("mouseenter", function(e) {
console.log(e.target)
e.target.setAttribute('scale', {x: 1.5, y: 1.5, z: 1.5});
});
this.el.addEventListener("mouseleave", function(e) {
console.log(e.target)
e.target.setAttribute('scale', {x: 1, y: 1, z: 1});
});
}
});
</script>
</head>
<body>
<a-scene>
<a-box event-listener position="-1 0.5 -3" rotation="0 45 0"
color="#4CC3D9" shadow></a-box>
<a-sphere event-listener position="0 1.25 -5" radius="1.25"
color="#EF2D5E" shadow></a-sphere>
<a-cylinder event-listener position="1 0.75 -3" radius="0.5"
height="1.5" color="#FFC65D" shadow></a-cylinder>
<a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4"
color="#7BC8A4" shadow></a-plane>
<a-sky color="#ECECEC"></a-sky>
<a-entity movement-controls="fly: true" position="0 0 0">
<a-entity camera position="0 1.6 0" look-controls></a-entity>
<a-entity cursor="rayOrigin:mouse"></a-entity>
<a-entity laser-controls="hand: right"></a-entity>
</a-entity>
</a-scene>
</body>
</html>