Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse mesh url from url-param search query to load https://f3d.app/web?mesh={mesh_url} #1595

Closed
jo-chemla opened this issue Aug 28, 2024 · 10 comments
Labels
source:F3DWeb type:enhancement New feature or request

Comments

@jo-chemla
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Long-time f3d user, however I just discovered the https://f3d.app/web WASM build which does look great so thanks a lot! It would be great if one could pass to the viewer a url-param which indicates a mesh file to load.

Describe the solution you'd like
f3d could parse mesh url given search query like the following: https://f3d.app/web?mesh={mesh_url}
Regarding at how the webassembly/app.html loads supported meshes on file select, it seem that this could be hacked to initially load a model if the urlparam search query is detected.

Some os urlparams seem to be parsed here, but only to know which os to look for the wasm build.

Describe alternatives you've considered
3dviewer.net does it this way - although a weird hash # replaces the question-mark in the search-query: https://3dviewer.net/#model=${mesh_url}.

Additional context
This would make it easier to inspect mesh files lying accessible on the web via a server endpoint using f3d. My interest is integrating f3d within STAC-browser (Spartio-Temporal Asset Catalogs) which is made to explore and standardize geospatial assets, among which meshes are an important part - see PR here for context

Contribution
Would love to contribute, although I don't know mulch about the f3d codebase. Would need some pointers, the implementation probably has to happen in the app.html file, but building/bundling the wasm seem hard once implementation is finished.

@snoyer
Copy link
Contributor

snoyer commented Aug 28, 2024

This would be a nice improvement indeed!

although a weird hash # replaces the question-mark in the search-query: 3dviewer.net#model=${mesh_url}.

Doing it with a hash seems better in this case actually. If there was anything to do server side we'd need to pass the parameters in the ? part of the URL, but in this case everything is local so we can use the # part that doesn't get send to the server and can be reacted to without reloading the page.

Basically, after the page is loaded and the viewer is set up, the script would look after the # for a model url and download it (locally on the client). Then if you changed the page url from f3d.app/web/#foo.glb to f3d.app/web/#bar.glb the script would be able to detect it and just download the new model without the whole page being refreshed.

Would love to contribute, although I don't know mulch about the f3d codebase. Would need some pointers, the implementation probably has to happen in the app.html file, but building/bundling the wasm seem hard once implementation is finished.

I believe @Meakk recently improved the build/packaging of the wasm version so he may be able to get you started. You may even be able to get away with editing app.html and serving it along the prebuild version of the wasm package win any local http server.

@Meakk
Copy link
Member

Meakk commented Aug 28, 2024

Some os urlparams seem to be parsed here, but only to know which os to look for the wasm build.

This code is only used to recommend the correct download on the Website, it's unrelated to F3D web.

Regarding at how the webassembly/app.html loads supported meshes on file select, it seem that this could be hacked to initially load a model if the urlparam search query is detected.

Sounds like a good idea. You have to download the file to a Uint8Array and write it to the internal filesystem like it's done here

I don't know the implementation details (maybe this page could help?), it's more about web development knowledge than F3D codebase knowledge at this point (and nobody is a web developer in regular contributors as far as I know)

If you want to give it a try, you can build and test F3D WASM very easily by following the guide (Linux, Docker and npm required)

@jo-chemla
Copy link
Contributor Author

Thanks both for the helpers. I just implemented the suggested changes that I think should allow parsing of a mesh urlparam, but I could not test it on my setup (docker and npm are installed, but I have a windows machine, also tried with WSL and git-bash with no luck).

Here are the suggested changes

master...jo-chemla:f3d:master

Should I make a PR to include them? Thanks!

@Meakk
Copy link
Member

Meakk commented Aug 28, 2024

Should I make a PR to include them? Thanks!

Yes please :)
I'll try it locally and let you know if it works.

@jo-chemla
Copy link
Contributor Author

For those stumbling here, implementation is done and PR awaiting merge here! #1596
Thanks you all for the feedback during implementation!

@jo-chemla
Copy link
Contributor Author

jo-chemla commented Sep 4, 2024

PR just got merged and is live, thanks to everyone for the feedback!
🚀

https://f3d.app/web/#model=${modelUrl}
more resilient at parsing mesh extension than 3dviewer.net (via either url extension, response contentDisposition header or user-provided extension)!

@github-project-automation github-project-automation bot moved this from Investigate to Done in F3D Sep 4, 2024
@mwestphal
Copy link
Contributor

mwestphal commented Sep 5, 2024

Hey @jo-chemla , We have been discussing on discord possible improvements, but it looks like you did not finish onboarding there so I cant add you to that discussion, do you wanna try communicate there ?

https://discord.f3d.app

@jo-chemla
Copy link
Contributor Author

jo-chemla commented Sep 5, 2024

Hi @mwestphal, I'll try to have a look but I avoid my discord which is pretty overloaded. If you want to summarize the discussion in this thread for possible improvements, please don't hesitate!

Just accepted your request though!

@mwestphal
Copy link
Contributor

If you want to summarize the discussion in this thread for possible improvements, please don't hesitate!

Definitely, discord is not great for feature discussion.

@jo-chemla
Copy link
Contributor Author

jo-chemla commented Sep 5, 2024

Created a new thread to track these improvements
#1604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source:F3DWeb type:enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants