├── README.md
└── chapters
├── chapter 1
└── HelloVirtualWorld
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── .watchmanconfig
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ ├── chess-world.jpg
│ └── horseshoe-bend.jpg
│ └── vr
│ ├── client.js
│ └── index.html
├── chapter 2
├── HelloVirtualWorld
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── .watchmanconfig
│ ├── __tests__
│ │ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ │ ├── chess-world.jpg
│ │ └── horseshoe-bend.jpg
│ └── vr
│ │ ├── client.js
│ │ └── index.html
└── PanoramicRoadTrip
│ ├── .babelrc
│ ├── .flowconfig
│ ├── .gitignore
│ ├── .watchmanconfig
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ ├── Arizona.jpg
│ ├── California.jpg
│ ├── Hawaii.jpg
│ ├── New Hampshire.jpg
│ └── Texas.jpg
│ └── vr
│ ├── client.js
│ └── index.html
├── chapter 3
└── OutdoorMovieTheater
│ ├── Components
│ └── Scenes
│ │ ├── Layouts
│ │ ├── Elements
│ │ │ ├── Button.js
│ │ │ ├── Movie.js
│ │ │ └── Title.js
│ │ ├── MainMenuContainer.js
│ │ └── MovieProjector.js
│ │ ├── MainMenu.js
│ │ └── MovieTheater.js
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ └── Readme.txt
│ └── vr
│ ├── client.js
│ └── index.html
├── chapter 4
└── OutdoorMovieTheater
│ ├── Components
│ └── Scenes
│ │ ├── Layouts
│ │ ├── Elements
│ │ │ ├── Button.js
│ │ │ ├── Movie.js
│ │ │ └── Title.js
│ │ ├── MainMenuContainer.js
│ │ ├── MovieProjector.js
│ │ └── SceneSelectMenu.js
│ │ ├── MainMenu.js
│ │ ├── MovieTheater.js
│ │ └── SceneSelect.js
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ └── Readme.txt
│ └── vr
│ ├── client.js
│ └── index.html
├── chapter 5
└── StarWarsModeling
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ └── ReadMe.txt.txt
│ └── vr
│ ├── client.js
│ └── index.html
├── chapter 6
└── VectorGraphicPanoramic
│ ├── __tests__
│ └── client.js
│ ├── index.vr.js
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ ├── ReadMe.txt
│ ├── chess-world.jpg
│ └── koala.PNG
│ ├── vr
│ ├── client.js
│ └── index.html
│ └── yarn.lock
└── chapter 8
├── After Study Break
└── VrVideoApp
│ ├── __tests__
│ └── client.js
│ ├── components
│ └── scenes
│ │ ├── Dashboard.js
│ │ ├── TitleScene.js
│ │ ├── VideoPlayer.js
│ │ └── layouts
│ │ ├── DashboardLayout.js
│ │ ├── TitleLayout.js
│ │ ├── VideoPlayerLayout.js
│ │ └── elements
│ │ ├── Button.js
│ │ ├── MenuButtons.js
│ │ ├── ProgressCircles.js
│ │ ├── TileButtons.js
│ │ ├── Title.js
│ │ └── VideoElement.js
│ ├── index.vr.js
│ ├── package-lock.json
│ ├── package.json
│ ├── rn-cli.config.js
│ ├── static_assets
│ └── ReadMe.text.txt
│ ├── vr
│ ├── client.js
│ └── index.html
│ └── yarn.lock
└── Before Study Break
└── VrVideoApp
├── __tests__
└── client.js
├── components
└── scenes
│ ├── Dashboard.js
│ ├── TitleScene.js
│ └── layouts
│ ├── DashboardLayout.js
│ ├── TitleLayout.js
│ └── elements
│ ├── Button.js
│ ├── MenuButtons.js
│ ├── ProgressCircles.js
│ ├── TileButtons.js
│ └── Title.js
├── index.vr.js
├── package.json
├── rn-cli.config.js
├── static_assets
└── ReadMe.txt
├── vr
├── client.js
└── index.html
└── yarn.lock
/README.md:
--------------------------------------------------------------------------------
1 | # Learn-React-VR
2 | Official code for my ebook Learn React VR
3 |
4 | 
5 |
6 | [Download the ebook.](https://leanpub.com/learnreactvr)
7 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react-native"]
3 | }
4 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/node_modules/.*
3 |
4 | [include]
5 |
6 | [libs]
7 |
8 | [options]
9 | emoji=true
10 | module.system=haste
11 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *~
3 | *.log
4 | *.js.meta
5 | node_modules/
6 | build/
7 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/.watchmanconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 1/HelloVirtualWorld/.watchmanconfig
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | } from 'react-vr';
9 |
10 | export default class HelloVirtualWorld extends React.Component {
11 | render() {
12 | return (
13 |
14 |
15 |
27 | Hello Visual World
28 |
29 |
30 | );
31 | }
32 | };
33 |
34 | AppRegistry.registerComponent('HelloVirtualWorld', () => HelloVirtualWorld);
35 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "HelloVirtualWorld",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "^1.1.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "^1.1.0",
18 | "react-vr-web": "^1.1.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/static_assets/chess-world.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 1/HelloVirtualWorld/static_assets/chess-world.jpg
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/static_assets/horseshoe-bend.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 1/HelloVirtualWorld/static_assets/horseshoe-bend.jpg
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'HelloVirtualWorld', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 1/HelloVirtualWorld/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | HelloVirtualWorld
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react-native"]
3 | }
4 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/node_modules/.*
3 |
4 | [include]
5 |
6 | [libs]
7 |
8 | [options]
9 | emoji=true
10 | module.system=haste
11 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *~
3 | *.log
4 | *.js.meta
5 | node_modules/
6 | build/
7 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/.watchmanconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/HelloVirtualWorld/.watchmanconfig
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | VrButton
9 | } from 'react-vr';
10 |
11 | export default class HelloVirtualWorld extends React.Component {
12 |
13 | render() {
14 | return (
15 |
16 |
17 |
18 |
19 | );
20 | }
21 | };
22 |
23 | class NestedMessage extends React.Component {
24 | constructor() {
25 | super();
26 | this.state = {message: "Hello State Message", showMessage: true};
27 | /* setInterval(() => {
28 | this.setState({ message: "Hello Updated Message" });
29 | }, 5000);
30 | */
31 | }
32 |
33 | componentDidMount () {
34 | this.setState({ showMessage: false });
35 | }
36 |
37 | handleClick () {
38 | this.setState({ message: "Updated Message" });
39 | }
40 |
41 | render() {
42 | const showMessage = this.state.showMessage;
43 |
44 | return (
45 |
46 | {showMessage ? (
47 |
50 |
63 | {this.state.message}
64 |
65 |
66 | ) : (
67 |
68 | )}
69 |
70 | );
71 | }
72 | };
73 |
74 |
75 | AppRegistry.registerComponent('HelloVirtualWorld', () => HelloVirtualWorld);
76 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "HelloVirtualWorld",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "^1.1.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "^1.1.0",
18 | "react-vr-web": "^1.1.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/static_assets/chess-world.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/HelloVirtualWorld/static_assets/chess-world.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/static_assets/horseshoe-bend.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/HelloVirtualWorld/static_assets/horseshoe-bend.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'HelloVirtualWorld', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 2/HelloVirtualWorld/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | HelloVirtualWorld
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react-native"]
3 | }
4 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/node_modules/.*
3 |
4 | [include]
5 |
6 | [libs]
7 |
8 | [options]
9 | emoji=true
10 | module.system=haste
11 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *~
3 | *.log
4 | *.js.meta
5 | node_modules/
6 | build/
7 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/.watchmanconfig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/.watchmanconfig
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | VrButton
9 | } from 'react-vr';
10 |
11 | export default class PanoramicRoadTrip extends React.Component {
12 | constructor() {
13 | super();
14 | this.state = {selectedState: ""};
15 | }
16 |
17 | stateClicked (selection) {
18 | let newState;
19 | switch(selection) {
20 | case 1:
21 | newState = "Arizona";
22 | break;
23 | case 2:
24 | newState = "New Hampshire";
25 | break;
26 | case 3:
27 | newState = "California";
28 | break;
29 | case 4:
30 | newState = "Hawaii";
31 | break;
32 | case 5:
33 | newState = "Texas";
34 | break;
35 | }
36 | console.log(newState);
37 | this.setState({ selectedState: newState});
38 | }
39 |
40 | componentDidMount() {
41 | const random = Math.floor((Math.random() * 5) + 1);
42 | let randState;
43 | switch(random) {
44 | case 1:
45 | randState = "Arizona";
46 | break;
47 | case 2:
48 | randState = "New Hampshire";
49 | break;
50 | case 3:
51 | randState = "California";
52 | break;
53 | case 4:
54 | randState = "Hawaii";
55 | break;
56 | case 5:
57 | randState = "Texas";
58 | break;
59 | }
60 | this.setState({ selectedState: randState});
61 | }
62 |
63 | render() {
64 | const states = {
65 | Arizona: "Arizona",
66 | NewHampshire: "New Hampshire",
67 | California: "California",
68 | Hawaii: "Hawaii",
69 | Texas: "Texas"
70 | }
71 |
72 | return (
73 |
74 |
75 |
85 |
86 |
87 |
88 |
89 | );
90 | }
91 | };
92 |
93 | class TextBoxes extends React.Component {
94 |
95 | render() {
96 | return (
97 |
98 | this.props.stateClicked(1)}>
99 |
100 | {this.props.states.Arizona}
101 |
102 |
103 | this.props.stateClicked(2)}>
104 |
105 | {this.props.states.NewHampshire}
106 |
107 |
108 | this.props.stateClicked(3)}>
109 |
110 | {this.props.states.California}
111 |
112 |
113 | this.props.stateClicked(4)}>
114 |
115 | {this.props.states.Hawaii}
116 |
117 |
118 | this.props.stateClicked(5)}>
119 |
120 | {this.props.states.Texas}
121 |
122 |
123 |
124 | )
125 | }
126 | }
127 |
128 | class Title extends React.Component {
129 | constructor() {
130 | super();
131 | this.state = {title: "Panoramic Road Trip"};
132 | }
133 | render() {
134 | return (
135 |
136 |
137 | {this.state.title}
138 |
139 |
140 | )
141 | }
142 | }
143 |
144 | AppRegistry.registerComponent('PanoramicRoadTrip', () => PanoramicRoadTrip);
145 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "PanoramicRoadTrip",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "^1.1.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "^1.1.0",
18 | "react-vr-web": "^1.1.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/static_assets/Arizona.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/static_assets/Arizona.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/static_assets/California.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/static_assets/California.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/static_assets/Hawaii.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/static_assets/Hawaii.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/static_assets/New Hampshire.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/static_assets/New Hampshire.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/static_assets/Texas.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 2/PanoramicRoadTrip/static_assets/Texas.jpg
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'PanoramicRoadTrip', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 2/PanoramicRoadTrip/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | PanoramicRoadTrip
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Button.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | //Element
9 | class Button extends React.Component {
10 | render() {
11 | return (
12 |
13 |
14 |
15 | Select a Movie
16 |
17 |
18 |
19 | )
20 | }
21 | }
22 |
23 | module.exports = Button;
24 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Movie.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Video,
4 | View,
5 | asset
6 | } from 'react-vr';
7 |
8 | //Element
9 | class Movie extends React.Component {
10 | render() {
11 | return (
12 |
13 |
14 |
15 | )
16 | }
17 | }
18 |
19 | module.exports = Movie;
20 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Title.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | } from 'react-vr';
6 |
7 | //Element
8 | class Title extends React.Component {
9 | render() {
10 | return (
11 |
12 |
19 | Outdoor Movie Theater
20 |
21 |
22 | )
23 | }
24 | }
25 |
26 | module.exports = Title;
27 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/Layouts/MainMenuContainer.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | } from 'react-vr';
6 | import Title from './Elements/Title.js';
7 | import Button from './Elements/Button.js';
8 |
9 | //Layout
10 | class MainMenuContainer extends React.Component {
11 | render() {
12 | return (
13 |
21 |
22 |
23 |
24 | )
25 | }
26 | }
27 |
28 |
29 | module.exports = MainMenuContainer;
30 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/Layouts/MovieProjector.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Video,
4 | View
5 | } from 'react-vr';
6 | import Movie from './Elements/Movie.js';
7 |
8 | //Layout
9 | class MovieProjector extends React.Component {
10 | render() {
11 | return (
12 |
21 |
22 |
23 | )
24 | }
25 | }
26 |
27 |
28 | module.exports = MovieProjector;
29 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/MainMenu.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | } from 'react-vr';
6 | import MainMenuContainer from './Layouts/MainMenuContainer.js';
7 |
8 | //Scene
9 | class MainMenu extends React.Component {
10 | render() {
11 | return (
12 |
13 | )
14 | }
15 | }
16 |
17 | module.exports = MainMenu;
18 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/Components/Scenes/MovieTheater.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Video
5 | } from 'react-vr';
6 | import MovieProjector from './Layouts/MovieProjector.js';
7 |
8 | //Scene
9 | class MovieTheater extends React.Component {
10 | render() {
11 | return (
12 |
13 | )
14 | }
15 | }
16 |
17 | module.exports = MovieTheater;
18 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | Sound,
9 | VideoPano
10 | } from 'react-vr';
11 | import MainMenu from './Components/Scenes/MainMenu.js';
12 | import MovieTheater from './Components/Scenes/MovieTheater.js';
13 |
14 | export default class OutdoorMovieTheater extends React.Component {
15 | render() {
16 | return (
17 |
18 |
19 |
24 |
25 |
26 |
27 | );
28 | }
29 | };
30 |
31 | AppRegistry.registerComponent('OutdoorMovieTheater', () => OutdoorMovieTheater);
32 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "OutdoorMovieTheater",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "^1.1.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "^1.1.0",
18 | "react-vr-web": "^1.1.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/static_assets/Readme.txt:
--------------------------------------------------------------------------------
1 | Check the chapter for all static_asset files
2 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'OutdoorMovieTheater', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 3/OutdoorMovieTheater/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | OutdoorMovieTheater
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Button.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | //Element
9 | class Button extends React.Component {
10 | render() {
11 | const scene = this.props.scene;
12 | return (
13 |
14 |
15 | {scene === 1 ? (
16 | this.props.updateScene(2)}>
17 |
18 | {this.props.buttonText}
19 |
20 |
21 | ) : (
22 | this.props.updateScene(3)}>
23 |
24 | {this.props.buttonText}
25 |
26 |
27 | )}
28 |
29 |
30 | )
31 | }
32 | }
33 |
34 | module.exports = Button;
35 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Movie.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Video,
4 | View,
5 | asset
6 | } from 'react-vr';
7 |
8 | //Element
9 | class Movie extends React.Component {
10 | render() {
11 | return (
12 |
13 |
14 |
15 | )
16 | }
17 | }
18 |
19 | module.exports = Movie;
20 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/Elements/Title.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | Animated
6 | } from 'react-vr';
7 |
8 | import { Easing } from 'react-native';
9 |
10 | //Element
11 | class Title extends React.Component {
12 | constructor() {
13 | super();
14 | this.state = { fade: new Animated.Value(0), slide: new Animated.Value(0) };
15 | }
16 |
17 | componentDidMount() {
18 | this.state.fade.setValue(1);
19 | this.state.slide.setValue(1.5);
20 | Animated.sequence([
21 | //animation 1
22 | Animated.timing(
23 | this.state.fade,
24 | {
25 | toValue: 0,
26 | duration: 2000,
27 | easing: Easing.ease
28 | }
29 | ),
30 | //fire animation 2 and 3 with success delay
31 | Animated.stagger(500, [
32 | //animation 2
33 | Animated.timing(
34 | this.state.fade,
35 | {
36 | toValue: 1,
37 | duration: 2000,
38 | easing: Easing.ease
39 | }
40 | ),
41 | //animation 3
42 | Animated.timing(
43 | this.state.slide,
44 | {
45 | toValue: 0,
46 | duration: 1000,
47 | easing: Easing.ease
48 | }
49 | )
50 | ])
51 | ]).start();
52 | }
53 |
54 | render() {
55 | return (
56 |
57 |
68 | {this.props.text}
69 |
70 |
71 | )
72 | }
73 |
74 | }
75 |
76 | module.exports = Title;
77 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/MainMenuContainer.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | } from 'react-vr';
6 | import Title from './Elements/Title.js';
7 | import Button from './Elements/Button.js';
8 |
9 | //Layout
10 | class MainMenuContainer extends React.Component {
11 | render() {
12 | return (
13 |
21 |
22 |
24 | )
25 | }
26 | }
27 |
28 |
29 | module.exports = MainMenuContainer;
30 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/MovieProjector.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Video,
4 | View
5 | } from 'react-vr';
6 | import Movie from './Elements/Movie.js';
7 |
8 | //Layout
9 | class MovieProjector extends React.Component {
10 | render() {
11 | return (
12 |
21 |
22 |
23 | )
24 | }
25 | }
26 |
27 |
28 | module.exports = MovieProjector;
29 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/Layouts/SceneSelectMenu.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Text,
5 | VrButton
6 | } from 'react-vr';
7 | import Title from './Elements/Title.js';
8 | import Button from './Elements/Button.js';
9 |
10 | //Layout
11 | class SceneSelectMenu extends React.Component {
12 | render() {
13 | return (
14 |
24 |
25 |
27 | )
28 | }
29 | }
30 |
31 | module.exports = SceneSelectMenu;
32 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/MainMenu.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | } from 'react-vr';
6 | import MainMenuContainer from './Layouts/MainMenuContainer.js';
7 |
8 | //Scene
9 | class MainMenu extends React.Component {
10 | render() {
11 | return (
12 |
13 | )
14 | }
15 | }
16 |
17 | module.exports = MainMenu;
18 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/MovieTheater.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Video
5 | } from 'react-vr';
6 | import MovieProjector from './Layouts/MovieProjector.js';
7 |
8 | //Scene
9 | class MovieTheater extends React.Component {
10 | render() {
11 | return (
12 |
13 | )
14 | }
15 | }
16 |
17 | module.exports = MovieTheater;
18 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/Components/Scenes/SceneSelect.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Text,
5 | VrButton
6 | } from 'react-vr';
7 | import SceneSelectMenu from './Layouts/SceneSelectMenu.js';
8 |
9 | //Scene
10 | class SceneSelect extends React.Component {
11 | render() {
12 | return (
13 |
14 | )
15 | }
16 | }
17 |
18 | module.exports = SceneSelect;
19 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | Sound,
9 | VideoPano
10 | } from 'react-vr';
11 | import MainMenu from './Components/Scenes/MainMenu.js';
12 | import MovieTheater from './Components/Scenes/MovieTheater.js';
13 | import SceneSelect from './Components/Scenes/SceneSelect.js';
14 |
15 | export default class OutdoorMovieTheater extends React.Component {
16 | constructor(){
17 | super();
18 | this.state={mainMenu: true, sceneSelect: false};
19 | }
20 |
21 | updateScene(scene) {
22 | switch(scene) {
23 | case 2:
24 | this.setState({ mainMenu: false, sceneSelect: true});
25 | break;
26 | case 3:
27 | this.setState({ mainMenu: false, sceneSelect: false});
28 | break;
29 | }
30 | }
31 |
32 | render() {
33 | const mainMenu = this.state.mainMenu;
34 | const sceneSelect = this.state.sceneSelect;
35 | return (
36 |
37 |
38 |
43 |
44 | {
45 | mainMenu ? (
46 |
47 | ) : (
48 | sceneSelect ? (
49 |
50 | ) : (
51 |
52 | )
53 |
54 | )
55 | }
56 |
57 | );
58 | }
59 | };
60 |
61 | AppRegistry.registerComponent('OutdoorMovieTheater', () => OutdoorMovieTheater);
62 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "OutdoorMovieTheater",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "^1.1.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "^1.1.0",
18 | "react-vr-web": "^1.1.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/static_assets/Readme.txt:
--------------------------------------------------------------------------------
1 | Check the chapter 3 for all static_asset files
2 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'OutdoorMovieTheater', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 4/OutdoorMovieTheater/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | OutdoorMovieTheater
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | Model,
9 | Animated
10 | } from 'react-vr';
11 |
12 | import { Easing } from 'react-native';
13 |
14 | export default class StarWarsModeling extends React.Component {
15 | constructor() {
16 | super();
17 | this.state = { spin: new Animated.Value(0) };
18 | }
19 |
20 | componentDidMount() {
21 | this.spinAnimation();
22 | }
23 |
24 | spinAnimation() {
25 | this.state.spin.setValue(0);
26 | Animated.timing(
27 | this.state.spin,
28 | {
29 | toValue: 1,
30 | duration: 3000,
31 | easing: Easing.linear
32 | }
33 | ).start( () => this.spinAnimation() );
34 | }
35 |
36 | render() {
37 | const spin = this.state.spin.interpolate({
38 | inputRange: [0, 1],
39 | outputRange: ['0deg', '360deg']
40 | });
41 |
42 | var AnimatedModel = Animated.createAnimatedComponent(Model);
43 |
44 | return (
45 |
46 |
47 |
61 |
62 | );
63 | }
64 | };
65 |
66 | AppRegistry.registerComponent('StarWarsModeling', () => StarWarsModeling);
67 |
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "StarWarsModeling",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "~1.2.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "~1.2.0",
18 | "react-vr-web": "~1.2.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/static_assets/ReadMe.txt.txt:
--------------------------------------------------------------------------------
1 | See the chapter for assets
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'StarWarsModeling', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 5/StarWarsModeling/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | StarWarsModeling
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | Image
9 | } from 'react-vr';
10 |
11 | export default class VectorGraphicPanoramic extends React.Component {
12 | render() {
13 | return (
14 |
15 |
16 |
25 |
26 | );
27 | }
28 | };
29 |
30 | AppRegistry.registerComponent('VectorGraphicPanoramic', () => VectorGraphicPanoramic);
31 |
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VectorGraphicPanoramic",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "~1.2.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "~1.2.0",
18 | "react-vr-web": "~1.2.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/static_assets/ReadMe.txt:
--------------------------------------------------------------------------------
1 | My panoramic background photo was too large to upload. See chapter.
2 |
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/static_assets/chess-world.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 6/VectorGraphicPanoramic/static_assets/chess-world.jpg
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/static_assets/koala.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelmang/Learn-React-VR/544f5dec5a8ddbb2fe6100e6dd80a47a6a953dba/chapters/chapter 6/VectorGraphicPanoramic/static_assets/koala.PNG
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'VectorGraphicPanoramic', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 6/VectorGraphicPanoramic/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | VectorGraphicPanoramic
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/Dashboard.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | asset,
6 | Pano
7 | } from 'react-vr';
8 |
9 | import DashboardLayout from './layouts/DashboardLayout.js';
10 |
11 | //Scene
12 | class Dashboard extends React.Component {
13 | render() {
14 | return (
15 |
16 |
17 |
25 |
26 | )
27 | }
28 | }
29 |
30 | module.exports = Dashboard;
31 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/TitleScene.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton,
6 | asset,
7 | Pano
8 | } from 'react-vr';
9 |
10 | import TitleLayout from './layouts/TitleLayout.js';
11 |
12 | //Scene
13 | class TitleScene extends React.Component {
14 | render() {
15 | return (
16 |
17 |
18 |
24 |
25 | )
26 | }
27 | }
28 |
29 | module.exports = TitleScene;
30 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/VideoPlayer.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | asset,
6 | Pano
7 | } from 'react-vr';
8 |
9 | import VideoPlayerLayout from './layouts/VideoPlayerLayout.js';
10 |
11 | //Scene
12 | class VideoPlayer extends React.Component {
13 | constructor() {
14 | super();
15 | this.state = { streamURL: "" }
16 | }
17 |
18 | componentWillMount() {
19 | this.setState({ streamURL: 'http://playertwitch.tv/?channel=' + this.props.streamID })
20 | //example: http://player.twitch.tv/?channel=beyondthesummit
21 | }
22 |
23 | render() {
24 | return (
25 |
26 |
27 |
34 |
35 | )
36 | }
37 | }
38 |
39 | module.exports = VideoPlayer;
40 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/DashboardLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Animated
5 | } from 'react-vr';
6 |
7 | import { Easing } from 'react-native';
8 |
9 | import MenuButtons from './elements/MenuButtons.js';
10 | import TileButtons from './elements/TileButtons.js';
11 | import ProgressCircles from './elements/ProgressCircles.js';
12 |
13 | import Button from './elements/Button.js';
14 |
15 | //Layout
16 | class DashboardLayout extends React.Component {
17 |
18 | constructor(props) {
19 | super(props);
20 | this.state = {
21 | slideLeft: new Animated.Value(-1),
22 | fadeIn: new Animated.Value(0),
23 | showButton: false,
24 | color1: "#A482DF",
25 | color2: "#DBDAF1",
26 | text: this.props.text,
27 | borderWidths: [0, 0, 0, 0, 0, 0],
28 | selectionIndex: "",
29 | stage: 1
30 | };
31 | }
32 |
33 | componentDidMount() {
34 | Animated.sequence([
35 | Animated.parallel([
36 | Animated.timing(
37 | this.state.slideLeft,
38 | {
39 | toValue: 0,
40 | duration: 2000,
41 | easing: Easing.ease
42 | }
43 | ),
44 | Animated.timing(
45 | this.state.fadeIn,
46 | {
47 | toValue: 1,
48 | duration: 2000,
49 | easing: Easing.ease
50 | }
51 | )
52 | ])
53 | ]).start();
54 | }
55 |
56 | updateStage(input) {
57 | if(this.state.showButton === false) {
58 | this.setState({showButton: true});
59 | }
60 |
61 | switch (input) {
62 | case 1:
63 | this.setState({borderWidths: [0.05, 0, 0, 0, 0, 0], selectionIndex: 1});
64 | break;
65 | case 2:
66 | this.setState({borderWidths: [0, 0.05, 0, 0, 0, 0], selectionIndex: 2});
67 | break;
68 | case 3:
69 | this.setState({borderWidths: [0, 0, 0.05, 0, 0, 0], selectionIndex: 3});
70 | break;
71 | case 4:
72 | this.setState({borderWidths: [0, 0, 0, 0.05, 0, 0], selectionIndex: 4});
73 | break;
74 | case 5:
75 | this.setState({borderWidths: [0, 0, 0, 0, 0.05, 0], selectionIndex: 5});
76 | break;
77 | case 6:
78 | this.setState({borderWidths: [0, 0, 0, 0, 0, 0.05], selectionIndex: 6});
79 | break;
80 | }
81 | }
82 |
83 | updateScene() {
84 | this.props.captureSelection(this.state.stage, this.state.selectionIndex);
85 | this.setState({color1: "#DBDAF1", color2: "#A482DF", text: "Watch Video", stage: 2});
86 | }
87 |
88 | render() {
89 | return (
90 |
91 |
106 |
107 |
114 |
115 |
116 |
117 |
127 |
136 |
137 |
138 | )
139 | }
140 | }
141 |
142 | module.exports = DashboardLayout;
143 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/TitleLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | import Title from './elements/Title.js';
9 | import Button from './elements/Button.js';
10 |
11 |
12 | //Layout
13 | class TitleLayout extends React.Component {
14 | render() {
15 | return (
16 |
24 |
25 |
31 |
32 | )
33 | }
34 | }
35 |
36 | module.exports = TitleLayout;
37 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/VideoPlayerLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View
4 | } from 'react-vr';
5 |
6 | import VideoElement from './elements/VideoElement.js';
7 | import Button from './elements/Button.js';
8 |
9 | //Layout
10 | class VideoPlayerLayout extends React.Component {
11 |
12 | render() {
13 | return (
14 |
15 |
24 |
25 |
26 |
27 |
35 |
41 |
42 |
43 | )
44 | }
45 | }
46 |
47 | module.exports = VideoPlayerLayout;
48 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/Button.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton,
6 | Animated
7 | } from 'react-vr';
8 |
9 | import { Easing } from 'react-native';
10 |
11 | //Element
12 | class Button extends React.Component {
13 | constructor() {
14 | super();
15 | this.state = { slideRight: new Animated.Value(1), fadeIn: new Animated.Value(0)};
16 | }
17 |
18 | componentDidMount() {
19 | Animated.sequence([
20 | Animated.parallel([
21 | Animated.timing(
22 | this.state.slideRight,
23 | {
24 | toValue: 0,
25 | duration: 2000,
26 | easing: Easing.ease
27 | }
28 | ),
29 | Animated.timing(
30 | this.state.fadeIn,
31 | {
32 | toValue: 1,
33 | duration: 2000,
34 | easing: Easing.ease
35 | }
36 | )
37 | ])
38 | ]).start();
39 | }
40 |
41 | render() {
42 | const showButton = this.props.showButton;
43 | const currentScene = this.props.scene;
44 | let nextScene;
45 | switch (currentScene) {
46 | case 1:
47 | nextScene = 2;
48 | break;
49 | case 2:
50 | nextScene = 3;
51 | break;
52 | case 3:
53 | nextScene = 1;
54 | break;
55 | }
56 | const stage = this.props.stage;
57 | const selectionIndex = this.props.selectionIndex;
58 | return (
59 |
60 | {showButton ? (
61 |
75 | {currentScene === 2 ? (
76 | {
79 | switch (stage) {
80 | case 1:
81 | this.props.updateScene();
82 | break;
83 | case 2:
84 | this.props.changeScenes(nextScene, selectionIndex);
85 | }
86 | }
87 | }
88 | >
89 |
95 | {this.props.text}
96 |
97 |
98 | ) : (
99 | this.props.changeScenes(nextScene)}>
100 |
106 | {this.props.text}
107 |
108 |
109 | )}
110 |
111 | ) :(
112 |
113 | )}
114 |
115 | )
116 | }
117 | }
118 |
119 | module.exports = Button;
120 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/MenuButtons.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | //Element
9 | class MenuButtons extends React.Component {
10 |
11 | render() {
12 | return (
13 |
22 |
29 |
30 |
36 | Twitch
37 |
38 |
39 |
40 |
41 |
48 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
67 |
68 |
74 |
75 |
76 |
77 |
78 |
79 |
86 |
87 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | )
100 | }
101 | }
102 |
103 | module.exports = MenuButtons;
104 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/ProgressCircles.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View
4 | } from 'react-vr';
5 |
6 | //Element
7 | class ProgressCircles extends React.Component {
8 |
9 | render() {
10 | return (
11 |
12 |
21 |
30 |
31 |
40 |
41 |
42 |
43 | )
44 | }
45 | }
46 |
47 | module.exports = ProgressCircles;
48 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/TileButtons.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton,
6 | Image,
7 | asset
8 | } from 'react-vr';
9 |
10 | //Element
11 | class TileButtons extends React.Component {
12 |
13 | render() {
14 | const stage = this.props.stage;
15 | return (
16 |
17 |
18 |
26 | this.props.updateStage(1) }>
27 | {stage === 1 ? (
28 |
38 | ): (
39 |
49 | )}
50 |
51 |
52 |
60 | this.props.updateStage(2) }>
61 | {stage === 1 ? (
62 |
72 | ): (
73 |
83 | )}
84 |
85 |
86 |
87 |
88 |
89 |
97 | this.props.updateStage(3) }>
98 | {stage === 1 ? (
99 |
109 | ): (
110 |
120 | )}
121 |
122 |
123 |
131 | this.props.updateStage(4) }>
132 | {stage === 1 ? (
133 |
143 | ): (
144 |
154 | )}
155 |
156 |
157 |
158 |
159 |
160 |
168 | this.props.updateStage(5) }>
169 | {stage === 1 ? (
170 |
180 | ): (
181 |
191 | )}
192 |
193 |
194 |
202 | this.props.updateStage(6) }>
203 | {stage === 1 ? (
204 |
214 | ): (
215 |
225 | )}
226 |
227 |
228 |
229 |
230 |
231 | )
232 | }
233 | }
234 |
235 | module.exports = TileButtons;
236 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/Title.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | Animated
6 | } from 'react-vr';
7 |
8 | import { Easing } from 'react-native';
9 |
10 | //Element
11 | class Title extends React.Component {
12 | constructor() {
13 | super();
14 | this.state = { slideLeft: new Animated.Value(-1), fadeIn: new Animated.Value(0)};
15 | }
16 |
17 | componentDidMount() {
18 | Animated.sequence([
19 | Animated.parallel([
20 | Animated.timing(
21 | this.state.slideLeft,
22 | {
23 | toValue: 0,
24 | duration: 2000,
25 | easing: Easing.ease
26 | }
27 | ),
28 | Animated.timing(
29 | this.state.fadeIn,
30 | {
31 | toValue: 1,
32 | duration: 2000,
33 | easing: Easing.ease
34 | }
35 | )
36 | ])
37 | ]).start();
38 | }
39 |
40 | render() {
41 | return (
42 |
43 |
53 | VR VIDEO APP
54 |
55 |
56 | )
57 | }
58 | }
59 |
60 | module.exports = Title;
61 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/components/scenes/layouts/elements/VideoElement.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Video,
4 | View,
5 | asset,
6 | Animated
7 | } from 'react-vr';
8 |
9 | import { Easing } from 'react-native';
10 |
11 | //Element
12 | class VideoElement extends React.Component {
13 | constructor() {
14 | super();
15 | this.state = { fadeIn: new Animated.Value(0) };
16 | }
17 |
18 | componentDidMount() {
19 | Animated.sequence([
20 | Animated.timing(
21 | this.state.fadeIn,
22 | {
23 | toValue: 1,
24 | duration: 2000,
25 | easing: Easing.ease
26 | }
27 | )
28 | ]).start();
29 | }
30 |
31 | render() {
32 | return (
33 |
34 |
35 |
36 | )
37 | }
38 | }
39 |
40 | module.exports = VideoElement;
41 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | } from 'react-vr';
9 |
10 | import TitleScene from './components/scenes/TitleScene.js';
11 | import Dashboard from './components/scenes/Dashboard.js';
12 | import VideoPlayer from './components/scenes/VideoPlayer.js';
13 |
14 | import axios from 'react-native-axios';
15 |
16 | export default class VrVideoApp extends React.Component {
17 | constructor() {
18 | super();
19 | this.state = {
20 | scene: 1,
21 | previews: "",
22 | IDs: "",
23 | selectedStreamID: "",
24 | selectedEnv: "",
25 | environments: [
26 | "title-background.jpg",
27 | "dashboard-background.jpg",
28 | "Arizona.jpg",
29 | "Hawaii.jpg",
30 | "New Hampshire.jpg",
31 | "Texas.jpg"
32 | ]
33 | };
34 | }
35 |
36 | componentWillMount() {
37 | axios.get('https://api.twitch.tv/kraken/streams/featured?limit=6&client_id=skawlpb80ixx8e9cxafxepbn66xhe1')
38 | .then(response => {
39 | this.gatherPreviews(response);
40 | this.gatherStreamIDs(response);
41 | })
42 | .catch(e => {
43 | console.log(error);
44 | });
45 | }
46 |
47 | gatherPreviews(response) {
48 | const previews = response.data.featured.map(function(feat) {
49 | return feat.stream.preview.large;
50 | });
51 |
52 | this.setState({previews: previews});
53 | }
54 |
55 | gatherStreamIDs(response) {
56 | const IDs = response.data.featured.map(function(feat) {
57 | return feat.stream.channel.name;
58 | });
59 |
60 | this.setState({IDs: IDs});
61 | }
62 |
63 | captureSelection(stage, value) {
64 | switch (stage) {
65 | case 1:
66 | this.setState({selectedStreamID: this.state.IDs[value-1]});
67 | break;
68 | case 2:
69 | this.setState({selectedEnv: this.state.environments[value-1]});
70 | break;
71 | }
72 | }
73 |
74 | changeScenes(nextScene, selectionIndex) {
75 | switch (nextScene) {
76 | case 1:
77 | this.setState({scene: 1});
78 | break;
79 | case 2:
80 | this.setState({scene: 2});
81 | break;
82 | case 3:
83 | this.captureSelection(2, selectionIndex);
84 | this.setState({scene: 3});
85 | break;
86 | }
87 | }
88 |
89 | render() {
90 | const scene = this.state.scene;
91 | return (
92 |
93 | {scene === 1 ? (
94 |
100 | ) : (
101 | scene === 2 ? (
102 |
111 | ) : (
112 |
120 | )
121 | )}
122 |
123 | );
124 | }
125 | };
126 |
127 | AppRegistry.registerComponent('VrVideoApp', () => VrVideoApp);
128 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VrVideoApp",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "~1.2.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "react-native-axios": "^0.17.1",
17 | "react-vr": "~1.2.0",
18 | "react-vr-web": "~1.2.0",
19 | "three": "^0.80.1"
20 | },
21 | "devDependencies": {
22 | "babel-jest": "^19.0.0",
23 | "babel-preset-react-native": "^1.9.1",
24 | "jest": "^19.0.2",
25 | "react-devtools": "^2.1.3",
26 | "react-test-renderer": "~15.4.1",
27 | "xopen": "1.0.0"
28 | },
29 | "jest": {
30 | "preset": "react-vr"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/static_assets/ReadMe.text.txt:
--------------------------------------------------------------------------------
1 | See the chapter for asset links.
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'VrVideoApp', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 8/After Study Break/VrVideoApp/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | VrVideoApp
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/__tests__/client.js:
--------------------------------------------------------------------------------
1 | import 'react-native';
2 | import 'react-vr';
3 | import React from 'react';
4 | import Index from '../index.vr.js';
5 |
6 | // Note: test renderer must be required after react-native.
7 | import renderer from 'react-test-renderer';
8 |
9 | it('renders correctly', () => {
10 | const tree = renderer.create(
11 |
12 | );
13 | });
14 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/Dashboard.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | asset,
6 | Pano
7 | } from 'react-vr';
8 |
9 | import DashboardLayout from './layouts/DashboardLayout.js';
10 |
11 | //Scene
12 | class Dashboard extends React.Component {
13 | render() {
14 | return (
15 |
16 |
17 |
18 |
19 | )
20 | }
21 | }
22 |
23 | module.exports = Dashboard;
24 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/TitleScene.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton,
6 | asset,
7 | Pano
8 | } from 'react-vr';
9 |
10 | import TitleLayout from './layouts/TitleLayout.js';
11 |
12 | //Scene
13 | class TitleScene extends React.Component {
14 | render() {
15 | return (
16 |
17 |
18 |
19 |
20 | )
21 | }
22 | }
23 |
24 | module.exports = TitleScene;
25 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/DashboardLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View,
4 | Animated
5 | } from 'react-vr';
6 |
7 | import { Easing } from 'react-native';
8 |
9 | import MenuButtons from './elements/MenuButtons.js';
10 | import TileButtons from './elements/TileButtons.js';
11 | import ProgressCircles from './elements/ProgressCircles.js';
12 |
13 | import Button from './elements/Button.js';
14 |
15 | //Layout
16 | class DashboardLayout extends React.Component {
17 |
18 | constructor(props) {
19 | super(props);
20 | this.state = {
21 | slideLeft: new Animated.Value(-1),
22 | fadeIn: new Animated.Value(0),
23 | showButton: false,
24 | color1: "#A482DF",
25 | color2: "#DBDAF1",
26 | text: this.props.text,
27 | borderWidths: [0, 0, 0, 0, 0, 0]
28 | };
29 | }
30 |
31 | componentDidMount() {
32 | Animated.sequence([
33 | Animated.parallel([
34 | Animated.timing(
35 | this.state.slideLeft,
36 | {
37 | toValue: 0,
38 | duration: 2000,
39 | easing: Easing.ease
40 | }
41 | ),
42 | Animated.timing(
43 | this.state.fadeIn,
44 | {
45 | toValue: 1,
46 | duration: 2000,
47 | easing: Easing.ease
48 | }
49 | )
50 | ])
51 | ]).start();
52 | }
53 |
54 | //previously updateShowButton
55 | updateStage(input) {
56 | if(this.state.showButton === false) {
57 | this.setState({showButton: true});
58 | }
59 |
60 | switch (input) {
61 | case 1:
62 | this.setState({borderWidths: [0.05, 0, 0, 0, 0, 0]});
63 | break;
64 | case 2:
65 | this.setState({borderWidths: [0, 0.05, 0, 0, 0, 0]});
66 | break;
67 | case 3:
68 | this.setState({borderWidths: [0, 0, 0.05, 0, 0, 0]});
69 | break;
70 | case 4:
71 | this.setState({borderWidths: [0, 0, 0, 0.05, 0, 0]});
72 | break;
73 | case 5:
74 | this.setState({borderWidths: [0, 0, 0, 0, 0.05, 0]});
75 | break;
76 | case 6:
77 | this.setState({borderWidths: [0, 0, 0, 0, 0, 0.05]});
78 | break;
79 | }
80 | }
81 |
82 | updateScene() {
83 | this.setState({color1: "#DBDAF1", color2: "#A482DF", text: "Watch Video"});
84 | }
85 |
86 | render() {
87 | return (
88 |
89 |
104 |
105 |
106 |
107 |
108 |
109 |
119 |
121 |
122 | )
123 | }
124 | }
125 |
126 | module.exports = DashboardLayout;
127 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/TitleLayout.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | import Title from './elements/Title.js';
9 | import Button from './elements/Button.js';
10 |
11 |
12 | //Layout
13 | class TitleLayout extends React.Component {
14 | render() {
15 | return (
16 |
24 |
25 |
27 | )
28 | }
29 | }
30 |
31 | module.exports = TitleLayout;
32 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/elements/Button.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton,
6 | Animated
7 | } from 'react-vr';
8 |
9 | import { Easing } from 'react-native';
10 |
11 | //Element
12 | class Button extends React.Component {
13 | constructor() {
14 | super();
15 | this.state = { slideRight: new Animated.Value(1), fadeIn: new Animated.Value(0)};
16 | }
17 |
18 | componentDidMount() {
19 | Animated.sequence([
20 | Animated.parallel([
21 | Animated.timing(
22 | this.state.slideRight,
23 | {
24 | toValue: 0,
25 | duration: 2000,
26 | easing: Easing.ease
27 | }
28 | ),
29 | Animated.timing(
30 | this.state.fadeIn,
31 | {
32 | toValue: 1,
33 | duration: 2000,
34 | easing: Easing.ease
35 | }
36 | )
37 | ])
38 | ]).start();
39 | }
40 |
41 | render() {
42 | const showButton = this.props.showButton;
43 | return (
44 |
45 | {showButton ? (
46 |
60 |
61 |
67 | {this.props.text}
68 |
69 |
70 |
71 | ) :(
72 |
73 | )}
74 |
75 | )
76 | }
77 | }
78 |
79 | module.exports = Button;
80 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/elements/MenuButtons.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | //Element
9 | class MenuButtons extends React.Component {
10 |
11 | render() {
12 | return (
13 |
22 |
29 |
30 |
36 | Twitch
37 |
38 |
39 |
40 |
41 |
48 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
67 |
68 |
74 |
75 |
76 |
77 |
78 |
79 |
86 |
87 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | )
100 | }
101 | }
102 |
103 | module.exports = MenuButtons;
104 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/elements/ProgressCircles.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | View
4 | } from 'react-vr';
5 |
6 | //Element
7 | class ProgressCircles extends React.Component {
8 |
9 | render() {
10 | return (
11 |
12 |
21 |
30 |
31 |
40 |
41 |
42 |
43 | )
44 | }
45 | }
46 |
47 | module.exports = ProgressCircles;
48 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/elements/TileButtons.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | VrButton
6 | } from 'react-vr';
7 |
8 | //Element
9 | class TileButtons extends React.Component {
10 |
11 | render() {
12 | return (
13 |
14 |
15 |
25 | this.props.updateStage(1) }>
26 |
32 |
33 |
34 |
35 |
36 |
46 | this.props.updateStage(2) }>
47 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
70 | this.props.updateStage(3) }>
71 |
77 |
78 |
79 |
80 |
81 |
91 | this.props.updateStage(4) }>
92 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
115 | this.props.updateStage(5) }>
116 |
122 |
123 |
124 |
125 |
126 |
136 | this.props.updateStage(6) }>
137 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 | )
151 | }
152 | }
153 |
154 | module.exports = TileButtons;
155 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/components/scenes/layouts/elements/Title.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | Text,
4 | View,
5 | Animated
6 | } from 'react-vr';
7 |
8 | import { Easing } from 'react-native';
9 |
10 | //Element
11 | class Title extends React.Component {
12 | constructor() {
13 | super();
14 | this.state = { slideLeft: new Animated.Value(-1), fadeIn: new Animated.Value(0)};
15 | }
16 |
17 | componentDidMount() {
18 | Animated.sequence([
19 | Animated.parallel([
20 | Animated.timing(
21 | this.state.slideLeft,
22 | {
23 | toValue: 0,
24 | duration: 2000,
25 | easing: Easing.ease
26 | }
27 | ),
28 | Animated.timing(
29 | this.state.fadeIn,
30 | {
31 | toValue: 1,
32 | duration: 2000,
33 | easing: Easing.ease
34 | }
35 | )
36 | ])
37 | ]).start();
38 | }
39 |
40 | render() {
41 | return (
42 |
43 |
53 | VR VIDEO APP
54 |
55 |
56 | )
57 | }
58 | }
59 |
60 | module.exports = Title;
61 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/index.vr.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {
3 | AppRegistry,
4 | asset,
5 | Pano,
6 | Text,
7 | View,
8 | } from 'react-vr';
9 |
10 | import TitleScene from './components/scenes/TitleScene.js';
11 | import Dashboard from './components/scenes/Dashboard.js';
12 |
13 | export default class VrVideoApp extends React.Component {
14 | render() {
15 | //
16 | return (
17 |
18 |
19 |
20 | );
21 | }
22 | };
23 |
24 | AppRegistry.registerComponent('VrVideoApp', () => VrVideoApp);
25 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VrVideoApp",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node -e \"console.log('open browser at http://localhost:8081/vr/\\n\\n');\" && node node_modules/react-native/local-cli/cli.js start",
7 | "bundle": "node node_modules/react-vr/scripts/bundle.js",
8 | "open": "node -e \"require('xopen')('http://localhost:8081/vr/')\"",
9 | "devtools": "react-devtools",
10 | "test": "jest"
11 | },
12 | "dependencies": {
13 | "ovrui": "~1.2.0",
14 | "react": "~15.4.1",
15 | "react-native": "~0.42.0",
16 | "three": "^0.80.1",
17 | "react-vr": "~1.2.0",
18 | "react-vr-web": "~1.2.0"
19 | },
20 | "devDependencies": {
21 | "babel-jest": "^19.0.0",
22 | "babel-preset-react-native": "^1.9.1",
23 | "jest": "^19.0.2",
24 | "react-devtools": "^2.1.3",
25 | "react-test-renderer": "~15.4.1",
26 | "xopen": "1.0.0"
27 | },
28 | "jest": {
29 | "preset": "react-vr"
30 | }
31 | }
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/rn-cli.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var blacklist = require('./node_modules/react-native/packager/blacklist');
5 |
6 | var config = {
7 | getProjectRoots() {
8 | return getRoots();
9 | },
10 |
11 | getBlacklistRE() {
12 | return blacklist([
13 | ]);
14 | },
15 |
16 | getAssetExts() {
17 | return ['obj', 'mtl'];
18 | },
19 |
20 | getPlatforms() {
21 | return ['vr'];
22 | },
23 |
24 | getProvidesModuleNodeModules() {
25 | return ['react-native', 'react-vr'];
26 | },
27 | };
28 |
29 | function getRoots() {
30 | var root = process.env.REACT_NATIVE_APP_ROOT;
31 | if (root) {
32 | return [path.resolve(root)];
33 | }
34 | return [path.resolve(__dirname)];
35 | }
36 |
37 | module.exports = config;
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/static_assets/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Get the assets from the chapter.
2 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/vr/client.js:
--------------------------------------------------------------------------------
1 | // Auto-generated content.
2 | // This file contains the boilerplate to set up your React app.
3 | // If you want to modify your application, start in "index.vr.js"
4 |
5 | // Auto-generated content.
6 | import {VRInstance} from 'react-vr-web';
7 |
8 | function init(bundle, parent, options) {
9 | const vr = new VRInstance(bundle, 'VrVideoApp', parent, {
10 | // Add custom options here
11 | ...options,
12 | });
13 | vr.render = function() {
14 | // Any custom behavior you want to perform on each frame goes here
15 | };
16 | // Begin the animation loop
17 | vr.start();
18 | return vr;
19 | }
20 |
21 | window.ReactVR = {init};
22 |
--------------------------------------------------------------------------------
/chapters/chapter 8/Before Study Break/VrVideoApp/vr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | VrVideoApp
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------