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

Allow viewing of models from shared link #4

Open
sinni800 opened this issue Mar 2, 2023 · 6 comments
Open

Allow viewing of models from shared link #4

sinni800 opened this issue Mar 2, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@sinni800
Copy link

sinni800 commented Mar 2, 2023

When a shared link is generated (/s/abcde), would it be possible to run the viewer there to be able to view the file as a user foreign to the Nextcloud instance?

Other plugins like Nextcloud Office are able to do so, too, but I have no idea how that functionality is faciliated.

@sinni800 sinni800 added the enhancement New feature or request label Mar 2, 2023
@kroko
Copy link
Member

kroko commented Mar 2, 2023

  1. Are you sharing 3D file directly? If so, which file format?
  2. Or are you sharing directory containing 3D file?

When single file is shared, the behaviour of nextcloud/viewer which this app taps into (both MIME handler and currently also MVC part) takes precedence. You can see that stuff behaves differently, try sharing single static image (png/jpg/whateva) for example, observe. For this app to show 3D model when single file is shared either
a) upstream (meaning nextcloud/viewer) changes are necessary
b) what I call iframe approach has to be chosen moving on, that I discuss in master readme. You can see that iframe approach works in your mentioned Collabora case or simpler example is nextcloud/files_pdfviewer that I studied and which, yes, still uses uses nextcloud/viewer for handler registering, but overwrites MVC (route + controller + template). Sharing single PDF file works like charm.

Meanwhile, if you share directory containing 3D model, it should work as expected (try iit, if not already). Moreover, I would always suggest sharing directory that contains 3D file, as one might forget, that many of 3D formats actually consume multiple files (i.e., if you would share .gltf file alone, unless it is embedded type, you're crewed 😄 , as it also needs .bin and all texture files that come separate; same for .obj that might need .mtl and texture files).

Your question is another reason to move to iframe approach, but that opens up issue discussed above - what if actually one needs multiple files to view the model as intended.

@sinni800
Copy link
Author

sinni800 commented Mar 2, 2023

It's an STL that is otherwise working with this app as expected.

When I share an image file, the share link will show that image as a preview, of course.

That preview is retrieved from the files_sharing app, then...

I dug into that and the JS side is what embeds the preview... And it only really checks image/video/text types https://github.com/nextcloud/server/blob/master/apps/files_sharing/js/public.js#L159 to embed the preview. If it's neither of that, that JS code cancels out and just puts the icon for the filetype by mime there.

I don't know how NextCloud office does it, it does a fullscreen open of the file in question. I would probably have to dig a bunch more to find that. But that's the iFrame approach you mention if I got that right?

But yes, if I share a folder it works as expected. If I don't have any additional files (textures, materials) though this is unnecessary and would necessiate making a folder to put the file into if you only want someone to look at that one file.

@kroko
Copy link
Member

kroko commented Mar 2, 2023

When I share an image file, the share link will show that image as a preview, of course.

but differently, as different view template is rendered by parent

But yes, if I share a folder it works as expected. If I don't have any additional files (textures, materials) though this is unnecessary and would necessiate making a folder to put the file into if you only want someone to look at that one file.

Sure, currently it is the way though.

Long story short - in order to achieve that if single 3D file is shared full preview is loaded one needs to override nextcloud/viewer template, by serving ones own. In order to render that template, one needs controller. In order to address controller one needs routing. I looked at all of this while creating this first version of the app and

Currently this app taps directly in nextcloud/viewer modal, as it was less code lines to mock it up.

...went the fastest way

I'd say I will make the necessary changes (rewrite this app using iframe with route + controller + template), but probably will have time for that in a few weeks.

@eric-schleicher
Copy link

+1 for this. I'm a fan of the iframe approach because it would also enable entirely custom loader/scenes based on the file being viewed..

i wish i could help make the changes.

@tristan-k
Copy link

+1 I'm looking forward to this feature.

@kroko
Copy link
Member

kroko commented May 15, 2024

so guys, i got some time for this on a coffee break.

sharing one file most likely will not work as 3D model usually is comprised of multiple files.
just think about .obj + .mtl + .tex. if you share .obj it will share the geometry, but the viewer has no way to access .mtl and .tex.
now theoretically a functionality could exist, which would need changes in nextcloud core, albeit that loosens the security and introduces clashes.

to give you idea.

  • plugin registers in NC -> i have a middleware for sharing file types of, say.obj, .gltf
  • output of this middleware is list of connected files that have to be shared too
  • whenever user clicks on "share this .obj file", it is passed to middleware register
  • register checks if any plugin(s) is responsible to do smth about it
  • it finds the plugin
  • the plugin on serverside(!) parses .obj, .gltf whatever files for baked in references (materials, textures)
  • the plugin actually checks if those files exist
  • the plugin returns to NC list of connected files
  • NC alerts user, hey you wanted to share this .obj file, but it depends on these .mtl and bunch of these .jpg files too
  • NC asks do you want to share only the .obj file or also all the connected files
  • if all connected files checked, then you get that all the files ar publically accessibe and viewing of models from shared link works. like you can share the file itself and clicking on the share link would open up the viewer (just like for PDF for example)

no such mw exists in NC. thus as of now - if your files are not self contained (such as .glb or files that only have geometry), you have to share the directory.

iframe is still on the table though, as that still has benefits, just haven't got time for that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants