Holodeckv6 / index.html
Metaprime's picture
Update index.html
7534a34 verified
Raw History Blame Contribute Delete
10 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Holodeck</title>
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
<style>
#bead {
position:fixed; bottom:35px; left:30px; width:38px; height:38px;
background:rgba(255,30,30,0.08);
border:2px solid #ff3366;
border-radius:50%;
box-shadow:0 0 18px #ff3366, 0 0 35px #ff3366, inset 0 0 12px rgba(255,255,255,0.3);
z-index:1000; cursor:pointer;
}
#panel {
position:fixed; bottom:88px; left:22px; width:205px;
background:rgba(20,0,10,0.12); backdrop-filter:blur(18px);
border:2px solid #ff3366; box-shadow:0 0 25px #ff3366, 0 0 45px #ff3366;
border-radius:16px; padding:12px; display:none; flex-direction:column; gap:8px;
z-index:1002;
}
button {
background:rgba(255,50,50,0.08);
color:#ff99aa;
border:1px solid #ff3366;
box-shadow:0 0 12px #ff3366;
padding:11px 12px;
border-radius:10px;
font-size:15px;
text-align: left;
}
#videoContainer {
position:fixed; bottom:170px; left:50%; transform:translateX(-50%);
width:380px; display:none; z-index:1000; background:rgba(0,0,0,0.85);
border-radius:12px; padding:8px;
}
#myVideo { width:100%; border-radius:8px; }
.close-btn {
position:absolute; top:12px; right:12px; color:white; font-size:24px;
background:rgba(255,60,60,0.9); width:28px; height:28px; border-radius:50%;
display:flex; align-items:center; justify-content:center; z-index:1001;
}
</style>
</head>
<body>
<a-scene background="color: #000000" xr-mode-ui="enabled: false">
<a-sky id="sky" src="galaxy.jpg" material="side: back" hide-on-enter-ar></a-sky>
<a-light type="ambient" color="#666"></a-light>
<a-light type="directional" intensity="0.6" position="5 10 5"></a-light>
</a-scene>
<div id="bead" onclick="togglePanel()"></div>
<div id="panel">
<button onclick="launchSky()">๐ŸŒŒ Sky Launcher</button>
<button onclick="Leftvideopanel()">โฌ…๏ธ Add Left Screen</button>
<button onclick="Rightvideopanel()">โžก๏ธ Add Right Screen</button>
<button onclick="playSky()">โ–ถ๏ธ Play Sky</button>
<button onclick="pauseSky()">โธ๏ธ Pause Sky</button>
<button onclick="Mutesky()">๐Ÿ”‡ Sky Mute</button>
<button onclick="Mediaplayer()">๐Ÿ“บ Browser Player</button>
<button onclick="AIChat()">๐Ÿ’ฌ AI Chat</button>
<button onclick="setTunnelURL()">๐Ÿ”— Set Tunnel URL</button>
<button onclick="enterVRMode()">๐Ÿฅฝ Enter VR Mode</button>
<button onclick="enterARMode()">๐Ÿ“ฑ Enter AR Mode</button>
</div>
<div id="videoContainer">
<div class="close-btn" onclick="closeVideo()">ร—</div>
<video id="myVideo" controls loop></video>
</div>
<input type="file" id="skyInput" accept="image/*,video/*" style="display:none;">
<input type="file" id="screenInput" accept="video/*" style="display:none;">
<script>
let videos = [];
let skyVideo = null;
let screenVideo = null;
let container = null;
function togglePanel() {
const panel = document.getElementById('panel');
panel.style.display = (panel.style.display === 'flex') ? 'none' : 'flex';
}
function enterVRMode() {
const scene = document.querySelector('a-scene');
if (scene) scene.enterVR();
}
function enterARMode() {
const scene = document.querySelector('a-scene');
const sky = document.getElementById('sky');
if (!scene) return;
scene.enterAR().then(() => {
console.log("โœ… Entered AR Mode");
if (sky) sky.setAttribute('visible', false);
}).catch(err => {
console.error("AR failed to start:", err);
alert("Could not start AR mode. Make sure you're on a supported device.");
});
}
function launchSky() {
document.getElementById('skyInput').click();
}
function Leftvideopanel() {
document.getElementById('screenInput').click();
document.getElementById('screenInput').onchange = (e) => handleNewVideo(e, 'left');
}
function Rightvideopanel() {
document.getElementById('screenInput').click();
document.getElementById('screenInput').onchange = (e) => handleNewVideo(e, 'right');
}
function Mediaplayer() {
document.getElementById('screenInput').click();
document.getElementById('screenInput').onchange = (e) => handleBrowserVideo(e);
}
function handleNewVideo(e, side) {
const file = e.target.files[0];
if (!file || !file.type.startsWith('video/')) return;
const url = URL.createObjectURL(file);
const scene = document.querySelector('a-scene');
const xPos = side === 'left' ? -5.2 : 5.2;
const plane = document.createElement('a-plane');
plane.setAttribute('width', '10');
plane.setAttribute('height', '6');
plane.setAttribute('position', `${xPos} 4 -10`);
plane.setAttribute('material', 'shader:flat; side:double; color:#fff');
scene.appendChild(plane);
const video = document.createElement('video');
video.src = url;
video.loop = true;
video.volume = 0.7;
video.muted = false;
const texture = new THREE.VideoTexture(video);
video.onloadeddata = function() {
const mesh = plane.object3DMap.mesh;
if (mesh && mesh.material) {
mesh.material.map = texture;
mesh.material.needsUpdate = true;
}
video.play();
};
video.load();
const videoData = { video: video, name: file.name, side: side };
videos.push(videoData);
createControlButtons(videoData);
}
function handleBrowserVideo(e) {
const file = e.target.files[0];
if (!file) return;
const url = URL.createObjectURL(file);
screenVideo.src = url;
container.style.display = 'block';
screenVideo.play();
}
function createControlButtons(videoData) {
const panel = document.getElementById('panel');
const label = document.createElement('div');
label.style.color = '#ff99aa';
label.style.fontSize = '14px';
label.style.padding = '4px 0 2px 0';
label.textContent = `${videoData.side.toUpperCase()} SCREEN`;
panel.appendChild(label);
const controls = document.createElement('div');
controls.style.display = 'flex';
controls.style.gap = '6px';
const playBtn = document.createElement('button');
playBtn.textContent = 'โ–ถ๏ธ / โธ๏ธ';
playBtn.onclick = () => {
if (videoData.video.paused) videoData.video.play();
else videoData.video.pause();
};
controls.appendChild(playBtn);
const muteBtn = document.createElement('button');
muteBtn.textContent = '๐Ÿ”Š / ๐Ÿ”‡';
muteBtn.onclick = () => {
videoData.video.muted = !videoData.video.muted;
};
controls.appendChild(muteBtn);
panel.appendChild(controls);
}
function playSky() {
if (skyVideo) skyVideo.play();
}
function pauseSky() {
if (skyVideo) skyVideo.pause();
}
function Mutesky() {
if (skyVideo) skyVideo.muted = !skyVideo.muted;
}
function closeVideo() {
if (screenVideo) screenVideo.pause();
if (container) container.style.display = 'none';
}
// Cloudflare Tunnel API Routing
function AIChat() {
let tunnelURL = localStorage.getItem('cf_tunnel_url');
if (!tunnelURL) {
tunnelURL = prompt("Enter your active Cloudflare Tunnel URL (e.g., https://your-tunnel-name.trycloudflare.com):");
if (tunnelURL) {
tunnelURL = tunnelURL.trim().replace(/\/$/, ""); // Format URL
localStorage.setItem('cf_tunnel_url', tunnelURL);
} else {
return;
}
}
window.location.href = tunnelURL;
}
function setTunnelURL() {
const currentURL = localStorage.getItem('cf_tunnel_url') || "";
const newURL = prompt("Update Cloudflare Tunnel URL:", currentURL);
if (newURL !== null) {
const formattedURL = newURL.trim().replace(/\/$/, "");
if (formattedURL) {
localStorage.setItem('cf_tunnel_url', formattedURL);
alert("Tunnel URL saved: " + formattedURL);
} else {
localStorage.removeItem('cf_tunnel_url');
alert("Tunnel URL cleared.");
}
}
}
// Sky Launcher Logic
document.getElementById('skyInput').addEventListener('change', function(e) {
const file = e.target.files[0];
if (!file) return;
const url = URL.createObjectURL(file);
const isVideo = file.type.startsWith('video/');
if (isVideo) {
if (skyVideo) skyVideo.pause();
skyVideo = document.createElement('video');
skyVideo.src = url;
skyVideo.loop = true;
skyVideo.muted = false;
skyVideo.volume = 0.6;
skyVideo.onloadeddata = () => {
const mesh = document.getElementById('sky').getObject3D('mesh');
if (mesh && mesh.material) {
const texture = new THREE.VideoTexture(skyVideo);
texture.mapping = THREE.EquirectangularReflectionMapping;
mesh.material.map = texture;
mesh.material.needsUpdate = true;
skyVideo.play();
}
};
skyVideo.load();
} else {
const loader = new THREE.TextureLoader();
loader.load(url, function(texture) {
const mesh = document.getElementById('sky').getObject3D('mesh');
if (mesh && mesh.material) {
texture.mapping = THREE.EquirectangularReflectionMapping;
mesh.material.map = texture;
mesh.material.needsUpdate = true;
}
});
}
});
// Initialize
window.onload = function() {
screenVideo = document.getElementById('myVideo');
container = document.getElementById('videoContainer');
};
</script>
</body>
</html>