Roblox UtilitiesDevlHub Roblox Documentation

Class

GeometryService

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

Service containing geometric operations.

Service containing geometric operations not directly related to specific objects.

Methods 7#

CalculateConstraintsToPreserveReturns a table of Constraints and Attachments which you may choose to preserve, along with their respective parents.
FragmentAsyncBreaks a BasePart into multiple MeshPart instances, according to the pattern of points passed in, by using voronoi decomposition.Yields
GenerateFragmentSitesProvides an array of positions which can easily be passed into FragmentAsync to perform simple types of destruction.
IntersectAsyncCreates one or more PartOperations or MeshParts from the intersecting geometry of multiple parts.Yields
SubtractAsyncCreates one or more PartOperations or MeshParts from one part minus the space occupied by other parts.Yields
SweepPartAsyncCreates a MeshPart which has the shape of the input part stretched/dragged through the given set of CFrame positions.Yields
UnionAsyncCreates one or more PartOperations or MeshParts from one part plus the space occupied by other parts.Yields

CalculateConstraintsToPreserve(source: Instance, destination: Array, options: Dictionary = nil): Array#

Returns a table of Constraints and Attachments which you may choose to preserve, along with their respective parents. Iterating over this table lets you decide whether to reparent recommended constraints and attachments to their respective parents.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
sourceInstanceAn original object that the solid modeling operation was performed on, for example part in UnionAsync().
destinationArrayArray of resulting BaseParts from the solid modeling operation, for example the results of UnionAsync().
optionsDictionarynil

Options dictionary for the method:

  • tolerance — The distance tolerance, in regards to Attachment preservation, between the attachment and the closest point on the original part's surface versus the closest point on the resulting part's surface. If the resulting distance following the solid modeling operation is greater than this value, the Parent of attachments and their associated constraints will be nil in the returned recommendation table.
  • weldConstraintPreserve — A WeldConstraintPreserve enum value describing how WeldConstraints are preserved in the resulting recommendation table.
  • dropAttachmentsWithoutConstraints — Boolean with default of true. If set to false, Attachments that have no Constraints will be preserved.
Returns

For WeldConstraints:

Key Type
WeldConstraint Class.WeldConstraint
WeldConstraintParent Class.BasePart or nil
WeldConstraintPart0 Class.BasePart
WeldConstraintPart1 Class.BasePart

For NoCollisionConstraints:

Key Type
NoCollisionConstraint Class.NoCollisionConstraint
NoCollisionConstraintParent Class.BasePart or nil
NoCollisionConstraintPart0 Class.BasePart
NoCollisionConstraintPart1 Class.BasePart

FragmentAsync(part: BasePart, sites: Array, options: Dictionary = nil): Array#

Yields

Breaks a BasePart into multiple MeshPart instances, according to the pattern of points passed in, by using voronoi decomposition. Terrain is not supported. Similar to Clone(), the returned parts have no set Parent.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
partBasePartA Part, PartOperation, or MeshPart to operate on.
sitesArrayArray of Vector3 defining the site positions. Each site will become a separate part. You can also provide a jagged 2D array of Vector3 by including inner arrays of Vector3 as elements of the outer array. Each inner array will have all of its voronoi cells merged into a single part. GeometryService:GenerateFragmentSites can be used to easily create this input.
optionsDictionarynil

Options table containing all the controls for the method:

  • CollisionFidelity — The value of CollisionFidelity in the resulting parts, with one caveat: If a 2D array of sites is provided, this collision fidelity will only be applied to parts which came from more than one site. The others will be given Hull precision.
  • RenderFidelity — The value of RenderFidelity in the resulting parts.
  • FluidFidelity — The value of FluidFidelity in the resulting parts.
  • SplitApart — Boolean controlling whether a part should be split into multiple parts if it contains multiple connected components. Default is true (split).
Returns

GenerateFragmentSites(part: BasePart, options: Dictionary = nil): Array#

Provides an array of positions which can easily be passed into FragmentAsync() to perform common types of destruction: Fragmenting an entire BasePart into pieces, or a localized area of a BasePart into pieces.

The positions outputted are partially random, so the output should not be relied on to look exactly the same as the first time it is run with the same parameters.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling. Luau code to mimic this API has also been provided on that page, which can be freely modified if a slightly different effect is desired.

NameTypeDefaultDescription
partBasePartThe Part, PartOperation, or MeshPart which you are planning to pass into FragmentAsync(). This is necessary to make the fragment site generation and the subsequent FragmentAsync() call efficient.
optionsDictionarynil

Options table containing all the controls for the method:

  • SiteSpacing — The approximate distance between sites, which directly corresponds to the diameter of the resulting fragments. If not specified, a reasonable value will be chosen.
  • Origin — If provided, this will be the center of the area to be fragmented. If not provided, the entire object will be fragmented.
  • Radius — If provided, this will be the center of the area to be fragmented. Either Origin and Radius should both be provided, or neither.
Returns

IntersectAsync(part: Instance, parts: Array, options: Dictionary = nil): Array#

Yields

Creates one or more PartOperations or MeshParts from the intersecting geometry of multiple parts. Primitive Parts, PartOperations, and MeshParts are supported as inputs, but not Terrain.

Similarly to Clone(), the returned parts have no set Parent. In most cases, you should parent the results to the same place as the main part, then Destroy() the original parts.

This function replaces BasePart:IntersectAsync(). Go to that page for a description of the differences.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
partInstanceMain Part, PartOperation, or MeshPart to operate on.
partsArrayArray of other parts to intersect with the main part.
optionsDictionarynil

Options table containing all the controls for the method:

  • CollisionFidelity — The value of CollisionFidelity in the resulting parts.
  • RenderFidelity — The value of RenderFidelity or RenderFidelity in the resulting parts.
  • FluidFidelity — The value of FluidFidelity in the resulting parts.
  • SplitApart — Boolean controlling whether the objects should all be kept together or properly split apart. Default is true (split).
Returns

SubtractAsync(part: Instance, parts: Array, options: Dictionary = nil): Array#

Yields

Creates one or more PartOperations or MeshParts consisting of the space occupied by one part minus the space occupied by the other parts. Primitive Parts, PartOperations, and MeshParts are supported as inputs, but not Terrain.

Similarly to Clone(), the returned parts have no set Parent. In most cases, you should parent the results to the same place as the main part, then Destroy() the original parts.

This function replaces BasePart:SubtractAsync(). Go to that page for a description of the differences.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
partInstanceMain Part, PartOperation, or MeshPart to operate on.
partsArrayArray of parts to subtract from the main part.
optionsDictionarynil

Options table containing all the controls for the method:

  • CollisionFidelity — The value of CollisionFidelity in the resulting parts.
  • RenderFidelity — The value of RenderFidelity or RenderFidelity in the resulting parts.
  • FluidFidelity — The value of FluidFidelity in the resulting parts.
  • SplitApart — Boolean controlling whether the objects should all be kept together or properly split apart. Default is true (split).
Returns

SweepPartAsync(part: BasePart, cframes: Array, options: Dictionary = nil): MeshPart#

Yields

Creates a MeshPart which has the shape of the input part stretched/dragged through the given set of CFrame positions. The exact shape of the result is defined as the union of the convex hulls of each adjacent pair of CFrames.

If a single CFrame is provided, the result will be a convex hull of the input part.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
partBasePartA Part, PartOperation, or MeshPart to operate on.
cframesArrayArray of coordinate frames to sweep parts through.
optionsDictionarynil

Options table containing all the controls for the method:

Returns

UnionAsync(part: Instance, parts: Array, options: Dictionary = nil): Array#

Yields

Creates one or more PartOperations or MeshParts consisting of the space occupied by one part plus the space occupied by the other parts. Primitive Parts, PartOperations, and MeshParts are supported as inputs, but not Terrain.

Similarly to Clone(), the returned parts have no set Parent. In most cases, you should parent the results to the same place as the main part, then Destroy() the original parts.

This function replaces BasePart:UnionAsync(). Go to that page for a description of the differences.

For more information and detailed examples, see https://create.roblox.com/docs/parts/solid-modeling#in-experience-solid-modeling.

NameTypeDefaultDescription
partInstanceMain Part, PartOperation, or MeshPart to operate on.
partsArrayArray of parts to union with the main part.
optionsDictionarynil

Options table containing all the controls for the method:

  • CollisionFidelity — The value of CollisionFidelity in the resulting parts.
  • RenderFidelity — The value of RenderFidelity or RenderFidelity in the resulting parts.
  • FluidFidelity — The value of FluidFidelity in the resulting parts.
  • SplitApart — Boolean controlling whether the objects should all be kept together or properly split apart. Default is true (split).
Returns

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed