MeshPart
MeshParts are a form of BasePart that includes a physically simulated custom mesh. Unlike with other mesh classes, such as SpecialMesh and BlockMesh, they are not parented to a BasePart but rather behave as a BasePart in their own right.
The mesh and texture of a MeshPart are determined by the MeshPart.MeshId and MeshPart.TextureID properties. For more information, see Meshes.
SpecialMesh or MeshPart?
There are currently two ways of using a developer created mesh. They are using a SpecialMesh with the SpecialMesh.FileType set to 'FileMesh', or by using a MeshPart. Although, on the whole, the MeshPart object has superseded the SpecialMesh there are some differences developers should be aware of.
- BasePart.Material displays correctly on the mesh when using a MeshPart and not when using a SpecialMesh
- MeshParts include the MeshPart.CollisionFidelity property, meaning the collision model of a MeshPart can be set to resemble the geometry of the mesh. The SpecialMesh object by contrast, uses the parent BaseParts collision model
- The mesh of a MeshPart scales on all axis depending on the BasePart.Size property of the MeshPart, the mesh of a SpecialMesh does not
- The SpecialMesh object includes the DataModelMesh.Offset and DataModelMesh.Scale properties whereas MeshParts do not
- The DataModelMesh.MeshId property of a SpecialMesh can be changed by a Script or LocalScript during runtime. The MeshPart.MeshId property of a MeshPart can not
In most, but not all cases, using a MeshPart is more suitable. As MeshParts are a relatively new feature however, developers should expect some of the above behavior to change.
Summary
Properties
Render both faces of polygons in the mesh.
Determines the level of detail that solid-modeled and mesh parts will be shown in.
Methods
Events
Properties
DoubleSided
This property determines whether to render both faces or polygons in the mesh. It is only changeable in Studio. This is useful for meshes that are typically modeled as cards such as a leaf, hair and cloth.
Example: The tree leaves are modeled with single sided cards.
With MeshPart.DoubleSided disabled some leaves are missing since they are back facing the camera.
With MeshPart.DoubleSided enabled, both faces of the leaves are rendered.
HasJointOffset
HasSkinnedMesh
JointOffset
MeshId
The MeshId is the content ID of the mesh that is to be displayed on the MeshPart.
Note that this property currently cannot be changed by scripts as the collision model of the mesh cannot be recomputed during runtime. Developers should not rely on this behavior as it may change in the future. Those looking for a custom mesh object that can be updated during runtime should use SpecialMesh.
MeshSize
RenderFidelity
This property determines the level of detail that solid-modeled and mesh parts will be shown in and can be set to the possible values of the RenderFidelity enum.
By default, solid-modeled and mesh parts will always be shown in precise fidelity, no matter how far they are from the game camera. This improves their appearance when viewed from any distance, but if a place has a large number of detailed solid-modeled or mesh parts, it may reduce overall game performance.
Distance From Camera | Render Fidelity |
---|---|
Less than 250 studs | Highest |
250-500 studs | Medium |
500 or more studs | Lowest |
TextureID
The texture applied to the MeshPart. When this property is set to an empty string, no texture will be applied to the mesh.
MeshPart.TextureID = "" -- no texture
Note, although the MeshPart.MeshId property cannot be changed during runtime, the texture can.
How can I change the texture of a mesh?
Using the TextureId property, the texture of a mesh can be changed without having to reupload the mesh. To do this, a new image will need to be uploaded to Roblox with the desired texture. The original texture image file can be obtained by exporting the mesh using the 'Export Selection' option in Roblox Studio. The image file will be saved alongside the exported .obj file.
The new texture can then be re-uploaded to Roblox as a Decal and its content ID can be applied to the mesh using the TextureId property.
How can I make a textured mesh?
A mesh can only be textured if the mesh has been UV mapped. UV mapping refers to the practice of projecting a texture map onto a mesh. This cannot be done using Roblox Studio and has to be done using an external 3D modelling application such as Blender.