-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstore.js
75 lines (67 loc) · 2.44 KB
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// 全局变量
const store = {
yaw: 0, // 移动设备的航空次序欧拉角
pitch: 0,
roll: 0,
originCoords: null,//虚拟坐标原点经纬度
poi: [],
scene: null, // three场景
camera: null, // three相机
renderer: new THREE.WebGLRenderer({alpha: true,antialias: true}), // trree渲染器
videoTack: null, // 后置摄像头视频流
eventName: getDeviceOrientationEventName(), // 设备姿态变换事件名称
VAOV: 2*Math.atan(18/27)*180/Math.PI, // 相机竖直视角
constraints: { // 视频流限制条件
audio: false,
video: {
facingMode: { exact: "environment" },
// aspectRatio:1440/3120,
aspectRatio: { exact: window.innerHeight/window.innerWidth }, // 高!!宽!!比
width: { ideal: 800 },
height: { ideal: 400 },
}
},
mixers: [], // 动画集合
textlabels: [],
selectedObject: null, // 选中的虚拟物体
record: [],// 实验记录
}
// isSafari();
/**
* Get device orientation event name, depends on browser implementation.
* @returns {string} event name
*/
function getDeviceOrientationEventName () {
if ('ondeviceorientationabsolute' in window) {
var eventName = 'deviceorientationabsolute'
}
else if ('ondeviceorientation' in window) {
var eventName = 'deviceorientation'
} else {
var eventName = ''
console.error('Compass not supported')
}
return eventName
}
function isSafari(){
// if Safari
if (!!navigator.userAgent.match(/Version\/[\d.]+.*Safari/)) {
// iOS 13+
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
var handler = function() {
console.log('Requesting device orientation permissions...')
DeviceOrientationEvent.requestPermission();
document.removeEventListener('touchend', handler);
};
document.addEventListener('touchend', function() { handler() }, false);
alert('After camera permission prompt, please tap the screen to active geolocation.');
} else {
var timeout = setTimeout(function () {
alert('Please enable device orientation in Settings > Safari > Motion & Orientation Access.')
}, 750);
window.addEventListener(eventName, function () {
clearTimeout(timeout);
});
}
}
}