calculate是Yuka js库中的一个方法,它属于FollowPathBehavior行为类。该方法可以计算一个物体沿着指定路径行进时的变化量以及到达目标点的时间。
calculate( entity, delta )
entity:Object - 必需。要计算路径的实体对象。delta:Number - 必需。统计帧时间的变量,单位为毫秒。此方法不返回任何值;取而代之的是,它将targetPosition和time属性设置为行进的目标位置和到达目标位置的时间。
const entity = new Entity();
const followPathBehavior = new FollowPathBehavior( path );
entity.setBehavior( followPathBehavior );
function animate() {
  const delta = clock.getDelta() * 1000;
  followPathBehavior.calculate( entity, delta );
  renderer.render( scene, camera );
}
FOLLOWPATH_START_DELAY属性。 该属性的默认值是1000ms。targetPosition属性等于endPoint属性而time属性将等于指定路径的总时间。