-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
54 lines (44 loc) · 1.33 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
// 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, Location, Surface, Module } from 'react-360-web';
class TitleChanger extends Module {
constructor() {
super('TitleChanger');
}
changeTitle(title) {
document.title = title;
}
}
function init(bundle, parent, options = {}) {
const r360 = new ReactInstance(bundle, parent, {
// Add custom options here
fullScreen: true,
nativeModules: [new TitleChanger()],
...options
});
const myCylindricalSurface = new Surface(
4680,
600,
Surface.SurfaceShape.Cylinder
);
// Render your app content to the default cylinder surface
r360.renderToSurface(
r360.createRoot('TravelVr', {
/* initial props */
}),
myCylindricalSurface
);
// const myFlatSurface = new Surface(600, 400, Surface.SurfaceShape.Flat);
// myFlatSurface.setAngle(-Math.PI / 4, 0);
// r360.renderToSurface(
// r360.createRoot('Flag', {
// image: 'flag_spain.png'
// }),
// myFlatSurface
// );
const myLocation = new Location([0, 0, -2]);
r360.renderToLocation(r360.createRoot('Pikachu'), myLocation);
// Load the initial environment
r360.compositor.setBackground(r360.getAssetURL('360_world.jpg'));
}
window.React360 = { init };