UNPKG

polygonjs-engine

Version:

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

41 lines (40 loc) 1.22 kB
import {TypedCopNode} from "./_Base"; import {InputCloneMode as InputCloneMode2} from "../../poly/InputCloneMode"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; class SwitchCopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.input = ParamConfig.INTEGER(0, { range: [0, 3], rangeLocked: [true, true] }); } } const ParamsConfig2 = new SwitchCopParamsConfig(); export class SwitchCopNode extends TypedCopNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; } static type() { return "switch"; } initializeNode() { this.io.inputs.setCount(0, 4); this.io.inputs.initInputsClonedState(InputCloneMode2.NEVER); this.cookController.disallow_inputs_evaluation(); } async cook() { const input_index = this.pv.input; if (this.io.inputs.has_input(input_index)) { const container = await this.container_controller.requestInputContainer(input_index); if (container) { this.set_texture(container.texture()); return; } } else { this.states.error.set(`no input ${input_index}`); } this.cookController.end_cook(); } }