エンジンクラス
GenerationService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
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つの車輪を持つ緑のドラゴン車"
}
-- 事前定義された5モデルの車体シャーシにスキーマを設定
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 = "ImageConditionedGeneration"
model.Parent = Workspace
end