gdcc / dataverse-previewers

A collection of Datafile Previewers that can be configured to work with Dataverse
MIT License
5 stars 15 forks source link

Initial implementation of a X3D previewer with the X_ITE library #56

Closed PaulBoon closed 3 months ago

PaulBoon commented 4 months ago

Adds a previewer for the x3d format (mime type: model/x3d+xml) using the X_ITE library. Using that library potentially many other formats can be rendered. Other libs I tried where x3dom and three.js, X_ITE was the simplest to use.

Solves part of https://github.com/gdcc/dataverse-previewers/issues/55

Example (screendump):

Screenshot from 2024-04-20 15-04-17

Tips for testing: Use the famous teapot model: https://www.web3d.org/x3d/content/examples/Basic/CAD/CadTeapot.x3d

pdurbin commented 4 months ago

@PaulBoon thanks for the pull request! I'm not sure if you say my post on the google group, but we are definitely in the market for a 3D viewer! Please see also:

qqmyers commented 4 months ago

@PaulBoon - in terms of a PR - the v1.4 previewers dir is intended to be frozen (so that people deploying from the gdcc repo don't see any changes). If you make your changes in the betatest dir, they are available once merged, and will also get added to the 1.5 version when that comes out.

landreev commented 4 months ago

@PaulBoon very cool! In addition to "contentType":"model/x3d+xml", do you think this previewer could be used on all, or any of the other formats listed at https://create3000.github.io/x_ite/ under "Supported File Formats"?

PaulBoon commented 3 months ago

Thanks for those positive comments, I will update my 'Draft' to use a 1.5 directory and have a look at more types + test with larger models.

qqmyers commented 3 months ago

@PaulBoon - just use /previewers/betatest - I'll copy everything there to a 1.5 dir when we release a new version.

PaulBoon commented 3 months ago

OK, I fixed some things so now it should work with more mimetypes:

I moved the 'code' to the 'betatest' folder, but those curl calls reference 1.4, so you would have to move the to the 1.4 folder when testing or change that curl.

PaulBoon commented 3 months ago

After downloading some example files for testing those mimetypes, I discovered that the preview does not always render them optimally. My expectations for a good previewer are that the initial rendering of a loaded file does try to let me see the model, by manipulating the viewport and lighting etc. for me. This does not always work, sometimes the model is far away, and I have to zoom in first. Other times the model is out of sight completely or the shading isn't helpful.

Downloaded sample files from MeshLab at: https://www.meshlab.net/data/sample_meshes.zip For glTF files I found this: https://github.com/KhronosGroup/glTF-Sample-Models/blob/main/2.0/README.md

PaulBoon commented 3 months ago

I just downloaded MRIPAS_coll_170974_VulpesVulpes_2017_F_jaw_scan3D.stl from https://dataverse.openforestdata.pl/dataset.xhtml?persistentId=doi:10.48370/OFD/Y8TNUO. This DV has a 3D viewer. If I use the X3Dviewer I have to zoom out first, but then it renders fine.

qqmyers commented 3 months ago

OK - I'll merge to make it easier for people to test. If there's further work to set a useful initial default view or something, just create a new PR. Thanks for the viewer - lots of people are interested!