瀏覽代碼

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 { SRGBColorSpace, LinearSRGBColorSpace, DisplayP3ColorSpace, } from '../constants.js';
 import { Matrix3 } from './Matrix3.js';
 import { Matrix3 } from './Matrix3.js';
-import { Vector3 } from './Vector3.js';
 
 
 export function SRGBToLinear( c ) {
 export function SRGBToLinear( c ) {
 
 
@@ -14,7 +13,6 @@ export function LinearToSRGB( c ) {
 
 
 }
 }
 
 
-
 /**
 /**
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
  * or clipping. Based on W3C specifications for sRGB and Display P3,
  * 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
 	0.0000001, 0.0000000, 1.0982735
 ] );
 ] );
 
 
-const _vector = /*@__PURE__*/ new Vector3();
-
 function DisplayP3ToLinearSRGB( color ) {
 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 ) {
 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();
 
 
 }
 }