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

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


ข้อมูลสรุป

วิธีการ
GenerateMeshAsync(inputs: Dictionary,player: Player,options: Dictionary,intermediateResultCallback: function?):Tuple
เลิกใช้แล้ว
GenerateModelAsync(inputs: GenerateModelInputs,schema: GenerateModelSchema,options: Dictionary?):Tuple
SegmentMeshAsync(meshPart: MeshPart,schema: GenerateModelSchema,options: Dictionary?):Tuple
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GenerateMeshAsync
เลิกใช้แล้ว

GenerateModelAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
GenerationService:GenerateModelAsync(
inputs:GenerateModelInputs, schema:GenerateModelSchema, options:Dictionary?
พารามิเตอร์
inputs:GenerateModelInputs
schema:GenerateModelSchema
options:Dictionary?
ส่งค่ากลับ
ตัวอย่างโค้ด
การสร้างโครงรถยนต์พื้นฐาน
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- ตั้งค่าข้อมูลนำเข้าสำหรับเรขาคณิตที่สร้างขึ้น
local inputs = {
TextPrompt = "รถมังกรสีเขียวที่มีล้อ 4 ล้อ"
}
-- ตั้งค่าสคีมาสำหรับโครงรถห้ารุ่นที่กำหนดไว้ล่วงหน้า
local schema = {
PredefinedSchema = "Car5"
}
-- ทำการเรียกเพื่อสร้างโมเดล
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- ปรับขนาดโมเดลให้มีขนาดเป้าหมายและวางใกล้ศูนย์กลางของโลก
local targetSize = 16
local modelSize = model:GetExtentsSize()
local scaleFactor = targetSize / math.max(modelSize.X, modelSize.Y, modelSize.Z)
model:ScaleTo(scaleFactor)
model:PivotTo(CFrame.new(15, model:GetExtentsSize().Y / 2, 0))
-- ยึดชิ้นส่วนทั้งหมดเพื่อไม่ให้เมชหลุดออก
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- ตั้งชื่อโมเดลและทำให้เป็นพ่อแม่ในเวิร์กสเปซ
model.Name = "BasicDragonCarGeneration"
model.Parent = Workspace
end
การสร้างด้วยสคีมาที่กำหนดเอง
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- อธิบายวัตถุที่จะสร้าง
local inputs = {
TextPrompt = "รถเข็นไม้ที่มีล้อสี่ล้อ",
}
-- กำหนดโครงสร้างหลายส่วนที่กำหนดเองแทนการใช้สคีมาที่กำหนดไว้ล่วงหน้า
-- แต่ละรายการใน `Groups` ตั้งชื่อส่วนที่การสร้างควรผลิต
local schema = {
SchemaDefinition = {
Groups = { "body", "wheel_fl", "wheel_fr", "wheel_rl", "wheel_rr" },
},
}
-- ทำการเรียกเพื่อสร้างโมเดล
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- ยึดส่วนทั้งหมดเพื่อไม่ให้เมชหลุดออก
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- ตั้งชื่อโมเดลและทำให้เป็นพ่อแม่ใน workspace
model.Name = "CustomSchemaGeneration"
model.Parent = Workspace
end
การสร้างที่มีเงื่อนไขตามภาพ
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- อ้างอิงภาพที่ใช้ในการสร้าง. เปลี่ยน `0` เป็น
-- ID ของสินทรัพย์ภาพที่คุณอัปโหลดเอง.
local imageAssetId = 0
local inputs = {
Image = Content.fromAssetId(imageAssetId),
TextPrompt = "กล่องสมบัติแบบโลว์โพลี",
}
-- ผลิตผลลัพธ์แบบเมชเดียว
local schema = {
PredefinedSchema = "Body1",
}
-- ทำการเรียกเพื่อสร้างโมเดล
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- ยึดทุกส่วนเพื่อไม่ให้เมชหลุดออก
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- ตั้งชื่อโมเดลและทำให้เป็นพ่อแม่ใน workspace
model.Name = "การสร้างตามเงื่อนไขภาพ"
model.Parent = Workspace
end

LoadGeneratedMeshAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
GenerationService:LoadGeneratedMeshAsync(generationId:string):MeshPart
พารามิเตอร์
generationId:string
ส่งค่ากลับ

SegmentMeshAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
GenerationService:SegmentMeshAsync(
meshPart:MeshPart, schema:GenerateModelSchema, options:Dictionary?
พารามิเตอร์
meshPart:MeshPart
schema:GenerateModelSchema
options:Dictionary?
ส่งค่ากลับ

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ