The circular buffer class can be used to cache objects that don't need to be created every frame.
This structure is used for e.g. Vector3 or Quaternion objects in the engine when calling getTempVector3 or getTempQuaternion.

Example: Create a circular buffer that caches Vector3 objects. Max size is 10.

const buffer = new CircularBuffer(() => new Vector3(), 10);
const vec = buffer.get();

Example: Create a circular buffer that caches Quaternion objects. Max size is 1000.

const buffer = new CircularBuffer(() => new Quaternion(), 1000);
const quat = buffer.get();

Type Parameters

  • T

Constructors

Methods

Constructors

Methods

  • Returns T

Generated using TypeDoc