How to use the NURBSCurve function from three

Find comprehensive JavaScript three.NURBSCurve code examples handpicked from public code repositorys.

three.NURBSCurve is a class in the Three.js library that represents a non-uniform rational B-spline curve in 3D space.

1457
1458
1459
1460
1461
1462
1463
1464
1465

	}

}

var curve = new THREE.NURBSCurve( degree, knots, controlPoints, startKnot, endKnot );
var vertices = curve.getPoints( controlPoints.length * 7 );

var positions = new Float32Array( vertices.length * 3 );
fork icon0
star icon0
watch icon1

+ 88 other calls in file

2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
  for (var i = 0; i < degree; ++i) {
    controlPoints.push(controlPoints[i]);
  }
}

var curve = new THREE.NURBSCurve(
  degree,
  knots,
  controlPoints,
  startKnot,
fork icon0
star icon0
watch icon0

How does three.NURBSCurve work?

three.NURBSCurve is a class in the Three.js library that represents a non-uniform rational B-spline curve (NURBS) in three-dimensional space, defined by a set of control points, a degree, and a knot vector. The curve can be used to define the path of an object in a 3D scene. When evaluating the curve at a specific parameter, the curve returns the corresponding point in 3D space. The three.NURBSCurve class provides methods to compute the curve's length, as well as its tangent and normal vectors at any given point.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Define the control points
const controlPoints = [
  new THREE.Vector4(-150, 0, 150, 1),
  new THREE.Vector4(-50, 200, 150, 1),
  new THREE.Vector4(50, -200, -150, 1),
  new THREE.Vector4(150, 0, -150, 1),
];

// Define the NURBS curve
const curve = new THREE.NURBSCurve(3, 2, controlPoints);

// Create a geometry and add it to a mesh
const geometry = new THREE.TubeBufferGeometry(curve, 64, 1, 8, false);
const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const mesh = new THREE.Mesh(geometry, material);

In this example, we define an array of four control points in 3D space, and use them to create a three.NURBSCurve. We then create a THREE.TubeBufferGeometry using the curve, and add it to a mesh that is rendered with a red basic material.

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)