Skip to content

Commit f5803c6

Browse files
authored
MeshStandardMaterial: Remove .vertexTangents property. (#22146)
1 parent 3a9152a commit f5803c6

File tree

11 files changed

+33
-41
lines changed

11 files changed

+33
-41
lines changed

docs/api/en/materials/MeshStandardMaterial.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,6 @@ <h3>[property:Float roughness]</h3>
233233
<h3>[property:Texture roughnessMap]</h3>
234234
<p>The green channel of this texture is used to alter the roughness of the material.</p>
235235

236-
<h3>[property:Boolean vertexTangents]</h3>
237-
<p>
238-
Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute,
239-
are used. When disabled, tangents are derived automatically. Using precomputed tangents will give
240-
more accurate normal map details in some cases, such as with mirrored UVs. Default is false.
241-
</p>
242-
243236
<h3>[property:Boolean wireframe]</h3>
244237
<p>Render geometry as wireframe. Default is *false* (i.e. render as flat polygons).</p>
245238

docs/api/zh/materials/MeshStandardMaterial.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ <h3>[property:Float roughness]</h3>
191191
<h3>[property:Texture roughnessMap]</h3>
192192
<p>该纹理的绿色通道用于改变材质的粗糙度。</p>
193193

194-
<h3>[property:Boolean vertexTangents]</h3>
195-
<p>
196-
Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute,
197-
are used. When disabled, tangents are derived automatically. Using precomputed tangents will give
198-
more accurate normal map details in some cases, such as with mirrored UVs. Default is false.
199-
</p>
200-
201-
202194
<h3>[property:Boolean wireframe]</h3>
203195
<p>将几何体渲染为线框。默认值为*false*(即渲染为平面多边形)。</p>
204196

editor/js/Sidebar.Material.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,6 @@ function SidebarMaterial( editor ) {
12551255
'clearcoatRoughness': materialClearcoatRoughnessRow,
12561256
'vertexShader': materialProgramRow,
12571257
'vertexColors': materialVertexColorsRow,
1258-
'vertexTangents': materialVertexTangentsRow,
12591258
'depthPacking': materialDepthPackingRow,
12601259
'map': materialMapRow,
12611260
'matcap': materialMatcapMapRow,

examples/jsm/loaders/GLTFLoader.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ class GLTFMaterialsClearcoatExtension {
684684

685685
const scale = extension.clearcoatNormalTexture.scale;
686686

687-
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
688-
materialParams.clearcoatNormalScale = new Vector2( scale, - scale );
687+
materialParams.clearcoatNormalScale = new Vector2( scale, scale );
689688

690689
}
691690

@@ -2892,16 +2891,6 @@ class GLTFParser {
28922891
if ( useVertexColors ) cachedMaterial.vertexColors = true;
28932892
if ( useFlatShading ) cachedMaterial.flatShading = true;
28942893

2895-
if ( useVertexTangents ) {
2896-
2897-
cachedMaterial.vertexTangents = true;
2898-
2899-
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
2900-
if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1;
2901-
if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1;
2902-
2903-
}
2904-
29052894
this.cache.add( cacheKey, cachedMaterial );
29062895

29072896
this.associations.set( cachedMaterial, this.associations.get( material ) );
@@ -3040,12 +3029,9 @@ class GLTFParser {
30403029

30413030
pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) );
30423031

3043-
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
3044-
materialParams.normalScale = new Vector2( 1, - 1 );
3045-
30463032
if ( materialDef.normalTexture.scale !== undefined ) {
30473033

3048-
materialParams.normalScale.set( materialDef.normalTexture.scale, - materialDef.normalTexture.scale );
3034+
materialParams.normalScale = new Vector2( materialDef.normalTexture.scale, materialDef.normalTexture.scale );
30493035

30503036
}
30513037

src/Three.Legacy.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,20 @@ Object.defineProperties( Material.prototype, {
12951295
this.stencilFuncMask = value;
12961296

12971297
}
1298-
}
1298+
},
1299+
1300+
vertexTangents: {
1301+
get: function () {
1302+
1303+
console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' );
1304+
1305+
},
1306+
set: function () {
1307+
1308+
console.warn( 'THREE.' + this.type + ': .vertexTangents has been removed.' );
1309+
1310+
}
1311+
},
12991312

13001313
} );
13011314

src/loaders/MaterialLoader.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ class MaterialLoader extends Loader {
127127
if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage;
128128
if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha;
129129

130-
if ( json.vertexTangents !== undefined ) material.vertexTangents = json.vertexTangents;
131-
132130
if ( json.visible !== undefined ) material.visible = json.visible;
133131

134132
if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped;

src/materials/MeshStandardMaterial.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ class MeshStandardMaterial extends Material {
106106

107107
this.flatShading = false;
108108

109-
this.vertexTangents = false;
110-
111109
this.setValues( parameters );
112110

113111
}
@@ -163,8 +161,6 @@ class MeshStandardMaterial extends Material {
163161

164162
this.flatShading = source.flatShading;
165163

166-
this.vertexTangents = source.vertexTangents;
167-
168164
return this;
169165

170166
}

src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ export default /* glsl */`
44
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
55
clearcoatMapN.xy *= clearcoatNormalScale;
66
7+
#ifdef FLIP_NORMAL_SCALE_Y
8+
9+
clearcoatMapN.y *= -1.0;
10+
11+
#endif
12+
713
#ifdef USE_TANGENT
814
915
clearcoatNormal = normalize( vTBN * clearcoatMapN );

src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ export default /* glsl */`
2323
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
2424
mapN.xy *= normalScale;
2525
26+
#ifdef FLIP_NORMAL_SCALE_Y
27+
28+
mapN.y *= -1.0;
29+
30+
#endif
31+
2632
#ifdef USE_TANGENT
2733
2834
normal = normalize( vTBN * mapN );

src/renderers/webgl/WebGLProgram.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
477477
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
478478
parameters.vertexUvs ? '#define USE_UV' : '',
479479
parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',
480+
parameters.flipNormalScaleY ? '#define FLIP_NORMAL_SCALE_Y' : '',
480481

481482
parameters.flatShading ? '#define FLAT_SHADED' : '',
482483

@@ -620,6 +621,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
620621
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',
621622
parameters.vertexUvs ? '#define USE_UV' : '',
622623
parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',
624+
parameters.flipNormalScaleY ? '#define FLIP_NORMAL_SCALE_Y' : '',
623625

624626
parameters.gradientMap ? '#define USE_GRADIENTMAP' : '',
625627

0 commit comments

Comments
 (0)