Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@
/jsplat-io-spz/.settings
/jsplat-io-spz/.classpath

/jsplat-io-spz-gltf/target
/jsplat-io-spz-gltf/.project
/jsplat-io-spz-gltf/.settings
/jsplat-io-spz-gltf/.classpath
/jsplat-io-gltf/target
/jsplat-io-gltf/.project
/jsplat-io-gltf/.settings
/jsplat-io-gltf/.classpath

/jsplat-io-gltf-spz/target
/jsplat-io-gltf-spz/.project
/jsplat-io-gltf-spz/.settings
/jsplat-io-gltf-spz/.classpath

/jsplat-viewer/target
/jsplat-viewer/.project
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Java libraries for Gaussian splats.
- [`jsplat-io-gsplat`](./jsplat-io-gsplat) - [gsplat](https://github.com/antimatter15/splat) format
- [`jsplat-io-ply`](./jsplat-io-ply) - PLY files
- [`jsplat-io-spz`](./jsplat-io-spz) - [SPZ](https://github.com/nianticlabs/spz) format
- [`jsplat-io-spz-gltf`](./jsplat-io-spz-gltf) - glTF with [`KHR_spz_gaussian_splats_compression`](https://github.com/KhronosGroup/glTF/pull/2490)
- [`jsplat-io-gltf`](./jsplat-io-gltf) - glTF with [`KHR_gaussian_splatting`](https://github.com/KhronosGroup/glTF/pull/2490)
- [`jsplat-io-gltf-spz`](./jsplat-io-gltf-spz) - glTF with [`KHR_spz_gaussian_splatting_compression_spz_2`](https://github.com/KhronosGroup/glTF/pull/2531)

A basic viewer implementation can be found in [`jsplat-viewer`](./jsplat-viewer),
with the actual implementation based on LWJGL in [`jsplat-viewer-lwjgl`](./jsplat-viewer-lwjgl).
Expand Down
7 changes: 6 additions & 1 deletion jsplat-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
</dependency>
<dependency>
<groupId>de.javagl</groupId>
<artifactId>jsplat-io-spz-gltf</artifactId>
<artifactId>jsplat-io-gltf-spz</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.javagl</groupId>
<artifactId>jsplat-io-gltf</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* www.javagl.de - JSplat
*
* Copyright 2025 Marco Hutter - http://www.javagl.de
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package de.javagl.jsplat.app;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

import de.javagl.common.ui.GuiUtils;

/**
* A base class for a panel that serves as an accessory for the save file
* chooser, enabled based on the current file extension.
*/
class ExtensionBasedSaveOptions extends JPanel
{
/**
* Serial UID
*/
private static final long serialVersionUID = 370867818308684812L;

/**
* The file chooser
*/
private JFileChooser fileChooser;

/**
* The extension that should cause this panel to become enabled, including
* the dot.
*/
private String extensionWithDot;

/**
* The file name text field, obtained from the file chooser (quirky)
*/
private JTextField fileNameTextField;

/**
* Creates a new instance
*
* @param fileChooser The file chooser
* @param title The title
* @param extensionWithDot The file extension, including the dot
*/
ExtensionBasedSaveOptions(JFileChooser fileChooser, String title,
String extensionWithDot)
{
super(new BorderLayout());
this.fileChooser = fileChooser;
this.extensionWithDot = extensionWithDot.toLowerCase();

setBorder(BorderFactory.createTitledBorder(title));

fileChooser.addPropertyChangeListener(e -> updateOptions());

fileNameTextField = findFileNameTextField(fileChooser);
installDocumentListener();

updateOptions();
}

/**
* Install a document listener to the file name text field to update the
* options when the file name changes
*/
private void installDocumentListener()
{
if (fileNameTextField == null)
{
return;
}
Document document = fileNameTextField.getDocument();
document.addDocumentListener(new DocumentListener()
{
@Override
public void removeUpdate(DocumentEvent e)
{
updateOptions();
}

@Override
public void insertUpdate(DocumentEvent e)
{
updateOptions();
}

@Override
public void changedUpdate(DocumentEvent e)
{
updateOptions();
}
});
}

/**
* Returns the current file name from the file name text field
*
* @return The file name
*/
private String getCurrentFileName()
{
if (fileNameTextField != null)
{
return fileNameTextField.getText();
}
File file = fileChooser.getSelectedFile();
if (file != null)
{
return file.toString();
}
return null;
}

/**
* Update the options based on the current file name
*/
private void updateOptions()
{
String fileName = getCurrentFileName();
if (fileName == null)
{
GuiUtils.setDeepEnabled(this, false);
return;
}
boolean isPly = fileName.toLowerCase().endsWith(extensionWithDot);
GuiUtils.setDeepEnabled(this, isPly);
}

/**
* Find the first text field in the given container, returning
* <code>null</code> if none is found
*
* @param container The container
* @return The text field
*/
private static JTextField findFileNameTextField(Container container)
{
for (Component component : container.getComponents())
{
if (component instanceof JTextField)
{
return (JTextField) component;
}
else if (component instanceof Container)
{
Container childContainer = (Container) component;
JTextField textField = findFileNameTextField(childContainer);
if (textField != null)
{
return textField;
}
}
}
return null;
}

}
91 changes: 91 additions & 0 deletions jsplat-app/src/main/java/de/javagl/jsplat/app/GlbSaveOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* www.javagl.de - JSplat
*
* Copyright 2025 Marco Hutter - http://www.javagl.de
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package de.javagl.jsplat.app;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
* A panel that serves as an accessory for the save file chooser, to select the
* compression that should be applied in GLB files
*/
class GlbSaveOptions extends ExtensionBasedSaveOptions
{
/**
* Serial UID
*/
private static final long serialVersionUID = 37867883086984812L;

/**
* The button for no compression
*/
private JRadioButton noneButton;

/**
* The button for SPZ compression
*/
private JRadioButton spzButton;

/**
* Creates a new instance
*
* @param fileChooser The file chooser
*/
GlbSaveOptions(JFileChooser fileChooser)
{
super(fileChooser, "GLB save options", ".glb");

noneButton = new JRadioButton("No compression");
noneButton.setSelected(true);
spzButton = new JRadioButton("SPZ compression");

ButtonGroup group = new ButtonGroup();
group.add(noneButton);
group.add(spzButton);

JPanel panel = new JPanel(new GridLayout(0, 1));
panel.add(noneButton);
panel.add(spzButton);
add(panel, BorderLayout.NORTH);
}

/**
* Returns whether SPZ compression should be applied
*
* @return The state
*/
boolean shouldApplySpzCompression()
{
return spzButton.isSelected();
}

}
Loading