# Explore 3D scans with MeshLab Light Detection and Ranging, better known as LiDAR, is a method of taking photographs of 3D space using lasers and GPS. That sounds like science fiction, and I can think of a few scenes in some movies that probably re-imagined this technology without realising it, but it's technology that's existed for over 50 years. LiDAR is useful for topographical surveying and archaeological record-keeping, and it's useful for obtaining sources for 3D printing, but I was introduced to it while working on a movie that needed to integrate an imaginary (or was it?) dragon with a real-world forest and foresting town. For all of these things to appear seamlessly in the same movie together, digital artists were sometimes tasked with recreating, with 3D models, a tree or building that actually existed. To get the real world objects exactly right in the 3D modeling applicaiton, the artists needed to essentially trace the real world object, just as you might trace a photograph to produce an accurate drawing on tracing paper. The photograph the artists were provided were LiDAR scans, which allowed them to "trace" an object in all dimensions. MeshLab is an open source LiDAR point cloud viewer and editor. ## Install MeshLab is available on most Linux distributions from your package manager. On Fedora, Mageia, and similar distributions: ```bash $ sudo dnf install meshlab ``` On Debian-based distributions: ```bash $ sudo apt install meshlab ``` I use MeshLab as a [Flatpak](https://opensource.com/article/21/11/install-flatpak-linux), and there's a convenient AppImage available on [MeshLab.net](https://www.meshlab.net/#support). ## Getting a LiDAR scan LiDAR equipment isn't easy to obtain, so unless you're working on a project using LiDAR scan, you probably don't have a LiDAR scan just lying around. The [OpenHeritage](https://openheritage3d.org) project, however, is dedicated to archiving scans of significant scientific and public interest. It has scans of ancient ruins at Tikal, cathedrals in France and Spain and Italy, palaces in Syria and Jordan, and more, published under the terms of [Creative Commons](https://opensource.com/article/20/1/what-creative-commons) licenses. LiDAR scans contain millions of points that define an object, so they're very taxing on system resources. To work on a LiDAR scan comfortably, anticipate requiring a good graphics card and plenty of RAM. If you just want to browse through a scan, though, the [Pantheon (10.26301/t9sj-mf53)](https://doi.org/10.26301/t9sj-mf53) dataset is surprisingly clean, and is only 89 MB with just 6 million vertices. The Pantheon scan is attributed to Gerd Graßhoff, Michael Heinzelmann, Markus Wäfler, Christian Berndt, Jon Albers, Oskar Kaelin, Bernd Kulawik, Ralph Rosenbauer, Nikolaos Theocharis, Michael Lustenberger, Bernhard Fritsch in 2021, and is distributed by Open Heritage 3D under the CC BY-NC-SA license. After downloading the mesh file, unzip it to uncompress the `.e57` file. For the purposes of this article, the terms *mesh*, *point cloud*, *data set* refer to the same thing: the collection of vertices produced by a LiDAR scan. ## MeshLab interface When you launch MeshLab, there's usually no LiDAR scan loaded. To import one, go to the **File** menu and select **Import Mesh** or press **Ctrl+I** on your keyboard. Select your mesh. ![Importing a mesh into MeshLab](meshlab-import.jpg) You can adjust your view of a point cloud by clicking and dragging on one of the axis handles (the **trackball**, in MeshLab terminology) appearing around the origin point of the mesh. To zoom in and out on the point cloud, use your scroll wheel. Scroll down to zoom in and scroll up to zoom out. Because the trackball doesn't scale with your mesh, it might *look* like the point cloud is being scaled up or down, but the panel at the bottom of the window reveals that your points haven't changed. The top toolbar of the MeshLab window displays your primary editing tools. The first batch of tools are file operations used to load and save and export meshes. The second batch are display options you can use to change how you're viewing the dataset: you can view just the bounding box around the point cloud, the points within the cloud, just a wireframe, a gridded background layer, axis labels, and so on. The rest of the toolbar contains tools for editing meshes. When no editing tool is selected, you're in viewing mode. ## Transforming a point cloud MeshLab is not a 3D modeling application, even though there are many similarities in the general interface. However, MeshLab does edit meshes, so there are some tools that can transform a point cloud. The most basic edits are rotate, scale, and translate. To transform a mesh, click the **Manipulators tool** icon in the top toolbar. ![Manipulators tool](meshlab-manipulators.jpg) With the Manipulators tool active, you can press **T** to translate your mesh's position, **R** to rotate your mesh, or **S** to scale your mesh. Controls appear for each operation, and as with Blender you can press extra keys to further constrain what you're doing. For example, press **X** in translation mode to constrain your translation just along the X-axis. Instructions like these are provided in the top left corner of the MeshLab window. ![Helpful instructions for each tool](meshlab-help.jpg) When you're finished with a tool, you must click its icon again to deactivate it. Clicking on a new tool does *not* deactivate your current tool. Pressing **Escape** on your keyboard switches you to view mode, though, and pressing it again returns you to your previous tool. This way, you can adjust and edit and adjust quickly with no added mouse clicks. ## Selecting points A common task in a mesh editor is to clean up a LiDAR scan by removing extraneous points. The LiDAR scan of the Pantheon is pretty clean as it is, but not all are, and it can save a lot of processing power and hard drive space to eliminate vertices you don't actually need. You can select points using the **Select vertex clusters** tool, **Select vertices on a plane**, and **Select faces/vertices inside polygonal area** tools. The concept is similar to selection in any graphic application, although it's a little more complex in MeshLab because you're interacting with 3D space. My favourite selection method is with the **Select faces/vertices inside polygonal area** tool: 1. Draw a polygonal selection area encompassing the points you want to select. 2. Once you've got a selection area, press **Q** on your keyboard to activate the selection on the points within your polygon. Selected points turn red. 3. Press **Escape** on your keyboard to switch to view mode and rotate or reposition your point cloud to see it from a different angle. 4. Add to your polygon selection and press **Q** to add the new points. Repeat that process until you have everything you need in your selection. You can refine your selection by pressing **C** to clear your polygon and start a new one. Pressing **C** doesn't clear your selection, just the selection area, so you can draw a new polygon and either add more points with **Q** or remove points you didn't mean to select with **W**. ![Polygonal selection](meshlab-select-polygon.jpg) Once you've got a selection, click on the **Filters** menu and browse through the **Selection** submenu to perform whatever action you need on your point cloud. ## Exploring LiDAR MeshLab is packed with features, and this article has only covered the basics. There are lots of filters, lots of ways to read data in from reference sources, point cloud simplification, Z-painting, model aligning, and much more. Whether you're diving into LiDAR to clean up scans for your 3D printer, adjust origin points for a carefully orchestrated tracking shot in the next blockbuster, or recording the states of historical sites over the years, MeshLab is an invaluable and unique open source tool.