-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgsplat.js.sai.html.template
More file actions
85 lines (70 loc) · 2.42 KB
/
gsplat.js.sai.html.template
File metadata and controls
85 lines (70 loc) · 2.42 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
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
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Spectacular AI 3DGS example</title>
<style>
body,
html {
margin: 0;
padding: 0;
overflow: hidden;
}
canvas {
width: 100vw;
height: 100vh;
}
.logo-link {
position: fixed;
top: 50px;
right: 50px;
z-index: 100;
}
.logo-link img {
width: 100px;
height: auto;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<div id="data" data-base64="CORS_SUCKS"></div>
<a class="logo-link" href="https://www.spectacularai.com/mapping"><img src="https://spectacularai.github.io/docs/png/SpectacularAI-logo-small-white-transparent-shadow.png"/></a>
<script type="module">
import * as SPLAT from "https://cdn.jsdelivr.net/npm/gsplat@1.2.3";
const canvas = document.getElementById("canvas");
const dataContainer = document.getElementById('data');
const renderer = new SPLAT.WebGLRenderer(canvas);
const scene = new SPLAT.Scene();
const camera = new SPLAT.Camera();
const controls = new SPLAT.OrbitControls(camera, canvas);
function base64ToUint8Array(base64) {
var raw = window.atob(base64);
var uint8Array = new Uint8Array(raw.length);
for (var i = 0; i < raw.length; i++) {
uint8Array[i] = raw.charCodeAt(i);
}
return uint8Array;
}
async function main() {
const base64Data = dataContainer.dataset.base64;
const binaryData = base64ToUint8Array(base64Data);
const splat = new SPLAT.Splat(SPLAT.SplatData.Deserialize(binaryData));
scene.addObject(splat);
const handleResize = () => {
renderer.setSize(window.innerWidth, window.innerHeight);
};
const frame = () => {
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(frame);
};
handleResize();
window.addEventListener("resize", handleResize);
requestAnimationFrame(frame);
}
main();
</script>
</body>
</html>