Skip to content

Commit

Permalink
morework on tquery.headtrackr
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeetienne committed Dec 8, 2012
1 parent 8ce8c84 commit 78ab90d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
6 changes: 2 additions & 4 deletions plugins/headtrackr/examples/demo.html
@@ -1,7 +1,5 @@
<!doctype html><title>Minimal tQuery Page</title>
<script src="../../../build/tquery-bundle-require.js"></script>
<script src="../vendor/headtrackr.js"></script>
<script src="../tquery.headtrackr.js"></script>
<body><div id="info">
Example of tQuery.headtrackr plugin -
<a href='https://github.com/mrdoob/three.js/' target='_blank'>three.js</a> +
Expand All @@ -10,7 +8,7 @@
<br/>
press [space] to reset head tracking
</div><script>
require(['tquery.skymap', 'tquery.lensflare'], function(){
require(['tquery.skymap', 'tquery.lensflare', 'tquery.headtrackr'], function(){
var world = tQuery.createWorld().boilerplate().pageTitle('#info').start();

// tune initial camera position
Expand All @@ -27,7 +25,7 @@

// load the head of walt
var loader = new THREE.BinaryLoader( true );
loader.load("../../assets/obj/walt/WaltHead_bin.js", function(tGeometry){
loader.load("../../../plugins/assets/obj/walt/WaltHead_bin.js", function(tGeometry){
// normalize the geometry
var geometry = tQuery(tGeometry).computeAll().normalize().computeAll();
// create the material
Expand Down
39 changes: 39 additions & 0 deletions plugins/headtrackr/examples/example.html
@@ -0,0 +1,39 @@
<!doctype html><title>Minimal tQuery Page</title>
<script src="../../../build/tquery-bundle-require.js"></script>
<script src="../vendor/headtrackr.js"></script>
<script src="../tquery.headtrackr.js"></script>
<body><script>
var world = tQuery.createWorld().boilerplate().start();
world.removeCameraControls();

var object = tQuery.createCube().addTo(world);

// create the headTracker
var headTracker = tQuery.createHeadtrackr({
headtrackrOpts : {
calcAngles : true
}
})
.debugView(true)
.start();

// make the camera move depending on facetrackingEvent
headTracker.addEventListener("facetrackingEvent", function(event){
// get a normalized coord [-1, +1]
var normalized = event.normalizedCoords;
// pass normalized coord
object.positionX(normalized.x);
object.positionY(normalized.y);
object.scaleX(normalized.width);
object.scaleY(normalized.height);
object.rotationZ(normalized.angle);
});

// reset headTracker if space is pressed
document.addEventListener('keydown', function(event){
// only if the key is space
if( event.keyCode !== ' '.charCodeAt(0) ) return;
// reset the head tracker
headTracker.reset();
});
</script></body>

0 comments on commit 78ab90d

Please sign in to comment.