openspecui 1.6.2 → 2.0.1
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/cli.mjs +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-CVJCbdiP.mjs → src-CFsMWl3_.mjs} +173 -40
- package/package.json +3 -3
- package/web/assets/{BufferResource-BFEntdoN.js → BufferResource-Cipj3hQ5.js} +1 -1
- package/web/assets/{CanvasRenderer-ZQxN8ITJ.js → CanvasRenderer-C151fKcy.js} +1 -1
- package/web/assets/{Filter-trCu1CQG.js → Filter-BpxymkGv.js} +1 -1
- package/web/assets/{RenderTargetSystem-DHoDBu3v.js → RenderTargetSystem-C0zk81Mh.js} +1 -1
- package/web/assets/{WebGLRenderer-DYS9LSzA.js → WebGLRenderer-De3GrxdN.js} +1 -1
- package/web/assets/{WebGPURenderer-CDj9ZzDs.js → WebGPURenderer-BkpejvST.js} +1 -1
- package/web/assets/{browserAll-B8FBs1Rt.js → browserAll-B8KqF-Xa.js} +1 -1
- package/web/assets/{ghostty-web-C6hNf21K.js → ghostty-web-BO5ww0eG.js} +1 -1
- package/web/assets/{index-FMaDFama.js → index-2DXouwnE.js} +1 -1
- package/web/assets/{index-YEDqrGu6.js → index-B-vvVL83.js} +212 -211
- package/web/assets/{index-vJWwTEOs.js → index-Bp2dpDFJ.js} +1 -1
- package/web/assets/{index-hID85NKg.js → index-Bxm-n0do.js} +1 -1
- package/web/assets/{index-Dj2t_cJN.js → index-CDX9fioY.js} +1 -1
- package/web/assets/{index-CxCFae0J.js → index-CFAzjIVm.js} +1 -1
- package/web/assets/{index-CxF-jUR9.js → index-Cj_nv8ue.js} +1 -1
- package/web/assets/{index-CqDTsKqD.js → index-Cv-LON1K.js} +1 -1
- package/web/assets/{index-CFiXnV5n.js → index-CwA_uPvf.js} +1 -1
- package/web/assets/{index-Cja7GFdu.js → index-CxDip8xJ.js} +1 -1
- package/web/assets/{index-CLKNqdA1.js → index-DL08rl2O.js} +1 -1
- package/web/assets/{index-Drwn-PWd.js → index-DtTSWBHJ.js} +1 -1
- package/web/assets/{index-BRrJSB9v.js → index-DzK6gT7C.js} +1 -1
- package/web/assets/{index-Cq8vn29r.js → index-Nl7iD8Yi.js} +1 -1
- package/web/assets/{index-BByfw4ws.js → index-a8osabOh.js} +1 -1
- package/web/assets/index-aWxXp1oO.css +1 -0
- package/web/assets/{index-BDu-q_RJ.js → index-iROJdLzk.js} +1 -1
- package/web/assets/{webworkerAll-Pgv9S8Bp.js → webworkerAll-DPcI1cDK.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/index-DzNp3fwv.css +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as SchemaInfoSchema, c as toOpsxDisplayPath, d as DEFAULT_CONFIG, f as OpenSpecAdapter, i as SchemaDetailSchema, l as CliExecutor, m as __toESM, o as SchemaResolutionSchema, p as __commonJS, r as require_dist, s as TemplatesSchema, t as startServer, u as ConfigManager } from "./src-
|
|
2
|
+
import { a as SchemaInfoSchema, c as toOpsxDisplayPath, d as DEFAULT_CONFIG, f as OpenSpecAdapter, i as SchemaDetailSchema, l as CliExecutor, m as __toESM, o as SchemaResolutionSchema, p as __commonJS, r as require_dist, s as TemplatesSchema, t as startServer, u as ConfigManager } from "./src-CFsMWl3_.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { basename, dirname, extname, join, normalize, relative, resolve } from "path";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
@@ -4507,7 +4507,7 @@ var yargs_default = Yargs;
|
|
|
4507
4507
|
//#endregion
|
|
4508
4508
|
//#region package.json
|
|
4509
4509
|
var import_dist = require_dist();
|
|
4510
|
-
var version = "
|
|
4510
|
+
var version = "2.0.1";
|
|
4511
4511
|
|
|
4512
4512
|
//#endregion
|
|
4513
4513
|
//#region src/export.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1926,7 +1926,7 @@ var OpenSpecAdapter = class {
|
|
|
1926
1926
|
});
|
|
1927
1927
|
}
|
|
1928
1928
|
async collectChangeFiles(root, dir) {
|
|
1929
|
-
const names = await reactiveReadDir(dir, { includeHidden:
|
|
1929
|
+
const names = await reactiveReadDir(dir, { includeHidden: true });
|
|
1930
1930
|
const files = [];
|
|
1931
1931
|
for (const name of names) {
|
|
1932
1932
|
const fullPath = join(dir, name);
|
|
@@ -6597,13 +6597,15 @@ var CliExecutor = class {
|
|
|
6597
6597
|
/**
|
|
6598
6598
|
* 执行 openspec init(非交互式)
|
|
6599
6599
|
*/
|
|
6600
|
-
async init(
|
|
6601
|
-
const
|
|
6602
|
-
|
|
6603
|
-
"
|
|
6604
|
-
"--tools",
|
|
6605
|
-
|
|
6606
|
-
|
|
6600
|
+
async init(options) {
|
|
6601
|
+
const args = ["init"];
|
|
6602
|
+
if (options?.tools !== void 0) {
|
|
6603
|
+
const toolsArg = Array.isArray(options.tools) ? options.tools.join(",") : options.tools;
|
|
6604
|
+
args.push("--tools", toolsArg);
|
|
6605
|
+
}
|
|
6606
|
+
if (options?.profile) args.push("--profile", options.profile);
|
|
6607
|
+
if (options?.force) args.push("--force");
|
|
6608
|
+
return this.execute(args);
|
|
6607
6609
|
}
|
|
6608
6610
|
/**
|
|
6609
6611
|
* 执行 openspec archive <changeId>(非交互式)
|
|
@@ -6770,13 +6772,15 @@ var CliExecutor = class {
|
|
|
6770
6772
|
/**
|
|
6771
6773
|
* 流式执行 openspec init
|
|
6772
6774
|
*/
|
|
6773
|
-
initStream(
|
|
6774
|
-
const
|
|
6775
|
-
|
|
6776
|
-
"
|
|
6777
|
-
"--tools",
|
|
6778
|
-
|
|
6779
|
-
|
|
6775
|
+
initStream(options, onEvent) {
|
|
6776
|
+
const args = ["init"];
|
|
6777
|
+
if (options.tools !== void 0) {
|
|
6778
|
+
const toolsArg = Array.isArray(options.tools) ? options.tools.join(",") : options.tools;
|
|
6779
|
+
args.push("--tools", toolsArg);
|
|
6780
|
+
}
|
|
6781
|
+
if (options.profile) args.push("--profile", options.profile);
|
|
6782
|
+
if (options.force) args.push("--force");
|
|
6783
|
+
return this.executeStream(args, onEvent);
|
|
6780
6784
|
}
|
|
6781
6785
|
/**
|
|
6782
6786
|
* 流式执行 openspec archive
|
|
@@ -6861,7 +6865,9 @@ const SKILL_NAMES = [
|
|
|
6861
6865
|
"openspec-sync-specs",
|
|
6862
6866
|
"openspec-archive-change",
|
|
6863
6867
|
"openspec-bulk-archive-change",
|
|
6864
|
-
"openspec-verify-change"
|
|
6868
|
+
"openspec-verify-change",
|
|
6869
|
+
"openspec-onboard",
|
|
6870
|
+
"openspec-propose"
|
|
6865
6871
|
];
|
|
6866
6872
|
/**
|
|
6867
6873
|
* 所有支持的 AI 工具配置
|
|
@@ -6980,6 +6986,13 @@ const AI_TOOLS = [
|
|
|
6980
6986
|
successLabel: "Kilo Code",
|
|
6981
6987
|
skillsDir: ".kilocode"
|
|
6982
6988
|
},
|
|
6989
|
+
{
|
|
6990
|
+
name: "Kiro",
|
|
6991
|
+
value: "kiro",
|
|
6992
|
+
available: true,
|
|
6993
|
+
successLabel: "Kiro",
|
|
6994
|
+
skillsDir: ".kiro"
|
|
6995
|
+
},
|
|
6983
6996
|
{
|
|
6984
6997
|
name: "OpenCode",
|
|
6985
6998
|
value: "opencode",
|
|
@@ -6987,6 +7000,13 @@ const AI_TOOLS = [
|
|
|
6987
7000
|
successLabel: "OpenCode",
|
|
6988
7001
|
skillsDir: ".opencode"
|
|
6989
7002
|
},
|
|
7003
|
+
{
|
|
7004
|
+
name: "Pi",
|
|
7005
|
+
value: "pi",
|
|
7006
|
+
available: true,
|
|
7007
|
+
successLabel: "Pi",
|
|
7008
|
+
skillsDir: ".pi"
|
|
7009
|
+
},
|
|
6990
7010
|
{
|
|
6991
7011
|
name: "Qoder",
|
|
6992
7012
|
value: "qoder",
|
|
@@ -23970,6 +23990,12 @@ const t = initTRPC.context().create();
|
|
|
23970
23990
|
const router = t.router;
|
|
23971
23991
|
const publicProcedure = t.procedure;
|
|
23972
23992
|
const execFileAsync = promisify$1(execFile);
|
|
23993
|
+
const OPSX_CORE_PROFILE_WORKFLOWS = [
|
|
23994
|
+
"propose",
|
|
23995
|
+
"explore",
|
|
23996
|
+
"apply",
|
|
23997
|
+
"archive"
|
|
23998
|
+
];
|
|
23973
23999
|
const dashboardGitTaskStatusEmitter = new EventEmitter$1();
|
|
23974
24000
|
dashboardGitTaskStatusEmitter.setMaxListeners(200);
|
|
23975
24001
|
const dashboardGitTaskStatus = {
|
|
@@ -24043,6 +24069,94 @@ function requireChangeId(changeId) {
|
|
|
24043
24069
|
if (!changeId) throw new Error("change is required");
|
|
24044
24070
|
return changeId;
|
|
24045
24071
|
}
|
|
24072
|
+
function parseOpsxProfileListJson(stdout) {
|
|
24073
|
+
try {
|
|
24074
|
+
const parsed = JSON.parse(stdout);
|
|
24075
|
+
const profile = parsed.profile === "custom" ? "custom" : "core";
|
|
24076
|
+
return {
|
|
24077
|
+
profile,
|
|
24078
|
+
delivery: parsed.delivery === "skills" || parsed.delivery === "commands" ? parsed.delivery : "both",
|
|
24079
|
+
workflows: Array.isArray(parsed.workflows) ? parsed.workflows.filter((item) => typeof item === "string" && item.length > 0) : profile === "core" ? [...OPSX_CORE_PROFILE_WORKFLOWS] : []
|
|
24080
|
+
};
|
|
24081
|
+
} catch {
|
|
24082
|
+
return null;
|
|
24083
|
+
}
|
|
24084
|
+
}
|
|
24085
|
+
function parseOpsxConfigDrift(output) {
|
|
24086
|
+
const lines = output.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
24087
|
+
const warningLine = lines.find((line) => /global config.+not applied.+project/i.test(line)) ?? lines.find((line) => /out of sync/i.test(line)) ?? lines.find((line) => /run\s+`?openspec\s+update`?/i.test(line)) ?? null;
|
|
24088
|
+
return {
|
|
24089
|
+
drift: warningLine !== null,
|
|
24090
|
+
warningText: warningLine
|
|
24091
|
+
};
|
|
24092
|
+
}
|
|
24093
|
+
async function fetchOpsxProfileState(ctx) {
|
|
24094
|
+
const configListJson = await ctx.cliExecutor.execute([
|
|
24095
|
+
"config",
|
|
24096
|
+
"list",
|
|
24097
|
+
"--json"
|
|
24098
|
+
]);
|
|
24099
|
+
if (!configListJson.success) return {
|
|
24100
|
+
available: false,
|
|
24101
|
+
profile: null,
|
|
24102
|
+
delivery: null,
|
|
24103
|
+
workflows: [],
|
|
24104
|
+
driftStatus: "unknown",
|
|
24105
|
+
warningText: null,
|
|
24106
|
+
error: configListJson.stderr || "Failed to load profile config."
|
|
24107
|
+
};
|
|
24108
|
+
const parsed = parseOpsxProfileListJson(configListJson.stdout);
|
|
24109
|
+
if (!parsed) return {
|
|
24110
|
+
available: false,
|
|
24111
|
+
profile: null,
|
|
24112
|
+
delivery: null,
|
|
24113
|
+
workflows: [],
|
|
24114
|
+
driftStatus: "unknown",
|
|
24115
|
+
warningText: null,
|
|
24116
|
+
error: "Invalid JSON from `openspec config list --json`."
|
|
24117
|
+
};
|
|
24118
|
+
const configListText = await ctx.cliExecutor.execute(["config", "list"]);
|
|
24119
|
+
if (!configListText.success) return {
|
|
24120
|
+
available: true,
|
|
24121
|
+
profile: parsed.profile,
|
|
24122
|
+
delivery: parsed.delivery,
|
|
24123
|
+
workflows: parsed.workflows,
|
|
24124
|
+
driftStatus: "unknown",
|
|
24125
|
+
warningText: null
|
|
24126
|
+
};
|
|
24127
|
+
const drift = parseOpsxConfigDrift(`${configListText.stdout}\n${configListText.stderr}`);
|
|
24128
|
+
return {
|
|
24129
|
+
available: true,
|
|
24130
|
+
profile: parsed.profile,
|
|
24131
|
+
delivery: parsed.delivery,
|
|
24132
|
+
workflows: parsed.workflows,
|
|
24133
|
+
driftStatus: drift.drift ? "drift" : "in-sync",
|
|
24134
|
+
warningText: drift.warningText
|
|
24135
|
+
};
|
|
24136
|
+
}
|
|
24137
|
+
async function resolveGlobalConfigPath(ctx) {
|
|
24138
|
+
const result = await ctx.cliExecutor.execute(["config", "path"]);
|
|
24139
|
+
if (!result.success) throw new Error(result.stderr || "Failed to resolve OpenSpec global config path.");
|
|
24140
|
+
const path$1 = result.stdout.trim();
|
|
24141
|
+
if (!path$1) throw new Error("OpenSpec global config path is empty.");
|
|
24142
|
+
return path$1;
|
|
24143
|
+
}
|
|
24144
|
+
async function fetchGlobalConfigJson(ctx) {
|
|
24145
|
+
const result = await ctx.cliExecutor.execute([
|
|
24146
|
+
"config",
|
|
24147
|
+
"list",
|
|
24148
|
+
"--json"
|
|
24149
|
+
]);
|
|
24150
|
+
if (!result.success) throw new Error(result.stderr || "Failed to load OpenSpec global config.");
|
|
24151
|
+
try {
|
|
24152
|
+
const parsed = JSON.parse(result.stdout);
|
|
24153
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("OpenSpec global config must be a JSON object.");
|
|
24154
|
+
return parsed;
|
|
24155
|
+
} catch (error) {
|
|
24156
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24157
|
+
throw new Error(`Invalid JSON from \`openspec config list --json\`: ${message}`);
|
|
24158
|
+
}
|
|
24159
|
+
}
|
|
24046
24160
|
function ensureEditableSource(source, label) {
|
|
24047
24161
|
if (source === "package") throw new Error(`${label} is read-only (package source)`);
|
|
24048
24162
|
}
|
|
@@ -24615,18 +24729,41 @@ const cliRouter = router({
|
|
|
24615
24729
|
successLabel: tool.successLabel
|
|
24616
24730
|
}));
|
|
24617
24731
|
}),
|
|
24732
|
+
getProfileState: publicProcedure.query(async ({ ctx }) => {
|
|
24733
|
+
return fetchOpsxProfileState(ctx);
|
|
24734
|
+
}),
|
|
24735
|
+
getGlobalConfigPath: publicProcedure.query(async ({ ctx }) => {
|
|
24736
|
+
return { path: await resolveGlobalConfigPath(ctx) };
|
|
24737
|
+
}),
|
|
24738
|
+
getGlobalConfig: publicProcedure.query(async ({ ctx }) => {
|
|
24739
|
+
return fetchGlobalConfigJson(ctx);
|
|
24740
|
+
}),
|
|
24741
|
+
setGlobalConfig: publicProcedure.input(objectType({ config: recordType(stringType(), unknownType()) })).mutation(async ({ ctx, input }) => {
|
|
24742
|
+
const configPath = await resolveGlobalConfigPath(ctx);
|
|
24743
|
+
await mkdir$1(dirname$1(configPath), { recursive: true });
|
|
24744
|
+
await writeFile$1(configPath, `${JSON.stringify(input.config, null, 2)}\n`, "utf8");
|
|
24745
|
+
return { success: true };
|
|
24746
|
+
}),
|
|
24618
24747
|
getConfiguredTools: publicProcedure.query(async ({ ctx }) => {
|
|
24619
24748
|
return getConfiguredTools(ctx.projectDir);
|
|
24620
24749
|
}),
|
|
24621
24750
|
subscribeConfiguredTools: publicProcedure.subscription(({ ctx }) => {
|
|
24622
24751
|
return createReactiveSubscription(() => getConfiguredTools(ctx.projectDir));
|
|
24623
24752
|
}),
|
|
24624
|
-
init: publicProcedure.input(objectType({
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24753
|
+
init: publicProcedure.input(objectType({
|
|
24754
|
+
tools: unionType([
|
|
24755
|
+
arrayType(stringType()),
|
|
24756
|
+
literalType("all"),
|
|
24757
|
+
literalType("none")
|
|
24758
|
+
]).optional(),
|
|
24759
|
+
profile: enumType(["core", "custom"]).optional(),
|
|
24760
|
+
force: booleanType().optional()
|
|
24761
|
+
}).optional()).mutation(async ({ ctx, input }) => {
|
|
24762
|
+
return ctx.cliExecutor.init({
|
|
24763
|
+
tools: input?.tools,
|
|
24764
|
+
profile: input?.profile,
|
|
24765
|
+
force: input?.force
|
|
24766
|
+
});
|
|
24630
24767
|
}),
|
|
24631
24768
|
archive: publicProcedure.input(objectType({
|
|
24632
24769
|
changeId: stringType(),
|
|
@@ -24653,12 +24790,20 @@ const cliRouter = router({
|
|
|
24653
24790
|
execute: publicProcedure.input(objectType({ args: arrayType(stringType()) })).mutation(async ({ ctx, input }) => {
|
|
24654
24791
|
return ctx.cliExecutor.execute(input.args);
|
|
24655
24792
|
}),
|
|
24656
|
-
initStream: publicProcedure.input(objectType({
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
|
|
24661
|
-
|
|
24793
|
+
initStream: publicProcedure.input(objectType({
|
|
24794
|
+
tools: unionType([
|
|
24795
|
+
arrayType(stringType()),
|
|
24796
|
+
literalType("all"),
|
|
24797
|
+
literalType("none")
|
|
24798
|
+
]).optional(),
|
|
24799
|
+
profile: enumType(["core", "custom"]).optional(),
|
|
24800
|
+
force: booleanType().optional()
|
|
24801
|
+
}).optional()).subscription(({ ctx, input }) => {
|
|
24802
|
+
return createCliStreamObservable((onEvent) => ctx.cliExecutor.initStream({
|
|
24803
|
+
tools: input?.tools,
|
|
24804
|
+
profile: input?.profile,
|
|
24805
|
+
force: input?.force
|
|
24806
|
+
}, onEvent));
|
|
24662
24807
|
}),
|
|
24663
24808
|
archiveStream: publicProcedure.input(objectType({
|
|
24664
24809
|
changeId: stringType(),
|
|
@@ -24892,18 +25037,6 @@ const opsxRouter = router({
|
|
|
24892
25037
|
return ctx.kernel.getChangeIds();
|
|
24893
25038
|
});
|
|
24894
25039
|
}),
|
|
24895
|
-
changeMetadata: publicProcedure.input(objectType({ changeId: stringType() })).query(async ({ ctx, input }) => {
|
|
24896
|
-
await ctx.kernel.waitForWarmup();
|
|
24897
|
-
await ctx.kernel.ensureChangeMetadata(input.changeId);
|
|
24898
|
-
return ctx.kernel.getChangeMetadata(input.changeId);
|
|
24899
|
-
}),
|
|
24900
|
-
subscribeChangeMetadata: publicProcedure.input(objectType({ changeId: stringType() })).subscription(({ ctx, input }) => {
|
|
24901
|
-
return createReactiveSubscription(async () => {
|
|
24902
|
-
await ctx.kernel.waitForWarmup();
|
|
24903
|
-
await ctx.kernel.ensureChangeMetadata(input.changeId);
|
|
24904
|
-
return ctx.kernel.getChangeMetadata(input.changeId);
|
|
24905
|
-
});
|
|
24906
|
-
}),
|
|
24907
25040
|
readArtifactOutput: publicProcedure.input(objectType({
|
|
24908
25041
|
changeId: stringType(),
|
|
24909
25042
|
outputPath: stringType()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openspecui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "OpenSpec UI - Visual interface for spec-driven development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"typescript": "^5.7.2",
|
|
34
34
|
"vitest": "^2.1.8",
|
|
35
35
|
"yargs": "^18.0.0",
|
|
36
|
-
"@openspecui/
|
|
37
|
-
"@openspecui/
|
|
36
|
+
"@openspecui/web": "2.0.1",
|
|
37
|
+
"@openspecui/server": "2.0.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "pnpm run build:web && pnpm run build:copy-web && tsdown",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{y as U,z as g,A as c,B as S,D as _,F as m,H as I,J as p}from"./index-
|
|
1
|
+
import{y as U,z as g,A as c,B as S,D as _,F as m,H as I,J as p}from"./index-B-vvVL83.js";const x={name:"local-uniform-bit",vertex:{header:`
|
|
2
2
|
|
|
3
3
|
struct LocalUniforms {
|
|
4
4
|
uTransformMatrix:mat3x3<f32>,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as U,M as A,O as K,P as be,Q as ne,R as O,T as S,U as qe,y as Le,V as we,W as Ye,X as Ne,Y as Xe,Z as je,_ as $e,$ as Ke,a0 as Qe,a1 as ze,a2 as se}from"./index-YEDqrGu6.js";import{R as Je,S as Ze,B as et,a as tt,b as nt,c as at,A as st,C as ot}from"./RenderTargetSystem-DHoDBu3v.js";import"./Filter-trCu1CQG.js";let $;function Me(s){const e=U.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function Se(){if($!==void 0)return $;try{const s=Me("#ff00ff"),e=Me("#ffff00"),a=U.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(s,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)$=!1;else{const o=n.data;$=o[0]===255&&o[1]===0&&o[2]===0}}catch{$=!1}return $}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Se(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e?.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,o=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||o!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),u=l.data,m=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let v=0;v<u.length&&v+3<m.length;v+=4)u[v]=m[v+2],u[v+1]=m[v+1],u[v+2]=m[v],u[v+3]=m[v+3];else u.set(m.subarray(0,u.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=U.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let u=0;u<l.length;u+=4){const m=l[u+3];if(m>0){const v=255/m;l[u]=Math.min(255,l[u]*v+.5),l[u+1]=Math.min(255,l[u+1]*v+.5),l[u+2]=Math.min(255,l[u+2]*v+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(s,e)=>{const t=s.texture,a=K.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),o=n[a],r=t.source._resourceId;if(o?.tintId===r)return o;const i=o&&"getContext"in o?o:U.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(s,e)=>{const t=K.shared.setValue(e).toHex(),a=s.patternCache||(s.patternCache={}),n=s.source._resourceId;let o=a[t];return o?.tintId===n||(d.canvas||(d.canvas=U.get().createCanvas()),d.tintMethod(s,e,d.canvas),o=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),o.tintId=n,a[t]=o),o},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const a=s;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const o=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?o.inverse():o)},tintWithMultiply:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const u=e>>16&255,m=e>>8&255,v=e&255,k=a.getImageData(0,0,c,h),T=k.data;for(let C=0;C<T.length;C+=4)T[C]=T[C]*u/255,T[C+1]=T[C+1]*m/255,T[C+2]=T[C+2]*v/255;a.putImageData(k,0,0)},_applyInverseRotation:(s,e,t,a)=>{const n=A.inv(e),o=A.uX(n),r=A.uY(n),i=A.vX(n),c=A.vY(n),h=-Math.min(0,o*t,i*a,o*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);s.transform(o,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const fe=class L{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){const a=t.elements;if(!a||!a.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let i=0;i<a.length;i++){const c=a[i];if(!c.packAsQuad)continue;const h=c,l=h.texture,u=l?d.getCanvasSource(l):null;if(!u)continue;const m=l.source.style,v=o.smoothProperty,k=m.scaleMode!=="nearest";r[v]!==k&&(r[v]=k),o.setBlendMode(t.blendMode);const T=n.globalUniforms.globalUniformData?.worldColor??4294967295,C=h.color,B=(T>>>24&255)/255,P=(C>>>24&255)/255,H=n.filter?.alphaMultiplier??1,V=B*P*H;if(V<=0)continue;r.globalAlpha=V;const J=T&16777215,b=C&16777215,F=be(ne(b,J)),W=l.frame,Q=m.addressModeU??m.addressMode,Y=m.addressModeV??m.addressMode,g=L._getPatternRepeat(Q,Y),y=l.source._resolution??l.source.resolution??1,x=h.renderable?.renderGroup?.isCachedAsTexture,G=W.x*y,N=W.y*y,w=W.width*y,E=W.height*y,_=h.bounds,I=n.renderTarget.renderTarget.isRoot,R=_.minX,z=_.minY,q=_.maxX-_.minX,D=_.maxY-_.minY,M=l.rotate,p=l.uvs,oe=Math.min(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),Ee=Math.max(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),ge=g!=="no-repeat"&&(oe<0||Ee>1),re=M&&!(!ge&&(F!==16777215||M));re?(L._tempPatternMatrix.copyFrom(h.transform),A.matrixAppendRotationInv(L._tempPatternMatrix,M,R,z,q,D),o.setContextTransform(L._tempPatternMatrix,h.roundPixels===1,void 0,x&&I)):o.setContextTransform(h.transform,h.roundPixels===1,void 0,x&&I);const Z=re?0:R,ee=re?0:z,ie=q,ce=D;if(ge){let le=u;const X=F!==16777215&&!M,j=W.width<=l.source.width&&W.height<=l.source.height;X&&j&&(le=d.getTintedCanvas({texture:l},F));const he=r.createPattern(le,g);if(!he)continue;const me=ie,ve=ce;if(me===0||ve===0)continue;const ye=1/me,Ce=1/ve,xe=(p.x1-p.x0)*ye,Te=(p.y1-p.y0)*ye,Pe=(p.x3-p.x0)*Ce,_e=(p.y3-p.y0)*Ce,Ve=p.x0-xe*Z-Pe*ee,Fe=p.y0-Te*Z-_e*ee,de=l.source.pixelWidth,pe=l.source.pixelHeight;L._tempPatternMatrix.set(xe*de,Te*pe,Pe*de,_e*pe,Ve*de,Fe*pe),d.applyPatternTransform(he,L._tempPatternMatrix),r.fillStyle=he,r.fillRect(Z,ee,ie,ce)}else{const X=F!==16777215||M?d.getTintedCanvas({texture:l},F):u,j=X!==u;r.drawImage(X,j?0:G,j?0:N,j?X.width:w,j?X.height:E,Z,ee,ie,ce)}}}};fe._tempPatternMatrix=new O;fe.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let rt=fe;class ke{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ke.extension={type:[S.CanvasPipes],name:"colorMask"};function it(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function Ie(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;it(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.moveTo(t.x+t.radius,t.y),s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?(s.moveTo(t.x+t.halfWidth,t.y),s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function ct(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ie(s,a.shape),o&&s.restore()}return!0}class Re{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a?.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof qe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=r.context?.instructions;if(!i?.length){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let l=0;l<i.length;l++){const u=i[l],m=u.action;if(m!=="fill"&&m!=="stroke")continue;const k=u.data?.path?.shapePath;if(!k?.shapePrimitives?.length)continue;const T=k.shapePrimitives;for(let C=0;C<T.length;C++){const B=T[C];if(!B?.shape)continue;const P=B.transform,H=P&&!P.isIdentity();H&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),Ie(n,B.shape),h=ct(n,B.holes)||h,c=!0,H&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Le(t))}}Re.extension={type:[S.CanvasPipes],name:"stencilMask"};const f="source-over";function lt(){const s=Se(),e=Object.create(null);return e.inherit=f,e.none=f,e.normal="source-over",e.add="lighter",e.multiply=s?"multiply":f,e.screen=s?"screen":f,e.overlay=s?"overlay":f,e.darken=s?"darken":f,e.lighten=s?"lighten":f,e["color-dodge"]=s?"color-dodge":f,e["color-burn"]=s?"color-burn":f,e["hard-light"]=s?"hard-light":f,e["soft-light"]=s?"soft-light":f,e.difference=s?"difference":f,e.exclusion=s?"exclusion":f,e.saturation=s?"saturation":f,e.color=s?"color":f,e.luminosity=s?"luminosity":f,e["linear-burn"]=s?"color-burn":f,e["linear-dodge"]=s?"color-dodge":f,e["linear-light"]=s?"hard-light":f,e["pin-light"]=s?"hard-light":f,e["vivid-light"]=s?"hard-light":f,e["hard-mix"]=f,e.negation=s?"difference":f,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=f,e.divide=f,e.min=f,e.max=f,e}const ht=new O;class Ae{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=lt(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){const o=n?O.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||O.IDENTITY;let r=ht;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const h=O.shared;h.copyFrom(r),h.prepend(i),r=h}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const o=K.shared.setValue(e);a.globalAlpha=t??o.alpha,a.fillStyle=o.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ae.extension={type:[S.CanvasSystem],name:"canvasContext"};class Be{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Be.extension={type:[S.CanvasSystem],name:"limits"};const dt="#808080",te=new O,pt=new O,ut=new O,ue=new O;function ft(s,e,t){s.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,o=t[a+1]*2,r=t[a+2]*2;s.moveTo(e[n],e[n+1]),s.lineTo(e[o],e[o+1]),s.lineTo(e[r],e[r+1]),s.closePath()}s.fill()}function gt(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function mt(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function ae(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;mt(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function vt(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ae(s,a.shape),o&&s.restore()}return!0}function yt(s,e,t,a){const n=s.fill;if(n instanceof je){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?ue.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):ue.copyFrom(n.transform);return a&&!s.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof $e){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const o=s.texture;if(o&&o!==we.WHITE){if(!o.source.resource)return dt;const r=d.getTintedPattern(o,e),i=t?ue.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):s.matrix;return d.applyPatternTransform(r,i),r}return gt(e)}class He{constructor(){this.shader=null}contextChange(e){}execute(e,t){const a=e.renderer,n=a.canvasContext,o=n.activeContext,r=t.groupTransform,i=a.globalUniforms.globalUniformData?.worldColor??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,u=a.filter?.alphaMultiplier??1,m=h*l*u;if(m<=0)return;const v=i&16777215,k=c&16777215,T=be(ne(k,v)),C=a._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,C===1),n.setBlendMode(t.groupBlendMode);const B=t.context.instructions;for(let P=0;P<B.length;P++){const H=B[P];if(H.action==="texture"){const g=H.data,y=g.image,x=y?d.getCanvasSource(y):null;if(!x)continue;const G=g.alpha*m;if(G<=0)continue;const N=ne(g.style,T);o.globalAlpha=G;let w=x;N!==16777215&&(w=d.getTintedCanvas({texture:y},N));const E=y.frame,_=y.source._resolution??y.source.resolution??1;let I=E.x*_,R=E.y*_;const z=E.width*_,q=E.height*_;w!==x&&(I=0,R=0);const D=g.transform,M=D&&!D.isIdentity(),p=y.rotate;M||p?(te.copyFrom(r),M&&te.append(D),p&&A.matrixAppendRotationInv(te,p,g.dx,g.dy,g.dw,g.dh),n.setContextTransform(te,C===1)):n.setContextTransform(r,C===1),o.drawImage(w,I,R,w===x?z:w.width,w===x?q:w.height,p?0:g.dx,p?0:g.dy,g.dw,g.dh),(M||p)&&n.setContextTransform(r,C===1);continue}const V=H.data,J=V?.path?.shapePath;if(!J?.shapePrimitives?.length)continue;const b=V.style,F=ne(b.color,T),W=b.alpha*m;if(W<=0)continue;const Q=H.action==="stroke";if(o.globalAlpha=W,Q){const g=b;o.lineWidth=g.width,o.lineCap=g.cap,o.lineJoin=g.join,o.miterLimit=g.miterLimit}const Y=J.shapePrimitives;if(!Q&&V.hole?.shapePath?.shapePrimitives?.length){const g=Y[Y.length-1];g.holes=V.hole.shapePath.shapePrimitives}for(let g=0;g<Y.length;g++){const y=Y[g];if(!y?.shape)continue;const x=y.transform,G=x&&!x.isIdentity(),N=b.texture&&b.texture!==we.WHITE,w=b.textureSpace==="global"?x:null,E=N?Ye(pt,b,y.shape,w):null,_=G?ut.copyFrom(r).append(x):r,I=yt(b,F,E,_);if(G&&(o.save(),o.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),Q){const R=b;if(R.alignment!==.5&&!R.pixelLine){const q=[],D=[],M=[];if(Ne[y.shape.type]?.build(y.shape,q)){const oe=y.shape.closePath??!0;Xe(q,R,!1,oe,D,M),o.fillStyle=I,ft(o,D,M)}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.fillStyle=I,o.beginPath(),ae(o,y.shape),vt(o,y.holes)?o.fill("evenodd"):o.fill();G&&o.restore()}}o.restore()}destroy(){this.shader=null}}He.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Ct{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=K.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=o?.x??0,u=o?.y??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,u,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Ke.test(t))&&(t=U.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class We extends Je{constructor(e){super(e),this.adaptor=new Ct,this.adaptor.init(e,this)}}We.extension={type:[S.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=U.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,h=o.width*r,l=o.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[S.CanvasSystem],name:"texture"};const xt=[...Ze,Ae,Be,De,We],Tt=[et,tt,nt,at,st,Re,ke,ot],Pt=[rt,He],Ue=[],Oe=[],Ge=[];se.handleByNamedList(S.CanvasSystem,Ue);se.handleByNamedList(S.CanvasPipes,Oe);se.handleByNamedList(S.CanvasPipesAdaptor,Ge);se.add(...xt,...Tt,...Pt);class St extends Qe{constructor(){const e={name:"canvas",type:ze.CANVAS,systems:Ue,renderPipes:Oe,renderPipeAdaptors:Ge};super(e)}}export{St as CanvasRenderer};
|
|
1
|
+
import{K as U,M as A,O as K,P as be,Q as ne,R as O,T as S,U as qe,y as Le,V as we,W as Ye,X as Ne,Y as Xe,Z as je,_ as $e,$ as Ke,a0 as Qe,a1 as ze,a2 as se}from"./index-B-vvVL83.js";import{R as Je,S as Ze,B as et,a as tt,b as nt,c as at,A as st,C as ot}from"./RenderTargetSystem-C0zk81Mh.js";import"./Filter-BpxymkGv.js";let $;function Me(s){const e=U.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function Se(){if($!==void 0)return $;try{const s=Me("#ff00ff"),e=Me("#ffff00"),a=U.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(s,0,0),a.drawImage(e,2,0);const n=a.getImageData(2,0,1,1);if(!n)$=!1;else{const o=n.data;$=o[0]===255&&o[1]===0&&o[2]===0}}catch{$=!1}return $}const d={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Se(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e?.resource;if(!t)return null;const a=e.alphaMode==="premultiplied-alpha",n=e.resourceWidth??e.pixelWidth,o=e.resourceHeight??e.pixelHeight,r=n!==e.pixelWidth||o!==e.pixelHeight;if(a){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!r)return t;const i=d._unpremultipliedCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d"),l=h.createImageData(e.pixelWidth,e.pixelHeight),u=l.data,m=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let v=0;v<u.length&&v+3<m.length;v+=4)u[v]=m[v+2],u[v+1]=m[v+1],u[v+2]=m[v],u[v+3]=m[v+3];else u.set(m.subarray(0,u.length));return h.putImageData(l,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(a){const i=U.get().createCanvas(e.pixelWidth,e.pixelHeight),c=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,c.drawImage(t,0,0);const h=c.getImageData(0,0,i.width,i.height),l=h.data;for(let u=0;u<l.length;u+=4){const m=l[u+3];if(m>0){const v=255/m;l[u]=Math.min(255,l[u]*v+.5),l[u+1]=Math.min(255,l[u+1]*v+.5),l[u+2]=Math.min(255,l[u+2]*v+.5)}}return c.putImageData(h,0,0),d._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(r){const i=d._canvasSourceCache.get(e);if(i?.resourceId===e._resourceId)return i.canvas;const c=U.get().createCanvas(e.pixelWidth,e.pixelHeight),h=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,h.drawImage(t,0,0),d._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(s,e)=>{const t=s.texture,a=K.shared.setValue(e).toHex(),n=t.tintCache||(t.tintCache={}),o=n[a],r=t.source._resourceId;if(o?.tintId===r)return o;const i=o&&"getContext"in o?o:U.get().createCanvas();return d.tintMethod(t,e,i),i.tintId=r,n[a]=i,n[a]},getTintedPattern:(s,e)=>{const t=K.shared.setValue(e).toHex(),a=s.patternCache||(s.patternCache={}),n=s.source._resourceId;let o=a[t];return o?.tintId===n||(d.canvas||(d.canvas=U.get().createCanvas()),d.tintMethod(s,e,d.canvas),o=d.canvas.getContext("2d").createPattern(d.canvas,"repeat"),o.tintId=n,a[t]=o),o},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const a=s;if(!a.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const o=new n([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(t?o.inverse():o)},tintWithMultiply:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="multiply";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.globalCompositeOperation="destination-atop",a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithOverlay:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy",a.fillStyle=K.shared.setValue(e).toHex(),a.fillRect(0,0,c,h),a.globalCompositeOperation="destination-atop";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore()},tintWithPerPixel:(s,e,t)=>{const a=t.getContext("2d"),n=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,r=s.rotate;n.x*=o,n.y*=o,n.width*=o,n.height*=o;const i=A.isVertical(r),c=i?n.height:n.width,h=i?n.width:n.height;t.width=Math.ceil(c),t.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const l=d.getCanvasSource(s);if(!l){a.restore();return}r&&d._applyInverseRotation(a,r,n.width,n.height),a.drawImage(l,n.x,n.y,n.width,n.height,0,0,n.width,n.height),a.restore();const u=e>>16&255,m=e>>8&255,v=e&255,k=a.getImageData(0,0,c,h),T=k.data;for(let C=0;C<T.length;C+=4)T[C]=T[C]*u/255,T[C+1]=T[C+1]*m/255,T[C+2]=T[C+2]*v/255;a.putImageData(k,0,0)},_applyInverseRotation:(s,e,t,a)=>{const n=A.inv(e),o=A.uX(n),r=A.uY(n),i=A.vX(n),c=A.vY(n),h=-Math.min(0,o*t,i*a,o*t+i*a),l=-Math.min(0,r*t,c*a,r*t+c*a);s.transform(o,r,i,c,h,l)}};d.tintMethod=d.canUseMultiply?d.tintWithMultiply:d.tintWithPerPixel;const fe=class L{static _getPatternRepeat(e,t){const a=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return a&&n?"repeat":a?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,a){}execute(e,t){const a=t.elements;if(!a||!a.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let i=0;i<a.length;i++){const c=a[i];if(!c.packAsQuad)continue;const h=c,l=h.texture,u=l?d.getCanvasSource(l):null;if(!u)continue;const m=l.source.style,v=o.smoothProperty,k=m.scaleMode!=="nearest";r[v]!==k&&(r[v]=k),o.setBlendMode(t.blendMode);const T=n.globalUniforms.globalUniformData?.worldColor??4294967295,C=h.color,B=(T>>>24&255)/255,P=(C>>>24&255)/255,H=n.filter?.alphaMultiplier??1,V=B*P*H;if(V<=0)continue;r.globalAlpha=V;const J=T&16777215,b=C&16777215,F=be(ne(b,J)),W=l.frame,Q=m.addressModeU??m.addressMode,Y=m.addressModeV??m.addressMode,g=L._getPatternRepeat(Q,Y),y=l.source._resolution??l.source.resolution??1,x=h.renderable?.renderGroup?.isCachedAsTexture,G=W.x*y,N=W.y*y,w=W.width*y,E=W.height*y,_=h.bounds,I=n.renderTarget.renderTarget.isRoot,R=_.minX,z=_.minY,q=_.maxX-_.minX,D=_.maxY-_.minY,M=l.rotate,p=l.uvs,oe=Math.min(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),Ee=Math.max(p.x0,p.x1,p.x2,p.x3,p.y0,p.y1,p.y2,p.y3),ge=g!=="no-repeat"&&(oe<0||Ee>1),re=M&&!(!ge&&(F!==16777215||M));re?(L._tempPatternMatrix.copyFrom(h.transform),A.matrixAppendRotationInv(L._tempPatternMatrix,M,R,z,q,D),o.setContextTransform(L._tempPatternMatrix,h.roundPixels===1,void 0,x&&I)):o.setContextTransform(h.transform,h.roundPixels===1,void 0,x&&I);const Z=re?0:R,ee=re?0:z,ie=q,ce=D;if(ge){let le=u;const X=F!==16777215&&!M,j=W.width<=l.source.width&&W.height<=l.source.height;X&&j&&(le=d.getTintedCanvas({texture:l},F));const he=r.createPattern(le,g);if(!he)continue;const me=ie,ve=ce;if(me===0||ve===0)continue;const ye=1/me,Ce=1/ve,xe=(p.x1-p.x0)*ye,Te=(p.y1-p.y0)*ye,Pe=(p.x3-p.x0)*Ce,_e=(p.y3-p.y0)*Ce,Ve=p.x0-xe*Z-Pe*ee,Fe=p.y0-Te*Z-_e*ee,de=l.source.pixelWidth,pe=l.source.pixelHeight;L._tempPatternMatrix.set(xe*de,Te*pe,Pe*de,_e*pe,Ve*de,Fe*pe),d.applyPatternTransform(he,L._tempPatternMatrix),r.fillStyle=he,r.fillRect(Z,ee,ie,ce)}else{const X=F!==16777215||M?d.getTintedCanvas({texture:l},F):u,j=X!==u;r.drawImage(X,j?0:G,j?0:N,j?X.width:w,j?X.height:E,Z,ee,ie,ce)}}}};fe._tempPatternMatrix=new O;fe.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let rt=fe;class ke{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,a){this._renderer.renderPipes.batch.break(a);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,a.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ke.extension={type:[S.CanvasPipes],name:"colorMask"};function it(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function Ie(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;it(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.moveTo(t.x+t.radius,t.y),s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?(s.moveTo(t.x+t.halfWidth,t.y),s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.moveTo(1,0),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function ct(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ie(s,a.shape),o&&s.restore()}return!0}class Re{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,a){this._renderer.renderPipes.batch.break(a),a.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,a=t.canvasContext,n=a?.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof qe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=r.context?.instructions;if(!i?.length){this._canvasMaskStack.push(!1);return}n.save(),a.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,h=!1;for(let l=0;l<i.length;l++){const u=i[l],m=u.action;if(m!=="fill"&&m!=="stroke")continue;const k=u.data?.path?.shapePath;if(!k?.shapePrimitives?.length)continue;const T=k.shapePrimitives;for(let C=0;C<T.length;C++){const B=T[C];if(!B?.shape)continue;const P=B.transform,H=P&&!P.isIdentity();H&&(n.save(),n.transform(P.a,P.b,P.c,P.d,P.tx,P.ty)),Ie(n,B.shape),h=ct(n,B.holes)||h,c=!0,H&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}h?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Le(t))}}Re.extension={type:[S.CanvasPipes],name:"stencilMask"};const f="source-over";function lt(){const s=Se(),e=Object.create(null);return e.inherit=f,e.none=f,e.normal="source-over",e.add="lighter",e.multiply=s?"multiply":f,e.screen=s?"screen":f,e.overlay=s?"overlay":f,e.darken=s?"darken":f,e.lighten=s?"lighten":f,e["color-dodge"]=s?"color-dodge":f,e["color-burn"]=s?"color-burn":f,e["hard-light"]=s?"hard-light":f,e["soft-light"]=s?"soft-light":f,e.difference=s?"difference":f,e.exclusion=s?"exclusion":f,e.saturation=s?"saturation":f,e.color=s?"color":f,e.luminosity=s?"luminosity":f,e["linear-burn"]=s?"color-burn":f,e["linear-dodge"]=s?"color-dodge":f,e["linear-light"]=s?"hard-light":f,e["pin-light"]=s?"hard-light":f,e["vivid-light"]=s?"hard-light":f,e["hard-mix"]=f,e.negation=s?"difference":f,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=f,e.divide=f,e.min=f,e.max=f,e}const ht=new O;class Ae{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=lt(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,a,n){const o=n?O.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||O.IDENTITY;let r=ht;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(a=a||c,i){const h=O.shared;h.copyFrom(r),h.prepend(i),r=h}t?this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*a,r.b*a,r.c*a,r.d*a,r.tx*c,r.ty*c)}clear(e,t){const a=this.activeContext,n=this._renderer;if(a.clearRect(0,0,n.width,n.height),e){const o=K.shared.setValue(e);a.globalAlpha=t??o.alpha,a.fillStyle=o.toHex(),a.fillRect(0,0,n.width,n.height),a.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Ae.extension={type:[S.CanvasSystem],name:"canvasContext"};class Be{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Be.extension={type:[S.CanvasSystem],name:"limits"};const dt="#808080",te=new O,pt=new O,ut=new O,ue=new O;function ft(s,e,t){s.beginPath();for(let a=0;a<t.length;a+=3){const n=t[a]*2,o=t[a+1]*2,r=t[a+2]*2;s.moveTo(e[n],e[n+1]),s.lineTo(e[o],e[o+1]),s.lineTo(e[r],e[r+1]),s.closePath()}s.fill()}function gt(s){return`#${(s&16777215).toString(16).padStart(6,"0")}`}function mt(s,e,t,a,n,o){o=Math.max(0,Math.min(o,Math.min(a,n)/2)),s.moveTo(e+o,t),s.lineTo(e+a-o,t),s.quadraticCurveTo(e+a,t,e+a,t+o),s.lineTo(e+a,t+n-o),s.quadraticCurveTo(e+a,t+n,e+a-o,t+n),s.lineTo(e+o,t+n),s.quadraticCurveTo(e,t+n,e,t+n-o),s.lineTo(e,t+o),s.quadraticCurveTo(e,t,e+o,t)}function ae(s,e){switch(e.type){case"rectangle":{const t=e;s.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;mt(s,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;s.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;s.ellipse?s.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(s.save(),s.translate(t.x,t.y),s.scale(t.halfWidth,t.halfHeight),s.arc(0,0,1,0,Math.PI*2),s.restore());break}case"triangle":{const t=e;s.moveTo(t.x,t.y),s.lineTo(t.x2,t.y2),s.lineTo(t.x3,t.y3),s.closePath();break}default:{const t=e,a=t.points;if(!a?.length)break;s.moveTo(a[0],a[1]);for(let n=2;n<a.length;n+=2)s.lineTo(a[n],a[n+1]);t.closePath&&s.closePath();break}}}function vt(s,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const a=e[t];if(!a?.shape)continue;const n=a.transform,o=n&&!n.isIdentity();o&&(s.save(),s.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ae(s,a.shape),o&&s.restore()}return!0}function yt(s,e,t,a){const n=s.fill;if(n instanceof je){n.buildGradient();const r=n.texture;if(r){const i=d.getTintedPattern(r,e),c=t?ue.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):ue.copyFrom(n.transform);return a&&!s.textureSpace&&c.append(a),d.applyPatternTransform(i,c),i}}if(n instanceof $e){const r=d.getTintedPattern(n.texture,e);return d.applyPatternTransform(r,n.transform),r}const o=s.texture;if(o&&o!==we.WHITE){if(!o.source.resource)return dt;const r=d.getTintedPattern(o,e),i=t?ue.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):s.matrix;return d.applyPatternTransform(r,i),r}return gt(e)}class He{constructor(){this.shader=null}contextChange(e){}execute(e,t){const a=e.renderer,n=a.canvasContext,o=n.activeContext,r=t.groupTransform,i=a.globalUniforms.globalUniformData?.worldColor??4294967295,c=t.groupColorAlpha,h=(i>>>24&255)/255,l=(c>>>24&255)/255,u=a.filter?.alphaMultiplier??1,m=h*l*u;if(m<=0)return;const v=i&16777215,k=c&16777215,T=be(ne(k,v)),C=a._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,C===1),n.setBlendMode(t.groupBlendMode);const B=t.context.instructions;for(let P=0;P<B.length;P++){const H=B[P];if(H.action==="texture"){const g=H.data,y=g.image,x=y?d.getCanvasSource(y):null;if(!x)continue;const G=g.alpha*m;if(G<=0)continue;const N=ne(g.style,T);o.globalAlpha=G;let w=x;N!==16777215&&(w=d.getTintedCanvas({texture:y},N));const E=y.frame,_=y.source._resolution??y.source.resolution??1;let I=E.x*_,R=E.y*_;const z=E.width*_,q=E.height*_;w!==x&&(I=0,R=0);const D=g.transform,M=D&&!D.isIdentity(),p=y.rotate;M||p?(te.copyFrom(r),M&&te.append(D),p&&A.matrixAppendRotationInv(te,p,g.dx,g.dy,g.dw,g.dh),n.setContextTransform(te,C===1)):n.setContextTransform(r,C===1),o.drawImage(w,I,R,w===x?z:w.width,w===x?q:w.height,p?0:g.dx,p?0:g.dy,g.dw,g.dh),(M||p)&&n.setContextTransform(r,C===1);continue}const V=H.data,J=V?.path?.shapePath;if(!J?.shapePrimitives?.length)continue;const b=V.style,F=ne(b.color,T),W=b.alpha*m;if(W<=0)continue;const Q=H.action==="stroke";if(o.globalAlpha=W,Q){const g=b;o.lineWidth=g.width,o.lineCap=g.cap,o.lineJoin=g.join,o.miterLimit=g.miterLimit}const Y=J.shapePrimitives;if(!Q&&V.hole?.shapePath?.shapePrimitives?.length){const g=Y[Y.length-1];g.holes=V.hole.shapePath.shapePrimitives}for(let g=0;g<Y.length;g++){const y=Y[g];if(!y?.shape)continue;const x=y.transform,G=x&&!x.isIdentity(),N=b.texture&&b.texture!==we.WHITE,w=b.textureSpace==="global"?x:null,E=N?Ye(pt,b,y.shape,w):null,_=G?ut.copyFrom(r).append(x):r,I=yt(b,F,E,_);if(G&&(o.save(),o.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),Q){const R=b;if(R.alignment!==.5&&!R.pixelLine){const q=[],D=[],M=[];if(Ne[y.shape.type]?.build(y.shape,q)){const oe=y.shape.closePath??!0;Xe(q,R,!1,oe,D,M),o.fillStyle=I,ft(o,D,M)}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.strokeStyle=I,o.beginPath(),ae(o,y.shape),o.stroke()}else o.fillStyle=I,o.beginPath(),ae(o,y.shape),vt(o,y.holes)?o.fill("evenodd"):o.fill();G&&o.restore()}}o.restore()}destroy(){this.shader=null}}He.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Ct{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:a,context:n}=this._ensureCanvas(t);return{canvas:a,context:n,width:a.width,height:a.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:a}=this._ensureCanvas(t);a.width=e.pixelWidth,a.height=e.pixelHeight}startRenderPass(e,t,a,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,a,n)}clear(e,t,a,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),a){const c=K.shared.setValue(a);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,a,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:h}=this._ensureCanvas(c),l=o?.x??0,u=o?.y??0;return h.drawImage(i,a.x,a.y,n.width,n.height,l,u,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Ke.test(t))&&(t=U.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const a=t.getContext("2d");return{canvas:t,context:a}}}class We extends Je{constructor(e){super(e),this.adaptor=new Ct,this.adaptor.init(e,this)}}We.extension={type:[S.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=U.get().createCanvas(),a=t.getContext("2d"),n=d.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,h=o.width*r,l=o.height*r;return t.width=Math.ceil(h),t.height=Math.ceil(l),a.drawImage(n,i,c,h,l,0,0,h,l),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[S.CanvasSystem],name:"texture"};const xt=[...Ze,Ae,Be,De,We],Tt=[et,tt,nt,at,st,Re,ke,ot],Pt=[rt,He],Ue=[],Oe=[],Ge=[];se.handleByNamedList(S.CanvasSystem,Ue);se.handleByNamedList(S.CanvasPipes,Oe);se.handleByNamedList(S.CanvasPipesAdaptor,Ge);se.add(...xt,...Tt,...Pt);class St extends Qe{constructor(){const e={name:"canvas",type:ze.CANVAS,systems:Ue,renderPipes:Oe,renderPipeAdaptors:Ge};super(e)}}export{St as CanvasRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as n,r as u,G as o,u as f}from"./index-
|
|
1
|
+
import{S as n,r as u,G as o,u as f}from"./index-B-vvVL83.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=u.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=o.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{al as Ve,af as oe,R as m,G as Ne,u as je,r as $e,am as le,T as l,a2 as W,an as w,ao as qe,ap as z,aq as T,a1 as V,ar as de,as as Ke,V as f,A as g,ad as D,at as ue,y as ce,au as ee,av as he,aw as pe,ax as fe,ay as me,a7 as P,az as Ye,O as E,K as N,ae as y,aA as G,aB as Je,a5 as Xe,aC as Qe,ab as Ze,a3 as te,aD as re,aE as p,J as et,$ as O,aF as tt,aG as rt,aH as st,aI as nt}from"./index-
|
|
1
|
+
import{al as Ve,af as oe,R as m,G as Ne,u as je,r as $e,am as le,T as l,a2 as W,an as w,ao as qe,ap as z,aq as T,a1 as V,ar as de,as as Ke,V as f,A as g,ad as D,at as ue,y as ce,au as ee,av as he,aw as pe,ax as fe,ay as me,a7 as P,az as Ye,O as E,K as N,ae as y,aA as G,aB as Je,a5 as Xe,aC as Qe,ab as Ze,a3 as te,aD as re,aE as p,J as et,$ as O,aF as tt,aG as rt,aH as st,aI as nt}from"./index-B-vvVL83.js";import{F as at}from"./Filter-BpxymkGv.js";var it=`in vec2 vMaskCoord;
|
|
2
2
|
in vec2 vTextureCoord;
|
|
3
3
|
|
|
4
4
|
uniform sampler2D uTexture;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{K as R,r as F,T as d,a9 as P,F as B,y as b,z,u as Be,S as O,V as S,aJ as ye,ae as q,aK as Ne,A as g,aA as V,$ as y,ad as N,af as M,R as Z,aL as J,aM as Ce,aN as De,aO as Q,aP as Ie,a0 as Ge,a1 as Ue,a2 as A}from"./index-YEDqrGu6.js";import{e as Fe,G as Pe,c as Oe,b as Me,U as Le,B as ee,d as C,f as te,g as we}from"./BufferResource-BFEntdoN.js";import{R as He,S as Ve,d as Xe}from"./RenderTargetSystem-DHoDBu3v.js";import"./Filter-trCu1CQG.js";function ke(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,a=this._didUploadHash[n.uid];s.shader.bind(n,a),a||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let a=0;a<r.textures.count;a++)n.texture.bind(s[a],a);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class We{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const a=this._boundBufferBases[s];if(a&&a._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:a}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,a.bindBufferRange(a.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,a=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,a)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,a)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new We(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(b("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,a=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:a,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&b("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&b("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,a=this.extensions;n.uint32Indices=s||!!a.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!a.vertexArrayObject,n.srgbTextures=s||!!a.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||b("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let je=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function Ke(t){return X[t]??X.float32}const $e={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ye{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ae{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,a,i,o)=>{n.drawArraysInstancedANGLE(s,a,i,o)},e.drawElementsInstanced=(s,a,i,o,c)=>{n.drawElementsInstancedANGLE(s,a,i,o,c)},e.vertexAttribDivisor=(s,a)=>n.vertexAttribDivisorANGLE(s,a)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const a in s)if(!n[a])throw new Error(`shader and geometry incompatible, geometry missing the "${a}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,a=["g",e.uid];for(const i in n)s[i]&&a.push(i,s[i].location);return a.join("-")}getVao(e,r){return e._gpuData[this._renderer.uid]?.vaoCache[r._key]||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,a=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const i=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new Ye,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[i];if(u)return c[r._key]=u,u;Fe(e,r._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<_.length;f++){const h=_[f];a.bind(h)}return this.activateVao(e,r),c[r._key]=u,c[i]=u,s.bindVertexArray(null),u}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const a in s)this._activeVao!==s[a]&&this.resetState(),this.gl.deleteVertexArray(s[a])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){const n=this._renderer.gl,s=this._renderer.buffer,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let i=null;for(const o in a){const c=a[o],u=c.buffer,_=s.getGlBuffer(u),f=r._attributeData[o];if(f){i!==_&&(s.bind(u),i=_);const h=f.location;n.enableVertexAttribArray(h);const m=z(c.format),p=Ke(c.format);if(f.format?.substring(1,4)==="int"?n.vertexAttribIPointer(h,m.size,p,c.stride,c.offset):n.vertexAttribPointer(h,m.size,p,m.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const E=c.divisor??1;n.vertexAttribDivisor(h,E)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:a}=this._renderer,i=this._activeGeometry,o=$e[e||i.topology];if(s??(s=i.instanceCount),i.indexBuffer){const c=i.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;s!==1?a.drawElementsInstanced(o,r||i.indexBuffer.data.length,u,(n||0)*c,s):a.drawElements(o,r||i.indexBuffer.data.length,u,(n||0)*c)}else s!==1?a.drawArraysInstanced(o,n||0,r||i.getSize(),s):a.drawArrays(o,n||0,r||i.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ae.extension={type:[d.WebGLSystem],name:"geometry"};const ze=new ye({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(b("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new Be({vertex:`
|
|
1
|
+
import{K as R,r as F,T as d,a9 as P,F as B,y as b,z,u as Be,S as O,V as S,aJ as ye,ae as q,aK as Ne,A as g,aA as V,$ as y,ad as N,af as M,R as Z,aL as J,aM as Ce,aN as De,aO as Q,aP as Ie,a0 as Ge,a1 as Ue,a2 as A}from"./index-B-vvVL83.js";import{e as Fe,G as Pe,c as Oe,b as Me,U as Le,B as ee,d as C,f as te,g as we}from"./BufferResource-Cipj3hQ5.js";import{R as He,S as Ve,d as Xe}from"./RenderTargetSystem-C0zk81Mh.js";import"./Filter-BpxymkGv.js";function ke(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,a=this._didUploadHash[n.uid];s.shader.bind(n,a),a||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let a=0;a<r.textures.count;a++)n.texture.bind(s[a],a);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class We{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const a=this._boundBufferBases[s];if(a&&a._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:a}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,a.bindBufferRange(a.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,a=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,a)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,a)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new We(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(b("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,a=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:a,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&b("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&b("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,a=this.extensions;n.uint32Indices=s||!!a.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!a.vertexArrayObject,n.srgbTextures=s||!!a.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||b("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let je=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const X={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function Ke(t){return X[t]??X.float32}const $e={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ye{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ae{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,a,i,o)=>{n.drawArraysInstancedANGLE(s,a,i,o)},e.drawElementsInstanced=(s,a,i,o,c)=>{n.drawElementsInstancedANGLE(s,a,i,o,c)},e.vertexAttribDivisor=(s,a)=>n.vertexAttribDivisorANGLE(s,a)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const a in s)if(!n[a])throw new Error(`shader and geometry incompatible, geometry missing the "${a}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,a=["g",e.uid];for(const i in n)s[i]&&a.push(i,s[i].location);return a.join("-")}getVao(e,r){return e._gpuData[this._renderer.uid]?.vaoCache[r._key]||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,a=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const i=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new Ye,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[i];if(u)return c[r._key]=u,u;Fe(e,r._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let f=0;f<_.length;f++){const h=_[f];a.bind(h)}return this.activateVao(e,r),c[r._key]=u,c[i]=u,s.bindVertexArray(null),u}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const a in s)this._activeVao!==s[a]&&this.resetState(),this.gl.deleteVertexArray(s[a])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){const n=this._renderer.gl,s=this._renderer.buffer,a=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let i=null;for(const o in a){const c=a[o],u=c.buffer,_=s.getGlBuffer(u),f=r._attributeData[o];if(f){i!==_&&(s.bind(u),i=_);const h=f.location;n.enableVertexAttribArray(h);const m=z(c.format),p=Ke(c.format);if(f.format?.substring(1,4)==="int"?n.vertexAttribIPointer(h,m.size,p,c.stride,c.offset):n.vertexAttribPointer(h,m.size,p,m.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const E=c.divisor??1;n.vertexAttribDivisor(h,E)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:a}=this._renderer,i=this._activeGeometry,o=$e[e||i.topology];if(s??(s=i.instanceCount),i.indexBuffer){const c=i.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;s!==1?a.drawElementsInstanced(o,r||i.indexBuffer.data.length,u,(n||0)*c,s):a.drawElements(o,r||i.indexBuffer.data.length,u,(n||0)*c)}else s!==1?a.drawArraysInstanced(o,n||0,r||i.getSize(),s):a.drawArrays(o,n||0,r||i.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ae.extension={type:[d.WebGLSystem],name:"geometry"};const ze=new ye({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(b("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new Be({vertex:`
|
|
2
2
|
attribute vec2 aPosition;
|
|
3
3
|
out vec2 vUv;
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as L,a8 as A,T as l,a9 as D,J as ce,aa as de,K as B,A as C,F as T,D as he,ab as k,ac as w,y as v,ad as y,$ as pe,ae as le,af as z,ag as M,R as F,ah as O,ai as fe,aj as ge,ak as I,S as W,V as R,a0 as me,a1 as _e,a2 as S}from"./index-YEDqrGu6.js";import{c as be,u as ye,U as xe,B as Ge,G as Pe,e as Be,l as Se,a as Te,t as Ce}from"./BufferResource-BFEntdoN.js";import{R as ve,S as Ue,d as we}from"./RenderTargetSystem-DHoDBu3v.js";import"./Filter-trCu1CQG.js";const G=L.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const a=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,a,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=A(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],a=this._renderer;for(const g in i){const h=e.resources[g]??e.resources[i[g]];let p;if(h._resourceType==="uniformGroup"){const d=h;a.ubo.updateUniformGroup(d);const f=d.buffer;p={buffer:a.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:a.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:a.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=a.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=a.texture.getTextureView(d)}n.push({binding:i[g],resource:p})}const u=a.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:a,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,a||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const a in r)this._setVertexBuffer(a,r[a]);for(const a in i)this.setBindGroup(a,i[a],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class ${constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}$.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(o){const e=o.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(o,e){const{size:t,align:r}=P[o.data.type],s=(r-t)/4,i=o.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
1
|
+
import{r as L,a8 as A,T as l,a9 as D,J as ce,aa as de,K as B,A as C,F as T,D as he,ab as k,ac as w,y as v,ad as y,$ as pe,ae as le,af as z,ag as M,R as F,ah as O,ai as fe,aj as ge,ak as I,S as W,V as R,a0 as me,a1 as _e,a2 as S}from"./index-B-vvVL83.js";import{c as be,u as ye,U as xe,B as Ge,G as Pe,e as Be,l as Se,a as Te,t as Ce}from"./BufferResource-Cipj3hQ5.js";import{R as ve,S as Ue,d as we}from"./RenderTargetSystem-C0zk81Mh.js";import"./Filter-BpxymkGv.js";const G=L.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const a=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,a,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=A(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],a=this._renderer;for(const g in i){const h=e.resources[g]??e.resources[i[g]];let p;if(h._resourceType==="uniformGroup"){const d=h;a.ubo.updateUniformGroup(d);const f=d.buffer;p={buffer:a.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:a.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:a.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=a.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=a.texture.getTextureView(d)}n.push({binding:i[g],resource:p})}const u=a.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:a,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,a||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const a in r)this._setVertexBuffer(a,r[a]);for(const a in i)this.setBindGroup(a,i[a],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class ${constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}$.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(o){const e=o.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(o,e){const{size:t,align:r}=P[o.data.type],s=(r-t)/4,i=o.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
2
2
|
v = uv.${o.data.name};
|
|
3
3
|
${e!==0?`offset += ${e};`:""}
|
|
4
4
|
|