Tips 2 : Display the 3D object on the original image
1. Introduction
Please note that this chapter follows the AR.js tutorial and puts the images on github
2. Prepare image files
Not all image files can be used, the image needs to have a large amount of features
Press the generate button to download the 3 files iset / fset / fset3
Put the data on github
code: file
sample_image
├ sample.iset
├ sample.fset
└ sample.fset3
This time, we will use the following image
https://gyazo.com/2d07d07e8a6bf434823a67049e5ff819
3. Import libraries
When tracking image with NFT, the following two libraries are required unlike Marker Tracking
Enter this script into the head tags
code: html
4. Image registration using NFT
Register the image file using the a-nft tag
The path is <username> / <repository name> / <branch name> / <file path>
Also, describe the three files iset / fset / fset3 with the extension name removed
code: html
<a-scene embedded arjs>
<a-nft
type="nft"
smooth="true"
smoothCount="10"
smoothTolerance=".01"
smoothThreshold="5"
</a-nft>
</a-scene>
5. Add an object to display
Add an object in the a-nft tags
code: html
<a-scene embedded arjs>
<a-nft
type="nft"
smooth="true"
smoothCount="10"
smoothTolerance=".01"
smoothThreshold="5"
<a-box position="0 0 0" width="100"></a-box>
</a-nft>
</a-scene>
6. Add camera
code:html
<a-scene embedded arjs>
<a-nft
type="nft"
smooth="true"
smoothCount="10"
smoothTolerance=".01"
smoothThreshold="5"
<a-box position="0 0 0" scale="75 75 75"></a-box>
</a-nft>
<a-entity camera></a-entity>
</a-scene>
7. Publish
The final script is as follows
code: html
<!doctype HTML>
<html>
<head>
</head>
<body style="margin : 0px; overflow: hidden;">
<a-scene >
<a-nft
type="nft"
smooth="true"
smoothCount="10"
smoothTolerance=".01"
smoothThreshold="5"
<a-box position="0 0 0" scale="75 75 75"></a-box>
</a-nft>
<a-entity camera></a-entity>
</a-scene>
</body>
</html>