gigascience / gigadb-website

Source code for running GigaDB
http://gigadb.org
GNU General Public License v3.0
9 stars 15 forks source link

Visualize 3D models locally without relying on sketchfab iframe #2091

Open luistoptal opened 1 day ago

luistoptal commented 1 day ago

Pull request for issue: #2054

This is a pull request for the following functionalities:

How to test?

The following steps describe how I test this widget locally (if you know of a better way, please be my guest and I would love to know 🙂):

image

You can test error states if you repeat the above process by adding a file that is not a valid 3d model or not a LAS, STL, PLY or OBJ file (or you can just add a throw new Error('Ooops') in the line before await loadModel(file);)

Example of error message:

image

How have functionalities been implemented?

3D models were previously visualized within an iframe taking a sketchfab url as input. This PR gets rid of the sketchfab iframe and replaces it with a JS widget that makes use of the three.js library to load and display an interactive 3D model

The main requirement is to load STL and OBJ file formats, and also (less common) PLY and LAS

Different options to locally load the model were considered (refer to the original ticket for some). I decided to use three.js because:

Other options I checked had very low or null adoption and / or did not fully cover the use case. I opted for the widely adopted solution.

The changes can be grouped as follows:

That covers all the changes outside of the protected/js/model-viewer folder, now related to the widget itself

Any issues with implementation?

Any changes to automated tests?

All tests pass