dylanebert HF staff commited on
Commit
83e721c
1 Parent(s): b3b413b

download choose format

Browse files
Files changed (3) hide show
  1. editor/index.html +25 -1
  2. editor/src/main.ts +30 -7
  3. editor/style.css +33 -4
editor/index.html CHANGED
@@ -44,7 +44,7 @@
44
  id="url-input"
45
  placeholder="https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/bonsai-7k-mini.splat"
46
  />
47
- <button id="upload-submit">Import</button>
48
  </div>
49
  <div class="modal-section">
50
  <p id="upload-error"></p>
@@ -52,6 +52,30 @@
52
  </div>
53
  </div>
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  <button id="download-button" class="tool-button" title="Download Selection">
56
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32">
57
  <path
 
44
  id="url-input"
45
  placeholder="https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/bonsai-7k-mini.splat"
46
  />
47
+ <button id="upload-submit" class="submit">Import</button>
48
  </div>
49
  <div class="modal-section">
50
  <p id="upload-error"></p>
 
52
  </div>
53
  </div>
54
 
55
+ <div id="download-modal" class="modal">
56
+ <div class="modal-content">
57
+ <span id="download-modal-close" class="close">&times;</span>
58
+ <p>Download Splat</p>
59
+ <hr class="divider" />
60
+ <div class="modal-section">
61
+ <div id="format-select">
62
+ <p>Select format</p>
63
+ <div>
64
+ <input type="radio" id="splat" name="format" value="splat" checked />
65
+ <label for="splat">.splat</label>
66
+ </div>
67
+ <div>
68
+ <input type="radio" id="ply" name="format" value="ply" />
69
+ <label for="ply">.ply</label>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <div class="modal-section">
74
+ <button id="download-submit" class="submit">Download</button>
75
+ </div>
76
+ </div>
77
+ </div>
78
+
79
  <button id="download-button" class="tool-button" title="Download Selection">
80
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32">
81
  <path
editor/src/main.ts CHANGED
@@ -11,11 +11,16 @@ const controlsDisplayButton = document.getElementById("controls-display-button")
11
  const controlsDisplay = document.getElementById("controls-display") as HTMLDivElement;
12
  const uploadModal = document.getElementById("upload-modal") as HTMLDialogElement;
13
  const uploadModalClose = document.getElementById("upload-modal-close") as HTMLButtonElement;
 
 
14
  const fileInput = document.getElementById("file-input") as HTMLInputElement;
15
  const urlInput = document.getElementById("url-input") as HTMLInputElement;
16
  const uploadSubmit = document.getElementById("upload-submit") as HTMLButtonElement;
17
  const uploadError = document.getElementById("upload-error") as HTMLDivElement;
 
18
  const learnMoreButton = document.getElementById("about") as HTMLButtonElement;
 
 
19
 
20
  const engine = new Engine(canvas);
21
 
@@ -42,7 +47,7 @@ async function selectFile(file: File) {
42
  (progress: number) => {
43
  progressIndicator.value = progress * 100;
44
  },
45
- format,
46
  );
47
  progressDialog.close();
48
  } else {
@@ -91,11 +96,11 @@ async function main() {
91
  });
92
 
93
  downloadButton.addEventListener("click", () => {
94
- if (SelectionManager.selectedSplat !== null) {
95
- SelectionManager.selectedSplat.saveToFile();
96
- } else {
97
- engine.scene.saveToFile();
98
- }
99
  });
100
 
101
  controlsDisplayButton.addEventListener("click", () => {
@@ -125,7 +130,7 @@ async function main() {
125
  await SPLAT.PLYLoader.LoadAsync(
126
  url,
127
  engine.scene,
128
- (progress) => (progressIndicator.value = progress * 100),
129
  );
130
  progressDialog.close();
131
  } else {
@@ -135,6 +140,24 @@ async function main() {
135
  }
136
  });
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  learnMoreButton.addEventListener("click", () => {
139
  window.open("https://huggingface.co/spaces/dylanebert/gsplat-editor/discussions/1", "_blank");
140
  });
 
11
  const controlsDisplay = document.getElementById("controls-display") as HTMLDivElement;
12
  const uploadModal = document.getElementById("upload-modal") as HTMLDialogElement;
13
  const uploadModalClose = document.getElementById("upload-modal-close") as HTMLButtonElement;
14
+ const downloadModal = document.getElementById("download-modal") as HTMLDialogElement;
15
+ const downloadModalClose = document.getElementById("download-modal-close") as HTMLButtonElement;
16
  const fileInput = document.getElementById("file-input") as HTMLInputElement;
17
  const urlInput = document.getElementById("url-input") as HTMLInputElement;
18
  const uploadSubmit = document.getElementById("upload-submit") as HTMLButtonElement;
19
  const uploadError = document.getElementById("upload-error") as HTMLDivElement;
20
+ const downloadSubmit = document.getElementById("download-submit") as HTMLButtonElement;
21
  const learnMoreButton = document.getElementById("about") as HTMLButtonElement;
22
+ const splatRadio = document.getElementById("splat") as HTMLInputElement;
23
+ const plyRadio = document.getElementById("ply") as HTMLInputElement;
24
 
25
  const engine = new Engine(canvas);
26
 
 
47
  (progress: number) => {
48
  progressIndicator.value = progress * 100;
49
  },
50
+ format
51
  );
52
  progressDialog.close();
53
  } else {
 
96
  });
97
 
98
  downloadButton.addEventListener("click", () => {
99
+ downloadModal.style.display = "block";
100
+ });
101
+
102
+ downloadModalClose.addEventListener("click", () => {
103
+ downloadModal.style.display = "none";
104
  });
105
 
106
  controlsDisplayButton.addEventListener("click", () => {
 
130
  await SPLAT.PLYLoader.LoadAsync(
131
  url,
132
  engine.scene,
133
+ (progress) => (progressIndicator.value = progress * 100)
134
  );
135
  progressDialog.close();
136
  } else {
 
140
  }
141
  });
142
 
143
+ downloadSubmit.addEventListener("click", () => {
144
+ let format;
145
+ if (splatRadio.checked) {
146
+ format = "splat";
147
+ } else if (plyRadio.checked) {
148
+ format = "ply";
149
+ } else {
150
+ throw new Error("Unknown format");
151
+ }
152
+ const filename = "model." + format;
153
+
154
+ if (SelectionManager.selectedSplat !== null) {
155
+ SelectionManager.selectedSplat.saveToFile(filename, format);
156
+ } else {
157
+ engine.scene.saveToFile(filename, format);
158
+ }
159
+ });
160
+
161
  learnMoreButton.addEventListener("click", () => {
162
  window.open("https://huggingface.co/spaces/dylanebert/gsplat-editor/discussions/1", "_blank");
163
  });
editor/style.css CHANGED
@@ -150,7 +150,7 @@ progress::-moz-progress-bar {
150
  padding: 16px;
151
  border: 1px solid #888;
152
  width: 80%;
153
- max-width: 960px;
154
  color: #ddd;
155
  }
156
 
@@ -183,7 +183,7 @@ progress::-moz-progress-bar {
183
  margin: 0;
184
  }
185
 
186
- #upload-submit {
187
  width: 80px;
188
  background-color: #000;
189
  border: 1px solid #888;
@@ -193,11 +193,11 @@ progress::-moz-progress-bar {
193
  cursor: pointer;
194
  }
195
 
196
- #upload-submit:hover {
197
  background-color: #222;
198
  }
199
 
200
- #upload-submit:focus {
201
  outline: inherit;
202
  }
203
 
@@ -233,4 +233,33 @@ input[type="file"] {
233
  text-decoration: underline;
234
  cursor: pointer;
235
  pointer-events: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
 
150
  padding: 16px;
151
  border: 1px solid #888;
152
  width: 80%;
153
+ max-width: 768px;
154
  color: #ddd;
155
  }
156
 
 
183
  margin: 0;
184
  }
185
 
186
+ .submit {
187
  width: 80px;
188
  background-color: #000;
189
  border: 1px solid #888;
 
193
  cursor: pointer;
194
  }
195
 
196
+ .submit:hover {
197
  background-color: #222;
198
  }
199
 
200
+ .submit:focus {
201
  outline: inherit;
202
  }
203
 
 
233
  text-decoration: underline;
234
  cursor: pointer;
235
  pointer-events: auto;
236
+ }
237
+
238
+ #format-select {
239
+ display: flex;
240
+ align-items: center;
241
+ }
242
+
243
+ #format-select p {
244
+ margin-right: 8px;
245
+ }
246
+
247
+ #format-select div {
248
+ margin: 0 8px;
249
+ }
250
+
251
+ input[type="radio"] {
252
+ appearance: none;
253
+ display: inline-block;
254
+ width: 16px;
255
+ height: 16px;
256
+ padding: 3px;
257
+ background-clip: content-box;
258
+ border: 1px solid #888;
259
+ background-color: #000;
260
+ border-radius: 50%;
261
+ }
262
+
263
+ input[type="radio"]:checked {
264
+ background-color: #ddd;
265
  }