AssetContainer fails with environmentTexture

Hello - I am trying to use an AssetContainer with a HDRCubeTexture that’s been set using createDefaultSkybox. This consistently fails with:

assetContainer.js?18ef:523 Uncaught (in promise) TypeError: sourceAssets is not iterable
    at AssetContainer._moveAssets (assetContainer.js?18ef:523:1)
    at AssetContainer.moveAllFromScene (assetContainer.js?18ef:551:1)

…from what I see, assetContainer.js does:

        for (const key in this) {
            if (, key)) {
                (<any>this)[key] = (<any>this)[key] || (key === "environmentTexture" ? null : []);
                this._moveAssets((<any>this.scene)[key], (<any>this)[key], (<any>keepAssets)[key]);

…which at some point calls _moveAssets with they key '_environmentTexture' (NOT 'environmentTexture'). At that point, this.scene['_environmentTexture'] is an instance of HDRCubeTexture, which is not a valid argument for _moveAssets.

I cannot repro this in the Playground, but I cannot see how this could work given the code. If the AssetCointainer instance hay a _environmentTexture key (looks like it does) then this line here will pass in this.scene['_environmentTexture']with a wrong type into _moveAssets.

Am I missing something? Thanks for your help!

Apparently this does not fail in the Playground because this line in assetContainer.ts is compiled to:

for (var n = 0, r = e; n < r.length; n++) { ... }

…which effectively skips the loop: r.length is undefined, 0 < r.length evaluates to false, and the loop exits immediately. If the code isn’t as optimized however, that line is:

for (const asset of sourceAssets) { ... }

…which fails because sourceAssets is not iterable.

Looks like this should be patched? Any workarounds? Thanks again!

Welcome aboard!

You’re right, there’s a bug in there. Here’s a PR that fixes it:


Awesome, thanks for the quick fix!