forked from KhronosGroup/glTF-Sample-Viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheadless.html
73 lines (59 loc) · 2.07 KB
/
headless.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>glTF Sample Viewer</title>
<meta name="author" content="Khronos Group Inc.">
<meta name="description" content="The official glTF sample viewer">
<meta name="keywords" content="glTF, WebGL, Sample, Viewer, PBR">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="assets/images/gltf.png">
<script src="libs/dat.gui.min.js"></script>
<script src="libs/stats.min.js"></script>
<script src="dist/gltf-reference-viewer.umd.js"></script>
</head>
<script>
// In renderer process (web page).
const {ipcRenderer} = require('electron');
var path = require('path');
let remote = require('electron').remote,
args = remote.getGlobal('sharedObject').args;
function startRenderer()
{
let viewer = gltf_rv.gltf_rv(
'canvas',
'assets/models/2.0/model-index.json',
args.environment,
true,
rendererReady);
var gltfPath = path.parse(args.gltf_path)
viewer.loadFromPath("/" + gltfPath.base, gltfPath.dir).then(() =>
{
const yfov_rad = args.yfov * Math.PI / 180.0;
viewer.setCamera(
args.eye_position,
args.target_position,
args.up,
args.projection,
args.znear,
args.zfar,
yfov_rad,
args.size[0],
args.size[1]);
viewer.renderingParameters.cameraIndex = args.camera_index;
viewer.setAnimation(args.animationIndex, args.animationTimeSec);
});
}
function rendererReady()
{
ipcRenderer.send('rendererReady');
}
</script>
<!-- Just create a rendering canvas like below and call gltf_rv! -->
<body onload="startRenderer();">
<div id="gltf-rv-model-spinner"> </div>
<canvas id="canvas">No Canvas!</canvas>
</body>
</html>