Explorar o código

Merge remote-tracking branch 'upstream/dev' into dev34

Mugen87 %!s(int64=5) %!d(string=hai) anos
pai
achega
83d6dff4b1
Modificáronse 73 ficheiros con 322 adicións e 605 borrados
  1. 1 1
      .github/ISSUE_TEMPLATE.md
  2. 26 22
      build/three.js
  3. 156 157
      build/three.min.js
  4. 26 22
      build/three.module.js
  5. 0 3
      docs/api/en/materials/LineBasicMaterial.html
  6. 0 3
      docs/api/en/materials/LineDashedMaterial.html
  7. 0 3
      docs/api/en/materials/Material.html
  8. 0 3
      docs/api/en/materials/MeshBasicMaterial.html
  9. 0 3
      docs/api/en/materials/MeshDepthMaterial.html
  10. 0 3
      docs/api/en/materials/MeshDistanceMaterial.html
  11. 0 3
      docs/api/en/materials/MeshNormalMaterial.html
  12. 1 1
      docs/api/en/materials/RawShaderMaterial.html
  13. 0 3
      docs/api/en/materials/ShaderMaterial.html
  14. 0 3
      docs/api/en/materials/ShadowMaterial.html
  15. 0 3
      docs/api/en/materials/SpriteMaterial.html
  16. 0 3
      docs/api/zh/materials/LineBasicMaterial.html
  17. 0 3
      docs/api/zh/materials/LineDashedMaterial.html
  18. 0 3
      docs/api/zh/materials/Material.html
  19. 0 3
      docs/api/zh/materials/MeshBasicMaterial.html
  20. 0 3
      docs/api/zh/materials/MeshDepthMaterial.html
  21. 0 3
      docs/api/zh/materials/MeshDistanceMaterial.html
  22. 0 3
      docs/api/zh/materials/MeshNormalMaterial.html
  23. 0 3
      docs/api/zh/materials/ShadowMaterial.html
  24. 0 3
      docs/api/zh/materials/SpriteMaterial.html
  25. 0 5
      docs/manual/en/introduction/How-to-dispose-of-objects.html
  26. 1 1
      editor/sw.js
  27. 1 1
      examples/files.js
  28. 2 2
      examples/js/loaders/BasisTextureLoader.js
  29. 0 2
      examples/js/loaders/GLTFLoader.js
  30. 0 1
      examples/js/loaders/MMDLoader.js
  31. 0 2
      examples/js/loaders/OBJLoader.js
  32. 2 2
      examples/jsm/loaders/BasisTextureLoader.js
  33. 3 0
      examples/jsm/loaders/EquirectangularToCubeGenerator.d.ts
  34. 0 2
      examples/jsm/loaders/GLTFLoader.js
  35. 0 1
      examples/jsm/loaders/MMDLoader.js
  36. 0 2
      examples/jsm/loaders/OBJLoader.js
  37. 15 9
      examples/jsm/nodes/misc/NormalMapNode.js
  38. 2 2
      examples/webgl2_materials_texture2darray.html
  39. 1 1
      examples/webgl2_materials_texture3d.html
  40. 4 2
      examples/webgl2_multisampled_renderbuffers.html
  41. 1 1
      examples/webgl2_sandbox.html
  42. 6 1
      examples/webgl_instancing_suzanne.html
  43. 0 2
      examples/webgl_loader_vrm.html
  44. 12 0
      examples/webgl_materials_nodes.html
  45. 1 1
      package.json
  46. 1 1
      src/constants.js
  47. 1 2
      src/extras/ShapeUtils.d.ts
  48. 0 1
      src/geometries/ExtrudeGeometry.d.ts
  49. 0 2
      src/materials/LineBasicMaterial.js
  50. 0 6
      src/materials/Material.d.ts
  51. 0 2
      src/materials/Material.js
  52. 0 2
      src/materials/MeshBasicMaterial.js
  53. 0 1
      src/materials/MeshDepthMaterial.js
  54. 0 1
      src/materials/MeshDistanceMaterial.js
  55. 0 2
      src/materials/MeshMatcapMaterial.js
  56. 0 1
      src/materials/MeshNormalMaterial.js
  57. 0 2
      src/materials/PointsMaterial.js
  58. 0 1
      src/materials/ShaderMaterial.d.ts
  59. 0 1
      src/materials/SpriteMaterial.js
  60. 1 3
      src/math/Vector3.js
  61. 2 0
      src/objects/InstancedMesh.js
  62. 0 191
      src/renderers/WebGL2Renderer.js
  63. 1 1
      src/renderers/WebGLRenderer.d.ts
  64. 13 4
      src/renderers/WebGLRenderer.js
  65. 3 1
      src/renderers/webgl/WebGLBufferRenderer.js
  66. 3 1
      src/renderers/webgl/WebGLIndexedBufferRenderer.js
  67. 0 1
      src/renderers/webgl/WebGLProgram.d.ts
  68. 4 2
      src/renderers/webgl/WebGLState.js
  69. 23 17
      src/renderers/webgl/WebGLTextures.js
  70. 5 3
      src/renderers/webgl/WebGLUtils.js
  71. 4 3
      src/renderers/webvr/WebXRManager.js
  72. 0 1
      test/three.source.unit.js
  73. 0 52
      test/unit/src/renderers/WebGL2Renderer.tests.js

+ 1 - 1
.github/ISSUE_TEMPLATE.md

@@ -17,7 +17,7 @@ Please also include a live example if possible. You can start from these templat
 ##### Three.js version
 
 - [ ] Dev
-- [ ] r108
+- [ ] r109
 - [ ] ...
 
 ##### Browser

+ 26 - 22
build/three.js

@@ -97,7 +97,7 @@
 
 	}
 
-	var REVISION = '109dev';
+	var REVISION = '109';
 	var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
 	var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
 	var CullFaceNone = 0;
@@ -2173,9 +2173,11 @@
 
 		angleTo: function ( v ) {
 
-			// assumes this and v are not the zero vector
+			var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
 
-			var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
+			if ( denominator === 0 ) { console.error( 'THREE.Vector3: angleTo() can\'t handle zero length vectors.' ); }
+
+			var theta = this.dot( v ) / denominator;
 
 			// clamp, to handle numerical problems
 
@@ -8312,7 +8314,6 @@
 		this.type = 'Material';
 
 		this.fog = true;
-		this.lights = true;
 
 		this.blending = NormalBlending;
 		this.side = FrontSide;
@@ -8636,7 +8637,6 @@
 			this.name = source.name;
 
 			this.fog = source.fog;
-			this.lights = source.lights;
 
 			this.blending = source.blending;
 			this.side = source.side;
@@ -8785,8 +8785,6 @@
 		this.skinning = false;
 		this.morphTargets = false;
 
-		this.lights = false;
-
 		this.setValues( parameters );
 
 	}
@@ -19319,7 +19317,6 @@
 		this.wireframeLinewidth = 1;
 
 		this.fog = false;
-		this.lights = false;
 
 		this.setValues( parameters );
 
@@ -19399,7 +19396,6 @@
 		this.displacementBias = 0;
 
 		this.fog = false;
-		this.lights = false;
 
 		this.setValues( parameters );
 
@@ -23059,6 +23055,8 @@
 
 		var session = null;
 
+		// var framebufferScaleFactor = 1.0;
+
 		var referenceSpace = null;
 		var referenceSpaceType = 'local-floor';
 
@@ -23146,7 +23144,9 @@
 
 		}
 
-		this.setFramebufferScaleFactor = function ( value ) {
+		this.setFramebufferScaleFactor = function ( /* value */ ) {
+
+			// framebufferScaleFactor = value;
 
 		};
 
@@ -23173,6 +23173,7 @@
 				session.addEventListener( 'selectend', onSessionEvent );
 				session.addEventListener( 'end', onSessionEnd );
 
+				// eslint-disable-next-line no-undef
 				session.updateRenderState( { baseLayer: new XRWebGLLayer( session, gl ) } );
 
 				session.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );
@@ -24187,7 +24188,7 @@
 
 			if ( object.isInstancedMesh ) {
 
-				renderer.renderInstances( geometry, drawStart, drawCount, object.instanceMatrix.count );
+				renderer.renderInstances( geometry, drawStart, drawCount, object.count );
 
 			} else if ( geometry.isInstancedBufferGeometry ) {
 
@@ -24938,9 +24939,10 @@
 
 			// store the light setup it was created for
 
+			materialProperties.needsLights = materialNeedsLights( material );
 			materialProperties.lightsStateVersion = lightsStateVersion;
 
-			if ( material.lights ) {
+			if ( materialProperties.needsLights ) {
 
 				// wire up the material to this renderer's lighting state
 
@@ -25006,7 +25008,7 @@
 
 					material.needsUpdate = true;
 
-				} else if ( material.lights && materialProperties.lightsStateVersion !== lights.state.version ) {
+				} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
 
 					material.needsUpdate = true;
 
@@ -25190,7 +25192,7 @@
 				p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
 				p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
 
-				if ( material.lights ) {
+				if ( materialProperties.needsLights ) {
 
 					// the current material requires lighting info
 
@@ -25797,6 +25799,14 @@
 
 		}
 
+		function materialNeedsLights( material ) {
+
+			return material.isMeshLambertMaterial || material.isMeshPhongMaterial ||
+				material.isMeshStandardMaterial || material.isShadowMaterial ||
+				( material.isShaderMaterial && material.lights === true );
+
+		}
+
 		//
 		this.setFramebuffer = function ( value ) {
 
@@ -26340,7 +26350,6 @@
 
 		this.sizeAttenuation = true;
 
-		this.lights = false;
 		this.transparent = true;
 
 		this.setValues( parameters );
@@ -27032,6 +27041,8 @@
 
 		this.instanceMatrix = new BufferAttribute( new Float32Array( count * 16 ), 16 );
 
+		this.count = count;
+
 	}
 
 	InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
@@ -27078,8 +27089,6 @@
 		this.linecap = 'round';
 		this.linejoin = 'round';
 
-		this.lights = false;
-
 		this.setValues( parameters );
 
 	}
@@ -27465,8 +27474,6 @@
 
 		this.morphTargets = false;
 
-		this.lights = false;
-
 		this.setValues( parameters );
 
 	}
@@ -32872,7 +32879,6 @@
 		this.wireframeLinewidth = 1;
 
 		this.fog = false;
-		this.lights = false;
 
 		this.skinning = false;
 		this.morphTargets = false;
@@ -33099,8 +33105,6 @@
 		this.morphTargets = false;
 		this.morphNormals = false;
 
-		this.lights = false;
-
 		this.setValues( parameters );
 
 	}

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 156 - 157
build/three.min.js


+ 26 - 22
build/three.module.js

@@ -91,7 +91,7 @@ if ( Object.assign === undefined ) {
 
 }
 
-var REVISION = '109dev';
+var REVISION = '109';
 var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
 var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
 var CullFaceNone = 0;
@@ -2167,9 +2167,11 @@ Object.assign( Vector3.prototype, {
 
 	angleTo: function ( v ) {
 
-		// assumes this and v are not the zero vector
+		var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
 
-		var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
+		if ( denominator === 0 ) console.error( 'THREE.Vector3: angleTo() can\'t handle zero length vectors.' );
+
+		var theta = this.dot( v ) / denominator;
 
 		// clamp, to handle numerical problems
 
@@ -8306,7 +8308,6 @@ function Material() {
 	this.type = 'Material';
 
 	this.fog = true;
-	this.lights = true;
 
 	this.blending = NormalBlending;
 	this.side = FrontSide;
@@ -8630,7 +8631,6 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		this.name = source.name;
 
 		this.fog = source.fog;
-		this.lights = source.lights;
 
 		this.blending = source.blending;
 		this.side = source.side;
@@ -8779,8 +8779,6 @@ function MeshBasicMaterial( parameters ) {
 	this.skinning = false;
 	this.morphTargets = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }
@@ -19306,7 +19304,6 @@ function MeshDepthMaterial( parameters ) {
 	this.wireframeLinewidth = 1;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.setValues( parameters );
 
@@ -19386,7 +19383,6 @@ function MeshDistanceMaterial( parameters ) {
 	this.displacementBias = 0;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.setValues( parameters );
 
@@ -23046,6 +23042,8 @@ function WebXRManager( renderer, gl ) {
 
 	var session = null;
 
+	// var framebufferScaleFactor = 1.0;
+
 	var referenceSpace = null;
 	var referenceSpaceType = 'local-floor';
 
@@ -23133,7 +23131,9 @@ function WebXRManager( renderer, gl ) {
 
 	}
 
-	this.setFramebufferScaleFactor = function ( value ) {
+	this.setFramebufferScaleFactor = function ( /* value */ ) {
+
+		// framebufferScaleFactor = value;
 
 	};
 
@@ -23160,6 +23160,7 @@ function WebXRManager( renderer, gl ) {
 			session.addEventListener( 'selectend', onSessionEvent );
 			session.addEventListener( 'end', onSessionEnd );
 
+			// eslint-disable-next-line no-undef
 			session.updateRenderState( { baseLayer: new XRWebGLLayer( session, gl ) } );
 
 			session.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );
@@ -24174,7 +24175,7 @@ function WebGLRenderer( parameters ) {
 
 		if ( object.isInstancedMesh ) {
 
-			renderer.renderInstances( geometry, drawStart, drawCount, object.instanceMatrix.count );
+			renderer.renderInstances( geometry, drawStart, drawCount, object.count );
 
 		} else if ( geometry.isInstancedBufferGeometry ) {
 
@@ -24925,9 +24926,10 @@ function WebGLRenderer( parameters ) {
 
 		// store the light setup it was created for
 
+		materialProperties.needsLights = materialNeedsLights( material );
 		materialProperties.lightsStateVersion = lightsStateVersion;
 
-		if ( material.lights ) {
+		if ( materialProperties.needsLights ) {
 
 			// wire up the material to this renderer's lighting state
 
@@ -24993,7 +24995,7 @@ function WebGLRenderer( parameters ) {
 
 				material.needsUpdate = true;
 
-			} else if ( material.lights && materialProperties.lightsStateVersion !== lights.state.version ) {
+			} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
 
 				material.needsUpdate = true;
 
@@ -25177,7 +25179,7 @@ function WebGLRenderer( parameters ) {
 			p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
 			p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
 
-			if ( material.lights ) {
+			if ( materialProperties.needsLights ) {
 
 				// the current material requires lighting info
 
@@ -25784,6 +25786,14 @@ function WebGLRenderer( parameters ) {
 
 	}
 
+	function materialNeedsLights( material ) {
+
+		return material.isMeshLambertMaterial || material.isMeshPhongMaterial ||
+			material.isMeshStandardMaterial || material.isShadowMaterial ||
+			( material.isShaderMaterial && material.lights === true );
+
+	}
+
 	//
 	this.setFramebuffer = function ( value ) {
 
@@ -26327,7 +26337,6 @@ function SpriteMaterial( parameters ) {
 
 	this.sizeAttenuation = true;
 
-	this.lights = false;
 	this.transparent = true;
 
 	this.setValues( parameters );
@@ -27019,6 +27028,8 @@ function InstancedMesh( geometry, material, count ) {
 
 	this.instanceMatrix = new BufferAttribute( new Float32Array( count * 16 ), 16 );
 
+	this.count = count;
+
 }
 
 InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
@@ -27065,8 +27076,6 @@ function LineBasicMaterial( parameters ) {
 	this.linecap = 'round';
 	this.linejoin = 'round';
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }
@@ -27452,8 +27461,6 @@ function PointsMaterial( parameters ) {
 
 	this.morphTargets = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }
@@ -32859,7 +32866,6 @@ function MeshNormalMaterial( parameters ) {
 	this.wireframeLinewidth = 1;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.skinning = false;
 	this.morphTargets = false;
@@ -33086,8 +33092,6 @@ function MeshMatcapMaterial( parameters ) {
 	this.morphTargets = false;
 	this.morphNormals = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }

+ 0 - 3
docs/api/en/materials/LineBasicMaterial.html

@@ -67,9 +67,6 @@ var material = new THREE.LineBasicMaterial( {
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Float linewidth]</h3>
 		<p>
 			Controls line thickness. Default is *1*.<br /><br />

+ 0 - 3
docs/api/en/materials/LineDashedMaterial.html

@@ -62,9 +62,6 @@ var material = new THREE.LineDashedMaterial( {
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Float linewidth]</h3>
 		<p>
 			Controls line thickness. Default is *1*.<br /><br />

+ 0 - 3
docs/api/en/materials/Material.html

@@ -181,9 +181,6 @@
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *true*.</p>
-
 		<h3>[property:String name]</h3>
 		<p>Optional name of the object (doesn't need to be unique). Default is an empty string.</p>
 

+ 0 - 3
docs/api/en/materials/MeshBasicMaterial.html

@@ -100,9 +100,6 @@
 		<h3>[property:Float lightMapIntensity]</h3>
 		<p>Intensity of the baked light. Default is 1.</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>The color map. Default is  null.</p>
 

+ 0 - 3
docs/api/en/materials/MeshDepthMaterial.html

@@ -89,9 +89,6 @@
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>The color map. Default is  null.</p>
 

+ 0 - 3
docs/api/en/materials/MeshDistanceMaterial.html

@@ -98,9 +98,6 @@
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>The color map. Default is  null.</p>
 

+ 0 - 3
docs/api/en/materials/MeshNormalMaterial.html

@@ -86,9 +86,6 @@
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:boolean morphNormals]</h3>
 		<p>
 			Defines whether the material uses morphNormals. Set as true to pass morphNormal

+ 1 - 1
docs/api/en/materials/RawShaderMaterial.html

@@ -50,7 +50,7 @@ var material = new THREE.RawShaderMaterial( {
 
 
 		<h2>Properties</h2>
-		<p>See the base [page:Material] and [page:ShaderMaterial] classes for common methods.</p>
+		<p>See the base [page:Material] and [page:ShaderMaterial] classes for common properties.</p>
 
 		<h3>[property:Boolean isRawShaderMaterial]</h3>
 		<p>

+ 0 - 3
docs/api/en/materials/ShaderMaterial.html

@@ -359,9 +359,6 @@ this.extensions = {
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-
-
-
 		<h3>[property:Boolean lights]</h3>
 		<p>
 		Defines whether this material uses lighting; true to pass uniform data related to lighting to this shader. Default is false.

+ 0 - 3
docs/api/en/materials/ShadowMaterial.html

@@ -51,9 +51,6 @@ scene.add( plane );
 			You should not change this, as it used internally for optimisation.
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *true*.</p>
-
 		<h3>[property:Boolean transparent]</h3>
 		<p>Defines whether this material is transparent. Default is *true*.</p>
 

+ 0 - 3
docs/api/en/materials/SpriteMaterial.html

@@ -56,9 +56,6 @@ scene.add( sprite );
 		<h3>[property:boolean fog]</h3>
 		<p>Whether or not this material affected by the scene's fog. Default is false</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>Whether the material is affected by lights. Default is *false*.</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>The texture map. Default is null.</p>
 

+ 0 - 3
docs/api/zh/materials/LineBasicMaterial.html

@@ -63,9 +63,6 @@ var material = new THREE.LineBasicMaterial( {
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Float linewidth]</h3>
 		<p> 控制线宽。默认值为 *1*。<br /><br />
 			由于[link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile]与

+ 0 - 3
docs/api/zh/materials/LineDashedMaterial.html

@@ -58,9 +58,6 @@ var material = new THREE.LineDashedMaterial( {
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Float linewidth]</h3>
 		<p>
 			控制线宽。默认值为 *1*。<br /><br />

+ 0 - 3
docs/api/zh/materials/Material.html

@@ -159,9 +159,6 @@ Which stencil operation to perform when the comparison function returns true and
     因为其通常用在内部优化,所以不应该更改该属性值。
 </p>
 
-<h3>[property:Boolean lights]</h3>
-<p>材质是否受到光照的影响。默认为*true*。</p>
-
 <h3>[property:String name]</h3>
 <p>对象的可选名称(不必是唯一的)。默认值为空字符串。</p>
 

+ 0 - 3
docs/api/zh/materials/MeshBasicMaterial.html

@@ -82,9 +82,6 @@
 		<h3>[property:Float lightMapIntensity]</h3>
 		<p>烘焙光的强度。默认值为1。</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Texture map]</h3>
 		<p> 颜色贴图。默认为null。</p>
 

+ 0 - 3
docs/api/zh/materials/MeshDepthMaterial.html

@@ -73,9 +73,6 @@
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>颜色贴图。默认为null。</p>
 

+ 0 - 3
docs/api/zh/materials/MeshDistanceMaterial.html

@@ -82,9 +82,6 @@
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>颜色贴图。默认为null。</p>
 

+ 0 - 3
docs/api/zh/materials/MeshNormalMaterial.html

@@ -72,9 +72,6 @@
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:boolean morphNormals]</h3>
 		<p> 定义是否使用morphNormals。设置为true可将morphNormal属性从[page:Geometry]传递到shader。默认值为*false*。
 		</p>

+ 0 - 3
docs/api/zh/materials/ShadowMaterial.html

@@ -48,9 +48,6 @@ scene.add( plane );
 			因为其通常用在内部优化,所以不应该更改该属性值。
 		</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p> 材质是否受到光照的影响。默认值为 *true*。</p>
-
 		<h3>[property:Boolean transparent]</h3>
 		<p>定义此材质是否透明。默认值为 *true*。</p>
 

+ 0 - 3
docs/api/zh/materials/SpriteMaterial.html

@@ -55,9 +55,6 @@ scene.add( sprite );
 		<h3>[property:boolean fog]</h3>
 		<p>材质是否受场景雾的影响。默认值为*false*。</p>
 
-		<h3>[property:Boolean lights]</h3>
-		<p>材质是否受到光照的影响。默认值为 *false*。</p>
-
 		<h3>[property:Texture map]</h3>
 		<p>颜色贴图。默认为null。</p>
 

+ 0 - 5
docs/manual/en/introduction/How-to-dispose-of-objects.html

@@ -92,11 +92,6 @@
 		in your application, it's a good idea to debug this property in order to easily identify a memory leak.
 	</p>
 
-	<p>
-		Internal resources for a texture are only allocated if the image has fully loaded. If you dispose a texture before the image was loaded,
-		nothing happens. No resources were allocated so there is also no need for clean up.
-	</p>
-
 	<h3>What happens when you call *dispose()* on a texture but the image is not loaded yet?</h3>
 
 	<p>

+ 1 - 1
editor/sw.js

@@ -1,4 +1,4 @@
-// r108
+// r109
 
 const assets = [
 	'./',

+ 1 - 1
examples/files.js

@@ -47,7 +47,7 @@ var files = {
 		"webgl_geometry_text_shapes",
 		"webgl_geometry_text_stroke",
 		"webgl_helpers",
-		"webgl_instancing",
+		"webgl_instancing_suzanne",
 		"webgl_interactive_buffergeometry",
 		"webgl_interactive_cubes",
 		"webgl_interactive_cubes_gpu",

+ 2 - 2
examples/js/loaders/BasisTextureLoader.js

@@ -476,8 +476,8 @@ THREE.BasisTextureLoader.BasisWorker = function () {
 				0,
 				mip,
 				config.format,
-				hasAlpha,
-				0
+				0,
+				hasAlpha
 			);
 
 			if ( ! status ) {

+ 0 - 2
examples/js/loaders/GLTFLoader.js

@@ -2116,7 +2116,6 @@ THREE.GLTFLoader = ( function () {
 				THREE.Material.prototype.copy.call( pointsMaterial, material );
 				pointsMaterial.color.copy( material.color );
 				pointsMaterial.map = material.map;
-				pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet
 				pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
 
 				this.cache.add( cacheKey, pointsMaterial );
@@ -2136,7 +2135,6 @@ THREE.GLTFLoader = ( function () {
 				lineMaterial = new THREE.LineBasicMaterial();
 				THREE.Material.prototype.copy.call( lineMaterial, material );
 				lineMaterial.color.copy( material.color );
-				lineMaterial.lights = false; // LineBasicMaterial doesn't support lights yet
 
 				this.cache.add( cacheKey, lineMaterial );
 

+ 0 - 1
examples/js/loaders/MMDLoader.js

@@ -1032,7 +1032,6 @@ THREE.MMDLoader = ( function () {
 
 				params.skinning = geometry.bones.length > 0 ? true : false;
 				params.morphTargets = geometry.morphTargets.length > 0 ? true : false;
-				params.lights = true;
 				params.fog = true;
 
 				// blend

+ 0 - 2
examples/js/loaders/OBJLoader.js

@@ -682,7 +682,6 @@ THREE.OBJLoader = ( function () {
 							var materialLine = new THREE.LineBasicMaterial();
 							THREE.Material.prototype.copy.call( materialLine, material );
 							materialLine.color.copy( material.color );
-							materialLine.lights = false;
 							material = materialLine;
 
 						} else if ( isPoints && material && ! ( material instanceof THREE.PointsMaterial ) ) {
@@ -691,7 +690,6 @@ THREE.OBJLoader = ( function () {
 							THREE.Material.prototype.copy.call( materialPoints, material );
 							materialPoints.color.copy( material.color );
 							materialPoints.map = material.map;
-							materialPoints.lights = false;
 							material = materialPoints;
 
 						}

+ 2 - 2
examples/jsm/loaders/BasisTextureLoader.js

@@ -489,8 +489,8 @@ BasisTextureLoader.BasisWorker = function () {
 				0,
 				mip,
 				config.format,
-				hasAlpha,
-				0
+				0,
+				hasAlpha
 			);
 
 			if ( ! status ) {

+ 3 - 0
examples/jsm/loaders/EquirectangularToCubeGenerator.d.ts

@@ -14,6 +14,9 @@ export interface EquirectangularToCubeGeneratorOptions {
 export class EquirectangularToCubeGenerator {
 
 	constructor( sourceTexture: Texture, options?: EquirectangularToCubeGeneratorOptions );
+	sourceTexture: Texture;
+	resolution: number;
+	renderTarget: WebGLRenderTargetCube;
 
 	dispose(): void;
 	update( renderer: WebGLRenderer ): Texture;

+ 0 - 2
examples/jsm/loaders/GLTFLoader.js

@@ -2180,7 +2180,6 @@ var GLTFLoader = ( function () {
 				Material.prototype.copy.call( pointsMaterial, material );
 				pointsMaterial.color.copy( material.color );
 				pointsMaterial.map = material.map;
-				pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet
 				pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
 
 				this.cache.add( cacheKey, pointsMaterial );
@@ -2200,7 +2199,6 @@ var GLTFLoader = ( function () {
 				lineMaterial = new LineBasicMaterial();
 				Material.prototype.copy.call( lineMaterial, material );
 				lineMaterial.color.copy( material.color );
-				lineMaterial.lights = false; // LineBasicMaterial doesn't support lights yet
 
 				this.cache.add( cacheKey, lineMaterial );
 

+ 0 - 1
examples/jsm/loaders/MMDLoader.js

@@ -1068,7 +1068,6 @@ var MMDLoader = ( function () {
 
 				params.skinning = geometry.bones.length > 0 ? true : false;
 				params.morphTargets = geometry.morphTargets.length > 0 ? true : false;
-				params.lights = true;
 				params.fog = true;
 
 				// blend

+ 0 - 2
examples/jsm/loaders/OBJLoader.js

@@ -699,7 +699,6 @@ var OBJLoader = ( function () {
 							var materialLine = new LineBasicMaterial();
 							Material.prototype.copy.call( materialLine, material );
 							materialLine.color.copy( material.color );
-							materialLine.lights = false;
 							material = materialLine;
 
 						} else if ( isPoints && material && ! ( material instanceof PointsMaterial ) ) {
@@ -708,7 +707,6 @@ var OBJLoader = ( function () {
 							Material.prototype.copy.call( materialPoints, material );
 							materialPoints.color.copy( material.color );
 							materialPoints.map = material.map;
-							materialPoints.lights = false;
 							material = materialPoints;
 
 						}

+ 15 - 9
examples/jsm/nodes/misc/NormalMapNode.js

@@ -2,6 +2,10 @@
  * @author sunag / http://www.sunag.com.br/
  */
 
+import {
+	BackSide 
+} from '../../../../build/three.module.js';
+
 import { TempNode } from '../core/TempNode.js';
 import { Vector2Node } from '../inputs/Vector2Node.js';
 import { FunctionNode } from '../core/FunctionNode.js';
@@ -25,7 +29,7 @@ NormalMapNode.Nodes = ( function () {
 		// Per-Pixel Tangent Space Normal Mapping
 		// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
 
-		`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
+`vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 map, vec2 vUv, vec2 normalScale ) {
 
 	// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
 
@@ -47,14 +51,8 @@ NormalMapNode.Nodes = ( function () {
 	#ifdef DOUBLE_SIDED
 
 		// Workaround for Adreno GPUs gl_FrontFacing bug. See #15850 and #10331
-		// http://hacksoflife.blogspot.com/2009/11/per-pixel-tangent-space-normal-mapping.html?showComment=1522254677437#c5087545147696715943
-		vec3 NfromST = cross( S, T );
-		if( dot( NfromST, N ) > 0.0 ) {
-
-			S *= -1.0;
-			T *= -1.0;
 
-		}
+		if ( dot( cross( S, T ), N ) < 0.0 ) mapN.xy *= - 1.0;
 
 	#else
 
@@ -87,11 +85,19 @@ NormalMapNode.prototype.generate = function ( builder, output ) {
 		this.position = this.position || new PositionNode( PositionNode.VIEW );
 		this.uv = this.uv || new UVNode();
 
+		var scale = this.scale.build( builder, 'v2' );
+
+		if ( builder.material.side === BackSide ) {
+
+			scale = '-' + scale;
+
+		}
+
 		return builder.format( perturbNormal2Arb + '( -' + this.position.build( builder, 'v3' ) + ', ' +
 			this.normal.build( builder, 'v3' ) + ', ' +
 			this.value.build( builder, 'v3' ) + ', ' +
 			this.uv.build( builder, 'v2' ) + ', ' +
-			this.scale.build( builder, 'v2' ) + ' )', this.getType( builder ), output );
+			scale + ' )', this.getType( builder ), output );
 
 	} else {
 

+ 2 - 2
examples/webgl2_materials_texture2darray.html

@@ -123,9 +123,9 @@
 				// 2D Texture array is available on WebGL 2.0
 
 				var canvas = document.createElement( 'canvas' );
-				var context = canvas.getContext( 'webgl2' );
+				var context = canvas.getContext( 'webgl2', { alpha: false, antialias: false } );
 
-				renderer = new THREE.WebGLRenderer( { antialias: true, canvas: canvas, context: context } );
+				renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );

+ 1 - 1
examples/webgl2_materials_texture3d.html

@@ -44,7 +44,7 @@
 
 			// Create renderer
 			var canvas = document.createElement( 'canvas' );
-			var context = canvas.getContext( 'webgl2' );
+			var context = canvas.getContext( 'webgl2', { alpha: false, antialias: false } );
 			renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );
 			renderer.setPixelRatio( window.devicePixelRatio );
 			renderer.setSize( window.innerWidth, window.innerHeight );

+ 4 - 2
examples/webgl2_multisampled_renderbuffers.html

@@ -28,7 +28,7 @@
 
 		<div id="info">
 			<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - Multisampled Renderbuffers<br />
-			Left scene is multi-sampled, right scene is rendered without anti-aliasing.
+			Left: WebGLMultisampleRenderTarget, Right: WebGLRenderTarget.
 		</div>
 		<div id="container">
 		</div>
@@ -102,7 +102,9 @@
 				//
 
 				var canvas = document.createElement( 'canvas' );
-				var context = canvas.getContext( 'webgl2', { antialias: false } );
+				canvas.style.imageRendering = 'pixelated'; // disable browser interpolation
+
+				var context = canvas.getContext( 'webgl2', { alpha: false, antialias: false } );
 
 				renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );
 				renderer.autoClear = false;

+ 1 - 1
examples/webgl2_sandbox.html

@@ -63,7 +63,7 @@
 				}
 
 				var canvas = document.createElement( 'canvas' );
-				var context = canvas.getContext( 'webgl2' );
+				var context = canvas.getContext( 'webgl2', { alpha: false, antialias: true } );
 
 				renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } );
 				renderer.setPixelRatio( window.devicePixelRatio );

+ 6 - 1
examples/webgl_instancing.html → examples/webgl_instancing_suzanne.html

@@ -13,6 +13,7 @@
 			import * as THREE from '../build/three.module.js';
 
 			import Stats from './jsm/libs/stats.module.js';
+			import { GUI } from './jsm/libs/dat.gui.module.js';
 
 			var camera, scene, renderer, stats;
 
@@ -36,7 +37,6 @@
 				// check overdraw
 				// var material = new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.1, transparent: true } );
 
-
 				var loader = new THREE.BufferGeometryLoader();
 				loader.load( 'models/json/suzanne_buffergeometry.json', function ( geometry ) {
 
@@ -46,6 +46,11 @@
 					mesh = new THREE.InstancedMesh( geometry, material, count );
 					scene.add( mesh );
 
+					//
+
+					var gui = new GUI();
+					gui.add( mesh, 'count', 0, count );
+
 				} );
 
 				//

+ 0 - 2
examples/webgl_loader_vrm.html

@@ -62,7 +62,6 @@
 									THREE.Material.prototype.copy.call( material, object.material[ i ] );
 									material.color.copy( object.material[ i ].color );
 									material.map = object.material[ i ].map;
-									material.lights = false;
 									material.skinning = object.material[ i ].skinning;
 									material.morphTargets = object.material[ i ].morphTargets;
 									material.morphNormals = object.material[ i ].morphNormals;
@@ -76,7 +75,6 @@
 								THREE.Material.prototype.copy.call( material, object.material );
 								material.color.copy( object.material.color );
 								material.map = object.material.map;
-								material.lights = false;
 								material.skinning = object.material.skinning;
 								material.morphTargets = object.material.morphTargets;
 								material.morphNormals = object.material.morphNormals;

+ 12 - 0
examples/webgl_materials_nodes.html

@@ -724,6 +724,18 @@
 
 						}, false );
 
+						addGui( 'side', {
+							DoubleSided: THREE.DoubleSide,
+							FrontSided: THREE.FrontSide,
+							BackSided: THREE.BackSide
+						}, function ( val ) {
+
+							defaultSide = Number( val );
+
+							updateMaterial();
+
+						} );
+
 						break;
 
 					case 'physical':

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "three",
-  "version": "0.108.0",
+  "version": "0.109.0",
   "description": "JavaScript 3D library",
   "main": "build/three.js",
   "module": "build/three.module.js",

+ 1 - 1
src/constants.js

@@ -1,4 +1,4 @@
-export var REVISION = '109dev';
+export var REVISION = '109';
 export var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
 export var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
 export var CullFaceNone = 0;

+ 1 - 2
src/extras/ShapeUtils.d.ts

@@ -5,7 +5,6 @@ interface Vec2 {
 
 export namespace ShapeUtils {
 	export function area( contour: Vec2[] ): number;
-	export function triangulate( contour: Vec2[], indices: boolean ): number[];
-	export function triangulateShape( contour: Vec2[], holes: Vec2[] ): number[][];
+	export function triangulateShape( contour: Vec2[], holes: Vec2[][] ): number[][];
 	export function isClockWise( pts: Vec2[] ): boolean;
 }

+ 0 - 1
src/geometries/ExtrudeGeometry.d.ts

@@ -1,5 +1,4 @@
 import { Curve } from './../extras/core/Curve';
-import { UVGenerator } from './ExtrudeGeometry';
 import { Vector2 } from './../math/Vector2';
 import { Vector3 } from './../math/Vector3';
 import { Shape } from './../extras/core/Shape';

+ 0 - 2
src/materials/LineBasicMaterial.js

@@ -27,8 +27,6 @@ function LineBasicMaterial( parameters ) {
 	this.linecap = 'round';
 	this.linejoin = 'round';
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }

+ 0 - 6
src/materials/Material.d.ts

@@ -34,7 +34,6 @@ export interface MaterialParameters {
 	depthTest?: boolean;
 	depthWrite?: boolean;
 	fog?: boolean;
-	lights?: boolean;
 	name?: string;
 	opacity?: number;
 	overdraw?: number;
@@ -195,11 +194,6 @@ export class Material extends EventDispatcher {
 	 */
 	isMaterial: boolean;
 
-	/**
-	 * Whether the material is affected by lights. Default is true.
-	 */
-	lights: boolean;
-
 	/**
 	 * Material name. Default is an empty string.
 	 */

+ 0 - 2
src/materials/Material.js

@@ -19,7 +19,6 @@ function Material() {
 	this.type = 'Material';
 
 	this.fog = true;
-	this.lights = true;
 
 	this.blending = NormalBlending;
 	this.side = FrontSide;
@@ -343,7 +342,6 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		this.name = source.name;
 
 		this.fog = source.fog;
-		this.lights = source.lights;
 
 		this.blending = source.blending;
 		this.side = source.side;

+ 0 - 2
src/materials/MeshBasicMaterial.js

@@ -70,8 +70,6 @@ function MeshBasicMaterial( parameters ) {
 	this.skinning = false;
 	this.morphTargets = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }

+ 0 - 1
src/materials/MeshDepthMaterial.js

@@ -47,7 +47,6 @@ function MeshDepthMaterial( parameters ) {
 	this.wireframeLinewidth = 1;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.setValues( parameters );
 

+ 0 - 1
src/materials/MeshDistanceMaterial.js

@@ -46,7 +46,6 @@ function MeshDistanceMaterial( parameters ) {
 	this.displacementBias = 0;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.setValues( parameters );
 

+ 0 - 2
src/materials/MeshMatcapMaterial.js

@@ -64,8 +64,6 @@ function MeshMatcapMaterial( parameters ) {
 	this.morphTargets = false;
 	this.morphNormals = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }

+ 0 - 1
src/materials/MeshNormalMaterial.js

@@ -50,7 +50,6 @@ function MeshNormalMaterial( parameters ) {
 	this.wireframeLinewidth = 1;
 
 	this.fog = false;
-	this.lights = false;
 
 	this.skinning = false;
 	this.morphTargets = false;

+ 0 - 2
src/materials/PointsMaterial.js

@@ -32,8 +32,6 @@ function PointsMaterial( parameters ) {
 
 	this.morphTargets = false;
 
-	this.lights = false;
-
 	this.setValues( parameters );
 
 }

+ 0 - 1
src/materials/ShaderMaterial.d.ts

@@ -1,4 +1,3 @@
-import { ShaderMaterialParameters } from './ShaderMaterial';
 import { IUniform } from '../renderers/shaders/UniformsLib';
 import { MaterialParameters, Material } from './Material';
 

+ 0 - 1
src/materials/SpriteMaterial.js

@@ -25,7 +25,6 @@ function SpriteMaterial( parameters ) {
 
 	this.sizeAttenuation = true;
 
-	this.lights = false;
 	this.transparent = true;
 
 	this.setValues( parameters );

+ 1 - 3
src/math/Vector3.js

@@ -555,11 +555,9 @@ Object.assign( Vector3.prototype, {
 
 	angleTo: function ( v ) {
 
-		// assumes this and v are not the zero vector
-
 		var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );
 
-		if ( denominator === 0 ) console.error( 'THREE.Vector3: angleTo() does not accept zero vectors.' );
+		if ( denominator === 0 ) console.error( 'THREE.Vector3: angleTo() can\'t handle zero length vectors.' );
 
 		var theta = this.dot( v ) / denominator;
 

+ 2 - 0
src/objects/InstancedMesh.js

@@ -11,6 +11,8 @@ function InstancedMesh( geometry, material, count ) {
 
 	this.instanceMatrix = new BufferAttribute( new Float32Array( count * 16 ), 16 );
 
+	this.count = count;
+
 }
 
 InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {

+ 0 - 191
src/renderers/WebGL2Renderer.js

@@ -1,191 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-import { REVISION } from '../constants.js';
-import { WebGLExtensions } from './webgl/WebGLExtensions.js';
-import { WebGLState } from './webgl/WebGLState.js';
-import { Color } from '../math/Color.js';
-import { Vector4 } from '../math/Vector4.js';
-
-function WebGL2Renderer( parameters ) {
-
-	console.log( 'THREE.WebGL2Renderer', REVISION );
-
-	parameters = parameters || {};
-
-	var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),
-		_context = parameters.context !== undefined ? parameters.context : null,
-
-		_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
-		_depth = parameters.depth !== undefined ? parameters.depth : true,
-		_stencil = parameters.stencil !== undefined ? parameters.stencil : true,
-		_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
-		_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
-		_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,
-		_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',
-		_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;
-
-	// initialize
-
-	var gl;
-
-	try {
-
-		var attributes = {
-			alpha: _alpha,
-			depth: _depth,
-			stencil: _stencil,
-			antialias: _antialias,
-			premultipliedAlpha: _premultipliedAlpha,
-			preserveDrawingBuffer: _preserveDrawingBuffer,
-			powerPreference: _powerPreference,
-			failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
-		};
-
-		// event listeners must be registered before WebGL context is created, see #12753
-
-		_canvas.addEventListener( 'webglcontextlost', onContextLost, false );
-		_canvas.addEventListener( 'webglcontextrestored', function () { } );
-
-		gl = _context || _canvas.getContext( 'webgl2', attributes );
-
-		if ( gl === null ) {
-
-			if ( _canvas.getContext( 'webgl2' ) !== null ) {
-
-				throw new Error( 'Error creating WebGL2 context with your selected attributes.' );
-
-			} else {
-
-				throw new Error( 'Error creating WebGL2 context.' );
-
-			}
-
-		}
-
-	} catch ( error ) {
-
-		console.error( 'THREE.WebGL2Renderer: ' + error.message );
-
-	}
-
-	//
-
-	var _autoClear = true,
-		_autoClearColor = true,
-		_autoClearDepth = true,
-		_autoClearStencil = true,
-
-		_clearColor = new Color( 0x000000 ),
-		_clearAlpha = 0,
-
-		_width = _canvas.width,
-		_height = _canvas.height,
-
-		_pixelRatio = 1,
-
-		_viewport = new Vector4( 0, 0, _width, _height );
-
-	var extensions = new WebGLExtensions( gl );
-	var state = new WebGLState( gl, extensions, function () {} );
-
-	//
-
-	function clear( color, depth, stencil ) {
-
-		var bits = 0;
-
-		if ( color === undefined || color ) bits |= gl.COLOR_BUFFER_BIT;
-		if ( depth === undefined || depth ) bits |= gl.DEPTH_BUFFER_BIT;
-		if ( stencil === undefined || stencil ) bits |= gl.STENCIL_BUFFER_BIT;
-
-		gl.clear( bits );
-
-	}
-
-	function setPixelRatio( value ) {
-
-		if ( value === undefined ) return;
-
-		_pixelRatio = value;
-
-		setSize( _viewport.z, _viewport.w, false );
-
-	}
-
-	function setSize( width, height, updateStyle ) {
-
-		_width = width;
-		_height = height;
-
-		_canvas.width = width * _pixelRatio;
-		_canvas.height = height * _pixelRatio;
-
-		if ( updateStyle !== false ) {
-
-			_canvas.style.width = width + 'px';
-			_canvas.style.height = height + 'px';
-
-		}
-
-		setViewport( 0, 0, width, height );
-
-	}
-
-	function setViewport( x, y, width, height ) {
-
-		state.viewport( _viewport.set( x, y, width, height ) );
-
-	}
-
-	function render( scene, camera ) {
-
-		if ( camera !== undefined && camera.isCamera !== true ) {
-
-			console.error( 'THREE.WebGL2Renderer.render: camera is not an instance of THREE.Camera.' );
-			return;
-
-		}
-
-		var background = scene.background;
-		var forceClear = false;
-
-		if ( background === null ) {
-
-			state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha );
-
-		} else if ( background && background.isColor ) {
-
-			state.buffers.color.setClear( background.r, background.g, background.b, 1, _premultipliedAlpha );
-			forceClear = true;
-
-		}
-
-		if ( _autoClear || forceClear ) {
-
-			this.clear( _autoClearColor, _autoClearDepth, _autoClearStencil );
-
-		}
-
-	}
-
-	function onContextLost( event ) {
-
-		event.preventDefault();
-
-	}
-
-	return {
-		domElement: _canvas,
-
-		clear: clear,
-		setPixelRatio: setPixelRatio,
-		setSize: setSize,
-		render: render
-	};
-
-}
-
-
-export { WebGL2Renderer };

+ 1 - 1
src/renderers/WebGLRenderer.d.ts

@@ -188,7 +188,7 @@ export class WebGLRenderer implements Renderer {
 
 	shadowMap: WebGLShadowMap;
 
-	pixelRation: number;
+	pixelRatio: number;
 
 	capabilities: WebGLCapabilities;
 	properties: WebGLProperties;

+ 13 - 4
src/renderers/WebGLRenderer.js

@@ -865,7 +865,7 @@ function WebGLRenderer( parameters ) {
 
 		if ( object.isInstancedMesh ) {
 
-			renderer.renderInstances( geometry, drawStart, drawCount, object.instanceMatrix.count );
+			renderer.renderInstances( geometry, drawStart, drawCount, object.count );
 
 		} else if ( geometry.isInstancedBufferGeometry ) {
 
@@ -1616,9 +1616,10 @@ function WebGLRenderer( parameters ) {
 
 		// store the light setup it was created for
 
+		materialProperties.needsLights = materialNeedsLights( material );
 		materialProperties.lightsStateVersion = lightsStateVersion;
 
-		if ( material.lights ) {
+		if ( materialProperties.needsLights ) {
 
 			// wire up the material to this renderer's lighting state
 
@@ -1684,7 +1685,7 @@ function WebGLRenderer( parameters ) {
 
 				material.needsUpdate = true;
 
-			} else if ( material.lights && materialProperties.lightsStateVersion !== lights.state.version ) {
+			} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
 
 				material.needsUpdate = true;
 
@@ -1868,7 +1869,7 @@ function WebGLRenderer( parameters ) {
 			p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
 			p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
 
-			if ( material.lights ) {
+			if ( materialProperties.needsLights ) {
 
 				// the current material requires lighting info
 
@@ -2475,6 +2476,14 @@ function WebGLRenderer( parameters ) {
 
 	}
 
+	function materialNeedsLights( material ) {
+
+		return material.isMeshLambertMaterial || material.isMeshPhongMaterial ||
+			material.isMeshStandardMaterial || material.isShadowMaterial ||
+			( material.isShaderMaterial && material.lights === true );
+
+	}
+
 	//
 	this.setFramebuffer = function ( value ) {
 

+ 3 - 1
src/renderers/webgl/WebGLBufferRenderer.js

@@ -4,6 +4,8 @@
 
 function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
 
+	var isWebGL2 = capabilities.isWebGL2;
+
 	var mode;
 
 	function setMode( value ) {
@@ -26,7 +28,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) {
 
 		var extension, methodName;
 
-		if ( capabilities.isWebGL2 ) {
+		if ( isWebGL2 ) {
 
 			extension = gl;
 			methodName = 'drawArraysInstanced';

+ 3 - 1
src/renderers/webgl/WebGLIndexedBufferRenderer.js

@@ -4,6 +4,8 @@
 
 function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
 
+	var isWebGL2 = capabilities.isWebGL2;
+
 	var mode;
 
 	function setMode( value ) {
@@ -35,7 +37,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {
 
 		var extension, methodName;
 
-		if ( capabilities.isWebGL2 ) {
+		if ( isWebGL2 ) {
 
 			extension = gl;
 			methodName = 'drawElementsInstanced';

+ 0 - 1
src/renderers/webgl/WebGLProgram.d.ts

@@ -1,7 +1,6 @@
 import { WebGLRenderer, WebGLRendererParameters } from './../WebGLRenderer';
 import { ShaderMaterial } from './../../materials/ShaderMaterial';
 import { WebGLShader } from './WebGLShader';
-import { WebGLCapabilities } from './WebGLCapabilities';
 import { WebGLExtensions } from './WebGLExtensions';
 import { WebGLUniforms } from './WebGLUniforms';
 

+ 4 - 2
src/renderers/webgl/WebGLState.js

@@ -7,6 +7,8 @@ import { Vector4 } from '../../math/Vector4.js';
 
 function WebGLState( gl, extensions, utils, capabilities ) {
 
+	var isWebGL2 = capabilities.isWebGL2;
+
 	function ColorBuffer() {
 
 		var locked = false;
@@ -438,9 +440,9 @@ function WebGLState( gl, extensions, utils, capabilities ) {
 
 		if ( attributeDivisors[ attribute ] !== meshPerAttribute ) {
 
-			var extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );
+			var extension = isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );
 
-			extension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
+			extension[ isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );
 			attributeDivisors[ attribute ] = meshPerAttribute;
 
 		}

+ 23 - 17
src/renderers/webgl/WebGLTextures.js

@@ -7,6 +7,12 @@ import { _Math } from '../../math/Math.js';
 
 function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {
 
+	var isWebGL2 = capabilities.isWebGL2;
+	var maxTextures = capabilities.maxTextures;
+	var maxCubemapSize = capabilities.maxCubemapSize;
+	var maxTextureSize = capabilities.maxTextureSize;
+	var maxSamples = capabilities.maxSamples;
+
 	var _videoTextures = new WeakMap();
 	var _canvas;
 
@@ -95,7 +101,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 	function textureNeedsPowerOfTwo( texture ) {
 
-		if ( capabilities.isWebGL2 ) return false;
+		if ( isWebGL2 ) return false;
 
 		return ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||
 			( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );
@@ -122,7 +128,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 	function getInternalFormat( glFormat, glType ) {
 
-		if ( ! capabilities.isWebGL2 ) return glFormat;
+		if ( isWebGL2 === false ) return glFormat;
 
 		var internalFormat = glFormat;
 
@@ -294,9 +300,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 		var textureUnit = textureUnits;
 
-		if ( textureUnit >= capabilities.maxTextures ) {
+		if ( textureUnit >= maxTextures ) {
 
-			console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
+			console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );
 
 		}
 
@@ -396,7 +402,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 				if ( ! isCompressed && ! isDataTexture ) {
 
-					cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );
+					cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
 
 				} else {
 
@@ -407,7 +413,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 			}
 
 			var image = cubeImage[ 0 ],
-				supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2,
+				supportsMips = isPowerOfTwo( image ) || isWebGL2,
 				glFormat = utils.convert( texture.format ),
 				glType = utils.convert( texture.type ),
 				glInternalFormat = getInternalFormat( glFormat, glType );
@@ -567,7 +573,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 		if ( extension ) {
 
 			if ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;
-			if ( texture.type === HalfFloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;
+			if ( texture.type === HalfFloatType && ( isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;
 
 			if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
 
@@ -613,9 +619,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 		_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
 
 		var needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
-		var image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
+		var image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
 
-		var supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2,
+		var supportsMips = isPowerOfTwo( image ) || isWebGL2,
 			glFormat = utils.convert( texture.format ),
 			glType = utils.convert( texture.type ),
 			glInternalFormat = getInternalFormat( glFormat, glType );
@@ -632,10 +638,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			if ( texture.type === FloatType ) {
 
-				if ( ! capabilities.isWebGL2 ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' );
+				if ( isWebGL2 === false ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' );
 				glInternalFormat = _gl.DEPTH_COMPONENT32F;
 
-			} else if ( capabilities.isWebGL2 ) {
+			} else if ( isWebGL2 ) {
 
 				// WebGL 2.0 requires signed internalformat for glTexImage2D
 				glInternalFormat = _gl.DEPTH_COMPONENT16;
@@ -962,7 +968,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 		var isCube = ( renderTarget.isWebGLRenderTargetCube === true );
 		var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
 		var isMultiview = ( renderTarget.isWebGLMultiviewRenderTarget === true );
-		var supportsMips = isPowerOfTwo( renderTarget ) || capabilities.isWebGL2;
+		var supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
 
 		// Setup framebuffer
 
@@ -982,7 +988,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			if ( isMultisample ) {
 
-				if ( capabilities.isWebGL2 ) {
+				if ( isWebGL2 ) {
 
 					renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
 					renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();
@@ -1110,7 +1116,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 	function updateRenderTargetMipmap( renderTarget ) {
 
 		var texture = renderTarget.texture;
-		var supportsMips = isPowerOfTwo( renderTarget ) || capabilities.isWebGL2;
+		var supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
 
 		if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
 
@@ -1129,7 +1135,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 		if ( renderTarget.isWebGLMultisampleRenderTarget ) {
 
-			if ( capabilities.isWebGL2 ) {
+			if ( isWebGL2 ) {
 
 				var renderTargetProperties = properties.get( renderTarget );
 
@@ -1157,8 +1163,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 	function getRenderTargetSamples( renderTarget ) {
 
-		return ( capabilities.isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?
-			Math.min( capabilities.maxSamples, renderTarget.samples ) : 0;
+		return ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?
+			Math.min( maxSamples, renderTarget.samples ) : 0;
 
 	}
 

+ 5 - 3
src/renderers/webgl/WebGLUtils.js

@@ -6,6 +6,8 @@ import { MaxEquation, MinEquation, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, R
 
 function WebGLUtils( gl, extensions, capabilities ) {
 
+	var isWebGL2 = capabilities.isWebGL2;
+
 	function convert( p ) {
 
 		var extension;
@@ -36,7 +38,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 		if ( p === HalfFloatType ) {
 
-			if ( capabilities.isWebGL2 ) return gl.HALF_FLOAT;
+			if ( isWebGL2 ) return gl.HALF_FLOAT;
 
 			extension = extensions.get( 'OES_texture_half_float' );
 
@@ -128,7 +130,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 		if ( p === MinEquation || p === MaxEquation ) {
 
-			if ( capabilities.isWebGL2 ) {
+			if ( isWebGL2 ) {
 
 				if ( p === MinEquation ) return gl.MIN;
 				if ( p === MaxEquation ) return gl.MAX;
@@ -148,7 +150,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
 
 		if ( p === UnsignedInt248Type ) {
 
-			if ( capabilities.isWebGL2 ) return gl.UNSIGNED_INT_24_8;
+			if ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;
 
 			extension = extensions.get( 'WEBGL_depth_texture' );
 

+ 4 - 3
src/renderers/webvr/WebXRManager.js

@@ -17,7 +17,7 @@ function WebXRManager( renderer, gl ) {
 
 	var session = null;
 
-	var framebufferScaleFactor = 1.0;
+	// var framebufferScaleFactor = 1.0;
 
 	var referenceSpace = null;
 	var referenceSpaceType = 'local-floor';
@@ -106,9 +106,9 @@ function WebXRManager( renderer, gl ) {
 
 	}
 
-	this.setFramebufferScaleFactor = function ( value ) {
+	this.setFramebufferScaleFactor = function ( /* value */ ) {
 
-		framebufferScaleFactor = value;
+		// framebufferScaleFactor = value;
 
 	};
 
@@ -135,6 +135,7 @@ function WebXRManager( renderer, gl ) {
 			session.addEventListener( 'selectend', onSessionEvent );
 			session.addEventListener( 'end', onSessionEnd );
 
+			// eslint-disable-next-line no-undef
 			session.updateRenderState( { baseLayer: new XRWebGLLayer( session, gl ) } );
 
 			session.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );

+ 0 - 1
test/three.source.unit.js

@@ -233,7 +233,6 @@ import './unit/src/objects/Sprite.tests';
 
 
 //src/renderers
-import './unit/src/renderers/WebGL2Renderer.tests';
 import './unit/src/renderers/WebGLRenderer.tests';
 import './unit/src/renderers/WebGLRenderTarget.tests';
 import './unit/src/renderers/WebGLRenderTargetCube.tests';

+ 0 - 52
test/unit/src/renderers/WebGL2Renderer.tests.js

@@ -1,52 +0,0 @@
-/**
- * @author TristanVALCKE / https://github.com/Itee
- */
-/* global QUnit */
-
-import { WebGL2Renderer } from '../../../../src/renderers/WebGL2Renderer';
-
-export default QUnit.module( 'Renderers', () => {
-
-	QUnit.module( 'WebGL2Renderer', () => {
-
-		// INSTANCING
-		QUnit.todo( "Instancing", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		// PUBLIC STUFF
-		QUnit.todo( "domElement", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "clear", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "setPixelRatio", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "setSize", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-		QUnit.todo( "render", ( assert ) => {
-
-			assert.ok( false, "everything's gonna be alright" );
-
-		} );
-
-	} );
-
-} );

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio