BabylonJS/Babylon.js · error

Multi-file loading not allowed on env files.

Error message

Multi-file loading not allowed on env files.

What it means

Environment (.env) cube textures are single-file formats containing all six faces plus specular data. The native cube texture loader therefore rejects a 6-element files array — multi-file (per-face) cube texture loading is only for non-env formats — and throws immediately.

Source

Thrown at packages/dev/core/src/Engines/Native/Extensions/nativeEngine.cubeTexture.pure.ts:102

                    imageData,
                    false,
                    texture._useSRGBBuffer,
                    () => {
                        texture.isReady = true;
                        if (onLoad) {
                            onLoad();
                        }
                    },
                    () => {
                        throw new Error("Could not load a native cube texture.");
                    }
                );
            };

            if (buffer) {
                onloaddata(buffer);
            } else if (files && files.length === 6) {
                throw new Error(`Multi-file loading not allowed on env files.`);
            } else {
                const onInternalError = (request?: IWebRequest, exception?: any) => {
                    if (onError && request) {
                        onError(request.status + " " + request.statusText, exception);
                    }
                };

                this._loadFile(
                    rootUrl,
                    (data) => {
                        onloaddata(new Uint8Array(data as ArrayBuffer, 0, (data as ArrayBuffer).byteLength));
                    },
                    undefined,
                    undefined,
                    true,
                    onInternalError
                );
            }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Use a single .env file (export one from the Babylon.js sandbox / IBL baker) instead of six separate face files
  2. If you only have six face images, pre-bake them into one .env or DDS cubemap file, then load that single file
  3. If you truly need per-face loading, use the non-env cube texture API path (e.g. CubeTexture.CreateFromImages-style) rather than the env loader
  4. Concatenate or convert face files at build time into a single container the native engine supports

Example fix

// before
const files = ['px.png','nx.png','py.png','ny.png','pz.png','nz.png'];
nativeEngine.loadCubeTexture({ url: 'env', files }); // throws
// after
nativeEngine.loadCubeTexture({ url: 'assets/skybox.env' }); // single .env file
Defensive patterns

Strategy: validation

Validate before calling

function assertNotMultiFileEnv(files?: string[] | null): void {
  if (files && files.length === 6) {
    throw new Error('env cube textures must be a single file; provide one .env instead of 6 face images');
  }
}

Try / catch

try {
  const tex = nativeEngine.loadCubeTexture({ url, files });
} catch (e) {
  if (String(e.message).includes('Multi-file loading not allowed')) {
    // convert face files to a single .env and retry
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling NativeEngine's createCubeTexture/loadCubeTexture with both an env-style request and a files array of exactly 6 files (the multi-file per-face pattern used for plain cube faces), e.g. passing 6 face image files while the loader expects a single .env file or URL.

Common situations: Porting WebGL engine code that used 6 face files straight to Babylon Native with an env texture; configuring scene.environmentTexture with an array of six images instead of one .env; copy-paste from non-native cube texture examples that accept 6 files.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/1e5d7539c4a37463. Report an issue: GitHub.