Skip to content

Commit c8db00a

Browse files
authored
Merge pull request #16876 from Mugen87/dev35
Material: Clean up serialization/deserialization.
2 parents 6a7784d + 707d947 commit c8db00a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/loaders/MaterialLoader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Object.assign( MaterialLoader.prototype, {
9393

9494
if ( json.skinning !== undefined ) material.skinning = json.skinning;
9595
if ( json.morphTargets !== undefined ) material.morphTargets = json.morphTargets;
96+
if ( json.morphNormals !== undefined ) material.morphNormals = json.morphNormals;
9697
if ( json.dithering !== undefined ) material.dithering = json.dithering;
9798

9899
if ( json.visible !== undefined ) material.visible = json.visible;
@@ -218,6 +219,7 @@ Object.assign( MaterialLoader.prototype, {
218219
if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;
219220

220221
if ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity;
222+
if ( json.refractionRatio !== undefined ) material.refractionRatio = json.refractionRatio;
221223

222224
if ( json.lightMap !== undefined ) material.lightMap = getTexture( json.lightMap );
223225
if ( json.lightMapIntensity !== undefined ) material.lightMapIntensity = json.lightMapIntensity;

src/materials/Material.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
160160
if ( this.metalness !== undefined ) data.metalness = this.metalness;
161161

162162
if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
163-
if ( this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
163+
if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
164164

165165
if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
166166
if ( this.shininess !== undefined ) data.shininess = this.shininess;
@@ -212,6 +212,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
212212

213213
data.envMap = this.envMap.toJSON( meta ).uuid;
214214
data.reflectivity = this.reflectivity; // Scale behind envMap
215+
data.refractionRatio = this.refractionRatio;
215216

216217
if ( this.combine !== undefined ) data.combine = this.combine;
217218
if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
@@ -240,13 +241,13 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
240241
data.depthWrite = this.depthWrite;
241242

242243
// rotation (SpriteMaterial)
243-
if ( this.rotation !== 0 ) data.rotation = this.rotation;
244+
if ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;
244245

245246
if ( this.polygonOffset === true ) data.polygonOffset = true;
246247
if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
247248
if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
248249

249-
if ( this.linewidth !== 1 ) data.linewidth = this.linewidth;
250+
if ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;
250251
if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
251252
if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
252253
if ( this.scale !== undefined ) data.scale = this.scale;
@@ -262,6 +263,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
262263
if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
263264

264265
if ( this.morphTargets === true ) data.morphTargets = true;
266+
if ( this.morphNormals === true ) data.morphNormals = true;
265267
if ( this.skinning === true ) data.skinning = true;
266268

267269
if ( this.visible === false ) data.visible = false;

0 commit comments

Comments
 (0)