简体   繁体   中英

How to find hotspots value(pitch,yaw) on mouseclick in Google VR View Web

I want to calculate below mentioned correct value for my 360 deg image on click event :

pitch: // In degrees. Up is positive. yaw: // In degrees. To the right is positive. radius: // Radius of the circular target in meters. distance: // Distance of target from camera in meters.

Can't find anything on https://developers.google.com/vr/develop/web/vrview-web#hotspots

Tried below code :

<!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>

Expected result should be some id which contains objects where I can see "yaw" and "pitch" values on click event.

Actual result with above code is :

onHotspotClick undefined

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM