Jelajahi Sumber

Examples: Convert loaders to ES6 Part I. (#21612)

Michael Herzog 4 tahun lalu
induk
melakukan
d1a513329d
40 mengubah file dengan 6661 tambahan dan 6691 penghapusan
  1. 253 253
      examples/js/loaders/3MFLoader.js
  2. 81 79
      examples/js/loaders/AMFLoader.js
  3. 49 47
      examples/js/loaders/BVHLoader.js
  4. 125 112
      examples/js/loaders/BasisTextureLoader.js
  5. 215 222
      examples/js/loaders/ColladaLoader.js
  6. 84 81
      examples/js/loaders/DDSLoader.js
  7. 24 22
      examples/js/loaders/KMZLoader.js
  8. 0 1
      examples/js/loaders/MD2Loader.js
  9. 28 26
      examples/js/loaders/MDDLoader.js
  10. 55 53
      examples/js/loaders/PCDLoader.js
  11. 60 61
      examples/js/loaders/PDBLoader.js
  12. 66 64
      examples/js/loaders/PLYLoader.js
  13. 41 40
      examples/js/loaders/PVRLoader.js
  14. 66 73
      examples/js/loaders/RGBELoader.js
  15. 71 70
      examples/js/loaders/STLLoader.js
  16. 333 309
      examples/js/loaders/TDSLoader.js
  17. 35 34
      examples/js/loaders/TGALoader.js
  18. 30 28
      examples/js/loaders/TTFLoader.js
  19. 1591 1596
      examples/js/loaders/VRMLLoader.js
  20. 33 35
      examples/js/loaders/VRMLoader.js
  21. 240 243
      examples/jsm/loaders/3MFLoader.js
  22. 78 80
      examples/jsm/loaders/AMFLoader.js
  23. 46 48
      examples/jsm/loaders/BVHLoader.js
  24. 111 112
      examples/jsm/loaders/BasisTextureLoader.js
  25. 206 218
      examples/jsm/loaders/ColladaLoader.js
  26. 88 88
      examples/jsm/loaders/DDSLoader.js
  27. 21 23
      examples/jsm/loaders/KMZLoader.js
  28. 259 265
      examples/jsm/loaders/MD2Loader.js
  29. 25 27
      examples/jsm/loaders/MDDLoader.js
  30. 52 55
      examples/jsm/loaders/PCDLoader.js
  31. 35 40
      examples/jsm/loaders/PDBLoader.js
  32. 62 65
      examples/jsm/loaders/PLYLoader.js
  33. 40 41
      examples/jsm/loaders/PVRLoader.js
  34. 66 61
      examples/jsm/loaders/RGBELoader.js
  35. 68 71
      examples/jsm/loaders/STLLoader.js
  36. 352 355
      examples/jsm/loaders/TDSLoader.js
  37. 34 37
      examples/jsm/loaders/TGALoader.js
  38. 27 30
      examples/jsm/loaders/TTFLoader.js
  39. 1581 1588
      examples/jsm/loaders/VRMLLoader.js
  40. 30 38
      examples/jsm/loaders/VRMLoader.js

File diff ditekan karena terlalu besar
+ 253 - 253
examples/js/loaders/3MFLoader.js


+ 81 - 79
examples/js/loaders/AMFLoader.js

@@ -7,7 +7,7 @@
  * More information about the AMF format: http://amf.wikispaces.com
  *
  * Usage:
- *	var loader = new AMFLoader();
+ *	const loader = new AMFLoader();
  *	loader.load('/path/to/project.amf', function(objecttree) {
  *		scene.add(objecttree);
  *	});
@@ -18,18 +18,18 @@
  *
  */
 
-	var AMFLoader = function ( manager ) {
+	class AMFLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	AMFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: AMFLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( scope.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( scope.manager );
 			loader.setPath( scope.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( scope.requestHeader );
@@ -58,18 +58,19 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( data ) {
+		}
+
+		parse( data ) {
 
 			function loadDocument( data ) {
 
-				var view = new DataView( data );
-				var magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
+				let view = new DataView( data );
+				const magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
 
 				if ( magic === 'PK' ) {
 
-					var zip = null;
-					var file = null;
+					let zip = null;
+					let file = null;
 					console.log( 'THREE.AMFLoader: Loading Zip' );
 
 					try {
@@ -87,7 +88,7 @@
 
 					}
 
-					for ( var file in zip ) {
+					for ( file in zip ) {
 
 						if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
 
@@ -102,8 +103,8 @@
 
 				}
 
-				var fileText = THREE.LoaderUtils.decodeText( view );
-				var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
+				const fileText = THREE.LoaderUtils.decodeText( view );
+				const xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
 
 				if ( xmlData.documentElement.nodeName.toLowerCase() !== 'amf' ) {
 
@@ -118,8 +119,8 @@
 
 			function loadDocumentScale( node ) {
 
-				var scale = 1.0;
-				var unit = 'millimeter';
+				let scale = 1.0;
+				let unit = 'millimeter';
 
 				if ( node.documentElement.attributes.unit !== undefined ) {
 
@@ -127,7 +128,7 @@
 
 				}
 
-				var scaleUnits = {
+				const scaleUnits = {
 					millimeter: 1.0,
 					inch: 25.4,
 					feet: 304.8,
@@ -148,19 +149,19 @@
 
 			function loadMaterials( node ) {
 
-				var matName = 'AMF Material';
-				var matId = node.attributes.id.textContent;
-				var color = {
+				let matName = 'AMF Material';
+				const matId = node.attributes.id.textContent;
+				let color = {
 					r: 1.0,
 					g: 1.0,
 					b: 1.0,
 					a: 1.0
 				};
-				var loadedMaterial = null;
+				let loadedMaterial = null;
 
-				for ( var i = 0; i < node.childNodes.length; i ++ ) {
+				for ( let i = 0; i < node.childNodes.length; i ++ ) {
 
-					var matChildEl = node.childNodes[ i ];
+					const matChildEl = node.childNodes[ i ];
 
 					if ( matChildEl.nodeName === 'metadata' && matChildEl.attributes.type !== undefined ) {
 
@@ -200,16 +201,16 @@
 
 			function loadColor( node ) {
 
-				var color = {
+				const color = {
 					r: 1.0,
 					g: 1.0,
 					b: 1.0,
 					a: 1.0
 				};
 
-				for ( var i = 0; i < node.childNodes.length; i ++ ) {
+				for ( let i = 0; i < node.childNodes.length; i ++ ) {
 
-					var matColor = node.childNodes[ i ];
+					const matColor = node.childNodes[ i ];
 
 					if ( matColor.nodeName === 'r' ) {
 
@@ -237,12 +238,12 @@
 
 			function loadMeshVolume( node ) {
 
-				var volume = {
+				const volume = {
 					name: '',
 					triangles: [],
 					materialid: null
 				};
-				var currVolumeNode = node.firstElementChild;
+				let currVolumeNode = node.firstElementChild;
 
 				if ( node.attributes.materialid !== undefined ) {
 
@@ -266,9 +267,9 @@
 
 					} else if ( currVolumeNode.nodeName === 'triangle' ) {
 
-						var v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
-						var v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
-						var v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
+						const v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
+						const v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
+						const v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
 						volume.triangles.push( v1, v2, v3 );
 
 					}
@@ -283,30 +284,30 @@
 
 			function loadMeshVertices( node ) {
 
-				var vertArray = [];
-				var normalArray = [];
-				var currVerticesNode = node.firstElementChild;
+				const vertArray = [];
+				const normalArray = [];
+				let currVerticesNode = node.firstElementChild;
 
 				while ( currVerticesNode ) {
 
 					if ( currVerticesNode.nodeName === 'vertex' ) {
 
-						var vNode = currVerticesNode.firstElementChild;
+						let vNode = currVerticesNode.firstElementChild;
 
 						while ( vNode ) {
 
 							if ( vNode.nodeName === 'coordinates' ) {
 
-								var x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
-								var y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
-								var z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
+								const x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
+								const y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
+								const z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
 								vertArray.push( x, y, z );
 
 							} else if ( vNode.nodeName === 'normal' ) {
 
-								var nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
-								var ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
-								var nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
+								const nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
+								const ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
+								const nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
 								normalArray.push( nx, ny, nz );
 
 							}
@@ -330,13 +331,13 @@
 
 			function loadObject( node ) {
 
-				var objId = node.attributes.id.textContent;
-				var loadedObject = {
+				const objId = node.attributes.id.textContent;
+				const loadedObject = {
 					name: 'amfobject',
 					meshes: []
 				};
-				var currColor = null;
-				var currObjNode = node.firstElementChild;
+				let currColor = null;
+				let currObjNode = node.firstElementChild;
 
 				while ( currObjNode ) {
 
@@ -358,8 +359,8 @@
 
 					} else if ( currObjNode.nodeName === 'mesh' ) {
 
-						var currMeshNode = currObjNode.firstElementChild;
-						var mesh = {
+						let currMeshNode = currObjNode.firstElementChild;
+						const mesh = {
 							vertices: [],
 							normals: [],
 							volumes: [],
@@ -370,7 +371,7 @@
 
 							if ( currMeshNode.nodeName === 'vertices' ) {
 
-								var loadedVertices = loadMeshVertices( currMeshNode );
+								const loadedVertices = loadMeshVertices( currMeshNode );
 								mesh.normals = mesh.normals.concat( loadedVertices.normals );
 								mesh.vertices = mesh.vertices.concat( loadedVertices.vertices );
 
@@ -399,18 +400,18 @@
 
 			}
 
-			var xmlData = loadDocument( data );
-			var amfName = '';
-			var amfAuthor = '';
-			var amfScale = loadDocumentScale( xmlData );
-			var amfMaterials = {};
-			var amfObjects = {};
-			var childNodes = xmlData.documentElement.childNodes;
-			var i, j;
+			const xmlData = loadDocument( data );
+			let amfName = '';
+			let amfAuthor = '';
+			const amfScale = loadDocumentScale( xmlData );
+			const amfMaterials = {};
+			const amfObjects = {};
+			const childNodes = xmlData.documentElement.childNodes;
+			let i, j;
 
 			for ( i = 0; i < childNodes.length; i ++ ) {
 
-				var child = childNodes[ i ];
+				const child = childNodes[ i ];
 
 				if ( child.nodeName === 'metadata' ) {
 
@@ -430,20 +431,20 @@
 
 				} else if ( child.nodeName === 'material' ) {
 
-					var loadedMaterial = loadMaterials( child );
+					const loadedMaterial = loadMaterials( child );
 					amfMaterials[ loadedMaterial.id ] = loadedMaterial.material;
 
 				} else if ( child.nodeName === 'object' ) {
 
-					var loadedObject = loadObject( child );
+					const loadedObject = loadObject( child );
 					amfObjects[ loadedObject.id ] = loadedObject.obj;
 
 				}
 
 			}
 
-			var sceneObject = new THREE.Group();
-			var defaultMaterial = new THREE.MeshPhongMaterial( {
+			const sceneObject = new THREE.Group();
+			const defaultMaterial = new THREE.MeshPhongMaterial( {
 				color: 0xaaaaff,
 				flatShading: true
 			} );
@@ -451,19 +452,19 @@
 			sceneObject.userData.author = amfAuthor;
 			sceneObject.userData.loader = 'AMF';
 
-			for ( var id in amfObjects ) {
+			for ( const id in amfObjects ) {
 
-				var part = amfObjects[ id ];
-				var meshes = part.meshes;
-				var newObject = new THREE.Group();
+				const part = amfObjects[ id ];
+				const meshes = part.meshes;
+				const newObject = new THREE.Group();
 				newObject.name = part.name || '';
 
 				for ( i = 0; i < meshes.length; i ++ ) {
 
-					var objDefaultMaterial = defaultMaterial;
-					var mesh = meshes[ i ];
-					var vertices = new THREE.Float32BufferAttribute( mesh.vertices, 3 );
-					var normals = null;
+					let objDefaultMaterial = defaultMaterial;
+					const mesh = meshes[ i ];
+					const vertices = new THREE.Float32BufferAttribute( mesh.vertices, 3 );
+					let normals = null;
 
 					if ( mesh.normals.length ) {
 
@@ -473,7 +474,7 @@
 
 					if ( mesh.color ) {
 
-						var color = mesh.color;
+						const color = mesh.color;
 						objDefaultMaterial = defaultMaterial.clone();
 						objDefaultMaterial.color = new THREE.Color( color.r, color.g, color.b );
 
@@ -486,13 +487,13 @@
 
 					}
 
-					var volumes = mesh.volumes;
+					const volumes = mesh.volumes;
 
 					for ( j = 0; j < volumes.length; j ++ ) {
 
-						var volume = volumes[ j ];
-						var newGeometry = new THREE.BufferGeometry();
-						var material = objDefaultMaterial;
+						const volume = volumes[ j ];
+						const newGeometry = new THREE.BufferGeometry();
+						let material = objDefaultMaterial;
 						newGeometry.setIndex( volume.triangles );
 						newGeometry.setAttribute( 'position', vertices.clone() );
 
@@ -522,7 +523,8 @@
 			return sceneObject;
 
 		}
-	} );
+
+	}
 
 	THREE.AMFLoader = AMFLoader;
 

+ 49 - 47
examples/js/loaders/BVHLoader.js

@@ -7,20 +7,20 @@
  *
  */
 
-	var BVHLoader = function ( manager ) {
+	class BVHLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
-		this.animateBonePositions = true;
-		this.animateBoneRotations = true;
+		constructor( manager ) {
 
-	};
+			super( manager );
+			this.animateBonePositions = true;
+			this.animateBoneRotations = true;
 
-	BVHLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: BVHLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( scope.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( scope.manager );
 			loader.setPath( scope.path );
 			loader.setRequestHeader( scope.requestHeader );
 			loader.setWithCredentials( scope.withCredentials );
@@ -48,8 +48,9 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( text ) {
+		}
+
+		parse( text ) {
 
 			/*
 			reads a string array (lines) from a BVH file
@@ -66,9 +67,9 @@
 
 				}
 
-				var list = []; // collects flat array of all bones
+				const list = []; // collects flat array of all bones
 
-				var root = readNode( lines, nextLine( lines ), list ); // read motion data
+				const root = readNode( lines, nextLine( lines ), list ); // read motion data
 
 				if ( nextLine( lines ) !== 'MOTION' ) {
 
@@ -77,8 +78,8 @@
 				} // number of frames
 
 
-				var tokens = nextLine( lines ).split( /[\s]+/ );
-				var numFrames = parseInt( tokens[ 1 ] );
+				let tokens = nextLine( lines ).split( /[\s]+/ );
+				const numFrames = parseInt( tokens[ 1 ] );
 
 				if ( isNaN( numFrames ) ) {
 
@@ -88,7 +89,7 @@
 
 
 				tokens = nextLine( lines ).split( /[\s]+/ );
-				var frameTime = parseFloat( tokens[ 2 ] );
+				const frameTime = parseFloat( tokens[ 2 ] );
 
 				if ( isNaN( frameTime ) ) {
 
@@ -97,7 +98,7 @@
 				} // read frame data line by line
 
 
-				for ( var i = 0; i < numFrames; i ++ ) {
+				for ( let i = 0; i < numFrames; i ++ ) {
 
 					tokens = nextLine( lines ).split( /[\s]+/ );
 					readFrameData( tokens, i * frameTime, root );
@@ -123,18 +124,18 @@
 				// end sites have no motion data
 				if ( bone.type === 'ENDSITE' ) return; // add keyframe
 
-				var keyframe = {
+				const keyframe = {
 					time: frameTime,
 					position: new THREE.Vector3(),
 					rotation: new THREE.Quaternion()
 				};
 				bone.frames.push( keyframe );
-				var quat = new THREE.Quaternion();
-				var vx = new THREE.Vector3( 1, 0, 0 );
-				var vy = new THREE.Vector3( 0, 1, 0 );
-				var vz = new THREE.Vector3( 0, 0, 1 ); // parse values for each channel in node
+				const quat = new THREE.Quaternion();
+				const vx = new THREE.Vector3( 1, 0, 0 );
+				const vy = new THREE.Vector3( 0, 1, 0 );
+				const vz = new THREE.Vector3( 0, 0, 1 ); // parse values for each channel in node
 
-				for ( var i = 0; i < bone.channels.length; i ++ ) {
+				for ( let i = 0; i < bone.channels.length; i ++ ) {
 
 					switch ( bone.channels[ i ] ) {
 
@@ -173,7 +174,7 @@
 				} // parse child nodes
 
 
-				for ( var i = 0; i < bone.children.length; i ++ ) {
+				for ( let i = 0; i < bone.children.length; i ++ ) {
 
 					readFrameData( data, frameTime, bone.children[ i ] );
 
@@ -191,14 +192,14 @@
 
 			function readNode( lines, firstline, list ) {
 
-				var node = {
+				const node = {
 					name: '',
 					type: '',
 					frames: []
 				};
 				list.push( node ); // parse node type and name
 
-				var tokens = firstline.split( /[\s]+/ );
+				let tokens = firstline.split( /[\s]+/ );
 
 				if ( tokens[ 0 ].toUpperCase() === 'END' && tokens[ 1 ].toUpperCase() === 'SITE' ) {
 
@@ -233,7 +234,7 @@
 
 				}
 
-				var offset = new THREE.Vector3( parseFloat( tokens[ 1 ] ), parseFloat( tokens[ 2 ] ), parseFloat( tokens[ 3 ] ) );
+				const offset = new THREE.Vector3( parseFloat( tokens[ 1 ] ), parseFloat( tokens[ 2 ] ), parseFloat( tokens[ 3 ] ) );
 
 				if ( isNaN( offset.x ) || isNaN( offset.y ) || isNaN( offset.z ) ) {
 
@@ -253,7 +254,7 @@
 
 					}
 
-					var numChannels = parseInt( tokens[ 1 ] );
+					const numChannels = parseInt( tokens[ 1 ] );
 					node.channels = tokens.splice( 2, numChannels );
 					node.children = [];
 
@@ -262,7 +263,7 @@
 
 				while ( true ) {
 
-					var line = nextLine( lines );
+					const line = nextLine( lines );
 
 					if ( line === '}' ) {
 
@@ -287,14 +288,14 @@
 
 			function toTHREEBone( source, list ) {
 
-				var bone = new THREE.Bone();
+				const bone = new THREE.Bone();
 				list.push( bone );
 				bone.position.add( source.offset );
 				bone.name = source.name;
 
 				if ( source.type !== 'ENDSITE' ) {
 
-					for ( var i = 0; i < source.children.length; i ++ ) {
+					for ( let i = 0; i < source.children.length; i ++ ) {
 
 						bone.add( toTHREEBone( source.children[ i ], list ) );
 
@@ -314,20 +315,20 @@
 
 			function toTHREEAnimation( bones ) {
 
-				var tracks = []; // create a position and quaternion animation track for each node
+				const tracks = []; // create a position and quaternion animation track for each node
 
-				for ( var i = 0; i < bones.length; i ++ ) {
+				for ( let i = 0; i < bones.length; i ++ ) {
 
-					var bone = bones[ i ];
+					const bone = bones[ i ];
 					if ( bone.type === 'ENDSITE' ) continue; // track data
 
-					var times = [];
-					var positions = [];
-					var rotations = [];
+					const times = [];
+					const positions = [];
+					const rotations = [];
 
-					for ( var j = 0; j < bone.frames.length; j ++ ) {
+					for ( let j = 0; j < bone.frames.length; j ++ ) {
 
-						var frame = bone.frames[ j ];
+						const frame = bone.frames[ j ];
 						times.push( frame.time ); // the animation system animates the position property,
 						// so we have to add the joint offset to all values
 
@@ -365,7 +366,7 @@
 
 			function nextLine( lines ) {
 
-				var line; // skip empty lines
+				let line; // skip empty lines
 
 				while ( ( line = lines.shift().trim() ).length === 0 ) {}
 
@@ -373,19 +374,20 @@
 
 			}
 
-			var scope = this;
-			var lines = text.split( /[\r\n]+/g );
-			var bones = readBvh( lines );
-			var threeBones = [];
+			const scope = this;
+			const lines = text.split( /[\r\n]+/g );
+			const bones = readBvh( lines );
+			const threeBones = [];
 			toTHREEBone( bones[ 0 ], threeBones );
-			var threeClip = toTHREEAnimation( bones );
+			const threeClip = toTHREEAnimation( bones );
 			return {
 				skeleton: new THREE.Skeleton( threeBones ),
 				clip: threeClip
 			};
 
 		}
-	} );
+
+	}
 
 	THREE.BVHLoader = BVHLoader;
 

+ 125 - 112
examples/js/loaders/BasisTextureLoader.js

@@ -13,36 +13,39 @@
  * to the main thread.
  */
 
-	var BasisTextureLoader = function ( manager ) {
-
-		THREE.Loader.call( this, manager );
-		this.transcoderPath = '';
-		this.transcoderBinary = null;
-		this.transcoderPending = null;
-		this.workerLimit = 4;
-		this.workerPool = [];
-		this.workerNextTaskID = 1;
-		this.workerSourceURL = '';
-		this.workerConfig = null;
+	const _taskCache = new WeakMap();
 
-	};
+	class BasisTextureLoader extends THREE.Loader {
+
+		constructor( manager ) {
+
+			super( manager );
+			this.transcoderPath = '';
+			this.transcoderBinary = null;
+			this.transcoderPending = null;
+			this.workerLimit = 4;
+			this.workerPool = [];
+			this.workerNextTaskID = 1;
+			this.workerSourceURL = '';
+			this.workerConfig = null;
+
+		}
 
-	BasisTextureLoader.taskCache = new WeakMap();
-	BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: BasisTextureLoader,
-		setTranscoderPath: function ( path ) {
+		setTranscoderPath( path ) {
 
 			this.transcoderPath = path;
 			return this;
 
-		},
-		setWorkerLimit: function ( workerLimit ) {
+		}
+
+		setWorkerLimit( workerLimit ) {
 
 			this.workerLimit = workerLimit;
 			return this;
 
-		},
-		detectSupport: function ( renderer ) {
+		}
+
+		detectSupport( renderer ) {
 
 			this.workerConfig = {
 				astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
@@ -54,20 +57,22 @@
 			};
 			return this;
 
-		},
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var loader = new THREE.FileLoader( this.manager );
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setWithCredentials( this.withCredentials );
-			var texture = new THREE.CompressedTexture();
+			const texture = new THREE.CompressedTexture();
 			loader.load( url, buffer => {
 
 				// Check for an existing task using this buffer. A transferred buffer cannot be transferred
 				// again from this thread.
-				if ( BasisTextureLoader.taskCache.has( buffer ) ) {
+				if ( _taskCache.has( buffer ) ) {
+
+					const cachedTask = _taskCache.get( buffer );
 
-					var cachedTask = BasisTextureLoader.taskCache.get( buffer );
 					return cachedTask.promise.then( onLoad ).catch( onError );
 
 				}
@@ -83,17 +88,18 @@
 			}, onProgress, onError );
 			return texture;
 
-		},
-
+		}
 		/** Low-level transcoding API, exposed for use by KTX2Loader. */
-		parseInternalAsync: function ( options ) {
 
-			var {
+
+		parseInternalAsync( options ) {
+
+			const {
 				levels
 			} = options;
-			var buffers = new Set();
+			const buffers = new Set();
 
-			for ( var i = 0; i < levels.length; i ++ ) {
+			for ( let i = 0; i < levels.length; i ++ ) {
 
 				buffers.add( levels[ i ].data.buffer );
 
@@ -103,27 +109,28 @@
 				lowLevel: true
 			} );
 
-		},
-
+		}
 		/**
 	 * @param {ArrayBuffer[]} buffers
 	 * @param {object?} config
 	 * @return {Promise<CompressedTexture>}
 	 */
-		_createTexture: function ( buffers, config ) {
 
-			var worker;
-			var taskID;
-			var taskConfig = config || {};
-			var taskCost = 0;
 
-			for ( var i = 0; i < buffers.length; i ++ ) {
+		_createTexture( buffers, config = {} ) {
+
+			let worker;
+			let taskID;
+			const taskConfig = config;
+			let taskCost = 0;
+
+			for ( let i = 0; i < buffers.length; i ++ ) {
 
 				taskCost += buffers[ i ].byteLength;
 
 			}
 
-			var texturePending = this._allocateWorker( taskCost ).then( _worker => {
+			const texturePending = this._allocateWorker( taskCost ).then( _worker => {
 
 				worker = _worker;
 				taskID = this.workerNextTaskID ++;
@@ -144,13 +151,13 @@
 
 			} ).then( message => {
 
-				var {
+				const {
 					mipmaps,
 					width,
 					height,
 					format
 				} = message;
-				var texture = new THREE.CompressedTexture( mipmaps, width, height, format, THREE.UnsignedByteType );
+				const texture = new THREE.CompressedTexture( mipmaps, width, height, format, THREE.UnsignedByteType );
 				texture.minFilter = mipmaps.length === 1 ? THREE.LinearFilter : THREE.LinearMipmapLinearFilter;
 				texture.magFilter = THREE.LinearFilter;
 				texture.generateMipmaps = false;
@@ -171,39 +178,41 @@
 
 			} ); // Cache the task result.
 
-			BasisTextureLoader.taskCache.set( buffers[ 0 ], {
+			_taskCache.set( buffers[ 0 ], {
 				promise: texturePending
 			} );
+
 			return texturePending;
 
-		},
-		_initTranscoder: function () {
+		}
+
+		_initTranscoder() {
 
 			if ( ! this.transcoderPending ) {
 
 				// Load transcoder wrapper.
-				var jsLoader = new THREE.FileLoader( this.manager );
+				const jsLoader = new THREE.FileLoader( this.manager );
 				jsLoader.setPath( this.transcoderPath );
 				jsLoader.setWithCredentials( this.withCredentials );
-				var jsContent = new Promise( ( resolve, reject ) => {
+				const jsContent = new Promise( ( resolve, reject ) => {
 
 					jsLoader.load( 'basis_transcoder.js', resolve, undefined, reject );
 
 				} ); // Load transcoder WASM binary.
 
-				var binaryLoader = new THREE.FileLoader( this.manager );
+				const binaryLoader = new THREE.FileLoader( this.manager );
 				binaryLoader.setPath( this.transcoderPath );
 				binaryLoader.setResponseType( 'arraybuffer' );
 				binaryLoader.setWithCredentials( this.withCredentials );
-				var binaryContent = new Promise( ( resolve, reject ) => {
+				const binaryContent = new Promise( ( resolve, reject ) => {
 
 					binaryLoader.load( 'basis_transcoder.wasm', resolve, undefined, reject );
 
 				} );
 				this.transcoderPending = Promise.all( [ jsContent, binaryContent ] ).then( ( [ jsContent, binaryContent ] ) => {
 
-					var fn = BasisTextureLoader.BasisWorker.toString();
-					var body = [ '/* constants */', 'var _EngineFormat = ' + JSON.stringify( BasisTextureLoader.EngineFormat ), 'var _TranscoderFormat = ' + JSON.stringify( BasisTextureLoader.TranscoderFormat ), 'var _BasisFormat = ' + JSON.stringify( BasisTextureLoader.BasisFormat ), '/* basis_transcoder.js */', jsContent, '/* worker */', fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) ].join( '\n' );
+					const fn = BasisTextureLoader.BasisWorker.toString();
+					const body = [ '/* constants */', 'let _EngineFormat = ' + JSON.stringify( BasisTextureLoader.EngineFormat ), 'let _TranscoderFormat = ' + JSON.stringify( BasisTextureLoader.TranscoderFormat ), 'let _BasisFormat = ' + JSON.stringify( BasisTextureLoader.BasisFormat ), '/* basis_transcoder.js */', jsContent, '/* worker */', fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) ].join( '\n' );
 					this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
 					this.transcoderBinary = binaryContent;
 
@@ -213,14 +222,15 @@
 
 			return this.transcoderPending;
 
-		},
-		_allocateWorker: function ( taskCost ) {
+		}
+
+		_allocateWorker( taskCost ) {
 
 			return this._initTranscoder().then( () => {
 
 				if ( this.workerPool.length < this.workerLimit ) {
 
-					var worker = new Worker( this.workerSourceURL );
+					const worker = new Worker( this.workerSourceURL );
 					worker._callbacks = {};
 					worker._taskLoad = 0;
 					worker.postMessage( {
@@ -231,7 +241,7 @@
 
 					worker.onmessage = function ( e ) {
 
-						var message = e.data;
+						const message = e.data;
 
 						switch ( message.type ) {
 
@@ -264,16 +274,17 @@
 
 				}
 
-				var worker = this.workerPool[ this.workerPool.length - 1 ];
+				const worker = this.workerPool[ this.workerPool.length - 1 ];
 				worker._taskLoad += taskCost;
 				return worker;
 
 			} );
 
-		},
-		dispose: function () {
+		}
 
-			for ( var i = 0; i < this.workerPool.length; i ++ ) {
+		dispose() {
+
+			for ( let i = 0; i < this.workerPool.length; i ++ ) {
 
 				this.workerPool[ i ].terminate();
 
@@ -283,9 +294,11 @@
 			return this;
 
 		}
-	} );
+
+	}
 	/* CONSTANTS */
 
+
 	BasisTextureLoader.BasisFormat = {
 		ETC1S: 0,
 		UASTC_4x4: 1
@@ -325,18 +338,18 @@
 
 	BasisTextureLoader.BasisWorker = function () {
 
-		var config;
-		var transcoderPending;
-		var BasisModule;
-		var EngineFormat = _EngineFormat; // eslint-disable-line no-undef
+		let config;
+		let transcoderPending;
+		let BasisModule;
+		const EngineFormat = _EngineFormat; // eslint-disable-line no-undef
 
-		var TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
+		const TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
 
-		var BasisFormat = _BasisFormat; // eslint-disable-line no-undef
+		const BasisFormat = _BasisFormat; // eslint-disable-line no-undef
 
 		onmessage = function ( e ) {
 
-			var message = e.data;
+			const message = e.data;
 
 			switch ( message.type ) {
 
@@ -350,16 +363,16 @@
 
 						try {
 
-							var {
+							const {
 								width,
 								height,
 								hasAlpha,
 								mipmaps,
 								format
 							} = message.taskConfig.lowLevel ? transcodeLowLevel( message.taskConfig ) : transcode( message.buffers[ 0 ] );
-							var buffers = [];
+							const buffers = [];
 
-							for ( var i = 0; i < mipmaps.length; ++ i ) {
+							for ( let i = 0; i < mipmaps.length; ++ i ) {
 
 								buffers.push( mipmaps[ i ].data.buffer );
 
@@ -413,24 +426,24 @@
 
 		function transcodeLowLevel( taskConfig ) {
 
-			var {
+			const {
 				basisFormat,
 				width,
 				height,
 				hasAlpha
 			} = taskConfig;
-			var {
+			const {
 				transcoderFormat,
 				engineFormat
 			} = getTranscoderFormat( basisFormat, width, height, hasAlpha );
-			var blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
+			const blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
 			assert( BasisModule.isFormatSupported( transcoderFormat ), 'THREE.BasisTextureLoader: Unsupported format.' );
-			var mipmaps = [];
+			const mipmaps = [];
 
 			if ( basisFormat === BasisFormat.ETC1S ) {
 
-				var transcoder = new BasisModule.LowLevelETC1SImageTranscoder();
-				var {
+				const transcoder = new BasisModule.LowLevelETC1SImageTranscoder();
+				const {
 					endpointCount,
 					endpointsData,
 					selectorCount,
@@ -440,18 +453,18 @@
 
 				try {
 
-					var ok;
+					let ok;
 					ok = transcoder.decodePalettes( endpointCount, endpointsData, selectorCount, selectorsData );
 					assert( ok, 'THREE.BasisTextureLoader: decodePalettes() failed.' );
 					ok = transcoder.decodeTables( tablesData );
 					assert( ok, 'THREE.BasisTextureLoader: decodeTables() failed.' );
 
-					for ( var i = 0; i < taskConfig.levels.length; i ++ ) {
+					for ( let i = 0; i < taskConfig.levels.length; i ++ ) {
 
-						var level = taskConfig.levels[ i ];
-						var imageDesc = taskConfig.globalData.imageDescs[ i ];
-						var dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
-						var dst = new Uint8Array( dstByteLength );
+						const level = taskConfig.levels[ i ];
+						const imageDesc = taskConfig.globalData.imageDescs[ i ];
+						const dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
+						const dst = new Uint8Array( dstByteLength );
 						ok = transcoder.transcodeImage( transcoderFormat, dst, dstByteLength / blockByteLength, level.data, getWidthInBlocks( transcoderFormat, level.width ), getHeightInBlocks( transcoderFormat, level.height ), level.width, level.height, level.index, imageDesc.rgbSliceByteOffset, imageDesc.rgbSliceByteLength, imageDesc.alphaSliceByteOffset, imageDesc.alphaSliceByteLength, imageDesc.imageFlags, hasAlpha, false, 0, 0 );
 						assert( ok, 'THREE.BasisTextureLoader: transcodeImage() failed for level ' + level.index + '.' );
 						mipmaps.push( {
@@ -470,12 +483,12 @@
 
 			} else {
 
-				for ( var i = 0; i < taskConfig.levels.length; i ++ ) {
+				for ( let i = 0; i < taskConfig.levels.length; i ++ ) {
 
-					var level = taskConfig.levels[ i ];
-					var dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
-					var dst = new Uint8Array( dstByteLength );
-					var ok = BasisModule.transcodeUASTCImage( transcoderFormat, dst, dstByteLength / blockByteLength, level.data, getWidthInBlocks( transcoderFormat, level.width ), getHeightInBlocks( transcoderFormat, level.height ), level.width, level.height, level.index, 0, level.data.byteLength, 0, hasAlpha, false, 0, 0, - 1, - 1 );
+					const level = taskConfig.levels[ i ];
+					const dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
+					const dst = new Uint8Array( dstByteLength );
+					const ok = BasisModule.transcodeUASTCImage( transcoderFormat, dst, dstByteLength / blockByteLength, level.data, getWidthInBlocks( transcoderFormat, level.width ), getHeightInBlocks( transcoderFormat, level.height ), level.width, level.height, level.index, 0, level.data.byteLength, 0, hasAlpha, false, 0, 0, - 1, - 1 );
 					assert( ok, 'THREE.BasisTextureLoader: transcodeUASTCImage() failed for level ' + level.index + '.' );
 					mipmaps.push( {
 						data: dst,
@@ -499,12 +512,12 @@
 
 		function transcode( buffer ) {
 
-			var basisFile = new BasisModule.BasisFile( new Uint8Array( buffer ) );
-			var basisFormat = basisFile.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
-			var width = basisFile.getImageWidth( 0, 0 );
-			var height = basisFile.getImageHeight( 0, 0 );
-			var levels = basisFile.getNumLevels( 0 );
-			var hasAlpha = basisFile.getHasAlpha();
+			const basisFile = new BasisModule.BasisFile( new Uint8Array( buffer ) );
+			const basisFormat = basisFile.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
+			const width = basisFile.getImageWidth( 0, 0 );
+			const height = basisFile.getImageHeight( 0, 0 );
+			const levels = basisFile.getNumLevels( 0 );
+			const hasAlpha = basisFile.getHasAlpha();
 
 			function cleanup() {
 
@@ -513,7 +526,7 @@
 
 			}
 
-			var {
+			const {
 				transcoderFormat,
 				engineFormat
 			} = getTranscoderFormat( basisFormat, width, height, hasAlpha );
@@ -532,14 +545,14 @@
 
 			}
 
-			var mipmaps = [];
+			const mipmaps = [];
 
-			for ( var mip = 0; mip < levels; mip ++ ) {
+			for ( let mip = 0; mip < levels; mip ++ ) {
 
-				var mipWidth = basisFile.getImageWidth( 0, mip );
-				var mipHeight = basisFile.getImageHeight( 0, mip );
-				var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, transcoderFormat ) );
-				var status = basisFile.transcodeImage( dst, 0, mip, transcoderFormat, 0, hasAlpha );
+				const mipWidth = basisFile.getImageWidth( 0, mip );
+				const mipHeight = basisFile.getImageHeight( 0, mip );
+				const dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, transcoderFormat ) );
+				const status = basisFile.transcodeImage( dst, 0, mip, transcoderFormat, 0, hasAlpha );
 
 				if ( ! status ) {
 
@@ -575,7 +588,7 @@
 		// chooses RGBA32 only as a last resort and does not expose that option to the caller.
 
 
-		var FORMAT_OPTIONS = [ {
+		const FORMAT_OPTIONS = [ {
 			if: 'astcSupported',
 			basisFormat: [ BasisFormat.UASTC_4x4 ],
 			transcoderFormat: [ TranscoderFormat.ASTC_4x4, TranscoderFormat.ASTC_4x4 ],
@@ -624,12 +637,12 @@
 			priorityUASTC: 6,
 			needsPowerOfTwo: true
 		} ];
-		var ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
+		const ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
 
 			return a.priorityETC1S - b.priorityETC1S;
 
 		} );
-		var UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
+		const UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
 
 			return a.priorityUASTC - b.priorityUASTC;
 
@@ -637,13 +650,13 @@
 
 		function getTranscoderFormat( basisFormat, width, height, hasAlpha ) {
 
-			var transcoderFormat;
-			var engineFormat;
-			var options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
+			let transcoderFormat;
+			let engineFormat;
+			const options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
 
-			for ( var i = 0; i < options.length; i ++ ) {
+			for ( let i = 0; i < options.length; i ++ ) {
 
-				var opt = options[ i ];
+				const opt = options[ i ];
 				if ( ! config[ opt.if ] ) continue;
 				if ( ! opt.basisFormat.includes( basisFormat ) ) continue;
 				if ( opt.needsPowerOfTwo && ! ( isPowerOfTwo( width ) && isPowerOfTwo( height ) ) ) continue;
@@ -686,7 +699,7 @@
 
 		function getTranscodedImageByteLength( transcoderFormat, width, height ) {
 
-			var blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
+			const blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
 
 			if ( BasisModule.formatIsUncompressed( transcoderFormat ) ) {
 
@@ -698,8 +711,8 @@
 
 				// GL requires extra padding for very small textures:
 				// https://www.khronos.org/registry/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
-				var paddedWidth = width + 3 & ~ 3;
-				var paddedHeight = height + 3 & ~ 3;
+				const paddedWidth = width + 3 & ~ 3;
+				const paddedHeight = height + 3 & ~ 3;
 				return ( Math.max( 8, paddedWidth ) * Math.max( 8, paddedHeight ) * 4 + 7 ) / 8;
 
 			}

File diff ditekan karena terlalu besar
+ 215 - 222
examples/js/loaders/ColladaLoader.js


+ 84 - 81
examples/js/loaders/DDSLoader.js

@@ -1,16 +1,16 @@
 ( function () {
 
-	var DDSLoader = function ( manager ) {
+	class DDSLoader extends THREE.CompressedTextureLoader {
 
-		THREE.CompressedTextureLoader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	DDSLoader.prototype = Object.assign( Object.create( THREE.CompressedTextureLoader.prototype ), {
-		constructor: DDSLoader,
-		parse: function ( buffer, loadMipmaps ) {
+		}
+
+		parse( buffer, loadMipmaps ) {
 
-			var dds = {
+			const dds = {
 				mipmaps: [],
 				width: 0,
 				height: 0,
@@ -21,31 +21,31 @@
 			// All values and structures referenced from:
 			// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
 
-			var DDS_MAGIC = 0x20534444; // var DDSD_CAPS = 0x1;
-			// var DDSD_HEIGHT = 0x2;
-			// var DDSD_WIDTH = 0x4;
-			// var DDSD_PITCH = 0x8;
-			// var DDSD_PIXELFORMAT = 0x1000;
-
-			var DDSD_MIPMAPCOUNT = 0x20000; // var DDSD_LINEARSIZE = 0x80000;
-			// var DDSD_DEPTH = 0x800000;
-			// var DDSCAPS_COMPLEX = 0x8;
-			// var DDSCAPS_MIPMAP = 0x400000;
-			// var DDSCAPS_TEXTURE = 0x1000;
-
-			var DDSCAPS2_CUBEMAP = 0x200;
-			var DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
-			var DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
-			var DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
-			var DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
-			var DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
-			var DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000; // var DDSCAPS2_VOLUME = 0x200000;
-			// var DDPF_ALPHAPIXELS = 0x1;
-			// var DDPF_ALPHA = 0x2;
-
-			var DDPF_FOURCC = 0x4; // var DDPF_RGB = 0x40;
-			// var DDPF_YUV = 0x200;
-			// var DDPF_LUMINANCE = 0x20000;
+			const DDS_MAGIC = 0x20534444; // let DDSD_CAPS = 0x1;
+			// let DDSD_HEIGHT = 0x2;
+			// let DDSD_WIDTH = 0x4;
+			// let DDSD_PITCH = 0x8;
+			// let DDSD_PIXELFORMAT = 0x1000;
+
+			const DDSD_MIPMAPCOUNT = 0x20000; // let DDSD_LINEARSIZE = 0x80000;
+			// let DDSD_DEPTH = 0x800000;
+			// let DDSCAPS_COMPLEX = 0x8;
+			// let DDSCAPS_MIPMAP = 0x400000;
+			// let DDSCAPS_TEXTURE = 0x1000;
+
+			const DDSCAPS2_CUBEMAP = 0x200;
+			const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
+			const DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
+			const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
+			const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
+			const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
+			const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000; // let DDSCAPS2_VOLUME = 0x200000;
+			// let DDPF_ALPHAPIXELS = 0x1;
+			// let DDPF_ALPHA = 0x2;
+
+			const DDPF_FOURCC = 0x4; // let DDPF_RGB = 0x40;
+			// let DDPF_YUV = 0x200;
+			// let DDPF_LUMINANCE = 0x20000;
 
 			function fourCCToInt32( value ) {
 
@@ -61,23 +61,23 @@
 
 			function loadARGBMip( buffer, dataOffset, width, height ) {
 
-				var dataLength = width * height * 4;
-				var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
-				var byteArray = new Uint8Array( dataLength );
-				var dst = 0;
-				var src = 0;
+				const dataLength = width * height * 4;
+				const srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
+				const byteArray = new Uint8Array( dataLength );
+				let dst = 0;
+				let src = 0;
 
-				for ( var y = 0; y < height; y ++ ) {
+				for ( let y = 0; y < height; y ++ ) {
 
-					for ( var x = 0; x < width; x ++ ) {
+					for ( let x = 0; x < width; x ++ ) {
 
-						var b = srcBuffer[ src ];
+						const b = srcBuffer[ src ];
 						src ++;
-						var g = srcBuffer[ src ];
+						const g = srcBuffer[ src ];
 						src ++;
-						var r = srcBuffer[ src ];
+						const r = srcBuffer[ src ];
 						src ++;
-						var a = srcBuffer[ src ];
+						const a = srcBuffer[ src ];
 						src ++;
 						byteArray[ dst ] = r;
 						dst ++; //r
@@ -99,32 +99,32 @@
 
 			}
 
-			var FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
-			var FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
-			var FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
-			var FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
-			var headerLengthInt = 31; // The header length in 32 bit ints
+			const FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
+			const FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
+			const FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
+			const FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
+			const headerLengthInt = 31; // The header length in 32 bit ints
 			// Offsets into the header array
 
-			var off_magic = 0;
-			var off_size = 1;
-			var off_flags = 2;
-			var off_height = 3;
-			var off_width = 4;
-			var off_mipmapCount = 7;
-			var off_pfFlags = 20;
-			var off_pfFourCC = 21;
-			var off_RGBBitCount = 22;
-			var off_RBitMask = 23;
-			var off_GBitMask = 24;
-			var off_BBitMask = 25;
-			var off_ABitMask = 26; // var off_caps = 27;
-
-			var off_caps2 = 28; // var off_caps3 = 29;
-			// var off_caps4 = 30;
+			const off_magic = 0;
+			const off_size = 1;
+			const off_flags = 2;
+			const off_height = 3;
+			const off_width = 4;
+			const off_mipmapCount = 7;
+			const off_pfFlags = 20;
+			const off_pfFourCC = 21;
+			const off_RGBBitCount = 22;
+			const off_RBitMask = 23;
+			const off_GBitMask = 24;
+			const off_BBitMask = 25;
+			const off_ABitMask = 26; // let off_caps = 27;
+
+			const off_caps2 = 28; // let off_caps3 = 29;
+			// let off_caps4 = 30;
 			// Parse header
 
-			var header = new Int32Array( buffer, 0, headerLengthInt );
+			const header = new Int32Array( buffer, 0, headerLengthInt );
 
 			if ( header[ off_magic ] !== DDS_MAGIC ) {
 
@@ -140,9 +140,9 @@
 
 			}
 
-			var blockBytes;
-			var fourCC = header[ off_pfFourCC ];
-			var isRGBAUncompressed = false;
+			let blockBytes;
+			const fourCC = header[ off_pfFourCC ];
+			let isRGBAUncompressed = false;
 
 			switch ( fourCC ) {
 
@@ -190,7 +190,7 @@
 
 			}
 
-			var caps2 = header[ off_caps2 ];
+			const caps2 = header[ off_caps2 ];
 			dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
 
 			if ( dds.isCubemap && ( ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) || ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) || ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) || ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) ) ) {
@@ -202,30 +202,32 @@
 
 			dds.width = header[ off_width ];
 			dds.height = header[ off_height ];
-			var dataOffset = header[ off_size ] + 4; // Extract mipmaps buffers
+			let dataOffset = header[ off_size ] + 4; // Extract mipmaps buffers
 
-			var faces = dds.isCubemap ? 6 : 1;
+			const faces = dds.isCubemap ? 6 : 1;
 
-			for ( var face = 0; face < faces; face ++ ) {
+			for ( let face = 0; face < faces; face ++ ) {
 
-				var width = dds.width;
-				var height = dds.height;
+				let width = dds.width;
+				let height = dds.height;
 
-				for ( var i = 0; i < dds.mipmapCount; i ++ ) {
+				for ( let i = 0; i < dds.mipmapCount; i ++ ) {
+
+					let byteArray, dataLength;
 
 					if ( isRGBAUncompressed ) {
 
-						var byteArray = loadARGBMip( buffer, dataOffset, width, height );
-						var dataLength = byteArray.length;
+						byteArray = loadARGBMip( buffer, dataOffset, width, height );
+						dataLength = byteArray.length;
 
 					} else {
 
-						var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
-						var byteArray = new Uint8Array( buffer, dataOffset, dataLength );
+						dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
+						byteArray = new Uint8Array( buffer, dataOffset, dataLength );
 
 					}
 
-					var mipmap = {
+					const mipmap = {
 						'data': byteArray,
 						'width': width,
 						'height': height
@@ -242,7 +244,8 @@
 			return dds;
 
 		}
-	} );
+
+	}
 
 	THREE.DDSLoader = DDSLoader;
 

+ 24 - 22
examples/js/loaders/KMZLoader.js

@@ -1,17 +1,17 @@
 ( function () {
 
-	var KMZLoader = function ( manager ) {
+	class KMZLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	KMZLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: KMZLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( scope.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( scope.manager );
 			loader.setPath( scope.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( scope.requestHeader );
@@ -40,12 +40,13 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( data ) {
+		}
+
+		parse( data ) {
 
 			function findFile( url ) {
 
-				for ( var path in zip ) {
+				for ( const path in zip ) {
 
 					if ( path.substr( - url.length ) === url ) {
 
@@ -57,15 +58,15 @@
 
 			}
 
-			var manager = new THREE.LoadingManager();
+			const manager = new THREE.LoadingManager();
 			manager.setURLModifier( function ( url ) {
 
-				var image = findFile( url );
+				const image = findFile( url );
 
 				if ( image ) {
 
 					console.log( 'Loading', url );
-					var blob = new Blob( [ image.buffer ], {
+					const blob = new Blob( [ image.buffer ], {
 						type: 'application/octet-stream'
 					} );
 					return URL.createObjectURL( blob );
@@ -76,17 +77,17 @@
 
 			} ); //
 
-			var zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
+			const zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
 
 			if ( zip[ 'doc.kml' ] ) {
 
-				var xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
+				const xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
 
-				var model = xml.querySelector( 'Placemark Model Link href' );
+				const model = xml.querySelector( 'Placemark Model Link href' );
 
 				if ( model ) {
 
-					var loader = new THREE.ColladaLoader( manager );
+					const loader = new THREE.ColladaLoader( manager );
 					return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); // eslint-disable-line no-undef
 
 				}
@@ -95,13 +96,13 @@
 
 				console.warn( 'KMZLoader: Missing doc.kml file.' );
 
-				for ( var path in zip ) {
+				for ( const path in zip ) {
 
-					var extension = path.split( '.' ).pop().toLowerCase();
+					const extension = path.split( '.' ).pop().toLowerCase();
 
 					if ( extension === 'dae' ) {
 
-						var loader = new THREE.ColladaLoader( manager );
+						const loader = new THREE.ColladaLoader( manager );
 						return loader.parse( fflate.strFromU8( zip[ path ] ) ); // eslint-disable-line no-undef
 
 					}
@@ -116,7 +117,8 @@
 			};
 
 		}
-	} );
+
+	}
 
 	THREE.KMZLoader = KMZLoader;
 

File diff ditekan karena terlalu besar
+ 0 - 1
examples/js/loaders/MD2Loader.js


+ 28 - 26
examples/js/loaders/MDDLoader.js

@@ -12,18 +12,18 @@
  * vertex data for each frame (sequence of float32)
  */
 
-	var MDDLoader = function ( manager ) {
+	class MDDLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	MDDLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: MDDLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( this.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.load( url, function ( data ) {
@@ -32,18 +32,19 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( data ) {
+		}
 
-			var view = new DataView( data );
-			var totalFrames = view.getUint32( 0 );
-			var totalPoints = view.getUint32( 4 );
-			var offset = 8; // animation clip
+		parse( data ) {
 
-			var times = new Float32Array( totalFrames );
-			var values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
+			const view = new DataView( data );
+			const totalFrames = view.getUint32( 0 );
+			const totalPoints = view.getUint32( 4 );
+			let offset = 8; // animation clip
 
-			for ( var i = 0; i < totalFrames; i ++ ) {
+			const times = new Float32Array( totalFrames );
+			const values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
+
+			for ( let i = 0; i < totalFrames; i ++ ) {
 
 				times[ i ] = view.getFloat32( offset );
 				offset += 4;
@@ -51,18 +52,18 @@
 
 			}
 
-			var track = new THREE.NumberKeyframeTrack( '.morphTargetInfluences', times, values );
-			var clip = new THREE.AnimationClip( 'default', times[ times.length - 1 ], [ track ] ); // morph targets
+			const track = new THREE.NumberKeyframeTrack( '.morphTargetInfluences', times, values );
+			const clip = new THREE.AnimationClip( 'default', times[ times.length - 1 ], [ track ] ); // morph targets
 
-			var morphTargets = [];
+			const morphTargets = [];
 
-			for ( var i = 0; i < totalFrames; i ++ ) {
+			for ( let i = 0; i < totalFrames; i ++ ) {
 
-				var morphTarget = new Float32Array( totalPoints * 3 );
+				const morphTarget = new Float32Array( totalPoints * 3 );
 
-				for ( var j = 0; j < totalPoints; j ++ ) {
+				for ( let j = 0; j < totalPoints; j ++ ) {
 
-					var stride = j * 3;
+					const stride = j * 3;
 					morphTarget[ stride + 0 ] = view.getFloat32( offset );
 					offset += 4; // x
 
@@ -74,7 +75,7 @@
 
 				}
 
-				var attribute = new THREE.BufferAttribute( morphTarget, 3 );
+				const attribute = new THREE.BufferAttribute( morphTarget, 3 );
 				attribute.name = 'morph_' + i;
 				morphTargets.push( attribute );
 
@@ -86,7 +87,8 @@
 			};
 
 		}
-	} );
+
+	}
 
 	THREE.MDDLoader = MDDLoader;
 

+ 55 - 53
examples/js/loaders/PCDLoader.js

@@ -1,18 +1,18 @@
 ( function () {
 
-	var PCDLoader = function ( manager ) {
+	class PCDLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
-		this.littleEndian = true;
+		constructor( manager ) {
 
-	};
+			super( manager );
+			this.littleEndian = true;
 
-	PCDLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: PCDLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( scope.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( scope.manager );
 			loader.setPath( scope.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( scope.requestHeader );
@@ -41,19 +41,20 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( data, url ) {
+		}
+
+		parse( data, url ) {
 
 			// from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js
 			function decompressLZF( inData, outLength ) {
 
-				var inLength = inData.length;
-				var outData = new Uint8Array( outLength );
-				var inPtr = 0;
-				var outPtr = 0;
-				var ctrl;
-				var len;
-				var ref;
+				const inLength = inData.length;
+				const outData = new Uint8Array( outLength );
+				let inPtr = 0;
+				let outPtr = 0;
+				let ctrl;
+				let len;
+				let ref;
 
 				do {
 
@@ -105,9 +106,9 @@
 
 			function parseHeader( data ) {
 
-				var PCDheader = {};
-				var result1 = data.search( /[\r\n]DATA\s(\S*)\s/i );
-				var result2 = /[\r\n]DATA\s(\S*)\s/i.exec( data.substr( result1 - 1 ) );
+				const PCDheader = {};
+				const result1 = data.search( /[\r\n]DATA\s(\S*)\s/i );
+				const result2 = /[\r\n]DATA\s(\S*)\s/i.exec( data.substr( result1 - 1 ) );
 				PCDheader.data = result2[ 1 ];
 				PCDheader.headerLen = result2[ 0 ].length + result1;
 				PCDheader.str = data.substr( 0, PCDheader.headerLen ); // remove comments
@@ -155,7 +156,7 @@
 
 					PCDheader.count = [];
 
-					for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
+					for ( let i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
 
 						PCDheader.count.push( 1 );
 
@@ -164,9 +165,9 @@
 				}
 
 				PCDheader.offset = {};
-				var sizeSum = 0;
+				let sizeSum = 0;
 
-				for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
+				for ( let i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
 
 					if ( PCDheader.data === 'ascii' ) {
 
@@ -187,24 +188,24 @@
 
 			}
 
-			var textData = THREE.LoaderUtils.decodeText( new Uint8Array( data ) ); // parse header (always ascii format)
+			const textData = THREE.LoaderUtils.decodeText( new Uint8Array( data ) ); // parse header (always ascii format)
 
-			var PCDheader = parseHeader( textData ); // parse data
+			const PCDheader = parseHeader( textData ); // parse data
 
-			var position = [];
-			var normal = [];
-			var color = []; // ascii
+			const position = [];
+			const normal = [];
+			const color = []; // ascii
 
 			if ( PCDheader.data === 'ascii' ) {
 
-				var offset = PCDheader.offset;
-				var pcdData = textData.substr( PCDheader.headerLen );
-				var lines = pcdData.split( '\n' );
+				const offset = PCDheader.offset;
+				const pcdData = textData.substr( PCDheader.headerLen );
+				const lines = pcdData.split( '\n' );
 
-				for ( var i = 0, l = lines.length; i < l; i ++ ) {
+				for ( let i = 0, l = lines.length; i < l; i ++ ) {
 
 					if ( lines[ i ] === '' ) continue;
-					var line = lines[ i ].split( ' ' );
+					const line = lines[ i ].split( ' ' );
 
 					if ( offset.x !== undefined ) {
 
@@ -216,10 +217,10 @@
 
 					if ( offset.rgb !== undefined ) {
 
-						var rgb = parseFloat( line[ offset.rgb ] );
-						var r = rgb >> 16 & 0x0000ff;
-						var g = rgb >> 8 & 0x0000ff;
-						var b = rgb >> 0 & 0x0000ff;
+						const rgb = parseFloat( line[ offset.rgb ] );
+						const r = rgb >> 16 & 0x0000ff;
+						const g = rgb >> 8 & 0x0000ff;
+						const b = rgb >> 0 & 0x0000ff;
 						color.push( r / 255, g / 255, b / 255 );
 
 					}
@@ -242,14 +243,14 @@
 
 			if ( PCDheader.data === 'binary_compressed' ) {
 
-				var sizes = new Uint32Array( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
-				var compressedSize = sizes[ 0 ];
-				var decompressedSize = sizes[ 1 ];
-				var decompressed = decompressLZF( new Uint8Array( data, PCDheader.headerLen + 8, compressedSize ), decompressedSize );
-				var dataview = new DataView( decompressed.buffer );
-				var offset = PCDheader.offset;
+				const sizes = new Uint32Array( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
+				const compressedSize = sizes[ 0 ];
+				const decompressedSize = sizes[ 1 ];
+				const decompressed = decompressLZF( new Uint8Array( data, PCDheader.headerLen + 8, compressedSize ), decompressedSize );
+				const dataview = new DataView( decompressed.buffer );
+				const offset = PCDheader.offset;
 
-				for ( var i = 0; i < PCDheader.points; i ++ ) {
+				for ( let i = 0; i < PCDheader.points; i ++ ) {
 
 					if ( offset.x !== undefined ) {
 
@@ -282,10 +283,10 @@
 
 			if ( PCDheader.data === 'binary' ) {
 
-				var dataview = new DataView( data, PCDheader.headerLen );
-				var offset = PCDheader.offset;
+				const dataview = new DataView( data, PCDheader.headerLen );
+				const offset = PCDheader.offset;
 
-				for ( var i = 0, row = 0; i < PCDheader.points; i ++, row += PCDheader.rowSize ) {
+				for ( let i = 0, row = 0; i < PCDheader.points; i ++, row += PCDheader.rowSize ) {
 
 					if ( offset.x !== undefined ) {
 
@@ -316,13 +317,13 @@
 			} // build geometry
 
 
-			var geometry = new THREE.BufferGeometry();
+			const geometry = new THREE.BufferGeometry();
 			if ( position.length > 0 ) geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );
 			if ( normal.length > 0 ) geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normal, 3 ) );
 			if ( color.length > 0 ) geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( color, 3 ) );
 			geometry.computeBoundingSphere(); // build material
 
-			var material = new THREE.PointsMaterial( {
+			const material = new THREE.PointsMaterial( {
 				size: 0.005
 			} );
 
@@ -337,15 +338,16 @@
 			} // build point cloud
 
 
-			var mesh = new THREE.Points( geometry, material );
-			var name = url.split( '' ).reverse().join( '' );
+			const mesh = new THREE.Points( geometry, material );
+			let name = url.split( '' ).reverse().join( '' );
 			name = /([^\/]*)/.exec( name );
 			name = name[ 1 ].split( '' ).reverse().join( '' );
 			mesh.name = name;
 			return mesh;
 
 		}
-	} );
+
+	}
 
 	THREE.PCDLoader = PCDLoader;
 

+ 60 - 61
examples/js/loaders/PDBLoader.js

@@ -1,17 +1,17 @@
 ( function () {
 
-	var PDBLoader = function ( manager ) {
+	class PDBLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	PDBLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: PDBLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( scope.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( scope.manager );
 			loader.setPath( scope.path );
 			loader.setRequestHeader( scope.requestHeader );
 			loader.setWithCredentials( scope.withCredentials );
@@ -39,9 +39,10 @@
 
 			}, onProgress, onError );
 
-		},
-		// Based on CanvasMol PDB parser
-		parse: function ( text ) {
+		} // Based on CanvasMol PDB parser
+
+
+		parse( text ) {
 
 			function trim( text ) {
 
@@ -61,13 +62,13 @@
 
 			}
 
-			function parseBond( start, length ) {
+			function parseBond( start, length, satom, i ) {
 
-				var eatom = parseInt( lines[ i ].substr( start, length ) );
+				const eatom = parseInt( lines[ i ].substr( start, length ) );
 
 				if ( eatom ) {
 
-					var h = hash( satom, eatom );
+					const h = hash( satom, eatom );
 
 					if ( _bhash[ h ] === undefined ) {
 
@@ -87,46 +88,44 @@
 
 			function buildGeometry() {
 
-				var build = {
+				const build = {
 					geometryAtoms: new THREE.BufferGeometry(),
 					geometryBonds: new THREE.BufferGeometry(),
 					json: {
 						atoms: atoms
 					}
 				};
-				var geometryAtoms = build.geometryAtoms;
-				var geometryBonds = build.geometryBonds;
-				var i, l;
-				var x, y, z;
-				var verticesAtoms = [];
-				var colorsAtoms = [];
-				var verticesBonds = []; // atoms
-
-				for ( i = 0, l = atoms.length; i < l; i ++ ) {
-
-					var atom = atoms[ i ];
-					x = atom[ 0 ];
-					y = atom[ 1 ];
-					z = atom[ 2 ];
+				const geometryAtoms = build.geometryAtoms;
+				const geometryBonds = build.geometryBonds;
+				const verticesAtoms = [];
+				const colorsAtoms = [];
+				const verticesBonds = []; // atoms
+
+				for ( let i = 0, l = atoms.length; i < l; i ++ ) {
+
+					const atom = atoms[ i ];
+					const x = atom[ 0 ];
+					const y = atom[ 1 ];
+					const z = atom[ 2 ];
 					verticesAtoms.push( x, y, z );
-					var r = atom[ 3 ][ 0 ] / 255;
-					var g = atom[ 3 ][ 1 ] / 255;
-					var b = atom[ 3 ][ 2 ] / 255;
+					const r = atom[ 3 ][ 0 ] / 255;
+					const g = atom[ 3 ][ 1 ] / 255;
+					const b = atom[ 3 ][ 2 ] / 255;
 					colorsAtoms.push( r, g, b );
 
 				} // bonds
 
 
-				for ( i = 0, l = _bonds.length; i < l; i ++ ) {
+				for ( let i = 0, l = _bonds.length; i < l; i ++ ) {
 
-					var bond = _bonds[ i ];
-					var start = bond[ 0 ];
-					var end = bond[ 1 ];
-					var startAtom = _atomMap[ start ];
-					var endAtom = _atomMap[ end ];
-					x = startAtom[ 0 ];
-					y = startAtom[ 1 ];
-					z = startAtom[ 2 ];
+					const bond = _bonds[ i ];
+					const start = bond[ 0 ];
+					const end = bond[ 1 ];
+					const startAtom = _atomMap[ start ];
+					const endAtom = _atomMap[ end ];
+					let x = startAtom[ 0 ];
+					let y = startAtom[ 1 ];
+					let z = startAtom[ 2 ];
 					verticesBonds.push( x, y, z );
 					x = endAtom[ 0 ];
 					y = endAtom[ 1 ];
@@ -143,7 +142,7 @@
 
 			}
 
-			var CPK = {
+			const CPK = {
 				h: [ 255, 255, 255 ],
 				he: [ 217, 255, 255 ],
 				li: [ 204, 128, 255 ],
@@ -263,23 +262,22 @@
 				uus: [ 235, 0, 38 ],
 				uuo: [ 235, 0, 38 ]
 			};
-			var atoms = [];
-			var _bonds = [];
-			var _bhash = {};
-			var _atomMap = {};
-			var x, y, z, index, e; // parse
+			const atoms = [];
+			const _bonds = [];
+			const _bhash = {};
+			const _atomMap = {}; // parse
 
-			var lines = text.split( '\n' );
+			const lines = text.split( '\n' );
 
-			for ( var i = 0, l = lines.length; i < l; i ++ ) {
+			for ( let i = 0, l = lines.length; i < l; i ++ ) {
 
 				if ( lines[ i ].substr( 0, 4 ) === 'ATOM' || lines[ i ].substr( 0, 6 ) === 'HETATM' ) {
 
-					x = parseFloat( lines[ i ].substr( 30, 7 ) );
-					y = parseFloat( lines[ i ].substr( 38, 7 ) );
-					z = parseFloat( lines[ i ].substr( 46, 7 ) );
-					index = parseInt( lines[ i ].substr( 6, 5 ) ) - 1;
-					e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase();
+					const x = parseFloat( lines[ i ].substr( 30, 7 ) );
+					const y = parseFloat( lines[ i ].substr( 38, 7 ) );
+					const z = parseFloat( lines[ i ].substr( 46, 7 ) );
+					const index = parseInt( lines[ i ].substr( 6, 5 ) ) - 1;
+					let e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase();
 
 					if ( e === '' ) {
 
@@ -287,17 +285,17 @@
 
 					}
 
-					var atomData = [ x, y, z, CPK[ e ], capitalize( e ) ];
+					const atomData = [ x, y, z, CPK[ e ], capitalize( e ) ];
 					atoms.push( atomData );
 					_atomMap[ index ] = atomData;
 
 				} else if ( lines[ i ].substr( 0, 6 ) === 'CONECT' ) {
 
-					var satom = parseInt( lines[ i ].substr( 6, 5 ) );
-					parseBond( 11, 5 );
-					parseBond( 16, 5 );
-					parseBond( 21, 5 );
-					parseBond( 26, 5 );
+					const satom = parseInt( lines[ i ].substr( 6, 5 ) );
+					parseBond( 11, 5, satom, i );
+					parseBond( 16, 5, satom, i );
+					parseBond( 21, 5, satom, i );
+					parseBond( 26, 5, satom, i );
 
 				}
 
@@ -307,7 +305,8 @@
 			return buildGeometry();
 
 		}
-	} );
+
+	}
 
 	THREE.PDBLoader = PDBLoader;
 

+ 66 - 64
examples/js/loaders/PLYLoader.js

@@ -7,7 +7,7 @@
  * Limitations: ASCII decoding assumes file is UTF-8.
  *
  * Usage:
- *	var loader = new PLYLoader();
+ *	const loader = new PLYLoader();
  *	loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {
  *
  *		scene.add( new THREE.Mesh( geometry ) );
@@ -26,19 +26,19 @@
  *
  */
 
-	var PLYLoader = function ( manager ) {
+	class PLYLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
-		this.propertyNameMapping = {};
+		constructor( manager ) {
 
-	};
+			super( manager );
+			this.propertyNameMapping = {};
 
-	PLYLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: PLYLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( this.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( this.requestHeader );
@@ -67,20 +67,22 @@
 
 			}, onProgress, onError );
 
-		},
-		setPropertyNameMapping: function ( mapping ) {
+		}
+
+		setPropertyNameMapping( mapping ) {
 
 			this.propertyNameMapping = mapping;
 
-		},
-		parse: function ( data ) {
+		}
+
+		parse( data ) {
 
 			function parseHeader( data ) {
 
-				var patternHeader = /ply([\s\S]*)end_header\r?\n/;
-				var headerText = '';
-				var headerLength = 0;
-				var result = patternHeader.exec( data );
+				const patternHeader = /ply([\s\S]*)end_header\r?\n/;
+				let headerText = '';
+				let headerLength = 0;
+				const result = patternHeader.exec( data );
 
 				if ( result !== null ) {
 
@@ -89,19 +91,18 @@
 
 				}
 
-				var header = {
+				const header = {
 					comments: [],
 					elements: [],
 					headerLength: headerLength,
 					objInfo: ''
 				};
-				var lines = headerText.split( '\n' );
-				var currentElement;
-				var lineType, lineValues;
+				const lines = headerText.split( '\n' );
+				let currentElement;
 
 				function make_ply_element_property( propertValues, propertyNameMapping ) {
 
-					var property = {
+					const property = {
 						type: propertValues[ 0 ]
 					};
 
@@ -127,13 +128,13 @@
 
 				}
 
-				for ( var i = 0; i < lines.length; i ++ ) {
+				for ( let i = 0; i < lines.length; i ++ ) {
 
-					var line = lines[ i ];
+					let line = lines[ i ];
 					line = line.trim();
 					if ( line === '' ) continue;
-					lineValues = line.split( /\s+/ );
-					lineType = lineValues.shift();
+					const lineValues = line.split( /\s+/ );
+					const lineType = lineValues.shift();
 					line = lineValues.join( ' ' );
 
 					switch ( lineType ) {
@@ -215,17 +216,17 @@
 
 			function parseASCIIElement( properties, line ) {
 
-				var values = line.split( /\s+/ );
-				var element = {};
+				const values = line.split( /\s+/ );
+				const element = {};
 
-				for ( var i = 0; i < properties.length; i ++ ) {
+				for ( let i = 0; i < properties.length; i ++ ) {
 
 					if ( properties[ i ].type === 'list' ) {
 
-						var list = [];
-						var n = parseASCIINumber( values.shift(), properties[ i ].countType );
+						const list = [];
+						const n = parseASCIINumber( values.shift(), properties[ i ].countType );
 
-						for ( var j = 0; j < n; j ++ ) {
+						for ( let j = 0; j < n; j ++ ) {
 
 							list.push( parseASCIINumber( values.shift(), properties[ i ].itemType ) );
 
@@ -248,7 +249,7 @@
 			function parseASCII( data, header ) {
 
 				// PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
-				var buffer = {
+				const buffer = {
 					indices: [],
 					vertices: [],
 					normals: [],
@@ -256,9 +257,9 @@
 					faceVertexUvs: [],
 					colors: []
 				};
-				var result;
-				var patternBody = /end_header\s([\s\S]*)$/;
-				var body = '';
+				let result;
+				const patternBody = /end_header\s([\s\S]*)$/;
+				let body = '';
 
 				if ( ( result = patternBody.exec( data ) ) !== null ) {
 
@@ -266,13 +267,13 @@
 
 				}
 
-				var lines = body.split( '\n' );
-				var currentElement = 0;
-				var currentElementCount = 0;
+				const lines = body.split( '\n' );
+				let currentElement = 0;
+				let currentElementCount = 0;
 
-				for ( var i = 0; i < lines.length; i ++ ) {
+				for ( let i = 0; i < lines.length; i ++ ) {
 
-					var line = lines[ i ];
+					let line = lines[ i ];
 					line = line.trim();
 
 					if ( line === '' ) {
@@ -288,7 +289,7 @@
 
 					}
 
-					var element = parseASCIIElement( header.elements[ currentElement ].properties, line );
+					const element = parseASCIIElement( header.elements[ currentElement ].properties, line );
 					handleElement( buffer, header.elements[ currentElement ].name, element );
 					currentElementCount ++;
 
@@ -300,7 +301,7 @@
 
 			function postProcess( buffer ) {
 
-				var geometry = new THREE.BufferGeometry(); // mandatory buffer data
+				let geometry = new THREE.BufferGeometry(); // mandatory buffer data
 
 				if ( buffer.indices.length > 0 ) {
 
@@ -366,9 +367,9 @@
 
 				} else if ( elementName === 'face' ) {
 
-					var vertex_indices = element.vertex_indices || element.vertex_index; // issue #9338
+					const vertex_indices = element.vertex_indices || element.vertex_index; // issue #9338
 
-					var texcoord = element.texcoord;
+					const texcoord = element.texcoord;
 
 					if ( vertex_indices.length === 3 ) {
 
@@ -436,20 +437,20 @@
 
 			function binaryReadElement( dataview, at, properties, little_endian ) {
 
-				var element = {};
-				var result,
+				const element = {};
+				let result,
 					read = 0;
 
-				for ( var i = 0; i < properties.length; i ++ ) {
+				for ( let i = 0; i < properties.length; i ++ ) {
 
 					if ( properties[ i ].type === 'list' ) {
 
-						var list = [];
+						const list = [];
 						result = binaryRead( dataview, at + read, properties[ i ].countType, little_endian );
-						var n = result[ 0 ];
+						const n = result[ 0 ];
 						read += result[ 1 ];
 
-						for ( var j = 0; j < n; j ++ ) {
+						for ( let j = 0; j < n; j ++ ) {
 
 							result = binaryRead( dataview, at + read, properties[ i ].itemType, little_endian );
 							list.push( result[ 0 ] );
@@ -475,7 +476,7 @@
 
 			function parseBinary( data, header ) {
 
-				var buffer = {
+				const buffer = {
 					indices: [],
 					vertices: [],
 					normals: [],
@@ -483,18 +484,18 @@
 					faceVertexUvs: [],
 					colors: []
 				};
-				var little_endian = header.format === 'binary_little_endian';
-				var body = new DataView( data, header.headerLength );
-				var result,
+				const little_endian = header.format === 'binary_little_endian';
+				const body = new DataView( data, header.headerLength );
+				let result,
 					loc = 0;
 
-				for ( var currentElement = 0; currentElement < header.elements.length; currentElement ++ ) {
+				for ( let currentElement = 0; currentElement < header.elements.length; currentElement ++ ) {
 
-					for ( var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) {
+					for ( let currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) {
 
 						result = binaryReadElement( body, loc, header.elements[ currentElement ].properties, little_endian );
 						loc += result[ 1 ];
-						var element = result[ 0 ];
+						const element = result[ 0 ];
 						handleElement( buffer, header.elements[ currentElement ].name, element );
 
 					}
@@ -506,13 +507,13 @@
 			} //
 
 
-			var geometry;
-			var scope = this;
+			let geometry;
+			const scope = this;
 
 			if ( data instanceof ArrayBuffer ) {
 
-				var text = THREE.LoaderUtils.decodeText( new Uint8Array( data ) );
-				var header = parseHeader( text );
+				const text = THREE.LoaderUtils.decodeText( new Uint8Array( data ) );
+				const header = parseHeader( text );
 				geometry = header.format === 'ascii' ? parseASCII( text, header ) : parseBinary( data, header );
 
 			} else {
@@ -524,7 +525,8 @@
 			return geometry;
 
 		}
-	} );
+
+	}
 
 	THREE.PLYLoader = PLYLoader;
 

+ 41 - 40
examples/js/loaders/PVRLoader.js

@@ -6,19 +6,19 @@
  *	 TODO : implement loadMipmaps option
  */
 
-	var PVRLoader = function ( manager ) {
+	class PVRLoader extends THREE.CompressedTextureLoader {
 
-		THREE.CompressedTextureLoader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	PVRLoader.prototype = Object.assign( Object.create( THREE.CompressedTextureLoader.prototype ), {
-		constructor: PVRLoader,
-		parse: function ( buffer, loadMipmaps ) {
+		}
+
+		parse( buffer, loadMipmaps ) {
 
-			var headerLengthInt = 13;
-			var header = new Uint32Array( buffer, 0, headerLengthInt );
-			var pvrDatas = {
+			const headerLengthInt = 13;
+			const header = new Uint32Array( buffer, 0, headerLengthInt );
+			const pvrDatas = {
 				buffer: buffer,
 				header: header,
 				loadMipmaps: loadMipmaps
@@ -27,12 +27,12 @@
 			if ( header[ 0 ] === 0x03525650 ) {
 
 				// PVR v3
-				return PVRLoader._parseV3( pvrDatas );
+				return _parseV3( pvrDatas );
 
 			} else if ( header[ 11 ] === 0x21525650 ) {
 
 				// PVR v2
-				return PVRLoader._parseV2( pvrDatas );
+				return _parseV2( pvrDatas );
 
 			} else {
 
@@ -41,13 +41,14 @@
 			}
 
 		}
-	} );
 
-	PVRLoader._parseV3 = function ( pvrDatas ) {
+	}
+
+	function _parseV3( pvrDatas ) {
 
-		var header = pvrDatas.header;
-		var bpp, format;
-		var metaLen = header[ 12 ],
+		const header = pvrDatas.header;
+		let bpp, format;
+		const metaLen = header[ 12 ],
 			pixelFormat = header[ 2 ],
 			height = header[ 6 ],
 			width = header[ 7 ],
@@ -94,14 +95,14 @@
 		pvrDatas.numSurfaces = numFaces;
 		pvrDatas.numMipmaps = numMipmaps;
 		pvrDatas.isCubemap = numFaces === 6;
-		return PVRLoader._extract( pvrDatas );
+		return _extract( pvrDatas );
 
-	};
+	}
 
-	PVRLoader._parseV2 = function ( pvrDatas ) {
+	function _parseV2( pvrDatas ) {
 
-		var header = pvrDatas.header;
-		var headerLength = header[ 0 ],
+		const header = pvrDatas.header;
+		const headerLength = header[ 0 ],
 			height = header[ 1 ],
 			width = header[ 2 ],
 			numMipmaps = header[ 3 ],
@@ -114,13 +115,13 @@
 			bitmaskAlpha = header[ 10 ],
 			// pvrTag = header[ 11 ],
 			numSurfs = header[ 12 ];
-		var TYPE_MASK = 0xff;
-		var PVRTC_2 = 24,
+		const TYPE_MASK = 0xff;
+		const PVRTC_2 = 24,
 			PVRTC_4 = 25;
-		var formatFlags = flags & TYPE_MASK;
-		var bpp, format;
+		const formatFlags = flags & TYPE_MASK;
+		let bpp, format;
 
-		var _hasAlpha = bitmaskAlpha > 0;
+		const _hasAlpha = bitmaskAlpha > 0;
 
 		if ( formatFlags === PVRTC_4 ) {
 
@@ -148,13 +149,13 @@
 		// it juste a pvr containing 6 surface (no explicit cubemap type)
 
 		pvrDatas.isCubemap = numSurfs === 6;
-		return PVRLoader._extract( pvrDatas );
+		return _extract( pvrDatas );
 
-	};
+	}
 
-	PVRLoader._extract = function ( pvrDatas ) {
+	function _extract( pvrDatas ) {
 
-		var pvr = {
+		const pvr = {
 			mipmaps: [],
 			width: pvrDatas.width,
 			height: pvrDatas.height,
@@ -162,16 +163,16 @@
 			mipmapCount: pvrDatas.numMipmaps,
 			isCubemap: pvrDatas.isCubemap
 		};
-		var buffer = pvrDatas.buffer;
-		var dataOffset = pvrDatas.dataPtr,
-			bpp = pvrDatas.bpp,
-			numSurfs = pvrDatas.numSurfaces,
+		const buffer = pvrDatas.buffer;
+		let dataOffset = pvrDatas.dataPtr,
 			dataSize = 0,
 			blockSize = 0,
 			blockWidth = 0,
 			blockHeight = 0,
 			widthBlocks = 0,
 			heightBlocks = 0;
+		const bpp = pvrDatas.bpp,
+			numSurfs = pvrDatas.numSurfaces;
 
 		if ( bpp === 2 ) {
 
@@ -187,11 +188,11 @@
 
 		blockSize = blockWidth * blockHeight * bpp / 8;
 		pvr.mipmaps.length = pvrDatas.numMipmaps * numSurfs;
-		var mipLevel = 0;
+		let mipLevel = 0;
 
 		while ( mipLevel < pvrDatas.numMipmaps ) {
 
-			var sWidth = pvrDatas.width >> mipLevel,
+			const sWidth = pvrDatas.width >> mipLevel,
 				sHeight = pvrDatas.height >> mipLevel;
 			widthBlocks = sWidth / blockWidth;
 			heightBlocks = sHeight / blockHeight; // Clamp to minimum number of blocks
@@ -200,10 +201,10 @@
 			if ( heightBlocks < 2 ) heightBlocks = 2;
 			dataSize = widthBlocks * heightBlocks * blockSize;
 
-			for ( var surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) {
+			for ( let surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) {
 
-				var byteArray = new Uint8Array( buffer, dataOffset, dataSize );
-				var mipmap = {
+				const byteArray = new Uint8Array( buffer, dataOffset, dataSize );
+				const mipmap = {
 					data: byteArray,
 					width: sWidth,
 					height: sHeight
@@ -219,7 +220,7 @@
 
 		return pvr;
 
-	};
+	}
 
 	THREE.PVRLoader = PVRLoader;
 

+ 66 - 73
examples/js/loaders/RGBELoader.js

@@ -2,19 +2,19 @@
 
 	// http://en.wikipedia.org/wiki/RGBE_image_format
 
-	var RGBELoader = function ( manager ) {
+	class RGBELoader extends THREE.DataTextureLoader {
 
-		THREE.DataTextureLoader.call( this, manager );
-		this.type = THREE.UnsignedByteType;
+		constructor( manager ) {
 
-	};
+			super( manager );
+			this.type = THREE.UnsignedByteType;
 
-	RGBELoader.prototype = Object.assign( Object.create( THREE.DataTextureLoader.prototype ), {
-		constructor: RGBELoader,
-		// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
-		parse: function ( buffer ) {
+		} // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
 
-			var
+
+		parse( buffer ) {
+
+			const
 				/* return codes for rgbe routines */
 				//RGBE_RETURN_SUCCESS = 0,
 				RGBE_RETURN_FAILURE = - 1,
@@ -65,12 +65,12 @@
 				NEWLINE = '\n',
 				fgets = function ( buffer, lineLimit, consume ) {
 
+					const chunkSize = 128;
 					lineLimit = ! lineLimit ? 1024 : lineLimit;
-					var p = buffer.pos,
+					let p = buffer.pos,
 						i = - 1,
 						len = 0,
 						s = '',
-						chunkSize = 128,
 						chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
 
 					while ( 0 > ( i = chunk.indexOf( NEWLINE ) ) && len < lineLimit && p < buffer.byteLength ) {
@@ -102,10 +102,8 @@
 				/* minimal header reading.	modify if you want to parse more information */
 				RGBE_ReadHeader = function ( buffer ) {
 
-					var line,
-						match,
-						// regexes to parse header info fields
-						magic_token_re = /^#\?(\S+)/,
+					// regexes to parse header info fields
+					const magic_token_re = /^#\?(\S+)/,
 						gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
 						exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
 						format_re = /^\s*FORMAT=(\S+)\s*$/,
@@ -138,6 +136,7 @@
 							/* image dimensions, width/height */
 
 						};
+					let line, match;
 
 					if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
 
@@ -218,21 +217,7 @@
 				},
 				RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
 
-					var data_rgba,
-						offset,
-						pos,
-						count,
-						byteValue,
-						scanline_buffer,
-						ptr,
-						ptr_end,
-						i,
-						l,
-						off,
-						isEncodedRun,
-						scanline_width = w,
-						num_scanlines = h,
-						rgbeStart;
+					const scanline_width = w;
 
 					if ( // run length encoding is not allowed so read flat
 						scanline_width < 8 || scanline_width > 0x7fff || // this file is not run length encoded
@@ -249,7 +234,7 @@
 
 					}
 
-					data_rgba = new Uint8Array( 4 * w * h );
+					const data_rgba = new Uint8Array( 4 * w * h );
 
 					if ( ! data_rgba.length ) {
 
@@ -257,11 +242,12 @@
 
 					}
 
-					offset = 0;
-					pos = 0;
-					ptr_end = 4 * scanline_width;
-					rgbeStart = new Uint8Array( 4 );
-					scanline_buffer = new Uint8Array( ptr_end ); // read in each successive scanline
+					let offset = 0,
+						pos = 0;
+					const ptr_end = 4 * scanline_width;
+					const rgbeStart = new Uint8Array( 4 );
+					const scanline_buffer = new Uint8Array( ptr_end );
+					let num_scanlines = h; // read in each successive scanline
 
 					while ( num_scanlines > 0 && pos < buffer.byteLength ) {
 
@@ -284,12 +270,13 @@
 						// first red, then green, then blue, then exponent
 
 
-						ptr = 0;
+						let ptr = 0,
+							count;
 
 						while ( ptr < ptr_end && pos < buffer.byteLength ) {
 
 							count = buffer[ pos ++ ];
-							isEncodedRun = count > 128;
+							const isEncodedRun = count > 128;
 							if ( isEncodedRun ) count -= 128;
 
 							if ( 0 === count || ptr + count > ptr_end ) {
@@ -301,9 +288,9 @@
 							if ( isEncodedRun ) {
 
 								// a (encoded) run of the same value
-								byteValue = buffer[ pos ++ ];
+								const byteValue = buffer[ pos ++ ];
 
-								for ( i = 0; i < count; i ++ ) {
+								for ( let i = 0; i < count; i ++ ) {
 
 									scanline_buffer[ ptr ++ ] = byteValue;
 
@@ -322,11 +309,11 @@
 						// first red, then green, then blue, then exponent (alpha)
 
 
-						l = scanline_width; //scanline_buffer.byteLength;
+						const l = scanline_width; //scanline_buffer.byteLength;
 
-						for ( i = 0; i < l; i ++ ) {
+						for ( let i = 0; i < l; i ++ ) {
 
-							off = 0;
+							let off = 0;
 							data_rgba[ offset ] = scanline_buffer[ i + off ];
 							off += scanline_width; //1;
 
@@ -349,75 +336,78 @@
 
 				};
 
-			var RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+			const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-				var e = sourceArray[ sourceOffset + 3 ];
-				var scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+				const e = sourceArray[ sourceOffset + 3 ];
+				const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 				destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
 				destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
 				destArray[ destOffset + 2 ] = sourceArray[ sourceOffset + 2 ] * scale;
 
 			};
 
-			var RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+			const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-				var e = sourceArray[ sourceOffset + 3 ];
-				var scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+				const e = sourceArray[ sourceOffset + 3 ];
+				const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 				destArray[ destOffset + 0 ] = THREE.DataUtils.toHalfFloat( sourceArray[ sourceOffset + 0 ] * scale );
 				destArray[ destOffset + 1 ] = THREE.DataUtils.toHalfFloat( sourceArray[ sourceOffset + 1 ] * scale );
 				destArray[ destOffset + 2 ] = THREE.DataUtils.toHalfFloat( sourceArray[ sourceOffset + 2 ] * scale );
 
 			};
 
-			var byteArray = new Uint8Array( buffer );
+			const byteArray = new Uint8Array( buffer );
 			byteArray.pos = 0;
-			var rgbe_header_info = RGBE_ReadHeader( byteArray );
+			const rgbe_header_info = RGBE_ReadHeader( byteArray );
 
 			if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) {
 
-				var w = rgbe_header_info.width,
+				const w = rgbe_header_info.width,
 					h = rgbe_header_info.height,
 					image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
 
 				if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
 
+					let data, format, type;
+					let numElements;
+
 					switch ( this.type ) {
 
 						case THREE.UnsignedByteType:
-							var data = image_rgba_data;
-							var format = THREE.RGBEFormat; // handled as THREE.RGBAFormat in shaders
+							data = image_rgba_data;
+							format = THREE.RGBEFormat; // handled as THREE.RGBAFormat in shaders
 
-							var type = THREE.UnsignedByteType;
+							type = THREE.UnsignedByteType;
 							break;
 
 						case THREE.FloatType:
-							var numElements = image_rgba_data.length / 4 * 3;
-							var floatArray = new Float32Array( numElements );
+							numElements = image_rgba_data.length / 4 * 3;
+							const floatArray = new Float32Array( numElements );
 
-							for ( var j = 0; j < numElements; j ++ ) {
+							for ( let j = 0; j < numElements; j ++ ) {
 
 								RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 3 );
 
 							}
 
-							var data = floatArray;
-							var format = THREE.RGBFormat;
-							var type = THREE.FloatType;
+							data = floatArray;
+							format = THREE.RGBFormat;
+							type = THREE.FloatType;
 							break;
 
 						case THREE.HalfFloatType:
-							var numElements = image_rgba_data.length / 4 * 3;
-							var halfArray = new Uint16Array( numElements );
+							numElements = image_rgba_data.length / 4 * 3;
+							const halfArray = new Uint16Array( numElements );
 
-							for ( var j = 0; j < numElements; j ++ ) {
+							for ( let j = 0; j < numElements; j ++ ) {
 
 								RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 3 );
 
 							}
 
-							var data = halfArray;
-							var format = THREE.RGBFormat;
-							var type = THREE.HalfFloatType;
+							data = halfArray;
+							format = THREE.RGBFormat;
+							type = THREE.HalfFloatType;
 							break;
 
 						default:
@@ -443,14 +433,16 @@
 
 			return null;
 
-		},
-		setDataType: function ( value ) {
+		}
+
+		setDataType( value ) {
 
 			this.type = value;
 			return this;
 
-		},
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
 			function onLoadCallback( texture, texData ) {
 
@@ -486,10 +478,11 @@
 
 			}
 
-			return THREE.DataTextureLoader.prototype.load.call( this, url, onLoadCallback, onProgress, onError );
+			return super.load( url, onLoadCallback, onProgress, onError );
 
 		}
-	} );
+
+	}
 
 	THREE.RGBELoader = RGBELoader;
 

+ 71 - 70
examples/js/loaders/STLLoader.js

@@ -13,7 +13,7 @@
  *	ASCII decoding assumes file is UTF-8.
  *
  * Usage:
- *	var loader = new STLLoader();
+ *	const loader = new STLLoader();
  *	loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
  *		scene.add( new THREE.Mesh( geometry ) );
  *	});
@@ -23,24 +23,24 @@
  *	if (geometry.hasColors) {
  *		material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
  *	} else { .... }
- *	var mesh = new THREE.Mesh( geometry, material );
+ *	const mesh = new THREE.Mesh( geometry, material );
  *
  * For ASCII STLs containing multiple solids, each solid is assigned to a different group.
  * Groups can be used to assign a different color by defining an array of materials with the same length of
  * geometry.groups and passing it to the Mesh constructor:
  *
- * var mesh = new THREE.Mesh( geometry, material );
+ * const mesh = new THREE.Mesh( geometry, material );
  *
  * For example:
  *
- *	var materials = [];
- *	var nGeometryGroups = geometry.groups.length;
+ *	const materials = [];
+ *	const nGeometryGroups = geometry.groups.length;
  *
- *	var colorMap = ...; // Some logic to index colors.
+ *	const colorMap = ...; // Some logic to index colors.
  *
- *	for (var i = 0; i < nGeometryGroups; i++) {
+ *	for (let i = 0; i < nGeometryGroups; i++) {
  *
- *		var material = new THREE.MeshPhongMaterial({
+ *		const material = new THREE.MeshPhongMaterial({
  *			color: colorMap[i],
  *			wireframe: false
  *		});
@@ -48,21 +48,21 @@
  *	}
  *
  *	materials.push(material);
- *	var mesh = new THREE.Mesh(geometry, materials);
+ *	const mesh = new THREE.Mesh(geometry, materials);
  */
 
-	var STLLoader = function ( manager ) {
+	class STLLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	STLLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: STLLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( this.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( this.requestHeader );
@@ -91,16 +91,16 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( data ) {
+		}
+
+		parse( data ) {
 
 			function isBinary( data ) {
 
-				var expect, face_size, n_faces, reader;
-				reader = new DataView( data );
-				face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8;
-				n_faces = reader.getUint32( 80, true );
-				expect = 80 + 32 / 8 + n_faces * face_size;
+				const reader = new DataView( data );
+				const face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8;
+				const n_faces = reader.getUint32( 80, true );
+				const expect = 80 + 32 / 8 + n_faces * face_size;
 
 				if ( expect === reader.byteLength ) {
 
@@ -115,9 +115,9 @@
 				// US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
 
 
-				var solid = [ 115, 111, 108, 105, 100 ];
+				const solid = [ 115, 111, 108, 105, 100 ];
 
-				for ( var off = 0; off < 5; off ++ ) {
+				for ( let off = 0; off < 5; off ++ ) {
 
 					// If "solid" text is matched to the current offset, declare it to be an ASCII STL.
 					if ( matchDataViewAt( solid, reader, off ) ) return false;
@@ -132,7 +132,7 @@
 			function matchDataViewAt( query, reader, offset ) {
 
 				// Check if each byte in query matches the corresponding byte from the current offset
-				for ( var i = 0, il = query.length; i < il; i ++ ) {
+				for ( let i = 0, il = query.length; i < il; i ++ ) {
 
 					if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
 
@@ -144,17 +144,17 @@
 
 			function parseBinary( data ) {
 
-				var reader = new DataView( data );
-				var faces = reader.getUint32( 80, true );
-				var r,
+				const reader = new DataView( data );
+				const faces = reader.getUint32( 80, true );
+				let r,
 					g,
 					b,
 					hasColors = false,
 					colors;
-				var defaultR, defaultG, defaultB, alpha; // process STL header
+				let defaultR, defaultG, defaultB, alpha; // process STL header
 				// check for default color in header ("COLOR=rgba" sequence).
 
-				for ( var index = 0; index < 80 - 10; index ++ ) {
+				for ( let index = 0; index < 80 - 10; index ++ ) {
 
 					if ( reader.getUint32( index, false ) == 0x434F4C4F
 				/*COLO*/
@@ -175,22 +175,22 @@
 
 				}
 
-				var dataOffset = 84;
-				var faceLength = 12 * 4 + 2;
-				var geometry = new THREE.BufferGeometry();
-				var vertices = new Float32Array( faces * 3 * 3 );
-				var normals = new Float32Array( faces * 3 * 3 );
+				const dataOffset = 84;
+				const faceLength = 12 * 4 + 2;
+				const geometry = new THREE.BufferGeometry();
+				const vertices = new Float32Array( faces * 3 * 3 );
+				const normals = new Float32Array( faces * 3 * 3 );
 
-				for ( var face = 0; face < faces; face ++ ) {
+				for ( let face = 0; face < faces; face ++ ) {
 
-					var start = dataOffset + face * faceLength;
-					var normalX = reader.getFloat32( start, true );
-					var normalY = reader.getFloat32( start + 4, true );
-					var normalZ = reader.getFloat32( start + 8, true );
+					const start = dataOffset + face * faceLength;
+					const normalX = reader.getFloat32( start, true );
+					const normalY = reader.getFloat32( start + 4, true );
+					const normalZ = reader.getFloat32( start + 8, true );
 
 					if ( hasColors ) {
 
-						var packedColor = reader.getUint16( start + 48, true );
+						const packedColor = reader.getUint16( start + 48, true );
 
 						if ( ( packedColor & 0x8000 ) === 0 ) {
 
@@ -209,10 +209,10 @@
 
 					}
 
-					for ( var i = 1; i <= 3; i ++ ) {
+					for ( let i = 1; i <= 3; i ++ ) {
 
-						var vertexstart = start + i * 12;
-						var componentIdx = face * 3 * 3 + ( i - 1 ) * 3;
+						const vertexstart = start + i * 12;
+						const componentIdx = face * 3 * 3 + ( i - 1 ) * 3;
 						vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
 						vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
 						vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
@@ -249,31 +249,31 @@
 
 			function parseASCII( data ) {
 
-				var geometry = new THREE.BufferGeometry();
-				var patternSolid = /solid([\s\S]*?)endsolid/g;
-				var patternFace = /facet([\s\S]*?)endfacet/g;
-				var faceCounter = 0;
-				var patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
-				var patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
-				var patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
-				var vertices = [];
-				var normals = [];
-				var normal = new THREE.Vector3();
-				var result;
-				var groupCount = 0;
-				var startVertex = 0;
-				var endVertex = 0;
+				const geometry = new THREE.BufferGeometry();
+				const patternSolid = /solid([\s\S]*?)endsolid/g;
+				const patternFace = /facet([\s\S]*?)endfacet/g;
+				let faceCounter = 0;
+				const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
+				const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
+				const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
+				const vertices = [];
+				const normals = [];
+				const normal = new THREE.Vector3();
+				let result;
+				let groupCount = 0;
+				let startVertex = 0;
+				let endVertex = 0;
 
 				while ( ( result = patternSolid.exec( data ) ) !== null ) {
 
 					startVertex = endVertex;
-					var solid = result[ 0 ];
+					const solid = result[ 0 ];
 
 					while ( ( result = patternFace.exec( solid ) ) !== null ) {
 
-						var vertexCountPerFace = 0;
-						var normalCountPerFace = 0;
-						var text = result[ 0 ];
+						let vertexCountPerFace = 0;
+						let normalCountPerFace = 0;
+						const text = result[ 0 ];
 
 						while ( ( result = patternNormal.exec( text ) ) !== null ) {
 
@@ -311,8 +311,8 @@
 
 					}
 
-					var start = startVertex;
-					var count = endVertex - startVertex;
+					const start = startVertex;
+					const count = endVertex - startVertex;
 					geometry.addGroup( start, count, groupCount );
 					groupCount ++;
 
@@ -340,9 +340,9 @@
 
 				if ( typeof buffer === 'string' ) {
 
-					var array_buffer = new Uint8Array( buffer.length );
+					const array_buffer = new Uint8Array( buffer.length );
 
-					for ( var i = 0; i < buffer.length; i ++ ) {
+					for ( let i = 0; i < buffer.length; i ++ ) {
 
 						array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
 
@@ -359,11 +359,12 @@
 			} // start
 
 
-			var binData = ensureBinary( data );
+			const binData = ensureBinary( data );
 			return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
 
 		}
-	} );
+
+	}
 
 	THREE.STLLoader = STLLoader;
 

+ 333 - 309
examples/js/loaders/TDSLoader.js

@@ -9,20 +9,18 @@
  * @constructor
  */
 
-	var TDSLoader = function ( manager ) {
+	class TDSLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
-		this.debug = false;
-		this.group = null;
-		this.position = 0;
-		this.materials = [];
-		this.meshes = [];
+		constructor( manager ) {
 
-	};
-
-	TDSLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: TDSLoader,
+			super( manager );
+			this.debug = false;
+			this.group = null;
+			this.position = 0;
+			this.materials = [];
+			this.meshes = [];
 
+		}
 		/**
 	 * Load 3ds file from url.
 	 *
@@ -32,11 +30,13 @@
 	 * @param {Function} onProgress onProgress callback.
 	 * @param {Function} onError onError callback.
 	 */
-		load: function ( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var path = this.path === '' ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
-			var loader = new THREE.FileLoader( this.manager );
+
+		load( url, onLoad, onProgress, onError ) {
+
+			const scope = this;
+			const path = this.path === '' ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( this.requestHeader );
@@ -65,8 +65,7 @@
 
 			}, onProgress, onError );
 
-		},
-
+		}
 		/**
 	 * Parse arraybuffer data and load 3ds file.
 	 *
@@ -75,7 +74,9 @@
 	 * @param {String} path Path for external resources.
 	 * @return {Group} THREE.Group loaded from 3ds file.
 	 */
-		parse: function ( arraybuffer, path ) {
+
+
+		parse( arraybuffer, path ) {
 
 			this.group = new THREE.Group();
 			this.position = 0;
@@ -83,7 +84,7 @@
 			this.meshes = [];
 			this.readFile( arraybuffer, path );
 
-			for ( var i = 0; i < this.meshes.length; i ++ ) {
+			for ( let i = 0; i < this.meshes.length; i ++ ) {
 
 				this.group.add( this.meshes[ i ] );
 
@@ -91,8 +92,7 @@
 
 			return this.group;
 
-		},
-
+		}
 		/**
 	 * Decode file content to read 3ds data.
 	 *
@@ -100,20 +100,22 @@
 	 * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
 	 * @param {String} path Path for external resources.
 	 */
-		readFile: function ( arraybuffer, path ) {
 
-			var data = new DataView( arraybuffer );
-			var chunk = this.readChunk( data );
+
+		readFile( arraybuffer, path ) {
+
+			const data = new DataView( arraybuffer );
+			const chunk = this.readChunk( data );
 
 			if ( chunk.id === MLIBMAGIC || chunk.id === CMAGIC || chunk.id === M3DMAGIC ) {
 
-				var next = this.nextChunk( data, chunk );
+				let next = this.nextChunk( data, chunk );
 
 				while ( next !== 0 ) {
 
 					if ( next === M3D_VERSION ) {
 
-						var version = this.readDWord( data );
+						const version = this.readDWord( data );
 						this.debugMessage( '3DS file version: ' + version );
 
 					} else if ( next === MDATA ) {
@@ -135,8 +137,7 @@
 
 			this.debugMessage( 'Parsed ' + this.meshes.length + ' meshes' );
 
-		},
-
+		}
 		/**
 	 * Read mesh data chunk.
 	 *
@@ -144,21 +145,23 @@
 	 * @param {Dataview} data Dataview in use.
 	 * @param {String} path Path for external resources.
 	 */
-		readMeshData: function ( data, path ) {
 
-			var chunk = this.readChunk( data );
-			var next = this.nextChunk( data, chunk );
+
+		readMeshData( data, path ) {
+
+			const chunk = this.readChunk( data );
+			let next = this.nextChunk( data, chunk );
 
 			while ( next !== 0 ) {
 
 				if ( next === MESH_VERSION ) {
 
-					var version = + this.readDWord( data );
+					const version = + this.readDWord( data );
 					this.debugMessage( 'Mesh Version: ' + version );
 
 				} else if ( next === MASTER_SCALE ) {
 
-					var scale = this.readFloat( data );
+					const scale = this.readFloat( data );
 					this.debugMessage( 'Master scale: ' + scale );
 					this.group.scale.set( scale, scale, scale );
 
@@ -184,27 +187,28 @@
 
 			}
 
-		},
-
+		}
 		/**
 	 * Read named object chunk.
 	 *
 	 * @method readNamedObject
 	 * @param {Dataview} data Dataview in use.
 	 */
-		readNamedObject: function ( data ) {
 
-			var chunk = this.readChunk( data );
-			var name = this.readString( data, 64 );
+
+		readNamedObject( data ) {
+
+			const chunk = this.readChunk( data );
+			const name = this.readString( data, 64 );
 			chunk.cur = this.position;
-			var next = this.nextChunk( data, chunk );
+			let next = this.nextChunk( data, chunk );
 
 			while ( next !== 0 ) {
 
 				if ( next === N_TRI_OBJECT ) {
 
 					this.resetPosition( data );
-					var mesh = this.readMesh( data );
+					const mesh = this.readMesh( data );
 					mesh.name = name;
 					this.meshes.push( mesh );
 
@@ -220,8 +224,7 @@
 
 			this.endChunk( chunk );
 
-		},
-
+		}
 		/**
 	 * Read material data chunk and add it to the material list.
 	 *
@@ -229,11 +232,13 @@
 	 * @param {Dataview} data Dataview in use.
 	 * @param {String} path Path for external resources.
 	 */
-		readMaterialEntry: function ( data, path ) {
 
-			var chunk = this.readChunk( data );
-			var next = this.nextChunk( data, chunk );
-			var material = new THREE.MeshPhongMaterial();
+
+		readMaterialEntry( data, path ) {
+
+			const chunk = this.readChunk( data );
+			let next = this.nextChunk( data, chunk );
+			const material = new THREE.MeshPhongMaterial();
 
 			while ( next !== 0 ) {
 
@@ -249,7 +254,7 @@
 
 				} else if ( next === MAT_WIRE_SIZE ) {
 
-					var value = this.readByte( data );
+					const value = this.readByte( data );
 					material.wireframeLinewidth = value;
 					this.debugMessage( '	 Wireframe Thickness: ' + value );
 
@@ -280,13 +285,13 @@
 
 				} else if ( next === MAT_SHININESS ) {
 
-					var shininess = this.readPercentage( data );
+					const shininess = this.readPercentage( data );
 					material.shininess = shininess * 100;
 					this.debugMessage( '	 Shininess : ' + shininess );
 
 				} else if ( next === MAT_TRANSPARENCY ) {
 
-					var transparency = this.readPercentage( data );
+					const transparency = this.readPercentage( data );
 					material.opacity = 1 - transparency;
 					this.debugMessage( '	Transparency : ' + transparency );
 					material.transparent = material.opacity < 1 ? true : false;
@@ -328,8 +333,7 @@
 			this.endChunk( chunk );
 			this.materials[ material.name ] = material;
 
-		},
-
+		}
 		/**
 	 * Read mesh data chunk.
 	 *
@@ -337,26 +341,27 @@
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Mesh} The parsed mesh.
 	 */
-		readMesh: function ( data ) {
-
-			var chunk = this.readChunk( data );
-			var next = this.nextChunk( data, chunk );
-			var geometry = new THREE.BufferGeometry();
-			var uvs = [];
-			var material = new THREE.MeshPhongMaterial();
-			var mesh = new THREE.Mesh( geometry, material );
+
+
+		readMesh( data ) {
+
+			const chunk = this.readChunk( data );
+			let next = this.nextChunk( data, chunk );
+			const geometry = new THREE.BufferGeometry();
+			const material = new THREE.MeshPhongMaterial();
+			const mesh = new THREE.Mesh( geometry, material );
 			mesh.name = 'mesh';
 
 			while ( next !== 0 ) {
 
 				if ( next === POINT_ARRAY ) {
 
-					var points = this.readWord( data );
+					const points = this.readWord( data );
 					this.debugMessage( '	 Vertex: ' + points ); //BufferGeometry
 
-					var vertices = [];
+					const vertices = [];
 
-					for ( var i = 0; i < points; i ++ ) {
+					for ( let i = 0; i < points; i ++ ) {
 
 						vertices.push( this.readFloat( data ) );
 						vertices.push( this.readFloat( data ) );
@@ -373,12 +378,12 @@
 
 				} else if ( next === TEX_VERTS ) {
 
-					var texels = this.readWord( data );
+					const texels = this.readWord( data );
 					this.debugMessage( '	 UV: ' + texels ); //BufferGeometry
 
-					var uvs = [];
+					const uvs = [];
 
-					for ( var i = 0; i < texels; i ++ ) {
+					for ( let i = 0; i < texels; i ++ ) {
 
 						uvs.push( this.readFloat( data ) );
 						uvs.push( this.readFloat( data ) );
@@ -390,15 +395,15 @@
 				} else if ( next === MESH_MATRIX ) {
 
 					this.debugMessage( '	 Tranformation Matrix (TODO)' );
-					var values = [];
+					const values = [];
 
-					for ( var i = 0; i < 12; i ++ ) {
+					for ( let i = 0; i < 12; i ++ ) {
 
 						values[ i ] = this.readFloat( data );
 
 					}
 
-					var matrix = new THREE.Matrix4(); //X Line
+					const matrix = new THREE.Matrix4(); //X Line
 
 					matrix.elements[ 0 ] = values[ 0 ];
 					matrix.elements[ 1 ] = values[ 6 ];
@@ -420,7 +425,7 @@
 					matrix.elements[ 14 ] = 0;
 					matrix.elements[ 15 ] = 1;
 					matrix.transpose();
-					var inverse = new THREE.Matrix4();
+					const inverse = new THREE.Matrix4();
 					inverse.copy( matrix ).invert();
 					geometry.applyMatrix4( inverse );
 					matrix.decompose( mesh.position, mesh.quaternion, mesh.scale );
@@ -439,8 +444,7 @@
 			geometry.computeVertexNormals();
 			return mesh;
 
-		},
-
+		}
 		/**
 	 * Read face array data chunk.
 	 *
@@ -448,14 +452,16 @@
 	 * @param {Dataview} data Dataview in use.
 	 * @param {Mesh} mesh THREE.Mesh to be filled with the data read.
 	 */
-		readFaceArray: function ( data, mesh ) {
 
-			var chunk = this.readChunk( data );
-			var faces = this.readWord( data );
+
+		readFaceArray( data, mesh ) {
+
+			const chunk = this.readChunk( data );
+			const faces = this.readWord( data );
 			this.debugMessage( '	 Faces: ' + faces );
-			var index = [];
+			const index = [];
 
-			for ( var i = 0; i < faces; ++ i ) {
+			for ( let i = 0; i < faces; ++ i ) {
 
 				index.push( this.readWord( data ), this.readWord( data ), this.readWord( data ) );
 				this.readWord( data ); // visibility
@@ -464,24 +470,24 @@
 
 			mesh.geometry.setIndex( index ); //The rest of the FACE_ARRAY chunk is subchunks
 
-			var materialIndex = 0;
-			var start = 0;
+			let materialIndex = 0;
+			let start = 0;
 
 			while ( this.position < chunk.end ) {
 
-				var subchunk = this.readChunk( data );
+				const subchunk = this.readChunk( data );
 
 				if ( subchunk.id === MSH_MAT_GROUP ) {
 
 					this.debugMessage( '			Material THREE.Group' );
 					this.resetPosition( data );
-					var group = this.readMaterialGroup( data );
-					var count = group.index.length * 3; // assuming successive indices
+					const group = this.readMaterialGroup( data );
+					const count = group.index.length * 3; // assuming successive indices
 
 					mesh.geometry.addGroup( start, count, materialIndex );
 					start += count;
 					materialIndex ++;
-					var material = this.materials[ group.name ];
+					const material = this.materials[ group.name ];
 					if ( Array.isArray( mesh.material ) === false ) mesh.material = [];
 
 					if ( material !== undefined ) {
@@ -504,8 +510,7 @@
 
 			this.endChunk( chunk );
 
-		},
-
+		}
 		/**
 	 * Read texture map data chunk.
 	 *
@@ -514,19 +519,21 @@
 	 * @param {String} path Path for external resources.
 	 * @return {Texture} Texture read from this data chunk.
 	 */
-		readMap: function ( data, path ) {
 
-			var chunk = this.readChunk( data );
-			var next = this.nextChunk( data, chunk );
-			var texture = {};
-			var loader = new THREE.TextureLoader( this.manager );
+
+		readMap( data, path ) {
+
+			const chunk = this.readChunk( data );
+			let next = this.nextChunk( data, chunk );
+			let texture = {};
+			const loader = new THREE.TextureLoader( this.manager );
 			loader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
 
 			while ( next !== 0 ) {
 
 				if ( next === MAT_MAPNAME ) {
 
-					var name = this.readString( data, 128 );
+					const name = this.readString( data, 128 );
 					texture = loader.load( name );
 					this.debugMessage( '			File: ' + path + name );
 
@@ -563,8 +570,7 @@
 			this.endChunk( chunk );
 			return texture;
 
-		},
-
+		}
 		/**
 	 * Read material group data chunk.
 	 *
@@ -572,16 +578,18 @@
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Object} Object with name and index of the object.
 	 */
-		readMaterialGroup: function ( data ) {
+
+
+		readMaterialGroup( data ) {
 
 			this.readChunk( data );
-			var name = this.readString( data, 64 );
-			var numFaces = this.readWord( data );
+			const name = this.readString( data, 64 );
+			const numFaces = this.readWord( data );
 			this.debugMessage( '				 Name: ' + name );
 			this.debugMessage( '				 Faces: ' + numFaces );
-			var index = [];
+			const index = [];
 
-			for ( var i = 0; i < numFaces; ++ i ) {
+			for ( let i = 0; i < numFaces; ++ i ) {
 
 				index.push( this.readWord( data ) );
 
@@ -592,8 +600,7 @@
 				index: index
 			};
 
-		},
-
+		}
 		/**
 	 * Read a color value.
 	 *
@@ -601,24 +608,26 @@
 	 * @param {DataView} data Dataview.
 	 * @return {Color} THREE.Color value read..
 	 */
-		readColor: function ( data ) {
 
-			var chunk = this.readChunk( data );
-			var color = new THREE.Color();
+
+		readColor( data ) {
+
+			const chunk = this.readChunk( data );
+			const color = new THREE.Color();
 
 			if ( chunk.id === COLOR_24 || chunk.id === LIN_COLOR_24 ) {
 
-				var r = this.readByte( data );
-				var g = this.readByte( data );
-				var b = this.readByte( data );
+				const r = this.readByte( data );
+				const g = this.readByte( data );
+				const b = this.readByte( data );
 				color.setRGB( r / 255, g / 255, b / 255 );
 				this.debugMessage( '			THREE.Color: ' + color.r + ', ' + color.g + ', ' + color.b );
 
 			} else if ( chunk.id === COLOR_F || chunk.id === LIN_COLOR_F ) {
 
-				var r = this.readFloat( data );
-				var g = this.readFloat( data );
-				var b = this.readFloat( data );
+				const r = this.readFloat( data );
+				const g = this.readFloat( data );
+				const b = this.readFloat( data );
 				color.setRGB( r, g, b );
 				this.debugMessage( '			THREE.Color: ' + color.r + ', ' + color.g + ', ' + color.b );
 
@@ -631,8 +640,7 @@
 			this.endChunk( chunk );
 			return color;
 
-		},
-
+		}
 		/**
 	 * Read next chunk of data.
 	 *
@@ -640,9 +648,11 @@
 	 * @param {DataView} data Dataview.
 	 * @return {Object} Chunk of data read.
 	 */
-		readChunk: function ( data ) {
 
-			var chunk = {};
+
+		readChunk( data ) {
+
+			const chunk = {};
 			chunk.cur = this.position;
 			chunk.id = this.readWord( data );
 			chunk.size = this.readDWord( data );
@@ -650,20 +660,20 @@
 			chunk.cur += 6;
 			return chunk;
 
-		},
-
+		}
 		/**
 	 * Set position to the end of the current chunk of data.
 	 *
 	 * @method endChunk
 	 * @param {Object} chunk Data chunk.
 	 */
-		endChunk: function ( chunk ) {
 
-			this.position = chunk.end;
 
-		},
+		endChunk( chunk ) {
 
+			this.position = chunk.end;
+
+		}
 		/**
 	 * Move to the next data chunk.
 	 *
@@ -671,7 +681,9 @@
 	 * @param {DataView} data Dataview.
 	 * @param {Object} chunk Data chunk.
 	 */
-		nextChunk: function ( data, chunk ) {
+
+
+		nextChunk( data, chunk ) {
 
 			if ( chunk.cur >= chunk.end ) {
 
@@ -683,7 +695,7 @@
 
 			try {
 
-				var next = this.readChunk( data );
+				const next = this.readChunk( data );
 				chunk.cur += next.size;
 				return next.id;
 
@@ -694,19 +706,19 @@
 
 			}
 
-		},
-
+		}
 		/**
 	 * Reset dataview position.
 	 *
 	 * @method resetPosition
 	 */
-		resetPosition: function () {
 
-			this.position -= 6;
 
-		},
+		resetPosition() {
 
+			this.position -= 6;
+
+		}
 		/**
 	 * Read byte value.
 	 *
@@ -714,14 +726,15 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readByte: function ( data ) {
 
-			var v = data.getUint8( this.position, true );
+
+		readByte( data ) {
+
+			const v = data.getUint8( this.position, true );
 			this.position += 1;
 			return v;
 
-		},
-
+		}
 		/**
 	 * Read 32 bit float value.
 	 *
@@ -729,11 +742,13 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readFloat: function ( data ) {
+
+
+		readFloat( data ) {
 
 			try {
 
-				var v = data.getFloat32( this.position, true );
+				const v = data.getFloat32( this.position, true );
 				this.position += 4;
 				return v;
 
@@ -743,8 +758,7 @@
 
 			}
 
-		},
-
+		}
 		/**
 	 * Read 32 bit signed integer value.
 	 *
@@ -752,14 +766,15 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readInt: function ( data ) {
 
-			var v = data.getInt32( this.position, true );
+
+		readInt( data ) {
+
+			const v = data.getInt32( this.position, true );
 			this.position += 4;
 			return v;
 
-		},
-
+		}
 		/**
 	 * Read 16 bit signed integer value.
 	 *
@@ -767,14 +782,15 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readShort: function ( data ) {
 
-			var v = data.getInt16( this.position, true );
+
+		readShort( data ) {
+
+			const v = data.getInt16( this.position, true );
 			this.position += 2;
 			return v;
 
-		},
-
+		}
 		/**
 	 * Read 64 bit unsigned integer value.
 	 *
@@ -782,14 +798,15 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readDWord: function ( data ) {
 
-			var v = data.getUint32( this.position, true );
+
+		readDWord( data ) {
+
+			const v = data.getUint32( this.position, true );
 			this.position += 4;
 			return v;
 
-		},
-
+		}
 		/**
 	 * Read 32 bit unsigned integer value.
 	 *
@@ -797,14 +814,15 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readWord: function ( data ) {
 
-			var v = data.getUint16( this.position, true );
+
+		readWord( data ) {
+
+			const v = data.getUint16( this.position, true );
 			this.position += 2;
 			return v;
 
-		},
-
+		}
 		/**
 	 * Read string value.
 	 *
@@ -813,13 +831,15 @@
 	 * @param {Number} maxLength Max size of the string to be read.
 	 * @return {String} Data read from the dataview.
 	 */
-		readString: function ( data, maxLength ) {
 
-			var s = '';
 
-			for ( var i = 0; i < maxLength; i ++ ) {
+		readString( data, maxLength ) {
+
+			let s = '';
+
+			for ( let i = 0; i < maxLength; i ++ ) {
 
-				var c = this.readByte( data );
+				const c = this.readByte( data );
 
 				if ( ! c ) {
 
@@ -833,8 +853,7 @@
 
 			return s;
 
-		},
-
+		}
 		/**
 	 * Read percentage value.
 	 *
@@ -842,10 +861,12 @@
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-		readPercentage: function ( data ) {
 
-			var chunk = this.readChunk( data );
-			var value;
+
+		readPercentage( data ) {
+
+			const chunk = this.readChunk( data );
+			let value;
 
 			switch ( chunk.id ) {
 
@@ -865,8 +886,7 @@
 			this.endChunk( chunk );
 			return value;
 
-		},
-
+		}
 		/**
 	 * Print debug message to the console.
 	 *
@@ -875,7 +895,9 @@
 	 * @method debugMessage
 	 * @param {Object} message Debug message to print to the console.
 	 */
-		debugMessage: function ( message ) {
+
+
+		debugMessage( message ) {
 
 			if ( this.debug ) {
 
@@ -884,155 +906,157 @@
 			}
 
 		}
-	} ); // var NULL_CHUNK = 0x0000;
-
-	var M3DMAGIC = 0x4D4D; // var SMAGIC = 0x2D2D;
-	// var LMAGIC = 0x2D3D;
-
-	var MLIBMAGIC = 0x3DAA; // var MATMAGIC = 0x3DFF;
-
-	var CMAGIC = 0xC23D;
-	var M3D_VERSION = 0x0002; // var M3D_KFVERSION = 0x0005;
-
-	var COLOR_F = 0x0010;
-	var COLOR_24 = 0x0011;
-	var LIN_COLOR_24 = 0x0012;
-	var LIN_COLOR_F = 0x0013;
-	var INT_PERCENTAGE = 0x0030;
-	var FLOAT_PERCENTAGE = 0x0031;
-	var MDATA = 0x3D3D;
-	var MESH_VERSION = 0x3D3E;
-	var MASTER_SCALE = 0x0100; // var LO_SHADOW_BIAS = 0x1400;
-	// var HI_SHADOW_BIAS = 0x1410;
-	// var SHADOW_MAP_SIZE = 0x1420;
-	// var SHADOW_SAMPLES = 0x1430;
-	// var SHADOW_RANGE = 0x1440;
-	// var SHADOW_FILTER = 0x1450;
-	// var RAY_BIAS = 0x1460;
-	// var O_CONSTS = 0x1500;
-	// var AMBIENT_LIGHT = 0x2100;
-	// var BIT_MAP = 0x1100;
-	// var SOLID_BGND = 0x1200;
-	// var V_GRADIENT = 0x1300;
-	// var USE_BIT_MAP = 0x1101;
-	// var USE_SOLID_BGND = 0x1201;
-	// var USE_V_GRADIENT = 0x1301;
-	// var FOG = 0x2200;
-	// var FOG_BGND = 0x2210;
-	// var LAYER_FOG = 0x2302;
-	// var DISTANCE_CUE = 0x2300;
-	// var DCUE_BGND = 0x2310;
-	// var USE_FOG = 0x2201;
-	// var USE_LAYER_FOG = 0x2303;
-	// var USE_DISTANCE_CUE = 0x2301;
-
-	var MAT_ENTRY = 0xAFFF;
-	var MAT_NAME = 0xA000;
-	var MAT_AMBIENT = 0xA010;
-	var MAT_DIFFUSE = 0xA020;
-	var MAT_SPECULAR = 0xA030;
-	var MAT_SHININESS = 0xA040; // var MAT_SHIN2PCT = 0xA041;
-
-	var MAT_TRANSPARENCY = 0xA050; // var MAT_XPFALL = 0xA052;
-	// var MAT_USE_XPFALL = 0xA240;
-	// var MAT_REFBLUR = 0xA053;
-	// var MAT_SHADING = 0xA100;
-	// var MAT_USE_REFBLUR = 0xA250;
-	// var MAT_SELF_ILLUM = 0xA084;
-
-	var MAT_TWO_SIDE = 0xA081; // var MAT_DECAL = 0xA082;
-
-	var MAT_ADDITIVE = 0xA083;
-	var MAT_WIRE = 0xA085; // var MAT_FACEMAP = 0xA088;
-	// var MAT_TRANSFALLOFF_IN = 0xA08A;
-	// var MAT_PHONGSOFT = 0xA08C;
-	// var MAT_WIREABS = 0xA08E;
-
-	var MAT_WIRE_SIZE = 0xA087;
-	var MAT_TEXMAP = 0xA200; // var MAT_SXP_TEXT_DATA = 0xA320;
-	// var MAT_TEXMASK = 0xA33E;
-	// var MAT_SXP_TEXTMASK_DATA = 0xA32A;
-	// var MAT_TEX2MAP = 0xA33A;
-	// var MAT_SXP_TEXT2_DATA = 0xA321;
-	// var MAT_TEX2MASK = 0xA340;
-	// var MAT_SXP_TEXT2MASK_DATA = 0xA32C;
-
-	var MAT_OPACMAP = 0xA210; // var MAT_SXP_OPAC_DATA = 0xA322;
-	// var MAT_OPACMASK = 0xA342;
-	// var MAT_SXP_OPACMASK_DATA = 0xA32E;
-
-	var MAT_BUMPMAP = 0xA230; // var MAT_SXP_BUMP_DATA = 0xA324;
-	// var MAT_BUMPMASK = 0xA344;
-	// var MAT_SXP_BUMPMASK_DATA = 0xA330;
-
-	var MAT_SPECMAP = 0xA204; // var MAT_SXP_SPEC_DATA = 0xA325;
-	// var MAT_SPECMASK = 0xA348;
-	// var MAT_SXP_SPECMASK_DATA = 0xA332;
-	// var MAT_SHINMAP = 0xA33C;
-	// var MAT_SXP_SHIN_DATA = 0xA326;
-	// var MAT_SHINMASK = 0xA346;
-	// var MAT_SXP_SHINMASK_DATA = 0xA334;
-	// var MAT_SELFIMAP = 0xA33D;
-	// var MAT_SXP_SELFI_DATA = 0xA328;
-	// var MAT_SELFIMASK = 0xA34A;
-	// var MAT_SXP_SELFIMASK_DATA = 0xA336;
-	// var MAT_REFLMAP = 0xA220;
-	// var MAT_REFLMASK = 0xA34C;
-	// var MAT_SXP_REFLMASK_DATA = 0xA338;
-	// var MAT_ACUBIC = 0xA310;
-
-	var MAT_MAPNAME = 0xA300; // var MAT_MAP_TILING = 0xA351;
-	// var MAT_MAP_TEXBLUR = 0xA353;
-
-	var MAT_MAP_USCALE = 0xA354;
-	var MAT_MAP_VSCALE = 0xA356;
-	var MAT_MAP_UOFFSET = 0xA358;
-	var MAT_MAP_VOFFSET = 0xA35A; // var MAT_MAP_ANG = 0xA35C;
-	// var MAT_MAP_COL1 = 0xA360;
-	// var MAT_MAP_COL2 = 0xA362;
-	// var MAT_MAP_RCOL = 0xA364;
-	// var MAT_MAP_GCOL = 0xA366;
-	// var MAT_MAP_BCOL = 0xA368;
-
-	var NAMED_OBJECT = 0x4000; // var N_DIRECT_LIGHT = 0x4600;
-	// var DL_OFF = 0x4620;
-	// var DL_OUTER_RANGE = 0x465A;
-	// var DL_INNER_RANGE = 0x4659;
-	// var DL_MULTIPLIER = 0x465B;
-	// var DL_EXCLUDE = 0x4654;
-	// var DL_ATTENUATE = 0x4625;
-	// var DL_SPOTLIGHT = 0x4610;
-	// var DL_SPOT_ROLL = 0x4656;
-	// var DL_SHADOWED = 0x4630;
-	// var DL_LOCAL_SHADOW2 = 0x4641;
-	// var DL_SEE_CONE = 0x4650;
-	// var DL_SPOT_RECTANGULAR = 0x4651;
-	// var DL_SPOT_ASPECT = 0x4657;
-	// var DL_SPOT_PROJECTOR = 0x4653;
-	// var DL_SPOT_OVERSHOOT = 0x4652;
-	// var DL_RAY_BIAS = 0x4658;
-	// var DL_RAYSHAD = 0x4627;
-	// var N_CAMERA = 0x4700;
-	// var CAM_SEE_CONE = 0x4710;
-	// var CAM_RANGES = 0x4720;
-	// var OBJ_HIDDEN = 0x4010;
-	// var OBJ_VIS_LOFTER = 0x4011;
-	// var OBJ_DOESNT_CAST = 0x4012;
-	// var OBJ_DONT_RECVSHADOW = 0x4017;
-	// var OBJ_MATTE = 0x4013;
-	// var OBJ_FAST = 0x4014;
-	// var OBJ_PROCEDURAL = 0x4015;
-	// var OBJ_FROZEN = 0x4016;
-
-	var N_TRI_OBJECT = 0x4100;
-	var POINT_ARRAY = 0x4110; // var POINT_FLAG_ARRAY = 0x4111;
-
-	var FACE_ARRAY = 0x4120;
-	var MSH_MAT_GROUP = 0x4130; // var SMOOTH_GROUP = 0x4150;
-	// var MSH_BOXMAP = 0x4190;
-
-	var TEX_VERTS = 0x4140;
-	var MESH_MATRIX = 0x4160; // var MESH_COLOR = 0x4165;
+
+	} // const NULL_CHUNK = 0x0000;
+
+
+	const M3DMAGIC = 0x4D4D; // const SMAGIC = 0x2D2D;
+	// const LMAGIC = 0x2D3D;
+
+	const MLIBMAGIC = 0x3DAA; // const MATMAGIC = 0x3DFF;
+
+	const CMAGIC = 0xC23D;
+	const M3D_VERSION = 0x0002; // const M3D_KFVERSION = 0x0005;
+
+	const COLOR_F = 0x0010;
+	const COLOR_24 = 0x0011;
+	const LIN_COLOR_24 = 0x0012;
+	const LIN_COLOR_F = 0x0013;
+	const INT_PERCENTAGE = 0x0030;
+	const FLOAT_PERCENTAGE = 0x0031;
+	const MDATA = 0x3D3D;
+	const MESH_VERSION = 0x3D3E;
+	const MASTER_SCALE = 0x0100; // const LO_SHADOW_BIAS = 0x1400;
+	// const HI_SHADOW_BIAS = 0x1410;
+	// const SHADOW_MAP_SIZE = 0x1420;
+	// const SHADOW_SAMPLES = 0x1430;
+	// const SHADOW_RANGE = 0x1440;
+	// const SHADOW_FILTER = 0x1450;
+	// const RAY_BIAS = 0x1460;
+	// const O_CONSTS = 0x1500;
+	// const AMBIENT_LIGHT = 0x2100;
+	// const BIT_MAP = 0x1100;
+	// const SOLID_BGND = 0x1200;
+	// const V_GRADIENT = 0x1300;
+	// const USE_BIT_MAP = 0x1101;
+	// const USE_SOLID_BGND = 0x1201;
+	// const USE_V_GRADIENT = 0x1301;
+	// const FOG = 0x2200;
+	// const FOG_BGND = 0x2210;
+	// const LAYER_FOG = 0x2302;
+	// const DISTANCE_CUE = 0x2300;
+	// const DCUE_BGND = 0x2310;
+	// const USE_FOG = 0x2201;
+	// const USE_LAYER_FOG = 0x2303;
+	// const USE_DISTANCE_CUE = 0x2301;
+
+	const MAT_ENTRY = 0xAFFF;
+	const MAT_NAME = 0xA000;
+	const MAT_AMBIENT = 0xA010;
+	const MAT_DIFFUSE = 0xA020;
+	const MAT_SPECULAR = 0xA030;
+	const MAT_SHININESS = 0xA040; // const MAT_SHIN2PCT = 0xA041;
+
+	const MAT_TRANSPARENCY = 0xA050; // const MAT_XPFALL = 0xA052;
+	// const MAT_USE_XPFALL = 0xA240;
+	// const MAT_REFBLUR = 0xA053;
+	// const MAT_SHADING = 0xA100;
+	// const MAT_USE_REFBLUR = 0xA250;
+	// const MAT_SELF_ILLUM = 0xA084;
+
+	const MAT_TWO_SIDE = 0xA081; // const MAT_DECAL = 0xA082;
+
+	const MAT_ADDITIVE = 0xA083;
+	const MAT_WIRE = 0xA085; // const MAT_FACEMAP = 0xA088;
+	// const MAT_TRANSFALLOFF_IN = 0xA08A;
+	// const MAT_PHONGSOFT = 0xA08C;
+	// const MAT_WIREABS = 0xA08E;
+
+	const MAT_WIRE_SIZE = 0xA087;
+	const MAT_TEXMAP = 0xA200; // const MAT_SXP_TEXT_DATA = 0xA320;
+	// const MAT_TEXMASK = 0xA33E;
+	// const MAT_SXP_TEXTMASK_DATA = 0xA32A;
+	// const MAT_TEX2MAP = 0xA33A;
+	// const MAT_SXP_TEXT2_DATA = 0xA321;
+	// const MAT_TEX2MASK = 0xA340;
+	// const MAT_SXP_TEXT2MASK_DATA = 0xA32C;
+
+	const MAT_OPACMAP = 0xA210; // const MAT_SXP_OPAC_DATA = 0xA322;
+	// const MAT_OPACMASK = 0xA342;
+	// const MAT_SXP_OPACMASK_DATA = 0xA32E;
+
+	const MAT_BUMPMAP = 0xA230; // const MAT_SXP_BUMP_DATA = 0xA324;
+	// const MAT_BUMPMASK = 0xA344;
+	// const MAT_SXP_BUMPMASK_DATA = 0xA330;
+
+	const MAT_SPECMAP = 0xA204; // const MAT_SXP_SPEC_DATA = 0xA325;
+	// const MAT_SPECMASK = 0xA348;
+	// const MAT_SXP_SPECMASK_DATA = 0xA332;
+	// const MAT_SHINMAP = 0xA33C;
+	// const MAT_SXP_SHIN_DATA = 0xA326;
+	// const MAT_SHINMASK = 0xA346;
+	// const MAT_SXP_SHINMASK_DATA = 0xA334;
+	// const MAT_SELFIMAP = 0xA33D;
+	// const MAT_SXP_SELFI_DATA = 0xA328;
+	// const MAT_SELFIMASK = 0xA34A;
+	// const MAT_SXP_SELFIMASK_DATA = 0xA336;
+	// const MAT_REFLMAP = 0xA220;
+	// const MAT_REFLMASK = 0xA34C;
+	// const MAT_SXP_REFLMASK_DATA = 0xA338;
+	// const MAT_ACUBIC = 0xA310;
+
+	const MAT_MAPNAME = 0xA300; // const MAT_MAP_TILING = 0xA351;
+	// const MAT_MAP_TEXBLUR = 0xA353;
+
+	const MAT_MAP_USCALE = 0xA354;
+	const MAT_MAP_VSCALE = 0xA356;
+	const MAT_MAP_UOFFSET = 0xA358;
+	const MAT_MAP_VOFFSET = 0xA35A; // const MAT_MAP_ANG = 0xA35C;
+	// const MAT_MAP_COL1 = 0xA360;
+	// const MAT_MAP_COL2 = 0xA362;
+	// const MAT_MAP_RCOL = 0xA364;
+	// const MAT_MAP_GCOL = 0xA366;
+	// const MAT_MAP_BCOL = 0xA368;
+
+	const NAMED_OBJECT = 0x4000; // const N_DIRECT_LIGHT = 0x4600;
+	// const DL_OFF = 0x4620;
+	// const DL_OUTER_RANGE = 0x465A;
+	// const DL_INNER_RANGE = 0x4659;
+	// const DL_MULTIPLIER = 0x465B;
+	// const DL_EXCLUDE = 0x4654;
+	// const DL_ATTENUATE = 0x4625;
+	// const DL_SPOTLIGHT = 0x4610;
+	// const DL_SPOT_ROLL = 0x4656;
+	// const DL_SHADOWED = 0x4630;
+	// const DL_LOCAL_SHADOW2 = 0x4641;
+	// const DL_SEE_CONE = 0x4650;
+	// const DL_SPOT_RECTANGULAR = 0x4651;
+	// const DL_SPOT_ASPECT = 0x4657;
+	// const DL_SPOT_PROJECTOR = 0x4653;
+	// const DL_SPOT_OVERSHOOT = 0x4652;
+	// const DL_RAY_BIAS = 0x4658;
+	// const DL_RAYSHAD = 0x4627;
+	// const N_CAMERA = 0x4700;
+	// const CAM_SEE_CONE = 0x4710;
+	// const CAM_RANGES = 0x4720;
+	// const OBJ_HIDDEN = 0x4010;
+	// const OBJ_VIS_LOFTER = 0x4011;
+	// const OBJ_DOESNT_CAST = 0x4012;
+	// const OBJ_DONT_RECVSHADOW = 0x4017;
+	// const OBJ_MATTE = 0x4013;
+	// const OBJ_FAST = 0x4014;
+	// const OBJ_PROCEDURAL = 0x4015;
+	// const OBJ_FROZEN = 0x4016;
+
+	const N_TRI_OBJECT = 0x4100;
+	const POINT_ARRAY = 0x4110; // const POINT_FLAG_ARRAY = 0x4111;
+
+	const FACE_ARRAY = 0x4120;
+	const MSH_MAT_GROUP = 0x4130; // const SMOOTH_GROUP = 0x4150;
+	// const MSH_BOXMAP = 0x4190;
+
+	const TEX_VERTS = 0x4140;
+	const MESH_MATRIX = 0x4160; // const MESH_COLOR = 0x4165;
 
 	THREE.TDSLoader = TDSLoader;
 

+ 35 - 34
examples/js/loaders/TGALoader.js

@@ -1,14 +1,14 @@
 ( function () {
 
-	var TGALoader = function ( manager ) {
+	class TGALoader extends THREE.DataTextureLoader {
 
-		THREE.DataTextureLoader.call( this, manager );
+		constructor( manager ) {
 
-	};
+			super( manager );
 
-	TGALoader.prototype = Object.assign( Object.create( THREE.DataTextureLoader.prototype ), {
-		constructor: TGALoader,
-		parse: function ( buffer ) {
+		}
+
+		parse( buffer ) {
 
 			// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
 			function tgaCheckHeader( header ) {
@@ -68,9 +68,9 @@
 
 			function tgaParse( use_rle, use_pal, header, offset, data ) {
 
-				var pixel_data, pixel_size, pixel_total, palettes;
-				pixel_size = header.pixel_size >> 3;
-				pixel_total = header.width * header.height * pixel_size; // read palettes
+				let pixel_data, palettes;
+				const pixel_size = header.pixel_size >> 3;
+				const pixel_total = header.width * header.height * pixel_size; // read palettes
 
 				if ( use_pal ) {
 
@@ -82,9 +82,9 @@
 				if ( use_rle ) {
 
 					pixel_data = new Uint8Array( pixel_total );
-					var c, count, i;
-					var shift = 0;
-					var pixels = new Uint8Array( pixel_size );
+					let c, count, i;
+					let shift = 0;
+					const pixels = new Uint8Array( pixel_size );
 
 					while ( shift < pixel_total ) {
 
@@ -142,12 +142,12 @@
 
 			function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes ) {
 
-				var colormap = palettes;
-				var color,
+				const colormap = palettes;
+				let color,
 					i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -169,11 +169,11 @@
 
 			function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-				var color,
+				let color,
 					i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -196,10 +196,10 @@
 
 			function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-				var i = 0,
+				let i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -220,10 +220,10 @@
 
 			function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-				var i = 0,
+				let i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -244,11 +244,11 @@
 
 			function tgaGetImageDataGrey8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-				var color,
+				let color,
 					i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -270,10 +270,10 @@
 
 			function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-				var i = 0,
+				let i = 0,
 					x,
 					y;
-				var width = header.width;
+				const width = header.width;
 
 				for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -294,7 +294,7 @@
 
 			function getTgaRGBA( data, width, height, image, palette ) {
 
-				var x_start, y_start, x_step, y_step, x_end, y_end;
+				let x_start, y_start, x_step, y_step, x_end, y_end;
 
 				switch ( ( header.flags & TGA_ORIGIN_MASK ) >> TGA_ORIGIN_SHIFT ) {
 
@@ -382,7 +382,7 @@
 					}
 
 				} // Load image data according to specific method
-				// var func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
+				// let func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
 				// func(data, y_start, y_step, y_end, x_start, x_step, x_end, width, image, palette );
 
 
@@ -391,7 +391,7 @@
 			} // TGA constants
 
 
-			var TGA_TYPE_NO_DATA = 0,
+			const TGA_TYPE_NO_DATA = 0,
 				TGA_TYPE_INDEXED = 1,
 				TGA_TYPE_RGB = 2,
 				TGA_TYPE_GREY = 3,
@@ -405,8 +405,8 @@
 				TGA_ORIGIN_UL = 0x02,
 				TGA_ORIGIN_UR = 0x03;
 			if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' );
-			var content = new Uint8Array( buffer ),
-				offset = 0,
+			let offset = 0;
+			const content = new Uint8Array( buffer ),
 				header = {
 					id_length: content[ offset ++ ],
 					colormap_type: content[ offset ++ ],
@@ -432,7 +432,7 @@
 
 			offset += header.id_length; // get targa information about RLE compression and palette
 
-			var use_rle = false,
+			let use_rle = false,
 				use_pal = false,
 				use_grey = false;
 
@@ -466,8 +466,8 @@
 			} //
 
 
-			var imageData = new Uint8Array( header.width * header.height * 4 );
-			var result = tgaParse( use_rle, use_pal, header, offset, content );
+			const imageData = new Uint8Array( header.width * header.height * 4 );
+			const result = tgaParse( use_rle, use_pal, header, offset, content );
 			getTgaRGBA( imageData, header.width, header.height, result.pixel_data, result.palettes );
 			return {
 				data: imageData,
@@ -479,7 +479,8 @@
 			};
 
 		}
-	} );
+
+	}
 
 	THREE.TGALoader = TGALoader;
 

+ 30 - 28
examples/js/loaders/TTFLoader.js

@@ -6,19 +6,19 @@
  * to create THREE.Font objects.
  */
 
-	var TTFLoader = function ( manager ) {
+	class TTFLoader extends THREE.Loader {
 
-		THREE.Loader.call( this, manager );
-		this.reversed = false;
+		constructor( manager ) {
 
-	};
+			super( manager );
+			this.reversed = false;
 
-	TTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-		constructor: TTFLoader,
-		load: function ( url, onLoad, onProgress, onError ) {
+		}
+
+		load( url, onLoad, onProgress, onError ) {
 
-			var scope = this;
-			var loader = new THREE.FileLoader( this.manager );
+			const scope = this;
+			const loader = new THREE.FileLoader( this.manager );
 			loader.setPath( this.path );
 			loader.setResponseType( 'arraybuffer' );
 			loader.setRequestHeader( this.requestHeader );
@@ -47,25 +47,26 @@
 
 			}, onProgress, onError );
 
-		},
-		parse: function ( arraybuffer ) {
+		}
+
+		parse( arraybuffer ) {
 
 			function convert( font, reversed ) {
 
-				var round = Math.round;
-				var glyphs = {};
-				var scale = 100000 / ( ( font.unitsPerEm || 2048 ) * 72 );
-				var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
-				var unicodes = Object.keys( glyphIndexMap );
+				const round = Math.round;
+				const glyphs = {};
+				const scale = 100000 / ( ( font.unitsPerEm || 2048 ) * 72 );
+				const glyphIndexMap = font.encoding.cmap.glyphIndexMap;
+				const unicodes = Object.keys( glyphIndexMap );
 
-				for ( var i = 0; i < unicodes.length; i ++ ) {
+				for ( let i = 0; i < unicodes.length; i ++ ) {
 
-					var unicode = unicodes[ i ];
-					var glyph = font.glyphs.glyphs[ glyphIndexMap[ unicode ] ];
+					const unicode = unicodes[ i ];
+					const glyph = font.glyphs.glyphs[ glyphIndexMap[ unicode ] ];
 
 					if ( unicode !== undefined ) {
 
-						var token = {
+						const token = {
 							ha: round( glyph.advanceWidth * scale ),
 							x_min: round( glyph.xMin * scale ),
 							x_max: round( glyph.xMax * scale ),
@@ -134,8 +135,8 @@
 
 			function reverseCommands( commands ) {
 
-				var paths = [];
-				var path;
+				const paths = [];
+				let path;
 				commands.forEach( function ( c ) {
 
 					if ( c.type.toLowerCase() === 'm' ) {
@@ -150,20 +151,20 @@
 					}
 
 				} );
-				var reversed = [];
+				const reversed = [];
 				paths.forEach( function ( p ) {
 
-					var result = {
+					const result = {
 						type: 'm',
 						x: p[ p.length - 1 ].x,
 						y: p[ p.length - 1 ].y
 					};
 					reversed.push( result );
 
-					for ( var i = p.length - 1; i > 0; i -- ) {
+					for ( let i = p.length - 1; i > 0; i -- ) {
 
-						var command = p[ i ];
-						var result = {
+						const command = p[ i ];
+						const result = {
 							type: command.type
 						};
 
@@ -202,7 +203,8 @@
 			return convert( opentype.parse( arraybuffer ), this.reversed ); // eslint-disable-line no-undef
 
 		}
-	} );
+
+	}
 
 	THREE.TTFLoader = TTFLoader;
 

File diff ditekan karena terlalu besar
+ 1591 - 1596
examples/js/loaders/VRMLLoader.js


+ 33 - 35
examples/js/loaders/VRMLoader.js

@@ -4,9 +4,9 @@
 	// VRM is based on glTF 2.0 and VRM extension is defined
 	// in top-level json.extensions.VRM
 
-	var VRMLoader = function () {
+	class VRMLoader extends THREE.Loader {
 
-		function VRMLoader( manager ) {
+		constructor( manager ) {
 
 			if ( THREE.GLTFLoader === undefined ) {
 
@@ -14,60 +14,58 @@
 
 			}
 
-			THREE.Loader.call( this, manager );
-			this.gltfLoader = new THREE.GLTFLoader( this.manager );
+			super( manager );
+			this.gltfLoader = new THREE.GLTFLoader( manager );
 
 		}
 
-		VRMLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
-			constructor: VRMLoader,
-			load: function ( url, onLoad, onProgress, onError ) {
+		load( url, onLoad, onProgress, onError ) {
 
-				var scope = this;
-				this.gltfLoader.load( url, function ( gltf ) {
+			const scope = this;
+			this.gltfLoader.load( url, function ( gltf ) {
 
-					try {
+				try {
 
-						scope.parse( gltf, onLoad );
+					scope.parse( gltf, onLoad );
 
-					} catch ( e ) {
+				} catch ( e ) {
 
-						if ( onError ) {
+					if ( onError ) {
 
-							onError( e );
+						onError( e );
 
-						} else {
+					} else {
 
-							console.error( e );
+						console.error( e );
 
-						}
+					}
 
-						scope.manager.itemError( url );
+					scope.manager.itemError( url );
 
-					}
+				}
+
+			}, onProgress, onError );
+
+		}
 
-				}, onProgress, onError );
+		setDRACOLoader( dracoLoader ) {
 
-			},
-			setDRACOLoader: function ( dracoLoader ) {
+			this.gltfLoader.setDRACOLoader( dracoLoader );
+			return this;
 
-				this.gltfLoader.setDRACOLoader( dracoLoader );
-				return this;
+		}
 
-			},
-			parse: function ( gltf, onLoad ) {
+		parse( gltf, onLoad ) {
 
-				// var gltfParser = gltf.parser;
-				// var gltfExtensions = gltf.userData.gltfExtensions || {};
-				// var vrmExtension = gltfExtensions.VRM || {};
-				// handle VRM Extension here
-				onLoad( gltf );
+			// const gltfParser = gltf.parser;
+			// const gltfExtensions = gltf.userData.gltfExtensions || {};
+			// const vrmExtension = gltfExtensions.VRM || {};
+			// handle VRM Extension here
+			onLoad( gltf );
 
-			}
-		} );
-		return VRMLoader;
+		}
 
-	}();
+	}
 
 	THREE.VRMLoader = VRMLoader;
 

File diff ditekan karena terlalu besar
+ 240 - 243
examples/jsm/loaders/3MFLoader.js


+ 78 - 80
examples/jsm/loaders/AMFLoader.js

@@ -18,7 +18,7 @@ import * as fflate from '../libs/fflate.module.min.js';
  * More information about the AMF format: http://amf.wikispaces.com
  *
  * Usage:
- *	var loader = new AMFLoader();
+ *	const loader = new AMFLoader();
  *	loader.load('/path/to/project.amf', function(objecttree) {
  *		scene.add(objecttree);
  *	});
@@ -29,21 +29,19 @@ import * as fflate from '../libs/fflate.module.min.js';
  *
  */
 
-var AMFLoader = function ( manager ) {
+class AMFLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: AMFLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( scope.manager );
+		const loader = new FileLoader( scope.manager );
 		loader.setPath( scope.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( scope.requestHeader );
@@ -72,19 +70,19 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( data ) {
+	parse( data ) {
 
 		function loadDocument( data ) {
 
-			var view = new DataView( data );
-			var magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
+			let view = new DataView( data );
+			const magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
 
 			if ( magic === 'PK' ) {
 
-				var zip = null;
-				var file = null;
+				let zip = null;
+				let file = null;
 
 				console.log( 'THREE.AMFLoader: Loading Zip' );
 
@@ -103,7 +101,7 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				for ( var file in zip ) {
+				for ( file in zip ) {
 
 					if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
 
@@ -118,8 +116,8 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var fileText = LoaderUtils.decodeText( view );
-			var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
+			const fileText = LoaderUtils.decodeText( view );
+			const xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
 
 			if ( xmlData.documentElement.nodeName.toLowerCase() !== 'amf' ) {
 
@@ -134,8 +132,8 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadDocumentScale( node ) {
 
-			var scale = 1.0;
-			var unit = 'millimeter';
+			let scale = 1.0;
+			let unit = 'millimeter';
 
 			if ( node.documentElement.attributes.unit !== undefined ) {
 
@@ -143,7 +141,7 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var scaleUnits = {
+			const scaleUnits = {
 				millimeter: 1.0,
 				inch: 25.4,
 				feet: 304.8,
@@ -164,15 +162,15 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadMaterials( node ) {
 
-			var matName = 'AMF Material';
-			var matId = node.attributes.id.textContent;
-			var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
+			let matName = 'AMF Material';
+			const matId = node.attributes.id.textContent;
+			let color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
 
-			var loadedMaterial = null;
+			let loadedMaterial = null;
 
-			for ( var i = 0; i < node.childNodes.length; i ++ ) {
+			for ( let i = 0; i < node.childNodes.length; i ++ ) {
 
-				var matChildEl = node.childNodes[ i ];
+				const matChildEl = node.childNodes[ i ];
 
 				if ( matChildEl.nodeName === 'metadata' && matChildEl.attributes.type !== undefined ) {
 
@@ -209,11 +207,11 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadColor( node ) {
 
-			var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
+			const color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
 
-			for ( var i = 0; i < node.childNodes.length; i ++ ) {
+			for ( let i = 0; i < node.childNodes.length; i ++ ) {
 
-				var matColor = node.childNodes[ i ];
+				const matColor = node.childNodes[ i ];
 
 				if ( matColor.nodeName === 'r' ) {
 
@@ -241,9 +239,9 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadMeshVolume( node ) {
 
-			var volume = { name: '', triangles: [], materialid: null };
+			const volume = { name: '', triangles: [], materialid: null };
 
-			var currVolumeNode = node.firstElementChild;
+			let currVolumeNode = node.firstElementChild;
 
 			if ( node.attributes.materialid !== undefined ) {
 
@@ -267,9 +265,9 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				} else if ( currVolumeNode.nodeName === 'triangle' ) {
 
-					var v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
-					var v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
-					var v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
+					const v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
+					const v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
+					const v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
 
 					volume.triangles.push( v1, v2, v3 );
 
@@ -285,31 +283,31 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadMeshVertices( node ) {
 
-			var vertArray = [];
-			var normalArray = [];
-			var currVerticesNode = node.firstElementChild;
+			const vertArray = [];
+			const normalArray = [];
+			let currVerticesNode = node.firstElementChild;
 
 			while ( currVerticesNode ) {
 
 				if ( currVerticesNode.nodeName === 'vertex' ) {
 
-					var vNode = currVerticesNode.firstElementChild;
+					let vNode = currVerticesNode.firstElementChild;
 
 					while ( vNode ) {
 
 						if ( vNode.nodeName === 'coordinates' ) {
 
-							var x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
-							var y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
-							var z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
+							const x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
+							const y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
+							const z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
 
 							vertArray.push( x, y, z );
 
 						} else if ( vNode.nodeName === 'normal' ) {
 
-							var nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
-							var ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
-							var nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
+							const nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
+							const ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
+							const nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
 
 							normalArray.push( nx, ny, nz );
 
@@ -331,10 +329,10 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function loadObject( node ) {
 
-			var objId = node.attributes.id.textContent;
-			var loadedObject = { name: 'amfobject', meshes: [] };
-			var currColor = null;
-			var currObjNode = node.firstElementChild;
+			const objId = node.attributes.id.textContent;
+			const loadedObject = { name: 'amfobject', meshes: [] };
+			let currColor = null;
+			let currObjNode = node.firstElementChild;
 
 			while ( currObjNode ) {
 
@@ -356,14 +354,14 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				} else if ( currObjNode.nodeName === 'mesh' ) {
 
-					var currMeshNode = currObjNode.firstElementChild;
-					var mesh = { vertices: [], normals: [], volumes: [], color: currColor };
+					let currMeshNode = currObjNode.firstElementChild;
+					const mesh = { vertices: [], normals: [], volumes: [], color: currColor };
 
 					while ( currMeshNode ) {
 
 						if ( currMeshNode.nodeName === 'vertices' ) {
 
-							var loadedVertices = loadMeshVertices( currMeshNode );
+							const loadedVertices = loadMeshVertices( currMeshNode );
 
 							mesh.normals = mesh.normals.concat( loadedVertices.normals );
 							mesh.vertices = mesh.vertices.concat( loadedVertices.vertices );
@@ -390,19 +388,19 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-		var xmlData = loadDocument( data );
-		var amfName = '';
-		var amfAuthor = '';
-		var amfScale = loadDocumentScale( xmlData );
-		var amfMaterials = {};
-		var amfObjects = {};
-		var childNodes = xmlData.documentElement.childNodes;
+		const xmlData = loadDocument( data );
+		let amfName = '';
+		let amfAuthor = '';
+		const amfScale = loadDocumentScale( xmlData );
+		const amfMaterials = {};
+		const amfObjects = {};
+		const childNodes = xmlData.documentElement.childNodes;
 
-		var i, j;
+		let i, j;
 
 		for ( i = 0; i < childNodes.length; i ++ ) {
 
-			var child = childNodes[ i ];
+			const child = childNodes[ i ];
 
 			if ( child.nodeName === 'metadata' ) {
 
@@ -422,13 +420,13 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} else if ( child.nodeName === 'material' ) {
 
-				var loadedMaterial = loadMaterials( child );
+				const loadedMaterial = loadMaterials( child );
 
 				amfMaterials[ loadedMaterial.id ] = loadedMaterial.material;
 
 			} else if ( child.nodeName === 'object' ) {
 
-				var loadedObject = loadObject( child );
+				const loadedObject = loadObject( child );
 
 				amfObjects[ loadedObject.id ] = loadedObject.obj;
 
@@ -436,26 +434,26 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-		var sceneObject = new Group();
-		var defaultMaterial = new MeshPhongMaterial( { color: 0xaaaaff, flatShading: true } );
+		const sceneObject = new Group();
+		const defaultMaterial = new MeshPhongMaterial( { color: 0xaaaaff, flatShading: true } );
 
 		sceneObject.name = amfName;
 		sceneObject.userData.author = amfAuthor;
 		sceneObject.userData.loader = 'AMF';
 
-		for ( var id in amfObjects ) {
+		for ( const id in amfObjects ) {
 
-			var part = amfObjects[ id ];
-			var meshes = part.meshes;
-			var newObject = new Group();
+			const part = amfObjects[ id ];
+			const meshes = part.meshes;
+			const newObject = new Group();
 			newObject.name = part.name || '';
 
 			for ( i = 0; i < meshes.length; i ++ ) {
 
-				var objDefaultMaterial = defaultMaterial;
-				var mesh = meshes[ i ];
-				var vertices = new Float32BufferAttribute( mesh.vertices, 3 );
-				var normals = null;
+				let objDefaultMaterial = defaultMaterial;
+				const mesh = meshes[ i ];
+				const vertices = new Float32BufferAttribute( mesh.vertices, 3 );
+				let normals = null;
 
 				if ( mesh.normals.length ) {
 
@@ -465,7 +463,7 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				if ( mesh.color ) {
 
-					var color = mesh.color;
+					const color = mesh.color;
 
 					objDefaultMaterial = defaultMaterial.clone();
 					objDefaultMaterial.color = new Color( color.r, color.g, color.b );
@@ -479,13 +477,13 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				var volumes = mesh.volumes;
+				const volumes = mesh.volumes;
 
 				for ( j = 0; j < volumes.length; j ++ ) {
 
-					var volume = volumes[ j ];
-					var newGeometry = new BufferGeometry();
-					var material = objDefaultMaterial;
+					const volume = volumes[ j ];
+					const newGeometry = new BufferGeometry();
+					let material = objDefaultMaterial;
 
 					newGeometry.setIndex( volume.triangles );
 					newGeometry.setAttribute( 'position', vertices.clone() );
@@ -517,6 +515,6 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { AMFLoader };

+ 46 - 48
examples/jsm/loaders/BVHLoader.js

@@ -17,24 +17,22 @@ import {
  *
  */
 
-var BVHLoader = function ( manager ) {
+class BVHLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-	this.animateBonePositions = true;
-	this.animateBoneRotations = true;
+		super( manager );
 
-};
+		this.animateBonePositions = true;
+		this.animateBoneRotations = true;
 
-BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: BVHLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( scope.manager );
+		const loader = new FileLoader( scope.manager );
 		loader.setPath( scope.path );
 		loader.setRequestHeader( scope.requestHeader );
 		loader.setWithCredentials( scope.withCredentials );
@@ -62,9 +60,9 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( text ) {
+	parse( text ) {
 
 		/*
 			reads a string array (lines) from a BVH file
@@ -83,8 +81,8 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var list = []; // collects flat array of all bones
-			var root = readNode( lines, nextLine( lines ), list );
+			const list = []; // collects flat array of all bones
+			const root = readNode( lines, nextLine( lines ), list );
 
 			// read motion data
 
@@ -96,8 +94,8 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// number of frames
 
-			var tokens = nextLine( lines ).split( /[\s]+/ );
-			var numFrames = parseInt( tokens[ 1 ] );
+			let tokens = nextLine( lines ).split( /[\s]+/ );
+			const numFrames = parseInt( tokens[ 1 ] );
 
 			if ( isNaN( numFrames ) ) {
 
@@ -108,7 +106,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 			// frame time
 
 			tokens = nextLine( lines ).split( /[\s]+/ );
-			var frameTime = parseFloat( tokens[ 2 ] );
+			const frameTime = parseFloat( tokens[ 2 ] );
 
 			if ( isNaN( frameTime ) ) {
 
@@ -118,7 +116,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// read frame data line by line
 
-			for ( var i = 0; i < numFrames; i ++ ) {
+			for ( let i = 0; i < numFrames; i ++ ) {
 
 				tokens = nextLine( lines ).split( /[\s]+/ );
 				readFrameData( tokens, i * frameTime, root );
@@ -147,7 +145,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// add keyframe
 
-			var keyframe = {
+			const keyframe = {
 				time: frameTime,
 				position: new Vector3(),
 				rotation: new Quaternion()
@@ -155,15 +153,15 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			bone.frames.push( keyframe );
 
-			var quat = new Quaternion();
+			const quat = new Quaternion();
 
-			var vx = new Vector3( 1, 0, 0 );
-			var vy = new Vector3( 0, 1, 0 );
-			var vz = new Vector3( 0, 0, 1 );
+			const vx = new Vector3( 1, 0, 0 );
+			const vy = new Vector3( 0, 1, 0 );
+			const vz = new Vector3( 0, 0, 1 );
 
 			// parse values for each channel in node
 
-			for ( var i = 0; i < bone.channels.length; i ++ ) {
+			for ( let i = 0; i < bone.channels.length; i ++ ) {
 
 				switch ( bone.channels[ i ] ) {
 
@@ -197,7 +195,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// parse child nodes
 
-			for ( var i = 0; i < bone.children.length; i ++ ) {
+			for ( let i = 0; i < bone.children.length; i ++ ) {
 
 				readFrameData( data, frameTime, bone.children[ i ] );
 
@@ -216,12 +214,12 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		*/
 		function readNode( lines, firstline, list ) {
 
-			var node = { name: '', type: '', frames: [] };
+			const node = { name: '', type: '', frames: [] };
 			list.push( node );
 
 			// parse node type and name
 
-			var tokens = firstline.split( /[\s]+/ );
+			let tokens = firstline.split( /[\s]+/ );
 
 			if ( tokens[ 0 ].toUpperCase() === 'END' && tokens[ 1 ].toUpperCase() === 'SITE' ) {
 
@@ -257,7 +255,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var offset = new Vector3(
+			const offset = new Vector3(
 				parseFloat( tokens[ 1 ] ),
 				parseFloat( tokens[ 2 ] ),
 				parseFloat( tokens[ 3 ] )
@@ -283,7 +281,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				var numChannels = parseInt( tokens[ 1 ] );
+				const numChannels = parseInt( tokens[ 1 ] );
 				node.channels = tokens.splice( 2, numChannels );
 				node.children = [];
 
@@ -293,7 +291,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			while ( true ) {
 
-				var line = nextLine( lines );
+				const line = nextLine( lines );
 
 				if ( line === '}' ) {
 
@@ -319,7 +317,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		*/
 		function toTHREEBone( source, list ) {
 
-			var bone = new Bone();
+			const bone = new Bone();
 			list.push( bone );
 
 			bone.position.add( source.offset );
@@ -327,7 +325,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			if ( source.type !== 'ENDSITE' ) {
 
-				for ( var i = 0; i < source.children.length; i ++ ) {
+				for ( let i = 0; i < source.children.length; i ++ ) {
 
 					bone.add( toTHREEBone( source.children[ i ], list ) );
 
@@ -348,26 +346,26 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		*/
 		function toTHREEAnimation( bones ) {
 
-			var tracks = [];
+			const tracks = [];
 
 			// create a position and quaternion animation track for each node
 
-			for ( var i = 0; i < bones.length; i ++ ) {
+			for ( let i = 0; i < bones.length; i ++ ) {
 
-				var bone = bones[ i ];
+				const bone = bones[ i ];
 
 				if ( bone.type === 'ENDSITE' )
 					continue;
 
 				// track data
 
-				var times = [];
-				var positions = [];
-				var rotations = [];
+				const times = [];
+				const positions = [];
+				const rotations = [];
 
-				for ( var j = 0; j < bone.frames.length; j ++ ) {
+				for ( let j = 0; j < bone.frames.length; j ++ ) {
 
-					var frame = bone.frames[ j ];
+					const frame = bone.frames[ j ];
 
 					times.push( frame.time );
 
@@ -408,7 +406,7 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		*/
 		function nextLine( lines ) {
 
-			var line;
+			let line;
 			// skip empty lines
 			while ( ( line = lines.shift().trim() ).length === 0 ) { }
 
@@ -416,16 +414,16 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-		var scope = this;
+		const scope = this;
 
-		var lines = text.split( /[\r\n]+/g );
+		const lines = text.split( /[\r\n]+/g );
 
-		var bones = readBvh( lines );
+		const bones = readBvh( lines );
 
-		var threeBones = [];
+		const threeBones = [];
 		toTHREEBone( bones[ 0 ], threeBones );
 
-		var threeClip = toTHREEAnimation( bones );
+		const threeClip = toTHREEAnimation( bones );
 
 		return {
 			skeleton: new Skeleton( threeBones ),
@@ -434,6 +432,6 @@ BVHLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { BVHLoader };

+ 111 - 112
examples/jsm/loaders/BasisTextureLoader.js

@@ -29,45 +29,44 @@ import {
  * of web workers, before transferring the transcoded compressed texture back
  * to the main thread.
  */
-var BasisTextureLoader = function ( manager ) {
 
-	Loader.call( this, manager );
+const _taskCache = new WeakMap();
 
-	this.transcoderPath = '';
-	this.transcoderBinary = null;
-	this.transcoderPending = null;
+class BasisTextureLoader extends Loader {
 
-	this.workerLimit = 4;
-	this.workerPool = [];
-	this.workerNextTaskID = 1;
-	this.workerSourceURL = '';
-	this.workerConfig = null;
+	constructor( manager ) {
 
-};
+		super( manager );
 
-BasisTextureLoader.taskCache = new WeakMap();
+		this.transcoderPath = '';
+		this.transcoderBinary = null;
+		this.transcoderPending = null;
 
-BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
+		this.workerLimit = 4;
+		this.workerPool = [];
+		this.workerNextTaskID = 1;
+		this.workerSourceURL = '';
+		this.workerConfig = null;
 
-	constructor: BasisTextureLoader,
+	}
 
-	setTranscoderPath: function ( path ) {
+	setTranscoderPath( path ) {
 
 		this.transcoderPath = path;
 
 		return this;
 
-	},
+	}
 
-	setWorkerLimit: function ( workerLimit ) {
+	setWorkerLimit( workerLimit ) {
 
 		this.workerLimit = workerLimit;
 
 		return this;
 
-	},
+	}
 
-	detectSupport: function ( renderer ) {
+	detectSupport( renderer ) {
 
 		this.workerConfig = {
 			astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
@@ -81,24 +80,24 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		return this;
 
-	},
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 
 		loader.setResponseType( 'arraybuffer' );
 		loader.setWithCredentials( this.withCredentials );
 
-		var texture = new CompressedTexture();
+		const texture = new CompressedTexture();
 
 		loader.load( url, ( buffer ) => {
 
 			// Check for an existing task using this buffer. A transferred buffer cannot be transferred
 			// again from this thread.
-			if ( BasisTextureLoader.taskCache.has( buffer ) ) {
+			if ( _taskCache.has( buffer ) ) {
 
-				var cachedTask = BasisTextureLoader.taskCache.get( buffer );
+				const cachedTask = _taskCache.get( buffer );
 
 				return cachedTask.promise.then( onLoad ).catch( onError );
 
@@ -119,16 +118,16 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		return texture;
 
-	},
+	}
 
 	/** Low-level transcoding API, exposed for use by KTX2Loader. */
-	parseInternalAsync: function ( options ) {
+	parseInternalAsync( options ) {
 
-		var { levels } = options;
+		const { levels } = options;
 
-		var buffers = new Set();
+		const buffers = new Set();
 
-		for ( var i = 0; i < levels.length; i ++ ) {
+		for ( let i = 0; i < levels.length; i ++ ) {
 
 			buffers.add( levels[ i ].data.buffer );
 
@@ -136,28 +135,28 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		return this._createTexture( Array.from( buffers ), { ...options, lowLevel: true } );
 
-	},
+	}
 
 	/**
 	 * @param {ArrayBuffer[]} buffers
 	 * @param {object?} config
 	 * @return {Promise<CompressedTexture>}
 	 */
-	_createTexture: function ( buffers, config ) {
+	_createTexture( buffers, config = {} ) {
 
-		var worker;
-		var taskID;
+		let worker;
+		let taskID;
 
-		var taskConfig = config || {};
-		var taskCost = 0;
+		const taskConfig = config;
+		let taskCost = 0;
 
-		for ( var i = 0; i < buffers.length; i ++ ) {
+		for ( let i = 0; i < buffers.length; i ++ ) {
 
 			taskCost += buffers[ i ].byteLength;
 
 		}
 
-		var texturePending = this._allocateWorker( taskCost )
+		const texturePending = this._allocateWorker( taskCost )
 			.then( ( _worker ) => {
 
 				worker = _worker;
@@ -174,9 +173,9 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 			} )
 			.then( ( message ) => {
 
-				var { mipmaps, width, height, format } = message;
+				const { mipmaps, width, height, format } = message;
 
-				var texture = new CompressedTexture( mipmaps, width, height, format, UnsignedByteType );
+				const texture = new CompressedTexture( mipmaps, width, height, format, UnsignedByteType );
 				texture.minFilter = mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
 				texture.magFilter = LinearFilter;
 				texture.generateMipmaps = false;
@@ -201,32 +200,32 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 			} );
 
 		// Cache the task result.
-		BasisTextureLoader.taskCache.set( buffers[ 0 ], { promise: texturePending } );
+		_taskCache.set( buffers[ 0 ], { promise: texturePending } );
 
 		return texturePending;
 
-	},
+	}
 
-	_initTranscoder: function () {
+	_initTranscoder() {
 
 		if ( ! this.transcoderPending ) {
 
 			// Load transcoder wrapper.
-			var jsLoader = new FileLoader( this.manager );
+			const jsLoader = new FileLoader( this.manager );
 			jsLoader.setPath( this.transcoderPath );
 			jsLoader.setWithCredentials( this.withCredentials );
-			var jsContent = new Promise( ( resolve, reject ) => {
+			const jsContent = new Promise( ( resolve, reject ) => {
 
 				jsLoader.load( 'basis_transcoder.js', resolve, undefined, reject );
 
 			} );
 
 			// Load transcoder WASM binary.
-			var binaryLoader = new FileLoader( this.manager );
+			const binaryLoader = new FileLoader( this.manager );
 			binaryLoader.setPath( this.transcoderPath );
 			binaryLoader.setResponseType( 'arraybuffer' );
 			binaryLoader.setWithCredentials( this.withCredentials );
-			var binaryContent = new Promise( ( resolve, reject ) => {
+			const binaryContent = new Promise( ( resolve, reject ) => {
 
 				binaryLoader.load( 'basis_transcoder.wasm', resolve, undefined, reject );
 
@@ -235,13 +234,13 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 			this.transcoderPending = Promise.all( [ jsContent, binaryContent ] )
 				.then( ( [ jsContent, binaryContent ] ) => {
 
-					var fn = BasisTextureLoader.BasisWorker.toString();
+					const fn = BasisTextureLoader.BasisWorker.toString();
 
-					var body = [
+					const body = [
 						'/* constants */',
-						'var _EngineFormat = ' + JSON.stringify( BasisTextureLoader.EngineFormat ),
-						'var _TranscoderFormat = ' + JSON.stringify( BasisTextureLoader.TranscoderFormat ),
-						'var _BasisFormat = ' + JSON.stringify( BasisTextureLoader.BasisFormat ),
+						'let _EngineFormat = ' + JSON.stringify( BasisTextureLoader.EngineFormat ),
+						'let _TranscoderFormat = ' + JSON.stringify( BasisTextureLoader.TranscoderFormat ),
+						'let _BasisFormat = ' + JSON.stringify( BasisTextureLoader.BasisFormat ),
 						'/* basis_transcoder.js */',
 						jsContent,
 						'/* worker */',
@@ -257,15 +256,15 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		return this.transcoderPending;
 
-	},
+	}
 
-	_allocateWorker: function ( taskCost ) {
+	_allocateWorker( taskCost ) {
 
 		return this._initTranscoder().then( () => {
 
 			if ( this.workerPool.length < this.workerLimit ) {
 
-				var worker = new Worker( this.workerSourceURL );
+				const worker = new Worker( this.workerSourceURL );
 
 				worker._callbacks = {};
 				worker._taskLoad = 0;
@@ -278,7 +277,7 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 				worker.onmessage = function ( e ) {
 
-					var message = e.data;
+					const message = e.data;
 
 					switch ( message.type ) {
 
@@ -309,7 +308,7 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 			}
 
-			var worker = this.workerPool[ this.workerPool.length - 1 ];
+			const worker = this.workerPool[ this.workerPool.length - 1 ];
 
 			worker._taskLoad += taskCost;
 
@@ -317,11 +316,11 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		} );
 
-	},
+	}
 
-	dispose: function () {
+	dispose() {
 
-		for ( var i = 0; i < this.workerPool.length; i ++ ) {
+		for ( let i = 0; i < this.workerPool.length; i ++ ) {
 
 			this.workerPool[ i ].terminate();
 
@@ -333,7 +332,7 @@ BasisTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 	}
 
-} );
+}
 
 /* CONSTANTS */
 
@@ -380,17 +379,17 @@ BasisTextureLoader.EngineFormat = {
 
 BasisTextureLoader.BasisWorker = function () {
 
-	var config;
-	var transcoderPending;
-	var BasisModule;
+	let config;
+	let transcoderPending;
+	let BasisModule;
 
-	var EngineFormat = _EngineFormat; // eslint-disable-line no-undef
-	var TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
-	var BasisFormat = _BasisFormat; // eslint-disable-line no-undef
+	const EngineFormat = _EngineFormat; // eslint-disable-line no-undef
+	const TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
+	const BasisFormat = _BasisFormat; // eslint-disable-line no-undef
 
 	onmessage = function ( e ) {
 
-		var message = e.data;
+		const message = e.data;
 
 		switch ( message.type ) {
 
@@ -404,13 +403,13 @@ BasisTextureLoader.BasisWorker = function () {
 
 					try {
 
-						var { width, height, hasAlpha, mipmaps, format } = message.taskConfig.lowLevel
+						const { width, height, hasAlpha, mipmaps, format } = message.taskConfig.lowLevel
 							? transcodeLowLevel( message.taskConfig )
 							: transcode( message.buffers[ 0 ] );
 
-						var buffers = [];
+						const buffers = [];
 
-						for ( var i = 0; i < mipmaps.length; ++ i ) {
+						for ( let i = 0; i < mipmaps.length; ++ i ) {
 
 							buffers.push( mipmaps[ i ].data.buffer );
 
@@ -450,25 +449,25 @@ BasisTextureLoader.BasisWorker = function () {
 
 	function transcodeLowLevel( taskConfig ) {
 
-		var { basisFormat, width, height, hasAlpha } = taskConfig;
+		const { basisFormat, width, height, hasAlpha } = taskConfig;
 
-		var { transcoderFormat, engineFormat } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
+		const { transcoderFormat, engineFormat } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
 
-		var blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
+		const blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
 
 		assert( BasisModule.isFormatSupported( transcoderFormat ), 'THREE.BasisTextureLoader: Unsupported format.' );
 
-		var mipmaps = [];
+		const mipmaps = [];
 
 		if ( basisFormat === BasisFormat.ETC1S ) {
 
-			var transcoder = new BasisModule.LowLevelETC1SImageTranscoder();
+			const transcoder = new BasisModule.LowLevelETC1SImageTranscoder();
 
-			var { endpointCount, endpointsData, selectorCount, selectorsData, tablesData } = taskConfig.globalData;
+			const { endpointCount, endpointsData, selectorCount, selectorsData, tablesData } = taskConfig.globalData;
 
 			try {
 
-				var ok;
+				let ok;
 
 				ok = transcoder.decodePalettes( endpointCount, endpointsData, selectorCount, selectorsData );
 
@@ -478,13 +477,13 @@ BasisTextureLoader.BasisWorker = function () {
 
 				assert( ok, 'THREE.BasisTextureLoader: decodeTables() failed.' );
 
-				for ( var i = 0; i < taskConfig.levels.length; i ++ ) {
+				for ( let i = 0; i < taskConfig.levels.length; i ++ ) {
 
-					var level = taskConfig.levels[ i ];
-					var imageDesc = taskConfig.globalData.imageDescs[ i ];
+					const level = taskConfig.levels[ i ];
+					const imageDesc = taskConfig.globalData.imageDescs[ i ];
 
-					var dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
-					var dst = new Uint8Array( dstByteLength );
+					const dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
+					const dst = new Uint8Array( dstByteLength );
 
 					ok = transcoder.transcodeImage(
 						transcoderFormat,
@@ -515,14 +514,14 @@ BasisTextureLoader.BasisWorker = function () {
 
 		} else {
 
-			for ( var i = 0; i < taskConfig.levels.length; i ++ ) {
+			for ( let i = 0; i < taskConfig.levels.length; i ++ ) {
 
-				var level = taskConfig.levels[ i ];
+				const level = taskConfig.levels[ i ];
 
-				var dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
-				var dst = new Uint8Array( dstByteLength );
+				const dstByteLength = getTranscodedImageByteLength( transcoderFormat, level.width, level.height );
+				const dst = new Uint8Array( dstByteLength );
 
-				var ok = BasisModule.transcodeUASTCImage(
+				const ok = BasisModule.transcodeUASTCImage(
 					transcoderFormat,
 					dst, dstByteLength / blockByteLength,
 					level.data,
@@ -552,13 +551,13 @@ BasisTextureLoader.BasisWorker = function () {
 
 	function transcode( buffer ) {
 
-		var basisFile = new BasisModule.BasisFile( new Uint8Array( buffer ) );
+		const basisFile = new BasisModule.BasisFile( new Uint8Array( buffer ) );
 
-		var basisFormat = basisFile.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
-		var width = basisFile.getImageWidth( 0, 0 );
-		var height = basisFile.getImageHeight( 0, 0 );
-		var levels = basisFile.getNumLevels( 0 );
-		var hasAlpha = basisFile.getHasAlpha();
+		const basisFormat = basisFile.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
+		const width = basisFile.getImageWidth( 0, 0 );
+		const height = basisFile.getImageHeight( 0, 0 );
+		const levels = basisFile.getNumLevels( 0 );
+		const hasAlpha = basisFile.getHasAlpha();
 
 		function cleanup() {
 
@@ -567,7 +566,7 @@ BasisTextureLoader.BasisWorker = function () {
 
 		}
 
-		var { transcoderFormat, engineFormat } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
+		const { transcoderFormat, engineFormat } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
 
 		if ( ! width || ! height || ! levels ) {
 
@@ -583,15 +582,15 @@ BasisTextureLoader.BasisWorker = function () {
 
 		}
 
-		var mipmaps = [];
+		const mipmaps = [];
 
-		for ( var mip = 0; mip < levels; mip ++ ) {
+		for ( let mip = 0; mip < levels; mip ++ ) {
 
-			var mipWidth = basisFile.getImageWidth( 0, mip );
-			var mipHeight = basisFile.getImageHeight( 0, mip );
-			var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, transcoderFormat ) );
+			const mipWidth = basisFile.getImageWidth( 0, mip );
+			const mipHeight = basisFile.getImageHeight( 0, mip );
+			const dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, transcoderFormat ) );
 
-			var status = basisFile.transcodeImage(
+			const status = basisFile.transcodeImage(
 				dst,
 				0,
 				mip,
@@ -626,7 +625,7 @@ BasisTextureLoader.BasisWorker = function () {
 	// In some cases, transcoding UASTC to RGBA32 might be preferred for higher quality (at
 	// significant memory cost) compared to ETC1/2, BC1/3, and PVRTC. The transcoder currently
 	// chooses RGBA32 only as a last resort and does not expose that option to the caller.
-	var FORMAT_OPTIONS = [
+	const FORMAT_OPTIONS = [
 		{
 			if: 'astcSupported',
 			basisFormat: [ BasisFormat.UASTC_4x4 ],
@@ -683,12 +682,12 @@ BasisTextureLoader.BasisWorker = function () {
 		},
 	];
 
-	var ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
+	const ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
 
 		return a.priorityETC1S - b.priorityETC1S;
 
 	} );
-	var UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
+	const UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
 
 		return a.priorityUASTC - b.priorityUASTC;
 
@@ -696,14 +695,14 @@ BasisTextureLoader.BasisWorker = function () {
 
 	function getTranscoderFormat( basisFormat, width, height, hasAlpha ) {
 
-		var transcoderFormat;
-		var engineFormat;
+		let transcoderFormat;
+		let engineFormat;
 
-		var options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
+		const options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
 
-		for ( var i = 0; i < options.length; i ++ ) {
+		for ( let i = 0; i < options.length; i ++ ) {
 
-			var opt = options[ i ];
+			const opt = options[ i ];
 
 			if ( ! config[ opt.if ] ) continue;
 			if ( ! opt.basisFormat.includes( basisFormat ) ) continue;
@@ -745,7 +744,7 @@ BasisTextureLoader.BasisWorker = function () {
 
 	function getTranscodedImageByteLength( transcoderFormat, width, height ) {
 
-		var blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
+		const blockByteLength = BasisModule.getBytesPerBlockOrPixel( transcoderFormat );
 
 		if ( BasisModule.formatIsUncompressed( transcoderFormat ) ) {
 
@@ -758,8 +757,8 @@ BasisTextureLoader.BasisWorker = function () {
 
 			// GL requires extra padding for very small textures:
 			// https://www.khronos.org/registry/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
-			var paddedWidth = ( width + 3 ) & ~ 3;
-			var paddedHeight = ( height + 3 ) & ~ 3;
+			const paddedWidth = ( width + 3 ) & ~ 3;
+			const paddedHeight = ( height + 3 ) & ~ 3;
 
 			return ( Math.max( 8, paddedWidth ) * Math.max( 8, paddedHeight ) * 4 + 7 ) / 8;
 

File diff ditekan karena terlalu besar
+ 206 - 218
examples/jsm/loaders/ColladaLoader.js


+ 88 - 88
examples/jsm/loaders/DDSLoader.js

@@ -7,19 +7,17 @@ import {
 	RGB_S3TC_DXT1_Format
 } from '../../../build/three.module.js';
 
-var DDSLoader = function ( manager ) {
+class DDSLoader extends CompressedTextureLoader {
 
-	CompressedTextureLoader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prototype ), {
-
-	constructor: DDSLoader,
+	}
 
-	parse: function ( buffer, loadMipmaps ) {
+	parse( buffer, loadMipmaps ) {
 
-		var dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 };
+		const dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 };
 
 		// Adapted from @toji's DDS utils
 		// https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js
@@ -27,36 +25,36 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 		// All values and structures referenced from:
 		// http://msdn.microsoft.com/en-us/library/bb943991.aspx/
 
-		var DDS_MAGIC = 0x20534444;
-
-		// var DDSD_CAPS = 0x1;
-		// var DDSD_HEIGHT = 0x2;
-		// var DDSD_WIDTH = 0x4;
-		// var DDSD_PITCH = 0x8;
-		// var DDSD_PIXELFORMAT = 0x1000;
-		var DDSD_MIPMAPCOUNT = 0x20000;
-		// var DDSD_LINEARSIZE = 0x80000;
-		// var DDSD_DEPTH = 0x800000;
-
-		// var DDSCAPS_COMPLEX = 0x8;
-		// var DDSCAPS_MIPMAP = 0x400000;
-		// var DDSCAPS_TEXTURE = 0x1000;
-
-		var DDSCAPS2_CUBEMAP = 0x200;
-		var DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
-		var DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
-		var DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
-		var DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
-		var DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
-		var DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
-		// var DDSCAPS2_VOLUME = 0x200000;
-
-		// var DDPF_ALPHAPIXELS = 0x1;
-		// var DDPF_ALPHA = 0x2;
-		var DDPF_FOURCC = 0x4;
-		// var DDPF_RGB = 0x40;
-		// var DDPF_YUV = 0x200;
-		// var DDPF_LUMINANCE = 0x20000;
+		const DDS_MAGIC = 0x20534444;
+
+		// let DDSD_CAPS = 0x1;
+		// let DDSD_HEIGHT = 0x2;
+		// let DDSD_WIDTH = 0x4;
+		// let DDSD_PITCH = 0x8;
+		// let DDSD_PIXELFORMAT = 0x1000;
+		const DDSD_MIPMAPCOUNT = 0x20000;
+		// let DDSD_LINEARSIZE = 0x80000;
+		// let DDSD_DEPTH = 0x800000;
+
+		// let DDSCAPS_COMPLEX = 0x8;
+		// let DDSCAPS_MIPMAP = 0x400000;
+		// let DDSCAPS_TEXTURE = 0x1000;
+
+		const DDSCAPS2_CUBEMAP = 0x200;
+		const DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
+		const DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
+		const DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
+		const DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
+		const DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
+		const DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
+		// let DDSCAPS2_VOLUME = 0x200000;
+
+		// let DDPF_ALPHAPIXELS = 0x1;
+		// let DDPF_ALPHA = 0x2;
+		const DDPF_FOURCC = 0x4;
+		// let DDPF_RGB = 0x40;
+		// let DDPF_YUV = 0x200;
+		// let DDPF_LUMINANCE = 0x20000;
 
 		function fourCCToInt32( value ) {
 
@@ -80,19 +78,19 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 		function loadARGBMip( buffer, dataOffset, width, height ) {
 
-			var dataLength = width * height * 4;
-			var srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
-			var byteArray = new Uint8Array( dataLength );
-			var dst = 0;
-			var src = 0;
-			for ( var y = 0; y < height; y ++ ) {
+			const dataLength = width * height * 4;
+			const srcBuffer = new Uint8Array( buffer, dataOffset, dataLength );
+			const byteArray = new Uint8Array( dataLength );
+			let dst = 0;
+			let src = 0;
+			for ( let y = 0; y < height; y ++ ) {
 
-				for ( var x = 0; x < width; x ++ ) {
+				for ( let x = 0; x < width; x ++ ) {
 
-					var b = srcBuffer[ src ]; src ++;
-					var g = srcBuffer[ src ]; src ++;
-					var r = srcBuffer[ src ]; src ++;
-					var a = srcBuffer[ src ]; src ++;
+					const b = srcBuffer[ src ]; src ++;
+					const g = srcBuffer[ src ]; src ++;
+					const r = srcBuffer[ src ]; src ++;
+					const a = srcBuffer[ src ]; src ++;
 					byteArray[ dst ] = r; dst ++;	//r
 					byteArray[ dst ] = g; dst ++;	//g
 					byteArray[ dst ] = b; dst ++;	//b
@@ -106,40 +104,40 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 		}
 
-		var FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
-		var FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
-		var FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
-		var FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
+		const FOURCC_DXT1 = fourCCToInt32( 'DXT1' );
+		const FOURCC_DXT3 = fourCCToInt32( 'DXT3' );
+		const FOURCC_DXT5 = fourCCToInt32( 'DXT5' );
+		const FOURCC_ETC1 = fourCCToInt32( 'ETC1' );
 
-		var headerLengthInt = 31; // The header length in 32 bit ints
+		const headerLengthInt = 31; // The header length in 32 bit ints
 
 		// Offsets into the header array
 
-		var off_magic = 0;
+		const off_magic = 0;
 
-		var off_size = 1;
-		var off_flags = 2;
-		var off_height = 3;
-		var off_width = 4;
+		const off_size = 1;
+		const off_flags = 2;
+		const off_height = 3;
+		const off_width = 4;
 
-		var off_mipmapCount = 7;
+		const off_mipmapCount = 7;
 
-		var off_pfFlags = 20;
-		var off_pfFourCC = 21;
-		var off_RGBBitCount = 22;
-		var off_RBitMask = 23;
-		var off_GBitMask = 24;
-		var off_BBitMask = 25;
-		var off_ABitMask = 26;
+		const off_pfFlags = 20;
+		const off_pfFourCC = 21;
+		const off_RGBBitCount = 22;
+		const off_RBitMask = 23;
+		const off_GBitMask = 24;
+		const off_BBitMask = 25;
+		const off_ABitMask = 26;
 
-		// var off_caps = 27;
-		var off_caps2 = 28;
-		// var off_caps3 = 29;
-		// var off_caps4 = 30;
+		// let off_caps = 27;
+		const off_caps2 = 28;
+		// let off_caps3 = 29;
+		// let off_caps4 = 30;
 
 		// Parse header
 
-		var header = new Int32Array( buffer, 0, headerLengthInt );
+		const header = new Int32Array( buffer, 0, headerLengthInt );
 
 		if ( header[ off_magic ] !== DDS_MAGIC ) {
 
@@ -155,11 +153,11 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 		}
 
-		var blockBytes;
+		let blockBytes;
 
-		var fourCC = header[ off_pfFourCC ];
+		const fourCC = header[ off_pfFourCC ];
 
-		var isRGBAUncompressed = false;
+		let isRGBAUncompressed = false;
 
 		switch ( fourCC ) {
 
@@ -216,7 +214,7 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 		}
 
-		var caps2 = header[ off_caps2 ];
+		const caps2 = header[ off_caps2 ];
 		dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false;
 		if ( dds.isCubemap && (
 			! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) ||
@@ -235,32 +233,34 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 		dds.width = header[ off_width ];
 		dds.height = header[ off_height ];
 
-		var dataOffset = header[ off_size ] + 4;
+		let dataOffset = header[ off_size ] + 4;
 
 		// Extract mipmaps buffers
 
-		var faces = dds.isCubemap ? 6 : 1;
+		const faces = dds.isCubemap ? 6 : 1;
+
+		for ( let face = 0; face < faces; face ++ ) {
 
-		for ( var face = 0; face < faces; face ++ ) {
+			let width = dds.width;
+			let height = dds.height;
 
-			var width = dds.width;
-			var height = dds.height;
+			for ( let i = 0; i < dds.mipmapCount; i ++ ) {
 
-			for ( var i = 0; i < dds.mipmapCount; i ++ ) {
+				let byteArray, dataLength;
 
 				if ( isRGBAUncompressed ) {
 
-					var byteArray = loadARGBMip( buffer, dataOffset, width, height );
-					var dataLength = byteArray.length;
+					byteArray = loadARGBMip( buffer, dataOffset, width, height );
+					dataLength = byteArray.length;
 
 				} else {
 
-					var dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
-					var byteArray = new Uint8Array( buffer, dataOffset, dataLength );
+					dataLength = Math.max( 4, width ) / 4 * Math.max( 4, height ) / 4 * blockBytes;
+					byteArray = new Uint8Array( buffer, dataOffset, dataLength );
 
 				}
 
-				var mipmap = { 'data': byteArray, 'width': width, 'height': height };
+				const mipmap = { 'data': byteArray, 'width': width, 'height': height };
 				dds.mipmaps.push( mipmap );
 
 				dataOffset += dataLength;
@@ -276,6 +276,6 @@ DDSLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 	}
 
-} );
+}
 
 export { DDSLoader };

+ 21 - 23
examples/jsm/loaders/KMZLoader.js

@@ -7,21 +7,19 @@ import {
 import { ColladaLoader } from '../loaders/ColladaLoader.js';
 import * as fflate from '../libs/fflate.module.min.js';
 
-var KMZLoader = function ( manager ) {
+class KMZLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: KMZLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( scope.manager );
+		const loader = new FileLoader( scope.manager );
 		loader.setPath( scope.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( scope.requestHeader );
@@ -50,13 +48,13 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( data ) {
+	parse( data ) {
 
 		function findFile( url ) {
 
-			for ( var path in zip ) {
+			for ( const path in zip ) {
 
 				if ( path.substr( - url.length ) === url ) {
 
@@ -68,16 +66,16 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-		var manager = new LoadingManager();
+		const manager = new LoadingManager();
 		manager.setURLModifier( function ( url ) {
 
-			var image = findFile( url );
+			const image = findFile( url );
 
 			if ( image ) {
 
 				console.log( 'Loading', url );
 
-				var blob = new Blob( [ image.buffer ], { type: 'application/octet-stream' } );
+				const blob = new Blob( [ image.buffer ], { type: 'application/octet-stream' } );
 				return URL.createObjectURL( blob );
 
 			}
@@ -88,17 +86,17 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		//
 
-		var zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
+		const zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
 
 		if ( zip[ 'doc.kml' ] ) {
 
-			var xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
+			const xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
 
-			var model = xml.querySelector( 'Placemark Model Link href' );
+			const model = xml.querySelector( 'Placemark Model Link href' );
 
 			if ( model ) {
 
-				var loader = new ColladaLoader( manager );
+				const loader = new ColladaLoader( manager );
 				return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); // eslint-disable-line no-undef
 
 			}
@@ -107,13 +105,13 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			console.warn( 'KMZLoader: Missing doc.kml file.' );
 
-			for ( var path in zip ) {
+			for ( const path in zip ) {
 
-				var extension = path.split( '.' ).pop().toLowerCase();
+				const extension = path.split( '.' ).pop().toLowerCase();
 
 				if ( extension === 'dae' ) {
 
-					var loader = new ColladaLoader( manager );
+					const loader = new ColladaLoader( manager );
 					return loader.parse( fflate.strFromU8( zip[ path ] ) ); // eslint-disable-line no-undef
 
 				}
@@ -127,6 +125,6 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { KMZLoader };

+ 259 - 265
examples/jsm/loaders/MD2Loader.js

@@ -7,21 +7,103 @@ import {
 	Vector3
 } from '../../../build/three.module.js';
 
-var MD2Loader = function ( manager ) {
-
-	Loader.call( this, manager );
-
-};
-
-MD2Loader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: MD2Loader,
-
-	load: function ( url, onLoad, onProgress, onError ) {
-
-		var scope = this;
-
-		var loader = new FileLoader( scope.manager );
+const _normalData = [
+	[ - 0.525731, 0.000000, 0.850651 ], [ - 0.442863, 0.238856, 0.864188 ],
+	[ - 0.295242, 0.000000, 0.955423 ], [ - 0.309017, 0.500000, 0.809017 ],
+	[ - 0.162460, 0.262866, 0.951056 ], [ 0.000000, 0.000000, 1.000000 ],
+	[ 0.000000, 0.850651, 0.525731 ], [ - 0.147621, 0.716567, 0.681718 ],
+	[ 0.147621, 0.716567, 0.681718 ], [ 0.000000, 0.525731, 0.850651 ],
+	[ 0.309017, 0.500000, 0.809017 ], [ 0.525731, 0.000000, 0.850651 ],
+	[ 0.295242, 0.000000, 0.955423 ], [ 0.442863, 0.238856, 0.864188 ],
+	[ 0.162460, 0.262866, 0.951056 ], [ - 0.681718, 0.147621, 0.716567 ],
+	[ - 0.809017, 0.309017, 0.500000 ], [ - 0.587785, 0.425325, 0.688191 ],
+	[ - 0.850651, 0.525731, 0.000000 ], [ - 0.864188, 0.442863, 0.238856 ],
+	[ - 0.716567, 0.681718, 0.147621 ], [ - 0.688191, 0.587785, 0.425325 ],
+	[ - 0.500000, 0.809017, 0.309017 ], [ - 0.238856, 0.864188, 0.442863 ],
+	[ - 0.425325, 0.688191, 0.587785 ], [ - 0.716567, 0.681718, - 0.147621 ],
+	[ - 0.500000, 0.809017, - 0.309017 ], [ - 0.525731, 0.850651, 0.000000 ],
+	[ 0.000000, 0.850651, - 0.525731 ], [ - 0.238856, 0.864188, - 0.442863 ],
+	[ 0.000000, 0.955423, - 0.295242 ], [ - 0.262866, 0.951056, - 0.162460 ],
+	[ 0.000000, 1.000000, 0.000000 ], [ 0.000000, 0.955423, 0.295242 ],
+	[ - 0.262866, 0.951056, 0.162460 ], [ 0.238856, 0.864188, 0.442863 ],
+	[ 0.262866, 0.951056, 0.162460 ], [ 0.500000, 0.809017, 0.309017 ],
+	[ 0.238856, 0.864188, - 0.442863 ], [ 0.262866, 0.951056, - 0.162460 ],
+	[ 0.500000, 0.809017, - 0.309017 ], [ 0.850651, 0.525731, 0.000000 ],
+	[ 0.716567, 0.681718, 0.147621 ], [ 0.716567, 0.681718, - 0.147621 ],
+	[ 0.525731, 0.850651, 0.000000 ], [ 0.425325, 0.688191, 0.587785 ],
+	[ 0.864188, 0.442863, 0.238856 ], [ 0.688191, 0.587785, 0.425325 ],
+	[ 0.809017, 0.309017, 0.500000 ], [ 0.681718, 0.147621, 0.716567 ],
+	[ 0.587785, 0.425325, 0.688191 ], [ 0.955423, 0.295242, 0.000000 ],
+	[ 1.000000, 0.000000, 0.000000 ], [ 0.951056, 0.162460, 0.262866 ],
+	[ 0.850651, - 0.525731, 0.000000 ], [ 0.955423, - 0.295242, 0.000000 ],
+	[ 0.864188, - 0.442863, 0.238856 ], [ 0.951056, - 0.162460, 0.262866 ],
+	[ 0.809017, - 0.309017, 0.500000 ], [ 0.681718, - 0.147621, 0.716567 ],
+	[ 0.850651, 0.000000, 0.525731 ], [ 0.864188, 0.442863, - 0.238856 ],
+	[ 0.809017, 0.309017, - 0.500000 ], [ 0.951056, 0.162460, - 0.262866 ],
+	[ 0.525731, 0.000000, - 0.850651 ], [ 0.681718, 0.147621, - 0.716567 ],
+	[ 0.681718, - 0.147621, - 0.716567 ], [ 0.850651, 0.000000, - 0.525731 ],
+	[ 0.809017, - 0.309017, - 0.500000 ], [ 0.864188, - 0.442863, - 0.238856 ],
+	[ 0.951056, - 0.162460, - 0.262866 ], [ 0.147621, 0.716567, - 0.681718 ],
+	[ 0.309017, 0.500000, - 0.809017 ], [ 0.425325, 0.688191, - 0.587785 ],
+	[ 0.442863, 0.238856, - 0.864188 ], [ 0.587785, 0.425325, - 0.688191 ],
+	[ 0.688191, 0.587785, - 0.425325 ], [ - 0.147621, 0.716567, - 0.681718 ],
+	[ - 0.309017, 0.500000, - 0.809017 ], [ 0.000000, 0.525731, - 0.850651 ],
+	[ - 0.525731, 0.000000, - 0.850651 ], [ - 0.442863, 0.238856, - 0.864188 ],
+	[ - 0.295242, 0.000000, - 0.955423 ], [ - 0.162460, 0.262866, - 0.951056 ],
+	[ 0.000000, 0.000000, - 1.000000 ], [ 0.295242, 0.000000, - 0.955423 ],
+	[ 0.162460, 0.262866, - 0.951056 ], [ - 0.442863, - 0.238856, - 0.864188 ],
+	[ - 0.309017, - 0.500000, - 0.809017 ], [ - 0.162460, - 0.262866, - 0.951056 ],
+	[ 0.000000, - 0.850651, - 0.525731 ], [ - 0.147621, - 0.716567, - 0.681718 ],
+	[ 0.147621, - 0.716567, - 0.681718 ], [ 0.000000, - 0.525731, - 0.850651 ],
+	[ 0.309017, - 0.500000, - 0.809017 ], [ 0.442863, - 0.238856, - 0.864188 ],
+	[ 0.162460, - 0.262866, - 0.951056 ], [ 0.238856, - 0.864188, - 0.442863 ],
+	[ 0.500000, - 0.809017, - 0.309017 ], [ 0.425325, - 0.688191, - 0.587785 ],
+	[ 0.716567, - 0.681718, - 0.147621 ], [ 0.688191, - 0.587785, - 0.425325 ],
+	[ 0.587785, - 0.425325, - 0.688191 ], [ 0.000000, - 0.955423, - 0.295242 ],
+	[ 0.000000, - 1.000000, 0.000000 ], [ 0.262866, - 0.951056, - 0.162460 ],
+	[ 0.000000, - 0.850651, 0.525731 ], [ 0.000000, - 0.955423, 0.295242 ],
+	[ 0.238856, - 0.864188, 0.442863 ], [ 0.262866, - 0.951056, 0.162460 ],
+	[ 0.500000, - 0.809017, 0.309017 ], [ 0.716567, - 0.681718, 0.147621 ],
+	[ 0.525731, - 0.850651, 0.000000 ], [ - 0.238856, - 0.864188, - 0.442863 ],
+	[ - 0.500000, - 0.809017, - 0.309017 ], [ - 0.262866, - 0.951056, - 0.162460 ],
+	[ - 0.850651, - 0.525731, 0.000000 ], [ - 0.716567, - 0.681718, - 0.147621 ],
+	[ - 0.716567, - 0.681718, 0.147621 ], [ - 0.525731, - 0.850651, 0.000000 ],
+	[ - 0.500000, - 0.809017, 0.309017 ], [ - 0.238856, - 0.864188, 0.442863 ],
+	[ - 0.262866, - 0.951056, 0.162460 ], [ - 0.864188, - 0.442863, 0.238856 ],
+	[ - 0.809017, - 0.309017, 0.500000 ], [ - 0.688191, - 0.587785, 0.425325 ],
+	[ - 0.681718, - 0.147621, 0.716567 ], [ - 0.442863, - 0.238856, 0.864188 ],
+	[ - 0.587785, - 0.425325, 0.688191 ], [ - 0.309017, - 0.500000, 0.809017 ],
+	[ - 0.147621, - 0.716567, 0.681718 ], [ - 0.425325, - 0.688191, 0.587785 ],
+	[ - 0.162460, - 0.262866, 0.951056 ], [ 0.442863, - 0.238856, 0.864188 ],
+	[ 0.162460, - 0.262866, 0.951056 ], [ 0.309017, - 0.500000, 0.809017 ],
+	[ 0.147621, - 0.716567, 0.681718 ], [ 0.000000, - 0.525731, 0.850651 ],
+	[ 0.425325, - 0.688191, 0.587785 ], [ 0.587785, - 0.425325, 0.688191 ],
+	[ 0.688191, - 0.587785, 0.425325 ], [ - 0.955423, 0.295242, 0.000000 ],
+	[ - 0.951056, 0.162460, 0.262866 ], [ - 1.000000, 0.000000, 0.000000 ],
+	[ - 0.850651, 0.000000, 0.525731 ], [ - 0.955423, - 0.295242, 0.000000 ],
+	[ - 0.951056, - 0.162460, 0.262866 ], [ - 0.864188, 0.442863, - 0.238856 ],
+	[ - 0.951056, 0.162460, - 0.262866 ], [ - 0.809017, 0.309017, - 0.500000 ],
+	[ - 0.864188, - 0.442863, - 0.238856 ], [ - 0.951056, - 0.162460, - 0.262866 ],
+	[ - 0.809017, - 0.309017, - 0.500000 ], [ - 0.681718, 0.147621, - 0.716567 ],
+	[ - 0.681718, - 0.147621, - 0.716567 ], [ - 0.850651, 0.000000, - 0.525731 ],
+	[ - 0.688191, 0.587785, - 0.425325 ], [ - 0.587785, 0.425325, - 0.688191 ],
+	[ - 0.425325, 0.688191, - 0.587785 ], [ - 0.425325, - 0.688191, - 0.587785 ],
+	[ - 0.587785, - 0.425325, - 0.688191 ], [ - 0.688191, - 0.587785, - 0.425325 ]
+];
+
+class MD2Loader extends Loader {
+
+	constructor( manager ) {
+
+		super( manager );
+
+	}
+
+	load( url, onLoad, onProgress, onError ) {
+
+		const scope = this;
+
+		const loader = new FileLoader( scope.manager );
 		loader.setPath( scope.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( scope.requestHeader );
@@ -50,355 +132,267 @@ MD2Loader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
-
-	parse: ( function () {
-
-		var normalData = [
-			[ - 0.525731, 0.000000, 0.850651 ], [ - 0.442863, 0.238856, 0.864188 ],
-			[ - 0.295242, 0.000000, 0.955423 ], [ - 0.309017, 0.500000, 0.809017 ],
-			[ - 0.162460, 0.262866, 0.951056 ], [ 0.000000, 0.000000, 1.000000 ],
-			[ 0.000000, 0.850651, 0.525731 ], [ - 0.147621, 0.716567, 0.681718 ],
-			[ 0.147621, 0.716567, 0.681718 ], [ 0.000000, 0.525731, 0.850651 ],
-			[ 0.309017, 0.500000, 0.809017 ], [ 0.525731, 0.000000, 0.850651 ],
-			[ 0.295242, 0.000000, 0.955423 ], [ 0.442863, 0.238856, 0.864188 ],
-			[ 0.162460, 0.262866, 0.951056 ], [ - 0.681718, 0.147621, 0.716567 ],
-			[ - 0.809017, 0.309017, 0.500000 ], [ - 0.587785, 0.425325, 0.688191 ],
-			[ - 0.850651, 0.525731, 0.000000 ], [ - 0.864188, 0.442863, 0.238856 ],
-			[ - 0.716567, 0.681718, 0.147621 ], [ - 0.688191, 0.587785, 0.425325 ],
-			[ - 0.500000, 0.809017, 0.309017 ], [ - 0.238856, 0.864188, 0.442863 ],
-			[ - 0.425325, 0.688191, 0.587785 ], [ - 0.716567, 0.681718, - 0.147621 ],
-			[ - 0.500000, 0.809017, - 0.309017 ], [ - 0.525731, 0.850651, 0.000000 ],
-			[ 0.000000, 0.850651, - 0.525731 ], [ - 0.238856, 0.864188, - 0.442863 ],
-			[ 0.000000, 0.955423, - 0.295242 ], [ - 0.262866, 0.951056, - 0.162460 ],
-			[ 0.000000, 1.000000, 0.000000 ], [ 0.000000, 0.955423, 0.295242 ],
-			[ - 0.262866, 0.951056, 0.162460 ], [ 0.238856, 0.864188, 0.442863 ],
-			[ 0.262866, 0.951056, 0.162460 ], [ 0.500000, 0.809017, 0.309017 ],
-			[ 0.238856, 0.864188, - 0.442863 ], [ 0.262866, 0.951056, - 0.162460 ],
-			[ 0.500000, 0.809017, - 0.309017 ], [ 0.850651, 0.525731, 0.000000 ],
-			[ 0.716567, 0.681718, 0.147621 ], [ 0.716567, 0.681718, - 0.147621 ],
-			[ 0.525731, 0.850651, 0.000000 ], [ 0.425325, 0.688191, 0.587785 ],
-			[ 0.864188, 0.442863, 0.238856 ], [ 0.688191, 0.587785, 0.425325 ],
-			[ 0.809017, 0.309017, 0.500000 ], [ 0.681718, 0.147621, 0.716567 ],
-			[ 0.587785, 0.425325, 0.688191 ], [ 0.955423, 0.295242, 0.000000 ],
-			[ 1.000000, 0.000000, 0.000000 ], [ 0.951056, 0.162460, 0.262866 ],
-			[ 0.850651, - 0.525731, 0.000000 ], [ 0.955423, - 0.295242, 0.000000 ],
-			[ 0.864188, - 0.442863, 0.238856 ], [ 0.951056, - 0.162460, 0.262866 ],
-			[ 0.809017, - 0.309017, 0.500000 ], [ 0.681718, - 0.147621, 0.716567 ],
-			[ 0.850651, 0.000000, 0.525731 ], [ 0.864188, 0.442863, - 0.238856 ],
-			[ 0.809017, 0.309017, - 0.500000 ], [ 0.951056, 0.162460, - 0.262866 ],
-			[ 0.525731, 0.000000, - 0.850651 ], [ 0.681718, 0.147621, - 0.716567 ],
-			[ 0.681718, - 0.147621, - 0.716567 ], [ 0.850651, 0.000000, - 0.525731 ],
-			[ 0.809017, - 0.309017, - 0.500000 ], [ 0.864188, - 0.442863, - 0.238856 ],
-			[ 0.951056, - 0.162460, - 0.262866 ], [ 0.147621, 0.716567, - 0.681718 ],
-			[ 0.309017, 0.500000, - 0.809017 ], [ 0.425325, 0.688191, - 0.587785 ],
-			[ 0.442863, 0.238856, - 0.864188 ], [ 0.587785, 0.425325, - 0.688191 ],
-			[ 0.688191, 0.587785, - 0.425325 ], [ - 0.147621, 0.716567, - 0.681718 ],
-			[ - 0.309017, 0.500000, - 0.809017 ], [ 0.000000, 0.525731, - 0.850651 ],
-			[ - 0.525731, 0.000000, - 0.850651 ], [ - 0.442863, 0.238856, - 0.864188 ],
-			[ - 0.295242, 0.000000, - 0.955423 ], [ - 0.162460, 0.262866, - 0.951056 ],
-			[ 0.000000, 0.000000, - 1.000000 ], [ 0.295242, 0.000000, - 0.955423 ],
-			[ 0.162460, 0.262866, - 0.951056 ], [ - 0.442863, - 0.238856, - 0.864188 ],
-			[ - 0.309017, - 0.500000, - 0.809017 ], [ - 0.162460, - 0.262866, - 0.951056 ],
-			[ 0.000000, - 0.850651, - 0.525731 ], [ - 0.147621, - 0.716567, - 0.681718 ],
-			[ 0.147621, - 0.716567, - 0.681718 ], [ 0.000000, - 0.525731, - 0.850651 ],
-			[ 0.309017, - 0.500000, - 0.809017 ], [ 0.442863, - 0.238856, - 0.864188 ],
-			[ 0.162460, - 0.262866, - 0.951056 ], [ 0.238856, - 0.864188, - 0.442863 ],
-			[ 0.500000, - 0.809017, - 0.309017 ], [ 0.425325, - 0.688191, - 0.587785 ],
-			[ 0.716567, - 0.681718, - 0.147621 ], [ 0.688191, - 0.587785, - 0.425325 ],
-			[ 0.587785, - 0.425325, - 0.688191 ], [ 0.000000, - 0.955423, - 0.295242 ],
-			[ 0.000000, - 1.000000, 0.000000 ], [ 0.262866, - 0.951056, - 0.162460 ],
-			[ 0.000000, - 0.850651, 0.525731 ], [ 0.000000, - 0.955423, 0.295242 ],
-			[ 0.238856, - 0.864188, 0.442863 ], [ 0.262866, - 0.951056, 0.162460 ],
-			[ 0.500000, - 0.809017, 0.309017 ], [ 0.716567, - 0.681718, 0.147621 ],
-			[ 0.525731, - 0.850651, 0.000000 ], [ - 0.238856, - 0.864188, - 0.442863 ],
-			[ - 0.500000, - 0.809017, - 0.309017 ], [ - 0.262866, - 0.951056, - 0.162460 ],
-			[ - 0.850651, - 0.525731, 0.000000 ], [ - 0.716567, - 0.681718, - 0.147621 ],
-			[ - 0.716567, - 0.681718, 0.147621 ], [ - 0.525731, - 0.850651, 0.000000 ],
-			[ - 0.500000, - 0.809017, 0.309017 ], [ - 0.238856, - 0.864188, 0.442863 ],
-			[ - 0.262866, - 0.951056, 0.162460 ], [ - 0.864188, - 0.442863, 0.238856 ],
-			[ - 0.809017, - 0.309017, 0.500000 ], [ - 0.688191, - 0.587785, 0.425325 ],
-			[ - 0.681718, - 0.147621, 0.716567 ], [ - 0.442863, - 0.238856, 0.864188 ],
-			[ - 0.587785, - 0.425325, 0.688191 ], [ - 0.309017, - 0.500000, 0.809017 ],
-			[ - 0.147621, - 0.716567, 0.681718 ], [ - 0.425325, - 0.688191, 0.587785 ],
-			[ - 0.162460, - 0.262866, 0.951056 ], [ 0.442863, - 0.238856, 0.864188 ],
-			[ 0.162460, - 0.262866, 0.951056 ], [ 0.309017, - 0.500000, 0.809017 ],
-			[ 0.147621, - 0.716567, 0.681718 ], [ 0.000000, - 0.525731, 0.850651 ],
-			[ 0.425325, - 0.688191, 0.587785 ], [ 0.587785, - 0.425325, 0.688191 ],
-			[ 0.688191, - 0.587785, 0.425325 ], [ - 0.955423, 0.295242, 0.000000 ],
-			[ - 0.951056, 0.162460, 0.262866 ], [ - 1.000000, 0.000000, 0.000000 ],
-			[ - 0.850651, 0.000000, 0.525731 ], [ - 0.955423, - 0.295242, 0.000000 ],
-			[ - 0.951056, - 0.162460, 0.262866 ], [ - 0.864188, 0.442863, - 0.238856 ],
-			[ - 0.951056, 0.162460, - 0.262866 ], [ - 0.809017, 0.309017, - 0.500000 ],
-			[ - 0.864188, - 0.442863, - 0.238856 ], [ - 0.951056, - 0.162460, - 0.262866 ],
-			[ - 0.809017, - 0.309017, - 0.500000 ], [ - 0.681718, 0.147621, - 0.716567 ],
-			[ - 0.681718, - 0.147621, - 0.716567 ], [ - 0.850651, 0.000000, - 0.525731 ],
-			[ - 0.688191, 0.587785, - 0.425325 ], [ - 0.587785, 0.425325, - 0.688191 ],
-			[ - 0.425325, 0.688191, - 0.587785 ], [ - 0.425325, - 0.688191, - 0.587785 ],
-			[ - 0.587785, - 0.425325, - 0.688191 ], [ - 0.688191, - 0.587785, - 0.425325 ]
-		];
+	}
 
-		return function ( buffer ) {
+	parse( buffer ) {
 
-			var data = new DataView( buffer );
+		const data = new DataView( buffer );
 
-			// http://tfc.duke.free.fr/coding/md2-specs-en.html
+		// http://tfc.duke.free.fr/coding/md2-specs-en.html
 
-			var header = {};
-			var headerNames = [
-				'ident', 'version',
-				'skinwidth', 'skinheight',
-				'framesize',
-				'num_skins', 'num_vertices', 'num_st', 'num_tris', 'num_glcmds', 'num_frames',
-				'offset_skins', 'offset_st', 'offset_tris', 'offset_frames', 'offset_glcmds', 'offset_end'
-			];
+		const header = {};
+		const headerNames = [
+			'ident', 'version',
+			'skinwidth', 'skinheight',
+			'framesize',
+			'num_skins', 'num_vertices', 'num_st', 'num_tris', 'num_glcmds', 'num_frames',
+			'offset_skins', 'offset_st', 'offset_tris', 'offset_frames', 'offset_glcmds', 'offset_end'
+		];
 
-			for ( var i = 0; i < headerNames.length; i ++ ) {
+		for ( let i = 0; i < headerNames.length; i ++ ) {
 
-				header[ headerNames[ i ] ] = data.getInt32( i * 4, true );
+			header[ headerNames[ i ] ] = data.getInt32( i * 4, true );
 
-			}
+		}
 
-			if ( header.ident !== 844121161 || header.version !== 8 ) {
+		if ( header.ident !== 844121161 || header.version !== 8 ) {
 
-				console.error( 'Not a valid MD2 file' );
-				return;
+			console.error( 'Not a valid MD2 file' );
+			return;
 
-			}
+		}
 
-			if ( header.offset_end !== data.byteLength ) {
-
-				console.error( 'Corrupted MD2 file' );
-				return;
-
-			}
+		if ( header.offset_end !== data.byteLength ) {
 
-			//
+			console.error( 'Corrupted MD2 file' );
+			return;
 
-			var geometry = new BufferGeometry();
+		}
 
-			// uvs
+		//
 
-			var uvsTemp = [];
-			var offset = header.offset_st;
+		const geometry = new BufferGeometry();
 
-			for ( var i = 0, l = header.num_st; i < l; i ++ ) {
+		// uvs
 
-				var u = data.getInt16( offset + 0, true );
-				var v = data.getInt16( offset + 2, true );
+		const uvsTemp = [];
+		let offset = header.offset_st;
 
-				uvsTemp.push( u / header.skinwidth, 1 - ( v / header.skinheight ) );
+		for ( let i = 0, l = header.num_st; i < l; i ++ ) {
 
-				offset += 4;
+			const u = data.getInt16( offset + 0, true );
+			const v = data.getInt16( offset + 2, true );
 
-			}
+			uvsTemp.push( u / header.skinwidth, 1 - ( v / header.skinheight ) );
 
-			// triangles
+			offset += 4;
 
-			offset = header.offset_tris;
+		}
 
-			var vertexIndices = [];
-			var uvIndices = [];
+		// triangles
 
-			for ( var i = 0, l = header.num_tris; i < l; i ++ ) {
+		offset = header.offset_tris;
 
-				vertexIndices.push(
-					data.getUint16( offset + 0, true ),
-					data.getUint16( offset + 2, true ),
-					data.getUint16( offset + 4, true )
-				);
+		const vertexIndices = [];
+		const uvIndices = [];
 
-				uvIndices.push(
-					data.getUint16( offset + 6, true ),
-					data.getUint16( offset + 8, true ),
-					data.getUint16( offset + 10, true )
-				);
+		for ( let i = 0, l = header.num_tris; i < l; i ++ ) {
 
-				offset += 12;
+			vertexIndices.push(
+				data.getUint16( offset + 0, true ),
+				data.getUint16( offset + 2, true ),
+				data.getUint16( offset + 4, true )
+			);
 
-			}
+			uvIndices.push(
+				data.getUint16( offset + 6, true ),
+				data.getUint16( offset + 8, true ),
+				data.getUint16( offset + 10, true )
+			);
 
-			// frames
+			offset += 12;
 
-			var translation = new Vector3();
-			var scale = new Vector3();
-			var string = [];
+		}
 
-			var frames = [];
+		// frames
 
-			offset = header.offset_frames;
+		const translation = new Vector3();
+		const scale = new Vector3();
+		const string = [];
 
-			for ( var i = 0, l = header.num_frames; i < l; i ++ ) {
+		const frames = [];
 
-				scale.set(
-					data.getFloat32( offset + 0, true ),
-					data.getFloat32( offset + 4, true ),
-					data.getFloat32( offset + 8, true )
-				);
+		offset = header.offset_frames;
 
-				translation.set(
-					data.getFloat32( offset + 12, true ),
-					data.getFloat32( offset + 16, true ),
-					data.getFloat32( offset + 20, true )
-				);
+		for ( let i = 0, l = header.num_frames; i < l; i ++ ) {
 
-				offset += 24;
+			scale.set(
+				data.getFloat32( offset + 0, true ),
+				data.getFloat32( offset + 4, true ),
+				data.getFloat32( offset + 8, true )
+			);
 
-				for ( var j = 0; j < 16; j ++ ) {
+			translation.set(
+				data.getFloat32( offset + 12, true ),
+				data.getFloat32( offset + 16, true ),
+				data.getFloat32( offset + 20, true )
+			);
 
-					var character = data.getUint8( offset + j, true );
-					if ( character === 0 ) break;
+			offset += 24;
 
-					string[ j ] = character;
+			for ( let j = 0; j < 16; j ++ ) {
 
-				}
+				const character = data.getUint8( offset + j, true );
+				if ( character === 0 ) break;
 
-				var frame = {
-					name: String.fromCharCode.apply( null, string ),
-					vertices: [],
-					normals: []
-				};
+				string[ j ] = character;
 
-				offset += 16;
+			}
 
-				for ( var j = 0; j < header.num_vertices; j ++ ) {
+			const frame = {
+				name: String.fromCharCode.apply( null, string ),
+				vertices: [],
+				normals: []
+			};
 
-					var x = data.getUint8( offset ++, true );
-					var y = data.getUint8( offset ++, true );
-					var z = data.getUint8( offset ++, true );
-					var n = normalData[ data.getUint8( offset ++, true ) ];
+			offset += 16;
 
-					x = x * scale.x + translation.x;
-					y = y * scale.y + translation.y;
-					z = z * scale.z + translation.z;
+			for ( let j = 0; j < header.num_vertices; j ++ ) {
 
-					frame.vertices.push( x, z, y ); // convert to Y-up
-					frame.normals.push( n[ 0 ], n[ 2 ], n[ 1 ] ); // convert to Y-up
+				let x = data.getUint8( offset ++, true );
+				let y = data.getUint8( offset ++, true );
+				let z = data.getUint8( offset ++, true );
+				const n = _normalData[ data.getUint8( offset ++, true ) ];
 
-				}
+				x = x * scale.x + translation.x;
+				y = y * scale.y + translation.y;
+				z = z * scale.z + translation.z;
 
-				frames.push( frame );
+				frame.vertices.push( x, z, y ); // convert to Y-up
+				frame.normals.push( n[ 0 ], n[ 2 ], n[ 1 ] ); // convert to Y-up
 
 			}
 
-			// static
-
-			var positions = [];
-			var normals = [];
-			var uvs = [];
+			frames.push( frame );
 
-			var verticesTemp = frames[ 0 ].vertices;
-			var normalsTemp = frames[ 0 ].normals;
+		}
 
-			for ( var i = 0, l = vertexIndices.length; i < l; i ++ ) {
+		// static
 
-				var vertexIndex = vertexIndices[ i ];
-				var stride = vertexIndex * 3;
+		const positions = [];
+		const normals = [];
+		const uvs = [];
 
-				//
+		const verticesTemp = frames[ 0 ].vertices;
+		const normalsTemp = frames[ 0 ].normals;
 
-				var x = verticesTemp[ stride ];
-				var y = verticesTemp[ stride + 1 ];
-				var z = verticesTemp[ stride + 2 ];
+		for ( let i = 0, l = vertexIndices.length; i < l; i ++ ) {
 
-				positions.push( x, y, z );
+			const vertexIndex = vertexIndices[ i ];
+			let stride = vertexIndex * 3;
 
-				//
+			//
 
-				var nx = normalsTemp[ stride ];
-				var ny = normalsTemp[ stride + 1 ];
-				var nz = normalsTemp[ stride + 2 ];
+			const x = verticesTemp[ stride ];
+			const y = verticesTemp[ stride + 1 ];
+			const z = verticesTemp[ stride + 2 ];
 
-				normals.push( nx, ny, nz );
+			positions.push( x, y, z );
 
-				//
+			//
 
-				var uvIndex = uvIndices[ i ];
-				stride = uvIndex * 2;
+			const nx = normalsTemp[ stride ];
+			const ny = normalsTemp[ stride + 1 ];
+			const nz = normalsTemp[ stride + 2 ];
 
-				var u = uvsTemp[ stride ];
-				var v = uvsTemp[ stride + 1 ];
+			normals.push( nx, ny, nz );
 
-				uvs.push( u, v );
+			//
 
-			}
+			const uvIndex = uvIndices[ i ];
+			stride = uvIndex * 2;
 
-			geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
-			geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
-			geometry.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
+			const u = uvsTemp[ stride ];
+			const v = uvsTemp[ stride + 1 ];
 
-			// animation
+			uvs.push( u, v );
 
-			var morphPositions = [];
-			var morphNormals = [];
+		}
 
-			for ( var i = 0, l = frames.length; i < l; i ++ ) {
+		geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
+		geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
+		geometry.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
 
-				var frame = frames[ i ];
-				var attributeName = frame.name;
+		// animation
 
-				if ( frame.vertices.length > 0 ) {
+		const morphPositions = [];
+		const morphNormals = [];
 
-					var positions = [];
+		for ( let i = 0, l = frames.length; i < l; i ++ ) {
 
-					for ( var j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
+			const frame = frames[ i ];
+			const attributeName = frame.name;
 
-						var vertexIndex = vertexIndices[ j ];
-						var stride = vertexIndex * 3;
+			if ( frame.vertices.length > 0 ) {
 
-						var x = frame.vertices[ stride ];
-						var y = frame.vertices[ stride + 1 ];
-						var z = frame.vertices[ stride + 2 ];
+				const positions = [];
 
-						positions.push( x, y, z );
+				for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
 
-					}
+					const vertexIndex = vertexIndices[ j ];
+					const stride = vertexIndex * 3;
 
-					var positionAttribute = new Float32BufferAttribute( positions, 3 );
-					positionAttribute.name = attributeName;
+					const x = frame.vertices[ stride ];
+					const y = frame.vertices[ stride + 1 ];
+					const z = frame.vertices[ stride + 2 ];
 
-					morphPositions.push( positionAttribute );
+					positions.push( x, y, z );
 
 				}
 
-				if ( frame.normals.length > 0 ) {
+				const positionAttribute = new Float32BufferAttribute( positions, 3 );
+				positionAttribute.name = attributeName;
 
-					var normals = [];
+				morphPositions.push( positionAttribute );
 
-					for ( var j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
+			}
 
-						var vertexIndex = vertexIndices[ j ];
-						var stride = vertexIndex * 3;
+			if ( frame.normals.length > 0 ) {
 
-						var nx = frame.normals[ stride ];
-						var ny = frame.normals[ stride + 1 ];
-						var nz = frame.normals[ stride + 2 ];
+				const normals = [];
 
-						normals.push( nx, ny, nz );
+				for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
 
-					}
+					const vertexIndex = vertexIndices[ j ];
+					const stride = vertexIndex * 3;
 
-					var normalAttribute = new Float32BufferAttribute( normals, 3 );
-					normalAttribute.name = attributeName;
+					const nx = frame.normals[ stride ];
+					const ny = frame.normals[ stride + 1 ];
+					const nz = frame.normals[ stride + 2 ];
 
-					morphNormals.push( normalAttribute );
+					normals.push( nx, ny, nz );
 
 				}
 
+				const normalAttribute = new Float32BufferAttribute( normals, 3 );
+				normalAttribute.name = attributeName;
+
+				morphNormals.push( normalAttribute );
+
 			}
 
-			geometry.morphAttributes.position = morphPositions;
-			geometry.morphAttributes.normal = morphNormals;
-			geometry.morphTargetsRelative = false;
+		}
 
-			geometry.animations = AnimationClip.CreateClipsFromMorphTargetSequences( frames, 10 );
+		geometry.morphAttributes.position = morphPositions;
+		geometry.morphAttributes.normal = morphNormals;
+		geometry.morphTargetsRelative = false;
 
-			return geometry;
+		geometry.animations = AnimationClip.CreateClipsFromMorphTargetSequences( frames, 10 );
 
-		};
+		return geometry;
 
-	} )()
+	}
 
-} );
+}
 
 export { MD2Loader };

+ 25 - 27
examples/jsm/loaders/MDDLoader.js

@@ -18,21 +18,19 @@ import {
 	NumberKeyframeTrack
 } from '../../../build/three.module.js';
 
-var MDDLoader = function ( manager ) {
+class MDDLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-MDDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: MDDLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 		loader.setPath( this.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.load( url, function ( data ) {
@@ -41,43 +39,43 @@ MDDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( data ) {
+	parse( data ) {
 
-		var view = new DataView( data );
+		const view = new DataView( data );
 
-		var totalFrames = view.getUint32( 0 );
-		var totalPoints = view.getUint32( 4 );
+		const totalFrames = view.getUint32( 0 );
+		const totalPoints = view.getUint32( 4 );
 
-		var offset = 8;
+		let offset = 8;
 
 		// animation clip
 
-		var times = new Float32Array( totalFrames );
-		var values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
+		const times = new Float32Array( totalFrames );
+		const values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
 
-		for ( var i = 0; i < totalFrames; i ++ ) {
+		for ( let i = 0; i < totalFrames; i ++ ) {
 
 			times[ i ] = view.getFloat32( offset ); offset += 4;
 			values[ ( totalFrames * i ) + i ] = 1;
 
 		}
 
-		var track = new NumberKeyframeTrack( '.morphTargetInfluences', times, values );
-		var clip = new AnimationClip( 'default', times[ times.length - 1 ], [ track ] );
+		const track = new NumberKeyframeTrack( '.morphTargetInfluences', times, values );
+		const clip = new AnimationClip( 'default', times[ times.length - 1 ], [ track ] );
 
 		// morph targets
 
-		var morphTargets = [];
+		const morphTargets = [];
 
-		for ( var i = 0; i < totalFrames; i ++ ) {
+		for ( let i = 0; i < totalFrames; i ++ ) {
 
-			var morphTarget = new Float32Array( totalPoints * 3 );
+			const morphTarget = new Float32Array( totalPoints * 3 );
 
-			for ( var j = 0; j < totalPoints; j ++ ) {
+			for ( let j = 0; j < totalPoints; j ++ ) {
 
-				var stride = ( j * 3 );
+				const stride = ( j * 3 );
 
 				morphTarget[ stride + 0 ] = view.getFloat32( offset ); offset += 4; // x
 				morphTarget[ stride + 1 ] = view.getFloat32( offset ); offset += 4; // y
@@ -85,7 +83,7 @@ MDDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var attribute = new BufferAttribute( morphTarget, 3 );
+			const attribute = new BufferAttribute( morphTarget, 3 );
 			attribute.name = 'morph_' + i;
 
 			morphTargets.push( attribute );
@@ -99,6 +97,6 @@ MDDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { MDDLoader };

+ 52 - 55
examples/jsm/loaders/PCDLoader.js

@@ -8,24 +8,21 @@ import {
 	PointsMaterial
 } from '../../../build/three.module.js';
 
-var PCDLoader = function ( manager ) {
+class PCDLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-	this.littleEndian = true;
+		super( manager );
 
-};
+		this.littleEndian = true;
 
+	}
 
-PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: PCDLoader,
-
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( scope.manager );
+		const loader = new FileLoader( scope.manager );
 		loader.setPath( scope.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( scope.requestHeader );
@@ -54,21 +51,21 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( data, url ) {
+	parse( data, url ) {
 
 		// from https://gitlab.com/taketwo/three-pcd-loader/blob/master/decompress-lzf.js
 
 		function decompressLZF( inData, outLength ) {
 
-			var inLength = inData.length;
-			var outData = new Uint8Array( outLength );
-			var inPtr = 0;
-			var outPtr = 0;
-			var ctrl;
-			var len;
-			var ref;
+			const inLength = inData.length;
+			const outData = new Uint8Array( outLength );
+			let inPtr = 0;
+			let outPtr = 0;
+			let ctrl;
+			let len;
+			let ref;
 			do {
 
 				ctrl = inData[ inPtr ++ ];
@@ -115,9 +112,9 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function parseHeader( data ) {
 
-			var PCDheader = {};
-			var result1 = data.search( /[\r\n]DATA\s(\S*)\s/i );
-			var result2 = /[\r\n]DATA\s(\S*)\s/i.exec( data.substr( result1 - 1 ) );
+			const PCDheader = {};
+			const result1 = data.search( /[\r\n]DATA\s(\S*)\s/i );
+			const result2 = /[\r\n]DATA\s(\S*)\s/i.exec( data.substr( result1 - 1 ) );
 
 			PCDheader.data = result2[ 1 ];
 			PCDheader.headerLen = result2[ 0 ].length + result1;
@@ -187,7 +184,7 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				PCDheader.count = [];
 
-				for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
+				for ( let i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
 
 					PCDheader.count.push( 1 );
 
@@ -197,9 +194,9 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			PCDheader.offset = {};
 
-			var sizeSum = 0;
+			let sizeSum = 0;
 
-			for ( var i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
+			for ( let i = 0, l = PCDheader.fields.length; i < l; i ++ ) {
 
 				if ( PCDheader.data === 'ascii' ) {
 
@@ -222,31 +219,31 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-		var textData = LoaderUtils.decodeText( new Uint8Array( data ) );
+		const textData = LoaderUtils.decodeText( new Uint8Array( data ) );
 
 		// parse header (always ascii format)
 
-		var PCDheader = parseHeader( textData );
+		const PCDheader = parseHeader( textData );
 
 		// parse data
 
-		var position = [];
-		var normal = [];
-		var color = [];
+		const position = [];
+		const normal = [];
+		const color = [];
 
 		// ascii
 
 		if ( PCDheader.data === 'ascii' ) {
 
-			var offset = PCDheader.offset;
-			var pcdData = textData.substr( PCDheader.headerLen );
-			var lines = pcdData.split( '\n' );
+			const offset = PCDheader.offset;
+			const pcdData = textData.substr( PCDheader.headerLen );
+			const lines = pcdData.split( '\n' );
 
-			for ( var i = 0, l = lines.length; i < l; i ++ ) {
+			for ( let i = 0, l = lines.length; i < l; i ++ ) {
 
 				if ( lines[ i ] === '' ) continue;
 
-				var line = lines[ i ].split( ' ' );
+				const line = lines[ i ].split( ' ' );
 
 				if ( offset.x !== undefined ) {
 
@@ -258,10 +255,10 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				if ( offset.rgb !== undefined ) {
 
-					var rgb = parseFloat( line[ offset.rgb ] );
-					var r = ( rgb >> 16 ) & 0x0000ff;
-					var g = ( rgb >> 8 ) & 0x0000ff;
-					var b = ( rgb >> 0 ) & 0x0000ff;
+					const rgb = parseFloat( line[ offset.rgb ] );
+					const r = ( rgb >> 16 ) & 0x0000ff;
+					const g = ( rgb >> 8 ) & 0x0000ff;
+					const b = ( rgb >> 0 ) & 0x0000ff;
 					color.push( r / 255, g / 255, b / 255 );
 
 				}
@@ -286,15 +283,15 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		if ( PCDheader.data === 'binary_compressed' ) {
 
-			var sizes = new Uint32Array( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
-			var compressedSize = sizes[ 0 ];
-			var decompressedSize = sizes[ 1 ];
-			var decompressed = decompressLZF( new Uint8Array( data, PCDheader.headerLen + 8, compressedSize ), decompressedSize );
-			var dataview = new DataView( decompressed.buffer );
+			const sizes = new Uint32Array( data.slice( PCDheader.headerLen, PCDheader.headerLen + 8 ) );
+			const compressedSize = sizes[ 0 ];
+			const decompressedSize = sizes[ 1 ];
+			const decompressed = decompressLZF( new Uint8Array( data, PCDheader.headerLen + 8, compressedSize ), decompressedSize );
+			const dataview = new DataView( decompressed.buffer );
 
-			var offset = PCDheader.offset;
+			const offset = PCDheader.offset;
 
-			for ( var i = 0; i < PCDheader.points; i ++ ) {
+			for ( let i = 0; i < PCDheader.points; i ++ ) {
 
 				if ( offset.x !== undefined ) {
 
@@ -328,10 +325,10 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		if ( PCDheader.data === 'binary' ) {
 
-			var dataview = new DataView( data, PCDheader.headerLen );
-			var offset = PCDheader.offset;
+			const dataview = new DataView( data, PCDheader.headerLen );
+			const offset = PCDheader.offset;
 
-			for ( var i = 0, row = 0; i < PCDheader.points; i ++, row += PCDheader.rowSize ) {
+			for ( let i = 0, row = 0; i < PCDheader.points; i ++, row += PCDheader.rowSize ) {
 
 				if ( offset.x !== undefined ) {
 
@@ -363,7 +360,7 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		// build geometry
 
-		var geometry = new BufferGeometry();
+		const geometry = new BufferGeometry();
 
 		if ( position.length > 0 ) geometry.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
 		if ( normal.length > 0 ) geometry.setAttribute( 'normal', new Float32BufferAttribute( normal, 3 ) );
@@ -373,7 +370,7 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		// build material
 
-		var material = new PointsMaterial( { size: 0.005 } );
+		const material = new PointsMaterial( { size: 0.005 } );
 
 		if ( color.length > 0 ) {
 
@@ -387,8 +384,8 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		// build point cloud
 
-		var mesh = new Points( geometry, material );
-		var name = url.split( '' ).reverse().join( '' );
+		const mesh = new Points( geometry, material );
+		let name = url.split( '' ).reverse().join( '' );
 		name = /([^\/]*)/.exec( name );
 		name = name[ 1 ].split( '' ).reverse().join( '' );
 		mesh.name = name;
@@ -397,6 +394,6 @@ PCDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { PCDLoader };

File diff ditekan karena terlalu besar
+ 35 - 40
examples/jsm/loaders/PDBLoader.js


+ 62 - 65
examples/jsm/loaders/PLYLoader.js

@@ -13,7 +13,7 @@ import {
  * Limitations: ASCII decoding assumes file is UTF-8.
  *
  * Usage:
- *	var loader = new PLYLoader();
+ *	const loader = new PLYLoader();
  *	loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {
  *
  *		scene.add( new THREE.Mesh( geometry ) );
@@ -33,23 +33,21 @@ import {
  */
 
 
-var PLYLoader = function ( manager ) {
+class PLYLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-	this.propertyNameMapping = {};
+		super( manager );
 
-};
+		this.propertyNameMapping = {};
 
-PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: PLYLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 		loader.setPath( this.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( this.requestHeader );
@@ -78,22 +76,22 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	setPropertyNameMapping: function ( mapping ) {
+	setPropertyNameMapping( mapping ) {
 
 		this.propertyNameMapping = mapping;
 
-	},
+	}
 
-	parse: function ( data ) {
+	parse( data ) {
 
 		function parseHeader( data ) {
 
-			var patternHeader = /ply([\s\S]*)end_header\r?\n/;
-			var headerText = '';
-			var headerLength = 0;
-			var result = patternHeader.exec( data );
+			const patternHeader = /ply([\s\S]*)end_header\r?\n/;
+			let headerText = '';
+			let headerLength = 0;
+			const result = patternHeader.exec( data );
 
 			if ( result !== null ) {
 
@@ -102,20 +100,19 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var header = {
+			const header = {
 				comments: [],
 				elements: [],
 				headerLength: headerLength,
 				objInfo: ''
 			};
 
-			var lines = headerText.split( '\n' );
-			var currentElement;
-			var lineType, lineValues;
+			const lines = headerText.split( '\n' );
+			let currentElement;
 
 			function make_ply_element_property( propertValues, propertyNameMapping ) {
 
-				var property = { type: propertValues[ 0 ] };
+				const property = { type: propertValues[ 0 ] };
 
 				if ( property.type === 'list' ) {
 
@@ -139,15 +136,15 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			for ( var i = 0; i < lines.length; i ++ ) {
+			for ( let i = 0; i < lines.length; i ++ ) {
 
-				var line = lines[ i ];
+				let line = lines[ i ];
 				line = line.trim();
 
 				if ( line === '' ) continue;
 
-				lineValues = line.split( /\s+/ );
-				lineType = lineValues.shift();
+				const lineValues = line.split( /\s+/ );
+				const lineType = lineValues.shift();
 				line = lineValues.join( ' ' );
 
 				switch ( lineType ) {
@@ -230,18 +227,18 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function parseASCIIElement( properties, line ) {
 
-			var values = line.split( /\s+/ );
+			const values = line.split( /\s+/ );
 
-			var element = {};
+			const element = {};
 
-			for ( var i = 0; i < properties.length; i ++ ) {
+			for ( let i = 0; i < properties.length; i ++ ) {
 
 				if ( properties[ i ].type === 'list' ) {
 
-					var list = [];
-					var n = parseASCIINumber( values.shift(), properties[ i ].countType );
+					const list = [];
+					const n = parseASCIINumber( values.shift(), properties[ i ].countType );
 
-					for ( var j = 0; j < n; j ++ ) {
+					for ( let j = 0; j < n; j ++ ) {
 
 						list.push( parseASCIINumber( values.shift(), properties[ i ].itemType ) );
 
@@ -265,7 +262,7 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
 
-			var buffer = {
+			const buffer = {
 				indices: [],
 				vertices: [],
 				normals: [],
@@ -274,23 +271,23 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				colors: []
 			};
 
-			var result;
+			let result;
 
-			var patternBody = /end_header\s([\s\S]*)$/;
-			var body = '';
+			const patternBody = /end_header\s([\s\S]*)$/;
+			let body = '';
 			if ( ( result = patternBody.exec( data ) ) !== null ) {
 
 				body = result[ 1 ];
 
 			}
 
-			var lines = body.split( '\n' );
-			var currentElement = 0;
-			var currentElementCount = 0;
+			const lines = body.split( '\n' );
+			let currentElement = 0;
+			let currentElementCount = 0;
 
-			for ( var i = 0; i < lines.length; i ++ ) {
+			for ( let i = 0; i < lines.length; i ++ ) {
 
-				var line = lines[ i ];
+				let line = lines[ i ];
 				line = line.trim();
 				if ( line === '' ) {
 
@@ -305,7 +302,7 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				var element = parseASCIIElement( header.elements[ currentElement ].properties, line );
+				const element = parseASCIIElement( header.elements[ currentElement ].properties, line );
 
 				handleElement( buffer, header.elements[ currentElement ].name, element );
 
@@ -319,7 +316,7 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function postProcess( buffer ) {
 
-			var geometry = new BufferGeometry();
+			let geometry = new BufferGeometry();
 
 			// mandatory buffer data
 
@@ -390,8 +387,8 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} else if ( elementName === 'face' ) {
 
-				var vertex_indices = element.vertex_indices || element.vertex_index; // issue #9338
-				var texcoord = element.texcoord;
+				const vertex_indices = element.vertex_indices || element.vertex_index; // issue #9338
+				const texcoord = element.texcoord;
 
 				if ( vertex_indices.length === 3 ) {
 
@@ -436,20 +433,20 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function binaryReadElement( dataview, at, properties, little_endian ) {
 
-			var element = {};
-			var result, read = 0;
+			const element = {};
+			let result, read = 0;
 
-			for ( var i = 0; i < properties.length; i ++ ) {
+			for ( let i = 0; i < properties.length; i ++ ) {
 
 				if ( properties[ i ].type === 'list' ) {
 
-					var list = [];
+					const list = [];
 
 					result = binaryRead( dataview, at + read, properties[ i ].countType, little_endian );
-					var n = result[ 0 ];
+					const n = result[ 0 ];
 					read += result[ 1 ];
 
-					for ( var j = 0; j < n; j ++ ) {
+					for ( let j = 0; j < n; j ++ ) {
 
 						result = binaryRead( dataview, at + read, properties[ i ].itemType, little_endian );
 						list.push( result[ 0 ] );
@@ -475,7 +472,7 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function parseBinary( data, header ) {
 
-			var buffer = {
+			const buffer = {
 				indices: [],
 				vertices: [],
 				normals: [],
@@ -484,17 +481,17 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				colors: []
 			};
 
-			var little_endian = ( header.format === 'binary_little_endian' );
-			var body = new DataView( data, header.headerLength );
-			var result, loc = 0;
+			const little_endian = ( header.format === 'binary_little_endian' );
+			const body = new DataView( data, header.headerLength );
+			let result, loc = 0;
 
-			for ( var currentElement = 0; currentElement < header.elements.length; currentElement ++ ) {
+			for ( let currentElement = 0; currentElement < header.elements.length; currentElement ++ ) {
 
-				for ( var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) {
+				for ( let currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount ++ ) {
 
 					result = binaryReadElement( body, loc, header.elements[ currentElement ].properties, little_endian );
 					loc += result[ 1 ];
-					var element = result[ 0 ];
+					const element = result[ 0 ];
 
 					handleElement( buffer, header.elements[ currentElement ].name, element );
 
@@ -508,13 +505,13 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		//
 
-		var geometry;
-		var scope = this;
+		let geometry;
+		const scope = this;
 
 		if ( data instanceof ArrayBuffer ) {
 
-			var text = LoaderUtils.decodeText( new Uint8Array( data ) );
-			var header = parseHeader( text );
+			const text = LoaderUtils.decodeText( new Uint8Array( data ) );
+			const header = parseHeader( text );
 
 			geometry = header.format === 'ascii' ? parseASCII( text, header ) : parseBinary( data, header );
 
@@ -528,6 +525,6 @@ PLYLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { PLYLoader };

+ 40 - 41
examples/jsm/loaders/PVRLoader.js

@@ -12,22 +12,20 @@ import {
  *   TODO : implement loadMipmaps option
  */
 
-var PVRLoader = function ( manager ) {
+class PVRLoader extends CompressedTextureLoader {
 
-	CompressedTextureLoader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-PVRLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prototype ), {
-
-	constructor: PVRLoader,
+	}
 
-	parse: function ( buffer, loadMipmaps ) {
+	parse( buffer, loadMipmaps ) {
 
-		var headerLengthInt = 13;
-		var header = new Uint32Array( buffer, 0, headerLengthInt );
+		const headerLengthInt = 13;
+		const header = new Uint32Array( buffer, 0, headerLengthInt );
 
-		var pvrDatas = {
+		const pvrDatas = {
 			buffer: buffer,
 			header: header,
 			loadMipmaps: loadMipmaps
@@ -37,13 +35,13 @@ PVRLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 			// PVR v3
 
-			return PVRLoader._parseV3( pvrDatas );
+			return _parseV3( pvrDatas );
 
 		} else if ( header[ 11 ] === 0x21525650 ) {
 
 			// PVR v2
 
-			return PVRLoader._parseV2( pvrDatas );
+			return _parseV2( pvrDatas );
 
 		} else {
 
@@ -53,15 +51,15 @@ PVRLoader.prototype = Object.assign( Object.create( CompressedTextureLoader.prot
 
 	}
 
-} );
+}
 
-PVRLoader._parseV3 = function ( pvrDatas ) {
+function _parseV3( pvrDatas ) {
 
-	var header = pvrDatas.header;
-	var bpp, format;
+	const header = pvrDatas.header;
+	let bpp, format;
 
 
-	var metaLen = header[ 12 ],
+	const metaLen = header[ 12 ],
 		pixelFormat = header[ 2 ],
 		height = header[ 6 ],
 		width = header[ 7 ],
@@ -105,15 +103,15 @@ PVRLoader._parseV3 = function ( pvrDatas ) {
 	pvrDatas.numMipmaps = numMipmaps;
 	pvrDatas.isCubemap 	= ( numFaces === 6 );
 
-	return PVRLoader._extract( pvrDatas );
+	return _extract( pvrDatas );
 
-};
+}
 
-PVRLoader._parseV2 = function ( pvrDatas ) {
+function _parseV2( pvrDatas ) {
 
-	var header = pvrDatas.header;
+	const header = pvrDatas.header;
 
-	var headerLength = header[ 0 ],
+	const headerLength = header[ 0 ],
 		height = header[ 1 ],
 		width = header[ 2 ],
 		numMipmaps = header[ 3 ],
@@ -128,14 +126,14 @@ PVRLoader._parseV2 = function ( pvrDatas ) {
 		numSurfs = header[ 12 ];
 
 
-	var TYPE_MASK = 0xff;
-	var PVRTC_2 = 24,
+	const TYPE_MASK = 0xff;
+	const PVRTC_2 = 24,
 		PVRTC_4 = 25;
 
-	var formatFlags = flags & TYPE_MASK;
+	const formatFlags = flags & TYPE_MASK;
 
-	var bpp, format;
-	var _hasAlpha = bitmaskAlpha > 0;
+	let bpp, format;
+	const _hasAlpha = bitmaskAlpha > 0;
 
 	if ( formatFlags === PVRTC_4 ) {
 
@@ -165,14 +163,14 @@ PVRLoader._parseV2 = function ( pvrDatas ) {
 	// it juste a pvr containing 6 surface (no explicit cubemap type)
 	pvrDatas.isCubemap 	= ( numSurfs === 6 );
 
-	return PVRLoader._extract( pvrDatas );
+	return _extract( pvrDatas );
 
-};
+}
 
 
-PVRLoader._extract = function ( pvrDatas ) {
+function _extract( pvrDatas ) {
 
-	var pvr = {
+	const pvr = {
 		mipmaps: [],
 		width: pvrDatas.width,
 		height: pvrDatas.height,
@@ -181,11 +179,9 @@ PVRLoader._extract = function ( pvrDatas ) {
 		isCubemap: pvrDatas.isCubemap
 	};
 
-	var buffer = pvrDatas.buffer;
+	const buffer = pvrDatas.buffer;
 
-	var dataOffset = pvrDatas.dataPtr,
-		bpp = pvrDatas.bpp,
-		numSurfs = pvrDatas.numSurfaces,
+	let dataOffset = pvrDatas.dataPtr,
 		dataSize = 0,
 		blockSize = 0,
 		blockWidth = 0,
@@ -193,6 +189,9 @@ PVRLoader._extract = function ( pvrDatas ) {
 		widthBlocks = 0,
 		heightBlocks = 0;
 
+	const bpp = pvrDatas.bpp,
+		numSurfs = pvrDatas.numSurfaces;
+
 	if ( bpp === 2 ) {
 
 		blockWidth = 8;
@@ -209,11 +208,11 @@ PVRLoader._extract = function ( pvrDatas ) {
 
 	pvr.mipmaps.length = pvrDatas.numMipmaps * numSurfs;
 
-	var mipLevel = 0;
+	let mipLevel = 0;
 
 	while ( mipLevel < pvrDatas.numMipmaps ) {
 
-		var sWidth = pvrDatas.width >> mipLevel,
+		const sWidth = pvrDatas.width >> mipLevel,
 			sHeight = pvrDatas.height >> mipLevel;
 
 		widthBlocks = sWidth / blockWidth;
@@ -225,11 +224,11 @@ PVRLoader._extract = function ( pvrDatas ) {
 
 		dataSize = widthBlocks * heightBlocks * blockSize;
 
-		for ( var surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) {
+		for ( let surfIndex = 0; surfIndex < numSurfs; surfIndex ++ ) {
 
-			var byteArray = new Uint8Array( buffer, dataOffset, dataSize );
+			const byteArray = new Uint8Array( buffer, dataOffset, dataSize );
 
-			var mipmap = {
+			const mipmap = {
 				data: byteArray,
 				width: sWidth,
 				height: sHeight
@@ -247,6 +246,6 @@ PVRLoader._extract = function ( pvrDatas ) {
 
 	return pvr;
 
-};
+}
 
 export { PVRLoader };

+ 66 - 61
examples/jsm/loaders/RGBELoader.js

@@ -15,23 +15,21 @@ import {
 // https://github.com/mrdoob/three.js/issues/5552
 // http://en.wikipedia.org/wiki/RGBE_image_format
 
-var RGBELoader = function ( manager ) {
+class RGBELoader extends DataTextureLoader {
 
-	DataTextureLoader.call( this, manager );
+	constructor( manager ) {
 
-	this.type = UnsignedByteType;
+		super( manager );
 
-};
+		this.type = UnsignedByteType;
 
-RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype ), {
-
-	constructor: RGBELoader,
+	}
 
 	// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
 
-	parse: function ( buffer ) {
+	parse( buffer ) {
 
-		var
+		const
 			/* return codes for rgbe routines */
 			//RGBE_RETURN_SUCCESS = 0,
 			RGBE_RETURN_FAILURE = - 1,
@@ -77,11 +75,13 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 			fgets = function ( buffer, lineLimit, consume ) {
 
+				const chunkSize = 128;
+
 				lineLimit = ! lineLimit ? 1024 : lineLimit;
-				var p = buffer.pos,
-					i = - 1, len = 0, s = '', chunkSize = 128,
-					chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) )
-				;
+				let p = buffer.pos,
+					i = - 1, len = 0, s = '',
+					chunk = String.fromCharCode.apply( null, new Uint16Array( buffer.subarray( p, p + chunkSize ) ) );
+
 				while ( ( 0 > ( i = chunk.indexOf( NEWLINE ) ) ) && ( len < lineLimit ) && ( p < buffer.byteLength ) ) {
 
 					s += chunk; len += chunk.length;
@@ -110,10 +110,9 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 			/* minimal header reading.  modify if you want to parse more information */
 			RGBE_ReadHeader = function ( buffer ) {
 
-				var line, match,
 
-					// regexes to parse header info fields
-					magic_token_re = /^#\?(\S+)/,
+				// regexes to parse header info fields
+				const magic_token_re = /^#\?(\S+)/,
 					gamma_re = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,
 					exposure_re = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,
 					format_re = /^\s*FORMAT=(\S+)\s*$/,
@@ -140,6 +139,8 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 					};
 
+				let line, match;
+
 				if ( buffer.pos >= buffer.byteLength || ! ( line = fgets( buffer ) ) ) {
 
 					return rgbe_error( rgbe_read_error, 'no header found' );
@@ -219,10 +220,7 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 			RGBE_ReadPixels_RLE = function ( buffer, w, h ) {
 
-				var data_rgba, offset, pos, count, byteValue,
-					scanline_buffer, ptr, ptr_end, i, l, off, isEncodedRun,
-					scanline_width = w, num_scanlines = h, rgbeStart
-				;
+				const scanline_width = w;
 
 				if (
 					// run length encoding is not allowed so read flat
@@ -242,7 +240,7 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 				}
 
-				data_rgba = new Uint8Array( 4 * w * h );
+				const data_rgba = new Uint8Array( 4 * w * h );
 
 				if ( ! data_rgba.length ) {
 
@@ -250,9 +248,12 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 				}
 
-				offset = 0; pos = 0; ptr_end = 4 * scanline_width;
-				rgbeStart = new Uint8Array( 4 );
-				scanline_buffer = new Uint8Array( ptr_end );
+				let offset = 0, pos = 0;
+
+				const ptr_end = 4 * scanline_width;
+				const rgbeStart = new Uint8Array( 4 );
+				const scanline_buffer = new Uint8Array( ptr_end );
+				let num_scanlines = h;
 
 				// read in each successive scanline
 				while ( ( num_scanlines > 0 ) && ( pos < buffer.byteLength ) ) {
@@ -276,11 +277,12 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 					// read each of the four channels for the scanline into the buffer
 					// first red, then green, then blue, then exponent
-					ptr = 0;
+					let ptr = 0, count;
+
 					while ( ( ptr < ptr_end ) && ( pos < buffer.byteLength ) ) {
 
 						count = buffer[ pos ++ ];
-						isEncodedRun = count > 128;
+						const isEncodedRun = count > 128;
 						if ( isEncodedRun ) count -= 128;
 
 						if ( ( 0 === count ) || ( ptr + count > ptr_end ) ) {
@@ -292,8 +294,8 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 						if ( isEncodedRun ) {
 
 							// a (encoded) run of the same value
-							byteValue = buffer[ pos ++ ];
-							for ( i = 0; i < count; i ++ ) {
+							const byteValue = buffer[ pos ++ ];
+							for ( let i = 0; i < count; i ++ ) {
 
 								scanline_buffer[ ptr ++ ] = byteValue;
 
@@ -313,10 +315,10 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 					// now convert data from buffer into rgba
 					// first red, then green, then blue, then exponent (alpha)
-					l = scanline_width; //scanline_buffer.byteLength;
-					for ( i = 0; i < l; i ++ ) {
+					const l = scanline_width; //scanline_buffer.byteLength;
+					for ( let i = 0; i < l; i ++ ) {
 
-						off = 0;
+						let off = 0;
 						data_rgba[ offset ] = scanline_buffer[ i + off ];
 						off += scanline_width; //1;
 						data_rgba[ offset + 1 ] = scanline_buffer[ i + off ];
@@ -336,10 +338,10 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 			};
 
-		var RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+		const RGBEByteToRGBFloat = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-			var e = sourceArray[ sourceOffset + 3 ];
-			var scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+			const e = sourceArray[ sourceOffset + 3 ];
+			const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 
 			destArray[ destOffset + 0 ] = sourceArray[ sourceOffset + 0 ] * scale;
 			destArray[ destOffset + 1 ] = sourceArray[ sourceOffset + 1 ] * scale;
@@ -347,10 +349,10 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		};
 
-		var RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
+		const RGBEByteToRGBHalf = function ( sourceArray, sourceOffset, destArray, destOffset ) {
 
-			var e = sourceArray[ sourceOffset + 3 ];
-			var scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
+			const e = sourceArray[ sourceOffset + 3 ];
+			const scale = Math.pow( 2.0, e - 128.0 ) / 255.0;
 
 			destArray[ destOffset + 0 ] = DataUtils.toHalfFloat( sourceArray[ sourceOffset + 0 ] * scale );
 			destArray[ destOffset + 1 ] = DataUtils.toHalfFloat( sourceArray[ sourceOffset + 1 ] * scale );
@@ -358,57 +360,60 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		};
 
-		var byteArray = new Uint8Array( buffer );
+		const byteArray = new Uint8Array( buffer );
 		byteArray.pos = 0;
-		var rgbe_header_info = RGBE_ReadHeader( byteArray );
+		const rgbe_header_info = RGBE_ReadHeader( byteArray );
 
 		if ( RGBE_RETURN_FAILURE !== rgbe_header_info ) {
 
-			var w = rgbe_header_info.width,
+			const w = rgbe_header_info.width,
 				h = rgbe_header_info.height,
 				image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h );
 
 			if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
 
+				let data, format, type;
+				let numElements;
+
 				switch ( this.type ) {
 
 					case UnsignedByteType:
 
-						var data = image_rgba_data;
-						var format = RGBEFormat; // handled as THREE.RGBAFormat in shaders
-						var type = UnsignedByteType;
+						data = image_rgba_data;
+						format = RGBEFormat; // handled as THREE.RGBAFormat in shaders
+						type = UnsignedByteType;
 						break;
 
 					case FloatType:
 
-						var numElements = ( image_rgba_data.length / 4 ) * 3;
-						var floatArray = new Float32Array( numElements );
+						numElements = ( image_rgba_data.length / 4 ) * 3;
+						const floatArray = new Float32Array( numElements );
 
-						for ( var j = 0; j < numElements; j ++ ) {
+						for ( let j = 0; j < numElements; j ++ ) {
 
 							RGBEByteToRGBFloat( image_rgba_data, j * 4, floatArray, j * 3 );
 
 						}
 
-						var data = floatArray;
-						var format = RGBFormat;
-						var type = FloatType;
+						data = floatArray;
+						format = RGBFormat;
+						type = FloatType;
 						break;
 
 					case HalfFloatType:
 
-						var numElements = ( image_rgba_data.length / 4 ) * 3;
-						var halfArray = new Uint16Array( numElements );
+						numElements = ( image_rgba_data.length / 4 ) * 3;
+						const halfArray = new Uint16Array( numElements );
 
-						for ( var j = 0; j < numElements; j ++ ) {
+						for ( let j = 0; j < numElements; j ++ ) {
 
 							RGBEByteToRGBHalf( image_rgba_data, j * 4, halfArray, j * 3 );
 
 						}
 
-						var data = halfArray;
-						var format = RGBFormat;
-						var type = HalfFloatType;
+						data = halfArray;
+						format = RGBFormat;
+						type = HalfFloatType;
 						break;
 
 					default:
@@ -434,16 +439,16 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		return null;
 
-	},
+	}
 
-	setDataType: function ( value ) {
+	setDataType( value ) {
 
 		this.type = value;
 		return this;
 
-	},
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
 		function onLoadCallback( texture, texData ) {
 
@@ -482,10 +487,10 @@ RGBELoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		}
 
-		return DataTextureLoader.prototype.load.call( this, url, onLoadCallback, onProgress, onError );
+		return super.load( url, onLoadCallback, onProgress, onError );
 
 	}
 
-} );
+}
 
 export { RGBELoader };

+ 68 - 71
examples/jsm/loaders/STLLoader.js

@@ -21,7 +21,7 @@ import {
  *  ASCII decoding assumes file is UTF-8.
  *
  * Usage:
- *  var loader = new STLLoader();
+ *  const loader = new STLLoader();
  *  loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
  *    scene.add( new THREE.Mesh( geometry ) );
  *  });
@@ -31,24 +31,24 @@ import {
  *  if (geometry.hasColors) {
  *    material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
  *  } else { .... }
- *  var mesh = new THREE.Mesh( geometry, material );
+ *  const mesh = new THREE.Mesh( geometry, material );
  *
  * For ASCII STLs containing multiple solids, each solid is assigned to a different group.
  * Groups can be used to assign a different color by defining an array of materials with the same length of
  * geometry.groups and passing it to the Mesh constructor:
  *
- * var mesh = new THREE.Mesh( geometry, material );
+ * const mesh = new THREE.Mesh( geometry, material );
  *
  * For example:
  *
- *  var materials = [];
- *  var nGeometryGroups = geometry.groups.length;
+ *  const materials = [];
+ *  const nGeometryGroups = geometry.groups.length;
  *
- *  var colorMap = ...; // Some logic to index colors.
+ *  const colorMap = ...; // Some logic to index colors.
  *
- *  for (var i = 0; i < nGeometryGroups; i++) {
+ *  for (let i = 0; i < nGeometryGroups; i++) {
  *
- *		var material = new THREE.MeshPhongMaterial({
+ *		const material = new THREE.MeshPhongMaterial({
  *			color: colorMap[i],
  *			wireframe: false
  *		});
@@ -56,25 +56,23 @@ import {
  *  }
  *
  *  materials.push(material);
- *  var mesh = new THREE.Mesh(geometry, materials);
+ *  const mesh = new THREE.Mesh(geometry, materials);
  */
 
 
-var STLLoader = function ( manager ) {
+class STLLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: STLLoader,
+	}
 
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 		loader.setPath( this.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( this.requestHeader );
@@ -104,17 +102,16 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( data ) {
+	parse( data ) {
 
 		function isBinary( data ) {
 
-			var expect, face_size, n_faces, reader;
-			reader = new DataView( data );
-			face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
-			n_faces = reader.getUint32( 80, true );
-			expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
+			const reader = new DataView( data );
+			const face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
+			const n_faces = reader.getUint32( 80, true );
+			const expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
 
 			if ( expect === reader.byteLength ) {
 
@@ -132,9 +129,9 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
 
-			var solid = [ 115, 111, 108, 105, 100 ];
+			const solid = [ 115, 111, 108, 105, 100 ];
 
-			for ( var off = 0; off < 5; off ++ ) {
+			for ( let off = 0; off < 5; off ++ ) {
 
 				// If "solid" text is matched to the current offset, declare it to be an ASCII STL.
 
@@ -152,7 +149,7 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			// Check if each byte in query matches the corresponding byte from the current offset
 
-			for ( var i = 0, il = query.length; i < il; i ++ ) {
+			for ( let i = 0, il = query.length; i < il; i ++ ) {
 
 				if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
 
@@ -164,16 +161,16 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function parseBinary( data ) {
 
-			var reader = new DataView( data );
-			var faces = reader.getUint32( 80, true );
+			const reader = new DataView( data );
+			const faces = reader.getUint32( 80, true );
 
-			var r, g, b, hasColors = false, colors;
-			var defaultR, defaultG, defaultB, alpha;
+			let r, g, b, hasColors = false, colors;
+			let defaultR, defaultG, defaultB, alpha;
 
 			// process STL header
 			// check for default color in header ("COLOR=rgba" sequence).
 
-			for ( var index = 0; index < 80 - 10; index ++ ) {
+			for ( let index = 0; index < 80 - 10; index ++ ) {
 
 				if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
 					( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
@@ -191,24 +188,24 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			}
 
-			var dataOffset = 84;
-			var faceLength = 12 * 4 + 2;
+			const dataOffset = 84;
+			const faceLength = 12 * 4 + 2;
 
-			var geometry = new BufferGeometry();
+			const geometry = new BufferGeometry();
 
-			var vertices = new Float32Array( faces * 3 * 3 );
-			var normals = new Float32Array( faces * 3 * 3 );
+			const vertices = new Float32Array( faces * 3 * 3 );
+			const normals = new Float32Array( faces * 3 * 3 );
 
-			for ( var face = 0; face < faces; face ++ ) {
+			for ( let face = 0; face < faces; face ++ ) {
 
-				var start = dataOffset + face * faceLength;
-				var normalX = reader.getFloat32( start, true );
-				var normalY = reader.getFloat32( start + 4, true );
-				var normalZ = reader.getFloat32( start + 8, true );
+				const start = dataOffset + face * faceLength;
+				const normalX = reader.getFloat32( start, true );
+				const normalY = reader.getFloat32( start + 4, true );
+				const normalZ = reader.getFloat32( start + 8, true );
 
 				if ( hasColors ) {
 
-					var packedColor = reader.getUint16( start + 48, true );
+					const packedColor = reader.getUint16( start + 48, true );
 
 					if ( ( packedColor & 0x8000 ) === 0 ) {
 
@@ -228,10 +225,10 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				for ( var i = 1; i <= 3; i ++ ) {
+				for ( let i = 1; i <= 3; i ++ ) {
 
-					var vertexstart = start + i * 12;
-					var componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
+					const vertexstart = start + i * 12;
+					const componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
 
 					vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
 					vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
@@ -270,38 +267,38 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function parseASCII( data ) {
 
-			var geometry = new BufferGeometry();
-			var patternSolid = /solid([\s\S]*?)endsolid/g;
-			var patternFace = /facet([\s\S]*?)endfacet/g;
-			var faceCounter = 0;
+			const geometry = new BufferGeometry();
+			const patternSolid = /solid([\s\S]*?)endsolid/g;
+			const patternFace = /facet([\s\S]*?)endfacet/g;
+			let faceCounter = 0;
 
-			var patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
-			var patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
-			var patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
+			const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
+			const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
+			const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
 
-			var vertices = [];
-			var normals = [];
+			const vertices = [];
+			const normals = [];
 
-			var normal = new Vector3();
+			const normal = new Vector3();
 
-			var result;
+			let result;
 
-			var groupCount = 0;
-			var startVertex = 0;
-			var endVertex = 0;
+			let groupCount = 0;
+			let startVertex = 0;
+			let endVertex = 0;
 
 			while ( ( result = patternSolid.exec( data ) ) !== null ) {
 
 				startVertex = endVertex;
 
-				var solid = result[ 0 ];
+				const solid = result[ 0 ];
 
 				while ( ( result = patternFace.exec( solid ) ) !== null ) {
 
-					var vertexCountPerFace = 0;
-					var normalCountPerFace = 0;
+					let vertexCountPerFace = 0;
+					let normalCountPerFace = 0;
 
-					var text = result[ 0 ];
+					const text = result[ 0 ];
 
 					while ( ( result = patternNormal.exec( text ) ) !== null ) {
 
@@ -341,8 +338,8 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				}
 
-				var start = startVertex;
-				var count = endVertex - startVertex;
+				const start = startVertex;
+				const count = endVertex - startVertex;
 
 				geometry.addGroup( start, count, groupCount );
 				groupCount ++;
@@ -372,8 +369,8 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			if ( typeof buffer === 'string' ) {
 
-				var array_buffer = new Uint8Array( buffer.length );
-				for ( var i = 0; i < buffer.length; i ++ ) {
+				const array_buffer = new Uint8Array( buffer.length );
+				for ( let i = 0; i < buffer.length; i ++ ) {
 
 					array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
 
@@ -391,12 +388,12 @@ STLLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		// start
 
-		var binData = ensureBinary( data );
+		const binData = ensureBinary( data );
 
 		return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
 
 	}
 
-} );
+}
 
 export { STLLoader };

+ 352 - 355
examples/jsm/loaders/TDSLoader.js

@@ -23,23 +23,21 @@ import {
  * @constructor
  */
 
-var TDSLoader = function ( manager ) {
+class TDSLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-	this.debug = false;
+		super( manager );
 
-	this.group = null;
-	this.position = 0;
+		this.debug = false;
 
-	this.materials = [];
-	this.meshes = [];
-
-};
+		this.group = null;
+		this.position = 0;
 
-TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
+		this.materials = [];
+		this.meshes = [];
 
-	constructor: TDSLoader,
+	}
 
 	/**
 	 * Load 3ds file from url.
@@ -50,13 +48,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Function} onProgress onProgress callback.
 	 * @param {Function} onError onError callback.
 	 */
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path;
+		const path = ( this.path === '' ) ? LoaderUtils.extractUrlBase( url ) : this.path;
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 		loader.setPath( this.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( this.requestHeader );
@@ -86,7 +84,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
 	/**
 	 * Parse arraybuffer data and load 3ds file.
@@ -96,7 +94,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {String} path Path for external resources.
 	 * @return {Group} Group loaded from 3ds file.
 	 */
-	parse: function ( arraybuffer, path ) {
+	parse( arraybuffer, path ) {
 
 		this.group = new Group();
 		this.position = 0;
@@ -105,7 +103,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		this.readFile( arraybuffer, path );
 
-		for ( var i = 0; i < this.meshes.length; i ++ ) {
+		for ( let i = 0; i < this.meshes.length; i ++ ) {
 
 			this.group.add( this.meshes[ i ] );
 
@@ -113,7 +111,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return this.group;
 
-	},
+	}
 
 	/**
 	 * Decode file content to read 3ds data.
@@ -122,20 +120,20 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
 	 * @param {String} path Path for external resources.
 	 */
-	readFile: function ( arraybuffer, path ) {
+	readFile( arraybuffer, path ) {
 
-		var data = new DataView( arraybuffer );
-		var chunk = this.readChunk( data );
+		const data = new DataView( arraybuffer );
+		const chunk = this.readChunk( data );
 
 		if ( chunk.id === MLIBMAGIC || chunk.id === CMAGIC || chunk.id === M3DMAGIC ) {
 
-			var next = this.nextChunk( data, chunk );
+			let next = this.nextChunk( data, chunk );
 
 			while ( next !== 0 ) {
 
 				if ( next === M3D_VERSION ) {
 
-					var version = this.readDWord( data );
+					const version = this.readDWord( data );
 					this.debugMessage( '3DS file version: ' + version );
 
 				} else if ( next === MDATA ) {
@@ -157,7 +155,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		this.debugMessage( 'Parsed ' + this.meshes.length + ' meshes' );
 
-	},
+	}
 
 	/**
 	 * Read mesh data chunk.
@@ -166,21 +164,21 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Dataview} data Dataview in use.
 	 * @param {String} path Path for external resources.
 	 */
-	readMeshData: function ( data, path ) {
+	readMeshData( data, path ) {
 
-		var chunk = this.readChunk( data );
-		var next = this.nextChunk( data, chunk );
+		const chunk = this.readChunk( data );
+		let next = this.nextChunk( data, chunk );
 
 		while ( next !== 0 ) {
 
 			if ( next === MESH_VERSION ) {
 
-				var version = + this.readDWord( data );
+				const version = + this.readDWord( data );
 				this.debugMessage( 'Mesh Version: ' + version );
 
 			} else if ( next === MASTER_SCALE ) {
 
-				var scale = this.readFloat( data );
+				const scale = this.readFloat( data );
 				this.debugMessage( 'Master scale: ' + scale );
 				this.group.scale.set( scale, scale, scale );
 
@@ -206,7 +204,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-	},
+	}
 
 	/**
 	 * Read named object chunk.
@@ -214,19 +212,19 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @method readNamedObject
 	 * @param {Dataview} data Dataview in use.
 	 */
-	readNamedObject: function ( data ) {
+	readNamedObject( data ) {
 
-		var chunk = this.readChunk( data );
-		var name = this.readString( data, 64 );
+		const chunk = this.readChunk( data );
+		const name = this.readString( data, 64 );
 		chunk.cur = this.position;
 
-		var next = this.nextChunk( data, chunk );
+		let next = this.nextChunk( data, chunk );
 		while ( next !== 0 ) {
 
 			if ( next === N_TRI_OBJECT ) {
 
 				this.resetPosition( data );
-				var mesh = this.readMesh( data );
+				const mesh = this.readMesh( data );
 				mesh.name = name;
 				this.meshes.push( mesh );
 
@@ -242,7 +240,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		this.endChunk( chunk );
 
-	},
+	}
 
 	/**
 	 * Read material data chunk and add it to the material list.
@@ -251,11 +249,11 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Dataview} data Dataview in use.
 	 * @param {String} path Path for external resources.
 	 */
-	readMaterialEntry: function ( data, path ) {
+	readMaterialEntry( data, path ) {
 
-		var chunk = this.readChunk( data );
-		var next = this.nextChunk( data, chunk );
-		var material = new MeshPhongMaterial();
+		const chunk = this.readChunk( data );
+		let next = this.nextChunk( data, chunk );
+		const material = new MeshPhongMaterial();
 
 		while ( next !== 0 ) {
 
@@ -271,7 +269,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} else if ( next === MAT_WIRE_SIZE ) {
 
-				var value = this.readByte( data );
+				const value = this.readByte( data );
 				material.wireframeLinewidth = value;
 				this.debugMessage( '   Wireframe Thickness: ' + value );
 
@@ -302,13 +300,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} else if ( next === MAT_SHININESS ) {
 
-				var shininess = this.readPercentage( data );
+				const shininess = this.readPercentage( data );
 				material.shininess = shininess * 100;
 				this.debugMessage( '   Shininess : ' + shininess );
 
 			} else if ( next === MAT_TRANSPARENCY ) {
 
-				var transparency = this.readPercentage( data );
+				const transparency = this.readPercentage( data );
 				material.opacity = 1 - transparency;
 				this.debugMessage( '  Transparency : ' + transparency );
 				material.transparent = material.opacity < 1 ? true : false;
@@ -351,7 +349,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		this.materials[ material.name ] = material;
 
-	},
+	}
 
 	/**
 	 * Read mesh data chunk.
@@ -360,31 +358,30 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Mesh} The parsed mesh.
 	 */
-	readMesh: function ( data ) {
+	readMesh( data ) {
 
-		var chunk = this.readChunk( data );
-		var next = this.nextChunk( data, chunk );
+		const chunk = this.readChunk( data );
+		let next = this.nextChunk( data, chunk );
 
-		var geometry = new BufferGeometry();
-		var uvs = [];
+		const geometry = new BufferGeometry();
 
-		var material = new MeshPhongMaterial();
-		var mesh = new Mesh( geometry, material );
+		const material = new MeshPhongMaterial();
+		const mesh = new Mesh( geometry, material );
 		mesh.name = 'mesh';
 
 		while ( next !== 0 ) {
 
 			if ( next === POINT_ARRAY ) {
 
-				var points = this.readWord( data );
+				const points = this.readWord( data );
 
 				this.debugMessage( '   Vertex: ' + points );
 
 				//BufferGeometry
 
-				var vertices = [];
+				const vertices = [];
 
-				for ( var i = 0; i < points; i ++ )		{
+				for ( let i = 0; i < points; i ++ )		{
 
 					vertices.push( this.readFloat( data ) );
 					vertices.push( this.readFloat( data ) );
@@ -401,15 +398,15 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} else if ( next === TEX_VERTS ) {
 
-				var texels = this.readWord( data );
+				const texels = this.readWord( data );
 
 				this.debugMessage( '   UV: ' + texels );
 
 				//BufferGeometry
 
-				var uvs = [];
+				const uvs = [];
 
-				for ( var i = 0; i < texels; i ++ )		{
+				for ( let i = 0; i < texels; i ++ )		{
 
 					uvs.push( this.readFloat( data ) );
 					uvs.push( this.readFloat( data ) );
@@ -423,14 +420,14 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				this.debugMessage( '   Tranformation Matrix (TODO)' );
 
-				var values = [];
-				for ( var i = 0; i < 12; i ++ ) {
+				const values = [];
+				for ( let i = 0; i < 12; i ++ ) {
 
 					values[ i ] = this.readFloat( data );
 
 				}
 
-				var matrix = new Matrix4();
+				const matrix = new Matrix4();
 
 				//X Line
 				matrix.elements[ 0 ] = values[ 0 ];
@@ -458,7 +455,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				matrix.transpose();
 
-				var inverse = new Matrix4();
+				const inverse = new Matrix4();
 				inverse.copy( matrix ).invert();
 				geometry.applyMatrix4( inverse );
 
@@ -480,7 +477,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return mesh;
 
-	},
+	}
 
 	/**
 	 * Read face array data chunk.
@@ -489,16 +486,16 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Dataview} data Dataview in use.
 	 * @param {Mesh} mesh Mesh to be filled with the data read.
 	 */
-	readFaceArray: function ( data, mesh ) {
+	readFaceArray( data, mesh ) {
 
-		var chunk = this.readChunk( data );
-		var faces = this.readWord( data );
+		const chunk = this.readChunk( data );
+		const faces = this.readWord( data );
 
 		this.debugMessage( '   Faces: ' + faces );
 
-		var index = [];
+		const index = [];
 
-		for ( var i = 0; i < faces; ++ i ) {
+		for ( let i = 0; i < faces; ++ i ) {
 
 			index.push( this.readWord( data ), this.readWord( data ), this.readWord( data ) );
 
@@ -510,12 +507,12 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		//The rest of the FACE_ARRAY chunk is subchunks
 
-		var materialIndex = 0;
-		var start = 0;
+		let materialIndex = 0;
+		let start = 0;
 
 		while ( this.position < chunk.end ) {
 
-			var subchunk = this.readChunk( data );
+			const subchunk = this.readChunk( data );
 
 			if ( subchunk.id === MSH_MAT_GROUP ) {
 
@@ -523,15 +520,15 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				this.resetPosition( data );
 
-				var group = this.readMaterialGroup( data );
-				var count = group.index.length * 3; // assuming successive indices
+				const group = this.readMaterialGroup( data );
+				const count = group.index.length * 3; // assuming successive indices
 
 				mesh.geometry.addGroup( start, count, materialIndex );
 
 				start += count;
 				materialIndex ++;
 
-				var material = this.materials[ group.name ];
+				const material = this.materials[ group.name ];
 
 				if ( Array.isArray( mesh.material ) === false ) mesh.material = [];
 
@@ -555,7 +552,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		this.endChunk( chunk );
 
-	},
+	}
 
 	/**
 	 * Read texture map data chunk.
@@ -565,20 +562,20 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {String} path Path for external resources.
 	 * @return {Texture} Texture read from this data chunk.
 	 */
-	readMap: function ( data, path ) {
+	readMap( data, path ) {
 
-		var chunk = this.readChunk( data );
-		var next = this.nextChunk( data, chunk );
-		var texture = {};
+		const chunk = this.readChunk( data );
+		let next = this.nextChunk( data, chunk );
+		let texture = {};
 
-		var loader = new TextureLoader( this.manager );
+		const loader = new TextureLoader( this.manager );
 		loader.setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
 
 		while ( next !== 0 ) {
 
 			if ( next === MAT_MAPNAME ) {
 
-				var name = this.readString( data, 128 );
+				const name = this.readString( data, 128 );
 				texture = loader.load( name );
 
 				this.debugMessage( '      File: ' + path + name );
@@ -617,7 +614,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return texture;
 
-	},
+	}
 
 	/**
 	 * Read material group data chunk.
@@ -626,17 +623,17 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Dataview} data Dataview in use.
 	 * @return {Object} Object with name and index of the object.
 	 */
-	readMaterialGroup: function ( data ) {
+	readMaterialGroup( data ) {
 
 		this.readChunk( data );
-		var name = this.readString( data, 64 );
-		var numFaces = this.readWord( data );
+		const name = this.readString( data, 64 );
+		const numFaces = this.readWord( data );
 
 		this.debugMessage( '         Name: ' + name );
 		this.debugMessage( '         Faces: ' + numFaces );
 
-		var index = [];
-		for ( var i = 0; i < numFaces; ++ i ) {
+		const index = [];
+		for ( let i = 0; i < numFaces; ++ i ) {
 
 			index.push( this.readWord( data ) );
 
@@ -644,7 +641,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return { name: name, index: index };
 
-	},
+	}
 
 	/**
 	 * Read a color value.
@@ -653,16 +650,16 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview.
 	 * @return {Color} Color value read..
 	 */
-	readColor: function ( data ) {
+	readColor( data ) {
 
-		var chunk = this.readChunk( data );
-		var color = new Color();
+		const chunk = this.readChunk( data );
+		const color = new Color();
 
 		if ( chunk.id === COLOR_24 || chunk.id === LIN_COLOR_24 ) {
 
-			var r = this.readByte( data );
-			var g = this.readByte( data );
-			var b = this.readByte( data );
+			const r = this.readByte( data );
+			const g = this.readByte( data );
+			const b = this.readByte( data );
 
 			color.setRGB( r / 255, g / 255, b / 255 );
 
@@ -670,9 +667,9 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}	else if ( chunk.id === COLOR_F || chunk.id === LIN_COLOR_F ) {
 
-			var r = this.readFloat( data );
-			var g = this.readFloat( data );
-			var b = this.readFloat( data );
+			const r = this.readFloat( data );
+			const g = this.readFloat( data );
+			const b = this.readFloat( data );
 
 			color.setRGB( r, g, b );
 
@@ -687,7 +684,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		this.endChunk( chunk );
 		return color;
 
-	},
+	}
 
 	/**
 	 * Read next chunk of data.
@@ -696,9 +693,9 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview.
 	 * @return {Object} Chunk of data read.
 	 */
-	readChunk: function ( data ) {
+	readChunk( data ) {
 
-		var chunk = {};
+		const chunk = {};
 
 		chunk.cur = this.position;
 		chunk.id = this.readWord( data );
@@ -708,7 +705,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return chunk;
 
-	},
+	}
 
 	/**
 	 * Set position to the end of the current chunk of data.
@@ -716,11 +713,11 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @method endChunk
 	 * @param {Object} chunk Data chunk.
 	 */
-	endChunk: function ( chunk ) {
+	endChunk( chunk ) {
 
 		this.position = chunk.end;
 
-	},
+	}
 
 	/**
 	 * Move to the next data chunk.
@@ -729,7 +726,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview.
 	 * @param {Object} chunk Data chunk.
 	 */
-	nextChunk: function ( data, chunk ) {
+	nextChunk( data, chunk ) {
 
 		if ( chunk.cur >= chunk.end ) {
 
@@ -741,7 +738,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		try {
 
-			var next = this.readChunk( data );
+			const next = this.readChunk( data );
 			chunk.cur += next.size;
 			return next.id;
 
@@ -752,18 +749,18 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-	},
+	}
 
 	/**
 	 * Reset dataview position.
 	 *
 	 * @method resetPosition
 	 */
-	resetPosition: function () {
+	resetPosition() {
 
 		this.position -= 6;
 
-	},
+	}
 
 	/**
 	 * Read byte value.
@@ -772,13 +769,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readByte: function ( data ) {
+	readByte( data ) {
 
-		var v = data.getUint8( this.position, true );
+		const v = data.getUint8( this.position, true );
 		this.position += 1;
 		return v;
 
-	},
+	}
 
 	/**
 	 * Read 32 bit float value.
@@ -787,11 +784,11 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readFloat: function ( data ) {
+	readFloat( data ) {
 
 		try {
 
-			var v = data.getFloat32( this.position, true );
+			const v = data.getFloat32( this.position, true );
 			this.position += 4;
 			return v;
 
@@ -801,7 +798,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}
 
-	},
+	}
 
 	/**
 	 * Read 32 bit signed integer value.
@@ -810,13 +807,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readInt: function ( data ) {
+	readInt( data ) {
 
-		var v = data.getInt32( this.position, true );
+		const v = data.getInt32( this.position, true );
 		this.position += 4;
 		return v;
 
-	},
+	}
 
 	/**
 	 * Read 16 bit signed integer value.
@@ -825,13 +822,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readShort: function ( data ) {
+	readShort( data ) {
 
-		var v = data.getInt16( this.position, true );
+		const v = data.getInt16( this.position, true );
 		this.position += 2;
 		return v;
 
-	},
+	}
 
 	/**
 	 * Read 64 bit unsigned integer value.
@@ -840,13 +837,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readDWord: function ( data ) {
+	readDWord( data ) {
 
-		var v = data.getUint32( this.position, true );
+		const v = data.getUint32( this.position, true );
 		this.position += 4;
 		return v;
 
-	},
+	}
 
 	/**
 	 * Read 32 bit unsigned integer value.
@@ -855,13 +852,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readWord: function ( data ) {
+	readWord( data ) {
 
-		var v = data.getUint16( this.position, true );
+		const v = data.getUint16( this.position, true );
 		this.position += 2;
 		return v;
 
-	},
+	}
 
 	/**
 	 * Read string value.
@@ -871,13 +868,13 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {Number} maxLength Max size of the string to be read.
 	 * @return {String} Data read from the dataview.
 	 */
-	readString: function ( data, maxLength ) {
+	readString( data, maxLength ) {
 
-		var s = '';
+		let s = '';
 
-		for ( var i = 0; i < maxLength; i ++ ) {
+		for ( let i = 0; i < maxLength; i ++ ) {
 
-			var c = this.readByte( data );
+			const c = this.readByte( data );
 			if ( ! c ) {
 
 				break;
@@ -890,7 +887,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return s;
 
-	},
+	}
 
 	/**
 	 * Read percentage value.
@@ -899,10 +896,10 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @param {DataView} data Dataview to read data from.
 	 * @return {Number} Data read from the dataview.
 	 */
-	readPercentage: function ( data ) {
+	readPercentage( data ) {
 
-		var chunk = this.readChunk( data );
-		var value;
+		const chunk = this.readChunk( data );
+		let value;
 
 		switch ( chunk.id ) {
 
@@ -923,7 +920,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		return value;
 
-	},
+	}
 
 	/**
 	 * Print debug message to the console.
@@ -933,7 +930,7 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 	 * @method debugMessage
 	 * @param {Object} message Debug message to print to the console.
 	 */
-	debugMessage: function ( message ) {
+	debugMessage( message ) {
 
 		if ( this.debug ) {
 
@@ -943,224 +940,224 @@ TDSLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
-
-// var NULL_CHUNK = 0x0000;
-var M3DMAGIC = 0x4D4D;
-// var SMAGIC = 0x2D2D;
-// var LMAGIC = 0x2D3D;
-var MLIBMAGIC = 0x3DAA;
-// var MATMAGIC = 0x3DFF;
-var CMAGIC = 0xC23D;
-var M3D_VERSION = 0x0002;
-// var M3D_KFVERSION = 0x0005;
-var COLOR_F = 0x0010;
-var COLOR_24 = 0x0011;
-var LIN_COLOR_24 = 0x0012;
-var LIN_COLOR_F = 0x0013;
-var INT_PERCENTAGE = 0x0030;
-var FLOAT_PERCENTAGE = 0x0031;
-var MDATA = 0x3D3D;
-var MESH_VERSION = 0x3D3E;
-var MASTER_SCALE = 0x0100;
-// var LO_SHADOW_BIAS = 0x1400;
-// var HI_SHADOW_BIAS = 0x1410;
-// var SHADOW_MAP_SIZE = 0x1420;
-// var SHADOW_SAMPLES = 0x1430;
-// var SHADOW_RANGE = 0x1440;
-// var SHADOW_FILTER = 0x1450;
-// var RAY_BIAS = 0x1460;
-// var O_CONSTS = 0x1500;
-// var AMBIENT_LIGHT = 0x2100;
-// var BIT_MAP = 0x1100;
-// var SOLID_BGND = 0x1200;
-// var V_GRADIENT = 0x1300;
-// var USE_BIT_MAP = 0x1101;
-// var USE_SOLID_BGND = 0x1201;
-// var USE_V_GRADIENT = 0x1301;
-// var FOG = 0x2200;
-// var FOG_BGND = 0x2210;
-// var LAYER_FOG = 0x2302;
-// var DISTANCE_CUE = 0x2300;
-// var DCUE_BGND = 0x2310;
-// var USE_FOG = 0x2201;
-// var USE_LAYER_FOG = 0x2303;
-// var USE_DISTANCE_CUE = 0x2301;
-var MAT_ENTRY = 0xAFFF;
-var MAT_NAME = 0xA000;
-var MAT_AMBIENT = 0xA010;
-var MAT_DIFFUSE = 0xA020;
-var MAT_SPECULAR = 0xA030;
-var MAT_SHININESS = 0xA040;
-// var MAT_SHIN2PCT = 0xA041;
-var MAT_TRANSPARENCY = 0xA050;
-// var MAT_XPFALL = 0xA052;
-// var MAT_USE_XPFALL = 0xA240;
-// var MAT_REFBLUR = 0xA053;
-// var MAT_SHADING = 0xA100;
-// var MAT_USE_REFBLUR = 0xA250;
-// var MAT_SELF_ILLUM = 0xA084;
-var MAT_TWO_SIDE = 0xA081;
-// var MAT_DECAL = 0xA082;
-var MAT_ADDITIVE = 0xA083;
-var MAT_WIRE = 0xA085;
-// var MAT_FACEMAP = 0xA088;
-// var MAT_TRANSFALLOFF_IN = 0xA08A;
-// var MAT_PHONGSOFT = 0xA08C;
-// var MAT_WIREABS = 0xA08E;
-var MAT_WIRE_SIZE = 0xA087;
-var MAT_TEXMAP = 0xA200;
-// var MAT_SXP_TEXT_DATA = 0xA320;
-// var MAT_TEXMASK = 0xA33E;
-// var MAT_SXP_TEXTMASK_DATA = 0xA32A;
-// var MAT_TEX2MAP = 0xA33A;
-// var MAT_SXP_TEXT2_DATA = 0xA321;
-// var MAT_TEX2MASK = 0xA340;
-// var MAT_SXP_TEXT2MASK_DATA = 0xA32C;
-var MAT_OPACMAP = 0xA210;
-// var MAT_SXP_OPAC_DATA = 0xA322;
-// var MAT_OPACMASK = 0xA342;
-// var MAT_SXP_OPACMASK_DATA = 0xA32E;
-var MAT_BUMPMAP = 0xA230;
-// var MAT_SXP_BUMP_DATA = 0xA324;
-// var MAT_BUMPMASK = 0xA344;
-// var MAT_SXP_BUMPMASK_DATA = 0xA330;
-var MAT_SPECMAP = 0xA204;
-// var MAT_SXP_SPEC_DATA = 0xA325;
-// var MAT_SPECMASK = 0xA348;
-// var MAT_SXP_SPECMASK_DATA = 0xA332;
-// var MAT_SHINMAP = 0xA33C;
-// var MAT_SXP_SHIN_DATA = 0xA326;
-// var MAT_SHINMASK = 0xA346;
-// var MAT_SXP_SHINMASK_DATA = 0xA334;
-// var MAT_SELFIMAP = 0xA33D;
-// var MAT_SXP_SELFI_DATA = 0xA328;
-// var MAT_SELFIMASK = 0xA34A;
-// var MAT_SXP_SELFIMASK_DATA = 0xA336;
-// var MAT_REFLMAP = 0xA220;
-// var MAT_REFLMASK = 0xA34C;
-// var MAT_SXP_REFLMASK_DATA = 0xA338;
-// var MAT_ACUBIC = 0xA310;
-var MAT_MAPNAME = 0xA300;
-// var MAT_MAP_TILING = 0xA351;
-// var MAT_MAP_TEXBLUR = 0xA353;
-var MAT_MAP_USCALE = 0xA354;
-var MAT_MAP_VSCALE = 0xA356;
-var MAT_MAP_UOFFSET = 0xA358;
-var MAT_MAP_VOFFSET = 0xA35A;
-// var MAT_MAP_ANG = 0xA35C;
-// var MAT_MAP_COL1 = 0xA360;
-// var MAT_MAP_COL2 = 0xA362;
-// var MAT_MAP_RCOL = 0xA364;
-// var MAT_MAP_GCOL = 0xA366;
-// var MAT_MAP_BCOL = 0xA368;
-var NAMED_OBJECT = 0x4000;
-// var N_DIRECT_LIGHT = 0x4600;
-// var DL_OFF = 0x4620;
-// var DL_OUTER_RANGE = 0x465A;
-// var DL_INNER_RANGE = 0x4659;
-// var DL_MULTIPLIER = 0x465B;
-// var DL_EXCLUDE = 0x4654;
-// var DL_ATTENUATE = 0x4625;
-// var DL_SPOTLIGHT = 0x4610;
-// var DL_SPOT_ROLL = 0x4656;
-// var DL_SHADOWED = 0x4630;
-// var DL_LOCAL_SHADOW2 = 0x4641;
-// var DL_SEE_CONE = 0x4650;
-// var DL_SPOT_RECTANGULAR = 0x4651;
-// var DL_SPOT_ASPECT = 0x4657;
-// var DL_SPOT_PROJECTOR = 0x4653;
-// var DL_SPOT_OVERSHOOT = 0x4652;
-// var DL_RAY_BIAS = 0x4658;
-// var DL_RAYSHAD = 0x4627;
-// var N_CAMERA = 0x4700;
-// var CAM_SEE_CONE = 0x4710;
-// var CAM_RANGES = 0x4720;
-// var OBJ_HIDDEN = 0x4010;
-// var OBJ_VIS_LOFTER = 0x4011;
-// var OBJ_DOESNT_CAST = 0x4012;
-// var OBJ_DONT_RECVSHADOW = 0x4017;
-// var OBJ_MATTE = 0x4013;
-// var OBJ_FAST = 0x4014;
-// var OBJ_PROCEDURAL = 0x4015;
-// var OBJ_FROZEN = 0x4016;
-var N_TRI_OBJECT = 0x4100;
-var POINT_ARRAY = 0x4110;
-// var POINT_FLAG_ARRAY = 0x4111;
-var FACE_ARRAY = 0x4120;
-var MSH_MAT_GROUP = 0x4130;
-// var SMOOTH_GROUP = 0x4150;
-// var MSH_BOXMAP = 0x4190;
-var TEX_VERTS = 0x4140;
-var MESH_MATRIX = 0x4160;
-// var MESH_COLOR = 0x4165;
-// var MESH_TEXTURE_INFO = 0x4170;
-// var KFDATA = 0xB000;
-// var KFHDR = 0xB00A;
-// var KFSEG = 0xB008;
-// var KFCURTIME = 0xB009;
-// var AMBIENT_NODE_TAG = 0xB001;
-// var OBJECT_NODE_TAG = 0xB002;
-// var CAMERA_NODE_TAG = 0xB003;
-// var TARGET_NODE_TAG = 0xB004;
-// var LIGHT_NODE_TAG = 0xB005;
-// var L_TARGET_NODE_TAG = 0xB006;
-// var SPOTLIGHT_NODE_TAG = 0xB007;
-// var NODE_ID = 0xB030;
-// var NODE_HDR = 0xB010;
-// var PIVOT = 0xB013;
-// var INSTANCE_NAME = 0xB011;
-// var MORPH_SMOOTH = 0xB015;
-// var BOUNDBOX = 0xB014;
-// var POS_TRACK_TAG = 0xB020;
-// var COL_TRACK_TAG = 0xB025;
-// var ROT_TRACK_TAG = 0xB021;
-// var SCL_TRACK_TAG = 0xB022;
-// var MORPH_TRACK_TAG = 0xB026;
-// var FOV_TRACK_TAG = 0xB023;
-// var ROLL_TRACK_TAG = 0xB024;
-// var HOT_TRACK_TAG = 0xB027;
-// var FALL_TRACK_TAG = 0xB028;
-// var HIDE_TRACK_TAG = 0xB029;
-// var POLY_2D = 0x5000;
-// var SHAPE_OK = 0x5010;
-// var SHAPE_NOT_OK = 0x5011;
-// var SHAPE_HOOK = 0x5020;
-// var PATH_3D = 0x6000;
-// var PATH_MATRIX = 0x6005;
-// var SHAPE_2D = 0x6010;
-// var M_SCALE = 0x6020;
-// var M_TWIST = 0x6030;
-// var M_TEETER = 0x6040;
-// var M_FIT = 0x6050;
-// var M_BEVEL = 0x6060;
-// var XZ_CURVE = 0x6070;
-// var YZ_CURVE = 0x6080;
-// var INTERPCT = 0x6090;
-// var DEFORM_LIMIT = 0x60A0;
-// var USE_CONTOUR = 0x6100;
-// var USE_TWEEN = 0x6110;
-// var USE_SCALE = 0x6120;
-// var USE_TWIST = 0x6130;
-// var USE_TEETER = 0x6140;
-// var USE_FIT = 0x6150;
-// var USE_BEVEL = 0x6160;
-// var DEFAULT_VIEW = 0x3000;
-// var VIEW_TOP = 0x3010;
-// var VIEW_BOTTOM = 0x3020;
-// var VIEW_LEFT = 0x3030;
-// var VIEW_RIGHT = 0x3040;
-// var VIEW_FRONT = 0x3050;
-// var VIEW_BACK = 0x3060;
-// var VIEW_USER = 0x3070;
-// var VIEW_CAMERA = 0x3080;
-// var VIEW_WINDOW = 0x3090;
-// var VIEWPORT_LAYOUT_OLD = 0x7000;
-// var VIEWPORT_DATA_OLD = 0x7010;
-// var VIEWPORT_LAYOUT = 0x7001;
-// var VIEWPORT_DATA = 0x7011;
-// var VIEWPORT_DATA_3 = 0x7012;
-// var VIEWPORT_SIZE = 0x7020;
-// var NETWORK_VIEW = 0x7030;
+}
+
+// const NULL_CHUNK = 0x0000;
+const M3DMAGIC = 0x4D4D;
+// const SMAGIC = 0x2D2D;
+// const LMAGIC = 0x2D3D;
+const MLIBMAGIC = 0x3DAA;
+// const MATMAGIC = 0x3DFF;
+const CMAGIC = 0xC23D;
+const M3D_VERSION = 0x0002;
+// const M3D_KFVERSION = 0x0005;
+const COLOR_F = 0x0010;
+const COLOR_24 = 0x0011;
+const LIN_COLOR_24 = 0x0012;
+const LIN_COLOR_F = 0x0013;
+const INT_PERCENTAGE = 0x0030;
+const FLOAT_PERCENTAGE = 0x0031;
+const MDATA = 0x3D3D;
+const MESH_VERSION = 0x3D3E;
+const MASTER_SCALE = 0x0100;
+// const LO_SHADOW_BIAS = 0x1400;
+// const HI_SHADOW_BIAS = 0x1410;
+// const SHADOW_MAP_SIZE = 0x1420;
+// const SHADOW_SAMPLES = 0x1430;
+// const SHADOW_RANGE = 0x1440;
+// const SHADOW_FILTER = 0x1450;
+// const RAY_BIAS = 0x1460;
+// const O_CONSTS = 0x1500;
+// const AMBIENT_LIGHT = 0x2100;
+// const BIT_MAP = 0x1100;
+// const SOLID_BGND = 0x1200;
+// const V_GRADIENT = 0x1300;
+// const USE_BIT_MAP = 0x1101;
+// const USE_SOLID_BGND = 0x1201;
+// const USE_V_GRADIENT = 0x1301;
+// const FOG = 0x2200;
+// const FOG_BGND = 0x2210;
+// const LAYER_FOG = 0x2302;
+// const DISTANCE_CUE = 0x2300;
+// const DCUE_BGND = 0x2310;
+// const USE_FOG = 0x2201;
+// const USE_LAYER_FOG = 0x2303;
+// const USE_DISTANCE_CUE = 0x2301;
+const MAT_ENTRY = 0xAFFF;
+const MAT_NAME = 0xA000;
+const MAT_AMBIENT = 0xA010;
+const MAT_DIFFUSE = 0xA020;
+const MAT_SPECULAR = 0xA030;
+const MAT_SHININESS = 0xA040;
+// const MAT_SHIN2PCT = 0xA041;
+const MAT_TRANSPARENCY = 0xA050;
+// const MAT_XPFALL = 0xA052;
+// const MAT_USE_XPFALL = 0xA240;
+// const MAT_REFBLUR = 0xA053;
+// const MAT_SHADING = 0xA100;
+// const MAT_USE_REFBLUR = 0xA250;
+// const MAT_SELF_ILLUM = 0xA084;
+const MAT_TWO_SIDE = 0xA081;
+// const MAT_DECAL = 0xA082;
+const MAT_ADDITIVE = 0xA083;
+const MAT_WIRE = 0xA085;
+// const MAT_FACEMAP = 0xA088;
+// const MAT_TRANSFALLOFF_IN = 0xA08A;
+// const MAT_PHONGSOFT = 0xA08C;
+// const MAT_WIREABS = 0xA08E;
+const MAT_WIRE_SIZE = 0xA087;
+const MAT_TEXMAP = 0xA200;
+// const MAT_SXP_TEXT_DATA = 0xA320;
+// const MAT_TEXMASK = 0xA33E;
+// const MAT_SXP_TEXTMASK_DATA = 0xA32A;
+// const MAT_TEX2MAP = 0xA33A;
+// const MAT_SXP_TEXT2_DATA = 0xA321;
+// const MAT_TEX2MASK = 0xA340;
+// const MAT_SXP_TEXT2MASK_DATA = 0xA32C;
+const MAT_OPACMAP = 0xA210;
+// const MAT_SXP_OPAC_DATA = 0xA322;
+// const MAT_OPACMASK = 0xA342;
+// const MAT_SXP_OPACMASK_DATA = 0xA32E;
+const MAT_BUMPMAP = 0xA230;
+// const MAT_SXP_BUMP_DATA = 0xA324;
+// const MAT_BUMPMASK = 0xA344;
+// const MAT_SXP_BUMPMASK_DATA = 0xA330;
+const MAT_SPECMAP = 0xA204;
+// const MAT_SXP_SPEC_DATA = 0xA325;
+// const MAT_SPECMASK = 0xA348;
+// const MAT_SXP_SPECMASK_DATA = 0xA332;
+// const MAT_SHINMAP = 0xA33C;
+// const MAT_SXP_SHIN_DATA = 0xA326;
+// const MAT_SHINMASK = 0xA346;
+// const MAT_SXP_SHINMASK_DATA = 0xA334;
+// const MAT_SELFIMAP = 0xA33D;
+// const MAT_SXP_SELFI_DATA = 0xA328;
+// const MAT_SELFIMASK = 0xA34A;
+// const MAT_SXP_SELFIMASK_DATA = 0xA336;
+// const MAT_REFLMAP = 0xA220;
+// const MAT_REFLMASK = 0xA34C;
+// const MAT_SXP_REFLMASK_DATA = 0xA338;
+// const MAT_ACUBIC = 0xA310;
+const MAT_MAPNAME = 0xA300;
+// const MAT_MAP_TILING = 0xA351;
+// const MAT_MAP_TEXBLUR = 0xA353;
+const MAT_MAP_USCALE = 0xA354;
+const MAT_MAP_VSCALE = 0xA356;
+const MAT_MAP_UOFFSET = 0xA358;
+const MAT_MAP_VOFFSET = 0xA35A;
+// const MAT_MAP_ANG = 0xA35C;
+// const MAT_MAP_COL1 = 0xA360;
+// const MAT_MAP_COL2 = 0xA362;
+// const MAT_MAP_RCOL = 0xA364;
+// const MAT_MAP_GCOL = 0xA366;
+// const MAT_MAP_BCOL = 0xA368;
+const NAMED_OBJECT = 0x4000;
+// const N_DIRECT_LIGHT = 0x4600;
+// const DL_OFF = 0x4620;
+// const DL_OUTER_RANGE = 0x465A;
+// const DL_INNER_RANGE = 0x4659;
+// const DL_MULTIPLIER = 0x465B;
+// const DL_EXCLUDE = 0x4654;
+// const DL_ATTENUATE = 0x4625;
+// const DL_SPOTLIGHT = 0x4610;
+// const DL_SPOT_ROLL = 0x4656;
+// const DL_SHADOWED = 0x4630;
+// const DL_LOCAL_SHADOW2 = 0x4641;
+// const DL_SEE_CONE = 0x4650;
+// const DL_SPOT_RECTANGULAR = 0x4651;
+// const DL_SPOT_ASPECT = 0x4657;
+// const DL_SPOT_PROJECTOR = 0x4653;
+// const DL_SPOT_OVERSHOOT = 0x4652;
+// const DL_RAY_BIAS = 0x4658;
+// const DL_RAYSHAD = 0x4627;
+// const N_CAMERA = 0x4700;
+// const CAM_SEE_CONE = 0x4710;
+// const CAM_RANGES = 0x4720;
+// const OBJ_HIDDEN = 0x4010;
+// const OBJ_VIS_LOFTER = 0x4011;
+// const OBJ_DOESNT_CAST = 0x4012;
+// const OBJ_DONT_RECVSHADOW = 0x4017;
+// const OBJ_MATTE = 0x4013;
+// const OBJ_FAST = 0x4014;
+// const OBJ_PROCEDURAL = 0x4015;
+// const OBJ_FROZEN = 0x4016;
+const N_TRI_OBJECT = 0x4100;
+const POINT_ARRAY = 0x4110;
+// const POINT_FLAG_ARRAY = 0x4111;
+const FACE_ARRAY = 0x4120;
+const MSH_MAT_GROUP = 0x4130;
+// const SMOOTH_GROUP = 0x4150;
+// const MSH_BOXMAP = 0x4190;
+const TEX_VERTS = 0x4140;
+const MESH_MATRIX = 0x4160;
+// const MESH_COLOR = 0x4165;
+// const MESH_TEXTURE_INFO = 0x4170;
+// const KFDATA = 0xB000;
+// const KFHDR = 0xB00A;
+// const KFSEG = 0xB008;
+// const KFCURTIME = 0xB009;
+// const AMBIENT_NODE_TAG = 0xB001;
+// const OBJECT_NODE_TAG = 0xB002;
+// const CAMERA_NODE_TAG = 0xB003;
+// const TARGET_NODE_TAG = 0xB004;
+// const LIGHT_NODE_TAG = 0xB005;
+// const L_TARGET_NODE_TAG = 0xB006;
+// const SPOTLIGHT_NODE_TAG = 0xB007;
+// const NODE_ID = 0xB030;
+// const NODE_HDR = 0xB010;
+// const PIVOT = 0xB013;
+// const INSTANCE_NAME = 0xB011;
+// const MORPH_SMOOTH = 0xB015;
+// const BOUNDBOX = 0xB014;
+// const POS_TRACK_TAG = 0xB020;
+// const COL_TRACK_TAG = 0xB025;
+// const ROT_TRACK_TAG = 0xB021;
+// const SCL_TRACK_TAG = 0xB022;
+// const MORPH_TRACK_TAG = 0xB026;
+// const FOV_TRACK_TAG = 0xB023;
+// const ROLL_TRACK_TAG = 0xB024;
+// const HOT_TRACK_TAG = 0xB027;
+// const FALL_TRACK_TAG = 0xB028;
+// const HIDE_TRACK_TAG = 0xB029;
+// const POLY_2D = 0x5000;
+// const SHAPE_OK = 0x5010;
+// const SHAPE_NOT_OK = 0x5011;
+// const SHAPE_HOOK = 0x5020;
+// const PATH_3D = 0x6000;
+// const PATH_MATRIX = 0x6005;
+// const SHAPE_2D = 0x6010;
+// const M_SCALE = 0x6020;
+// const M_TWIST = 0x6030;
+// const M_TEETER = 0x6040;
+// const M_FIT = 0x6050;
+// const M_BEVEL = 0x6060;
+// const XZ_CURVE = 0x6070;
+// const YZ_CURVE = 0x6080;
+// const INTERPCT = 0x6090;
+// const DEFORM_LIMIT = 0x60A0;
+// const USE_CONTOUR = 0x6100;
+// const USE_TWEEN = 0x6110;
+// const USE_SCALE = 0x6120;
+// const USE_TWIST = 0x6130;
+// const USE_TEETER = 0x6140;
+// const USE_FIT = 0x6150;
+// const USE_BEVEL = 0x6160;
+// const DEFAULT_VIEW = 0x3000;
+// const VIEW_TOP = 0x3010;
+// const VIEW_BOTTOM = 0x3020;
+// const VIEW_LEFT = 0x3030;
+// const VIEW_RIGHT = 0x3040;
+// const VIEW_FRONT = 0x3050;
+// const VIEW_BACK = 0x3060;
+// const VIEW_USER = 0x3070;
+// const VIEW_CAMERA = 0x3080;
+// const VIEW_WINDOW = 0x3090;
+// const VIEWPORT_LAYOUT_OLD = 0x7000;
+// const VIEWPORT_DATA_OLD = 0x7010;
+// const VIEWPORT_LAYOUT = 0x7001;
+// const VIEWPORT_DATA = 0x7011;
+// const VIEWPORT_DATA_3 = 0x7012;
+// const VIEWPORT_SIZE = 0x7020;
+// const NETWORK_VIEW = 0x7030;
 
 export { TDSLoader };

+ 34 - 37
examples/jsm/loaders/TGALoader.js

@@ -3,17 +3,15 @@ import {
 	LinearMipmapLinearFilter
 } from '../../../build/three.module.js';
 
-var TGALoader = function ( manager ) {
+class TGALoader extends DataTextureLoader {
 
-	DataTextureLoader.call( this, manager );
+	constructor( manager ) {
 
-};
+		super( manager );
 
-TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype ), {
-
-	constructor: TGALoader,
+	}
 
-	parse: function ( buffer ) {
+	parse( buffer ) {
 
 		// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
 
@@ -82,13 +80,11 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaParse( use_rle, use_pal, header, offset, data ) {
 
-			var pixel_data,
-				pixel_size,
-				pixel_total,
+			let pixel_data,
 				palettes;
 
-			pixel_size = header.pixel_size >> 3;
-			pixel_total = header.width * header.height * pixel_size;
+			const pixel_size = header.pixel_size >> 3;
+			const pixel_total = header.width * header.height * pixel_size;
 
 			 // read palettes
 
@@ -104,9 +100,9 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 				 pixel_data = new Uint8Array( pixel_total );
 
-				var c, count, i;
-				var shift = 0;
-				var pixels = new Uint8Array( pixel_size );
+				let c, count, i;
+				let shift = 0;
+				const pixels = new Uint8Array( pixel_size );
 
 				while ( shift < pixel_total ) {
 
@@ -172,9 +168,9 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageData8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image, palettes ) {
 
-			var colormap = palettes;
-			var color, i = 0, x, y;
-			var width = header.width;
+			const colormap = palettes;
+			let color, i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -196,8 +192,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageData16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-			var color, i = 0, x, y;
-			var width = header.width;
+			let color, i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -219,8 +215,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageData24bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-			var i = 0, x, y;
-			var width = header.width;
+			let i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -241,8 +237,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageData32bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-			var i = 0, x, y;
-			var width = header.width;
+			let i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -263,8 +259,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageDataGrey8bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-			var color, i = 0, x, y;
-			var width = header.width;
+			let color, i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -286,8 +282,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function tgaGetImageDataGrey16bits( imageData, y_start, y_step, y_end, x_start, x_step, x_end, image ) {
 
-			var i = 0, x, y;
-			var width = header.width;
+			let i = 0, x, y;
+			const width = header.width;
 
 			for ( y = y_start; y !== y_end; y += y_step ) {
 
@@ -308,7 +304,7 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		function getTgaRGBA( data, width, height, image, palette ) {
 
-			var x_start,
+			let x_start,
 				y_start,
 				x_step,
 				y_step,
@@ -403,7 +399,7 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 			}
 
 			// Load image data according to specific method
-			// var func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
+			// let func = 'tgaGetImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
 			// func(data, y_start, y_step, y_end, x_start, x_step, x_end, width, image, palette );
 			return data;
 
@@ -411,7 +407,7 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		// TGA constants
 
-		var TGA_TYPE_NO_DATA = 0,
+		const TGA_TYPE_NO_DATA = 0,
 			TGA_TYPE_INDEXED = 1,
 			TGA_TYPE_RGB = 2,
 			TGA_TYPE_GREY = 3,
@@ -428,8 +424,9 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		if ( buffer.length < 19 ) console.error( 'THREE.TGALoader: Not enough data to contain header.' );
 
-		var content = new Uint8Array( buffer ),
-			offset = 0,
+		let offset = 0;
+
+		const content = new Uint8Array( buffer ),
 			header = {
 				id_length: content[ offset ++ ],
 				colormap_type: content[ offset ++ ],
@@ -463,7 +460,7 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		// get targa information about RLE compression and palette
 
-		var use_rle = false,
+		let use_rle = false,
 			use_pal = false,
 			use_grey = false;
 
@@ -498,8 +495,8 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 		//
 
-		var imageData = new Uint8Array( header.width * header.height * 4 );
-		var result = tgaParse( use_rle, use_pal, header, offset, content );
+		const imageData = new Uint8Array( header.width * header.height * 4 );
+		const result = tgaParse( use_rle, use_pal, header, offset, content );
 		getTgaRGBA( imageData, header.width, header.height, result.pixel_data, result.palettes );
 
 		return {
@@ -515,6 +512,6 @@ TGALoader.prototype = Object.assign( Object.create( DataTextureLoader.prototype
 
 	}
 
-} );
+}
 
 export { TGALoader };

+ 27 - 30
examples/jsm/loaders/TTFLoader.js

@@ -10,24 +10,21 @@ import { opentype } from '../libs/opentype.module.min.js';
  * to create THREE.Font objects.
  */
 
-var TTFLoader = function ( manager ) {
+class TTFLoader extends Loader {
 
-	Loader.call( this, manager );
+	constructor( manager ) {
 
-	this.reversed = false;
+		super( manager );
 
-};
+		this.reversed = false;
 
+	}
 
-TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
-
-	constructor: TTFLoader,
-
-	load: function ( url, onLoad, onProgress, onError ) {
+	load( url, onLoad, onProgress, onError ) {
 
-		var scope = this;
+		const scope = this;
 
-		var loader = new FileLoader( this.manager );
+		const loader = new FileLoader( this.manager );
 		loader.setPath( this.path );
 		loader.setResponseType( 'arraybuffer' );
 		loader.setRequestHeader( this.requestHeader );
@@ -56,28 +53,28 @@ TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		}, onProgress, onError );
 
-	},
+	}
 
-	parse: function ( arraybuffer ) {
+	parse( arraybuffer ) {
 
 		function convert( font, reversed ) {
 
-			var round = Math.round;
+			const round = Math.round;
 
-			var glyphs = {};
-			var scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
+			const glyphs = {};
+			const scale = ( 100000 ) / ( ( font.unitsPerEm || 2048 ) * 72 );
 
-			var glyphIndexMap = font.encoding.cmap.glyphIndexMap;
-			var unicodes = Object.keys( glyphIndexMap );
+			const glyphIndexMap = font.encoding.cmap.glyphIndexMap;
+			const unicodes = Object.keys( glyphIndexMap );
 
-			for ( var i = 0; i < unicodes.length; i ++ ) {
+			for ( let i = 0; i < unicodes.length; i ++ ) {
 
-				var unicode = unicodes[ i ];
-				var glyph = font.glyphs.glyphs[ glyphIndexMap[ unicode ] ];
+				const unicode = unicodes[ i ];
+				const glyph = font.glyphs.glyphs[ glyphIndexMap[ unicode ] ];
 
 				if ( unicode !== undefined ) {
 
-					var token = {
+					const token = {
 						ha: round( glyph.advanceWidth * scale ),
 						x_min: round( glyph.xMin * scale ),
 						x_max: round( glyph.xMax * scale ),
@@ -147,8 +144,8 @@ TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 		function reverseCommands( commands ) {
 
-			var paths = [];
-			var path;
+			const paths = [];
+			let path;
 
 			commands.forEach( function ( c ) {
 
@@ -165,11 +162,11 @@ TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 			} );
 
-			var reversed = [];
+			const reversed = [];
 
 			paths.forEach( function ( p ) {
 
-				var result = {
+				const result = {
 					type: 'm',
 					x: p[ p.length - 1 ].x,
 					y: p[ p.length - 1 ].y
@@ -177,10 +174,10 @@ TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				reversed.push( result );
 
-				for ( var i = p.length - 1; i > 0; i -- ) {
+				for ( let i = p.length - 1; i > 0; i -- ) {
 
-					var command = p[ i ];
-					var result = { type: command.type };
+					const command = p[ i ];
+					const result = { type: command.type };
 
 					if ( command.x2 !== undefined && command.y2 !== undefined ) {
 
@@ -219,6 +216,6 @@ TTFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 	}
 
-} );
+}
 
 export { TTFLoader };

File diff ditekan karena terlalu besar
+ 1581 - 1588
examples/jsm/loaders/VRMLLoader.js


+ 30 - 38
examples/jsm/loaders/VRMLoader.js

@@ -8,9 +8,9 @@ import { GLTFLoader } from '../loaders/GLTFLoader.js';
 // VRM is based on glTF 2.0 and VRM extension is defined
 // in top-level json.extensions.VRM
 
-var VRMLoader = ( function () {
+class VRMLoader extends Loader {
 
-	function VRMLoader( manager ) {
+	constructor( manager ) {
 
 		if ( GLTFLoader === undefined ) {
 
@@ -18,69 +18,61 @@ var VRMLoader = ( function () {
 
 		}
 
-		Loader.call( this, manager );
+		super( manager );
 
-		this.gltfLoader = new GLTFLoader( this.manager );
+		this.gltfLoader = new GLTFLoader( manager );
 
 	}
 
-	VRMLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
+	load( url, onLoad, onProgress, onError ) {
 
-		constructor: VRMLoader,
+		const scope = this;
 
-		load: function ( url, onLoad, onProgress, onError ) {
+		this.gltfLoader.load( url, function ( gltf ) {
 
-			var scope = this;
+			try {
 
-			this.gltfLoader.load( url, function ( gltf ) {
+				scope.parse( gltf, onLoad );
 
-				try {
+			} catch ( e ) {
 
-					scope.parse( gltf, onLoad );
+				if ( onError ) {
 
-				} catch ( e ) {
+					onError( e );
 
-					if ( onError ) {
+				} else {
 
-						onError( e );
-
-					} else {
-
-						console.error( e );
-
-					}
-
-					scope.manager.itemError( url );
+					console.error( e );
 
 				}
 
-			}, onProgress, onError );
+				scope.manager.itemError( url );
 
-		},
+			}
 
-		setDRACOLoader: function ( dracoLoader ) {
+		}, onProgress, onError );
 
-			this.gltfLoader.setDRACOLoader( dracoLoader );
-			return this;
+	}
 
-		},
+	setDRACOLoader( dracoLoader ) {
 
-		parse: function ( gltf, onLoad ) {
+		this.gltfLoader.setDRACOLoader( dracoLoader );
+		return this;
 
-			// var gltfParser = gltf.parser;
-			// var gltfExtensions = gltf.userData.gltfExtensions || {};
-			// var vrmExtension = gltfExtensions.VRM || {};
+	}
 
-			// handle VRM Extension here
+	parse( gltf, onLoad ) {
 
-			onLoad( gltf );
+		// const gltfParser = gltf.parser;
+		// const gltfExtensions = gltf.userData.gltfExtensions || {};
+		// const vrmExtension = gltfExtensions.VRM || {};
 
-		}
+		// handle VRM Extension here
 
-	} );
+		onLoad( gltf );
 
-	return VRMLoader;
+	}
 
-} )();
+}
 
 export { VRMLoader };

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini