-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Multiple.js
79 lines (72 loc) · 1.63 KB
/
Multiple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import React, {Component} from 'react';
import {StyleSheet, View, Animated} from 'react-native';
import ModelView from 'react-native-gl-model-view';
const AnimatedModelView = Animated.createAnimatedComponent(ModelView);
export default class Multiple extends Component {
constructor() {
super();
this.state = {
rotateZ: new Animated.Value(0),
};
}
componentDidMount() {
this.animate(0);
}
animate(iteration) {
Animated.timing(this.state.rotateZ, {
toValue: ++iteration * 360,
useNativeDriver: true,
duration: 5000,
}).start(this.animate.bind(this, iteration++));
}
renderModel() {
return (
<AnimatedModelView
model={{
uri: 'demon.model',
}}
texture={{
uri: 'demon.png',
}}
tint={{r: 1.0, g: 1.0, b: 1.0, a: 1.0}}
animate
scale={0.01}
translateZ={-2.5}
rotateX={270}
rotateZ={Animated.add(this.state.rotateZ, Math.random() * 360)}
style={styles.model}
/>
);
}
render() {
return (
<View style={styles.container}>
<View style={styles.row}>
{this.renderModel()}
{this.renderModel()}
</View>
<View style={styles.row}>
{this.renderModel()}
{this.renderModel()}
</View>
<View style={styles.row}>
{this.renderModel()}
{this.renderModel()}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
row: {
flex: 1,
flexDirection: 'row',
},
model: {
flex: 1,
backgroundColor: 'transparent',
},
});