Yay it works!
Browse files- AnimatedCube.bin +3 -0
- AnimatedCube_BaseColor.png +0 -0
- AnimatedCube_MetallicRoughness.png +0 -0
- app.py +5 -1
- toto.py +11 -0
AnimatedCube.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:82de770fc82b48a77a33bb26abd4d7e75620491b36ddf98e8dca69fa73dd798c
|
| 3 |
+
size 1860
|
AnimatedCube_BaseColor.png
ADDED
|
AnimatedCube_MetallicRoughness.png
ADDED
|
app.py
CHANGED
|
@@ -9,8 +9,12 @@ cube = GLTF.load("./AnimatedCube/AnimatedCube.gltf")
|
|
| 9 |
|
| 10 |
def load_mesh(im: str, choose: str):
|
| 11 |
print(im)
|
|
|
|
| 12 |
model = (avocado if choose == "avocado" else cube).clone()
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
with tempfile.NamedTemporaryFile(suffix=".glb", delete=False) as file:
|
| 15 |
model.export(file.name)
|
| 16 |
return file.name
|
|
|
|
| 9 |
|
| 10 |
def load_mesh(im: str, choose: str):
|
| 11 |
print(im)
|
| 12 |
+
# let's first clone the source model
|
| 13 |
model = (avocado if choose == "avocado" else cube).clone()
|
| 14 |
+
resource = FileResource(im.name)
|
| 15 |
+
model.resources.append(resource)
|
| 16 |
+
# let's do surgery
|
| 17 |
+
model.model.images[0].uri = im.name
|
| 18 |
with tempfile.NamedTemporaryFile(suffix=".glb", delete=False) as file:
|
| 19 |
model.export(file.name)
|
| 20 |
return file.name
|
toto.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from gltflib import GLTF, FileResource
|
| 2 |
+
|
| 3 |
+
gltf = GLTF.load('./AnimatedCube/AnimatedCube.gltf')
|
| 4 |
+
|
| 5 |
+
model = gltf.clone()
|
| 6 |
+
resource = FileResource("/Users/gibbon/Desktop/hippo.jpg")
|
| 7 |
+
model.resources.append(resource)
|
| 8 |
+
|
| 9 |
+
model.model.images[0].uri = "/Users/gibbon/Desktop/hippo.jpg"
|
| 10 |
+
|
| 11 |
+
model.export("toto.glb")
|