GenerationService
Không Thể Tạo
Dịch Vụ

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.


Tóm tắt

Phương Pháp
GenerateMeshAsync(inputs: Dictionary,player: Player,options: Dictionary,intermediateResultCallback: function?):Tuple
Đã Lỗi Thời
GenerateModelAsync(inputs: GenerateModelInputs,schema: GenerateModelSchema,options: Dictionary?):Tuple
SegmentMeshAsync(meshPart: MeshPart,schema: GenerateModelSchema,options: Dictionary?):Tuple
Thành viên kế thừa

Tài Liệu Tham Khảo API
Phương Pháp
GenerateMeshAsync
Đã Lỗi Thời

GenerateModelAsync
Sinh Lợi
Các khả năng: DynamicGeneration
GenerationService:GenerateModelAsync(
inputs:GenerateModelInputs, schema:GenerateModelSchema, options:Dictionary?
Tham Số
inputs:GenerateModelInputs
schema:GenerateModelSchema
options:Dictionary?
Lợi Nhuận
Mẫu mã
Thế hệ Khung Xe Cơ Bản
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- Thiết lập đầu vào cho hình học được tạo ra
local inputs = {
TextPrompt = "một chiếc xe rồng xanh với 4 bánh"
}
-- Đặt sơ đồ cho khung xe năm mô hình đã định nghĩa trước
local schema = {
PredefinedSchema = "Car5"
}
-- Thực hiện cuộc gọi để tạo mô hình
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Thay đổi kích thước mô hình đến kích thước mục tiêu và vị trí gần trung tâm thế giới
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))
-- Ghim tất cả các phần để các lưới không bị rời ra
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- Đặt tên cho mô hình và làm cha nó vào workspace
model.Name = "BasicDragonCarGeneration"
model.Parent = Workspace
end
Thế hệ với một Schema Tùy chỉnh
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- Mô tả đối tượng để tạo ra
local inputs = {
TextPrompt = "một chiếc xe gỗ với bốn bánh",
}
-- Định nghĩa một cấu trúc đa phần tùy chỉnh thay vì sử dụng một sơ đồ đã định nghĩa sẵn.
-- Mỗi mục trong `Groups` đặt tên cho một phần mà việc tạo ra nên sản xuất.
local schema = {
SchemaDefinition = {
Groups = { "body", "wheel_fl", "wheel_fr", "wheel_rl", "wheel_rr" },
},
}
-- Thực hiện cuộc gọi để tạo ra mô hình
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Ghim tất cả các phần để các lưới không bị rời ra
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- Đặt tên cho mô hình và gán nó vào workspace
model.Name = "CustomSchemaGeneration"
model.Parent = Workspace
end
Điều kiện thế hệ dựa trên hình ảnh
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- Hình ảnh tham chiếu được sử dụng để điều kiện hóa việc tạo ra. Thay thế `0` bằng tài sản
-- ID của hình ảnh mà bạn đã tải lên.
local imageAssetId = 0
local inputs = {
Image = Content.fromAssetId(imageAssetId),
TextPrompt = "một chiếc rương kho báu low-poly",
}
-- Tạo ra một đầu ra đơn lưới
local schema = {
PredefinedSchema = "Body1",
}
-- Thực hiện cuộc gọi để tạo mô hình
local success, model = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Ghim tất cả các phần để các lưới không bị rời ra
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- Đặt tên cho mô hình và gán nó vào workspace
model.Name = "ImageConditionedGeneration"
model.Parent = Workspace
end

LoadGeneratedMeshAsync
Sinh Lợi
Các khả năng: DynamicGeneration
GenerationService:LoadGeneratedMeshAsync(generationId:string):MeshPart
Tham Số
generationId:string
Lợi Nhuận

SegmentMeshAsync
Sinh Lợi
Các khả năng: DynamicGeneration
GenerationService:SegmentMeshAsync(
meshPart:MeshPart, schema:GenerateModelSchema, options:Dictionary?
Tham Số
meshPart:MeshPart
schema:GenerateModelSchema
options:Dictionary?
Lợi Nhuận

©2026 Roblox Corporation. Roblox, logo Roblox và Powering Imagination là các nhãn hiệu đã đăng ký và chưa đăng ký của chúng tôi tại Hoa Kỳ và các quốc gia khác.