UNPKG

polygonjs-engine

Version:

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

45 lines (44 loc) 1.5 kB
import {TypedEventNode} from "./_Base"; import {EventConnectionPoint, EventConnectionPointType} from "../utils/io/connections/Event"; import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig"; class BlockParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); this.blocking = ParamConfig.BOOLEAN(1); } } const ParamsConfig2 = new BlockParamsConfig(); const BlockEventNode2 = class extends TypedEventNode { constructor() { super(...arguments); this.params_config = ParamsConfig2; } static type() { return "block"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new EventConnectionPoint("in", EventConnectionPointType.BASE, this._process_incoming_event.bind(this)) ]); this.io.outputs.setNamedOutputConnectionPoints([ new EventConnectionPoint(BlockEventNode2.OUTPUT, EventConnectionPointType.BASE) ]); this.scene().dispatchController.onAddListener(() => { this.params.onParamsCreated("params_label", () => { this.params.label.init([this.p.blocking], () => { return this.pv.blocking ? "blocking (X)" : "pass-through (-->)"; }); }); }); } trigger_output(context) { this.dispatch_event_to_output(BlockEventNode2.OUTPUT, context); } _process_incoming_event(context) { if (!this.pv.blocking) { this.trigger_output(context); } } }; export let BlockEventNode = BlockEventNode2; BlockEventNode.OUTPUT = "output";