Joseph Khan
Apr 24, 2019
Building 360 immersive apps with React
Joseph Khan
Senior Developer
Author of Adobe Edge Inspect Starter
Technical reviewer of Sencha Touch Cookbook
React VR aims to allow web developers to author virtual reality (VR) applications using the declarative approach of React and, in particular, React Native
React VR uses JSX syntax
VR is being used in many industries
Besides games, it is being used in the field of medicines, education, movies etc
Provides immersive experience in a scene
360 tours and views because you can interact with a scene
React VR
React + React Native
Runtime
Three.js
WebVR & WebGL
npm install -g react-vr-cli
Install
react-vr init GettingStarted
Create a Project:
cd GettingStarted
Get inside the project root:
npm run start
Launch/Run the project:
react-vr -v
Optional: Check Version
A pano image allows you to see the image from every angle including above, below, behind and next to you, that's the reason they are also called 360 images or spherical panoramas.
An equirectangular pano consists of a single image with an aspect ratio of 2:1, meaning that the width must be twice the height.
These images are created with a special 360 camera.
<Pano
source={ {uri:'../static_assets/sample_pano.jpg'} }/>
Cubemaps are the other format of 360 panoramas. This format uses six images for the six faces of a cube that will fill the sphere around us. It's also known as a skybox.
<Pano source={
{
uri: [
'../static_assets/sample_right.jpg',
'../static_assets/sample_left.jpg',
'../static_assets/sample_top.jpg',
'../static_assets/sample_bottom.jpg',
'../static_assets/sample_back.jpg',
'../static_assets/sample_front.jpg'
]
}
} />
React VR uses the same right-handed coordinate system that OpenGL uses, with positive X pointing to the right, positive Y pointing up, and positive Z pointing forwards towards the user
column layout
alignItems
justifyContent
main-axis
cross-axis
justifyContent
alignItems
cross-axis
main-axis
row layout
* column by default
React VR has a Model component that supports the Wavefront .obj file format to represent 3D models.
A .obj file is a plain text file that contains coordinates of geometric vertices, texture coordinates, vertex normals and polygonal face elements, among other things.
Typically, a .obj file references an external .mtl file where the materials (or textures) that describe the visual aspect of the polygons are stored.
There's also a lot of sites where you can download 3D models either for free or at a cost. The following are three of the best ones:
Lets build a VR app..
Enhancing the Tajawal Hotels App
npm run bundle
Will be Happy to Answer!
Code repo: