Skip to content

Commit

Permalink
NodeEditor: Add vertex position input (#23311)
Browse files Browse the repository at this point in the history
Thanks!
  • Loading branch information
fyoudine authored Jan 24, 2022
1 parent 6c89ee2 commit a3ce4c9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions examples/jsm/node-editor/materials/StandardMaterialEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class StandardMaterialEditor extends BaseNode {
const opacity = new LabelElement( 'opacity' ).setInput( 1 );
const metalness = new LabelElement( 'metalness' ).setInput( 1 );
const roughness = new LabelElement( 'roughness' ).setInput( 1 );
const position = new LabelElement( 'position' ).setInput( 3 );

color.add( new ColorInput( material.color.getHex() ).onChange( ( input ) => {

Expand Down Expand Up @@ -48,16 +49,19 @@ export class StandardMaterialEditor extends BaseNode {
opacity.onConnect( () => this.update(), true );
metalness.onConnect( () => this.update(), true );
roughness.onConnect( () => this.update(), true );
position.onConnect(() => this.update(), true );

this.add( color )
.add( opacity )
.add( metalness )
.add( roughness );
.add( roughness )
.add( position );

this.color = color;
this.opacity = opacity;
this.metalness = metalness;
this.roughness = roughness;
this.position = position;

this.material = material;

Expand All @@ -67,20 +71,20 @@ export class StandardMaterialEditor extends BaseNode {

update() {

const { material, color, opacity, roughness, metalness } = this;
const { material, color, opacity, roughness, metalness, position } = this;

color.setEnabledInputs( ! color.getLinkedObject() );
opacity.setEnabledInputs( ! opacity.getLinkedObject() );
roughness.setEnabledInputs( ! roughness.getLinkedObject() );
metalness.setEnabledInputs( ! metalness.getLinkedObject() );

material.colorNode = color.getLinkedObject();

material.opacityNode = opacity.getLinkedObject() || null;

material.metalnessNode = metalness.getLinkedObject();
material.roughnessNode = roughness.getLinkedObject();

material.positionNode = position.getLinkedObject() || null;

material.dispose();

this.updateTransparent();
Expand Down

0 comments on commit a3ce4c9

Please sign in to comment.