[ReactVR] Animate Text, Images, Views, and 3D Elements Using the Animated Library in React VR
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);
[ReactVR] Animate Text, Images, Views, and 3D Elements Using the Animated Library in React VR的更多相关文章
- [ReactVR] Render Custom 3D Objects Using the Model Component in React VR
React VR isn't limited to simple 3D primitives. By using the <Model/> Component we can place a ...
- [ReactVR] Add Shapes Using 3D Primitives in React VR
React VR ships with a handful of 3D primitives. We'll importprimitives like <Sphere/>, <Box ...
- [ReactVR] Start a Virtual Reality Project Using the React VR CLI
We will learn how to set up a React VR project, run the development mode with hot reloading, and tak ...
- css3 animate写的超炫3D转换
上一篇中介绍了animate的基本的属性,这一篇讲的则是关于animate以及transforms的使用 <!DOCTYPE html><html lang="en&quo ...
- [ReactVR] Add Lighting Using Light Components in React VR
In order to illuminate a scene containing 3D objects a lighting setup is required. In this lesson we ...
- [React] Return a list of elements from a functional component in React
We sometimes just want to return a couple of elements next to one another from a React functional co ...
- WPF: Creation of Text Labels for 3D Scene
原文:WPF: Creation of Text Labels for 3D Scene 转载:http://www.codeproject.com/KB/WPF/WPF_Text3D.aspx Do ...
- 3D Text & GUI Text & GUI Texture
[Unity3D Text] 3D Text通过"Text Mesh"组件."MeshRender共同完成",通过如下方法要以创建一个3D Text. 3D T ...
- osgText::Text简介
整理自<OpenSceneGraph三维渲染引擎编程指南> 在OSG中,为了显示高质量的文字,专门定义了一个新的名字空间来管理场景中的文字渲染,这个名字空间中的类主要用于加载字体和控制文字 ...
随机推荐
- HDU 4342
先确定M的大致范围后即可求. #include <iostream> #include <cstdio> #include <algorithm> #include ...
- poj 2396 Budget 边容量有上下界的最大流
题意: 给一个矩阵的每行和及每列和,在给一些行列或点的限制条件.求一个满足的矩阵. 分析: 转化为有上下界的网络流,注意等于也是一种上下界关系,然后用dinic算法. 代码: //poj 2396 / ...
- openfire 安装部署
1. openfire安装和配置 本文介绍openfire 在linux上安装部署过程 linux上有两种安装方式,一个是RPM包方式.还有一个是tar.gz压缩包方式, 官方推荐採用RPM包方式,会 ...
- 杂项-Java:Shiro(Java安全架构)
ylbtech-杂项-Java:Shiro(Java安全架构) Apache Shiro是一个强大且易用的Java安全框架,执行身份验证.授权.密码和会话管理.使用Shiro的易于理解的API,您可以 ...
- 反向Shell增强
下载socat 在客户端: socat file:`tty`,raw,echo=0 tcp-listen:4444 在服务端: socat exec:'bash -li',pty,stderr,set ...
- web.config or app.config 中configSections配置节点
以前还真没见过,今天看项目中有在用,简单写了个Demo,这样配置的好处就是可以自定义配置,更加模块化,直接上代码; 1.配置文件 由于我创建的是一个控制台项目,所以配置文件是App.Config:(这 ...
- ViewPager滑动到最后一页再向左滑动进入主界面
在OnPageChangeListener中的onPageScrolled方法里判断 @Override public void onPageScrolled(int arg0, float arg1 ...
- 使用pgpool管理数据库集群故障的问题
pgpool如何选举master角色 在pgpool启动的过程中通过对 pgpoo.conf配置文件中的数据库节点条目信息,对集群中的数据库节点从0开始一个个的遍历,并发送SQL语句“select p ...
- uploadifive上传文件
uploadifive是一个款基于H5的上传文件的插件.优点是,可以在PC端,也可以在手机上进行操作.缺点是,IE9以下的兼容性不好. View: <!DOCTYPE html> < ...
- poj 2135 Farm Tour【 最小费用最大流 】
第一道费用流的题目--- 其实---还是不是很懂,只知道沿着最短路找增广路 建图 源点到1连一条容量为2(因为要来回),费用为0的边 n到汇点连一条容量为2,费用为0的边 另外的就是题目中输入的了 另 ...