เรียนรู้
Engine Class
PartOperation

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
สมาชิกที่ได้รับทอด
ได้รับทอดโดย

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
RenderFidelity
การรักษาความปลอดภัยของปลั๊กอิน
อ่านพร้อมๆ กัน
ความสามารถ: Basic, CSG
PartOperation.RenderFidelity:Enum.RenderFidelity

SmoothingAngle
การรักษาความปลอดภัยของปลั๊กอิน
อ่านพร้อมๆ กัน
ความสามารถ: Basic, CSG
PartOperation.SmoothingAngle:number

TriangleCount
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Basic, CSG
PartOperation.TriangleCount:number

UsePartColor
อ่านพร้อมๆ กัน
ความสามารถ: Basic, CSG
PartOperation.UsePartColor:boolean

วิธีการ
SubstituteGeometry
ความสามารถ: Basic, CSG
PartOperation:SubstituteGeometry(source:Instance):()
พารามิเตอร์
source:Instance
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การแทนที่รูปทรงเรขาคณิตและการลดข้อจำกัด
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,
}
-- ดำเนินการรวมใน pcall() เนื่องจากมันเป็นแบบอะซิงโครนัส
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, otherParts, options)
end)
if success and #newParts > 0 and mainPart:IsA("PartOperation") then
-- ตั้งค่าชิ้นส่วนแรกในผลลัพธ์การดำเนินการเป็นชิ้นส่วนที่จะใช้ในการแทนที่
-- ชิ้นส่วนแรกเป็นเพียงทางเลือก; นี่สามารถเป็น PartOperation ใดก็ได้
local substitutePart = newParts[1]
-- เปลี่ยนตำแหน่งชิ้นส่วนให้ตรงกับตำแหน่งของชิ้นส่วนหลัก
substitutePart.CFrame = mainPart.CFrame
-- คำนวณข้อจำกัด/การแนบที่จะเก็บรักษาหรือทำการลด
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- แทนที่รูปทรงเรขาคณิตของชิ้นส่วนหลักด้วยรูปทรงเรขาคณิตการแทนที่
mainPart:SubstituteGeometry(substitutePart)
-- ลดข้อจำกัด/การแนบที่ไม่ถูกเก็บรักษาโดยอัตโนมัติด้วยการแทนที่
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
-- ทำลายชิ้นส่วนอื่น
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ