@@ -3,14 +3,59 @@ import { CubeTexture } from '../textures/CubeTexture.js';
3
3
import { Loader } from './Loader.js' ;
4
4
import { SRGBColorSpace } from '../constants.js' ;
5
5
6
+ /**
7
+ * Class for loading cube textures. Images are internally loaded via {@link ImageLoader}.
8
+ *
9
+ * The loader returns an instance of {@link CubeTexture} and expects the cube map to
10
+ * be defined as six separate images representing the sides of a cube. Other cube map definitions
11
+ * like vertical and horizontal cross, column and row layouts are not supported.
12
+ *
13
+ * Note that, by convention, cube maps are specified in a coordinate system
14
+ * in which positive-x is to the right when looking up the positive-z axis --
15
+ * in other words, using a left-handed coordinate system. Since three.js uses
16
+ * a right-handed coordinate system, environment maps used in three.js will
17
+ * have pos-x and neg-x swapped.
18
+ *
19
+ * The loaded cube textureis in sRGB color space. Meaning {@link Texture#colorSpace}
20
+ * is set to `SRGBColorSpace` by default.
21
+ *
22
+ * ```js
23
+ * const loader = new THREE.CubeTextureLoader().setPath( 'textures/cubeMaps/' );
24
+ * const cubeTexture = await loader.loadAsync( [
25
+ * 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'
26
+ * ] );
27
+ * scene.background = cubeTexture;
28
+ * ```
29
+ *
30
+ * @augments Loader
31
+ */
6
32
class CubeTextureLoader extends Loader {
7
33
34
+ /**
35
+ * Constructs a new cube texture loader.
36
+ *
37
+ * @param {LoadingManager } [manager] - The loading manager.
38
+ */
8
39
constructor ( manager ) {
9
40
10
41
super ( manager ) ;
11
42
12
43
}
13
44
45
+ /**
46
+ * Starts loading from the given URL and pass the fully loaded cube texture
47
+ * to the `onLoad()` callback. The method also returns a new cube texture object which can
48
+ * directly be used for material creation. If you do it this way, the cube texture
49
+ * may pop up in your scene once the respective loading process is finished.
50
+ *
51
+ * @param {Array<string> } urls - Array of 6 URLs to images, one for each side of the
52
+ * cube texture. The urls should be specified in the following order: pos-x,
53
+ * neg-x, pos-y, neg-y, pos-z, neg-z. An array of data URIs are allowed as well.
54
+ * @param {function(CubeTexture) } onLoad - Executed when the loading process has been finished.
55
+ * @param {onProgressCallback } onProgress - Unsupported in this loader.
56
+ * @param {onErrorCallback } onError - Executed when errors occur.
57
+ * @return {CubeTexture } The cube texture.
58
+ */
14
59
load ( urls , onLoad , onProgress , onError ) {
15
60
16
61
const texture = new CubeTexture ( ) ;
0 commit comments