-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainScene1.js
84 lines (79 loc) · 2.31 KB
/
MainScene1.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
80
81
82
83
84
import React from 'react';
import { Animated, asset, VrButton, VideoPano, View, Scene } from 'react-vr';
const AnimatedScene = Animated.createAnimatedComponent(Scene);
export default class MainScene extends React.Component {
constructor(props) {
super(props);
this.state = {
movement: new Animated.Value(0),
rotation: new Animated.Value(0)
};
}
moveTo(endPos) {
Animated.timing(this.state.rotation, {
toValue: 1,
duration: 1000
}).start();
Animated.timing(this.state.movement, {
toValue: endPos,
duration: 1000
}).start();
}
render() {
return (
<AnimatedScene
style={{
transform: [
{ translate: [0, 0, this.state.movement] },
{ rotateY: this.state.rotation }
]
}}
>
<VideoPano source={asset('space.webm')} loop={true}>
<View>
<VrButton onClick={() => this.moveTo(-8)}>
<Animated.Text
style={{
backgroundColor: '#777879',
fontSize: 0.8,
fontWeight: '400',
layoutOrigin: [0.5, 0.5],
paddingLeft: 0.2,
paddingRight: 0.2,
textAlign: 'center',
textAlignVertical: 'center',
transform: [
{ translate: [0, 0, -6] },
{ rotateY: this.state.rotation }
]
}}
>
foreground
</Animated.Text>
</VrButton>
<VrButton onClick={() => this.moveTo(0)}>
<Animated.Text
style={{
backgroundColor: 'red',
fontSize: 0.8,
fontWeight: '400',
layoutOrigin: [0.5, 0.5],
paddingLeft: 0.2,
paddingRight: 0.2,
textAlign: 'center',
textAlignVertical: 'center',
transform: [
{ translate: [0, 0, -12] },
{ rotateY: this.state.rotation }
]
}}
>
background
</Animated.Text>
</VrButton>
</View>
</VideoPano>
</AnimatedScene>
);
}
}