-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
51 lines (42 loc) · 2.1 KB
/
Copy pathapp.js
File metadata and controls
51 lines (42 loc) · 2.1 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
const cubeRoom = document.getElementById('cube-room');
const centerWall = document.getElementById('center-wall');
const resetBtn = document.getElementById('reset-bg-btn');
const walls = document.querySelectorAll('.wall-grid');
// Generate Foto Otomatis ke Dinding Samping
walls.forEach((wall) => {
const wallType = wall.getAttribute('data-wall');
for (let i = 0; i < 12; i++) {
const imgUrl = `https://picsum.photos/800/600?random=${Math.floor(Math.random() * 10000)}`;
const img = document.createElement('img');
img.src = imgUrl;
img.classList.add('photo-item');
// Eksekusi Klik Gambar
img.addEventListener('click', (e) => {
e.stopPropagation();
// Efek kamera bergerak halus mendekat ke arah dinding yang diklik
if (wallType === 'left') cubeRoom.style.transform = "rotateY(-15deg) translateZ(80px)";
if (wallType === 'right') cubeRoom.style.transform = "rotateY(15deg) translateZ(80px)";
if (wallType === 'top') cubeRoom.style.transform = "rotateX(-10deg) translateZ(80px)";
if (wallType === 'bottom') cubeRoom.style.transform = "rotateX(10deg) translateZ(80px)";
// Langsung update background di sekat tengah
centerWall.style.backgroundImage = `url('${imgUrl}')`;
centerWall.classList.add('has-bg');
centerWall.style.borderColor = "#fff";
resetBtn.style.display = "inline-block";
// Kamera otomatis reset lurus fokus ke tengah lagi secara smooth
setTimeout(() => {
cubeRoom.style.transform = "rotateX(0deg) rotateY(0deg) translateZ(0px)";
}, 600);
});
wall.appendChild(img);
}
});
// Tombol Reset Background
resetBtn.addEventListener('click', (e) => {
e.stopPropagation();
centerWall.style.backgroundImage = "none";
centerWall.classList.remove('has-bg');
centerWall.style.borderColor = "rgba(255, 255, 255, 0.1)";
resetBtn.style.display = "none";
cubeRoom.style.transform = "rotateX(0deg) rotateY(0deg) translateZ(0px)";
});