-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,54 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>AR Application - Pattern Recognition</title> | ||
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/jeromeetienne/ar.js@3.3.2/aframe/build/aframe-ar.min.js"></script> | ||
<style> | ||
body { | ||
margin: 0; | ||
overflow: hidden; | ||
} | ||
#error-message { | ||
display: none; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
color: white; | ||
font-size: 18px; | ||
background-color: rgba(0, 0, 0, 0.8); | ||
padding: 20px; | ||
border-radius: 8px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="error-message"> | ||
Please allow camera access to use the AR application. | ||
</div> | ||
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@1.3.0/dist/aframe-master.min.js"></script> | ||
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script> | ||
|
||
<a-scene embedded arjs> | ||
<!-- Marker Definition --> | ||
<a-marker | ||
preset="custom" | ||
type="pattern" | ||
url="./marker.patt"> | ||
<!-- Indicator for Pattern Recognition --> | ||
<a-box | ||
position="0 0.5 0" | ||
material="color: green"> | ||
</a-box> | ||
</a-marker> | ||
<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; | ||
} | ||
|
||
<!-- AR.js Camera --> | ||
<a-entity camera></a-entity> | ||
</a-scene> | ||
.arjs-loader div { | ||
text-align: center; | ||
font-size: 1.25em; | ||
color: white; | ||
} | ||
</style> | ||
|
||
<script> | ||
// Check if AR.js initializes properly | ||
document.querySelector('a-scene').addEventListener('loaded', () => { | ||
console.log('AR.js is ready'); | ||
document.getElementById('error-message').style.display = 'none'; | ||
}); | ||
|
||
// Handle camera errors | ||
navigator.mediaDevices.getUserMedia({ video: true }).catch((err) => { | ||
console.error('Camera access error:', err); | ||
document.getElementById('error-message').style.display = 'block'; | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
<body style="margin : 0px; overflow: hidden;"> | ||
<!-- minimal loader shown until image descriptors are loaded --> | ||
<div class="arjs-loader"> | ||
<div>Loading, please wait...</div> | ||
</div> | ||
<a-scene | ||
vr-mode-ui="enabled: false;" | ||
renderer="logarithmicDepthBuffer: true; precision: medium;" | ||
embedded | ||
arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;" | ||
> | ||
<!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server --> | ||
<a-nft | ||
type="nft" | ||
url="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/trex-image/trex" | ||
smooth="true" | ||
smoothCount="10" | ||
smoothTolerance=".01" | ||
smoothThreshold="5" | ||
> | ||
<a-entity | ||
gltf-model="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf" | ||
scale="5 5 5" | ||
position="150 300 -100" | ||
> | ||
</a-entity> | ||
</a-nft> | ||
<a-entity camera></a-entity> | ||
</a-scene> | ||
</body> |