เรียนรู้
Engine Class
GenerationService
ไม่สามารถสร้าง
บริการ

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


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

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

GenerateModelAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
GenerationService:GenerateModelAsync(
inputs:Dictionary, schema:Dictionary, options:Dictionary?
พารามิเตอร์
inputs:Dictionary
schema:Dictionary
options:Dictionary?
ส่งค่ากลับ
ตัวอย่างโค้ด
การสร้างโครงรถยนต์พื้นฐาน
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- ตั้งค่าการป้อนข้อมูลสำหรับเรขาคณิตที่สร้าง
local inputs = {
TextPrompt = "รถมังกรสีเขียวที่มีล้อ 4"
}
-- ตั้งค่าสคีมาสำหรับโครงรถยนต์ห้ารูปแบบที่กำหนดไว้ล่วงหน้า
local schema = {
PredefinedSchema = "Car5"
}
-- ทำการเรียกเพื่อสร้างโมเดล
local success, model, metadata = 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, metadata = 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, metadata = 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
ส่งค่ากลับ

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