How to use the LineLoop function from three

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

three.LineLoop is a class in the Three.js library that creates a closed loop geometry object consisting of a series of connected line segments.

2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
} else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
  mesh = new THREE.LineSegments(geometry, material);
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
  mesh = new THREE.Line(geometry, material);
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
  mesh = new THREE.LineLoop(geometry, material);
} else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
  mesh = new THREE.Points(geometry, material);
} else {
  throw new Error(
fork icon3
star icon7
watch icon8

+ 14 other calls in file

3324
3325
3326
3327
3328
3329
3330
3331
3332
3333

    mesh = new THREE.Line( geometry, material );

} else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {

    mesh = new THREE.LineLoop( geometry, material );

} else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {

    mesh = new THREE.Points( geometry, material );
fork icon2
star icon10
watch icon0

How does three.LineLoop work?

three.LineLoop is a Three.js object that represents a looped line segment in 3D space, with each segment defined by two connected vertices, and the last vertex connected to the first vertex to form a closed loop.

2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
}
else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
    mesh = new three.Line(geometry, material);
}
else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
    mesh = new three.LineLoop(geometry, material);
}
else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
    mesh = new three.Points(geometry, material);
}
fork icon2
star icon7
watch icon0

1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
case 'LineSegments':
  child = new THREE.LineSegments(originalGeometry, material);
  break;

case 'LineLoop':
  child = new THREE.LineLoop(originalGeometry, material);
  break;

case 'Line':
  child = new THREE.Line(originalGeometry, material);
fork icon0
star icon1
watch icon0

+ 9 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// create geometry
const geometry = new THREE.BufferGeometry();
const vertices = [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0];
geometry.setAttribute(
  "position",
  new THREE.Float32BufferAttribute(vertices, 3)
);

// create material
const material = new THREE.LineBasicMaterial({ color: 0xff0000 });

// create line loop
const lineLoop = new THREE.LineLoop(geometry, material);
scene.add(lineLoop);

In this example, we first create a BufferGeometry that defines the vertices of the LineLoop. We then create a LineBasicMaterial and use it to create a new LineLoop object, passing in the geometry and material as arguments. Finally, we add the LineLoop to the scene.

2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
} else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
  mesh = new _three.LineSegments(geometry, _material);
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
  mesh = new _three.Line(geometry, _material);
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
  mesh = new _three.LineLoop(geometry, _material);
} else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
  mesh = new _three.Points(geometry, _material);
} else {
  throw new Error('THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode);
fork icon0
star icon1
watch icon0

223
224
225
226
227
228
229
230
231
232
let material = new THREE.LineBasicMaterial({color: color});
let geometry = new THREE.CircleGeometry(radius, segments);
geometry.vertices.shift();
let line = new THREE.Line(geometry, material);
line.material.transparent = true;
let lineLoop = new THREE.LineLoop(geometry, material);
line.add(lineLoop);
let vector3 = new THREE.Vector3(0, 0, 0);
line.position.copy(position);
line.lookAt(vector3);
fork icon0
star icon0
watch icon0

Other functions in three

Sorted by popularity

function icon

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