谷歌VR视图使用点击热点来更改内容



一旦我的网站上有一个嵌入式VR视图,我该如何实现点击热点?

function onVrViewLoad() {
var v;
v = new VRView.Player('#vrview', {
image: '/images/firstImage.jpg',
is_stereo: false
});
v.on('ready', function(){
v.addHotspot('hotspotOne', {
pitch: 0, // In degrees. Up is positive.
yaw: 180, // In degrees. To the right is positive.
radius: 0.05, // Radius of the circular target in meters.
distance: 2 // Distance of target from camera in meters.
});
});
v.on('click', function(event) {
if (event.id == 'hotspotOne') {
v.setContentInfo({
image: '/images/secondImage.jpg',
is_stereo: false
});
}
});}

热点将显示并可以单击,但它不会更改图像。如果我将 v.setContentInfo(( 替换为 window.location.href='/secondImage.html',在那里我用该图像设置了另一个 vr 查看器,它会加载页面。所以我知道点击事件正在正确注册,但 setContentInfo(( 没有。

虽然文档说要使用setContentInfo((,但我发现它实际上是setContent((可以工作的。这让我一时头疼!

v.setContent({
image: '/images/secondImage.jpg',
is_stereo: false
});

最新更新