11import { computed , effect , Injector , signal , untracked } from '@angular/core' ;
22import { GainMapLoader , HDRJPGLoader } from '@monogrid/gainmap-js' ;
33import { injectLoader , injectStore , is , pick } from 'angular-three' ;
4- import { LinearEncoding , sRGBEncoding , TextureEncoding } from 'angular-three-soba/misc' ;
54import { assertInjector } from 'ngxtension/assert-injector' ;
65import * as THREE from 'three' ;
76import { EXRLoader , RGBELoader } from 'three-stdlib' ;
@@ -28,7 +27,7 @@ export interface NgtsInjectEnvironmentOptions {
2827 path : string ;
2928 preset ?: NgtsEnvironmentPresets ;
3029 extensions ?: ( loader : THREE . Loader ) => void ;
31- encoding ?: TextureEncoding ;
30+ colorSpace ?: THREE . ColorSpace ;
3231}
3332
3433const defaultFiles = [ '/px.png' , '/nx.png' , '/py.png' , '/ny.png' , '/pz.png' , '/nz.png' ] ;
@@ -39,7 +38,7 @@ export function injectEnvironment(
3938) {
4039 return assertInjector ( injectEnvironment , injector , ( ) => {
4140 const adjustedOptions = computed ( ( ) => {
42- const { preset, extensions, encoding , ...rest } = options ( ) ;
41+ const { preset, extensions, colorSpace , ...rest } = options ( ) ;
4342 let { files, path } = rest ;
4443
4544 if ( files == null ) {
@@ -56,7 +55,7 @@ export function injectEnvironment(
5655 path = CUBEMAP_ROOT ;
5756 }
5857
59- return { files, preset, encoding , path, extensions } ;
58+ return { files, preset, colorSpace , path, extensions } ;
6059 } ) ;
6160
6261 const files = pick ( adjustedOptions , 'files' ) ;
@@ -112,7 +111,7 @@ export function injectEnvironment(
112111
113112 const { extension, isCubeMap } = untracked ( resultOptions ) ;
114113 const _multiFile = untracked ( multiFile ) ;
115- const { encoding } = untracked ( adjustedOptions ) ;
114+ const { colorSpace } = untracked ( adjustedOptions ) ;
116115
117116 // @ts -expect-error - ensure textureResult is a Texture or CubeTexture
118117 let textureResult = ( _multiFile ? loaderResult [ 0 ] : loaderResult ) as Texture | CubeTexture ;
@@ -135,10 +134,7 @@ export function injectEnvironment(
135134 }
136135
137136 textureResult . mapping = isCubeMap ? THREE . CubeReflectionMapping : THREE . EquirectangularReflectionMapping ;
138-
139- if ( 'colorSpace' in textureResult )
140- ( textureResult as any ) . colorSpace = encoding ?? ( isCubeMap ? 'srgb' : 'srgb-linear' ) ;
141- else ( textureResult as any ) . encoding = encoding ?? ( isCubeMap ? sRGBEncoding : LinearEncoding ) ;
137+ textureResult . colorSpace = colorSpace ?? ( isCubeMap ? 'srgb' : 'srgb-linear' ) ;
142138
143139 texture . set ( textureResult ) ;
144140 } ) ;
0 commit comments