Переглянути джерело

ColorManagement: Clean up (#25709)

* Clean up

* Clean up

* Clean up
WestLangley 2 роки тому
батько
коміт
8ad86047a2
1 змінених файлів з 4 додано та 12 видалено
  1. 4 12
      src/math/ColorManagement.js

+ 4 - 12
src/math/ColorManagement.js

@@ -1,6 +1,5 @@
 import { SRGBColorSpace, LinearSRGBColorSpace, DisplayP3ColorSpace, } from '../constants.js';
 import { Matrix3 } from './Matrix3.js';
-import { Vector3 } from './Vector3.js';
 
 export function SRGBToLinear( c ) {
 
@@ -14,7 +13,6 @@ export function LinearToSRGB( c ) {
 
 }
 
-
 /**
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -39,23 +37,17 @@ const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().fromArray(
 	0.0000001, 0.0000000, 1.0982735
 ] );
 
-const _vector = /*@__PURE__*/ new Vector3();
-
 function DisplayP3ToLinearSRGB( color ) {
 
-	color.convertSRGBToLinear();
-
-	_vector.set( color.r, color.g, color.b ).applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB );
-
-	return color.setRGB( _vector.x, _vector.y, _vector.z );
+	// Display P3 uses the sRGB transfer functions
+	return color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB );
 
 }
 
 function LinearSRGBToDisplayP3( color ) {
 
-	_vector.set( color.r, color.g, color.b ).applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 );
-
-	return color.setRGB( _vector.x, _vector.y, _vector.z ).convertLinearToSRGB();
+	// Display P3 uses the sRGB transfer functions
+	return color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB();
 
 }