v1r0x / files_3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

e-alfred opened this issue Β· comments

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?

Thank you! 😊

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).

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(?)

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

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.

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.

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

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

Thanks for the files! Seems like they were always there, but with black color πŸ˜† 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.

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.

.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:

  • Lock rotation (checkbox)
  • Enable grid (checkbox)
  • Fit object(s) to view (button)
    and for manipulation either:
  • Scaling (slider)
  • Position (3 inputs)
  • Rotation (3 inputs)
    or
  • Checkbox to enable manipulation + Controls
    or both.

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

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

Thanks in advance!

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

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.

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 πŸ˜‰

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

Thank you very much! Much appreciated! πŸŽ‰ 😊

I'm curious: which forum? 😁

What about .dwg files support?

@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?

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.

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

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

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.

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

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

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.

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

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 :)

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.

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.

πŸ˜€
That's why my testing instance is running on an old school apache πŸ˜…
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 πŸ˜‰ But you can use my PP account (connected to my mail address in the appinfo file). Don't really have something proper for donations πŸ˜…

New build is released on https://apps.nextcloud.com πŸŽ‰

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.

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.

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.

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

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.

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

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 πŸ‘ on the first issue comment is best way to show support

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