[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);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2016-02-09 [Cycle.js] Fine-grained control over the DOM Source
2016-02-09 [Cycle.js] Making our toy DOM Driver more flexible
2016-02-09 [Redux] Generating Containers with connect() from React Redux (VisibleTodoList)
2016-02-09 [MongoDB] Remove, update, create document