Generation Service
*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 |
GenerateModelAsync(inputs: GenerateModelInputs,schema: GenerateModelSchema,options: Dictionary?):Tuple |
LoadGeneratedMeshAsync(generationId: string):MeshPart |
SegmentMeshAsync(meshPart: MeshPart,schema: GenerateModelSchema,options: Dictionary?):Tuple |
Tài Liệu Tham Khảo API
Phương Pháp
Generate Mesh Async
Generate Model Async
Generation Service: Generate Model Async(
Tham Số
inputs:GenerateModelInputs |
schema:GenerateModelSchema |
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
endThế 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
endLoad Generated Mesh Async
Segment Mesh Async
Generation Service: Segment Mesh Async(
Tham Số
schema:GenerateModelSchema |
Lợi Nhuận