import { Texture3DLayout } from './Texture3DLayout.mjs';

let UID = 0;
class Texture3D {
  constructor({ source, layout, label, data = null }) {
    this.id = UID++;
    this.dirty = false;
    this.isEmpty = false;
    this.label = label;
    this.data = null;
    if (!source && !layout) {
      throw Error("For Texture3D source or layout is needed");
    }
    this.source = source;
    if (layout) {
      if (layout instanceof Texture3DLayout) {
        this.layout = layout;
      } else {
        this.layout = new Texture3DLayout(layout);
      }
    } else {
      this.layout = new Texture3DLayout({
        size: source,
        offset: { x: 0, y: 0, z: 0 }
      });
    }
    if (data) {
      this.update(data);
    }
  }
  update(data) {
    const rs = this.source.resource;
    if (!this.dirty && rs.useSubRegions) {
      rs.regionsToUpdate.push(this);
      this.source.update();
    }
    this.dirty = true;
    if (data) {
      this.data = data;
    }
  }
  castToBaseTexture() {
    return this.source;
  }
}

export { Texture3D };
//# sourceMappingURL=Texture3D.mjs.map
