Skip to content

Commit 25198b0

Browse files
authored
ColorManagement: Rename .legacyMode=false → .enabled=true (#24940)
* ColorManagement: Rename .legacyMode=false → .enabled=true * Update 'webgl_mirror' to use ColorManagement.enabled = true * ColorManagement: Add revision to rename warning. * Update Editor
1 parent 780feac commit 25198b0

File tree

8 files changed

+39
-22
lines changed

8 files changed

+39
-22
lines changed

docs/manual/en/introduction/Color-management.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ <h3>Input color space</h3>
158158
each have an associated color space. Those not already in the Linear-sRGB working color
159159
space must be converted, and textures be given the correct <i>texture.encoding</i> assignment.
160160
Certain conversions (for hexadecimal and CSS colors in sRGB) can be made automatically if
161-
the legacy color management mode is disabled before initializing colors:
161+
the THREE.ColorManagement API is enabled before initializing colors:
162162
</p>
163163

164164
<code>
165-
THREE.ColorManagement.legacyMode = false;
165+
THREE.ColorManagement.enabled = true;
166166
</code>
167167

168168
<ul>
@@ -264,7 +264,7 @@ <h2>Working with THREE.Color instances</h2>
264264
</code>
265265

266266
<p>
267-
With <i>ColorManagement.legacyMode = false</i> set (recommended), certain conversions
267+
With <i>ColorManagement.enabled = true</i> set (recommended), certain conversions
268268
are made automatically. Because hexadecimal and CSS colors are generally sRGB, [page:Color]
269269
methods will automatically convert these inputs from sRGB to Linear-sRGB in setters, or
270270
convert from Linear-sRGB to sRGB when returning hexadecimal or CSS output from getters.

docs/manual/fr/introduction/Color-management.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ <h3>Espaces colorimétriques d'entrée</h3>
162162
</p>
163163

164164
<code>
165-
THREE.ColorManagement.legacyMode = false;
165+
THREE.ColorManagement.enabled = true;
166166
</code>
167167

168168
<ul>
@@ -264,7 +264,7 @@ <h2>Utiliser des instances de THREE.Color</h2>
264264
</code>
265265

266266
<p>
267-
Avec <i>ColorManagement.legacyMode = false</i> d'activé (recommandé), certaines conversions
267+
Avec <i>ColorManagement.enabled = true</i> d'activé (recommandé), certaines conversions
268268
sont faites automatiquement. Parce que l'héxadécimal et les couleurs CSS sont généralement en sRGB, les méthodes [page:Color]
269269
vont automatiquement convertir ces entrées du sRGB au sRGB-Linéaire dans des setters, ou
270270
convertir depuis du sRGB-Linéaire au sRGB lors du renvoi de valeurs héxadécimales ou CSS depuis les getters.

docs/manual/it/introduction/Color-management.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ <h3>Input color space</h3>
195195
colori:
196196
</p>
197197

198-
<code> THREE.ColorManagement.legacyMode = false; </code>
198+
<code> THREE.ColorManagement.enabled = true; </code>
199199

200200
<ul>
201201
<li>
@@ -320,7 +320,7 @@ <h2>Lavorare con le istanze di THREE.Color</h2>
320320
</code>
321321

322322
<p>
323-
Con <i>ColorManagement.legacyMode = false</i> impostato (consigliato),
323+
Con <i>ColorManagement.enabled = true</i> impostato (consigliato),
324324
alcune conversioni vengono effettuate automaticamente. Poiché i colori
325325
esadecimali e CSS sono generalmente sRGB, i metodi [page:Color]
326326
convertiranno automaticamente questi input da sRGB a Linear-sRGB nei

docs/manual/pt-br/introduction/Color-management.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ <h3>Input do espaço de cores</h3>
162162
</p>
163163

164164
<code>
165-
THREE.ColorManagement.legacyMode = false;
165+
THREE.ColorManagement.enabled = true;
166166
</code>
167167

168168
<ul>
@@ -265,7 +265,7 @@ <h2>Trabalhando com instâncias THREE.Color</h2>
265265
</code>
266266

267267
<p>
268-
Com <i>ColorManagement.legacyMode = false</i> definido (recomendado), determinadas conversões
268+
Com <i>ColorManagement.enabled = true</i> definido (recomendado), determinadas conversões
269269
são feitas automaticamente. Como as cores hexadecimais e CSS geralmente são sRGB, métodos [page:Color]
270270
irão converter automaticamente essas entradas de sRGB para Linear-sRGB em setters, ou
271271
converter de Linear-sRGB para sRGB ao retornar hexadecimal ou CSS de getters.

editor/js/Editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Strings } from './Strings.js';
77
import { Storage as _Storage } from './Storage.js';
88
import { Selector } from './Viewport.Selector.js';
99

10-
THREE.ColorManagement.legacyMode = false;
10+
THREE.ColorManagement.enabled = true;
1111

1212
var _DEFAULT_CAMERA = new THREE.PerspectiveCamera( 50, 1, 0.01, 1000 );
1313
_DEFAULT_CAMERA.name = 'Camera';

editor/js/libs/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
window.THREE = THREE; // Used by APP Scripts.
2828
window.VRButton = VRButton; // Used by APP Scripts.
2929

30-
THREE.ColorManagement.legacyMode = false;
30+
THREE.ColorManagement.enabled = true;
3131

3232
var loader = new THREE.FileLoader();
3333
loader.load( 'app.json', function ( text ) {

examples/webgl_mirror.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
let groundMirror, verticalMirror;
5050

51+
THREE.ColorManagement.enabled = true;
52+
5153
init();
5254
animate();
5355

@@ -87,7 +89,7 @@
8789
clipBias: 0.003,
8890
textureWidth: window.innerWidth * window.devicePixelRatio,
8991
textureHeight: window.innerHeight * window.devicePixelRatio,
90-
color: 0x777777
92+
color: 0xb5b5b5
9193
} );
9294
groundMirror.position.y = 0.5;
9395
groundMirror.rotateX( - Math.PI / 2 );
@@ -98,7 +100,7 @@
98100
clipBias: 0.003,
99101
textureWidth: window.innerWidth * window.devicePixelRatio,
100102
textureHeight: window.innerHeight * window.devicePixelRatio,
101-
color: 0x889999
103+
color: 0xc1cbcb
102104
} );
103105
verticalMirror.position.y = 50;
104106
verticalMirror.position.z = - 50;
@@ -109,7 +111,7 @@
109111
scene.add( sphereGroup );
110112

111113
geometry = new THREE.CylinderGeometry( 0.1, 15 * Math.cos( Math.PI / 180 * 30 ), 0.1, 24, 1 );
112-
material = new THREE.MeshPhongMaterial( { color: 0xffffff, emissive: 0x444444 } );
114+
material = new THREE.MeshPhongMaterial( { color: 0xffffff, emissive: 0x8d8d8d } );
113115
const sphereCap = new THREE.Mesh( geometry, material );
114116
sphereCap.position.y = - 15 * Math.sin( Math.PI / 180 * 30 ) - 0.05;
115117
sphereCap.rotateX( - Math.PI );
@@ -124,7 +126,7 @@
124126
sphereGroup.add( halfSphere );
125127

126128
geometry = new THREE.IcosahedronGeometry( 5, 0 );
127-
material = new THREE.MeshPhongMaterial( { color: 0xffffff, emissive: 0x333333, flatShading: true } );
129+
material = new THREE.MeshPhongMaterial( { color: 0xffffff, emissive: 0x7b7b7b, flatShading: true } );
128130
smallSphere = new THREE.Mesh( geometry, material );
129131
scene.add( smallSphere );
130132

@@ -138,7 +140,7 @@
138140
planeBottom.rotateX( - Math.PI / 2 );
139141
scene.add( planeBottom );
140142

141-
const planeFront = new THREE.Mesh( planeGeo, new THREE.MeshPhongMaterial( { color: 0x7f7fff } ) );
143+
const planeFront = new THREE.Mesh( planeGeo, new THREE.MeshPhongMaterial( { color: 0xbbbbfe } ) );
142144
planeFront.position.z = 50;
143145
planeFront.position.y = 50;
144146
planeFront.rotateY( Math.PI );
@@ -157,7 +159,7 @@
157159
scene.add( planeLeft );
158160

159161
// lights
160-
const mainLight = new THREE.PointLight( 0xcccccc, 1.5, 250 );
162+
const mainLight = new THREE.PointLight( 0xe7e7e7, 1.5, 250 );
161163
mainLight.position.y = 60;
162164
scene.add( mainLight );
163165

@@ -169,7 +171,7 @@
169171
redLight.position.set( - 550, 50, 0 );
170172
scene.add( redLight );
171173

172-
const blueLight = new THREE.PointLight( 0x7f7fff, 0.25, 1000 );
174+
const blueLight = new THREE.PointLight( 0xbbbbfe, 0.25, 1000 );
173175
blueLight.position.set( 0, 50, 550 );
174176
scene.add( blueLight );
175177

src/math/ColorManagement.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,31 @@ export function LinearToSRGB( c ) {
1212

1313
}
1414

15-
// JavaScript RGB-to-RGB transforms, defined as
16-
// FN[InputColorSpace][OutputColorSpace] callback functions.
15+
// RGB-to-RGB transforms, defined as `FN[InputColorSpace][OutputColorSpace] → conversionFn`.
1716
const FN = {
1817
[ SRGBColorSpace ]: { [ LinearSRGBColorSpace ]: SRGBToLinear },
1918
[ LinearSRGBColorSpace ]: { [ SRGBColorSpace ]: LinearToSRGB },
2019
};
2120

2221
export const ColorManagement = {
2322

24-
legacyMode: true,
23+
enabled: false,
24+
25+
get legacyMode() {
26+
27+
console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r147.' );
28+
29+
return ! this.enabled;
30+
31+
},
32+
33+
set legacyMode( legacyMode ) {
34+
35+
console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r147.' );
36+
37+
this.enabled = ! legacyMode;
38+
39+
},
2540

2641
get workingColorSpace() {
2742

@@ -37,7 +52,7 @@ export const ColorManagement = {
3752

3853
convert: function ( color, sourceColorSpace, targetColorSpace ) {
3954

40-
if ( this.legacyMode || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
55+
if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
4156

4257
return color;
4358

0 commit comments

Comments
 (0)