BabylonJS/Babylon.js · error · Error

You must implement this method

Error message

You must implement this method

What it means

EasingFunction.easeInCore is the abstract core of Babylon's easing system; the base class provides ease() which delegates to easeInCore. The base implementation throws 'You must implement this method' to signal that a concrete easing function subclass did not override it.

Source

Thrown at packages/dev/core/src/Animations/easing.ts:63

     */
    public setEasingMode(easingMode: number) {
        const n = Math.min(Math.max(easingMode, 0), 2);
        this._easingMode = n;
    }
    /**
     * Gets the current easing mode.
     * @returns the easing mode
     */
    public getEasingMode(): number {
        return this._easingMode;
    }

    /**
     * @internal
     */
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    public easeInCore(gradient: number): number {
        throw new Error("You must implement this method");
    }

    /**
     * Given an input gradient between 0 and 1, this returns the corresponding value
     * of the easing function.
     * @param gradient Defines the value between 0 and 1 we want the easing value for
     * @returns the corresponding value on the curve defined by the easing function
     */
    public ease(gradient: number): number {
        switch (this._easingMode) {
            case EasingFunction.EASINGMODE_EASEIN:
                return this.easeInCore(gradient);
            case EasingFunction.EASINGMODE_EASEOUT:
                return 1 - this.easeInCore(1 - gradient);
        }

        if (gradient >= 0.5) {
            return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Use a built-in easing class (CubicEase, QuadraticEase, BackEase, etc.) instead of the base EasingFunction
  2. In a custom subclass, override easeInCore(gradient: number): number and return the eased value
  3. Add @Override-style linting/tests so missing overrides are caught early

Example fix

// before
class MyEase extends EasingFunction { }
// after
class MyEase extends EasingFunction {
    public easeInCore(gradient: number): number {
        return gradient * gradient;
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

function isUsableEasing(e: EasingFunction): boolean {
    return e.constructor !== EasingFunction || e.easeInCore(0.5) !== undefined;
}

Type guard

function hasEaseInCore(e: unknown): e is Required<Pick<EasingFunction, 'easeInCore'>> {
    return e instanceof EasingFunction &&
        e.constructor !== EasingFunction &&
        typeof (e as any).easeInCore === 'function';
}

Try / catch

try {
    anim.setEasingFunction(myEase);
    scene.beginAnimation(target, 0, 100);
} catch (e) {
    if (e.message.includes("You must implement this method")) {
        anim.setEasingFunction(new CubicEase()); // fallback to built-in
    }
}

Prevention

When it happens

Trigger: Instantiating EasingFunction (or a custom subclass) directly and using it in an Animation, or writing a custom easing subclass that forgets to override easeInCore, then playing an animation that calls ease().

Common situations: Custom easing implementations missing the override; passing new EasingFunction() instead of a concrete one like CubicEase or QuadraticEase; TypeScript not catching it because the base method is public and concrete.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/f25640729212f821. Report an issue: GitHub.