| 113 | * ``` |
| 114 | */ |
| 115 | export class Spline extends Curve { |
| 116 | /** |
| 117 | * The smoothness of the spline when using auto-calculated handles. |
| 118 | * |
| 119 | * @remarks |
| 120 | * This property is only applied to knots that don't use explicit handles. |
| 121 | * |
| 122 | * @defaultValue 0.4 |
| 123 | */ |
| 124 | @initial(0.4) |
| 125 | @signal() |
| 126 | public declare readonly smoothness: SimpleSignal<number>; |
| 127 | |
| 128 | /** |
| 129 | * The knots of the spline as an array of knots with auto-calculated handles. |
| 130 | * |
| 131 | * @remarks |
| 132 | * You can control the smoothness of the resulting curve |
| 133 | * via the {@link smoothness} property. |
| 134 | */ |
| 135 | @initial(null) |
| 136 | @signal() |
| 137 | public declare readonly points: SimpleSignal< |
| 138 | SignalValue<PossibleVector2>[] | null, |
| 139 | this |
| 140 | >; |
| 141 | |
| 142 | public constructor(props: SplineProps) { |
| 143 | super(props); |
| 144 | |
| 145 | if ( |
| 146 | (props.children === undefined || |
| 147 | !Array.isArray(props.children) || |
| 148 | props.children.length < 2) && |
| 149 | (props.points === undefined || props.points.length < 2) && |
| 150 | props.spawner === undefined |
| 151 | ) { |
| 152 | useLogger().warn({ |
| 153 | message: |
| 154 | 'Insufficient number of knots specified for spline. A spline needs at least two knots.', |
| 155 | remarks: splineWithInsufficientKnots, |
| 156 | inspect: this.key, |
| 157 | }); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | @computed() |
| 162 | public override profile(): CurveProfile { |
| 163 | return getBezierSplineProfile( |
| 164 | this.knots(), |
| 165 | this.closed(), |
| 166 | this.smoothness(), |
| 167 | ); |
| 168 | } |
| 169 | |
| 170 | @computed() |
| 171 | public knots(): KnotInfo[] { |
| 172 | const points = this.points(); |