commit 4af08348880ed312c1d7903901820cb85963f7de
Author: root <root@hub.scroll.pub> Date: 2024-12-27 12:55:44 +0000 Subject: Initial commit diff --git a/body.html b/body.html new file mode 100644 index 0000000..b9d40a6 --- /dev/null +++ b/body.html @@ -0,0 +1,30 @@ +<header> + <h1>AR View</h1> + <p>Experience Augmented Reality directly in your mobile browser</p> +</header> + +<main> + <section class="ar-container"> + <div class="camera-feed"> + <video id="camera" autoplay playsinline></video> + <canvas id="ar-canvas"></canvas> + </div> + <div class="controls"> + <button id="start-ar">Start AR</button> + <button id="stop-ar" disabled>Stop AR</button> + </div> + </section> + + <section class="instructions"> + <h2>How It Works</h2> + <ol> + <li>Allow camera access when prompted</li> + <li>Point your camera at a flat surface</li> + <li>Watch as virtual objects appear in your space</li> + </ol> + </section> +</main> + +<footer> + <p>Bringing augmented reality to your fingertips</p> +</footer> \ No newline at end of file diff --git a/index.scroll b/index.scroll new file mode 100644 index 0000000..181a7fe --- /dev/null +++ b/index.scroll @@ -0,0 +1,8 @@ +buildHtml +baseUrl https://arview.scroll.pub +metaTags +editButton /edit.html +title AR View - Augmented Reality for Mobile +style.css +body.html +script.js \ No newline at end of file diff --git a/readme.scroll b/readme.scroll new file mode 100644 index 0000000..dc1ecbf --- /dev/null +++ b/readme.scroll @@ -0,0 +1,2 @@ +# arview.scroll.pub +Website generated by DeepSeek from prompt: I want a website where it able to do augmented reality that compatible with mobile phone where it use the camera as input \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..7133451 --- /dev/null +++ b/script.js @@ -0,0 +1,64 @@ +const video = document.getElementById('camera'); +const canvas = document.getElementById('ar-canvas'); +const startButton = document.getElementById('start-ar'); +const stopButton = document.getElementById('stop-ar'); +const ctx = canvas.getContext('2d'); + +let isARActive = false; + +async function startAR() { + try { + const stream = await navigator.mediaDevices.getUserMedia({ video: true }); + video.srcObject = stream; + isARActive = true; + startButton.disabled = true; + stopButton.disabled = false; + requestAnimationFrame(renderAR); + } catch (error) { + alert('Error accessing camera. Please ensure you have granted permission.'); + console.error('Camera access error:', error); + } +} + +function stopAR() { + const stream = video.srcObject; + if (stream) { + stream.getTracks().forEach(track => track.stop()); + } + video.srcObject = null; + isARActive = false; + startButton.disabled = false; + stopButton.disabled = true; +} + +function renderAR() { + if (!isARActive) return; + + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + + // Draw camera feed + ctx.drawImage(video, 0, 0, canvas.width, canvas.height); + + // Add AR elements + ctx.fillStyle = 'rgba(255, 0, 0, 0.5)'; + ctx.fillRect( + canvas.width / 2 - 50, + canvas.height / 2 - 50, + 100, + 100 + ); + + requestAnimationFrame(renderAR); +} + +startButton.addEventListener('click', startAR); +stopButton.addEventListener('click', stopAR); + +// Handle window resize +window.addEventListener('resize', () => { + if (isARActive) { + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + } +}); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..557e272 --- /dev/null +++ b/style.css @@ -0,0 +1,127 @@ +:root { + --primary-color: #4a90e2; + --secondary-color: #333; + --bg-color: #f5f5f5; + --text-color: #333; + --button-bg: var(--primary-color); + --button-text: white; +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; + line-height: 1.6; + color: var(--text-color); + background-color: var(--bg-color); + min-height: 100vh; + display: flex; + flex-direction: column; +} + +header { + background: var(--primary-color); + color: white; + padding: 2rem; + text-align: center; +} + +header h1 { + font-size: 2.5rem; + margin-bottom: 0.5rem; +} + +.ar-container { + max-width: 800px; + margin: 2rem auto; + padding: 1rem; + background: white; + border-radius: 8px; + box-shadow: 0 2px 10px rgba(0,0,0,0.1); +} + +.camera-feed { + position: relative; + width: 100%; + padding-top: 56.25%; + background: black; + border-radius: 8px; + overflow: hidden; +} + +video, canvas { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + object-fit: cover; +} + +.controls { + display: flex; + gap: 1rem; + justify-content: center; + margin-top: 1rem; +} + +button { + padding: 0.75rem 1.5rem; + border: none; + border-radius: 4px; + background: var(--button-bg); + color: var(--button-text); + font-size: 1rem; + cursor: pointer; + transition: all 0.3s ease; +} + +button:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +button:hover:not(:disabled) { + transform: translateY(-2px); + box-shadow: 0 2px 5px rgba(0,0,0,0.2); +} + +.instructions { + max-width: 800px; + margin: 2rem auto; + padding: 1rem; + background: white; + border-radius: 8px; + box-shadow: 0 2px 10px rgba(0,0,0,0.1); +} + +.instructions h2 { + margin-bottom: 1rem; + color: var(--primary-color); +} + +.instructions ol { + padding-left: 1.5rem; +} + +footer { + margin-top: auto; + padding: 1rem; + text-align: center; + background: var(--secondary-color); + color: white; +} + +@media (max-width: 600px) { + header h1 { + font-size: 2rem; + } + + .ar-container { + margin: 1rem; + } +} \ No newline at end of file