MeshService
Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.
Up and coming
Open and save meshes in the formats you work with, and run the heavy mesh jobs from code.
Write use MeshService. It reads and writes Roblox .mesh files, Draco included, and OBJ, FBX, glTF and GLB; one combined GLB uploads to Roblox as one Model with every part named and placed. It also packs UV islands, runs a smart UV unwrap, reads each face's texture colour, splits by colour and sets up BakeContext bakes, and every job returns a real error when it fails.
A service: write use MeshService.
local function example(x : MeshService)
local mesh, why = x:LoadAsync("rock.glb")
print(mesh and mesh.TriangleCount, why)
endMethods
| Name | Arguments | Returns | Description |
|---|---|---|---|
| LoadAsync yields | (source: string | buffer, format: MeshFormat?) | (EditableMesh?, string?) | Opens a mesh file or its bytes; with no format the extension or header decides, and several objects are merged into one. |
| LoadObjectsAsync yields | (path: string) | ({ [string]: EditableMesh }?, string?) | Opens every object of an FBX, GLB or OBJ with many parts, keyed by name. |
| SaveAsync yields | (meshes: EditableMesh | { [string]: EditableMesh }, path: string, options: { Texture: EditableImage? }?) | (boolean, string?) | Saves one mesh or named meshes in the extension's format; a GLB embeds the texture, an OBJ writes its .mtl and PNG beside it. |
| PackIslandsAsync yields | (meshes: { EditableMesh }, margin: number?) | ({ EditableMesh }?, string?) | Lays the meshes' UV islands out in one shared layout and returns them in the same order. |
| UnwrapAsync yields | (mesh: EditableMesh) | (EditableMesh?, string?) | Unwraps the mesh's UVs with Blender's smart UV project and waits for the result. |
| GetTriangleColorsAsync yields | (mesh: EditableMesh, texture: EditableImage) | (TriangleInfo?, string?) | Returns each face's average texture colour (u8 RGB), its UV island and its object (u16 each), in three buffers. |
| SplitByColorAsync yields | (mesh: EditableMesh, texture: EditableImage, colors: number | { Color3 }) | ({ EditableMesh }?, string?) | Splits a mesh into colour groups: a number finds that many from the texture, a list of colours uses that palette. |
| CreateBakeContext | (target: EditableMesh, bakeType: "Diffuse" | "Normal") | BakeContext | Makes a BakeContext that bakes source meshes' textures onto the target's UV layout, as diffuse colour or normals. |
| RemapTexturesAsync yields | (old: { EditableMesh }, new: { EditableMesh }, textures: { EditableImage }, bakeType: "Diffuse" | "Normal") | (EditableImage?, string?) | After PackIslandsAsync, redraws each old mesh's texture into the new shared layout and returns the one image. |
From ShotInstance 33
ClassNameNameParentAncestryChangedAttributeChangedChangedChildAddedChildRemovedDestroyingAddTagClearAllChildrenCloneDestroyFindFirstAncestorFindFirstAncestorOfClassFindFirstAncestorWhichIsAFindFirstChildFindFirstChildOfClassFindFirstChildWhichIsAGetAttributeGetAttributeChangedSignalGetAttributesGetChildrenGetDescendantsGetFullNameGetPropertyChangedSignalGetTagsHasTagIsAIsAncestorOfIsDescendantOfRemoveTagSetAttribute
