-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathscreenshot_docker.sh
More file actions
executable file
·31 lines (27 loc) · 997 Bytes
/
Copy pathscreenshot_docker.sh
File metadata and controls
executable file
·31 lines (27 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -eu
if [[ ${#} -lt 1 ]]; then
echo "Usage: ${0} <gltf-file-path> [<additional-arguments>]"
echo "Example: ${0} ../gltf/Box.glb --count 3 --headless"
echo "You can pull a docker image instead of building locally by setting DOCKER_IMAGE."
echo "Example: DOCKER_IMAGE=bwasty/gltf-viewer:latest ${0} ../gltf/Box.glb"
exit 1
fi
gltf_path=$1
gltf_dir=$(dirname "$gltf_path")
gltf_file=$(basename "$gltf_path")
model_name=${gltf_file%.*}
output_file="$gltf_dir/$model_name.png"
if [[ ! -z "${DOCKER_IMAGE:-}" ]]; then
docker pull "$DOCKER_IMAGE"
image="$DOCKER_IMAGE"
else
docker build -t gltf-viewer .
image=gltf-viewer
fi
rm "$output_file" || true
docker run -t --rm -v "$(pwd)/$gltf_dir:/input" \
$image "/input/$gltf_file" -s "/input/$model_name.png" "${@:2}"
# uncomment to run bash interactively
# docker run -it -v "$(pwd)/$gltf_dir:/input" --entrypoint bash $image
[ -f "$HOME/.iterm2/imgcat" ] && "$HOME/.iterm2/imgcat" "$output_file"