Skip to content

Instantly share code, notes, and snippets.

@adamTrz
Last active August 23, 2021 15:26
Show Gist options
  • Select an option

  • Save adamTrz/141bcead282ff53c5cffd6d2d4cad016 to your computer and use it in GitHub Desktop.

Select an option

Save adamTrz/141bcead282ff53c5cffd6d2d4cad016 to your computer and use it in GitHub Desktop.
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