@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
58 lines • 2.24 kB
TypeScript
/**
* The blend math an adapter performs. Read by higher-level wiring to
* decide whether the adapter is compatible with the current rendering
* pipeline.
*/
export type InterpolationKind = number;
/**
* The blend math an adapter performs. Read by higher-level wiring to
* decide whether the adapter is compatible with the current rendering
* pipeline.
*
* @readonly
* @enum {number}
*/
export const InterpolationKind: Readonly<{
/** No blending — output is one of the two snapshots exactly. */
Discrete: 0;
/** Linear blend at fractional `t ∈ [0, 1]` between two snapshots. */
Linear: 1;
/** Cubic between four samples. Reserved; not yet supported. */
Cubic: 2;
}>;
/**
* Per-component-type interpolator: reads two encoded snapshots of one
* component from `source`, blends by `t`, writes the result to
* `out_buffer` in the SAME wire format so the receiver can deserialize
* directly via the corresponding `BinaryClassSerializationAdapter`.
*
* Pair with {@link InterpolationLog}, which resolves
* `(network_id, type_id, tick) → byte offset` so the adapter only sees
* offsets.
*
* Subclasses override `kind` if their blend math is non-linear; the
* default is `Linear`.
*
* @author Alex Goldring
* @copyright Company Named Limited (c) 2025
*/
export class BinaryInterpolationAdapter {
/** @type {number} one of {@link InterpolationKind} */
kind: number;
/**
* Advance `out_buffer.position` past the bytes written. `source.position`
* may be mutated freely (the log restores it).
*
* `first_offset === second_offset` is the degenerate "snap to single
* snapshot" case — implementations don't need to special-case it; the
* blend at any `t` reduces to the input.
*
* @param {BinaryBuffer} out_buffer
* @param {BinaryBuffer} source
* @param {number} first_offset byte position of snapshot A
* @param {number} second_offset byte position of snapshot B
* @param {number} t blend fraction in [0, 1]; 0 ⇒ A, 1 ⇒ B
*/
interpolate(out_buffer: BinaryBuffer, source: BinaryBuffer, first_offset: number, second_offset: number, t: number): void;
}
//# sourceMappingURL=BinaryInterpolationAdapter.d.ts.map