forked from petrbroz/svf-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-svf-to-gltf.sh
executable file
·29 lines (23 loc) · 1.23 KB
/
local-svf-to-gltf.sh
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
#!/usr/bin/env bash
# Script converting an SVF (without property database) from local file system
# into (1) vanilla gltf, (2) gltf with Draco compression, (3) binary gltf, and
# (4) binary gltf with Draco compression.
# Usage example:
# ./local-svf-to-gltf.sh <path to svf file> <path to output folder>
# Install dependencies
npm install --global svf-utils gltf-pipeline
# Convert SVF to glTF with [svf-utils](https://github.com/petrbroz/svf-utils)
svf-to-gltf $1 --output-folder $2/gltf --deduplicate --skip-unused-uvs --ignore-lines --ignore-points
# Validate glTF using [gltf-validator](https://github.com/KhronosGroup/glTF-Validator), if available
if [ -x "$(command -v gltf_validator)" ]; then
gltf_validator $2/gltf/output.gltf
fi
# Post-process with [gltf-pipeline](https://github.com/AnalyticalGraphicsInc/gltf-pipeline)
gltf-pipeline -i $2/gltf/output.gltf -o $2/gltf-draco/output.gltf -d
gltf-pipeline -i $2/gltf/output.gltf -o $2/glb/output.glb
gltf-pipeline -i $2/gltf/output.gltf -o $2/glb-draco/output.glb -d
# Post-process with [gltfpack](https://github.com/zeux/meshoptimizer#gltfpack), if available
if [ -x "$(command -v gltfpack)" ]; then
mkdir -p $2/glb-pack
gltfpack -i $2/gltf/output.gltf -o $2/glb-pack/output.glb
fi