-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (79 loc) · 2.2 KB
/
index.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
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
NativeModules,
VrButton
} from 'react-360';
const surfaceModule = NativeModules.surfaceModule;
class ButtonSurface extends React.Component {
render() {
return(
<View style={styles.buttonPanel}>
<VrButton style={styles.greetingBox} onClick={() => surfaceModule.createPanel()}>
<Text>Create Panel</Text>
</VrButton>
</View>
)
}
}
export default class SurfaceVR extends React.Component {
state = {
width: 1000,
height: 600
}
changeSurfaceDimensions(width, height) {
surfaceModule.resizeSurface(width, height);
this.setState({width: width, height: height});
}
render() {
return (
<View style={[styles.panel, {width: this.state.width, height: this.state.height}]}>
<VrButton style={styles.greetingBox} onClick={() => this.changeSurfaceDimensions(500,300)}>
<Text>Change Dim.</Text>
</VrButton>
<VrButton style={styles.greetingBox} onClick={() => surfaceModule.changeSurfaceType("Flat")}>
<Text>Flat</Text>
</VrButton>
<VrButton style={styles.greetingBox} onClick={() => surfaceModule.changeSurfaceType("Cylinder")}>
<Text>Cylinder</Text>
</VrButton>
<VrButton style={styles.greetingBox} onClick={() => this.changeSurfaceDimensions(1000,600)}>
<Text>Reset</Text>
</VrButton>
<VrButton style={styles.greetingBox} onClick={() => surfaceModule.destroyPanel()}>
<Text>Destroy</Text>
</VrButton>
</View>
);
}
};
const styles = StyleSheet.create({
panel: {
backgroundColor: 'rgba(255, 255, 255, 0.4)',
justifyContent: 'center',
alignItems: 'center',
},
greetingBox: {
width: 200,
height: 60,
padding: 20,
backgroundColor: '#000000',
borderColor: '#639dda',
borderWidth: 2,
},
greeting: {
fontSize: 30,
},
buttonPanel: {
width: 300,
height: 300,
backgroundColor: 'rgb(255,127,80)',
justifyContent: 'center',
alignItems: 'center'
}
});
AppRegistry.registerComponent('SurfaceVR', () => SurfaceVR);
AppRegistry.registerComponent('ButtonSurface', () => ButtonSurface);