Static Batching for additive scene loading

Hi PlayCanvas gang,

How can one have static batching when loading additional scenes?

I have forked this project:

Then I have set one van to static batching and the other van to dynamic batching. The static batched van doesn’t get rendered when loading the van scene additive.


Here is the project:

Any hints appreciated,

1 Like

Issued ticket on engine GIT:

Hi @dexter_deluxe,

Check my answer here:

Running the generate method from console or within the load function doesn’t resolve the issue.

SceneManager.prototype._loadSelectedScene = function () {
    if (!this._loadingScene) {
        this._loadingScene = true; = false;
        // Remove the current scene that is loaded
        if (this.sceneRootEntity.children.length > 0) {
            // Assume that there is only one entity attached to the sceneRootEntity
            // which would be the loaded scene
        var self = this;
        var scene =[this._selectedSceneIndex]);, function (err, loadedSceneRootEntity) {
            if (err) {
            } else {
                self._loadingScene = false;
       = true;
                console.log("BATCHER: GENERATE");

It seems the issue isn’t with batching, but with the Static model component flag. There is some optimization there that breaks batching. If you disable that flag batching works as expected:


I am updating the github issue.

1 Like

Btw running the .generate() method indeed may not be required in your case since you are enabling those entities for the first time.

So I think the batcher will run once on its own.

1 Like

Hey @Leonidas,

just for clarification, could you tell me when it would be necessary to call .generate()? I’m assuming after spawning new models dynamically? We are also running a system, which disables/enables submeshes for collision and rendering, do you have any input on whether or not this might break batching?


Hi @Ciaviel,

So I’ve run some tests to be sure how the batcher behaves now, it seems the engine has been updated at some point to automate some things. Making the following example work a bit differently:

If you run it, and open the profiler, you will notice that when you create new boxes they are automatically batched. There is no need to press the create batches button, as the engine now calls the batcher generate() method for any entity with a model component that is assigned to a batch group.

Same when enabling/disabling those entities, the batcher reruns automatically. You can confirm the fact by watching the profiler, the batching time will increase when doing that: