diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d87d5ef --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,44 @@ +name: Asset Pallet Generator + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install screenshot-glb + run: npm install --save @shopify/screenshot-glb + + - name: Update pallet site + run: | + chmod +x scripts/generate_html_gallery.sh + ./scripts/generate_html_gallery.sh models --head > index.html + + + - name: Take screenshots and make pallet + run: | + chmod +x scripts/process_files.sh + ./scripts/process_files.sh models glb png 512 512 + ./scripts/generate_html_gallery.sh models --body >> index.html + + - name: Update README + run: | + python scripts/table.py --head > README.md + python scripts/table.py models >> README.md + + + - name: Commit changes + run: | + git config --global user.name "madjin" + git config --global user.email "32600939+madjin@users.noreply.github.com" + git add . + git commit -m "Update READMEs" + git push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/models/01fc3e145a3b_e40a0b64cd69_A_3D_barracks_with_.glb b/models/01fc3e145a3b_e40a0b64cd69_A_3D_barracks_with_.glb new file mode 100644 index 0000000..ca85710 Binary files /dev/null and b/models/01fc3e145a3b_e40a0b64cd69_A_3D_barracks_with_.glb differ diff --git a/models/08886d0a2ab6_bea34dec37c6_submarine_pirate_sh.glb b/models/08886d0a2ab6_bea34dec37c6_submarine_pirate_sh.glb new file mode 100644 index 0000000..cbf90d9 Binary files /dev/null and b/models/08886d0a2ab6_bea34dec37c6_submarine_pirate_sh.glb differ diff --git a/models/092b2610e163_46551126f160_Seahorse_playing_a_.glb b/models/092b2610e163_46551126f160_Seahorse_playing_a_.glb new file mode 100644 index 0000000..00aa516 Binary files /dev/null and b/models/092b2610e163_46551126f160_Seahorse_playing_a_.glb differ diff --git a/models/28451cbf8266_c9bc90f09d7a_A_building_resembli.glb b/models/28451cbf8266_c9bc90f09d7a_A_building_resembli.glb new file mode 100644 index 0000000..d75a279 Binary files /dev/null and b/models/28451cbf8266_c9bc90f09d7a_A_building_resembli.glb differ diff --git a/models/3b7ada4d65a4_5e45c2c2be0b_coral_reef_circus_t.glb b/models/3b7ada4d65a4_5e45c2c2be0b_coral_reef_circus_t.glb new file mode 100644 index 0000000..a3be2d7 Binary files /dev/null and b/models/3b7ada4d65a4_5e45c2c2be0b_coral_reef_circus_t.glb differ diff --git a/models/40ac6c042cf0_557ec607b4ee_a_farm_plot_with_lo.glb b/models/40ac6c042cf0_557ec607b4ee_a_farm_plot_with_lo.glb new file mode 100644 index 0000000..ef561c6 Binary files /dev/null and b/models/40ac6c042cf0_557ec607b4ee_a_farm_plot_with_lo.glb differ diff --git a/models/76eff27ef71f_fe4c9c9f2b52_A_retro_icon_of_a_c.glb b/models/76eff27ef71f_fe4c9c9f2b52_A_retro_icon_of_a_c.glb new file mode 100644 index 0000000..e09f7dc Binary files /dev/null and b/models/76eff27ef71f_fe4c9c9f2b52_A_retro_icon_of_a_c.glb differ diff --git a/models/91b6191aea87_e29d3620d146_underwater_pizza_cl.glb b/models/91b6191aea87_e29d3620d146_underwater_pizza_cl.glb new file mode 100644 index 0000000..e5a53d4 Binary files /dev/null and b/models/91b6191aea87_e29d3620d146_underwater_pizza_cl.glb differ diff --git a/models/9457d7e111fa_178350aca399_a_temple_in_the_sha.glb b/models/9457d7e111fa_178350aca399_a_temple_in_the_sha.glb new file mode 100644 index 0000000..eb2a9dc Binary files /dev/null and b/models/9457d7e111fa_178350aca399_a_temple_in_the_sha.glb differ diff --git a/models/9d3f0d0d2ead_b182b18f7fa1_hibrido_entre_un_ed.glb b/models/9d3f0d0d2ead_b182b18f7fa1_hibrido_entre_un_ed.glb new file mode 100644 index 0000000..4c45d6e Binary files /dev/null and b/models/9d3f0d0d2ead_b182b18f7fa1_hibrido_entre_un_ed.glb differ diff --git a/models/b7c4ec396f0c_a9b6b80ea2b6_mycelial_solarpunk_.glb b/models/b7c4ec396f0c_a9b6b80ea2b6_mycelial_solarpunk_.glb new file mode 100644 index 0000000..c705d7d Binary files /dev/null and b/models/b7c4ec396f0c_a9b6b80ea2b6_mycelial_solarpunk_.glb differ diff --git a/models/c26056a48278_666d71d60755_shell_streetlights_.glb b/models/c26056a48278_666d71d60755_shell_streetlights_.glb new file mode 100644 index 0000000..9fa24a2 Binary files /dev/null and b/models/c26056a48278_666d71d60755_shell_streetlights_.glb differ diff --git a/models/d74be3b18d3a_74016a1e41f4_giant_sprouting_pur.glb b/models/d74be3b18d3a_74016a1e41f4_giant_sprouting_pur.glb new file mode 100644 index 0000000..8b9b178 Binary files /dev/null and b/models/d74be3b18d3a_74016a1e41f4_giant_sprouting_pur.glb differ diff --git a/models/d8442a6fd5f8_c5928ede910a_purple_octupus_coin.glb b/models/d8442a6fd5f8_c5928ede910a_purple_octupus_coin.glb new file mode 100644 index 0000000..20ede90 Binary files /dev/null and b/models/d8442a6fd5f8_c5928ede910a_purple_octupus_coin.glb differ diff --git a/models/db3620ee50dd_d1cdd01f8e5f_a_octopus_solarpunk.glb b/models/db3620ee50dd_d1cdd01f8e5f_a_octopus_solarpunk.glb new file mode 100644 index 0000000..bd9b906 Binary files /dev/null and b/models/db3620ee50dd_d1cdd01f8e5f_a_octopus_solarpunk.glb differ diff --git a/models/db5003c99da0_35887557abd3_solarpunk_cafe_with.glb b/models/db5003c99da0_35887557abd3_solarpunk_cafe_with.glb new file mode 100644 index 0000000..41de4cc Binary files /dev/null and b/models/db5003c99da0_35887557abd3_solarpunk_cafe_with.glb differ diff --git a/models/ee5b97a8d331_88c4f2b4c6c7_starfish_pergola_un.glb b/models/ee5b97a8d331_88c4f2b4c6c7_starfish_pergola_un.glb new file mode 100644 index 0000000..a0933cf Binary files /dev/null and b/models/ee5b97a8d331_88c4f2b4c6c7_starfish_pergola_un.glb differ diff --git a/models/f8e705191dd0_7f5008f19c7e_a_radio_tower_min.glb b/models/f8e705191dd0_7f5008f19c7e_a_radio_tower_min.glb new file mode 100644 index 0000000..c90a5c7 Binary files /dev/null and b/models/f8e705191dd0_7f5008f19c7e_a_radio_tower_min.glb differ diff --git a/scripts/generate_html_gallery.sh b/scripts/generate_html_gallery.sh new file mode 100755 index 0000000..d265b4b --- /dev/null +++ b/scripts/generate_html_gallery.sh @@ -0,0 +1,85 @@ +#!/bin/bash + + +# Function to print HTML header +print_html_header() { + echo "" + echo "" + echo "" + echo "" + echo "Image Gallery" + echo "" + echo "" + echo "" + echo "
" +} + +# Function to generate HTML gallery +generate_html_gallery() { + local dir="$1" + + ## Add ability to find gif if thumbnails become animated in future + find "$dir" -type f -name "*.png" | while read -r file; do + local glb_file="${file%.*}.glb" + echo " " + done +} + +# Main function +main() { + local dir="$1" + local print_header=false + local print_footer=false + local print_body=false + + # Check if optional flag is passed + while [[ $# -gt 0 ]]; do + case "$2" in + --head) + print_header=true + shift + ;; + --body) + print_body=true + shift + ;; + --tail) + print_footer=true + shift + ;; + *) + break + ;; + esac + done + + # Generate HTML gallery + if [[ $print_header == true ]]; then + print_html_header + fi + + if [[ $print_body == true ]]; then + generate_html_gallery "$dir" + fi + + # Print closing HTML tags if --tail flag is passed + if [[ $print_footer == true ]]; then + echo "
" + echo "" + echo "" + fi +} + +main "$@" + diff --git a/scripts/process_files.sh b/scripts/process_files.sh new file mode 100755 index 0000000..c1904cc --- /dev/null +++ b/scripts/process_files.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Function to process files +process_files() { + # Check for required arguments + if [[ $# -ne 5 ]]; then + echo "Usage: $0 directory filetype output_type output_width output_height" + exit 1 + fi + + local dir="$1" + local filetype="$2" + local output_type="$3" + local output_width="$4" + local output_height="$5" + + # Loop through all files of given filetype in the directory + find "$dir" -type f -name "*.$filetype" -print0 | while IFS= read -r -d '' file; do + echo "Processing $file..." + local base_filename=$(basename "$file" ".$filetype") + local skip_gif=false skip_png=false + + # Store the directory path of the current file + local output_dir=$(dirname "$file") + + [[ -f "$output_dir/$base_filename.gif" ]] && skip_gif=true + [[ -f "$output_dir/$base_filename.png" ]] && skip_png=true + + # Process gif files + if [[ $output_type == "gif" || $output_type == "both" ]]; then + if [[ $skip_gif == false ]]; then + for i in {0..5}; do + local yaw=$((i 45 % 315)) + local filename="$base_filename-$i.png" + node ./node_modules/.bin/screenshot-glb -i "$file" -w 512 -h 512 -m "orientation=0 0 $yaw" -o "$output_dir/$filename" + done + + montage "$output_dir/$base_filename"-*.png -tile 6x1 -geometry +0+0 -background none -resize 3072x512 "$output_dir/montage-$base_filename.png" + convert -dispose background -delay 50 -loop 0 "$output_dir/$base_filename"-*.png "$output_dir/$base_filename.gif" + rm "$output_dir/$base_filename"-*.png + fi + fi + + # Process png files + if [[ $output_type == "png" || $output_type == "both" ]]; then + if [[ $skip_png == false ]]; then + node ./node_modules/.bin/screenshot-glb -i "$file" -w "$output_width" -h "$output_height" -m "orientation=0 0 180" -o "$output_dir/$base_filename.png" + fi + fi + done +} + +# Call process_files function with command line arguments +process_files "$@" diff --git a/scripts/table.py b/scripts/table.py new file mode 100644 index 0000000..8a89001 --- /dev/null +++ b/scripts/table.py @@ -0,0 +1,63 @@ +import os +import sys +import math +from pathlib import Path + +def main(): + if "--head" in sys.argv: + print("# Metaville\n") + print("[![Asset Pallet Generator](https://github.com/m3-org/metaville/actions/workflows/main.yml/badge.svg)](https://github.com/m3-org/metaville/actions/workflows/main.yml)\n") + print("Download templates: https://sketchfab.com/3d-models/remixable-booth-templates-d565cb7935744d6190b7d23b260e743b\n") + print("\n") + sys.exit(0) + + if len(sys.argv) < 2: + print("Usage: python table.py directory/") + sys.exit(1) + + directory = sys.argv[1] + pairs = {} + + for root, dirs, files in os.walk(directory): + for glb in files: + if glb.endswith(".glb"): + base = Path(glb).stem + png = Path(root) / (base + ".png") + if png.exists(): + pairs[base] = (Path(root) / glb, png) + + count = len(pairs) + size = int(math.sqrt(count)) + + ## Change this later to be based on repo name + print(f" ## {directory}") + print("\n") + + print("|", end="") + for i in range(size): + print(f" {i + 1} |", end="") + print() + + print("|", end="") + for i in range(size): + print(" --- |", end="") + print() + + index = 0 + for key, value in pairs.items(): + if index % size == 0: + print("|", end="") + + glb, png = value + print(f" [![{key}]({png})]({glb}) |", end="") + + index += 1 + + if index % size == 0: + print() + + print() + +if __name__ == "__main__": + main() +