@@ -233,18 +233,23 @@ export class StepLoadModel extends EventTarget {
233
233
let scale_factor : number = 1.0
234
234
235
235
// calculate all the meshes to find out the max height
236
+ // some models are more wide like a bird, so don't just use height for this calculation
236
237
const bounding_box = this . calculate_bounding_box ( scene_object )
237
238
const height = bounding_box . max . y - bounding_box . min . y
239
+ const width = bounding_box . max . x - bounding_box . min . x
240
+ const depth = bounding_box . max . z - bounding_box . min . z
238
241
239
- // if model is very large, or very small, scale it to 1.0 to help with application
240
- if ( height > 0.1 && height < 4 ) {
241
- console . log ( 'Model a reasonable size, so no scaling applied: ' , height , ' height' )
242
+ const largest_dimension = Math . max ( height , width , depth )
243
+
244
+ // if model is very large, or very small, scale it to 1.5 to help with application
245
+ if ( largest_dimension > 0.5 && largest_dimension < 8 ) {
246
+ console . log ( 'Model a reasonable size, so no scaling applied: ' , largest_dimension , ' units is largest dimension' )
242
247
return
243
248
} else {
244
- console . log ( 'Model is very large or small, so scaling applied: ' , height , ' height ' )
249
+ console . log ( 'Model is very large or small, so scaling applied: ' , largest_dimension , ' units is largest dimension ' )
245
250
}
246
251
247
- scale_factor = 1.0 / height // goal is to scale the model to 1.0 height
252
+ scale_factor = 1.5 / height // goal is to scale the model to 1.5 units height (similar to skeleton proportions)
248
253
249
254
// scale all the meshes down by the calculated amount
250
255
scene_object . traverse ( ( child ) => {
0 commit comments