WIP 1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Speckle.ConnectorUnity.Components;
|
||||
@@ -26,8 +27,20 @@ namespace VRSample.Speckle_Helpers
|
||||
|
||||
public IEnumerator ConvertAndSend(GameObject environment, Client client, Stream stream, Branch branch)
|
||||
{
|
||||
Base b = converter.RecursivelyConvertToSpeckle(environment, _ => true);
|
||||
yield return null;
|
||||
//Convert one (top level) object per coroutine update
|
||||
List<Base> convertedRootObjects = new List<Base>();
|
||||
foreach (Transform rootObject in environment.transform)
|
||||
{
|
||||
converter.RecurseTreeToSpeckle(rootObject.gameObject,
|
||||
converter.ConverterInstance.CanConvertToSpeckle,
|
||||
convertedRootObjects);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Base b = new Base()
|
||||
{
|
||||
["@objects"] = convertedRootObjects,
|
||||
};
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace VRSample.Speckle_Helpers
|
||||
Flatten(rootMember.Value, objectsToConvertThisFrame);
|
||||
foreach (var so in objectsToConvertThisFrame)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
var converted = Receiver.Converter.RecursivelyConvertToNative(so, null);
|
||||
|
||||
//Skip empties
|
||||
@@ -55,17 +57,22 @@ namespace VRSample.Speckle_Helpers
|
||||
|
||||
GameObject go = ObjectFactory.CreateGameObject("Interactable", typeof (Rigidbody), typeof (XRGrabInteractable));
|
||||
go.transform.SetParent(parent);
|
||||
|
||||
Rigidbody rb = go.GetComponent<Rigidbody>();
|
||||
rb.drag = 10;
|
||||
rb.useGravity = false;
|
||||
|
||||
IXRInteractable interactable = go.GetComponent<XRGrabInteractable>();
|
||||
XRInteractionManager.RegisterInteractable(interactable);
|
||||
foreach (var o in converted)
|
||||
{
|
||||
if (o.transform.parent == null)
|
||||
o.transform.SetParent(interactable.transform);
|
||||
Collider c = o.AddComponent<MeshCollider>();
|
||||
MeshCollider c = o.AddComponent<MeshCollider>();
|
||||
c.convex = true;
|
||||
interactable.colliders.Add(c);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
XRInteractionManager.UnregisterInteractable(interactable);
|
||||
XRInteractionManager.RegisterInteractable(interactable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user