Spaces:
Running
Running
File size: 2,822 Bytes
688c4b9 c633347 688c4b9 c633347 688c4b9 b8b929f 688c4b9 c633347 688c4b9 c633347 b8b929f 688c4b9 c633347 b8b929f c633347 688c4b9 c633347 b8b929f 688c4b9 c633347 688c4b9 c633347 688c4b9 c633347 688c4b9 c633347 688c4b9 c633347 688c4b9 c633347 688c4b9 c633347 688c4b9 | 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 | <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sky Launcher</title>
<script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
<style>
body { margin:0; overflow:hidden; background:#000; }
.back-btn {
position:fixed; top:20px; left:20px; padding:12px 20px;
background:rgba(255,50,50,0.2); color:#ff99aa; border:2px solid #ff3366;
border-radius:12px; font-size:16px; z-index:100; cursor:pointer;
backdrop-filter:blur(10px);
}
.status {
position:fixed; top:20px; right:20px; color:#ff99aa; background:rgba(0,0,0,0.6);
padding:8px 14px; border-radius:8px; font-size:14px; z-index:100;
}
</style>
</head>
<body>
<a-scene background="color: #000000" xr-mode-ui="enabled: true">
<a-sky id="sky" src="galaxy.jpg" material="side: back"></a-sky>
</a-scene>
<div class="back-btn" onclick="history.back()">
← Back to Holodeck
</div>
<div class="status" id="status">Tap anywhere on the sky to change background</div>
<input type="file" id="skyInput" accept="image/*,video/*" style="display:none;">
<script>
const status = document.getElementById('status');
// Tap anywhere to open file picker
document.addEventListener('click', function(e) {
if (e.target.tagName === 'CANVAS') {
document.getElementById('skyInput').click();
}
});
document.getElementById('skyInput').addEventListener('change', function(e) {
const file = e.target.files[0];
if (!file) return;
status.textContent = `Loading: ${file.name}`;
const url = URL.createObjectURL(file);
const isVideo = file.type.startsWith('video/');
if (isVideo) {
const vid = document.createElement('video');
vid.src = url;
vid.loop = true;
vid.muted = true;
vid.onloadeddata = () => {
const mesh = document.getElementById('sky').getObject3D('mesh');
if (mesh && mesh.material) {
const texture = new THREE.VideoTexture(vid);
texture.mapping = THREE.EquirectangularReflectionMapping;
mesh.material.map = texture;
mesh.material.needsUpdate = true;
vid.play();
status.textContent = "✅ Video background loaded";
}
};
vid.load();
} else {
const loader = new THREE.TextureLoader();
loader.load(url, (texture) => {
const mesh = document.getElementById('sky').getObject3D('mesh');
if (mesh && mesh.material) {
texture.mapping = THREE.EquirectangularReflectionMapping;
mesh.material.map = texture;
mesh.material.needsUpdate = true;
status.textContent = "✅ Image background loaded";
}
});
}
});
</script>
</body>
</html> |