@@ -979,12 +979,26 @@ DisplayMode.updateDisplayBase = function(slot) {
979979}
980980
981981
982+ // Extracted from a Bedrock 1.26.50.27 APK
983+ DisplayMode . bedrock_defaults = {
984+ gui : { translation : [ 0 , 0 , 0 ] , rotation : [ 30 , 45 , 0 ] , scale : [ 0.625 , 0.625 , 0.625 ] , fit_to_frame : true } ,
985+ firstperson_righthand : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , 45 , 0 ] , scale : [ 0.4 , 0.4 , 0.4 ] } ,
986+ firstperson_lefthand : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , - 135 , 0 ] , scale : [ 0.4 , 0.4 , 0.4 ] } ,
987+ thirdperson_righthand : { translation : [ 0 , 2.5 , 0 ] , rotation : [ 70 , 45 , 0 ] , scale : [ 0.375 , 0.375 , 0.375 ] } ,
988+ thirdperson_lefthand : { translation : [ 0 , 2.5 , 0 ] , rotation : [ 70 , 45 , 0 ] , scale : [ 0.375 , 0.375 , 0.375 ] } ,
989+ ground : { translation : [ 0 , 3 , 0 ] , rotation : [ 0 , 0 , 0 ] , scale : [ 0.25 , 0.25 , 0.25 ] } ,
990+ fixed : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , 0 , 0 ] , scale : [ 0.5 , 0.5 , 0.5 ] } ,
991+ head : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , 0 , 0 ] , scale : [ 1 , 1 , 1 ] } ,
992+ embedded : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , 0 , 0 ] , scale : [ 0.75 , 0.75 , 0.75 ] } ,
993+ on_shelf : { translation : [ 0 , 0 , 0 ] , rotation : [ 0 , 0 , 0 ] , scale : [ 0.5 , 0.5 , 0.5 ] } ,
994+ }
982995DisplayMode . applyPreset = function ( preset , all ) {
983996 if ( preset == undefined ) return ;
997+ let areas = ( preset . id == 'block' && Format . id == 'bedrock_block' ) ? DisplayMode . bedrock_defaults : preset . areas ;
984998 var slots = [ DisplayMode . display_slot ] ;
985999 if ( all ) {
9861000 slots = displayReferenceObjects . slots
987- } else if ( preset . areas [ DisplayMode . display_slot ] == undefined ) {
1001+ } else if ( areas [ DisplayMode . display_slot ] == undefined ) {
9881002 Blockbench . showQuickMessage ( 'message.preset_no_info' )
9891003 return ;
9901004 } ;
@@ -993,23 +1007,22 @@ DisplayMode.applyPreset = function(preset, all) {
9931007 if ( ! Project . display_settings [ sl ] ) {
9941008 Project . display_settings [ sl ] = new DisplaySlot ( sl )
9951009 }
996- let preset_values = preset . areas [ sl ] ;
1010+ let preset_values = areas [ sl ] ;
9971011 if ( preset_values ) {
9981012 if ( ! preset_values . rotation_pivot ) Project . display_settings [ sl ] . rotation_pivot . replace ( [ 0 , 0 , 0 ] ) ;
9991013 if ( ! preset_values . scale_pivot ) Project . display_settings [ sl ] . scale_pivot . replace ( [ 0 , 0 , 0 ] ) ;
1000- Project . display_settings [ sl ] . extend ( preset . areas [ sl ] ) ;
1001- if ( preset . id == 'block' && Format . id == 'bedrock_block' && sl == 'gui' ) {
1002- Project . display_settings [ sl ] . rotation [ 1 ] = 45 ;
1003- }
1014+ Project . display_settings [ sl ] . extend ( preset_values ) ;
10041015 }
10051016 } )
10061017 DisplayMode . updateDisplayBase ( )
10071018 Undo . finishEdit ( 'Apply display preset' )
10081019}
1009- DisplayMode . loadJSON = function ( data ) {
1010- for ( var slot in data ) {
1020+ DisplayMode . loadJSON = function ( data , defaults ) {
1021+ for ( let slot in data ) {
10111022 if ( displayReferenceObjects . slots . includes ( slot ) ) {
1012- Project . display_settings [ slot ] = new DisplaySlot ( slot ) . extend ( data [ slot ] )
1023+ let display_slot = new DisplaySlot ( slot ) ;
1024+ if ( defaults && defaults [ slot ] ) display_slot . extend ( defaults [ slot ] ) ;
1025+ Project . display_settings [ slot ] = display_slot . extend ( data [ slot ] ) ;
10131026 }
10141027 }
10151028}
0 commit comments