Skip to content

Commit 1073ea3

Browse files
committed
Merge branch 'glb-export' into main
2 parents 226dbb5 + c00118d commit 1073ea3

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
0.0.2 2022-01-27
2+
- Default GLB export
3+
- Optional OBJ export
4+
5+
0.0.1 2022-07-08
6+
- First version
7+
- Default OBJ export

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM ubuntu:22.04
22

33
ENV DEBIAN_FRONTEND noninteractive
4-
RUN apt-get update
5-
RUN apt-get install -y blender
4+
RUN apt-get update && apt-get install -y python3-numpy blender
65

76
COPY tn.py /var/tn/tn.py
87
WORKDIR /var/tn/data

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
From the directory containing your OBJ file `Big.obj`:
88

99
```bash
10-
docker run -v="$(pwd):/var/tn/data" -u="$(id -u):$(id -g)" memowe/thumbnailify:0.0.1 Big.obj --percent 5
10+
docker run -v="$(pwd):/var/tn/data" -u="$(id -u):$(id -g)" memowe/thumbnailify:0.0.2 Big.obj --percent 5
1111
```
1212

13-
This will write new OBJ data as `Big_thumbnail.obj`.
13+
This will write new GLB data as `Big_thumbnail.glb`.
1414

15-
The optional `--percent` argument defines in percent, which *collapse ratio* of the Blender [Decimate Modifier][decmod] should be used. Default is 10.
15+
The optional `--percent 42` argument defines in percent, which *collapse ratio* of the Blender [Decimate Modifier][decmod] should be used. Default is 10. If you prefer OBJ output, use the optional `--obj` argument.
1616

1717
## Early development
1818

tn.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def die(*args, **kwargs):
1414

1515
arg_parser = argparse.ArgumentParser() # TODO customize
1616
arg_parser.add_argument('--percent', type=int, default=10)
17+
arg_parser.add_argument('--obj', action='store_true')
1718
arg_parser.add_argument('obj_filename')
1819
pyargs = list(dropwhile(lambda arg: arg != '--', sys.argv))[1:]
1920
args = arg_parser.parse_args(pyargs)
@@ -56,7 +57,18 @@ def die(*args, **kwargs):
5657
bpy.ops.object.modifier_apply(modifier='Decimate')
5758
print('... Done.')
5859

59-
# Export result
60-
export_filename = f'{obj_purename}_thumbnail.obj'
61-
print(f'Exporting to {export_filename}.')
62-
bpy.ops.export_scene.obj(filepath=export_filename)
60+
### Export result ###
61+
62+
export_filename = f'{obj_purename}_thumbnail.'
63+
64+
# GLB (default)
65+
if (not args.obj):
66+
export_filename += 'glb'
67+
print(f'Exporting to {export_filename}.')
68+
bpy.ops.export_scene.gltf(filepath=export_filename)
69+
70+
# OBJ
71+
else:
72+
export_filename += 'obj'
73+
print(f'Exporting to {export_filename}.')
74+
bpy.ops.export_scene.obj(filepath=export_filename)

0 commit comments

Comments
 (0)