@@ -6,6 +6,7 @@ import { ModelLoader } from "./../../io/model_loader";
66import { animation_codec } from "./bedrock_animation"
77import "./animation_controller_codec"
88import { loadBedrockCollisionFromJSON } from "./bedrock_voxel_shape" ;
9+ import PlayerTexture from './../../../assets/player_skin.png'
910
1011if ( isApp ) {
1112window . BedrockEntityManager = class BedrockEntityManager {
@@ -1792,25 +1793,47 @@ BARS.defineActions(function() {
17921793 show_on_start_screen : false ,
17931794 icon : 'icon-player' ,
17941795 target : 'Minecraft: Bedrock Edition' ,
1795- onStart ( import_as_attachable ) {
1796- let import_bbmodel = import_as_attachable ? Codecs . project . compile ( ) : null ;
1796+ onStart : async function ( ) {
1797+
1798+ let form_config = await new Promise ( ( resolve , reject ) => {
1799+ new Dialog ( {
1800+ title : 'Bedrock Player Model' ,
1801+ form : {
1802+ import_as_attachable : { label : 'Import current model as attachable' , value : true , type : 'checkbox' } ,
1803+ } ,
1804+ onConfirm ( result ) {
1805+ resolve ( result )
1806+ } ,
1807+ onCancel ( ) {
1808+ reject ( ) ;
1809+ }
1810+ } ) . show ( ) ;
1811+ } ) ;
1812+
1813+ let import_bbmodel = form_config . import_as_attachable ? Codecs . project . compile ( ) : null ;
17971814
17981815 setupProject ( entity_format ) ;
17991816 parseGeometry ( { object : player_geo } , { } ) ;
18001817
1818+
1819+
1820+ new Texture ( { name : 'player.png' } ) . fromDataURL ( PlayerTexture ) . add ( true , true ) ;
1821+
18011822 let elements_before = Outliner . elements . slice ( ) ;
18021823 let groups_before = Group . all . slice ( ) ;
1824+ let textures_before = Texture . all . slice ( ) ;
1825+ let animations_before = Animation . all . slice ( ) ;
18031826 Outliner . nodes . forEach ( node => {
18041827 node . scope = 1 ;
18051828 } )
18061829
1807- if ( import_as_attachable ) {
1830+ if ( form_config . import_as_attachable ) {
18081831 Codecs . project . merge ( JSON . parse ( import_bbmodel ) ) ;
18091832 Outliner . nodes . forEach ( node => {
18101833 if ( ! elements_before . includes ( node ) && ! groups_before . includes ( node ) ) {
18111834 node . scope = 2 ;
18121835 }
1813- } )
1836+ } ) ;
18141837 }
18151838 }
18161839 } )
0 commit comments