-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.vr.js
109 lines (97 loc) · 2.12 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
import React from 'react';
import {
AppRegistry,
asset,
StyleSheet,
Pano,
Text,
View,
VrButton
} from 'react-vr';
import Mars from './components/Mars'
import Studio from './components/Studio'
// Son tres escenarios. Chess, Estudio y marte 0776
const places = [
{
title: 'Paisaje',
img: 'paisaje.jpg',
color: 'red'
},
{
title: 'Mars',
img: 'mars.jpg',
color: 'blue'
},
{
title: 'Studio',
img: 'studio.jpg',
color: 'orange'
}
]
export default class demo extends React.Component {
constructor(props) {
super(props)
this.state = {
place: places[0],
showMenu: false
}
}
renderPlaces() {
return places.map((place, key) =>
<VrButton
key={key}
style={[style.item, {backgroundColor: places[key].color}]}
onClick={() => this.setState({place: places[key]})}
>
<Text style={style.text}>{place.title}</Text>
</VrButton>
)
}
render() {
return (
<View>
<Pano source={asset(this.state.place.img)} />
<View style={[style.wrap]}>
{this.state.showMenu ? this.renderPlaces() : null}
</View>
{this.state.place.title == 'Mars' ? <Mars /> : this.state.place.title == 'Studio' ? <Studio /> : null }
<VrButton style={style.floorButton} onClick={() => this.setState({showMenu: !this.state.showMenu})}>
<Text style={style.text}>Menu</Text>
</VrButton>
</View>
);
}
};
const style = StyleSheet.create({
wrap: {
layoutOrigin: [0.5, 0.5],
position: 'absolute',
flex: 1,
flexDirection: 'column',
width: 2,
alignItems: 'stretch',
transform: [{translate: [0, 0, -3]}],
},
item: {
margin: 0.1,
height: 0.3
},
text: {
fontSize: 0.2,
textAlign: 'center'
},
floorButton: {
position: 'absolute',
layoutOrigin: [0.5, 0.5],
transform: [
{translate: [0, -1, 0]},
{rotateX: -90}
],
backgroundColor: 'red',
height: 0.6,
width: 0.6,
borderRadius: 1,
justifyContent: 'center'
}
})
AppRegistry.registerComponent('demo', () => demo);