# Mesh Component

**URL:** <https://forum.defold.com/t/mesh-component/65137>\
**Category:** Announcements\
**Created:** [May 15, 2020, 2:36pm UTC](https://forum.defold.com/t/mesh-component/65137 "2020-05-15T14:36:37Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [May 15, 2020, 2:36pm UTC](https://forum.defold.com/t/mesh-component/65137/1 "2020-05-15T14:36:37Z")

</div>

In this latest beta, we’ve added a quite exciting feature: the **Mesh Component**

Although the feature isn’t 100% done, we believe it’s still usable in its current form.  
And we’d love to hear your feedback to this feature.

For instance, we lack proper documentation for this feature (but ofc that will come soon too).  
So, currently, this test project will have to serve as a starting/learning point for those interested.

What does it do then, you ask?

## Mesh

This component displays a single mesh.  
This is different form a _model_ which might have multiple meshes, and may be skinned.

## Custom vertex formats

The mesh format supports custom vertex formats.  
We use our [buffer](https://defold.com/ref/stable/buffer/) api which supports multiple named streams.  
As such, you can get/set values and alter a stream at runtime. (E.g. positions, colors, normals…)

## Formats

In order to make these files easy to generate and manipulate using tools or by hand, they’re in json format. (.mesh, .buffer)

## Material

The named streams are automatically provided as input to the vertex shader.  
There is no need to specify them in the material file itself.

### Material Local Space

The data will be provided as-is to you in your shader, and you will have to transform vertices/normals as usual on the GPU.

### Material World Space

If your material has “World” space set, you have to either provide a default “position” and “normal”, stream, or you can select it from the dropdown, when editing the mesh. This is so that the engine can transform the data to world space for batching with other objects.

# Test project

[MeshTest.zip](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/3X/8/7/8771a30e90921d6710960760a72639364aa70556.zip) (252.5 KB) (License: MIT)

_Rotate the camera with the left moust button_ (or touching the screen)

# Blender

Inside the test project, in `assets/blender/` you’ll find the test scene I created for with geometry setup.

- UV coordinates layer named `texcoord0`
- Vertex color layer named `color0`  
(You _can_ name these what you wish, as long as you match the names in your shaders)

## Exporter

Also, you’ll find the `defold_mesh.py`, a Blender exporter which outputs to the mesh buffer format.  
It is currently _very_ basic, it currently only exports the mesh of the currently selected object

Currently, it supports positions, normals, uvcoordinates and vertex colors.

# Wrap up

Finally, I’d also like to thank the team, most notably @sven and @mats.gisselson for their hard work implementing this feature. 👏

And ofc a mention to @ross.grams for the excellent [RenderCam](https://forum.defold.com/t/rendercam-universal-camera-library/12877) which is part of this test project. 👏

And please get back to us with feedback to this feature!

_In this clip, I the manipulation of the buffer at runtime, using [hot reload](https://defold.com/manuals/hot-reload/?q=hot%20reload) (CTRL+R) to refresh the resources while the app is still running._

[![](https://img.youtube.com/vi/VEhZ9pKC6uA/maxresdefault.jpg "Mesh Component") ](https://www.youtube.com/watch?v=VEhZ9pKC6uA)

(Update 2024-08-13: Added MIT license)

---

_[View the full topic](https://forum.defold.com/t/mesh-component/65137)._
