-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
433 lines (412 loc) · 11.6 KB
/
App.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
/**
* Copyright (c) 2017-present, Viro, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import React, { Component } from "react";
import { Provider } from "react-redux";
import store from "./client/js/store/index.js";
import {
Text,
View,
StyleSheet,
TouchableHighlight,
StatusBar,
Image
} from "react-native";
import { Container, Tabs, Tab, TabHeading, Header, Button } from "native-base";
import { Overlay } from "react-native-elements";
import { ViroARSceneNavigator } from "react-viro";
import AuthForm from "./client/js/components/auth-form";
import Tourform from "./client/js/components/tour-form";
import ARView from "./client/js/components/AR-view";
import TourView from "./client/js/components/tours-view";
import { dropPoint, undoPoint } from "./client/js/store/points.js";
/*
TODO: Insert your API key below
*/
var sharedProps = {
apiKey: "API_KEY_HERE"
};
// Sets the default scene you want for AR and VR
var InitialARScene = require("./client/js/HelloWorldSceneAR");
var InitialARSceneEditor = require("./client/js/AR-Editor");
var UNSET = "UNSET";
var AR_NAVIGATOR_TYPE = "AR";
var AR_EDITOR_TYPE = "AREditor";
// This determines which type of experience to launch in, or UNSET, if the user should
// be presented with a choice of AR or VR. By default, we offer the user a choice.
var defaultNavigatorType = UNSET;
console.disableYellowBox = true;
export default class App extends Component {
constructor() {
super();
this.state = {
navigatorType: defaultNavigatorType,
sharedProps: sharedProps,
page: 1,
tourId: "",
isVisible: false
};
this._getExperienceSelector = this._getExperienceSelector.bind(this);
this._getARNavigator = this._getARNavigator.bind(this);
this._getAREditor = this._getAREditor.bind(this);
this._getExperienceButtonOnPress = this._getExperienceButtonOnPress.bind(
this
);
this._exitViro = this._exitViro.bind(this);
this.tabHandler = this.tabHandler.bind(this);
this._endButtonHandler = this._endButtonHandler.bind(this);
this._XButtonHandler = this._XButtonHandler.bind(this);
}
// Replace this function with the contents of _getVRNavigator() or _getARNavigator()
// if you are building a specific type of experience.
render() {
if (this.state.navigatorType == UNSET) {
return this._getExperienceSelector();
} else if (this.state.navigatorType == AR_NAVIGATOR_TYPE) {
return this._getARNavigator();
} else if (this.state.navigatorType == AR_EDITOR_TYPE) {
return this._getAREditor();
}
}
// Presents the user with a choice of an AR or VR experience
_getExperienceSelector() {
return (
<Provider store={store}>
<Container>
<StatusBar />
<Header style={styles.header} hasTabs />
<Tabs page={this.state.page}>
<Tab
heading={
<TabHeading style={styles.header}>
<Text>Profile</Text>
</TabHeading>
}
>
<AuthForm tabHandler={this.tabHandler} />
</Tab>
<Tab
heading={
<TabHeading style={styles.header}>
<Text>Editor</Text>
</TabHeading>
}
>
<ARView
_getExperienceButtonOnPress={this._getExperienceButtonOnPress}
AR_NAVIGATOR_TYPE={AR_NAVIGATOR_TYPE}
AR_EDITOR_TYPE={AR_EDITOR_TYPE}
/>
</Tab>
<Tab
heading={
<TabHeading style={styles.header}>
<Text>Tours</Text>
</TabHeading>
}
>
<TourView
_getExperienceButtonOnPress={this._getExperienceButtonOnPress}
AR_NAVIGATOR_TYPE={AR_NAVIGATOR_TYPE}
/>
</Tab>
</Tabs>
</Container>
</Provider>
);
}
// Returns the ViroARSceneNavigator which will start the AR experience
_getARNavigator() {
return (
<View style={styles.outer}>
<ViroARSceneNavigator
{...this.state.sharedProps}
initialScene={{ scene: InitialARScene }}
viroAppProps={{ tourId: this.state.tourId }}
onExitViro={this._exitViro}
/>
<View style={styles.backButtonPosition}>
<TouchableHighlight
onPress={() => this._exitViro()}
style={styles.buttons}
underlayColor={"#00000000"}
>
<Image source={require("./client/js/res/icon_left.png")} />
</TouchableHighlight>
</View>
</View>
);
}
_getAREditor() {
return (
<Provider store={store}>
<View style={styles.outer}>
<ViroARSceneNavigator
{...this.state.sharedProps}
initialScene={{ scene: InitialARSceneEditor }}
onExitViro={this._exitViro}
/>
<View>
<Overlay isVisible={this.state.isVisible}>
<Tourform
closeOverlay={this._XButtonHandler}
exitViro={this._exitViro}
/>
{/* <View style={styles.menu}>
<Form>
<View style={styles.Form}>
<Item floatingLabel>
<Input
placeholder="Tour Name"
name="tourName"
value={this.state.tourName}
onChangeText={value =>
this._handleChange("tourName", value)
}
/>
</Item>
<Item floatingLabel>
<Input
placeholder="Description"
name="description"
value={this.state.description}
onChangeText={value =>
this._handleChange("description", value)
}
/>
</Item>
<Button
style={styles.loginButton}
onPress={this._handleSubmit}
>
<Text style={styles.SubmitbuttonText}>Submit</Text>
</Button>
</View>
<Button
transparent
style={styles.XButton}
onPress={this.handleSubmit}
onPress={() => this._XButtonHandler()}
>
<Text style={styles.XButtonText}>X</Text>
</Button>
</Form>
</View> */}
</Overlay>
</View>
<View style={styles.backButtonPosition}>
<TouchableHighlight
onPress={() => this._exitViro()}
style={styles.buttons}
underlayColor={"#00000000"}
>
<Image source={require("./client/js/res/icon_left.png")} />
</TouchableHighlight>
</View>
<View style={styles.undoButtonPosition}>
<TouchableHighlight
onPress={e => {
if (store.getState().points.pointCount > 1) {
store.dispatch(undoPoint());
}
}}
style={styles.buttons}
underlayColor={"#00000000"}
>
<Image source={require("./client/js/res/icon_repeat.png")} />
</TouchableHighlight>
</View>
{/* <View style={styles.startButtonPosition}>
<TouchableHighlight
style={styles.UIButton}
underlayColor={"#00000000"}
onTrackingUpdated={this._onInitialized}
>
<Text style={styles.buttonText}>Start</Text>
</TouchableHighlight>
</View> */}
<View style={styles.stopButtonPositon}>
<Button
style={styles.UIButton}
underlayColor={"#00000000"}
onPress={() => this._endButtonHandler()}
>
<Text style={styles.buttonText}>End</Text>
</Button>
</View>
<View style={styles.dropButtonPosition}>
<TouchableHighlight
onPress={e => store.dispatch(dropPoint())}
style={styles.MainButton}
underlayColor={"#00000000"}
>
<Text style={styles.mainButtonText}>Drop</Text>
</TouchableHighlight>
</View>
</View>
</Provider>
);
}
tabHandler() {
this.setState({
page: 2
});
}
// This function returns an anonymous/lambda function to be used
// by the experience selector buttons
_getExperienceButtonOnPress(navigatorType, tourId = "") {
return () => {
this.setState({
navigatorType: navigatorType,
tourId: tourId
});
};
}
// This function "exits" Viro by setting the navigatorType to UNSET.
_exitViro() {
this.setState({
navigatorType: UNSET
});
}
//closes overlay and returns to AREditor
_XButtonHandler() {
this.setState({
isVisible: false
});
}
//Opens tour-form-overlay in AREditor
_endButtonHandler() {
this.setState({
isVisible: true
});
}
}
var styles = StyleSheet.create({
backButtonPosition: {
position: "absolute",
left: -10,
right: 0,
top: 10,
alignItems: "flex-start"
},
undoButtonPosition: {
position: "absolute",
left: 100,
right: 0,
top: 45,
alignItems: "flex-end"
},
startButtonPosition: {
position: "absolute",
left: 10,
right: 0,
bottom: 20,
alignItems: "baseline"
},
stopButtonPositon: {
position: "absolute",
left: 0,
right: 15,
bottom: 20,
alignItems: "flex-end"
},
dropButtonPosition: {
position: "absolute",
left: 100,
right: 100,
bottom: 20,
alignItems: "center"
},
viroContainer: {
flex: 1,
backgroundColor: "black"
},
outer: {
flex: 1,
flexDirection: "row",
alignItems: "flex-end"
},
inner: {
flex: 1,
flexDirection: "column",
alignItems: "center",
backgroundColor: "black"
},
titleText: {
paddingTop: 30,
paddingBottom: 20,
color: "#fff",
textAlign: "center",
fontSize: 25
},
buttons: {
height: 80,
width: 80,
marginTop: 15,
backgroundColor: "#00000000",
borderRadius: 10,
borderWidth: 1,
borderColor: "#ffffff00"
},
exitButton: {
marginTop: 10,
alignSelf: "center",
width: 100
},
UIButton: {
width: 80,
height: 40,
backgroundColor: "white",
borderRadius: 10,
borderWidth: 1,
borderColor: "black",
marginBottom: 15
},
TopUIButton: {
width: 80,
height: 40,
paddingTop: 5,
backgroundColor: "white",
borderRadius: 10,
borderWidth: 1,
borderColor: "black",
marginTop: 40
},
buttonText: {
color: "black",
textAlign: "center",
fontSize: 20
},
mainButtonText: {
color: "black",
textAlign: "center",
fontSize: 25,
marginTop: 18,
fontWeight: "bold"
},
MainButton: {
width: 80,
height: 80,
paddingTop: 5,
backgroundColor: "white",
borderRadius: 50,
borderWidth: 1,
borderColor: "black"
},
Form: {
marginTop: 70
},
buttonText: {
color: "black",
textAlign: "center",
fontSize: 20,
marginLeft: 22,
fontWeight: "bold"
}
});
module.exports = App;