瀏覽代碼

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

raub 7 年之前
父節點
當前提交
ddf9406240
共有 91 個文件被更改,包括 974 次插入949 次删除
  1. 1 1
      README.md
  2. 12 14
      docs/index.css
  3. 1 1
      editor/js/Menubar.Examples.js
  4. 1 1
      editor/js/Sidebar.Material.js
  5. 6 6
      editor/js/Sidebar.Object.js
  6. 1 1
      editor/js/Toolbar.js
  7. 2 2
      examples/canvas_geometry_birds.html
  8. 1 2
      examples/canvas_geometry_terrain.html
  9. 0 2
      examples/canvas_interactive_voxelpainter.html
  10. 2 2
      examples/canvas_lights_pointlights.html
  11. 2 9
      examples/canvas_lines.html
  12. 1 5
      examples/canvas_lines_sphere.html
  13. 3 6
      examples/canvas_materials_normal.html
  14. 2 6
      examples/canvas_materials_reflection.html
  15. 1 0
      examples/files.js
  16. 25 20
      examples/js/MD2Character.js
  17. 6 6
      examples/js/UCSCharacter.js
  18. 1 1
      examples/js/Volume.js
  19. 13 16
      examples/js/VolumeSlice.js
  20. 4 4
      examples/js/animation/MMDAnimationHelper.js
  21. 16 16
      examples/js/controls/OrthographicTrackballControls.js
  22. 2 0
      examples/js/controls/TrackballControls.js
  23. 5 5
      examples/js/controls/TransformControls.js
  24. 15 13
      examples/js/crossfade/transition.js
  25. 1 1
      examples/js/loaders/DRACOLoader.js
  26. 3 3
      examples/js/loaders/EXRLoader.js
  27. 43 30
      examples/js/loaders/KMZLoader.js
  28. 6 2
      examples/js/loaders/LoaderSupport.js
  29. 3 3
      examples/js/loaders/OBJLoader2.js
  30. 31 30
      examples/js/loaders/VRMLLoader.js
  31. 6 5
      examples/js/loaders/deprecated/LegacyGLTFLoader.js
  32. 4 2
      examples/js/loaders/sea3d/SEA3DLoader.js
  33. 57 24
      examples/js/postprocessing/SSAOPass.js
  34. 11 9
      examples/js/renderers/RaytracingRenderer.js
  35. 9 18
      examples/js/renderers/RaytracingWorker.js
  36. 1 1
      examples/misc_controls_orbit.html
  37. 1 1
      examples/misc_exporter_obj.html
  38. 1 1
      examples/misc_exporter_stl.html
  39. 二進制
      examples/models/gltf/Nefertiti/Nefertiti.glb
  40. 9 0
      examples/models/gltf/Nefertiti/README.md
  41. 288 0
      examples/models/gltf/SimpleSkinning.gltf
  42. 0 8
      examples/models/json/WaltHeadLo.json
  43. 0 0
      examples/models/json/WaltHeadLo_buffergeometry.json
  44. 1 3
      examples/webgl_animation_cloth.html
  45. 0 19
      examples/webgl_animation_skinning_morph.html
  46. 1 1
      examples/webgl_buffergeometry_indexed.html
  47. 0 1
      examples/webgl_buffergeometry_instancing.html
  48. 1 3
      examples/webgl_camera_logarithmicdepthbuffer.html
  49. 62 489
      examples/webgl_effects_parallaxbarrier.html
  50. 1 1
      examples/webgl_geometries.html
  51. 0 1
      examples/webgl_geometry_minecraft_ao.html
  52. 1 2
      examples/webgl_geometry_terrain.html
  53. 1 2
      examples/webgl_geometry_terrain_fog.html
  54. 1 2
      examples/webgl_geometry_terrain_raycast.html
  55. 0 1
      examples/webgl_lights_physical.html
  56. 1 1
      examples/webgl_lights_pointlights2.html
  57. 1 1
      examples/webgl_lines_sphere.html
  58. 4 4
      examples/webgl_loader_babylon.html
  59. 1 1
      examples/webgl_loader_collada_kinematics.html
  60. 0 7
      examples/webgl_loader_nrrd.html
  61. 1 1
      examples/webgl_materials_cubemap.html
  62. 1 1
      examples/webgl_materials_curvature.html
  63. 0 2
      examples/webgl_materials_normalmap.html
  64. 150 0
      examples/webgl_materials_normalmap_object_space.html
  65. 4 2
      examples/webgl_materials_reflectivity.html
  66. 0 2
      examples/webgl_materials_texture_rotation.html
  67. 0 4
      examples/webgl_materials_variations_basic.html
  68. 0 4
      examples/webgl_materials_variations_lambert.html
  69. 1 4
      examples/webgl_materials_variations_phong.html
  70. 6 1
      examples/webgl_materials_variations_physical.html
  71. 7 5
      examples/webgl_materials_variations_standard.html
  72. 1 4
      examples/webgl_materials_variations_toon.html
  73. 7 5
      examples/webgl_modifier_subdivision.html
  74. 1 1
      examples/webgl_modifier_tessellation.html
  75. 1 18
      examples/webgl_octree.html
  76. 2 2
      examples/webgl_physics_volume.html
  77. 1 1
      examples/webgl_points_sprites.html
  78. 1 1
      examples/webgl_postprocessing_dof.html
  79. 1 2
      examples/webgl_postprocessing_nodes.html
  80. 1 2
      examples/webgl_postprocessing_sao.html
  81. 3 3
      examples/webgl_shaders_tonemapping.html
  82. 0 1
      examples/webgl_shaders_vector.html
  83. 0 12
      examples/webgl_shading_physical.html
  84. 1 1
      examples/webgl_shadowmap_performance.html
  85. 1 1
      examples/webgl_simple_gi.html
  86. 80 32
      examples/webgl_skinning_simple.html
  87. 1 1
      examples/webgl_sprites.html
  88. 0 2
      examples/webgl_terrain_dynamic.html
  89. 4 2
      examples/webgl_tonemapping.html
  90. 4 0
      src/materials/Material.js
  91. 21 16
      src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl

+ 1 - 1
README.md

@@ -10,7 +10,7 @@ three.js
 
 #### JavaScript 3D library ####
 
-The aim of the project is to create an easy to use, lightweight, 3D library. The library provides <canvas>, <svg>, CSS3D and WebGL renderers.
+The aim of the project is to create an easy to use, lightweight, 3D library. The library provides Canvas 2D, SVG, CSS3D and WebGL renderers.
 
 [Examples](http://threejs.org/examples/) —
 [Documentation](http://threejs.org/docs/) —

+ 12 - 14
docs/index.css

@@ -5,7 +5,7 @@
 	font-style: normal;
 }
 
-*{
+* {
 	box-sizing: border-box;
 }
 
@@ -27,7 +27,6 @@ body {
 h1 {
 	margin-top: 30px;
 	margin-bottom: 40px;
-	margin-left: 20px;
 	font-size: 25px;
 	font-weight: normal;
 }
@@ -38,7 +37,6 @@ h2 {
 	font-weight: normal;
 
 	margin-top: 20px;
-	margin-left: 20px;
 }
 
 h3 {
@@ -47,7 +45,6 @@ h3 {
 	font-weight: normal;
 
 	margin-top: 20px;
-	margin-left: 20px;
 }
 
 a {
@@ -61,13 +58,13 @@ a {
 	width: 260px;
 	height: 100%;
 	overflow: auto;
+	padding-left: 20px;
 	background: #fafafa;
 }
 
 #panel ul {
 	list-style-type: none;
 	padding: 0px;
-	margin-left: 20px;
 }
 
 iframe {
@@ -79,8 +76,8 @@ iframe {
 	overflow: auto;
 }
 
-.filterBlock{
-	margin: 20px;
+.filterBlock {
+	margin-right: 20px;
 	position: relative;
 }
 
@@ -158,12 +155,12 @@ iframe {
 
 @media all and ( max-width: 640px ) {
 
-	h1{
+	h1 {
 		margin-top: 20px;
 		margin-bottom: 20px;
 	}
 
-	#panel{
+	#panel {
 		position: absolute;
 		left: 0;
 		top: 0;
@@ -175,7 +172,7 @@ iframe {
 		border-bottom: 1px solid #dedede;
 	}
 
-	#content{
+	#content {
 		position: absolute;
 		left: 0;
 		top: 90px;
@@ -183,10 +180,11 @@ iframe {
 		bottom: 0;
 		font-size: 17px;
 		line-height: 22px;
+		padding-left: 20px;
 		overflow: auto;
 	}
 
-	#navigation{
+	#navigation {
 		position: absolute;
 		left: 0;
 		top: 90px;
@@ -197,7 +195,7 @@ iframe {
 		overflow: auto;
 	}
 
-	iframe{
+	iframe {
 		position: absolute;
 		left: 0;
 		top: 56px;
@@ -205,11 +203,11 @@ iframe {
 		height: calc(100% - 56px);
 	}
 
-	#expandButton{
+	#expandButton {
 		display: block;
 	}
 
-	#panel.collapsed{
+	#panel.collapsed {
 		height: 56px;
 	}
 

+ 1 - 1
editor/js/Menubar.Examples.js

@@ -53,7 +53,7 @@ Menubar.Examples = function ( editor ) {
 			} );
 			options.add( option );
 
-		} )( i )
+		} )( i );
 
 	}
 

+ 1 - 1
editor/js/Sidebar.Material.js

@@ -517,7 +517,7 @@ Sidebar.Material = function ( editor ) {
 
 		if ( currentMaterialSlot !== previousSelectedSlot ) refreshUI( true );
 
-		var material = editor.getObjectMaterial( currentObject, currentMaterialSlot )
+		var material = editor.getObjectMaterial( currentObject, currentMaterialSlot );
 
 		var textureWarning = false;
 		var objectHasUvs = false;

+ 6 - 6
editor/js/Sidebar.Object.js

@@ -97,9 +97,9 @@ Sidebar.Object = function ( editor ) {
 	// position
 
 	var objectPositionRow = new UI.Row();
-	var objectPositionX = new UI.Number().setWidth( '50px' ).onChange( update );
-	var objectPositionY = new UI.Number().setWidth( '50px' ).onChange( update );
-	var objectPositionZ = new UI.Number().setWidth( '50px' ).onChange( update );
+	var objectPositionX = new UI.Number().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
+	var objectPositionY = new UI.Number().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
+	var objectPositionZ = new UI.Number().setPrecision( 3 ).setWidth( '50px' ).onChange( update );
 
 	objectPositionRow.add( new UI.Text( 'Position' ).setWidth( '90px' ) );
 	objectPositionRow.add( objectPositionX, objectPositionY, objectPositionZ );
@@ -122,9 +122,9 @@ Sidebar.Object = function ( editor ) {
 
 	var objectScaleRow = new UI.Row();
 	var objectScaleLock = new UI.Checkbox( true ).setPosition( 'absolute' ).setLeft( '75px' );
-	var objectScaleX = new UI.Number( 1 ).setRange( 0.01, Infinity ).setWidth( '50px' ).onChange( updateScaleX );
-	var objectScaleY = new UI.Number( 1 ).setRange( 0.01, Infinity ).setWidth( '50px' ).onChange( updateScaleY );
-	var objectScaleZ = new UI.Number( 1 ).setRange( 0.01, Infinity ).setWidth( '50px' ).onChange( updateScaleZ );
+	var objectScaleX = new UI.Number( 1 ).setPrecision( 3 ).setRange( 0.001, Infinity ).setWidth( '50px' ).onChange( updateScaleX );
+	var objectScaleY = new UI.Number( 1 ).setPrecision( 3 ).setRange( 0.001, Infinity ).setWidth( '50px' ).onChange( updateScaleY );
+	var objectScaleZ = new UI.Number( 1 ).setPrecision( 3 ).setRange( 0.001, Infinity ).setWidth( '50px' ).onChange( updateScaleZ );
 
 	objectScaleRow.add( new UI.Text( 'Scale' ).setWidth( '90px' ) );
 	objectScaleRow.add( objectScaleLock );

+ 1 - 1
editor/js/Toolbar.js

@@ -40,7 +40,7 @@ var Toolbar = function ( editor ) {
 	} );
 	buttons.add( scale );
 
-	var local = new UI.THREE.Boolean( false, 'local' )
+	var local = new UI.THREE.Boolean( false, 'local' );
 	local.onChange( function () {
 
 		signals.spaceChanged.dispatch( this.getValue() === true ? 'local' : 'world' );

+ 2 - 2
examples/canvas_geometry_birds.html

@@ -76,7 +76,7 @@
 
 			Bird.prototype = Object.create( THREE.Geometry.prototype );
 			Bird.prototype.constructor = Bird;
-			
+
 			// Based on https://www.openprocessing.org/sketch/6910
 
 			var Boid = function () {
@@ -351,7 +351,7 @@
 
 					return posSum;
 
-				}
+				};
 
 			}
 

+ 1 - 2
examples/canvas_geometry_terrain.html

@@ -145,8 +145,7 @@
 
 			function generateTexture( data, width, height ) {
 
-				var canvas, context, image, imageData,
-					level, diff, vector3, sun, shade;
+				var canvas, context, image, imageData, vector3, sun, shade;
 
 				vector3 = new THREE.Vector3( 0, 0, 0 );
 

+ 0 - 2
examples/canvas_interactive_voxelpainter.html

@@ -74,8 +74,6 @@
 
 				objects.push( plane );
 
-				var material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
-
 				// Lights
 
 				var ambientLight = new THREE.AmbientLight( 0x606060 );

+ 2 - 2
examples/canvas_lights_pointlights.html

@@ -91,8 +91,8 @@
 				var sprite = new THREE.Sprite( new THREE.SpriteCanvasMaterial( { color: 0x80ff80, program: program } ) );
 				light3.add( sprite );
 
-				loader = new THREE.JSONLoader();
-				loader.load( 'models/json/WaltHeadLo.json', function ( geometry ) {
+				loader = new THREE.BufferGeometryLoader();
+				loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
 
 					mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: 0.5 } ) );
 					scene.add( mesh );

+ 2 - 9
examples/canvas_lines.html

@@ -30,10 +30,6 @@
 			windowHalfX = window.innerWidth / 2,
 			windowHalfY = window.innerHeight / 2,
 
-			SEPARATION = 200,
-			AMOUNTX = 10,
-			AMOUNTY = 10,
-
 			camera, scene, renderer;
 
 			init();
@@ -41,10 +37,7 @@
 
 			function init() {
 
-				var container, separation = 100, amountX = 50, amountY = 50,
-				particles, particle;
-
-				container = document.createElement('div');
+				var container = document.createElement('div');
 				document.body.appendChild(container);
 
 				camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
@@ -77,7 +70,7 @@
 
 				for ( var i = 0; i < 100; i ++ ) {
 
-					particle = new THREE.Sprite( material );
+					var particle = new THREE.Sprite( material );
 					particle.position.x = Math.random() * 2 - 1;
 					particle.position.y = Math.random() * 2 - 1;
 					particle.position.z = Math.random() * 2 - 1;

+ 1 - 5
examples/canvas_lines_sphere.html

@@ -33,10 +33,6 @@
 				windowHalfX = window.innerWidth / 2,
 				windowHalfY = window.innerHeight / 2,
 
-				SEPARATION = 200,
-				AMOUNTX = 10,
-				AMOUNTY = 10,
-
 				camera, scene, renderer;
 
 			init();
@@ -44,7 +40,7 @@
 
 			function init() {
 
-				var container, separation = 100, amountX = 50, amountY = 50, particles, particle;
+				var container, particle;
 
 				container = document.createElement( 'div' );
 				document.body.appendChild( container );

+ 3 - 6
examples/canvas_materials_normal.html

@@ -46,8 +46,7 @@
 
 		<script>
 
-			var camera, scene, renderer,
-			loader, mesh;
+			var camera, scene, renderer, mesh;
 
 			init();
 			animate();
@@ -61,8 +60,8 @@
 
 				scene = new THREE.Scene();
 
-				loader = new THREE.JSONLoader();
-				loader.load( 'models/json/WaltHeadLo.json', function ( geometry ) {
+				var loader = new THREE.BufferGeometryLoader();
+				loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
 
 					mesh = new THREE.Mesh( geometry, new THREE.MeshNormalMaterial( { overdraw: 0.5 } ) );
 					scene.add( mesh );
@@ -100,8 +99,6 @@
 
 			function render() {
 
-				var time = Date.now() * 0.0005;
-
 				if ( mesh ) {
 
 					mesh.rotation.x -= 0.005;

+ 2 - 6
examples/canvas_materials_reflection.html

@@ -62,10 +62,8 @@
 
 				scene = new THREE.Scene();
 
-				loader = new THREE.JSONLoader();
-				loader.load( 'models/json/WaltHeadLo.json', function ( geometry ) {
-
-					geometry.computeVertexNormals();
+				loader = new THREE.BufferGeometryLoader();
+				loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
 
 					var envMap = new THREE.TextureLoader().load( 'textures/metal.jpg' );
 					envMap.mapping = THREE.SphericalReflectionMapping;
@@ -107,8 +105,6 @@
 
 			function render() {
 
-				var time = Date.now() * 0.0005;
-
 				if ( mesh ) mesh.rotation.y -= 0.01;
 
 				renderer.render( scene, camera );

+ 1 - 0
examples/files.js

@@ -158,6 +158,7 @@ var files = {
 		"webgl_materials_lightmap",
 		"webgl_materials_nodes",
 		"webgl_materials_normalmap",
+		"webgl_materials_normalmap_object_space",
 		"webgl_materials_parallaxmap",
 		"webgl_materials_reflectivity",
 		"webgl_materials_shaders_fresnel",

+ 25 - 20
examples/js/MD2Character.js

@@ -42,7 +42,7 @@ THREE.MD2Character = function () {
 
 		var loader = new THREE.MD2Loader();
 
-		loader.load( config.baseUrl + config.body, function( geo ) {
+		loader.load( config.baseUrl + config.body, function ( geo ) {
 
 			geo.computeBoundingBox();
 			scope.root.position.y = - scope.scale * geo.boundingBox.min.y;
@@ -55,7 +55,7 @@ THREE.MD2Character = function () {
 			scope.meshBody = mesh;
 
 			scope.meshBody.clipOffset = 0;
-			scope.activeAnimationClipName = mesh.geometry.animations[0].name;
+			scope.activeAnimationClipName = mesh.geometry.animations[ 0 ].name;
 
 			scope.mixer = new THREE.AnimationMixer( mesh );
 
@@ -67,7 +67,7 @@ THREE.MD2Character = function () {
 
 		var generateCallback = function ( index, name ) {
 
-			return function( geo ) {
+			return function ( geo ) {
 
 				var mesh = createPart( geo, scope.skinsWeapon[ index ] );
 				mesh.scale.set( scope.scale, scope.scale, scope.scale );
@@ -82,7 +82,7 @@ THREE.MD2Character = function () {
 
 				checkLoadingComplete();
 
-			}
+			};
 
 		};
 
@@ -96,11 +96,14 @@ THREE.MD2Character = function () {
 
 	this.setPlaybackRate = function ( rate ) {
 
-		if( rate !== 0 ) {
+		if ( rate !== 0 ) {
+
 			this.mixer.timeScale = 1 / rate;
-		}
-		else {
+
+		} else {
+
 			this.mixer.timeScale = 0;
+
 		}
 
 	};
@@ -121,7 +124,7 @@ THREE.MD2Character = function () {
 
 	};
 
-	this.setSkin = function( index ) {
+	this.setSkin = function ( index ) {
 
 		if ( this.meshBody && this.meshBody.material.wireframe === false ) {
 
@@ -152,13 +155,16 @@ THREE.MD2Character = function () {
 
 		if ( this.meshBody ) {
 
-			if( this.meshBody.activeAction ) {
+			if ( this.meshBody.activeAction ) {
+
 				this.meshBody.activeAction.stop();
 				this.meshBody.activeAction = null;
+
 			}
 
 			var action = this.mixer.clipAction( clipName, this.meshBody );
-			if( action ) {
+
+			if ( action ) {
 
 				this.meshBody.activeAction = action.play();
 
@@ -172,35 +178,34 @@ THREE.MD2Character = function () {
 
 	};
 
-	this.syncWeaponAnimation = function() {
+	this.syncWeaponAnimation = function () {
 
 		var clipName = scope.activeClipName;
 
 		if ( scope.meshWeapon ) {
 
-			if( this.meshWeapon.activeAction ) {
+			if ( this.meshWeapon.activeAction ) {
+
 				this.meshWeapon.activeAction.stop();
 				this.meshWeapon.activeAction = null;
-			}
 
-			var geometry = this.meshWeapon.geometry,
-				animations = geometry.animations;
+			}
 
 			var action = this.mixer.clipAction( clipName, this.meshWeapon );
-			if( action ) {
 
-				this.meshWeapon.activeAction =
-						action.syncWith( this.meshBody.activeAction ).play();
+			if ( action ) {
+
+				this.meshWeapon.activeAction = action.syncWith( this.meshBody.activeAction ).play();
 
 			}
 
 		}
 
-	}
+	};
 
 	this.update = function ( delta ) {
 
-		if( this.mixer ) this.mixer.update( delta );
+		if ( this.mixer ) this.mixer.update( delta );
 
 	};
 

+ 6 - 6
examples/js/UCSCharacter.js

@@ -1,4 +1,4 @@
-THREE.UCSCharacter = function() {
+THREE.UCSCharacter = function () {
 
 	var scope = this;
 
@@ -39,7 +39,7 @@ THREE.UCSCharacter = function() {
 		// CHARACTER
 		var loader = new THREE.JSONLoader();
 		console.log( config.baseUrl + config.character );
-		loader.load( config.baseUrl + config.character, function( geometry ) {
+		loader.load( config.baseUrl + config.character, function ( geometry ) {
 
 			geometry.computeBoundingBox();
 			geometry.computeVertexNormals();
@@ -55,7 +55,7 @@ THREE.UCSCharacter = function() {
 			mesh.castShadow = true;
 			mesh.receiveShadow = true;
 
-			scope.mixer.clipAction( geometry.animations[0], mesh ).play();
+			scope.mixer.clipAction( geometry.animations[ 0 ], mesh ).play();
 
 			scope.setSkin( 0 );
 
@@ -65,7 +65,7 @@ THREE.UCSCharacter = function() {
 
 	};
 
-	this.setSkin = function( index ) {
+	this.setSkin = function ( index ) {
 
 		if ( mesh && scope.materials ) {
 
@@ -75,7 +75,7 @@ THREE.UCSCharacter = function() {
 
 	};
 
-	this.updateMorphs = function( influences ) {
+	this.updateMorphs = function ( influences ) {
 
 		if ( mesh ) {
 
@@ -136,6 +136,6 @@ THREE.UCSCharacter = function() {
 
 		}
 
-	}
+	};
 
 };

+ 1 - 1
examples/js/Volume.js

@@ -374,7 +374,7 @@ THREE.Volume.prototype = {
 			matrix : planeMatrix,
 			planeWidth : planeWidth,
 			planeHeight : planeHeight
-		}
+		};
 
 	},
 

+ 13 - 16
examples/js/VolumeSlice.js

@@ -7,7 +7,7 @@
  * @param   {string}       [axis='z']      For now only 'x', 'y' or 'z' but later it will change to a normal vector
  * @see THREE.Volume
  */
-THREE.VolumeSlice = function( volume, index, axis ) {
+THREE.VolumeSlice = function ( volume, index, axis ) {
 
 	var slice = this;
 	/**
@@ -19,12 +19,12 @@ THREE.VolumeSlice = function( volume, index, axis ) {
 	 */
 	index = index || 0;
 	Object.defineProperty( this, 'index', {
-		get : function() {
+		get: function () {
 
 			return index;
 
 		},
-		set : function( value ) {
+		set: function ( value ) {
 
 			index = value;
 			slice.geometryNeedsUpdate = true;
@@ -57,7 +57,7 @@ THREE.VolumeSlice = function( volume, index, axis ) {
 	var canvasMap = new THREE.Texture( this.canvas );
 	canvasMap.minFilter = THREE.LinearFilter;
 	canvasMap.wrapS = canvasMap.wrapT = THREE.ClampToEdgeWrapping;
-	var material = new THREE.MeshBasicMaterial( { map: canvasMap, side: THREE.DoubleSide, transparent : true } );
+	var material = new THREE.MeshBasicMaterial( { map: canvasMap, side: THREE.DoubleSide, transparent: true } );
 	/**
 	 * @member {THREE.Mesh} mesh The mesh ready to get used in the scene
 	 */
@@ -89,13 +89,13 @@ THREE.VolumeSlice = function( volume, index, axis ) {
 
 THREE.VolumeSlice.prototype = {
 
-	constructor : THREE.VolumeSlice,
+	constructor: THREE.VolumeSlice,
 
 	/**
 	 * @member {Function} repaint Refresh the texture and the geometry if geometryNeedsUpdate is set to true
 	 * @memberof THREE.VolumeSlice
 	 */
-	repaint : function() {
+	repaint: function () {
 
 		if ( this.geometryNeedsUpdate ) {
 
@@ -104,13 +104,11 @@ THREE.VolumeSlice.prototype = {
 		}
 
 		var iLength = this.iLength,
-		jLength = this.jLength,
-		sliceAccess = this.sliceAccess,
-		volume = this.volume,
-		axis = this.axis,
-		index = this.index,
-		canvas = this.canvasBuffer,
-		ctx = this.ctxBuffer;
+			jLength = this.jLength,
+			sliceAccess = this.sliceAccess,
+			volume = this.volume,
+			canvas = this.canvasBuffer,
+			ctx = this.ctxBuffer;
 
 
 		// get the imageData and pixel array from the canvas
@@ -145,8 +143,7 @@ THREE.VolumeSlice.prototype = {
 
 			}
 
-		}
-		else {
+		} else {
 
 			for ( var j = 0; j < jLength; j ++ ) {
 
@@ -184,7 +181,7 @@ THREE.VolumeSlice.prototype = {
 	 * @see THREE.Volume.extractPerpendicularPlane
 	 * @memberof THREE.VolumeSlice
 	 */
-	updateGeometry : function() {
+	updateGeometry: function () {
 
 		var extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );
 		this.sliceAccess = extracted.sliceAccess;

+ 4 - 4
examples/js/animation/MMDAnimationHelper.js

@@ -221,7 +221,7 @@ THREE.MMDAnimationHelper = ( function () {
 
 			if ( params.ik !== false ) {
 
-				this._createCCDIKSolver( mesh ).update( params.saveOriginalBonesBeforeIK );  // this param is experimental
+				this._createCCDIKSolver( mesh ).update( params.saveOriginalBonesBeforeIK ); // this param is experimental
 
 			}
 
@@ -324,7 +324,7 @@ THREE.MMDAnimationHelper = ( function () {
 
 			if ( params.animation !== undefined ) {
 
-				this._setupCameraAnimation( camera, params.animation )
+				this._setupCameraAnimation( camera, params.animation );
 
 			}
 
@@ -668,7 +668,7 @@ THREE.MMDAnimationHelper = ( function () {
 
 						objects.set( clip, {
 							duration: clip.duration
-						} )
+						} );
 
 					}
 
@@ -692,7 +692,7 @@ THREE.MMDAnimationHelper = ( function () {
 
 							objects.set( clip, {
 								duration: clip.duration
-							} )
+							} );
 
 						}
 

+ 16 - 16
examples/js/controls/OrthographicTrackballControls.js

@@ -43,21 +43,21 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 	var _changed = true;
 
 	var _state = STATE.NONE,
-	_prevState = STATE.NONE,
+		_prevState = STATE.NONE,
 
-	_eye = new THREE.Vector3(),
+		_eye = new THREE.Vector3(),
 
-	_rotateStart = new THREE.Vector3(),
-	_rotateEnd = new THREE.Vector3(),
+		_rotateStart = new THREE.Vector3(),
+		_rotateEnd = new THREE.Vector3(),
 
-	_zoomStart = new THREE.Vector2(),
-	_zoomEnd = new THREE.Vector2(),
+		_zoomStart = new THREE.Vector2(),
+		_zoomEnd = new THREE.Vector2(),
 
-	_touchZoomDistanceStart = 0,
-	_touchZoomDistanceEnd = 0,
+		_touchZoomDistanceStart = 0,
+		_touchZoomDistanceEnd = 0,
 
-	_panStart = new THREE.Vector2(),
-	_panEnd = new THREE.Vector2();
+		_panStart = new THREE.Vector2(),
+		_panEnd = new THREE.Vector2();
 
 	// for reset
 
@@ -176,7 +176,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 	}() );
 
-	this.rotateCamera = ( function() {
+	this.rotateCamera = ( function () {
 
 		var axis = new THREE.Vector3(),
 			quaternion = new THREE.Quaternion();
@@ -214,7 +214,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 			}
 
-		}
+		};
 
 	}() );
 
@@ -255,7 +255,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 	};
 
-	this.panCamera = ( function() {
+	this.panCamera = ( function () {
 
 		var mouseChange = new THREE.Vector2(),
 			objectUp = new THREE.Vector3(),
@@ -293,7 +293,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 			}
 
-		}
+		};
 
 	}() );
 
@@ -429,7 +429,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 		} else if ( _state === STATE.PAN && ! _this.noPan ) {
 
 			_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
-			_panEnd.copy( _panStart )
+			_panEnd.copy( _panStart );
 
 		}
 
@@ -586,7 +586,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 
 	}
 
-	this.dispose = function() {
+	this.dispose = function () {
 
 		this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
 		this.domElement.removeEventListener( 'mousedown', mousedown, false );

+ 2 - 0
examples/js/controls/TrackballControls.js

@@ -492,6 +492,8 @@ THREE.TrackballControls = function ( object, domElement ) {
 	function touchstart( event ) {
 
 		if ( _this.enabled === false ) return;
+		
+		event.preventDefault();
 
 		switch ( event.touches.length ) {
 

+ 5 - 5
examples/js/controls/TransformControls.js

@@ -52,7 +52,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 		X: new THREE.Vector3( 1, 0, 0 ),
 		Y: new THREE.Vector3( 0, 1, 0 ),
 		Z: new THREE.Vector3( 0, 0, 1 )
-	}
+	};
 	var _identityQuaternion = new THREE.Quaternion();
 	var _alignVector = new THREE.Vector3();
 
@@ -232,7 +232,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 
 		}
 
-	}
+	};
 
 	this.pointerDown = function( pointer ) {
 
@@ -289,7 +289,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 
 		}
 
-	}
+	};
 
 	this.pointerMove = function( pointer ) {
 
@@ -483,7 +483,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 		this.dispatchEvent( changeEvent );
 		this.dispatchEvent( objectChangeEvent );
 
-	}
+	};
 
 	this.pointerUp = function( pointer ) {
 
@@ -500,7 +500,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 
 		if ( pointer.button === undefined ) this.axis = null;
 
-	}
+	};
 
 	// normalize mouse / touch pointer and remap {x,y} to view space.
 

+ 15 - 13
examples/js/crossfade/transition.js

@@ -61,22 +61,24 @@ function Transition ( sceneA, sceneB ) {
 
 			"void main() {",
 
-			"vec4 texel1 = texture2D( tDiffuse1, vUv );",
-			"vec4 texel2 = texture2D( tDiffuse2, vUv );",
+			"	vec4 texel1 = texture2D( tDiffuse1, vUv );",
+			"	vec4 texel2 = texture2D( tDiffuse2, vUv );",
 
-			"if (useTexture==1) {",
+			"	if (useTexture==1) {",
 
-				"vec4 transitionTexel = texture2D( tMixTexture, vUv );",
-				"float r = mixRatio * (1.0 + threshold * 2.0) - threshold;",
-				"float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);",
+			"		vec4 transitionTexel = texture2D( tMixTexture, vUv );",
+			"		float r = mixRatio * (1.0 + threshold * 2.0) - threshold;",
+			"		float mixf=clamp((transitionTexel.r - r)*(1.0/threshold), 0.0, 1.0);",
 
-				"gl_FragColor = mix( texel1, texel2, mixf );",
-			"} else {",
+			"		gl_FragColor = mix( texel1, texel2, mixf );",
 
-				"gl_FragColor = mix( texel2, texel1, mixRatio );",
+			"	} else {",
 
-			"}",
-		"}"
+			"		gl_FragColor = mix( texel2, texel1, mixRatio );",
+
+			"	}",
+
+			"}"
 
 		].join( "\n" )
 
@@ -114,7 +116,7 @@ function Transition ( sceneA, sceneB ) {
 
 	};
 
-	this.render = function( delta ) {
+	this.render = function ( delta ) {
 
 		// Transition animation
 		if ( transitionParams.animateTransition ) {
@@ -159,6 +161,6 @@ function Transition ( sceneA, sceneB ) {
 
 		}
 
-	}
+	};
 
 }

+ 1 - 1
examples/js/loaders/DRACOLoader.js

@@ -129,7 +129,7 @@ THREE.DRACOLoader.prototype = {
           console.log('Loaded a point cloud.');
         }
       } else {
-        var errorMsg = 'THREE.DRACOLoader: Unknown geometry type.'
+        var errorMsg = 'THREE.DRACOLoader: Unknown geometry type.';
         console.error(errorMsg);
         throw new Error(errorMsg);
       }

+ 3 - 3
examples/js/loaders/EXRLoader.js

@@ -132,7 +132,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
 
 		for ( var i = 0; i < HUF_DECSIZE; i ++ ) {
 
-			hdec[ i ] = {}
+			hdec[ i ] = {};
 			hdec[ i ].len = 0;
 			hdec[ i ].lit = 0;
 			hdec[ i ].p = null;
@@ -692,7 +692,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
 
 		if ( maxNonZero >= BITMAP_SIZE ) {
 
-			throw 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE'
+			throw 'Something is wrong with PIZ_COMPRESSION BITMAP_SIZE';
 
 		}
 
@@ -715,7 +715,7 @@ THREE.EXRLoader.prototype._parser = function ( buffer ) {
 
 		var pizChannelData = new Array( num_channels );
 
-		var outBufferEnd = 0
+		var outBufferEnd = 0;
 
 		for ( var i = 0; i < num_channels; i ++ ) {
 

+ 43 - 30
examples/js/loaders/KMZLoader.js

@@ -28,63 +28,76 @@ THREE.KMZLoader.prototype = {
 
 	parse: function ( data ) {
 
-		var zip = new JSZip( data ); // eslint-disable-line no-undef
+		function findFile( url ) {
 
-		// console.log( zip );
+			for ( var path in zip.files ) {
 
-		// var xml = new DOMParser().parseFromString( zip.file( 'doc.kml' ).asText(), 'application/xml' );
+				if ( path.substr( - url.length ) === url ) {
 
-		function loadImage( image ) {
+					return zip.files[ path ];
 
-			var path = decodeURI( image.init_from );
+				}
 
-			// Hack to support relative paths
-			path = path.replace( '../', '' );
+			}
 
-			var regex = new RegExp( path + '$' );
-			var files = zip.file( regex );
+		}
 
-			// console.log( image, files );
+		var manager = new THREE.LoadingManager();
+		manager.setURLModifier( function ( url ) {
 
-			if ( files.length ) {
+			var image = findFile( url );
 
-				var file = files[ 0 ];
-				var blob = new Blob( [ file.asArrayBuffer() ], { type: 'application/octet-binary' } );
-				image.build.src = URL.createObjectURL( blob );
+			if ( image ) {
 
-			}
+				console.log( 'Loading', url );
 
-		}
+				var blob = new Blob( [ image.asArrayBuffer() ], { type: 'application/octet-stream' } );
+				return URL.createObjectURL( blob );
 
-		// load collada
+			}
+
+			return url;
 
-		var files = zip.file( /dae$/i );
+		} );
 
-		if ( files.length ) {
+		//
 
-			var file = files[ 0 ];
+		var zip = new JSZip( data ); // eslint-disable-line no-undef
 
-			var collada = new THREE.ColladaLoader().parse( file.asText() );
+		if ( zip.files[ 'doc.kml' ] ) {
 
-			// fix images
+			var xml = new DOMParser().parseFromString( zip.files[ 'doc.kml' ].asText(), 'application/xml' );
 
-			var images = collada.library.images;
+			var model = xml.querySelector( 'Placemark Model Link href' );
 
-			for ( var name in images ) {
+			if ( model ) {
 
-				loadImage( images[ name ] );
+				var loader = new THREE.ColladaLoader( manager );
+				return loader.parse( zip.files[ model.textContent ].asText() );
 
 			}
 
-			return collada;
+		} else {
+
+			console.warn( 'KMZLoader: Missing doc.kml file.' );
+
+			for ( var path in zip.files ) {
+
+				var extension = path.split( '.' ).pop().toLowerCase();
+
+				if ( extension === 'dae' ) {
+
+					var loader = new THREE.ColladaLoader( manager );
+					return loader.parse( zip.files[ path ].asText() );
+
+				}
+
+			}
 
 		}
 
 		console.error( 'KMZLoader: Couldn\'t find .dae file.' );
-
-		return {
-			scene: new THREE.Group()
-		};
+		return { scene: new THREE.Group() };
 
 	}
 

+ 6 - 2
examples/js/loaders/LoaderSupport.js

@@ -5,7 +5,11 @@
 
 'use strict';
 
-if ( THREE.LoaderSupport === undefined ) { THREE.LoaderSupport = {} }
+if ( THREE.LoaderSupport === undefined ) {
+
+	THREE.LoaderSupport = {};
+
+}
 
 /**
  * Validation functions.
@@ -943,7 +947,7 @@ THREE.LoaderSupport.WorkerSupport = (function () {
 				payload.logging = {
 					enabled: true,
 					debug: false
-				}
+				};
 
 			}
 			this._postMessage();

+ 3 - 3
examples/js/loaders/OBJLoader2.js

@@ -218,7 +218,7 @@ THREE.OBJLoader2 = (function () {
 		if ( ! Validator.isValid( onError ) ) {
 			onError = function ( event ) {
 				scope._onError( event );
-			}
+			};
 		}
 
 		// fast-fail
@@ -419,7 +419,7 @@ THREE.OBJLoader2 = (function () {
 		if ( ! Validator.isValid( content ) ) {
 
 			console.warn( 'Provided content is not a valid ArrayBuffer.' );
-			scopedOnLoad()
+			scopedOnLoad();
 
 		} else {
 
@@ -1427,7 +1427,7 @@ THREE.OBJLoader2 = (function () {
 				if ( ! Validator.isValid( onError ) ) {
 					onError = function ( event ) {
 						scope._onError( event );
-					}
+					};
 				}
 				if ( ! Validator.isValid( onProgress ) ) {
 					var numericalValueRef = 0;

+ 31 - 30
examples/js/loaders/VRMLLoader.js

@@ -50,6 +50,7 @@ THREE.VRMLLoader.prototype = {
 
 	parse: function ( data ) {
 
+		var scope = this;
 		var texturePath = this.texturePath || '';
 
 		var textureLoader = new THREE.TextureLoader( this.manager );
@@ -204,34 +205,34 @@ THREE.VRMLLoader.prototype = {
 
 					case 'skyAngle':
 					case 'groundAngle':
-						this.recordingFieldname = fieldName;
-						this.isRecordingAngles = true;
-						this.angles = [];
+						scope.recordingFieldname = fieldName;
+						scope.isRecordingAngles = true;
+						scope.angles = [];
 						break;
 
 					case 'skyColor':
 					case 'groundColor':
-						this.recordingFieldname = fieldName;
-						this.isRecordingColors = true;
-						this.colors = [];
+						scope.recordingFieldname = fieldName;
+						scope.isRecordingColors = true;
+						scope.colors = [];
 						break;
 
 					case 'point':
-						this.recordingFieldname = fieldName;
-						this.isRecordingPoints = true;
-						this.points = [];
+						scope.recordingFieldname = fieldName;
+						scope.isRecordingPoints = true;
+						scope.points = [];
 						break;
 
 					case 'coordIndex':
 					case 'texCoordIndex':
-						this.recordingFieldname = fieldName;
-						this.isRecordingFaces = true;
-						this.indexes = [];
+						scope.recordingFieldname = fieldName;
+						scope.isRecordingFaces = true;
+						scope.indexes = [];
 						break;
 
 				}
 
-				if ( this.isRecordingFaces ) {
+				if ( scope.isRecordingFaces ) {
 
 					// the parts hold the indexes as strings
 					if ( parts.length > 0 ) {
@@ -250,7 +251,7 @@ THREE.VRMLLoader.prototype = {
 
 								if ( index.length > 0 ) {
 
-									this.indexes.push( index );
+									scope.indexes.push( index );
 
 								}
 
@@ -272,19 +273,19 @@ THREE.VRMLLoader.prototype = {
 
 						if ( index.length > 0 ) {
 
-							this.indexes.push( index );
+							scope.indexes.push( index );
 
 						}
 
 						// start new one
 						index = [];
 
-						this.isRecordingFaces = false;
-						node[ this.recordingFieldname ] = this.indexes;
+						scope.isRecordingFaces = false;
+						node[ scope.recordingFieldname ] = scope.indexes;
 
 					}
 
-				} else if ( this.isRecordingPoints ) {
+				} else if ( scope.isRecordingPoints ) {
 
 					if ( node.nodeType == 'Coordinate' ) {
 
@@ -296,7 +297,7 @@ THREE.VRMLLoader.prototype = {
 								z: parseFloat( parts[ 3 ] )
 							};
 
-							this.points.push( point );
+							scope.points.push( point );
 
 						}
 
@@ -311,7 +312,7 @@ THREE.VRMLLoader.prototype = {
 								y: parseFloat( parts[ 2 ] )
 							};
 
-							this.points.push( point );
+							scope.points.push( point );
 
 						}
 
@@ -320,12 +321,12 @@ THREE.VRMLLoader.prototype = {
 					// end
 					if ( /]/.exec( line ) ) {
 
-						this.isRecordingPoints = false;
-						node.points = this.points;
+						scope.isRecordingPoints = false;
+						node.points = scope.points;
 
 					}
 
-				} else if ( this.isRecordingAngles ) {
+				} else if ( scope.isRecordingAngles ) {
 
 					// the parts hold the angles as strings
 					if ( parts.length > 0 ) {
@@ -339,7 +340,7 @@ THREE.VRMLLoader.prototype = {
 
 							}
 
-							this.angles.push( parseFloat( parts[ ind ] ) );
+							scope.angles.push( parseFloat( parts[ ind ] ) );
 
 						}
 
@@ -348,12 +349,12 @@ THREE.VRMLLoader.prototype = {
 					// end
 					if ( /]/.exec( line ) ) {
 
-						this.isRecordingAngles = false;
-						node[ this.recordingFieldname ] = this.angles;
+						scope.isRecordingAngles = false;
+						node[ scope.recordingFieldname ] = scope.angles;
 
 					}
 
-				} else if ( this.isRecordingColors ) {
+				} else if ( scope.isRecordingColors ) {
 
 					while ( null !== ( parts = float3_pattern.exec( line ) ) ) {
 
@@ -363,15 +364,15 @@ THREE.VRMLLoader.prototype = {
 							b: parseFloat( parts[ 3 ] )
 						};
 
-						this.colors.push( color );
+						scope.colors.push( color );
 
 					}
 
 					// end
 					if ( /]/.exec( line ) ) {
 
-						this.isRecordingColors = false;
-						node[ this.recordingFieldname ] = this.colors;
+						scope.isRecordingColors = false;
+						node[ scope.recordingFieldname ] = scope.colors;
 
 					}
 

+ 6 - 5
examples/js/loaders/deprecated/LegacyGLTFLoader.js

@@ -78,8 +78,9 @@ THREE.LegacyGLTFLoader = ( function () {
 
 			var parser = new GLTFParser( json, extensions, {
 
-				path: path || this.path,
-				crossOrigin: this.crossOrigin
+				crossOrigin: this.crossOrigin,
+				manager: this.manager,
+				path: path || this.path
 
 			} );
 
@@ -922,7 +923,7 @@ THREE.LegacyGLTFLoader = ( function () {
 
 				return new Promise( function ( resolve ) {
 
-					var loader = new THREE.FileLoader();
+					var loader = new THREE.FileLoader( options.manager );
 					loader.setResponseType( 'text' );
 					loader.load( resolveURL( shader.uri, options.path ), function ( shaderText ) {
 
@@ -956,7 +957,7 @@ THREE.LegacyGLTFLoader = ( function () {
 
 				return new Promise( function ( resolve ) {
 
-					var loader = new THREE.FileLoader();
+					var loader = new THREE.FileLoader( options.manager );
 					loader.setResponseType( 'arraybuffer' );
 					loader.load( resolveURL( buffer.uri, options.path ), function ( buffer ) {
 
@@ -1081,7 +1082,7 @@ THREE.LegacyGLTFLoader = ( function () {
 
 						if ( textureLoader === null ) {
 
-							textureLoader = new THREE.TextureLoader();
+							textureLoader = new THREE.TextureLoader( options.manager );
 
 						}
 

+ 4 - 2
examples/js/loaders/sea3d/SEA3DLoader.js

@@ -2418,12 +2418,14 @@ THREE.SEA3D.prototype.readCubeMapURL = function ( sea ) {
 				var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
 				pmremCubeUVPacker.update( this.config.renderer );
 
-				texture.dispose();
-
 				this.objects[ "cmap/" + sea.name ] = sea.tag = pmremCubeUVPacker.CubeUVRenderTarget.texture;
 
 				this.file.resume = true;
 
+				texture.dispose();
+				pmremGenerator.dispose();
+				pmremCubeUVPacker.dispose();
+
 			}
 
 		}.bind( this ) );

+ 57 - 24
examples/js/postprocessing/SSAOPass.js

@@ -12,7 +12,7 @@
  *  	- Ambient occlusion clamp (numeric value).
  *  - lumInfluence
  *  	- Pixel luminosity influence in AO calculation (numeric value).
- * 
+ *
  * To output to screen set renderToScreens true
  *
  * @author alteredq / http://alteredqualia.com/
@@ -21,7 +21,7 @@
  */
 THREE.SSAOPass = function ( scene, camera, width, height ) {
 
-	if ( THREE.SSAOShader === undefined) {
+	if ( THREE.SSAOShader === undefined ) {
 
 		console.warn( 'THREE.SSAOPass depends on THREE.SSAOShader' );
 		return new THREE.ShaderPass();
@@ -46,7 +46,7 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 	//Depth render target
 	this.depthRenderTarget = new THREE.WebGLRenderTarget( this.width, this.height, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter } );
 	//this.depthRenderTarget.texture.name = 'SSAOShader.rt';
-	
+
 	//Shader uniforms
 	this.uniforms[ 'tDepth' ].value = this.depthRenderTarget.texture;
 	this.uniforms[ 'size' ].value.set( this.width, this.height );
@@ -59,37 +59,70 @@ THREE.SSAOPass = function ( scene, camera, width, height ) {
 	this.uniforms[ 'lumInfluence' ].value = 0.7;
 
 	//Setters and getters for uniforms
-	var self = this;
-	Object.defineProperties(this, {
+
+	Object.defineProperties( this, {
 
 		radius: {
-			get: function() { return this.uniforms[ 'radius' ].value; },
-			set: function( value ) { this.uniforms[ 'radius' ].value = value; }
+			get: function () {
+
+				return this.uniforms[ 'radius' ].value;
+
+			},
+			set: function ( value ) {
+
+				this.uniforms[ 'radius' ].value = value;
+
+			}
 		},
 
 		onlyAO: {
-			get: function() { return this.uniforms[ 'onlyAO' ].value; },
-			set: function( value ) { this.uniforms[ 'onlyAO' ].value = value; }
+			get: function () {
+
+				return this.uniforms[ 'onlyAO' ].value;
+
+			},
+			set: function ( value ) {
+
+				this.uniforms[ 'onlyAO' ].value = value;
+
+			}
 		},
 
 		aoClamp: {
-			get: function() { return this.uniforms[ 'aoClamp' ].value; },
-			set: function( value ) { this.uniforms[ 'aoClamp' ].value = value; }
+			get: function () {
+
+				return this.uniforms[ 'aoClamp' ].value;
+
+			},
+			set: function ( value ) {
+
+				this.uniforms[ 'aoClamp' ].value = value;
+
+			}
 		},
 
 		lumInfluence: {
-			get: function() { return this.uniforms[ 'lumInfluence' ].value; },
-			set: function( value ) { this.uniforms[ 'lumInfluence' ].value = value; }
+			get: function () {
+
+				return this.uniforms[ 'lumInfluence' ].value;
+
+			},
+			set: function ( value ) {
+
+				this.uniforms[ 'lumInfluence' ].value = value;
+
+			}
 		},
 
-	});
-}
+	} );
+
+};
 
 THREE.SSAOPass.prototype = Object.create( THREE.ShaderPass.prototype );
 
 /**
  * Render using this pass.
- * 
+ *
  * @method render
  * @param {WebGLRenderer} renderer
  * @param {WebGLRenderTarget} writeBuffer Buffer to write output.
@@ -97,13 +130,13 @@ THREE.SSAOPass.prototype = Object.create( THREE.ShaderPass.prototype );
  * @param {Number} delta Delta time in milliseconds.
  * @param {Boolean} maskActive Not used in this pass.
  */
-THREE.SSAOPass.prototype.render = function( renderer, writeBuffer, readBuffer, delta, maskActive ) {
+THREE.SSAOPass.prototype.render = function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
 
 	//Render depth into depthRenderTarget
 	this.scene2.overrideMaterial = this.depthMaterial;
-	
+
 	renderer.render( this.scene2, this.camera2, this.depthRenderTarget, true );
-	
+
 	this.scene2.overrideMaterial = null;
 
 
@@ -118,8 +151,8 @@ THREE.SSAOPass.prototype.render = function( renderer, writeBuffer, readBuffer, d
  * @method setScene
  * @param {Scene} scene
  */
-THREE.SSAOPass.prototype.setScene = function(scene) {
-	
+THREE.SSAOPass.prototype.setScene = function ( scene ) {
+
 	this.scene2 = scene;
 
 };
@@ -130,7 +163,7 @@ THREE.SSAOPass.prototype.setScene = function(scene) {
  * @method setCamera
  * @param {Camera} camera
  */
-THREE.SSAOPass.prototype.setCamera = function( camera ) {
+THREE.SSAOPass.prototype.setCamera = function ( camera ) {
 
 	this.camera2 = camera;
 
@@ -141,12 +174,12 @@ THREE.SSAOPass.prototype.setCamera = function( camera ) {
 
 /**
  * Set resolution of this render pass.
- * 
+ *
  * @method setSize
  * @param {Number} width
  * @param {Number} height
  */
-THREE.SSAOPass.prototype.setSize = function( width, height ) {
+THREE.SSAOPass.prototype.setSize = function ( width, height ) {
 
 	this.width = width;
 	this.height = height;

+ 11 - 9
examples/js/renderers/RaytracingRenderer.js

@@ -21,8 +21,6 @@ THREE.RaytracingRenderer = function ( parameters ) {
 		alpha: parameters.alpha === true
 	} );
 
-	var maxRecursionDepth = 3;
-
 	var canvasWidth, canvasHeight;
 
 	var clearColor = new THREE.Color( 0x000000 );
@@ -39,15 +37,16 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 	console.log( '%cSpinning off ' + workers + ' Workers ', 'font-size: 20px; background: black; color: white; font-family: monospace;' );
 
-	this.setWorkers = function( w ) {
+	this.setWorkers = function ( w ) {
 
 		workers = w || navigator.hardwareConcurrency || 4;
 
 		while ( pool.length < workers ) {
+
 			var worker = new Worker( parameters.workerPath );
-			worker.id = workerId++;
+			worker.id = workerId ++;
 
-			worker.onmessage = function( e ) {
+			worker.onmessage = function ( e ) {
 
 				var data = e.data;
 
@@ -75,7 +74,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 			};
 
-			worker.color = new THREE.Color().setHSL( Math.random() , 0.8, 0.8 ).getHexString();
+			worker.color = new THREE.Color().setHSL( Math.random(), 0.8, 0.8 ).getHexString();
 			pool.push( worker );
 
 			updateSettings( worker );
@@ -109,7 +108,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 	this.setWorkers( workers );
 
-	this.setClearColor = function ( color, alpha ) {
+	this.setClearColor = function ( color /*, alpha */ ) {
 
 		clearColor.set( color );
 
@@ -155,6 +154,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 	}
 
 	function renderNext( worker ) {
+
 		if ( ! toRender.length ) {
 
 			renderering = false;
@@ -213,6 +213,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 		}
 
 		materials[ mat.uuid ] = props;
+
 	}
 
 	this.render = function ( scene, camera ) {
@@ -234,7 +235,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 		scene.traverse( serializeObject );
 
-		pool.forEach( function( worker ) {
+		pool.forEach( function ( worker ) {
 
 			worker.postMessage( {
 				scene: sceneJSON,
@@ -242,6 +243,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 				annex: materials,
 				sceneId: sceneId
 			} );
+
 		} );
 
 		context.clearRect( 0, 0, canvasWidth, canvasHeight );
@@ -266,7 +268,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
 
 			for ( var i = 0; i < totalBlocks; i ++ ) {
 
-				var swap = Math.random()  * totalBlocks | 0;
+				var swap = Math.random() * totalBlocks | 0;
 				var tmp = toRender[ swap ];
 				toRender[ swap ] = toRender[ i ];
 				toRender[ i ] = tmp;

+ 9 - 18
examples/js/renderers/RaytracingWorker.js

@@ -1,13 +1,12 @@
-var worker;
 var BLOCK = 128;
-var startX, startY, division, completed = 0;
+var startX, startY;
 
 var scene, camera, renderer, loader, sceneId;
 
 importScripts( '../../../build/three.js' );
 
 
-self.onmessage = function( e ) {
+self.onmessage = function ( e ) {
 
 	var data = e.data;
 	if ( ! data ) return;
@@ -18,7 +17,6 @@ self.onmessage = function( e ) {
 			width = data.init[ 0 ],
 			height = data.init[ 1 ];
 
-		worker = data.worker;
 		BLOCK = data.blockSize;
 
 		if ( ! renderer ) renderer = new THREE.RaytracingRendererWorker();
@@ -29,8 +27,6 @@ self.onmessage = function( e ) {
 		// TODO fix passing maxRecursionDepth as parameter.
 		// if (data.maxRecursionDepth) maxRecursionDepth = data.maxRecursionDepth;
 
-		completed = 0;
-
 	}
 
 	if ( data.scene ) {
@@ -39,7 +35,7 @@ self.onmessage = function( e ) {
 		camera = loader.parse( data.camera );
 
 		var meta = data.annex;
-		scene.traverse( function( o ) {
+		scene.traverse( function ( o ) {
 
 			if ( o.isPointLight ) {
 
@@ -49,10 +45,11 @@ self.onmessage = function( e ) {
 
 			var mat = o.material;
 
-			if (!mat) return;
+			if ( ! mat ) return;
 
 			var material = meta[ mat.uuid ];
-			for (var m in material) {
+
+			for ( var m in material ) {
 
 				mat[ m ] = material[ m ];
 
@@ -61,6 +58,7 @@ self.onmessage = function( e ) {
 		} );
 
 		sceneId = data.sceneId;
+
 	}
 
 	if ( data.render && scene && camera ) {
@@ -71,7 +69,7 @@ self.onmessage = function( e ) {
 
 	}
 
-}
+};
 
 /**
  * DOM-less version of Raytracing Renderer
@@ -84,8 +82,6 @@ THREE.RaytracingRendererWorker = function () {
 
 	console.log( 'THREE.RaytracingRendererWorker', THREE.REVISION );
 
-	var scope = this;
-
 	var maxRecursionDepth = 3;
 
 	var canvasWidth, canvasHeight;
@@ -479,22 +475,17 @@ THREE.RaytracingRendererWorker = function () {
 				blockY: blockY,
 				blockSize: blockSize,
 				sceneId: sceneId,
-				time: Date.now() - reallyThen, // time for this renderer
+				time: Date.now(), // time for this renderer
 			}, [ data.buffer ] );
 
 			data = new Uint8ClampedArray( blockSize * blockSize * 4 );
 
-			// OK Done!
-			completed ++;
-
 		};
 
 	}() );
 
 	this.render = function ( scene, camera ) {
 
-		reallyThen = Date.now()
-
 		// update scene graph
 
 		if ( scene.autoUpdate === true ) scene.updateMatrixWorld();

+ 1 - 1
examples/misc_controls_orbit.html

@@ -76,7 +76,7 @@
 				controls.screenSpacePanning = false;
 
 				controls.minDistance = 100;
-				controls.maxDistance = 500
+				controls.maxDistance = 500;
 
 				controls.maxPolarAngle = Math.PI / 2;
 

+ 1 - 1
examples/misc_exporter_obj.html

@@ -118,7 +118,7 @@
 				} else if ( type === 4 || type === 5 ) {
 
 					var material = new THREE.MeshLambertMaterial( { color : 0x00cc00 } );
-					var geometry = generateTriangleGeometry()
+					var geometry = generateTriangleGeometry();
 
 					var mesh = new THREE.Mesh( geometry, material );
 					mesh.position.x = -200;

+ 1 - 1
examples/misc_exporter_stl.html

@@ -118,7 +118,7 @@
 					Binary: function() {
 						exportBinary();
 					}
-				}
+				};
 
 				var gui = new dat.GUI();
 				var folder = gui.addFolder( 'Export' );

二進制
examples/models/gltf/Nefertiti/Nefertiti.glb


+ 9 - 0
examples/models/gltf/Nefertiti/README.md

@@ -0,0 +1,9 @@
+# Nefertiti
+
+## License Information
+
+Model is provided under a creative commons license for non-commercial purposes (CC BY-NC).
+
+3D scan of a copy of the Nefertiti Bust
+
+Digitized by Fraunhofer IGD, Competence Center Cultural Heritage Digitization, http://www.cultlab3d.de/

文件差異過大導致無法顯示
+ 288 - 0
examples/models/gltf/SimpleSkinning.gltf


文件差異過大導致無法顯示
+ 0 - 8
examples/models/json/WaltHeadLo.json


文件差異過大導致無法顯示
+ 0 - 0
examples/models/json/WaltHeadLo_buffergeometry.json


+ 1 - 3
examples/webgl_animation_cloth.html

@@ -104,11 +104,9 @@
 
 				// lights
 
-				var light, materials;
-
 				scene.add( new THREE.AmbientLight( 0x666666 ) );
 
-				light = new THREE.DirectionalLight( 0xdfebff, 1 );
+				var light = new THREE.DirectionalLight( 0xdfebff, 1 );
 				light.position.set( 50, 200, 100 );
 				light.position.multiplyScalar( 1.3 );
 

+ 0 - 19
examples/webgl_animation_skinning_morph.html

@@ -181,19 +181,9 @@
 
 			function createScene( geometry, materials, x, y, z, s ) {
 
-				//ensureLoop( geometry.animation );
-
 				geometry.computeBoundingBox();
 				var bb = geometry.boundingBox;
 
-				var path = "textures/cube/Park2/";
-				var format = '.jpg';
-				var urls = [
-						path + 'posx' + format, path + 'negx' + format,
-						path + 'posy' + format, path + 'negy' + format,
-						path + 'posz' + format, path + 'negz' + format
-					];
-
 				for ( var i = 0; i < materials.length; i ++ ) {
 
 					var m = materials[ i ];
@@ -201,17 +191,8 @@
 					m.morphTargets = true;
 
 					m.specular.setHSL( 0, 0, 0.1 );
-
 					m.color.setHSL( 0.6, 0, 0.6 );
 
-					//m.map = map;
-					//m.envMap = envMap;
-					//m.bumpMap = bumpMap;
-					//m.bumpScale = 2;
-
-					//m.combine = THREE.MixOperation;
-					//m.reflectivity = 0.75;
-
 				}
 
 				mesh = new THREE.SkinnedMesh( geometry, materials );

+ 1 - 1
examples/webgl_buffergeometry_indexed.html

@@ -160,7 +160,7 @@
 
 				//
 
-				var gui = new dat.GUI()
+				var gui = new dat.GUI();
 				gui.add( material, 'wireframe' );
 
 				//

+ 0 - 1
examples/webgl_buffergeometry_instancing.html

@@ -129,7 +129,6 @@
 
 			var vector = new THREE.Vector4();
 
-			var triangles = 1;
 			var instances = 50000;
 
 			var positions = [];

+ 1 - 3
examples/webgl_camera_logarithmicdepthbuffer.html

@@ -172,7 +172,7 @@
 				renderer.domElement.id = 'renderer_' + name;
 				framecontainer.appendChild(renderer.domElement);
 
-				return { container: framecontainer, renderer: renderer, scene: scene, camera: camera }
+				return { container: framecontainer, renderer: renderer, scene: scene, camera: camera };
 
 			}
 
@@ -193,8 +193,6 @@
 					emissive: 0x000000
 				};
 
-				var meshes = [];
-
 				var geometry = new THREE.SphereBufferGeometry(0.5, 24, 12);
 
 				for (var i = 0; i < labeldata.length; i++) {

+ 62 - 489
examples/webgl_effects_parallaxbarrier.html

@@ -6,152 +6,61 @@
 		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
 		<style>
 			body {
-				background:#000;
-				color:#fff;
+				background:#777;
 				padding:0;
 				margin:0;
+				font-weight: bold;
 				overflow:hidden;
-				font-family:georgia;
-				text-align:center;
 			}
-			h1 { }
-			a { color:skyblue; text-decoration:none }
-			canvas { pointer-events:none; z-index:10; position:relative; }
-
-			#d { position:absolute; width: 100%; text-align:center; margin:1em 0 -4.5em 0; z-index:1000; }
 
-			.bwrap { margin:0.5em 0 0 0 }
-			button { font-family:georgia; border:0; background:#000; color:#fff; padding:0.2em 0.5em; cursor:pointer; border-radius:3px; }
-			button:hover { background:#333 }
-			#buttons_cars button { color:#fa0 }
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				color: #ffffff;
+				padding: 5px;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+				z-index:1000;
+			}
 
-			#car_info { text-align:center; }
-			#car_name { font-size:1em }
-			#car_author { font-size:1em }
+			a {
+				color: #ffffff;
+			}
 
-			#oldie { background:rgb(50,0,0) !important; color:#fff !important; margin-top:7em!important }
+			#oldie a { color:#da0 }
 		</style>
 	</head>
 
 	<body>
-		<div id="d">
-			<div id="info">
-				<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - effects - parallax barrier.
-				texture by <a href="http://www.humus.name/index.php?page=Textures" target="_blank" rel="noopener">Humus</a> :
-				<span id="car_info">
-					<span id="car_name">Bugatti Veyron model</span>
-					by <span id="car_author"><a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank" rel="noopener">Troyano</a></span>
-				</span>
-
-			</div>
-
-			<div id="buttons_cars" class="bwrap">
-				<button id="veyron">Bugatti Veyron</button>
-				<button id="gallardo">Lamborghini Gallardo</button>
-				<button id="f50">Ferrari F50</button>
-				<button id="camaro">Chevrolet Camaro</button>
-			</div>
-
-			<div id="buttons_materials" class="bwrap"></div>
-		</div>
+		<div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - effects - parallax barrier. skybox by <a href="http://ict.debevec.org/~debevec/" target="_blank" rel="noopener">Paul Debevec</a></div>
 
 		<script src="../build/three.js"></script>
 
 		<script src="js/effects/ParallaxBarrierEffect.js"></script>
-		<script src="js/loaders/BinaryLoader.js"></script>
 
 		<script src="js/Detector.js"></script>
-		<script src="js/libs/stats.min.js"></script>
 
 		<script>
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
-			var STATS_ENABLED = false;
-
-			var CARS = {
-
-				"veyron": 	{
-
-					name:	"Bugatti Veyron",
-					url: 	"obj/veyron/VeyronNoUv_bin.js",
-					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1129" target="_blank" rel="noopener">Troyano</a>',
-					init_rotation: [ 0, 0, 0 ],
-					scale: 5.5,
-					init_material: 4,
-					body_materials: [ 2 ],
-
-					object: null,
-					buttons: null,
-					materials: null
-
-				},
-
-				"gallardo": {
-
-					name: 	"Lamborghini Gallardo",
-					url:	"obj/gallardo/GallardoNoUv_bin.js",
-					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1711" target="_blank" rel="noopener">machman_3d</a>',
-					init_rotation: [ 0, 0, 0 ],
-					scale: 3.7,
-					init_material: 9,
-					body_materials: [ 3 ],
-
-					object:	null,
-					buttons: null,
-					materials: null
-
-				},
-
-				"f50": {
-
-					name: 	"Ferrari F50",
-					url:	"obj/f50/F50NoUv_bin.js",
-					author: '<a href="http://artist-3d.com/free_3d_models/dnm/model_disp.php?uid=1687" target="_blank" rel="noopener">daniel sathya</a>',
-					init_rotation: [ 0, 0, 0 ],
-					scale: 0.175,
-					init_material: 2,
-					body_materials: [ 3, 6, 7, 8, 9, 10, 23, 24 ],
-
-					object:	null,
-					buttons: null,
-					materials: null
-
-				},
-
-				"camaro": {
-
-					name: 	"Chevrolet Camaro",
-					url:	"obj/camaro/CamaroNoUv_bin.js",
-					author: '<a href="http://www.turbosquid.com/3d-models/blender-camaro/411348" target="_blank" rel="noopener">dskfnwn</a>',
-					init_rotation: [ 0.0, 0.0, 0.0 ],
-					scale: 75,
-					init_material: 0,
-					body_materials: [ 0 ],
-
-					object:	null,
-					buttons: null,
-					materials: null
-
-				}
-
-			};
-
-
-			var container, stats;
+			var container;
 
 			var camera, scene, renderer, effect;
 
-			var m, mi;
+			var mesh, lightMesh, geometry;
+			var spheres = [];
 
 			var directionalLight, pointLight;
 
-			var mouseX = 0, mouseY = 0;
+			var mouseX = 0;
+			var mouseY = 0;
 
 			var windowHalfX = window.innerWidth / 2;
 			var windowHalfY = window.innerHeight / 2;
 
-			var loader = new THREE.BinaryLoader();
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 
 			init();
 			animate();
@@ -161,31 +70,41 @@
 				container = document.createElement( 'div' );
 				document.body.appendChild( container );
 
-				camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 100000 );
+				camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.01, 100 );
+				camera.position.z = 3;
+				camera.focalLength = 3;
 
-				var textureCube = new THREE.CubeTextureLoader()
-					.setPath( 'textures/cube/Bridge2/')
-					.load( [ 'posx.jpg', 'negx.jpg', 'posy.jpg', 'negy.jpg', 'posz.jpg', 'negz.jpg' ] );
+				var path = "textures/cube/pisa/";
+				var format = '.png';
+				var urls = [
+					path + 'px' + format, path + 'nx' + format,
+					path + 'py' + format, path + 'ny' + format,
+					path + 'pz' + format, path + 'nz' + format
+				];
+
+				var textureCube = new THREE.CubeTextureLoader().load( urls );
 
 				scene = new THREE.Scene();
 				scene.background = textureCube;
 
-				// LIGHTS
+				var geometry = new THREE.SphereBufferGeometry( 0.1, 32, 16 );
+				var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube } );
+
+				for ( var i = 0; i < 500; i ++ ) {
+
+					var mesh = new THREE.Mesh( geometry, material );
 
-				var ambient = new THREE.AmbientLight( 0x050505 );
-				scene.add( ambient );
+					mesh.position.x = Math.random() * 10 - 5;
+					mesh.position.y = Math.random() * 10 - 5;
+					mesh.position.z = Math.random() * 10 - 5;
 
-				directionalLight = new THREE.DirectionalLight( 0xffffff, 2 );
-				directionalLight.position.set( 2, 1.2, 10 ).normalize();
-				scene.add( directionalLight );
+					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 3 + 1;
 
-				directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
-				directionalLight.position.set( - 2, 1.2, -10 ).normalize();
-				scene.add( directionalLight );
+					scene.add( mesh );
 
-				pointLight = new THREE.PointLight( 0xffaa00, 2 );
-				pointLight.position.set( 2000, 1200, 10000 );
-				scene.add( pointLight );
+					spheres.push( mesh );
+
+				}
 
 				//
 
@@ -199,245 +118,6 @@
 				effect = new THREE.ParallaxBarrierEffect( renderer );
 				effect.setSize( width, height );
 
-				if ( STATS_ENABLED ) {
-
-					stats = new Stats();
-					container.appendChild( stats.dom );
-
-				}
-
-				document.addEventListener('mousemove', onDocumentMouseMove, false);
-
-				// common materials
-
-				var mlib = {
-
-				"Orange": 	new THREE.MeshLambertMaterial( { color: 0xff6600, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
-				"Blue": 	new THREE.MeshLambertMaterial( { color: 0x001133, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.3 } ),
-				"Red": 		new THREE.MeshLambertMaterial( { color: 0x660000, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
-				"Black": 	new THREE.MeshLambertMaterial( { color: 0x000000, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.15 } ),
-				"White":	new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
-
-				"Carmine": 	new THREE.MeshPhongMaterial( { color: 0x770000, specular:0xffaaaa, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-				"Gold": 	new THREE.MeshPhongMaterial( { color: 0xaa9944, specular:0xbbaa99, shininess:50, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-				"Bronze":	new THREE.MeshPhongMaterial( { color: 0x150505, specular:0xee6600, shininess:10, envMap: textureCube, combine: THREE.MixOperation, reflectivity: 0.25 } ),
-				"Chrome": 	new THREE.MeshPhongMaterial( { color: 0xffffff, specular:0xffffff, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-
-				"Orange metal": new THREE.MeshLambertMaterial( { color: 0xff6600, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-				"Blue metal": 	new THREE.MeshLambertMaterial( { color: 0x001133, envMap: textureCube, combine: THREE.MultiplyOperation  } ),
-				"Red metal": 	new THREE.MeshLambertMaterial( { color: 0x770000, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-				"Green metal": 	new THREE.MeshLambertMaterial( { color: 0x007711, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-				"Black metal":	new THREE.MeshLambertMaterial( { color: 0x222222, envMap: textureCube, combine: THREE.MultiplyOperation } ),
-
-				"Pure chrome": 	new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube } ),
-				"Dark chrome":	new THREE.MeshLambertMaterial( { color: 0x444444, envMap: textureCube } ),
-				"Darker chrome":new THREE.MeshLambertMaterial( { color: 0x222222, envMap: textureCube } ),
-
-				"Black glass": 	new THREE.MeshLambertMaterial( { color: 0x101016, envMap: textureCube, opacity: 0.975, transparent: true } ),
-				"Dark glass":	new THREE.MeshLambertMaterial( { color: 0x101046, envMap: textureCube, opacity: 0.25, transparent: true } ),
-				"Blue glass":	new THREE.MeshLambertMaterial( { color: 0x668899, envMap: textureCube, opacity: 0.75, transparent: true } ),
-				"Light glass":	new THREE.MeshBasicMaterial( { color: 0x223344, envMap: textureCube, opacity: 0.25, transparent: true, combine: THREE.MixOperation, reflectivity: 0.25 } ),
-
-				"Red glass":	new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.75, transparent: true } ),
-				"Yellow glass":	new THREE.MeshLambertMaterial( { color: 0xffffaa, opacity: 0.75, transparent: true } ),
-				"Orange glass":	new THREE.MeshLambertMaterial( { color: 0x995500, opacity: 0.75, transparent: true } ),
-
-				"Orange glass 50":	new THREE.MeshLambertMaterial( { color: 0xffbb00, opacity: 0.5, transparent: true } ),
-				"Red glass 50": 	new THREE.MeshLambertMaterial( { color: 0xff0000, opacity: 0.5, transparent: true } ),
-
-				"Fullblack rough":	new THREE.MeshLambertMaterial( { color: 0x000000 } ),
-				"Black rough":		new THREE.MeshLambertMaterial( { color: 0x050505 } ),
-				"Darkgray rough":	new THREE.MeshLambertMaterial( { color: 0x090909 } ),
-				"Red rough":		new THREE.MeshLambertMaterial( { color: 0x330500 } ),
-
-				"Darkgray shiny":	new THREE.MeshPhongMaterial( { color: 0x000000, specular: 0x050505 } ),
-				"Gray shiny":		new THREE.MeshPhongMaterial( { color: 0x050505, shininess: 20 } )
-
-				};
-
-				// Gallardo materials
-
-				CARS[ "gallardo" ].materials = {
-
-					body: [
-
-						[ "Orange", 	mlib[ "Orange" ] ],
-						[ "Blue", 		mlib[ "Blue" ] ],
-						[ "Red", 		mlib[ "Red" ] ],
-						[ "Black", 		mlib[ "Black" ] ],
-						[ "White", 		mlib[ "White" ] ],
-
-						[ "Orange metal", 	mlib[ "Orange metal" ] ],
-						[ "Blue metal", 	mlib[ "Blue metal" ] ],
-						[ "Green metal", 	mlib[ "Green metal" ] ],
-						[ "Black metal", 	mlib[ "Black metal" ] ],
-
-						[ "Carmine", 	mlib[ "Carmine" ] ],
-						[ "Gold", 		mlib[ "Gold" ] ],
-						[ "Bronze", 	mlib[ "Bronze" ] ],
-						[ "Chrome", 	mlib[ "Chrome" ] ]
-
-					]
-
-				};
-
-				m = CARS[ "gallardo" ].materials;
-				mi = CARS[ "gallardo" ].init_material;
-
-				CARS[ "gallardo" ].mmap = {
-
-					0: mlib[ "Pure chrome" ], 	// wheels chrome
-					1: mlib[ "Black rough" ],   // tire
-					2: mlib[ "Black glass" ], 	// windshield
-					3: m.body[ mi ][ 1 ], 		// body
-					4: mlib[ "Red glass" ],    	// back lights
-					5: mlib[ "Yellow glass" ],  // front lights
-					6: mlib[ "Dark chrome" ]	// windshield rim
-
-				};
-
-				// Veyron materials
-
-				CARS[ "veyron" ].materials = {
-
-					body: [
-
-						[ "Orange metal", 	mlib[ "Orange metal" ] ],
-						[ "Blue metal", 	mlib[ "Blue metal" ] ],
-						[ "Red metal", 		mlib[ "Red metal" ] ],
-						[ "Green metal",	mlib[ "Green metal" ] ],
-						[ "Black metal", 	mlib[ "Black metal" ] ],
-
-						[ "Gold", 		mlib[ "Gold" ] ],
-						[ "Bronze", 	mlib[ "Bronze" ] ],
-						[ "Chrome", 	mlib[ "Chrome" ] ]
-
-					]
-
-				};
-
-				m = CARS[ "veyron" ].materials;
-				mi = CARS[ "veyron" ].init_material;
-
-				CARS[ "veyron" ].mmap = {
-
-					0: mlib[ "Black rough" ],		// tires + inside
-					1: mlib[ "Pure chrome" ],		// wheels + extras chrome
-					2: m.body[ mi ][ 1 ], 			// back / top / front torso
-					3: mlib[ "Dark glass" ],		// glass
-					4: mlib[ "Pure chrome" ],		// sides torso
-					5: mlib[ "Pure chrome" ],		// engine
-					6: mlib[ "Red glass 50" ],		// backlights
-					7: mlib[ "Orange glass 50" ]	// backsignals
-
-				};
-
-				// F50 materials
-
-				CARS[ "f50" ].materials = {
-
-					body: [
-
-						[ "Orange", 	mlib[ "Orange" ] ],
-						[ "Blue", 		mlib[ "Blue" ] ],
-						[ "Red", 		mlib[ "Red" ] ],
-						[ "Black", 		mlib[ "Black" ] ],
-						[ "White", 		mlib[ "White" ] ],
-
-						[ "Orange metal", 	mlib[ "Orange metal" ] ],
-						[ "Blue metal", 	mlib[ "Blue metal" ] ],
-						[ "Black metal", 	mlib[ "Black metal" ] ],
-
-						[ "Carmine", 	mlib[ "Carmine" ] ],
-						[ "Gold", 		mlib[ "Gold" ] ],
-						[ "Bronze", 	mlib[ "Bronze" ] ],
-						[ "Chrome", 	mlib[ "Chrome" ] ]
-
-					]
-
-				};
-
-				m = CARS[ "f50" ].materials;
-				mi = CARS[ "f50" ].init_material;
-
-				CARS[ "f50" ].mmap = {
-
-					0:  mlib[ "Dark chrome" ], 		// interior + rim
-					1:  mlib[ "Pure chrome" ], 		// wheels + gears chrome
-					2:  mlib[ "Blue glass" ], 		// glass
-					3:  m.body[ mi ][ 1 ], 			// torso mid + front spoiler
-					4:  mlib[ "Darkgray shiny" ], 	// interior + behind seats
-					5:  mlib[ "Darkgray shiny" ], 	// tiny dots in interior
-					6:  m.body[ mi ][ 1 ], 			// back torso
-					7:  m.body[ mi ][ 1 ], 			// right mirror decal
-					8:  m.body[ mi ][ 1 ], 			// front decal
-					9:  m.body[ mi ][ 1 ], 			// front torso
-					10: m.body[ mi ][ 1 ], 			// left mirror decal
-					11: mlib[ "Pure chrome" ], 		// engine
-					12: mlib[ "Darkgray rough" ],	// tires side
-					13: mlib[ "Darkgray rough" ],	// tires bottom
-					14: mlib[ "Darkgray shiny" ], 	// bottom
-					15: mlib[ "Black rough" ],		// ???
-					16: mlib[ "Orange glass" ],		// front signals
-					17: mlib[ "Dark chrome" ], 		// wheels center
-					18: mlib[ "Red glass" ], 		// back lights
-					19: mlib[ "Black rough" ], 		// ???
-					20: mlib[ "Red rough" ], 		// seats
-					21: mlib[ "Black rough" ], 		// back plate
-					22: mlib[ "Black rough" ], 		// front light dots
-					23: m.body[ mi ][ 1 ], 			// back torso
-					24: m.body[ mi ][ 1 ] 			// back torso center
-
-				};
-
-
-				// Camero materials
-
-				CARS[ "camaro" ].materials = {
-
-					body: [
-
-						[ "Orange", 	mlib[ "Orange" ] ],
-						[ "Blue", 		mlib[ "Blue" ] ],
-						[ "Red", 		mlib[ "Red" ] ],
-						[ "Black", 		mlib[ "Black" ] ],
-						[ "White", 		mlib[ "White" ] ],
-
-						[ "Orange metal", 	mlib[ "Orange metal" ] ],
-						[ "Blue metal", 	mlib[ "Blue metal" ] ],
-						[ "Red metal", 		mlib[ "Red metal" ] ],
-						[ "Green metal", 	mlib[ "Green metal" ] ],
-						[ "Black metal", 	mlib[ "Black metal" ] ],
-
-						[ "Gold", 		mlib[ "Gold" ] ],
-						[ "Bronze", 	mlib[ "Bronze" ] ],
-						[ "Chrome", 	mlib[ "Chrome" ] ]
-
-					]
-
-				};
-
-				m = CARS[ "camaro" ].materials;
-				mi = CARS[ "camaro" ].init_material;
-
-				CARS[ "camaro" ].mmap = {
-
-					0: m.body[ mi ][ 1 ], 			// car body
-					1: mlib[ "Pure chrome" ], 		// wheels chrome
-					2: mlib[ "Pure chrome" ], 		// grille chrome
-					3: mlib[ "Dark chrome" ], 		// door lines
-					4: mlib[ "Light glass" ], 		// windshield
-					5: mlib[ "Gray shiny" ],        // interior
-					6: mlib[ "Black rough" ],       // tire
-					7: mlib[ "Fullblack rough" ],   // tireling
-					8: mlib[ "Fullblack rough" ]    // behind grille
-
-				};
-
-				loader.load( CARS[ "veyron" ].url, function( geometry ) { createScene( geometry, "veyron" ) } );
-
-				for( var c in CARS ) initCarButton( c );
-
 				//
 
 				window.addEventListener( 'resize', onWindowResize, false );
@@ -456,121 +136,10 @@
 
 			}
 
-			function initCarButton( car ) {
-
-				$( car ).addEventListener( 'click', function() {
-
-					if ( ! CARS[ car ].object ) {
-
-						loader.load( CARS[ car ].url, function( geometry ) { createScene( geometry, car ) } );
-
-					} else {
-
-						switchCar( car );
-
-					}
-
-				}, false );
-
-			}
-
-			function $( id ) { return document.getElementById( id ) }
-			function button_name( car, index ) { return "m_" + car  + "_" + index }
-
-			function switchCar( car ) {
-
-				for ( var c in CARS ) {
-
-					if ( c != car && CARS[ c ].object ) {
-
-						CARS[ c ].object.visible = false;
-						CARS[ c ].buttons.style.display = "none";
-
-					}
-				}
-
-				CARS[ car ].object.visible = true;
-				CARS[ car ].buttons.style.display = "block";
-
-				$( "car_name" ).innerHTML = CARS[ car ].name + " model";
-				$( "car_author" ).innerHTML = CARS[ car ].author;
-
-			}
-
-			function createButtons( materials, car ) {
-
-				var buttons, i, src = "";
-
-				for( i = 0; i < materials.length; i++ ) {
-
-					src += '<button id="' + button_name( car, i ) + '">' + materials[ i ][ 0 ] + '</button> ';
-
-				}
-
-				buttons = document.createElement("div");
-				buttons.innerHTML = src;
-
-				$( "buttons_materials" ).appendChild( buttons );
-
-				return buttons;
-
-			}
-
-			function attachButtonMaterials( materials, faceMaterials, material_indices, car ) {
-
-				for( var i = 0; i < materials.length; i++ ) {
-
-					$( button_name( car, i ) ).counter = i;
-					$( button_name( car, i ) ).addEventListener( 'click', function() {
-
-						for ( var j = 0; j < material_indices.length; j ++ ) {
-
-							faceMaterials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
-
-						}
-
-					}, false );
-
-				}
-
-			}
-
-			function createScene( geometry, car ) {
-
-				geometry.sortFacesByMaterialIndex();
-
-				var m = [],
-					s = CARS[ car ].scale * 1,
-					r = CARS[ car ].init_rotation,
-					materials = CARS[ car ].materials,
-					mi = CARS[ car ].init_material,
-					bm = CARS[ car ].body_materials;
-
-				for( var i in CARS[ car ].mmap ) {
-
-					m[ i ] = CARS[ car ].mmap[ i ];
-
-				}
-
-				var mesh = new THREE.Mesh( geometry, m );
-				mesh.rotation.x = r[ 0 ];
-				mesh.rotation.y = r[ 1 ];
-				mesh.rotation.z = r[ 2 ];
-				mesh.scale.x = mesh.scale.y = mesh.scale.z = s;
-				scene.add( mesh );
-
-				CARS[ car ].object = mesh;
-
-				CARS[ car ].buttons = createButtons( materials.body, car );
-				attachButtonMaterials( materials.body, m, bm, car );
-
-				switchCar( car );
-
-			}
-
 			function onDocumentMouseMove(event) {
 
-				mouseY = ( event.clientY - window.innerHeight );
+				mouseX = ( event.clientX - windowHalfX ) / 100;
+				mouseY = ( event.clientY - windowHalfY ) / 100;
 
 			}
 
@@ -586,21 +155,25 @@
 
 			function render() {
 
-				var timer = -0.0002 * Date.now();
+				var timer = 0.0001 * Date.now();
 
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
 
-				camera.position.x = 1000 * Math.cos( timer );
-				camera.position.z = 1000 * Math.sin( timer );
-
 				camera.lookAt( scene.position );
 
-				effect.render( scene, camera );
+				for ( var i = 0, il = spheres.length; i < il; i ++ ) {
 
-				if ( STATS_ENABLED ) stats.update();
+					var sphere = spheres[ i ];
 
-			}
+					sphere.position.x = 5 * Math.cos( timer + i );
+					sphere.position.y = 5 * Math.sin( timer + i * 1.1 );
 
+				}
+
+				effect.render( scene, camera );
+
+			}
 
 		</script>
 

+ 1 - 1
examples/webgl_geometries.html

@@ -53,7 +53,7 @@
 
 				scene = new THREE.Scene();
 
-				var light, object;
+				var object;
 
 				var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
 				scene.add( ambientLight );

+ 0 - 1
examples/webgl_geometry_minecraft_ao.html

@@ -160,7 +160,6 @@
 				//
 
 				var geometry = new THREE.Geometry();
-				var dummy = new THREE.Mesh();
 
 				for ( var z = 0; z < worldDepth; z ++ ) {
 

+ 1 - 2
examples/webgl_geometry_terrain.html

@@ -152,8 +152,7 @@
 
 			function generateTexture( data, width, height ) {
 
-				var canvas, canvasScaled, context, image, imageData,
-				level, diff, vector3, sun, shade;
+				var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
 
 				vector3 = new THREE.Vector3( 0, 0, 0 );
 

+ 1 - 2
examples/webgl_geometry_terrain_fog.html

@@ -155,8 +155,7 @@
 
 			function generateTexture( data, width, height ) {
 
-				var canvas, canvasScaled, context, image, imageData,
-				level, diff, vector3, sun, shade;
+				var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
 
 				vector3 = new THREE.Vector3( 0, 0, 0 );
 

+ 1 - 2
examples/webgl_geometry_terrain_raycast.html

@@ -168,8 +168,7 @@
 
 				// bake lighting into texture
 
-				var canvas, canvasScaled, context, image, imageData,
-					level, diff, vector3, sun, shade;
+				var canvas, canvasScaled, context, image, imageData, vector3, sun, shade;
 
 				vector3 = new THREE.Vector3( 0, 0, 0 );
 

+ 0 - 1
examples/webgl_lights_physical.html

@@ -290,7 +290,6 @@
 
 				hemiLight.intensity = hemiLuminousIrradiances[ params.hemiIrradiance ];
 				var time = Date.now() * 0.0005;
-				var delta = clock.getDelta();
 
 				bulbLight.position.y = Math.cos( time ) * 0.75 + 1.25;
 

+ 1 - 1
examples/webgl_lights_pointlights2.html

@@ -217,7 +217,7 @@
 			function render() {
 
 				var time = Date.now() * 0.00025;
-				var z = 20, d = 150;
+				var d = 150;
 
 				light1.position.x = Math.sin( time * 0.7 ) * d;
 				light1.position.z = Math.cos( time * 0.3 ) * d;

+ 1 - 1
examples/webgl_lines_sphere.html

@@ -74,7 +74,7 @@
 
 				scene = new THREE.Scene();
 
-				var i, line, vertex1, vertex2, material, p,
+				var i, line, material, p,
 					parameters = [ [ 0.25, 0xff7700, 1, 2 ], [ 0.5, 0xff9900, 1, 1 ], [ 0.75, 0xffaa00, 0.75, 1 ], [ 1, 0xffaa00, 0.5, 1 ], [ 1.25, 0x000833, 0.8, 1 ],
 							       [ 3.0, 0xaaaaaa, 0.75, 2 ], [ 3.5, 0xffffff, 0.5, 1 ], [ 4.5, 0xffffff, 0.25, 1 ], [ 5.5, 0xffffff, 0.125, 1 ] ];
 

+ 4 - 4
examples/webgl_loader_babylon.html

@@ -60,15 +60,15 @@
 
 				};
 
-				var texture = new THREE.Texture();
-
-				var material = new THREE.MeshBasicMaterial( { color: 'red' } );
-
 				var onProgress = function ( xhr ) {
+
 					if ( xhr.lengthComputable ) {
+
 						var percentComplete = xhr.loaded / xhr.total * 100;
 						console.log( Math.round(percentComplete, 2) + '% downloaded' );
+
 					}
+
 				};
 
 				var onError = function ( xhr ) {

+ 1 - 1
examples/webgl_loader_collada_kinematics.html

@@ -149,7 +149,7 @@
 
 							tweenParameters[ prop ] = position;
 
-							target[ prop ] = THREE.Math.randInt( joint.limits.min, joint.limits.max )
+							target[ prop ] = THREE.Math.randInt( joint.limits.min, joint.limits.max );
 
 						}
 

+ 0 - 7
examples/webgl_loader_nrrd.html

@@ -103,10 +103,7 @@
 				var loader = new THREE.NRRDLoader();
 				loader.load( "models/nrrd/I.nrrd", function ( volume ) {
 					var geometry,
-						canvas,
-						canvasMap,
 						material,
-						plane,
 						sliceZ,
 						sliceY,
 						sliceX;
@@ -122,18 +119,14 @@
 					scene.add( cube );
 
 					//z plane
-
-					var indexZ = 0;
 					sliceZ = volume.extractSlice('z',Math.floor(volume.RASDimensions[2]/4));
 					scene.add( sliceZ.mesh );
 
 					//y plane
-					var indexY = 0;
 					sliceY = volume.extractSlice('y',Math.floor(volume.RASDimensions[1]/2));
 					scene.add( sliceY.mesh );
 
 					//x plane
-					var indexX = 0;
 					sliceX = volume.extractSlice('x',Math.floor(volume.RASDimensions[0]/2));
 					scene.add( sliceX.mesh );
 

+ 1 - 1
examples/webgl_materials_cubemap.html

@@ -124,7 +124,7 @@
 					head3.position.x = 900;
 					head3.material = cubeMaterial3;
 
-					scene.add( head, head2, head3 )
+					scene.add( head, head2, head3 );
 
 				} );
 

+ 1 - 1
examples/webgl_materials_curvature.html

@@ -338,7 +338,7 @@
 				topologyFolder.add( params, 'filterConvex' );
 				topologyFolder.add( params, 'filterConcave' );
 				topologyFolder.add( params, 'filterBoth' );
-				topologyFolder.open()
+				topologyFolder.open();
 
 				onWindowResize();
 

+ 0 - 2
examples/webgl_materials_normalmap.html

@@ -158,8 +158,6 @@
 				var effectColor = new THREE.ShaderPass( THREE.ColorCorrectionShader );
 				effectFXAA = new THREE.ShaderPass( THREE.FXAAShader );
 
-				var canvas = renderer.context.canvas;
-
 				effectFXAA.uniforms[ 'resolution' ].value.set( 1 / window.innerWidth, 1 / window.innerHeight );
 
 				effectBleach.uniforms[ 'opacity' ].value = 0.4;

+ 150 - 0
examples/webgl_materials_normalmap_object_space.html

@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<title>three.js webgl - materials - normal map [object space]</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+		<style>
+			body {
+				font-family: Monospace;
+				background-color: #000;
+				color: #fff;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			a {
+				color: #ffa;
+				font-weight: bold;
+			}
+
+			#info {
+				color: #fff;
+				position: absolute;
+				top: 10px;
+				width: 100%;
+				text-align: center;
+				z-index: 100;
+				display:block;
+			}
+		</style>
+	</head>
+
+	<body>
+		<div id="info">
+			<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl object-space normalmap demo<br />
+			Nefertiti Bust by
+			<a href="http://www.cultlab3d.de/" target="_blank" rel="noopener">CultLab3D</a><br />
+
+		</div>
+
+		<script src="../build/three.js"></script>
+
+		<script src="js/controls/OrbitControls.js"></script>
+		<script src="js/loaders/GLTFLoader.js"></script>
+
+		<script src="js/Detector.js"></script>
+
+		<script>
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var mesh, renderer, scene, camera;
+
+			var obj;
+
+			init();
+
+			function init() {
+
+				// renderer
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				document.body.appendChild( renderer.domElement );
+
+				renderer.gammaOutput = true;
+
+				// scene
+				scene = new THREE.Scene();
+
+				// camera
+				camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 1000 );
+				camera.position.set( - 10, 0, 23 );
+				scene.add( camera );
+
+				// controls
+				var controls = new THREE.OrbitControls( camera, renderer.domElement );
+				controls.addEventListener( 'change', render );
+				controls.minDistance = 10;
+				controls.maxDistance = 50;
+				controls.enablePan = false;
+
+				// ambient
+				scene.add( new THREE.AmbientLight( 0xffffff, .2 ) );
+
+				// light
+				var light = new THREE.PointLight( 0xffffff, 1.5 );
+				camera.add( light );
+
+				// model
+				new THREE.GLTFLoader().load( 'models/gltf/Nefertiti/Nefertiti.glb', function ( gltf ) {
+
+					gltf.scene.traverse( function ( child ) {
+
+						if ( child.isMesh ) {
+
+							// glTF currently supports only tangent-space normal maps.
+							// this model has been modified to demonstrate the use of an object-space normal map.
+
+							child.material.normalMapType = THREE.ObjectSpaceNormalMap;
+
+							// attribute normals are not required with an object-space normal map. remove them.
+
+							child.geometry.removeAttribute( 'normal' );
+
+							//
+
+							child.material.side = THREE.DoubleSide;
+
+							child.scale.multiplyScalar( 0.5 );
+
+							// recenter
+
+							new THREE.Box3().setFromObject( child ).getCenter( child.position ).multiplyScalar( - 1 );
+
+							scene.add( child );
+
+						}
+
+					} );
+
+					render();
+
+				} );
+
+
+			    window.addEventListener( 'resize', onWindowResize, false );
+
+			}
+
+			function onWindowResize() {
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+				render();
+
+			}
+
+			function render() {
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 4 - 2
examples/webgl_materials_reflectivity.html

@@ -166,6 +166,10 @@
 					gemFrontMaterial.envMap = gemBackMaterial.envMap = hdrCubeRenderTarget.texture;
 					gemFrontMaterial.needsUpdate = gemBackMaterial.needsUpdate = true;
 
+					hdrCubeMap.dispose();
+					pmremGenerator.dispose();
+					pmremCubeUVPacker.dispose();
+
 				} );
 
 
@@ -260,8 +264,6 @@
 
 				renderer.toneMappingExposure = params.exposure;
 
-				var timer = Date.now() * 0.00025;
-
 				camera.lookAt( scene.position );
 
 				if( params.autoRotate ) {

+ 0 - 2
examples/webgl_materials_texture_rotation.html

@@ -154,8 +154,6 @@
 
 			function initGui() {
 
-				var drop;
-
 				gui = new dat.GUI();
 
 				gui.add( API, 'offsetX', 0.0, 1.0 ).name( 'offset.x' ).onChange( updateUvTransform );

+ 0 - 4
examples/webgl_materials_variations_basic.html

@@ -76,10 +76,6 @@
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 
-				var shininess = 50, specular = 0x333333;
-
-				var materials = [];
-
 				var cubeWidth = 400;
 				var numberOfSphersPerSide = 5;
 				var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;

+ 0 - 4
examples/webgl_materials_variations_lambert.html

@@ -76,10 +76,6 @@
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 
-				var shininess = 50, specular = 0x333333;
-
-				var materials = [];
-
 				var cubeWidth = 400;
 				var numberOfSphersPerSide = 5;
 				var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;

+ 1 - 4
examples/webgl_materials_variations_phong.html

@@ -76,10 +76,7 @@
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 
-				var shininess = 50, specular = 0x333333, bumpScale = 1;
-
-				var materials = [];
-
+				var bumpScale = 1;
 				var cubeWidth = 400;
 				var numberOfSphersPerSide = 5;
 				var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;

+ 6 - 1
examples/webgl_materials_variations_physical.html

@@ -143,7 +143,12 @@
 						index ++;
 
 					}
-				});
+
+					hdrCubeMap.dispose();
+					pmremGenerator.dispose();
+					pmremCubeUVPacker.dispose();
+
+				} );
 
 				function addLabel( name, location ) {
 

+ 7 - 5
examples/webgl_materials_variations_standard.html

@@ -101,10 +101,7 @@
 
 					hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
 
-					var shininess = 50, specular = 0x333333, bumpScale = 1;
-
-					var materials = [];
-
+					var bumpScale = 1;
 					var cubeWidth = 400;
 					var numberOfSphersPerSide = 5;
 					var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;
@@ -150,7 +147,12 @@
 						index ++;
 
 					}
-				});
+
+					hdrCubeMap.dispose();
+					pmremGenerator.dispose();
+					pmremCubeUVPacker.dispose();
+
+				} );
 
 				function addLabel( name, location ) {
 

+ 1 - 4
examples/webgl_materials_variations_toon.html

@@ -78,10 +78,7 @@
 				imgTexture.anisotropy = 16;
 				imgTexture = null;
 
-				var shininess = 50, specular = 0x333333, bumpScale = 1;
-
-				var materials = [];
-
+				var bumpScale = 1;
 				var cubeWidth = 400;
 				var numberOfSphersPerSide = 5;
 				var sphereRadius = ( cubeWidth / numberOfSphersPerSide ) * 0.8 * 0.5;

+ 7 - 5
examples/webgl_modifier_subdivision.html

@@ -49,7 +49,7 @@
 
 			var wireframeMaterial = new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, opacity: 0.15, transparent: true } );
 			var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
-			var smoothMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } )
+			var smoothMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, flatShading: true, vertexColors: THREE.VertexColors } );
 
 			// Cube
 
@@ -94,10 +94,12 @@
 
 			} );
 
-			var loader = new THREE.JSONLoader();
-			loader.load( 'models/json/WaltHeadLo.json', function ( geometry ) {
+			var loader = new THREE.BufferGeometryLoader();
+			loader.load( 'models/json/WaltHeadLo_buffergeometry.json', function ( geometry ) {
 
-				geometriesParams.push({type: 'WaltHead', args: [ ], meshScale: 6 });
+				geometry = new THREE.Geometry().fromBufferGeometry( geometry );
+
+				geometriesParams.push( {type: 'WaltHead', args: [ ], meshScale: 6 } );
 
 				THREE.WaltHead = function() {
 					return geometry.clone();
@@ -112,7 +114,7 @@
 
 				geometry = new THREE.Geometry().fromBufferGeometry( geometry );
 
-				geometriesParams.push({type: 'Suzanne', args: [ ], scale: 100, meshScale:2 });
+				geometriesParams.push( {type: 'Suzanne', args: [ ], scale: 100, meshScale:2 } );
 
 				THREE.Suzanne = function() {
 					return geometry.clone();

+ 1 - 1
examples/webgl_modifier_tessellation.html

@@ -143,7 +143,7 @@
 
 			geometry = new THREE.BufferGeometry().fromGeometry( geometry );
 
-			var numFaces = geometry.attributes.position.count / 3
+			var numFaces = geometry.attributes.position.count / 3;
 
 			var colors = new Float32Array( numFaces * 3 * 3 );
 			var displacement = new Float32Array( numFaces * 3 * 3 );

+ 1 - 18
examples/webgl_octree.html

@@ -216,10 +216,6 @@
 					Math.random() * radiusMax - radiusMaxHalf
 				);
 
-				// record start time
-
-				var timeStart = Date.now();
-
 				// search octree from search mesh position with search radius
 				// optional third parameter: boolean, if should sort results by object when using faces in octree
 				// optional fourth parameter: vector3, direction of search when using ray (assumes radius is distance/far of ray)
@@ -228,11 +224,7 @@
 				direction.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ).normalize();
 				rayCaster.set( origin, direction );
 				meshesSearch = octree.search( rayCaster.ray.origin, radiusSearch, true, rayCaster.ray.direction );
-				var intersections = rayCaster.intersectOctreeObjects( meshesSearch );
-
-				// record end time
-
-				var timeEnd = Date.now();
+				rayCaster.intersectOctreeObjects( meshesSearch );
 
 				// set color of all meshes found in search
 
@@ -242,15 +234,6 @@
 
 				}
 
-				/*
-
-				// results to console
-
-				console.log( 'OCTREE: ', octree );
-				console.log( '... searched ', meshes.length, ' and found ', meshesSearch.length, ' with intersections ', intersections.length, ' and took ', ( timeEnd - timeStart ), ' ms ' );
-
-				*/
-
 			}
 
 			function render() {

+ 2 - 2
examples/webgl_physics_volume.html

@@ -204,7 +204,7 @@
 				var geometry = new THREE.Geometry().fromBufferGeometry( bufGeometry );
 
 				// Merge the vertices so the triangle soup is converted to indexed triangles
-				var vertsDiff = geometry.mergeVertices();
+				geometry.mergeVertices();
 
 				// Convert again to BufferGeometry, indexed
 				var indexedBufferGeom = createIndexedBufferGeometryFromGeometry( geometry );
@@ -339,7 +339,7 @@
 				volumeSoftBody.get_m_materials().at( 0 ).set_m_kLST( 0.9 );
 				volumeSoftBody.get_m_materials().at( 0 ).set_m_kAST( 0.9 );
 
-				volumeSoftBody.setTotalMass( mass, false )
+				volumeSoftBody.setTotalMass( mass, false );
 				Ammo.castObject( volumeSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin );
 				physicsWorld.addSoftBody( volumeSoftBody, 1, -1 );
 				volume.userData.physicsBody = volumeSoftBody;

+ 1 - 1
examples/webgl_points_sprites.html

@@ -132,7 +132,7 @@
 
 				var params = {
 					texture: true
-				}
+				};
 
 				gui.add( params, 'texture' ).onChange( function( value ) {
 

+ 1 - 1
examples/webgl_postprocessing_dof.html

@@ -136,7 +136,7 @@
 					} else {
 
 						mesh = new THREE.Mesh( geo, new THREE.MeshBasicMaterial( parameters ) );
-						materials[ count ] = mesh.material
+						materials[ count ] = mesh.material;
 
 					}
 

+ 1 - 2
examples/webgl_postprocessing_nodes.html

@@ -65,7 +65,7 @@
 
 				gui = new dat.GUI();
 
-				var example = gui.add( param, 'example', {
+				gui.add( param, 'example', {
 					'basic / color-adjustment': 'color-adjustment',
 					'basic / blends': 'blends',
 					'basic / fade': 'fade',
@@ -312,7 +312,6 @@
 						var normal = new THREE.TextureNode( decalNormal );
 						var normalXY = new THREE.SwitchNode( normal, 'xy' );
 						var scale = new THREE.FloatNode( .5 );
-						var flip = new THREE.Vector2Node( - 1, 1 );
 
 						var normalXYFlip = new THREE.Math1Node(
 							normalXY,

+ 1 - 2
examples/webgl_postprocessing_sao.html

@@ -73,7 +73,7 @@
 				saoBlurRadius: 12,
 				saoBlurStdDev: 6,
 				saoBlurDepthCutoff: 0.01
-			}
+			};
 			var supportsDepthTextureExtension = false;
 			var isWebGL2 = false;
 
@@ -183,7 +183,6 @@
 
 				var width = window.innerWidth || 1;
 				var height = window.innerHeight || 1;
-				var devicePixelRatio = window.devicePixelRatio || 1;
 
 				camera.aspect = width / height;
 				camera.updateProjectionMatrix();

+ 3 - 3
examples/webgl_shaders_tonemapping.html

@@ -202,11 +202,11 @@
 
 				var textureLoader = new THREE.TextureLoader();
 
-				var earthDiffuse = textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function( tex ) {
+				textureLoader.load( 'textures/planets/earth_atmos_4096.jpg', function( tex ) {
 					earthMat.map = tex;
 					earthMat.needsUpdate = true;
 				} );
-				var earthSpecular = textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function( tex ) {
+				textureLoader.load( 'textures/planets/earth_specular_2048.jpg', function( tex ) {
 					earthMat.specularMap = tex;
 					earthMat.needsUpdate = true;
 				} );
@@ -235,7 +235,7 @@
 					depthTest: false
 				} );
 
-				var earthClouds = textureLoader.load( 'textures/planets/earth_clouds_2048.png', function( tex ) {
+				textureLoader.load( 'textures/planets/earth_clouds_2048.png', function( tex ) {
 					earthCloudsMat.map = tex;
 					earthCloudsMat.needsUpdate = true;
 				} );

+ 0 - 1
examples/webgl_shaders_vector.html

@@ -119,7 +119,6 @@
 
 				var vA = new THREE.Vector2();
 				var vB = new THREE.Vector2();
-				var vDot = new THREE.Vector2();
 
 				function processShape( path, reverse ) {
 

+ 0 - 12
examples/webgl_shading_physical.html

@@ -112,18 +112,6 @@
 				textureLava.wrapS = textureLava.wrapT = THREE.RepeatWrapping;
 				textureLava.format = THREE.RGBFormat;
 
-				//
-
-				var path = "textures/cube/SwedishRoyalCastle/";
-				var format = '.jpg';
-				var urls = [
-						path + 'px' + format, path + 'nx' + format,
-						path + 'py' + format, path + 'ny' + format,
-						path + 'pz' + format, path + 'nz' + format
-					];
-
-				var reflectionCube = new THREE.CubeTextureLoader().load( urls );
-
 				// GROUND
 
 				var groundMaterial = new THREE.MeshPhongMaterial( {

+ 1 - 1
examples/webgl_shadowmap_performance.html

@@ -238,7 +238,7 @@
 				for ( var i = 0; i !== ANIMATION_GROUPS; ++ i ) {
 
 					var group = new THREE.AnimationObjectGroup();
-					animGroups.push( new THREE.AnimationObjectGroup() );
+					animGroups.push( group );
 
 				}
 

+ 1 - 1
examples/webgl_simple_gi.html

@@ -148,7 +148,7 @@
 						clone = scene.clone();
 						clone.autoUpdate = false;
 
-						bounces ++
+						bounces ++;
 						currentVertex = 0;
 
 					}

+ 80 - 32
examples/webgl_skinning_simple.html

@@ -7,79 +7,127 @@
 		<style>
 			body {
 				font-family: Monospace;
-				background-color: #f0f0f0;
+				background-color: #000;
+				color: #fff;
 				margin: 0px;
 				overflow: hidden;
 			}
+			#info {
+				color: #fff;
+				position: absolute;
+				top: 10px;
+				width: 100%;
+				text-align: center;
+				z-index: 100;
+				display:block;
+			}
+			#info a {
+				color: #046;
+				font-weight: bold;
+			}
 		</style>
 	</head>
 	<body>
 
+		<div id="info">
+		<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - simple skinning -
+		<a href="https://github.com/mrdoob/three.js/blob/master/examples/models/skinned/simple/simple.blend" target="_blank" rel="noopener">Blender File</a>
+		</div>
+
 		<script src="../build/three.js"></script>
 		<script src="js/libs/stats.min.js"></script>
 		<script src="js/controls/OrbitControls.js"></script>
+		<script src="js/loaders/GLTFLoader.js"></script>
 
 		<script>
 
-			var container, stats, controls;
-			var camera, scene, renderer, loader, clock, light;
-			var skinnedMesh, animation, mixer;
+			var stats, mixer, camera, scene, renderer, clock;
 
 			init();
 			animate();
 
 			function init() {
 
-				container = document.createElement( 'div' );
+				var container = document.createElement( 'div' );
 				document.body.appendChild( container );
 
-				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
-				camera.position.set( 10, 0, 10 );
+				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
+				camera.position.set( 24, 8, 24 );
 
 				scene = new THREE.Scene();
-				loader = new THREE.JSONLoader();
-				clock = new THREE.Clock;
+				scene.background = new THREE.Color( 0xa0a0a0 );
+				scene.fog = new THREE.Fog( 0xa0a0a0, 70, 100 );
 
-				renderer = new THREE.WebGLRenderer();
-				renderer.setPixelRatio( window.devicePixelRatio );
-				renderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( renderer.domElement );
+				clock = new THREE.Clock();
 
-				controls = new THREE.OrbitControls( camera, renderer.domElement );
+				// ground
 
-				stats = new Stats();
-				container.appendChild( stats.dom );
-
-				var geometry = new THREE.PlaneBufferGeometry( 16000, 16000 );
-				var material = new THREE.MeshBasicMaterial( { emissive: 0xbbbbbb } );
+				var geometry = new THREE.PlaneBufferGeometry( 500, 500 );
+				var material = new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } );
 
 				var ground = new THREE.Mesh( geometry, material );
-				ground.position.set( 0, -5, 0 );
-				ground.rotation.x = -Math.PI / 2;
+				ground.position.set( 0, - 5, 0 );
+				ground.rotation.x = - Math.PI / 2;
+				ground.receiveShadow = true;
 				scene.add( ground );
 
-				light = new THREE.HemisphereLight( 0xffffff, 0x003300, 1 );
-				light.position.set( - 80, 500, 50 );
+				var grid = new THREE.GridHelper( 500, 100, 0x000000, 0x000000 );
+				grid.position.y = - 5;
+				grid.material.opacity = 0.2;
+				grid.material.transparent = true;
+				scene.add( grid );
+
+				// lights
+
+				var light = new THREE.HemisphereLight( 0xffffff, 0x444444, 0.6 );
+				light.position.set( 0, 200, 0 );
 				scene.add( light );
 
-				loader.load( './models/skinned/simple/simple.js', function ( geometry, materials ) {
+				light = new THREE.DirectionalLight( 0xffffff, 0.8 );
+				light.position.set( 0, 20, 10 );
+				light.castShadow = true;
+				light.shadow.camera.top = 18;
+				light.shadow.camera.bottom = - 10;
+				light.shadow.camera.left = - 12;
+				light.shadow.camera.right = 12;
+				scene.add( light );
 
-					for ( var k in materials ) {
+				//
 
-						materials[ k ].skinning = true;
+				var loader = new THREE.GLTFLoader();
+				loader.load( './models/gltf/SimpleSkinning.gltf', function ( gltf ) {
 
-					}
+					scene.add( gltf.scene );
 
-					skinnedMesh = new THREE.SkinnedMesh( geometry, materials );
-					skinnedMesh.scale.set( 1, 1, 1 );
+					gltf.scene.traverse( function ( child ) {
 
-					scene.add( skinnedMesh );
+						if ( child.isSkinnedMesh ) child.castShadow = true;
 
-					mixer = new THREE.AnimationMixer( skinnedMesh );
-					mixer.clipAction( skinnedMesh.geometry.animations[ 0 ] ).play();
+					} );
+
+					mixer = new THREE.AnimationMixer( gltf.scene );
+					mixer.clipAction( gltf.animations[ 0 ] ).play();
 
 				} );
 
+				//
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setPixelRatio( window.devicePixelRatio );
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.shadowMap.enabled = true;
+				container.appendChild( renderer.domElement );
+
+				//
+
+				stats = new Stats();
+				container.appendChild( stats.dom );
+
+				var controls = new THREE.OrbitControls( camera, renderer.domElement );
+				controls.enablePan = false;
+				controls.minDistance = 5;
+				controls.maxDistance = 50;
+
 			}
 
 			function animate() {

+ 1 - 1
examples/webgl_sprites.html

@@ -54,7 +54,7 @@
 
 				var textureLoader = new THREE.TextureLoader();
 
-				var mapA = textureLoader.load( "textures/sprite0.png", createHUDSprites );
+				textureLoader.load( "textures/sprite0.png", createHUDSprites );
 				var mapB = textureLoader.load( "textures/sprite1.png" );
 				mapC = textureLoader.load( "textures/sprite2.png" );
 

+ 0 - 2
examples/webgl_terrain_dynamic.html

@@ -466,8 +466,6 @@
 
 				if ( terrain.visible ) {
 
-					var time = Date.now() * 0.001;
-
 					var fLow = 0.1, fHigh = 0.8;
 
 					lightVal = THREE.Math.clamp( lightVal + 0.5 * delta * lightDir, fLow, fHigh );

+ 4 - 2
examples/webgl_tonemapping.html

@@ -171,6 +171,10 @@
 					standardMaterial.envMap = pmremCubeUVPacker.CubeUVRenderTarget.texture;
 					standardMaterial.needsUpdate = true;
 
+					hdrCubeMap.dispose();
+					pmremGenerator.dispose();
+					pmremCubeUVPacker.dispose();
+
 				} );
 
 				// Lights
@@ -265,8 +269,6 @@
 				renderer.toneMappingExposure = params.exposure;
 				renderer.toneMappingWhitePoint = params.whitePoint;
 
-				var timer = Date.now() * 0.00025;
-
 				camera.lookAt( scene.position );
 
 				for ( var i = 0, l = group.children.length; i < l; i ++ ) {

+ 4 - 0
src/materials/Material.js

@@ -244,6 +244,10 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		// rotation (SpriteMaterial)
 		if ( this.rotation !== 0 ) data.rotation = this.rotation;
 
+		if ( this.polygonOffset === true ) data.polygonOffset = true;
+		if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
+		if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
+
 		if ( this.linewidth !== 1 ) data.linewidth = this.linewidth;
 		if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
 		if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;

+ 21 - 16
src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl

@@ -5,22 +5,25 @@ vec4 LinearToLinear( in vec4 value ) {
 }
 
 vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {
-	return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );
+	return vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );
 }
+
 vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {
-	return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );
+	return vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );
 }
 
 vec4 sRGBToLinear( in vec4 value ) {
-	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );
+	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
 }
+
 vec4 LinearTosRGB( in vec4 value ) {
-	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );
+	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
 }
 
 vec4 RGBEToLinear( in vec4 value ) {
 	return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );
 }
+
 vec4 LinearToRGBE( in vec4 value ) {
 	float maxComponent = max( max( value.r, value.g ), value.b );
 	float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );
@@ -30,12 +33,13 @@ vec4 LinearToRGBE( in vec4 value ) {
 
 // reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html
 vec4 RGBMToLinear( in vec4 value, in float maxRange ) {
-	return vec4( value.xyz * value.w * maxRange, 1.0 );
+	return vec4( value.rgb * value.a * maxRange, 1.0 );
 }
+
 vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
-	float maxRGB = max( value.x, max( value.g, value.b ) );
-	float M      = clamp( maxRGB / maxRange, 0.0, 1.0 );
-	M            = ceil( M * 255.0 ) / 255.0;
+	float maxRGB = max( value.r, max( value.g, value.b ) );
+	float M = clamp( maxRGB / maxRange, 0.0, 1.0 );
+	M = ceil( M * 255.0 ) / 255.0;
 	return vec4( value.rgb / ( M * maxRange ), M );
 }
 
@@ -43,10 +47,11 @@ vec4 LinearToRGBM( in vec4 value, in float maxRange ) {
 vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
 	return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );
 }
+
 vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
-	float maxRGB = max( value.x, max( value.g, value.b ) );
-	float D      = max( maxRange / maxRGB, 1.0 );
-	D            = min( floor( D ) / 255.0, 1.0 );
+	float maxRGB = max( value.r, max( value.g, value.b ) );
+	float D = max( maxRange / maxRGB, 1.0 );
+	D = min( floor( D ) / 255.0, 1.0 );
 	return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
 }
 
@@ -56,12 +61,12 @@ vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
 const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
 vec4 LinearToLogLuv( in vec4 value )  {
 	vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;
-	Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));
+	Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );
 	vec4 vResult;
 	vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;
 	float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;
-	vResult.w = fract(Le);
-	vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;
+	vResult.w = fract( Le );
+	vResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;
 	return vResult;
 }
 
@@ -70,9 +75,9 @@ const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5
 vec4 LogLuvToLinear( in vec4 value ) {
 	float Le = value.z * 255.0 + value.w;
 	vec3 Xp_Y_XYZp;
-	Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);
+	Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );
 	Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;
 	Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;
 	vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;
-	return vec4( max(vRGB, 0.0), 1.0 );
+	return vec4( max( vRGB, 0.0 ), 1.0 );
 }

部分文件因文件數量過多而無法顯示