Skip to content

Commit

Permalink
chore: init colorspace as null
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Apr 21, 2023
1 parent ccc52af commit 21723b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/fiber/src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Dpr, Renderer, RootState, Size } from './store'
*/
export const hasColorSpace = <
T extends Renderer | THREE.Texture | object,
P = T extends Renderer ? { outputColorSpace: string } : { colorSpace: string },
P = T extends Renderer ? { outputColorSpace: string | null } : { colorSpace: string | null },
>(
object: T,
): object is T & P => 'colorSpace' in object || 'outputColorSpace' in object
Expand Down
8 changes: 4 additions & 4 deletions packages/fiber/tests/core/renderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ describe('renderer', () => {
})

it('should respect color management preferences via gl', async () => {
const texture = new THREE.Texture() as THREE.Texture & { colorSpace?: string }
const texture = new THREE.Texture() as THREE.Texture & { colorSpace?: string | null }
let key = 0
function Test() {
return <meshBasicMaterial key={key++} map={texture} />
Expand All @@ -749,7 +749,7 @@ describe('renderer', () => {
const LinearEncoding = 3000
const sRGBEncoding = 3001

let gl: THREE.WebGLRenderer & { outputColorSpace?: string } = null!
let gl: THREE.WebGLRenderer & { outputColorSpace?: string | null } = null!
await act(async () => (gl = root.render(<Test />).getState().gl))
expect(gl.outputEncoding).toBe(sRGBEncoding)
expect(gl.toneMapping).toBe(THREE.ACESFilmicToneMapping)
Expand All @@ -764,8 +764,8 @@ describe('renderer', () => {
const SRGBColorSpace = 'srgb'
const LinearSRGBColorSpace = 'srgb-linear'

gl.outputColorSpace ??= ''
texture.colorSpace ??= ''
gl.outputColorSpace ??= null
texture.colorSpace ??= null

await act(async () => root.configure({ linear: true }).render(<Test />))
expect(gl.outputColorSpace).toBe(LinearSRGBColorSpace)
Expand Down

0 comments on commit 21723b3

Please sign in to comment.