@@ -4,43 +4,78 @@ import { Script } from "../../export/Script";
44import  {  BaseColorProperty  }  from  "../../properties/BaseColorProperty" ; 
55import  {  MaterialOutput  }  from  "../../properties/MaterialOutput" ; 
66import  {  WinNode  }  from  "../WinNode" ;  
7+ import  {  InputOrValue  }  from  "../../properties/InputOrValue" ; 
8+ import  {  MeshStandardNodeMaterial ,  NormalMapNode  }  from  "three/webgpu" ; 
9+ import  {  BasicInputProperty  }  from  "../../properties/BasicInputProperty" ; 
710
811export  class  MeshStandardNode  extends  WinNode  { 
912
1013    protected  colorProperty :BaseColorProperty ; 
14+     protected  metallic :InputOrValue ; 
15+     protected  roughness :InputOrValue ; 
16+     protected  normal :BasicInputProperty ; 
1117
1218    constructor ( )  { 
1319
1420        const  colorNodeInput  =  new  BaseColorProperty ( ) ; 
21+         const  metallic  =  new  InputOrValue ( 1 ,  {  label :"Metallic" ,  min :0 ,  max :1 ,  asBar :true  } ) ; 
22+               metallic . multiplyInputWithValue  =  true ; 
1523
16-         super (  "MeshStandardMaterial" ,  Theme . config . groupShader ,  [ 
24+         const  roughness  =  new  InputOrValue ( 1 ,  {  label :"Roughness" ,  min :0 ,  max :1 ,  asBar :true  } ) ; 
25+               roughness . multiplyInputWithValue  =  true ; 
26+ 
27+         const  normal  =  new  BasicInputProperty ( 2 ,  "Normal" ) ; 
28+ 
29+ 
30+         super (  "MeshStandardNodeMaterial" ,  Theme . config . groupShader ,  [ 
1731            new  MaterialOutput ( ) , 
18-             colorNodeInput 
32+             colorNodeInput , 
33+             metallic , 
34+             roughness , 
35+             normal 
1936        ]  ) ; 
2037
2138        this . colorProperty  =  colorNodeInput ; 
39+         this . metallic  =  metallic ; 
40+         this . roughness  =  roughness ; 
41+         this . normal  =  normal ; 
2242    }  
2343
2444    override  writeScript (  script : Script )  {  
2545
2646        const  colorNode  =  this . colorProperty . writeScript (  script  ) ; 
27-   
47+         const  metallicNode  =  this . metallic . writeScript (  script  ) ; 
48+         const  roughnessNode  =  this . roughness . writeScript (  script  ) ;  
49+         const  normalNode  =  this . normal . writeScript (  script  ) ;  
50+ 
51+         //const material = new MeshStandardNodeMaterial();   
52+ 
2853        return  script . define (  this . nodeName ,  `()=>{ 
2954            const material = new THREE.MeshStandardNodeMaterial(); 
3055            material.colorNode = ${ colorNode }  
56+ 
57+             material.metalnessNode = ${ metallicNode }  
58+             material.roughnessNode = ${ roughnessNode }  
59+ ${  normalNode != "" ? `material.normalNode = ${ normalNode }  :""  } 
60+ 
3161            return material; 
3262        }`  ) ; 
3363    } 
3464
3565    override  serialize ( ) : Record < string ,  any >  { 
3666        return  { 
3767            ...super . serialize ( ) , 
38-             baseColor : "#" + this . colorProperty . baseColor . getHexString ( ) 
68+             baseColor : "#" + this . colorProperty . baseColor . getHexString ( ) , 
69+             metallic : this . metallic . value , 
70+             roughness : this . roughness . value 
3971        } 
4072    } 
4173
4274    override  unserialize ( data : Record < string ,  any > ) : void { 
4375        super . unserialize ( data ) ; 
4476        if (  data . baseColor  )  this . colorProperty . baseColor  =  new  Color (  data . baseColor  ) ; 
77+ 
78+         this . metallic . value  =  data . metallic ; 
79+         this . roughness . value  =  data . roughness ; 
4580    } 
4681} 
0 commit comments