react-native - 如何创建 react-vr "enter vr button/cardboard"?

标签 react-native google-cardboard webvr react-360

我正在玩弄 react-VR框架,似乎无法在文档中找到有关在 chrome/cardboard 上进入 vr 模式的任何内容?非常感谢任何帮助或指点。

最佳答案

这是我创建 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

关于react-native - 如何创建 react-vr "enter vr button/cardboard"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43258059/

相关文章:

javascript - Firebase连接到集合,但按键过滤

react-native - 意外使用保留字 'import React-native

android - 如何为 unity 升级 google cardboard sdk?

java - Android InflateException - 膨胀类 com.google.vr.sdk.base.GvrView 时出错

javascript - 在 A-Frame 组件上,如何在函数之间共享数据?

google-chrome - 如何在 Google Chrome 上启用 WebVR?

android - 如何从WebVR/A-Frame在YoutubeVR应用程序中打开360 Youtube视频

javascript - 不变违规 : Calling pop to route for a route that doesn't exist

android - Expo 的 Android 应用程序无法正确响应代码更改和摇动

android - 读取加载配置文件的当前纸板设备参数