Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class Capsule

    A capsule geometry consisting of a cylinder with hemispherical caps. Also known as a spherocylinder (Sphärozylinder).

    Mathematical formulas:

    • Sphere radius: $r$
    • Cylinder length: $h$
    • Total capsule length: $l = h + 2r$
    • Surface area: $A = 2\pi r(2r + h) = 4\pi r^2 + 2\pi r h$
    • Volume: $V = \pi r^2 (\frac{4}{3}r + h) = \frac{4}{3}\pi r^3 + \pi r^2 h$
    • Surface-to-volume ratio: $A / V$

    Hierarchy (View Summary)

    Index
    _cachedBoundingVolume: BoundingVolume | undefined = undefined

    Cached bounding volume to prevent re-allocation

    _indices:
        | Uint16Array<ArrayBufferLike>
        | Uint32Array<ArrayBufferLike>
        | undefined = undefined

    The indices of the geometry for indexed rendering.

    _isLineGeometry: boolean = false

    Whether the geometry is purely line-based.

    _joints?: Float32Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> = undefined

    Optional skinning joints (4 IDs per vertex).

    _normals: Float32Array = ...

    The normals of the geometry (nx, ny, nz).

    _tangents: Float32Array = ...

    The tangents of the geometry (tx, ty, tz).

    _uvs: Float32Array = ...

    The UV coordinates of the geometry (u, v).

    _vertices: Float32Array = ...

    The vertices of the geometry (x, y, z).

    _weights?: Float32Array<ArrayBufferLike> = undefined

    Optional skinning weights (4 weights per vertex).

    _wireframeIndices:
        | Uint16Array<ArrayBufferLike>
        | Uint32Array<ArrayBufferLike>
        | undefined = undefined

    The indices for wireframe rendering.

    capSegments: number

    The number of segments for the caps.

    length: number

    The length of the cylinder part.

    radialSegments: number

    The number of radial segments.

    radius: number

    The radius of the capsule.

    • Helper method to create an appropriately sized index array. Automatically chooses between 16-bit and 32-bit indices based on vertex count.

      Parameters

      • indexCount: number

        The number of indices needed.

      Returns Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

      A Uint16Array or Uint32Array.

    • Calculates the cylinder body lateral area $A_{\text{cyl}} = 2\pi r h$.

      Returns number

    • Calculates the surface area of both hemispherical caps combined $A_{\text{caps}} = 4\pi r^2$.

      Returns number

    • Calculates the surface-to-volume ratio $A / V$.

      Returns number

    • Calculates the total tip-to-tip length $l = h + 2r$.

      Returns number

    • Calculates the total surface area $A = 2\pi r (2r + h) = 4\pi r^2 + 2\pi r h$.

      Returns number

    • Calculates the total volume $V = \pi r^2 (\frac{4}{3}r + h) = \frac{4}{3}\pi r^3 + \pi r^2 h$.

      Returns number