or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

animation.mdcameras.mdgeometries.mdindex.mdlights.mdloaders.mdmaterials.mdmath.mdrenderers.mdscene-management.mdtsl.mdwebgpu.md

geometries.mddocs/

0

# Geometries

1

2

Geometry system providing vertex data, buffer management, and primitive shape generation for 3D rendering. All geometries use the efficient BufferGeometry system with typed array attributes.

3

4

## Capabilities

5

6

### Buffer Geometry Foundation

7

8

Core geometry class using buffer attributes for efficient GPU data transfer and rendering performance.

9

10

```typescript { .api }

11

import {

12

BufferGeometry,

13

BufferAttribute,

14

EventDispatcher,

15

Vector3,

16

Vector2,

17

Matrix4,

18

Matrix3,

19

Box3,

20

Sphere,

21

Ray

22

} from 'three';

23

24

/**

25

* Base geometry class using buffer attributes for efficient rendering

26

*/

27

class BufferGeometry extends EventDispatcher {

28

/** Type flag for buffer geometry detection */

29

readonly isBufferGeometry: true;

30

31

/** Unique geometry ID */

32

readonly id: number;

33

34

/** UUID string identifier */

35

readonly uuid: string;

36

37

/** Geometry name */

38

name: string;

39

40

/** Geometry type string */

41

type: string;

42

43

/** Vertex indices for indexed rendering */

44

index: BufferAttribute | null;

45

46

/** Indirect draw buffer (WebGPU only) */

47

indirect: BufferAttribute | null;

48

49

/** Vertex attributes (position, normal, uv, etc.) */

50

attributes: Record<string, BufferAttribute | InterleavedBufferAttribute>;

51

52

/** Morph target attributes */

53

morphAttributes: Record<string, BufferAttribute[]>;

54

55

/** Treat morph targets as relative offsets */

56

morphTargetsRelative: boolean;

57

58

/** Geometry groups for multi-material rendering */

59

groups: Array<{

60

start: number;

61

count: number;

62

materialIndex?: number;

63

}>;

64

65

/** Bounding box (computed) */

66

boundingBox: Box3 | null;

67

68

/** Bounding sphere (computed) */

69

boundingSphere: Sphere | null;

70

71

/** Draw range for partial rendering */

72

drawRange: { start: number; count: number };

73

74

/** User data storage */

75

userData: Record<string, any>;

76

77

/**

78

* Create buffer geometry

79

*/

80

constructor();

81

82

/**

83

* Get index buffer attribute

84

* @returns Index attribute or null

85

*/

86

getIndex(): BufferAttribute | null;

87

88

/**

89

* Set index buffer attribute

90

* @param index - Index buffer attribute

91

* @returns This geometry for chaining

92

*/

93

setIndex(index: BufferAttribute | number[] | null): this;

94

95

/**

96

* Set indirect draw buffer (WebGPU)

97

* @param indirect - Indirect buffer attribute

98

* @returns This geometry for chaining

99

*/

100

setIndirect(indirect: BufferAttribute | null): this;

101

102

/**

103

* Get indirect draw buffer

104

* @returns Indirect buffer or null

105

*/

106

getIndirect(): BufferAttribute | null;

107

108

/**

109

* Get named attribute

110

* @param name - Attribute name

111

* @returns Buffer attribute or undefined

112

*/

113

getAttribute(name: string): BufferAttribute | InterleavedBufferAttribute | undefined;

114

115

/**

116

* Set named attribute

117

* @param name - Attribute name

118

* @param attribute - Buffer attribute

119

* @returns This geometry for chaining

120

*/

121

setAttribute(name: string, attribute: BufferAttribute | InterleavedBufferAttribute): this;

122

123

/**

124

* Delete named attribute

125

* @param name - Attribute name

126

* @returns This geometry for chaining

127

*/

128

deleteAttribute(name: string): this;

129

130

/**

131

* Check if attribute exists

132

* @param name - Attribute name

133

* @returns True if attribute exists

134

*/

135

hasAttribute(name: string): boolean;

136

137

/**

138

* Add geometry group for multi-material support

139

* @param start - Start index

140

* @param count - Index count

141

* @param materialIndex - Material index (optional)

142

*/

143

addGroup(start: number, count: number, materialIndex?: number): void;

144

145

/**

146

* Clear all geometry groups

147

*/

148

clearGroups(): void;

149

150

/**

151

* Set draw range for partial rendering

152

* @param start - Start index

153

* @param count - Index count

154

*/

155

setDrawRange(start: number, count: number): void;

156

157

/**

158

* Apply transformation matrix to geometry

159

* @param matrix - Transformation matrix

160

* @returns This geometry for chaining

161

*/

162

applyMatrix4(matrix: Matrix4): this;

163

164

/**

165

* Apply quaternion rotation to geometry

166

* @param quaternion - Quaternion rotation

167

* @returns This geometry for chaining

168

*/

169

applyQuaternion(quaternion: Quaternion): this;

170

171

/**

172

* Rotate geometry around axis

173

* @param axis - Rotation axis

174

* @param angle - Rotation angle in radians

175

* @returns This geometry for chaining

176

*/

177

rotateX(angle: number): this;

178

rotateY(angle: number): this;

179

rotateZ(angle: number): this;

180

181

/**

182

* Translate geometry

183

* @param x - X offset

184

* @param y - Y offset

185

* @param z - Z offset

186

* @returns This geometry for chaining

187

*/

188

translate(x: number, y: number, z: number): this;

189

190

/**

191

* Scale geometry

192

* @param x - X scale

193

* @param y - Y scale

194

* @param z - Z scale

195

* @returns This geometry for chaining

196

*/

197

scale(x: number, y: number, z: number): this;

198

199

/**

200

* Look at target (orient geometry)

201

* @param vector - Target direction

202

* @returns This geometry for chaining

203

*/

204

lookAt(vector: Vector3): this;

205

206

/**

207

* Center geometry at origin

208

* @returns This geometry for chaining

209

*/

210

center(): this;

211

212

/**

213

* Set attribute from array

214

* @param name - Attribute name

215

* @param array - Data array

216

* @param itemSize - Items per vertex

217

* @param normalized - Normalize data

218

* @returns This geometry for chaining

219

*/

220

setFromPoints(points: Vector3[]): this;

221

222

/**

223

* Update attribute range

224

* @param name - Attribute name

225

* @param start - Start index

226

* @param count - Item count

227

*/

228

updateFromObject(object: Object3D): this;

229

230

/**

231

* Compute vertex normals

232

*/

233

computeVertexNormals(): void;

234

235

/**

236

* Compute tangent vectors (requires UVs and normals)

237

*/

238

computeTangents(): void;

239

240

/**

241

* Compute bounding box

242

*/

243

computeBoundingBox(): void;

244

245

/**

246

* Compute bounding sphere

247

*/

248

computeBoundingSphere(): void;

249

250

/**

251

* Raycast against geometry

252

* @param raycaster - Raycaster object

253

* @param intersects - Intersection results array

254

*/

255

raycast(raycaster: Raycaster, intersects: Intersection[]): void;

256

257

/**

258

* Merge another geometry

259

* @param geometry - Geometry to merge

260

* @param offset - Vertex offset

261

* @returns This geometry for chaining

262

*/

263

merge(geometry: BufferGeometry, offset?: number): this;

264

265

/**

266

* Normalize normals to unit length

267

* @returns This geometry for chaining

268

*/

269

normalizeNormals(): this;

270

271

/**

272

* Convert to non-indexed geometry

273

* @returns New non-indexed geometry

274

*/

275

toNonIndexed(): BufferGeometry;

276

277

/**

278

* Serialize geometry to JSON

279

* @param meta - Metadata object

280

* @returns JSON representation

281

*/

282

toJSON(meta?: any): any;

283

284

/**

285

* Clone geometry

286

* @returns Cloned geometry

287

*/

288

clone(): this;

289

290

/**

291

* Copy properties from another geometry

292

* @param source - Source geometry

293

* @returns This geometry for chaining

294

*/

295

copy(source: BufferGeometry): this;

296

297

/**

298

* Dispose geometry resources

299

*/

300

dispose(): void;

301

}

302

```

303

304

**Usage Examples:**

305

306

```typescript

307

import { BufferGeometry, BufferAttribute, Vector3 } from 'three';

308

309

// Create custom geometry

310

const geometry = new BufferGeometry();

311

312

// Define vertices (triangle)

313

const vertices = new Float32Array([

314

-1.0, -1.0, 0.0, // Bottom left

315

1.0, -1.0, 0.0, // Bottom right

316

0.0, 1.0, 0.0 // Top center

317

]);

318

geometry.setAttribute('position', new BufferAttribute(vertices, 3));

319

320

// Add normals

321

const normals = new Float32Array([

322

0, 0, 1,

323

0, 0, 1,

324

0, 0, 1

325

]);

326

geometry.setAttribute('normal', new BufferAttribute(normals, 3));

327

328

// Add UVs

329

const uvs = new Float32Array([

330

0, 0,

331

1, 0,

332

0.5, 1

333

]);

334

geometry.setAttribute('uv', new BufferAttribute(uvs, 2));

335

336

// Compute bounds

337

geometry.computeBoundingBox();

338

geometry.computeBoundingSphere();

339

340

// Transform geometry

341

geometry.translate(0, 1, 0);

342

geometry.rotateX(Math.PI / 4);

343

geometry.scale(2, 2, 2);

344

```

345

346

### Buffer Attributes

347

348

Typed array data containers for vertex attributes with efficient GPU transfer.

349

350

```typescript { .api }

351

import {

352

BufferAttribute,

353

Int8BufferAttribute,

354

Uint8BufferAttribute,

355

Int16BufferAttribute,

356

Uint16BufferAttribute,

357

Int32BufferAttribute,

358

Uint32BufferAttribute,

359

Float16BufferAttribute,

360

Float32BufferAttribute,

361

InstancedBufferAttribute,

362

InterleavedBuffer,

363

InterleavedBufferAttribute

364

} from 'three';

365

366

/**

367

* Base buffer attribute for typed array vertex data

368

*/

369

class BufferAttribute {

370

/** Type flag for buffer attribute detection */

371

readonly isBufferAttribute: true;

372

373

/** Unique attribute ID */

374

readonly id: number;

375

376

/** Attribute name */

377

name: string;

378

379

/** Typed array data */

380

array: TypedArray;

381

382

/** Items per vertex (1-4) */

383

itemSize: number;

384

385

/** Total item count */

386

readonly count: number;

387

388

/** Normalize values on GPU */

389

normalized: boolean;

390

391

/** Buffer usage pattern */

392

usage: number;

393

394

/** Update range for partial updates */

395

updateRange: { offset: number; count: number };

396

397

/** GPU buffer version */

398

readonly version: number;

399

400

/** Buffer needs update flag */

401

needsUpdate: boolean;

402

403

/**

404

* Create buffer attribute

405

* @param array - Typed array data

406

* @param itemSize - Components per vertex

407

* @param normalized - Normalize values (default: false)

408

*/

409

constructor(array: TypedArray, itemSize: number, normalized?: boolean);

410

411

/**

412

* Set usage pattern for optimization

413

* @param usage - Usage constant (StaticDrawUsage, DynamicDrawUsage, StreamDrawUsage)

414

* @returns This attribute for chaining

415

*/

416

setUsage(usage: number): this;

417

418

/**

419

* Copy data from another attribute

420

* @param source - Source attribute

421

* @returns This attribute for chaining

422

*/

423

copy(source: BufferAttribute): this;

424

425

/**

426

* Copy array data from another attribute

427

* @param source - Source attribute

428

* @returns This attribute for chaining

429

*/

430

copyArray(source: BufferAttribute): this;

431

432

/**

433

* Apply transformation matrix to position/normal data

434

* @param matrix - Transformation matrix

435

* @returns This attribute for chaining

436

*/

437

applyMatrix3(matrix: Matrix3): this;

438

applyMatrix4(matrix: Matrix4): this;

439

440

/**

441

* Apply normal matrix transformation

442

* @param matrix - Normal matrix

443

* @returns This attribute for chaining

444

*/

445

applyNormalMatrix(matrix: Matrix3): this;

446

447

/**

448

* Transform by 4x4 matrix (positions)

449

* @param matrix - Transformation matrix

450

* @returns This attribute for chaining

451

*/

452

transformDirection(matrix: Matrix4): this;

453

454

/**

455

* Set single component value

456

* @param index - Vertex index

457

* @param x - X component

458

* @param y - Y component (optional)

459

* @param z - Z component (optional)

460

* @param w - W component (optional)

461

* @returns This attribute for chaining

462

*/

463

setX(index: number, x: number): this;

464

setY(index: number, y: number): this;

465

setZ(index: number, z: number): this;

466

setW(index: number, w: number): this;

467

468

/**

469

* Get single component value

470

* @param index - Vertex index

471

* @returns Component value

472

*/

473

getX(index: number): number;

474

getY(index: number): number;

475

getZ(index: number): number;

476

getW(index: number): number;

477

478

/**

479

* Set XY components

480

* @param index - Vertex index

481

* @param x - X component

482

* @param y - Y component

483

* @returns This attribute for chaining

484

*/

485

setXY(index: number, x: number, y: number): this;

486

487

/**

488

* Set XYZ components

489

* @param index - Vertex index

490

* @param x - X component

491

* @param y - Y component

492

* @param z - Z component

493

* @returns This attribute for chaining

494

*/

495

setXYZ(index: number, x: number, y: number, z: number): this;

496

497

/**

498

* Set XYZW components

499

* @param index - Vertex index

500

* @param x - X component

501

* @param y - Y component

502

* @param z - Z component

503

* @param w - W component

504

* @returns This attribute for chaining

505

*/

506

setXYZW(index: number, x: number, y: number, z: number, w: number): this;

507

508

/**

509

* Clone attribute

510

* @returns Cloned attribute

511

*/

512

clone(): this;

513

514

/**

515

* Serialize to JSON

516

* @returns JSON representation

517

*/

518

toJSON(): any;

519

}

520

521

/**

522

* Typed buffer attribute classes for specific data types

523

*/

524

525

/** 8-bit signed integer attributes */

526

class Int8BufferAttribute extends BufferAttribute {

527

constructor(array: Int8Array | number[], itemSize: number, normalized?: boolean);

528

}

529

530

/** 8-bit unsigned integer attributes */

531

class Uint8BufferAttribute extends BufferAttribute {

532

constructor(array: Uint8Array | number[], itemSize: number, normalized?: boolean);

533

}

534

535

/** 16-bit signed integer attributes */

536

class Int16BufferAttribute extends BufferAttribute {

537

constructor(array: Int16Array | number[], itemSize: number, normalized?: boolean);

538

}

539

540

/** 16-bit unsigned integer attributes */

541

class Uint16BufferAttribute extends BufferAttribute {

542

constructor(array: Uint16Array | number[], itemSize: number, normalized?: boolean);

543

}

544

545

/** 32-bit signed integer attributes */

546

class Int32BufferAttribute extends BufferAttribute {

547

constructor(array: Int32Array | number[], itemSize: number, normalized?: boolean);

548

}

549

550

/** 32-bit unsigned integer attributes */

551

class Uint32BufferAttribute extends BufferAttribute {

552

constructor(array: Uint32Array | number[], itemSize: number, normalized?: boolean);

553

}

554

555

/** 16-bit float attributes */

556

class Float16BufferAttribute extends BufferAttribute {

557

constructor(array: Uint16Array | number[], itemSize: number, normalized?: boolean);

558

}

559

560

/** 32-bit float attributes */

561

class Float32BufferAttribute extends BufferAttribute {

562

constructor(array: Float32Array | number[], itemSize: number, normalized?: boolean);

563

}

564

565

/**

566

* Instanced buffer attribute for instanced rendering

567

*/

568

class InstancedBufferAttribute extends BufferAttribute {

569

/** Type flag for instanced attribute detection */

570

readonly isInstancedBufferAttribute: true;

571

572

/** Number of instances using this data */

573

meshPerAttribute: number;

574

575

/**

576

* Create instanced buffer attribute

577

* @param array - Typed array data

578

* @param itemSize - Components per instance

579

* @param normalized - Normalize values

580

* @param meshPerAttribute - Instances per attribute value

581

*/

582

constructor(

583

array: TypedArray,

584

itemSize: number,

585

normalized?: boolean,

586

meshPerAttribute?: number

587

);

588

}

589

590

/**

591

* Interleaved buffer for packed vertex data

592

*/

593

class InterleavedBuffer {

594

/** Type flag for interleaved buffer detection */

595

readonly isInterleavedBuffer: true;

596

597

/** Interleaved data array */

598

array: TypedArray;

599

600

/** Stride (bytes per vertex) */

601

stride: number;

602

603

/** Total vertex count */

604

readonly count: number;

605

606

/** Buffer usage pattern */

607

usage: number;

608

609

/** Update range */

610

updateRange: { offset: number; count: number };

611

612

/** Buffer version */

613

readonly version: number;

614

615

/** Needs update flag */

616

needsUpdate: boolean;

617

618

/**

619

* Create interleaved buffer

620

* @param array - Typed array with interleaved data

621

* @param stride - Bytes per vertex

622

*/

623

constructor(array: TypedArray, stride: number);

624

625

/**

626

* Set usage pattern

627

* @param usage - Usage constant

628

* @returns This buffer for chaining

629

*/

630

setUsage(usage: number): this;

631

632

/**

633

* Copy from another interleaved buffer

634

* @param source - Source buffer

635

* @returns This buffer for chaining

636

*/

637

copy(source: InterleavedBuffer): this;

638

639

/**

640

* Copy array data

641

* @param source - Source buffer

642

* @returns This buffer for chaining

643

*/

644

copyArray(source: InterleavedBuffer): this;

645

646

/**

647

* Set data range

648

* @param value - Value array

649

* @param offset - Start offset

650

* @returns This buffer for chaining

651

*/

652

set(value: ArrayLike<number>, offset?: number): this;

653

654

/**

655

* Clone buffer

656

* @returns Cloned buffer

657

*/

658

clone(): this;

659

660

/**

661

* Serialize to JSON

662

* @returns JSON representation

663

*/

664

toJSON(): any;

665

}

666

667

/**

668

* Interleaved buffer attribute referencing part of interleaved data

669

*/

670

class InterleavedBufferAttribute {

671

/** Type flag for interleaved buffer attribute detection */

672

readonly isInterleavedBufferAttribute: true;

673

674

/** Attribute name */

675

name: string;

676

677

/** Source interleaved buffer */

678

data: InterleavedBuffer;

679

680

/** Items per vertex */

681

itemSize: number;

682

683

/** Offset in interleaved data */

684

offset: number;

685

686

/** Normalize values */

687

normalized: boolean;

688

689

/**

690

* Create interleaved buffer attribute

691

* @param interleavedBuffer - Source interleaved buffer

692

* @param itemSize - Components per vertex

693

* @param offset - Offset in buffer

694

* @param normalized - Normalize values

695

*/

696

constructor(

697

interleavedBuffer: InterleavedBuffer,

698

itemSize: number,

699

offset: number,

700

normalized?: boolean

701

);

702

703

/** Get vertex count from buffer */

704

readonly count: number;

705

706

/** Get array from buffer */

707

readonly array: TypedArray;

708

709

/** Buffer needs update flag */

710

needsUpdate: boolean;

711

712

/**

713

* Apply transformation matrix

714

* @param matrix - Transformation matrix

715

* @returns This attribute for chaining

716

*/

717

applyMatrix4(matrix: Matrix4): this;

718

719

/**

720

* Apply normal matrix

721

* @param matrix - Normal matrix

722

* @returns This attribute for chaining

723

*/

724

applyNormalMatrix(matrix: Matrix3): this;

725

726

/**

727

* Transform direction vectors

728

* @param matrix - Transformation matrix

729

* @returns This attribute for chaining

730

*/

731

transformDirection(matrix: Matrix4): this;

732

733

/**

734

* Get/set component values

735

*/

736

getX(index: number): number;

737

setX(index: number, x: number): this;

738

getY(index: number): number;

739

setY(index: number, y: number): this;

740

getZ(index: number): number;

741

setZ(index: number, z: number): this;

742

getW(index: number): number;

743

setW(index: number, w: number): this;

744

745

setXY(index: number, x: number, y: number): this;

746

setXYZ(index: number, x: number, y: number, z: number): this;

747

setXYZW(index: number, x: number, y: number, z: number, w: number): this;

748

749

/**

750

* Clone attribute

751

* @returns Cloned attribute

752

*/

753

clone(): this;

754

755

/**

756

* Serialize to JSON

757

* @returns JSON representation

758

*/

759

toJSON(): any;

760

}

761

```

762

763

**Usage Examples:**

764

765

```typescript

766

import {

767

Float32BufferAttribute,

768

Uint16BufferAttribute,

769

InstancedBufferAttribute,

770

InterleavedBuffer,

771

InterleavedBufferAttribute

772

} from 'three';

773

774

// Standard attributes

775

const positions = new Float32BufferAttribute([

776

-1, -1, 0,

777

1, -1, 0,

778

0, 1, 0

779

], 3);

780

781

const colors = new Float32BufferAttribute([

782

1, 0, 0,

783

0, 1, 0,

784

0, 0, 1

785

], 3);

786

787

// Index buffer

788

const indices = new Uint16BufferAttribute([0, 1, 2], 1);

789

790

// Instanced attributes for instanced rendering

791

const instancePositions = new InstancedBufferAttribute(

792

new Float32Array(300), // 100 instances * 3 components

793

3, // XYZ per instance

794

false, // not normalized

795

1 // one instance per attribute value

796

);

797

798

// Interleaved buffer (position + normal + uv)

799

const interleavedData = new Float32Array([

800

// vertex 0: px, py, pz, nx, ny, nz, u, v

801

-1, -1, 0, 0, 0, 1, 0, 0,

802

// vertex 1: px, py, pz, nx, ny, nz, u, v

803

1, -1, 0, 0, 0, 1, 1, 0,

804

// vertex 2: px, py, pz, nx, ny, nz, u, v

805

0, 1, 0, 0, 0, 1, 0.5, 1

806

]);

807

808

const interleavedBuffer = new InterleavedBuffer(interleavedData, 8);

809

810

// Extract attributes from interleaved buffer

811

const interleavedPositions = new InterleavedBufferAttribute(interleavedBuffer, 3, 0);

812

const interleavedNormals = new InterleavedBufferAttribute(interleavedBuffer, 3, 3);

813

const interleavedUVs = new InterleavedBufferAttribute(interleavedBuffer, 2, 6);

814

815

// Set on geometry

816

geometry.setAttribute('position', interleavedPositions);

817

geometry.setAttribute('normal', interleavedNormals);

818

geometry.setAttribute('uv', interleavedUVs);

819

820

// Update attributes

821

positions.setXYZ(1, 2, -1, 0);

822

positions.needsUpdate = true;

823

824

// Partial updates

825

positions.updateRange.offset = 3;

826

positions.updateRange.count = 3;

827

```

828

829

### Primitive Geometries

830

831

Built-in geometry classes for common 3D shapes with configurable parameters.

832

833

```typescript { .api }

834

import {

835

BoxGeometry,

836

SphereGeometry,

837

CylinderGeometry,

838

ConeGeometry,

839

PlaneGeometry,

840

CircleGeometry,

841

RingGeometry,

842

TorusGeometry,

843

TorusKnotGeometry

844

} from 'three';

845

846

/**

847

* Rectangular box geometry

848

*/

849

class BoxGeometry extends BufferGeometry {

850

/** Geometry parameters */

851

readonly parameters: {

852

width: number;

853

height: number;

854

depth: number;

855

widthSegments: number;

856

heightSegments: number;

857

depthSegments: number;

858

};

859

860

/**

861

* Create box geometry

862

* @param width - Width (X axis)

863

* @param height - Height (Y axis)

864

* @param depth - Depth (Z axis)

865

* @param widthSegments - Width segments

866

* @param heightSegments - Height segments

867

* @param depthSegments - Depth segments

868

*/

869

constructor(

870

width?: number,

871

height?: number,

872

depth?: number,

873

widthSegments?: number,

874

heightSegments?: number,

875

depthSegments?: number

876

);

877

}

878

879

/**

880

* Sphere geometry with latitude/longitude segments

881

*/

882

class SphereGeometry extends BufferGeometry {

883

/** Geometry parameters */

884

readonly parameters: {

885

radius: number;

886

widthSegments: number;

887

heightSegments: number;

888

phiStart: number;

889

phiLength: number;

890

thetaStart: number;

891

thetaLength: number;

892

};

893

894

/**

895

* Create sphere geometry

896

* @param radius - Sphere radius

897

* @param widthSegments - Horizontal segments

898

* @param heightSegments - Vertical segments

899

* @param phiStart - Horizontal start angle

900

* @param phiLength - Horizontal sweep angle

901

* @param thetaStart - Vertical start angle

902

* @param thetaLength - Vertical sweep angle

903

*/

904

constructor(

905

radius?: number,

906

widthSegments?: number,

907

heightSegments?: number,

908

phiStart?: number,

909

phiLength?: number,

910

thetaStart?: number,

911

thetaLength?: number

912

);

913

}

914

915

/**

916

* Cylindrical geometry

917

*/

918

class CylinderGeometry extends BufferGeometry {

919

/** Geometry parameters */

920

readonly parameters: {

921

radiusTop: number;

922

radiusBottom: number;

923

height: number;

924

radialSegments: number;

925

heightSegments: number;

926

openEnded: boolean;

927

thetaStart: number;

928

thetaLength: number;

929

};

930

931

/**

932

* Create cylinder geometry

933

* @param radiusTop - Top radius

934

* @param radiusBottom - Bottom radius

935

* @param height - Cylinder height

936

* @param radialSegments - Radial segments

937

* @param heightSegments - Height segments

938

* @param openEnded - Open ended cylinder

939

* @param thetaStart - Start angle

940

* @param thetaLength - Sweep angle

941

*/

942

constructor(

943

radiusTop?: number,

944

radiusBottom?: number,

945

height?: number,

946

radialSegments?: number,

947

heightSegments?: number,

948

openEnded?: boolean,

949

thetaStart?: number,

950

thetaLength?: number

951

);

952

}

953

954

/**

955

* Cone geometry (cylinder with zero top radius)

956

*/

957

class ConeGeometry extends CylinderGeometry {

958

/**

959

* Create cone geometry

960

* @param radius - Base radius

961

* @param height - Cone height

962

* @param radialSegments - Radial segments

963

* @param heightSegments - Height segments

964

* @param openEnded - Open ended cone

965

* @param thetaStart - Start angle

966

* @param thetaLength - Sweep angle

967

*/

968

constructor(

969

radius?: number,

970

height?: number,

971

radialSegments?: number,

972

heightSegments?: number,

973

openEnded?: boolean,

974

thetaStart?: number,

975

thetaLength?: number

976

);

977

}

978

979

/**

980

* Rectangular plane geometry

981

*/

982

class PlaneGeometry extends BufferGeometry {

983

/** Geometry parameters */

984

readonly parameters: {

985

width: number;

986

height: number;

987

widthSegments: number;

988

heightSegments: number;

989

};

990

991

/**

992

* Create plane geometry

993

* @param width - Plane width

994

* @param height - Plane height

995

* @param widthSegments - Width segments

996

* @param heightSegments - Height segments

997

*/

998

constructor(

999

width?: number,

1000

height?: number,

1001

widthSegments?: number,

1002

heightSegments?: number

1003

);

1004

}

1005

1006

/**

1007

* Circle/sector geometry

1008

*/

1009

class CircleGeometry extends BufferGeometry {

1010

/** Geometry parameters */

1011

readonly parameters: {

1012

radius: number;

1013

segments: number;

1014

thetaStart: number;

1015

thetaLength: number;

1016

};

1017

1018

/**

1019

* Create circle geometry

1020

* @param radius - Circle radius

1021

* @param segments - Number of segments

1022

* @param thetaStart - Start angle

1023

* @param thetaLength - Sweep angle

1024

*/

1025

constructor(

1026

radius?: number,

1027

segments?: number,

1028

thetaStart?: number,

1029

thetaLength?: number

1030

);

1031

}

1032

1033

/**

1034

* Ring/annulus geometry

1035

*/

1036

class RingGeometry extends BufferGeometry {

1037

/** Geometry parameters */

1038

readonly parameters: {

1039

innerRadius: number;

1040

outerRadius: number;

1041

thetaSegments: number;

1042

phiSegments: number;

1043

thetaStart: number;

1044

thetaLength: number;

1045

};

1046

1047

/**

1048

* Create ring geometry

1049

* @param innerRadius - Inner radius

1050

* @param outerRadius - Outer radius

1051

* @param thetaSegments - Angular segments

1052

* @param phiSegments - Radial segments

1053

* @param thetaStart - Start angle

1054

* @param thetaLength - Sweep angle

1055

*/

1056

constructor(

1057

innerRadius?: number,

1058

outerRadius?: number,

1059

thetaSegments?: number,

1060

phiSegments?: number,

1061

thetaStart?: number,

1062

thetaLength?: number

1063

);

1064

}

1065

1066

/**

1067

* Torus (doughnut) geometry

1068

*/

1069

class TorusGeometry extends BufferGeometry {

1070

/** Geometry parameters */

1071

readonly parameters: {

1072

radius: number;

1073

tube: number;

1074

radialSegments: number;

1075

tubularSegments: number;

1076

arc: number;

1077

};

1078

1079

/**

1080

* Create torus geometry

1081

* @param radius - Major radius

1082

* @param tube - Tube radius

1083

* @param radialSegments - Radial segments

1084

* @param tubularSegments - Tubular segments

1085

* @param arc - Central arc angle

1086

*/

1087

constructor(

1088

radius?: number,

1089

tube?: number,

1090

radialSegments?: number,

1091

tubularSegments?: number,

1092

arc?: number

1093

);

1094

}

1095

1096

/**

1097

* Torus knot geometry

1098

*/

1099

class TorusKnotGeometry extends BufferGeometry {

1100

/** Geometry parameters */

1101

readonly parameters: {

1102

radius: number;

1103

tube: number;

1104

tubularSegments: number;

1105

radialSegments: number;

1106

p: number;

1107

q: number;

1108

};

1109

1110

/**

1111

* Create torus knot geometry

1112

* @param radius - Major radius

1113

* @param tube - Tube radius

1114

* @param tubularSegments - Tubular segments

1115

* @param radialSegments - Radial segments

1116

* @param p - Winding parameter p

1117

* @param q - Winding parameter q

1118

*/

1119

constructor(

1120

radius?: number,

1121

tube?: number,

1122

tubularSegments?: number,

1123

radialSegments?: number,

1124

p?: number,

1125

q?: number

1126

);

1127

}

1128

```

1129

1130

**Usage Examples:**

1131

1132

```typescript

1133

import {

1134

BoxGeometry,

1135

SphereGeometry,

1136

CylinderGeometry,

1137

PlaneGeometry,

1138

TorusGeometry

1139

} from 'three';

1140

1141

// Basic shapes

1142

const box = new BoxGeometry(2, 2, 2);

1143

const sphere = new SphereGeometry(1, 32, 32);

1144

const cylinder = new CylinderGeometry(1, 1, 2, 32);

1145

1146

// Detailed shapes

1147

const detailedSphere = new SphereGeometry(

1148

1, // radius

1149

64, // width segments

1150

32, // height segments

1151

0, // phi start

1152

Math.PI // phi length (hemisphere)

1153

);

1154

1155

// Ground plane

1156

const ground = new PlaneGeometry(100, 100, 10, 10);

1157

ground.rotateX(-Math.PI / 2); // Make horizontal

1158

1159

// Torus with custom parameters

1160

const torus = new TorusGeometry(

1161

2, // radius

1162

0.5, // tube

1163

16, // radial segments

1164

100, // tubular segments

1165

Math.PI * 2 // full circle

1166

);

1167

1168

// Access parameters

1169

console.log('Box parameters:', box.parameters);

1170

```

1171

1172

### Complex Geometries

1173

1174

Advanced geometry types for complex shapes and special use cases.

1175

1176

```typescript { .api }

1177

import {

1178

TetrahedronGeometry,

1179

OctahedronGeometry,

1180

DodecahedronGeometry,

1181

IcosahedronGeometry,

1182

CapsuleGeometry,

1183

LatheGeometry,

1184

ExtrudeGeometry,

1185

TubeGeometry,

1186

ShapeGeometry,

1187

EdgesGeometry,

1188

WireframeGeometry

1189

} from 'three';

1190

1191

/**

1192

* Regular polyhedron geometries

1193

*/

1194

class TetrahedronGeometry extends BufferGeometry {

1195

constructor(radius?: number, detail?: number);

1196

}

1197

1198

class OctahedronGeometry extends BufferGeometry {

1199

constructor(radius?: number, detail?: number);

1200

}

1201

1202

class DodecahedronGeometry extends BufferGeometry {

1203

constructor(radius?: number, detail?: number);

1204

}

1205

1206

class IcosahedronGeometry extends BufferGeometry {

1207

constructor(radius?: number, detail?: number);

1208

}

1209

1210

/**

1211

* Capsule geometry (cylinder with rounded ends)

1212

*/

1213

class CapsuleGeometry extends BufferGeometry {

1214

readonly parameters: {

1215

radius: number;

1216

length: number;

1217

capSegments: number;

1218

radialSegments: number;

1219

};

1220

1221

constructor(

1222

radius?: number,

1223

length?: number,

1224

capSegments?: number,

1225

radialSegments?: number

1226

);

1227

}

1228

1229

/**

1230

* Lathe geometry (revolve 2D shape around axis)

1231

*/

1232

class LatheGeometry extends BufferGeometry {

1233

readonly parameters: {

1234

points: Vector2[];

1235

segments: number;

1236

phiStart: number;

1237

phiLength: number;

1238

};

1239

1240

constructor(

1241

points: Vector2[],

1242

segments?: number,

1243

phiStart?: number,

1244

phiLength?: number

1245

);

1246

}

1247

1248

/**

1249

* Extrude 2D shape into 3D geometry

1250

*/

1251

class ExtrudeGeometry extends BufferGeometry {

1252

readonly parameters: {

1253

shapes: Shape | Shape[];

1254

options: ExtrudeGeometryOptions;

1255

};

1256

1257

constructor(shapes: Shape | Shape[], options?: ExtrudeGeometryOptions);

1258

}

1259

1260

interface ExtrudeGeometryOptions {

1261

/** Extrusion depth */

1262

depth?: number;

1263

1264

/** Number of depth segments */

1265

steps?: number;

1266

1267

/** Bevel enabled */

1268

bevelEnabled?: boolean;

1269

1270

/** Bevel thickness */

1271

bevelThickness?: number;

1272

1273

/** Bevel size */

1274

bevelSize?: number;

1275

1276

/** Bevel offset */

1277

bevelOffset?: number;

1278

1279

/** Bevel segments */

1280

bevelSegments?: number;

1281

1282

/** Extrude path curve */

1283

extrudePath?: Curve<Vector3>;

1284

1285

/** UV generator */

1286

UVGenerator?: UVGenerator;

1287

}

1288

1289

/**

1290

* Tube geometry following a 3D curve

1291

*/

1292

class TubeGeometry extends BufferGeometry {

1293

readonly parameters: {

1294

path: Curve<Vector3>;

1295

tubularSegments: number;

1296

radius: number;

1297

radialSegments: number;

1298

closed: boolean;

1299

};

1300

1301

/** Tangent vectors along path */

1302

tangents: Vector3[];

1303

1304

/** Normal vectors along path */

1305

normals: Vector3[];

1306

1307

/** Binormal vectors along path */

1308

binormals: Vector3[];

1309

1310

constructor(

1311

path: Curve<Vector3>,

1312

tubularSegments?: number,

1313

radius?: number,

1314

radialSegments?: number,

1315

closed?: boolean

1316

);

1317

}

1318

1319

/**

1320

* 2D shape geometry

1321

*/

1322

class ShapeGeometry extends BufferGeometry {

1323

readonly parameters: {

1324

shapes: Shape | Shape[];

1325

curveSegments: number;

1326

};

1327

1328

constructor(shapes: Shape | Shape[], curveSegments?: number);

1329

}

1330

1331

/**

1332

* Edge-only geometry from existing geometry

1333

*/

1334

class EdgesGeometry extends BufferGeometry {

1335

readonly parameters: {

1336

geometry: BufferGeometry;

1337

thresholdAngle: number;

1338

};

1339

1340

constructor(geometry: BufferGeometry, thresholdAngle?: number);

1341

}

1342

1343

/**

1344

* Wireframe geometry from existing geometry

1345

*/

1346

class WireframeGeometry extends BufferGeometry {

1347

constructor(geometry: BufferGeometry);

1348

}

1349

```

1350

1351

**Usage Examples:**

1352

1353

```typescript

1354

import {

1355

CapsuleGeometry,

1356

LatheGeometry,

1357

ExtrudeGeometry,

1358

TubeGeometry,

1359

EdgesGeometry,

1360

Vector2,

1361

Shape,

1362

CatmullRomCurve3

1363

} from 'three';

1364

1365

// Capsule for rounded cylinders

1366

const capsule = new CapsuleGeometry(0.5, 2, 8, 32);

1367

1368

// Lathe geometry from profile

1369

const points = [

1370

new Vector2(0, 0),

1371

new Vector2(1, 0),

1372

new Vector2(1, 1),

1373

new Vector2(0.5, 2),

1374

new Vector2(0, 2)

1375

];

1376

const lathe = new LatheGeometry(points, 32);

1377

1378

// Extrude 2D shape

1379

const shape = new Shape();

1380

shape.moveTo(0, 0);

1381

shape.lineTo(0, 1);

1382

shape.lineTo(1, 1);

1383

shape.lineTo(1, 0);

1384

shape.lineTo(0, 0);

1385

1386

const extruded = new ExtrudeGeometry(shape, {

1387

depth: 0.5,

1388

bevelEnabled: true,

1389

bevelThickness: 0.1,

1390

bevelSize: 0.05,

1391

bevelSegments: 8

1392

});

1393

1394

// Tube following curve

1395

const curve = new CatmullRomCurve3([

1396

new Vector3(-2, 0, 0),

1397

new Vector3(0, 2, 0),

1398

new Vector3(2, 0, 0),

1399

new Vector3(0, -2, 0)

1400

]);

1401

1402

const tube = new TubeGeometry(curve, 64, 0.2, 8, true);

1403

1404

// Edge geometry for wireframe overlay

1405

const box = new BoxGeometry();

1406

const edges = new EdgesGeometry(box);

1407

```

1408

1409

The geometry system provides comprehensive vertex data management through BufferGeometry and efficient attribute handling with typed arrays. The extensive collection of primitive geometries covers most common 3D shapes while supporting custom geometry creation for specialized needs.