createPrefilteredCubeTexture unavailable on Engine when using most specific imports

Using: import { Engine, EngineOptions } from ‘@babylonjs/core’

  • I can access createPrefilteredCubeTexture on the engine object.

Using: import { Engine, EngineOptions } from ‘@babylonjs/core/Engines/engine’;

  • createPrefilteredCubeTexture is unavailable on the engine object and my application fails.

Currently I need to use the most specific imports to correctly tree shake as re-exported values are causing my bundle size to be bigger than it needs to be.

pinging @sebavan

This is part of the DDS loader, so you need to

import "@babylonjs/coreMaterials/Textures/Loaders/ddsTextureLoader"

I will add it to the documentation ASAP.

After imported the file you suggested I now get the following error.

Error: Cannot load cubemap because files were not defined
at Engine.push…/node_modules/@babylonjs/core/Engines/Extensions/engine.cubeTexture.js.Engines_engine__WEBPACK_IMPORTED_MODULE_1_.Engine.createCubeTexture (engine.cubeTexture.js:232)
at Engine.push…/node_modules/@babylonjs/core/Misc/dds.js.Engines_engine__WEBPACK_IMPORTED_MODULE_3_.Engine.createPrefilteredCubeTexture (dds.js:768)
at new CubeTexture (cubeTexture.js:147)
at Function.CubeTexture.CreateFromPrefilteredData (cubeTexture.js:259)
at WorkflowScene.createSkybox (Component.tsx:271)

To clarify, everything works perfectly when I load from the re-export file in babylonjs/core

This is really strange, could you share your code ? it would be easier to address

Apologies for the long reply time. I couldn’t reproduce this issue in code sandbox so I went back to my implementation and found that I was missing the following import.

import ‘@babylonjs/core/Helpers/sceneHelpers’;

This contains the scene.createDefault* functions I use in my main scene component and must supply any of the additional imports to handle the texture loading.

Thanks again for the advice.

3 Likes