WARP-LAB / files_3dmodelviewer

3D Model Viewer for Nextcloud
GNU Affero General Public License v3.0
31 stars 6 forks source link

Allow viewing of models from shared link #4

Open sinni800 opened 1 year ago

sinni800 commented 1 year ago

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.

kroko commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 4 months ago

+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 commented 2 months ago

+1 I'm looking forward to this feature.

kroko commented 1 month ago

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.

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.