Skip to content

Commit f17deea

Browse files
committed
Refactor NurbsCurve component to rename curveResolution prop to resolution for consistency, and update related Storybook stories accordingly.
1 parent 56751e9 commit f17deea

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/components/NurbsCurve.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ import verb from "verb-nurbs";
44
import { Line } from "@react-three/drei";
55
import type { LineProps } from "@react-three/drei";
66

7-
export interface NurbsCurveProps extends Omit<LineProps, "points"> {
7+
export interface NurbsCurveProps
8+
extends Omit<LineProps, "points" | "resolution"> {
89
points: number[][];
910
degree?: number;
1011
weights?: number[];
1112
knots: number[];
12-
curveResolution?: number;
13+
resolution?: number;
1314
}
1415

1516
export const NurbsCurve = ({
1617
points,
1718
degree = 3,
1819
weights,
1920
knots,
20-
curveResolution = 50,
21+
resolution = 50,
2122
color = "black",
2223
segments,
2324
dashed = false,
@@ -41,16 +42,17 @@ export const NurbsCurve = ({
4142
);
4243

4344
// Create points along the curve
44-
return Array.from({ length: curveResolution + 1 }, (_, i) => {
45-
const t = i / curveResolution;
45+
const res = resolution;
46+
return Array.from({ length: res + 1 }, (_, i) => {
47+
const t = i / res;
4648
const point = verbCurve.point(t);
4749
return new Vector3(point[0], point[1], point[2]);
4850
});
4951
} catch (error) {
5052
console.error("Error creating NURBS curve:", error);
5153
return [];
5254
}
53-
}, [points, degree, weights, knots, curveResolution]);
55+
}, [points, degree, weights, knots, resolution]);
5456

5557
if (curvePoints.length === 0) return null;
5658

src/stories/NurbsCurve.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const Degree2Curve: Story = {
3838
],
3939
degree: 2,
4040
knots: [0, 0, 0, 1, 1, 1],
41-
curveResolution: 50,
41+
resolution: 50,
4242
color: "#ff0000",
4343
lineWidth: 1,
4444
},
@@ -55,7 +55,7 @@ export const Degree3Curve: Story = {
5555
],
5656
degree: 3,
5757
knots: [0, 0, 0, 0, 1, 1, 1, 1],
58-
curveResolution: 50,
58+
resolution: 50,
5959
color: "#00ff00",
6060
lineWidth: 1,
6161
},
@@ -72,7 +72,7 @@ export const WeightedCurve: Story = {
7272
degree: 2,
7373
knots: [0, 0, 0, 1, 1, 1],
7474
weights: [1, 2, 1],
75-
curveResolution: 50,
75+
resolution: 50,
7676
color: "#0000ff",
7777
lineWidth: 1,
7878
},

0 commit comments

Comments
 (0)