エンジンクラス
PartOperation
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
方法
SubstituteGeometry(source: Instance):() |
継承されたメンバー
TriangleMeshPartから継承された3
BasePartから継承された105
PVInstanceから継承された4
Instanceから継承された58
Objectから継承された6
APIリファレンス
プロパティ
方法
SubstituteGeometry
パラメータ
戻り値
()
コードサンプル
ジオメトリの置き換えと制約の削除
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