PartOperation

Pokaż przestarzałe

*Ta zawartość będzie dostępna wkrótce w wybranym przez ciebie języku.

An abstract class that all parts based on solid modeling inherit from.

Podsumowanie

Właściwości

Właściwości odziedziczeni z: TriangleMeshPartWłaściwości odziedziczeni z: BasePartWłaściwości odziedziczeni z: PVInstance
  • Bez replikacji
    Brak możliwości dodawania do skryptu
    Odczyt równoległy
  • Bez replikacji
    Brak możliwości dodawania do skryptu
    Odczyt równoległy

Metody

Metody odziedziczeni z: BasePartMetody odziedziczeni z: PVInstance

Zdarzenia

Zdarzenia odziedziczeni z: BasePart

Właściwości

RenderFidelity

Odczyt równoległy
Zabezpieczenia dodatku plug-in

This property determines the level of detail that the solid modeled part will be shown in. It can be set to the possible values of the Enum.RenderFidelity enum.

The default value is Automatic, meaning the part's detail is based on its distance from the camera as outlined in the following table.

Distance From CameraRender Fidelity
Less than 250 studsHighest
250-500 studsMedium
500 or more studsLowest

SmoothingAngle

Odczyt równoległy
Zabezpieczenia dodatku plug-in

This property represents an angle in degrees for a threshold value between face normals on a solid modeled part. If the normal difference is less than the value, normals will be adjusted to smooth the difference. While a value between 30 and 70 degrees usually produces a good result, values between 90 and 180 are not recommended as they may cause a "shadowing" effect on unions with sharp edges.

Note that smoothing does not affect the normals between different materials or different colors.

Solid modeled part with SmoothingAngle of 0
SmoothingAngle = 0
Solid modeled part with SmoothingAngle of 50
SmoothingAngle = 50

TriangleCount

Tylko do odczytu
Bez replikacji
Odczyt równoległy

The number of polygons in this solid model.

UsePartColor

Odczyt równoległy

Sets whether the PartOperation can be recolored using the BasePart.Color or BasePart.BrickColor properties. When true, the entire union will be colored as per Color or BrickColor. When false, the parts in the union will maintain their original colors from before the onion operation was performed.

Metody

SubstituteGeometry

void

Substitutes the geometry of this PartOperation with the geometry of another PartOperation. This makes it easier to utilize the geometry of a solid modeling operation like UnionAsync(), SubtractAsync(), or IntersectAsync() but maintain properties, attributes, tags, and children of the main part such as Attachments, Constraints, ParticleEmitters, light objects, decals, and more. This approach also circumvents the potential "flicker" of completely replacing the original PartOperation with another.

Note that if you're calling this method on a PartOperation with child Attachments or Constraints, you should calculate the affected instances with CalculateConstraintsToPreserve(), then drop those whose recommended parent is nil.

Parametry

source: Instance

The PartOperation whose geometry will substitute the geometry of this PartOperation.


Zwroty

void

Przykłady kodu

Substitute Geometry and Drop Constraints

local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.PurpleBlock
local otherParts = {workspace.BlueBlock}
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = false
}
local constraintOptions = {
tolerance = 0.1,
weldConstraintPreserve = Enum.WeldConstraintPreserve.All
}
-- Perform union operation in pcall() since it's asyncronous
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, otherParts, options)
end)
if success and #newParts > 0 and mainPart:IsA("PartOperation") then
-- Set first part in resulting operation as part to use for substitution
-- First part is simply an option; this can be any PartOperation
local substitutePart = newParts[1]
-- Reposition part to the position of main part
substitutePart.CFrame = mainPart.CFrame
-- Calculate constraints/attachments to either preserve or drop
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- Substitute main part's geometry with substitution geometry
mainPart:SubstituteGeometry(substitutePart)
-- Drop constraints/attachments that are not automatically preserved with substitution
for _, item in pairs(recommendedTable) do
if item.Attachment then
if item.ConstraintParent == nil then
item.Constraint.Parent = nil
end
if item.AttachmentParent == nil then
item.Attachment.Parent = nil
end
elseif item.WeldConstraint then
if item.Parent == nil then
item.WeldConstraint.Parent = nil
end
end
end
-- Destroy other parts
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

Zdarzenia