Last active
August 23, 2021 15:26
-
-
Save adamTrz/141bcead282ff53c5cffd6d2d4cad016 to your computer and use it in GitHub Desktop.
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 AnimatedMath from 'react-native-animated-math' | |
| /*...*/ | |
| export default class Globe extends React.Component { | |
| /*...*/ | |
| rotation = new Animated.Value(0) | |
| componentDidMount() { | |
| this.spinAround() | |
| this.rotate() | |
| } | |
| /* ...*/ | |
| this.rotate = () => { | |
| Animated.loop( | |
| Animated.timing(this.rotation, { | |
| toValue: 2 * Math.PI, | |
| easing: Easing.linear, | |
| duration: this.props.yearDuration, | |
| }) | |
| ).start() | |
| } | |
| render() { | |
| return( | |
| <View> | |
| <Planet | |
| style={{ | |
| transform: [ | |
| { | |
| translateX: Animated.multiply( | |
| AnimatedMath.sinus(this.rotation), | |
| -elipsisRadius | |
| ), | |
| }, | |
| { | |
| translateZ: Animated.multiply( | |
| AnimatedMath.cosinus(this.rotation), | |
| elipsisRadius | |
| ), | |
| }, | |
| {rotateY: this.spin} | |
| ]}} /> | |
| <PointLight intensuty={2} /> | |
| </View> | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment