|
145 | 145 | reversePointerDir: false, |
146 | 146 | reversePointerSlide: false, |
147 | 147 | backgroundColor: "#000000", |
| 148 | + viewBoundingBox: false, |
148 | 149 | openFiles: () => { |
149 | 150 | fileInput.click(); |
150 | 151 | }, |
|
340 | 341 |
|
341 | 342 | async function loadFiles(splatFiles) { |
342 | 343 | if (guiOptions.resetOnLoad) { |
343 | | - const toRemove = frame.children.filter((child) => child instanceof SplatMesh); |
| 344 | + const toRemove = frame.children.filter((child) => child instanceof SplatMesh || child instanceof THREE.Box3Helper); |
344 | 345 | for (const child of toRemove) { |
345 | 346 | frame.remove(child); |
346 | 347 | } |
|
403 | 404 | } |
404 | 405 | frame.add(splatMesh); |
405 | 406 | console.log(`Loaded ${fileName} with ${splatMesh.numSplats} splats`); |
| 407 | + addBoundingBoxHelper(splatMesh); |
406 | 408 |
|
407 | 409 | const splatFolder = splatsFolder.addFolder(fileName).close(); |
408 | 410 | splatFolder.add(splatMesh, "opacity", 0, 1, 0.01).name("Opacity").listen(); |
|
433 | 435 | canvas.focus(); |
434 | 436 | } |
435 | 437 |
|
| 438 | + async function addBoundingBoxHelper(splatMesh) { |
| 439 | + await splatMesh.initialized; |
| 440 | + const box = splatMesh.getBoundingBox(); |
| 441 | + const boxHelper = new THREE.Box3Helper(box, 0x00ff00); |
| 442 | + boxHelper.visible = guiOptions.viewBoundingBox; |
| 443 | + frame.add(boxHelper); |
| 444 | + } |
| 445 | + |
436 | 446 | secondGui.add(guiOptions, "resetOnLoad").name("Reset on load"); |
437 | 447 | secondGui.add(guiOptions, "loadOffset", -2, 2, 0.01).name("Loading offset"); |
438 | 448 | secondGui.add(guiOptions, "openFiles").name("Select Files"); |
|
502 | 512 | const debugFolder = gui.addFolder("Debug").close(); |
503 | 513 | const normalColor = dyno.dynoBool(false); |
504 | 514 | debugFolder.add(normalColor, "value").name("Normal color").onChange(() => updateFrameSplats()); |
| 515 | + debugFolder.add(guiOptions, "viewBoundingBox").name("View bounding boxes").onChange((viewBoundingBox) => { |
| 516 | + frame.children.forEach((child) => { |
| 517 | + if (child instanceof THREE.Box3Helper) { |
| 518 | + child.visible = viewBoundingBox; |
| 519 | + } |
| 520 | + }); |
| 521 | + }); |
505 | 522 |
|
506 | 523 | debugFolder.add(spark, "maxStdDev", 0.1, 3.0, 0.01).name("Max Gsplat stddev").listen(); |
507 | 524 | debugFolder.add(spark, "falloff", 0, 1, 0.01).name("Gaussian falloff").listen(); |
|
688 | 705 | } |
689 | 706 |
|
690 | 707 | const instructions = makeInstructions(); |
| 708 | + addBoundingBoxHelper(instructions); |
691 | 709 | frame.add(instructions); |
692 | 710 |
|
693 | 711 | // Load URLs from query parameters if any |
|
0 commit comments