2017-04-06 86 views

回答

0

這裏是我的代碼的一部分,同時創造一個WebVR旅遊

<View> 
     <Pano source={asset(this.state.current_scene['scene_image'])} onInput={this.onPanoInput.bind(this)} 
      onLoad={this.sceneOnLoad} onLoadEnd={this.sceneOnLoadEnd} 
      style={{ transform: [{translate: [0, 0, 0]}] }}/> 
     {this.state.current_scene['navigations'].map(function(item,i){ 
       return <Mesh key={i} 
          style={{ 
           layoutOrigin: [0.5, 0.5], 
           transform: [{translate: item['translate']}, 
              {rotateX: item['rotation'][0]}, 
              {rotateY: item['rotation'][1]}, 
              {rotateZ: item['rotation'][2]}] 
          }} 
         onInput={ e => that.onNavigationClick(item,e)}> 
           <VrButton 
            style={{ width: 0.15, 
              height:0.15, 
              borderRadius: 50, 
              justifyContent: 'center', 
              alignItems: 'center', 
              borderStyle: 'solid', 
              borderColor: '#FFFFFF80', 
              borderWidth: 0.01 
            }}> 
            <VrButton 
              style={{ width: that.state.animationWidth, 
                height:that.state.animationWidth, 
                borderRadius: that.state.animationRadius, 
                backgroundColor: '#FFFFFFD9' 
              }}> 
            </VrButton> 
     </VrButton> 
    </Mesh> 
      })} 
     </View> 
onNavigationClick(item,e){ 
    if(e.nativeEvent.inputEvent.eventType === "mousedown" && e.nativeEvent.inputEvent.button === 0){ 
      var new_scene = this.state.scenes.find(i => i['step'] === item.step); 
      this.setState({current_scene: new_scene}); 
      postMessage({ type: "sceneChanged"}) 
    } 
} 
sceneOnLoad(){ 
    postMessage({ type: "sceneLoadStart"}) 
    } 

    sceneOnLoadEnd(){ 
    postMessage({ type: "sceneLoadEnd"}) 
    } 
this.sceneOnLoad = this.sceneOnLoad.bind(this); 
this.sceneOnLoadEnd = this.sceneOnLoadEnd.bind(this); 
this.onNavigationClick = this.onNavigationClick.bind(this); 

也許你會發現一些有助於您還here

0

對於桌面版Chrome有標誌:鉻://標誌/ #enable-webvr 啓用Chrome並重新啓動Chrome後,將出現「View in VR」按鈕,但不幸的是,當我單擊它時沒有看到任何更改。 我也嘗試過使用Chromium的實驗開發者版本,但是應該啓用更多的標誌。 很多關於調整瀏覽器的內容在這裏: https://superuser.com/questions/836832/how-can-i-enable-webgl-in-my-browser chrome:// gpu /非常方便檢查您的3D環境,並且不要忘記,在某些情況下(通常在筆記本電腦上),您可以運行瀏覽器視頻卡,而不是強大的GPU,所以resluuts可能是極端不同的。 ,最後你可以檢查node_modules/ovrui/dist/ovrui.js函數tryEnterVR()的源代碼,以更好地理解當你嘗試切換到VR模式時應該發生什麼。

0

像帕維爾索科洛夫說,默認情況下,WebVR未啓用,需要在chrome:// flags部分更新。這將啓用顯示在VR按鈕中。但是,當前版本的Chrome(57)在WebVR中存在問題,可能會導致黑屏。那樣的話,試試Chrome Canary吧,我已經成功地使用了它。

我寫了一本關於如何讓我的紙板與React-VR一起運行的指南,您可以閱讀它here

+0

我剛剛嘗試用鉻和vr reactvr只閃現場一微秒,然後完全黑色,你說得到鉻金絲雀任何想法爲什麼鉻(57)不起作用? – JRowan