Explorar o código

Material: Move .lights property to ShaderMaterial.

Mugen87 %!s(int64=5) %!d(string=hai) anos
pai
achega
f1b4e8da32

+ 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 - 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.
 	 */

+ 11 - 3
src/renderers/WebGLRenderer.js

@@ -1618,7 +1618,7 @@ function WebGLRenderer( parameters ) {
 
 		materialProperties.lightsStateVersion = lightsStateVersion;
 
-		if ( material.lights ) {
+		if ( materialNeedsLights( material ) ) {
 
 			// wire up the material to this renderer's lighting state
 
@@ -1684,7 +1684,7 @@ function WebGLRenderer( parameters ) {
 
 				material.needsUpdate = true;
 
-			} else if ( material.lights && materialProperties.lightsStateVersion !== lights.state.version ) {
+			} else if ( materialNeedsLights( material ) && materialProperties.lightsStateVersion !== lights.state.version ) {
 
 				material.needsUpdate = true;
 
@@ -1868,7 +1868,7 @@ function WebGLRenderer( parameters ) {
 			p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
 			p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
 
-			if ( material.lights ) {
+			if ( materialNeedsLights( material ) ) {
 
 				// the current material requires lighting info
 
@@ -2475,6 +2475,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 ) {