[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中,为了显示高质量的文字,专门定义了一个新的名字空间来管理场景中的文字渲染,这个名字空间中的类主要用于加载字体和控制文字 ...
随机推荐
- gem update --system
gem update --system 修改完gem sources之后,进行gem update: gem update --system 之后的输出: C:\Sites\test01>gem ...
- OC-JS交互(WebViewJavascriptBridge使用说明)
首先确保一份已经配好功能的html文件. 1.初始化一个webview(viewdidload) UIWebView* webView = [[UIWebView alloc] initWithFra ...
- 为什么网络银行不支持GNU/Linux操作系统下的浏览器操作
当年Linux没出时.银行就開始信息化建设了. 所为信息化,就是指用计算机工作了.服务客户了. 顺带着,慢慢的建server,连网(内部网).外网(网上银行) 这样下来, unix, dos, win ...
- win7-32虚拟机安装
前置条件:安装好VMware-workstation 一.本人本机win7—32位 准备win7_32位镜像文件GSP1RMCULFRER_CN_DVD.iso 新建一个文件夹,将它保存在我们的新建文 ...
- 朴素的UNIX之-调度器细节
0.多进程调度的本质 我们都知道UNIX上有一个著名的nice调用.何谓nice,当然是"好"了.常规的想法是nice值越大越好,实际上,nice值越好,自己的优先级越低.那么为何 ...
- Swift - 使用CollectionView实现图片Gallery画廊效果(左右滑动浏览图片)
1,效果图 (1)图片从左至右横向排列(只有一行),通过手指拖动可以前后浏览图片. (2)视图滚动时,每张图片根据其与屏幕中心距离的不同,显示尺寸也会相应地变化.越靠近屏幕中心尺寸就越大,远离屏幕中心 ...
- P1233 木棍加工
P1233 木棍加工 题目描述 一堆木头棍子共有n根,每根棍子的长度和宽度都是已知的.棍子可以被一台机器一个接一个地加工.机器处理一根棍子之前需要准备时间.准备时间是这样定义的: 第一根棍子的准备时间 ...
- nginx的安装步骤
nginx学习资料;https://zhuanlan.zhihu.com/p/34943332 1.下载nginx的安装包:https://nginx.org/en/download.html 2. ...
- CZLayer的阴影
CALayer有一个shadow属性 意思是阴影 shadowcolor //颜色 shadowoffset //偏移 shadowOpacity //透明度 layer有一个方法 mas ...
- Ubuntu 16.04或14.04里下安装搜狗输入法(图文详解)(全网最简单)
不多说,直接上干货! 其实啊,很简单 分三步走 1.添加fcitx的键盘输入法系统,因为sogou是基于fcitx的,而系统默认的是iBus: 2.安装sogou输入法: 3.设置系统参数及一些注意点 ...