1
0
forked from cgvr/DeltaVR

add TrellisClient, use it for model generation

This commit is contained in:
2025-12-22 15:07:23 +02:00
parent 1b3b3db1bf
commit 7bc58a48d0
8 changed files with 191 additions and 49 deletions

View File

@@ -9,14 +9,16 @@ public class ImageGenerationBox : MonoBehaviour
public Material loadingMaterial;
public VoiceTranscriptionBox voiceTranscriptionTestBox;
public Image UIImage;
public Image imageDisplay;
public Texture2D LastTexture { get; private set; }
public string promptSuffix = ", single object, front and side fully visible, realistic style, plain neutral background, clear details, soft studio lighting, true-to-scale";
private MeshRenderer meshRenderer;
private bool isLoading;
// Start is called before the first frame update
void Start()
// Start is called before the first frame update
void Start()
{
meshRenderer = GetComponent<MeshRenderer>();
}
@@ -42,15 +44,16 @@ public class ImageGenerationBox : MonoBehaviour
meshRenderer.material = loadingMaterial;
byte[] imageBytes = await InvokeAiClient.Instance.GenerateImage(refinedPrompt);
Sprite sprite = CreateSprite(imageBytes);
UIImage.sprite = sprite;
LastTexture = CreateTexture(imageBytes);
Sprite sprite = CreateSprite(LastTexture);
imageDisplay.sprite = sprite;
isLoading = false;
meshRenderer.material = inactiveMaterial;
}
}
private Sprite CreateSprite(byte[] imageBytes)
private Texture2D CreateTexture(byte[] imageBytes)
{
var tex = new Texture2D(2, 2, TextureFormat.RGBA32, false);
// ImageConversion.LoadImage returns bool (true = success)
@@ -59,10 +62,15 @@ public class ImageGenerationBox : MonoBehaviour
Destroy(tex);
throw new InvalidOperationException("Failed to decode image bytes into Texture2D.");
}
tex.filterMode = FilterMode.Bilinear;
tex.wrapMode = TextureWrapMode.Clamp;
return tex;
}
private Sprite CreateSprite(Texture2D tex)
{
var sprite = Sprite.Create(
tex,
new Rect(0, 0, tex.width, tex.height),