Creates a new Barrel geometry.
Configuration options.
Protected_Cached bounding volume to prevent re-allocation
Protected_The indices of the geometry for indexed rendering.
Protected_Whether the geometry is purely line-based.
Protected Optional_Optional skinning joints (4 IDs per vertex).
Protected_The normals of the geometry (nx, ny, nz).
Protected_The tangents of the geometry (tx, ty, tz).
Protected_The UV coordinates of the geometry (u, v).
Protected_The vertices of the geometry (x, y, z).
Protected Optional_Optional skinning weights (4 weights per vertex).
Protected_The indices for wireframe rendering.
The total height (h).
The number of height subdivisions.
Whether the barrel ends are open (no caps).
The number of radial subdivisions.
The bottom radius (r_bottom) at y = -height/2.
The middle radius (R) at equator y = 0.
The top radius (r_top) at y = +height/2.
The central angle in radians.
The start angle in radians.
Gets the average end radius $r = (r_{\text{top}} + r_{\text{bottom}}) / 2$.
Protected_Helper method to create an appropriately sized index array. Automatically chooses between 16-bit and 32-bit indices based on vertex count.
The number of indices needed.
A Uint16Array or Uint32Array.
Applies a Matrix4 transformation to all geometry vertices in-place.
The transformation matrix.
this
Computes the normals of the geometry using the current vertices and indices. Averages normals for shared vertices.
Computes the tangents of the geometry based on normals and UVs. Required for normal mapping.
Computes the wireframe indices (line-segments) from the current triangle topology.
ProtectedgenerateGenerates the raw geometry data. Must be implemented by subclasses.
Returns a bounding volume that encapsulates this geometry.
The bounding volume.
Calculates the space diagonal $d = \sqrt{h^2 + 4 r^2}$ between opposing rim edges.
Returns the raw geometry data ready for GPU upload.
The geometry data interface.
Evaluates the radius $r(y)$ of the parabolic barrel profile at height $y \in [-h/2, +h/2]$.
Vertical height coordinate.
Calculates the barrel volume using Kepler's Barrel Formula (Keplersche Fassregel). $V \approx \frac{\theta_{\text{len}}}{2\pi} \cdot \frac{\pi \cdot h}{3} \left(2 R^2 + \frac{r_{\text{top}}^2 + r_{\text{bottom}}^2}{2}\right)$.
Rotates the geometry vertices around the X-axis in-place.
The rotation angle in radians.
this
Rotates the geometry vertices around the Y-axis in-place.
The rotation angle in radians.
this
Rotates the geometry vertices around the Z-axis in-place.
The rotation angle in radians.
this
Scales the geometry vertices in-place.
The scale factor.
this
A barrel geometry (Fass / wooden barrel / storage cask).
Mathematically, a barrel is a body of revolution with a bulging profile (often modelled as a parabolic arc or prolate spheroid truncated at both ends by planar circular caps).
Mathematical formulas:
See
https://rechneronline.de/pi/fass.php