PHP 7.4.33
Preview: WebGLCubeMaps.js Size: 1.86 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/renderers/webgl/WebGLCubeMaps.js
import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js';
import { WebGLCubeRenderTarget } from '../WebGLCubeRenderTarget.js';

function WebGLCubeMaps( renderer ) {

	let cubemaps = new WeakMap();

	function mapTextureMapping( texture, mapping ) {

		if ( mapping === EquirectangularReflectionMapping ) {

			texture.mapping = CubeReflectionMapping;

		} else if ( mapping === EquirectangularRefractionMapping ) {

			texture.mapping = CubeRefractionMapping;

		}

		return texture;

	}

	function get( texture ) {

		if ( texture && texture.isTexture ) {

			const mapping = texture.mapping;

			if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) {

				if ( cubemaps.has( texture ) ) {

					const cubemap = cubemaps.get( texture ).texture;
					return mapTextureMapping( cubemap, texture.mapping );

				} else {

					const image = texture.image;

					if ( image && image.height > 0 ) {

						const renderTarget = new WebGLCubeRenderTarget( image.height );
						renderTarget.fromEquirectangularTexture( renderer, texture );
						cubemaps.set( texture, renderTarget );

						texture.addEventListener( 'dispose', onTextureDispose );

						return mapTextureMapping( renderTarget.texture, texture.mapping );

					} else {

						// image not yet ready. try the conversion next frame

						return null;

					}

				}

			}

		}

		return texture;

	}

	function onTextureDispose( event ) {

		const texture = event.target;

		texture.removeEventListener( 'dispose', onTextureDispose );

		const cubemap = cubemaps.get( texture );

		if ( cubemap !== undefined ) {

			cubemaps.delete( texture );
			cubemap.dispose();

		}

	}

	function dispose() {

		cubemaps = new WeakMap();

	}

	return {
		get: get,
		dispose: dispose
	};

}

export { WebGLCubeMaps };

Directory Contents

Dirs: 0 × Files: 30
Name Size Perms Modified Actions
767 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
4.86 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
7.57 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
12.14 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.61 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.70 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.29 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.86 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.87 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.87 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.33 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.86 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.00 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
12.91 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
13.66 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
4.46 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.54 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
30.46 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
20.88 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
639 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.96 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.63 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
196 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.93 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
11.32 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
25.73 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
60.56 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
20.31 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
8.39 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
9.39 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).