Generation Service
요약
메서드
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 |
상속된 멤버
API 참조
메서드
Generate Mesh Async
Generate Model Async
Generation Service: Generate Model Async(
매개 변수
inputs:GenerateModelInputs |
schema:GenerateModelSchema |
반환
코드 샘플
기본 자동차 섀시 생성
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- 생성된 기하학을 위한 입력 설정
local inputs = {
TextPrompt = "4개의 바퀴가 있는 초록색 드래곤 자동차"
}
-- 미리 정의된 다섯 모델 자동차 섀시로 스키마 설정
local schema = {
PredefinedSchema = "Car5"
}
-- 모델 생성을 위한 호출
local success, model = 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 = 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 = 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 = "ImageConditionedGeneration"
model.Parent = Workspace
endLoad Generated Mesh Async
Segment Mesh Async
Generation Service: Segment Mesh Async(
매개 변수
schema:GenerateModelSchema |
반환