UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

69 lines (68 loc) 2.53 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { AttribClassMenuEntries, ATTRIBUTE_CLASSES } from "../../../core/geometry/Constant"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { AudioNotesSopOperation, OUT_OF_RANGE_BEHAVIOR } from "../../operations/sop/AudioNotes"; import { SopType } from "../../poly/registers/nodes/types/Sop"; const DEFAULT = AudioNotesSopOperation.DEFAULT_PARAMS; class AudioNotesSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param the attribute class (geometry or object) */ this.class = ParamConfig.INTEGER(DEFAULT.class, { menu: { entries: AttribClassMenuEntries } }); /** @param attribute name */ this.name = ParamConfig.STRING(DEFAULT.name); /** @param adds an octave attribute */ this.toctave = ParamConfig.BOOLEAN(0); /** @param octave attribute name */ this.octaveName = ParamConfig.STRING(DEFAULT.octaveName, { visibleIf: { toctave: 1 } }); /** @param octave to start iterating the notes from */ this.startOctave = ParamConfig.INTEGER(DEFAULT.startOctave, { range: [1, 8], rangeLocked: [true, true] }); /** @param last octave up to which the nodes will be added */ this.endOctave = ParamConfig.INTEGER(DEFAULT.endOctave, { range: [1, 8], rangeLocked: [true, true] }); /** @param behavior if there are more objects than notes within the selected octave range */ this.outOfRangeBehavior = ParamConfig.INTEGER(DEFAULT.outOfRangeBehavior, { menu: { entries: OUT_OF_RANGE_BEHAVIOR.map((name, i) => { return { value: i, name }; }) } }); } } const ParamsConfig = new AudioNotesSopParamsConfig(); export class AudioNotesSopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.AUDIO_NOTES; } initializeNode() { this.io.inputs.setCount(1); this.io.inputs.initInputsClonedState(AudioNotesSopOperation.INPUT_CLONED_STATE); } cook(input_contents) { this._operation = this._operation || new AudioNotesSopOperation(this.scene(), this.states, this); const core_group = this._operation.cook(input_contents, this.pv); this.setCoreGroup(core_group); } // // // API UTILS // // setAttribClass(attribClass) { this.p.class.set(ATTRIBUTE_CLASSES.indexOf(attribClass)); } attribClass() { return ATTRIBUTE_CLASSES[this.pv.class]; } }