Motion is an important aspect of a complete immersive experience, therefor we are going to look into the animation API Animated.

Animated allows us to express a wide variety of animation patterns to animate text, images, and views.

In addition we'll leverage the higher order component, <CreateAnimatedComponent/>, to create a rotating box!

import React from 'react';
import {
AppRegistry,
Animated,
asset,
Pano,
Box,
Text,
View,
Image,
Model,
Sphere,
PointLight,
AmbientLight,
DirectionalLight,
} from 'react-vr'; const AnimatedBox = Animated.createAnimatedComponent(Box); export default class app extends React.Component {
constructor() {
super();
this.state = {
fadeIn: new Animated.Value(0),
springValue: new Animated.Value(-1),
rotation: new Animated.Value(0)
}
} componentDidMount() {
Animated.timing(
this.state.rotation,
{
duration: 10000,
toValue: 930
}
).start();
Animated.sequence([
Animated.spring(
this.state.springValue,
{
toValue: 0,
duration: 3000,
tension: 1,
friction: 2
}
),
Animated.delay(200),
Animated.timing(
this.state.fadeIn,
{
duration: 1500,
toValue: 1,
easing: (x) => x
}
)
]).start();
} render() {
return (
<View>
<View>
<AmbientLight intensity={0.5}/>
<AnimatedBox
lit
dimWidth={2}
dimDepth={2}
dimHeight={1}
style={
{
color: 'orange',
transform: [
{translate: [0,2,-3]},
{rotateY: this.state.rotation},
{rotateX: -40}
]
}
}
></AnimatedBox>
</View>
<Animated.Image
style={{
layoutOrigin: [0.5, 0.5],
transform: [
{translateZ: -1},
{translateY: this.state.springValue}
],
height: 0.5,
width: 0.5,
backgroundColor: '#335'
}}
source={asset('4.jpeg')}
>
<Animated.Text
style={{
opacity: this.state.fadeIn,
color: 'green',
fontSize: 0.10,
textAlign: 'center'
}}
>Grit</Animated.Text>
</Animated.Image>
</View>
);
}
}; AppRegistry.registerComponent('app', () => app);

最新文章

  1. Spark的Straggler深入学习(1):如何在本地图形监控远程Spark的GC情况——使用java自带的jvisualvm
  2. loj 1201(最大独立集)
  3. 下载pdf_不同操作系统,无法正常下载(兼容性问题)
  4. SQL 操作结果集 -并集、差集、交集、结果集排序
  5. 安装Nginx+uWSGI+Django环境
  6. 2013 ACM 通化邀请赛 A. Tutor
  7. pyhton与json,Xml
  8. rsync介绍
  9. WPF小程序:贪吃蛇
  10. 数据库分库分表(sharding)系列(三) 关于使用框架还是自主开发以及sharding实现层面的考量
  11. [置顶] c# datagridview‘s learn
  12. u-boot: Error: Can&amp;#39;t overwrite &amp;quot;ethaddr&amp;quot;
  13. Android ELF文件格式
  14. 酷派8702手机打开logcat
  15. python selenium-webdriver 通过cookie登陆(十一)
  16. maven jar包冲三种解决方式
  17. (二)SpringBoot基础篇- 静态资源的访问及Thymeleaf模板引擎的使用
  18. Android串口通讯
  19. Eureka源码解读
  20. Python从入门到精通之Seventh!

热门文章

  1. HDU 1757
  2. [ES6] Proxy &amp; Reflect
  3. Android 自己定义View学习(2)
  4. jQuery动画animate()的使用
  5. Window7幻灯片字体显示混乱,难道真的是病毒么
  6. Object::connect: Cannot queue arguments of type &#39;QMap&lt;QString,QString&gt;&#39;(要使用qRegisterMetaType&lt;StringMap&gt;进行注册)
  7. 0x01 位运算
  8. 随机森林算法demo python spark
  9. 谷歌开源可视化工具Facets,将用于人+AI协作项目研究——无非就是一个用于特征工程探索的绘图工具集,pandas可以做的
  10. ubuntu在桌面创建快捷方式