Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Normalize rotation when importing model

Scott Petroviccee5db22175c
diff --git a/src/lib/processes/StepLoadModel.ts b/src/lib/processes/StepLoadModel.ts
index fda519b..9902d13 100644
--- a/src/lib/processes/StepLoadModel.ts
+++ b/src/lib/processes/StepLoadModel.ts
@@ -141,6 +141,15 @@ export class StepLoadModel extends EventTarget {
const clean_scene_with_only_models = this.strip_out_all_unecessary_model_data(this.original_model_data)
this.scale_model_on_import(clean_scene_with_only_models, max_height) // if we have multiple objects, we want to scale them all the same
+ // loop through each child in scene and reset rotation
+ // if we don't the skinning process doesn't take rotation into account
+ // and creates odd results
+ clean_scene_with_only_models.traverse((child) => {
+ child.rotation.set(0, 0, 0)
+ })
+
+ console.log('Model loaded', clean_scene_with_only_models)
+
// assign the final cleaned up model to the original model data
this.final_mesh_data = clean_scene_with_only_models
diff --git a/static/models/mesh-x-bot.glb b/static/models/mesh-x-bot.glb
index afb2b35..2adc38b 100644
Binary files a/static/models/mesh-x-bot.glb and b/static/models/mesh-x-bot.glb differ