Skip to content

Commit 65c6fc6

Browse files
LeviPesinsunag
authored andcommitted
NodeMaterial.fromMaterial(): Support copying getters and setters (mrdoob#25861)
* NodeMaterial.fromMaterial(): Support copying getters and setters * Fix * update screenshot * Fix --------- Co-authored-by: sunag <sunagbrasil@gmail.com>
1 parent 8877763 commit 65c6fc6

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
3232
this.attenuationDistanceNode = null;
3333
this.attenuationColorNode = null;
3434

35-
this.sheen = 0;
36-
this.clearcoat = 0;
37-
this.iridescence = 0;
38-
this.transmission = 0;
39-
4035
this.setDefaultValues( defaultValues );
4136

4237
this.setValues( parameters );

examples/jsm/nodes/materials/NodeMaterial.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ class NodeMaterial extends ShaderMaterial {
253253

254254
}
255255

256-
setDefaultValues( values ) {
256+
setDefaultValues( material ) {
257257

258258
// This approach is to reuse the native refreshUniforms*
259259
// and turn available the use of features like transmission and environment in core
260260

261-
for ( const property in values ) {
261+
for ( const property in material ) {
262262

263-
const value = values[ property ];
263+
const value = material[ property ];
264264

265265
if ( this[ property ] === undefined ) {
266266

@@ -272,7 +272,20 @@ class NodeMaterial extends ShaderMaterial {
272272

273273
}
274274

275-
Object.assign( this.defines, values.defines );
275+
Object.assign( this.defines, material.defines );
276+
277+
const descriptors = Object.getOwnPropertyDescriptors( material.constructor.prototype );
278+
279+
for ( const key in descriptors ) {
280+
281+
if ( Object.getOwnPropertyDescriptor( this.constructor.prototype, key ) === undefined &&
282+
descriptors[ key ].get !== undefined ) {
283+
284+
Object.defineProperty( this.constructor.prototype, key, descriptors[ key ] );
285+
286+
}
287+
288+
}
276289

277290
}
278291

-523 Bytes
Loading

0 commit comments

Comments
 (0)