-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.vr.js
65 lines (57 loc) · 1.29 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
import React from 'react';
import {
AppRegistry,
Box,
View,
Plane
} from 'react-vr';
export default class WelcomeToVR extends React.Component {
state = {
color: '#FFFFFF',
rotate: 45,
}
componentWillMount() {
this.setRotation();
}
setRotation = () => {
setTimeout(() => {
this.setState({
rotate: this.state.rotate + 10
});
this.setRotation();
}, 100)
}
setColor(position) {
this.setState({
position,
});
}
resetColor() {
this.setState({
position: -1
})
}
render() {
const { position, rotate } = this.state;
return (
<View>
{[0, 1, 2, 3, 4].map(val =>
<Box
key={val}
texture="https://i.imgur.com/mYmmbrp.jpg"
dimWidth={1}
dimDepth={1}
dimHeight={1}
style={{
color: position === val ? 'red' : '#FFFFFF',
layoutOrigin: [0.5, 0.5],
transform: [{translate: [0, (3 * val) - 1, (-5 * (val + 1))]}, {rotateY: rotate}, {rotateZ: rotate}],
}}
onEnter={this.setColor.bind(this, val)}
onExit={this.resetColor.bind(this, val)}
/>)}
</View>
);
}
};
AppRegistry.registerComponent('WelcomeToVR', () => WelcomeToVR);