-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
46 lines (39 loc) · 1.43 KB
/
Copy pathclient.js
File metadata and controls
46 lines (39 loc) · 1.43 KB
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
// 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, Surface} from 'react-360-web';
function init(bundle, parent, options = {}) {
// initialise instant game
if (FBInstant) {
FBInstant.initializeAsync()
.then(function() {
FBInstant.setLoadingProgress(100);
FBInstant.startGameAsync();
});
}
const subtitleSurface = new Surface(600, 800, Surface.SurfaceShape.Flat);
subtitleSurface.setRadius(6);
const r360 = new ReactInstance(bundle, parent, {
// Add custom options here
fullScreen: true,
frame: () => {
// This will makes the subtitle surface always in front of user
// Please be careful about the design of any this kind of HMD-like surface.
// It will be really hard to view and interact with the content in VR
// if it's placed in a corner position.
const cameraQuat = r360.getCameraQuaternion();
subtitleSurface.recenter(cameraQuat, 'all');
},
...options,
});
// Render your app content to the default cylinder surface
r360.renderToSurface(
r360.createRoot('MediaAppTemplate', { /* initial props */ }),
r360.getDefaultSurface()
);
// Render the subtitle content to a flat surface
r360.renderToSurface(
r360.createRoot('MediaAppTemplateSubtitle', { /* initial props */ }),
subtitleSurface,
);
}
window.React360 = {init};