I
I
Ilya Sandul2017-07-24 19:15:04
JavaScript
Ilya Sandul, 2017-07-24 19:15:04

How to tie a flashlight to a gyroscope?

Ladies and gentlemen, tell me how to bind a flashlight written in JS, or Jquery, to the phone's gyroscope? What if, when tilted, the flashlight also deflected? Imagine that it is initially in a central position, relative to the screen. When you tilt the phone slightly up, the flashlight deviates to the bottom. I hope the idea is clearly stated, who can help, ideally, of course, if everything is like for a moron, tell, show, and do it.
Flashlight examples.
https://github.com/jwagner/normalmap.js/
https://codepen.io/zKevin/pen/LVgLvy
Tried it on my own, couldn't really figure it out.
Umnikov, with advice, kind, googled, please do not unsubscribe. Or arrogant rednecks, like, "Hands out of your ass, get out of here."

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kornilov, 2017-07-24
@KorniloFF

// Обработчик поворота экрана
function change_orientation() {
    alert('Screen: '+screen.width+' '+screen.height);
}
// Установка обработчика поворота экрана
if (window.onorientationchange) {
    window.onorientationchange=function() {
        change_orientation();
    }
}
else {
    window.onresize = function() {
        change_orientation();
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question