Stroke Definition
StrokeDef is the whole definition of one stroke: an array of points, a width on each side of those points, and a reference to the renderer that turns the two into geometry. Splitting it this way means the same path can be drawn as a hard-edged ribbon, a tapered brush mark, or a volumetric tube by swapping one field.
public/lib/StrokeDef.js
StrokeDef
Constructed from a single options object.
points—THREE.Vector3[]. Control points, not final vertices. Renderers treat them as a centripetal Catmull-Rom curve and resample it; two points are the minimum.
制御点であり、最終的な頂点ではありません。レンダラはこれを centripetal Catmull-Rom 曲線として扱い、再サンプリングします。最低2点が必要です。widthLeft— width on the left of the spine. Default0.02.
スパイン(芯線)の左側の幅。既定値は0.02。widthRight— width on the right. Defaults towidthLeft, giving a symmetric stroke.
右側の幅。省略するとwidthLeftと同じ値になり、左右対称のストロークになります。renderer— theStrokeRendererused bybuild().build()が使用するStrokeRenderer。
“Left” is the +90° rotation of the tangent in the XY plane. Because the two sides are stored separately, a stroke can lean off the path that generated it — the spine stays where the gesture put it while the visible mark thickens to one side.
build() hands the definition to its renderer and returns a THREE.Object3D. maxWidth() samples both sides and returns the largest value; polylineLength measures the control polygon, which is a cheap approximation renderers do not rely on — they measure the resampled curve instead.
Width
A width is one of three things, resolved by resolveWidth(width, t) where t runs 0 → 1 over arc length.
- number — constant along the stroke.
ストローク全体で一定。 - number[] — sampled evenly along the stroke and linearly interpolated between entries. Useful for recorded pressure.
ストロークに沿って等間隔にサンプリングされ、値の間は線形補間されます。記録した筆圧などに向いています。 - (t) => number — evaluated per sample. Useful for analytic profiles.
サンプルごとに評価されます。解析的なプロファイルに向いています。
Because t is normalised over arc length rather than over the control point index, a width profile keeps its shape when the control points are unevenly spaced. A taper written as sin(πt) peaks at the halfway point of the drawn mark, not at the middle entry of the array.
The renderer reference
renderer is a reference, not a subclass hook: one renderer instance can build any
number of strokes, because it carries style and never state about a particular stroke.
build() simply hands the definition over.
Renderers, the contract they share, and RibbonStrokeRenderer are documented on
Renderers.