WordPress / openverse-frontend

The gateway to the Openverse. Openverse is a search tool for CC-licensed and public domain content across the internet.
https://wordpress.org/openverse
MIT License
71 stars 63 forks source link

[RFC] Frontend 3D Model Support #889

Closed zackkrida closed 2 years ago

zackkrida commented 2 years ago

Note: this proposal will be preceded by RFCs in the API and Catalog repositories. That work should be started, or at least outlined, prior to this work.

3D Models in the Openverse Frontend

Openverse will add first-class support for 3D models, alongside audio and images. This means 3D models will have their own table in the Catalog, and their own API endpoints. Adding these to the frontend will require some new components and utilities, but should be more straightforward than the implementation of audio because we are not conducting a complete redesign of the site in parallel.

This outline of work is predicated on the idea that we've identified sources of 3D models, and determined the list of metadata fields we need for each model. Basically, this plan talks about the literal, technical frontend implementation of this feature once we've figured out all of the more product-focused details.

Some potential risks

Prior Art

Some code considerations

Technical implementation

1. Add 3D Models to Meta Search

Prerequisites

Todos

2. Setup the data for 3D models

3. Implement new 3D model UI

Prerequisites

Design work for the new components must be completed, or at least in a good enough place that we decide work can begin.

Todos

Open Questions

AetherUnbound commented 2 years ago

When a unique identifier is necessary, we should use the string constant 'MODELS' to refer to 3D models. Compare this to AUDIO for audio files, for example.

Ha, the plural versions of these words are throwing me off :sweat_smile: That means we'll have IMAGES, MODELS, and AUDIO, correct?

zackkrida commented 2 years ago

@AetherUnbound that's such helpful feedback, I was sloppy about pluralization. I've changed the constant to THREE_D_MODEL to be singular and more explicit, and fixed other pluralization inconsistencies in the proposal.

AetherUnbound commented 2 years ago

Awesome, thanks! Maybe we could do MODEL_3D? 😁

zackkrida commented 2 years ago

...that's also much better haha!

sarayourfriend commented 2 years ago

Thanks for writing this up! It's exciting to consider all the new media types. My go-to "birds" search is going to get a lot more diverse and interesting :slightly_smiling_face:

Basically, this plan talks about the literal, technical frontend implementation of this feature once we've figured out all of the more product-focused details

Do we need to discuss the catalog and API side of things as well? Identifying the metadata fields we'd like to try to obtain for each 3D model, how to structure the API, and whether we'd want to somehow integrate the 3D models into the thumbnail cache all jump out to me as things that would be good to discuss up front along with the frontend implementation (or potentially before/alongside as a separate RFC that would inform the frontend implementation).

This mostly comes from an inclination (from experience) that frontend implementation plans are not very good drivers for backend API design; that is, designing a general API with optional specific enhancements required by the frontend, might be a better place to start and could uncover specific hurdles we'd need to cross in the frontend that won't be obvious until we've discussed the API. Audio was this way for example with the long discussions about the alt_files being informed by frontend data needs but also having to happen all the way at the catalog level (i.e., early in the implementation process).

We'll need to find a standardized 3d model viewer that will work with various formats. We really, really don't want to write our own code here. We will also need to decide if we want to use this universally, or use SketchFab's viewer for SketchFab models, which is an excellent viewer.

I would really really like to avoid SketchFab's viewer if possible.

  1. It is not free software
  2. It has much looser/worse privacy guarantees than we've tried to achieve with Openverse so far

On the other hand, their viewer is extremely convenient and works very well.

In a brief search I found this js-3d-model-viewer library that is MIT licensed. It's not great, but I wonder if we could help improve it and add some of the features we might want (like UI buttons for controlling zoom when a mousewheel isn't available, recentering, snapping to specific axis, etc).

Currently it only support OBJ files though and has poor texture support (the latter of which is something we could probably spend some time contributing against). These might be unacceptable limitations though.

I guess it depends on how much upfront work we're willing to do for this or if it's something we'd rather just get out the door and be able to move on to video.

3D model support should be enabled via a feature flag

Do we have a good way of manipulating feature flags? Do we need to add something to Django for this or is it already configured? If not, it could be nice to add something like waffle to manage these. At minimum I'd say we should be able to enable the feature per-host (i.e., turn it on in staging but off in production) all via the API rather than a deployment or some other thing like that.

Alternatively we could just rely on deployments and use nuxt-feature-toggle. Worst case we could just use a query param that toggles it on.

My vote is for the query param, but it'd be nice to have a recommendation in the RFC for this.

zackkrida commented 2 years ago

Do we need to discuss the catalog and API side of things as well?

Definitely, @AetherUnbound signed up to do the full 3D model feature RFC so I focused solely on the frontend. A lot of this has been floating in my brain for a bit so I wanted to get it out. I do think it makes sense to do the Catalog and API implementations a bit before the frontend.

Regarding viewers, I chatted a bit with @antpb today who works on wp core media, but also around open source projects tackling standardizing 3D content performance, and might have some recommendations for us here 😄

The suggestion to think about feature flagging is really welcome, and probably warrants its own RFC. I like the idea of a query param approach and maybe writing some helpers:

Historically we've done it with env vars and deploys.

sarayourfriend commented 2 years ago

Definitely, @AetherUnbound signed up to do the full 3D model feature RFC so I focused solely on the frontend. A lot of this has been floating in my brain for a bit so I wanted to get it out. I do think it makes sense to do the Catalog and API implementations a bit before the frontend.

Oh! Sorry, I totally missed this piece of information. That sounds great then :+1:

Regarding viewers, I chatted a bit with @antpb today who works on wp core media, but also around open source projects tackling standardizing 3D content performance, and might have some recommendations for us here smile

Yes! That's awesome. I'd love it if we could help promote those projects and also contribute new features and bug reports :nerd_face:

Feature flags ... and probably warrants its own RFC

For sure, it could be a nice small one I think :slightly_smiling_face:

AetherUnbound commented 2 years ago

Another question, do we need to distinguish between 3D models specifically, or just models in general? For instance, this resource has both 2D and 3D models that are CC licensed: https://kenney.nl/assets?q=2d

sarayourfriend commented 2 years ago

@AetherUnbound I think the 2d stuff there would be classified as textures, not models, right? Though I guess some of those are sprite sheets which aren't exactly textures (that'd be more of an implementation detail).

Maybe "model" by itself is the right way to go.

I was thinking about textures as well, those would probably just fall under our regular image content type (they have all the same metadata like resolution) but potentially as a distinct category. Sprite sheets wouldn't make sense in the images content type; sprite sheet dimensions aren't really relevant, they probably have a whole different set of interesting criteria people would want to filter by.

From a UI perspective it'd be nice to at least be able to filter by them... and I think from a viewer perspective it'd be nice for sprite sheets to have something to zoom and pan around the sheet.

AetherUnbound commented 2 years ago

That totally makes sense @sarayourfriend! I think having them fall under image with a different category works great.

AetherUnbound commented 2 years ago

Closing in favor of WordPress/openverse#171