-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (91 loc) · 3.1 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/daisyui@3.7.3/dist/full.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.16/dist/tailwind.min.css" rel="stylesheet">
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<title>Visualizador de Foto 360</title>
<style>
body {
overflow: hidden;
}
#uploadBtn {
opacity: 0.5;
transition: opacity 0.3s;
}
#uploadBtn:hover {
opacity: 1;
}
</style>
</head>
<body class="dark">
<div class="flex justify-center items-center h-screen bg-gray-900">
<a-scene embedded background="color: #111">
<a-sky id="sky" src="DJI_0727.JPG" rotation="0 -130 0"></a-sky>
<a-camera id="camera" position="0 0 3.8" fov="80">
<!-- <a-cursor></a-cursor>-->
</a-camera>
</a-scene>
</div>
<div class="absolute top-4 left-4">
<button id="themeToggle" class="bg-gray-700 text-white px-4 py-2 rounded">Mudar Tema</button>
<input type="file" id="uploadBtn" class="bg-gray-700 text-white px-4 py-2 rounded" accept="image/*">
</div>
<script>
function setSkyImage(file) {
const reader = new FileReader();
reader.onload = function (event) {
const scene = document.querySelector('a-scene');
const oldSky = document.getElementById('sky');
if (oldSky) {
scene.removeChild(oldSky);
}
const newSky = document.createElement('a-sky');
newSky.setAttribute('id', 'sky');
newSky.setAttribute('src', event.target.result);
scene.appendChild(newSky);
console.log('Imagem definida como: ', event.target.result);
};
reader.readAsDataURL(file);
}
document.getElementById('themeToggle').addEventListener('click', () => {
document.body.classList.toggle('dark');
const scene = document.querySelector('a-scene');
scene.setAttribute('background', scene.getAttribute('background').color === '#111' ? 'color: #fff' : 'color: #111');
});
document.querySelector('a-scene').addEventListener('wheel', (event) => {
const camera = document.getElementById('camera');
let fov = camera.getAttribute('fov') - event.deltaY * 0.05;
fov = fov < 20 ? 20 : fov;
fov = fov > 80 ? 80 : fov;
camera.setAttribute('fov', fov);
});
document.body.addEventListener('dragover', (event) => {
event.preventDefault();
});
document.body.addEventListener('drop', (event) => {
event.preventDefault();
console.log('Evento drop detectado');
const files = event.dataTransfer.files;
if (files.length > 0) {
const file = files[0];
setSkyImage(file);
} else {
console.log('Nenhum arquivo dropado');
}
});
document.getElementById('uploadBtn').addEventListener('change', (event) => {
console.log('Evento change detectado');
const files = event.target.files;
if (files.length > 0) {
const file = files[0];
setSkyImage(file);
} else {
console.log('Nenhum arquivo selecionado');
}
});
</script>
</body>
</html>