SlideShare a Scribd company logo
Building VR experience
with React VR
About me
Mirek Ciastek
Front-end Developer in SwingDev
https://twitter.com/mciastek
https://medium.com/@mciastek
https://github.com/mciastek
About Swing
SwingDev is a Polish-American
company building software solutions for
enterprise and startup clients in Silicon
Valley.
Our creative department, Swing3D,
specialises in AR and VR technologies,
building 3D modelling tools and
interactive presentations of 3D projects.
www.swingdev.io
www.swing3d.io
State of VR in Web
What is ReactVR?
ReactVR basics
Extending ReactVR
Demo
Docs and articles
Agenda
State of VR in Web
Browser
support
https://github.com/googlevr/webvr-polyfill
WebVR polyfill
What is
ReactVR?
React + React Native + three.js
Main Thread
ReactVR Runtime
React Native
WebGL/WebVR
OVRUI Three.js
WebWorker
ReactVR
Application
Code
React
Native
React
Web Browser
AsynchronousBridge
React VR lets you
build VR apps using
only JavaScript. It
uses the same design
as React, letting you
compose a rich VR
world and UI from
declarative
components.
1
2
3
<View>
<Pano source={asset(‘chess-world.jpg')}/>
<Text
style={{
backgroundColor: '#777879',
fontSize: 0.8,
layoutOrigin: [0.5, 0.5],
paddingLeft: 0.2,
paddingRight: 0.2,
textAlign: 'center',
textAlignVertical: 'center',
transform: [{translate: [0, 0, -3]}],
}}>
hello
</Text
</View>
1
2
3
3D object primitives - Box, Sphere, Plane, Cylinder, etc.
Panorama - both photo and video panoramas
Lights - AmbientLight, DirectionalLight, PointLight, SpotLight
User interactions through buttons and events - VrButton and e.g. onInput event
Loading models in OBJ and GLTF format
Animations
CSS-like styles and flexbox (inherited from React Native)
…and CLI
ReactVR gives us..
Building Browser VR Experience in React VR
Let’s build a room
Maybe something like this
First attempt
I prefer the real 3D experience
Final project
Building Browser VR Experience in React VR
know basics of 3D
know how to write your own shaders
know very well API of three.js
know how WebGL works
have a dedicated team of 3D artists and 3D programmers
You can do it yourself, if you…
Building this scene entirely in ReactVR is very difficult. You should use a 3D
programme (like Blender or 3ds Max) to create a 3D model and then import
it to ReactVR.
ReactVR supports OBJ and GLTF formats by default, but you can add
loaders for your own formats.
You can’t build beautiful scene using only ReactVR primitives. You need to
go further…
How you can use ReactVR for such project?
By extending ReactVR,
you can make pretty
nice cursor navigation
based on Navigation
Mesh.
Extending React VR
Navigation mesh made in any 3D programme, loaded in any format that
three.js supports (I used JSON)
Custom cursor component using Animated class Custom module for
navigation mesh
Raycaster to check if user can go to pointed direction
RCTDeviceEventEmitter to communicate between UI and WebWorker
What you need
Cursor component
Add components
<AnimatedPlane
dimWidth={SIZE}
dimHeight={SIZE}
materialParameters={{
side: THREE.FrontSide,
blending: THREE.AdditiveBlending,
depthWrite: false,
}}
texture={asset('cursor-outline.png')}
style={{
opacity: this.state.opacity,
transform: [{
scale: this.state.scale,
}],
}}
/>
<Plane
dimWidth={SIZE}
dimHeight={SIZE}
materialParameters={{
side: THREE.FrontSide,
depthWrite: false,
}}
texture={asset('cursor-bg.png')}
style={{
opacity: baseOpacity,
}}
/>
Cursor component
Animated.parallel([
Animated.timing(this.state.opacity, {
duration: 300,
toValue: 0,
}),
Animated.timing(this.state.scale, {
duration: 300,
toValue: 1.5,
}),
]).start(this.handleAnimationEnd);
Run the animation
handleAnimationEnd = () => {
Animated.timing(this.state.opacity, {
duration: 200,
toValue: OPACITY,
}).start();
this.state.scale.setValue(1);
if (this.props.onAnimationEnd) {
this.props.onAnimationEnd();
}
};
Reset scale on animation end
Nav mesh module
Load navigation mesh
load() {
this.loader = new THREE.JSONLoader();
this.loader.load(
‘/static_assets/nav-mesh.json’,
this.handleModelLoad
);
}
Emit event on camera move
this.rtContext.callFunction(
'RCTDeviceEventEmitter',
'emit',
['teleport', this.targetPos.x, this.targetPos.z],
);
Nav mesh module
Check for intersections with navigation mesh
// Set raycast from camera
this.raycaster.setFromCamera({
x: this.lastX,
y: this.lastY
}, this.camera);
// Get intersections
const objectsIntersections = this.raycaster.intersectObjects(this.objects);
// Check if there are any intersection with nav mesh
if (
objectsIntersections[0] &&
objectsIntersections[0].object === this.mesh
) {
// Move your camera
}
Index.vr.js
Add Cursor component
<Cursor
animate={this.state.cursorAnimate}
onAnimationEnd={this.handleCursorAnimationEnd}
visible={this.state.cursorVisibility}
style={{
transform: [{
rotateX: -90,
}, {
translate: [this.state.cursorX, -this.state.cursorZ, -0.098],
}],
opacity: this.state.cursorOpacity,
}}
/>
Index.vr.js
Add event listener
RCTDeviceEventEmitter.addListener('teleport',
(x, z) => {
this.setState({
cursorAnimate: true,
});
Animated.timing(this.state.camPos, {
toValue: { x, y: z },
duration: 500,
easing: Easing.inOut(Easing.quad),
}).start(this.handleCameraAnimationEnd);
});
Demo
Thanks to:
Bartek Gadzała
Tomek Wieczorkowski
Docs and articles
Getting Started with ReactVR
Oculus Developer Center
WebVR Rocks
Prototyping with React VR
Getting Started with WebVR
Thank you

More Related Content

PDF
[GREE Tech Talk #08] You Don't Know WebGL
PPTX
Dataflow Visualization using ASCII DAG
PPTX
Augmented Reality with JavaScript
PPTX
Getting Started with React.js
PPTX
Say hello to react js - Day 1
PDF
Building UWP apps with React-Native
PPTX
React-VR: An Early Experiment with React and WebGL for VR Development
PPTX
Building AR and VR Experiences for Web Apps with JavaScript
[GREE Tech Talk #08] You Don't Know WebGL
Dataflow Visualization using ASCII DAG
Augmented Reality with JavaScript
Getting Started with React.js
Say hello to react js - Day 1
Building UWP apps with React-Native
React-VR: An Early Experiment with React and WebGL for VR Development
Building AR and VR Experiences for Web Apps with JavaScript

Similar to Building Browser VR Experience in React VR (20)

PDF
Quick dive into WebVR
PPTX
Турський Віктор “Як (і чому) побудувати додаток VR з ReactVR?” GameDev Confe...
PDF
WebVR - JAX 2016
PPTX
Hacking Reality: Browser-Based VR with HTML5
PDF
Getting Started in VR with JS
PDF
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
PDF
Introduction to WebVR Autodesk Forge 2016
PPTX
VR Without Borders RIVER WebVR April 2015
PDF
WebVR: Developing for the Immersive Web
PDF
Ferguson VR Hackathon - May 6, 2017
PPTX
Introduction to The VR Web
PDF
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
PDF
Building a game with WebVR
PPTX
Browser-Based Virtual Reality April 2015
PDF
Migrating your Web app to Virtual Reality
PDF
Casper Fabricius (Cimmerse): WebVR with A-Frame, React and Redux
PPTX
Getting Started with Web VR
PDF
Foundations of the Immersive Web
PPTX
Up And Running With Web VR Fall 2014
PPTX
An Introduction to Web VR January 2015
Quick dive into WebVR
Турський Віктор “Як (і чому) побудувати додаток VR з ReactVR?” GameDev Confe...
WebVR - JAX 2016
Hacking Reality: Browser-Based VR with HTML5
Getting Started in VR with JS
Bringing Virtual Reality to the Web: VR, WebGL and CSS – Together At Last!
Introduction to WebVR Autodesk Forge 2016
VR Without Borders RIVER WebVR April 2015
WebVR: Developing for the Immersive Web
Ferguson VR Hackathon - May 6, 2017
Introduction to The VR Web
Портируем существующее Web-приложение в виртуальную реальность / Денис Радин ...
Building a game with WebVR
Browser-Based Virtual Reality April 2015
Migrating your Web app to Virtual Reality
Casper Fabricius (Cimmerse): WebVR with A-Frame, React and Redux
Getting Started with Web VR
Foundations of the Immersive Web
Up And Running With Web VR Fall 2014
An Introduction to Web VR January 2015
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A Presentation on Artificial Intelligence
Mobile App Security Testing_ A Comprehensive Guide.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Ad

Building Browser VR Experience in React VR