Import a 3D Model and automatically assign and export animations
TypeScript
do not scale model when we are using reference models
Scott Petrovice2eca7817b7a
diff --git a/src/lib/RigConfig.ts b/src/lib/RigConfig.tsindex c2c1f8f..dd840ab 100644--- a/src/lib/RigConfig.ts+++ b/src/lib/RigConfig.ts@@ -94,7 +94,7 @@ const rig_settings: RigSettings[] = ['psx-monster-03': { display_name: 'Monster 3', attribution: 'elbolilloduro', pelvis_position_scale: 1.05 },'psx-monster-04': { display_name: 'Monster 4', attribution: 'elbolilloduro', pelvis_position_scale: 1.55 },'psx-monster-05': { display_name: 'Monster 5', attribution: 'elbolilloduro', pelvis_position_scale: 1.12 },- sophia: { display_name: 'Sophia', attribution: 'Tysan Tan', license: 'CC-SA 4.0' },+ sophia: { display_name: 'Sophia', attribution: 'Tysan Tan', license: 'CC-SA 4.0', pelvis_position_scale: 0.94 },jay: { display_name: 'Jay', attribution: 'Blender Studio', license: 'CC-BY' },sintel: { display_name: 'Sintel', attribution: 'Blender Studio', license: 'CC-BY' },bunny: { display_name: 'Bunny', attribution: 'Blender Studio', license: 'CC-BY', expand_arms: -30 }diff --git a/src/lib/processes/load-model/StepLoadModel.ts b/src/lib/processes/load-model/StepLoadModel.tsindex cdf9ca8..88574f8 100644--- a/src/lib/processes/load-model/StepLoadModel.ts+++ b/src/lib/processes/load-model/StepLoadModel.ts@@ -46,6 +46,10 @@ export class StepLoadModel extends EventTarget {// controls whether to preserve all objects (bones, lights, etc.) or strip to meshes onlyprivate preserve_skinned_mesh: boolean = false+ // the reference models in the drop-down are authored at the exact size of their skeleton+ // template, so scaling them on import would leave the template misaligned (e.g. the 2.1m kaiju)+ private is_reference_model: boolean = false+// for debugging, let's count these to help us test performance things bettervertex_count = 0triangle_count = 0@@ -154,7 +158,7 @@ export class StepLoadModel extends EventTarget {const file_name = model_selection.options[model_selection.selectedIndex].valueconst file_extension: string = Utility.get_file_extension(file_name)this.source_file_name = file_name.split('/').pop() ?? file_name- this.load_model_file(file_name, file_extension)+ this.load_model_file(file_name, file_extension, true)}})}@@ -200,7 +204,10 @@ export class StepLoadModel extends EventTarget {this.preserve_skinned_mesh = preserve}- public load_model_file (model_file_path: string | ArrayBuffer | null, file_extension: string): void {+ public load_model_file (model_file_path: string | ArrayBuffer | null, file_extension: string,+ is_reference_model: boolean = false): void {+ this.is_reference_model = is_reference_model+// only the FBX loader can flag this, so clear it here or a previous broken FBX// would keep forcing the fallback material onto every model loaded after itthis.mesh_has_broken_material = false@@ -349,7 +356,9 @@ export class StepLoadModel extends EventTarget {// Some objects come in very large, which makes it harder to work with// scale everything down to a max height. mutate the clean scene object- ModelCleanupUtility.scale_model_on_import_if_extreme(clean_scene_with_only_models)+ if (!this.is_reference_model) {+ ModelCleanupUtility.scale_model_on_import_if_extreme(clean_scene_with_only_models)+ }// preserved skinned meshes shouldn't be breaking apart mesh data// breaking apart skinned meshes converts it to a regular mesh which we don't want.diff --git a/src/marketing/MarketingBootstrap.ts b/src/marketing/MarketingBootstrap.tsindex bb51842..32e7476 100644--- a/src/marketing/MarketingBootstrap.ts+++ b/src/marketing/MarketingBootstrap.ts@@ -48,7 +48,7 @@ export class MarketingBootstrap {// if we previously swapped a variation model into scene, clear it firstthis.mesh2motion_engine.animations_listing_step.clear_variation_model_from_scene()this.mesh2motion_engine.load_model_step.clear_loaded_model_data()- this.mesh2motion_engine.load_model_step.load_model_file('../' + rig.model_file, 'glb')+ this.mesh2motion_engine.load_model_step.load_model_file('../' + rig.model_file, 'glb', true)this.skeleton_type = rig.skeleton_typethis.change_active_skeleton(model_button)this.model_variation_switcher.update_for_rig(rig.skeleton_type)