@@ -645,25 +645,26 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
645645 * viewer.modelCentric(true);
646646 * ```
647647 */
648- viewer . modelCentric = function ( model_centric = false ) {
649- var model = viewer . model ;
648+ viewer . modelCentric = function ( model_centric ) {
649+ model_centric = model_centric === undefined ? false : true ;
650650
651+ var model = viewer . model ;
651652 viewer . findUserDataCentroid ( model ) ;
652653
653- if ( model_centric === model . userData . model_centric ) { return } ;
654+ if ( model_centric === model . userData . model_centric ) { return ; }
654655
655656 // Caculate the offset
656657 var offset_centroid = new THREE . Vector3 ( ) ;
657658 offset_centroid . copy ( model . userData . model_center_offset ) ;
658- if ( model_centric === false ) { offset_centroid . negate ( ) } ;
659+ if ( model_centric === false ) { offset_centroid . negate ( ) ; }
659660
660661 model . children . forEach ( function ( children ) {
661662 // Return if children is not given by the user
662- if ( Object . keys ( children . userData ) . length === 0 && children . userData . constructor === Object ) { return } ;
663- children . translateX ( offset_centroid . x ) ;
664- children . translateY ( offset_centroid . y ) ;
665- children . translateZ ( offset_centroid . z ) ;
666- model . userData . model_centric = model_centric ;
663+ if ( Object . keys ( children . userData ) . length === 0 && children . userData . constructor === Object ) { return ; }
664+ children . translateX ( offset_centroid . x ) ;
665+ children . translateY ( offset_centroid . y ) ;
666+ children . translateZ ( offset_centroid . z ) ;
667+ model . userData . model_centric = model_centric ;
667668 } ) ;
668669 viewer . updated = true ;
669670 } ;
@@ -684,7 +685,7 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
684685 */
685686 viewer . findUserDataCentroid = function ( model ) {
686687 // Calculate only if needed
687- if ( model . userData . model_center_offset !== undefined ) { return } ;
688+ if ( model . userData . model_center_offset !== undefined ) { return ; }
688689
689690 // Calculate bounding box for all children given by the user
690691 // ignore other children
@@ -696,30 +697,28 @@ BrainBrowser.SurfaceViewer.modules.rendering = function(viewer) {
696697 var model_name = children . userData . model_name ;
697698 var model_data = viewer . model_data . get ( model_name ) ;
698699
699- var current_shape = undefined ;
700700 var children_name = children . name ;
701701 model_data . shapes . forEach ( function ( shape ) {
702- if ( shape . name !== children_name ) { return } ;
703- current_shape = shape ;
704- var bounding_box = shape . bounding_box ;
705-
706- // min
707- min_x = Math . min ( min_x , bounding_box . min_x ) ;
708- min_y = Math . min ( min_y , bounding_box . min_y ) ;
709- min_z = Math . min ( min_z , bounding_box . min_z ) ;
710- // max
711- max_x = Math . max ( max_x , bounding_box . max_x ) ;
712- max_y = Math . max ( max_y , bounding_box . max_y ) ;
713- max_z = Math . max ( max_z , bounding_box . max_z ) ;
702+ if ( shape . name !== children_name ) { return ; }
703+ var bounding_box = shape . bounding_box ;
704+
705+ // min
706+ min_x = Math . min ( min_x , bounding_box . min_x ) ;
707+ min_y = Math . min ( min_y , bounding_box . min_y ) ;
708+ min_z = Math . min ( min_z , bounding_box . min_z ) ;
709+ // max
710+ max_x = Math . max ( max_x , bounding_box . max_x ) ;
711+ max_y = Math . max ( max_y , bounding_box . max_y ) ;
712+ max_z = Math . max ( max_z , bounding_box . max_z ) ;
714713 } ) ;
715714
716715 // centroid of all the model
717- var centroid = new THREE . Vector3 ( )
716+ var centroid = new THREE . Vector3 ( ) ;
718717 centroid . x = min_x + ( max_x - min_x ) / 2 ;
719718 centroid . y = min_y + ( max_y - min_y ) / 2 ;
720719 centroid . z = min_z + ( max_z - min_z ) / 2 ;
721720
722- model . userData . model_center_offset = new THREE . Vector3 ( - centroid . x , - centroid . y , - centroid . z )
721+ model . userData . model_center_offset = new THREE . Vector3 ( - centroid . x , - centroid . y , - centroid . z ) ;
723722 } ) ;
724723 } ;
725724
0 commit comments