GeometryService

แสดงที่เลิกใช้งานแล้ว

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

ไม่สามารถสร้าง
บริการ

บริการที่มีการดำเนินการทางภาพที่ไม่เกี่ยวข้องโดยตรงกับวัตถุที่เฉพาะ

สรุป

วิธีการ

  • กลับตารางของ Constraints และ Attachments ซึ่งคุณสามารถเลือกได้ว่าจะเก็บไว้พร้อมกับพ่อแม่ของพวกเขา Errors: No errors found.

  • IntersectAsync(part : Instance,parts : Array,options : Dictionary):Array
    ผลตอบแทน

    สร้างหนึ่งหรือมากกว่า PartOperations จากเหลี่ยมของหนึ่งส่วนและอื่น ๆ

  • SubtractAsync(part : Instance,parts : Array,options : Dictionary):Array
    ผลตอบแทน

    สร้างหนึ่งหรือมากกว่า PartOperations จากส่วนหนึ่งโดยลดเวลาที่ใช้โดยส่วนอื่น

  • UnionAsync(part : Instance,parts : Array,options : Dictionary):Array
    ผลตอบแทน

    สร้างหนึ่งหรือมากกว่า PartOperations จากส่วนหนึ่งเพิ่มการออกแบบโดยภาพลายจากส่วนอื่น

คุณสมบัติ

วิธีการ

CalculateConstraintsToPreserve

กลับตารางของ Constraints และ Attachments ซึ่งคุณสามารถเลือกได้ว่าจะเก็บไว้พร้อมกับพ่อแม่ของพวกเขา การเรียกคืนสิ่งนี้จะทำให้คุณตัดสินใจได้ว่าจะเก็บรักษาข้อจ

หมายเหตุว่าตาราง options สามารถประกอบด้วย tolerance ค่า (จํานวน) และ/หรือ WeldConstraintPreserve ค่า (จํานวน) และ/หรือ 2>WeldConstraintsPreserve2> ค่า (จํานวน) และ/หรือ 5>WeldConstraintsPreserve</

  • tolerance – ความอดทนระยะทางเมื่อเทียบกับการรักษา Attachment – ความอดทนระยะทางเมื่อเทียบกับตำแหน่งที่ใกล้ที่ส
  • weldConstraintPreserve – รายการค่า Enum.WeldConstraintPreserve ที่ระบุวิธีการที่ WeldConstraints ได้รับการรักษาในตารางแนะนำที่เกิดขึ้น

พารามิเตอร์

source: Instance

วัตถุที่แสดงผลคือต้นฉบับที่การดำเนินการของการจำลองแข็งแกร่งดำเนินการบนเช่น part ใน UnionAsync()

destination: Array
options: Dictionary

ตารางตัวเลือกสำหรับวิธี:

  • tolerance – ความอดทนระยะทางเมื่อเทียบกับการรักษา Attachment – ความอดทนระยะทางเมื่อเทียบกับตำแหน่งที่ใกล้ที่ส
  • weldConstraintPreserve – รายการค่า Enum.WeldConstraintPreserve ที่ระบุวิธีการที่ WeldConstraints ได้รับการรักษาในตารางแนะนำที่เกิดขึ้น
ค่าเริ่มต้น: "nil"

ส่งค่ากลับ

ตารางที่มีข้อมูลสำหรับกรณีทั่วไป Constraints , NoCollisionConstraints และ WeldConstraints ในกรณีที่มี 1> Class.Attach1> หรื

สำหรับกรณีทั่วไป Constraints เช่น HingeConstraint :


<tbody>
<tr>
<td>อุปกรณ์เสริม</td>
<td><code>Class.Attachment</code></td>
</tr>
<tr>
<td>ข้อจํากัด</td>
<td><code>Class.Constraint</code></td>
</tr>
<tr>
<td>พ่อค้าแนบ</td>
<td><code>Class.BasePart</code> หรือ <code>ไม่มี</code></td>
</tr>
<tr>
<td>พ่อค้ามีข้อกำหนด</td>
<td><code>Class.BasePart</code> หรือ <code>ไม่มี</code></td>
</tr>
</tbody>
กุญแจชนิด

สำหรับ WeldConstraints :


<tbody>
<tr>
<td>ข้อจํากัดการเชื่อม</td>
<td><code>Class.WeldConstraint</code></td>
</tr>
<tr>
<td>พ่อคุณวลายุประหยัด</td>
<td><code>Class.BasePart</code> หรือ <code>ไม่มี</code></td>
</tr>
<tr>
<td>WeldConstructPart0</td>
<td><code>Class.BasePart</code></td>
</tr>
<tr>
<td>WeldConstruct1</td>
<td><code>Class.BasePart</code></td>
</tr>
</tbody>
กุญแจชนิด

สำหรับ NoCollisionConstraints :


<tbody>
<tr>
<td>ไม่มีข้อจํากัดการชน</td>
<td><code>Class.NoCollisionConstraint</code></td>
</tr>
<tr>
<td>ไม่มีข้อจํากัดการชนกัน</td>
<td><code>Class.BasePart</code> หรือ <code>ไม่มี</code></td>
</tr>
<tr>
<td>ไม่มีข้อจํากัดการชนกันPart0</td>
<td><code>Class.BasePart</code></td>
</tr>
<tr>
<td>ไม่มีข้อจํากัดการชนกัน1</td>
<td><code>Class.BasePart</code></td>
</tr>
</tbody>
กุญแจชนิด

ตัวอย่างโค้ด

The following example shows how to preserve Attachments and Constraints based on a recommended table produced by CalculateConstraintsToPreserve().

Preserve 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 = true
}
local constraintOptions = {
tolerance = 0.1,
weldConstraintPreserve = Enum.WeldConstraintPreserve.All,
dropAttachmentsWithoutConstraints = false
}
-- Perform subtract operation in pcall() since it's asyncronous
local success, newParts = pcall(function()
return GeometryService:SubtractAsync(mainPart, otherParts, options)
end)
if success and newParts then
-- Loop through resulting parts to reparent/reposition
for _, newPart in pairs(newParts) do
newPart.Parent = mainPart.Parent
newPart.CFrame = mainPart.CFrame
newPart.Anchored = mainPart.Anchored
end
-- Calculate constraints/attachments to either preserve or drop
local recommendedTable = GeometryService:CalculateConstraintsToPreserve(mainPart, newParts, constraintOptions)
-- Preserve constraints/attachments based on recommended table
for _, item in pairs(recommendedTable) do
if item.Attachment then
item.Attachment.Parent = item.AttachmentParent
if item.Constraint then
item.Constraint.Parent = item.ConstraintParent
end
elseif item.NoCollisionConstraint then
local newNoCollision = Instance.new("NoCollisionConstraint")
newNoCollision.Part0 = item.NoCollisionPart0
newNoCollision.Part1 = item.NoCollisionPart1
newNoCollision.Parent = item.NoCollisionParent
elseif item.WeldConstraint then
local newWeldConstraint = Instance.new("WeldConstraint")
newWeldConstraint.Part0 = item.WeldConstraintPart0
newWeldConstraint.Part1 = item.WeldConstraintPart1
newWeldConstraint.Parent = item.WeldConstraintParent
end
end
-- Destroy original parts
mainPart.Parent = nil
mainPart:Destroy()
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

IntersectAsync

ผลตอบแทน

สร้างหนึ่งหรือมากกว่า PartOperations จากเหลี่ยมกระบอกของส่วนหลักและส่

ลักษณะต่อไปนี้จากส่วนหลัก ( part ) ใช้กับผลลัพธ์ PartOperations :

ในภาพประกอบต่อไปนี้, IntersectAsync() เรียกใช้โดยการใช้บล็อกสีม่วงและค่าตัวแปรที่ประกอบด้วยบล็อกสีน้ำเงิน ผลลัพธ์ PartOperation จะแปลงเป็นรูปร่างของเรืองเรี

Two block parts overlapping

<figcaption>ชิ้นส่วนที่แยกออกจากกัน</figcaption>
Parts intersected into a new solid model

<figcaption>ผล <code>Class.PartOperation</code></figcaption>

โน้ต

  • เมื่อเปรียบเทียบกับ BasePart:IntersectAsync() วิธีนี้แตกต่างกันดังต่อไปนี้:

    • ส่วนป้อนไม่จำเป็นต้องเป็นลูกของฉาก สามารถทำการพื้นหลังได้
    • เมื่อตัวเลือก SplitApart ถูกตั้งค่าเป็น true (ปกติ) แต่ละตัวจะถูกส่งกลับใน PartOperation ของตัวเอง
    • แต่ละส่วนที่กลับมาอยู่ในพื้นที่หน้าหลักของส่วนหลัก ซึ่งหมายความว่า (0, 0, 0) ของส่วนใดก็ไม่จำเป็นต้องอยู่ในศูนย์กลางของร่างกาย
    • มันเป็นไปได้ที่จะเรียกวิธีนี้ในเครื่องคอมพิวเตอร์ แต่มีข้อจํากัดบางอย่าง ก่อนอื่น เซิร์ฟเวอร์ประการที่สอง ไม่มีการเลียนแบบที่สามารถ
  • ชิ้นส่วนดั้งเดิมที่เหลืออยู่หลังจากการดำเนินงานที่ประสบความสำเร็จ ในกรณีส่วนใหญ่คุณควรประกอบ PartOperations ที่กลับมาใหม่ในสถานที่เดียวกับส่วนหลัก แล้ว Class.Instance.Destroy|

  • โดยปกติ, สีหน้าของผลลัพธ์ PartOperations จะได้รับการยืมจากสมบัติของผลลัพธ์ด้านบน, แม้ว่าคุณจะสามารถเปิด สมบัติของผลลัพธ์ด้านบน เพื่อเปลี่ยนพ

  • หากการเชื่อมต่อกันจะสร้างผลลัพธ์ใด ๆ ของ PartOperations มากกว่า 20,000 สามเหลี่ยม พวกเขาจะถูกเรียบเรียงเป็น 20,000 พวกเขาจะสร้างข้อผิดพลาดด้วยโค้ด -14

  • หากส่วนหลักเคลื่อนที่ในระหว่างการคํานวณของการดําเนินงานคุณสามารถตั้งค่าผลลัพธ์ของผลลัพธ์ให้เป็น CFrame ของส่วนหลักโดยเฉพาะเนื่องจากผลลัพธ์ที่กลับมาอยู่ในพื้นที่คํ

  • หากใช้วิธีนี้กับ PartOperation เป

พารามิเตอร์

part: Instance

หลัก Part หรือ PartOperation เพื่อดำเนินการบน

parts: Array

หน้าต่างของชิ้นส่วนที่จะเชื่อมต่อกับส่วนหลัก

options: Dictionary

ตารางตัวเลือกที่มีการควบคุมทั้งหมดสำหรับวิธีการ:

  • CollisionFidelity – ค่าของ CollisionFidelity ในชิ้นส่วนที่เกิดขึ้น
  • RenderFidelity – ค่าของ RenderFidelity ในชิ้นส่วนที่เกิดขึ้น
  • FluidFidelity – ค่าของ FluidFidelity ในชิ้นส่วนที่เกิดขึ้น
  • SplitApart – การควบคุมว่าตัวอักษรทั้งหมดควรถูกรวมเป็นหนึ่งหรือแบ่งออกเป็นสองส่วนอย่างถูกต้อง ค่าเริ่มต้นคือ true (สปลิท)
ค่าเริ่มต้น: "nil"

ส่งค่ากลับ

หนึ่งหรือมากกว่า PartOperations จากเหลี่ยมของเรืองตัวหลัก ( part ) และเหลี่ยมของอื่นๆ

ตัวอย่างโค้ด

This example intersects the geometry of mainPart and the parts in the otherParts array, splitting them into distinct PartOperations. Then it destroys the original parts involved in the operation.

GeometryService:IntersectAsync()

local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.PurpleBlock
local otherParts = {workspace.BlueBlock}
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = true
}
-- Perform intersect operation in pcall() since it's asyncronous
local success, newParts = pcall(function()
return GeometryService:IntersectAsync(mainPart, otherParts, options)
end)
if success and newParts then
-- Loop through resulting parts to reparent/reposition
for _, newPart in pairs(newParts) do
newPart.Parent = mainPart.Parent
newPart.CFrame = mainPart.CFrame
newPart.Anchored = mainPart.Anchored
end
-- Destroy original parts
mainPart.Parent = nil
mainPart:Destroy()
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

SubtractAsync

ผลตอบแทน

สร้างหนึ่งหรือมากกว่า PartOperations จากส่วนหลักโดยลบภาพเขียวของอื่น ๆ

ลักษณะต่อไปนี้จากส่วนหลัก ( part ) ใช้กับผลลัพธ์ PartOperations :

ในภาพประกอบต่อไปนี้, SubtractAsync() ถูกเรียกใช้โดยใช้ไซลินเดอร์สีน้ำเงินและค่าตัวแปรที่ประกอบด้วยบล็อกสีม่วง ผลลัพธ์ PartOperation จะแก้ไขเป็นรูปร่

Longer block overlapping a cylinder

<figcaption>ชิ้นส่วนที่แยกออกจากกัน</figcaption>
Block part subtracted from cylinder

<figcaption>ผล <code>Class.PartOperation</code></figcaption>

โน้ต

  • เมื่อเปรียบเทียบกับ BasePart:SubtractAsync() วิธีนี้แตกต่างกันดังต่อไปนี้:

    • ส่วนป้อนไม่จำเป็นต้องเป็นลูกของฉาก สามารถทำการพื้นหลังได้
    • เมื่อตัวเลือก SplitApart ถูกตั้งค่าเป็น true (ปกติ) แต่ละตัวจะถูกส่งกลับใน PartOperation ของตัวเอง
    • แต่ละส่วนที่กลับมาอยู่ในพื้นที่หน้าหลักของส่วนหลัก ซึ่งหมายความว่า (0, 0, 0) ของส่วนใดก็ไม่จำเป็นต้องอยู่ในศูนย์กลางของร่างกาย
    • มันเป็นไปได้ที่จะเรียกวิธีนี้ในเครื่องคอมพิวเตอร์ แต่มีข้อจํากัดบางอย่าง ก่อนอื่น เซิร์ฟเวอร์ประการที่สอง ไม่มีการเลียนแบบที่สามารถ
  • ชิ้นส่วนดั้งเดิมที่เหลืออยู่หลังจากการดำเนินงานที่ประสบความสำเร็จ ในกรณีส่วนใหญ่คุณควรประกอบ PartOperations ที่กลับมาใหม่ในสถานที่เดียวกับส่วนหลัก แล้ว Class.Instance.Destroy|

  • โดยปกติ, สีหน้าของผลลัพธ์ PartOperations จะได้รับการยืมจากสมบัติของผลลัพธ์ด้านบน, แม้ว่าคุณจะสามารถเปิด สมบัติของผลลัพธ์ด้านบน เพื่อเปลี่ยนพ

  • หากการลบจะสร้างผลลัพธ์ใด ๆ ใน PartOperations มากกว่า 20,000 สามเหลี่ยม พวกเขาจะถูกเรียบเรียงเป็น 20,000 พวกเขาจะได้รับผลลัพธ์ด้วยรหัส -14

  • หากส่วนหลักเคลื่อนที่ในระหว่างการคํานวณของการดําเนินงานคุณสามารถตั้งค่าผลลัพธ์ของผลลัพธ์ให้เป็น CFrame ของส่วนหลักโดยเฉพาะเนื่องจากผลลัพธ์ที่กลับมาอยู่ในพื้นที่คํ

  • หากใช้วิธีนี้กับ PartOperation เป

พารามิเตอร์

part: Instance

หลัก Part หรือ PartOperation เพื่อดำเนินการบน

parts: Array

รายการของชิ้นส่วนที่จะลบออกจากส่วนหลัก

options: Dictionary

ตารางตัวเลือกที่มีการควบคุมทั้งหมดสำหรับวิธีการ:

  • CollisionFidelity – ค่าของ CollisionFidelity ในชิ้นส่วนที่เกิดขึ้น
  • RenderFidelity – ค่าของ RenderFidelity ในชิ้นส่วนที่เกิดขึ้น
  • FluidFidelity – ค่าของ FluidFidelity ในชิ้นส่วนที่เกิดขึ้น
  • SplitApart – การควบคุมว่าตัวอักษรทั้งหมดควรถูกรวมเป็นหนึ่งหรือแบ่งออกเป็นสองส่วนอย่างถูกต้อง ค่าเริ่มต้นคือ true (สปลิท)
ค่าเริ่มต้น: "nil"

ส่งค่ากลับ

หนึ่งหรือมากกว่า PartOperations จากโครงสร้างของส่วนหลัก ( part ) โดยลบออกจากโครงสร้างของส่วนอื่น

ตัวอย่างโค้ด

This example subtracts the geometry of the parts in the otherParts array from mainPart, splitting the results into distinct PartOperations. Then it destroys the original parts involved in the operation.

GeometryService:SubtractAsync()

local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.BlueCylinder
local otherParts = {workspace.PurpleBlock}
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = true
}
-- Perform subtract operation in pcall() since it's asyncronous
local success, newParts = pcall(function()
return GeometryService:SubtractAsync(mainPart, otherParts, options)
end)
if success and newParts then
-- Loop through resulting parts to reparent/reposition
for _, newPart in pairs(newParts) do
newPart.Parent = mainPart.Parent
newPart.CFrame = mainPart.CFrame
newPart.Anchored = mainPart.Anchored
end
-- Destroy original parts
mainPart.Parent = nil
mainPart:Destroy()
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

UnionAsync

ผลตอบแทน

สร้างหนึ่งหรือมากกว่า PartOperations จากส่วนหลักพร้อมภาพที่โดดเด่นโดยผู้อ

ลักษณะต่อไปนี้จากส่วนหลัก ( part ) ใช้กับผลลัพธ์ PartOperations :

ในภาพประกอบต่อไปนี้, UnionAsync() เรียกใช้บล็อกสีน้ำเงินและค่าย่อที่ประกอบด้วยสีม่วง ผลลัพธ์ PartOperation จะแปลงเป็นรูปร่างของเกียรติยศระหว่างทั้งสองส่วน

Block and cylinder parts overlapping

<figcaption>ชิ้นส่วนที่แยกออกจากกัน</figcaption>
Parts joined together into a single solid union

<figcaption>ผล <code>Class.PartOperation</code></figcaption>

โน้ต

  • เมื่อเปรียบเทียบกับ BasePart:UnionAsync() วิธีนี้แตกต่างกันดังต่อไปนี้:

    • ส่วนป้อนไม่จำเป็นต้องเป็นลูกของฉาก สามารถทำการพื้นหลังได้
    • เมื่อตัวเลือก SplitApart ถูกตั้งค่าเป็น true (ปกติ) แต่ละตัวจะถูกส่งกลับใน PartOperation ของตัวเอง
    • แต่ละส่วนที่กลับมาอยู่ในพื้นที่หน้าหลักของส่วนหลัก ซึ่งหมายความว่า (0, 0, 0) ของส่วนใดก็ไม่จำเป็นต้องอยู่ในศูนย์กลางของร่างกาย
    • มันเป็นไปได้ที่จะเรียกวิธีนี้ในเครื่องคอมพิวเตอร์ แต่มีข้อจํากัดบางอย่าง ก่อนอื่น เซิร์ฟเวอร์ประการที่สอง ไม่มีการเลียนแบบที่สามารถ
  • ชิ้นส่วนดั้งเดิมที่เหลืออยู่หลังจากการดำเนินงานที่ประสบความสำเร็จ ในกรณีส่วนใหญ่คุณควรประกอบ PartOperations ที่กลับมาใหม่ในสถานที่เดียวกับส่วนหลัก แล้ว Class.Instance.Destroy|

  • โดยปกติ, สีของผลลัพธ์ PartOperations จะยืมจากสมบัติของ Color ของอินส่วนปูมต้นฉบับ แม้ว่าคุณจะเปิดใช้งานสมบัติของพวกเขา Class.PartOperation.UsePartColor

  • หากคํานวณความสัมพันธ์ของสหภาพจะสร้างให้เป็น PartOperations มากกว่า 20,000 สามเหลี่ยม พวกเขาจะถูกเรียบเรียงเป็น -14 นี้จะทําให้เกิดข้อผิดพลาดด้วยรหั

  • หากส่วนหลักเคลื่อนที่ในระหว่างการคํานวณของการดําเนินงานคุณสามารถตั้งค่าผลลัพธ์ของผลลัพธ์ให้เป็น CFrame ของส่วนหลักโดยเฉพาะเนื่องจากผลลัพธ์ที่กลับมาอยู่ในพื้นที่คํ

  • หากใช้วิธีนี้กับ PartOperation เป

พารามิเตอร์

part: Instance

หลัก Part หรือ PartOperation เพื่อดำเนินการบน

parts: Array

หน้าย่อของชิ้นส่วนที่จะใช้ร่วมกับชิ้นส่วนหลัก

options: Dictionary

ตารางตัวเลือกที่มีการควบคุมทั้งหมดสำหรับวิธีการ:

  • CollisionFidelity – ค่าของ CollisionFidelity ในชิ้นส่วนที่เกิดขึ้น
  • RenderFidelity – ค่าของ RenderFidelity ในชิ้นส่วนที่เกิดขึ้น
  • FluidFidelity – ค่าของ FluidFidelity ในชิ้นส่วนที่เกิดขึ้น
  • SplitApart – การควบคุมว่าตัวอักษรทั้งหมดควรถูกรวมเป็นหนึ่งหรือแบ่งออกเป็นสองส่วนอย่างถูกต้อง ค่าเริ่มต้นคือ true (สปลิท)
ค่าเริ่มต้น: "nil"

ส่งค่ากลับ

หนึ่งหรือมากกว่า PartOperations จากโครงสร้างของส่วนหลัก ( part ) พร้อมกับโครงสร้างที่ได้รับการใช้งานจากส่วนอื่น

ตัวอย่างโค้ด

This example combines the geometry of mainPart and the parts in the otherParts array, then it destroys the original parts involved in the operation.

GeometryService:UnionAsync()

local GeometryService = game:GetService("GeometryService")
local mainPart = workspace.BlueBlock
local otherParts = {workspace.PurpleCylinder}
local options = {
CollisionFidelity = Enum.CollisionFidelity.Default,
RenderFidelity = Enum.RenderFidelity.Automatic,
SplitApart = false
}
-- 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 then
-- Loop through resulting parts to reparent/reposition
for _, newPart in pairs(newParts) do
newPart.Parent = mainPart.Parent
newPart.CFrame = mainPart.CFrame
newPart.Anchored = mainPart.Anchored
end
-- Destroy original parts
mainPart.Parent = nil
mainPart:Destroy()
for _, otherPart in pairs(otherParts) do
otherPart.Parent = nil
otherPart:Destroy()
end
end

อีเวนต์