'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var uid = require('../../../../utils/data/uid.js');
var defaultUniformValue = require('./utils/defaultUniformValue.js');

const _UniformGroup = class {
  constructor(uniformStructures, options) {
    this.touched = 0;
    this.uid = uid.uid("uniform");
    this.resourceType = "uniformGroup";
    this.resourceId = this.uid;
    // to identify this as a uniform group
    this.isUniformGroup = true;
    this.dirtyId = 0;
    options = { ..._UniformGroup.DEFAULT, ...options };
    this.uniformStructures = uniformStructures;
    const uniforms = {};
    for (const i in uniformStructures) {
      const uniformData = uniformStructures[i];
      uniformData.name = i;
      uniformData.size = uniformData.size ?? 1;
      uniformData.value ?? (uniformData.value = defaultUniformValue.defaultUniformValue(uniformData.type, uniformData.size));
      uniforms[i] = uniformData.value;
    }
    this.uniforms = uniforms;
    this.dirtyId = 1;
    this.ubo = options.ubo;
    this.isStatic = options.isStatic;
    this.signature = Object.keys(uniforms).map(
      (i) => `${i}-${uniformStructures[i].type}`
    ).join("-");
  }
  update() {
    this.dirtyId++;
  }
};
let UniformGroup = _UniformGroup;
UniformGroup.DEFAULT = {
  ubo: false,
  isStatic: false
};

exports.UniformGroup = UniformGroup;
//# sourceMappingURL=UniformGroup.js.map
