Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gyro.startTracking(function(o) {
- if (!loaded) {
- return;
- }
- isUserInteracting = true;
- var newTime;
- if (typeof performance !== 'undefined' && performance.now()) {
- newTime = performance.now();
- } else {
- newTime = Date.now();
- }
- if (prevTime === undefined) {
- prevTime = newTime;
- }
- var diff = (newTime - prevTime) * config.hfov / 1700;
- diff = Math.min(diff, 1.0);
- //console.log(diff);
- var alpha = (o.alpha) - 180;
- alpha = ((alpha) - ((alpha) * 2));
- // console.log(alpha);
- var beta = o.beta - (o.beta *2);
- yawSpeed = ((alpha) - config.yaw) % 360 * 0.2;
- pitchSpeed = (beta - config.pitch) *0.2;
- //console.log("speed: " + yawSpeed);
- if(oldAlpha > alpha){
- oldAlpha = alpha;
- //Image to left, config.yaw lower
- config.yaw += (yawSpeed * 0.8 - 0.2) * diff;
- }
- else if(oldAlpha < alpha){
- oldAlpha = alpha;
- //Image to right, config.yaw higher
- config.yaw += (yawSpeed * 0.8 + 0.2) * diff;
- }
- if(oldBeta > beta){
- oldBeta = beta;
- console.log("up");
- config.pitch += (pitchSpeed * 0.8 - 0.2) * diff;
- }
- else if(oldBeta < beta){
- console.log("down");
- config.pitch += (pitchSpeed * 0.8 + 0.2) * diff;
- oldBeta = beta;
- }
- animateInit();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement