1
0
forked from cgvr/DeltaVR

trellis and invokeAI urls configurable in config

This commit is contained in:
2026-01-19 18:55:25 +02:00
parent 4292750b65
commit ad6954884b
8 changed files with 83 additions and 10 deletions

View File

@@ -1,5 +1,4 @@
### TODO ### TODO
* InvokAI ja Trellis URLid teha konfitavaks ka buildis
* glTF loading: vahetada ära shader Universal render pipelin Lit, mitte panna buildi kaasa glTf oma * glTF loading: vahetada ära shader Universal render pipelin Lit, mitte panna buildi kaasa glTf oma
* shape scanner initialisation correct number of confs * shape scanner initialisation correct number of confs
* user flow: grab item? mida krabada * user flow: grab item? mida krabada

View File

@@ -0,0 +1,39 @@
using System.IO;
using UnityEngine;
public class ConfigManager : MonoBehaviour
{
public GameConfig Config { get; private set; }
public static ConfigManager Instance { get; private set; }
private static string configPath => Path.Combine(Application.persistentDataPath, "config.json");
private void Awake()
{
Instance = this;
LoadConfig();
}
public void LoadConfig()
{
if (File.Exists(configPath))
{
string json = File.ReadAllText(configPath);
Config = JsonUtility.FromJson<GameConfig>(json);
}
else
{
// Create config with default values
Config = new GameConfig();
SaveConfig();
}
Debug.Log("Loaded config from: " + configPath);
}
public void SaveConfig()
{
string json = JsonUtility.ToJson(Config, true);
File.WriteAllText(configPath, json);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a9ed26713a3c4c4f8f6be3bbd4af5c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
[System.Serializable]
public class GameConfig
{
public string invokeAIUrl = "http://192.168.0.53:9090";
public string invokeAIModelKey = "81d45960-08a0-4b8c-a48b-e7d73b21bfe2";
public string TrellisUrl = "http://192.168.0.53:7960";
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5412d5465648e6c40bfe932c9098194b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -14,9 +14,7 @@ public class InvokeAiClient : MonoBehaviour
{ {
public static InvokeAiClient Instance { get; private set; } public static InvokeAiClient Instance { get; private set; }
public string INVOKEAI_BASE_URL;
public string DEFAULT_QUEUE_ID = "default"; public string DEFAULT_QUEUE_ID = "default";
public string MODEL_KEY;
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale"; public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
private HttpClient httpClient; private HttpClient httpClient;
@@ -27,7 +25,7 @@ public class InvokeAiClient : MonoBehaviour
{ {
Timeout = TimeSpan.FromSeconds(120) Timeout = TimeSpan.FromSeconds(120)
}; };
httpClient.BaseAddress = new Uri(INVOKEAI_BASE_URL); httpClient.BaseAddress = new Uri(ConfigManager.Instance.Config.invokeAIUrl);
Instance = this; Instance = this;
} }
@@ -520,13 +518,14 @@ public class InvokeAiClient : MonoBehaviour
public async Task<byte[]> GenerateImage(string prompt) public async Task<byte[]> GenerateImage(string prompt)
{ {
string modelKey = ConfigManager.Instance.Config.invokeAIModelKey;
string refinedPrompt = prompt + promptSuffix; string refinedPrompt = prompt + promptSuffix;
JObject args = new JObject() JObject args = new JObject()
{ {
["prompt"] = refinedPrompt, ["prompt"] = refinedPrompt,
["width"] = 512, ["width"] = 512,
["height"] = 512, ["height"] = 512,
["model_key"] = MODEL_KEY, ["model_key"] = modelKey,
}; };
UnityEngine.Debug.Log("Starting image generation..."); UnityEngine.Debug.Log("Starting image generation...");

View File

@@ -9,16 +9,16 @@ public class TrellisClient : MonoBehaviour
{ {
public static TrellisClient Instance { get; private set; } public static TrellisClient Instance { get; private set; }
public string TRELLIS_BASE_URL;
private HttpClient httpClient; private HttpClient httpClient;
private void Awake() private void Awake()
{ {
httpClient = new HttpClient(); httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(TRELLIS_BASE_URL); httpClient.BaseAddress = new Uri(ConfigManager.Instance.Config.TrellisUrl);
Instance = this; Instance = this;
TestConnection();
} }
// Start is called before the first frame update // Start is called before the first frame update
@@ -33,6 +33,12 @@ public class TrellisClient : MonoBehaviour
} }
private async void TestConnection()
{
var statusResp = await httpClient.GetAsync("status");
Debug.Log("Trellis status: " + statusResp.StatusCode);
}
public async Task<byte[]> GenerateModel( public async Task<byte[]> GenerateModel(
string imageBase64, string imageBase64,