@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
38 lines (33 loc) • 1.16 kB
JavaScript
import { lerp } from "../../../math/lerp.js";
import { plane3_normalize } from "./plane3_normalize.js";
/**
* Interpolate between two planes in linear space.
*
* Note: It does not work for planes that are parallel with opposing normals. There is no valid solution, as the number of such planes would be infinite.
* @param {number[]} destination
* @param {number} destination_offset
* @param {number} a_normal_x
* @param {number} a_normal_y
* @param {number} a_normal_z
* @param {number} a_constant
* @param {number} b_normal_x
* @param {number} b_normal_y
* @param {number} b_normal_z
* @param {number} b_constant
* @param {number} t
*/
export function plane3_lerp(
destination, destination_offset,
a_normal_x, a_normal_y, a_normal_z, a_constant,
b_normal_x, b_normal_y, b_normal_z, b_constant,
t
) {
const nx = lerp(a_normal_x, b_normal_x, t);
const ny = lerp(a_normal_y, b_normal_y, t);
const nz = lerp(a_normal_z, b_normal_z, t);
const c = lerp(a_constant, b_constant, t);
plane3_normalize(
destination, destination_offset,
nx, ny, nz, c
);
}