Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn ARCore - Fundamentals of Google ARCore

You're reading from  Learn ARCore - Fundamentals of Google ARCore

Product type Book
Published in Mar 2018
Publisher Packt
ISBN-13 9781788830409
Pages 274 pages
Edition 1st Edition
Languages
Toc

Table of Contents (17) Chapters close

Title Page
Packt Upsell
Contributors
Preface
1. Getting Started 2. ARCore on Android 3. ARCore on Unity 4. ARCore on the Web 5. Real-World Motion Tracking 6. Understanding the Environment 7. Light Estimation 8. Recognizing the Environment 9. Blending Light for Architectural Design 10. Mixing in Mixed Reality 11. Performance Tips and Troubleshooting 1. Other Books You May Enjoy Index

Visualizing tracked motion


Now that we understand how to track motion and have a service in place, let's see how we can put this service to use and visualize the tracked data in our AR app. Open up the spawn-at-surface.html page in a text editor and follow the given steps:

  1. Find that last line of code we added in the last exercise and delete it:
firebase.database().ref('pose/' + 1).set({x: 12,y: 1,z : 0});  //delete me
  1. Replace that line with the following code:
var idx = 1;
setInterval(function(){
 idx = idx + 1;
 if(camera){
  camera.updateProjectionMatrix();
  var pos = camera.position;
  var rot = camera.rotation;
  firebase.database().ref('pose/' + idx).set({x: pos.x,y: pos.y,z : pos.z, roll: rot._z, pitch: rot._x, yaw: rot._y });
 }  }, 1000);
  1. The first line in the preceding snippet is setting an index or count variable. Then, we use the setInterval function to set up a repeating timer that calls the anonymous function every second (1000 milliseconds). We do this so that we only track movement...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}