Skip to content

Commit

Permalink
ColorManagement: Clean up (#25709)
Browse files Browse the repository at this point in the history
* Clean up

* Clean up

* Clean up
  • Loading branch information
WestLangley committed Mar 24, 2023
1 parent a8638ec commit 8ad8604
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/math/ColorManagement.js
Original file line number Diff line number Diff line change
@@ -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 ) {

Expand All @@ -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,
Expand All @@ -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();

}

Expand Down

0 comments on commit 8ad8604

Please sign in to comment.