Browse Source

MeshDistanceMaterial: Remove light related properties. (#25695)

Michael Herzog 2 years ago
parent
commit
3c4b97f57d

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

@@ -84,11 +84,6 @@
 			Without a displacement map set, this value is not applied. Default is 0.
 			Without a displacement map set, this value is not applied. Default is 0.
 		</p>
 		</p>
 
 
-		<h3>[property:Float farDistance]</h3>
-		<p>
-			The far value of the point light's internal shadow camera.
-		</p>
-
 		<h3>[property:Boolean fog]</h3>
 		<h3>[property:Boolean fog]</h3>
 		<p>Whether the material is affected by fog. Default is `false`.</p>
 		<p>Whether the material is affected by fog. Default is `false`.</p>
 
 
@@ -98,16 +93,6 @@
 			[page:Material.transparent .transparent] or [page:Material.alphaTest .alphaTest]. Default is null.
 			[page:Material.transparent .transparent] or [page:Material.alphaTest .alphaTest]. Default is null.
 		</p>
 		</p>
 
 
-		<h3>[property:Float nearDistance]</h3>
-		<p>
-			The near value of the point light's internal shadow camera.
-		</p>
-
-		<h3>[property:Vector3 referencePosition]</h3>
-		<p>
-			The position of the point light in world space.
-		</p>
-
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 		<p>See the base [page:Material] class for common methods.</p>
 		<p>See the base [page:Material] class for common methods.</p>
 
 

+ 0 - 15
docs/api/fr/materials/MeshDistanceMaterial.html

@@ -85,11 +85,6 @@
 			Sans ensemble de cartes de déplacement, cette valeur n'est pas appliquée. La valeur par défaut est 0.
 			Sans ensemble de cartes de déplacement, cette valeur n'est pas appliquée. La valeur par défaut est 0.
 		</p>
 		</p>
 
 
-		<h3>[property:Float farDistance]</h3>
-		<p>
-			La valeur lointaine de la caméra d'ombre interne de la lumière ponctuelle.
-		</p>
-
 		<h3>[property:Boolean fog]</h3>
 		<h3>[property:Boolean fog]</h3>
 		<p>Si le matériau est affecté par le brouillard (fog) La valeur par défaut est `false`.</p>
 		<p>Si le matériau est affecté par le brouillard (fog) La valeur par défaut est `false`.</p>
 
 
@@ -99,16 +94,6 @@
 			[page:Material.transparent .transparent] ou [page:Material.alphaTest .alphaTest]. La valeur par défaut est null.
 			[page:Material.transparent .transparent] ou [page:Material.alphaTest .alphaTest]. La valeur par défaut est null.
 		</p>
 		</p>
 
 
-		<h3>[property:Float nearDistance]</h3>
-		<p>
-			La valeur proche de la caméra d'ombre interne de la lumière ponctuelle.
-		</p>
-
-		<h3>[property:Vector3 referencePosition]</h3>
-		<p>
-			La position du point lumineux dans le repère monde.
-		</p>
-
 		<h2>Méthodes</h2>
 		<h2>Méthodes</h2>
 		<p>Voir la classe [page:Material] pour les méthodes communes.</p>
 		<p>Voir la classe [page:Material] pour les méthodes communes.</p>
 
 

+ 0 - 15
docs/api/it/materials/MeshDistanceMaterial.html

@@ -87,11 +87,6 @@
 			non viene applicato. Il valore predefinito è 0.
 			non viene applicato. Il valore predefinito è 0.
 		</p>
 		</p>
 
 
-		<h3>[property:Float farDistance]</h3>
-		<p>
-			Il valore far della telecamera d'ombra interna della luce puntiforme.
-		</p>
-
 		<h3>[property:Boolean fog]</h3>
 		<h3>[property:Boolean fog]</h3>
 		<p>Indica se il materiale è influenzato dalla nebbia. Il valore predefinito è `false`.</p>
 		<p>Indica se il materiale è influenzato dalla nebbia. Il valore predefinito è `false`.</p>
 
 
@@ -101,16 +96,6 @@
 			[page:Material.transparent .transparent] o [page:Material.alphaTest .alphaTest]. Il valore predefinito è `null`.
 			[page:Material.transparent .transparent] o [page:Material.alphaTest .alphaTest]. Il valore predefinito è `null`.
 		</p>
 		</p>
 
 
-		<h3>[property:Float nearDistance]</h3>
-		<p>
-			Il valore near della telecamera d'obra interna della luce puntiforme.
-		</p>
-
-		<h3>[property:Vector3 referencePosition]</h3>
-		<p>
-			La posizione della luce puntiforme nello spazio world.
-		</p>
-
 		<h2>Metodi</h2>
 		<h2>Metodi</h2>
 		<p>Vedi la classe base [page:Material] per i metodi comuni.</p>
 		<p>Vedi la classe base [page:Material] per i metodi comuni.</p>
 
 

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

@@ -73,27 +73,12 @@
 		<p> 位移贴图在网格顶点上的偏移量。如果没有设置位移贴图,则不会应用此值。默认值为0。
 		<p> 位移贴图在网格顶点上的偏移量。如果没有设置位移贴图,则不会应用此值。默认值为0。
 		</p>
 		</p>
 
 
-		<h3>[property:Float farDistance]</h3>
-		<p>
-			The far value of the point light's internal shadow camera.
-		</p>
-
 		<h3>[property:Texture map]</h3>
 		<h3>[property:Texture map]</h3>
 		<p>
 		<p>
 			颜色贴图。可以选择包括一个alpha通道,通常与[page:Material.transparent .transparent]
 			颜色贴图。可以选择包括一个alpha通道,通常与[page:Material.transparent .transparent]
 			或[page:Material.alphaTest .alphaTest]。默认为null。
 			或[page:Material.alphaTest .alphaTest]。默认为null。
 		</p>
 		</p>
 
 
-		<h3>[property:Float nearDistance]</h3>
-		<p>
-			The near value of the point light's internal shadow camera.
-		</p>
-
-		<h3>[property:Vector3 referencePosition]</h3>
-		<p>
-			The position of the point light in world space.
-		</p>
-
 		<h2>方法(Methods)</h2>
 		<h2>方法(Methods)</h2>
 		<p>共有方法请参见其基类[page:Material]。</p>
 		<p>共有方法请参见其基类[page:Material]。</p>
 
 

+ 0 - 9
src/materials/MeshDistanceMaterial.js

@@ -1,5 +1,4 @@
 import { Material } from './Material.js';
 import { Material } from './Material.js';
-import { Vector3 } from '../math/Vector3.js';
 
 
 class MeshDistanceMaterial extends Material {
 class MeshDistanceMaterial extends Material {
 
 
@@ -11,10 +10,6 @@ class MeshDistanceMaterial extends Material {
 
 
 		this.type = 'MeshDistanceMaterial';
 		this.type = 'MeshDistanceMaterial';
 
 
-		this.referencePosition = new Vector3();
-		this.nearDistance = 1;
-		this.farDistance = 1000;
-
 		this.map = null;
 		this.map = null;
 
 
 		this.alphaMap = null;
 		this.alphaMap = null;
@@ -31,10 +26,6 @@ class MeshDistanceMaterial extends Material {
 
 
 		super.copy( source );
 		super.copy( source );
 
 
-		this.referencePosition.copy( source.referencePosition );
-		this.nearDistance = source.nearDistance;
-		this.farDistance = source.farDistance;
-
 		this.map = source.map;
 		this.map = source.map;
 
 
 		this.alphaMap = source.alphaMap;
 		this.alphaMap = source.alphaMap;

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

@@ -662,9 +662,11 @@ function WebGLMaterials( renderer, properties ) {
 
 
 	function refreshUniformsDistance( uniforms, material ) {
 	function refreshUniformsDistance( uniforms, material ) {
 
 
-		uniforms.referencePosition.value.copy( material.referencePosition );
-		uniforms.nearDistance.value = material.nearDistance;
-		uniforms.farDistance.value = material.farDistance;
+		const light = properties.get( material ).light;
+
+		uniforms.referencePosition.value.setFromMatrixPosition( light.matrixWorld );
+		uniforms.nearDistance.value = light.shadow.camera.near;
+		uniforms.farDistance.value = light.shadow.camera.far;
 
 
 	}
 	}
 
 

+ 5 - 6
src/renderers/webgl/WebGLShadowMap.js

@@ -226,7 +226,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 
 	}
 	}
 
 
-	function getDepthMaterial( object, material, light, shadowCameraNear, shadowCameraFar, type ) {
+	function getDepthMaterial( object, material, light, type ) {
 
 
 		let result = null;
 		let result = null;
 
 
@@ -304,9 +304,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 
 		if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
 		if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
 
 
-			result.referencePosition.setFromMatrixPosition( light.matrixWorld );
-			result.nearDistance = shadowCameraNear;
-			result.farDistance = shadowCameraFar;
+			const materialProperties = _renderer.properties.get( result );
+			materialProperties.light = light;
 
 
 		}
 		}
 
 
@@ -340,7 +339,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 
 						if ( groupMaterial && groupMaterial.visible ) {
 						if ( groupMaterial && groupMaterial.visible ) {
 
 
-							const depthMaterial = getDepthMaterial( object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );
+							const depthMaterial = getDepthMaterial( object, groupMaterial, light, type );
 
 
 							_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
 							_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );
 
 
@@ -350,7 +349,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
 
 
 				} else if ( material.visible ) {
 				} else if ( material.visible ) {
 
 
-					const depthMaterial = getDepthMaterial( object, material, light, shadowCamera.near, shadowCamera.far, type );
+					const depthMaterial = getDepthMaterial( object, material, light, type );
 
 
 					_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
 					_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );
 
 

+ 0 - 18
test/unit/src/materials/MeshDistanceMaterial.tests.js

@@ -38,24 +38,6 @@ export default QUnit.module( 'Materials', () => {
 
 
 		} );
 		} );
 
 
-		QUnit.todo( 'referencePosition', ( assert ) => {
-
-			assert.ok( false, 'everything\'s gonna be alright' );
-
-		} );
-
-		QUnit.todo( 'nearDistance', ( assert ) => {
-
-			assert.ok( false, 'everything\'s gonna be alright' );
-
-		} );
-
-		QUnit.todo( 'farDistance', ( assert ) => {
-
-			assert.ok( false, 'everything\'s gonna be alright' );
-
-		} );
-
 		QUnit.todo( 'map', ( assert ) => {
 		QUnit.todo( 'map', ( assert ) => {
 
 
 			assert.ok( false, 'everything\'s gonna be alright' );
 			assert.ok( false, 'everything\'s gonna be alright' );