Skip to content

Commit b920260

Browse files
authored
Merge pull request #21319 from Mugen87/dev51
MeshStandardMaterial: Revert class change.
2 parents a036601 + 1630c94 commit b920260

File tree

2 files changed

+134
-136
lines changed

2 files changed

+134
-136
lines changed

src/materials/MeshPhysicalMaterial.js

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,92 +22,90 @@ import { MathUtils } from '../math/MathUtils.js';
2222
* }
2323
*/
2424

25-
class MeshPhysicalMaterial extends MeshStandardMaterial {
25+
function MeshPhysicalMaterial( parameters ) {
2626

27-
constructor( parameters ) {
27+
MeshStandardMaterial.call( this );
2828

29-
super();
29+
this.defines = {
3030

31-
this.defines = {
31+
'STANDARD': '',
32+
'PHYSICAL': ''
3233

33-
'STANDARD': '',
34-
'PHYSICAL': ''
34+
};
3535

36-
};
36+
this.type = 'MeshPhysicalMaterial';
3737

38-
this.type = 'MeshPhysicalMaterial';
38+
this.clearcoat = 0.0;
39+
this.clearcoatMap = null;
40+
this.clearcoatRoughness = 0.0;
41+
this.clearcoatRoughnessMap = null;
42+
this.clearcoatNormalScale = new Vector2( 1, 1 );
43+
this.clearcoatNormalMap = null;
3944

40-
this.clearcoat = 0.0;
41-
this.clearcoatMap = null;
42-
this.clearcoatRoughness = 0.0;
43-
this.clearcoatRoughnessMap = null;
44-
this.clearcoatNormalScale = new Vector2( 1, 1 );
45-
this.clearcoatNormalMap = null;
45+
this.reflectivity = 0.5; // maps to F0 = 0.04
4646

47-
this.reflectivity = 0.5; // maps to F0 = 0.04
47+
Object.defineProperty( this, 'ior', {
48+
get: function () {
4849

49-
Object.defineProperty( this, 'ior', {
50-
get: function () {
50+
return ( 1 + 0.4 * this.reflectivity ) / ( 1 - 0.4 * this.reflectivity );
5151

52-
return ( 1 + 0.4 * this.reflectivity ) / ( 1 - 0.4 * this.reflectivity );
52+
},
53+
set: function ( ior ) {
5354

54-
},
55-
set: function ( ior ) {
55+
this.reflectivity = MathUtils.clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
5656

57-
this.reflectivity = MathUtils.clamp( 2.5 * ( ior - 1 ) / ( ior + 1 ), 0, 1 );
58-
59-
}
60-
} );
61-
62-
63-
this.sheen = null; // null will disable sheen bsdf
57+
}
58+
} );
6459

65-
this.transmission = 0.0;
66-
this.transmissionMap = null;
60+
this.sheen = null; // null will disable sheen bsdf
6761

68-
this.setValues( parameters );
62+
this.transmission = 0.0;
63+
this.transmissionMap = null;
6964

70-
}
65+
this.setValues( parameters );
7166

72-
copy( source ) {
67+
}
7368

74-
super.copy( source );
69+
MeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype );
70+
MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
7571

76-
this.defines = {
72+
MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
7773

78-
'STANDARD': '',
79-
'PHYSICAL': ''
74+
MeshPhysicalMaterial.prototype.copy = function ( source ) {
8075

81-
};
76+
MeshStandardMaterial.prototype.copy.call( this, source );
8277

83-
this.clearcoat = source.clearcoat;
84-
this.clearcoatMap = source.clearcoatMap;
85-
this.clearcoatRoughness = source.clearcoatRoughness;
86-
this.clearcoatRoughnessMap = source.clearcoatRoughnessMap;
87-
this.clearcoatNormalMap = source.clearcoatNormalMap;
88-
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
78+
this.defines = {
8979

90-
this.reflectivity = source.reflectivity;
80+
'STANDARD': '',
81+
'PHYSICAL': ''
9182

92-
if ( source.sheen ) {
83+
};
9384

94-
this.sheen = ( this.sheen || new Color() ).copy( source.sheen );
85+
this.clearcoat = source.clearcoat;
86+
this.clearcoatMap = source.clearcoatMap;
87+
this.clearcoatRoughness = source.clearcoatRoughness;
88+
this.clearcoatRoughnessMap = source.clearcoatRoughnessMap;
89+
this.clearcoatNormalMap = source.clearcoatNormalMap;
90+
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
9591

96-
} else {
92+
this.reflectivity = source.reflectivity;
9793

98-
this.sheen = null;
94+
if ( source.sheen ) {
9995

100-
}
96+
this.sheen = ( this.sheen || new Color() ).copy( source.sheen );
10197

102-
this.transmission = source.transmission;
103-
this.transmissionMap = source.transmissionMap;
98+
} else {
10499

105-
return this;
100+
this.sheen = null;
106101

107102
}
108103

109-
}
104+
this.transmission = source.transmission;
105+
this.transmissionMap = source.transmissionMap;
110106

111-
MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
107+
return this;
108+
109+
};
112110

113111
export { MeshPhysicalMaterial };

src/materials/MeshStandardMaterial.js

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -55,134 +55,134 @@ import { Color } from '../math/Color.js';
5555
* }
5656
*/
5757

58-
class MeshStandardMaterial extends Material {
58+
function MeshStandardMaterial( parameters ) {
5959

60-
constructor( parameters ) {
60+
Material.call( this );
6161

62-
super();
62+
this.defines = { 'STANDARD': '' };
6363

64-
this.defines = { 'STANDARD': '' };
64+
this.type = 'MeshStandardMaterial';
6565

66-
this.type = 'MeshStandardMaterial';
66+
this.color = new Color( 0xffffff ); // diffuse
67+
this.roughness = 1.0;
68+
this.metalness = 0.0;
6769

68-
this.color = new Color( 0xffffff ); // diffuse
69-
this.roughness = 1.0;
70-
this.metalness = 0.0;
70+
this.map = null;
7171

72-
this.map = null;
72+
this.lightMap = null;
73+
this.lightMapIntensity = 1.0;
7374

74-
this.lightMap = null;
75-
this.lightMapIntensity = 1.0;
75+
this.aoMap = null;
76+
this.aoMapIntensity = 1.0;
7677

77-
this.aoMap = null;
78-
this.aoMapIntensity = 1.0;
78+
this.emissive = new Color( 0x000000 );
79+
this.emissiveIntensity = 1.0;
80+
this.emissiveMap = null;
7981

80-
this.emissive = new Color( 0x000000 );
81-
this.emissiveIntensity = 1.0;
82-
this.emissiveMap = null;
82+
this.bumpMap = null;
83+
this.bumpScale = 1;
8384

84-
this.bumpMap = null;
85-
this.bumpScale = 1;
85+
this.normalMap = null;
86+
this.normalMapType = TangentSpaceNormalMap;
87+
this.normalScale = new Vector2( 1, 1 );
8688

87-
this.normalMap = null;
88-
this.normalMapType = TangentSpaceNormalMap;
89-
this.normalScale = new Vector2( 1, 1 );
89+
this.displacementMap = null;
90+
this.displacementScale = 1;
91+
this.displacementBias = 0;
9092

91-
this.displacementMap = null;
92-
this.displacementScale = 1;
93-
this.displacementBias = 0;
93+
this.roughnessMap = null;
9494

95-
this.roughnessMap = null;
95+
this.metalnessMap = null;
9696

97-
this.metalnessMap = null;
97+
this.alphaMap = null;
9898

99-
this.alphaMap = null;
99+
this.envMap = null;
100+
this.envMapIntensity = 1.0;
100101

101-
this.envMap = null;
102-
this.envMapIntensity = 1.0;
102+
this.refractionRatio = 0.98;
103103

104-
this.refractionRatio = 0.98;
104+
this.wireframe = false;
105+
this.wireframeLinewidth = 1;
106+
this.wireframeLinecap = 'round';
107+
this.wireframeLinejoin = 'round';
105108

106-
this.wireframe = false;
107-
this.wireframeLinewidth = 1;
108-
this.wireframeLinecap = 'round';
109-
this.wireframeLinejoin = 'round';
109+
this.skinning = false;
110+
this.morphTargets = false;
111+
this.morphNormals = false;
110112

111-
this.skinning = false;
112-
this.morphTargets = false;
113-
this.morphNormals = false;
113+
this.flatShading = false;
114114

115-
this.flatShading = false;
115+
this.vertexTangents = false;
116116

117-
this.vertexTangents = false;
117+
this.setValues( parameters );
118118

119-
this.setValues( parameters );
119+
}
120120

121-
}
121+
MeshStandardMaterial.prototype = Object.create( Material.prototype );
122+
MeshStandardMaterial.prototype.constructor = MeshStandardMaterial;
122123

123-
copy( source ) {
124+
MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
124125

125-
super.copy( source );
126+
MeshStandardMaterial.prototype.copy = function ( source ) {
126127

127-
this.defines = { 'STANDARD': '' };
128+
Material.prototype.copy.call( this, source );
128129

129-
this.color.copy( source.color );
130-
this.roughness = source.roughness;
131-
this.metalness = source.metalness;
130+
this.defines = { 'STANDARD': '' };
132131

133-
this.map = source.map;
132+
this.color.copy( source.color );
133+
this.roughness = source.roughness;
134+
this.metalness = source.metalness;
134135

135-
this.lightMap = source.lightMap;
136-
this.lightMapIntensity = source.lightMapIntensity;
136+
this.map = source.map;
137137

138-
this.aoMap = source.aoMap;
139-
this.aoMapIntensity = source.aoMapIntensity;
138+
this.lightMap = source.lightMap;
139+
this.lightMapIntensity = source.lightMapIntensity;
140140

141-
this.emissive.copy( source.emissive );
142-
this.emissiveMap = source.emissiveMap;
143-
this.emissiveIntensity = source.emissiveIntensity;
141+
this.aoMap = source.aoMap;
142+
this.aoMapIntensity = source.aoMapIntensity;
144143

145-
this.bumpMap = source.bumpMap;
146-
this.bumpScale = source.bumpScale;
144+
this.emissive.copy( source.emissive );
145+
this.emissiveMap = source.emissiveMap;
146+
this.emissiveIntensity = source.emissiveIntensity;
147147

148-
this.normalMap = source.normalMap;
149-
this.normalMapType = source.normalMapType;
150-
this.normalScale.copy( source.normalScale );
148+
this.bumpMap = source.bumpMap;
149+
this.bumpScale = source.bumpScale;
151150

152-
this.displacementMap = source.displacementMap;
153-
this.displacementScale = source.displacementScale;
154-
this.displacementBias = source.displacementBias;
151+
this.normalMap = source.normalMap;
152+
this.normalMapType = source.normalMapType;
153+
this.normalScale.copy( source.normalScale );
155154

156-
this.roughnessMap = source.roughnessMap;
155+
this.displacementMap = source.displacementMap;
156+
this.displacementScale = source.displacementScale;
157+
this.displacementBias = source.displacementBias;
157158

158-
this.metalnessMap = source.metalnessMap;
159+
this.roughnessMap = source.roughnessMap;
159160

160-
this.alphaMap = source.alphaMap;
161+
this.metalnessMap = source.metalnessMap;
161162

162-
this.envMap = source.envMap;
163-
this.envMapIntensity = source.envMapIntensity;
163+
this.alphaMap = source.alphaMap;
164164

165-
this.refractionRatio = source.refractionRatio;
165+
this.envMap = source.envMap;
166+
this.envMapIntensity = source.envMapIntensity;
166167

167-
this.wireframe = source.wireframe;
168-
this.wireframeLinewidth = source.wireframeLinewidth;
169-
this.wireframeLinecap = source.wireframeLinecap;
170-
this.wireframeLinejoin = source.wireframeLinejoin;
168+
this.refractionRatio = source.refractionRatio;
171169

172-
this.skinning = source.skinning;
173-
this.morphTargets = source.morphTargets;
174-
this.morphNormals = source.morphNormals;
170+
this.wireframe = source.wireframe;
171+
this.wireframeLinewidth = source.wireframeLinewidth;
172+
this.wireframeLinecap = source.wireframeLinecap;
173+
this.wireframeLinejoin = source.wireframeLinejoin;
175174

176-
this.flatShading = source.flatShading;
175+
this.skinning = source.skinning;
176+
this.morphTargets = source.morphTargets;
177+
this.morphNormals = source.morphNormals;
177178

178-
this.vertexTangents = source.vertexTangents;
179+
this.flatShading = source.flatShading;
179180

180-
return this;
181+
this.vertexTangents = source.vertexTangents;
181182

182-
}
183+
return this;
183184

184-
}
185+
};
185186

186-
MeshStandardMaterial.prototype.isMeshStandardMaterial = true;
187187

188188
export { MeshStandardMaterial };

0 commit comments

Comments
 (0)