Capítulo 521 de 859

Chapter 521: Capsule

Core Idea

A capsule is essentially a cylinder with hemispherical caps at both ends. It can be thought of as a swept sphere, where a sphere is moved along a line segment.

Capsules are often used as bounding volumes (next to AABBs and bounding spheres).

Key Concepts

  • end : Vector3: The end vector.
  • radius : number: The capsule's radius.
  • start : Vector3: The start vector.

Code Examples

import { Capsule } from 'three/addons/math/Capsule.js';
  • What it demonstrates: Typical usage of Capsule.

Reference Tables

Constructor

Signature
new Capsule( start : Vector3, end : Vector3, radius : number )

Properties

PropertyDescription
.end : Vector3The end vector.
.radius : numberThe capsule's radius.
.start : Vector3The start vector.

Methods

MethodDescription
.clone() : CapsuleReturns a new capsule with copied values from this instance.
.copy( capsule : Capsule ) : CapsuleCopies the values of the given capsule to this instance.
.getCenter( target : Vector3 ) : Vector3Returns the center point of this capsule.
.intersectsBox( box : Box3 ) : booleanReturns true if the given bounding box intersects with this capsule.
.set( start : Vector3, end : Vector3, radius : number ) : CapsuleSets the capsule components to the given values. Please note that this method only copies the values from the given objects.
.translate( v : Vector3 ) : CapsuleAdds the given offset to this capsule, effectively moving it in 3D space.

Key Takeaways

  1. Most relevant properties: end, radius, start.
  2. Key methods: clone, copy, getCenter, intersectsBox.

Connects To