UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

41 lines (38 loc) 1.11 kB
'use strict'; "use strict"; class UboBatch { constructor({ minUniformOffsetAlignment }) { this._minUniformOffsetAlignment = 256; this.byteIndex = 0; this._minUniformOffsetAlignment = minUniformOffsetAlignment; this.data = new Float32Array(65535); } clear() { this.byteIndex = 0; } addEmptyGroup(size) { if (size > this._minUniformOffsetAlignment / 4) { throw new Error(`UniformBufferBatch: array is too large: ${size * 4}`); } const start = this.byteIndex; let newSize = start + size * 4; newSize = Math.ceil(newSize / this._minUniformOffsetAlignment) * this._minUniformOffsetAlignment; if (newSize > this.data.length * 4) { throw new Error("UniformBufferBatch: ubo batch got too big"); } this.byteIndex = newSize; return start; } addGroup(array) { const offset = this.addEmptyGroup(array.length); for (let i = 0; i < array.length; i++) { this.data[offset / 4 + i] = array[i]; } return offset; } destroy() { this.data = null; } } exports.UboBatch = UboBatch; //# sourceMappingURL=UboBatch.js.map