UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

97 lines (94 loc) 4.52 kB
import { c3 as ExponentialEase, c4 as ElasticEase, c5 as CubicEase, c6 as BounceEase, c7 as BackEase, c8 as CircleEase, c9 as BezierCurveEase, R as RegisterClass } from './index-FzOfPXLV.esm.js'; import { F as FlowGraphBlock } from './KHR_interactivity-Bmb38TjL.esm.js'; import { R as RichTypeAny, f as RichTypeNumber } from './declarationMapper-rcGCdcDP.esm.js'; import './objectModelMapping-CJnQ6at_.esm.js'; /** * The type of the easing function. */ var EasingFunctionType; (function (EasingFunctionType) { EasingFunctionType[EasingFunctionType["CircleEase"] = 0] = "CircleEase"; EasingFunctionType[EasingFunctionType["BackEase"] = 1] = "BackEase"; EasingFunctionType[EasingFunctionType["BounceEase"] = 2] = "BounceEase"; EasingFunctionType[EasingFunctionType["CubicEase"] = 3] = "CubicEase"; EasingFunctionType[EasingFunctionType["ElasticEase"] = 4] = "ElasticEase"; EasingFunctionType[EasingFunctionType["ExponentialEase"] = 5] = "ExponentialEase"; EasingFunctionType[EasingFunctionType["PowerEase"] = 6] = "PowerEase"; EasingFunctionType[EasingFunctionType["QuadraticEase"] = 7] = "QuadraticEase"; EasingFunctionType[EasingFunctionType["QuarticEase"] = 8] = "QuarticEase"; EasingFunctionType[EasingFunctionType["QuinticEase"] = 9] = "QuinticEase"; EasingFunctionType[EasingFunctionType["SineEase"] = 10] = "SineEase"; EasingFunctionType[EasingFunctionType["BezierCurveEase"] = 11] = "BezierCurveEase"; })(EasingFunctionType || (EasingFunctionType = {})); /** * @internal * Creates an easing function object based on the type and parameters provided. * This is not tree-shaking friendly, so if you need cubic bezier, use the dedicated bezier block. * @param type The type of the easing function. * @param controlPoint1 The first control point for the bezier curve. * @param controlPoint2 The second control point for the bezier curve. * @returns The easing function object. */ function CreateEasingFunction(type, ...parameters) { switch (type) { case 11 /* EasingFunctionType.BezierCurveEase */: return new BezierCurveEase(...parameters); case 0 /* EasingFunctionType.CircleEase */: return new CircleEase(); case 1 /* EasingFunctionType.BackEase */: return new BackEase(...parameters); case 2 /* EasingFunctionType.BounceEase */: return new BounceEase(...parameters); case 3 /* EasingFunctionType.CubicEase */: return new CubicEase(); case 4 /* EasingFunctionType.ElasticEase */: return new ElasticEase(...parameters); case 5 /* EasingFunctionType.ExponentialEase */: return new ExponentialEase(...parameters); default: throw new Error("Easing type not yet implemented"); } } /** * An easing block that generates an easingFunction object based on the data provided. */ class FlowGraphEasingBlock extends FlowGraphBlock { constructor( /** * the configuration of the block */ config) { super(config); this.config = config; /** * Internal cache of reusable easing functions. * key is type-mode-properties */ this._easingFunctions = {}; this.type = this.registerDataInput("type", RichTypeAny, 11); this.mode = this.registerDataInput("mode", RichTypeNumber, 0); this.parameters = this.registerDataInput("parameters", RichTypeAny, [1, 0, 0, 1]); this.easingFunction = this.registerDataOutput("easingFunction", RichTypeAny); } _updateOutputs(context) { const type = this.type.getValue(context); const mode = this.mode.getValue(context); const parameters = this.parameters.getValue(context); if (type === undefined || mode === undefined) { return; } const key = `${type}-${mode}-${parameters.join("-")}`; if (!this._easingFunctions[key]) { const easing = CreateEasingFunction(type, ...parameters); easing.setEasingMode(mode); this._easingFunctions[key] = easing; } this.easingFunction.setValue(this._easingFunctions[key], context); } getClassName() { return "FlowGraphEasingBlock" /* FlowGraphBlockNames.Easing */; } } RegisterClass("FlowGraphEasingBlock" /* FlowGraphBlockNames.Easing */, FlowGraphEasingBlock); export { EasingFunctionType, FlowGraphEasingBlock }; //# sourceMappingURL=flowGraphEasingBlock-B6PcN8uo.esm.js.map