UNPKG

@pixi/core

Version:
54 lines (49 loc) 1.5 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var constants = require('@pixi/constants'); var Buffer = require('../geometry/Buffer.js'); let UID = 0; class UniformGroup { constructor(uniforms, isStatic, isUbo) { this.group = true; this.syncUniforms = {}; this.dirtyId = 0; this.id = UID++; this.static = !!isStatic; this.ubo = !!isUbo; if (uniforms instanceof Buffer.Buffer) { this.buffer = uniforms; this.buffer.type = constants.BUFFER_TYPE.UNIFORM_BUFFER; this.autoManage = false; this.ubo = true; } else { this.uniforms = uniforms; if (this.ubo) { this.buffer = new Buffer.Buffer(new Float32Array(1)); this.buffer.type = constants.BUFFER_TYPE.UNIFORM_BUFFER; this.autoManage = true; } } } update() { this.dirtyId++; if (!this.autoManage && this.buffer) { this.buffer.update(); } } add(name, uniforms, _static) { if (!this.ubo) { this.uniforms[name] = new UniformGroup(uniforms, _static); } else { throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them"); } } static from(uniforms, _static, _ubo) { return new UniformGroup(uniforms, _static, _ubo); } static uboFrom(uniforms, _static) { return new UniformGroup(uniforms, _static ?? true, true); } } exports.UniformGroup = UniformGroup; //# sourceMappingURL=UniformGroup.js.map