@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
64 lines (63 loc) • 2.59 kB
JavaScript
"use strict";
import {
TypedJsNode
} from "./_Base";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { TRIGGER_CONNECTION_NAME } from "./_Base";
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 AnimationActionFadeInJsParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param fadeIn duration */
this.duration = ParamConfig.FLOAT(1);
/** @param fade out other actions */
this.fadeOutOtherActions = ParamConfig.BOOLEAN(1);
/** @param additional warping (gradually changes of the time scales) will be applied */
this.warp = ParamConfig.BOOLEAN(1, {
visibleIf: { fadeOutOtherActions: 1 }
});
/** @param starts cross fade when the from action ends */
this.startOnFromActionEnd = ParamConfig.BOOLEAN(1, {
visibleIf: { fadeOutOtherActions: 1 }
});
}
}
const ParamsConfig = new AnimationActionFadeInJsParamsConfig();
export class AnimationActionFadeInJsNode extends TypedJsNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return "animationActionFadeIn";
}
initializeNode() {
this.io.inputs.setNamedInputConnectionPoints([
new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS),
new JsConnectionPoint(
JsConnectionPointType.ANIMATION_ACTION,
JsConnectionPointType.ANIMATION_ACTION,
CONNECTION_OPTIONS
)
]);
}
setTriggerableLines(shadersCollectionController) {
const action = this.variableForInput(shadersCollectionController, JsConnectionPointType.ANIMATION_ACTION);
const duration = this.variableForInputParam(shadersCollectionController, this.p.duration);
const fadeOutOtherActions = this.variableForInputParam(shadersCollectionController, this.p.fadeOutOtherActions);
const warp = this.variableForInputParam(shadersCollectionController, this.p.warp);
const startOnFromActionEnd = this.variableForInputParam(
shadersCollectionController,
this.p.startOnFromActionEnd
);
const func = Poly.namedFunctionsRegister.getFunction(
"animationActionFadeIn",
this,
shadersCollectionController
);
const bodyLine = func.asString(action, duration, fadeOutOtherActions, warp, startOnFromActionEnd);
shadersCollectionController.addTriggerableLines(this, [bodyLine]);
}
}