@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
57 lines (56 loc) • 1.88 kB
JavaScript
;
import { TRIGGER_CONNECTION_NAME, TypedJsNode } from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { JsConnectionPoint, JsConnectionPointType } from "../utils/io/connections/Js";
import { JsType } from "../../poly/registers/nodes/types/Js";
import { nodeMethodName } from "./code/assemblers/actor/ActorAssemblerUtils";
class OnManualTriggerJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
this.trigger = ParamConfig.BUTTON(null, {
cook: false,
callback: (node) => {
OnManualTriggerJsNode.PARAM_CALLBACK_sendTrigger(node);
}
});
}
}
const ParamsConfig = new OnManualTriggerJsParamsConfig();
export class OnManualTriggerJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return JsType.ON_MANUAL_TRIGGER;
}
isTriggering() {
return true;
}
initializeNode() {
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER)
]);
}
static PARAM_CALLBACK_sendTrigger(node) {
node._triggerWithNode();
}
setTriggeringLines(shadersCollectionController, triggeredMethods) {
shadersCollectionController.addTriggeringLines(this, [triggeredMethods], {
gatherable: false,
triggeringMethodName: nodeMethodName(this)
});
}
_triggerWithNode() {
const functionNode = this.functionNode();
if (!functionNode) {
console.warn("no function node found");
return;
}
const actorNode = functionNode;
if (!actorNode.compilationController.evaluatorGenerator()) {
console.warn("no evaluator found");
}
this.scene().actorsManager.manualTriggerController.runTriggerFromFunctionNode(actorNode, nodeMethodName(this));
}
}