Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
force srgb colorspace on diffuse like threejs does
Browse files Browse the repository at this point in the history
  • Loading branch information
dinomut1 committed Oct 28, 2023
1 parent a7e30a8 commit f922256
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/engine/src/assets/loaders/gltf/GLTFLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
BufferAttribute,
BufferGeometry,
Camera,
ColorSpace,
Group,
InterleavedBufferAttribute,
Loader,
Expand Down Expand Up @@ -128,7 +129,8 @@ export class GLTFParser {
index: number
texCoord?: number | undefined
extensions?: any
}
},
colorSpace?: ColorSpace
) => Promise<void>
assignFinalMaterial: (object: Mesh) => void
getMaterialType: () => typeof MeshStandardMaterial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import { Color, Material } from 'three'
import { Color, Material, SRGBColorSpace } from 'three'

import { getState } from '@etherealengine/hyperflux'

Expand Down Expand Up @@ -111,7 +111,11 @@ export class EEMaterialImporterExtension extends ImporterExtension implements GL
Object.entries(oldExtension.args).map(async ([k, v]) => {
//check if the value is a texture
if (matches.shape({ index: matches.number }).test(v)) {
await parser.assignTexture(parseTarget, k, v)
if (k === 'map') {
await parser.assignTexture(parseTarget, k, v, SRGBColorSpace)
} else {
await parser.assignTexture(parseTarget, k, v)
}
}
//check if the value is a color by checking key
else if ((k.toLowerCase().includes('color') || k === 'emissive') && typeof v === 'number') {
Expand All @@ -131,7 +135,11 @@ export class EEMaterialImporterExtension extends ImporterExtension implements GL
break
case 'texture':
if (v.contents) {
await parser.assignTexture(parseTarget, k, v.contents)
if (k === 'map') {
await parser.assignTexture(parseTarget, k, v.contents, SRGBColorSpace)
} else {
await parser.assignTexture(parseTarget, k, v.contents)
}
} else {
parseTarget[k] = null
}
Expand Down

0 comments on commit f922256

Please sign in to comment.