BlendEditor.js 926 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { ObjectNode, LabelElement } from '../../libs/flow.module.js';
  2. import { MathNode, FloatNode } from '../../renderers/nodes/Nodes.js';
  3. const NULL_VALUE = new FloatNode();
  4. const ONE_VALUE = new FloatNode( 1 );
  5. export class BlendEditor extends ObjectNode {
  6. constructor() {
  7. const node = new MathNode( MathNode.MIX, NULL_VALUE, NULL_VALUE, ONE_VALUE );
  8. super( 'Blend', 3, node );
  9. const aElement = new LabelElement( 'Base' ).setInput( 3 );
  10. const bElement = new LabelElement( 'Blend' ).setInput( 3 );
  11. const cElement = new LabelElement( 'Opacity' ).setInput( 1 );
  12. aElement.onConnect( () => {
  13. node.aNode = aElement.linkedExtra || NULL_VALUE;
  14. } );
  15. bElement.onConnect( () => {
  16. node.bNode = bElement.linkedExtra || NULL_VALUE;
  17. } );
  18. cElement.onConnect( () => {
  19. node.cNode = cElement.linkedExtra || ONE_VALUE;
  20. } );
  21. this.add( aElement )
  22. .add( bElement )
  23. .add( cElement );
  24. }
  25. }