1 | "use strict";
|
2 | var constants = require("@pixi/constants"), Buffer = require("../geometry/Buffer.js");
|
3 | let UID = 0;
|
4 | class UniformGroup {
|
5 | |
6 |
|
7 |
|
8 |
|
9 |
|
10 | constructor(uniforms, isStatic, isUbo) {
|
11 | this.group = !0, this.syncUniforms = {}, this.dirtyId = 0, this.id = UID++, this.static = !!isStatic, this.ubo = !!isUbo, uniforms instanceof Buffer.Buffer ? (this.buffer = uniforms, this.buffer.type = constants.BUFFER_TYPE.UNIFORM_BUFFER, this.autoManage = !1, this.ubo = !0) : (this.uniforms = uniforms, this.ubo && (this.buffer = new Buffer.Buffer(new Float32Array(1)), this.buffer.type = constants.BUFFER_TYPE.UNIFORM_BUFFER, this.autoManage = !0));
|
12 | }
|
13 | update() {
|
14 | this.dirtyId++, !this.autoManage && this.buffer && this.buffer.update();
|
15 | }
|
16 | add(name, uniforms, _static) {
|
17 | if (!this.ubo)
|
18 | this.uniforms[name] = new UniformGroup(uniforms, _static);
|
19 | else
|
20 | throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");
|
21 | }
|
22 | static from(uniforms, _static, _ubo) {
|
23 | return new UniformGroup(uniforms, _static, _ubo);
|
24 | }
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | static uboFrom(uniforms, _static) {
|
31 | return new UniformGroup(uniforms, _static ?? !0, !0);
|
32 | }
|
33 | }
|
34 | exports.UniformGroup = UniformGroup;
|
35 |
|