1
0
forked from cgvr/DeltaVR

scale spawned object to match given bounding sphere diameter

This commit is contained in:
2026-02-07 14:10:12 +02:00
parent 9fd4188d55
commit 7384a21d58
3 changed files with 59 additions and 10 deletions

View File

@@ -13,6 +13,7 @@ public class CafeWaiterNPC : NPCController
public Transform backRoom;
public Transform plate;
public float backRoomMovingTime = 5f;
public float spawnedFoodDiameter = 0.5f;
public int ignorePlayerCollisionLayer = 2;
@@ -135,7 +136,7 @@ public class CafeWaiterNPC : NPCController
Sprite sprite = ModelGenerationUtils.CreateSprite(GeneratedTexture);
string encodedTexture = Convert.ToBase64String(GeneratedTexture.EncodeToJPG());
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel, spawnedFoodDiameter);
// Come back
transform.DOMove(startingPosition, backRoomMovingTime).OnComplete(() =>
@@ -160,6 +161,7 @@ public class CafeWaiterNPC : NPCController
spawnedObjectCollider.convex = true;
spawnedObject.layer = ignorePlayerCollisionLayer;
spawnedObject.AddComponent<XRGrabInteractable>();
XRGrabInteractable grabComponent = spawnedObject.AddComponent<XRGrabInteractable>();
grabComponent.useDynamicAttach = true;
}
}