1
0
forked from cgvr/DeltaVR

test boxes change colours based on progress

This commit is contained in:
2025-12-16 10:43:58 +02:00
parent 5956b9508d
commit 32a5e4f332
5 changed files with 166 additions and 16 deletions

View File

@@ -3,12 +3,14 @@ using UnityEngine;
public class ModelGenerationTestBox : MonoBehaviour
{
public Material activeMaterial;
public Material inactiveMaterial;
public Material loadingMaterial;
public Transform modelSpawnPoint;
public VoiceTranscriptionTestBox voiceTranscriptionTestBox;
private MeshRenderer meshRenderer;
private bool isLoading;
// Start is called before the first frame update
@@ -25,31 +27,25 @@ public class ModelGenerationTestBox : MonoBehaviour
async void OnTriggerEnter(Collider other)
{
if (isLoading) return;
KbmController controller = other.GetComponent<KbmController>();
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
{
meshRenderer.material = activeMaterial;
string inputPrompt = voiceTranscriptionTestBox.currentTextOutput;
isLoading = true;
meshRenderer.material = loadingMaterial;
string modelPath = await PipelineManager.Instance.GenerateModelAsync(inputPrompt);
//LoadModel("D:\\henrisel\\DeltaVR3DModelGeneration\\3d-generation-pipeline\\models\\2025-11-17-16-13-33\\mesh.glb");
GameObject spawnedObject = await PipelineManager.Instance.SpawnModel(modelPath);
spawnedObject.transform.parent = modelSpawnPoint;
spawnedObject.transform.position = modelSpawnPoint.position;
}
}
private void OnTriggerExit(Collider other)
{
KbmController controller = other.GetComponent<KbmController>();
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
{
isLoading = false;
meshRenderer.material = inactiveMaterial;
}
}
}

View File

@@ -9,8 +9,10 @@ public class VoiceTranscriptionTestBox : MonoBehaviour
{
public Material activeMaterial;
public Material inactiveMaterial;
public Material loadingMaterial;
private MeshRenderer meshRenderer;
private bool isLoading;
public WhisperManager whisper;
@@ -22,6 +24,8 @@ public class VoiceTranscriptionTestBox : MonoBehaviour
private void Awake()
{
isLoading = false;
whisper.OnNewSegment += OnNewSegment;
whisper.OnProgress += OnProgressHandler;
@@ -42,6 +46,11 @@ public class VoiceTranscriptionTestBox : MonoBehaviour
void OnTriggerEnter(Collider other)
{
if (isLoading)
{
return;
}
KbmController controller = other.GetComponent<KbmController>();
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
@@ -57,8 +66,9 @@ public class VoiceTranscriptionTestBox : MonoBehaviour
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null | playerOrigin != null)
{
meshRenderer.material = inactiveMaterial;
microphoneRecord.StopRecord();
meshRenderer.material = loadingMaterial;
isLoading = true;
}
}
@@ -82,6 +92,9 @@ public class VoiceTranscriptionTestBox : MonoBehaviour
currentTextOutput = text;
outputText.text = text;
meshRenderer.material = inactiveMaterial;
isLoading = false;
}
private void OnProgressHandler(int progress)