@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
41 lines (40 loc) • 1.58 kB
JavaScript
;
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js";
import { Poly } from "../../Poly";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
class TriggerDelayJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param delay (in milliseconds) */
this.delay = ParamConfig.FLOAT(1e3, {
range: [0, 1e4],
rangeLocked: [true, false]
});
}
}
const ParamsConfig = new TriggerDelayJsParamsConfig();
export class TriggerDelayJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "triggerDelay";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER)
]);
}
setTriggerableLines(shadersCollectionController) {
const delay = this.variableForInputParam(shadersCollectionController, this.p.delay);
const func = Poly.namedFunctionsRegister.getFunction("sleep", this, shadersCollectionController);
const bodyLine = func.asString(delay);
shadersCollectionController.addTriggerableLines(this, [bodyLine], { async: true });
}
}