PartOperation

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

一個抽象類別,所有零件都基於 固體模型 繼承。

概要

屬性

屬性 繼承自 TriangleMeshPart屬性 繼承自 BasePart屬性 繼承自 PVInstance

方法

方法 繼承自 BasePart方法 繼承自 PVInstance
  • 平行寫入

    獲得 PVInstance 的軸心。

  • PivotTo(targetCFrame : CFrame):()

    將 以及所有其子孫 轉換為指定的 位置,使旋轉點現在位於指定的 位置。

活動

活動 繼承自 BasePart

屬性

RenderFidelity

外掛程式安全性
平行讀取

此屬性決定了固體模型化零件將會顯示的細節程度。它可以設為 Enum.RenderFidelity 枚列的可能值。

預設值為 Automatic ,意味著零件的詳情是根據在下表中列出的相機距離來進行的。


<th>渲染穩定性</th>
</tr>
</thead>
<tbody>
<tr>
<td>少於 250 個單位</td>
<td>最高</td>
</tr>
<tr>
<td>250-500 格</td>
<td>中等</td>
</tr>
<tr>
<td>500 或更多個單位</td>
<td>最低</td>
</tr>
</tbody>
從相機的距離

SmoothingAngle

外掛程式安全性
平行讀取

此屬性代表在 固體模型 零件上之間的閾值值角度以度。如果正常差異小於值,則正常差異將被調整以減少差異。雖然 30 到 70 度之間的值通常會產生良好的結果,但 90 到 180 度之間的值可能會對具有鋒利邊緣的聯盟造成「陰影」效果,因此不建議使用。

請注意,平滑不會影響不同材料或不同顏色之間的正常。

Solid modeled part with SmoothingAngle of 0

<figcaption><code>Class.PartOperation.SmoothingAngle|SmoothingAngle</code> = 0</figcaption>
Solid modeled part with SmoothingAngle of 50

<figcaption><code>Class.PartOperation.SmoothingAngle|SmoothingAngle</code> = 50</figcaption>

TriangleCount

唯讀
未複製
平行讀取

此固體模型中的多邊形數量。

UsePartColor

平行讀取

設置是否可以使用 PartOperationBasePart.ColorBasePart.BrickColor 屬性重新上色。當真實時,整個聯盟將以 ColorBrickColor 的方式被彩色。當為 false 時,聯盟中的零件會保留從洋蔥操作執行之前的原始顏色。

方法

SubstituteGeometry

()

用另一個 PartOperation 的幾何圖形來取代這個 PartOperation 的幾何圖形。這使得使用像 UnionAsync()SubtractAsync()IntersectAsync() 等固體模型操作的幾何學變得更容易,但仍保留主部分的特性、標籤、標籤和子部分的兒童,例如 AttachmentsConstraintsParticleEmitters、輕型對象、裝飾和更多。這種方法也可以避免完全替換原始 PartOperation 的潛在"閃爍"。

請注意,如果您在 PartOperation 上呼叫此方法並將其作為子 AttachmentsConstraints 使用,您應該使用 CalculateConstraintsToPreserve() 計算受影響的實例,然後放棄那些建議的父親是 nil 的。

參數

source: Instance

PartOperation 的幾何圖形將會替換此 PartOperation 的幾何圖形。

預設值:""

返回

()

範例程式碼

The following example substitutes the geometry of one PartOperation with the geometry of another PartOperation, then drops constraints/attachments that should not be preserved after substitution.

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

活動