Skip to content

Commit c0ed7c5

Browse files
authored
Merge pull request #17443 from sdinesh86/dev
Physical Material Sheen parameter serialization and deserialization and exposed in editor
2 parents 3b07b7f + c6f4e71 commit c0ed7c5

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

editor/js/Sidebar.Material.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ Sidebar.Material = function ( editor ) {
195195

196196
container.add( materialMetalnessRow );
197197

198+
// sheen
199+
200+
var materialSheenRow = new UI.Row();
201+
var materialSheenEnabled = new UI.Checkbox( false ).onChange( update );
202+
var materialSheen = new UI.Color().setHexValue(0x000000).onChange( update );
203+
204+
materialSheenRow.add( new UI.Text( strings.getKey( 'sidebar/material/sheen' ) ).setWidth( '90px' ) )
205+
materialSheenRow.add( materialSheenEnabled );
206+
materialSheenRow.add( materialSheen );
207+
208+
container.add( materialSheenRow );
209+
198210
// emissive
199211

200212
var materialEmissiveRow = new UI.Row();
@@ -636,6 +648,22 @@ Sidebar.Material = function ( editor ) {
636648

637649
}
638650

651+
if ( material.sheen !== undefined ) {
652+
653+
var sheenEnabled = materialSheenEnabled.getValue() === true;
654+
655+
var sheen = sheenEnabled ? new THREE.Color(materialSheen.getHexValue()) : null;
656+
657+
editor.execute( new SetMaterialValueCommand( editor, currentObject, 'sheen', sheen, currentMaterialSlot ) );
658+
659+
}
660+
661+
if ( material.sheen !== undefined && material.sheen !== null && material.sheen.getHex() !== materialSheen.getHexValue() ) {
662+
663+
editor.execute( new SetMaterialColorCommand( editor, currentObject, 'sheen', materialSheen.getHexValue(), currentMaterialSlot ) );
664+
665+
}
666+
639667
if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) {
640668

641669
editor.execute( new SetMaterialColorCommand( editor, currentObject, 'emissive', materialEmissive.getHexValue(), currentMaterialSlot ) );
@@ -1157,6 +1185,7 @@ Sidebar.Material = function ( editor ) {
11571185
'roughness': materialRoughnessRow,
11581186
'metalness': materialMetalnessRow,
11591187
'emissive': materialEmissiveRow,
1188+
'sheen': materialSheenRow,
11601189
'specular': materialSpecularRow,
11611190
'shininess': materialShininessRow,
11621191
'clearcoat': materialClearcoatRow,
@@ -1268,6 +1297,13 @@ Sidebar.Material = function ( editor ) {
12681297
materialMetalness.setValue( material.metalness );
12691298

12701299
}
1300+
1301+
if ( material.sheen !== undefined && material.sheen !== null ) {
1302+
1303+
materialSheenEnabled.setValue( true );
1304+
materialSheen.setHexValue( material.sheen.getHexString() );
1305+
1306+
}
12711307

12721308
if ( material.emissive !== undefined ) {
12731309

editor/js/Strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ var Strings = function ( config ) {
225225
'sidebar/material/depthPacking': 'Depth Packing',
226226
'sidebar/material/roughness': 'Roughness',
227227
'sidebar/material/metalness': 'Metalness',
228+
'sidebar/material/sheen': 'Sheen',
228229
'sidebar/material/emissive': 'Emissive',
229230
'sidebar/material/specular': 'Specular',
230231
'sidebar/material/shininess': 'Shininess',

src/loaders/MaterialLoader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
6161
if ( json.color !== undefined ) material.color.setHex( json.color );
6262
if ( json.roughness !== undefined ) material.roughness = json.roughness;
6363
if ( json.metalness !== undefined ) material.metalness = json.metalness;
64+
if ( json.sheen !== undefined ) material.sheen = new Color().setHex( json.sheen );
6465
if ( json.emissive !== undefined ) material.emissive.setHex( json.emissive );
6566
if ( json.specular !== undefined ) material.specular.setHex( json.specular );
6667
if ( json.shininess !== undefined ) material.shininess = json.shininess;

src/materials/Material.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
169169
if ( this.roughness !== undefined ) data.roughness = this.roughness;
170170
if ( this.metalness !== undefined ) data.metalness = this.metalness;
171171

172+
if ( this.sheen && this.sheen.isColor ) data.sheen = this.sheen.getHex();
172173
if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
173174
if ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
174175

src/renderers/WebGLRenderer.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class WebGLRenderer implements Renderer {
326326
* A build in function that can be used instead of requestAnimationFrame. For WebVR projects this function must be used.
327327
* @param callback The function will be called every available frame. If `null` is passed it will stop any already ongoing animation.
328328
*/
329-
setAnimationLoop( callback: Function ): void;
329+
setAnimationLoop( callback: Function | null ): void;
330330

331331
/**
332332
* @deprecated Use {@link WebGLRenderer#setAnimationLoop .setAnimationLoop()} instead.

0 commit comments

Comments
 (0)