Skip to content

Commit be02a54

Browse files
mrdoobclaude
andauthored
WebGLRenderer: Unify cubemaps and cubeuvmaps into WebGLEnvironments (#32792)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent eab337a commit be02a54

File tree

6 files changed

+240
-248
lines changed

6 files changed

+240
-248
lines changed

src/renderers/WebGLRenderer.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import { WebGLBindingStates } from './webgl/WebGLBindingStates.js';
3131
import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';
3232
import { WebGLCapabilities } from './webgl/WebGLCapabilities.js';
3333
import { WebGLClipping } from './webgl/WebGLClipping.js';
34-
import { WebGLCubeMaps } from './webgl/WebGLCubeMaps.js';
35-
import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js';
34+
import { WebGLEnvironments } from './webgl/WebGLEnvironments.js';
3635
import { WebGLExtensions } from './webgl/WebGLExtensions.js';
3736
import { WebGLGeometries } from './webgl/WebGLGeometries.js';
3837
import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';
@@ -414,7 +413,7 @@ class WebGLRenderer {
414413
}
415414

416415
let extensions, capabilities, state, info;
417-
let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
416+
let properties, textures, environments, attributes, geometries, objects;
418417
let programCache, materials, renderLists, renderStates, clipping, shadowMap;
419418

420419
let background, morphtargets, bufferRenderer, indexedBufferRenderer;
@@ -441,19 +440,18 @@ class WebGLRenderer {
441440
info = new WebGLInfo( _gl );
442441
properties = new WebGLProperties();
443442
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
444-
cubemaps = new WebGLCubeMaps( _this );
445-
cubeuvmaps = new WebGLCubeUVMaps( _this );
443+
environments = new WebGLEnvironments( _this );
446444
attributes = new WebGLAttributes( _gl );
447445
bindingStates = new WebGLBindingStates( _gl, attributes );
448446
geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
449447
objects = new WebGLObjects( _gl, geometries, attributes, bindingStates, info );
450448
morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
451449
clipping = new WebGLClipping( properties );
452-
programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
450+
programCache = new WebGLPrograms( _this, environments, extensions, capabilities, bindingStates, clipping );
453451
materials = new WebGLMaterials( _this, properties );
454452
renderLists = new WebGLRenderLists();
455453
renderStates = new WebGLRenderStates( extensions );
456-
background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
454+
background = new WebGLBackground( _this, environments, state, objects, _alpha, premultipliedAlpha );
457455
shadowMap = new WebGLShadowMap( _this, objects, capabilities );
458456
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
459457

@@ -1055,8 +1053,7 @@ class WebGLRenderer {
10551053
renderLists.dispose();
10561054
renderStates.dispose();
10571055
properties.dispose();
1058-
cubemaps.dispose();
1059-
cubeuvmaps.dispose();
1056+
environments.dispose();
10601057
objects.dispose();
10611058
bindingStates.dispose();
10621059
uniformsGroups.dispose();
@@ -2137,7 +2134,7 @@ class WebGLRenderer {
21372134

21382135
materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
21392136
materialProperties.fog = scene.fog;
2140-
materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
2137+
materialProperties.envMap = environments.get( material.envMap || materialProperties.environment, material.isMeshStandardMaterial );
21412138
materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
21422139

21432140
if ( programs === undefined ) {
@@ -2270,7 +2267,7 @@ class WebGLRenderer {
22702267
const fog = scene.fog;
22712268
const environment = material.isMeshStandardMaterial ? scene.environment : null;
22722269
const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
2273-
const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
2270+
const envMap = environments.get( material.envMap || environment, material.isMeshStandardMaterial );
22742271
const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
22752272
const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
22762273
const morphTargets = !! geometry.morphAttributes.position;

src/renderers/webgl/WebGLBackground.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const _rgb = { r: 0, b: 0, g: 0 };
1414
const _e1 = /*@__PURE__*/ new Euler();
1515
const _m1 = /*@__PURE__*/ new Matrix4();
1616

17-
function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
17+
function WebGLBackground( renderer, environments, state, objects, alpha, premultipliedAlpha ) {
1818

1919
const clearColor = new Color( 0x000000 );
2020
let clearAlpha = alpha === true ? 0 : 1;
@@ -33,7 +33,7 @@ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha,
3333
if ( background && background.isTexture ) {
3434

3535
const usePMREM = scene.backgroundBlurriness > 0; // use PMREM if the user wants to blur the background
36-
background = ( usePMREM ? cubeuvmaps : cubemaps ).get( background );
36+
background = environments.get( background, usePMREM );
3737

3838
}
3939

src/renderers/webgl/WebGLCubeMaps.js

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/renderers/webgl/WebGLCubeUVMaps.js

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)