فهرست منبع

NodeMaterial.fromMaterial(): Support copying getters and setters (#25861)

* NodeMaterial.fromMaterial(): Support copying getters and setters

* Fix

* update screenshot

* Fix

---------

Co-authored-by: sunag <[email protected]>
Levi Pesin 2 سال پیش
والد
کامیت
64c8d59ac9

+ 0 - 5
examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js

@@ -32,11 +32,6 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
 		this.attenuationDistanceNode = null;
 		this.attenuationColorNode = null;
 
-		this.sheen = 0;
-		this.clearcoat = 0;
-		this.iridescence = 0;
-		this.transmission = 0;
-
 		this.setDefaultValues( defaultValues );
 
 		this.setValues( parameters );

+ 17 - 4
examples/jsm/nodes/materials/NodeMaterial.js

@@ -253,14 +253,14 @@ class NodeMaterial extends ShaderMaterial {
 
 	}
 
-	setDefaultValues( values ) {
+	setDefaultValues( material ) {
 
 		// This approach is to reuse the native refreshUniforms*
 		// and turn available the use of features like transmission and environment in core
 
-		for ( const property in values ) {
+		for ( const property in material ) {
 
-			const value = values[ property ];
+			const value = material[ property ];
 
 			if ( this[ property ] === undefined ) {
 
@@ -272,7 +272,20 @@ class NodeMaterial extends ShaderMaterial {
 
 		}
 
-		Object.assign( this.defines, values.defines );
+		Object.assign( this.defines, material.defines );
+
+		const descriptors = Object.getOwnPropertyDescriptors( material.constructor.prototype );
+
+		for ( const key in descriptors ) {
+
+			if ( Object.getOwnPropertyDescriptor( this.constructor.prototype, key ) === undefined &&
+			     descriptors[ key ].get !== undefined ) {
+
+				Object.defineProperty( this.constructor.prototype, key, descriptors[ key ] );
+
+			}
+
+		}
 
 	}
 

BIN
examples/screenshots/webgl_nodes_loader_gltf_iridescence.jpg