document.addEventListener("DOMContentLoaded", () => { console.log("📸 Memuat galeri AR tanpa marker..."); loadGallery(); // langsung panggil fungsi tanpa marker }); function loadGallery() { fetch(`fetch_images.php?code=15`) // kamu bisa ubah kode sesuai kebutuhan .then(res => res.json()) .then(data => { const container = document.getElementById("galleryContainer"); if (!Array.isArray(data)) return; data.forEach((item, i) => { // posisi otomatis agar rapi const x = (i % 3) * 1.5 - 1.5; const y = Math.floor(i / 3) * 1.5; const z = 0; if (item.type === "image") { const plane = document.createElement("a-plane"); plane.setAttribute("src", item.file_path); plane.setAttribute("position", `${x} ${y} ${z}`); plane.setAttribute("width", "1"); plane.setAttribute("height", "1"); plane.setAttribute("material", "shader: flat; opacity: 0.9; color: #66ccff"); plane.setAttribute("animation__float", "property: position; dir: alternate; dur:2000; to: 0 0.1 0; loop:true;"); container.appendChild(plane); } else if (item.type === "model") { const model = document.createElement("a-entity"); model.setAttribute("gltf-model", item.file_path); model.setAttribute("position", `${x} ${y} ${z}`); model.setAttribute("scale", item.scale || "1 1 1"); model.setAttribute("animation__spin", "property: rotation; dur:8000; to:0 360 0; loop:true; easing:linear"); container.appendChild(model); } }); console.log("✅ Galeri berhasil dimuat"); }) .catch(err => console.error("❌ Error mengambil data:", err)); }