PHP 7.4.33
Preview: WebGLCapabilities.js Size: 3.70 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/renderers/webgl/WebGLCapabilities.js
import { FloatType, HalfFloatType, RGBAFormat, UnsignedByteType } from '../../constants.js';

function WebGLCapabilities( gl, extensions, parameters, utils ) {

	let maxAnisotropy;

	function getMaxAnisotropy() {

		if ( maxAnisotropy !== undefined ) return maxAnisotropy;

		if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {

			const extension = extensions.get( 'EXT_texture_filter_anisotropic' );

			maxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );

		} else {

			maxAnisotropy = 0;

		}

		return maxAnisotropy;

	}

	function textureFormatReadable( textureFormat ) {

		if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {

			return false;

		}

		return true;

	}

	function textureTypeReadable( textureType ) {

		const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) );

		if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
			textureType !== FloatType && ! halfFloatSupportedByExt ) {

			return false;

		}

		return true;

	}

	function getMaxPrecision( precision ) {

		if ( precision === 'highp' ) {

			if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
				gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {

				return 'highp';

			}

			precision = 'mediump';

		}

		if ( precision === 'mediump' ) {

			if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&
				gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {

				return 'mediump';

			}

		}

		return 'lowp';

	}

	let precision = parameters.precision !== undefined ? parameters.precision : 'highp';
	const maxPrecision = getMaxPrecision( precision );

	if ( maxPrecision !== precision ) {

		console.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );
		precision = maxPrecision;

	}

	const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
	const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );

	const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
	const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
	const maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );
	const maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );

	const maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );
	const maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );
	const maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );
	const maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );

	const vertexTextures = maxVertexTextures > 0;

	const maxSamples = gl.getParameter( gl.MAX_SAMPLES );

	return {

		isWebGL2: true, // keeping this for backwards compatibility

		getMaxAnisotropy: getMaxAnisotropy,
		getMaxPrecision: getMaxPrecision,

		textureFormatReadable: textureFormatReadable,
		textureTypeReadable: textureTypeReadable,

		precision: precision,
		logarithmicDepthBuffer: logarithmicDepthBuffer,
		reverseDepthBuffer: reverseDepthBuffer,

		maxTextures: maxTextures,
		maxVertexTextures: maxVertexTextures,
		maxTextureSize: maxTextureSize,
		maxCubemapSize: maxCubemapSize,

		maxAttributes: maxAttributes,
		maxVertexUniforms: maxVertexUniforms,
		maxVaryings: maxVaryings,
		maxFragmentUniforms: maxFragmentUniforms,

		vertexTextures: vertexTextures,

		maxSamples: maxSamples

	};

}


export { WebGLCapabilities };

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).