Generation Service
概要
方法
GenerateMeshAsync(inputs: Dictionary,player: Player,options: Dictionary,intermediateResultCallback: function?):Tuple |
GenerateModelAsync(inputs: Dictionary,schema: Dictionary,options: Dictionary?):Tuple |
LoadGeneratedMeshAsync(generationId: string):MeshPart |
SegmentMeshAsync(meshPart: MeshPart,schema: Dictionary,options: Dictionary?):Tuple |
APIリファレンス
方法
Generate Mesh Async
Generate Model Async
Generation Service: Generate Model Async(
パラメータ
戻り値
コードサンプル
基本的な車体シャーシの生成
local GenerationService = game:GetService("GenerationService")
local Workspace = game:GetService("Workspace")
-- 生成されたジオメトリの入力を設定します
local inputs = {
TextPrompt = "4つの車輪を持つ緑のドラゴンカー"
}
-- 事前定義された5モデルの車シャーシにスキーマを設定します
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 = "画像条件生成"
model.Parent = Workspace
endLoad Generated Mesh Async
Segment Mesh Async
パラメータ
戻り値