File size: 14,396 Bytes
80ae081 | 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | <!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>تجربة الواقع المعزز بالفيديو | AR.js</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/ar.js/2.1.8/aframe/build/aframe-ar.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.arjs-loader {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
color: white;
}
.arjs-loader div {
text-align: center;
font-size: 1.25em;
margin-top: 1em;
}
.controls-panel {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
background: rgba(0,0,0,0.7);
border-radius: 20px;
padding: 10px;
backdrop-filter: blur(5px);
}
.info-panel {
position: absolute;
top: 20px;
right: 20px;
z-index: 100;
background: rgba(0,0,0,0.7);
border-radius: 15px;
padding: 15px;
color: white;
max-width: 300px;
backdrop-filter: blur(5px);
}
@media (max-width: 768px) {
.info-panel {
max-width: 200px;
font-size: 0.8rem;
}
}
</style>
</head>
<body class="bg-gray-900 text-white font-sans">
<!-- Loading Screen -->
<div class="arjs-loader">
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500 mb-4"></div>
<div>جاري تحميل تجربة الواقع المعزز...</div>
<div class="text-sm mt-2">يمكنك الآن عرض المحتوى في مساحة العالم الحقيقي</div>
</div>
<!-- AR Scene -->
<a-scene embedded arjs='sourceType: webcam; detectionMode: mono;' vr-mode-ui="enabled: false" loading-screen="enabled: false;">
<!-- Video Content -->
<a-entity id="content-entity" position="0 0 -2">
<a-video
id="ar-video"
src="https://www.w3schools.com/html/mov_bbb.mp4"
width="1.5"
height="1"
position="0 0 0"
rotation="0 0 0"
autoplay="false"
loop="true">
</a-video>
</a-entity>
<!-- Camera -->
<a-entity camera></a-entity>
</a-scene>
<!-- Info Panel -->
<div class="info-panel hidden md:block">
<h2 class="text-xl font-bold mb-2 text-blue-400">تعليمات الاستخدام</h2>
<ul class="list-disc list-inside space-y-2">
<li>وجه الكاميرا نحو المساحة التي تريد عرض المحتوى فيها</li>
<li>استخدم عناصر التحكم للتحكم بالفيديو</li>
<li>يمكنك تحريك جهازك لتغيير زاوية العرض</li>
<li>استخدم الاستوديو لتغيير المحتوى المعروض</li>
</ul>
<div class="mt-3 pt-3 border-t border-gray-600">
<p class="text-sm">تم التطوير باستخدام AR.js و A-Frame</p>
</div>
</div>
<!-- Controls Panel -->
<div class="controls-panel flex items-center space-x-4 space-x-reverse">
<button id="studio-btn" class="bg-purple-600 hover:bg-purple-700 text-white p-3 rounded-full">
<i class="fas fa-cog"></i>
</button>
<button id="play-btn" class="bg-blue-600 hover:bg-blue-700 text-white p-3 rounded-full">
<i class="fas fa-play"></i>
</button>
<button id="pause-btn" class="bg-yellow-600 hover:bg-yellow-700 text-white p-3 rounded-full">
<i class="fas fa-pause"></i>
</button>
<button id="volume-up" class="bg-green-600 hover:bg-green-700 text-white p-3 rounded-full">
<i class="fas fa-volume-up"></i>
</button>
<button id="volume-off" class="bg-red-600 hover:bg-red-700 text-white p-3 rounded-full">
<i class="fas fa-volume-off"></i>
</button>
</div>
<!-- AR Studio -->
<div id="ar-studio" class="fixed inset-0 bg-black bg-opacity-90 z-50 hidden flex flex-col items-center justify-center p-4">
<div class="bg-gray-800 rounded-lg p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-white">استوديو AR</h2>
<button id="close-studio" class="text-gray-400 hover:text-white">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-300 mb-1">رابط الفيديو</label>
<input type="text" id="video-url" class="w-full bg-gray-700 text-white rounded p-2 mb-2"
placeholder="أدخل رابط الفيديو" value="https://www.w3schools.com/html/mov_bbb.mp4">
<label class="block text-sm font-medium text-gray-300 mb-1">رابط الصورة</label>
<input type="text" id="image-url" class="w-full bg-gray-700 text-white rounded p-2"
placeholder="أدخل رابط الصورة">
</div>
<div class="pt-2 border-t border-gray-700">
<div class="flex space-x-2 space-x-reverse">
<button id="set-video" class="flex-1 bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded">
<i class="fas fa-video mr-2"></i> تعيين فيديو
</button>
<button id="set-image" class="flex-1 bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded">
<i class="fas fa-image mr-2"></i> تعيين صورة
</button>
</div>
</div>
<div class="flex space-x-2 space-x-reverse">
<button id="apply-video" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded">
تطبيق الفيديو
</button>
<button id="test-video" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded">
اختبار
</button>
<button id="download-marker" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded">
<i class="fas fa-download mr-2"></i> تحميل الماركر
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const scene = document.querySelector('a-scene');
const loader = document.querySelector('.arjs-loader');
const video = document.querySelector('#ar-video');
const playBtn = document.querySelector('#play-btn');
const pauseBtn = document.querySelector('#pause-btn');
const volumeUp = document.querySelector('#volume-up');
const volumeOff = document.querySelector('#volume-off');
const markerDetected = document.querySelector('#marker-detected');
const marker = document.querySelector('#video-marker');
// Hide loader when scene is loaded
scene.addEventListener('loaded', () => {
setTimeout(() => {
loader.style.display = 'none';
}, 1500);
});
// Video controls
playBtn.addEventListener('click', () => {
video.components.material.material.map.image.play();
playBtn.classList.add('hidden');
pauseBtn.classList.remove('hidden');
});
pauseBtn.addEventListener('click', () => {
video.components.material.material.map.image.pause();
pauseBtn.classList.add('hidden');
playBtn.classList.remove('hidden');
});
volumeUp.addEventListener('click', () => {
video.setAttribute('sound', 'volume', 1);
volumeUp.classList.add('hidden');
volumeOff.classList.remove('hidden');
});
volumeOff.addEventListener('click', () => {
video.setAttribute('sound', 'volume', 0);
volumeOff.classList.add('hidden');
volumeUp.classList.remove('hidden');
});
// Initially hide pause button (video starts paused)
pauseBtn.classList.add('hidden');
volumeOff.classList.add('hidden');
// Add sound component to video
video.setAttribute('sound', 'src', '#video-src; autoplay: false; volume: 1');
// Handle mobile orientation
window.addEventListener('orientationchange', () => {
window.location.reload();
});
// Studio controls
const studioBtn = document.querySelector('#studio-btn');
const studio = document.querySelector('#ar-studio');
const closeStudio = document.querySelector('#close-studio');
const videoUrl = document.querySelector('#video-url');
const applyVideo = document.querySelector('#apply-video');
const testVideo = document.querySelector('#test-video');
studioBtn.addEventListener('click', () => {
studio.classList.remove('hidden');
});
closeStudio.addEventListener('click', () => {
studio.classList.add('hidden');
});
applyVideo.addEventListener('click', () => {
video.setAttribute('src', videoUrl.value);
studio.classList.add('hidden');
});
testVideo.addEventListener('click', () => {
const testWindow = window.open(videoUrl.value, '_blank');
setTimeout(() => {
testWindow.close();
}, 3000);
});
// Handle content switching
const contentEntity = document.querySelector('#content-entity');
const imageUrl = document.querySelector('#image-url');
const setVideo = document.querySelector('#set-video');
const setImage = document.querySelector('#set-image');
setVideo.addEventListener('click', () => {
const url = videoUrl.value;
if (!url) return;
// Clear existing content
contentEntity.innerHTML = '';
// Add video element
const videoEl = document.createElement('a-video');
videoEl.setAttribute('id', 'ar-video');
videoEl.setAttribute('src', url);
videoEl.setAttribute('width', '1.5');
videoEl.setAttribute('height', '1');
videoEl.setAttribute('position', '0 0 0');
videoEl.setAttribute('rotation', '0 0 0');
videoEl.setAttribute('autoplay', 'false');
videoEl.setAttribute('loop', 'true');
contentEntity.appendChild(videoEl);
studio.classList.add('hidden');
});
// Marker download
const downloadMarker = document.querySelector('#download-marker');
downloadMarker.addEventListener('click', () => {
const link = document.createElement('a');
link.href = 'https://raw.githubusercontent.com/AR-js-org/AR.js/master/data/images/hiro.png';
link.download = 'ar-marker.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
setImage.addEventListener('click', () => {
const url = imageUrl.value;
if (!url) return;
// Clear existing content
contentEntity.innerHTML = '';
// Add image element
const imageEl = document.createElement('a-image');
imageEl.setAttribute('id', 'ar-image');
imageEl.setAttribute('src', url);
imageEl.setAttribute('width', '1.5');
imageEl.setAttribute('height', '1');
imageEl.setAttribute('position', '0 0 0');
imageEl.setAttribute('rotation', '0 0 0');
contentEntity.appendChild(imageEl);
studio.classList.add('hidden');
});
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Mkdm1/ar" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |