Last active
February 28, 2018 14:32
-
-
Save adamTrz/c02b4ba7437e17a2fa0da118faec7485 to your computer and use it in GitHub Desktop.
VR Earth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { | |
| AppRegistry, | |
| Sphere, | |
| asset, | |
| View, | |
| PointLight, | |
| Animated, | |
| } from 'react-vr'; | |
| import { Easing } from 'react-native'; | |
| const Planet = Animated.createAnimatedComponent(Sphere); | |
| export default class Globe extends React.Component { | |
| spin = new Animated.Value(0); | |
| componentDidMount() { | |
| this.spinAround(); | |
| } | |
| spinAround = () => { | |
| Animated.loop( | |
| Animated.timing(this.spin, { | |
| toValue: 360, | |
| easing: Easing.linear, | |
| duration: 2000, | |
| }) | |
| ).start() | |
| }; | |
| render() { | |
| return ( | |
| <View> | |
| <Planet | |
| heightSegments={20} | |
| widthSegments={20} | |
| radius={0.3} | |
| lit | |
| style={{ | |
| transform: [{ translateZ: -3 }, { rotateY: this.spin }], | |
| }} | |
| texture={asset('earth.jpg')} | |
| /> | |
| <PointLight | |
| intensity={2} | |
| style={{ transform: [{ translate: [0, 700, 700] }] }} | |
| /> | |
| </View> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment