UNPKG

polygonjs-engine

Version:

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

48 lines (47 loc) 1.44 kB
import {TypedSopNode} from "./_Base"; const INPUT_NAME = "geometry to switch to"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; import {InputCloneMode as InputCloneMode2} from "../../poly/InputCloneMode"; class SwitchSopParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.input = ParamConfig.INTEGER(0, { range: [0, 3], rangeLocked: [true, true] }); } } const ParamsConfig2 = new SwitchSopParamsConfig(); export class SwitchSopNode extends TypedSopNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; } static type() { return "switch"; } static displayedInputNames() { return [INPUT_NAME, INPUT_NAME, INPUT_NAME, INPUT_NAME]; } 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) { const core_group = container.coreContent(); if (core_group) { this.setCoreGroup(core_group); return; } } } else { this.states.error.set(`no input ${input_index}`); } this.cookController.end_cook(); } }