UNPKG

@pixi/core

Version:
49 lines (44 loc) 1.16 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var constants = require('@pixi/constants'); var runner = require('@pixi/runner'); let UID = 0; class Buffer { constructor(data, _static = true, index = false) { this.data = data || new Float32Array(1); this._glBuffers = {}; this._updateID = 0; this.index = index; this.static = _static; this.id = UID++; this.disposeRunner = new runner.Runner("disposeBuffer"); } update(data) { if (data instanceof Array) { data = new Float32Array(data); } this.data = data || this.data; this._updateID++; } dispose() { this.disposeRunner.emit(this, false); } destroy() { this.dispose(); this.data = null; } set index(value) { this.type = value ? constants.BUFFER_TYPE.ELEMENT_ARRAY_BUFFER : constants.BUFFER_TYPE.ARRAY_BUFFER; } get index() { return this.type === constants.BUFFER_TYPE.ELEMENT_ARRAY_BUFFER; } static from(data) { if (data instanceof Array) { data = new Float32Array(data); } return new Buffer(data); } } exports.Buffer = Buffer; //# sourceMappingURL=Buffer.js.map