holostaff-widget 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CanvasRenderer-Cnd4gbWc.js → CanvasRenderer-J_XwG2_5.js} +50 -50
- package/dist/{CanvasRenderer-Cnd4gbWc.js.map → CanvasRenderer-J_XwG2_5.js.map} +1 -1
- package/dist/Filter-GqToX76B.js +670 -0
- package/dist/Filter-GqToX76B.js.map +1 -0
- package/dist/GpuStencilModesToPixi-Cc8Nerk4.js +222 -0
- package/dist/GpuStencilModesToPixi-Cc8Nerk4.js.map +1 -0
- package/dist/{RenderTargetSystem-oYKzpCzn.js → RenderTargetSystem-Bl4mRBf3.js} +327 -391
- package/dist/RenderTargetSystem-Bl4mRBf3.js.map +1 -0
- package/dist/WebGLRenderer-BtNMOOvs.js +2237 -0
- package/dist/WebGLRenderer-BtNMOOvs.js.map +1 -0
- package/dist/{WebGPURenderer-CwI3VE9f.js → WebGPURenderer-89fMKfXn.js} +281 -374
- package/dist/WebGPURenderer-89fMKfXn.js.map +1 -0
- package/dist/{browserAll-DrS3vkVd.js → browserAll-B7LFPR0f.js} +3 -3
- package/dist/{browserAll-DrS3vkVd.js.map → browserAll-B7LFPR0f.js.map} +1 -1
- package/dist/{getTextureBatchBindGroup-C0vQRfwn.js → getTextureBatchBindGroup-CMmHwizJ.js} +3 -3
- package/dist/{getTextureBatchBindGroup-C0vQRfwn.js.map → getTextureBatchBindGroup-CMmHwizJ.js.map} +1 -1
- package/dist/hs-widget.es.js +2 -2
- package/dist/hs-widget.umd.js +360 -346
- package/dist/hs-widget.umd.js.map +1 -1
- package/dist/{index-B7aJuEyO.js → index-BpOQ7Z5z.js} +11185 -9093
- package/dist/index-BpOQ7Z5z.js.map +1 -0
- package/dist/{webworkerAll-BNR1nfRY.js → webworkerAll-CAG5YOrW.js} +12 -12
- package/dist/{webworkerAll-BNR1nfRY.js.map → webworkerAll-CAG5YOrW.js.map} +1 -1
- package/package.json +1 -1
- package/dist/BufferResource-BsetVigd.js +0 -537
- package/dist/BufferResource-BsetVigd.js.map +0 -1
- package/dist/Geometry-C_hP7eDY.js +0 -1017
- package/dist/Geometry-C_hP7eDY.js.map +0 -1
- package/dist/RenderTargetSystem-oYKzpCzn.js.map +0 -1
- package/dist/WebGLRenderer-CnlX2m2i.js +0 -2939
- package/dist/WebGLRenderer-CnlX2m2i.js.map +0 -1
- package/dist/WebGPURenderer-CwI3VE9f.js.map +0 -1
- package/dist/index-B7aJuEyO.js.map +0 -1
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
import { D as I, c as L, g as X, b as z, u as Z, d as Y } from "./index-BpOQ7Z5z.js";
|
|
2
|
+
let p;
|
|
3
|
+
function J() {
|
|
4
|
+
return (!p || p != null && p.isContextLost()) && (p = I.get().createCanvas().getContext("webgl", {})), p;
|
|
5
|
+
}
|
|
6
|
+
let _;
|
|
7
|
+
function Q() {
|
|
8
|
+
if (!_) {
|
|
9
|
+
_ = "mediump";
|
|
10
|
+
const r = J();
|
|
11
|
+
r && r.getShaderPrecisionFormat && (_ = r.getShaderPrecisionFormat(r.FRAGMENT_SHADER, r.HIGH_FLOAT).precision ? "highp" : "mediump");
|
|
12
|
+
}
|
|
13
|
+
return _;
|
|
14
|
+
}
|
|
15
|
+
function tt(r, t, e) {
|
|
16
|
+
return t ? r : e ? (r = r.replace("out vec4 finalColor;", ""), `
|
|
17
|
+
|
|
18
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
19
|
+
#define in varying
|
|
20
|
+
#define finalColor gl_FragColor
|
|
21
|
+
#define texture texture2D
|
|
22
|
+
#endif
|
|
23
|
+
${r}
|
|
24
|
+
`) : `
|
|
25
|
+
|
|
26
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
27
|
+
#define in attribute
|
|
28
|
+
#define out varying
|
|
29
|
+
#endif
|
|
30
|
+
${r}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
function et(r, t, e) {
|
|
34
|
+
const s = e ? t.maxSupportedFragmentPrecision : t.maxSupportedVertexPrecision;
|
|
35
|
+
if (r.substring(0, 9) !== "precision") {
|
|
36
|
+
let i = e ? t.requestedFragmentPrecision : t.requestedVertexPrecision;
|
|
37
|
+
return i === "highp" && s !== "highp" && (i = "mediump"), `precision ${i} float;
|
|
38
|
+
${r}`;
|
|
39
|
+
} else if (s !== "highp" && r.substring(0, 15) === "precision highp")
|
|
40
|
+
return r.replace("precision highp", "precision mediump");
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
43
|
+
function st(r, t) {
|
|
44
|
+
return t ? `#version 300 es
|
|
45
|
+
${r}` : r;
|
|
46
|
+
}
|
|
47
|
+
const rt = {}, it = {};
|
|
48
|
+
function nt(r, { name: t = "pixi-program" }, e = !0) {
|
|
49
|
+
t = t.replace(/\s+/g, "-"), t += e ? "-fragment" : "-vertex";
|
|
50
|
+
const s = e ? rt : it;
|
|
51
|
+
return s[t] ? (s[t]++, t += `-${s[t]}`) : s[t] = 1, r.indexOf("#define SHADER_NAME") !== -1 ? r : `${`#define SHADER_NAME ${t}`}
|
|
52
|
+
${r}`;
|
|
53
|
+
}
|
|
54
|
+
function ot(r, t) {
|
|
55
|
+
return t ? r.replace("#version 300 es", "") : r;
|
|
56
|
+
}
|
|
57
|
+
const P = {
|
|
58
|
+
// strips any version headers..
|
|
59
|
+
stripVersion: ot,
|
|
60
|
+
// adds precision string if not already present
|
|
61
|
+
ensurePrecision: et,
|
|
62
|
+
// add some defines if WebGL1 to make it more compatible with WebGL2 shaders
|
|
63
|
+
addProgramDefines: tt,
|
|
64
|
+
// add the program name to the shader
|
|
65
|
+
setProgramName: nt,
|
|
66
|
+
// add the version string to the shader header
|
|
67
|
+
insertVersion: st
|
|
68
|
+
}, m = /* @__PURE__ */ Object.create(null), V = class O {
|
|
69
|
+
/**
|
|
70
|
+
* Creates a shiny new GlProgram. Used by WebGL renderer.
|
|
71
|
+
* @param options - The options for the program.
|
|
72
|
+
*/
|
|
73
|
+
constructor(t) {
|
|
74
|
+
t = { ...O.defaultOptions, ...t };
|
|
75
|
+
const e = t.fragment.indexOf("#version 300 es") !== -1, s = {
|
|
76
|
+
stripVersion: e,
|
|
77
|
+
ensurePrecision: {
|
|
78
|
+
requestedFragmentPrecision: t.preferredFragmentPrecision,
|
|
79
|
+
requestedVertexPrecision: t.preferredVertexPrecision,
|
|
80
|
+
maxSupportedVertexPrecision: "highp",
|
|
81
|
+
maxSupportedFragmentPrecision: Q()
|
|
82
|
+
},
|
|
83
|
+
setProgramName: {
|
|
84
|
+
name: t.name
|
|
85
|
+
},
|
|
86
|
+
addProgramDefines: e,
|
|
87
|
+
insertVersion: e
|
|
88
|
+
};
|
|
89
|
+
let i = t.fragment, n = t.vertex;
|
|
90
|
+
Object.keys(P).forEach((a) => {
|
|
91
|
+
const o = s[a];
|
|
92
|
+
i = P[a](i, o, !0), n = P[a](n, o, !1);
|
|
93
|
+
}), this.fragment = i, this.vertex = n, this.transformFeedbackVaryings = t.transformFeedbackVaryings, this._key = L(`${this.vertex}:${this.fragment}`, "gl-program");
|
|
94
|
+
}
|
|
95
|
+
/** destroys the program */
|
|
96
|
+
destroy() {
|
|
97
|
+
this.fragment = null, this.vertex = null, this._attributeData = null, this._uniformData = null, this._uniformBlockData = null, this.transformFeedbackVaryings = null, m[this._cacheKey] = null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Helper function that creates a program for a given source.
|
|
101
|
+
* It will check the program cache if the program has already been created.
|
|
102
|
+
* If it has that one will be returned, if not a new one will be created and cached.
|
|
103
|
+
* @param options - The options for the program.
|
|
104
|
+
* @returns A program using the same source
|
|
105
|
+
*/
|
|
106
|
+
static from(t) {
|
|
107
|
+
const e = `${t.vertex}:${t.fragment}`;
|
|
108
|
+
return m[e] || (m[e] = new O(t), m[e]._cacheKey = e), m[e];
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
V.defaultOptions = {
|
|
112
|
+
preferredVertexPrecision: "highp",
|
|
113
|
+
preferredFragmentPrecision: "mediump"
|
|
114
|
+
};
|
|
115
|
+
let U = V;
|
|
116
|
+
const at = {
|
|
117
|
+
f32: "float32",
|
|
118
|
+
"vec2<f32>": "float32x2",
|
|
119
|
+
"vec3<f32>": "float32x3",
|
|
120
|
+
"vec4<f32>": "float32x4",
|
|
121
|
+
vec2f: "float32x2",
|
|
122
|
+
vec3f: "float32x3",
|
|
123
|
+
vec4f: "float32x4",
|
|
124
|
+
i32: "sint32",
|
|
125
|
+
"vec2<i32>": "sint32x2",
|
|
126
|
+
"vec3<i32>": "sint32x3",
|
|
127
|
+
"vec4<i32>": "sint32x4",
|
|
128
|
+
vec2i: "sint32x2",
|
|
129
|
+
vec3i: "sint32x3",
|
|
130
|
+
vec4i: "sint32x4",
|
|
131
|
+
u32: "uint32",
|
|
132
|
+
"vec2<u32>": "uint32x2",
|
|
133
|
+
"vec3<u32>": "uint32x3",
|
|
134
|
+
"vec4<u32>": "uint32x4",
|
|
135
|
+
vec2u: "uint32x2",
|
|
136
|
+
vec3u: "uint32x3",
|
|
137
|
+
vec4u: "uint32x4",
|
|
138
|
+
bool: "uint32",
|
|
139
|
+
"vec2<bool>": "uint32x2",
|
|
140
|
+
"vec3<bool>": "uint32x3",
|
|
141
|
+
"vec4<bool>": "uint32x4"
|
|
142
|
+
}, B = /@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;
|
|
143
|
+
function C(r, t) {
|
|
144
|
+
let e;
|
|
145
|
+
for (; (e = B.exec(r)) !== null; ) {
|
|
146
|
+
const s = at[e[3]] ?? "float32";
|
|
147
|
+
t[e[2]] = {
|
|
148
|
+
location: parseInt(e[1], 10),
|
|
149
|
+
format: s,
|
|
150
|
+
stride: X(s).stride,
|
|
151
|
+
offset: 0,
|
|
152
|
+
instance: !1,
|
|
153
|
+
start: 0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
B.lastIndex = 0;
|
|
157
|
+
}
|
|
158
|
+
function ut(r) {
|
|
159
|
+
return r.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
160
|
+
}
|
|
161
|
+
function ct({ source: r, entryPoint: t }) {
|
|
162
|
+
const e = {}, s = ut(r), i = s.indexOf(`fn ${t}(`);
|
|
163
|
+
if (i === -1)
|
|
164
|
+
return e;
|
|
165
|
+
const n = s.indexOf("->", i);
|
|
166
|
+
if (n === -1)
|
|
167
|
+
return e;
|
|
168
|
+
const a = s.substring(i, n);
|
|
169
|
+
if (C(a, e), Object.keys(e).length === 0) {
|
|
170
|
+
const o = a.match(/\(\s*\w+\s*:\s*(\w+)/);
|
|
171
|
+
if (o) {
|
|
172
|
+
const d = o[1], c = new RegExp(`struct\\s+${d}\\s*\\{([^}]+)\\}`, "s"), u = s.match(c);
|
|
173
|
+
u && C(u[1], e);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return e;
|
|
177
|
+
}
|
|
178
|
+
function v(r) {
|
|
179
|
+
var f, h;
|
|
180
|
+
const t = /(^|[^/])@(group|binding)\(\d+\)[^;]+;/g, e = /@group\((\d+)\)/, s = /@binding\((\d+)\)/, i = /var(<[^>]+>)? (\w+)/, n = /:\s*([\w<>]+)/, a = /struct\s+(\w+)\s*{([^}]+)}/g, o = /(\w+)\s*:\s*([\w\<\>]+)/g, d = /struct\s+(\w+)/, c = (f = r.match(t)) == null ? void 0 : f.map((l) => ({
|
|
181
|
+
group: parseInt(l.match(e)[1], 10),
|
|
182
|
+
binding: parseInt(l.match(s)[1], 10),
|
|
183
|
+
name: l.match(i)[2],
|
|
184
|
+
isUniform: l.match(i)[1] === "<uniform>",
|
|
185
|
+
type: l.match(n)[1]
|
|
186
|
+
}));
|
|
187
|
+
if (!c)
|
|
188
|
+
return {
|
|
189
|
+
groups: [],
|
|
190
|
+
structs: []
|
|
191
|
+
};
|
|
192
|
+
const u = ((h = r.match(a)) == null ? void 0 : h.map((l) => {
|
|
193
|
+
const y = l.match(d)[1], N = l.match(o).reduce((D, j) => {
|
|
194
|
+
const [H, q] = j.split(":");
|
|
195
|
+
return D[H.trim()] = q.trim(), D;
|
|
196
|
+
}, {});
|
|
197
|
+
return N ? { name: y, members: N } : null;
|
|
198
|
+
}).filter(({ name: l }) => c.some(
|
|
199
|
+
(y) => (
|
|
200
|
+
// Handle both direct type matches and generic types like array<StructName>
|
|
201
|
+
y.type === l || y.type.includes(`<${l}>`)
|
|
202
|
+
)
|
|
203
|
+
))) ?? [];
|
|
204
|
+
return {
|
|
205
|
+
groups: c,
|
|
206
|
+
structs: u
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
var g = /* @__PURE__ */ ((r) => (r[r.VERTEX = 1] = "VERTEX", r[r.FRAGMENT = 2] = "FRAGMENT", r[r.COMPUTE = 4] = "COMPUTE", r))(g || {});
|
|
210
|
+
function lt({ groups: r }) {
|
|
211
|
+
const t = [];
|
|
212
|
+
for (let e = 0; e < r.length; e++) {
|
|
213
|
+
const s = r[e];
|
|
214
|
+
t[s.group] || (t[s.group] = []), s.isUniform ? t[s.group].push({
|
|
215
|
+
binding: s.binding,
|
|
216
|
+
visibility: g.VERTEX | g.FRAGMENT,
|
|
217
|
+
buffer: {
|
|
218
|
+
type: "uniform"
|
|
219
|
+
}
|
|
220
|
+
}) : s.type === "sampler" ? t[s.group].push({
|
|
221
|
+
binding: s.binding,
|
|
222
|
+
visibility: g.FRAGMENT,
|
|
223
|
+
sampler: {
|
|
224
|
+
type: "filtering"
|
|
225
|
+
}
|
|
226
|
+
}) : s.type === "texture_2d" || s.type.startsWith("texture_2d<") ? t[s.group].push({
|
|
227
|
+
binding: s.binding,
|
|
228
|
+
visibility: g.FRAGMENT,
|
|
229
|
+
texture: {
|
|
230
|
+
sampleType: "float",
|
|
231
|
+
viewDimension: "2d",
|
|
232
|
+
multisampled: !1
|
|
233
|
+
}
|
|
234
|
+
}) : s.type === "texture_2d_array" || s.type.startsWith("texture_2d_array<") ? t[s.group].push({
|
|
235
|
+
binding: s.binding,
|
|
236
|
+
visibility: g.FRAGMENT,
|
|
237
|
+
texture: {
|
|
238
|
+
sampleType: "float",
|
|
239
|
+
viewDimension: "2d-array",
|
|
240
|
+
multisampled: !1
|
|
241
|
+
}
|
|
242
|
+
}) : (s.type === "texture_cube" || s.type.startsWith("texture_cube<")) && t[s.group].push({
|
|
243
|
+
binding: s.binding,
|
|
244
|
+
visibility: g.FRAGMENT,
|
|
245
|
+
texture: {
|
|
246
|
+
sampleType: "float",
|
|
247
|
+
viewDimension: "cube",
|
|
248
|
+
multisampled: !1
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
for (let e = 0; e < t.length; e++)
|
|
253
|
+
t[e] || (t[e] = []);
|
|
254
|
+
return t;
|
|
255
|
+
}
|
|
256
|
+
function ft({ groups: r }) {
|
|
257
|
+
const t = [];
|
|
258
|
+
for (let e = 0; e < r.length; e++) {
|
|
259
|
+
const s = r[e];
|
|
260
|
+
t[s.group] || (t[s.group] = {}), t[s.group][s.name] = s.binding;
|
|
261
|
+
}
|
|
262
|
+
return t;
|
|
263
|
+
}
|
|
264
|
+
function dt(r, t) {
|
|
265
|
+
const e = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = [...r.structs, ...t.structs].filter((a) => e.has(a.name) ? !1 : (e.add(a.name), !0)), n = [...r.groups, ...t.groups].filter((a) => {
|
|
266
|
+
const o = `${a.name}-${a.binding}`;
|
|
267
|
+
return s.has(o) ? !1 : (s.add(o), !0);
|
|
268
|
+
});
|
|
269
|
+
return { structs: i, groups: n };
|
|
270
|
+
}
|
|
271
|
+
const b = /* @__PURE__ */ Object.create(null);
|
|
272
|
+
class x {
|
|
273
|
+
/**
|
|
274
|
+
* Create a new GpuProgram
|
|
275
|
+
* @param options - The options for the gpu program
|
|
276
|
+
*/
|
|
277
|
+
constructor(t) {
|
|
278
|
+
var o, d;
|
|
279
|
+
this._layoutKey = 0, this._attributeLocationsKey = 0;
|
|
280
|
+
const { fragment: e, vertex: s, layout: i, gpuLayout: n, name: a } = t;
|
|
281
|
+
if (this.name = a, this.fragment = e, this.vertex = s, e.source === s.source) {
|
|
282
|
+
const c = v(e.source);
|
|
283
|
+
this.structsAndGroups = c;
|
|
284
|
+
} else {
|
|
285
|
+
const c = v(s.source), u = v(e.source);
|
|
286
|
+
this.structsAndGroups = dt(c, u);
|
|
287
|
+
}
|
|
288
|
+
this.layout = i ?? ft(this.structsAndGroups), this.gpuLayout = n ?? lt(this.structsAndGroups), this.autoAssignGlobalUniforms = ((o = this.layout[0]) == null ? void 0 : o.globalUniforms) !== void 0, this.autoAssignLocalUniforms = ((d = this.layout[1]) == null ? void 0 : d.localUniforms) !== void 0, this._generateProgramKey();
|
|
289
|
+
}
|
|
290
|
+
// TODO maker this pure
|
|
291
|
+
_generateProgramKey() {
|
|
292
|
+
const { vertex: t, fragment: e } = this, s = t.source + e.source + t.entryPoint + e.entryPoint;
|
|
293
|
+
this._layoutKey = L(s, "program");
|
|
294
|
+
}
|
|
295
|
+
get attributeData() {
|
|
296
|
+
return this._attributeData ?? (this._attributeData = ct(this.vertex)), this._attributeData;
|
|
297
|
+
}
|
|
298
|
+
/** destroys the program */
|
|
299
|
+
destroy() {
|
|
300
|
+
this.gpuLayout = null, this.layout = null, this.structsAndGroups = null, this.fragment = null, this.vertex = null, b[this._cacheKey] = null;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Helper function that creates a program for a given source.
|
|
304
|
+
* It will check the program cache if the program has already been created.
|
|
305
|
+
* If it has that one will be returned, if not a new one will be created and cached.
|
|
306
|
+
* @param options - The options for the program.
|
|
307
|
+
* @returns A program using the same source
|
|
308
|
+
*/
|
|
309
|
+
static from(t) {
|
|
310
|
+
const e = `${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;
|
|
311
|
+
return b[e] || (b[e] = new x(t), b[e]._cacheKey = e), b[e];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
class G {
|
|
315
|
+
/**
|
|
316
|
+
* Create a new instance eof the Bind Group.
|
|
317
|
+
* @param resources - The resources that are bound together for use by a shader.
|
|
318
|
+
*/
|
|
319
|
+
constructor(t) {
|
|
320
|
+
this.resources = /* @__PURE__ */ Object.create(null), this._dirty = !0;
|
|
321
|
+
let e = 0;
|
|
322
|
+
for (const s in t) {
|
|
323
|
+
const i = t[s];
|
|
324
|
+
this.setResource(i, e++);
|
|
325
|
+
}
|
|
326
|
+
this._updateKey();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Updates the key if its flagged as dirty. This is used internally to
|
|
330
|
+
* match this bind group to a WebGPU BindGroup.
|
|
331
|
+
* @internal
|
|
332
|
+
*/
|
|
333
|
+
_updateKey() {
|
|
334
|
+
if (!this._dirty) return;
|
|
335
|
+
this._dirty = !1;
|
|
336
|
+
const t = [];
|
|
337
|
+
let e = 0;
|
|
338
|
+
for (const s in this.resources)
|
|
339
|
+
t[e++] = this.resources[s]._resourceId;
|
|
340
|
+
this._key = t.join("|");
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Set a resource at a given index. this function will
|
|
344
|
+
* ensure that listeners will be removed from the current resource
|
|
345
|
+
* and added to the new resource.
|
|
346
|
+
* @param resource - The resource to set.
|
|
347
|
+
* @param index - The index to set the resource at.
|
|
348
|
+
*/
|
|
349
|
+
setResource(t, e) {
|
|
350
|
+
var i, n;
|
|
351
|
+
const s = this.resources[e];
|
|
352
|
+
t !== s && ((i = s == null ? void 0 : s.off) == null || i.call(s, "change", this.onResourceChange, this), (n = t.on) == null || n.call(t, "change", this.onResourceChange, this), this.resources[e] = t, this._dirty = !0);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Returns the resource at the current specified index.
|
|
356
|
+
* @param index - The index of the resource to get.
|
|
357
|
+
* @returns - The resource at the specified index.
|
|
358
|
+
*/
|
|
359
|
+
getResource(t) {
|
|
360
|
+
return this.resources[t];
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Used internally to 'touch' each resource, to ensure that the GC
|
|
364
|
+
* knows that all resources in this bind group are still being used.
|
|
365
|
+
* @param now - The current time in milliseconds.
|
|
366
|
+
* @param tick - The current tick.
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
_touch(t, e) {
|
|
370
|
+
const s = this.resources;
|
|
371
|
+
for (const i in s)
|
|
372
|
+
s[i]._gcLastUsed = t, s[i]._touched = e;
|
|
373
|
+
}
|
|
374
|
+
/** Destroys this bind group and removes all listeners. */
|
|
375
|
+
destroy() {
|
|
376
|
+
var e;
|
|
377
|
+
const t = this.resources;
|
|
378
|
+
for (const s in t) {
|
|
379
|
+
const i = t[s];
|
|
380
|
+
(e = i == null ? void 0 : i.off) == null || e.call(i, "change", this.onResourceChange, this);
|
|
381
|
+
}
|
|
382
|
+
this.resources = null;
|
|
383
|
+
}
|
|
384
|
+
onResourceChange(t) {
|
|
385
|
+
this._dirty = !0, t.destroyed ? this.destroy() : this._updateKey();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
var T = /* @__PURE__ */ ((r) => (r[r.WEBGL = 1] = "WEBGL", r[r.WEBGPU = 2] = "WEBGPU", r[r.CANVAS = 4] = "CANVAS", r[r.BOTH = 3] = "BOTH", r))(T || {});
|
|
389
|
+
class k extends z {
|
|
390
|
+
constructor(t) {
|
|
391
|
+
super(), this.uid = Z("shader"), this._uniformBindMap = /* @__PURE__ */ Object.create(null), this._ownedBindGroups = [], this._destroyed = !1;
|
|
392
|
+
let {
|
|
393
|
+
gpuProgram: e,
|
|
394
|
+
glProgram: s,
|
|
395
|
+
groups: i,
|
|
396
|
+
resources: n,
|
|
397
|
+
compatibleRenderers: a,
|
|
398
|
+
groupMap: o
|
|
399
|
+
} = t;
|
|
400
|
+
this.gpuProgram = e, this.glProgram = s, a === void 0 && (a = 0, e && (a |= T.WEBGPU), s && (a |= T.WEBGL)), this.compatibleRenderers = a;
|
|
401
|
+
const d = {};
|
|
402
|
+
if (!n && !i && (n = {}), n && i)
|
|
403
|
+
throw new Error("[Shader] Cannot have both resources and groups");
|
|
404
|
+
if (!e && i && !o)
|
|
405
|
+
throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");
|
|
406
|
+
if (!e && i && o)
|
|
407
|
+
for (const c in o)
|
|
408
|
+
for (const u in o[c]) {
|
|
409
|
+
const f = o[c][u];
|
|
410
|
+
d[f] = {
|
|
411
|
+
group: c,
|
|
412
|
+
binding: u,
|
|
413
|
+
name: f
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
else if (e && i && !o) {
|
|
417
|
+
const c = e.structsAndGroups.groups;
|
|
418
|
+
o = {}, c.forEach((u) => {
|
|
419
|
+
o[u.group] = o[u.group] || {}, o[u.group][u.binding] = u.name, d[u.name] = u;
|
|
420
|
+
});
|
|
421
|
+
} else if (n) {
|
|
422
|
+
i = {}, o = {}, e && e.structsAndGroups.groups.forEach((f) => {
|
|
423
|
+
o[f.group] = o[f.group] || {}, o[f.group][f.binding] = f.name, d[f.name] = f;
|
|
424
|
+
});
|
|
425
|
+
let c = 0;
|
|
426
|
+
for (const u in n)
|
|
427
|
+
d[u] || (i[99] || (i[99] = new G(), this._ownedBindGroups.push(i[99])), d[u] = { group: 99, binding: c, name: u }, o[99] = o[99] || {}, o[99][c] = u, c++);
|
|
428
|
+
for (const u in n) {
|
|
429
|
+
const f = u;
|
|
430
|
+
let h = n[u];
|
|
431
|
+
!h.source && !h._resourceType && (h = new Y(h));
|
|
432
|
+
const l = d[f];
|
|
433
|
+
l && (i[l.group] || (i[l.group] = new G(), this._ownedBindGroups.push(i[l.group])), i[l.group].setResource(h, l.binding));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
this.groups = i, this._uniformBindMap = o, this.resources = this._buildResourceAccessor(i, d);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Sometimes a resource group will be provided later (for example global uniforms)
|
|
440
|
+
* In such cases, this method can be used to let the shader know about the group.
|
|
441
|
+
* @param name - the name of the resource group
|
|
442
|
+
* @param groupIndex - the index of the group (should match the webGPU shader group location)
|
|
443
|
+
* @param bindIndex - the index of the bind point (should match the webGPU shader bind point)
|
|
444
|
+
*/
|
|
445
|
+
addResource(t, e, s) {
|
|
446
|
+
var i, n;
|
|
447
|
+
(i = this._uniformBindMap)[e] || (i[e] = {}), (n = this._uniformBindMap[e])[s] || (n[s] = t), this.groups[e] || (this.groups[e] = new G(), this._ownedBindGroups.push(this.groups[e]));
|
|
448
|
+
}
|
|
449
|
+
_buildResourceAccessor(t, e) {
|
|
450
|
+
const s = {};
|
|
451
|
+
for (const i in e) {
|
|
452
|
+
const n = e[i];
|
|
453
|
+
Object.defineProperty(s, n.name, {
|
|
454
|
+
get() {
|
|
455
|
+
return t[n.group].getResource(n.binding);
|
|
456
|
+
},
|
|
457
|
+
set(a) {
|
|
458
|
+
t[n.group].setResource(a, n.binding);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return s;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Use to destroy the shader when its not longer needed.
|
|
466
|
+
* It will destroy the resources and remove listeners.
|
|
467
|
+
* @param destroyPrograms - if the programs should be destroyed as well.
|
|
468
|
+
* Make sure its not being used by other shaders!
|
|
469
|
+
*/
|
|
470
|
+
destroy(t = !1) {
|
|
471
|
+
var e, s;
|
|
472
|
+
this._destroyed || (this._destroyed = !0, this.emit("destroy", this), t && ((e = this.gpuProgram) == null || e.destroy(), (s = this.glProgram) == null || s.destroy()), this.gpuProgram = null, this.glProgram = null, this.removeAllListeners(), this._uniformBindMap = null, this._ownedBindGroups.forEach((i) => {
|
|
473
|
+
i.destroy();
|
|
474
|
+
}), this._ownedBindGroups = null, this.resources = null, this.groups = null);
|
|
475
|
+
}
|
|
476
|
+
static from(t) {
|
|
477
|
+
const { gpu: e, gl: s, ...i } = t;
|
|
478
|
+
let n, a;
|
|
479
|
+
return e && (n = x.from(e)), s && (a = U.from(s)), new k({
|
|
480
|
+
gpuProgram: n,
|
|
481
|
+
glProgram: a,
|
|
482
|
+
...i
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const ht = {
|
|
487
|
+
normal: 0,
|
|
488
|
+
add: 1,
|
|
489
|
+
multiply: 2,
|
|
490
|
+
screen: 3,
|
|
491
|
+
overlay: 4,
|
|
492
|
+
erase: 5,
|
|
493
|
+
"normal-npm": 6,
|
|
494
|
+
"add-npm": 7,
|
|
495
|
+
"screen-npm": 8,
|
|
496
|
+
min: 9,
|
|
497
|
+
max: 10
|
|
498
|
+
}, E = 0, F = 1, M = 2, w = 3, A = 4, $ = 5, R = class W {
|
|
499
|
+
constructor() {
|
|
500
|
+
this.data = 0, this.blendMode = "normal", this.polygonOffset = 0, this.blend = !0, this.depthMask = !0;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Activates blending of the computed fragment color values.
|
|
504
|
+
* @default true
|
|
505
|
+
*/
|
|
506
|
+
get blend() {
|
|
507
|
+
return !!(this.data & 1 << E);
|
|
508
|
+
}
|
|
509
|
+
set blend(t) {
|
|
510
|
+
!!(this.data & 1 << E) !== t && (this.data ^= 1 << E);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Activates adding an offset to depth values of polygon's fragments
|
|
514
|
+
* @default false
|
|
515
|
+
*/
|
|
516
|
+
get offsets() {
|
|
517
|
+
return !!(this.data & 1 << F);
|
|
518
|
+
}
|
|
519
|
+
set offsets(t) {
|
|
520
|
+
!!(this.data & 1 << F) !== t && (this.data ^= 1 << F);
|
|
521
|
+
}
|
|
522
|
+
/** The culling settings for this state none - No culling back - Back face culling front - Front face culling */
|
|
523
|
+
set cullMode(t) {
|
|
524
|
+
if (t === "none") {
|
|
525
|
+
this.culling = !1;
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
this.culling = !0, this.clockwiseFrontFace = t === "front";
|
|
529
|
+
}
|
|
530
|
+
get cullMode() {
|
|
531
|
+
return this.culling ? this.clockwiseFrontFace ? "front" : "back" : "none";
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Activates culling of polygons.
|
|
535
|
+
* @default false
|
|
536
|
+
*/
|
|
537
|
+
get culling() {
|
|
538
|
+
return !!(this.data & 1 << M);
|
|
539
|
+
}
|
|
540
|
+
set culling(t) {
|
|
541
|
+
!!(this.data & 1 << M) !== t && (this.data ^= 1 << M);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Activates depth comparisons and updates to the depth buffer.
|
|
545
|
+
* @default false
|
|
546
|
+
*/
|
|
547
|
+
get depthTest() {
|
|
548
|
+
return !!(this.data & 1 << w);
|
|
549
|
+
}
|
|
550
|
+
set depthTest(t) {
|
|
551
|
+
!!(this.data & 1 << w) !== t && (this.data ^= 1 << w);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Enables or disables writing to the depth buffer.
|
|
555
|
+
* @default true
|
|
556
|
+
*/
|
|
557
|
+
get depthMask() {
|
|
558
|
+
return !!(this.data & 1 << $);
|
|
559
|
+
}
|
|
560
|
+
set depthMask(t) {
|
|
561
|
+
!!(this.data & 1 << $) !== t && (this.data ^= 1 << $);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Specifies whether or not front or back-facing polygons can be culled.
|
|
565
|
+
* @default false
|
|
566
|
+
*/
|
|
567
|
+
get clockwiseFrontFace() {
|
|
568
|
+
return !!(this.data & 1 << A);
|
|
569
|
+
}
|
|
570
|
+
set clockwiseFrontFace(t) {
|
|
571
|
+
!!(this.data & 1 << A) !== t && (this.data ^= 1 << A);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* The blend mode to be applied when this state is set. Apply a value of `normal` to reset the blend mode.
|
|
575
|
+
* Setting this mode to anything other than NO_BLEND will automatically switch blending on.
|
|
576
|
+
* @default 'normal'
|
|
577
|
+
*/
|
|
578
|
+
get blendMode() {
|
|
579
|
+
return this._blendMode;
|
|
580
|
+
}
|
|
581
|
+
set blendMode(t) {
|
|
582
|
+
this.blend = t !== "none", this._blendMode = t, this._blendModeId = ht[t] || 0;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.
|
|
586
|
+
* @default 0
|
|
587
|
+
*/
|
|
588
|
+
get polygonOffset() {
|
|
589
|
+
return this._polygonOffset;
|
|
590
|
+
}
|
|
591
|
+
set polygonOffset(t) {
|
|
592
|
+
this.offsets = !!t, this._polygonOffset = t;
|
|
593
|
+
}
|
|
594
|
+
toString() {
|
|
595
|
+
return `[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* A quickly getting an instance of a State that is configured for 2d rendering.
|
|
599
|
+
* @returns a new State with values set for 2d rendering
|
|
600
|
+
*/
|
|
601
|
+
static for2d() {
|
|
602
|
+
const t = new W();
|
|
603
|
+
return t.depthTest = !1, t.blend = !0, t;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
R.default2d = R.for2d();
|
|
607
|
+
let gt = R;
|
|
608
|
+
const K = class S extends k {
|
|
609
|
+
/**
|
|
610
|
+
* @param options - The optional parameters of this filter.
|
|
611
|
+
*/
|
|
612
|
+
constructor(t) {
|
|
613
|
+
t = { ...S.defaultOptions, ...t }, super(t), this.enabled = !0, this._state = gt.for2d(), this.blendMode = t.blendMode, this.padding = t.padding, typeof t.antialias == "boolean" ? this.antialias = t.antialias ? "on" : "off" : this.antialias = t.antialias, this.resolution = t.resolution, this.blendRequired = t.blendRequired, this.clipToViewport = t.clipToViewport, this.addResource("uTexture", 0, 1), t.blendRequired && this.addResource("uBackTexture", 0, 3);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Applies the filter
|
|
617
|
+
* @param filterManager - The renderer to retrieve the filter from
|
|
618
|
+
* @param input - The input render target.
|
|
619
|
+
* @param output - The target to output to.
|
|
620
|
+
* @param clearMode - Should the output be cleared before rendering to it
|
|
621
|
+
*/
|
|
622
|
+
apply(t, e, s, i) {
|
|
623
|
+
t.applyFilter(this, e, s, i);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Get the blend mode of the filter.
|
|
627
|
+
* @default "normal"
|
|
628
|
+
*/
|
|
629
|
+
get blendMode() {
|
|
630
|
+
return this._state.blendMode;
|
|
631
|
+
}
|
|
632
|
+
/** Sets the blend mode of the filter. */
|
|
633
|
+
set blendMode(t) {
|
|
634
|
+
this._state.blendMode = t;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* A short hand function to create a filter based of a vertex and fragment shader src.
|
|
638
|
+
* @param options
|
|
639
|
+
* @returns A shiny new PixiJS filter!
|
|
640
|
+
*/
|
|
641
|
+
static from(t) {
|
|
642
|
+
const { gpu: e, gl: s, ...i } = t;
|
|
643
|
+
let n, a;
|
|
644
|
+
return e && (n = x.from(e)), s && (a = U.from(s)), new S({
|
|
645
|
+
gpuProgram: n,
|
|
646
|
+
glProgram: a,
|
|
647
|
+
...i
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
K.defaultOptions = {
|
|
652
|
+
blendMode: "normal",
|
|
653
|
+
resolution: 1,
|
|
654
|
+
padding: 0,
|
|
655
|
+
antialias: "off",
|
|
656
|
+
blendRequired: !1,
|
|
657
|
+
clipToViewport: !0
|
|
658
|
+
};
|
|
659
|
+
let mt = K;
|
|
660
|
+
export {
|
|
661
|
+
G as B,
|
|
662
|
+
mt as F,
|
|
663
|
+
U as G,
|
|
664
|
+
T as R,
|
|
665
|
+
gt as S,
|
|
666
|
+
k as a,
|
|
667
|
+
x as b,
|
|
668
|
+
J as g
|
|
669
|
+
};
|
|
670
|
+
//# sourceMappingURL=Filter-GqToX76B.js.map
|