-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.vr.js
60 lines (46 loc) · 1.76 KB
/
index.vr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from "react";
import axios from "react-native-axios";
import {
AppRegistry,
} from "react-vr";
import PanoScene from "./scenes/PanoScene";
import DefaultScene from "./scenes/DefaultScene";
import CustomModelScene from "./scenes/CustomModelScene";
import AnimationScene from "./scenes/AnimationScene";
import PanoVideoScene from "./scenes/PanoVideoScene";
import MovieScene from "./scenes/MovieScene";
export default class ReactVR extends React.Component {
constructor(props) {
super(props);
this.state = {
scene: "default",
movieData: null
};
}
componentDidMount() {
axios.get("https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=10®ionCode=IN&key=AIzaSyAK5HZ_j5WS1M2brpgrsGj6EDeEwTwHHEc").then((resp) => {
console.log(resp);
}).catch((err) => {
console.log(err);
});
}
_onViewChange(value) {
this.setState({scene: value});
}
render() {
let scene = <DefaultScene onViewChange={(value) => this._onViewChange(value)}/>;
if (this.state.scene === "pano") {
scene = <PanoScene onViewChange={(value) => this._onViewChange(value)}/>;
} else if (this.state.scene === "custom") {
scene = <CustomModelScene onViewChange={(value) => this._onViewChange(value)}/>;
} else if (this.state.scene === "anim") {
scene = <AnimationScene/>;
} else if (this.state.scene === "movie") {
scene = <MovieScene movieData={this.state.movieData}/>;
} else if (this.state.scene === "panomovie") {
scene = <PanoVideoScene/>;
}
return scene;
}
}
AppRegistry.registerComponent("ReactVR", () => ReactVR);