[ReactVR] Animate Text, Images, Views, and 3D Elements Using the Animated Library in React VR
2018-02-09 04:27
495 查看
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,
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] Render Custom 3D Objects Using the Model Component in React VR
- [ReactVR] Add Shapes Using 3D Primitives in React VR
- [React] Render Elements Outside the Current React Tree using Portals in React 16
- [ReactVR] Start a Virtual Reality Project Using the React VR CLI
- [ReactVR] Add Lighting Using Light Components in React VR
- CRUD Operations Using the Generic Repository Pattern and Dependency Injection in MVC
- 32-bit Assembler is Easy, why and how to develop using the assembler; start learning to program in Assembly now!
- The study of chapter 13 in programming windows with mfc-printing with document and views
- A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++
- Swift Standard Library: Documented and undocumented built-in functions in the Swift standard library – the complete list with all 74 functions
- matlab 标定箱错误:Disabling view 2 - Reason: the left and right images are found inconsistent (已解决)
- BI Java 补丁错误处理 :Cannot login to the SAP J2EE Engine using user and password as provided in the Filesystem Secure Store. Enter va
- [Yii Framework] How to embed the css and images in a module
- [Angular] Show a loading indicator in Angular using *ngIf/else, the as keyword and the async pipe
- Using MC.exe, message resources and the NT event log in your own projects
- [转]C# and the using Statement in 3 seconds and a bug in Reflector
- Integrating Gear VR and the AR/VR Sample in Unity 5.3
- Using the five elements of fashion colors to create the best feng shui in auspicious Home
- More 3D Graphics (rgl) for Classification with Local Logistic Regression and Kernel Density Estimates (from The Elements of Statistical Learning)(转)
- Kalman Filters in the MRPT and using tips