22/// <reference path="D:/github-repos/snavesutit/blockbench-types/types/index.d.ts"/>
33/// <reference path="../global.d.ts"/>
44
5- import { IBlueprintVariantJSON } from '../blueprintFormat'
5+ import type { IBlueprintBoneConfigJSON , IBlueprintVariantJSON } from '../blueprintFormat'
66import { type defaultValues } from '../blueprintSettings'
77import { EasingKey } from '../util/easing'
88import { detectCircularReferences , scrubUndefined } from '../util/misc'
@@ -29,9 +29,10 @@ type ExportedNodetransform = Omit<INodeTransform, 'node' | 'matrix' | 'transform
2929}
3030type ExportedRenderedNode = Omit <
3131 AnyRenderedNode ,
32- 'node' | 'parentNode' | 'model' | 'boundingBox'
32+ 'node' | 'parentNode' | 'model' | 'boundingBox' | 'configs'
3333> & {
3434 boundingBox ?: { min : ArrayVector3 ; max : ArrayVector3 }
35+ configs ?: Record < string , IBlueprintBoneConfigJSON >
3536}
3637type ExportedAnimationFrame = Omit < IRenderedFrame , 'nodes' | 'node_transforms' > & {
3738 node_transforms : ExportedNodetransform [ ]
@@ -68,6 +69,7 @@ type ExportedDynamicAnimation = {
6869}
6970interface ISerializedTexture {
7071 name : string
72+ id : string
7173 expectedPath : string
7274 src : string
7375}
@@ -124,9 +126,10 @@ export function exportJSON(options: {
124126
125127 console . log ( 'Exporting JSON...' , options )
126128
127- function serializeTexture ( texture : Texture ) : ISerializedTexture {
129+ function serializeTexture ( id : string , texture : Texture ) : ISerializedTexture {
128130 return {
129131 name : texture . name ,
132+ id,
130133 expectedPath : PathModule . join (
131134 textureExportFolder ,
132135 texture . name . endsWith ( '.png' ) ? texture . name : texture . name + '.png'
@@ -154,9 +157,9 @@ export function exportJSON(options: {
154157 models : rig . models ,
155158 variant_models : rig . variantModels ,
156159 textures : Object . fromEntries (
157- Object . entries ( rig . textures ) . map ( ( [ key , texture ] ) => [
158- key ,
159- serializeTexture ( texture ) ,
160+ Object . entries ( rig . textures ) . map ( ( [ id , texture ] ) => [
161+ texture . uuid ,
162+ serializeTexture ( id , texture ) ,
160163 ] )
161164 ) ,
162165 } ,
@@ -222,6 +225,12 @@ function serailizeRenderedNode(node: AnyRenderedNode): ExportedRenderedNode {
222225 min : node . boundingBox . min . toArray ( ) ,
223226 max : node . boundingBox . max . toArray ( ) ,
224227 }
228+ delete json . configs
229+ json . configs = { ...node . configs . variants }
230+ const defaultVariant = Variant . getDefault ( )
231+ if ( node . configs . default && defaultVariant ) {
232+ json . configs [ defaultVariant . uuid ] = node . configs . default
233+ }
225234 }
226235 return json as ExportedRenderedNode
227236}
0 commit comments