Spaces:
Running
Running
Update index.html
Browse files- index.html +41 -15
index.html
CHANGED
|
@@ -33,8 +33,7 @@
|
|
| 33 |
<body>
|
| 34 |
<a-scene background="color: #000000" xr-mode-ui="enabled: true">
|
| 35 |
<a-sky id="sky" src="galaxy.jpg" material="side: back"></a-sky>
|
| 36 |
-
|
| 37 |
-
<a-light type="directional" color="#fff" intensity="0.6" position="5 10 5"></a-light>
|
| 38 |
</a-scene>
|
| 39 |
|
| 40 |
<div id="bead" onclick="togglePanel()"></div>
|
|
@@ -47,6 +46,7 @@
|
|
| 47 |
<button class="btn" onclick="openAIChat()">π¬ AI Chat</button>
|
| 48 |
</div>
|
| 49 |
|
|
|
|
| 50 |
<div id="mediaPicker">
|
| 51 |
<div class="picker-header">
|
| 52 |
<div>Choose Media Frame Style</div>
|
|
@@ -64,6 +64,7 @@
|
|
| 64 |
|
| 65 |
<script>
|
| 66 |
let currentFrame = null;
|
|
|
|
| 67 |
|
| 68 |
function togglePanel() {
|
| 69 |
const p = document.getElementById('panel');
|
|
@@ -81,31 +82,34 @@
|
|
| 81 |
|
| 82 |
function selectFrameStyle(style) {
|
| 83 |
closeMediaPicker();
|
| 84 |
-
|
| 85 |
if (currentFrame) currentFrame.remove();
|
|
|
|
| 86 |
|
| 87 |
let html = '';
|
| 88 |
if (style === 'flat') {
|
| 89 |
-
html = `<a-plane id="mediaFrame" width="16" height="9" position="0 4 -12" material="
|
| 90 |
} else if (style === 'curved') {
|
| 91 |
-
html = `<a-cylinder id="mediaFrame" radius="12" height="8" theta-start="260" theta-length="130" position="0 4 -6" material="
|
| 92 |
-
} else if (style === 'dome') {
|
| 93 |
-
html = `<a-sphere id="mediaFrame" radius="18" position="0 0 0" material="color:#111;shader:flat;side:double"></a-sphere>`;
|
| 94 |
} else if (style === 'floating') {
|
| 95 |
-
html = `<a-plane id="mediaFrame" width="10" height="6" position="5 3 -8" rotation="0 40 0" material="
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
|
| 98 |
document.querySelector('a-scene').insertAdjacentHTML('beforeend', html);
|
| 99 |
currentFrame = document.getElementById('mediaFrame');
|
| 100 |
|
| 101 |
-
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
function launchSky() { document.getElementById('mediaInput').click(); }
|
| 105 |
-
function openGLBPicker() { alert("GLB Picker
|
| 106 |
-
function randomEnvironment() { alert("Surprise Me
|
| 107 |
-
function openAIChat() { alert("AI Chat
|
| 108 |
|
|
|
|
| 109 |
document.getElementById('mediaInput').addEventListener('change', function(e) {
|
| 110 |
const file = e.target.files[0];
|
| 111 |
if (!file) return;
|
|
@@ -113,9 +117,31 @@
|
|
| 113 |
const url = URL.createObjectURL(file);
|
| 114 |
const frame = document.getElementById('mediaFrame');
|
| 115 |
|
| 116 |
-
if (frame) {
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
});
|
| 121 |
</script>
|
|
|
|
| 33 |
<body>
|
| 34 |
<a-scene background="color: #000000" xr-mode-ui="enabled: true">
|
| 35 |
<a-sky id="sky" src="galaxy.jpg" material="side: back"></a-sky>
|
| 36 |
+
<a-light type="ambient" color="#555"></a-light>
|
|
|
|
| 37 |
</a-scene>
|
| 38 |
|
| 39 |
<div id="bead" onclick="togglePanel()"></div>
|
|
|
|
| 46 |
<button class="btn" onclick="openAIChat()">π¬ AI Chat</button>
|
| 47 |
</div>
|
| 48 |
|
| 49 |
+
<!-- Media Frames Picker -->
|
| 50 |
<div id="mediaPicker">
|
| 51 |
<div class="picker-header">
|
| 52 |
<div>Choose Media Frame Style</div>
|
|
|
|
| 64 |
|
| 65 |
<script>
|
| 66 |
let currentFrame = null;
|
| 67 |
+
let currentVideoElement = null;
|
| 68 |
|
| 69 |
function togglePanel() {
|
| 70 |
const p = document.getElementById('panel');
|
|
|
|
| 82 |
|
| 83 |
function selectFrameStyle(style) {
|
| 84 |
closeMediaPicker();
|
| 85 |
+
|
| 86 |
if (currentFrame) currentFrame.remove();
|
| 87 |
+
if (currentVideoElement) currentVideoElement.pause();
|
| 88 |
|
| 89 |
let html = '';
|
| 90 |
if (style === 'flat') {
|
| 91 |
+
html = `<a-plane id="mediaFrame" width="16" height="9" position="0 4 -12" material="shader:flat; side:double"></a-plane>`;
|
| 92 |
} else if (style === 'curved') {
|
| 93 |
+
html = `<a-cylinder id="mediaFrame" radius="12" height="8" theta-start="260" theta-length="130" position="0 4 -6" material="shader:flat; side:double"></a-cylinder>`;
|
|
|
|
|
|
|
| 94 |
} else if (style === 'floating') {
|
| 95 |
+
html = `<a-plane id="mediaFrame" width="10" height="6" position="5 3 -8" rotation="0 40 0" material="shader:flat; side:double"></a-plane>`;
|
| 96 |
+
} else if (style === 'dome') {
|
| 97 |
+
html = `<a-sphere id="mediaFrame" radius="18" position="0 0 0" material="shader:flat; side:double"></a-sphere>`;
|
| 98 |
}
|
| 99 |
|
| 100 |
document.querySelector('a-scene').insertAdjacentHTML('beforeend', html);
|
| 101 |
currentFrame = document.getElementById('mediaFrame');
|
| 102 |
|
| 103 |
+
alert("β
Frame created. Now choose your video");
|
| 104 |
+
setTimeout(() => document.getElementById('mediaInput').click(), 300);
|
| 105 |
}
|
| 106 |
|
| 107 |
function launchSky() { document.getElementById('mediaInput').click(); }
|
| 108 |
+
function openGLBPicker() { alert("π§ GLB Picker coming soon"); }
|
| 109 |
+
function randomEnvironment() { alert("π² Surprise Me coming soon"); }
|
| 110 |
+
function openAIChat() { alert("π¬ AI Chat coming soon"); }
|
| 111 |
|
| 112 |
+
// Simple and reliable video loader
|
| 113 |
document.getElementById('mediaInput').addEventListener('change', function(e) {
|
| 114 |
const file = e.target.files[0];
|
| 115 |
if (!file) return;
|
|
|
|
| 117 |
const url = URL.createObjectURL(file);
|
| 118 |
const frame = document.getElementById('mediaFrame');
|
| 119 |
|
| 120 |
+
if (frame && file.type.startsWith('video/')) {
|
| 121 |
+
// Create video element
|
| 122 |
+
currentVideoElement = document.createElement('video');
|
| 123 |
+
currentVideoElement.src = url;
|
| 124 |
+
currentVideoElement.loop = true;
|
| 125 |
+
currentVideoElement.muted = true;
|
| 126 |
+
currentVideoElement.crossOrigin = "anonymous";
|
| 127 |
+
|
| 128 |
+
currentVideoElement.onloadeddata = () => {
|
| 129 |
+
const texture = new THREE.VideoTexture(currentVideoElement);
|
| 130 |
+
const mesh = frame.object3DMap.mesh;
|
| 131 |
+
|
| 132 |
+
if (mesh && mesh.material) {
|
| 133 |
+
mesh.material.map = texture;
|
| 134 |
+
mesh.material.needsUpdate = true;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
currentVideoElement.play();
|
| 138 |
+
alert("β
Video should now be playing on the screen");
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
currentVideoElement.load();
|
| 142 |
+
}
|
| 143 |
+
else if (frame) {
|
| 144 |
+
frame.setAttribute('material', `src:${url}`);
|
| 145 |
}
|
| 146 |
});
|
| 147 |
</script>
|