high-quality WebP + 512px optimization, and save them as _clean.glb.

Here is the fresh script. It will automatically loop through all your original 3D files, apply the high-quality WebP + 512px optimization, and save them as _clean.glb.

Copy and paste this into your terminal:

bash

for f in *.glb; do
   # Skip clean files if rerun
   [[ "$f" == *"_clean.glb" ]] && continue
   
   base="${f%.glb}"
   echo "Optimizing $f to high-quality _clean.glb..."
   
   # 1. Resize to 512x512 (keeps details crisp)
   gltf-transform resize "$f" "${base}_clean.glb" --width 512 --height 512 && \
   
   # 2. Prune duplicate/empty data
   gltf-transform prune "${base}_clean.glb" "${base}_clean.glb" && \
   
   # 3. Compress textures using WebP (small size, high quality)
   gltf-transform webp "${base}_clean.glb" "${base}_clean.glb" --slots baseColor && \
   
   # 4. Smooth Draco geometry compression (prevents distortion)
   gltf-transform draco "${base}_clean.glb" "${base}_clean.glb" --quantizePosition 11 --quantizeTexcoord 12
done

Use code with caution.