@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
59 lines (58 loc) • 2.36 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 { NodeContext } from "../../poly/NodeContext";
import { inputObject3D } from "./_BaseObject3D";
import { Poly } from "../../Poly";
import { ModuleName } from "../../poly/registers/modules/Common";
const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF;
export var AnimationJsOutput = /* @__PURE__ */ ((AnimationJsOutput2) => {
AnimationJsOutput2["START"] = "start";
AnimationJsOutput2["COMPLETE"] = "completed";
return AnimationJsOutput2;
})(AnimationJsOutput || {});
class PlayAnimationJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param include children */
this.node = ParamConfig.NODE_PATH("", {
nodeSelection: { context: NodeContext.ANIM },
dependentOnFoundNode: false
});
}
}
const ParamsConfig = new PlayAnimationJsParamsConfig();
export class PlayAnimationJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "playAnimation";
}
requiredModules() {
return [ModuleName.GSAP];
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS),
new JsConnectionPoint(JsConnectionPointType.OBJECT_3D, JsConnectionPointType.OBJECT_3D, CONNECTION_OPTIONS)
]);
this.io.outputs.setNamedOutputConnectionPoints([
new JsConnectionPoint("start" /* START */, JsConnectionPointType.TRIGGER),
new JsConnectionPoint("completed" /* COMPLETE */, JsConnectionPointType.TRIGGER)
]);
}
setTriggerableLines(shadersCollectionController) {
const object3D = inputObject3D(this, shadersCollectionController);
const node = this.pv.node.node();
if (!node) {
return;
}
const nodePath = `'${node.path()}'`;
const func = Poly.namedFunctionsRegister.getFunction("playAnimation", this, shadersCollectionController);
const bodyLine = func.asString(object3D, nodePath);
shadersCollectionController.addTriggerableLines(this, [bodyLine]);
}
}