[ReactVR] Start a Virtual Reality Project Using the React VR CLI

We will learn how to set up a React VR project, run the development mode with hot reloading, and take a small dive into the generated code and make a small change.

 

Install:

npm -g i react-vr-cli

 

Create app:

react-vr init app

 

Enable hotreload:

localhost:8081/vr/?hotreload

 

复制代码
import React from 'react';
import {
  AppRegistry,
  asset,
  Pano,
  Text,
  View,
} from 'react-vr';

export default class app extends React.Component {
  render() {
    return (
      <View>
        <Pano 
          style={{
            transform: [{rotateY: "10deg"}]
          }}
          onLoad={() => {console.log('Image is loaded successfully')}}
          onLoadEnd={() => {console.log('Load end')}}
          source={asset('mittel.jpg')}
          />
        <Text
          style={{
            backgroundColor: '#777879',
            fontSize: 0.8,
            fontWeight: '400',
            layoutOrigin: [0.5, 0.5],
            paddingLeft: 0.2,
            paddingRight: 0.2,
            textAlign: 'center',
            textAlignVertical: 'center',
            transform: [{translate: [0, 0, -3]}],
          }}>
          hello world
        </Text>
      </View>
    );
  }
};

AppRegistry.registerComponent('app', () => app);
复制代码

 

'source' can also take array of assets:

<Pano
    source={[asset('right.png'), asset('left.png'), asset('up.png'), asset('down.png'), asset('back.png'), asset('front.png')]} 
/>

 

posted @   Zhentiw  阅读(214)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2017-02-07 [NPM] Run npm scripts with git hooks
2017-02-07 [NPM] Use custom config settings in your npm scripts
2017-02-07 [React] Use Jest's Snapshot Testing Feature
2017-02-07 [NPM] Use package.json variables in npm scripts
2017-02-07 [NPM] Run npm scripts when files change with onchange
点击右上角即可分享
微信分享提示