Ghi chú phát hành
Học
Lớp công cụ
GeometryService
Không Thể Tạo
Dịch Vụ

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm Tắt
Thành viên kế thừa

Tài Liệu Tham Khảo API
Phương Pháp
CalculateConstraintsToPreserve
Các khả năng: CSG
GeometryService:CalculateConstraintsToPreserve(
source:Instance, destination:{any}, options:Dictionary
Tham Số
source:Instance
destination:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Giữ nguyên Ràng buộc
local GeometryService = game:GetService("GeometryService")
local main, other = workspace.Part1, workspace.Part2
local success, newParts = pcall(function()
return GeometryService:SubtractAsync(main, {other})
end)
if success and newParts then
for _, p in newParts do p.Parent = workspace end
for _, rec in GeometryService:CalculateConstraintsToPreserve(main, newParts) do
if rec.Constraint then
rec.Constraint.Parent = rec.ConstraintParent
end
end
end
main:Destroy()
other:Destroy()

FragmentAsync
Sinh Lợi
Các khả năng: CSG
GeometryService:FragmentAsync(
part:BasePart, sites:{any}, options:Dictionary
Tham Số
sites:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Phá vỡ một Phần
local GeometryService = game:GetService("GeometryService")
local inputPart = Instance.new("Part")
inputPart.Position = Vector3.new(0, 0.7, 20)
local sites = GeometryService:GenerateFragmentSites(inputPart)
local success, fragments = pcall( function()
return GeometryService:FragmentAsync(inputPart, sites)
end)
if success and fragments then
for _, item in fragments do
local instance = item.Instance
instance.Parent = workspace
end
end

GenerateFragmentSites
Các khả năng: CSG
GeometryService:GenerateFragmentSites(
part:BasePart, options:Dictionary
Tham Số
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Mảnh địa phương hóa
local GeometryService = game:GetService("GeometryService")
local inputPart = workspace.Part
local pos = inputPart.Position + inputPart.Size / 2
local sites = GeometryService:GenerateFragmentSites(inputPart, {Origin = pos, Radius = 1.5})
local success, fragments = pcall( function()
return GeometryService:FragmentAsync(inputPart, sites)
end)
if success and fragments then
for _, item in fragments do
local instance = item.Instance
instance.Parent = inputPart.Parent
end
inputPart:Destroy()
end

IntersectAsync
Sinh Lợi
Các khả năng: CSG
GeometryService:IntersectAsync(
part:Instance, parts:{any}, options:Dictionary
Tham Số
parts:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Giao nhau hai phần
local GeometryService = game:GetService("GeometryService")
local mainPart = Instance.new("Part")
local otherPart = Instance.new("Part")
otherPart.Position = Vector3.new(1, 0.5, 1)
local success, newParts = pcall(function()
return GeometryService:IntersectAsync(mainPart, {otherPart})
end)
if success and newParts then
for _, newPart in pairs(newParts) do
newPart.Parent = workspace
end
end

SubtractAsync
Sinh Lợi
Các khả năng: CSG
GeometryService:SubtractAsync(
part:Instance, parts:{any}, options:Dictionary
Tham Số
parts:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Trừ hai phần
local GeometryService = game:GetService("GeometryService")
local mainPart = Instance.new("Part")
local otherPart = Instance.new("Part")
otherPart.Position = Vector3.new(1, 0.5, 1)
local success, newParts = pcall(function()
return GeometryService:SubtractAsync(mainPart, {otherPart})
end)
if success and newParts then
for _, newPart in pairs(newParts) do
newPart.Parent = workspace
end
end

SweepPartAsync
Sinh Lợi
Các khả năng: CSG
GeometryService:SweepPartAsync(
part:BasePart, cframes:{any}, options:Dictionary
Tham Số
cframes:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Quét một phần
local GeometryService = game:GetService("GeometryService")
local inputPart = Instance.new("Part")
inputPart.Shape = Enum.PartType.Ball
local cframeList = {}
for i = 1, 50 do
local rotation = CFrame.Angles(0, i * 0.2, 0)
local position = Vector3.new(0, i * 0.1, -1)
table.insert(cframeList, rotation * CFrame.new(position))
end
local success, sweptPart = pcall( function()
return GeometryService:SweepPartAsync(inputPart, cframeList)
end)
if success and sweptPart then
sweptPart.Parent = workspace
end

UnionAsync
Sinh Lợi
Các khả năng: CSG
GeometryService:UnionAsync(
part:Instance, parts:{any}, options:Dictionary
Tham Số
parts:{any}
options:Dictionary
Giá Trị Mặc Định: "nil"
Lợi Nhuận
Mẫu mã
Gộp hai phần
local GeometryService = game:GetService("GeometryService")
local mainPart = Instance.new("Part")
local otherPart = Instance.new("Part")
otherPart.Position = Vector3.new(1, 0.5, 1)
local success, newParts = pcall(function()
return GeometryService:UnionAsync(mainPart, {otherPart})
end)
if success and newParts then
for _, newPart in pairs(newParts) do
newPart.Parent = workspace
end
end

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.