/
development.html
75 lines (67 loc) · 1.65 KB
/
development.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
74
75
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>K3D</title>
<script src="node_modules/requirejs/require.js"></script>
<script src="dist/standalone.js?k3d"></script>
<style>
body, html {
background-color: #F5F5F5;
margin: 0;
padding: 0;
overflow: hidden;
}
#canvasTarget {
width: 100%;
height: 100%;
position: absolute;
}
</style>
</head>
<body>
<div id="canvasTarget"></div>
<script>
var K3DInstance;
function fileLoader(url, callback) {
var xhrLoad = new XMLHttpRequest();
xhrLoad.responseType = "arraybuffer";
xhrLoad.open('GET', url, true);
xhrLoad.onreadystatechange = function () {
if (xhrLoad.readyState === 4) {
callback(xhrLoad.response);
}
};
xhrLoad.send(null);
}
require(['k3d'], function (lib) {
// try {
// K3DInstance = new lib.K3D(
// lib.ThreeJsProvider,
// document.getElementById('canvasTarget'),
// );
// } catch (e) {
// console.log(e);
// return reject(e);
// }
fileLoader('binary_snapshot.k3d', function (data) {
K3DInstance = lib.CreateK3DAndLoadBinarySnapshot(
data,
document.getElementById('canvasTarget')
).then(function (ret) {
K3DInstance = ret;
K3DInstance.resetCamera(0.7);
// setTimeout(function () {
// let jsons = ret.getWorld().ObjectsListJson;
//
// Object.keys(jsons).forEach(function(id) {
// jsons[id].group = null;
// K3DInstance.reload(jsons[id], {group: null});
// });
// }, 5000);
});
});
});
</script>
</body>
</html>