Mr.doob 3 роки тому
батько
коміт
90d50bfc3a

+ 1 - 1
examples/js/csm/CSMFrustum.js

@@ -117,7 +117,7 @@
 
 		toSpace( cameraMatrix, target ) {
 
-			for ( var i = 0; i < 4; i ++ ) {
+			for ( let i = 0; i < 4; i ++ ) {
 
 				target.vertices.near[ i ].copy( this.vertices.near[ i ] ).applyMatrix4( cameraMatrix );
 				target.vertices.far[ i ].copy( this.vertices.far[ i ] ).applyMatrix4( cameraMatrix );

+ 3 - 3
examples/js/geometries/ParametricGeometries.js

@@ -173,9 +173,9 @@
 
 				u *= Math.PI;
 				v *= 2 * Math.PI;
-				var x = size * Math.sin( u ) * Math.cos( v );
-				var y = size * Math.sin( u ) * Math.sin( v );
-				var z = size * Math.cos( u );
+				const x = size * Math.sin( u ) * Math.cos( v );
+				const y = size * Math.sin( u ) * Math.sin( v );
+				const z = size * Math.cos( u );
 				target.set( x, y, z );
 
 			}

+ 7 - 7
examples/js/lines/LineGeometry.js

@@ -12,10 +12,10 @@
 		setPositions( array ) {
 
 			// converts [ x1, y1, z1,  x2, y2, z2, ... ] to pairs format
-			var length = array.length - 3;
-			var points = new Float32Array( 2 * length );
+			const length = array.length - 3;
+			const points = new Float32Array( 2 * length );
 
-			for ( var i = 0; i < length; i += 3 ) {
+			for ( let i = 0; i < length; i += 3 ) {
 
 				points[ 2 * i ] = array[ i ];
 				points[ 2 * i + 1 ] = array[ i + 1 ];
@@ -34,10 +34,10 @@
 		setColors( array ) {
 
 			// converts [ r1, g1, b1,  r2, g2, b2, ... ] to pairs format
-			var length = array.length - 3;
-			var colors = new Float32Array( 2 * length );
+			const length = array.length - 3;
+			const colors = new Float32Array( 2 * length );
 
-			for ( var i = 0; i < length; i += 3 ) {
+			for ( let i = 0; i < length; i += 3 ) {
 
 				colors[ 2 * i ] = array[ i ];
 				colors[ 2 * i + 1 ] = array[ i + 1 ];
@@ -55,7 +55,7 @@
 
 		fromLine( line ) {
 
-			var geometry = line.geometry;
+			const geometry = line.geometry;
 
 			if ( geometry.isGeometry ) {
 

+ 1 - 1
examples/js/lines/LineSegments2.js

@@ -191,7 +191,7 @@
 				_end4.applyMatrix4( _mvMatrix ); // skip the segment if it's entirely behind the camera
 
 
-				var isBehindCameraNear = _start4.z > near && _end4.z > near;
+				const isBehindCameraNear = _start4.z > near && _end4.z > near;
 
 				if ( isBehindCameraNear ) {
 

+ 37 - 46
examples/js/misc/Volume.js

@@ -157,7 +157,7 @@
    *                      If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
    */
 
-		var lowerThreshold = - Infinity;
+		let lowerThreshold = - Infinity;
 		Object.defineProperty( this, 'lowerThreshold', {
 			get: function () {
 
@@ -180,7 +180,7 @@
    *                      If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume
    */
 
-		var upperThreshold = Infinity;
+		let upperThreshold = Infinity;
 		Object.defineProperty( this, 'upperThreshold', {
 			get: function () {
 
@@ -248,9 +248,9 @@
    */
 		reverseAccess: function ( index ) {
 
-			var z = Math.floor( index / ( this.yLength * this.xLength ) );
-			var y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );
-			var x = index - z * this.yLength * this.xLength - y * this.xLength;
+			const z = Math.floor( index / ( this.yLength * this.xLength ) );
+			const y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );
+			const x = index - z * this.yLength * this.xLength - y * this.xLength;
 			return [ x, y, z ];
 
 		},
@@ -267,10 +267,10 @@
    */
 		map: function ( functionToMap, context ) {
 
-			var length = this.data.length;
+			const length = this.data.length;
 			context = context || this;
 
-			for ( var i = 0; i < length; i ++ ) {
+			for ( let i = 0; i < length; i ++ ) {
 
 				this.data[ i ] = functionToMap.call( context, this.data[ i ], i, this.data );
 
@@ -289,21 +289,13 @@
    */
 		extractPerpendicularPlane: function ( axis, RASIndex ) {
 
-			var iLength,
-				jLength,
-				sliceAccess,
-				planeMatrix = new THREE.Matrix4().identity(),
-				volume = this,
-				planeWidth,
-				planeHeight,
-				firstSpacing,
-				secondSpacing,
-				positionOffset,
-				IJKIndex;
-			var axisInIJK = new THREE.Vector3(),
+			let firstSpacing, secondSpacing, positionOffset, IJKIndex;
+			const axisInIJK = new THREE.Vector3(),
 				firstDirection = new THREE.Vector3(),
-				secondDirection = new THREE.Vector3();
-			var dimensions = new THREE.Vector3( this.xLength, this.yLength, this.zLength );
+				secondDirection = new THREE.Vector3(),
+				planeMatrix = new THREE.Matrix4().identity(),
+				volume = this;
+			const dimensions = new THREE.Vector3( this.xLength, this.yLength, this.zLength );
 
 			switch ( axis ) {
 
@@ -346,45 +338,44 @@
 			}
 
 			firstDirection.applyMatrix4( volume.inverseMatrix ).normalize();
-			firstDirection.argVar = 'i';
+			firstDirection.arglet = 'i';
 			secondDirection.applyMatrix4( volume.inverseMatrix ).normalize();
-			secondDirection.argVar = 'j';
+			secondDirection.arglet = 'j';
 			axisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();
-			iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
-			jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
-			planeWidth = Math.abs( iLength * firstSpacing );
-			planeHeight = Math.abs( jLength * secondSpacing );
+			const iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );
+			const jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );
+			const planeWidth = Math.abs( iLength * firstSpacing );
+			const planeHeight = Math.abs( jLength * secondSpacing );
 			IJKIndex = Math.abs( Math.round( IJKIndex.applyMatrix4( volume.inverseMatrix ).dot( axisInIJK ) ) );
-			var base = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ];
-			var iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
+			const base = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ];
+			const iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
 
 				return Math.abs( x.dot( base[ 0 ] ) ) > 0.9;
 
 			} );
-			var jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
+			const jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
 
 				return Math.abs( x.dot( base[ 1 ] ) ) > 0.9;
 
 			} );
-			var kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
+			const kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {
 
 				return Math.abs( x.dot( base[ 2 ] ) ) > 0.9;
 
 			} );
 
-			sliceAccess = function ( i, j ) {
+			function sliceAccess( i, j ) {
 
-				var accessI, accessJ, accessK;
-				var si = iDirection === axisInIJK ? IJKIndex : iDirection.argVar === 'i' ? i : j;
-				var sj = jDirection === axisInIJK ? IJKIndex : jDirection.argVar === 'i' ? i : j;
-				var sk = kDirection === axisInIJK ? IJKIndex : kDirection.argVar === 'i' ? i : j; // invert indices if necessary
+				const si = iDirection === axisInIJK ? IJKIndex : iDirection.arglet === 'i' ? i : j;
+				const sj = jDirection === axisInIJK ? IJKIndex : jDirection.arglet === 'i' ? i : j;
+				const sk = kDirection === axisInIJK ? IJKIndex : kDirection.arglet === 'i' ? i : j; // invert indices if necessary
 
-				var accessI = iDirection.dot( base[ 0 ] ) > 0 ? si : volume.xLength - 1 - si;
-				var accessJ = jDirection.dot( base[ 1 ] ) > 0 ? sj : volume.yLength - 1 - sj;
-				var accessK = kDirection.dot( base[ 2 ] ) > 0 ? sk : volume.zLength - 1 - sk;
+				const accessI = iDirection.dot( base[ 0 ] ) > 0 ? si : volume.xLength - 1 - si;
+				const accessJ = jDirection.dot( base[ 1 ] ) > 0 ? sj : volume.yLength - 1 - sj;
+				const accessK = kDirection.dot( base[ 2 ] ) > 0 ? sk : volume.zLength - 1 - sk;
 				return volume.access( accessI, accessJ, accessK );
 
-			};
+			}
 
 			return {
 				iLength: iLength,
@@ -407,7 +398,7 @@
    */
 		extractSlice: function ( axis, index ) {
 
-			var slice = new THREE.VolumeSlice( this, index, axis );
+			const slice = new THREE.VolumeSlice( this, index, axis );
 			this.sliceList.push( slice );
 			return slice;
 
@@ -437,17 +428,17 @@
    */
 		computeMinMax: function () {
 
-			var min = Infinity;
-			var max = - Infinity; // buffer the length
+			let min = Infinity;
+			let max = - Infinity; // buffer the length
 
-			var datasize = this.data.length;
-			var i = 0;
+			const datasize = this.data.length;
+			let i = 0;
 
 			for ( i = 0; i < datasize; i ++ ) {
 
 				if ( ! isNaN( this.data[ i ] ) ) {
 
-					var value = this.data[ i ];
+					const value = this.data[ i ];
 					min = Math.min( min, value );
 					max = Math.max( max, value );
 

+ 21 - 21
examples/js/misc/VolumeSlice.js

@@ -11,7 +11,7 @@
 
 	function VolumeSlice( volume, index, axis ) {
 
-		var slice = this;
+		const slice = this;
 		/**
    * @member {Volume} volume The associated volume
    */
@@ -60,10 +60,10 @@
 
 		this.canvasBuffer = document.createElement( 'canvas' );
 		this.updateGeometry();
-		var canvasMap = new THREE.Texture( this.canvas );
+		const canvasMap = new THREE.Texture( this.canvas );
 		canvasMap.minFilter = THREE.LinearFilter;
 		canvasMap.wrapS = canvasMap.wrapT = THREE.ClampToEdgeWrapping;
-		var material = new THREE.MeshBasicMaterial( {
+		const material = new THREE.MeshBasicMaterial( {
 			map: canvasMap,
 			side: THREE.DoubleSide,
 			transparent: true
@@ -113,33 +113,33 @@
 
 			}
 
-			var iLength = this.iLength,
+			const iLength = this.iLength,
 				jLength = this.jLength,
 				sliceAccess = this.sliceAccess,
 				volume = this.volume,
 				canvas = this.canvasBuffer,
 				ctx = this.ctxBuffer; // get the imageData and pixel array from the canvas
 
-			var imgData = ctx.getImageData( 0, 0, iLength, jLength );
-			var data = imgData.data;
-			var volumeData = volume.data;
-			var upperThreshold = volume.upperThreshold;
-			var lowerThreshold = volume.lowerThreshold;
-			var windowLow = volume.windowLow;
-			var windowHigh = volume.windowHigh; // manipulate some pixel elements
+			const imgData = ctx.getImageData( 0, 0, iLength, jLength );
+			const data = imgData.data;
+			const volumeData = volume.data;
+			const upperThreshold = volume.upperThreshold;
+			const lowerThreshold = volume.lowerThreshold;
+			const windowLow = volume.windowLow;
+			const windowHigh = volume.windowHigh; // manipulate some pixel elements
 
-			var pixelCount = 0;
+			let pixelCount = 0;
 
 			if ( volume.dataType === 'label' ) {
 
 				//this part is currently useless but will be used when colortables will be handled
-				for ( var j = 0; j < jLength; j ++ ) {
+				for ( let j = 0; j < jLength; j ++ ) {
 
-					for ( var i = 0; i < iLength; i ++ ) {
+					for ( let i = 0; i < iLength; i ++ ) {
 
-						var label = volumeData[ sliceAccess( i, j ) ];
+						let label = volumeData[ sliceAccess( i, j ) ];
 						label = label >= this.colorMap.length ? label % this.colorMap.length + 1 : label;
-						var color = this.colorMap[ label ];
+						const color = this.colorMap[ label ];
 						data[ 4 * pixelCount ] = color >> 24 & 0xff;
 						data[ 4 * pixelCount + 1 ] = color >> 16 & 0xff;
 						data[ 4 * pixelCount + 2 ] = color >> 8 & 0xff;
@@ -152,12 +152,12 @@
 
 			} else {
 
-				for ( var j = 0; j < jLength; j ++ ) {
+				for ( let j = 0; j < jLength; j ++ ) {
 
-					for ( var i = 0; i < iLength; i ++ ) {
+					for ( let i = 0; i < iLength; i ++ ) {
 
-						var value = volumeData[ sliceAccess( i, j ) ];
-						var alpha = 0xff; //apply threshold
+						let value = volumeData[ sliceAccess( i, j ) ];
+						let alpha = 0xff; //apply threshold
 
 						alpha = upperThreshold >= value ? lowerThreshold <= value ? alpha : 0 : 0; //apply window level
 
@@ -188,7 +188,7 @@
    */
 		updateGeometry: function () {
 
-			var extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );
+			const extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );
 			this.sliceAccess = extracted.sliceAccess;
 			this.jLength = extracted.jLength;
 			this.iLength = extracted.iLength;

+ 1 - 1
examples/js/modifiers/SimplifyModifier.js

@@ -141,7 +141,7 @@
 
 	function removeFromArray( array, object ) {
 
-		var k = array.indexOf( object );
+		const k = array.indexOf( object );
 		if ( k > - 1 ) array.splice( k, 1 );
 
 	}

+ 1 - 1
examples/js/postprocessing/DotScreenPass.js

@@ -6,7 +6,7 @@
 
 			super();
 			if ( THREE.DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on THREE.DotScreenShader' );
-			var shader = THREE.DotScreenShader;
+			const shader = THREE.DotScreenShader;
 			this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 			if ( center !== undefined ) this.uniforms[ 'center' ].value.copy( center );
 			if ( angle !== undefined ) this.uniforms[ 'angle' ].value = angle;

+ 1 - 1
examples/js/shaders/CopyShader.js

@@ -3,7 +3,7 @@
 	/**
  * Full-screen textured quad shader
  */
-	var CopyShader = {
+	const CopyShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null

+ 1 - 1
examples/js/shaders/FreiChenShader.js

@@ -7,7 +7,7 @@
  * aspect: vec2 of (1/width, 1/height)
  */
 
-	var FreiChenShader = {
+	const FreiChenShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null

+ 1 - 1
examples/js/shaders/HorizontalBlurShader.js

@@ -8,7 +8,7 @@
  * - standard deviation 2.7
  * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
  */
-	var HorizontalBlurShader = {
+	const HorizontalBlurShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null

+ 1 - 1
examples/js/shaders/HorizontalTiltShiftShader.js

@@ -8,7 +8,7 @@
  * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
  * - "r" parameter control where "focused" horizontal line lies
  */
-	var HorizontalTiltShiftShader = {
+	const HorizontalTiltShiftShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null

+ 3 - 3
examples/js/shaders/SSRShader.js

@@ -5,7 +5,7 @@
  * https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html
  */
 
-	var SSRShader = {
+	const SSRShader = {
 		defines: {
 			MAX_STEP: 0,
 			PERSPECTIVE_CAMERA: true,
@@ -251,7 +251,7 @@
 		}
 	`
 	};
-	var SSRDepthShader = {
+	const SSRDepthShader = {
 		defines: {
 			'PERSPECTIVE_CAMERA': 1
 		},
@@ -320,7 +320,7 @@
 
 	`
 	};
-	var SSRBlurShader = {
+	const SSRBlurShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null

+ 1 - 1
examples/js/shaders/SSRrShader.js

@@ -260,7 +260,7 @@
 		}
 	`
 	};
-	var SSRrDepthShader = {
+	const SSRrDepthShader = {
 		defines: {
 			'PERSPECTIVE_CAMERA': 1
 		},

+ 1 - 1
examples/js/shaders/ToneMapShader.js

@@ -3,7 +3,7 @@
 	/**
  * Full-screen tone-mapping shader based on http://www.cis.rit.edu/people/faculty/ferwerda/publications/sig02_paper.pdf
  */
-	var ToneMapShader = {
+	const ToneMapShader = {
 		uniforms: {
 			'tDiffuse': {
 				value: null