polygonjs-engine
Version:
node-based webgl 3D engine https://polygonjs.com
35 lines (34 loc) • 1.12 kB
JavaScript
import {TypedEventNode} from "./_Base";
const INPUT_NAME = "in";
const OUTPUT_NAME = "out";
import {NodeParamsConfig, ParamConfig} from "../utils/params/ParamsConfig";
import {EventConnectionPoint, EventConnectionPointType} from "../utils/io/connections/Event";
class TimerEventParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.delay = ParamConfig.INTEGER(1e3);
}
}
const ParamsConfig2 = new TimerEventParamsConfig();
export class DelayEventNode extends TypedEventNode {
constructor() {
super(...arguments);
this.params_config = ParamsConfig2;
}
static type() {
return "delay";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new EventConnectionPoint(INPUT_NAME, EventConnectionPointType.BASE, this._process_input.bind(this))
]);
this.io.outputs.setNamedOutputConnectionPoints([
new EventConnectionPoint(OUTPUT_NAME, EventConnectionPointType.BASE)
]);
}
_process_input(event_context) {
setTimeout(() => {
this.dispatch_event_to_output(OUTPUT_NAME, event_context);
}, this.pv.delay);
}
}