-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAframe_modelViewer.html
51 lines (51 loc) · 2.01 KB
/
Aframe_modelViewer.html
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.0/css/bulma.min.css">
<script src="https://unpkg.com/aframe-extras@3.3.0/dist/aframe-extras.min.js"></script>
<script src="https://unpkg.com/aframe-environment-component@1.1.0/dist/aframe-environment-component.min.js"></script>
<title>cube</title>
<script>
AFRAME.registerComponent('hide-in-ar-mode', {
// Set this object invisible while in AR mode.
init: function () {
this.el.sceneEl.addEventListener('enter-vr', (ev) => {
this.wasVisible = this.el.getAttribute('visible');
if (this.el.sceneEl.is('ar-mode')) {
this.el.setAttribute('visible', false);
}
});
this.el.sceneEl.addEventListener('exit-vr', (ev) => {
if (this.wasVisible) this.el.setAttribute('visible', true);
});
}
});
</script>
</head>
<body>
<div class="columns is-mobile">
<div class="column">
<img src="assets/wood.jpg" width="120" height="120" onclick="change_texture('assets/wood.jpg')">
<br>
<img src="assets/brick_wall.jpg" width="120" height="120" onclick="change_texture('assets/brick_wall.jpg')">
<br>
<img src="assets/metal_texture.jpg" width="120" height="120" onclick="change_texture('assets/metal_texture.jpg')">
<br>
</div>
<div class="column">
<a-scene embedded>
<a-entity id="box" geometry="primitive: box" material="color: #4CC3D9; " position="-1 0.5 -3" rotation="0 45 0"></a-entity>
</a-scene>
</div>
</div>
<script>
function change_texture(texture){
var entity = document.querySelector('a-entity');
console.log(texture);
entity.setAttribute('material', { src: texture });
}
</script>
</body>
</html>