How to Export (and Share) Your 3D Result Plots as glTF™ Files
Looking for an easy — and visually enticing — way to share 3D results plots from the COMSOL Multiphysics® software? In this blog post, we demonstrate how to export your 3D plots as glTF™ files and share them in a variety of web-based graphics viewers, and even in Facebook® posts.
Different File Formats for Exporting Simulation Results
The COMSOL Multiphysics software has support for exporting results in many different formats. Here I list just a few of the possibilities:
- Submit a geometry for 3D printing in the STL-file format.
- Export accurate geometries as Parasolid® or ACIS® files (also requires the add-on CAD Import Module).
- Export numerical results as a variety of file formats, depending on the type of data. The unstructured VTK® file format (VTU) is the most versatile file format for storing numerical results and can be used by other software programs for further analysis and simulation.
What About 3D Results?
The Khronos Group is an organization that helps graphics vendors by creating open standards that can be used by anyone to create platform-independent graphics file formats and APIs. The Khronos Group is known for two of its most famous APIs, OpenGL® and Vulkan®, which are used by graphics cards to provide fast and high-quality 2D and 3D graphics, but they in addition developed a file format called glTF™ (short for GL Transmission Format). It can be used to transfer 3D scenes and models between programs.
The emphasis for the glTF™ file format is on the display of the 3D figures and not the accuracy of the exported geometry. This means that the graphics file format is good for exporting visually strong 3D results, but not for exporting geometries and results that should be used for further modeling.
For 3D results, you can use the glTF™ file format. There are many organizations and conversion programs that support glTF™, including the graphics industry, software vendors, and open-source players.
glTF™ files come in two “flavors”:
- The glTF™ file format is a collection of files that describe the 3D scene as well as the coordinates, colors, and more.
- The GLB-file format makes it easier to manage the transfer of 3D content, via a single binary file that contains all of the information that is necessary to define a 3D object in a scene.
It is possible to convert a GLB-file to a glTF™ file and vice versa.
How to Export a 3D Results Plot from COMSOL Multiphysics®
As of COMSOL Multiphysics® version 5.4, you can export results as glTF™ files. The COMSOL® software exports GLB-files that can be used to easily open and manipulate the geometry in other tools.
Note that only 3D results can be exported this way, since the glTF™ and glb file formats support 3D graphics only.
Results can be exported either by adding an Export Image feature to the model tree or simply clicking the Image Snapshot button at the top of the Graphics window. The latter is the easier method. When pressing the Image Snapshot button (denoted by a camera icon), a dialog box opens. In the dialog box, you can select the option for glTF™ files and specify which filename should be used. You do not need to give an extension to the filename, as the extension GLB will automatically be used.
When you click OK, the file is exported and ready to be used by whatever graphics tools you have available to display and manipulate the object in. Note that only the main content of the Graphics window is exported. Items such as the plot title and legend are not exported, since the glTF™ file format does not support these items.
How to Include a glTF™ File in a Facebook® Update
The Facebook® platform has supported the glTF™ file format for some time now. It is easy to insert the exported GLB-file into a Facebook® update, but before doing so, it is important to acknowledge some of the limitations.
At this time, Facebook® only allows GLB-files that are less than 3 MB in size. It is quite easy to create result plots in COMSOL Multiphysics that are much larger than this limitation, so you have to be creative in minimizing the amount of content that is included in the result graphics. Also, Facebook® doesn’t support exported plots that include points and lines. This is a severe limitation in most 3D plots, since dataset edges are shown by default and lines are always used to display such edges. The solution is to clear the Plot data set edges option for the plot groups you wish to export (you can always switch them on again after exporting).
There are other plot types that create lines, most commonly, Streamline plots. If you have a streamline plot, then switching from lines to either ribbons or tubes will solve the problem. However, Tube plots tend to create rather large GLB-files.
After modifying the export settings to accommodate the specifications of the Facebook® platform, you can insert the GLB-file into an update simply by dragging and dropping it into a blank post. The display of the post will change to notify you where you can drop the file, as shown here:
Simply drop the GLB-file and, if you want, write text to go along with your model image. Now that the GLB-file is embedded in your post, your Facebook® audience can view and manipulate the figure.
See this update live on the COMSOL Facebook® page.
Note that the current file size and content limitations imposed by Facebook will most likely change over time. We expect them to support larger files as well as points and lines in the future.
Online 3D Viewer Tools for glTF™ Files
glTF™ file format is already supported by many graphics programs and viewers. One such viewer is available in your browser: https://gltf-viewer.donmccurdy.com/. You can simply drag your GLB-file into this window for viewing. The viewer supports lines and points as well as surfaces, so all COMSOL Multiphysics features can be exported and viewed using this tool.
Microsoft Support for glTF™ Files
Microsoft® has started to support the glTF™ format with various tools. Windows® 10 comes with a tool called Paint 3D, which is very different from the much older Paint application that was shipped with Microsoft® Windows® 1.0. Paint 3D adds the ability to import and export glTF™ files in order to create scenes of graphics content. You are also able to paint on the imported objects — in 3D!
A glTF™ file shown in the Microsoft® Windows® Paint 3D tool.
The latest version of Windows® 10, the November 2018 update, has a new 3D Viewer app that can be used for viewing glTF™ files and other 3D file formats. And if you have Microsoft® Office 365 or Office 2019, you can insert glTF™ files into PowerPoint®, Word, or Excel® in order to create presentations and documents with the exact 3D view you wish to create using 3D graphics from COMSOL Multiphysics® and other sources. Microsoft® Office has support for directly importing 3D assets from the internet to create more rich and appealing work. Note that the Microsoft® programs mentioned here currently do not support lines and points, so these have to be suppressed using the same method as described when creating the GLB-file for the Facebook® post.
Learn more about the specialized features for sharing your COMSOL Multiphysics results by contacting us to evaluate the software.
Read about more features for exporting your simulation results:
- How to Export Images Automatically After Solving Your Model
- Exporting Meshes and Solutions Using the Application Builder
ACIS is a registered trademark of Spatial Corporation. Facebook is a registered trademark of Facebook, Inc. glTF and the glTF logo are trademarks of the Khronos Group Inc. Microsoft, Excel, and PowerPoint are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. OpenGL is a trademark or registered trademark of Silicon Graphics, Inc. in the United States and/or other countries worldwide. Parasolid is a trademark or registered trademark of Siemens Product Lifecycle Management Software Inc. or its subsidiaries in the United States and in other countries. VTK is a registered trademark of Kitware, Inc. Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.
- COMSOL Now
- Today in Science
- COMSOL Now
- Today in Science