@@ -150,7 +150,6 @@ export type AnyRenderedNode = IRenderedNodes[keyof IRenderedNodes]
150150export interface IRenderedVariantModel {
151151 model : IRenderedModel | null
152152 custom_model_data : number
153- model_path : string
154153 resource_location : string
155154}
156155
@@ -350,7 +349,6 @@ function renderGroup(
350349 display : { head : { rotation : [ 0 , 180 , 0 ] } } ,
351350 } ,
352351 custom_model_data : - 1 , // This is calculated when constructing the resource pack.
353- model_path : path ,
354352 resource_location : parsed . resourceLocation ,
355353 }
356354 }
@@ -554,20 +552,25 @@ function renderCamera(camera: ICamera, rig: IRenderedRig) {
554552function renderVariantModels ( variant : Variant , rig : IRenderedRig ) {
555553 const models : Record < string , IRenderedVariantModel > = { }
556554
555+ const defaultVariant = Variant . getDefault ( )
556+ const defaultModels = rig . variants [ defaultVariant . uuid ] . models
557+
558+ // debugger
557559 for ( const [ uuid , bone ] of Object . entries ( rig . nodes ) ) {
558560 if ( bone . type !== 'bone' ) continue
559561 if ( variant . excludedNodes . find ( v => v . value === uuid ) ) continue
560562 const textures : IRenderedModel [ 'textures' ] = { }
561563
562- // Is set false if any texture other than the internal transparency texture is found.
563- let isTransparent = true
564+ let isOnlyTransparent = true
565+ const unreplacedTextures = new Set < string > ( Object . keys ( defaultModels [ uuid ] . model ! . textures ) )
564566
565567 for ( const [ fromUUID , toUUID ] of variant . textureMap . map . entries ( ) ) {
566568 const fromTexture = Texture . all . find ( t => t . uuid === fromUUID )
567569 if ( ! fromTexture ) throw new Error ( `From texture not found: ${ fromUUID } ` )
568570 if ( toUUID === TRANSPARENT_TEXTURE . uuid ) {
569571 textures [ fromTexture . id ] = TRANSPARENT_TEXTURE_RESOURCE_LOCATION
570572 rig . textures [ TRANSPARENT_TEXTURE . id ] = TRANSPARENT_TEXTURE
573+ unreplacedTextures . delete ( fromTexture . id )
571574 } else {
572575 const toTexture = Texture . all . find ( t => t . uuid === toUUID )
573576 if ( ! toTexture ) throw new Error ( `To texture not found: ${ toUUID } ` )
@@ -576,12 +579,22 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
576579 rig
577580 ) . resourceLocation
578581 rig . textures [ toTexture . id ] = toTexture
579- isTransparent = false
582+ isOnlyTransparent = false
580583 }
581584 }
582585
583- // Don't export models without any texture changes, or that are fully transparent.
584- if ( isTransparent || Object . keys ( textures ) . length === 0 ) continue
586+ // Don't export models without any texture changes
587+ if ( Object . keys ( textures ) . length === 0 ) continue
588+
589+ // Use empty model if all textures are transparent
590+ if ( isOnlyTransparent && unreplacedTextures . size === 0 ) {
591+ models [ uuid ] = {
592+ model : null ,
593+ custom_model_data : 1 ,
594+ resource_location : 'animated_java:empty' ,
595+ }
596+ continue
597+ }
585598
586599 const modelParent = PathModule . join (
587600 rig . model_export_folder ,
@@ -609,7 +622,6 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
609622 textures,
610623 } ,
611624 custom_model_data : - 1 , // This is calculated when constructing the resource pack.
612- model_path : modelPath ,
613625 resource_location : parsedModelPath . resourceLocation ,
614626 }
615627 }
0 commit comments