@@ -333,22 +333,49 @@ export class BabylonScene {
333333 * @shortname skybox
334334 */
335335 enableSkybox ( inputs : Inputs . BabylonScene . SkyboxDto ) : void {
336- let texture : BABYLON . CubeTexture ;
337- if ( inputs . skybox === Inputs . Base . skyboxEnum . default ) {
338- texture = new BABYLON . CubeTexture ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/default_skybox/skybox" , this . context . scene ) ;
339- } else if ( inputs . skybox === Inputs . Base . skyboxEnum . greyGradient ) {
340- texture = new BABYLON . CubeTexture ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/grey_gradient/skybox" , this . context . scene ) ;
341- } else if ( inputs . skybox === Inputs . Base . skyboxEnum . clearSky ) {
342- texture = BABYLON . CubeTexture . CreateFromPrefilteredData ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/clear_sky/environment.env" ,
343- this . context . scene , false , false ) ;
344- } else if ( inputs . skybox === Inputs . Base . skyboxEnum . city ) {
345- texture = BABYLON . CubeTexture . CreateFromPrefilteredData ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/city/environmentSpecular.env" ,
346- this . context . scene , false , false ) ;
336+
337+ let texture : BABYLON . CubeTexture | BABYLON . HDRCubeTexture ;
338+
339+ if ( inputs . skybox === "custom" && inputs . textureUrl ) {
340+ // Handle custom HDR/EXR textures
341+ const textureUrl = inputs . textureUrl ;
342+ const textureSize = inputs . textureSize || 512 ; // Default size
343+
344+ // Better URL parsing to handle query strings
345+ const urlPath = textureUrl . split ( "?" ) [ 0 ] . toLowerCase ( ) ;
346+
347+ if ( urlPath . endsWith ( ".hdr" ) ) {
348+ // Use HDRCubeTexture for .hdr files
349+ if ( inputs . hdrTexture ) {
350+ texture = new BABYLON . HDRCubeTexture ( textureUrl , this . context . scene , textureSize , false , true , false , true ) ;
351+ }
352+ } else if ( urlPath . endsWith ( ".env" ) ) {
353+ texture = BABYLON . CubeTexture . CreateFromPrefilteredData ( inputs . textureUrl ,
354+ this . context . scene , false , false ) ;
355+ } else {
356+ // Fallback to CubeTexture for other formats
357+ texture = new BABYLON . CubeTexture ( textureUrl , this . context . scene ) ;
358+ }
359+ } else {
360+ if ( inputs . skybox === Inputs . Base . skyboxEnum . default ) {
361+ texture = new BABYLON . CubeTexture ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/default_skybox/skybox" , this . context . scene ) ;
362+ } else if ( inputs . skybox === Inputs . Base . skyboxEnum . greyGradient ) {
363+ texture = new BABYLON . CubeTexture ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/grey_gradient/skybox" , this . context . scene ) ;
364+ } else if ( inputs . skybox === Inputs . Base . skyboxEnum . clearSky ) {
365+ texture = BABYLON . CubeTexture . CreateFromPrefilteredData ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/clear_sky/environment.env" ,
366+ this . context . scene , false , false ) ;
367+ } else if ( inputs . skybox === Inputs . Base . skyboxEnum . city ) {
368+ texture = BABYLON . CubeTexture . CreateFromPrefilteredData ( "https://cdn.jsdelivr.net/gh/bitbybit-dev/bitbybit-assets@0.20.5/textures/skybox/city/environmentSpecular.env" ,
369+ this . context . scene , false , false ) ;
370+ }
347371 }
348372
349373 this . context . scene . getMeshByName ( "bitbybit-hdrSkyBox" ) ?. dispose ( false , true ) ;
350374 const skybox = this . context . scene . createDefaultSkybox ( texture , true , inputs . size , inputs . blur , true ) ;
351375 skybox . name = "bitbybit-hdrSkyBox" ;
376+ if ( inputs . hideSkybox ) {
377+ skybox . isVisible = false ;
378+ }
352379 this . context . scene . environmentIntensity = inputs . environmentIntensity ;
353380 }
354381
0 commit comments