-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplat_viewer.html
More file actions
181 lines (155 loc) · 5.3 KB
/
Copy pathsplat_viewer.html
File metadata and controls
181 lines (155 loc) · 5.3 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Splat Viewer — Nebula</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
margin: 0;
padding: 0;
background-color: #000;
color: #eee;
font-family: 'Space Grotesk', sans-serif;
overflow: hidden;
display: flex;
flex-direction: column;
height: 100vh;
}
header {
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
background-color: rgba(10, 10, 10, 0.8);
padding: 10px 20px;
text-align: center;
position: absolute;
top: 0;
width: 100%;
z-index: 10;
box-sizing: border-box;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
header h1 {
margin: 0;
font-size: 1.2rem;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#container {
flex-grow: 1;
width: 100%;
height: 100%;
}
#loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
z-index: 5;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid rgba(255, 255, 255, 0.1);
border-top: 3px solid #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 15px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.controls-hint {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.6);
padding: 8px 15px;
border-radius: 20px;
font-size: 0.8rem;
color: #888;
pointer-events: none;
z-index: 10;
}
.back-link {
position: absolute;
top: 15px;
left: 20px;
z-index: 20;
color: #fff;
text-decoration: none;
font-size: 0.9rem;
opacity: 0.7;
transition: opacity 0.3s;
}
.back-link:hover {
opacity: 1;
}
</style>
</head>
<body>
<header>
<a href="index.html" class="back-link">← Back</a>
<h1>Nebula Splat Viewer</h1>
</header>
<div id="loading">
<div class="spinner"></div>
<div id="status">Loading Gaussian Splat...</div>
</div>
<div id="container"></div>
<div class="controls-hint">
Left Click: Rotate | Right Click: Pan | Scroll: Zoom
</div>
<script type="module">
// Using a pinned version for stability
import * as SPLAT from "https://cdn.jsdelivr.net/npm/gsplat@1.2.9/dist/index.es.min.js";
async function init() {
const container = document.getElementById('container');
const status = document.getElementById('status');
const loading = document.getElementById('loading');
try {
const renderer = new SPLAT.WebGLRenderer();
container.appendChild(renderer.canvas);
const scene = new SPLAT.Scene();
const camera = new SPLAT.Camera();
const controls = new SPLAT.OrbitControls(camera, renderer.canvas);
// Resize handler
const resize = () => {
renderer.setSize(window.innerWidth, window.innerHeight);
};
window.addEventListener('resize', resize);
resize();
// Load the Splat file
status.innerText = "Downloading Splat...";
await SPLAT.Loader.LoadAsync("/models/gs/nebula_rnd1.splat", scene, (progress) => {
status.innerText = `Loading: ${Math.round(progress * 100)}%`;
});
loading.style.display = 'none';
// Set initial camera position AFTER loading,
// because some models might be very far from origin
camera.position.z = 5;
camera.position.y = 1;
controls.update();
const frame = () => {
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(frame);
};
requestAnimationFrame(frame);
console.log("Splat loaded successfully into scene", scene);
} catch (error) {
console.error("Error in GSPLAT init:", error);
status.innerText = "Error: " + error.message;
status.style.color = "#ff4444";
document.querySelector('.spinner').style.display = 'none';
}
}
init();
</script>
</body>
</html>