pub struct CurvePath<P: CurveVector> {
pub curves: Vec<CurveRef<P>>,
pub auto_close: bool,
pub arc_length_divisions: usize,
pub needs_update: Cell<bool>,
/* private fields */
}Expand description
CurvePath: a sequence of connected curves, itself a Curve.
§The two caches
CurvePath.getPoint( t ) is built on getLength(), which sums every
sub-curve’s length, and the inherited getPointAt( u ) maps u through
getLengths(), which calls getPoint 201 times. Uncached that is
quadratic, so unlike the leaf curves (see super::curve) this keeps
both of three.js’ caches, with three.js’ own invalidation rules:
cacheLengths(the per-curve running sums,getCurveLengths()) is reused while it has one entry per curve, so adding a curve refreshes it;cacheArcLengths(Curve.getLengths()) is reused while it hasdivisions + 1entries andneedsUpdateis unset. Adding a curve does not refresh it — in three.js either — soget_point_atafter a laterline_tomaps through the old path’s arc lengths untilupdate_arc_lengthsis called. That is reproduced on purpose: it is what three.js computes.
Fields§
§curves: Vec<CurveRef<P>>The curves, in order.
auto_close: boolWhether the path should automatically be closed by a line curve.
arc_length_divisions: usizeCurve.arcLengthDivisions, default 200.
needs_update: Cell<bool>this.needsUpdate.
Implementations§
Source§impl<P: CurveVector> CurvePath<P>
impl<P: CurveVector> CurvePath<P>
Sourcepub fn update_arc_lengths(&self)
pub fn update_arc_lengths(&self)
CurvePath.updateArcLengths().
Sourcepub fn get_curve_lengths(&self) -> Vec<f64>
pub fn get_curve_lengths(&self) -> Vec<f64>
CurvePath.getCurveLengths(): the running sum of the sub-curves’
lengths, cached while the curve count is unchanged.
Source§impl<P: LineVector> CurvePath<P>
impl<P: LineVector> CurvePath<P>
Sourcepub fn close_path(&mut self) -> &mut Self
pub fn close_path(&mut self) -> &mut Self
CurvePath.closePath(): adds a line curve back to the start if the
path does not already end there.
Trait Implementations§
Source§impl<P: CurveVector> Clone for CurvePath<P>
impl<P: CurveVector> Clone for CurvePath<P>
Source§impl<P: CurveVector> Curve for CurvePath<P>
impl<P: CurveVector> Curve for CurvePath<P>
Source§fn get_point(&self, t: f64) -> P
fn get_point(&self, t: f64) -> P
CurvePath.getPoint( t ).
§Panics
Where three.js returns null: when t * getLength() lies past the last
curve (t > 1, or an empty path).
Source§fn get_length(&self) -> f64
fn get_length(&self) -> f64
CurvePath.getLength().
We cannot use the default THREE.Curve getPoint() with getLength() because in THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath getPoint() depends on getLength
Source§fn get_lengths(&self, divisions: usize) -> Vec<f64>
fn get_lengths(&self, divisions: usize) -> Vec<f64>
Curve.getLengths( divisions ) with its cacheArcLengths cache; see
the type’s doc.
Source§fn get_spaced_points(&self, divisions: usize) -> Vec<P>
fn get_spaced_points(&self, divisions: usize) -> Vec<P>
CurvePath.getSpacedPoints( divisions ): getPoint, not getPointAt,
at even t, plus the first point again when autoClose is set.
Source§fn get_points(&self, divisions: usize) -> Vec<P>
fn get_points(&self, divisions: usize) -> Vec<P>
CurvePath.getPoints( divisions ): each curve sampled at its own
resolution (Curve::curve_path_resolution), consecutive duplicates
dropped.
Source§fn arc_length_divisions(&self) -> usize
fn arc_length_divisions(&self) -> usize
Curve.arcLengthDivisions, default 200.Source§fn curve_path_resolution(&self, divisions: usize) -> usize
fn curve_path_resolution(&self, divisions: usize) -> usize
CurvePath.getPoints( divisions ) asks this curve
for. three.js writes it as a chain of brand checks in CurvePath:
isEllipseCurve doubles it, isLineCurve / isLineCurve3 use 1 and
isSplineCurve multiplies by its point count; every other curve uses
divisions as given. Here each of those subclasses overrides this.Source§fn is_closed_catmull_rom(&self) -> bool
fn is_closed_catmull_rom(&self) -> bool
extrudePath.isCatmullRomCurve3 ? extrudePath.closed : false — the one
place three.js reads a subclass’ closed generically
(ExtrudeGeometry). Only CatmullRomCurve3
overrides it.Source§fn get_point_at(&self, u: f64) -> Self::Point
fn get_point_at(&self, u: f64) -> Self::Point
Curve.getPointAt( u, optionalTarget ).Source§fn get_u_to_t_mapping(&self, u: f64, distance: Option<f64>) -> f64
fn get_u_to_t_mapping(&self, u: f64, distance: Option<f64>) -> f64
Curve.getUtoTmapping( u, distance ), statement for statement.Source§fn get_tangent(&self, t: f64) -> Self::Point
fn get_tangent(&self, t: f64) -> Self::Point
Curve.getTangent( t, optionalTarget ).Source§fn get_tangent_at(&self, u: f64) -> Self::Point
fn get_tangent_at(&self, u: f64) -> Self::Point
Curve.getTangentAt( u, optionalTarget ).Source§fn compute_frenet_frames(&self, segments: usize, closed: bool) -> FrenetFrames
fn compute_frenet_frames(&self, segments: usize, closed: bool) -> FrenetFrames
Curve.computeFrenetFrames( segments, closed ). Read more