我想在下面计算我的360度图像的正确值:
俯仰://以度为单位。向上是积极的。 偏航://以度为单位。右边是积极的。 半径://圆形目标的半径为米。 距离://目标距离摄像机的距离。
在https://developers.google.com/vr/develop/web/vrview-web#hotspots
上找不到任何东西在以下代码下尝试:
<!doctype html>
<html>
<head>
<title>VR Test</title>
<script src="https://storage.googleapis.com/vrview/2.0/build/vrview.min.js"></script>
<style>
</style>
</head>
<body>
<div id='vrview'></div>
<script>
var vrView;
window.addEventListener('load', onVrViewLoad);
function onVrViewLoad() {
// Selector '#vrview' finds element with id 'vrview'.
vrView = new VRView.Player('#vrview', {
image: 'https://storage.googleapis.com/vrview/examples/coral.jpg',
width: '100%',
height: '500px',
is_stereo: true,
is_debug: true
});
vrView.on('click', onHotspotClick);
vrView.on('getposition', onGetPosition);
vrView.addHotspot('hotspot-one', {
pitch: 30, // In degrees. Up is positive.
yaw: 30, // In degrees. To the right is positive.
radius: 100, // Radius of the circular target in meters.
distance: 2, // Distance of target from camera in meters.
});
}
function onGetPosition(e) {
console.log('position',e.id);
}
function onHotspotClick(e) {
vrView.getPosition();
console.log('onHotspotClick', e.id);
}
</script>
</body>
</html>
预期结果应该是一些ID,其中包含我可以在单击事件上看到" yaw"one_answers" pitch"值的对象。
上述代码的实际结果是:
onHotsPotClick undefined
问题是脚本标签,我错过了添加类型<script type="text/javascript">
,这在图像上添加了标记。