├── .gitignore ├── README.md ├── batch.sh ├── build.sh ├── examples └── exterior.glb ├── package.json ├── start.sh ├── usd-from-gltf └── Dockerfile └── usd └── Dockerfile /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Convert .glb and .gltf into apples .usdz quicklook files. 2 | 3 | It uses this repo under the hood. 4 | https://github.com/google/usd_from_gltf#compatibility 5 | 6 | # Run 7 | 8 | Using helper script that will output a usdz file with same name as input 9 | 10 | Via Npm or yarn 11 | 12 | ``` 13 | npm start examples/exterior.glb 14 | yarn start examples/exterior.glb 15 | ``` 16 | 17 | Directly via the shellscript 18 | 19 | ``` 20 | ./start.sh examples/exterior.glb 21 | ``` 22 | 23 | Using raw docker command 24 | 25 | ``` 26 | docker run \ 27 | --rm \ 28 | -v $(PWD):/usr/app \ 29 | leon/usd-from-gltf:latest \ 30 | examples/exterior.glb \ 31 | examples/exterior.usdz 32 | 33 | # or on one line 34 | docker run --rm -v $(PWD):/usr/app leon/usd-from-gltf:latest examples/exterior.glb examples/exterior.usdz 35 | ``` 36 | 37 | # Batch Run 38 | 39 | To be able to batch convert files, place all your glb files in a directory. 40 | then `cd` to that directory, 41 | now run the `batch.sh` file from that directory. 42 | it will pick up the directory that you started it from and convert all the .glb files to .usdz 43 | 44 | ``` 45 | cd examples 46 | ../batch.sh 47 | ``` 48 | 49 | # Build 50 | 51 | ``` 52 | ./build.sh 53 | ``` 54 | -------------------------------------------------------------------------------- /batch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker run -i --rm -v $(PWD):/usr/app --entrypoint="/bin/sh" leon/usd-from-gltf:latest -c 'for f in *.glb; do echo "Processing $f"; usd_from_gltf "$f" "${f%.*}.usdz"; done' 3 | echo "Done" 4 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Build USD container 4 | docker build usd -t leon/usd 5 | 6 | # Build gltf_to_usdz container 7 | docker build usd-from-gltf -t leon/usd-from-gltf 8 | 9 | # Push 10 | docker push leon/usd:latest 11 | docker push leon/usd-from-gltf:latest 12 | -------------------------------------------------------------------------------- /examples/exterior.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leon/docker-gltf-to-udsz/10a5ce1f6cf79f05b96a4d548b09ae1ad96e3a43/examples/exterior.glb -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker-gltf-to-udsz", 3 | "version": "1.2.0", 4 | "description": "convert from gltf to usdz using docker", 5 | "main": "start.sh", 6 | "scripts": { 7 | "start": "./start.sh", 8 | "batch": "./batch.sh", 9 | "build": "./build.sh" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/leon/docker-gltf-to-udsz.git" 14 | }, 15 | "keywords": [ 16 | "docker", 17 | "gltf", 18 | "usdz", 19 | "converter" 20 | ], 21 | "author": "leon", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/leon/docker-gltf-to-udsz/issues" 25 | }, 26 | "homepage": "https://github.com/leon/docker-gltf-to-udsz#readme" 27 | } 28 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker run -i --rm -v $(PWD):/usr/app leon/usd-from-gltf:latest "$@" "${@%.*}.usdz" -------------------------------------------------------------------------------- /usd-from-gltf/Dockerfile: -------------------------------------------------------------------------------- 1 | # Since USD takes so long to build, we separate it into it's own container 2 | FROM leon/usd:latest 3 | 4 | WORKDIR /usr/src/ufg 5 | 6 | # Add NASM 7 | RUN apt-get install nasm 8 | 9 | # Add PIL 10 | RUN pip install Pillow 11 | 12 | # Configuration 13 | ARG UFG_RELEASE="6d288cce8b68744494a226574ae1d7ba6a9c46eb" 14 | ARG UFG_SRC="/usr/src/ufg" 15 | ARG UFG_INSTALL="/usr/local/ufg" 16 | ENV USD_DIR="/usr/local/usd" 17 | ENV LD_LIBRARY_PATH="${USD_DIR}/lib:${UFG_SRC}/lib" 18 | ENV PATH="${PATH}:${UFG_INSTALL}/bin" 19 | ENV PYTHONPATH="${PYTHONPATH}:${UFG_INSTALL}/python" 20 | 21 | # Build + install usd_from_gltf 22 | RUN git init && \ 23 | git remote add origin https://github.com/google/usd_from_gltf.git && \ 24 | git fetch --depth 1 origin "${UFG_RELEASE}" && \ 25 | git checkout FETCH_HEAD && \ 26 | python "${UFG_SRC}/tools/ufginstall/ufginstall.py" -v "${UFG_INSTALL}" "${USD_DIR}" && \ 27 | cp -r "${UFG_SRC}/tools/ufgbatch" "${UFG_INSTALL}/python" && \ 28 | rm -rf "${UFG_SRC}" "${UFG_INSTALL}/build" "${UFG_INSTALL}/src" 29 | 30 | RUN mkdir /usr/app 31 | WORKDIR /usr/app 32 | 33 | # Start the service 34 | ENTRYPOINT ["usd_from_gltf"] 35 | CMD ["usd_from_gltf"] 36 | -------------------------------------------------------------------------------- /usd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-slim-buster 2 | 3 | WORKDIR /usr/src/usd 4 | 5 | # Configuration 6 | ARG USD_RELEASE="21.02" 7 | ARG USD_INSTALL="/usr/local/usd" 8 | ENV PYTHONPATH="${PYTHONPATH}:${USD_INSTALL}/lib/python" 9 | ENV PATH="${PATH}:${USD_INSTALL}/bin" 10 | 11 | # Dependencies 12 | RUN apt-get -qq update && apt-get install -y --no-install-recommends \ 13 | git build-essential cmake nasm \ 14 | libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev && \ 15 | rm -rf /var/lib/apt/lists/* 16 | 17 | # Build + install USD 18 | RUN git clone --branch "v${USD_RELEASE}" --depth 1 https://github.com/PixarAnimationStudios/USD.git /usr/src/usd 19 | RUN python ./build_scripts/build_usd.py --verbose --prefer-safety-over-speed --no-examples --no-tutorials --no-python --no-imaging --no-usdview --draco "${USD_INSTALL}" && \ 20 | rm -rf "${USD_REPO}" "${USD_INSTALL}/build" "${USD_INSTALL}/src" 21 | 22 | # Share the volume that we have built to 23 | VOLUME ["/usr/local/usd"] --------------------------------------------------------------------------------