PartOperation

显示已弃用

*此内容使用人工智能(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

读取并联

设置 whether the PartOperation 可以使用 BasePart.ColorBasePart.BrickColor 属性重新着色。当真实时,整个联盟将按照 ColorBrickColor 的颜色进行颜色。当为 false 时,联盟中的部件会保留从洋葱操作执行之前的原始颜色。

方法

SubstituteGeometry

()

用另一个 PartOperation 的几何图形替换这个 PartOperation 的几何图形。这使得更容易使用固体建模操作的几何,例如 UnionAsync() , SubtractAsync() ,或 IntersectAsync() 但保留主部分的属性、属性、标签和子部件,例如 Attachments , Constraints , ParticleEmitters ,轻型对象、装饰和更多。这种方法也可以避免完全替换原始 PartOperation 的潜在"闪烁"。

请注意,如果你在 上调用此方法,并将其与子 或 结合,那么你应该计算受影响的实例,然后丢弃那些建议的父级是 的实例。

参数

source: Instance

whose 几何图形将替换这个 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

活动