Interpolant.evaluate() 方法在插值器中插值给定时间(或位置)的值。它被用于在动画中平滑地过渡对象的属性值。
interpolant.evaluate(delta: Number)
delta: Number - 需要插值的时间或位置。value: * - 在给定时间或位置插值后的结果。const times = [0, 1, 2];
const values = [10, 20, 30];
const linearInterpolant = new THREE.LinearInterpolant(times, values, 1);
const result = linearInterpolant.evaluate(1.5);
console.log(result); // 25
TypeError - 如果 delta 参数无效,抛出类型错误异常。如果要更改 evaluate() 方法返回的值,可以继承并覆盖该类的 interpolate_() 方法。
THREE.Interpolant.prototype = {
interpolate_: function (i1, t0, t, t1) {
// 实现自定义方法的代码
},
evaluate: function (t) {
// 调用 interpolate_() 方法
return this.resultBuffer;
}
};