• Stars
    star
    680
  • Rank 66,440 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of React VR & A-Frame experiments

WebVR Experiments

A collection of React VR & A-Frame experiments (potentially ReasonML & Elm in the future)

Hello World (ReactVR)

This is an experience report/guide to explore ReactVR. Keep in mind I had some basic knowledge in 3D-modeling as well as computer graphics beforehand. Please ping me on Twitter in case you have questions or I take things for granted you have a hard time wrapping your head around. I also highly recommend to read the full ReactVR docs. I did as well :)

reactvr-helloworld

To try out the examples run

# cd into/the/folder
yarn install
npm start
# open http://localhost:8081/vr/

Or check out the hosted live demo of HelloWorld v3 and live demo of Animation v2.

v1 - Basic Cube Rendering

screen shot cube

With this example I wanted to explore how to create my own geometries and render it within ReactVR. I evaluated a couple of tools and in the end decided to go with Blender. I'm still struggling with the interface a bit, but Blender is open source has all the advanced features I will probably need for the next couple of years.

In Blender I created a cube, removed the light and camera, added a material to color the cube's surfaces and exported the scene to the Wavefront .obj (geometry) and .mtl (material) format. Then learned that Three.js failed to render my simple cube properly as soon as I create a <Model source={{ obj: asset('cube.obj'), mtl: asset('cube.mtl') }} lit={true} /> due to some issues with the material definitions. What worked for me was to remove all the gimmick features from the material and reduce it to Diffuse & Specular lighting. I unchecked all other checkboxes for the material. This is not a Blender only issue, as I encountered similar issues once I gave other tools a try.

cube setup in blender

v2 - Tree (first custom component)

screen shot tree

The goal of this stage was to create a Tree component. I created two geometries (tree-crown, tree-trunk) and placed them in my HelloWorld component. After some positioning I was able to extract both into a Tree component. This allowed me to create a second one and place it next to the first one.

screen shot 2016-12-28 at 01 33 52

screen shot 2016-12-28 at 01 35 03

Tree component:

export default ({ style }) => (
  <View style={style}>
    <Model
      source={{ obj: asset('tree-trunk.obj'), mtl: asset('tree-trunk.mtl') }}
      lit={true}
      style={{ transform: [{scale: [0.6, 1, 0.6]}] }}
    />
    <Model
      source={{ obj: asset('tree-crown.obj'), mtl: asset('tree-crown.mtl') }}
      lit={true}
      style={{ transform: [{translate: [0, 2.5, 0]}] }}
    />
  </View>
);

In addition to that I generated a plane geometry in Blender as floor element. For the sky I generated a blue gradient image and used it in a <Pano /> component.

Initially I planned to place the scenic camera approximately one meter above the ground, but discovered a bug with the <Scene /> component. My fallback was to position the floor as well as the trees -1 (meter) on the z-axis.

v3 - Forest

screen shot forest

Next up I wanted to have a more interesting scene as well as explore how I could generate it. I decided to create a forest. This was pretty much straight forward as I could create a Forest component which uses the Tree component multiple times. By adding some randomizers for positioning, height and scale, I ended up with what I envisioned.

Forest component:

export default ({ style }) => (
  <View style={style}>
    {trees.map((tree) => {
      const scale = randomScale();
      return (
        <Tree
          key={tree.id}
          style={{
            transform: [
              {scale: [scale, scale, scale]},
              {translate: [tree.x, randomHeight(), tree.y]},
            ]
          }}
        />
      );
    })}
  </View>
);

Right now 100 trees are generated and the user is placed at the center of the forest. Trying it with 1000 trees, led to a laggy experience (MacBook 13", Chrome Canary). ReactVR 0.1.2 shipped with .obj fetch and parse caching. 1000 trees are still a smooth experience 🙌.

What bothered me a bit was that for each Tree a fetch request was fired. I was hoping that ReactVR would cache the geometry and material.

v4 - Animation (coming soon …)

Next up I'm going to write a guide about animations. There is already some code you can check out now:

More Repositories

1

belle

Configurable React Components with great UX
JavaScript
2,511
star
2

awesome-draft-js

Awesome list of Draft.js resources
2,482
star
3

react-hooks

Collection of React Hooks
JavaScript
1,116
star
4

awesome-react-360

Awesome list of React VR resources
515
star
5

CarteJaune

A React Native/Redux (+Saga) app to keep track of your vaccinations.
JavaScript
209
star
6

future-react-ui

A Playground to investigate third-party React UI Lib Architecture
JavaScript
166
star
7

graphiql-spark

Demo a GraphQL schema without a GraphQL endpoint
TypeScript
83
star
8

react-yjs

React hooks for Yjs
TypeScript
60
star
9

react-reduce-stress

The name says it all
TypeScript
56
star
10

graphql-apollo-client-course

JavaScript
54
star
11

2020-05-react-advanced

TypeScript
48
star
12

2020-06-react-advanced

TypeScript
43
star
13

vienna-guide

A simple City Guide for Vienna built with Reason & React
OCaml
28
star
14

automerge-jumpstart

A boilerplate for building real-time collaborative editing applications with Automerge, React, tRPC, and more.
TypeScript
26
star
15

serverless-framework-course

JavaScript
22
star
16

exploring-angular.dart

Exploring Angular.dart while pairing with Edi
19
star
17

2023-react-advanced

TypeScript
18
star
18

webassembly-rust-course

Rust
16
star
19

2019-10-reason-workshop

React Advanced Reason Workshop
JavaScript
13
star
20

2019-react-finland-workshop

JavaScript
12
star
21

react-vr-course

Build Virtual Reality Experiences Using React VR
JavaScript
12
star
22

revery-memory-dojo

OCaml
12
star
23

vimfiles

Vimfiles for mainly Python/Javascript/Ruby Programming
Vim Script
10
star
24

reason-apollo-hooks

OCaml
10
star
25

2022-09-react-advanced

TypeScript
10
star
26

design-graphql-schemas-workshop

JavaScript
8
star
27

ar-app

AR App using React & ViewAR SDK
JavaScript
8
star
28

designing-graphql-schemas-course

JavaScript
8
star
29

reasonconf-workshop

Feedback form: https://docs.google.com/forms/d/e/1FAIpQLSduti27Gold0T3WDtSe04Hi3V-yaBG0ChqAbS-t3-qoe4qsbA/viewform
C++
8
star
30

2020-03-graphql-schema-design

JavaScript
7
star
31

upleveled-lessons

JavaScript
7
star
32

2022-06-react-advanced

TypeScript
6
star
33

gae-path

Small Helper to find your App Engine SDK Path
6
star
34

2020-03-graphql-errors-and-security

JavaScript
5
star
35

redux-universal-app

JavaScript
5
star
36

revery-memory

OCaml
5
star
37

brunch-with-backbone-relational

An example how to use brunch with backbone-relational.js
JavaScript
4
star
38

js-codemod

A collection of codemods
JavaScript
4
star
39

2019-11-graphql-beginner-workshop

JavaScript
4
star
40

reason-react-examples

OCaml
4
star
41

reason-workshop-2

OCaml
4
star
42

workshop

JavaScript
4
star
43

2024-react-workshop

TypeScript
4
star
44

2019-11-react-beginner-workshop

JavaScript
3
star
45

datepicker-polymer-dart-example

Demonstration how to wrap a jQuery UI Widget inside a Polymer.dart component
Dart
3
star
46

2020-01-graphql-workshop

TypeScript
3
star
47

2023-02-react-all-the-things-workshop

TypeScript
2
star
48

plugin-architecture-prototype

JavaScript
2
star
49

workshop-examples

Set of simple examples for my workshops
JavaScript
2
star
50

nesting-components

Example to point our my issue nesting components in packages
Dart
2
star
51

my-first-ai

JavaScript
2
star
52

2019-05-reason-workshop

React Europe Reason Workshop
C++
2
star
53

serenity-macos-test

Objective-C
1
star
54

2019-11-redux-workshop

JavaScript
1
star
55

belle-playground

Playground for Belle
1
star
56

sam-workshop

JavaScript
1
star
57

alarm

A small example app using Dart's polymer package
Dart
1
star
58

String

Exploring how Belt's String implementation could look like
1
star
59

upleveled-exercise

JavaScript
1
star
60

server-experiment

JavaScript
1
star
61

jest-bug-example

JavaScript
1
star
62

js-template-comparison

This project contains different implementations of various JavaScript template engines.
CoffeeScript
1
star
63

router-6

1
star
64

cryptography-benchmark

TypeScript
1
star