v1r0x / files_3d

GNU Affero General Public License v3.0
33 stars 9 forks source link

Adding support for more formats like *.stl, *.dxf and so on? #1

Closed e-alfred closed 2 years ago

e-alfred commented 5 years ago

Hello,

this is an awesome app with a lot of potential! I think it should support a few more formats like .stl and .dxf and possibly even more so it can be a more versatile file viewer for Nextcloud. What do you think?

v1r0x commented 5 years ago

Thank you! :blush:

Yes, new formats and features are always very welcome. I only added the formats I know/use to get a working version and see if it's useful.

You can browse the examples to see which loaders are supported. Looks like stl is supported, but dxf not (or it has a different name).

v1r0x commented 5 years ago

I added .stl support in the more-loaders branch. You have to add stl to the mimetypemapping (readme updated) to make it work. Material is hard-coded, since stl only supports the model(?)

e-alfred commented 5 years ago

Hello,

thanks for consideration! I already looked into this and for *.dxf there is a 3rd-party loader available (actually more than one but I think this is the best supported):

https://github.com/gdsestimating/three-dxf https://www.npmjs.com/package/three-dxf https://devhub.io/repos/gdsestimating-three-dxf

With a *.dxf viewer this app idea could be finally solved:

https://help.nextcloud.com/t/cad-files-and-drawings/24079

v1r0x commented 5 years ago

Unfortunately, this one is only based on three.js, but not a plugin. It ships with it's own version of three.js.

I found a "real" loader for three.js (https://github.com/Gerdon262/DXFLoader). I had to build some stuff around to get it working, but at least it works! Best would be to update/fork this loader and fix it.

I added it to the loaders branch. If you could test it, to see if it's working correctly, we can discuss what to do with it.

e-alfred commented 5 years ago

I tried it out with a few simple .dxf and .stl files but it shows only the grid and nothing else. The DXFLoader throws no error in the browser console, although for 2d files rotation doesn't seem to be necessary.

v1r0x commented 5 years ago

Do you have some sample screenshots and files how it should look like so I can play around with the importert?

e-alfred commented 5 years ago

Here are two files in a Zip archive (Github doesn't allow other file types). Both are just a few lines created in Librecad. Here is a screenshot how they should look like:

image

image

796638b5-ea4d-47bb-b48b-ebb6eb1cd2d9.zip

v1r0x commented 5 years ago

Thanks for the files! Seems like they were always there, but with black color :laughing: I set a light gray as default color.

Are dxf always 2D? Otherwise I don't know how to determine if an object is 2D or 3D and lock rotation or not.

You have to zoom out a bit to see the object. I think repositioning the object or camera would be good.

e-alfred commented 5 years ago

There seems to be some 3d support for *.dxf, but it is not really common.

Can you also set the color to grey for *.stl files? Those don't show up either.

It would be great to be able to zoom in on the object by default so it fits on the display. Currently the object doesn't fit in usually (either too small or too big) and a lot of zooming is needed.

I think the app should have some kind of controls to control zoom/rotation/etc in the future. It would make the handling much easier. An option to turn off the grid would be useful as well if needed to have an unobstructed view of the object.

v1r0x commented 5 years ago

.stl worked for me as my test files already had gray background, but makes sense to set their default color to gray as well.

For the other things, I think datgui (which threejs already uses for the examples) is a good solution. I'd go with the following setup:

kkremitzki commented 5 years ago

It would be very cool to somehow add support for FreeCAD .fcstd files one day, although it would probably be a big undertaking. Here's a related project for reference: https://www.npmjs.com/package/node-occ

wwwwiii commented 5 years ago

Are .dwg files supported and can they be viewed within nextcloud? Is there already a worked app that i can upload.

Thanks in advance!

PhuriousGeorge commented 5 years ago

This is exactly what I was looking for! Working to get it on my instance, can't wait for these updates to be released

ldrrp commented 4 years ago

When can this be merged to master to support the meme type mapping changes made in master recently. I would like to have stl support.

v1r0x commented 4 years ago

I'm currently working on a version with nc viewer integration. When this is done, I'll go through the current open issues and fix/merge them. Doesn't take too long hopefully :wink:

ldrrp commented 4 years ago

Thank you, i cant contribute code at this time but i can buy you a coffee :)

"You've sent €5.00 EUR to sc*****o@web.de" Found your email on another forum

v1r0x commented 4 years ago

Thank you very much! Much appreciated! :tada: :blush:

I'm curious: which forum? :grin:

ldrrp commented 4 years ago

Xda

wwwwiii commented 4 years ago

What about .dwg files support?

v1r0x commented 4 years ago

@wwwwiii Unfortunately, there is no loader for dwg available. So I can't support it in this app.

@ldrrp and @e-alfred I added stl to the current viewer branch, but it's not loaded at all. The default browser download action is shown. (To test it you also need a patched version of nc viewer) Maybe @awesome-manuel knows what's up?

kkremitzki commented 4 years ago

What about https://www.gnu.org/software/libredwg/?

v1r0x commented 4 years ago

Something like that would be possible, yes. All unsupported files by threejs could be converted on php side and then loaded using a supported format. But this could lead to heavy load on the server, if many users load unsupported formats at the same time.

ldrrp commented 4 years ago

Ahh thats interesting, I figured you would have made your own viewer. IDK much of the inner workings of nextcloud. I was gonna clone the files_pdfviewer repo and change the js to three.js but then found this repo. Ill give this a shot after cloning that viewer repo, i have a feeling that makefile viewer has is gonna hate me

wwwwiii commented 4 years ago

Just need big hardware thats fine:) would be nice though :)

e-alfred commented 4 years ago

I don't think it could be more power hungry than for example video/audio conversion done by other Nextcloud apps (https://apps.nextcloud.com/apps/video_converter), rather the conversion quality could be a problem because DWG is a pretty proprietary format sadly.

ldrrp commented 4 years ago

so the new viewer patch is requiring nextcloud 19 :P, i might just have to wait.

v1r0x commented 4 years ago

I don't think it could be more power hungry than for example video/audio conversion done by other Nextcloud apps (https://apps.nextcloud.com/apps/video_converter), rather the conversion quality could be a problem because DWG is a pretty proprietary format sadly.

there are (at least) two approaches to use a converter:

  1. convert the file and save it (less power hungry because you only have to do it once per file)
  2. convert the file temporarily and send it back to the client (has to be converted each time the file is opened)

I was talking about approach 2, because it doesn't add new files the user didn't want (or didn't know how this works). IMO the best would be to add an extra app for approach 1 (like video_converter) and recommend this for opening unsupported files

msegec commented 4 years ago

v1r0x, Mate, Love your work, but as a gent mentioned a few posts back, v19 is needed :)

WIlling to pay you for your time to get some last minute tasks done, or to help me integrate three.js and potree into NC.

CoreyBurger commented 4 years ago

I'd be willing to kick in some money for this too - about to have a local NC install for backup and having this would make organizing my STLs so much easier

v1r0x commented 4 years ago

Thank you both for your offer 😊 I have some other things to do and not much time to support this app that much, unfortunately. So I don't want to waste your money, but I really appreciate it! I plan to work on a release for NC 19 in the coming days. STL support shouldn't be that hard to add, as it is already supported by three.js. I'll let you know if the release is ready :)

v1r0x commented 4 years ago

Hey folks, I finally managed to fix the last couple of small things for a new release :tada: STL is now supported. You should be able to use the current master branch or 0.2.0 release in your instances. Appstore release might take a while, due to code signing.

msegec commented 4 years ago

Dang. I'm a freaking noob these days, I haven't even worked out how to copy files from my windows OS to my docker NC instance... Heh.

On Wed, 1 Jul 2020, 5:17 pm Vinzenz Rosenkranz, notifications@github.com wrote:

Hey folks, I finally managed to fix the last couple of small things for a new release 🎉 STL is now supported. You should be able to use the current master branch or 0.2.0 release in your instances. Appstore release might take a while, due to code signing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/v1r0x/files_3d/issues/1#issuecomment-652300121, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWGYCWI6UI4SRRS7OW7HITRZL5LFANCNFSM4GOROXJQ .

msegec commented 4 years ago

Also thank you so much though!

How can I send you something for a beer, coffee, vodka or gin.... Haha

On Wed, 1 Jul 2020, 5:19 pm Mark Segec, marksegec@gmail.com wrote:

Dang. I'm a freaking noob these days, I haven't even worked out how to copy files from my windows OS to my docker NC instance... Heh.

On Wed, 1 Jul 2020, 5:17 pm Vinzenz Rosenkranz, notifications@github.com wrote:

Hey folks, I finally managed to fix the last couple of small things for a new release 🎉 STL is now supported. You should be able to use the current master branch or 0.2.0 release in your instances. Appstore release might take a while, due to code signing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/v1r0x/files_3d/issues/1#issuecomment-652300121, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWGYCWI6UI4SRRS7OW7HITRZL5LFANCNFSM4GOROXJQ .

v1r0x commented 4 years ago

Dang. I'm a freaking noob these days, I haven't even worked out how to copy files from my windows OS to my docker NC instance... Heh.

:grinning: That's why my testing instance is running on an old school apache :sweat_smile: You could try something like docker exec nextcloud wget .... Not sure if that's the exact command, but something like that could work (as long as wget is installed). But then you also have to run npm inside your docker container... I think it's easier to wait for the appstore release. I try to release it during the weekend.

Also thank you so much though! How can I send you something for a beer, coffee, vodka or gin.... Haha

You're welcome. Glad this app is helpful :) You really don't have to :wink: But you can use my PP account (connected to my mail address in the appinfo file). Don't really have something proper for donations :sweat_smile:

v1r0x commented 4 years ago

New build is released on https://apps.nextcloud.com :tada:

msegec commented 4 years ago

Okay, now I definitely am keen to get back into my next project! mate THANK YOU!

On Fri, 3 Jul 2020 at 19:13, Vinzenz Rosenkranz notifications@github.com wrote:

New build is released on apps.nextcloud.com 🎉

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/v1r0x/files_3d/issues/1#issuecomment-653494897, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWGYCQ2MZX5EK4XBBZLXMDRZW4MZANCNFSM4GOROXJQ .

plages commented 4 years ago

Hi Great app!!. A lot of formats have been mentioned here but there's one i know a lot of people are going to be happy about. I have no idea if it's feasable but adding .ifc support would spread joy all across architects, builders etc. It is an open format.

demonlibra commented 3 years ago

Nextcloud 20.0.2 Installed app "files 3d"

Added row: ["application/sla"] to "nextcloud/config/mimetypemapping.json"

Installed app OCCWeb and executed command "maintenance:mimetype:update-js"

Is someting else to do to showing STL model in browser? Thank you.

v1r0x commented 3 years ago

Since verison 0.3 you no longer have to use mimetypemapping. The only thing you have to do is disable and re-enabling the app to update the file format support.

demonlibra commented 3 years ago

Thank you. Now It is working. Is it possible to add something in code for "viewall" and "center" model?

1Ale commented 3 years ago

I don't know how to determine if an object is 2D or 3D and lock rotation or not.

Using the boundingBox that was added in #37 it should be possible to detect if an object is 2D if one dimension of the bounding box is zero (the difference between the max and min value of the bounding box for each dimension x, y or z). If none or more than one dimension of the bounding box is zero the default 3D view can be used.

If the detection detects a 2D object the rotation can be locked and the initial camera can be set to look at the center from the direction of the zeroed bounding box dimension (ex: if the object is on the x,z plane, its bounding box max.y minus min.y should be zero and the camera may be positioned on the y axis away from the object looking at its center, the rotation around the y axis may be locked).

Not only for a future dxf support, I think this method is useful to any other 3D format that may contain a simple 2D shape for both the initial camera position and the thumbnail/icon in #30.

binford6000 commented 2 years ago

Hi v1r0x, i would like to take up the topic of ifc-files. Is there support for this in the meantime? three.js obviously supports it. Would be really great if 3d_files could support this file format! Kind regards, Sebastian

v1r0x commented 2 years ago

Hey folks!

As this issue is now rather long and kinda messy I'm going to close this one. Please create a new issue for any formats missing (so I get a better overview of what is still needed).

Two things I would like the new issues to be:

  1. One issue per format. Keeps the discussion clean and I can easily see what's that issue is about
  2. A :+1: on the first issue comment is best way to show support

Thank you all for your contribution here and sorry for any inconvenience!