Spaces:
Running
Running
Update index.html
Browse files- index.html +200 -1
index.html
CHANGED
|
@@ -71,4 +71,203 @@
|
|
| 71 |
</div>
|
| 72 |
|
| 73 |
<input type="file" id="skyInput" accept="image/*,video/*" style="display:none;">
|
| 74 |
-
<input type="file" id="screenInput" accept="video/*" style="display:none;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
</div>
|
| 72 |
|
| 73 |
<input type="file" id="skyInput" accept="image/*,video/*" style="display:none;">
|
| 74 |
+
<input type="file" id="screenInput" accept="video/*" style="display:none;">
|
| 75 |
+
<script>
|
| 76 |
+
let videos = [];
|
| 77 |
+
let skyVideo = null;
|
| 78 |
+
let screenVideo = null;
|
| 79 |
+
let container = null;
|
| 80 |
+
|
| 81 |
+
function togglePanel() {
|
| 82 |
+
const panel = document.getElementById('panel');
|
| 83 |
+
panel.style.display = (panel.style.display === 'flex') ? 'none' : 'flex';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
function enterVRMode() {
|
| 87 |
+
const scene = document.querySelector('a-scene');
|
| 88 |
+
if (scene) scene.enterVR();
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
function enterARMode() {
|
| 92 |
+
const scene = document.querySelector('a-scene');
|
| 93 |
+
const sky = document.getElementById('sky');
|
| 94 |
+
|
| 95 |
+
if (!scene) return;
|
| 96 |
+
|
| 97 |
+
scene.enterAR().then(() => {
|
| 98 |
+
console.log("✅ Entered AR Mode");
|
| 99 |
+
if (sky) sky.setAttribute('visible', false);
|
| 100 |
+
}).catch(err => {
|
| 101 |
+
console.error("AR failed to start:", err);
|
| 102 |
+
alert("Could not start AR mode. Make sure you're on a supported device.");
|
| 103 |
+
});
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function launchSky() {
|
| 107 |
+
document.getElementById('skyInput').click();
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
function Leftvideopanel() {
|
| 111 |
+
document.getElementById('screenInput').click();
|
| 112 |
+
document.getElementById('screenInput').onchange = (e) => handleNewVideo(e, 'left');
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
function Rightvideopanel() {
|
| 116 |
+
document.getElementById('screenInput').click();
|
| 117 |
+
document.getElementById('screenInput').onchange = (e) => handleNewVideo(e, 'right');
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
function Mediaplayer() {
|
| 121 |
+
document.getElementById('screenInput').click();
|
| 122 |
+
document.getElementById('screenInput').onchange = (e) => handleBrowserVideo(e);
|
| 123 |
+
}
|
| 124 |
+
function handleNewVideo(e, side) {
|
| 125 |
+
const file = e.target.files[0];
|
| 126 |
+
if (!file || !file.type.startsWith('video/')) return;
|
| 127 |
+
|
| 128 |
+
const url = URL.createObjectURL(file);
|
| 129 |
+
const scene = document.querySelector('a-scene');
|
| 130 |
+
const xPos = side === 'left' ? -5.2 : 5.2;
|
| 131 |
+
|
| 132 |
+
const plane = document.createElement('a-plane');
|
| 133 |
+
plane.setAttribute('width', '10');
|
| 134 |
+
plane.setAttribute('height', '6');
|
| 135 |
+
plane.setAttribute('position', `${xPos} 4 -10`);
|
| 136 |
+
plane.setAttribute('material', 'shader:flat; side:double; color:#fff');
|
| 137 |
+
scene.appendChild(plane);
|
| 138 |
+
|
| 139 |
+
const video = document.createElement('video');
|
| 140 |
+
video.src = url;
|
| 141 |
+
video.loop = true;
|
| 142 |
+
video.volume = 0.7;
|
| 143 |
+
video.muted = false;
|
| 144 |
+
|
| 145 |
+
const texture = new THREE.VideoTexture(video);
|
| 146 |
+
|
| 147 |
+
video.onloadeddata = function() {
|
| 148 |
+
const mesh = plane.object3DMap.mesh;
|
| 149 |
+
if (mesh && mesh.material) {
|
| 150 |
+
mesh.material.map = texture;
|
| 151 |
+
mesh.material.needsUpdate = true;
|
| 152 |
+
}
|
| 153 |
+
video.play();
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
video.load();
|
| 157 |
+
|
| 158 |
+
const videoData = { video: video, name: file.name, side: side };
|
| 159 |
+
videos.push(videoData);
|
| 160 |
+
|
| 161 |
+
createControlButtons(videoData);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
function handleBrowserVideo(e) {
|
| 165 |
+
const file = e.target.files[0];
|
| 166 |
+
if (!file) return;
|
| 167 |
+
const url = URL.createObjectURL(file);
|
| 168 |
+
screenVideo.src = url;
|
| 169 |
+
container.style.display = 'block';
|
| 170 |
+
screenVideo.play();
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
function createControlButtons(videoData) {
|
| 174 |
+
const panel = document.getElementById('panel');
|
| 175 |
+
|
| 176 |
+
const label = document.createElement('div');
|
| 177 |
+
label.style.color = '#ff99aa';
|
| 178 |
+
label.style.fontSize = '14px';
|
| 179 |
+
label.style.padding = '4px 0 2px 0';
|
| 180 |
+
label.textContent = `${videoData.side.toUpperCase()} SCREEN`;
|
| 181 |
+
panel.appendChild(label);
|
| 182 |
+
|
| 183 |
+
const controls = document.createElement('div');
|
| 184 |
+
controls.style.display = 'flex';
|
| 185 |
+
controls.style.gap = '6px';
|
| 186 |
+
|
| 187 |
+
const playBtn = document.createElement('button');
|
| 188 |
+
playBtn.textContent = '▶️ / ⏸️';
|
| 189 |
+
playBtn.onclick = () => {
|
| 190 |
+
if (videoData.video.paused) videoData.video.play();
|
| 191 |
+
else videoData.video.pause();
|
| 192 |
+
};
|
| 193 |
+
controls.appendChild(playBtn);
|
| 194 |
+
|
| 195 |
+
const muteBtn = document.createElement('button');
|
| 196 |
+
muteBtn.textContent = '🔊 / 🔇';
|
| 197 |
+
muteBtn.onclick = () => {
|
| 198 |
+
videoData.video.muted = !videoData.video.muted;
|
| 199 |
+
};
|
| 200 |
+
controls.appendChild(muteBtn);
|
| 201 |
+
|
| 202 |
+
panel.appendChild(controls);
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
function playSky() {
|
| 206 |
+
if (skyVideo) skyVideo.play();
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
function pauseSky() {
|
| 210 |
+
if (skyVideo) skyVideo.pause();
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
function Mutesky() {
|
| 214 |
+
if (skyVideo) skyVideo.muted = !skyVideo.muted;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
function closeVideo() {
|
| 218 |
+
if (screenVideo) screenVideo.pause();
|
| 219 |
+
if (container) container.style.display = 'none';
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function AIChat() {
|
| 223 |
+
window.location.href = "http://localhost:8000";
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
// Sky Launcher Logic
|
| 227 |
+
document.getElementById('skyInput').addEventListener('change', function(e) {
|
| 228 |
+
const file = e.target.files[0];
|
| 229 |
+
if (!file) return;
|
| 230 |
+
|
| 231 |
+
const url = URL.createObjectURL(file);
|
| 232 |
+
const isVideo = file.type.startsWith('video/');
|
| 233 |
+
|
| 234 |
+
if (isVideo) {
|
| 235 |
+
if (skyVideo) skyVideo.pause();
|
| 236 |
+
skyVideo = document.createElement('video');
|
| 237 |
+
skyVideo.src = url;
|
| 238 |
+
skyVideo.loop = true;
|
| 239 |
+
skyVideo.muted = false;
|
| 240 |
+
skyVideo.volume = 0.6;
|
| 241 |
+
|
| 242 |
+
skyVideo.onloadeddata = () => {
|
| 243 |
+
const mesh = document.getElementById('sky').getObject3D('mesh');
|
| 244 |
+
if (mesh && mesh.material) {
|
| 245 |
+
const texture = new THREE.VideoTexture(skyVideo);
|
| 246 |
+
texture.mapping = THREE.EquirectangularReflectionMapping;
|
| 247 |
+
mesh.material.map = texture;
|
| 248 |
+
mesh.material.needsUpdate = true;
|
| 249 |
+
skyVideo.play();
|
| 250 |
+
}
|
| 251 |
+
};
|
| 252 |
+
skyVideo.load();
|
| 253 |
+
} else {
|
| 254 |
+
const loader = new THREE.TextureLoader();
|
| 255 |
+
loader.load(url, function(texture) {
|
| 256 |
+
const mesh = document.getElementById('sky').getObject3D('mesh');
|
| 257 |
+
if (mesh && mesh.material) {
|
| 258 |
+
texture.mapping = THREE.EquirectangularReflectionMapping;
|
| 259 |
+
mesh.material.map = texture;
|
| 260 |
+
mesh.material.needsUpdate = true;
|
| 261 |
+
}
|
| 262 |
+
});
|
| 263 |
+
}
|
| 264 |
+
});
|
| 265 |
+
|
| 266 |
+
// Initialize
|
| 267 |
+
window.onload = function() {
|
| 268 |
+
screenVideo = document.getElementById('myVideo');
|
| 269 |
+
container = document.getElementById('videoContainer');
|
| 270 |
+
};
|
| 271 |
+
</script>
|
| 272 |
+
</body>
|
| 273 |
+
</html>
|