cables_dev/cables/src/core/cg/cg_matrixstack.js
const MatrixStack = function ()
{
this._arr = [mat4.create()];
this._index = 0;
this.stateCounter = 0;
};
MatrixStack.prototype.push = function (m)
{
this._index++;
this.stateCounter++;
if (this._index == this._arr.length)
{
const copy = mat4.create();
this._arr.push(copy);
}
mat4.copy(this._arr[this._index], m || this._arr[this._index - 1]);
return this._arr[this._index];
};
MatrixStack.prototype.pop = function ()
{
this.stateCounter++;
this._index--;
if (this._index < 0) this._index = 0;
return this._arr[this._index];
};
MatrixStack.prototype.length = function ()
{
return this._index;
};
export { MatrixStack };