[英]How to find hotspots value(pitch,yaw) on mouseclick in Google VR View Web
我想在點擊事件時為我的 360 度圖像計算下面提到的正確值:
俯仰://以度為單位。 向上為正。 yaw: // 以度為單位。 右邊是積極的。 radius: // 圓形目標的半徑(以米為單位)。 distance: // 目標與相機的距離,以米為單位。
在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”和“pitch”值的對象。
上面代碼的實際結果是:
onHotspotClick 未定義
問題在於腳本標簽,我錯過了添加類型<script type="text/javascript">
,這在圖像上添加了一個標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.