-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.vr.js
123 lines (115 loc) · 3.34 KB
/
index.vr.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import React from 'react';
import {
AppRegistry,
SpotLight,
asset,
Pano,
Text,
View,
Model,
VrButton,
Animated
} from 'react-vr';
import TheGlasses from './components/TheGlasses.vr.js';
export default class putontheglasses extends React.Component {
constructor() {
super();
this.state = {
showName: false,
alternateMode: false,
textOpacity: new Animated.Value(1),
vrTextOpacity: new Animated.Value(1)
};
this.toggleMode = this.toggleMode.bind(this);
this.showTitle = this.showTitle.bind(this);
}
render() {
return (
<View
style={{
layoutOrigin: [0.5, 0.5],
alignItems: 'center'
}}>
<SpotLight intensity={1.5} style={{ color: '#00d8ff' }} />
{this.state.alternateMode
? <Pano source={asset('teapots.jpg')} />
: <Pano source={asset('times-square-pano.jpg')} />}
{this.state.showName && !this.state.alternateMode
? <VrButton
onClick={this.showTitle}
style={{
flexDirection: 'row',
height: 0.15,
width: 1,
layoutOrigin: [-0.02, 0],
transform: [{ translateY: 0.2 }, { translateZ: -1 }]
}}>
<Animated.Text
style={{
opacity: this.state.vrTextOpacity,
backgroundColor: '#00d8ff80',
fontSize: 0.13
}}>
V
</Animated.Text>
<Animated.Text
style={{
opacity: this.state.textOpacity,
backgroundColor: '#00d8ff80',
fontSize: 0.13
}}>
alentin
</Animated.Text>
<Animated.Text
style={{
opacity: this.state.vrTextOpacity,
backgroundColor: '#00d8ff80',
fontSize: 0.13
}}>
R
</Animated.Text>
<Animated.Text
style={{
opacity: this.state.textOpacity,
backgroundColor: '#00d8ff80',
fontSize: 0.13
}}>
adulescu
</Animated.Text>
</VrButton>
: null}
{!this.state.alternateMode && <TheGlasses onClick={this.toggleMode} />}
{!this.state.showName && !this.state.alternateMode
? <VrButton
onClick={() => this.setState({ showName: true })}
style={{
height: 0.15,
width: 0.783,
backgroundColor: '#00d8ff80',
layoutOrigin: [-0.02, 0],
transform: [{ translateY: -0.1 }, { translateZ: -1 }]
}}>
<Text>Put on the Glasses</Text>
</VrButton>
: null}
</View>
);
}
toggleMode() {
this.setState({ alternateMode: !this.state.alternateMode });
}
showTitle() {
Animated.sequence([
Animated.timing(this.state.textOpacity, {
toValue: 0,
duration: 1000
}),
Animated.timing(this.state.vrTextOpacity, {
toValue: 0,
duration: 1000,
delay: 500
})
]).start(() => {});
}
}
AppRegistry.registerComponent('putontheglasses', () => putontheglasses);