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:
- 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
- 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); ...