-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
65 lines (49 loc) · 1.32 KB
/
client.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
// This file contains the boilerplate to execute your React app.
// If you want to modify your application's content, start in "index.js"
import {ReactInstance, Module ,Surface} from 'react-360-web';
function init(bundle, parent, options = {}) {
r360 = new ReactInstance(bundle, parent, {
fullScreen: true,
nativeModules: [
new surfaceModule(),
],
...options,
});
buttonSurface = new Surface(300,300, Surface.SurfaceShape.Flat);
buttonSurface.setAngle(
5,
0
);
r360.renderToSurface(
r360.createRoot('ButtonSurface', {}),
buttonSurface
);
surface = r360.getDefaultSurface();
surfacePanel = r360.renderToSurface(
r360.createRoot('SurfaceVR', {}),
surface
);
r360.compositor.setBackground(r360.getAssetURL('360_world.jpg'));
}
class surfaceModule extends Module {
constructor() {
super('surfaceModule');
}
resizeSurface(width, height) {
surface.resize(width, height)
}
changeSurfaceType(Type) {
Type === "Flat" ? surface.setShape(Surface.SurfaceShape.Flat) : surface.setShape(Surface.SurfaceShape.Cylinder);
}
destroyPanel() {
console.log(r360)
r360.detachRoot(surfacePanel);
}
createPanel() {
surfacePanel = r360.renderToSurface(
r360.createRoot('SurfaceVR', {}),
surface
);
}
}
window.React360 = {init};