UNPKG

@polygonjs/polygonjs

Version:

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

47 lines (46 loc) 1.51 kB
"use strict"; import { TypedAnimNode } from "./_Base"; import { TimelineBuilder } from "../../../core/animation/TimelineBuilder"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { isBooleanTrue } from "../../../core/BooleanValue"; class RepeatAnimParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param sets if it should repeat indefinitely */ this.unlimited = ParamConfig.BOOLEAN(0); /** @param number of times the animation should repeat */ this.count = ParamConfig.INTEGER(1, { range: [0, 10], visibleIf: { unlimited: 0 } }); /** @param delay */ this.delay = ParamConfig.FLOAT(0); /** @param sets if the animation should go back and forth at each repeat */ this.yoyo = ParamConfig.BOOLEAN(0); } } const ParamsConfig = new RepeatAnimParamsConfig(); export class RepeatAnimNode extends TypedAnimNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "repeat"; } initializeNode() { this.io.inputs.setCount(0, 1); } _repeat_params() { return { count: isBooleanTrue(this.pv.unlimited) ? -1 : this.pv.count, delay: this.pv.delay, yoyo: isBooleanTrue(this.pv.yoyo) }; } cook(input_contents) { const timeline_builder = input_contents[0] || new TimelineBuilder(); timeline_builder.setRepeatParams(this._repeat_params()); this.setTimelineBuilder(timeline_builder); } }