+2
Completed

3d Viewer

Kevan H 5 months ago in Feature requests • updated by me 2 weeks ago 26

any chance of a plugin to view 3d files directx meshes, obj I know there is the Autodesk plugin but after 12 months you have to purchase credits 100 credits $100 ! I think webGL could be used 

thank you

Answer

Answer
Started

The plugin for viewing 3D files can be now downloaded from here: https://github.com/filerun/plugins-3d_viewer (pull requests are welcome).

The plugin can currently open the following types of files: OBJ & MTL (external resources get loaded), STL (both ASCII and binary), FBX, DAE, X, GLTF/GLB, 3DS

For IFC:

- one could adapt the plugin to convert the file on the fly to OBJ, using something like IfcConvert, and load that instead.

- or perhaps just use https://github.com/opensourcebim/BIMsurfer instead of Three.js

I will soon review the thumbnail generation app suggestions.

Under review

We did work on a plugin for it, and seems to work fine for smaller 3D models. It's fully browser-based and requires no third-party server for conversion, but it can be slow and even fail for large models. Also can fail with models that have external file resources.

The plugin is big, and we don't think we'll include it by default in FileRun given its very specific use, but will probably make it available as a separate download. It will be compatible with the next FileRun version, so it might take a month or two.

Ok thank you look forward to trying it :)

I'm interested to see if this has progressed.  The interface for this application appears to be the best for browsing and tagging 3d assets.

The main goal for me is to have a tagged and searchable contact sheet of models.  Having a couple pre-cached thumbnails of each model is suitable for browsing and searching. 

So the process would be to traverse a directory of STL and OBJ

Make cached images of them from one or more orientations

And then display the images using your current templates but with a link to the actual stl that would load it into a three.js scene.  There's a large number of modelers and 3d print folks like me that have created and purchased fairly large collections of models and there's no good self hosted solution for this yet.  You'd be the darling of the community if you could do that!  (PS. just tried to install media goblin and got into circular dependency hell.  You might be the only hope!)

https://www.npmjs.com/package/three-software-renderer

https://www.npmjs.com/package/node-stl-thumbnailer

Looks like this is the best cross platform stl thumbnail generator:

https://github.com/unlimitedbacon/stl-thumb/releases/tag/v0.3.1

It works on all platforms, has a good CLI and has ARM support which is nice and has attractive and easy to configure defaults.

Since it works from the command line you should be able to exec() it with PHP.  It might have php bindings as well.

Three.js is probably the best for online viewing, as I'm sure you've seen.

If you wanted to enable quick edits admesh is cross platform and very fast:

https://github.com/admesh/admesh

I would imagine a world where if the STL is position poorly (like many are) then you right click on the thumbnail and select an option to position the object (center and which face forward) then you would regenerate the STL thumbnail.  This would be one line of code and very useful.


Lastly a utility feature would be to allow users to right click invoke a quick conversion:

https://github.com/cmpolis/convertSTL

Many STL are ascii and binary are 1/6th the size.  This is also cross platform from what I can tell and would work from a command line.  I would fork this to let the users do a ascii->binary conversion.  Bonus points if we can figure that out in the file metadata and let the user search for ascii stl.


I can develop any of these in PHP but the code is hidden and it doesn't look like I can create thumbnails or invoke shell scripts with the current plugin architecture.  Contact me if you'd be willing to let me integrate these features.

The "stl-thumb" utility turns out to function quite well. Will add the option with the next FileRun update:

a BIM viewer / server
for ifc format will be very interesting also

Answer
Started

The plugin for viewing 3D files can be now downloaded from here: https://github.com/filerun/plugins-3d_viewer (pull requests are welcome).

The plugin can currently open the following types of files: OBJ & MTL (external resources get loaded), STL (both ASCII and binary), FBX, DAE, X, GLTF/GLB, 3DS

For IFC:

- one could adapt the plugin to convert the file on the fly to OBJ, using something like IfcConvert, and load that instead.

- or perhaps just use https://github.com/opensourcebim/BIMsurfer instead of Three.js

I will soon review the thumbnail generation app suggestions.

Awesome plugin... I have lots of STL files for my 3D Printer so it's nice to be able to view them online.

Thank you so much for this, it is brilliant, is it possible to add direct-X extension too? ;)

Support for .X models has been now added.

WOW :) that was quick thank you very much 

You're welcome!


Support for GLTF/GLB and 3DS files has been now also added.

not sure if I have done anything wrong but I cannot open/preview X files, I downloaded the latest build from GitHub all other formats work fine but X files is just a blank window :(

Can you share a sample file?

I made a few updates:

added loading progress bar

set camera position so the model fills the viewport (dynamically calculated)

added shadows

improved material settings

added directional light

change BG color to make the model contrast better

Things that would be nice would be to swap from orbit control to a control that spins the model.  Then shadows would be cast dynamically which would provide good clues about geometry and textures.  I got a drag-drop model view to work but not one that spins the model.  Probably someone with more THREE.js familiarity could get it done in a couple minutes.

What's the best way to get you the changes?

A GitHub pull request would be great.

pull request sent.  can't wait for the thumbnails.  

Got my instance online.  Ping me if you'd like more help with dev for the 3D modules.

Completed

A FileRun update is now available. It includes the 3D viewer with some changes.

3D model files now have icons. And thumbnails for STL files, using this 3rd party requirement, can be enabled from the control panel.

The option for saving thumbnails from rendered screenshots was postponed for the next update, but there is still an option for saving screenshots as PNG files.

This works extremely well.  Thank you very much.

I'll post this to the modeler groups.


1.  It appears nobody can agree on "which way is up" for models.  I'll make a pull request so that the stl-thumb and three.js at least agree and the thumbnail is taken from the default angle the model is shown in three.js

2.  Your loading indicator is better than mine was. 

3.  Is there a way to right-click and regenerate thumbnail?  I didn't see it as a plugin.  I updated some models and they were synced but the thumbnails are lagging.

Thumbnail Orientation

you can see from this screen shot that model orientation can make the thumbnail unhelpful.  So I reposition the models and update them but not sure how to clear the existing thumbnail.

4.  Is there a way for me to execute a command line operation on the file via right click menu?  On my Mac I've created quick actions that execute things like this:

/usr/local/bin/admesh -c --x-rotate=90 --translate=0,0,0 -b "$1" "$1"

Where $1 is the filename.  I would add a plugin to give me that option in filerun if there's a way for me to pass in the file path and then subsequently regenerate the thumbnail.


Thank you very much for this.  This is almost exactly what the modeling community needs.

+1
It appears nobody can agree on "which way is up" for models.

:)) I didn't know much about 3D models before making this plugin so I can't confirm if they are displayed in the right orientation or not. With the ThreeJS viewer, most other formats look right to me, except STL which seem pretty random. Don't know if it's the sample files I found online or not.

Is there a way to right-click and regenerate thumbnail?

The only option would be, signed in as FileRun superuser, to right click a folder, go to "More options" -> "Properties" and then "[Clear thumbnail cache]" which clears all thumbnails for the selected folder.

But re-uploading a file should have FileRun regenerate the thumbnail automatically. (Unless the new file has an absolutely identical byte size, which is quite rare.)

Is there a way for me to execute a command line operation on the file via right click menu?

Yes, it should be pretty easy (https://docs.filerun.com/file_plugins). You have the variables for the file's path, so you can "exec($yourCommand)". You can also check the code of the other plugins inside "customizables/plugins"

If you check the viewer plugin's "app.js" you will see some commented code, a bit for a button for setting a thumbnail, and at the bottom, for the Ajax request for it. You could add a button that makes an Ajax request for the "admesh" command, so you do it directly from the viewer, rather than from the file manager.

If I find a bit more free time, I could also add a button that loads all the models in a folder, one after the other, and saves thumbnails for each of them. Not as elegant as having a proper server side solution for it, and would probably be a bit slow, but still pretty convenient for those that can't install "stl-thumb". This would also give a bit more flexibility on the scene and thumbnail look.


This is one of the rare cases where changing the orientation doesn't change the file size at all.

It legitimately sets one string in the file to be something like 0,0,1 instead of 1,0,0. 

I just verified this.  The file is still synced by the Nextcloud system but it apparently doesn't trigger the re-create thumbnail process and the file size is the same down to the byte.

STLs suffer from the fight between groups whether Z means "out from the screen towards the user" or whether Z means "up from the floor like in real life".  Game designers say it's one thing, cad people say something else.  It's like the spaces and tabs fight.  So the files come out every which way.  I create the quick actions to rotate them so the madness is contained slightly.  I'll use the samples you sent to apply this server side.  Thank you very much for that.

Making a client side thumbnailer would give you really good control.  Three.js is quite capable, besides the slowness of loading models like that it would be an excellent option if you can't get stl-thumb on your system.  Good news is that stl-thumb should be pretty easy.  It was trivial to install for me and should run on any arm device.  It even chewed through some monstrously large 500mb stl files which is something three.js would have more trouble with.

If rotating a model is as simple as changing a byte, we could do it in PHP, inside FileRun, without having to call an external program. This way the thumbnail cache can also be cleared.

Let me research that and see.  The trick is to find the one right byte.......

I was going to make a pull request but the change for the orientation is so small I'm lazy:


in loadModelSTL: function()

change

mesh.rotation.set(0, -Math.PI/2, 0);    =====>  mesh.rotation.set(-Math.PI/2,0,0);

Then the rotation in the viewer will match the rotation in the thumbnail generator