1
0
forked from cgvr/DeltaVR

can insert printable into 3d printer, 3d printer starts printing

This commit is contained in:
2026-02-14 16:08:13 +02:00
parent 884459842e
commit 17c9122a14
11 changed files with 192 additions and 45 deletions

View File

@@ -15,11 +15,7 @@ public class ShapeDetectionNPC : NPCController
public Image imageDisplay;
public ShapeScanner shapeScanner;
public float radioAmount = 1f;
public GameObject GeneratedModel { get; private set; }
public Transform modelSpawnPoint;
public string shapeScannerTag = "ShapeScannable";
public int ignorePlayerCollisionLayer = 2;
// states:
// 0 - idle
@@ -144,14 +140,8 @@ public class ShapeDetectionNPC : NPCController
byte[] encodedModel = await TrellisClient.Instance.GenerateModel(encodedTexture);
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
InitializeSpawnedObject(spawnedObject);
if (GeneratedModel != null)
{
// Destroy previous generated object (first move out of ShapeScanner to trigger OnTriggerExit
GeneratedModel.transform.position = Vector3.zero;
}
GeneratedModel = spawnedObject;
modelGenerationButton.Deactivate();
if (state == 5)
@@ -160,25 +150,5 @@ public class ShapeDetectionNPC : NPCController
}
}
private void InitializeSpawnedObject(GameObject spawnedObject)
{
GameObject spawnedObjectParent = new GameObject("SpawnedModelParent");
spawnedObjectParent.transform.parent = modelSpawnPoint;
spawnedObjectParent.transform.position = modelSpawnPoint.transform.position;
spawnedObjectParent.layer = ignorePlayerCollisionLayer;
Rigidbody rigidbody = spawnedObjectParent.AddComponent<Rigidbody>();
rigidbody.isKinematic = true;
//spawnedObject.AddComponent<NetworkObject>();
//spawnedObject.AddComponent<NetworkTransform>();
MeshCollider spawnedObjectCollider = spawnedObject.GetComponent<MeshCollider>();
spawnedObjectCollider.convex = false;
spawnedObject.transform.parent = spawnedObjectParent.transform;
spawnedObject.transform.position = spawnedObjectParent.transform.position;
spawnedObject.tag = shapeScannerTag;
spawnedObject.layer = ignorePlayerCollisionLayer;
spawnedObjectParent.AddComponent<TwoHandScaleGrabInteractable>();
}
}