如何在Google VR View Web中点击鼠标查找热点值(俯仰,偏航)

问题描述 投票:1回答:1

我想在点击事件中为我的360度图像计算下面提到的正确值:

pitch://以度为单位。向上是积极的。 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,我可以在click事件中看到“yaw”和“pitch”值。

以上代码的实际结果是:

onHotspotClick undefined

jquery html google-vr
1个回答
1
投票

问题是脚本标签,我错过了添加类型<script type="text/javascript">,这在图像上添加了一个标记。

© www.soinside.com 2019 - 2024. All rights reserved.