@@ -52,9 +52,10 @@ const HOLOGRAM_LAYER_MODES = createNumericEnum(["SINGLE", "ALL_BELOW"]);
5252 * @param {HoloPrintConfig } [config]
5353 * @param {ResourcePackStack } [resourcePackStack]
5454 * @param {HTMLElement } [previewCont]
55+ * @param {Function } [previewLoadedCallback] A function that will be called once the preview has finished loading
5556 * @returns {Promise<File> } Resource pack (`*.mcpack`)
5657 */
57- export async function makePack ( structureFiles , config = { } , resourcePackStack , previewCont ) {
58+ export async function makePack ( structureFiles , config = { } , resourcePackStack , previewCont , previewLoadedCallback ) {
5859 console . info ( `Running HoloPrint ${ VERSION } ` ) ;
5960 if ( ! resourcePackStack ) {
6061 console . debug ( "Waiting for resource pack stack initialisation..." ) ;
@@ -491,14 +492,15 @@ export async function makePack(structureFiles, config = {}, resourcePackStack, p
491492 console . info ( `Finished creating pack in ${ ( performance . now ( ) - startTime ) . toFixed ( 0 ) / 1000 } s!` ) ;
492493
493494 if ( previewCont ) {
494- let showPreview = ( ) => {
495- hologramGeo [ "minecraft:geometry" ] . filter ( geo => geo [ "description" ] [ "identifier" ] . startsWith ( "geometry.armor_stand.hologram_" ) ) . map ( ( geo , structureI ) => {
496- PreviewRenderer . new ( previewCont , packName , textureAtlas , structureSizes [ structureI ] , blockPalette , boneTemplatePalette , allStructureIndicesByLayer [ structureI ] , {
495+ let showPreview = async ( ) => {
496+ await Promise . all ( structureSizes . map ( async ( structureSize , structureI ) => {
497+ await PreviewRenderer . new ( previewCont , packName , textureAtlas , structureSize , blockPalette , boneTemplatePalette , allStructureIndicesByLayer [ structureI ] , {
497498 showSkybox : config . SHOW_PREVIEW_SKYBOX ,
498499 showFps : config . SHOW_PREVIEW_WIDGETS ,
499500 showOptions : config . SHOW_PREVIEW_WIDGETS
500501 } ) ;
501- } ) ;
502+ } ) ) ;
503+ previewLoadedCallback ?. ( ) ;
502504 } ;
503505 if ( totalBlockCount < config . PREVIEW_BLOCK_LIMIT ) {
504506 showPreview ( ) ;
0 commit comments