You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
994 B
43 lines
994 B
import { SelectInput, LabelElement, Element } from '../../libs/flow.module.js';
|
|
import { BaseNode } from '../core/BaseNode.js';
|
|
import { OscNode, UniformNode } from 'three/nodes';
|
|
|
|
const NULL_VALUE = new UniformNode( 0 );
|
|
|
|
export class OscillatorEditor extends BaseNode {
|
|
|
|
constructor() {
|
|
|
|
const node = new OscNode( OscNode.SINE, NULL_VALUE );
|
|
|
|
super( 'Oscillator', 1, node, 175 );
|
|
|
|
const methodInput = new SelectInput( [
|
|
{ name: 'Sine', value: OscNode.SINE },
|
|
{ name: 'Square', value: OscNode.SQUARE },
|
|
{ name: 'Triangle', value: OscNode.TRIANGLE },
|
|
{ name: 'Sawtooth', value: OscNode.SAWTOOTH }
|
|
], OscNode.SINE );
|
|
|
|
methodInput.onChange( () => {
|
|
|
|
node.method = methodInput.getValue();
|
|
|
|
this.invalidate();
|
|
|
|
} );
|
|
|
|
const timeElement = new LabelElement( 'Time' ).setInput( 1 );
|
|
|
|
timeElement.onConnect( () => {
|
|
|
|
node.timeNode = timeElement.getLinkedObject() || NULL_VALUE;
|
|
|
|
} );
|
|
|
|
this.add( new Element().add( methodInput ) )
|
|
.add( timeElement );
|
|
|
|
}
|
|
|
|
}
|
|
|