1
1
import { computed , effect , Injector , signal , untracked } from '@angular/core' ;
2
2
import { GainMapLoader , HDRJPGLoader } from '@monogrid/gainmap-js' ;
3
3
import { injectLoader , injectStore , is , pick } from 'angular-three' ;
4
- import { LinearEncoding , sRGBEncoding , TextureEncoding } from 'angular-three-soba/misc' ;
5
4
import { assertInjector } from 'ngxtension/assert-injector' ;
6
5
import * as THREE from 'three' ;
7
6
import { EXRLoader , RGBELoader } from 'three-stdlib' ;
@@ -28,7 +27,7 @@ export interface NgtsInjectEnvironmentOptions {
28
27
path : string ;
29
28
preset ?: NgtsEnvironmentPresets ;
30
29
extensions ?: ( loader : THREE . Loader ) => void ;
31
- encoding ?: TextureEncoding ;
30
+ colorSpace ?: THREE . ColorSpace ;
32
31
}
33
32
34
33
const defaultFiles = [ '/px.png' , '/nx.png' , '/py.png' , '/ny.png' , '/pz.png' , '/nz.png' ] ;
@@ -39,7 +38,7 @@ export function injectEnvironment(
39
38
) {
40
39
return assertInjector ( injectEnvironment , injector , ( ) => {
41
40
const adjustedOptions = computed ( ( ) => {
42
- const { preset, extensions, encoding , ...rest } = options ( ) ;
41
+ const { preset, extensions, colorSpace , ...rest } = options ( ) ;
43
42
let { files, path } = rest ;
44
43
45
44
if ( files == null ) {
@@ -56,7 +55,7 @@ export function injectEnvironment(
56
55
path = CUBEMAP_ROOT ;
57
56
}
58
57
59
- return { files, preset, encoding , path, extensions } ;
58
+ return { files, preset, colorSpace , path, extensions } ;
60
59
} ) ;
61
60
62
61
const files = pick ( adjustedOptions , 'files' ) ;
@@ -112,7 +111,7 @@ export function injectEnvironment(
112
111
113
112
const { extension, isCubeMap } = untracked ( resultOptions ) ;
114
113
const _multiFile = untracked ( multiFile ) ;
115
- const { encoding } = untracked ( adjustedOptions ) ;
114
+ const { colorSpace } = untracked ( adjustedOptions ) ;
116
115
117
116
// @ts -expect-error - ensure textureResult is a Texture or CubeTexture
118
117
let textureResult = ( _multiFile ? loaderResult [ 0 ] : loaderResult ) as Texture | CubeTexture ;
@@ -135,10 +134,7 @@ export function injectEnvironment(
135
134
}
136
135
137
136
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' ) ;
142
138
143
139
texture . set ( textureResult ) ;
144
140
} ) ;
0 commit comments