[英]How to solve a problem with devicemotion script?
我不確定這是問不對的地方,但是我的devicemotion
腳本有問題。
我有一些代碼在頁面加載時運行,以檢查是否有陀螺儀可用。 我通過以下方式執行此操作:
function check_user_hardware(){
if (mobile_size <= 600) {
hidden = true;
}
console.log("checking hardware");
giro_timer = setTimeout(update_gyro_value, 30);
window.addEventListener("devicemotion", function(event){
console.log("device motion?");
if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma){
calculate_rotation_mesh_pos(event.rotationRate.beta, event.rotationRate.gamma);
if (!gyroscope) {
gyroscope = true;
console.log("gyroscope here");
current_interaction_mode = 'gyroscope_option';
set_user_ui_elements();
}
}else{
followMouse = true;
console.log("no gyroscope here");
current_interaction_mode = 'followMouse_option';
set_user_ui_elements();
window.addEventListener('mousemove', get_user_mouse_pos);
}
});
}
幾周前,這種方法就很好了,但是現在不起作用了。 我在控制台中看到以下打印:
checking hardware
就是這樣。 為什么我的devicemotion事件不觸發? 即使在使用基本SSL加密的網站上也無法正常工作,為什么? 我需要某種特殊的SSL加密嗎?
這是怎么回事 歡迎提出所有建議!
如果需要更多信息,我將很樂意提供。
您可以在此處查看有問題的網站:gravient.thomashoek.com
我在Web應用程序上遇到了同樣的問題。 我發現在Chromium 62上存在有關加速度計的問題,但似乎在v.63中已解決。
但是,“ devicemotion”事件在我這邊的chrome Android上也不再起作用(但在iOS上卻能正常工作)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.