AtlasBuilder

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

Up and coming

Pack many images into as few sheets as possible, and cut the big ones into tiles.

Add images by name, then BuildAsync packs them into sheets of SheetSize, 1024 square by default, with a gutter of repeated edge pixels so filtering never samples a neighbour. An image too big for a sheet is cut into tiles. Each piece records its sheet, ImageRectOffset and ImageRectSize, GetIcon hands one to an ImageLabel, and SaveAsync writes the sheets with an Atlas.json.

Made with Instance.new("AtlasBuilder") or Clone().

Properties

NameTypeDefaultDescription
SheetSizeVector2The size of each sheet, 1024 by 1024 by default, Roblox's image limit.
Gutternumber2 by default: pixels of each piece's own edge repeated around it, so filtering never samples a neighbour.
Trialsnumber20 by default: random orderings tried beside six sorted ones; the fewest sheets, then the least waste, wins.

Methods

NameArgumentsReturnsDescription
AddImage(name: string, image: GpuTexture | string | buffer, options: { WorldRect: Rect?, Data: any? }?)()Adds one image to pack under a name; WorldRect is the stud area it covers, and Data rides along to its piece.
AddLarge(name: string, image: GpuTexture | string, options: { WorldRect: Rect?, MaxPiece: number?, Data: any? }?)()Cuts an image into near-equal tiles of at most MaxPiece a side, 1020 by default; each tile gets its share of WorldRect.
BuildAsync
yields
()({ AtlasSheet }?, string?)Packs everything added and waits, then returns the sheets, each with its image and the pieces on it.
SaveAsync
yields
(folder: string | PathHandler)(boolean, string?)Writes a numbered PNG per sheet and an Atlas.json into the folder.
GetIcon(name: string)Icon?Returns an Icon for an ImageLabel: the piece's sheet with its ImageRectOffset and ImageRectSize.
PackIslandsAsync
yields
(meshes: { EditableMesh }, margin: number?)({ EditableMesh }?, string?)Lays the meshes' UV islands out in one shared layout with the same packer as the sheets; the meshes come back in the same order.

Events

NamePassesDescription
Progress(number, number)Fires as a build goes, passing the count done and the total.
From ShotInstance 33