Deploy from Lumerel
This commit is contained in:
109
main.js
Normal file
109
main.js
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Lumerel — 3D Homepage · main.js
|
||||
*
|
||||
* Responsibilities:
|
||||
* 1. Spline 3D scene pointer-events toggle
|
||||
* 2. Navbar scroll backdrop blur
|
||||
* 3. Background video autoplay fallback (iOS Safari)
|
||||
* 4. Waitlist button click hooks
|
||||
*/
|
||||
|
||||
/* ── 1. Spline / 3D Layer Integration ────────────────────────────────
|
||||
*
|
||||
* When your Spline scene is ready:
|
||||
*
|
||||
* A) Open index.html and find the .spline-placeholder div.
|
||||
* B) Delete that entire div.
|
||||
* C) In its place, paste:
|
||||
*
|
||||
* <spline-viewer
|
||||
* url="https://prod.spline.design/YOUR_SCENE_ID/scene.splinecode"
|
||||
* events-target="global"
|
||||
* ></spline-viewer>
|
||||
*
|
||||
* D) If the scene needs mouse/touch interaction, call:
|
||||
* window.Lumerel.enableSpline()
|
||||
*
|
||||
* The <spline-viewer> web component is already loaded via CDN
|
||||
* in the <head> of index.html — no extra imports needed.
|
||||
*
|
||||
─────────────────────────────────────────────────────────────────── */
|
||||
|
||||
const splineLayer = document.getElementById('spline-layer');
|
||||
|
||||
/** Allow pointer events on the 3D layer (for interactive Spline scenes). */
|
||||
function enableSpline() {
|
||||
if (splineLayer) splineLayer.style.pointerEvents = 'auto';
|
||||
}
|
||||
|
||||
/** Block pointer events on the 3D layer (default — keeps UI clickable). */
|
||||
function disableSpline() {
|
||||
if (splineLayer) splineLayer.style.pointerEvents = 'none';
|
||||
}
|
||||
|
||||
// Auto-detect spline-viewer and log confirmation on load
|
||||
if (splineLayer) {
|
||||
const viewer = splineLayer.querySelector('spline-viewer');
|
||||
if (viewer) {
|
||||
viewer.addEventListener('load', () => {
|
||||
console.log('[Lumerel] ✓ Spline scene loaded.');
|
||||
// Uncomment to enable 3D mouse interaction after scene loads:
|
||||
// enableSpline();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 2. Navbar Scroll Backdrop ───────────────────────────────────────── */
|
||||
const navbar = document.querySelector('.navbar');
|
||||
|
||||
function updateNavbar() {
|
||||
if (!navbar) return;
|
||||
if (window.scrollY > 24) {
|
||||
navbar.style.background = 'rgba(0, 0, 0, 0.45)';
|
||||
navbar.style.backdropFilter = 'blur(16px)';
|
||||
navbar.style.webkitBackdropFilter = 'blur(16px)';
|
||||
} else {
|
||||
navbar.style.background = 'transparent';
|
||||
navbar.style.backdropFilter = 'none';
|
||||
navbar.style.webkitBackdropFilter = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', updateNavbar, { passive: true });
|
||||
updateNavbar(); // run once on load
|
||||
|
||||
/* ── 3. Background Video Fallback ────────────────────────────────────── */
|
||||
const heroVideo = document.querySelector('.hero__video');
|
||||
|
||||
if (heroVideo) {
|
||||
// Gradient fallback if video fails to load
|
||||
heroVideo.addEventListener('error', () => {
|
||||
console.warn('[Lumerel] Background video failed — using gradient fallback.');
|
||||
const wrap = document.querySelector('.hero__video-wrap');
|
||||
if (wrap) {
|
||||
wrap.style.background = 'linear-gradient(135deg, #0a0a0a 0%, #111 100%)';
|
||||
}
|
||||
});
|
||||
|
||||
// iOS Safari sometimes requires a user gesture to trigger autoplay
|
||||
document.addEventListener('touchstart', () => {
|
||||
if (heroVideo.paused) heroVideo.play().catch(() => {});
|
||||
}, { once: true });
|
||||
}
|
||||
|
||||
/* ── 4. Waitlist Button Hooks ────────────────────────────────────────── */
|
||||
document.querySelectorAll('.btn-pill').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
// TODO: wire up your waitlist modal, form, or redirect here
|
||||
console.log('[Lumerel] Join Waitlist clicked.');
|
||||
// Examples:
|
||||
// openWaitlistModal();
|
||||
// window.location.href = '/waitlist';
|
||||
});
|
||||
});
|
||||
|
||||
/* ── Global API ──────────────────────────────────────────────────────── */
|
||||
window.Lumerel = {
|
||||
enableSpline,
|
||||
disableSpline,
|
||||
};
|
||||
Reference in New Issue
Block a user