@@ -94,21 +94,31 @@ export default async function initCreator(
9494 updateProcessing ( )
9595 } )
9696
97+ let lastAssetsSnapshot : ZigAssetOutput [ ] = [ ]
9798 Logic . connect_on_asset_update_callback ( ( serializedData : ZigAssetOutput [ ] ) => {
98- const serializedAssetsTextureUrl = [ ...serializedData ] . map < SerializedOutputAsset > ( ( asset ) => ( {
99- id : asset . id ,
100- textureId : asset . texture_id ,
101- points : [ ...asset . points ] . map ( ( point ) => ( {
102- x : point . x ,
103- y : point . y ,
104- u : point . u ,
105- v : point . v ,
106- } ) ) ,
107- url : Textures . getUrl ( asset . texture_id ) ,
108- } ) )
109- onAssetsUpdate ( serializedAssetsTextureUrl )
99+ lastAssetsSnapshot = serializedData
100+ newAssetsSnapshot ( )
110101 } )
111102
103+ function newAssetsSnapshot ( ) {
104+ // this function is not part of Logic.connect_on_asset_update_callback
105+ // only because once we update a texture url, we have to notify about the assets update
106+ const serializedAssetsTextureUrl = [ ...lastAssetsSnapshot ] . map < SerializedOutputAsset > (
107+ ( asset ) => ( {
108+ id : asset . id ,
109+ textureId : asset . texture_id ,
110+ points : [ ...asset . points ] . map ( ( point ) => ( {
111+ x : point . x ,
112+ y : point . y ,
113+ u : point . u ,
114+ v : point . v ,
115+ } ) ) ,
116+ url : Textures . getUrl ( asset . texture_id ) ,
117+ } )
118+ )
119+ onAssetsUpdate ( serializedAssetsTextureUrl )
120+ }
121+
112122 Logic . connect_on_asset_selection_callback ( onAssetSelect )
113123
114124 Logic . connect_cache_callbacks ( ( textureId , boundingBox , width , height ) => {
@@ -123,6 +133,7 @@ export default async function initCreator(
123133 if ( isNew ) {
124134 uploadTexture ( url , ( newUrl ) => {
125135 Textures . updateTextureUrl ( textureId , newUrl )
136+ newAssetsSnapshot ( )
126137 } )
127138 }
128139 } )
@@ -174,8 +185,8 @@ export default async function initCreator(
174185 // snapshot with "default" points and then update it to the real points.
175186 if ( isNew ) {
176187 uploadTexture ( asset . url , ( newUrl ) => {
177- console . log ( asset . url , newUrl )
178188 Textures . updateTextureUrl ( textureId , newUrl )
189+ newAssetsSnapshot ( )
179190 } )
180191 }
181192
0 commit comments