UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

69 lines (68 loc) 2.82 kB
"use strict"; import { TRIGGER_CONNECTION_NAME } from "./_Base"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { JsConnectionPoint, JsConnectionPointType, JS_CONNECTION_POINT_IN_NODE_DEF } from "../utils/io/connections/Js"; import { TypedJsNode } from "./_Base"; import { Poly } from "../../Poly"; const CONNECTION_OPTIONS = JS_CONNECTION_POINT_IN_NODE_DEF; export var AnimationActionCrossFadeJsNodeInputName = /* @__PURE__ */ ((AnimationActionCrossFadeJsNodeInputName2) => { AnimationActionCrossFadeJsNodeInputName2["FROM"] = "from"; AnimationActionCrossFadeJsNodeInputName2["TO"] = "to"; return AnimationActionCrossFadeJsNodeInputName2; })(AnimationActionCrossFadeJsNodeInputName || {}); class AnimationActionCrossFadeJsParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param fadeIn duration */ this.duration = ParamConfig.FLOAT(1); /** @param additional warping (gradually changes of the time scales) will be applied */ this.warp = ParamConfig.BOOLEAN(1); /** @param starts cross fade when the from action ends */ this.startOnFromActionEnd = ParamConfig.BOOLEAN(1); } } const ParamsConfig = new AnimationActionCrossFadeJsParamsConfig(); export class AnimationActionCrossFadeJsNode extends TypedJsNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "animationActionCrossFade"; } initializeNode() { this.io.inputs.setNamedInputConnectionPoints([ new JsConnectionPoint(TRIGGER_CONNECTION_NAME, JsConnectionPointType.TRIGGER, CONNECTION_OPTIONS), new JsConnectionPoint( "from" /* FROM */, JsConnectionPointType.ANIMATION_ACTION, CONNECTION_OPTIONS ), new JsConnectionPoint( "to" /* TO */, JsConnectionPointType.ANIMATION_ACTION, CONNECTION_OPTIONS ) ]); } setTriggerableLines(shadersCollectionController) { const actionFrom = this.variableForInput( shadersCollectionController, "from" /* FROM */ ); const actionTo = this.variableForInput(shadersCollectionController, "to" /* TO */); const duration = this.variableForInputParam(shadersCollectionController, this.p.duration); const warp = this.variableForInputParam(shadersCollectionController, this.p.warp); const startOnFromActionEnd = this.variableForInputParam( shadersCollectionController, this.p.startOnFromActionEnd ); const func = Poly.namedFunctionsRegister.getFunction( "animationActionCrossFade", this, shadersCollectionController ); const bodyLine = func.asString(actionFrom, `()=>${actionTo}`, duration, warp, startOnFromActionEnd); shadersCollectionController.addTriggerableLines(this, [bodyLine]); } }