Browse Source

Apply conventions and tidy up.

yellowtailfan 4 years ago
parent
commit
dab677f6a8

+ 1 - 6
examples/jsm/lights/RectAreaLightUniformsLib.d.ts

@@ -1,10 +1,5 @@
-import {
-	WebGLRenderer,
-} from '../../../src/Three';
-
-
 export namespace RectAreaLightUniformsLib {
 
-	export function init( renderer: WebGLRenderer ): void;
+	export function init(): void;
 
 }

+ 14 - 8
examples/jsm/lights/RectAreaLightUniformsLib.js

@@ -38,7 +38,7 @@ var int32View = new Int32Array( floatView.buffer );
 * used, eg. in Ogre), with the additional benefit of rounding, inspired
 * by James Tursa?s half-precision code. */
 
-function toHalf ( val ) {
+function toHalf( val ) {
 
 	floatView[ 0 ] = val;
 	var x = int32View[ 0 ];
@@ -79,7 +79,7 @@ function toHalf ( val ) {
 	bits += m & 1;
 	return bits;
 
-};
+}
 
 var RectAreaLightUniformsLib = {
 
@@ -101,18 +101,24 @@ var RectAreaLightUniformsLib = {
 		UniformsLib.LTC_FLOAT_2 = new DataTexture( ltc_float_2, 64, 64, RGBAFormat, FloatType, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, NearestFilter, 1 );
 
 		const ltc_half_1 = new Uint16Array( LTC_MAT_1.length );
+
 		LTC_MAT_1.forEach( function ( x, index ) {
-			ltc_half_1[index] = toHalf( x );
-		});
+
+			ltc_half_1[ index ] = toHalf( x );
+
+		} );
 
 		const ltc_half_2 = new Uint16Array( LTC_MAT_2.length );
+
 		LTC_MAT_2.forEach( function ( x, index ) {
-			ltc_half_2[index] = toHalf( x );
-		});
-	
+
+			ltc_half_2[ index ] = toHalf( x );
+
+		} );
+
 		UniformsLib.LTC_HALF_1 = new DataTexture( ltc_half_1, 64, 64, RGBAFormat, HalfFloatType, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, NearestFilter, 1 );
 		UniformsLib.LTC_HALF_2 = new DataTexture( ltc_half_2, 64, 64, RGBAFormat, HalfFloatType, UVMapping, ClampToEdgeWrapping, ClampToEdgeWrapping, LinearFilter, NearestFilter, 1 );
-		
+
 	}
 
 };

+ 1 - 1
examples/webgl_lights_rectarealight.html

@@ -54,7 +54,7 @@
 				var ambient = new THREE.AmbientLight( 0xffffff, 0.1 );
 				scene.add( ambient );
 
-				RectAreaLightUniformsLib.init( );
+				RectAreaLightUniformsLib.init();
 
 				rectLight = new THREE.RectAreaLight( 0xffffff, 1, 10, 10 );
 				rectLight.position.set( 5, 5, 0 );

+ 3 - 3
src/renderers/webgl/WebGLLights.js

@@ -407,19 +407,19 @@ function WebGLLights( extensions, capabilities ) {
 
 		if ( rectAreaLength > 0 ) {
 
-			if ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float_linear' ) ) {
+			if ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float_linear' ) ) {
 
 				state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;
 				state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;
 
-			} else if ( extensions.get( 'OES_texture_half_float_linear' ) ) {
+			} else if ( extensions.has( 'OES_texture_half_float_linear' ) ) {
 
 				state.rectAreaLTC1 = UniformsLib.LTC_HALF_1;
 				state.rectAreaLTC2 = UniformsLib.LTC_HALF_2;
 
 			} else {
 
-				throw 'missing webgl extension';
+				console.error( 'THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.' );
 
 			}