1
0
forked from cgvr/DeltaVR
Files
DeltaVR3DModelGeneration/Assets/_PROJECT/Scripts/3DModeGeneration/ModelGenerationTestBox.cs

52 lines
1.5 KiB
C#

using Unity.XR.CoreUtils;
using UnityEngine;
public class ModelGenerationTestBox : MonoBehaviour
{
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
void Start()
{
meshRenderer = GetComponent<MeshRenderer>();
}
// Update is called once per frame
void Update()
{
}
async void OnTriggerEnter(Collider other)
{
if (isLoading) return;
KbmController controller = other.GetComponent<KbmController>();
XROrigin playerOrigin = other.GetComponent<XROrigin>();
if (controller != null || playerOrigin != null)
{
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;
isLoading = false;
meshRenderer.material = inactiveMaterial;
}
}
}