Import a 3D Model and automatically assign and export animations
TypeScript
Added new dragon rig with better controls and more bones in wings. Updated combine script to make sure Y+ is used.
Scott Petrovicbb14562dafb8
diff --git a/static/animations/dragon-animations.glb b/static/animations/dragon-animations.glbindex 809e201..47cc51c 100644Binary files a/static/animations/dragon-animations.glb and b/static/animations/dragon-animations.glb differdiff --git a/static/blender/rigs/bird/combine-and-export.py b/static/blender/rigs/bird/combine-and-export.pydeleted file mode 100644index b29f04d..0000000--- a/static/blender/rigs/bird/combine-and-export.py+++ /dev/null@@ -1,55 +0,0 @@-import bpy-import os--## WHAT IS THIS SCRIPT FOR?-# Each BLEND file only has one animation action. This script consolidates all these actions and-# creates one GLB file that the Mesh2Motion tool can load.-# This will make loading faster since it will be one HTTP request-# if there gets to be a ton of animations, we can revisit this to split things apart.--## INSTRUCTIONS ON HOW TO RUN-# 1. Open the rig-bird.blend file in Blender. This process should work for all the rig files-# 2. Open a "Text Editor" view and click New to create a new text area-# 3. Copy and paste this script into the text area-# 4. Update the path below to point to the rig you want to create a GLB for-# 5. Click the "Run Script" (play) button-# 6. You can put the GLB file in the static > animations folder overwriting the old rig one---# Define the directory containing the Blender RIG files-base_dir = r"C:\git\ModelMotionizer\static\blender\rigs"--# Define the rig type/folder-rig_type = "bird"---# DO NOT NEED TO CHANGE BELOW THIS LINE-#------------------------------------------------------# Define the output file path. It will be saved in the same directory as the input files-blend_dir = os.path.join(base_dir, rig_type)-output_file = os.path.join(blend_dir, f"{rig_type}-animations.glb")---# Iterate over each Blender file-for file in os.listdir(blend_dir):- if file.endswith(".blend") and "animation" in file.lower():- # Append actions from the file- filepath = os.path.join(blend_dir, file)- with bpy.data.libraries.load(filepath) as (data_from, data_to):- data_to.actions = data_from.actions--# Export the combined actions to a GLB file-# select just the armature and mesh objects we want to export-export_objects = [obj for obj in bpy.context.scene.objects if obj.type in ['ARMATURE', 'MESH']]-for obj in export_objects:- obj.select_set(True)---bpy.ops.export_scene.gltf(- filepath=output_file,- export_format="GLB",- export_animations=True,- export_nla_strips=False, # Export actions instead of NLA strips- use_selection=True-)\ No newline at end of filediff --git a/static/blender/rigs/fox/combine-and-export.py b/static/blender/rigs/combine-and-export.pysimilarity index 91%rename from static/blender/rigs/fox/combine-and-export.pyrename to static/blender/rigs/combine-and-export.pyindex 11feecc..7bf6fc0 100644--- a/static/blender/rigs/fox/combine-and-export.py+++ b/static/blender/rigs/combine-and-export.py@@ -20,7 +20,7 @@ import osbase_dir = r"C:\git\ModelMotionizer\static\blender\rigs"# Define the rig type/folder-rig_type = "fox"+rig_type = "dragon"# DO NOT NEED TO CHANGE BELOW THIS LINE@@ -52,5 +52,7 @@ bpy.ops.export_scene.gltf(export_animations=True,export_nla_strips=False, # Export actions instead of NLA stripsuse_selection=True,- use_visible=True # hides bone shape collection objects+ export_yup=True, # Blender uses Z-up, three.js uses Y-up+ export_def_bones=True, # only export deformation bones+ use_visible=True, # hides bone shape collection objects)\ No newline at end of filediff --git a/static/blender/rigs/dragon/animation-dragon-flap-v2.blend b/static/blender/rigs/dragon/animation-dragon-flap-v2.blendnew file mode 100644index 0000000..aabd0e6Binary files /dev/null and b/static/blender/rigs/dragon/animation-dragon-flap-v2.blend differdiff --git a/static/blender/rigs/dragon/animation-dragon-flap.blend b/static/blender/rigs/dragon/animation-dragon-flap.blenddeleted file mode 100644index 32023a3..0000000Binary files a/static/blender/rigs/dragon/animation-dragon-flap.blend and /dev/null differdiff --git a/static/blender/rigs/dragon/animation-dragon-idle-v2.blend b/static/blender/rigs/dragon/animation-dragon-idle-v2.blendnew file mode 100644index 0000000..e9bd633Binary files /dev/null and b/static/blender/rigs/dragon/animation-dragon-idle-v2.blend differdiff --git a/static/blender/rigs/dragon/animation-dragon-idle.blend b/static/blender/rigs/dragon/animation-dragon-idle.blenddeleted file mode 100644index 528ad72..0000000Binary files a/static/blender/rigs/dragon/animation-dragon-idle.blend and /dev/null differdiff --git a/static/blender/rigs/dragon/animation-dragon-walk-v2.blend b/static/blender/rigs/dragon/animation-dragon-walk-v2.blendnew file mode 100644index 0000000..c602658Binary files /dev/null and b/static/blender/rigs/dragon/animation-dragon-walk-v2.blend differdiff --git a/static/blender/rigs/dragon/animation-dragon-walk.blend b/static/blender/rigs/dragon/animation-dragon-walk.blenddeleted file mode 100644index b67c905..0000000Binary files a/static/blender/rigs/dragon/animation-dragon-walk.blend and /dev/null differdiff --git a/static/blender/rigs/dragon/rig-dragon.blend b/static/blender/rigs/dragon/rig-dragon-v2.blendsimilarity index 52%rename from static/blender/rigs/dragon/rig-dragon.blendrename to static/blender/rigs/dragon/rig-dragon-v2.blendindex 0afe806..a312b4d 100644Binary files a/static/blender/rigs/dragon/rig-dragon.blend and b/static/blender/rigs/dragon/rig-dragon-v2.blend differdiff --git a/static/blender/rigs/fox/animation-fox-idle-v2.blend b/static/blender/rigs/fox/animation-fox-idle-v2.blendindex 510b104..24721c6 100644Binary files a/static/blender/rigs/fox/animation-fox-idle-v2.blend and b/static/blender/rigs/fox/animation-fox-idle-v2.blend differdiff --git a/static/blender/rigs/fox/rig-fox-v2.blend b/static/blender/rigs/fox/rig-fox-v2.blendindex 505d909..f252c10 100644Binary files a/static/blender/rigs/fox/rig-fox-v2.blend and b/static/blender/rigs/fox/rig-fox-v2.blend differdiff --git a/static/rigs/rig-dragon.glb b/static/rigs/rig-dragon.glbindex 26705cb..81803d2 100644Binary files a/static/rigs/rig-dragon.glb and b/static/rigs/rig-dragon.glb differ