@@ -41,7 +41,7 @@ type ExportedNodetransform = Omit<
4141}
4242type ExportedRenderedNode = Omit <
4343 AnyRenderedNode ,
44- 'node' | 'parentNode' | 'model' | 'boundingBox' | 'configs' | 'baseScale'
44+ 'node' | 'parentNode' | 'model' | 'boundingBox' | 'configs' | 'baseScale' | 'safe_name'
4545> & {
4646 default_transform : ExportedNodetransform
4747 bounding_box ?: { min : ArrayVector3 ; max : ArrayVector3 }
@@ -50,7 +50,10 @@ type ExportedRenderedNode = Omit<
5050type ExportedAnimationFrame = Omit < IRenderedFrame , 'nodes' | 'node_transforms' > & {
5151 node_transforms : Record < string , ExportedNodetransform >
5252}
53- type ExportedBakedAnimation = Omit < IRenderedAnimation , 'uuid' | 'frames' | 'modified_nodes' > & {
53+ type ExportedBakedAnimation = Omit <
54+ IRenderedAnimation ,
55+ 'uuid' | 'frames' | 'modified_nodes' | 'safe_name'
56+ > & {
5457 frames : ExportedAnimationFrame [ ]
5558 modified_nodes : string [ ]
5659}
@@ -95,7 +98,6 @@ type ExportedDynamicAnimation = {
9598}
9699interface ExportedTexture {
97100 name : string
98- id : string
99101 src : string
100102}
101103type ExportedVariantModel = Omit < IRenderedVariantModel , 'model_path' | 'resource_location' > & {
@@ -117,7 +119,6 @@ export interface IExportedJSON {
117119 export_namespace : ( typeof defaultValues ) [ 'export_namespace' ]
118120 bounding_box : ( typeof defaultValues ) [ 'bounding_box' ]
119121 // Resource Pack Settings
120- display_item : ( typeof defaultValues ) [ 'display_item' ]
121122 custom_model_data_offset : ( typeof defaultValues ) [ 'custom_model_data_offset' ]
122123 // Plugin Settings
123124 baked_animations : ( typeof defaultValues ) [ 'baked_animations' ]
@@ -197,12 +198,19 @@ function serailizeKeyframe(kf: _Keyframe): ExportedKeyframe {
197198 return json
198199}
199200
200- function serializeVariant ( variant : IRenderedVariant ) : ExportedVariant {
201+ function serializeVariant ( rig : IRenderedRig , variant : IRenderedVariant ) : ExportedVariant {
201202 const json : ExportedVariant = {
202203 ...variant ,
203204 models : mapObjEntries ( variant . models , ( uuid , model ) => {
204205 const json : ExportedVariantModel = {
205- model : model . model ,
206+ model : {
207+ ...model . model ,
208+ // textures: mapObjEntries(model.model.textures, (id, path) => {
209+ // const actualTexture = rig.textures[id]
210+ // if (!actualTexture) return [id, path]
211+ // return [id, actualTexture.uuid]
212+ // }),
213+ } ,
206214 custom_model_data : model . custom_model_data ,
207215 }
208216 return [ uuid , json ]
@@ -223,10 +231,9 @@ export function exportJSON(options: {
223231
224232 console . log ( 'Exporting JSON...' , options )
225233
226- function serializeTexture ( id : string , texture : Texture ) : ExportedTexture {
234+ function serializeTexture ( texture : Texture ) : ExportedTexture {
227235 return {
228236 name : texture . name ,
229- id,
230237 src : texture . getDataURL ( ) ,
231238 }
232239 }
@@ -235,16 +242,18 @@ export function exportJSON(options: {
235242 settings : {
236243 export_namespace : aj . export_namespace ,
237244 bounding_box : aj . bounding_box ,
238- display_item : options . displayItemPath ,
239245 custom_model_data_offset : aj . custom_model_data_offset ,
240246 baked_animations : aj . baked_animations ,
241247 } ,
242- textures : mapObjEntries ( rig . textures , ( id , texture ) => [
248+ textures : mapObjEntries ( rig . textures , ( _ , texture ) => [
243249 texture . uuid ,
244- serializeTexture ( id , texture ) ,
250+ serializeTexture ( texture ) ,
245251 ] ) ,
246252 nodes : mapObjEntries ( rig . nodes , ( uuid , node ) => [ uuid , serailizeRenderedNode ( node ) ] ) ,
247- variants : mapObjEntries ( rig . variants , ( uuid , variant ) => [ uuid , serializeVariant ( variant ) ] ) ,
253+ variants : mapObjEntries ( rig . variants , ( uuid , variant ) => [
254+ uuid ,
255+ serializeVariant ( rig , variant ) ,
256+ ] ) ,
248257 animations : { } ,
249258 }
250259
@@ -311,6 +320,7 @@ function serailizeRenderedNode(node: AnyRenderedNode): ExportedRenderedNode {
311320 const json : any = { ...node }
312321 delete json . node
313322 delete json . parentNode
323+ delete json . safe_name
314324 delete json . model
315325 transferKey ( json , 'lineWidth' , 'line_width' )
316326 transferKey ( json , 'backgroundColor' , 'background_color' )
@@ -343,7 +353,6 @@ function serailizeRenderedNode(node: AnyRenderedNode): ExportedRenderedNode {
343353function serializeAnimation ( animation : IRenderedAnimation ) : ExportedBakedAnimation {
344354 const json : ExportedBakedAnimation = {
345355 name : animation . name ,
346- safe_name : animation . safe_name ,
347356 duration : animation . duration ,
348357 loop_delay : animation . loop_delay ,
349358 loop_mode : animation . loop_mode ,
0 commit comments