@@ -41,7 +41,7 @@ type ExportedNodetransform = Omit<
41
41
}
42
42
type ExportedRenderedNode = Omit <
43
43
AnyRenderedNode ,
44
- 'node' | 'parentNode' | 'model' | 'boundingBox' | 'configs' | 'baseScale'
44
+ 'node' | 'parentNode' | 'model' | 'boundingBox' | 'configs' | 'baseScale' | 'safe_name'
45
45
> & {
46
46
default_transform : ExportedNodetransform
47
47
bounding_box ?: { min : ArrayVector3 ; max : ArrayVector3 }
@@ -50,7 +50,10 @@ type ExportedRenderedNode = Omit<
50
50
type ExportedAnimationFrame = Omit < IRenderedFrame , 'nodes' | 'node_transforms' > & {
51
51
node_transforms : Record < string , ExportedNodetransform >
52
52
}
53
- type ExportedBakedAnimation = Omit < IRenderedAnimation , 'uuid' | 'frames' | 'modified_nodes' > & {
53
+ type ExportedBakedAnimation = Omit <
54
+ IRenderedAnimation ,
55
+ 'uuid' | 'frames' | 'modified_nodes' | 'safe_name'
56
+ > & {
54
57
frames : ExportedAnimationFrame [ ]
55
58
modified_nodes : string [ ]
56
59
}
@@ -95,7 +98,6 @@ type ExportedDynamicAnimation = {
95
98
}
96
99
interface ExportedTexture {
97
100
name : string
98
- id : string
99
101
src : string
100
102
}
101
103
type ExportedVariantModel = Omit < IRenderedVariantModel , 'model_path' | 'resource_location' > & {
@@ -117,7 +119,6 @@ export interface IExportedJSON {
117
119
export_namespace : ( typeof defaultValues ) [ 'export_namespace' ]
118
120
bounding_box : ( typeof defaultValues ) [ 'bounding_box' ]
119
121
// Resource Pack Settings
120
- display_item : ( typeof defaultValues ) [ 'display_item' ]
121
122
custom_model_data_offset : ( typeof defaultValues ) [ 'custom_model_data_offset' ]
122
123
// Plugin Settings
123
124
baked_animations : ( typeof defaultValues ) [ 'baked_animations' ]
@@ -197,12 +198,19 @@ function serailizeKeyframe(kf: _Keyframe): ExportedKeyframe {
197
198
return json
198
199
}
199
200
200
- function serializeVariant ( variant : IRenderedVariant ) : ExportedVariant {
201
+ function serializeVariant ( rig : IRenderedRig , variant : IRenderedVariant ) : ExportedVariant {
201
202
const json : ExportedVariant = {
202
203
...variant ,
203
204
models : mapObjEntries ( variant . models , ( uuid , model ) => {
204
205
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
+ } ,
206
214
custom_model_data : model . custom_model_data ,
207
215
}
208
216
return [ uuid , json ]
@@ -223,10 +231,9 @@ export function exportJSON(options: {
223
231
224
232
console . log ( 'Exporting JSON...' , options )
225
233
226
- function serializeTexture ( id : string , texture : Texture ) : ExportedTexture {
234
+ function serializeTexture ( texture : Texture ) : ExportedTexture {
227
235
return {
228
236
name : texture . name ,
229
- id,
230
237
src : texture . getDataURL ( ) ,
231
238
}
232
239
}
@@ -235,16 +242,18 @@ export function exportJSON(options: {
235
242
settings : {
236
243
export_namespace : aj . export_namespace ,
237
244
bounding_box : aj . bounding_box ,
238
- display_item : options . displayItemPath ,
239
245
custom_model_data_offset : aj . custom_model_data_offset ,
240
246
baked_animations : aj . baked_animations ,
241
247
} ,
242
- textures : mapObjEntries ( rig . textures , ( id , texture ) => [
248
+ textures : mapObjEntries ( rig . textures , ( _ , texture ) => [
243
249
texture . uuid ,
244
- serializeTexture ( id , texture ) ,
250
+ serializeTexture ( texture ) ,
245
251
] ) ,
246
252
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
+ ] ) ,
248
257
animations : { } ,
249
258
}
250
259
@@ -311,6 +320,7 @@ function serailizeRenderedNode(node: AnyRenderedNode): ExportedRenderedNode {
311
320
const json : any = { ...node }
312
321
delete json . node
313
322
delete json . parentNode
323
+ delete json . safe_name
314
324
delete json . model
315
325
transferKey ( json , 'lineWidth' , 'line_width' )
316
326
transferKey ( json , 'backgroundColor' , 'background_color' )
@@ -343,7 +353,6 @@ function serailizeRenderedNode(node: AnyRenderedNode): ExportedRenderedNode {
343
353
function serializeAnimation ( animation : IRenderedAnimation ) : ExportedBakedAnimation {
344
354
const json : ExportedBakedAnimation = {
345
355
name : animation . name ,
346
- safe_name : animation . safe_name ,
347
356
duration : animation . duration ,
348
357
loop_delay : animation . loop_delay ,
349
358
loop_mode : animation . loop_mode ,
0 commit comments