Capítulo 38 de 859

Chapter 38: LoftGeometry

Core Idea

This class can be used to generate a geometry by lofting (skinning) a surface through a series of cross sections. Each section is an array of points in 3D space and all sections must have the same number of points.

LoftGeometry is the general case of geometries like LatheGeometry (which revolves a fixed profile around an axis) or TubeGeometry (which sweeps a circular section along a path): the sections can have any shape, and can change shape, size, position and orientation from one section to the next.

Sections wind around the loft so the resulting face normals point outwards when each section is ordered counterclockwise as seen from the end of the loft, looking back towards the start. If the surface appears inside out, reverse the point order of each section.

Key Concepts

  • parameters : Object: Holds the constructor parameters that have been used to generate the geometry. Any modification after instantiation does not change the geo…

Code Examples

const sections = [];
for ( let i = 0; i <= 10; i ++ ) {
	const points = [];
	const radius = 2 + Math.sin( i * 0.8 );
	for ( let j = 0; j < 32; j ++ ) {
		const angle = j / 32 * Math.PI * 2;
		points.push( new THREE.Vector3( Math.sin( angle ) * radius, i, Math.cos( angle ) * radius ) );
	}
	sections.push( points );
}
const geometry = new LoftGeometry( sections, { capStart: true, capEnd: true } );
const material = new THREE.MeshStandardMaterial( { color: 0x00ff00 } );
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
  • What it demonstrates: Typical usage of LoftGeometry.

Reference Tables

Constructor

Signature
new LoftGeometry( sections : Array.<Array.<Vector3>>, options : Object )

Properties

PropertyDescription
.parameters : ObjectHolds the constructor parameters that have been used to generate the geometry. Any modification after instantiation does not change the geometry.

Key Takeaways

  1. LoftGeometry extends: EventDispatcher → BufferGeometry
  2. Most relevant properties: parameters.

Connects To