[SOLVED] If model Preload is not checked, batch is invalid?

If model Preload is not checked, batch is invalid?Is this a bug?

You may have to regenerate the batch after assets have been loaded and used in the scene

    var modelAsset = pc.app.assets.get(models[0].asset);
    if (modelAsset) {
        if (!modelAsset.resource) {
            modelAsset.once("load", function () {
                setTimeout(function () {
                    for (var i = 0; i < models.length; i++) {
                        if(models[i].batchGroupId != -1) models[i].batchGroupId = -1;
                        models[i].batchGroupId = group.id;
                    }
                }, 0);
            });
        } else {
            setTimeout(function () {
                for (var i = 0; i < models.length; i++) {
                    if(models[i].batchGroupId != -1) models[i].batchGroupId = -1;
                    models[i].batchGroupId = group.id;
                }
            }, 0);
        }
    }

OK, that’s the only way for now, but can this be repaired?

After you have loaded and added all the models/entities to the scene at runtime, try marking the batch group as dirty so it generates the batch on the next frame BatchManager | PlayCanvas API Reference

If you are still running into issues, please post a project example for people to look at

Thank you for your reply. It has been solved. :hand_with_index_finger_and_thumb_crossed:

1 Like