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
1 parent
8ce8c84
commit 78ab90d
Showing
2 changed files
with
41 additions
and
4 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
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 |
---|---|---|
@@ -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> |