Ghi chú phát hành
Học
Lớp công cụ
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
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:Dictionary, schema:Dictionary, options:Dictionary?
Tham Số
inputs:Dictionary
schema:Dictionary
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 các đầu vào cho hình học được tạo ra
local inputs = {
TextPrompt = "một chiếc xe rồng màu xanh lá cây với 4 bánh"
}
-- Đặt lược đồ thành khung xe năm mô hình đã định nghĩa sẵn
local schema = {
PredefinedSchema = "Car5"
}
-- Thực hiện lời gọi để tạo mô hình
local success, model, metadata = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Tỷ lệ 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))
-- Neo tất cả các bộ phận để các lưới không bị tách 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à cha nó vào workspace
model.Name = "TạoXeRồngCơBản"
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 cần tạo
local inputs = {
TextPrompt = "một chiếc xe gỗ có bốn bánh",
}
-- Định nghĩa một cấu trúc nhiều phần tùy chỉnh thay vì sử dụng schema đã định nghĩa sẵn.
-- Mỗi mục trong `Groups` đặt tên cho một phần mà quá trình tạo ra cầ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 mô hình
local success, model, metadata = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Ghim tất cả các phần để các mô hình không bị rơi rụng
for _, descendant in model:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- Đặt tên cho mô hình và đưa 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 cho việc sinh ra. Thay thế `0` bằng ID
-- tài sản của hình ảnh 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 dạng low-poly",
}
-- Tạo một đầu ra duy nhất cho lưới
local schema = {
PredefinedSchema = "Body1",
}
-- Thực hiện cuộc gọi để sinh ra mô hình
local success, model, metadata = pcall(function()
return GenerationService:GenerateModelAsync(inputs, schema)
end)
if success then
-- Gắn 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 cho nó trở thành cha của 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

©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.