요약
메서드
GenerateMeshAsync(inputs: Dictionary,player: Player,options: Dictionary,intermediateResultCallback: function?):Tuple |
GenerateModelAsync(inputs: Dictionary,schema: Dictionary,options: Dictionary?):Tuple |
LoadGeneratedMeshAsync(generationId: string):MeshPart |
상속된 멤버
API 참조
메서드
GenerateMeshAsync
GenerateModelAsync
GenerationService:GenerateModelAsync(
매개 변수
반환
코드 샘플
기본 자동차 섀시 생성
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
-- 모델의 이름을 지정하고 워크스페이스에 부모로 설정합니다.
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
-- 모델의 이름을 지정하고 작업 공간에 부모로 설정합니다.
model.Name = "이미지 기반 생성"
model.Parent = Workspace
end